Rename gtkmm/ to gui/
authorNikita Kitaev <nikitakit@gmail.com>
Fri, 16 Apr 2010 00:01:49 +0000 (17:01 -0700)
committerNikita Kitaev <nikitakit@gmail.com>
Fri, 16 Apr 2010 00:01:49 +0000 (17:01 -0700)
530 files changed:
synfig-studio/configure.ac
synfig-studio/src/Makefile.am
synfig-studio/src/gtkmm/Makefile.am [deleted file]
synfig-studio/src/gtkmm/about.cpp [deleted file]
synfig-studio/src/gtkmm/about.h [deleted file]
synfig-studio/src/gtkmm/adjust_window.cpp [deleted file]
synfig-studio/src/gtkmm/adjust_window.h [deleted file]
synfig-studio/src/gtkmm/app.cpp [deleted file]
synfig-studio/src/gtkmm/app.h [deleted file]
synfig-studio/src/gtkmm/asyncrenderer.cpp [deleted file]
synfig-studio/src/gtkmm/asyncrenderer.h [deleted file]
synfig-studio/src/gtkmm/audiocontainer.cpp [deleted file]
synfig-studio/src/gtkmm/audiocontainer.h [deleted file]
synfig-studio/src/gtkmm/autorecover.cpp [deleted file]
synfig-studio/src/gtkmm/autorecover.h [deleted file]
synfig-studio/src/gtkmm/canvasoptions.cpp [deleted file]
synfig-studio/src/gtkmm/canvasoptions.h [deleted file]
synfig-studio/src/gtkmm/canvasproperties.cpp [deleted file]
synfig-studio/src/gtkmm/canvasproperties.h [deleted file]
synfig-studio/src/gtkmm/canvastreestore.cpp [deleted file]
synfig-studio/src/gtkmm/canvastreestore.h [deleted file]
synfig-studio/src/gtkmm/canvasview.cpp [deleted file]
synfig-studio/src/gtkmm/canvasview.h [deleted file]
synfig-studio/src/gtkmm/cellrenderer_gradient.cpp [deleted file]
synfig-studio/src/gtkmm/cellrenderer_gradient.h [deleted file]
synfig-studio/src/gtkmm/cellrenderer_time.cpp [deleted file]
synfig-studio/src/gtkmm/cellrenderer_time.h [deleted file]
synfig-studio/src/gtkmm/cellrenderer_timetrack.cpp [deleted file]
synfig-studio/src/gtkmm/cellrenderer_timetrack.h [deleted file]
synfig-studio/src/gtkmm/cellrenderer_value.cpp [deleted file]
synfig-studio/src/gtkmm/cellrenderer_value.h [deleted file]
synfig-studio/src/gtkmm/childrentree.cpp [deleted file]
synfig-studio/src/gtkmm/childrentree.h [deleted file]
synfig-studio/src/gtkmm/childrentreestore.cpp [deleted file]
synfig-studio/src/gtkmm/childrentreestore.h [deleted file]
synfig-studio/src/gtkmm/compview.cpp [deleted file]
synfig-studio/src/gtkmm/compview.h [deleted file]
synfig-studio/src/gtkmm/devicetracker.cpp [deleted file]
synfig-studio/src/gtkmm/devicetracker.h [deleted file]
synfig-studio/src/gtkmm/dialog_color.cpp [deleted file]
synfig-studio/src/gtkmm/dialog_color.h [deleted file]
synfig-studio/src/gtkmm/dialog_gradient.cpp [deleted file]
synfig-studio/src/gtkmm/dialog_gradient.h [deleted file]
synfig-studio/src/gtkmm/dialog_keyframe.cpp [deleted file]
synfig-studio/src/gtkmm/dialog_keyframe.h [deleted file]
synfig-studio/src/gtkmm/dialog_preview.cpp [deleted file]
synfig-studio/src/gtkmm/dialog_preview.h [deleted file]
synfig-studio/src/gtkmm/dialog_setup.cpp [deleted file]
synfig-studio/src/gtkmm/dialog_setup.h [deleted file]
synfig-studio/src/gtkmm/dialog_soundselect.cpp [deleted file]
synfig-studio/src/gtkmm/dialog_soundselect.h [deleted file]
synfig-studio/src/gtkmm/dialog_targetparam.cpp [deleted file]
synfig-studio/src/gtkmm/dialog_targetparam.h [deleted file]
synfig-studio/src/gtkmm/dialog_tooloptions.cpp [deleted file]
synfig-studio/src/gtkmm/dialog_tooloptions.h [deleted file]
synfig-studio/src/gtkmm/dialog_waypoint.cpp [deleted file]
synfig-studio/src/gtkmm/dialog_waypoint.h [deleted file]
synfig-studio/src/gtkmm/dialogsettings.cpp [deleted file]
synfig-studio/src/gtkmm/dialogsettings.h [deleted file]
synfig-studio/src/gtkmm/dock_canvases.cpp [deleted file]
synfig-studio/src/gtkmm/dock_canvases.h [deleted file]
synfig-studio/src/gtkmm/dock_canvasspecific.cpp [deleted file]
synfig-studio/src/gtkmm/dock_canvasspecific.h [deleted file]
synfig-studio/src/gtkmm/dock_children.cpp [deleted file]
synfig-studio/src/gtkmm/dock_children.h [deleted file]
synfig-studio/src/gtkmm/dock_curves.cpp [deleted file]
synfig-studio/src/gtkmm/dock_curves.h [deleted file]
synfig-studio/src/gtkmm/dock_history.cpp [deleted file]
synfig-studio/src/gtkmm/dock_history.h [deleted file]
synfig-studio/src/gtkmm/dock_info.cpp [deleted file]
synfig-studio/src/gtkmm/dock_info.h [deleted file]
synfig-studio/src/gtkmm/dock_keyframes.cpp [deleted file]
synfig-studio/src/gtkmm/dock_keyframes.h [deleted file]
synfig-studio/src/gtkmm/dock_layergroups.cpp [deleted file]
synfig-studio/src/gtkmm/dock_layergroups.h [deleted file]
synfig-studio/src/gtkmm/dock_layers.cpp [deleted file]
synfig-studio/src/gtkmm/dock_layers.h [deleted file]
synfig-studio/src/gtkmm/dock_metadata.cpp [deleted file]
synfig-studio/src/gtkmm/dock_metadata.h [deleted file]
synfig-studio/src/gtkmm/dock_navigator.cpp [deleted file]
synfig-studio/src/gtkmm/dock_navigator.h [deleted file]
synfig-studio/src/gtkmm/dock_params.cpp [deleted file]
synfig-studio/src/gtkmm/dock_params.h [deleted file]
synfig-studio/src/gtkmm/dock_timetrack.cpp [deleted file]
synfig-studio/src/gtkmm/dock_timetrack.h [deleted file]
synfig-studio/src/gtkmm/dockable.cpp [deleted file]
synfig-studio/src/gtkmm/dockable.h [deleted file]
synfig-studio/src/gtkmm/dockbook.cpp [deleted file]
synfig-studio/src/gtkmm/dockbook.h [deleted file]
synfig-studio/src/gtkmm/dockdialog.cpp [deleted file]
synfig-studio/src/gtkmm/dockdialog.h [deleted file]
synfig-studio/src/gtkmm/dockmanager.cpp [deleted file]
synfig-studio/src/gtkmm/dockmanager.h [deleted file]
synfig-studio/src/gtkmm/duck.cpp [deleted file]
synfig-studio/src/gtkmm/duck.h [deleted file]
synfig-studio/src/gtkmm/duckmatic.cpp [deleted file]
synfig-studio/src/gtkmm/duckmatic.h [deleted file]
synfig-studio/src/gtkmm/ducktransform_rotate.h [deleted file]
synfig-studio/src/gtkmm/ducktransform_scale.h [deleted file]
synfig-studio/src/gtkmm/ducktransform_translate.h [deleted file]
synfig-studio/src/gtkmm/event_layerclick.h [deleted file]
synfig-studio/src/gtkmm/event_mouse.h [deleted file]
synfig-studio/src/gtkmm/eventkey.h [deleted file]
synfig-studio/src/gtkmm/framedial.cpp [deleted file]
synfig-studio/src/gtkmm/framedial.h [deleted file]
synfig-studio/src/gtkmm/general.h [deleted file]
synfig-studio/src/gtkmm/groupactionmanager.cpp [deleted file]
synfig-studio/src/gtkmm/groupactionmanager.h [deleted file]
synfig-studio/src/gtkmm/historytreestore.cpp [deleted file]
synfig-studio/src/gtkmm/historytreestore.h [deleted file]
synfig-studio/src/gtkmm/iconcontroller.cpp [deleted file]
synfig-studio/src/gtkmm/iconcontroller.h [deleted file]
synfig-studio/src/gtkmm/instance.cpp [deleted file]
synfig-studio/src/gtkmm/instance.h [deleted file]
synfig-studio/src/gtkmm/ipc.cpp [deleted file]
synfig-studio/src/gtkmm/ipc.h [deleted file]
synfig-studio/src/gtkmm/keyframeactionmanager.cpp [deleted file]
synfig-studio/src/gtkmm/keyframeactionmanager.h [deleted file]
synfig-studio/src/gtkmm/keyframedial.cpp [deleted file]
synfig-studio/src/gtkmm/keyframedial.h [deleted file]
synfig-studio/src/gtkmm/keyframetree.cpp [deleted file]
synfig-studio/src/gtkmm/keyframetree.h [deleted file]
synfig-studio/src/gtkmm/keyframetreestore.cpp [deleted file]
synfig-studio/src/gtkmm/keyframetreestore.h [deleted file]
synfig-studio/src/gtkmm/keymapsettings.cpp [deleted file]
synfig-studio/src/gtkmm/keymapsettings.h [deleted file]
synfig-studio/src/gtkmm/layeractionmanager.cpp [deleted file]
synfig-studio/src/gtkmm/layeractionmanager.h [deleted file]
synfig-studio/src/gtkmm/layergrouptree.cpp [deleted file]
synfig-studio/src/gtkmm/layergrouptree.h [deleted file]
synfig-studio/src/gtkmm/layergrouptreestore.cpp [deleted file]
synfig-studio/src/gtkmm/layergrouptreestore.h [deleted file]
synfig-studio/src/gtkmm/layerparamtreestore.cpp [deleted file]
synfig-studio/src/gtkmm/layerparamtreestore.h [deleted file]
synfig-studio/src/gtkmm/layertree.cpp [deleted file]
synfig-studio/src/gtkmm/layertree.h [deleted file]
synfig-studio/src/gtkmm/layertreestore.cpp [deleted file]
synfig-studio/src/gtkmm/layertreestore.h [deleted file]
synfig-studio/src/gtkmm/main.cpp [deleted file]
synfig-studio/src/gtkmm/metadatatreestore.cpp [deleted file]
synfig-studio/src/gtkmm/metadatatreestore.h [deleted file]
synfig-studio/src/gtkmm/mod_mirror/mod_mirror.cpp [deleted file]
synfig-studio/src/gtkmm/mod_mirror/mod_mirror.h [deleted file]
synfig-studio/src/gtkmm/mod_mirror/state_mirror.cpp [deleted file]
synfig-studio/src/gtkmm/mod_mirror/state_mirror.h [deleted file]
synfig-studio/src/gtkmm/mod_palette/dock_palbrowse.cpp [deleted file]
synfig-studio/src/gtkmm/mod_palette/dock_palbrowse.h [deleted file]
synfig-studio/src/gtkmm/mod_palette/dock_paledit.cpp [deleted file]
synfig-studio/src/gtkmm/mod_palette/dock_paledit.h [deleted file]
synfig-studio/src/gtkmm/mod_palette/mod_palette.cpp [deleted file]
synfig-studio/src/gtkmm/mod_palette/mod_palette.h [deleted file]
synfig-studio/src/gtkmm/module.cpp [deleted file]
synfig-studio/src/gtkmm/module.h [deleted file]
synfig-studio/src/gtkmm/onemoment.cpp [deleted file]
synfig-studio/src/gtkmm/onemoment.h [deleted file]
synfig-studio/src/gtkmm/preview.cpp [deleted file]
synfig-studio/src/gtkmm/preview.h [deleted file]
synfig-studio/src/gtkmm/renddesc.cpp [deleted file]
synfig-studio/src/gtkmm/renddesc.h [deleted file]
synfig-studio/src/gtkmm/render.cpp [deleted file]
synfig-studio/src/gtkmm/render.h [deleted file]
synfig-studio/src/gtkmm/renderer_bbox.cpp [deleted file]
synfig-studio/src/gtkmm/renderer_bbox.h [deleted file]
synfig-studio/src/gtkmm/renderer_canvas.cpp [deleted file]
synfig-studio/src/gtkmm/renderer_canvas.h [deleted file]
synfig-studio/src/gtkmm/renderer_dragbox.cpp [deleted file]
synfig-studio/src/gtkmm/renderer_dragbox.h [deleted file]
synfig-studio/src/gtkmm/renderer_ducks.cpp [deleted file]
synfig-studio/src/gtkmm/renderer_ducks.h [deleted file]
synfig-studio/src/gtkmm/renderer_grid.cpp [deleted file]
synfig-studio/src/gtkmm/renderer_grid.h [deleted file]
synfig-studio/src/gtkmm/renderer_guides.cpp [deleted file]
synfig-studio/src/gtkmm/renderer_guides.h [deleted file]
synfig-studio/src/gtkmm/renderer_timecode.cpp [deleted file]
synfig-studio/src/gtkmm/renderer_timecode.h [deleted file]
synfig-studio/src/gtkmm/resolutiondial.cpp [deleted file]
synfig-studio/src/gtkmm/resolutiondial.h [deleted file]
synfig-studio/src/gtkmm/smach.h [deleted file]
synfig-studio/src/gtkmm/splash.cpp [deleted file]
synfig-studio/src/gtkmm/splash.h [deleted file]
synfig-studio/src/gtkmm/state_bline.cpp [deleted file]
synfig-studio/src/gtkmm/state_bline.h [deleted file]
synfig-studio/src/gtkmm/state_circle.cpp [deleted file]
synfig-studio/src/gtkmm/state_circle.h [deleted file]
synfig-studio/src/gtkmm/state_draw.cpp [deleted file]
synfig-studio/src/gtkmm/state_draw.h [deleted file]
synfig-studio/src/gtkmm/state_eyedrop.cpp [deleted file]
synfig-studio/src/gtkmm/state_eyedrop.h [deleted file]
synfig-studio/src/gtkmm/state_fill.cpp [deleted file]
synfig-studio/src/gtkmm/state_fill.h [deleted file]
synfig-studio/src/gtkmm/state_gradient.cpp [deleted file]
synfig-studio/src/gtkmm/state_gradient.h [deleted file]
synfig-studio/src/gtkmm/state_normal.cpp [deleted file]
synfig-studio/src/gtkmm/state_normal.h [deleted file]
synfig-studio/src/gtkmm/state_polygon.cpp [deleted file]
synfig-studio/src/gtkmm/state_polygon.h [deleted file]
synfig-studio/src/gtkmm/state_rectangle.cpp [deleted file]
synfig-studio/src/gtkmm/state_rectangle.h [deleted file]
synfig-studio/src/gtkmm/state_rotate.cpp [deleted file]
synfig-studio/src/gtkmm/state_rotate.h [deleted file]
synfig-studio/src/gtkmm/state_scale.cpp [deleted file]
synfig-studio/src/gtkmm/state_scale.h [deleted file]
synfig-studio/src/gtkmm/state_sketch.cpp [deleted file]
synfig-studio/src/gtkmm/state_sketch.h [deleted file]
synfig-studio/src/gtkmm/state_smoothmove.cpp [deleted file]
synfig-studio/src/gtkmm/state_smoothmove.h [deleted file]
synfig-studio/src/gtkmm/state_star.cpp [deleted file]
synfig-studio/src/gtkmm/state_star.h [deleted file]
synfig-studio/src/gtkmm/state_stroke.cpp [deleted file]
synfig-studio/src/gtkmm/state_stroke.h [deleted file]
synfig-studio/src/gtkmm/state_text.cpp [deleted file]
synfig-studio/src/gtkmm/state_text.h [deleted file]
synfig-studio/src/gtkmm/state_width.cpp [deleted file]
synfig-studio/src/gtkmm/state_width.h [deleted file]
synfig-studio/src/gtkmm/state_zoom.cpp [deleted file]
synfig-studio/src/gtkmm/state_zoom.h [deleted file]
synfig-studio/src/gtkmm/statemanager.cpp [deleted file]
synfig-studio/src/gtkmm/statemanager.h [deleted file]
synfig-studio/src/gtkmm/toggleducksdial.cpp [deleted file]
synfig-studio/src/gtkmm/toggleducksdial.h [deleted file]
synfig-studio/src/gtkmm/toolbox.cpp [deleted file]
synfig-studio/src/gtkmm/toolbox.h [deleted file]
synfig-studio/src/gtkmm/valuelink.cpp [deleted file]
synfig-studio/src/gtkmm/valuelink.h [deleted file]
synfig-studio/src/gtkmm/widget_canvaschooser.cpp [deleted file]
synfig-studio/src/gtkmm/widget_canvaschooser.h [deleted file]
synfig-studio/src/gtkmm/widget_color.cpp [deleted file]
synfig-studio/src/gtkmm/widget_color.h [deleted file]
synfig-studio/src/gtkmm/widget_coloredit.cpp [deleted file]
synfig-studio/src/gtkmm/widget_coloredit.h [deleted file]
synfig-studio/src/gtkmm/widget_compselect.cpp [deleted file]
synfig-studio/src/gtkmm/widget_compselect.h [deleted file]
synfig-studio/src/gtkmm/widget_curves.cpp [deleted file]
synfig-studio/src/gtkmm/widget_curves.h [deleted file]
synfig-studio/src/gtkmm/widget_defaults.cpp [deleted file]
synfig-studio/src/gtkmm/widget_defaults.h [deleted file]
synfig-studio/src/gtkmm/widget_distance.cpp [deleted file]
synfig-studio/src/gtkmm/widget_distance.h [deleted file]
synfig-studio/src/gtkmm/widget_enum.cpp [deleted file]
synfig-studio/src/gtkmm/widget_enum.h [deleted file]
synfig-studio/src/gtkmm/widget_filename.cpp [deleted file]
synfig-studio/src/gtkmm/widget_filename.h [deleted file]
synfig-studio/src/gtkmm/widget_gradient.cpp [deleted file]
synfig-studio/src/gtkmm/widget_gradient.h [deleted file]
synfig-studio/src/gtkmm/widget_keyframe_list.cpp [deleted file]
synfig-studio/src/gtkmm/widget_keyframe_list.h [deleted file]
synfig-studio/src/gtkmm/widget_sound.cpp [deleted file]
synfig-studio/src/gtkmm/widget_sound.h [deleted file]
synfig-studio/src/gtkmm/widget_time.cpp [deleted file]
synfig-studio/src/gtkmm/widget_time.h [deleted file]
synfig-studio/src/gtkmm/widget_timeslider.cpp [deleted file]
synfig-studio/src/gtkmm/widget_timeslider.h [deleted file]
synfig-studio/src/gtkmm/widget_value.cpp [deleted file]
synfig-studio/src/gtkmm/widget_value.h [deleted file]
synfig-studio/src/gtkmm/widget_vector.cpp [deleted file]
synfig-studio/src/gtkmm/widget_vector.h [deleted file]
synfig-studio/src/gtkmm/widget_waypoint.cpp [deleted file]
synfig-studio/src/gtkmm/widget_waypoint.h [deleted file]
synfig-studio/src/gtkmm/widget_waypointmodel.cpp [deleted file]
synfig-studio/src/gtkmm/widget_waypointmodel.h [deleted file]
synfig-studio/src/gtkmm/workarea.cpp [deleted file]
synfig-studio/src/gtkmm/workarea.h [deleted file]
synfig-studio/src/gtkmm/workarearenderer.cpp [deleted file]
synfig-studio/src/gtkmm/workarearenderer.h [deleted file]
synfig-studio/src/gtkmm/zoomdial.cpp [deleted file]
synfig-studio/src/gtkmm/zoomdial.h [deleted file]
synfig-studio/src/gui/Makefile.am [new file with mode: 0644]
synfig-studio/src/gui/about.cpp [new file with mode: 0644]
synfig-studio/src/gui/about.h [new file with mode: 0644]
synfig-studio/src/gui/adjust_window.cpp [new file with mode: 0644]
synfig-studio/src/gui/adjust_window.h [new file with mode: 0644]
synfig-studio/src/gui/app.cpp [new file with mode: 0644]
synfig-studio/src/gui/app.h [new file with mode: 0644]
synfig-studio/src/gui/asyncrenderer.cpp [new file with mode: 0644]
synfig-studio/src/gui/asyncrenderer.h [new file with mode: 0644]
synfig-studio/src/gui/audiocontainer.cpp [new file with mode: 0644]
synfig-studio/src/gui/audiocontainer.h [new file with mode: 0644]
synfig-studio/src/gui/autorecover.cpp [new file with mode: 0644]
synfig-studio/src/gui/autorecover.h [new file with mode: 0644]
synfig-studio/src/gui/canvasoptions.cpp [new file with mode: 0644]
synfig-studio/src/gui/canvasoptions.h [new file with mode: 0644]
synfig-studio/src/gui/canvasproperties.cpp [new file with mode: 0644]
synfig-studio/src/gui/canvasproperties.h [new file with mode: 0644]
synfig-studio/src/gui/canvastreestore.cpp [new file with mode: 0644]
synfig-studio/src/gui/canvastreestore.h [new file with mode: 0644]
synfig-studio/src/gui/canvasview.cpp [new file with mode: 0644]
synfig-studio/src/gui/canvasview.h [new file with mode: 0644]
synfig-studio/src/gui/cellrenderer_gradient.cpp [new file with mode: 0644]
synfig-studio/src/gui/cellrenderer_gradient.h [new file with mode: 0644]
synfig-studio/src/gui/cellrenderer_time.cpp [new file with mode: 0644]
synfig-studio/src/gui/cellrenderer_time.h [new file with mode: 0644]
synfig-studio/src/gui/cellrenderer_timetrack.cpp [new file with mode: 0644]
synfig-studio/src/gui/cellrenderer_timetrack.h [new file with mode: 0644]
synfig-studio/src/gui/cellrenderer_value.cpp [new file with mode: 0644]
synfig-studio/src/gui/cellrenderer_value.h [new file with mode: 0644]
synfig-studio/src/gui/childrentree.cpp [new file with mode: 0644]
synfig-studio/src/gui/childrentree.h [new file with mode: 0644]
synfig-studio/src/gui/childrentreestore.cpp [new file with mode: 0644]
synfig-studio/src/gui/childrentreestore.h [new file with mode: 0644]
synfig-studio/src/gui/compview.cpp [new file with mode: 0644]
synfig-studio/src/gui/compview.h [new file with mode: 0644]
synfig-studio/src/gui/devicetracker.cpp [new file with mode: 0644]
synfig-studio/src/gui/devicetracker.h [new file with mode: 0644]
synfig-studio/src/gui/dialog_color.cpp [new file with mode: 0644]
synfig-studio/src/gui/dialog_color.h [new file with mode: 0644]
synfig-studio/src/gui/dialog_gradient.cpp [new file with mode: 0644]
synfig-studio/src/gui/dialog_gradient.h [new file with mode: 0644]
synfig-studio/src/gui/dialog_keyframe.cpp [new file with mode: 0644]
synfig-studio/src/gui/dialog_keyframe.h [new file with mode: 0644]
synfig-studio/src/gui/dialog_preview.cpp [new file with mode: 0644]
synfig-studio/src/gui/dialog_preview.h [new file with mode: 0644]
synfig-studio/src/gui/dialog_setup.cpp [new file with mode: 0644]
synfig-studio/src/gui/dialog_setup.h [new file with mode: 0644]
synfig-studio/src/gui/dialog_soundselect.cpp [new file with mode: 0644]
synfig-studio/src/gui/dialog_soundselect.h [new file with mode: 0644]
synfig-studio/src/gui/dialog_targetparam.cpp [new file with mode: 0644]
synfig-studio/src/gui/dialog_targetparam.h [new file with mode: 0644]
synfig-studio/src/gui/dialog_tooloptions.cpp [new file with mode: 0644]
synfig-studio/src/gui/dialog_tooloptions.h [new file with mode: 0644]
synfig-studio/src/gui/dialog_waypoint.cpp [new file with mode: 0644]
synfig-studio/src/gui/dialog_waypoint.h [new file with mode: 0644]
synfig-studio/src/gui/dialogsettings.cpp [new file with mode: 0644]
synfig-studio/src/gui/dialogsettings.h [new file with mode: 0644]
synfig-studio/src/gui/dock_canvases.cpp [new file with mode: 0644]
synfig-studio/src/gui/dock_canvases.h [new file with mode: 0644]
synfig-studio/src/gui/dock_canvasspecific.cpp [new file with mode: 0644]
synfig-studio/src/gui/dock_canvasspecific.h [new file with mode: 0644]
synfig-studio/src/gui/dock_children.cpp [new file with mode: 0644]
synfig-studio/src/gui/dock_children.h [new file with mode: 0644]
synfig-studio/src/gui/dock_curves.cpp [new file with mode: 0644]
synfig-studio/src/gui/dock_curves.h [new file with mode: 0644]
synfig-studio/src/gui/dock_history.cpp [new file with mode: 0644]
synfig-studio/src/gui/dock_history.h [new file with mode: 0644]
synfig-studio/src/gui/dock_info.cpp [new file with mode: 0644]
synfig-studio/src/gui/dock_info.h [new file with mode: 0644]
synfig-studio/src/gui/dock_keyframes.cpp [new file with mode: 0644]
synfig-studio/src/gui/dock_keyframes.h [new file with mode: 0644]
synfig-studio/src/gui/dock_layergroups.cpp [new file with mode: 0644]
synfig-studio/src/gui/dock_layergroups.h [new file with mode: 0644]
synfig-studio/src/gui/dock_layers.cpp [new file with mode: 0644]
synfig-studio/src/gui/dock_layers.h [new file with mode: 0644]
synfig-studio/src/gui/dock_metadata.cpp [new file with mode: 0644]
synfig-studio/src/gui/dock_metadata.h [new file with mode: 0644]
synfig-studio/src/gui/dock_navigator.cpp [new file with mode: 0644]
synfig-studio/src/gui/dock_navigator.h [new file with mode: 0644]
synfig-studio/src/gui/dock_params.cpp [new file with mode: 0644]
synfig-studio/src/gui/dock_params.h [new file with mode: 0644]
synfig-studio/src/gui/dock_timetrack.cpp [new file with mode: 0644]
synfig-studio/src/gui/dock_timetrack.h [new file with mode: 0644]
synfig-studio/src/gui/dockable.cpp [new file with mode: 0644]
synfig-studio/src/gui/dockable.h [new file with mode: 0644]
synfig-studio/src/gui/dockbook.cpp [new file with mode: 0644]
synfig-studio/src/gui/dockbook.h [new file with mode: 0644]
synfig-studio/src/gui/dockdialog.cpp [new file with mode: 0644]
synfig-studio/src/gui/dockdialog.h [new file with mode: 0644]
synfig-studio/src/gui/dockmanager.cpp [new file with mode: 0644]
synfig-studio/src/gui/dockmanager.h [new file with mode: 0644]
synfig-studio/src/gui/duck.cpp [new file with mode: 0644]
synfig-studio/src/gui/duck.h [new file with mode: 0644]
synfig-studio/src/gui/duckmatic.cpp [new file with mode: 0644]
synfig-studio/src/gui/duckmatic.h [new file with mode: 0644]
synfig-studio/src/gui/ducktransform_rotate.h [new file with mode: 0644]
synfig-studio/src/gui/ducktransform_scale.h [new file with mode: 0644]
synfig-studio/src/gui/ducktransform_translate.h [new file with mode: 0644]
synfig-studio/src/gui/event_layerclick.h [new file with mode: 0644]
synfig-studio/src/gui/event_mouse.h [new file with mode: 0644]
synfig-studio/src/gui/eventkey.h [new file with mode: 0644]
synfig-studio/src/gui/framedial.cpp [new file with mode: 0644]
synfig-studio/src/gui/framedial.h [new file with mode: 0644]
synfig-studio/src/gui/general.h [new file with mode: 0644]
synfig-studio/src/gui/groupactionmanager.cpp [new file with mode: 0644]
synfig-studio/src/gui/groupactionmanager.h [new file with mode: 0644]
synfig-studio/src/gui/historytreestore.cpp [new file with mode: 0644]
synfig-studio/src/gui/historytreestore.h [new file with mode: 0644]
synfig-studio/src/gui/iconcontroller.cpp [new file with mode: 0644]
synfig-studio/src/gui/iconcontroller.h [new file with mode: 0644]
synfig-studio/src/gui/instance.cpp [new file with mode: 0644]
synfig-studio/src/gui/instance.h [new file with mode: 0644]
synfig-studio/src/gui/ipc.cpp [new file with mode: 0644]
synfig-studio/src/gui/ipc.h [new file with mode: 0644]
synfig-studio/src/gui/keyframeactionmanager.cpp [new file with mode: 0644]
synfig-studio/src/gui/keyframeactionmanager.h [new file with mode: 0644]
synfig-studio/src/gui/keyframedial.cpp [new file with mode: 0644]
synfig-studio/src/gui/keyframedial.h [new file with mode: 0644]
synfig-studio/src/gui/keyframetree.cpp [new file with mode: 0644]
synfig-studio/src/gui/keyframetree.h [new file with mode: 0644]
synfig-studio/src/gui/keyframetreestore.cpp [new file with mode: 0644]
synfig-studio/src/gui/keyframetreestore.h [new file with mode: 0644]
synfig-studio/src/gui/keymapsettings.cpp [new file with mode: 0644]
synfig-studio/src/gui/keymapsettings.h [new file with mode: 0644]
synfig-studio/src/gui/layeractionmanager.cpp [new file with mode: 0644]
synfig-studio/src/gui/layeractionmanager.h [new file with mode: 0644]
synfig-studio/src/gui/layergrouptree.cpp [new file with mode: 0644]
synfig-studio/src/gui/layergrouptree.h [new file with mode: 0644]
synfig-studio/src/gui/layergrouptreestore.cpp [new file with mode: 0644]
synfig-studio/src/gui/layergrouptreestore.h [new file with mode: 0644]
synfig-studio/src/gui/layerparamtreestore.cpp [new file with mode: 0644]
synfig-studio/src/gui/layerparamtreestore.h [new file with mode: 0644]
synfig-studio/src/gui/layertree.cpp [new file with mode: 0644]
synfig-studio/src/gui/layertree.h [new file with mode: 0644]
synfig-studio/src/gui/layertreestore.cpp [new file with mode: 0644]
synfig-studio/src/gui/layertreestore.h [new file with mode: 0644]
synfig-studio/src/gui/main.cpp [new file with mode: 0644]
synfig-studio/src/gui/metadatatreestore.cpp [new file with mode: 0644]
synfig-studio/src/gui/metadatatreestore.h [new file with mode: 0644]
synfig-studio/src/gui/mod_mirror/mod_mirror.cpp [new file with mode: 0644]
synfig-studio/src/gui/mod_mirror/mod_mirror.h [new file with mode: 0644]
synfig-studio/src/gui/mod_mirror/state_mirror.cpp [new file with mode: 0644]
synfig-studio/src/gui/mod_mirror/state_mirror.h [new file with mode: 0644]
synfig-studio/src/gui/mod_palette/dock_palbrowse.cpp [new file with mode: 0644]
synfig-studio/src/gui/mod_palette/dock_palbrowse.h [new file with mode: 0644]
synfig-studio/src/gui/mod_palette/dock_paledit.cpp [new file with mode: 0644]
synfig-studio/src/gui/mod_palette/dock_paledit.h [new file with mode: 0644]
synfig-studio/src/gui/mod_palette/mod_palette.cpp [new file with mode: 0644]
synfig-studio/src/gui/mod_palette/mod_palette.h [new file with mode: 0644]
synfig-studio/src/gui/module.cpp [new file with mode: 0644]
synfig-studio/src/gui/module.h [new file with mode: 0644]
synfig-studio/src/gui/onemoment.cpp [new file with mode: 0644]
synfig-studio/src/gui/onemoment.h [new file with mode: 0644]
synfig-studio/src/gui/preview.cpp [new file with mode: 0644]
synfig-studio/src/gui/preview.h [new file with mode: 0644]
synfig-studio/src/gui/renddesc.cpp [new file with mode: 0644]
synfig-studio/src/gui/renddesc.h [new file with mode: 0644]
synfig-studio/src/gui/render.cpp [new file with mode: 0644]
synfig-studio/src/gui/render.h [new file with mode: 0644]
synfig-studio/src/gui/renderer_bbox.cpp [new file with mode: 0644]
synfig-studio/src/gui/renderer_bbox.h [new file with mode: 0644]
synfig-studio/src/gui/renderer_canvas.cpp [new file with mode: 0644]
synfig-studio/src/gui/renderer_canvas.h [new file with mode: 0644]
synfig-studio/src/gui/renderer_dragbox.cpp [new file with mode: 0644]
synfig-studio/src/gui/renderer_dragbox.h [new file with mode: 0644]
synfig-studio/src/gui/renderer_ducks.cpp [new file with mode: 0644]
synfig-studio/src/gui/renderer_ducks.h [new file with mode: 0644]
synfig-studio/src/gui/renderer_grid.cpp [new file with mode: 0644]
synfig-studio/src/gui/renderer_grid.h [new file with mode: 0644]
synfig-studio/src/gui/renderer_guides.cpp [new file with mode: 0644]
synfig-studio/src/gui/renderer_guides.h [new file with mode: 0644]
synfig-studio/src/gui/renderer_timecode.cpp [new file with mode: 0644]
synfig-studio/src/gui/renderer_timecode.h [new file with mode: 0644]
synfig-studio/src/gui/resolutiondial.cpp [new file with mode: 0644]
synfig-studio/src/gui/resolutiondial.h [new file with mode: 0644]
synfig-studio/src/gui/smach.h [new file with mode: 0644]
synfig-studio/src/gui/splash.cpp [new file with mode: 0644]
synfig-studio/src/gui/splash.h [new file with mode: 0644]
synfig-studio/src/gui/state_bline.cpp [new file with mode: 0644]
synfig-studio/src/gui/state_bline.h [new file with mode: 0644]
synfig-studio/src/gui/state_circle.cpp [new file with mode: 0644]
synfig-studio/src/gui/state_circle.h [new file with mode: 0644]
synfig-studio/src/gui/state_draw.cpp [new file with mode: 0644]
synfig-studio/src/gui/state_draw.h [new file with mode: 0644]
synfig-studio/src/gui/state_eyedrop.cpp [new file with mode: 0644]
synfig-studio/src/gui/state_eyedrop.h [new file with mode: 0644]
synfig-studio/src/gui/state_fill.cpp [new file with mode: 0644]
synfig-studio/src/gui/state_fill.h [new file with mode: 0644]
synfig-studio/src/gui/state_gradient.cpp [new file with mode: 0644]
synfig-studio/src/gui/state_gradient.h [new file with mode: 0644]
synfig-studio/src/gui/state_normal.cpp [new file with mode: 0644]
synfig-studio/src/gui/state_normal.h [new file with mode: 0644]
synfig-studio/src/gui/state_polygon.cpp [new file with mode: 0644]
synfig-studio/src/gui/state_polygon.h [new file with mode: 0644]
synfig-studio/src/gui/state_rectangle.cpp [new file with mode: 0644]
synfig-studio/src/gui/state_rectangle.h [new file with mode: 0644]
synfig-studio/src/gui/state_rotate.cpp [new file with mode: 0644]
synfig-studio/src/gui/state_rotate.h [new file with mode: 0644]
synfig-studio/src/gui/state_scale.cpp [new file with mode: 0644]
synfig-studio/src/gui/state_scale.h [new file with mode: 0644]
synfig-studio/src/gui/state_sketch.cpp [new file with mode: 0644]
synfig-studio/src/gui/state_sketch.h [new file with mode: 0644]
synfig-studio/src/gui/state_smoothmove.cpp [new file with mode: 0644]
synfig-studio/src/gui/state_smoothmove.h [new file with mode: 0644]
synfig-studio/src/gui/state_star.cpp [new file with mode: 0644]
synfig-studio/src/gui/state_star.h [new file with mode: 0644]
synfig-studio/src/gui/state_stroke.cpp [new file with mode: 0644]
synfig-studio/src/gui/state_stroke.h [new file with mode: 0644]
synfig-studio/src/gui/state_text.cpp [new file with mode: 0644]
synfig-studio/src/gui/state_text.h [new file with mode: 0644]
synfig-studio/src/gui/state_width.cpp [new file with mode: 0644]
synfig-studio/src/gui/state_width.h [new file with mode: 0644]
synfig-studio/src/gui/state_zoom.cpp [new file with mode: 0644]
synfig-studio/src/gui/state_zoom.h [new file with mode: 0644]
synfig-studio/src/gui/statemanager.cpp [new file with mode: 0644]
synfig-studio/src/gui/statemanager.h [new file with mode: 0644]
synfig-studio/src/gui/toggleducksdial.cpp [new file with mode: 0644]
synfig-studio/src/gui/toggleducksdial.h [new file with mode: 0644]
synfig-studio/src/gui/toolbox.cpp [new file with mode: 0644]
synfig-studio/src/gui/toolbox.h [new file with mode: 0644]
synfig-studio/src/gui/valuelink.cpp [new file with mode: 0644]
synfig-studio/src/gui/valuelink.h [new file with mode: 0644]
synfig-studio/src/gui/widget_canvaschooser.cpp [new file with mode: 0644]
synfig-studio/src/gui/widget_canvaschooser.h [new file with mode: 0644]
synfig-studio/src/gui/widget_color.cpp [new file with mode: 0644]
synfig-studio/src/gui/widget_color.h [new file with mode: 0644]
synfig-studio/src/gui/widget_coloredit.cpp [new file with mode: 0644]
synfig-studio/src/gui/widget_coloredit.h [new file with mode: 0644]
synfig-studio/src/gui/widget_compselect.cpp [new file with mode: 0644]
synfig-studio/src/gui/widget_compselect.h [new file with mode: 0644]
synfig-studio/src/gui/widget_curves.cpp [new file with mode: 0644]
synfig-studio/src/gui/widget_curves.h [new file with mode: 0644]
synfig-studio/src/gui/widget_defaults.cpp [new file with mode: 0644]
synfig-studio/src/gui/widget_defaults.h [new file with mode: 0644]
synfig-studio/src/gui/widget_distance.cpp [new file with mode: 0644]
synfig-studio/src/gui/widget_distance.h [new file with mode: 0644]
synfig-studio/src/gui/widget_enum.cpp [new file with mode: 0644]
synfig-studio/src/gui/widget_enum.h [new file with mode: 0644]
synfig-studio/src/gui/widget_filename.cpp [new file with mode: 0644]
synfig-studio/src/gui/widget_filename.h [new file with mode: 0644]
synfig-studio/src/gui/widget_gradient.cpp [new file with mode: 0644]
synfig-studio/src/gui/widget_gradient.h [new file with mode: 0644]
synfig-studio/src/gui/widget_keyframe_list.cpp [new file with mode: 0644]
synfig-studio/src/gui/widget_keyframe_list.h [new file with mode: 0644]
synfig-studio/src/gui/widget_sound.cpp [new file with mode: 0644]
synfig-studio/src/gui/widget_sound.h [new file with mode: 0644]
synfig-studio/src/gui/widget_time.cpp [new file with mode: 0644]
synfig-studio/src/gui/widget_time.h [new file with mode: 0644]
synfig-studio/src/gui/widget_timeslider.cpp [new file with mode: 0644]
synfig-studio/src/gui/widget_timeslider.h [new file with mode: 0644]
synfig-studio/src/gui/widget_value.cpp [new file with mode: 0644]
synfig-studio/src/gui/widget_value.h [new file with mode: 0644]
synfig-studio/src/gui/widget_vector.cpp [new file with mode: 0644]
synfig-studio/src/gui/widget_vector.h [new file with mode: 0644]
synfig-studio/src/gui/widget_waypoint.cpp [new file with mode: 0644]
synfig-studio/src/gui/widget_waypoint.h [new file with mode: 0644]
synfig-studio/src/gui/widget_waypointmodel.cpp [new file with mode: 0644]
synfig-studio/src/gui/widget_waypointmodel.h [new file with mode: 0644]
synfig-studio/src/gui/workarea.cpp [new file with mode: 0644]
synfig-studio/src/gui/workarea.h [new file with mode: 0644]
synfig-studio/src/gui/workarearenderer.cpp [new file with mode: 0644]
synfig-studio/src/gui/workarearenderer.h [new file with mode: 0644]
synfig-studio/src/gui/zoomdial.cpp [new file with mode: 0644]
synfig-studio/src/gui/zoomdial.h [new file with mode: 0644]

index 0077290..704fd4e 100755 (executable)
@@ -275,7 +275,7 @@ synfigstudio.keys
 synfigstudio.xml
 synfigstudio-thumbnailer.schemas
 src/Makefile
-src/gtkmm/Makefile
+src/gui/Makefile
 src/synfigapp/Makefile
 images/Makefile
 win32inst.nsi
index adc00c2..4bc8c6e 100644 (file)
@@ -8,4 +8,4 @@ EXTRA_DIST = \
 
 SUBDIRS = \
        synfigapp \
-       gtkmm
+       gui
diff --git a/synfig-studio/src/gtkmm/Makefile.am b/synfig-studio/src/gtkmm/Makefile.am
deleted file mode 100644 (file)
index 384a865..0000000
+++ /dev/null
@@ -1,387 +0,0 @@
-# $Id$
-
-EXTRA_DIST = \
-       compview.cpp
-
-MAINTAINERCLEANFILES = \
-       Makefile.in
-
-
-CELLRENDERER_HH = \
-       cellrenderer_gradient.h \
-       cellrenderer_time.h \
-       cellrenderer_timetrack.h \
-       cellrenderer_value.h
-
-CELLRENDERER_CC = \
-       cellrenderer_gradient.cpp \
-       cellrenderer_time.cpp \
-       cellrenderer_timetrack.cpp \
-       cellrenderer_value.cpp
-
-
-WORKAREARENDERER_HH = \
-       renderer_bbox.h \
-       renderer_canvas.h \
-       renderer_dragbox.h \
-       renderer_ducks.h \
-       renderer_grid.h \
-       renderer_guides.h \
-       renderer_timecode.h \
-       workarearenderer.h
-
-WORKAREARENDERER_CC = \
-       renderer_bbox.cpp \
-       renderer_canvas.cpp \
-       renderer_dragbox.cpp \
-       renderer_ducks.cpp \
-       renderer_grid.cpp \
-       renderer_guides.cpp \
-       renderer_timecode.cpp \
-       workarearenderer.cpp
-
-
-PALETTE_HH = \
-       mod_palette/dock_palbrowse.h \
-       mod_palette/dock_paledit.h \
-       mod_palette/mod_palette.h
-
-PALETTE_CC = \
-       mod_palette/dock_palbrowse.cpp \
-       mod_palette/dock_paledit.cpp \
-       mod_palette/mod_palette.cpp
-
-
-MOD_MIRROR_HH = \
-       mod_mirror/mod_mirror.h \
-       mod_mirror/state_mirror.h
-
-MOD_MIRROR_CC = \
-       mod_mirror/mod_mirror.cpp \
-       mod_mirror/state_mirror.cpp
-
-
-DIALOG_HH = \
-       dialog_color.h \
-       dialog_gradient.h \
-       dialog_keyframe.h \
-       dialog_preview.h \
-       dialog_setup.h \
-       dialog_soundselect.h \
-       dialog_targetparam.h \
-       dialog_waypoint.h
-
-DIALOG_CC = \
-       dialog_color.cpp \
-       dialog_gradient.cpp \
-       dialog_keyframe.cpp \
-       dialog_preview.cpp \
-       dialog_setup.cpp \
-       dialog_soundselect.cpp \
-       dialog_targetparam.cpp \
-       dialog_waypoint.cpp
-
-
-DOCK_HH = \
-       dialog_tooloptions.h \
-       dock_canvases.h \
-       dock_canvasspecific.h \
-       dock_children.h \
-       dock_curves.h \
-       dock_history.h \
-       dock_info.h \
-       dock_keyframes.h \
-       dock_layergroups.h \
-       dock_layers.h \
-       dock_metadata.h \
-       dock_navigator.h \
-       dock_params.h \
-       dock_timetrack.h \
-       dockable.h \
-       dockbook.h \
-       dockdialog.h \
-       dockmanager.h
-
-DOCK_CC = \
-       dialog_tooloptions.cpp \
-       dock_canvases.cpp \
-       dock_canvasspecific.cpp \
-       dock_children.cpp \
-       dock_curves.cpp \
-       dock_history.cpp \
-       dock_info.cpp \
-       dock_keyframes.cpp \
-       dock_layergroups.cpp \
-       dock_layers.cpp \
-       dock_metadata.cpp \
-       dock_navigator.cpp \
-       dock_params.cpp \
-       dock_timetrack.cpp \
-       dockable.cpp \
-       dockbook.cpp \
-       dockdialog.cpp \
-       dockmanager.cpp
-
-
-WIDGET_HH = \
-       widget_canvaschooser.h \
-       widget_color.h \
-       widget_coloredit.h \
-       widget_compselect.h \
-       widget_curves.h \
-       widget_defaults.h \
-       widget_distance.h \
-       widget_enum.h \
-       widget_filename.h \
-       widget_gradient.h \
-       widget_sound.h \
-       widget_time.h \
-       widget_timeslider.h \
-       widget_value.h \
-       widget_vector.h \
-       widget_waypoint.h \
-       widget_waypointmodel.h \
-       widget_keyframe_list.h
-
-WIDGET_CC = \
-       widget_canvaschooser.cpp \
-       widget_color.cpp \
-       widget_coloredit.cpp \
-       widget_compselect.cpp \
-       widget_curves.cpp \
-       widget_defaults.cpp \
-       widget_distance.cpp \
-       widget_enum.cpp \
-       widget_filename.cpp \
-       widget_gradient.cpp \
-       widget_sound.cpp \
-       widget_time.cpp \
-       widget_timeslider.cpp \
-       widget_value.cpp \
-       widget_vector.cpp \
-       widget_waypoint.cpp \
-       widget_waypointmodel.cpp \
-       widget_keyframe_list.cpp
-
-
-STATE_HH = \
-       state_bline.h \
-       state_circle.h \
-       state_draw.h \
-       state_eyedrop.h \
-       state_fill.h \
-       state_gradient.h \
-       state_normal.h \
-       state_polygon.h \
-       state_rectangle.h \
-       state_rotate.h \
-       state_scale.h \
-       state_sketch.h \
-       state_smoothmove.h \
-       state_star.h \
-       state_stroke.h \
-       state_text.h \
-       state_width.h \
-       state_zoom.h
-
-STATE_CC = \
-       state_bline.cpp \
-       state_circle.cpp \
-       state_draw.cpp \
-       state_eyedrop.cpp \
-       state_fill.cpp \
-       state_gradient.cpp \
-       state_normal.cpp \
-       state_polygon.cpp \
-       state_rectangle.cpp \
-       state_rotate.cpp \
-       state_scale.cpp \
-       state_sketch.cpp \
-       state_smoothmove.cpp \
-       state_star.cpp \
-       state_stroke.cpp \
-       state_text.cpp \
-       state_width.cpp \
-       state_zoom.cpp
-
-
-TREEVIEW_HH = \
-       childrentree.h \
-       keyframetree.h \
-       layergrouptree.h \
-       layertree.h
-
-TREEVIEW_CC = \
-       childrentree.cpp \
-       keyframetree.cpp \
-       layergrouptree.cpp \
-       layertree.cpp
-
-
-TREESTORE_HH = \
-       canvastreestore.h \
-       childrentreestore.h \
-       historytreestore.h \
-       keyframetreestore.h \
-       layergrouptreestore.h \
-       layerparamtreestore.h \
-       layertreestore.h \
-       metadatatreestore.h
-
-TREESTORE_CC = \
-       canvastreestore.cpp \
-       childrentreestore.cpp \
-       historytreestore.cpp \
-       keyframetreestore.cpp \
-       layergrouptreestore.cpp \
-       layerparamtreestore.cpp \
-       layertreestore.cpp \
-       metadatatreestore.cpp
-
-
-DUCKTRANSFORM_HH = \
-       ducktransform_rotate.h \
-       ducktransform_scale.h \
-       ducktransform_translate.h \
-       duck.h
-
-DUCKTRANSFORM_CC = \
-       duck.cpp
-
-
-EVENTS_HH = \
-       event_layerclick.h \
-       event_mouse.h
-
-
-ACTION_MANAGERS_HH = \
-       groupactionmanager.h \
-       keyframeactionmanager.h \
-       layeractionmanager.h
-
-ACTION_MANAGERS_CC = \
-       groupactionmanager.cpp \
-       keyframeactionmanager.cpp \
-       layeractionmanager.cpp
-
-
-OTHER_HH = \
-       compview.h \
-       eventkey.h \
-       smach.h \
-       about.h \
-       adjust_window.h \
-       app.h \
-       asyncrenderer.h \
-       audiocontainer.h \
-       autorecover.h \
-       canvasoptions.h \
-       canvasproperties.h \
-       canvasview.h \
-       devicetracker.h \
-       dialogsettings.h \
-       duckmatic.h \
-       general.h \
-       iconcontroller.h \
-       instance.h \
-       ipc.h \
-       keymapsettings.h \
-       module.h \
-       onemoment.h \
-       preview.h \
-       renddesc.h \
-       render.h \
-       splash.h \
-       statemanager.h \
-       toolbox.h \
-       valuelink.h \
-       workarea.h \
-       zoomdial.h \
-       framedial.h \
-       keyframedial.h \
-       toggleducksdial.h \
-       resolutiondial.h
-
-OTHER_CC = \
-       main.cpp \
-       about.cpp \
-       adjust_window.cpp \
-       app.cpp \
-       asyncrenderer.cpp \
-       audiocontainer.cpp \
-       autorecover.cpp \
-       canvasoptions.cpp \
-       canvasproperties.cpp \
-       canvasview.cpp \
-       devicetracker.cpp \
-       dialogsettings.cpp \
-       duckmatic.cpp \
-       iconcontroller.cpp \
-       instance.cpp \
-       ipc.cpp \
-       keymapsettings.cpp \
-       module.cpp \
-       onemoment.cpp \
-       preview.cpp \
-       renddesc.cpp \
-       render.cpp \
-       splash.cpp \
-       statemanager.cpp \
-       toolbox.cpp \
-       valuelink.cpp \
-       workarea.cpp \
-       zoomdial.cpp \
-       framedial.cpp \
-       keyframedial.cpp \
-       toggleducksdial.cpp \
-       resolutiondial.cpp
-
-INCLUDES = \
-       -I$(top_srcdir)/src
-
-bin_PROGRAMS = synfigstudio
-
-synfigstudio_SOURCES = \
-       $(MOD_MIRROR_CC) \
-       $(MOD_MIRROR_HH) \
-       $(PALETTE_CC) \
-       $(PALETTE_HH) \
-       $(WORKAREARENDERER_CC) \
-       $(WORKAREARENDERER_HH) \
-       $(ACTION_MANAGERS_HH) \
-       $(ACTION_MANAGERS_CC) \
-       $(DOCK_HH) \
-       $(DOCK_CC) \
-       $(OTHER_HH) \
-       $(OTHER_CC) \
-       $(EVENTS_HH) \
-       $(DUCKTRANSFORM_HH) \
-       $(DUCKTRANSFORM_CC) \
-       $(TREEVIEW_HH) \
-       $(TREEVIEW_CC) \
-       $(TREESTORE_HH) \
-       $(TREESTORE_CC) \
-       $(STATE_CC) \
-       $(STATE_HH) \
-       $(WIDGET_CC) \
-       $(WIDGET_HH) \
-       $(CELLRENDERER_HH) \
-       $(CELLRENDERER_CC) \
-       $(DIALOG_HH) \
-       $(DIALOG_CC)
-
-synfigstudio_LDADD = \
-       ../synfigapp/libsynfigapp.la \
-       @SYNFIG_LIBS@ \
-       @GTKMM_LIBS@ \
-       @FMOD_LIBS@
-
-synfigstudio_LDFLAGS = \
-       -dlopen self
-
-synfigstudio_CXXFLAGS = \
-       @SYNFIG_CFLAGS@ \
-       @GTKMM_CFLAGS@ \
-       -DIMAGE_DIR=\"$(imagedir)\" \
-       -DIMAGE_EXT=\"$(imageext)\" \
-       "-DLOCALEDIR=\"$(localedir)\""
diff --git a/synfig-studio/src/gtkmm/about.cpp b/synfig-studio/src/gtkmm/about.cpp
deleted file mode 100644 (file)
index 600d135..0000000
+++ /dev/null
@@ -1,248 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file about.cpp
-**     \brief About dialog implementation
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2008 Paul Wise
-**
-**     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 <config.h>
-#endif
-
-#include <vector>
-
-#include <gtk/gtk.h>
-
-#include <gtkmm/aboutdialog.h>
-
-#include <ETL/stringf>
-
-#include <synfig/general.h>
-
-// This is generated at make time from .svn or .git/svn or autorevision.conf
-#include <autorevision.h>
-
-#include "about.h"
-#include "app.h"
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-using namespace studio;
-
-/* === M A C R O S ========================================================= */
-
-#ifndef VERSION
-#define VERSION        "unknown"
-#define PACKAGE        "synfigstudio"
-#endif
-
-#ifdef WIN32
-#      ifdef IMAGE_DIR
-#              undef IMAGE_DIR
-#              define IMAGE_DIR "share\\pixmaps"
-#      endif
-#endif
-
-#ifndef IMAGE_DIR
-#      define IMAGE_DIR "/usr/local/share/pixmaps"
-#endif
-
-#ifndef IMAGE_EXT
-#      define IMAGE_EXT        "png"
-#endif
-
-#define stringify_(x) #x
-#define stringify(x) stringify_(x)
-
-/* === G L O B A L S ======================================================= */
-
-extern const guint gtk_major_version;
-extern const guint gtk_minor_version;
-extern const guint gtk_micro_version;
-extern const guint gtk_binary_age;
-extern const guint gtk_interface_age;
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-About::About()
-{
-
-#ifdef HAVE_GTK_ABOUTDIALOG_SET_PROGRAM_NAME
-       set_program_name(PACKAGE_NAME);
-#else
-       set_name(PACKAGE_NAME);
-#endif
-       set_version(VERSION);
-       set_comments(_("2D vector animation studio"));
-
-       set_url_hook(sigc::mem_fun(*this, &About::on_link_clicked));
-       set_website("http://www.synfig.org/");
-       set_website_label(_("Visit the Synfig website"));
-
-       set_copyright(_("Copyright 2001-2008\nRobert B. Quattlebaum Jr.,\nAdrian Bentley and Synfig contributors"));
-       Glib::ustring license =
-               "This program 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.\n\n"
-
-               "This program 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.\n\n"
-
-               "You should have received a copy of the GNU General Public License along "
-               "with this program; if not, write to the Free Software Foundation, Inc., "
-               "51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or visit: http://www.gnu.org/";
-       set_license(license);
-#ifdef HAVE_GTK_ABOUTDIALOG_SET_WRAP_LICENSE
-       set_wrap_license(true);
-#endif
-
-       std::vector<Glib::ustring> authors;
-       authors.push_back(_("Original developers:"));
-       authors.push_back("");
-       authors.push_back("Robert B. Quattlebaum Jr (darco)");
-       authors.push_back("Adrian Bentley");
-       authors.push_back("");
-       authors.push_back(_("Contributors:"));
-       authors.push_back("");
-       authors.push_back("Adrian Winchell (SnapSilverlight)");
-       authors.push_back("Andreas Jochens");
-       authors.push_back("Carlos López González (genete)");
-       authors.push_back("Carlos A. Sosa Navarro");
-       authors.push_back("Chris Moore (dooglus)");
-       authors.push_back("Chris Norman (pixelgeek)");
-       authors.push_back("Cyril Brulebois (KiBi)");
-       authors.push_back("Daniel Fort");
-       authors.push_back("Daniel Hornung (rubikcube)");
-       authors.push_back("David Roden (Bombe)");
-       authors.push_back("Dmitriy Pomerantsev (Atrus)");
-       authors.push_back("Douglas Lau");
-       authors.push_back("Gerald Young (Yoyobuae)");
-       authors.push_back("Gerco Ballintijn");
-       authors.push_back("IL'dar AKHmetgaleev (AkhIL)");
-       authors.push_back("Konstantin Dmitriev (zelgadis)");
-       authors.push_back("Luka Pravica");
-       authors.push_back("Martin Michlmayr (tbm)");
-       authors.push_back("Miguel Gea Milvaques (xerakko)");
-       authors.push_back("Paul Wise (pabs)");
-       authors.push_back("Ralf Corsepius");
-       authors.push_back("Ray Frederikson");
-       authors.push_back("Timo Paulssen (timonator)");
-       authors.push_back("Yue Shi Lai");
-       set_authors(authors);
-
-       std::vector<Glib::ustring> artists;
-       artists.push_back("Aurore D (rore)");
-       artists.push_back("Carlos López González (genete)");
-       artists.push_back("Chris Norman (pixelgeek)");
-       artists.push_back("Daniel Hornung (rubikcube)");
-       artists.push_back("David Rylander (rylleman)");
-       artists.push_back("Franco Iacomella (Yaco)");
-       artists.push_back("Gerald Young (Yoyobuae)");
-       artists.push_back("Henrique Lopes Barone");
-       artists.push_back("Robert B. Quattlebaum Jr. (darco)");
-
-       set_artists(artists);
-
-       // TRANSLATORS: change this to your name, separate multiple names with \n
-       set_translator_credits(_("translator-credits"));
-
-       std::string imagepath;
-#ifdef WIN32
-       imagepath=App::get_base_path()+ETL_DIRECTORY_SEPARATOR+IMAGE_DIR;
-#else
-       imagepath=IMAGE_DIR;
-#endif
-       char* synfig_root=getenv("SYNFIG_ROOT");
-       if(synfig_root) {
-               imagepath=synfig_root;
-               imagepath+=ETL_DIRECTORY_SEPARATOR;
-               imagepath+="share";
-               imagepath+=ETL_DIRECTORY_SEPARATOR;
-               imagepath+="pixmaps";
-       }
-       imagepath+=ETL_DIRECTORY_SEPARATOR;
-
-       Gtk::Image *Logo = manage(new class Gtk::Image());
-       Logo->set(imagepath+"synfig_icon."IMAGE_EXT);
-       set_logo(Logo->get_pixbuf());
-
-#ifdef SHOW_EXTRA_INFO
-
-       string extra_info = get_comments() + "\n";
-
-       #ifdef DEVEL_VERSION
-               extra_info += strprintf(_("\nDevelopment version:\n%s\n"),DEVEL_VERSION);
-       #endif
-
-       extra_info += "\n";
-
-       extra_info += strprintf(_("Built on %s" /* at %s */ "\n"), __DATE__ /* , __TIME__ */ );
-
-       extra_info += "\n";
-
-       extra_info += strprintf(_("Built with:\n"), ETL_VERSION);
-       extra_info += strprintf(_("ETL %s\n"), ETL_VERSION);
-       extra_info += strprintf(_("Synfig API %s\n"), stringify(SYNFIG_VERSION));
-       extra_info += strprintf(_("Synfig library %d\n"), SYNFIG_LIBRARY_VERSION);
-       extra_info += strprintf(_("GTK+ %d.%d.%d\n"), GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
-       #ifdef __GNUC__
-               extra_info += strprintf(_("GNU G++ %d.%d.%d\n"),__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__);
-       #endif
-
-       extra_info += "\n";
-
-       extra_info += strprintf(_("Using:\n"), synfig::get_version());
-       extra_info += strprintf(_("Synfig %s\n"), synfig::get_version());
-       extra_info += strprintf(_("GTK+ %d.%d.%d"),gtk_major_version,gtk_minor_version,gtk_micro_version);
-
-       #ifdef _DEBUG
-               extra_info += "\n\nDEBUG BUILD";
-       #endif
-
-       set_comments(extra_info);
-
-#endif
-
-       // Hide the dialog when you click close
-       signal_response().connect(sigc::mem_fun(*this, &About::close));
-}
-
-void About::close(int){
-       hide();
-}
-
-void About::on_link_clicked(Gtk::AboutDialog&, const Glib::ustring &url)
-{
-       App::open_url(url);
-}
diff --git a/synfig-studio/src/gtkmm/about.h b/synfig-studio/src/gtkmm/about.h
deleted file mode 100644 (file)
index f00a773..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file about.h
-**     \brief About dialog class
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2008 Paul Wise
-**
-**     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_GTKMM_ABOUT_H
-#define __SYNFIG_GTKMM_ABOUT_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/aboutdialog.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 About : public Gtk::AboutDialog
-{
-public:
-
-       About();
-       void close(int);
-       void on_link_clicked(Gtk::AboutDialog&, const Glib::ustring &url);
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/adjust_window.cpp b/synfig-studio/src/gtkmm/adjust_window.cpp
deleted file mode 100644 (file)
index 0b62737..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file adjust_window.cpp
-**     \brief Adjustment Window Implementation File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2004 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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "adjust_window.h"
-#include "app.h"
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-//using namespace etl;
-//using namespace synfig;
-
-using studio::Adjust_Window;
-
-/* === M A C R O S ========================================================= */
-const double EPSILON = 1.0e-6;
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-/* === E N T R Y P O I N T ================================================= */
-
-Adjust_Window::Adjust_Window(double value, double lower, double upper,
-                                                       double stepinc, double pageinc, double pagesize,
-                                                       Gtk::Adjustment *adj)
-: Adjustment(value,lower,upper,stepinc,pageinc,pagesize),
-       adj_child(0)
-{
-       if(adj) set_child_adjustment(adj);
-}
-
-Adjust_Window::~Adjust_Window()
-{
-       //connections should automatically be killed etc.
-}
-
-//child interface functions
-Gtk::Adjustment *Adjust_Window::get_child_adjustment()
-{
-       return adj_child;
-}
-
-const Gtk::Adjustment *Adjust_Window::get_child_adjustment() const
-{
-       return adj_child;
-}
-
-void Adjust_Window::set_child_adjustment(Gtk::Adjustment *child)
-{
-       childchanged.disconnect();
-
-       adj_child = child;
-
-       // synfig::info("Adjust: connecting to child signals");
-
-       if(child)
-       {
-               childchanged = child->signal_changed().connect(sigc::mem_fun(*this,&Adjust_Window::update_fromchild));
-
-               update_child();
-       }
-}
-
-void Adjust_Window::on_changed()
-{
-       update_child();
-}
-
-void Adjust_Window::on_value_changed()
-{
-       update_child();
-}
-
-//SUB TIME FUNCTIONS
-double Adjust_Window::get_sub_lower() const
-{
-       return get_value();
-}
-
-double Adjust_Window::get_sub_upper() const
-{
-       return get_value() + get_page_size();
-}
-
-//---- REFRESH FUNCTIONS -----
-void Adjust_Window::update_child()
-{
-       if(adj_child)
-       {
-               bool childchanged = false;
-
-               double v = get_value();
-               double ve = v + get_page_size();
-
-               //reset child's values if they need to be...
-               if(abs(v - adj_child->get_lower()) > EPSILON)
-               {
-                       adj_child->set_lower(v);
-                       childchanged = true;
-               }
-
-               if(abs(ve - adj_child->get_upper()) > EPSILON)
-               {
-                       adj_child->set_upper(ve);
-                       childchanged = true;
-               }
-
-               if(childchanged)
-               {
-                       adj_child->changed();
-               }
-       }
-}
-
-void Adjust_Window::update_fromchild()
-{
-       if(adj_child)
-       {
-               double b = adj_child->get_lower();
-               double dist = adj_child->get_upper() - b;
-
-               //reset our values if they need to be...
-               if(abs(get_value() - b) > EPSILON)
-               {
-                       set_value(b);
-                       value_changed();
-               }
-
-               if(abs(get_page_size() - dist) > EPSILON)
-               {
-                       set_page_size(dist);
-                       changed();
-               }
-       }
-}
diff --git a/synfig-studio/src/gtkmm/adjust_window.h b/synfig-studio/src/gtkmm/adjust_window.h
deleted file mode 100644 (file)
index d1b57c3..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file adjust_window.h
-**     \brief Adjustment Window Header
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2004 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_TEMPLATE_H
-#define __SYNFIG_TEMPLATE_H
-
-/* === H E A D E R S ======================================================= */
-#include <gtkmm/adjustment.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 {
-
-/* Sets up an adjustment that controls/communicates with another adjustment
-       (could be expanded to multiple children)
-
-       The current value and pagesize define the lower and upper bounds of the
-       child adjustment.
-
-       NEED TO REPLACE FUNCTIONALITY IN:
-       refresh_rend_desc
-       refresh_time_window
-       on_time_changed - possibly....
-
-       time_zoom_in - possibly...
-       time_zoom_out - possibly...
-
-       play - possibly...
-
-       THINGS TO CHECK:
-       disp_audio's use of time_adjustment
-       children_tree's use of time_adjustment
-       layer_tree's use of time_adjustment
-*/
-class Adjust_Window : public Gtk::Adjustment
-{
-       Gtk::Adjustment *adj_child;
-
-       sigc::connection childchanged; //we only care about the non-value parts of the child
-
-       virtual void on_changed(); //value+pagesize corresponds to child upper
-       virtual void on_value_changed(); //value corresponds to child lower
-
-protected: //update interface
-       virtual void update_child();
-       virtual void update_fromchild();
-
-public: //structors
-       Adjust_Window(double value, double lower, double upper,
-                                       double step_increment=1, double page_increment=10, double page_size=0,
-                                       Gtk::Adjustment *adj = 0);
-
-       virtual ~Adjust_Window();
-
-public: //child interface
-       Gtk::Adjustment *get_child_adjustment();
-       const Gtk::Adjustment *get_child_adjustment() const;
-       void set_child_adjustment(Gtk::Adjustment *child);
-
-public: //Sub value interface
-       double get_sub_lower() const;
-       double get_sub_upper() const;
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/app.cpp b/synfig-studio/src/gtkmm/app.cpp
deleted file mode 100644 (file)
index 01a4f8f..0000000
+++ /dev/null
@@ -1,2515 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file app.cpp
-**     \brief writeme
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 2008 Chris Moore
-**     Copyright (c) 2008 Gerald Young
-**  Copyright (c) 2008 Carlos López
-**     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 <config.h>
-#endif
-
-#ifdef WIN32
-#define WINVER 0x0500
-#include <windows.h>
-#endif
-
-#include <fstream>
-#include <iostream>
-#include <locale>
-#include <cstring>
-
-#ifdef HAVE_SYS_ERRNO_H
-#include <sys/errno.h>
-#endif
-#include <gtkmm/fileselection.h>
-#include <gtkmm/dialog.h>
-#include <gtkmm/messagedialog.h>
-#include <gtkmm/label.h>
-#include <gtkmm/stock.h>
-#include <gtkmm/stockitem.h>
-#include <gtkmm/iconsource.h>
-#include <gtkmm/inputdialog.h>
-#include <gtkmm/accelmap.h>
-#include <gtkmm/uimanager.h>
-#include <gtkmm/textview.h>
-
-#include <gtk/gtk.h>
-
-#include <gdkmm/general.h>
-
-#include <synfig/loadcanvas.h>
-#include <synfig/savecanvas.h>
-
-#include "app.h"
-#include "about.h"
-#include "splash.h"
-#include "instance.h"
-#include "canvasview.h"
-#include "dialog_setup.h"
-#include "dialog_gradient.h"
-#include "dialog_color.h"
-#include "toolbox.h"
-#include "onemoment.h"
-
-#include "dockmanager.h"
-
-#include "state_eyedrop.h"
-#include "state_normal.h"
-#include "state_draw.h"
-#include "state_fill.h"
-#include "state_bline.h"
-#include "state_polygon.h"
-#include "state_sketch.h"
-#include "state_gradient.h"
-#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"
-#include "dialog_tooloptions.h"
-#include "widget_enum.h"
-
-#include "autorecover.h"
-
-#include <synfigapp/settings.h>
-#include "dock_history.h"
-#include "dock_canvases.h"
-#include "dock_keyframes.h"
-#include "dock_layers.h"
-#include "dock_params.h"
-#include "dock_metadata.h"
-#include "dock_children.h"
-#include "dock_info.h"
-#include "dock_navigator.h"
-#include "dock_layergroups.h"
-#include "dock_timetrack.h"
-#include "dock_curves.h"
-
-#include "mod_palette/mod_palette.h"
-#include "mod_mirror/mod_mirror.h"
-
-#include <sys/stat.h>
-
-#include "ipc.h"
-
-#include "module.h"
-
-#include "statemanager.h"
-
-#ifdef WITH_FMOD
-#include <fmod.h>
-#endif
-
-#include <gtkmm/accelmap.h>
-#include <gtkmm/filechooser.h>
-#include <gtkmm/filechooserdialog.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 ========================================================= */
-
-#ifndef SYNFIG_USER_APP_DIR
-#ifdef __APPLE__
-#define SYNFIG_USER_APP_DIR    "Library/Synfig"
-#elif defined(_WIN32)
-#define SYNFIG_USER_APP_DIR    "Synfig"
-#else
-#define SYNFIG_USER_APP_DIR    ".synfig"
-#endif
-#endif
-
-#ifndef DPM2DPI
-#define DPM2DPI(x)     (float(x)/39.3700787402f)
-#define DPI2DPM(x)     (float(x)*39.3700787402f)
-#endif
-
-#ifdef WIN32
-#      ifdef IMAGE_DIR
-#              undef IMAGE_DIR
-#              define IMAGE_DIR "share\\pixmaps"
-#      endif
-#endif
-
-#ifndef IMAGE_DIR
-#      define IMAGE_DIR "/usr/local/share/pixmaps"
-#endif
-
-#ifndef IMAGE_EXT
-#      define IMAGE_EXT        "tif"
-#endif
-
-#include <synfigapp/main.h>
-
-/* === S I G N A L S ======================================================= */
-
-static sigc::signal<void> signal_present_all_;
-sigc::signal<void>&
-App::signal_present_all() { return signal_present_all_; }
-
-static sigc::signal<void> signal_recent_files_changed_;
-sigc::signal<void>&
-App::signal_recent_files_changed() { return signal_recent_files_changed_; }
-
-static sigc::signal<void,etl::loose_handle<CanvasView> > signal_canvas_view_focus_;
-sigc::signal<void,etl::loose_handle<CanvasView> >&
-App::signal_canvas_view_focus() { return signal_canvas_view_focus_; }
-
-static sigc::signal<void,etl::handle<Instance> > signal_instance_selected_;
-sigc::signal<void,etl::handle<Instance> >&
-App::signal_instance_selected() { return signal_instance_selected_; }
-
-static sigc::signal<void,etl::handle<Instance> > signal_instance_created_;
-sigc::signal<void,etl::handle<Instance> >&
-App::signal_instance_created() { return signal_instance_created_; }
-
-static sigc::signal<void,etl::handle<Instance> > signal_instance_deleted_;
-sigc::signal<void,etl::handle<Instance> >&
-App::signal_instance_deleted() { return signal_instance_deleted_; }
-
-/* === G L O B A L S ======================================================= */
-
-static std::list<std::string> recent_files;
-const std::list<std::string>& App::get_recent_files() { return recent_files; }
-
-static std::list<std::string> recent_files_window_size;
-
-int    App::Busy::count;
-bool App::shutdown_in_progress;
-
-synfig::Gamma App::gamma;
-
-Glib::RefPtr<studio::UIManager>        App::ui_manager_;
-
-synfig::Distance::System App::distance_system;
-
-studio::Dialog_Setup* App::dialog_setup;
-
-etl::handle< studio::ModPalette > mod_palette_;
-//studio::Dialog_Palette* App::dialog_palette;
-
-std::list<etl::handle<Instance> > App::instance_list;
-
-static etl::handle<synfigapp::UIInterface> ui_interface_;
-const etl::handle<synfigapp::UIInterface>& App::get_ui_interface() { return ui_interface_; }
-
-etl::handle<Instance> App::selected_instance;
-etl::handle<CanvasView> App::selected_canvas_view;
-
-studio::About *studio::App::about=NULL;
-
-studio::Toolbox *studio::App::toolbox=NULL;
-
-studio::AutoRecover *studio::App::auto_recover=NULL;
-
-studio::IPC *ipc=NULL;
-
-studio::DockManager* studio::App::dock_manager=0;
-
-studio::DeviceTracker* studio::App::device_tracker=0;
-
-studio::Dialog_Gradient* studio::App::dialog_gradient;
-
-studio::Dialog_Color* studio::App::dialog_color;
-
-Gtk::InputDialog* studio::App::dialog_input;
-
-studio::Dialog_ToolOptions* studio::App::dialog_tool_options;
-
-studio::Dock_History* dock_history;
-studio::Dock_Canvases* dock_canvases;
-studio::Dock_Keyframes* dock_keyframes;
-studio::Dock_Layers* dock_layers;
-studio::Dock_Params* dock_params;
-studio::Dock_MetaData* dock_meta_data;
-studio::Dock_Children* dock_children;
-studio::Dock_Info* dock_info;
-studio::Dock_LayerGroups* dock_layer_groups;
-studio::Dock_Navigator* dock_navigator;
-studio::Dock_Timetrack* dock_timetrack;
-studio::Dock_Curves* dock_curves;
-
-std::list< etl::handle< studio::Module > > module_list_;
-
-bool studio::App::use_colorspace_gamma=true;
-#ifdef SINGLE_THREADED
-bool studio::App::single_threaded=false;
-#endif
-bool studio::App::restrict_radius_ducks=false;
-bool studio::App::resize_imported_images=false;
-String studio::App::custom_filename_prefix(DEFAULT_FILENAME_PREFIX);
-int studio::App::preferred_x_size=480;
-int studio::App::preferred_y_size=270;
-String studio::App::predefined_size(DEFAULT_PREDEFINED_SIZE);
-String studio::App::predefined_fps(DEFAULT_PREDEFINED_FPS);
-float studio::App::preferred_fps=24.0;
-#ifdef USE_OPEN_FOR_URLS
-String studio::App::browser_command("open"); // MacOS only
-#else
-String studio::App::browser_command("xdg-open"); // Linux XDG standard
-#endif
-
-static int max_recent_files_=25;
-int studio::App::get_max_recent_files() { return max_recent_files_; }
-void studio::App::set_max_recent_files(int x) { max_recent_files_=x; }
-
-static synfig::String app_base_path_;
-
-namespace studio {
-
-bool
-really_delete_widget(Gtk::Widget *widget)
-{
-       // synfig::info("really delete %p", (void*)widget);
-       delete widget;
-       return false;
-}
-
-// nasty workaround - when we've finished with a popup menu, we want to delete it
-// attaching to the signal_hide() signal gets us here before the action on the menu has run,
-// so schedule the real delete to happen in 50ms, giving the action a chance to run
-void
-delete_widget(Gtk::Widget *widget)
-{
-       // synfig::info("delete %p", (void*)widget);
-       Glib::signal_timeout().connect(sigc::bind(sigc::ptr_fun(&really_delete_widget), widget), 50);
-}
-
-}; // END of namespace studio
-studio::StateManager* state_manager;
-
-
-
-
-class GlobalUIInterface : public synfigapp::UIInterface
-{
-public:
-
-       virtual Response confirmation(const std::string &title,
-                       const std::string &primaryText,
-                       const std::string &secondaryText,
-                       const std::string &confirmPhrase,
-                       const std::string &cancelPhrase,
-                       Response defaultResponse)
-       {
-               Gtk::MessageDialog dialog(
-                       primaryText,            // Message
-                       false,                  // Markup
-                       Gtk::MESSAGE_WARNING,   // Type
-                       Gtk::BUTTONS_NONE,      // Buttons
-                       true                    // Modal
-               );
-
-               if (! title.empty())
-                       dialog.set_title(title);
-               if (! secondaryText.empty())
-                       dialog.set_secondary_text(secondaryText);
-
-               dialog.add_button(cancelPhrase, RESPONSE_CANCEL);
-               dialog.add_button(confirmPhrase, RESPONSE_OK);
-               dialog.set_default_response(defaultResponse);
-
-               dialog.show_all();
-               return (Response) dialog.run();
-       }
-
-       virtual Response yes_no(const std::string &title, const std::string &message,Response dflt=RESPONSE_YES)
-       {
-               Gtk::Dialog dialog(
-                       title,          // Title
-                       true,           // Modal
-                       true            // use_separator
-               );
-               Gtk::Label label(message);
-               label.show();
-
-               dialog.get_vbox()->pack_start(label);
-               dialog.add_button(Gtk::StockID("gtk-yes"),RESPONSE_YES);
-               dialog.add_button(Gtk::StockID("gtk-no"),RESPONSE_NO);
-
-               dialog.set_default_response(dflt);
-               dialog.show();
-               return (Response)dialog.run();
-       }
-       virtual Response yes_no_cancel(const std::string &title, const std::string &message,Response dflt=RESPONSE_YES)
-       {
-               Gtk::Dialog dialog(
-                       title,          // Title
-                       true,           // Modal
-                       true            // use_separator
-               );
-               Gtk::Label label(message);
-               label.show();
-
-               dialog.get_vbox()->pack_start(label);
-               dialog.add_button(Gtk::StockID("gtk-yes"),RESPONSE_YES);
-               dialog.add_button(Gtk::StockID("gtk-no"),RESPONSE_NO);
-               dialog.add_button(Gtk::StockID("gtk-cancel"),RESPONSE_CANCEL);
-
-               dialog.set_default_response(dflt);
-               dialog.show();
-               return (Response)dialog.run();
-       }
-       virtual Response ok_cancel(const std::string &title, const std::string &message,Response dflt=RESPONSE_OK)
-       {
-               Gtk::Dialog dialog(
-                       title,          // Title
-                       true,           // Modal
-                       true            // use_separator
-               );
-               Gtk::Label label(message);
-               label.show();
-
-               dialog.get_vbox()->pack_start(label);
-               dialog.add_button(Gtk::StockID("gtk-ok"),RESPONSE_OK);
-               dialog.add_button(Gtk::StockID("gtk-cancel"),RESPONSE_CANCEL);
-
-               dialog.set_default_response(dflt);
-               dialog.show();
-               return (Response)dialog.run();
-       }
-
-       virtual bool
-       task(const std::string &task)
-       {
-               std::cerr<<task<<std::endl;
-               while(studio::App::events_pending())studio::App::iteration(false);
-               return true;
-       }
-
-       virtual bool
-       error(const std::string &err)
-       {
-               Gtk::MessageDialog dialog(err, false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE, true);
-               dialog.show();
-               dialog.run();
-               return true;
-       }
-
-       virtual bool
-       warning(const std::string &err)
-       {
-               std::cerr<<"warning: "<<err<<std::endl;
-               while(studio::App::events_pending())studio::App::iteration(false);
-               return true;
-       }
-
-       virtual bool
-       amount_complete(int /*current*/, int /*total*/)
-       {
-               while(studio::App::events_pending())studio::App::iteration(false);
-               return true;
-       }
-};
-
-/* === P R O C E D U R E S ================================================= */
-
-/*
-void
-studio::UIManager::insert_action_group (const Glib::RefPtr<Gtk::ActionGroup>& action_group, int pos)
-{
-       action_group_list.push_back(action_group);
-       Gtk::UIManager::insert_action_group(action_group, pos);
-}
-
-void
-studio::UIManager::remove_action_group (const Glib::RefPtr<Gtk::ActionGroup>& action_group)
-{
-       std::list<Glib::RefPtr<Gtk::ActionGroup> >::iterator iter;
-       for(iter=action_group_list.begin();iter!=action_group_list.end();++iter)
-               if(*iter==action_group)
-               {
-                       action_group_list.erase(iter);
-                       Gtk::UIManager::remove_action_group(action_group);
-                       return;
-               }
-       synfig::error("Unable to find action group");
-}
-
-void
-studio::add_action_group_to_top(Glib::RefPtr<studio::UIManager> ui_manager, Glib::RefPtr<Gtk::ActionGroup> group)
-{
-       ui_manager->insert_action_group(group,0);
-       return;
-       std::list<Glib::RefPtr<Gtk::ActionGroup> > prev_groups(ui_manager->get_action_groups());
-       std::list<Glib::RefPtr<Gtk::ActionGroup> >::reverse_iterator iter;
-
-       for(iter=prev_groups.rbegin();iter!=prev_groups.rend();++iter)
-       {
-               if(*iter && (*iter)->get_name()!="menus")
-               {
-                       synfig::info("Removing action group "+(*iter)->get_name());
-                       ui_manager->remove_action_group(*iter);
-               }
-       }
-       ui_manager->insert_action_group(group,0);
-
-       for(;!prev_groups.empty();prev_groups.pop_front())
-       {
-               if(prev_groups.front() && prev_groups.front()!=group && prev_groups.front()->get_name()!="menus")
-                       ui_manager->insert_action_group(prev_groups.front(),1);
-       }
-}
-*/
-class Preferences : public synfigapp::Settings
-{
-public:
-       virtual bool get_value(const synfig::String& key, synfig::String& value)const
-       {
-               if(key=="gamma")
-               {
-                       value=strprintf("%f %f %f %f",
-                               App::gamma.get_gamma_r(),
-                               App::gamma.get_gamma_g(),
-                               App::gamma.get_gamma_b(),
-                               App::gamma.get_black_level()
-                       );
-                       return true;
-               }
-               if(key=="time_format")
-               {
-                       value=strprintf("%i",App::get_time_format());
-                       return true;
-               }
-               if(key=="file_history.size")
-               {
-                       value=strprintf("%i",App::get_max_recent_files());
-                       return true;
-               }
-               if(key=="use_colorspace_gamma")
-               {
-                       value=strprintf("%i",(int)App::use_colorspace_gamma);
-                       return true;
-               }
-               if(key=="distance_system")
-               {
-                       value=strprintf("%s",Distance::system_name(App::distance_system).c_str());
-                       return true;
-               }
-#ifdef SINGLE_THREADED
-               if(key=="single_threaded")
-               {
-                       value=strprintf("%i",(int)App::single_threaded);
-                       return true;
-               }
-#endif
-               if(key=="auto_recover_backup_interval")
-               {
-                       value=strprintf("%i",App::auto_recover->get_timeout());
-                       return true;
-               }
-               if(key=="restrict_radius_ducks")
-               {
-                       value=strprintf("%i",(int)App::restrict_radius_ducks);
-                       return true;
-               }
-               if(key=="resize_imported_images")
-               {
-                       value=strprintf("%i",(int)App::resize_imported_images);
-                       return true;
-               }
-               if(key=="browser_command")
-               {
-                       value=App::browser_command;
-                       return true;
-               }
-               if(key=="custom_filename_prefix")
-               {
-                       value=App::custom_filename_prefix;
-                       return true;
-               }
-               if(key=="preferred_x_size")
-               {
-                       value=strprintf("%i",App::preferred_x_size);
-                       return true;
-               }
-               if(key=="preferred_y_size")
-               {
-                       value=strprintf("%i",App::preferred_y_size);
-                       return true;
-               }
-               if(key=="predefined_size")
-               {
-                       value=strprintf("%s",App::predefined_size.c_str());
-                       return true;
-               }
-               if(key=="preferred_fps")
-               {
-                       value=strprintf("%f",App::preferred_fps);
-                       return true;
-               }
-               if(key=="predefined_fps")
-               {
-                       value=strprintf("%s",App::predefined_fps.c_str());
-                       return true;
-               }
-
-               return synfigapp::Settings::get_value(key,value);
-       }
-
-       virtual bool set_value(const synfig::String& key,const synfig::String& value)
-       {
-               if(key=="gamma")
-               {
-                       float r,g,b,blk;
-
-                       strscanf(value,"%f %f %f %f",
-                               &r,
-                               &g,
-                               &b,
-                               &blk
-                       );
-
-                       App::gamma.set_all(r,g,b,blk);
-
-                       return true;
-               }
-               if(key=="time_format")
-               {
-                       int i(atoi(value.c_str()));
-                       App::set_time_format(static_cast<synfig::Time::Format>(i));
-                       return true;
-               }
-               if(key=="auto_recover_backup_interval")
-               {
-                       int i(atoi(value.c_str()));
-                       App::auto_recover->set_timeout(i);
-                       return true;
-               }
-               if(key=="file_history.size")
-               {
-                       int i(atoi(value.c_str()));
-                       App::set_max_recent_files(i);
-                       return true;
-               }
-               if(key=="use_colorspace_gamma")
-               {
-                       int i(atoi(value.c_str()));
-                       App::use_colorspace_gamma=i;
-                       return true;
-               }
-               if(key=="distance_system")
-               {
-                       App::distance_system=Distance::ident_system(value);;
-                       return true;
-               }
-#ifdef SINGLE_THREADED
-               if(key=="single_threaded")
-               {
-                       int i(atoi(value.c_str()));
-                       App::single_threaded=i;
-                       return true;
-               }
-#endif
-               if(key=="restrict_radius_ducks")
-               {
-                       int i(atoi(value.c_str()));
-                       App::restrict_radius_ducks=i;
-                       return true;
-               }
-               if(key=="resize_imported_images")
-               {
-                       int i(atoi(value.c_str()));
-                       App::resize_imported_images=i;
-                       return true;
-               }
-               if(key=="browser_command")
-               {
-                       App::browser_command=value;
-                       return true;
-               }
-               if(key=="custom_filename_prefix")
-               {
-                       App::custom_filename_prefix=value;
-                       return true;
-               }
-               if(key=="preferred_x_size")
-               {
-                       int i(atoi(value.c_str()));
-                       App::preferred_x_size=i;
-                       return true;
-               }
-               if(key=="preferred_y_size")
-               {
-                       int i(atoi(value.c_str()));
-                       App::preferred_y_size=i;
-                       return true;
-               }
-               if(key=="predefined_size")
-               {
-                       App::predefined_size=value;
-                       return true;
-               }
-               if(key=="preferred_fps")
-               {
-                       float i(atof(value.c_str()));
-                       App::preferred_fps=i;
-                       return true;
-               }
-               if(key=="predefined_fps")
-               {
-                       App::predefined_fps=value;
-                       return true;
-               }
-
-               return synfigapp::Settings::set_value(key,value);
-       }
-
-       virtual KeyList get_key_list()const
-       {
-               KeyList ret(synfigapp::Settings::get_key_list());
-               ret.push_back("gamma");
-               ret.push_back("time_format");
-               ret.push_back("distance_system");
-               ret.push_back("file_history.size");
-               ret.push_back("use_colorspace_gamma");
-#ifdef SINGLE_THREADED
-               ret.push_back("single_threaded");
-#endif
-               ret.push_back("auto_recover_backup_interval");
-               ret.push_back("restrict_radius_ducks");
-               ret.push_back("resize_imported_images");
-               ret.push_back("browser_command");
-               ret.push_back("custom_filename_prefix");
-               ret.push_back("preferred_x_size");
-               ret.push_back("preferred_y_size");
-               ret.push_back("predefined_size");
-               ret.push_back("preferred_fps");
-               ret.push_back("predefined_fps");
-               return ret;
-       }
-};
-
-static ::Preferences _preferences;
-
-void
-init_ui_manager()
-{
-       Glib::RefPtr<Gtk::ActionGroup> menus_action_group = Gtk::ActionGroup::create("menus");
-
-       Glib::RefPtr<Gtk::ActionGroup> toolbox_action_group = Gtk::ActionGroup::create("toolbox");
-
-       Glib::RefPtr<Gtk::ActionGroup> actions_action_group = Gtk::ActionGroup::create("actions");
-
-       menus_action_group->add( Gtk::Action::create("menu-file", _("_File")) );
-       menus_action_group->add( Gtk::Action::create("menu-edit", _("_Edit")) );
-       menus_action_group->add( Gtk::Action::create("menu-view", _("_View")) );
-       menus_action_group->add( Gtk::Action::create("menu-canvas", _("_Canvas")) );
-       menus_action_group->add( Gtk::Action::create("menu-layer", _("_Layer")) );
-       menus_action_group->add( Gtk::Action::create("menu-duck-mask", _("Show/Hide Ducks")) );
-       menus_action_group->add( Gtk::Action::create("menu-preview-quality", _("Preview Quality")) );
-       menus_action_group->add( Gtk::Action::create("menu-lowres-pixel", _("Low-Res Pixel Size")) );
-       menus_action_group->add( Gtk::Action::create("menu-layer-new", _("New Layer")) );
-       menus_action_group->add( Gtk::Action::create("menu-keyframe", _("Keyframe")) );
-       menus_action_group->add( Gtk::Action::create("menu-group", _("Group")) );
-       menus_action_group->add( Gtk::Action::create("menu-state", _("Tool")) );
-       menus_action_group->add( Gtk::Action::create("menu-toolbox", _("Toolbox")) );
-
-       // Add the synfigapp actions...
-       synfigapp::Action::Book::iterator iter;
-       for(iter=synfigapp::Action::book().begin();iter!=synfigapp::Action::book().end();++iter)
-       {
-               actions_action_group->add(Gtk::Action::create(
-                       "action-"+iter->second.name,
-                       get_action_stock_id(iter->second),
-                       iter->second.local_name,iter->second.local_name
-               ));
-       }
-
-#define DEFINE_ACTION(x,stock) { Glib::RefPtr<Gtk::Action> action( Gtk::Action::create(x, stock) ); actions_action_group->add(action); }
-#define DEFINE_ACTION2(x,stock,label) { Glib::RefPtr<Gtk::Action> action( Gtk::Action::create(x, stock,label,label) ); actions_action_group->add(action); }
-#define DEFINE_ACTION_SIG(group,x,stock,sig) { Glib::RefPtr<Gtk::Action> action( Gtk::Action::create(x, stock) ); group->add(action,sig); }
-
-       DEFINE_ACTION2("keyframe-properties", Gtk::StockID("gtk-properties"), _("Keyframe Properties"));
-       DEFINE_ACTION("about", Gtk::StockID("synfig-about"));
-       DEFINE_ACTION("new", Gtk::Stock::NEW);
-       DEFINE_ACTION("open", Gtk::Stock::OPEN);
-       DEFINE_ACTION("save", Gtk::Stock::SAVE);
-       DEFINE_ACTION("save-as", Gtk::Stock::SAVE_AS);
-       DEFINE_ACTION("revert", Gtk::Stock::REVERT_TO_SAVED);
-       DEFINE_ACTION("cvs-add", Gtk::StockID("synfig-cvs_add"));
-       DEFINE_ACTION("cvs-update", Gtk::StockID("synfig-cvs_update"));
-       DEFINE_ACTION("cvs-commit", Gtk::StockID("synfig-cvs_commit"));
-       DEFINE_ACTION("cvs-revert", Gtk::StockID("synfig-cvs_revert"));
-       DEFINE_ACTION("import", _("Import"));
-       DEFINE_ACTION("render", _("Render"));
-       DEFINE_ACTION("preview", _("Preview"));
-       DEFINE_ACTION("dialog-flipbook", _("Preview Dialog"));
-       DEFINE_ACTION("sound", _("Sound File"));
-       DEFINE_ACTION("options", _("Options"));
-       DEFINE_ACTION("close", _("Close View"));
-       DEFINE_ACTION("close-document", _("Close Document"));
-       DEFINE_ACTION("quit", Gtk::Stock::QUIT);
-
-
-       DEFINE_ACTION("undo", Gtk::StockID("gtk-undo"));
-       DEFINE_ACTION("redo", Gtk::StockID("gtk-redo"));
-       DEFINE_ACTION("cut", Gtk::StockID("gtk-cut"));
-       DEFINE_ACTION("copy", Gtk::StockID("gtk-copy"));
-       DEFINE_ACTION("paste", Gtk::StockID("gtk-paste"));
-       DEFINE_ACTION("select-all-ducks", _("Select All Ducks"));
-       DEFINE_ACTION("unselect-all-ducks", _("Unselect All Ducks"));
-       DEFINE_ACTION("select-all-layers", _("Select All Layers"));
-       DEFINE_ACTION("unselect-all-layers", _("Unselect All Layers"));
-       DEFINE_ACTION("properties", _("Properties"));
-
-       DEFINE_ACTION("mask-position-ducks", _("Show Position Ducks"));
-       DEFINE_ACTION("mask-vertex-ducks", _("Show Vertex Ducks"));
-       DEFINE_ACTION("mask-tangent-ducks", _("Show Tangent Ducks"));
-       DEFINE_ACTION("mask-radius-ducks", _("Show Radius Ducks"));
-       DEFINE_ACTION("mask-width-ducks", _("Show Width Ducks"));
-       DEFINE_ACTION("mask-angle-ducks", _("Show Angle Ducks"));
-       DEFINE_ACTION("quality-00", _("Use Parametric Renderer"));
-       DEFINE_ACTION("quality-01", _("Use Quality Level 1"));
-       DEFINE_ACTION("quality-02", _("Use Quality Level 2"));
-       DEFINE_ACTION("quality-03", _("Use Quality Level 3"));
-       DEFINE_ACTION("quality-04", _("Use Quality Level 4"));
-       DEFINE_ACTION("quality-05", _("Use Quality Level 5"));
-       DEFINE_ACTION("quality-06", _("Use Quality Level 6"));
-       DEFINE_ACTION("quality-07", _("Use Quality Level 7"));
-       DEFINE_ACTION("quality-08", _("Use Quality Level 8"));
-       DEFINE_ACTION("quality-09", _("Use Quality Level 9"));
-       DEFINE_ACTION("quality-10", _("Use Quality Level 10"));
-       for(list<int>::iterator iter = CanvasView::get_pixel_sizes().begin(); iter != CanvasView::get_pixel_sizes().end(); iter++)
-               DEFINE_ACTION(strprintf("lowres-pixel-%d", *iter), strprintf(_("Set Low-Res pixel size to %d"), *iter));
-       DEFINE_ACTION("play", _("Play"));
-       // DEFINE_ACTION("pause", _("Pause"));
-       DEFINE_ACTION("stop", _("Stop"));
-       DEFINE_ACTION("toggle-grid-show", _("Toggle Grid Show"));
-       DEFINE_ACTION("toggle-grid-snap", _("Toggle Grid Snap"));
-       DEFINE_ACTION("toggle-guide-show", _("Toggle Guide Show"));
-       DEFINE_ACTION("toggle-low-res", _("Toggle Low-Res"));
-       DEFINE_ACTION("decrease-low-res-pixel-size", _("Decrease Low-Res Pixel Size"));
-       DEFINE_ACTION("increase-low-res-pixel-size", _("Increase Low-Res Pixel Size"));
-       DEFINE_ACTION("toggle-onion-skin", _("Toggle Onion Skin"));
-       DEFINE_ACTION("canvas-zoom-in", Gtk::StockID("gtk-zoom-in"));
-       DEFINE_ACTION("canvas-zoom-out", Gtk::StockID("gtk-zoom-out"));
-       DEFINE_ACTION("canvas-zoom-fit", Gtk::StockID("gtk-zoom-fit"));
-       DEFINE_ACTION("canvas-zoom-100", Gtk::StockID("gtk-zoom-100"));
-       DEFINE_ACTION("time-zoom-in", Gtk::StockID("gtk-zoom-in"));
-       DEFINE_ACTION("time-zoom-out", Gtk::StockID("gtk-zoom-out"));
-       DEFINE_ACTION("jump-next-keyframe", _("Jump to Next Keyframe"));
-       DEFINE_ACTION("jump-prev-keyframe", _("Jump to Prev Keyframe"));
-       DEFINE_ACTION("seek-next-frame", _("Next Frame"));
-       DEFINE_ACTION("seek-prev-frame", _("Prev Frame"));
-       DEFINE_ACTION("seek-next-second", _("Seek Forward"));
-       DEFINE_ACTION("seek-prev-second", _("Seek Backward"));
-       DEFINE_ACTION("seek-begin", _("Seek to Begin"));
-       DEFINE_ACTION("seek-end", _("Seek to End"));
-
-       DEFINE_ACTION("action-group_add", _("Add group"));
-
-       DEFINE_ACTION("canvas-new", _("New Canvas"));
-
-       DEFINE_ACTION("amount-inc", _("Increase Amount"));
-       DEFINE_ACTION("amount-dec", _("Decrease Amount"));
-
-#undef DEFINE_ACTION
-#undef DEFINE_ACTION_2
-#undef DEFINE_ACTION_SIG
-
-    Glib::ustring ui_info =
-"<ui>"
-"      <popup name='menu-toolbox' action='menu-toolbox'>"
-"      <menu action='menu-file'>"
-"      </menu>"
-"      </popup>"
-"      <popup name='menu-main' action='menu-main'>"
-"      <menu action='menu-file'>"
-"              <menuitem action='new' />"
-"              <menuitem action='open' />"
-"              <menuitem action='save' />"
-"              <menuitem action='save-as' />"
-"              <menuitem action='revert' />"
-"              <separator name='bleh01'/>"
-"              <menuitem action='cvs-add' />"
-"              <menuitem action='cvs-update' />"
-"              <menuitem action='cvs-commit' />"
-"              <menuitem action='cvs-revert' />"
-"              <separator name='bleh02'/>"
-"              <menuitem action='import' />"
-"              <separator name='bleh03'/>"
-"              <menuitem action='render' />"
-"              <menuitem action='preview' />"
-"              <menuitem action='sound' />"
-"              <separator name='bleh04'/>"
-"              <menuitem action='options' />"
-"              <menuitem action='close' />"
-"              <menuitem action='close-document' />"
-"              <menuitem action='quit' />"
-"      </menu>"
-"      <menu action='menu-edit'>"
-"              <menuitem action='undo'/>"
-"              <menuitem action='redo'/>"
-"              <separator name='bleh05'/>"
-"              <menuitem action='cut'/>"
-"              <menuitem action='copy'/>"
-"              <menuitem action='paste'/>"
-"              <separator name='bleh06'/>"
-"              <menuitem action='select-all-layers'/>"
-"              <menuitem action='unselect-all-layers'/>"
-"              <menuitem action='select-all-ducks'/>"
-"              <menuitem action='unselect-all-ducks'/>"
-"              <separator name='bleh07'/>"
-"              <menuitem action='properties'/>"
-"      </menu>"
-"      <menu action='menu-view'>"
-"              <menu action='menu-duck-mask'>"
-"                      <menuitem action='mask-position-ducks' />"
-"                      <menuitem action='mask-vertex-ducks' />"
-"                      <menuitem action='mask-tangent-ducks' />"
-"                      <menuitem action='mask-radius-ducks' />"
-"                      <menuitem action='mask-width-ducks' />"
-"                      <menuitem action='mask-angle-ducks' />"
-"              </menu>"
-"              <menu action='menu-preview-quality'>"
-"                      <menuitem action='quality-00' />"
-"                      <menuitem action='quality-01' />"
-"                      <menuitem action='quality-02' />"
-"                      <menuitem action='quality-03' />"
-"                      <menuitem action='quality-04' />"
-"                      <menuitem action='quality-05' />"
-"                      <menuitem action='quality-06' />"
-"                      <menuitem action='quality-07' />"
-"                      <menuitem action='quality-08' />"
-"                      <menuitem action='quality-09' />"
-"                      <menuitem action='quality-10' />"
-"              </menu>"
-"              <menu action='menu-lowres-pixel'>"
-"              <menuitem action='decrease-low-res-pixel-size'/>"
-"              <menuitem action='increase-low-res-pixel-size'/>"
-"              <separator name='pixel-size-separator'/>"
-;
-
-       for(list<int>::iterator iter = CanvasView::get_pixel_sizes().begin(); iter != CanvasView::get_pixel_sizes().end(); iter++)
-               ui_info += strprintf("                  <menuitem action='lowres-pixel-%d' />", *iter);
-
-       ui_info +=
-"              </menu>"
-"              <separator name='bleh08'/>"
-"              <menuitem action='play'/>"
-//"            <menuitem action='pause'/>"
-"              <menuitem action='stop'/>"
-"              <menuitem action='dialog-flipbook'/>"
-"              <separator name='bleh09'/>"
-"              <menuitem action='toggle-grid-show'/>"
-"              <menuitem action='toggle-grid-snap'/>"
-"              <menuitem action='toggle-guide-show'/>"
-"              <menuitem action='toggle-low-res'/>"
-"              <menuitem action='toggle-onion-skin'/>"
-"              <separator name='bleh10'/>"
-"              <menuitem action='canvas-zoom-in'/>"
-"              <menuitem action='canvas-zoom-out'/>"
-"              <menuitem action='canvas-zoom-fit'/>"
-"              <menuitem action='canvas-zoom-100'/>"
-"              <separator name='bleh11'/>"
-"              <menuitem action='time-zoom-in'/>"
-"              <menuitem action='time-zoom-out'/>"
-"              <separator name='bleh12'/>"
-"              <menuitem action='jump-next-keyframe'/>"
-"              <menuitem action='jump-prev-keyframe'/>"
-"              <menuitem action='seek-next-frame'/>"
-"              <menuitem action='seek-prev-frame'/>"
-"              <menuitem action='seek-next-second'/>"
-"              <menuitem action='seek-prev-second'/>"
-"              <menuitem action='seek-begin'/>"
-"              <menuitem action='seek-end'/>"
-"      </menu>"
-"      <menu action='menu-canvas'>"
-"              <menuitem action='canvas-new'/>"
-"      </menu>"
-"      <menu name='menu-state' action='menu-state'>"
-"      </menu>"
-"      <menu action='menu-group'>"
-"              <menuitem action='action-group_add'/>"
-"      </menu>"
-"      <menu action='menu-layer'>"
-//"            <menuitem action='cut'/>"
-//"            <menuitem action='copy'/>"
-//"            <menuitem action='paste'/>"
-//"            <separator name='bleh06'/>"
-"              <menu action='menu-layer-new'></menu>"
-"              <menuitem action='amount-inc'/>"
-"              <menuitem action='amount-dec'/>"
-"      </menu>"
-"      <menu action='menu-keyframe'>"
-"              <menuitem action='keyframe-properties'/>"
-"      </menu>"
-"      </popup>"
-
-"</ui>"
-;
-/*             "<ui>"
-        "  <menubar name='MenuBar'>"
-        "    <menu action='MenuFile'>"
-        "      <menuitem action='New'/>"
-        "      <menuitem action='Open'/>"
-        "      <separator/>"
-        "      <menuitem action='Quit'/>"
-        "    </menu>"
-        "    <menu action='MenuEdit'>"
-        "      <menuitem action='Cut'/>"
-        "      <menuitem action='Copy'/>"
-        "      <menuitem action='Paste'/>"
-        "    </menu>"
-        "  </menubar>"
-        "  <toolbar  name='ToolBar'>"
-        "    <toolitem action='Open'/>"
-        "    <toolitem action='Quit'/>"
-        "  </toolbar>"
-        "</ui>";
-*/
-       try
-       {
-               actions_action_group->set_sensitive(false);
-               App::ui_manager()->set_add_tearoffs(true);
-               App::ui_manager()->insert_action_group(menus_action_group,1);
-               App::ui_manager()->insert_action_group(actions_action_group,1);
-               App::ui_manager()->add_ui_from_string(ui_info);
-
-               //App::ui_manager()->get_accel_group()->unlock();
-       }
-       catch(const Glib::Error& ex)
-       {
-               synfig::error("building menus and toolbars failed: " + ex.what());
-       }
-
-       // Add default keyboard accelerators
-#define ACCEL(accel,path)                                              \
-       {                                                                                       \
-               Gtk::AccelKey accel_key(accel,path);    \
-               Gtk::AccelMap::add_entry(accel_key.get_path(), accel_key.get_key(), accel_key.get_mod());       \
-       }
-
-#define ACCEL2(accel)                                                  \
-       {                                                                                       \
-               Gtk::AccelKey accel_key(accel);                 \
-               Gtk::AccelMap::add_entry(accel_key.get_path(), accel_key.get_key(), accel_key.get_mod());       \
-       }
-
-       // the toolbox
-       ACCEL("<Mod1>a",                                                                                                        "<Actions>/action_group_state_manager/state-normal"                                     );
-       ACCEL("<Mod1>v",                                                                                                        "<Actions>/action_group_state_manager/state-smooth_move"                                );
-       ACCEL("<Mod1>s",                                                                                                        "<Actions>/action_group_state_manager/state-scale"                                      );
-       ACCEL("<Mod1>t",                                                                                                        "<Actions>/action_group_state_manager/state-rotate"                                     );
-       ACCEL("<Mod1>m",                                                                                                        "<Actions>/action_group_state_manager/state-mirror"                                     );
-       ACCEL("<Mod1>c",                                                                                                        "<Actions>/action_group_state_manager/state-circle"                                     );
-       ACCEL("<Mod1>r",                                                                                                        "<Actions>/action_group_state_manager/state-rectangle"                          );
-       ACCEL("<Mod1>q",                                                                                                        "<Actions>/action_group_state_manager/state-star"                                               );
-       ACCEL("<Mod1>g",                                                                                                        "<Actions>/action_group_state_manager/state-gradient"                                   );
-       ACCEL("<Mod1>p",                                                                                                        "<Actions>/action_group_state_manager/state-polygon"                                    );
-       ACCEL("<Mod1>b",                                                                                                        "<Actions>/action_group_state_manager/state-bline"                                      );
-       ACCEL("<Mod1>x",                                                                                                        "<Actions>/action_group_state_manager/state-text"                                               );
-       ACCEL("<Mod1>f",                                                                                                        "<Actions>/action_group_state_manager/state-fill"                                               );
-       ACCEL("<Mod1>e",                                                                                                        "<Actions>/action_group_state_manager/state-eyedrop"                                    );
-       ACCEL("<Mod1>z",                                                                                                        "<Actions>/action_group_state_manager/state-zoom"                                               );
-       ACCEL("<Mod1>d",                                                                                                        "<Actions>/action_group_state_manager/state-draw"                                               );
-       ACCEL("<Mod1>k",                                                                                                        "<Actions>/action_group_state_manager/state-sketch"                                     );
-       ACCEL("<Mod1>w",                                                                                                        "<Actions>/action_group_state_manager/state-width"                                      );
-
-       // everything else
-       ACCEL("<Control>a",                                                                                                     "<Actions>/canvasview/select-all-ducks"                         );
-       ACCEL("<Control>d",                                                                                                     "<Actions>/canvasview/unselect-all-ducks"                               );
-       ACCEL("<Control><Shift>a",                                                                                      "<Actions>/canvasview/select-all-layers"                                );
-       ACCEL("<Control><Shift>d",                                                                                      "<Actions>/canvasview/unselect-all-layers"                      );
-       ACCEL("F9",                                                                                                                     "<Actions>/canvasview/render"                                                   );
-       ACCEL("F11",                                                                                                            "<Actions>/canvasview/preview"                                          );
-       ACCEL("F8",                                                                                                                     "<Actions>/canvasview/properties"                                               );
-       ACCEL("F12",                                                                                                            "<Actions>/canvasview/options"                                          );
-       ACCEL("<control>i",                                                                                                     "<Actions>/canvasview/import"                                                   );
-       ACCEL2(Gtk::AccelKey(GDK_Escape,static_cast<Gdk::ModifierType>(0),      "<Actions>/canvasview/stop"                                                     ));
-       ACCEL("<Control>g",                                                                                                     "<Actions>/canvasview/toggle-grid-show"                         );
-       ACCEL("<Control>l",                                                                                                     "<Actions>/canvasview/toggle-grid-snap"                         );
-       ACCEL2(Gtk::AccelKey('`',Gdk::CONTROL_MASK,                                                     "<Actions>/canvasview/toggle-low-res"                                   ));
-       ACCEL("<Mod1>1",                                                                                                        "<Actions>/canvasview/mask-position-ducks"                      );
-       ACCEL("<Mod1>2",                                                                                                        "<Actions>/canvasview/mask-vertex-ducks"                                );
-       ACCEL("<Mod1>3",                                                                                                        "<Actions>/canvasview/mask-tangent-ducks"                               );
-       ACCEL("<Mod1>4",                                                                                                        "<Actions>/canvasview/mask-radius-ducks"                                );
-       ACCEL("<Mod1>5",                                                                                                        "<Actions>/canvasview/mask-width-ducks"                         );
-       ACCEL("<Mod1>6",                                                                                                        "<Actions>/canvasview/mask-angle-ducks"                         );
-       ACCEL2(Gtk::AccelKey(GDK_Page_Up,Gdk::SHIFT_MASK,                                       "<Actions>/action_group_layer_action_manager/action-LayerRaise"                         ));
-       ACCEL2(Gtk::AccelKey(GDK_Page_Down,Gdk::SHIFT_MASK,                                     "<Actions>/action_group_layer_action_manager/action-LayerLower"                         ));
-       ACCEL("<Control>1",                                                                                                     "<Actions>/canvasview/quality-01"                                               );
-       ACCEL("<Control>2",                                                                                                     "<Actions>/canvasview/quality-02"                                               );
-       ACCEL("<Control>3",                                                                                                     "<Actions>/canvasview/quality-03"                                               );
-       ACCEL("<Control>4",                                                                                                     "<Actions>/canvasview/quality-04"                                               );
-       ACCEL("<Control>5",                                                                                                     "<Actions>/canvasview/quality-05"                                               );
-       ACCEL("<Control>6",                                                                                                     "<Actions>/canvasview/quality-06"                                               );
-       ACCEL("<Control>7",                                                                                                     "<Actions>/canvasview/quality-07"                                               );
-       ACCEL("<Control>8",                                                                                                     "<Actions>/canvasview/quality-08"                                               );
-       ACCEL("<Control>9",                                                                                                     "<Actions>/canvasview/quality-09"                                               );
-       ACCEL("<Control>0",                                                                                                     "<Actions>/canvasview/quality-10"                                               );
-       ACCEL("<Control>z",                                                                                                     "<Actions>/action_group_dock_history/undo"                                                      );
-       ACCEL("<Control>r",                                                                                                     "<Actions>/action_group_dock_history/redo"                                                      );
-       ACCEL2(Gtk::AccelKey(GDK_Delete,Gdk::CONTROL_MASK,                                      "<Actions>/action_group_layer_action_manager/action-LayerRemove"                                ));
-       ACCEL2(Gtk::AccelKey('(',Gdk::CONTROL_MASK,                                                     "<Actions>/canvasview/decrease-low-res-pixel-size"      ));
-       ACCEL2(Gtk::AccelKey(')',Gdk::CONTROL_MASK,                                                     "<Actions>/canvasview/increase-low-res-pixel-size"      ));
-       ACCEL2(Gtk::AccelKey('(',Gdk::MOD1_MASK|Gdk::CONTROL_MASK,                      "<Actions>/action_group_layer_action_manager/amount-dec"                                                ));
-       ACCEL2(Gtk::AccelKey(')',Gdk::MOD1_MASK|Gdk::CONTROL_MASK,                      "<Actions>/action_group_layer_action_manager/amount-inc"                                                ));
-       ACCEL2(Gtk::AccelKey(']',Gdk::CONTROL_MASK,                                                     "<Actions>/canvasview/jump-next-keyframe"                               ));
-       ACCEL2(Gtk::AccelKey('[',Gdk::CONTROL_MASK,                                                     "<Actions>/canvasview/jump-prev-keyframe"                               ));
-       ACCEL2(Gtk::AccelKey('=',Gdk::CONTROL_MASK,                                                     "<Actions>/canvasview/canvas-zoom-in"                                   ));
-       ACCEL2(Gtk::AccelKey('-',Gdk::CONTROL_MASK,                                                     "<Actions>/canvasview/canvas-zoom-out"                          ));
-       ACCEL2(Gtk::AccelKey('+',Gdk::CONTROL_MASK,                                                     "<Actions>/canvasview/time-zoom-in"                                     ));
-       ACCEL2(Gtk::AccelKey('_',Gdk::CONTROL_MASK,                                                     "<Actions>/canvasview/time-zoom-out"                                    ));
-       ACCEL2(Gtk::AccelKey('.',Gdk::CONTROL_MASK,                                                     "<Actions>/canvasview/seek-next-frame"                          ));
-       ACCEL2(Gtk::AccelKey(',',Gdk::CONTROL_MASK,                                                     "<Actions>/canvasview/seek-prev-frame"                          ));
-       ACCEL2(Gtk::AccelKey('>',Gdk::CONTROL_MASK,                                                     "<Actions>/canvasview/seek-next-second"                         ));
-       ACCEL2(Gtk::AccelKey('<',Gdk::CONTROL_MASK,                                                     "<Actions>/canvasview/seek-prev-second"                         ));
-       ACCEL("<Mod1>o",                                                                                                        "<Actions>/canvasview/toggle-onion-skin"                                );
-       ACCEL("<Control><Shift>z",                                                                                      "<Actions>/canvasview/canvas-zoom-fit"                          );
-       ACCEL("<Control>p",                                                                                                     "<Actions>/canvasview/play"                                                     );
-       ACCEL("Home",                                                                                                           "<Actions>/canvasview/seek-begin"                                               );
-       ACCEL("End",                                                                                                            "<Actions>/canvasview/seek-end"                                         );
-
-#undef ACCEL
-#undef ACCEL2
-}
-
-#ifdef _WIN32
-#define mkdir(x,y) mkdir(x)
-#endif
-
-/* === M E T H O D S ======================================================= */
-
-App::App(int *argc, char ***argv):
-       Gtk::Main(argc,argv),
-       IconController(etl::dirname((*argv)[0]))
-{
-       app_base_path_=etl::dirname(etl::dirname((*argv)[0]));
-
-
-       ui_interface_=new GlobalUIInterface();
-
-       gdk_rgb_init();
-
-       // don't call thread_init() if threads are already initialized
-       // on some machines bonobo_init() initialized threads before we get here
-       if (!g_thread_supported())
-               Glib::thread_init();
-
-       distance_system=Distance::SYSTEM_UNITS;
-
-       if(mkdir(get_user_app_directory().c_str(),ACCESSPERMS)<0)
-       {
-               if(errno!=EEXIST)
-                       synfig::error("UNABLE TO CREATE \"%s\"",get_user_app_directory().c_str());
-       }
-       else
-       {
-               synfig::info("Created directory \"%s\"",get_user_app_directory().c_str());
-       }
-
-
-       ipc=new IPC();
-
-       if(!SYNFIG_CHECK_VERSION())
-       {
-               cerr<<"FATAL: Synfig Version Mismatch"<<endl;
-               dialog_error_blocking("Synfig Studio",
-                       "This copy of Synfig Studio was compiled against a\n"
-                       "different version of libsynfig than what is currently\n"
-                       "installed. Synfig Studio will now abort. Try downloading\n"
-                       "the latest version from the Synfig website at\n"
-                       "http://synfig.org/Download"
-               );
-               throw 40;
-       }
-       Glib::set_application_name(_("Synfig Studio"));
-
-       Splash splash_screen;
-       splash_screen.show();
-
-       shutdown_in_progress=false;
-       SuperCallback synfig_init_cb(splash_screen.get_callback(),0,9000,10000);
-       SuperCallback studio_init_cb(splash_screen.get_callback(),9000,10000,10000);
-
-       // Initialize the Synfig library
-       try { synfigapp_main=etl::smart_ptr<synfigapp::Main>(new synfigapp::Main(etl::dirname((*argv)[0]),&synfig_init_cb)); }
-       catch(std::runtime_error x)
-       {
-               get_ui_interface()->error(strprintf("%s\n\n%s", _("Failed to initialize synfig!"), x.what()));
-               throw;
-       }
-       catch(...)
-       {
-               get_ui_interface()->error(_("Failed to initialize synfig!"));
-               throw;
-       }
-
-       // add the preferences to the settings
-       synfigapp::Main::settings().add_domain(&_preferences,"pref");
-
-       try
-       {
-               studio_init_cb.task(_("Init UI Manager..."));
-               App::ui_manager_=studio::UIManager::create();
-               init_ui_manager();
-
-               studio_init_cb.task(_("Init Dock Manager..."));
-               dock_manager=new studio::DockManager();
-
-               studio_init_cb.task(_("Init State Manager..."));
-               state_manager=new StateManager();
-
-               studio_init_cb.task(_("Init Toolbox..."));
-               toolbox=new studio::Toolbox();
-
-               studio_init_cb.task(_("Init About Dialog..."));
-               about=new studio::About();
-
-               studio_init_cb.task(_("Init Tool Options..."));
-               dialog_tool_options=new studio::Dialog_ToolOptions();
-               dock_manager->register_dockable(*dialog_tool_options);
-
-               studio_init_cb.task(_("Init History..."));
-               dock_history=new studio::Dock_History();
-               dock_manager->register_dockable(*dock_history);
-
-               studio_init_cb.task(_("Init Canvases..."));
-               dock_canvases=new studio::Dock_Canvases();
-               dock_manager->register_dockable(*dock_canvases);
-
-               studio_init_cb.task(_("Init Keyframes..."));
-               dock_keyframes=new studio::Dock_Keyframes();
-               dock_manager->register_dockable(*dock_keyframes);
-
-               studio_init_cb.task(_("Init Layers..."));
-               dock_layers=new studio::Dock_Layers();
-               dock_manager->register_dockable(*dock_layers);
-
-               studio_init_cb.task(_("Init Params..."));
-               dock_params=new studio::Dock_Params();
-               dock_manager->register_dockable(*dock_params);
-
-               studio_init_cb.task(_("Init MetaData..."));
-               dock_meta_data=new studio::Dock_MetaData();
-               dock_manager->register_dockable(*dock_meta_data);
-
-               studio_init_cb.task(_("Init Children..."));
-               dock_children=new studio::Dock_Children();
-               dock_manager->register_dockable(*dock_children);
-
-               studio_init_cb.task(_("Init Info..."));
-               dock_info = new studio::Dock_Info();
-               dock_manager->register_dockable(*dock_info);
-
-               studio_init_cb.task(_("Init Navigator..."));
-               dock_navigator = new studio::Dock_Navigator();
-               dock_manager->register_dockable(*dock_navigator);
-
-               studio_init_cb.task(_("Init Timetrack..."));
-               dock_timetrack = new studio::Dock_Timetrack();
-               dock_manager->register_dockable(*dock_timetrack);
-
-               studio_init_cb.task(_("Init Curve Editor..."));
-               dock_curves = new studio::Dock_Curves();
-               dock_manager->register_dockable(*dock_curves);
-
-               studio_init_cb.task(_("Init Layer Groups..."));
-               dock_layer_groups = new studio::Dock_LayerGroups();
-               dock_manager->register_dockable(*dock_layer_groups);
-
-
-               studio_init_cb.task(_("Init Color Dialog..."));
-               dialog_color=new studio::Dialog_Color();
-
-               studio_init_cb.task(_("Init Gradient Dialog..."));
-               dialog_gradient=new studio::Dialog_Gradient();
-
-               studio_init_cb.task(_("Init DeviceTracker..."));
-               device_tracker=new studio::DeviceTracker();
-
-               studio_init_cb.task(_("Init Tools..."));
-
-               /* 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_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);
-               if(!getenv("SYNFIG_DISABLE_SKETCH" )) state_manager->add_state(&state_sketch);
-
-               studio_init_cb.task(_("Init ModPalette..."));
-               module_list_.push_back(new ModPalette()); module_list_.back()->start();
-
-               studio_init_cb.task(_("Init Setup Dialog..."));
-               dialog_setup=new studio::Dialog_Setup();
-
-               studio_init_cb.task(_("Init Input Dialog..."));
-               dialog_input=new Gtk::InputDialog();
-               dialog_input->get_close_button()->signal_clicked().connect( sigc::mem_fun( *dialog_input, &Gtk::InputDialog::hide ) );
-               dialog_input->get_save_button()->signal_clicked().connect( sigc::mem_fun( *device_tracker, &DeviceTracker::save_preferences) );
-
-               studio_init_cb.task(_("Init auto recovery..."));
-               auto_recover=new AutoRecover();
-
-               studio_init_cb.amount_complete(9250,10000);
-               studio_init_cb.task(_("Loading Settings..."));
-               load_settings();
-               device_tracker->load_preferences();
-
-               studio_init_cb.task(_("Checking auto-recover..."));
-
-               studio_init_cb.amount_complete(9900,10000);
-
-               bool opened_any = false;
-               if(auto_recover->recovery_needed())
-               {
-                       splash_screen.hide();
-                       if (get_ui_interface()->confirmation("Crash Recovery",
-                                       _("Auto recovery file found"),
-                                       _("Synfig Studio seems to have crashed\n"
-                                         "before you could save all your files.\n"
-                                         "Recover unsaved changes?"),
-                                       _("Recover"), _("Ignore"))
-                               == synfigapp::UIInterface::RESPONSE_OK)
-                       {
-                               int number_recovered;
-                               if(!auto_recover->recover(number_recovered))
-                                       if (number_recovered)
-                                               get_ui_interface()->error(_("Unable to fully recover from previous crash"));
-                                       else
-                                               get_ui_interface()->error(_("Unable to recover from previous crash"));
-                               else
-                                       get_ui_interface()->error(
-                                               _("Synfig Studio has attempted to recover\n"
-                                                 "from a previous crash. The files that it has\n"
-                                                 "recovered are NOT YET SAVED. It would be a good\n"
-                                                 "idea to review them and save them now."));
-
-                               if (number_recovered)
-                                       opened_any = true;
-                       }
-                       splash_screen.show();
-               }
-
-               // Look for any files given on the command line,
-               // and load them if found.
-               for(;*argc>=1;(*argc)--)
-                       if((*argv)[*argc] && (*argv)[*argc][0]!='-')
-                       {
-                               studio_init_cb.task(_("Loading files..."));
-                               splash_screen.hide();
-                               open((*argv)[*argc]);
-                               opened_any = true;
-                               splash_screen.show();
-                       }
-
-               // if no file was specified to be opened, create a new document to help new users get started more easily
-               if (!opened_any && !getenv("SYNFIG_DISABLE_AUTOMATIC_DOCUMENT_CREATION"))
-                       new_instance();
-
-               studio_init_cb.task(_("Done."));
-               studio_init_cb.amount_complete(10000,10000);
-
-               toolbox->present();
-       }
-       catch(String x)
-       {
-               get_ui_interface()->error(_("Unknown exception caught when constructing App.\nThis software may be unstable.") + String("\n\n") + x);
-       }
-       catch(...)
-       {
-               get_ui_interface()->error(_("Unknown exception caught when constructing App.\nThis software may be unstable."));
-       }
-}
-
-StateManager* App::get_state_manager() { return state_manager; }
-
-App::~App()
-{
-       shutdown_in_progress=true;
-
-       save_settings();
-
-       synfigapp::Main::settings().remove_domain("pref");
-
-       selected_instance=0;
-
-       // Unload all of the modules
-       for(;!module_list_.empty();module_list_.pop_back())
-               ;
-
-       delete state_manager;
-
-       delete ipc;
-
-       delete auto_recover;
-
-       delete about;
-
-       toolbox->hide();
-
-       delete toolbox;
-
-       delete dialog_setup;
-
-       delete dialog_gradient;
-
-       delete dialog_color;
-
-       delete dialog_input;
-
-       delete dock_manager;
-
-       instance_list.clear();
-}
-
-String
-App::get_user_app_directory()
-{
-//! \todo do we need locale_from_utf8() on non-Windows boxes too?  (bug #1837445)
-#ifdef WIN32
-       return Glib::locale_from_utf8(Glib::build_filename(Glib::get_home_dir(),SYNFIG_USER_APP_DIR));
-#else
-       return Glib::build_filename(Glib::get_home_dir(),SYNFIG_USER_APP_DIR);
-#endif
-}
-
-synfig::String
-App::get_config_file(const synfig::String& file)
-{
-       return Glib::build_filename(get_user_app_directory(),file);
-}
-
-#define SCALE_FACTOR   (1280)
-//! set the \a instance's canvas(es) position and size to be those specified in the first entry of recent_files_window_size
-void
-App::set_recent_file_window_size(etl::handle<Instance> instance)
-{
-       int screen_w(Gdk::screen_width());
-       int screen_h(Gdk::screen_height());
-
-       const std::string &canvas_window_size = *recent_files_window_size.begin();
-
-       if(canvas_window_size.empty())
-               return;
-
-       synfig::String::size_type current=0;
-       bool seen_root(false), shown_non_root(false);
-
-       while(current != synfig::String::npos)
-       {
-               // find end of first field (canvas) or return
-               synfig::String::size_type separator = canvas_window_size.find_first_of(' ', current);
-               if(separator == synfig::String::npos) break;
-
-               // find the canvas
-               synfig::Canvas::Handle canvas;
-               try {
-                       String warnings;
-                       canvas = instance->get_canvas()->find_canvas(String(canvas_window_size, current, separator-current), warnings);
-               }
-               catch(Exception::IDNotFound) {
-                       // can't find the canvas; skip to the next canvas or return
-                       separator = canvas_window_size.find_first_of('\t', current);
-                       if(separator == synfig::String::npos) return;
-                       current = separator+1;
-                       continue;
-               }
-
-               if (canvas->is_root())
-                       seen_root = true;
-               else
-                       shown_non_root = true;
-
-               // check that we have the tab character the ends this canvas' data or return
-               current = separator+1;
-               separator = canvas_window_size.find_first_of('\t', current);
-               if(separator == synfig::String::npos) return;
-
-               int x,y,w,h;
-               if(!strscanf(String(canvas_window_size, current, separator-current),"%d %d %d %d",&x, &y, &w, &h))
-               {
-                       current = separator+1;
-                       continue;
-               }
-
-               if (x > SCALE_FACTOR) x = SCALE_FACTOR - 150; if (x < 0) x = 0;
-               if (y > SCALE_FACTOR) y = SCALE_FACTOR - 150; if (y < 0) y = 0;
-               x=x*screen_w/SCALE_FACTOR;
-               y=y*screen_h/SCALE_FACTOR;
-               if(getenv("SYNFIG_WINDOW_POSITION_X_OFFSET"))
-                       x += atoi(getenv("SYNFIG_WINDOW_POSITION_X_OFFSET"));
-               if(getenv("SYNFIG_WINDOW_POSITION_Y_OFFSET"))
-                       y += atoi(getenv("SYNFIG_WINDOW_POSITION_Y_OFFSET"));
-
-               if (w > SCALE_FACTOR) w = 150; if (w < 0) w = 0;
-               if (h > SCALE_FACTOR) h = 150; if (h < 0) h = 0;
-
-               CanvasView::Handle canvasview = instance->find_canvas_view(canvas);
-               canvasview->move(x,y);
-               canvasview->resize(w*screen_w/SCALE_FACTOR,h*screen_h/SCALE_FACTOR);
-               canvasview->present();
-
-               current = separator+1;
-       }
-
-       if (shown_non_root && !seen_root)
-               instance->find_canvas_view(instance->get_canvas())->hide();
-}
-
-void
-App::add_recent_file(const etl::handle<Instance> instance)
-{
-       int screen_w(Gdk::screen_width());
-       int screen_h(Gdk::screen_height());
-
-       std::string canvas_window_size;
-
-       const Instance::CanvasViewList& cview_list = instance->canvas_view_list();
-       Instance::CanvasViewList::const_iterator iter;
-
-       for(iter=cview_list.begin();iter!=cview_list.end();iter++)
-       {
-               if( !((*iter)->is_visible()) )
-                       continue;
-
-               etl::handle<synfig::Canvas> canvas = (*iter)->get_canvas();
-               int x_pos, y_pos, x_size, y_size;
-               (*iter)->get_position(x_pos,y_pos);
-               (*iter)->get_size(x_size,y_size);
-
-               canvas_window_size += strprintf("%s %d %d %d %d\t",
-                                                                               canvas->get_relative_id(canvas->get_root()).c_str(),
-                                                                               x_pos*SCALE_FACTOR/screen_w,  y_pos*SCALE_FACTOR/screen_h,
-                                                                               x_size*SCALE_FACTOR/screen_w, y_size*SCALE_FACTOR/screen_h);
-       }
-
-       add_recent_file(absolute_path(instance->get_file_name()), canvas_window_size);
-}
-#undef SCALE_FACTOR
-
-void
-App::add_recent_file(const std::string &file_name, const std::string &window_size)
-{
-       std::string filename(file_name);
-
-       assert(!filename.empty());
-
-       if(filename.empty())
-               return;
-
-       // Toss out any "hidden" files
-       if(basename(filename)[0]=='.')
-               return;
-
-       // If we aren't an absolute path, turn ourselves into one
-       if(!is_absolute_path(filename))
-               filename=absolute_path(filename);
-
-       std::string old_window_size;
-
-       list<string>::iterator iter;
-       list<string>::iterator iter_wsize;
-       // Check to see if the file is already on the list.
-       // If it is, then remove it from the list
-       for(iter=recent_files.begin(), iter_wsize=recent_files_window_size.begin();iter!=recent_files.end();iter++, iter_wsize++)
-               if(*iter==filename)
-               {
-                       recent_files.erase(iter);
-                       old_window_size = *iter_wsize;
-                       recent_files_window_size.erase(iter_wsize);
-                       break;
-               }
-
-
-       // Push the filename to the front of the list
-       recent_files.push_front(filename);
-       if(window_size.empty())
-               recent_files_window_size.push_front(old_window_size);
-       else
-               recent_files_window_size.push_front(window_size);
-
-       // Clean out the files at the end of the list.
-       while(recent_files.size()>(unsigned)get_max_recent_files())
-       {
-               recent_files.pop_back();
-               recent_files_window_size.pop_back();
-       }
-
-       signal_recent_files_changed_();
-
-       return;
-}
-
-static Time::Format _App_time_format(Time::FORMAT_NORMAL);
-
-Time::Format
-App::get_time_format()
-{
-       return _App_time_format;
-}
-
-void
-App::set_time_format(synfig::Time::Format x)
-{
-       _App_time_format=x;
-}
-
-
-void
-App::save_settings()
-{
-       char * old_locale;
-       try
-       {
-       old_locale=strdup(setlocale(LC_NUMERIC, NULL));
-       setlocale(LC_NUMERIC, "C");
-               {
-                       std::string filename=get_config_file("accelrc");
-                       Gtk::AccelMap::save(filename);
-               }
-               do{
-                       std::string filename=get_config_file("recentfiles");
-
-                       std::ofstream file(filename.c_str());
-
-                       if(!file)
-                       {
-                               synfig::warning("Unable to save %s",filename.c_str());
-                               break;
-                       }
-
-                       list<string>::reverse_iterator iter;
-
-                       for(iter=recent_files.rbegin();iter!=recent_files.rend();iter++)
-                               file<<*iter<<endl;
-               }while(0);
-               do{
-                       std::string filename=get_config_file("recentfiles")+std::string("_window_size");
-
-                       std::ofstream file(filename.c_str());
-
-                       if(!file)
-                       {
-                               synfig::warning("Unable to save %s",filename.c_str());
-                               break;
-                       }
-
-                       list<string>::reverse_iterator iter;
-
-                       for(iter=recent_files_window_size.rbegin();iter!=recent_files_window_size.rend();iter++)
-                               file<<*iter<<endl;
-
-               }while(0);
-               std::string filename=get_config_file("settings");
-               synfigapp::Main::settings().save_to_file(filename);
-       setlocale(LC_NUMERIC,old_locale);
-       }
-       catch(...)
-       {
-               synfig::warning("Caught exception when attempting to save settings.");
-       }
-}
-
-void
-App::load_settings()
-{
-       char  * old_locale;
-       try
-       {
-       old_locale=strdup(setlocale(LC_NUMERIC, NULL));
-       setlocale(LC_NUMERIC, "C");
-               {
-                       std::string filename=get_config_file("accelrc");
-                       Gtk::AccelMap::load(filename);
-               }
-               {
-                       bool window_size_broken = false;
-
-                       std::string filename=get_config_file("recentfiles");
-                       std::string filename_window_size=filename+std::string("_window_size");
-
-                       std::ifstream file(filename.c_str());
-                       std::ifstream file_window_size(filename_window_size.c_str());
-
-                       if(!file_window_size)
-                               window_size_broken = true;
-
-                       while(file)
-                       {
-                               std::string recent_file;
-                               std::string recent_file_window_size;
-                               getline(file,recent_file);
-                               if(!window_size_broken)
-                                       getline(file_window_size,recent_file_window_size);
-                               if(!recent_file.empty())
-                               {
-                                       if(!window_size_broken && !file_window_size)
-                                               window_size_broken = true;
-                                       if (std::ifstream(recent_file.c_str()))
-                                       {
-                                               if(!window_size_broken)
-                                                       add_recent_file(recent_file,recent_file_window_size);
-                                               else
-                                                       add_recent_file(recent_file);
-                                       }
-                               }
-                       }
-                       if(!window_size_broken && file_window_size)
-                               window_size_broken = true;
-
-                       if(window_size_broken)
-                       {
-                               recent_files_window_size.clear();
-                               recent_files_window_size.resize(recent_files.size());
-                       }
-               }
-               std::string filename=get_config_file("settings");
-               if(!synfigapp::Main::settings().load_from_file(filename))
-               {
-                       //std::string filename=Glib::locale_from_utf8(Glib::build_filename(Glib::get_home_dir(),".synfigrc"));
-                       //if(!synfigapp::Main::settings().load_from_file(filename))
-                       {
-                               gamma.set_gamma(1.0/2.2);
-                               reset_initial_window_configuration();
-                       }
-               }
-       setlocale(LC_NUMERIC,old_locale);
-       }
-       catch(...)
-       {
-               synfig::warning("Caught exception when attempting to load settings.");
-       }
-}
-
-void
-App::reset_initial_window_configuration()
-{
-       synfigapp::Main::settings().set_value("dock.dialog.1.comp_selector","1");
-       synfigapp::Main::settings().set_value("dock.dialog.1.contents","navigator - info pal_edit pal_browse - tool_options history canvases - layers groups");
-       synfigapp::Main::settings().set_value("dock.dialog.1.contents_size","225 167 207");
-       synfigapp::Main::settings().set_value("dock.dialog.1.pos","1057 32");
-       synfigapp::Main::settings().set_value("dock.dialog.1.size","208 1174");
-       synfigapp::Main::settings().set_value("dock.dialog.2.comp_selector","0");
-       synfigapp::Main::settings().set_value("dock.dialog.2.contents","params children keyframes | timetrack curves meta_data");
-       synfigapp::Main::settings().set_value("dock.dialog.2.contents_size","263");
-       synfigapp::Main::settings().set_value("dock.dialog.2.pos","0 973");
-       synfigapp::Main::settings().set_value("dock.dialog.2.size","1045 235");
-       synfigapp::Main::settings().set_value("pref.distance_system","pt");
-       synfigapp::Main::settings().set_value("pref.use_colorspace_gamma","1");
-#ifdef SINGLE_THREADED
-       synfigapp::Main::settings().set_value("pref.single_threaded","1");
-#endif
-       synfigapp::Main::settings().set_value("pref.restrict_radius_ducks","0");
-       synfigapp::Main::settings().set_value("pref.resize_imported_images","0");
-       synfigapp::Main::settings().set_value("pref.custom_filename_prefix",DEFAULT_FILENAME_PREFIX);
-       synfigapp::Main::settings().set_value("pref.preferred_x_size","480");
-       synfigapp::Main::settings().set_value("pref.preferred_y_size","270");
-       synfigapp::Main::settings().set_value("pref.predefined_size",DEFAULT_PREDEFINED_SIZE);
-       synfigapp::Main::settings().set_value("pref.preferred_fps","24.0");
-       synfigapp::Main::settings().set_value("pref.predefined_fps",DEFAULT_PREDEFINED_FPS);
-       synfigapp::Main::settings().set_value("window.toolbox.pos","4 4");
-}
-
-bool
-App::shutdown_request(GdkEventAny*)
-{
-       quit();
-       return true;
-       //return !shutdown_in_progress;
-}
-
-void
-App::quit()
-{
-       if(shutdown_in_progress)return;
-
-
-       get_ui_interface()->task(_("Quit Request"));
-       if(Busy::count)
-       {
-               dialog_error_blocking(_("Cannot quit!"),_("Tasks are currently running.\nPlease cancel the current tasks and try again"));
-               return;
-       }
-
-       std::list<etl::handle<Instance> >::iterator iter;
-       for(iter=instance_list.begin();!instance_list.empty();iter=instance_list.begin())
-       {
-               if(!(*iter)->safe_close())
-                       return;
-
-/*
-               if((*iter)->synfigapp::Instance::get_action_count())
-               {
-                       handle<synfigapp::UIInterface> uim;
-                       uim=(*iter)->find_canvas_view((*iter)->get_canvas())->get_ui_interface();
-                       assert(uim);
-                       string str=strprintf(_("Would you like to save your changes to %s?"),(*iter)->get_file_name().c_str() );
-                       switch(uim->yes_no_cancel((*iter)->get_canvas()->get_name(),str,synfigapp::UIInterface::RESPONSE_YES))
-                       {
-                               case synfigapp::UIInterface::RESPONSE_NO:
-                                       break;
-                               case synfigapp::UIInterface::RESPONSE_YES:
-                                       (*iter)->save();
-                                       break;
-                               case synfigapp::UIInterface::RESPONSE_CANCEL:
-                                       return;
-                               default:
-                                       assert(0);
-                                       return;
-                       }
-               }
-
-
-               if((*iter)->synfigapp::Instance::is_modified())
-               {
-                       handle<synfigapp::UIInterface> uim;
-                       uim=(*iter)->find_canvas_view((*iter)->get_canvas())->get_ui_interface();
-                       assert(uim);
-                       string str=strprintf(_("%s has changes not yet on the CVS repository.\nWould you like to commit these changes?"),(*iter)->get_file_name().c_str() );
-                       switch(uim->yes_no_cancel((*iter)->get_canvas()->get_name(),str,synfigapp::UIInterface::RESPONSE_YES))
-                       {
-                               case synfigapp::UIInterface::RESPONSE_NO:
-                                       break;
-                               case synfigapp::UIInterface::RESPONSE_YES:
-                                       (*iter)->dialog_cvs_commit();
-                                       break;
-                               case synfigapp::UIInterface::RESPONSE_CANCEL:
-                                       return;
-                               default:
-                                       assert(0);
-                                       return;
-                       }
-               }
-*/
-
-               // This next line causes things to crash for some reason
-               //(*iter)->close();
-       }
-
-       shutdown_in_progress=true;
-
-       instance_list.clear();
-
-       while(studio::App::events_pending())studio::App::iteration(false);
-
-       Gtk::Main::quit();
-       auto_recover->normal_shutdown();
-
-       get_ui_interface()->task(_("Quit Request sent"));
-}
-
-void
-App::show_setup()
-{
-       dialog_setup->refresh();
-       dialog_setup->show();
-}
-
-gint Signal_Open_Ok(GtkWidget */*widget*/, int *val){*val=1;return 0;}
-gint Signal_Open_Cancel(GtkWidget */*widget*/, int *val){*val=2;return 0;}
-
-//#ifdef WIN32
-//#define USE_WIN32_FILE_DIALOGS 1
-//#endif
-
-#ifdef USE_WIN32_FILE_DIALOGS
-static OPENFILENAME ofn={};
-#endif
-
-#ifdef WIN32
-#include <gdk/gdkwin32.h>
-#endif
-
-bool
-App::dialog_open_file(const std::string &title, std::string &filename, std::string preference)
-{
-       // info("App::dialog_open_file('%s', '%s', '%s')", title.c_str(), filename.c_str(), preference.c_str());
-
-#ifdef USE_WIN32_FILE_DIALOGS
-       static TCHAR szFilter[] = TEXT ("All Files (*.*)\0*.*\0\0") ;
-
-       GdkWindow *gdkWinPtr=toolbox->get_window()->gobj();
-       HINSTANCE hInstance=static_cast<HINSTANCE>(GetModuleHandle(NULL));
-       HWND hWnd=static_cast<HWND>(GDK_WINDOW_HWND(gdkWinPtr));
-
-       ofn.lStructSize=sizeof(OPENFILENAME);
-       ofn.hwndOwner = hWnd;
-       ofn.hInstance = hInstance;
-       ofn.lpstrFilter = szFilter;
-//     ofn.lpstrCustomFilter=NULL;
-//     ofn.nMaxCustFilter=0;
-//     ofn.nFilterIndex=0;
-//     ofn.lpstrFile=NULL;
-       ofn.nMaxFile=MAX_PATH;
-//     ofn.lpstrFileTitle=NULL;
-//     ofn.lpstrInitialDir=NULL;
-//     ofn.lpstrTitle=NULL;
-       ofn.Flags=OFN_HIDEREADONLY;
-//     ofn.nFileOffset=0;
-//     ofn.nFileExtension=0;
-       ofn.lpstrDefExt=TEXT("sif");
-//     ofn.lCustData = 0l;
-       ofn.lpfnHook=NULL;
-//     ofn.lpTemplateName=NULL;
-
-       CHAR szFilename[MAX_PATH];
-       CHAR szTitle[500];
-       strcpy(szFilename,filename.c_str());
-       strcpy(szTitle,title.c_str());
-
-       ofn.lpstrFile=szFilename;
-       ofn.lpstrFileTitle=szTitle;
-
-       if(GetOpenFileName(&ofn))
-       {
-               filename=szFilename;
-               return true;
-       }
-       return false;
-
-#else   // not USE_WIN32_FILE_DIALOGS
-       synfig::String prev_path;
-
-       if(!_preferences.get_value(preference, prev_path))
-               prev_path = ".";
-
-       prev_path = absolute_path(prev_path);
-
-    Gtk::FileChooserDialog *dialog = new Gtk::FileChooserDialog(title, Gtk::FILE_CHOOSER_ACTION_OPEN);
-
-    dialog->set_current_folder(prev_path);
-    dialog->add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
-    dialog->add_button(Gtk::Stock::OPEN,   Gtk::RESPONSE_ACCEPT);
-
-    if (filename.empty())
-               dialog->set_filename(prev_path);
-       else if (is_absolute_path(filename))
-               dialog->set_filename(filename);
-       else
-               dialog->set_filename(prev_path + ETL_DIRECTORY_SEPARATOR + filename);
-
-    if(dialog->run() == GTK_RESPONSE_ACCEPT) {
-        filename = dialog->get_filename();
-               // info("Saving preference %s = '%s' in App::dialog_open_file()", preference.c_str(), dirname(filename).c_str());
-               _preferences.set_value(preference, dirname(filename));
-        delete dialog;
-        return true;
-    }
-
-    delete dialog;
-    return false;
-#endif   // not USE_WIN32_FILE_DIALOGS
-}
-
-bool
-App::dialog_save_file(const std::string &title, std::string &filename, std::string preference)
-{
-       // info("App::dialog_save_file('%s', '%s', '%s')", title.c_str(), filename.c_str(), preference.c_str());
-
-#if USE_WIN32_FILE_DIALOGS
-       static TCHAR szFilter[] = TEXT ("All Files (*.*)\0*.*\0\0") ;
-
-       GdkWindow *gdkWinPtr=toolbox->get_window()->gobj();
-       HINSTANCE hInstance=static_cast<HINSTANCE>(GetModuleHandle(NULL));
-       HWND hWnd=static_cast<HWND>(GDK_WINDOW_HWND(gdkWinPtr));
-
-       ofn.lStructSize=sizeof(OPENFILENAME);
-       ofn.hwndOwner = hWnd;
-       ofn.hInstance = hInstance;
-       ofn.lpstrFilter = szFilter;
-//     ofn.lpstrCustomFilter=NULL;
-//     ofn.nMaxCustFilter=0;
-//     ofn.nFilterIndex=0;
-//     ofn.lpstrFile=NULL;
-       ofn.nMaxFile=MAX_PATH;
-//     ofn.lpstrFileTitle=NULL;
-//     ofn.lpstrInitialDir=NULL;
-//     ofn.lpstrTitle=NULL;
-       ofn.Flags=OFN_OVERWRITEPROMPT;
-//     ofn.nFileOffset=0;
-//     ofn.nFileExtension=0;
-       ofn.lpstrDefExt=TEXT("sif");
-//     ofn.lCustData = 0l;
-       ofn.lpfnHook=NULL;
-//     ofn.lpTemplateName=NULL;
-
-       CHAR szFilename[MAX_PATH];
-       CHAR szTitle[500];
-       strcpy(szFilename,filename.c_str());
-       strcpy(szTitle,title.c_str());
-
-       ofn.lpstrFile=szFilename;
-       ofn.lpstrFileTitle=szTitle;
-
-       if(GetSaveFileName(&ofn))
-       {
-               filename=szFilename;
-               _preferences.set_value(preference,dirname(filename));
-               return true;
-       }
-       return false;
-#else
-       synfig::String prev_path;
-
-       if(!_preferences.get_value(preference, prev_path))
-               prev_path=".";
-
-       prev_path = absolute_path(prev_path);
-
-    Gtk::FileChooserDialog *dialog = new Gtk::FileChooserDialog(title, Gtk::FILE_CHOOSER_ACTION_SAVE);
-
-    dialog->set_current_folder(prev_path);
-    dialog->add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
-    dialog->add_button(Gtk::Stock::SAVE,   Gtk::RESPONSE_ACCEPT);
-
-       Widget_Enum *file_type_enum = 0;
-       if (preference == ANIMATION_DIR_PREFERENCE)
-       {
-               file_type_enum = manage(new Widget_Enum());
-               file_type_enum->set_param_desc(ParamDesc().set_hint("enum")
-                                                                          .add_enum_value(synfig::RELEASE_VERSION_0_62_00, "0.62.00", strprintf("0.62.00 (%s)", _("current")))
-                                                                          .add_enum_value(synfig::RELEASE_VERSION_0_61_09, "0.61.09", "0.61.09")
-                                                                          .add_enum_value(synfig::RELEASE_VERSION_0_61_08, "0.61.08", "0.61.08")
-                                                                          .add_enum_value(synfig::RELEASE_VERSION_0_61_07, "0.61.07", "0.61.07")
-                                                                          .add_enum_value(synfig::RELEASE_VERSION_0_61_06, "0.61.06", strprintf("0.61.06 %s", _("and older"))));
-               file_type_enum->set_value(RELEASE_VERSION_END-1); // default to the most recent version
-
-               Gtk::HBox *hbox = manage(new Gtk::HBox);
-               hbox->pack_start(*manage(new Gtk::Label(_("File Format Version: "))),Gtk::PACK_SHRINK,0);
-               hbox->pack_start(*file_type_enum,Gtk::PACK_EXPAND_WIDGET,0);
-               hbox->show_all();
-
-               dialog->set_extra_widget(*hbox);
-       }
-
-    if (filename.empty())
-               dialog->set_filename(prev_path);
-    else
-       {
-               std::string full_path;
-               if (is_absolute_path(filename))
-                       full_path = filename;
-               else
-                       full_path = prev_path + ETL_DIRECTORY_SEPARATOR + filename;
-
-               // select the file if it exists
-               dialog->set_filename(full_path);
-
-               // if the file doesn't exist, put its name into the filename box
-               struct stat s;
-               if(stat(full_path.c_str(),&s) == -1 && errno == ENOENT)
-                       dialog->set_current_name(basename(filename));
-       }
-
-    if(dialog->run() == GTK_RESPONSE_ACCEPT) {
-               if (preference == ANIMATION_DIR_PREFERENCE)
-                       set_file_version(synfig::ReleaseVersion(file_type_enum->get_value()));
-        filename = dialog->get_filename();
-               // info("Saving preference %s = '%s' in App::dialog_save_file()", preference.c_str(), dirname(filename).c_str());
-               _preferences.set_value(preference, dirname(filename));
-        delete dialog;
-        return true;
-    }
-
-    delete dialog;
-    return false;
-#endif
-}
-
-void
-App::dialog_error_blocking(const std::string &title, const std::string &message)
-{
-       Gtk::MessageDialog dialog(message, false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE, true);
-       dialog.set_title(title);
-       dialog.show();
-       dialog.run();
-}
-
-void
-App::dialog_warning_blocking(const std::string &title, const std::string &message)
-{
-       Gtk::MessageDialog dialog(message, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_CLOSE, true);
-       dialog.set_title(title);
-       dialog.show();
-       dialog.run();
-}
-
-bool
-App::dialog_yes_no(const std::string &title, const std::string &message)
-{
-       Gtk::Dialog dialog(
-               title,          // Title
-               true,           // Modal
-               true            // use_separator
-       );
-       Gtk::Label label(message);
-       label.show();
-
-       dialog.get_vbox()->pack_start(label);
-       dialog.add_button(Gtk::StockID("gtk-yes"),1);
-       dialog.add_button(Gtk::StockID("gtk-no"),0);
-       dialog.show();
-       return dialog.run();
-}
-
-int
-App::dialog_yes_no_cancel(const std::string &title, const std::string &message)
-{
-       Gtk::Dialog dialog(
-               title,          // Title
-               true,           // Modal
-               true            // use_separator
-       );
-       Gtk::Label label(message);
-       label.show();
-
-       dialog.get_vbox()->pack_start(label);
-       dialog.add_button(Gtk::StockID("gtk-yes"),1);
-       dialog.add_button(Gtk::StockID("gtk-no"),0);
-       dialog.add_button(Gtk::StockID("gtk-cancel"),2);
-       dialog.show();
-       return dialog.run();
-}
-
-void
-App::dialog_not_implemented()
-{
-       Gtk::MessageDialog dialog(_("Feature not available"), false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE, true);
-       dialog.set_secondary_text(_("Sorry, this feature has not yet been implemented."));
-       dialog.run();
-}
-
-static bool
-try_open_url(const std::string &url)
-{
-#ifdef WIN32
-       return ShellExecute(GetDesktopWindow(), "open", url.c_str(), NULL, NULL, SW_SHOW);
-#else // !WIN32
-       std::vector<std::string> command_line;
-       std::vector<std::string> browsers;
-       browsers.reserve(23);
-
-       // Browser wrapper scripts
-#ifdef USE_OPEN_FOR_URLS
-       browsers.push_back("open");              // Apple MacOS X wrapper, on Linux it opens a virtual console
-#endif
-       browsers.push_back("xdg-open");          // XDG wrapper
-       browsers.push_back("sensible-browser");  // Debian wrapper
-       browsers.push_back("gnome-open");        // GNOME wrapper
-       browsers.push_back("kfmclient");         // KDE wrapper
-       browsers.push_back("exo-open");          // XFCE wrapper
-
-       // Alternatives system
-       browsers.push_back("gnome-www-browser"); // Debian GNOME alternative
-       browsers.push_back("x-www-browser");     // Debian GUI alternative
-
-       // Individual browsers
-       browsers.push_back("firefox");
-       browsers.push_back("epiphany-browser");
-       browsers.push_back("epiphany");
-       browsers.push_back("konqueror");
-       browsers.push_back("iceweasel");
-       browsers.push_back("mozilla");
-       browsers.push_back("netscape");
-       browsers.push_back("icecat");
-       browsers.push_back("galeon");
-       browsers.push_back("midori");
-       browsers.push_back("safari");
-       browsers.push_back("opera");
-       browsers.push_back("amaya");
-       browsers.push_back("netsurf");
-       browsers.push_back("dillo");
-
-       // Try the user-specified browser first
-       command_line.push_back(App::browser_command);
-       if( command_line[0] == "kfmclient" ) command_line.push_back("openURL");
-       command_line.push_back(url);
-
-       try { Glib::spawn_async(".", command_line, Glib::SPAWN_SEARCH_PATH); return true; }
-       catch( Glib::SpawnError& exception ){
-
-               while ( !browsers.empty() )
-               {
-                       // Skip the browser if we already tried it
-                       if( browsers[0] == App::browser_command )
-                               continue;
-
-                       // Construct the command line
-                       command_line.clear();
-                       command_line.push_back(browsers[0]);
-                       if( command_line[0] == "kfmclient" ) command_line.push_back("openURL");
-                       command_line.push_back(url);
-
-                       // Remove the browser from the list
-                       browsers.erase(browsers.begin());
-
-                       // Try to spawn the browser
-                       try { Glib::spawn_async(".", command_line, Glib::SPAWN_SEARCH_PATH); }
-                       // Failed, move on to the next one
-                       catch(Glib::SpawnError& exception){ continue; }
-                       return true; // No exception means we succeeded!
-               }
-       }
-
-       return false;
-#endif // !WIN32
-}
-
-void
-App::dialog_help()
-{
-       if (!try_open_url("http://synfig.org/Documentation"))
-       {
-               Gtk::MessageDialog dialog(_("Documentation"), false, Gtk::MESSAGE_INFO, Gtk::BUTTONS_CLOSE, true);
-               dialog.set_secondary_text(_("Documentation for Synfig Studio is available on the website:\n\nhttp://www.synfig.org/Documentation"));
-               dialog.set_title(_("Help"));
-               dialog.run();
-       }
-}
-
-void
-App::open_url(const std::string &url)
-{
-       if(!try_open_url(url))
-       {
-               Gtk::MessageDialog dialog(_("No browser was found. Please load this website manually:"), false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE, true);
-               dialog.set_secondary_text(url);
-               dialog.set_title(_("No browser found"));
-               dialog.run();
-       }
-}
-
-bool
-App::dialog_entry(const std::string &title, const std::string &message,std::string &text)
-{
-       Gtk::Dialog dialog(
-               title,          // Title
-               true,           // Modal
-               true);          // use_separator
-
-       Gtk::Label label(message);
-       label.show();
-       dialog.get_vbox()->pack_start(label);
-
-       Gtk::Entry entry;
-       entry.set_text(text);
-       entry.show();
-       entry.set_activates_default(true);
-
-       dialog.get_vbox()->pack_start(entry);
-
-       dialog.add_button(Gtk::StockID("gtk-ok"),Gtk::RESPONSE_OK);
-       dialog.add_button(Gtk::StockID("gtk-cancel"),Gtk::RESPONSE_CANCEL);
-       dialog.set_default_response(Gtk::RESPONSE_OK);
-
-       entry.signal_activate().connect(sigc::bind(sigc::mem_fun(dialog,&Gtk::Dialog::response),Gtk::RESPONSE_OK));
-       dialog.show();
-
-       if(dialog.run()!=Gtk::RESPONSE_OK)
-               return false;
-
-       text=entry.get_text();
-
-       return true;
-}
-
-bool
-App::dialog_paragraph(const std::string &title, const std::string &message,std::string &text)
-{
-       Gtk::Dialog dialog(
-               title,          // Title
-               true,           // Modal
-               true);          // use_separator
-
-       Gtk::Label label(message);
-       label.show();
-       dialog.get_vbox()->pack_start(label);
-
-       Glib::RefPtr<Gtk::TextBuffer> text_buffer(Gtk::TextBuffer::create());
-       text_buffer->set_text(text);
-       Gtk::TextView text_view(text_buffer);
-       text_view.show();
-
-       dialog.get_vbox()->pack_start(text_view);
-
-       dialog.add_button(Gtk::StockID("gtk-ok"),Gtk::RESPONSE_OK);
-       dialog.add_button(Gtk::StockID("gtk-cancel"),Gtk::RESPONSE_CANCEL);
-       dialog.set_default_response(Gtk::RESPONSE_OK);
-
-       //text_entry.signal_activate().connect(sigc::bind(sigc::mem_fun(dialog,&Gtk::Dialog::response),Gtk::RESPONSE_OK));
-       dialog.show();
-
-       if(dialog.run()!=Gtk::RESPONSE_OK)
-               return false;
-
-       text=text_buffer->get_text();
-
-       return true;
-}
-
-bool
-App::open(std::string filename)
-{
-       return open_as(filename,filename);
-}
-
-// this is called from autorecover.cpp:
-//   App::open_as(get_shadow_file_name(filename),filename)
-// other than that, 'filename' and 'as' are the same
-bool
-App::open_as(std::string filename,std::string as)
-{
-#ifdef WIN32
-    char long_name[1024];
-    if(GetLongPathName(as.c_str(),long_name,sizeof(long_name)));
-       // when called from autorecover.cpp, filename doesn't exist, and so long_name is empty
-       // don't use it if that's the case
-       if (long_name[0] != '\0')
-               as=long_name;
-#endif
-
-       try
-       {
-               OneMoment one_moment;
-               String errors, warnings;
-
-               etl::handle<synfig::Canvas> canvas(open_canvas_as(filename,as,errors,warnings));
-               if(canvas && get_instance(canvas))
-               {
-                       get_instance(canvas)->find_canvas_view(canvas)->present();
-                       info("%s is already open", filename.c_str());
-                       // throw (String)strprintf(_("\"%s\" appears to already be open!"),filename.c_str());
-               }
-               else
-               {
-                       if(!canvas)
-                               throw (String)strprintf(_("Unable to load \"%s\":\n\n"),filename.c_str()) + errors;
-
-                       if (warnings != "")
-                               dialog_warning_blocking(_("Warnings"), strprintf("%s:\n\n%s", _("Warnings"), warnings.c_str()));
-
-                       if (as.find(custom_filename_prefix.c_str()) != 0)
-                               add_recent_file(as);
-
-                       handle<Instance> instance(Instance::create(canvas));
-
-                       if(!instance)
-                               throw (String)strprintf(_("Unable to create instance for \"%s\""),filename.c_str());
-
-                       set_recent_file_window_size(instance);
-
-                       one_moment.hide();
-
-                       if(instance->is_updated() && App::dialog_yes_no(_("CVS Update"), _("There appears to be a newer version of this file available on the CVS repository.\nWould you like to update now? (It would probably be a good idea)")))
-                               instance->dialog_cvs_update();
-               }
-       }
-       catch(String x)
-       {
-               dialog_error_blocking(_("Error"), x);
-               return false;
-       }
-       catch(runtime_error x)
-       {
-               dialog_error_blocking(_("Error"), x.what());
-               return false;
-       }
-       catch(...)
-       {
-               dialog_error_blocking(_("Error"), _("Uncaught error on file open (BUG)"));
-               return false;
-       }
-
-       return true;
-}
-
-
-void
-App::new_instance()
-{
-       handle<synfig::Canvas> canvas=synfig::Canvas::create();
-
-       String file_name(strprintf("%s%d", App::custom_filename_prefix.c_str(), Instance::get_count()+1));
-       canvas->set_name(file_name);
-       file_name += ".sifz";
-
-       canvas->rend_desc().set_frame_rate(preferred_fps);
-       canvas->rend_desc().set_time_start(0.0);
-       canvas->rend_desc().set_time_end(5.0);
-       canvas->rend_desc().set_x_res(DPI2DPM(72.0f));
-       canvas->rend_desc().set_y_res(DPI2DPM(72.0f));
-       // The top left and botton right positions are expressed in units
-       // Original convention is that 1 unit = 60 pixels
-       canvas->rend_desc().set_tl(Vector(-(preferred_x_size/60.0)/2.0,(preferred_y_size/60.0)/2.0));
-       canvas->rend_desc().set_br(Vector((preferred_x_size/60.0)/2.0,-(preferred_y_size/60.0)/2.0));
-       canvas->rend_desc().set_w(preferred_x_size);
-       canvas->rend_desc().set_h(preferred_y_size);
-       canvas->rend_desc().set_antialias(1);
-       canvas->rend_desc().set_flags(RendDesc::PX_ASPECT|RendDesc::IM_SPAN);
-       canvas->set_file_name(file_name);
-
-       handle<Instance> instance = Instance::create(canvas);
-
-       if (getenv("SYNFIG_ENABLE_NEW_CANVAS_EDIT_PROPERTIES"))
-               instance->find_canvas_view(canvas)->canvas_properties.present();
-}
-
-void
-App::dialog_open(string filename)
-{
-       if (filename.empty())
-               filename="*.sif";
-
-       while(dialog_open_file("Open", filename, ANIMATION_DIR_PREFERENCE))
-       {
-               // If the filename still has wildcards, then we should
-               // continue looking for the file we want
-               if(find(filename.begin(),filename.end(),'*')!=filename.end())
-                       continue;
-
-               if(open(filename))
-                       break;
-
-               get_ui_interface()->error(_("Unable to open file"));
-       }
-}
-
-void
-App::set_selected_instance(etl::loose_handle<Instance> instance)
-{
-/*     if(get_selected_instance()==instance)
-       {
-               selected_instance=instance;
-               signal_instance_selected()(instance);
-               return;
-       }
-       else
-       {
-*/
-               selected_instance=instance;
-               if(get_selected_canvas_view() && get_selected_canvas_view()->get_instance()!=instance)
-               {
-                       if(instance)
-                       {
-                               instance->focus(instance->get_canvas());
-                       }
-                       else
-                               set_selected_canvas_view(0);
-               }
-               signal_instance_selected()(instance);
-}
-
-void
-App::set_selected_canvas_view(etl::loose_handle<CanvasView> canvas_view)
-{
-       selected_canvas_view=canvas_view;
-       signal_canvas_view_focus()(selected_canvas_view);
-       if(canvas_view)
-       {
-               selected_instance=canvas_view->get_instance();
-               signal_instance_selected()(canvas_view->get_instance());
-       }
-/*
-       if(get_selected_canvas_view()==canvas_view)
-       {
-               signal_canvas_view_focus()(selected_canvas_view);
-               signal_instance_selected()(canvas_view->get_instance());
-               return;
-       }
-       selected_canvas_view=canvas_view;
-       if(canvas_view && canvas_view->get_instance() != get_selected_instance())
-               set_selected_instance(canvas_view->get_instance());
-       signal_canvas_view_focus()(selected_canvas_view);
-*/
-}
-
-etl::loose_handle<Instance>
-App::get_instance(etl::handle<synfig::Canvas> canvas)
-{
-       if(!canvas) return 0;
-       canvas=canvas->get_root();
-
-       std::list<etl::handle<Instance> >::iterator iter;
-       for(iter=instance_list.begin();iter!=instance_list.end();++iter)
-       {
-               if((*iter)->get_canvas()==canvas)
-                       return *iter;
-       }
-       return 0;
-}
-
-void
-App::dialog_about()
-{
-       if(about)
-               about->show();
-}
-
-void
-studio::App::undo()
-{
-       if(selected_instance)
-               selected_instance->undo();
-}
-
-void
-studio::App::redo()
-{
-       if(selected_instance)
-               selected_instance->redo();
-}
-
-synfig::String
-studio::App::get_base_path()
-{
-       return app_base_path_;
-}
diff --git a/synfig-studio/src/gtkmm/app.h b/synfig-studio/src/gtkmm/app.h
deleted file mode 100644 (file)
index f9960d3..0000000
+++ /dev/null
@@ -1,363 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file app.h
-**     \brief writeme
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 2008 Chris Moore
-**  Copyright (c) 2008 Carlos López
-**
-**     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_APP_H
-#define __SYNFIG_STUDIO_APP_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <sigc++/bind.h>
-
-#include <gtkmm/main.h>
-#include <string>
-#include <list>
-
-#include <ETL/smart_ptr>
-
-#include <synfig/distance.h>
-#include <synfig/string.h>
-#include <synfig/time.h>
-
-#include <gtkmm/uimanager.h>
-
-#include <synfigapp/instance.h>
-#include "iconcontroller.h"
-
-/* === M A C R O S ========================================================= */
-
-#define MISC_DIR_PREFERENCE                    "misc_dir"
-#define ANIMATION_DIR_PREFERENCE       "animation_dir"
-#define IMAGE_DIR_PREFERENCE           "image_dir"
-#define SKETCH_DIR_PREFERENCE          "sketch_dir"
-#define RENDER_DIR_PREFERENCE          "render_dir"
-
-/* === T Y P E D E F S ===================================================== */
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-namespace Gtk
-{
-       class InputDialog;
-       class UIManager;
-       class ActionGroup;
-};
-
-namespace synfigapp
-{
-       class UIInterface;
-       class Main;
-};
-
-class Preferences;
-
-namespace studio {
-
-typedef Gtk::UIManager UIManager;
-
-class About;
-class Toolbox;
-class Instance;
-class CanvasView;
-class Dialog_Setup;
-class Dialog_Gradient;
-class Dialog_Color;
-class Dialog_ToolOptions;
-class DeviceTracker;
-class AutoRecover;
-
-class DockManager;
-
-class Dock_History;
-class Dock_Canvases;
-
-class Dock_Keyframes;
-class Dock_Params;
-class Dock_Layers;
-class Dock_MetaData;
-class Dock_Children;
-class Dock_Info;
-class Dock_Navigator;
-class Dock_LayerGroups;
-class IPC;
-
-class Module;
-
-class StateManager;
-class IconController;
-
-class App : public Gtk::Main, private IconController
-{
-       friend class Preferences;
-       friend class Dialog_Setup;
-
-       /*
- -- ** -- P U B L I C   T Y P E S ---------------------------------------------
-       */
-
-public:
-
-       struct Busy
-       {
-               static int count;
-               Busy(){count++;}
-               ~Busy(){count--;}
-       };
-
-
-       /*
- -- ** -- P R I V A T E   D A T A ---------------------------------------------
-       */
-
-private:
-       //static etl::handle<synfigapp::UIInterface> ui_interface_;
-       //static int max_recent_files;
-
-/*      //declated as globals in app.cpp
-       static Dock_Keyframes *dock_keyframes;
-       static Dock_Layers *dock_layers;
-       static Dock_Params *dock_params;
-       static Dock_MetaData *dock_meta_data;
-       static Dock_Children *dock_children;
-       static Dock_Info *dock_info;
-       static Dock_Navigator *dock_navigator;
-       static Dock_History *dock_history;
-       static Dock_Canvases *dock_canvases;
-       static Dock_LayerGroups *dock_layer_groups;
-
-       static IPC *ipc;
-*/
-
-       etl::smart_ptr<synfigapp::Main> synfigapp_main;
-
-
-       static etl::handle<Instance> selected_instance;
-       static etl::handle<CanvasView> selected_canvas_view;
-
-       static Glib::RefPtr<UIManager>  ui_manager_;
-
-//     static std::list< etl::handle< Module > > module_list_;
-
-       /*
- -- ** -- P U B L I C   D A T A -----------------------------------------------
-       */
-
-public:
-       static Gtk::InputDialog* dialog_input;
-
-       static DeviceTracker*   device_tracker;
-       static AutoRecover*     auto_recover;
-       static DockManager* dock_manager;
-
-       static DockManager* get_dock_manager() { return dock_manager; }
-
-       static Dialog_Setup* dialog_setup;
-       static Dialog_Gradient* dialog_gradient;
-       static Dialog_Color* dialog_color;
-//     static Dialog_Palette* dialog_palette;
-       static Dialog_ToolOptions *dialog_tool_options;
-
-       static synfig::Distance::System distance_system;
-
-       static synfig::Gamma gamma;
-
-       static About *about;
-       static Toolbox *toolbox;
-
-       static std::list<etl::handle<Instance> > instance_list;
-
-       static bool shutdown_in_progress;
-
-       static bool use_colorspace_gamma;
-
-#ifdef SINGLE_THREADED
-       static bool single_threaded;
-#endif
-
-       static bool restrict_radius_ducks;
-       static bool resize_imported_images;
-
-       static synfig::String browser_command;
-       static synfig::String custom_filename_prefix;
-       static int preferred_x_size;
-       static int preferred_y_size;
-       static synfig::String predefined_size;
-       static synfig::String predefined_fps;
-       static float preferred_fps;
-       /*
- -- ** -- S I G N A L S -------------------------------------------------------
-       */
-/*      //declated as globals in app.cpp
-       static sigc::signal<
-               void,
-               etl::loose_handle<CanvasView>
-       > signal_canvas_view_focus_;
-       static sigc::signal<
-               void,
-               etl::handle<Instance>
-       > signal_instance_selected_;
-       static sigc::signal<
-               void,
-               etl::handle<Instance>
-       > signal_instance_created_;
-       static sigc::signal<
-               void,
-               etl::handle<Instance>
-       > signal_instance_deleted_;
-       static sigc::signal<void> signal_recent_files_changed_;
-       static sigc::signal<void> signal_present_all_;
-*/
-public:
-
-       static sigc::signal<void> &signal_present_all();
-
-       static sigc::signal<void> &signal_recent_files_changed();
-
-       static sigc::signal<
-               void,
-               etl::loose_handle<CanvasView>
-       >& signal_canvas_view_focus();
-
-       static sigc::signal<
-               void,
-               etl::handle<Instance>
-       > &signal_instance_selected();
-
-       static sigc::signal<
-               void,
-               etl::handle<Instance>
-       > &signal_instance_created();
-
-       static sigc::signal<
-               void,
-               etl::handle<Instance>
-       > &signal_instance_deleted();
-
-       /*
- -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
-       */
-
-private:
-       static void add_recent_file(const std::string &filename, const std::string &window_size = std::string());
-
-       /*
- -- ** -- P U B L I C   M E T H O D S -----------------------------------------
-       */
-
-public:
-
-       App(int *argc, char ***argv);
-       virtual ~App();
-
-       /*
- -- ** -- S T A T I C   P U B L I C   M E T H O D S ---------------------------
-       */
-
-public:
-
-       static StateManager* get_state_manager();
-
-       static Glib::RefPtr<UIManager>& ui_manager() { return ui_manager_; }
-
-       static void set_recent_file_window_size(etl::handle<Instance> instance);
-       static void add_recent_file(const etl::handle<Instance> instance);
-
-       static synfig::String get_base_path();
-       static void save_settings();
-       static void load_settings();
-       static void reset_initial_window_configuration();
-
-       static const std::list<std::string>& get_recent_files();
-
-       static const etl::handle<synfigapp::UIInterface>& get_ui_interface();
-
-
-       static void set_selected_instance(etl::loose_handle<Instance> instance);
-       static void set_selected_canvas_view(etl::loose_handle<CanvasView>);
-
-       static etl::loose_handle<Instance> get_instance(etl::handle<synfig::Canvas> canvas);
-
-       static etl::loose_handle<Instance> get_selected_instance() { return selected_instance; }
-       static etl::loose_handle<CanvasView> get_selected_canvas_view() { return selected_canvas_view; }
-
-       static bool open(std::string filename);
-
-       static bool open_as(std::string filename,std::string as);
-
-       static void new_instance();
-
-       static void dialog_open(std::string filename = "");
-
-       static void dialog_about();
-
-       static void quit();
-
-       static void show_setup();
-
-       static void undo();
-       static void redo();
-
-       static int get_max_recent_files();
-       static void set_max_recent_files(int x);
-
-
-       static synfig::Time::Format get_time_format();
-       static void set_time_format(synfig::Time::Format x);
-
-       static bool shutdown_request(GdkEventAny*bleh=NULL);
-
-//     static bool dialog_file(const std::string &title, std::string &filename);
-
-       static bool dialog_open_file(const std::string &title, std::string &filename, std::string preference);
-       static bool dialog_save_file(const std::string &title, std::string &filename, std::string preference);
-
-       static void dialog_error_blocking(const std::string &title, const std::string &message);
-
-       static void dialog_warning_blocking(const std::string &title, const std::string &message);
-
-       static bool dialog_entry(const std::string &title, const std::string &message,std::string &text);
-       static bool dialog_paragraph(const std::string &title, const std::string &message,std::string &text);
-
-       static bool dialog_yes_no(const std::string &title, const std::string &message);
-
-       static int dialog_yes_no_cancel(const std::string &title, const std::string &message);
-
-       static void dialog_not_implemented();
-
-       static void dialog_help();
-
-       static void open_url(const std::string &url);
-
-       static synfig::String get_user_app_directory();
-       static synfig::String get_config_file(const synfig::String& file);
-}; // END of class App
-
-       void delete_widget(Gtk::Widget *widget);
-
-}; // END namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/asyncrenderer.cpp b/synfig-studio/src/gtkmm/asyncrenderer.cpp
deleted file mode 100644 (file)
index 72a286c..0000000
+++ /dev/null
@@ -1,541 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file asyncrenderer.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \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
-**     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 <config.h>
-#endif
-
-#include "asyncrenderer.h"
-#include "app.h"
-#include <glibmm/thread.h>
-#include <glibmm/dispatcher.h>
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-
-#ifdef HAVE_SIGNAL_H
-#include <signal.h>
-#endif
-
-#include <synfig/general.h>
-#include <ETL/clock>
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-using namespace synfig;
-using namespace studio;
-
-#define BOREDOM_TIMEOUT                50
-
-#define REJOIN_ON_STOP 1
-
-// The Glib::Dispatcher class is broken as of Glibmm 2.4.5.
-// Defining this macro enables the workaround.
-#define GLIB_DISPATCHER_BROKEN 1
-
-/* === C L A S S E S ======================================================= */
-
-class AsyncTarget_Tile : public synfig::Target_Tile
-{
-public:
-       etl::handle<synfig::Target_Tile> warm_target;
-
-       struct tile_t
-       {
-               Surface surface;
-               int x,y;
-               tile_t(const Surface& surface,int x, int y):
-                       surface(surface),
-                       x(x),y(y)
-               {
-               }
-       };
-       std::list<tile_t> tile_queue;
-       Glib::Mutex mutex;
-
-#ifndef GLIB_DISPATCHER_BROKEN
-       Glib::Dispatcher tile_ready_signal;
-#endif
-       Glib::Cond cond_tile_queue_empty;
-       bool alive_flag;
-
-       sigc::connection ready_connection;
-
-public:
-       AsyncTarget_Tile(etl::handle<synfig::Target_Tile> warm_target):
-               warm_target(warm_target)
-       {
-               set_avoid_time_sync(warm_target->get_avoid_time_sync());
-               set_tile_w(warm_target->get_tile_w());
-               set_tile_h(warm_target->get_tile_h());
-               set_canvas(warm_target->get_canvas());
-               set_quality(warm_target->get_quality());
-               set_remove_alpha(warm_target->get_remove_alpha());
-               set_threads(warm_target->get_threads());
-               set_clipping(warm_target->get_clipping());
-               set_rend_desc(&warm_target->rend_desc());
-               alive_flag=true;
-#ifndef GLIB_DISPATCHER_BROKEN
-               ready_connection=tile_ready_signal.connect(sigc::mem_fun(*this,&AsyncTarget_Tile::tile_ready));
-#endif
-       }
-
-       ~AsyncTarget_Tile()
-       {
-               ready_connection.disconnect();
-       }
-       void set_dead()
-       {
-               Glib::Mutex::Lock lock(mutex);
-               alive_flag=false;
-       }
-
-       virtual int total_tiles()const
-       {
-               return warm_target->total_tiles();
-       }
-
-       virtual int next_tile(int& x, int& y)
-       {
-               if(!alive_flag)
-                       return 0;
-
-               return warm_target->next_tile(x,y);
-       }
-
-       virtual int next_frame(Time& time)
-       {
-               if(!alive_flag)
-                       return 0;
-               return warm_target->next_frame(time);
-       }
-
-       virtual bool start_frame(synfig::ProgressCallback *cb=0)
-       {
-               if(!alive_flag)
-                       return false;
-               return warm_target->start_frame(cb);
-       }
-
-       virtual bool add_tile(const synfig::Surface &surface, int gx, int gy)
-       {
-               assert(surface);
-               if(!alive_flag)
-                       return false;
-               Glib::Mutex::Lock lock(mutex);
-               tile_queue.push_back(tile_t(surface,gx,gy));
-               if(tile_queue.size()==1)
-               {
-#ifdef GLIB_DISPATCHER_BROKEN
-               ready_connection=Glib::signal_timeout().connect(
-                       sigc::bind_return(
-                               sigc::mem_fun(*this,&AsyncTarget_Tile::tile_ready),
-                               false
-                       )
-                       ,0
-               );
-#else
-               tile_ready_signal();
-#endif
-               }
-
-               return alive_flag;
-       }
-
-       void tile_ready()
-       {
-               Glib::Mutex::Lock lock(mutex);
-               if(!alive_flag)
-               {
-                       tile_queue.clear();
-                       cond_tile_queue_empty.signal();
-                       return;
-               }
-               while(!tile_queue.empty() && alive_flag)
-               {
-                       tile_t& tile(tile_queue.front());
-
-                       if (getenv("SYNFIG_SHOW_TILE_OUTLINES"))
-                       {
-                               Color red(1,0,0);
-                               tile.surface.fill(red, 0, 0, 1, tile.surface.get_h());
-                               tile.surface.fill(red, 0, 0, tile.surface.get_w(), 1);
-                       }
-
-                       alive_flag=warm_target->add_tile(tile.surface,tile.x,tile.y);
-
-                       tile_queue.pop_front();
-               }
-               cond_tile_queue_empty.signal();
-       }
-
-       virtual void end_frame()
-       {
-#ifdef SINGLE_THREADED
-               if (!single_threaded())
-               {
-#endif
-                       while(alive_flag)
-                       {
-                               Glib::Mutex::Lock lock(mutex);
-                               if(!tile_queue.empty() && alive_flag)
-                               {
-                                       if(cond_tile_queue_empty.timed_wait(mutex,Glib::TimeVal(0,BOREDOM_TIMEOUT)))
-                                               break;
-                               }
-                               else
-                                       break;
-                       }
-#ifdef SINGLE_THREADED
-               }
-#endif
-               Glib::Mutex::Lock lock(mutex);
-               if(!alive_flag)
-                       return;
-               return warm_target->end_frame();
-       }
-};
-
-
-
-class AsyncTarget_Scanline : public synfig::Target_Scanline
-{
-public:
-       etl::handle<synfig::Target_Scanline> warm_target;
-
-       int scanline_;
-       Surface surface;
-
-       Glib::Mutex mutex;
-
-#ifndef GLIB_DISPATCHER_BROKEN
-       Glib::Dispatcher frame_ready_signal;
-#endif
-       Glib::Cond cond_frame_queue_empty;
-       bool alive_flag;
-       bool ready_next;
-       sigc::connection ready_connection;
-
-
-public:
-       AsyncTarget_Scanline(etl::handle<synfig::Target_Scanline> warm_target):
-               warm_target(warm_target)
-       {
-               set_avoid_time_sync(warm_target->get_avoid_time_sync());
-               set_canvas(warm_target->get_canvas());
-               set_quality(warm_target->get_quality());
-               set_remove_alpha(warm_target->get_remove_alpha());
-               set_threads(warm_target->get_threads());
-               set_rend_desc(&warm_target->rend_desc());
-               alive_flag=true;
-#ifndef GLIB_DISPATCHER_BROKEN
-               ready_connection=frame_ready_signal.connect(sigc::mem_fun(*this,&AsyncTarget_Scanline::frame_ready));
-#endif
-               surface.set_wh(warm_target->rend_desc().get_w(),warm_target->rend_desc().get_h());
-       }
-
-       ~AsyncTarget_Scanline()
-       {
-               ready_connection.disconnect();
-       }
-
-       virtual int next_frame(Time& time)
-       {
-               if(!alive_flag)
-                       return 0;
-               return warm_target->next_frame(time);
-
-       }
-
-       void set_dead()
-       {
-               Glib::Mutex::Lock lock(mutex);
-               alive_flag=false;
-       }
-
-       virtual bool start_frame(synfig::ProgressCallback */*cb*/=0)
-       {
-               return alive_flag;
-       }
-
-       virtual void end_frame()
-       {
-               {
-                       Glib::Mutex::Lock lock(mutex);
-
-                       if(!alive_flag)
-                               return;
-                       ready_next=false;
-
-#ifdef GLIB_DISPATCHER_BROKEN
-               ready_connection=Glib::signal_timeout().connect(
-                       sigc::bind_return(
-                               sigc::mem_fun(*this,&AsyncTarget_Scanline::frame_ready),
-                               false
-                       )
-                       ,0
-               );
-#else
-                       frame_ready_signal();
-#endif
-               }
-
-#ifdef SINGLE_THREADED
-               if (single_threaded())
-                       signal_progress()();
-               else
-#endif
-                       while(alive_flag && !ready_next)
-                       {
-                               Glib::Mutex::Lock lock(mutex);
-                               if(cond_frame_queue_empty.timed_wait(mutex,Glib::TimeVal(0,BOREDOM_TIMEOUT)))
-                                       break;
-                       }
-       }
-
-
-       virtual Color * start_scanline(int scanline)
-       {
-               Glib::Mutex::Lock lock(mutex);
-
-               return surface[scanline];
-       }
-
-       virtual bool end_scanline()
-       {
-               return alive_flag;
-       }
-
-       void frame_ready()
-       {
-               Glib::Mutex::Lock lock(mutex);
-               if(alive_flag)
-                       alive_flag=warm_target->add_frame(&surface);
-#ifdef SINGLE_THREADED
-               if (!single_threaded())
-#endif
-                       cond_frame_queue_empty.signal();
-               ready_next=true;
-       }
-};
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-AsyncRenderer::AsyncRenderer(etl::handle<synfig::Target> target_,synfig::ProgressCallback *cb):
-       error(false),
-       success(false),
-       cb(cb)
-#ifdef SINGLE_THREADED
-       , updating(false)
-#endif
-{
-       render_thread=0;
-       if(etl::handle<synfig::Target_Tile>::cast_dynamic(target_))
-       {
-               etl::handle<AsyncTarget_Tile> wrap_target(
-                       new AsyncTarget_Tile(etl::handle<synfig::Target_Tile>::cast_dynamic(target_))
-               );
-
-               signal_stop_.connect(sigc::mem_fun(*wrap_target,&AsyncTarget_Tile::set_dead));
-
-               target=wrap_target;
-       }
-       else if(etl::handle<synfig::Target_Scanline>::cast_dynamic(target_))
-       {
-               etl::handle<AsyncTarget_Scanline> wrap_target(
-                       new AsyncTarget_Scanline(
-                               etl::handle<synfig::Target_Scanline>::cast_dynamic(target_)
-                       )
-               );
-
-               signal_stop_.connect(sigc::mem_fun(*wrap_target,&AsyncTarget_Scanline::set_dead));
-
-               target=wrap_target;
-       }
-}
-
-AsyncRenderer::~AsyncRenderer()
-{
-       stop();
-}
-
-void
-AsyncRenderer::stop()
-{
-       if(target)
-       {
-               Glib::Mutex::Lock lock(mutex);
-               done_connection.disconnect();
-
-               if(render_thread)
-               {
-                       signal_stop_();
-
-#if REJOIN_ON_STOP
-#ifdef SINGLE_THREADED
-                       if (!single_threaded())
-#endif
-                               render_thread->join();
-#endif
-
-                       // Make sure all the dispatch crap is cleared out
-                       //Glib::MainContext::get_default()->iteration(false);
-
-                       if(success)
-                               signal_success_();
-
-                       signal_finished_();
-
-                       target=0;
-                       render_thread=0;
-               }
-       }
-}
-
-void
-AsyncRenderer::pause()
-{
-}
-
-void
-AsyncRenderer::resume()
-{
-}
-
-void
-AsyncRenderer::start()
-{
-       done_connection=Glib::signal_timeout().connect(
-               sigc::bind_return(
-                       mem_fun(*this,&AsyncRenderer::start_),
-                       false
-               )
-               ,50
-       );
-}
-
-#ifdef SINGLE_THREADED
-void
-AsyncRenderer::rendering_progress()
-{
-       updating = true;
-       while(studio::App::events_pending()) studio::App::iteration(false);
-       updating = false;
-}
-#endif
-
-void
-AsyncRenderer::start_()
-{
-       error=false;success=false;
-       if(target)
-       {
-#ifndef GLIB_DISPATCHER_BROKEN
-               done_connection=signal_done_.connect(mem_fun(*this,&AsyncRenderer::stop));
-#endif
-
-#ifdef SINGLE_THREADED
-               if (single_threaded())
-               {
-                       synfig::info("%s:%d rendering in the same thread", __FILE__, __LINE__);
-                       target->signal_progress().connect(sigc::mem_fun(this,&AsyncRenderer::rendering_progress));
-                       render_thread = (Glib::Thread*)1;
-                       render_target();
-               }
-               else
-#endif
-               {
-                       render_thread=Glib::Thread::create(
-                               sigc::mem_fun(*this,&AsyncRenderer::render_target),
-#if REJOIN_ON_STOP
-                               true
-#else
-                               false
-#endif
-                               );
-                       assert(render_thread);
-               }
-       }
-       else
-       {
-               stop();
-       }
-}
-
-void
-AsyncRenderer::render_target()
-{
-       etl::handle<Target> target(AsyncRenderer::target);
-
-       if(target && target->render())
-       {
-               success=true;
-       }
-       else
-       {
-               error=true;
-#ifndef REJOIN_ON_STOP
-               return;
-#endif
-       }
-
-       if(mutex.trylock())
-       {
-#ifdef GLIB_DISPATCHER_BROKEN
-               done_connection=Glib::signal_timeout().connect(
-                       sigc::bind_return(
-                               mem_fun(*this,&AsyncRenderer::stop),
-                               false
-                       )
-                       ,0
-               );
-#else
-               signal_done_.emit();
-#endif
-               mutex.unlock();
-       }
-}
diff --git a/synfig-studio/src/gtkmm/asyncrenderer.h b/synfig-studio/src/gtkmm/asyncrenderer.h
deleted file mode 100644 (file)
index 7d865fd..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file asyncrenderer.h
-**     \brief Template Header
-**
-**     $Id$
-**
-**     \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
-**     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_ASYNCRENDERER_H
-#define __SYNFIG_ASYNCRENDERER_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <ETL/handle>
-#include <sigc++/signal.h>
-#include <sigc++/trackable.h>
-#include <sigc++/connection.h>
-
-#include <synfig/target_scanline.h>
-#include <synfig/target_tile.h>
-#include <synfig/surface.h>
-#include <glibmm/main.h>
-#include <ETL/ref_count>
-#include <glibmm/thread.h>
-#include <glibmm/dispatcher.h>
-
-/* === M A C R O S ========================================================= */
-
-// uncomment define SINGLE_THREADED to use a single thread, and hopefully get more stability (dooglus) - changed to be default if using windows (Nov 2009 pixelgeek)
-#ifdef WIN32
-#define SINGLE_THREADED
-#endif
-#ifdef SINGLE_THREADED
-#  define single_threaded()    App::single_threaded
-#endif
-
-/* === 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 AsyncRenderer : public etl::shared_object, public sigc::trackable
-{
-       sigc::signal<void> signal_finished_;
-       sigc::signal<void> signal_success_;
-
-       std::list<sigc::connection> activity_connection_list;
-
-       //etl::handle<synfig::Target_Scanline> target_scanline;
-       //etl::handle<synfig::Target_Tile> target_tile;
-       etl::handle<synfig::Target> target;
-
-       bool error;
-       bool success;
-
-       synfig::ProgressCallback *cb;
-
-       sigc::signal<void> signal_stop_;
-
-       Glib::Thread* render_thread;
-       Glib::Dispatcher signal_done_;
-       Glib::Mutex mutex;
-       sigc::connection done_connection;
-
-       /*
- --    ** -- P A R E N T   M E M B E R S -----------------------------------------
-       */
-public:
-
-       AsyncRenderer(etl::handle<synfig::Target> target,synfig::ProgressCallback *cb=0);
-       virtual ~AsyncRenderer();
-
-       void start();
-       void stop();
-       void pause();
-       void resume();
-#ifdef SINGLE_THREADED
-       void rendering_progress();
-       bool updating;
-#endif
-
-       bool has_error()const { return error; }
-       bool has_success()const { return success; }
-
-       sigc::signal<void>& signal_finished() { return signal_finished_; }
-       sigc::signal<void>& signal_success() { return signal_success_; }
-
-private:
-
-       void render_target();
-       void start_();
-
-       /*
- --    ** -- C H I L D   M E M B E R S -------------------------------------------
-       */
-
-protected:
-
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/audiocontainer.cpp b/synfig-studio/src/gtkmm/audiocontainer.cpp
deleted file mode 100644 (file)
index 70d5dd9..0000000
+++ /dev/null
@@ -1,1429 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file audiocontainer.cpp
-**     \brief Audio Container implementation File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include <algorithm>
-#include <sigc++/signal.h>
-
-#include <ETL/stringf>
-#include <ETL/clock>
-//#include <ETL/thread>
-#include <glibmm/thread.h>
-
-#include <synfig/general.h>
-
-#include <glibmm/main.h>
-
-#include "audiocontainer.h"
-
-#include <cstdio>
-#include <sys/stat.h>
-#include <errno.h>
-
-#include <set>
-#include <vector>
-
-#ifdef WITH_FMOD
-#include <fmod.h>
-#endif
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-using namespace synfig;
-
-/* === M A C R O S ========================================================= */
-#ifdef __WIN32
-#else //linux...
-#define AUDIO_OUTPUT   FSOUND_OUTPUT_OSS
-#endif
-
-/* === G L O B A L S ======================================================= */
-const double delay_factor = 3;
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-/* === E N T R Y P O I N T ================================================= */
-
-//Help constructing stuff
-struct FSOUND_SAMPLE;
-using studio::AudioContainer;
-
-#ifdef WITH_FMOD
-bool build_profile(FSOUND_SAMPLE *sample, double &samplerate, std::vector<char> &samples)
-#else
-bool build_profile(FSOUND_SAMPLE */*sample*/, double &/*samplerate*/, std::vector<char> &/*samples*/)
-#endif
-{
-#ifdef WITH_FMOD
-
-       float sps = samplerate;
-
-       //trivial rejection...
-       if(!sample || sps < 1)
-       {
-               synfig::warning("build_profile: Sample rate was too low or sample was invalid");
-               return false;
-       }
-
-       //lock for all samples and process them into a subset
-       unsigned int mode = FSOUND_Sample_GetMode(sample);
-
-       //make sure that it's 8 bit... I hope this works...
-
-       //sample rate of the actual song...
-       int allsamplerate = 0;
-       FSOUND_Sample_GetDefaults(sample,&allsamplerate,0,0,0);
-
-       //get the size of the sample defaults from the mode
-       int channels = 1;
-       int channelsize = 1; //number of bytes
-
-       if(mode & FSOUND_16BITS) channelsize = 2; //this shouldn't happen
-       if(mode & FSOUND_STEREO) channels = 2;
-
-       //Get the sample information
-       int samplesize = channels*channelsize; //the only two things that increase samplesize
-       int numsamples = FSOUND_Sample_GetLength(sample); //number of samples in the sound
-       int sizeall = samplesize*numsamples; //should be the size of the entire song...
-
-       if(sizeall <= 0)
-       {
-               synfig::warning("ProfileAudio: Sample buffer cannot be size smaller than 1 (%X)",FSOUND_GetError());
-               return false;
-       }
-
-       //be sure that the new sample rate is less than or equal to the original
-       if(sps > allsamplerate) sps = allsamplerate;
-
-       float stride = allsamplerate/(float)sps;
-
-       //down sampling to 8 bit min/max values
-       synfig::warning("About to downsample from %d Hz to %.1f Hz, sample stride: %f", allsamplerate, sps, stride);
-
-       char *sampledata=0,*useless = 0;
-       unsigned int len1,len2;
-       // vector<char> samples;
-       {
-               if(!FSOUND_Sample_Lock(sample,0,sizeall,(void**)&sampledata,(void**)&useless,&len1,&len2))
-               {
-                       synfig::warning("ProfileAudio: Unable to lock the sound buffer... (%X)",FSOUND_GetError());
-                       return false;
-               }
-               synfig::warning("Locked: %X: %d bytes, %X: %d bytes",sampledata,len1,useless,len2);
-
-               if(channelsize == 1)
-               {
-                       //process the data
-                       char *iter = sampledata;
-                       char *end = iter + sizeall;
-
-                       float curaccum = 0;
-                       float numinc = sps/(float)allsamplerate;
-
-                       /* Loop per sample DDA alg.
-                       */
-
-                       int i = 0;
-
-                       //HACK - to prevent if statement inside inner loop
-                       //synfig::warning("wo baby wo baby, inc: %d, stride: %f, size: %d", inc, stride, sizeall);
-                       while(iter < end)
-                       {
-                               int maxs = 0, mins = 0;
-
-                               for(;curaccum < 1; curaccum += numinc)
-                               {
-                                       for(i = 0; iter < end && i < channels; ++i, iter += channelsize)
-                                       {
-                                               maxs = std::max(maxs,(int)*iter);
-                                               mins = std::min(mins,(int)*iter);
-                                       }
-                               }
-                               //insert onto new list
-                               samples.push_back(maxs);
-                               samples.push_back(mins);
-
-                               //and flush all the used samples for curaccum
-                               curaccum -= 1;
-                       }
-               }else if(channelsize == 2)
-               {
-                       //process the data
-                       char *iter = sampledata;
-                       char *end = iter + sizeall;
-
-                       float curaccum = 0;
-                       float numinc = sps/(float)allsamplerate;
-
-                       /* Loop per sample DDA alg.
-                       */
-
-                       int i = 0;
-
-                       //HACK - to prevent if statement inside inner loop
-                       //synfig::warning("wo baby wo baby, inc: %d, stride: %f, size: %d", inc, stride, sizeall);
-                       while(iter < end)
-                       {
-                               int maxs = 0, mins = 0;
-
-                               for(;curaccum < 1; curaccum += numinc)
-                               {
-                                       for(i = 0; iter < end && i < channels; ++i, iter += channelsize)
-                                       {
-                                               maxs = std::max(maxs,(int)*(short*)iter);
-                                               mins = std::min(mins,(int)*(short*)iter);
-                                       }
-                               }
-                               //insert onto new list
-                               samples.push_back(maxs / 256);
-                               samples.push_back(mins / 256);
-
-                               //and flush all the used samples for curaccum
-                               curaccum -= 1;
-                       }
-               }
-       }
-
-       synfig::warning("Stats: %f seconds with %d bytes now %d bytes", (samples.size()/2)/sps, sizeall, samples.size());
-       synfig::warning("               %f seconds before", numsamples/(float)allsamplerate);
-
-       //we're done yay!, unlock
-       FSOUND_Sample_Unlock(sample,sampledata,useless,len1,len2);
-       synfig::info("Unlocked");
-
-       //FSOUND_PlaySound(FSOUND_FREE,sound); //test
-
-       //we're done
-       samplerate = sps*2; //it must be x2 because we are sampling max and min
-
-       return true;
-
-       #else
-
-       return false;
-
-       #endif
-}
-
-
-//FMOD Systemwide Specific data mostly here...
-
-struct scrubinfo;
-
-#ifdef WITH_FMOD
-static double  buffer_length_sec = 0;
-
-//------- Scrubbing --------------
-/* Scrubbing works as follows:
-
-       The sound is played using PlaySoundEx
-               we specify a user created DSP for scrubbing
-               set it initially to inactive
-
-       When the program initiates it
-               we set the initial data in the shared structure and activate the dsp unit
-               then for each cursor update we get we set the value in the shared structure
-*/
-
-/* Things to check:
-       If IsPlaying just governs the channel play/stop value or if it also concerns the pause state
-
-*/
-
-//so we can know where to create all this stuff
-struct scrubinfo
-{
-       /*      Linearly fit the frequency to hit the desired zero point...
-       */
-       /*struct scrubelement
-       {
-               double  pos;
-               double  dt;
-               //the amount of time left til the cursor hits this one
-               //      it's incremental so that the cursor must pass previous
-               //      ones before decrementing this value
-       };
-       */
-
-       //the time it should take to get to the next position...
-
-       //to prevent from writing to the same location at once... (pos, deltatime, delaystart)
-       //Glib::Mutex   lock;
-
-       //the queue system would provide a more accurate representation...
-       volatile double pos;
-       volatile double deltatime;
-
-       volatile double delaystart; //the amount of time we need to go before we start interpolating...
-
-       volatile int    channel;
-
-       /*std::list<scrubelement>       queue;
-
-       volatile int    channel;
-
-       //current position is FSOUND_GetCurrentPosition and current time is always 0...
-
-       void add(const scrubelement &elem)
-       {
-               lock.LockWrite();
-
-               queue.push_back(elem);
-
-               lock.UnlockWrite();
-       }
-
-       //Function to safely get rid of all the old samples (dt < 0)
-       void flush()
-       {
-               lock.LockWrite();
-
-               while(queue.size() && queue.front().dt < 0)
-               {
-                       queue.pop_front();
-               }
-
-               lock.UnlockWrite();
-       }*/
-
-       void Lock()
-       {
-               //lock.lock();
-       }
-
-       void Unlock()
-       {
-               //lock.unlock();
-       }
-
-       //All parameters and state should be set by the time we get here...
-       void scrub_dsp_process()
-       {
-               const double epsilon = 1e-5;
-
-               //Trivial reject... we go nowhere if we aren't playing (hit boundary...)
-               if(!FSOUND_IsPlaying(channel)) return;
-
-               //Get rid of all the old samples
-               //flush();
-
-               //Trivial reject #2 - We also go nowhere with no future samples (pause)
-               /*if(queue.size() <= 0)
-               {
-                       FSOUND_SetPaused(channel,true);
-                       return;
-               }*/
-
-               double dt = buffer_length_sec;
-
-               //Lock ourselves so we don't die
-               Lock();
-
-               //printf("DSP data: delay = %.3f s, pos = %d, dt = %.3f\n", delaystart, (int)pos, deltatime);
-
-               //Check delay
-               if(delaystart > 0)
-               {
-                       delaystart -= dt;
-
-                       if(delaystart < 0)
-                       {
-                               dt = -delaystart; //add time back...
-                               delaystart = 0;
-                       }
-               }
-
-               //Trivial reject for if we're past current sample...
-               if(delaystart > 0 || deltatime <= 0)
-               {
-                       FSOUND_SetPaused(channel,true);
-                       Unlock();
-                       return;
-               }
-
-               //Calculate stretched frequency based on delayed future sample...
-
-               //NOTE: BY NOT TRACKING POSITION AS A FLOAT AND JUST USING THE SOUNDS VALUE
-               //              WE ARE LOSING A TINY AMOUNT OF PRECISION ACCURACY EVERY UPDATE
-               //              (THIS SHOULDN'T BE A PROBLEM)
-               const double p0 = FSOUND_GetCurrentPosition(channel);
-               double curdp = 0;
-
-               if(!FSOUND_GetPaused(channel))
-               {
-                       curdp = FSOUND_GetFrequency(channel) * deltatime;
-               }
-
-               //need to rescale derivative...
-
-               //Extrapolate from difference in position and deltatime vs dt...
-               const double pa = p0 + curdp/2;
-
-               const double p1 = pos;
-
-               //const double pb = p0/3 + p1*2/3;
-
-               //will extrapolate if needed... (could be funky on a curve)
-               double t = 0;
-               if(deltatime > epsilon)
-               {
-                       t = dt / deltatime;
-               }
-
-               //Decrement deltatime (we may have gone past but that's what happens when we don't get input...)
-               deltatime -= dt;
-
-               //we don't need to look at the current variables anymore...
-               Unlock();
-
-               const double invt = 1-t;
-               //double deltapos = (p1-p0)*t; //linear version
-               double deltapos = invt*invt*p0 + 2*t*invt*pa + t*t*p1 - p0; //quadratic smoothing version
-
-               //Attempted cubic smoothing
-               //const double invt2 = invt*invt;
-               //const double t2 = t*t;
-               //double deltapos = invt2*invt*p0 + 3*t*invt2*pa + 3*t2*invt*pb + t2*t*p1;
-               //double deltapos = p0 + t*(3*(pa-p0) + t*(3*(p0+2*pa+pb) + t*((p1-3*pb+3*ba-p0)))); //unwound cubic
-
-               //printf("\ttime = %.2f; p(%d,%d,%d) dp:%d - delta = %d\n",t,(int)p0,(int)p1,(int)p2,(int)curdp,(int)deltapos);
-
-               //Based on the delta info calculate the stretched frequency
-               const int dest_samplesize = FSOUND_DSP_GetBufferLength();
-
-               //rounded to nearest frequency... (hopefully...)
-               int freq = (int)(deltapos * FSOUND_GetOutputRate() / (double)dest_samplesize);
-
-               //NOTE: WE MIGHT WANT TO DO THIS TO BE MORE ACCURATE BUT YEAH... ISSUES WITH SMALL NUMBERS
-               //double newdp = deltapos / t;
-
-               //printf("\tfreq = %d Hz\n", freq);
-
-               // !If I failed... um assume we have to pause it... ?
-               if(abs(freq) < 100)
-               {
-                       FSOUND_SetPaused(channel,true);
-               }else
-               {
-                       //synfig::info("DSP f = %d Hz", freq);
-                       FSOUND_SetPaused(channel,false);
-                       if(!FSOUND_SetFrequency(channel,freq))
-                       {
-                               //ERROR WILL ROBINSON!!!...
-                               printf("Error in Freq... what do I do?\n");
-                       }
-               }
-       }
-};
-
-struct scrubuserdata
-{
-       /* //for use with multiple
-       //each one is a 'handle' to a pointer that will be effected by something else
-       typedef scrubinfo**     value_type;
-       typedef std::set< value_type > scrubslist;
-       scrubslist              scrubs;
-
-       //so we can lock access to the list...
-       ReadWriteLock   lock;
-
-       void AddScrub(scrubinfo **i)
-       {
-               lock.LockWrite();
-               scrubs.insert(i);
-               lock.UnLockWrite();
-       }
-
-       void RemoveScrub(scrubinfo **i)
-       {
-               lock.LockWrite();
-               scrubs.erase(i);
-               lock.UnLockWrite();
-       }*/
-
-       scrubinfo * volatile *  scrub;
-};
-
-//Scrubbing data structures
-static const int               default_scrub_priority = 5; //between clear and sfx/music mix
-static scrubuserdata   g_scrubdata = {0};
-static FSOUND_DSPUNIT  *scrubdspunit = 0;
-
-void * scrubdspwrap(void *originalbuffer, void *newbuffer, int length, void *userdata)
-{
-       //std::string   dsp = "DSP";
-       if(userdata)
-       {
-               scrubuserdata &sd = *(scrubuserdata*)userdata;
-
-               /* //For use with multiple scrubs...
-               //Lock so no one can write to it while we're reading from it...
-               sd.lock.LockRead();
-
-               //make a copy of it...
-               std::vector<scrubinfo**>        v(sd.scrubs.begin(),sd.scrubs.end());
-
-               //other things can do stuff with it again...
-               sd.lock.UnLockRead();
-
-               //loop through the list and process all the active scrub units
-               std::vector<scrubinfo**>::iterator      i = v.begin(),
-                                                                                       end = v.end();
-               for(;i != end; ++i)
-               {
-                       //check to make sure this object is active...
-                       if(*i && **i)
-                       {
-                               (**i)->scrub_dsp_process();
-                       }
-               }
-               */
-
-               if(sd.scrub && *sd.scrub)
-               {
-                       //dsp += " processing...";
-                       scrubinfo * info = (*sd.scrub);
-                       info->scrub_dsp_process();
-               }
-       }
-
-       //synfig::info(dsp);
-
-       return newbuffer;
-}
-
-//------- Class for loading fmod on demand -------
-
-class FMODInitializer
-{
-       bool loaded;
-       int     refcount;
-
-public:
-       FMODInitializer():loaded(false),refcount(0) {}
-       ~FMODInitializer()
-       {
-               clear();
-       }
-
-       void addref()
-       {
-               if(!loaded)
-               {
-                       #ifdef WITH_FMOD
-                       synfig::info("Initializing FMOD on demand...");
-
-                       {
-                               FSOUND_SetOutput(AUDIO_OUTPUT);
-
-                               /*int numdrivers = FSOUND_GetNumDrivers();
-                               synfig::info("Num FMOD drivers = %d",numdrivers);
-                               synfig::info("Current Driver is #%d", FSOUND_GetDriver());
-
-                               for(int i = 0; i < numdrivers; ++i)
-                               {
-                                       unsigned int caps = 0;
-                                       FSOUND_GetDriverCaps(i,&caps);
-
-                                       synfig::info("   Caps for driver %d (%s) = %x",i,FSOUND_GetDriverName(i),caps);
-                               }
-
-                               FSOUND_SetDriver(0);*/
-
-                               //Modify buffer size...
-                               //FSOUND_SetBufferSize(100);
-
-                               if(!FSOUND_Init(44100, 32, 0))
-                               {
-                                       synfig::warning("Unable to load FMOD");
-                               }else
-                               {
-                                       loaded = true;
-
-                                       //Create the DSP for processing scrubbing...
-                                       scrubdspunit = FSOUND_DSP_Create(&scrubdspwrap,default_scrub_priority,&g_scrubdata);
-
-                                       //Load the number of sec per buffer into the global variable...
-                                       buffer_length_sec = FSOUND_DSP_GetBufferLength() / (double)FSOUND_GetOutputRate();
-                               }
-                       }
-                       #endif
-               }
-
-               //add to the refcount
-               ++refcount;
-               //synfig::info("Audio: increment fmod refcount %d", refcount);
-       }
-
-       void decref()
-       {
-               if(refcount <= 0)
-               {
-                       synfig::warning("FMOD refcount is already 0...");
-               }else
-               {
-                       --refcount;
-                       //synfig::info("Audio: decrement fmod refcount %d", refcount);
-
-                       //NOTE: UNCOMMENT THIS IF YOU WANT FMOD TO UNLOAD ITSELF WHEN IT ISN'T NEEDED ANYMORE...
-                       flush();
-               }
-       }
-
-       bool is_loaded() const { return loaded; }
-
-       void clear()
-       {
-               refcount = 0;
-               flush();
-       }
-
-       void flush()
-       {
-               if(loaded && refcount <= 0)
-               {
-                       #ifdef WITH_FMOD
-                       synfig::info("Unloading FMOD");
-                       if(scrubdspunit) FSOUND_DSP_Free(scrubdspunit);
-                       FSOUND_Close();
-                       #endif
-                       loaded = false;
-               }
-       }
-};
-
-//The global counter for FMOD....
-FMODInitializer                fmodinit;
-
-#endif
-
-//----- AudioProfile Implementation -----------
-void studio::AudioProfile::clear()
-{
-       samplerate = 0;
-       samples.clear();
-}
-
-handle<AudioContainer> studio::AudioProfile::get_parent() const
-{
-       return parent;
-}
-
-void studio::AudioProfile::set_parent(etl::handle<AudioContainer> i)
-{
-       parent = i;
-}
-
-double studio::AudioProfile::get_offset() const
-{
-       if(parent)
-               return parent->get_offset();
-       return 0;
-}
-
-//---------- AudioContainer definitions ---------------------
-
-struct studio::AudioContainer::AudioImp
-{
-       //Sample load time information
-       FSOUND_SAMPLE *         sample;
-       int                                     channel;
-       int                                     sfreq;
-       int                                     length;
-
-       //Time information
-       double                          offset; //time offset for playing...
-
-       //We don't need it now that we've adopted the play(t) time schedule...
-       //current time... and playing info....
-       //float                         seekpost;
-       //bool                          useseekval;
-
-       //Make sure to sever our delayed start if we are stopped prematurely
-       sigc::connection        delaycon;
-
-       //Action information
-       bool                            playing;
-       double                          curscrubpos;
-       etl::clock                      timer;  //for getting the time diff between scrub input points
-
-       //Scrubbing information...
-       //the current position of the sound will be sufficient for normal stuff...
-       #ifdef WITH_FMOD
-       scrubinfo                       scrinfo;
-       #endif
-
-       scrubinfo                       *scrptr;
-
-       bool is_scrubbing() const {return scrptr != 0;}
-#ifdef WITH_FMOD
-       void set_scrubbing(bool s)
-#else
-       void set_scrubbing(bool /*s*/)
-#endif
-       {
-               #ifdef WITH_FMOD
-               if(s)
-                       scrptr = &scrinfo;
-               else
-               #endif
-               scrptr = 0;
-       }
-
-       //helper to make sure we are actually playing (and to get a new channel...)
-       bool init_play()
-       {
-               #ifdef WITH_FMOD
-               if(!FSOUND_IsPlaying(channel))
-               {
-                       if(sample)
-                       {
-                               //play sound paused etc.
-                               channel = FSOUND_PlaySoundEx(FSOUND_FREE,sample,0,true);
-                               if(channel < 0 || FSOUND_GetError() != FMOD_ERR_NONE)
-                               {
-                                       synfig::warning("Could not play the sample...");
-                                       return false;
-                               }
-                       }
-               }else
-               {
-                       FSOUND_SetPaused(channel,true);
-                       FSOUND_SetFrequency(channel,sfreq);
-               }
-               return true;
-
-               #else
-
-               return false;
-
-               #endif
-       }
-
-public: //structors
-       AudioImp()
-       :sample(0),
-       channel(0),
-       sfreq(0),
-       length(0),
-       offset(0),
-       playing(false),
-       scrptr(0)
-       {
-               //reuse the channel...
-               #ifdef WITH_FMOD
-               channel = FSOUND_FREE;
-               #endif
-       }
-
-       ~AudioImp()
-       {
-               clear();
-       }
-
-public: //helper/accessor funcs
-       bool start_playing_now() //callback for timer...
-       {
-               #ifdef WITH_FMOD
-               if(playing)
-               {
-                       //Make sure the sound is playing and if it is un pause it...
-                       if(init_play())
-                               FSOUND_SetPaused(channel,false);
-               }
-               #endif
-
-               return false; //so the timer doesn't repeat itself
-       }
-
-       bool isRunning()
-       {
-               #ifdef WITH_FMOD
-               return FSOUND_IsPlaying(channel);
-               #else
-               return false;
-               #endif
-       }
-
-       bool isPaused()
-       {
-#ifdef WITH_FMOD
-               return FSOUND_GetPaused(channel);
-#else
-               return false;
-#endif
-       }
-
-
-public: //forward interface
-
-       //Accessors for the offset - in seconds
-       const double &get_offset() const {return offset;}
-       void set_offset(const double &d)
-       {
-               offset = d;
-       }
-
-       //Will override the parameter timevalue if the sound is running, and not if it's not...
-#ifdef WITH_FMOD
-       bool get_current_time(double &out)
-#else
-       bool get_current_time(double &/*out*/)
-#endif
-       {
-               if(isRunning())
-               {
-                       #ifdef WITH_FMOD
-                       unsigned int pos = FSOUND_GetCurrentPosition(channel);
-
-                       //adjust back by 1 frame... HACK....
-                       //pos -= FSOUND_DSP_GetBufferLength();
-
-                       //set the position
-                       out = pos/(double)sfreq + offset;
-                       #endif
-
-                       return true;
-               }
-               return false;
-       }
-
-       //Big implementation functions...
-       bool load(const std::string &filename, const std::string &filedirectory);
-       void clear();
-
-       //playing functions
-       void play(double t);
-       void stop();
-
-       //scrubbing functions
-       void start_scrubbing(double t);
-       void scrub(double t);
-       void stop_scrubbing();
-
-       double scrub_time()
-       {
-               return curscrubpos;
-       }
-};
-
-//--------------- Audio Container definitions --------------------------
-studio::AudioContainer::AudioContainer()
-{
-       imp = 0;
-}
-
-studio::AudioContainer::~AudioContainer()
-{
-       if(imp) delete (imp);
-}
-
-bool studio::AudioContainer::load(const std::string &filename,const std::string &filedirectory)
-{
-       if(!imp)
-       {
-               imp = new AudioImp;
-       }
-
-       profilevalid = false;
-       return imp->load(filename,filedirectory);
-}
-
-#ifdef WITH_FMOD
-handle<studio::AudioProfile> studio::AudioContainer::get_profile(float samplerate)
-#else
-handle<studio::AudioProfile> studio::AudioContainer::get_profile(float /*samplerate*/)
-#endif
-{
-       #ifdef WITH_FMOD
-
-       //if we already have done our work, then we're good
-       if(profilevalid && prof)
-       {
-               //synfig::info("Using already built profile");
-               return prof;
-       }
-
-       //synfig::info("Before profile");
-       //make a new profile at current sample rate
-
-       //NOTE: We might want to reuse the structure already there...
-       prof = new AudioProfile;
-       prof->set_parent(this); //Our parent is THIS!!!
-
-       if(!prof)
-       {
-               synfig::warning("Couldn't allocate audioprofile...");
-               return handle<studio::AudioProfile>();
-       }
-
-       //setting the info for the sample rate
-       //synfig::info("Setting info...");
-
-       synfig::info("Building Profile...");
-       prof->samplerate = samplerate;
-       if(build_profile(imp->sample,prof->samplerate,prof->samples))
-       {
-               synfig::info("  Success!");
-               profilevalid = true;
-               return prof;
-       }else
-       {
-               return handle<studio::AudioProfile>();
-       }
-
-       #else
-
-       return handle<studio::AudioProfile>();
-
-       #endif
-}
-
-void studio::AudioContainer::clear()
-{
-       if(imp)
-       {
-               delete imp;
-               imp = 0;
-       }
-
-       profilevalid = false;
-}
-
-void studio::AudioContainer::play(double t)
-{
-       if(imp) imp->play(t);
-}
-
-void studio::AudioContainer::stop()
-{
-       if(imp) imp->stop();
-}
-
-bool studio::AudioContainer::get_current_time(double &out)
-{
-       if(imp) return imp->get_current_time(out);
-       else return false;
-}
-
-void AudioContainer::set_offset(const double &s)
-{
-       if(imp) imp->set_offset(s);
-}
-
-double AudioContainer::get_offset() const
-{
-       static double zero = 0;
-       if(imp)
-               return imp->get_offset();
-       return zero;
-}
-
-bool AudioContainer::is_playing() const
-{
-       if(imp)
-               return imp->playing;
-       return false;
-}
-
-bool AudioContainer::is_scrubbing() const
-{
-       if(imp)
-               return imp->is_scrubbing();
-       return false;
-}
-
-void AudioContainer::start_scrubbing(double t)
-{
-       if(imp) imp->start_scrubbing(t);
-}
-
-void AudioContainer::stop_scrubbing()
-{
-       if(imp) imp->stop_scrubbing();
-}
-
-void AudioContainer::scrub(double t)
-{
-       if(imp) imp->scrub(t);
-}
-
-double AudioContainer::scrub_time() const
-{
-       if(imp) return imp->scrub_time();
-       else return 0;
-}
-
-bool AudioContainer::isRunning() const
-{
-       if(imp) return imp->isRunning();
-       else return false;
-}
-
-bool AudioContainer::isPaused() const
-{
-       if(imp) return imp->isPaused();
-       else return false;
-}
-
-//----------- Audio imp information -------------------
-
-#ifdef WITH_FMOD
-bool studio::AudioContainer::AudioImp::load(const std::string &filename,
-                                                                                       const std::string &filedirectory)
-#else
-bool studio::AudioContainer::AudioImp::load(const std::string &/*filename*/,
-                                                                                       const std::string &/*filedirectory*/)
-#endif
-{
-       clear();
-
-       #ifdef WITH_FMOD
-
-       //And continue with the sound loading...
-       string  file = filename;
-
-       //Trivial reject... (fixes stat call problem... where it just looks at directory and not file...)
-       if(file.length() == 0) return false;
-
-       //we don't need the file directory?
-       if(!is_absolute_path(file))
-       {
-               file=filedirectory+filename;
-               synfig::warning("Not absolute hoooray");
-       }
-       synfig::info("Loading Audio file: %s", file.c_str());
-
-       //check to see if file exists
-       {
-               struct stat     s;
-               if(stat(file.c_str(),&s) == -1 && errno == ENOENT)
-               {
-                       synfig::info("There was no audio file...");
-                       return false;
-               }
-       }
-
-       //load fmod if we can...
-       //synfig::warning("I'm compiled with FMOD!");
-       fmodinit.addref();
-
-       //load the stream
-       int ch = FSOUND_FREE;
-       FSOUND_SAMPLE *sm = FSOUND_Sample_Load(FSOUND_FREE,file.c_str(),FSOUND_LOOP_OFF|FSOUND_MPEGACCURATE,0,0);
-
-       if(!sm)
-       {
-               synfig::warning("Could not open the audio file as a sample: %s",file.c_str());
-               goto error;
-       }
-
-       //synfig::warning("Opened a file as a sample! :)");
-
-       /*{
-               int bufferlen = FSOUND_DSP_GetBufferLength();
-               synfig::info("Buffer length = %d samples, %.3lf s",bufferlen, bufferlen / (double)FSOUND_GetOutputRate());
-       }*/
-
-       //set all the variables since everything has worked out...
-       //get the length of the stream
-       {
-               length = FSOUND_Sample_GetLength(sm);
-
-               int volume = 0;
-               FSOUND_Sample_GetDefaults(sm,&sfreq,&volume,0,0);
-
-               //double len = length / (double)sfreq;
-               //synfig::info("Sound info: %.2lf s long, %d Hz, %d Vol",(double)length,sfreq,volume);
-       }
-
-       //synfig::warning("Got all info, and setting up everything, %.2f sec.", length);
-       //synfig::warning("     BigSample: composed of %d samples", FSOUND_Sample_GetLength(sm));
-       synfig::info("Successfully opened %s as a sample and initialized it.",file.c_str());
-
-       //set up the playable info
-       sample = sm;
-       channel = ch;
-
-       //the length and sfreq params have already been initialized
-
-       return true;
-
-error:
-       if(sm) FSOUND_Sample_Free(sm);
-       file = "";
-
-       fmodinit.decref();
-
-       return false;
-
-       #else
-       return false;
-       #endif
-}
-
-#ifdef WITH_FMOD
-void studio::AudioContainer::AudioImp::play(double t)
-#else
-void studio::AudioContainer::AudioImp::play(double /*t*/)
-#endif
-{
-       #ifdef WITH_FMOD
-       if(!sample) return;
-
-       //stop scrubbing if we are...
-       if(is_scrubbing()) stop_scrubbing();
-
-       //t -= offset;
-       t -= get_offset();
-       playing = true;
-
-       if(t < 0)
-       {
-               unsigned int timeout = (int)floor(-t * 1000 + 0.5);
-               //synfig::info("Playing audio delayed by %d ms",timeout);
-               //delay for t seconds...
-               delaycon = Glib::signal_timeout().connect(
-                                               sigc::mem_fun(*this,&studio::AudioContainer::AudioImp::start_playing_now),timeout);
-
-               init_play();
-               FSOUND_SetFrequency(channel,sfreq);
-               FSOUND_SetCurrentPosition(channel,0);
-               return;
-       }
-
-       unsigned int position = (int)floor(t*sfreq + 0.5);
-
-       if(position >= FSOUND_Sample_GetLength(sample))
-       {
-               synfig::warning("Can't play audio when past length...");
-               return;
-       }
-
-       init_play();
-       FSOUND_SetFrequency(channel,sfreq);
-       FSOUND_SetCurrentPosition(channel,position);
-       FSOUND_SetPaused(channel,false);
-
-       //synfig::info("Playing audio with position %d samples",position);
-
-       #endif
-}
-
-void studio::AudioContainer::AudioImp::stop()
-{
-       delaycon.disconnect();
-
-       #ifdef WITH_FMOD
-       if(fmodinit.is_loaded() && playing && isRunning())
-       {
-               FSOUND_SetPaused(channel,true);
-       }
-       #endif
-
-       playing = false;
-}
-
-void studio::AudioContainer::AudioImp::clear()
-{
-       #ifdef WITH_FMOD
-       delaycon.disconnect();
-
-       stop();
-       stop_scrubbing();
-
-       if(sample)
-       {
-               if(FSOUND_IsPlaying(channel))
-               {
-                       FSOUND_StopSound(channel);
-               }
-               channel = FSOUND_FREE;
-               FSOUND_Sample_Free(sample);
-               fmodinit.decref();
-       }
-
-       playing = false;
-
-       #else
-       channel = 0;
-       #endif
-
-       sample = 0;
-       playing = false;
-}
-
-#ifdef WITH_FMOD
-void studio::AudioContainer::AudioImp::start_scrubbing(double t)
-#else
-void studio::AudioContainer::AudioImp::start_scrubbing(double /*t*/)
-#endif
-{
-       //synfig::info("Start scrubbing: %lf", t);
-       if(playing) stop();
-
-       set_scrubbing(true);
-
-       #ifdef WITH_FMOD
-       //make sure the other one is not scrubbing...
-       if(g_scrubdata.scrub)
-       {
-               *g_scrubdata.scrub = 0; //nullify the pointer...
-       }
-
-       //Set up the initial state for the delayed audio position
-       scrinfo.delaystart = 0;
-       scrinfo.pos = 0;
-       scrinfo.deltatime = 0;
-
-       //set it to point to our pointer (dizzy...)
-       g_scrubdata.scrub = &scrptr;
-
-       //setup position info so we can know what to do on boundary conditions...
-       curscrubpos = (t - get_offset()) * sfreq;
-
-       //So we can get an accurate difference...
-       timer.reset();
-
-       //reposition the sound if it won't be when scrubbed (if it's already in the range...)
-       int curi = (int)curscrubpos;
-       if(curi >= 0 && curi < length)
-       {
-               init_play();
-               FSOUND_SetCurrentPosition(channel,curi);
-
-               //Set the values...
-               scrinfo.pos = curscrubpos;
-               scrinfo.delaystart = delay_factor*buffer_length_sec;
-
-               //synfig::info("\tStarting at %d samps, with %d p %.3f delay",
-               //                              FSOUND_GetCurrentPosition(channel), (int)scrinfo.pos, scrinfo.delaystart);
-       }
-
-
-
-       //enable the dsp...
-       //synfig::info("\tActivating DSP");
-       FSOUND_DSP_SetActive(scrubdspunit,true);
-       #endif
-}
-
-void studio::AudioContainer::AudioImp::stop_scrubbing()
-{
-       //synfig::info("Stop scrubbing");
-
-       if(is_scrubbing())
-       {
-               set_scrubbing(false);
-
-               #ifdef WITH_FMOD
-               g_scrubdata.scrub = 0;
-
-               //stop the dsp...
-               //synfig::info("\tDeactivating DSP");
-               FSOUND_DSP_SetActive(scrubdspunit,false);
-               if(FSOUND_IsPlaying(channel)) FSOUND_SetPaused(channel,true);
-               #endif
-       }
-
-       curscrubpos = 0;
-}
-
-#ifdef WITH_FMOD
-void studio::AudioContainer::AudioImp::scrub(double t)
-#else
-void studio::AudioContainer::AudioImp::scrub(double /*t*/)
-#endif
-{
-       #ifdef WITH_FMOD
-       //synfig::info("Scrub to %lf",t);
-       if(is_scrubbing())
-       {
-               //What should we do?
-
-               /* Different special cases
-                       All outside, all inside,
-                       coming in (left or right),
-                       going out (left or right)
-               */
-               double oldpos = curscrubpos;
-               double newpos = (t - get_offset()) * sfreq;
-
-               curscrubpos = newpos;
-
-               //Ok the sound is running, now we need to tweak it
-               if(newpos > oldpos)
-               {
-                       //Outside so completely stopped...
-                       if(newpos < 0 || oldpos >= length)
-                       {
-                               //synfig::info("\tOut +");
-                               if(FSOUND_IsPlaying(channel))
-                               {
-                                       FSOUND_SetPaused(channel,true);
-                               }
-
-                               //Zero out the data!
-                               scrinfo.Lock();
-                               scrinfo.delaystart = 0;
-                               scrinfo.deltatime = 0;
-                               scrinfo.Unlock();
-
-                               return;
-                       }
-
-                       //going in? - start the sound at the beginning...
-                       /*else if(oldpos < 0)
-                       {
-                               //Set up the sound to be playing paused at the start...
-                               init_play();
-                               FSOUND_SetCurrentPosition(channel,0);
-
-                               synfig::info("\tIn + %d", FSOUND_GetCurrentPosition(channel));
-
-                               scrinfo.Lock();
-                               scrinfo.pos = 0;
-                               scrinfo.delaystart = delay_factor*buffer_length_sec;
-                               scrinfo.deltatime = 0;
-                               scrinfo.Unlock();
-                       }*/
-                       //don't need to deal with leaving... automatically dealt with...
-
-                       else //We're all inside...
-                       {
-                               //Set new position and decide what to do with time...
-                               scrinfo.Lock();
-                               scrinfo.pos = newpos;
-
-                               //should we restart the delay cycle... (is it done?)
-                               if(!isRunning() || (scrinfo.delaystart <= 0 && scrinfo.deltatime <= 0 && isPaused()))
-                               {
-                                       //synfig::info("Starting + at %d",(int)newpos);
-                                       scrinfo.deltatime = 0;
-                                       scrinfo.delaystart = delay_factor*buffer_length_sec;
-                                       scrinfo.Unlock();
-
-                                       //Set up the sound paused at the current position
-                                       init_play();
-                                       int setpos = min(max((int)newpos,0),length);
-                                       FSOUND_SetCurrentPosition(channel,setpos);
-                                       timer.reset();
-                                       return;
-                               }
-
-                               //No! just increment the time delta...
-                               scrinfo.deltatime += timer.pop_time();
-
-                               //Nope... continue and just increment the deltatime and reset position...
-                               scrinfo.Unlock();
-
-                               //set channel and unpause
-                               FSOUND_SetPaused(channel,false);
-                               scrinfo.channel = channel;
-
-                       }
-               }else if(newpos < oldpos)
-               {
-                       //completely stopped...
-                       if(newpos >= length || oldpos < 0)
-                       {
-                               //synfig::info("Out -");
-                               if(FSOUND_IsPlaying(channel))
-                               {
-                                       FSOUND_SetPaused(channel,true);
-                               }
-
-                               //Zero out the data!
-                               scrinfo.Lock();
-                               scrinfo.delaystart = 0;
-                               scrinfo.deltatime = 0;
-                               scrinfo.Unlock();
-                       }
-
-                       //going in? - start going backwards at the end...
-                       /*else if(oldpos >= length)
-                       {
-                               synfig::info("In -");
-                               //Set up the sound to be playing paused at the start...
-                               init_play();
-                               FSOUND_SetCurrentPosition(channel,length-1);
-
-                               scrinfo.Lock();
-                               scrinfo.pos = length-1;
-                               scrinfo.delaystart = delay_factor*buffer_length_sec;
-                               scrinfo.deltatime = 0;
-                               scrinfo.Unlock();
-                       }*/
-                       //we don't have to worry about the leaving case...
-
-                       else //We're all inside...
-                       {
-                               //Set new position and decide what to do with time...
-                               scrinfo.Lock();
-                               scrinfo.pos = newpos;
-
-                               //should we restart the delay cycle... (is it done?)
-                               if(!isRunning() ||(scrinfo.delaystart <= 0 && scrinfo.deltatime <= 0 && isPaused()))
-                               {
-                                       //synfig::info("Starting - at %d",(int)newpos);
-                                       scrinfo.deltatime = 0;
-                                       scrinfo.delaystart = delay_factor*buffer_length_sec;
-                                       scrinfo.Unlock();
-
-                                       //reset timing so next update will be a valid diff...
-                                       init_play();
-                                       int setpos = min(max((int)newpos,0),length);
-                                       FSOUND_SetCurrentPosition(channel,setpos);
-                                       timer.reset();
-                                       return;
-                               }
-
-                               //No! just increment the time delta...
-                               scrinfo.deltatime += timer.pop_time();
-
-                               //Nope... continue and just increment the deltatime and reset position...
-                               scrinfo.Unlock();
-
-                               //set channel and unpause
-                               FSOUND_SetPaused(channel,false);
-                               scrinfo.channel = channel;
-                       }
-               }
-       }
-       #endif
-}
diff --git a/synfig-studio/src/gtkmm/audiocontainer.h b/synfig-studio/src/gtkmm/audiocontainer.h
deleted file mode 100644 (file)
index 21d5f51..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file audiocontainer.h
-**     \brief Sound info 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_AUDIOCONTAINER_H
-#define __SYNFIG_AUDIOCONTAINER_H
-
-/* === H E A D E R S ======================================================= */
-#include <sigc++/signal.h>
-
-#include <ETL/handle>
-
-#include <vector>
-#include <string>
-
-#include <synfig/time.h>
-
-/* === M A C R O S ========================================================= */
-const float DEF_DISPLAYSAMPLERATE = 400;
-/* === 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 AudioContainer;
-
-//Note: Might want to abstract something to share data between profile and parent
-class AudioProfile : public etl::shared_object
-{
-public:
-       typedef std::vector<char>       SampleProfile;
-
-private:
-       SampleProfile   samples;
-       double                  samplerate; //samples / second of the profile
-
-       //reference our parent for any native sound info
-       etl::loose_handle<AudioContainer>       parent;
-
-public:        //samples interface
-
-       SampleProfile::const_iterator   begin() const   {return samples.begin();}
-       SampleProfile::const_iterator   end() const     {return samples.end();}
-
-       void clear();
-       unsigned int size() const {return samples.size();}
-
-       char operator[](int i) const
-       {
-               if(i >= 0 && i < (int)samples.size()) return samples[i];
-               else return 0;
-       }
-
-public: //
-
-       double get_samplerate() const {return samplerate;}
-       void set_samplerate(double f) {samplerate = f;}
-
-       double get_offset() const;
-
-       etl::handle<AudioContainer>     get_parent() const;
-       void set_parent(etl::handle<AudioContainer> i);
-       friend class AudioContainer;
-};
-
-/*     Audio container actually implements all the cool stuff
-       Note: May be a bit too monolithic...
-*/
-class AudioContainer : public sigc::trackable, public etl::shared_object
-{
-       etl::handle<AudioProfile>       prof;
-
-       struct  AudioImp;
-       AudioImp *imp;
-
-       bool    profilevalid; //this is only half useful
-               //it makes it so we don't always have to realloc memory when the file switches...
-
-public: //structors
-
-       AudioContainer();
-       ~AudioContainer();
-
-public: //accessor interface
-       void set_offset(const double &s);
-       double get_offset() const;
-
-public: //info gather interface
-       etl::handle<AudioProfile>       get_profile(float samplerate = DEF_DISPLAYSAMPLERATE);
-       bool get_current_time(double &out);
-
-public: //operational interface
-       bool load(const std::string &filename, const std::string &filedirectory = "");
-       void clear();
-
-       //play functions...
-       void play(double t);
-       void stop();
-       //Note: this refers to the wrapper concept of the audio, the actual sound may or may not be playing...
-       bool is_playing() const;
-
-       //scrubbing functions...
-       void start_scrubbing(double t);
-       void stop_scrubbing();
-       void scrub(double t); //!< if we are not currently scrubbing this will not work
-       bool is_scrubbing() const;
-
-       double scrub_time() const;
-
-       bool isRunning() const;
-       bool isPaused() const;
-};
-
-} // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/autorecover.cpp b/synfig-studio/src/gtkmm/autorecover.cpp
deleted file mode 100644 (file)
index 4e9eeb8..0000000
+++ /dev/null
@@ -1,329 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file autorecover.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 <config.h>
-#endif
-
-#include "autorecover.h"
-
-#ifdef HAVE_SYS_ERRNO_H
-#include <sys/errno.h>
-#endif
-//#include <unistd.h>
-#include "app.h"
-#include <synfig/savecanvas.h>
-#include <synfig/loadcanvas.h>
-#include <fstream>
-#include <iostream>
-#include "instance.h"
-
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-
-#ifdef HAVE_SYS_RESOURCE_H
-#include <sys/resource.h>
-#endif
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#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 ========================================================= */
-
-#ifdef _WIN32
-#define mkdir(x,y) mkdir(x)
-#endif
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-AutoRecover::AutoRecover()
-{
-       // Three Minutes
-       set_timeout(3*60*1000);
-
-       if(mkdir(get_shadow_directory().c_str(),ACCESSPERMS)<0)
-       {
-               if(errno!=EEXIST)
-                       synfig::error("UNABLE TO CREATE \"%s\"",get_shadow_directory().c_str());
-       }
-       else
-       {
-               synfig::info("Created directory \"%s\"",get_shadow_directory().c_str());
-       }
-}
-
-AutoRecover::~AutoRecover()
-{
-}
-
-synfig::String
-AutoRecover::get_shadow_directory()
-{
-       return Glib::build_filename(App::get_user_app_directory(),"tmp");
-}
-
-int
-AutoRecover::pid()
-{
-//     return getpid();
-       return 0;
-}
-
-void
-AutoRecover::set_timeout(int milliseconds)
-{
-       timeout=milliseconds;
-       auto_backup_connect.disconnect();
-       if(timeout)
-               auto_backup_connect=Glib::signal_timeout().connect(sigc::ptr_fun(&AutoRecover::auto_backup),timeout);
-}
-
-synfig::String
-AutoRecover::get_shadow_file_name(const synfig::String& filename)
-{
-       unsigned int hash1(0xdeadbeef);
-       unsigned int hash2(0x83502529);
-       char* str_hash1(reinterpret_cast<char*>(&hash1));
-       char* str_hash2(reinterpret_cast<char*>(&hash2));
-
-       // First we need to hash up the directory
-       {
-               String pool(dirname(filename));
-
-               while(pool.size()>4)
-               {
-                       str_hash1[0]^=pool[1];str_hash1[1]^=pool[2];str_hash1[2]^=pool[3];str_hash1[3]^=pool[0];
-                       str_hash2[3]+=pool[0];str_hash2[2]+=pool[1];str_hash2[1]+=pool[2];str_hash2[0]+=pool[3];
-                       swap(hash1,hash2);
-                       pool=String(pool,4,pool.size());
-               }
-               while(pool.size())
-               {
-                       str_hash1[0]^=pool[0];
-                       str_hash1[2]^=pool[0];
-                       str_hash2[1]^=pool[0];
-                       str_hash2[3]^=pool[0];
-                       swap(hash1,hash2);
-                       pool=String(pool,1,pool.size());
-               }
-       }
-       hash1^=hash2;
-
-       return Glib::build_filename(get_shadow_directory(),strprintf("%08X-%s",hash1,basename(filename).c_str()));
-
-//     return dirname(filename) + ETL_DIRECTORY_SEPARATOR + ".shadow_" + basename(filename);
-}
-
-bool
-AutoRecover::cleanup_pid(int pid)
-{
-#ifdef HAVE_FORK
-       int status=0;
-       if(waitpid(pid,&status,WNOHANG)==-1)
-       {
-               synfig::info("PID %d isn't a zombie yet",pid);
-               return true;
-       }
-       if(WEXITSTATUS(status)!=0)
-       {
-               synfig::error("Autobackup seems to have failed! (PID=%d)",pid);
-       }
-//     else
-//             synfig::info("PID=%d has been cleaned up",pid);
-#endif
-       return false;
-}
-
-bool
-AutoRecover::auto_backup()
-{
-       int pid(0);
-
-#ifdef HAVE_FORK
-       pid=fork();
-#endif
-
-       if(pid<=0)
-       {
-#ifdef HAVE_SETPRIORITY
-               // make us low priority so that we don't
-               // cause the machine to slow down too much
-               setpriority(PRIO_PROCESS,0,15);
-#endif
-
-               try
-               {
-                       std::list<etl::handle<Instance> >::iterator iter;
-
-                       std::string filename=App::get_config_file("autorecovery");
-                       std::ofstream file(filename.c_str());
-
-                       int savecount(0);
-
-                       for(iter=App::instance_list.begin();iter!=App::instance_list.end();++iter)
-                       {
-                               // If this file hasn't even been changed
-                               // since it was last saved, then don't bother
-                               // backing it up.
-                               if((*iter)->get_action_count()==0)
-                                       continue;
-
-                               Canvas::Handle canvas((*iter)->get_canvas());
-                               file<<canvas->get_file_name()<<endl;
-                               save_canvas(get_shadow_file_name(canvas->get_file_name()),canvas);
-                               savecount++;
-                       }
-
-//                     if(savecount)
-//                             synfig::info("AutoRecover::auto_backup(): %d Files backed up.",savecount);
-               }
-               catch(...)
-               {
-                       synfig::error("AutoRecover::auto_backup(): UNKNOWN EXCEPTION THROWN.");
-                       synfig::error("AutoRecover::auto_backup(): FILES NOT BACKED UP.");
-               }
-
-#ifdef HAVE_FORK
-               if(pid==0)
-               {
-                       _exit(0);
-               }
-#endif
-       }
-
-#ifdef HAVE_FORK
-       Glib::signal_timeout().connect(
-               sigc::bind(
-                       sigc::ptr_fun(&AutoRecover::cleanup_pid),
-                       pid
-               ),
-               60*1000
-       );
-#endif
-
-       // Also go ahead and save the settings
-       App::save_settings();
-
-       return true;
-}
-
-bool
-AutoRecover::recovery_needed()const
-{
-       std::string filename=App::get_config_file("autorecovery");
-       std::ifstream file(filename.c_str());
-       if(!file)
-               return false;
-
-       while(file)
-       {
-               std::string filename;
-               getline(file,filename);
-               if(!filename.empty())
-                       return true;
-       }
-
-       return false;
-}
-
-bool
-AutoRecover::recover(int& number_recovered)
-{
-       std::string filename=App::get_config_file("autorecovery");
-       std::ifstream file(filename.c_str());
-       number_recovered = 0;
-       if(!file)
-               return false;
-       bool success=true;
-
-       while(file)
-       {
-               std::string filename;
-               getline(file,filename);
-               if(filename.empty())
-                       continue;
-
-               // Open the file
-               if(App::open_as(get_shadow_file_name(filename),filename))
-               {
-                       // Correct the file name
-                       App::instance_list.back()->set_file_name(filename);
-
-                       // This file isn't saved! mark it as such
-                       App::instance_list.back()->inc_action_count();
-
-                       number_recovered++;
-               }
-               else
-                       success=false;
-       }
-
-       return success;
-}
-
-void
-AutoRecover::normal_shutdown()
-{
-       // Turn off the timer
-       auto_backup_connect.disconnect();
-
-       std::string filename=App::get_config_file("autorecovery");
-       remove(filename.c_str());
-}
-
-void
-AutoRecover::clear_backup(synfig::Canvas::Handle canvas)
-{
-       if(canvas)
-               remove(get_shadow_file_name(canvas->get_file_name()).c_str());
-}
diff --git a/synfig-studio/src/gtkmm/autorecover.h b/synfig-studio/src/gtkmm/autorecover.h
deleted file mode 100644 (file)
index 9bdedac..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file autorecover.h
-**     \brief Template Header
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === S T A R T =========================================================== */
-
-#ifndef __SYNFIG_AUTORECOVER_H
-#define __SYNFIG_AUTORECOVER_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <synfig/string.h>
-#include <synfig/canvas.h>
-#include <sigc++/connection.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 AutoRecover
-{
-       int timeout;
-       sigc::connection auto_backup_connect;
-public:
-       AutoRecover();
-       ~AutoRecover();
-
-       static int pid();
-       static synfig::String get_shadow_file_name(const synfig::String& filename);
-
-       static bool auto_backup();
-
-       static bool cleanup_pid(int pid);
-
-       void set_timeout(int milliseconds);
-       int get_timeout()const { return timeout; }
-
-       static synfig::String get_shadow_directory();
-
-       bool recovery_needed()const;
-       bool recover(int& number_recovered);
-
-       void normal_shutdown();
-
-       void clear_backup(synfig::Canvas::Handle canvas);
-}; // END of class AutoRecover
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/canvasoptions.cpp b/synfig-studio/src/gtkmm/canvasoptions.cpp
deleted file mode 100644 (file)
index dfc15ed..0000000
+++ /dev/null
@@ -1,215 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file canvasoptions.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "canvasoptions.h"
-#include <gtkmm/frame.h>
-#include <gtkmm/table.h>
-#include <gtkmm/label.h>
-#include <gtkmm/notebook.h>
-#include <gtkmm/alignment.h>
-#include "canvasview.h"
-#include "workarea.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-CanvasOptions::CanvasOptions(etl::loose_handle<CanvasView> canvas_view):
-       Gtk::Dialog(_("Canvas Options"),*canvas_view,false,true),
-       canvas_view_(canvas_view),
-       toggle_grid_snap(_("_Snap to grid"), true),
-       toggle_grid_show(_("S_how grid"), true),
-       toggle_time_snap(_("Snap to _frame"), true)
-{
-       vector_grid_size.set_canvas(canvas_view->get_canvas());
-
-       Gtk::Alignment *dialogPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
-       dialogPadding->set_padding(12, 12, 12, 12);
-
-       Gtk::Notebook *notebook=manage(new class Gtk::Notebook());
-       dialogPadding->add(*notebook);
-
-       toggle_grid_snap.signal_toggled().connect(sigc::mem_fun(*this, &studio::CanvasOptions::on_grid_snap_toggle));
-       toggle_grid_show.signal_toggled().connect(sigc::mem_fun(*this, &studio::CanvasOptions::on_grid_show_toggle));
-
-       Gtk::Alignment *gridPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
-       gridPadding->set_padding(12, 12, 12, 12);
-       notebook->append_page(*gridPadding, _("Grid"));
-
-       Gtk::VBox *gridBox = manage(new Gtk::VBox(false, 12));
-       gridPadding->add(*gridBox);
-
-       Gtk::Table *gridTable = manage(new Gtk::Table(3, 2, false));
-       gridTable->set_row_spacings(6);
-       gridTable->set_col_spacings(12);
-       gridBox->pack_start(*gridTable, false, false, 0);
-
-       Gtk::Label *gridSizeLabel = manage(new Gtk::Label(_("_Grid size"), true));
-       gridSizeLabel->set_alignment(0, 0.5);
-       gridSizeLabel->set_mnemonic_widget(vector_grid_size);
-
-       toggle_grid_show.set_alignment(0, 0.5);
-       toggle_grid_snap.set_alignment(0, 0.5);
-
-       gridTable->attach(*gridSizeLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       gridTable->attach(vector_grid_size, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       gridTable->attach(toggle_grid_show, 0, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       gridTable->attach(toggle_grid_snap, 0, 2, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
-       Gtk::Alignment *timePadding = manage(new Gtk::Alignment(0, 0, 1, 1));
-       timePadding->set_padding(12, 12, 12, 12);
-       notebook->append_page(*timePadding, _("Time"));
-
-       Gtk::VBox *timeBox = manage(new Gtk::VBox(false, 12));
-       timePadding->add(*timeBox);
-
-       timeBox->pack_start(toggle_time_snap, false, false, 0);
-
-       Gtk::Alignment *unitPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
-       unitPadding->set_padding(12, 12, 12, 12);
-       notebook->append_page(*unitPadding, _("Units"));
-       unitPadding->add(*manage(new Gtk::Label(_("Not yet implemented!"))));
-
-       Gtk::Button *ok_button(manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))));
-       ok_button->show();
-       add_action_widget(*ok_button,2);
-       ok_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasOptions::on_ok_pressed));
-
-       Gtk::Button *apply_button(manage(new class Gtk::Button(Gtk::StockID("gtk-apply"))));
-       apply_button->show();
-       add_action_widget(*apply_button,1);
-       apply_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasOptions::on_apply_pressed));
-
-       Gtk::Button *cancel_button(manage(new class Gtk::Button(Gtk::StockID("gtk-close"))));
-       cancel_button->show();
-       add_action_widget(*cancel_button,0);
-       cancel_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasOptions::on_cancel_pressed));
-
-       //set_default_response(1);
-
-
-       get_vbox()->pack_start(*dialogPadding);
-       get_vbox()->show_all();
-
-       signal_show().connect(sigc::mem_fun(*this, &studio::CanvasOptions::refresh));
-
-       vector_grid_size.set_digits(5);
-
-       update_title();
-}
-
-CanvasOptions::~CanvasOptions()
-{
-}
-
-void
-CanvasOptions::update_title()
-{
-       set_title(_("Options")+String(" - ")+canvas_view_->get_canvas()->get_name());
-}
-
-void
-CanvasOptions::refresh()
-{
-       if(canvas_view_->work_area->grid_status())
-               toggle_grid_show.set_active(true);
-       else
-               toggle_grid_show.set_active(false);
-
-       if(canvas_view_->work_area->get_grid_snap())
-               toggle_grid_snap.set_active(true);
-       else
-               toggle_grid_snap.set_active(false);
-
-       vector_grid_size.set_value(canvas_view_->work_area->get_grid_size());
-
-       tooltips.set_tip(toggle_time_snap,_("Not yet implemented"));
-       toggle_time_snap.set_sensitive(false);
-
-       update_title();
-}
-
-void
-CanvasOptions::on_grid_snap_toggle()
-{
-}
-
-void
-CanvasOptions::on_grid_show_toggle()
-{
-}
-
-void
-CanvasOptions::on_apply_pressed()
-{
-       canvas_view_->set_grid_snap_toggle(toggle_grid_snap.get_active());
-       if(toggle_grid_snap.get_active())
-               canvas_view_->work_area->enable_grid_snap();
-       else
-               canvas_view_->work_area->disable_grid_snap();
-
-       canvas_view_->set_grid_show_toggle(toggle_grid_show.get_active());
-       if(toggle_grid_show.get_active())
-               canvas_view_->work_area->enable_grid();
-       else
-               canvas_view_->work_area->disable_grid();
-
-       canvas_view_->work_area->set_grid_size(vector_grid_size.get_value());
-}
-
-void
-CanvasOptions::on_ok_pressed()
-{
-       on_apply_pressed();
-       hide();
-}
-
-void
-CanvasOptions::on_cancel_pressed()
-{
-       refresh();
-       hide();
-}
diff --git a/synfig-studio/src/gtkmm/canvasoptions.h b/synfig-studio/src/gtkmm/canvasoptions.h
deleted file mode 100644 (file)
index 452ab3f..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file canvasoptions.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_GTKMM_CANVASOPTIONS_H
-#define __SYNFIG_GTKMM_CANVASOPTIONS_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/dialog.h>
-#include <gtkmm/tooltips.h>
-#include <gtkmm/table.h>
-#include <gtkmm/entry.h>
-#include <gtkmm/tooltips.h>
-#include "widget_value.h"
-#include "widget_vector.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 CanvasView;
-
-class CanvasOptions  :  public Gtk::Dialog
-{
-       Gtk::Tooltips tooltips;
-
-       etl::loose_handle<CanvasView> canvas_view_;
-
-       Gtk::CheckButton toggle_grid_snap;
-       Gtk::CheckButton toggle_grid_show;
-
-       Widget_Vector vector_grid_size;
-
-       Gtk::CheckButton toggle_time_snap;
-
-public:
-       CanvasOptions(etl::loose_handle<CanvasView> canvas_view);
-       ~CanvasOptions();
-
-       void refresh();
-       void update_title();
-private:
-
-       void on_grid_snap_toggle();
-       void on_grid_show_toggle();
-
-       void on_ok_pressed();
-       void on_apply_pressed();
-       void on_cancel_pressed();
-}; // END of class CanvasOptions
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/canvasproperties.cpp b/synfig-studio/src/gtkmm/canvasproperties.cpp
deleted file mode 100644 (file)
index d095331..0000000
+++ /dev/null
@@ -1,255 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file canvasproperties.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 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 <config.h>
-#endif
-
-#include "canvasproperties.h"
-#include <gtkmm/frame.h>
-#include <gtkmm/table.h>
-#include <gtkmm/label.h>
-#include <gtkmm/alignment.h>
-#include <synfigapp/canvasinterface.h>
-#include "metadatatreestore.h"
-#include <gtkmm/treeview.h>
-#include <gtkmm/scrolledwindow.h>
-#include "app.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-CanvasProperties::CanvasProperties(Gtk::Window& parent,etl::handle<synfigapp::CanvasInterface> canvas_interface):
-       Gtk::Dialog(_("Canvas Properties"),parent,false,true),
-       canvas_interface_(canvas_interface)
-{
-       widget_rend_desc.show();
-       widget_rend_desc.signal_changed().connect(sigc::mem_fun(*this,&studio::CanvasProperties::on_rend_desc_changed));
-
-       Gtk::Alignment *dialogPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
-       dialogPadding->set_padding(12, 12, 12, 12);
-       get_vbox()->pack_start(*dialogPadding, false, false, 0);
-
-       Gtk::VBox *dialogBox = manage(new Gtk::VBox(false, 12));
-       dialogPadding->add(*dialogBox);
-
-       Gtk::Frame *info_frame=manage(new Gtk::Frame(_("Canvas Info")));
-       info_frame->set_shadow_type(Gtk::SHADOW_NONE);
-       ((Gtk::Label *) info_frame->get_label_widget())->set_markup(_("<b>Canvas Info</b>"));
-       dialogBox->pack_start(*info_frame, false, false, 0);
-
-       Gtk::Alignment *infoPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
-       infoPadding->set_padding(6, 0, 24, 0);
-       info_frame->add(*infoPadding);
-
-       Gtk::Table *info_table=manage(new Gtk::Table(2,2,false));
-       info_table->set_row_spacings(6);
-       info_table->set_col_spacings(12);
-       infoPadding->add(*info_table);
-
-       // The root canvas doesn't have an ID, so don't
-       // display it if this is a root canvas.
-       if(!canvas_interface_->get_canvas()->is_root())
-       {
-               Gtk::Label *idLabel = manage(new Gtk::Label(_("_ID"), true));
-               idLabel->set_alignment(0, 0.5);
-               idLabel->set_mnemonic_widget(entry_id);
-               info_table->attach(*idLabel, 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-               info_table->attach(entry_id, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       }
-       Gtk::Label *nameLabel = manage(new Gtk::Label(_("_Name"), true));
-       nameLabel->set_alignment(0, 0.5);
-       nameLabel->set_mnemonic_widget(entry_name);
-       Gtk::Label *descriptionLabel = manage(new Gtk::Label(_("_Description"), true));
-       descriptionLabel->set_alignment(0, 0.5);
-       descriptionLabel->set_mnemonic_widget(entry_description);
-       info_table->attach(*nameLabel, 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       info_table->attach(*descriptionLabel, 0, 1, 2, 3, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       info_table->attach(entry_name, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       info_table->attach(entry_description, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-
-       dialogBox->pack_start(widget_rend_desc, false, false, 0);
-
-       canvas_interface_->signal_rend_desc_changed().connect(sigc::mem_fun(*this,&studio::CanvasProperties::refresh));
-       canvas_interface_->signal_id_changed().connect(sigc::mem_fun(*this,&studio::CanvasProperties::refresh));
-
-       Gtk::Button *ok_button(manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))));
-       ok_button->show();
-       add_action_widget(*ok_button,2);
-       ok_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasProperties::on_ok_pressed));
-
-       Gtk::Button *apply_button(manage(new class Gtk::Button(Gtk::StockID("gtk-apply"))));
-       apply_button->show();
-       add_action_widget(*apply_button,1);
-       apply_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasProperties::on_apply_pressed));
-
-       Gtk::Button *cancel_button(manage(new class Gtk::Button(Gtk::StockID("gtk-close"))));
-       cancel_button->show();
-       add_action_widget(*cancel_button,0);
-       cancel_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasProperties::on_cancel_pressed));
-
-       //set_default_response(1);
-
-       get_vbox()->show_all();
-       refresh();
-
-       update_title();
-}
-
-Gtk::Widget&
-CanvasProperties::create_meta_data_view()
-{
-       MetaDataTreeStore::Model model;
-       meta_data_tree_view=(manage(new class Gtk::TreeView()));
-
-       meta_data_tree_view->append_column(_("Key"),model.key);
-       meta_data_tree_view->append_column_editable(_("Data"),model.data);
-       meta_data_tree_view->set_model(MetaDataTreeStore::create(canvas_interface_));
-       meta_data_tree_view->set_rules_hint();
-       meta_data_tree_view->show();
-
-       Gtk::ScrolledWindow *scrolledwindow = manage(new class Gtk::ScrolledWindow());
-       scrolledwindow->set_flags(Gtk::CAN_FOCUS);
-       scrolledwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
-       scrolledwindow->add(*meta_data_tree_view);
-       scrolledwindow->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
-       scrolledwindow->show();
-
-
-
-       Gtk::Table *table=manage(new Gtk::Table());
-       table->attach(*scrolledwindow, 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       Gtk::Button* button_add(manage(new Gtk::Button(Gtk::StockID("gtk-add"))));
-       button_add->show();
-       button_add->signal_clicked().connect(sigc::mem_fun(*this,&CanvasProperties::on_button_meta_data_add));
-       table->attach(*button_add, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-
-       Gtk::Button* button_delete(manage(new Gtk::Button(Gtk::StockID("gtk-delete"))));
-       button_delete->show();
-       button_delete->signal_clicked().connect(sigc::mem_fun(*this,&CanvasProperties::on_button_meta_data_delete));
-       table->attach(*button_delete, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-
-       table->show();
-       return *table;
-}
-
-void
-CanvasProperties::on_button_meta_data_add()
-{
-       synfig::String key;
-       if(App::dialog_entry(_("New MetaData Entry"), _("Please enter the name of the key"),key) && !key.empty())
-       {
-               canvas_interface_->set_meta_data(key," ");
-       }
-
-}
-
-void
-CanvasProperties::on_button_meta_data_delete()
-{
-}
-
-void
-CanvasProperties::update_title()
-{
-       set_title(_("Properties")+String(" - ")+canvas_interface_->get_canvas()->get_name());
-}
-
-void
-CanvasProperties::refresh()
-{
-       widget_rend_desc.set_rend_desc(canvas_interface_->get_canvas()->rend_desc());
-       entry_id.set_text(canvas_interface_->get_canvas()->get_id());
-       entry_name.set_text(canvas_interface_->get_canvas()->get_name());
-       entry_description.set_text(canvas_interface_->get_canvas()->get_description());
-
-       dirty_rend_desc=false;
-
-       update_title();
-}
-
-CanvasProperties::~CanvasProperties()
-{
-}
-
-void
-CanvasProperties::on_rend_desc_changed()
-{
-       dirty_rend_desc=true;
-}
-
-void
-CanvasProperties::on_apply_pressed()
-{
-       synfigapp::Action::PassiveGrouper group(canvas_interface_->get_instance().get(),_("Edit Canvas Properties"));
-
-       // fetch these three values first, because each set_() method refreshes the dialog with currently set values
-       String id = entry_id.get_text();
-       String name = entry_name.get_text();
-       String description = entry_description.get_text();
-
-       // do this first, because the other three cause the dialog to be refreshed with currently set values
-       if (dirty_rend_desc) canvas_interface_->set_rend_desc(widget_rend_desc.get_rend_desc());
-
-       if (id != canvas_interface_->get_canvas()->get_id() && !id.empty())             canvas_interface_->set_id(id);
-       if (name != canvas_interface_->get_canvas()->get_name())                                canvas_interface_->set_name(name);
-       if (description != canvas_interface_->get_canvas()->get_description())  canvas_interface_->set_description(description);
-
-       dirty_rend_desc=false;
-}
-
-void
-CanvasProperties::on_ok_pressed()
-{
-       on_apply_pressed();
-       hide();
-}
-
-void
-CanvasProperties::on_cancel_pressed()
-{
-       refresh();
-       hide();
-}
diff --git a/synfig-studio/src/gtkmm/canvasproperties.h b/synfig-studio/src/gtkmm/canvasproperties.h
deleted file mode 100644 (file)
index 3a32d40..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file canvasproperties.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_GTKMM_CANVASPROPERTIES_H
-#define __SYNFIG_GTKMM_CANVASPROPERTIES_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <ETL/handle>
-
-#include <gtkmm/dialog.h>
-#include <gtkmm/tooltips.h>
-#include <gtkmm/table.h>
-#include <gtkmm/entry.h>
-#include <gtkmm/tooltips.h>
-
-#include "renddesc.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 Gtk { class TreeView; };
-namespace synfigapp { class CanvasInterface; };
-
-namespace studio
-{
-class CanvasProperties  :  public Gtk::Dialog
-{
-       Gtk::Tooltips tooltips;
-
-       etl::handle<synfigapp::CanvasInterface> canvas_interface_;
-       Widget_RendDesc widget_rend_desc;
-       Gtk::Entry entry_id;
-       Gtk::Entry entry_name;
-       Gtk::Entry entry_description;
-
-       bool dirty_rend_desc;
-
-       Gtk::TreeView* meta_data_tree_view;
-       void on_button_meta_data_add();
-       void on_button_meta_data_delete();
-
-public:
-       CanvasProperties(Gtk::Window& parent,etl::handle<synfigapp::CanvasInterface> canvas_interface);
-       ~CanvasProperties();
-
-       void refresh();
-       void update_title();
-private:
-       void on_rend_desc_changed();
-
-       Gtk::Widget& create_meta_data_view();
-
-       void on_ok_pressed();
-       void on_apply_pressed();
-       void on_cancel_pressed();
-}; // END of class CanvasProperties
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/canvastreestore.cpp b/synfig-studio/src/gtkmm/canvastreestore.cpp
deleted file mode 100644 (file)
index f49d7a3..0000000
+++ /dev/null
@@ -1,622 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file canvastreestore.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 <config.h>
-#endif
-
-#include "canvastreestore.h"
-#include <synfig/valuenode.h>
-#include "iconcontroller.h"
-#include <synfig/valuenode_timedswap.h>
-#include <synfig/valuenode_animated.h>
-#include <gtkmm/button.h>
-#include <synfigapp/instance.h>
-#include "cellrenderer_value.h"
-#include "cellrenderer_timetrack.h"
-#include <ETL/clock>
-
-#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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-static CanvasTreeStore::Model& ModelHack()
-{
-       static CanvasTreeStore::Model* model(0);
-       if(!model)model=new CanvasTreeStore::Model;
-       return *model;
-}
-
-CanvasTreeStore::CanvasTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_):
-       Gtk::TreeStore(ModelHack()),
-       canvas_interface_               (canvas_interface_)
-{
-}
-
-CanvasTreeStore::~CanvasTreeStore()
-{
-}
-
-void
-CanvasTreeStore::get_value_vfunc(const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const
-{
-       if(column==model.value.index())
-       {
-               synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
-
-               Glib::Value<synfig::ValueBase> x;
-               g_value_init(x.gobj(),x.value_type());
-
-               if(!value_desc)
-               {
-                       x.set(ValueBase());
-               }
-               else
-               if(value_desc.is_const())
-                       x.set(value_desc.get_value());
-               else
-               if(value_desc.is_value_node())
-                       x.set((*value_desc.get_value_node())(canvas_interface()->get_time()));
-               else
-               {
-                       synfig::error(__FILE__":%d: Unable to figure out value",__LINE__);
-                       return;
-               }
-
-               g_value_init(value.gobj(),x.value_type());
-               g_value_copy(x.gobj(),value.gobj());
-       }
-       else
-       if(column==model.is_value_node.index())
-       {
-               synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
-
-               Glib::Value<bool> x;
-               g_value_init(x.gobj(),x.value_type());
-
-               x.set(value_desc && value_desc.is_value_node());
-
-               g_value_init(value.gobj(),x.value_type());
-               g_value_copy(x.gobj(),value.gobj());
-       }
-       else
-       if(column==model.is_shared.index())
-       {
-               synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
-
-               Glib::Value<bool> x;
-               g_value_init(x.gobj(),x.value_type());
-
-               x.set(value_desc.is_value_node() && value_desc.get_value_node()->rcount()>1);
-
-               g_value_init(value.gobj(),x.value_type());
-               g_value_copy(x.gobj(),value.gobj());
-       }
-       else
-       if(column==model.is_exported.index())
-       {
-               synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
-
-               Glib::Value<bool> x;
-               g_value_init(x.gobj(),x.value_type());
-
-               x.set(value_desc.is_value_node() && value_desc.get_value_node()->is_exported());
-
-               g_value_init(value.gobj(),x.value_type());
-               g_value_copy(x.gobj(),value.gobj());
-       }
-       else
-       if(column==model.is_canvas.index())
-       {
-               synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
-
-               Glib::Value<bool> x;
-               g_value_init(x.gobj(),x.value_type());
-
-               x.set(!value_desc && (Canvas::Handle)(*iter)[model.canvas]);
-
-               g_value_init(value.gobj(),x.value_type());
-               g_value_copy(x.gobj(),value.gobj());
-       }
-       else
-       if(column==model.id.index())
-       {
-               synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
-
-               Glib::Value<Glib::ustring> x;
-               g_value_init(x.gobj(),x.value_type());
-
-               if(value_desc && value_desc.is_value_node())
-                       x.set(value_desc.get_value_node()->get_id());
-               else if(!value_desc && Canvas::Handle((*iter)[model.canvas]))
-                       x.set(Canvas::Handle((*iter)[model.canvas])->get_id());
-               else
-                       return Gtk::TreeStore::get_value_vfunc(iter,column,value);
-
-               g_value_init(value.gobj(),x.value_type());
-               g_value_copy(x.gobj(),value.gobj());
-       }
-       else
-       if(column==model.is_editable.index())
-       {
-               synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
-
-               Glib::Value<bool> x;
-               g_value_init(x.gobj(),x.value_type());
-
-               x.set(!value_desc.is_value_node() || synfigapp::is_editable(value_desc.get_value_node()));
-
-               g_value_init(value.gobj(),x.value_type());
-               g_value_copy(x.gobj(),value.gobj());
-       }
-       else
-       if(column==model.type.index())
-       {
-               synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
-
-               Glib::Value<Glib::ustring> x;
-               g_value_init(x.gobj(),x.value_type());
-
-               // Set the type
-               if(!value_desc)
-               {
-                       if((*iter)[model.is_canvas])
-                               x.set(_("Canvas"));
-               }
-               else
-               {
-                       if(!value_desc.is_value_node() || value_desc.get_value_node()->get_name()=="constant")
-                       {
-                               x.set(ValueBase::type_local_name(value_desc.get_value_type()));
-                       }
-                       else
-                       {
-                               x.set(value_desc.get_value_node()->get_local_name());
-                       }
-               }
-
-               g_value_init(value.gobj(),x.value_type());
-               g_value_copy(x.gobj(),value.gobj());
-       }
-       else
-       if(column==model.label.index())
-       {
-               synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
-
-               Glib::Value<Glib::ustring> x;
-               g_value_init(x.gobj(),x.value_type());
-
-               // Set the type
-               if(!value_desc)
-               {
-                       Canvas::Handle canvas((*iter)[model.canvas]);
-                       if(canvas)
-                       {
-                               if(!canvas->get_id().empty())
-                                       x.set(canvas->get_id());
-                               else
-                               if(!canvas->get_name().empty())
-                                       x.set(canvas->get_name());
-                               else
-                                       x.set(_("[Unnamed]"));
-                               x.set(_("Canvas"));
-                       }
-                       return Gtk::TreeStore::get_value_vfunc(iter,column,value);
-               }
-               else
-               {
-                       ValueNode::Handle value_node=value_desc.get_value_node();
-
-                       // Setup the row's label
-                       if(value_node->get_id().empty())
-                               x.set(Glib::ustring((*iter)[model.name]));
-                       else if(Glib::ustring((*iter)[model.name]).empty())
-                               x.set(value_node->get_id());
-                       else
-                               x.set(Glib::ustring((*iter)[model.name])+" ("+value_node->get_id()+')');
-               }
-
-               g_value_init(value.gobj(),x.value_type());
-               g_value_copy(x.gobj(),value.gobj());
-       }
-       else
-       if(column==model.icon.index())
-       {
-               synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
-               if(!value_desc)
-                       return Gtk::TreeStore::get_value_vfunc(iter,column,value);
-
-               Glib::Value<Glib::RefPtr<Gdk::Pixbuf> > x;
-               g_value_init(x.gobj(),x.value_type());
-
-               x.set(get_tree_pixbuf(value_desc.get_value_type()));
-
-               g_value_init(value.gobj(),x.value_type());
-               g_value_copy(x.gobj(),value.gobj());
-       }
-       else
-               Gtk::TreeStore::get_value_vfunc(iter,column,value);
-}
-
-bool
-CanvasTreeStore::find_first_value_desc(const synfigapp::ValueDesc& value_desc, Gtk::TreeIter& iter)
-{
-       iter=children().begin();
-       while(iter && value_desc!=(*iter)[model.value_desc])
-       {
-               if(!iter->children().empty())
-               {
-                       Gtk::TreeIter iter2(iter->children().begin());
-                       //! \todo confirm that the && should be done before the ||
-                       if((iter2 && value_desc==(*iter2)[model.value_desc]) || find_next_value_desc(value_desc, iter2))
-                       {
-                               iter=iter2;
-                               return true;
-                       }
-               }
-               Gtk::TreeIter iter2(++iter);
-               if(!iter2)
-                       iter==iter->parent();
-               else
-                       iter=iter2;
-       }
-       return (bool)iter && value_desc==(*iter)[model.value_desc];
-}
-
-bool
-CanvasTreeStore::find_next_value_desc(const synfigapp::ValueDesc& value_desc, Gtk::TreeIter& iter)
-{
-       if(!iter) return find_first_value_desc(value_desc,iter);
-
-       if(iter) do {
-               if(!iter->children().empty())
-               {
-                       Gtk::TreeIter iter2(iter->children().begin());
-                       //! \todo confirm that the && should be done before the ||
-                       if((iter2 && value_desc==(*iter2)[model.value_desc]) || find_next_value_desc(value_desc, iter2))
-                       {
-                               iter=iter2;
-                               return true;
-                       }
-               }
-               Gtk::TreeIter iter2(++iter);
-               if(!iter2)
-               {
-                       iter==iter->parent();
-                       if(iter)++iter;
-               }
-               else
-                       iter=iter2;
-       } while(iter && value_desc!=(*iter)[model.value_desc]);
-       return (bool)iter && value_desc==(*iter)[model.value_desc];
-}
-
-bool
-CanvasTreeStore::find_first_value_node(const synfig::ValueNode::Handle& value_node, Gtk::TreeIter& iter)
-{
-       iter=children().begin();
-       while(iter && value_node!=(ValueNode::Handle)(*iter)[model.value_node])
-       {
-               if(!iter->children().empty())
-               {
-                       Gtk::TreeIter iter2(iter->children().begin());
-                       //! \todo confirm that the && should be done before the ||
-                       if((iter2 && value_node==(ValueNode::Handle)(*iter2)[model.value_node]) || find_next_value_node(value_node, iter2))
-                       {
-                               iter=iter2;
-                               return true;
-                       }
-               }
-               Gtk::TreeIter iter2(++iter);
-               if(!iter2)
-                       iter==iter->parent();
-               else
-                       iter=iter2;
-       }
-       return (bool)iter && value_node==(ValueNode::Handle)(*iter)[model.value_node];
-}
-
-bool
-CanvasTreeStore::find_next_value_node(const synfig::ValueNode::Handle& value_node, Gtk::TreeIter& iter)
-{
-       if(!iter) return find_first_value_node(value_node,iter);
-
-       if(iter) do {
-               if(!iter->children().empty())
-               {
-                       Gtk::TreeIter iter2(iter->children().begin());
-                       //! \todo confirm that the && should be done before the ||
-                       if((iter2 && value_node==(ValueNode::Handle)(*iter2)[model.value_node]) || find_next_value_node(value_node, iter2))
-                       {
-                               iter=iter2;
-                               return true;
-                       }
-               }
-               Gtk::TreeIter iter2(++iter);
-               if(!iter2)
-               {
-                       iter==iter->parent();
-                       if(iter)++iter;
-               }
-               else
-                       iter=iter2;
-       } while(iter && value_node!=(ValueNode::Handle)(*iter)[model.value_node]);
-       return (bool)iter && value_node==(ValueNode::Handle)(*iter)[model.value_node];
-}
-
-void
-CanvasTreeStore::set_row(Gtk::TreeRow row,synfigapp::ValueDesc value_desc, bool do_children)
-{
-       Gtk::TreeModel::Children children = row.children();
-       while(!children.empty() && erase(children.begin()))
-               ;
-
-       row[model.value_desc]=value_desc;
-       try
-       {
-               //row[model.icon] = get_tree_pixbuf(value_desc.get_value_type());
-
-               if(value_desc.is_value_node())
-               {
-                       ValueNode::Handle value_node=value_desc.get_value_node();
-
-                       assert(value_node);
-
-                       row[model.value_node] = value_node;
-                       //row[model.is_canvas] = false;
-                       //row[model.is_value_node] = true;
-                       //row[model.is_editable] = synfigapp::is_editable(value_node);
-                       //row[model.id]=value_node->get_id();
-
-                       // Set the canvas
-                       if(value_desc.parent_is_canvas())
-                               row[model.canvas]=value_desc.get_canvas();
-                       else
-                               row[model.canvas]=canvas_interface()->get_canvas();
-
-                       LinkableValueNode::Handle linkable;
-                       linkable=LinkableValueNode::Handle::cast_dynamic(value_node);
-
-                       if(linkable && do_children)
-                       {
-                               row[model.link_count] = linkable->link_count();
-                               for(int i=0;i<linkable->link_count();i++)
-                               {
-                                       Gtk::TreeRow child_row=*(append(row.children()));
-                                       child_row[model.link_id] = i;
-                                       child_row[model.canvas] = static_cast<Canvas::Handle>(row[model.canvas]);
-                                       child_row[model.name] = linkable->link_local_name(i);
-                                       set_row(child_row,synfigapp::ValueDesc(linkable,i));
-                               }
-                       }
-                       return;
-               }
-               else
-               {
-                       //row[model.is_value_node] = false;
-                       //row[model.is_editable] = true;
-                       //row[model.label] = Glib::ustring(row[model.name]);
-                       return;
-               }
-       }
-       catch(synfig::Exception::IDNotFound x)
-       {
-               synfig::error(__FILE__":%d: IDNotFound thrown",__LINE__);
-               erase(row);
-               return;
-       }
-
-       // We should never get to this point
-       assert(0);
-}
-
-void
-CanvasTreeStore::refresh_row(Gtk::TreeModel::Row &row, bool do_children)
-{
-       synfigapp::ValueDesc value_desc=row[model.value_desc];
-
-       if(value_desc)
-       {
-               if((bool)row[model.is_value_node] != value_desc.is_value_node() ||
-                       (!bool(row[model.is_value_node]) && row[model.link_count]!=0))
-               {
-                       set_row(row,value_desc,do_children);
-                       return;
-               }
-
-               if(row[model.is_value_node])
-               {
-                       ValueNode::Handle value_node(value_desc.get_value_node());
-
-                       if(ValueNode::Handle(row[model.value_node])!=value_node)
-                       {
-                               rebuild_row(row,do_children);
-                               return;
-                       }
-
-                       //row[model.id]=value_node->get_id();
-
-                       // Setup the row's label
-                       /*
-                       if(value_node->get_id().empty())
-                               row[model.label] = Glib::ustring(row[model.name]);
-                       else if(Glib::ustring(row[model.name]).empty())
-                               row[model.label] = value_node->get_id();
-                       else
-                               row[model.label] = Glib::ustring(row[model.name])+" ("+value_node->get_id()+')';
-                       */
-
-                       LinkableValueNode::Handle linkable;
-                       linkable=LinkableValueNode::Handle::cast_dynamic(value_node);
-                       if(do_children && linkable && ((int)row[model.link_count] != linkable->link_count()))
-                       {
-       //                      Gtk::TreeModel::Children children = row.children();
-       //                      while(!children.empty() && erase(children.begin()));
-
-                               set_row(row,value_desc);
-                               return;
-                       }
-               }
-               else
-               {
-                       //row[model.label] = Glib::ustring(row[model.name]);
-                       //row[model.is_value_node] = false;
-                       //row[model.is_editable] = true;
-               }
-       }
-       if(!do_children)
-               return;
-
-       Gtk::TreeModel::Children children = row.children();
-       Gtk::TreeModel::Children::iterator iter;
-
-       if(!children.empty())
-       for(iter = children.begin(); iter != children.end(); ++iter)
-       {
-               Gtk::TreeRow row=*iter;
-               refresh_row(row);
-       }
-}
-
-void
-CanvasTreeStore::rebuild_row(Gtk::TreeModel::Row &row, bool do_children)
-{
-       synfigapp::ValueDesc value_desc=(synfigapp::ValueDesc)row[model.value_desc];
-
-       if(value_desc && value_desc.get_value_node())
-       {
-               ValueNode::Handle value_node;
-               value_node=value_desc.get_value_node();
-
-               assert(value_node);if(!value_node)return;
-
-               if(value_node && value_node!=(ValueNode::Handle)row[model.value_node])
-               {
-//                     Gtk::TreeModel::Children children = row.children();
-//                     while(!children.empty() && erase(children.begin()));
-
-                       set_row(row,value_desc,do_children);
-                       return;
-               }
-
-               LinkableValueNode::Handle linkable;
-               linkable=LinkableValueNode::Handle::cast_dynamic(value_node);
-
-               if( do_children && linkable && (int)row[model.link_count] != linkable->link_count())
-               {
-//                     Gtk::TreeModel::Children children = row.children();
-//                     while(!children.empty() && erase(children.begin()));
-
-                       set_row(row,value_desc);
-                       return;
-               }
-
-               //if(!value_node)
-               //      value_node=row[model.value_node];
-
-               row[model.id]=value_node->get_id();
-
-               // Setup the row's label
-               if(value_node->get_id().empty())
-                       row[model.label] = Glib::ustring(row[model.name]);
-               else if(Glib::ustring(row[model.name]).empty())
-                       row[model.label] = value_node->get_id();
-               else
-                       row[model.label] = Glib::ustring(row[model.name])+" ("+value_node->get_id()+')';
-       }
-       else
-       {
-               row[model.label] = Glib::ustring(row[model.name]);
-               row[model.is_value_node] = false;
-               row[model.is_editable] = true;
-               Gtk::TreeModel::Children children = row.children();
-               while(!children.empty() && erase(children.begin()))
-                       ;
-       }
-       if(!do_children)
-               return;
-
-       Gtk::TreeModel::Children children = row.children();
-       Gtk::TreeModel::Children::iterator iter;
-       if(!children.empty())
-       for(iter = children.begin(); iter != children.end(); ++iter)
-       {
-               Gtk::TreeRow row=*iter;
-               rebuild_row(row);
-       }
-}
-
-CellRenderer_ValueBase*
-CanvasTreeStore::add_cell_renderer_value(Gtk::TreeView::Column* column)
-{
-       const CanvasTreeStore::Model model;
-
-       CellRenderer_ValueBase* ret;
-
-       ret=Gtk::manage( new CellRenderer_ValueBase() );
-
-       column->pack_start(*ret,true);
-       column->add_attribute(ret->property_value(), model.value);
-       column->add_attribute(ret->property_editable(), model.is_editable);
-       column->add_attribute(ret->property_canvas(), model.canvas);
-
-       return ret;
-}
-
-CellRenderer_TimeTrack*
-CanvasTreeStore::add_cell_renderer_value_node(Gtk::TreeView::Column* column)
-{
-       const CanvasTreeStore::Model model;
-
-       CellRenderer_TimeTrack* ret;
-
-       ret = Gtk::manage( new CellRenderer_TimeTrack() );
-
-       column->pack_start(*ret,true);
-       //column->add_attribute(ret->property_visible(), model.is_value_node);
-       column->add_attribute(ret->property_value_desc(), model.value_desc);
-       column->add_attribute(ret->property_canvas(), model.canvas);
-
-
-       return ret;
-}
diff --git a/synfig-studio/src/gtkmm/canvastreestore.h b/synfig-studio/src/gtkmm/canvastreestore.h
deleted file mode 100644 (file)
index faed8b6..0000000
+++ /dev/null
@@ -1,195 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file canvastreestore.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_CANVASTREESTORE_H
-#define __SYNFIG_STUDIO_CANVASTREESTORE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/treestore.h>
-#include <synfigapp/canvasinterface.h>
-#include <gdkmm/pixbuf.h>
-#include <synfigapp/value_desc.h>
-#include <gtkmm/treeview.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 CellRenderer_TimeTrack;
-class CellRenderer_ValueBase;
-
-       enum ColumnID
-       {
-               COLUMNID_ID,
-               COLUMNID_VALUE,
-               COLUMNID_TIME_TRACK,
-               COLUMNID_TYPE,
-
-               COLUMNID_END                    //!< \internal
-       };
-#define        COLUMNID_NAME COLUMNID_ID
-
-class CanvasTreeStore : virtual public Gtk::TreeStore
-{
-       /*
- -- ** -- P U B L I C   T Y P E S ---------------------------------------------
-       */
-
-public:
-
-       class Model : public Gtk::TreeModel::ColumnRecord
-       {
-       public:
-               Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
-               Gtk::TreeModelColumn<Glib::ustring> label;
-               Gtk::TreeModelColumn<Glib::ustring> name;
-               Gtk::TreeModelColumn<Glib::ustring> id;
-
-               Gtk::TreeModelColumn<synfig::Canvas::Handle> canvas;
-               Gtk::TreeModelColumn<bool> is_canvas;
-
-               Gtk::TreeModelColumn<synfig::ValueNode::Handle> value_node;
-               Gtk::TreeModelColumn<bool> is_value_node;
-               Gtk::TreeModelColumn<synfig::ValueBase> value;
-               Gtk::TreeModelColumn<Glib::ustring> type;
-               Gtk::TreeModelColumn<int> link_id;
-               Gtk::TreeModelColumn<int> link_count;
-
-               Gtk::TreeModelColumn<bool> is_editable;
-
-               Gtk::TreeModelColumn<bool> is_shared;
-               Gtk::TreeModelColumn<bool> is_exported;
-
-               Gtk::TreeModelColumn<synfigapp::ValueDesc> value_desc;
-
-               Gtk::TreeModelColumn<Glib::ustring> tooltip;
-
-               Model()
-               {
-                       add(value);
-                       add(name);
-                       add(label);
-                       add(icon);
-                       add(type);
-                       add(id);
-                       add(canvas);
-                       add(value_node);
-                       add(is_canvas);
-                       add(is_value_node);
-
-                       add(is_shared);
-                       add(is_exported);
-                       add(is_editable);
-                       add(value_desc);
-                       add(link_count);
-                       add(link_id);
-
-                       add(tooltip);
-               }
-       };
-
-       /*
- -- ** -- P U B L I C  D A T A ------------------------------------------------
-       */
-
-public:
-
-       const Model model;
-
-       //std::multimap<etl::handle<ValueNode>, sigc::connection> connection_map;
-
-       /*
- -- ** -- P R I V A T E   D A T A ---------------------------------------------
-       */
-
-private:
-
-       etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
-
-       /*
- -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
-       */
-
-private:
-
-protected:
-       virtual void  get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const;
-
-       /*
- -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
-       */
-
-private:
-
-       /*
- -- ** -- P U B L I C   M E T H O D S -----------------------------------------
-       */
-
-public:
-
-       CanvasTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
-       ~CanvasTreeStore();
-
-       etl::loose_handle<synfigapp::CanvasInterface> canvas_interface() { return canvas_interface_; }
-       etl::loose_handle<const synfigapp::CanvasInterface> canvas_interface()const { return canvas_interface_; }
-
-       virtual void rebuild_row(Gtk::TreeModel::Row &row, bool do_children=true);
-
-       virtual void refresh_row(Gtk::TreeModel::Row &row, bool do_children=true);
-
-       virtual void set_row(Gtk::TreeRow row,synfigapp::ValueDesc value_desc, bool do_children=true);
-
-       bool find_first_value_desc(const synfigapp::ValueDesc& value_desc, Gtk::TreeIter& iter);
-       bool find_next_value_desc(const synfigapp::ValueDesc& value_desc, Gtk::TreeIter& iter);
-
-       bool find_first_value_node(const synfig::ValueNode::Handle& value_node, Gtk::TreeIter& iter);
-       bool find_next_value_node(const synfig::ValueNode::Handle& value_node, Gtk::TreeIter& iter);
-
-
-       static CellRenderer_ValueBase* add_cell_renderer_value(Gtk::TreeView::Column* column);
-
-       static CellRenderer_TimeTrack* add_cell_renderer_value_node(Gtk::TreeView::Column* column);
-
-       etl::loose_handle<synfigapp::CanvasInterface> get_canvas_interface()const { return canvas_interface_; }
-
-       virtual void on_value_node_changed(synfig::ValueNode::Handle value_node)=0;
-
-       /*
- -- ** -- P R O T E C T E D   M E T H O D S -----------------------------------
-       */
-
-public:
-
-}; // END of class CanvasTreeStore
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/canvasview.cpp b/synfig-studio/src/gtkmm/canvasview.cpp
deleted file mode 100644 (file)
index f520ced..0000000
+++ /dev/null
@@ -1,4338 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file canvasview.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 2008 Chris Moore
-**     Copyright (c) 2009 Carlos López
-**     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 <config.h>
-#endif
-
-#include <sigc++/adaptors/hide.h>
-
-#include <ETL/clock>
-#include <sstream>
-#include <math.h>
-
-#include <gtkmm/paned.h>
-#include <gtkmm/scale.h>
-#include <gtkmm/dialog.h>
-#include <gtkmm/messagedialog.h>
-#include <gtkmm/treemodelsort.h>
-#include <gtkmm/buttonbox.h>
-#include <gtkmm/separator.h>
-
-#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_range.h>
-#include <synfig/valuenode_dynamiclist.h>
-#include <synfig/valuenode_twotone.h>
-#include <synfig/valuenode_stripes.h>
-#include <synfig/valuenode_blinecalctangent.h>
-#include <synfig/valuenode_blinecalcvertex.h>
-#include <synfig/valuenode_blinecalcwidth.h>
-#include <synfig/valuenode_bline.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 "keyframedial.h"
-
-#include <synfigapp/main.h>
-#include <synfigapp/inputdevice.h>
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-using namespace synfig;
-using namespace studio;
-using namespace sigc;
-
-/* === M A C R O S ========================================================= */
-
-#define GRAB_HINT_DATA(y)      { \
-               String x; \
-               if(synfigapp::Main::settings().get_value(String("pref.")+y+"_hints",x)) \
-               { \
-                       set_type_hint((Gdk::WindowTypeHint)atoi(x.c_str()));    \
-               } \
-       }
-
-#define DEFAULT_TIME_WINDOW_SIZE               (10.0)
-
-#ifndef SMALL_BUTTON
-#define SMALL_BUTTON(button,stockid,tooltip)   \
-       button = manage(new class Gtk::Button());       \
-       icon=manage(new Gtk::Image(Gtk::StockID(stockid),iconsize));    \
-       button->add(*icon);     \
-       tooltips.set_tip(*button,tooltip);      \
-       icon->set_padding(0,0);\
-       icon->show();   \
-       button->set_relief(Gtk::RELIEF_NONE); \
-       button->show()
-#endif
-
-#ifndef NORMAL_BUTTON
-#define NORMAL_BUTTON(button,stockid,tooltip)  \
-       button = manage(new class Gtk::Button());       \
-       icon=manage(new Gtk::Image(Gtk::StockID(stockid),Gtk::ICON_SIZE_BUTTON));       \
-       button->add(*icon);     \
-       tooltips.set_tip(*button,tooltip);      \
-       icon->set_padding(0,0);\
-       icon->show();   \
-       /*button->set_relief(Gtk::RELIEF_NONE);*/ \
-       button->show()
-#endif
-
-#define NEW_SMALL_BUTTON(x,y,z)        Gtk::Button *SMALL_BUTTON(x,y,z)
-
-#define NOT_IMPLEMENTED_SLOT sigc::mem_fun(*reinterpret_cast<studio::CanvasViewUIInterface*>(get_ui_interface().get()),&studio::CanvasViewUIInterface::not_implemented)
-
-#define SLOT_EVENT(x)  sigc::hide_return(sigc::bind(sigc::mem_fun(*this,&studio::CanvasView::process_event_key),x))
-
-/* === C L A S S E S ======================================================= */
-
-class studio::UniversalScrubber
-{
-       CanvasView *canvas_view;
-
-       bool            scrubbing;
-       etl::clock      scrub_timer;
-
-       sigc::connection end_scrub_connection;
-public:
-       UniversalScrubber(CanvasView *canvas_view):
-               canvas_view(canvas_view),
-               scrubbing(false)
-       {
-               canvas_view->canvas_interface()->signal_time_changed().connect(
-                       sigc::mem_fun(*this,&studio::UniversalScrubber::on_time_changed)
-               );
-       }
-
-       ~UniversalScrubber()
-       {
-               end_scrub_connection.disconnect();
-       }
-
-       void on_time_changed()
-       {
-               // Make sure we are changing the time quickly
-               // before we enable scrubbing
-               if(!scrubbing && scrub_timer()>1)
-               {
-                       scrub_timer.reset();
-                       return;
-               }
-
-               // If we aren't scrubbing already, enable it
-               if(!scrubbing)
-               {
-                       scrubbing=true;
-                       audio_container()->start_scrubbing(canvas_view->get_time());
-               }
-
-               // Reset the scrubber ender
-               end_scrub_connection.disconnect();
-               end_scrub_connection=Glib::signal_timeout().connect(
-                       sigc::bind_return(
-                               sigc::mem_fun(*this,&UniversalScrubber::end_of_scrubbing),
-                               false
-                       ),
-                       1000
-               );
-
-               // Scrub!
-               audio_container()->scrub(canvas_view->get_time());
-
-               scrub_timer.reset();
-       }
-
-       void end_of_scrubbing()
-       {
-               scrubbing=false;
-               audio_container()->stop_scrubbing();
-               scrub_timer.reset();
-       }
-
-       handle<AudioContainer> audio_container()
-       {
-               assert(canvas_view->audio);
-               return canvas_view->audio;
-       }
-};
-
-class studio::CanvasViewUIInterface : public synfigapp::UIInterface
-{
-       CanvasView *view;
-
-public:
-
-       CanvasViewUIInterface(CanvasView *view):
-               view(view)
-       {
-               view->statusbar->push(_("Idle"));
-       }
-
-       ~CanvasViewUIInterface()
-       {
-               //view->statusbar->pop();
-               //view->progressbar->set_fraction(0);
-       }
-
-       virtual Response confirmation(const std::string &title,
-                       const std::string &primaryText,
-                       const std::string &secondaryText,
-                       const std::string &confirmPhrase,
-                       const std::string &cancelPhrase,
-                       Response defaultResponse=RESPONSE_OK)
-       {
-               view->present();
-               //while(studio::App::events_pending())studio::App::iteration(false);
-               Gtk::MessageDialog dialog(
-                       *view,                  // Parent
-                       primaryText,            // Message
-                       false,                  // Markup
-                       Gtk::MESSAGE_WARNING,   // Type
-                       Gtk::BUTTONS_NONE,      // Buttons
-                       true                    // Modal
-               );
-
-               if (! title.empty())
-                       dialog.set_title(title);
-               if (! secondaryText.empty())
-                       dialog.set_secondary_text(secondaryText);
-
-               dialog.add_button(cancelPhrase, RESPONSE_CANCEL);
-               dialog.add_button(confirmPhrase, RESPONSE_OK);
-               dialog.set_default_response(defaultResponse);
-
-               dialog.show_all();
-               return (Response) dialog.run();
-       }
-
-       virtual Response yes_no(const std::string &title, const std::string &message,Response dflt=RESPONSE_YES)
-       {
-               view->present();
-               //while(studio::App::events_pending())studio::App::iteration(false);
-               Gtk::Dialog dialog(
-                       title,          // Title
-                       *view,          // Parent
-                       true,           // Modal
-                       true            // use_separator
-               );
-               Gtk::Label label(message);
-               label.show();
-
-               dialog.get_vbox()->pack_start(label);
-               dialog.add_button(Gtk::StockID("gtk-yes"),RESPONSE_YES);
-               dialog.add_button(Gtk::StockID("gtk-no"),RESPONSE_NO);
-
-               dialog.set_default_response(dflt);
-               dialog.show();
-               return (Response)dialog.run();
-       }
-       virtual Response yes_no_cancel(const std::string &title, const std::string &message,Response dflt=RESPONSE_YES)
-       {
-               view->present();
-               //while(studio::App::events_pending())studio::App::iteration(false);
-               Gtk::Dialog dialog(
-                       title,          // Title
-                       *view,          // Parent
-                       true,           // Modal
-                       true            // use_separator
-               );
-               Gtk::Label label(message);
-               label.show();
-
-               dialog.get_vbox()->pack_start(label);
-               dialog.add_button(Gtk::StockID("gtk-yes"),RESPONSE_YES);
-               dialog.add_button(Gtk::StockID("gtk-no"),RESPONSE_NO);
-               dialog.add_button(Gtk::StockID("gtk-cancel"),RESPONSE_CANCEL);
-
-               dialog.set_default_response(dflt);
-               dialog.show();
-               return (Response)dialog.run();
-       }
-       virtual Response ok_cancel(const std::string &title, const std::string &message,Response dflt=RESPONSE_OK)
-       {
-               view->present();
-               //while(studio::App::events_pending())studio::App::iteration(false);
-               Gtk::Dialog dialog(
-                       title,          // Title
-                       *view,          // Parent
-                       true,           // Modal
-                       true            // use_separator
-               );
-               Gtk::Label label(message);
-               label.show();
-
-               dialog.get_vbox()->pack_start(label);
-               dialog.add_button(Gtk::StockID("gtk-ok"),RESPONSE_OK);
-               dialog.add_button(Gtk::StockID("gtk-cancel"),RESPONSE_CANCEL);
-
-               dialog.set_default_response(dflt);
-               dialog.show();
-               return (Response)dialog.run();
-       }
-
-       virtual bool
-       task(const std::string &task)
-       {
-               if(!view->is_playing_)
-               {
-                       view->statusbar->pop();
-                       view->statusbar->push(task);
-               }
-               //while(studio::App::events_pending())studio::App::iteration(false);
-               if(view->cancel){return false;}
-               return true;
-       }
-
-       virtual bool
-       error(const std::string &err)
-       {
-               view->statusbar->push(_("ERROR"));
-
-               // If we are in the process of canceling,
-               // then just go ahead and return false --
-               // don't bother displaying a dialog
-               if(view->cancel)return false;
-               Gtk::MessageDialog dialog(*view, err, false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE, true);
-               dialog.show();
-               dialog.run();
-               view->statusbar->pop();
-               return true;
-       }
-
-       virtual bool
-       warning(const std::string &err)
-       {
-               view->statusbar->pop();
-               view->statusbar->push(err);
-
-               //while(studio::App::events_pending())studio::App::iteration(false);
-               if(view->cancel)return false;
-               return true;
-       }
-
-       virtual bool
-       amount_complete(int current, int total)
-       {
-               if(!view->is_playing_)
-               {
-                       if(!view->working_depth)
-                       {
-                               if(current)
-                                       view->stopbutton->set_sensitive(true);
-                               else
-                                       view->stopbutton->set_sensitive(false);
-                       }
-                       float x((float)current/(float)total);
-                       if(x<0)x=0;
-                       else if(x>1)x=1;
-                       view->progressbar->set_fraction(x);
-               }
-               //while(studio::App::events_pending())studio::App::iteration(false);
-               if(view->cancel){/*view->cancel=false;*/return false;}
-               return true;
-       }
-
-       void
-       not_implemented()
-       {
-               error(_("Feature not yet implemented"));
-       }
-};
-
-class studio::CanvasViewSelectionManager : public synfigapp::SelectionManager
-{
-       CanvasView *view;
-       CanvasView::LayerTreeModel layer_tree_model;
-       CanvasView::ChildrenTreeModel children_tree_model;
-
-public:
-       CanvasViewSelectionManager(CanvasView *view): view(view) { }
-
-private:
-       void _set_selected_layer(const synfig::Layer::Handle &layer)
-       {
-               view->layer_tree->select_layer(layer);
-/*
-               // Don't change the selection while we are busy
-               // I cannot remember exactly why I put this here...
-               // It musta been for some reason, but I cannot recall.
-               //if(App::Busy::count)
-               //      return;
-
-               if(view->layer_tree->get_selection()->get_selected())
-               {
-                       const Gtk::TreeRow row = *(view->layer_tree->get_selection()->get_selected());
-
-                       // Don't do anything if that layer is already selected
-                       if(layer == static_cast<synfig::Layer::Handle>(row[layer_tree_model.layer]))
-                               return;
-               }
-               Gtk::TreeModel::Children::iterator iter;
-               if(view->layer_tree_store()->find_layer_row(layer,iter))
-               {
-                       Gtk::TreePath path(iter);
-                       for(int i=path.get_depth();i;i--)
-                       {
-                               int j;
-                               path=Gtk::TreePath(iter);
-                               for(j=i;j;j--)
-                                       path.up();
-                               view->layer_tree->get_tree_view().expand_row(path,false);
-                       }
-                       view->layer_tree->get_tree_view().scroll_to_row(Gtk::TreePath(iter));
-                       view->layer_tree->get_selection()->select(iter);
-               }
-*/
-       }
-public:
-
-       //! Returns the number of layers selected.
-       virtual int get_selected_layer_count()const
-       {
-               return get_selected_layers().size();
-       }
-
-       //! Returns a list of the currently selected layers.
-       virtual LayerList get_selected_layers()const
-       {
-//             assert(view->layer_tree);
-
-               if(!view->layer_tree) { synfig::error("%s:%d canvas_view.layer_tree not defined!?", __FILE__, __LINE__); return LayerList(); }
-               return view->layer_tree->get_selected_layers();
-       }
-
-       //! Returns the first layer selected or an empty handle if none are selected.
-       virtual synfig::Layer::Handle get_selected_layer()const
-       {
-//             assert(view->layer_tree);
-
-               if(!view->layer_tree) { synfig::error("%s:%d canvas_view.layer_tree not defined!?", __FILE__, __LINE__); return 0; }
-               return view->layer_tree->get_selected_layer();
-       }
-
-       //! Sets which layers should be selected
-       virtual void set_selected_layers(const LayerList &layer_list)
-       {
-//             assert(view->layer_tree);
-
-               if(!view->layer_tree) { 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);
-
-               //view->queue_rebuild_ducks();
-       }
-
-       //! Sets which layer should be selected.
-       virtual void set_selected_layer(const synfig::Layer::Handle &layer)
-       {
-//             assert(view->layer_tree);
-
-               if(!view->layer_tree) { synfig::error("canvas_view.layer_tree not defined!?"); return; }
-               view->layer_tree->select_layer(layer);
-               //view->queue_rebuild_ducks();
-       }
-
-       //! Clears the layer selection list
-       virtual void clear_selected_layers()
-       {
-               if(!view->layer_tree) return;
-               view->layer_tree->clear_selected_layers();
-       }
-
-       //! Returns the number of value_nodes selected.
-       virtual int get_selected_children_count()const
-       {
-               return get_selected_children().size();
-       }
-
-       static inline void __child_grabber(const Gtk::TreeModel::iterator& iter, ChildrenList* ret)
-       {
-               const CanvasView::ChildrenTreeModel children_tree_model;
-               synfigapp::ValueDesc value_desc((*iter)[children_tree_model.value_desc]);
-               if(value_desc)
-                       ret->push_back(value_desc);
-       }
-
-       //! Returns a list of the currently selected value_nodes.
-       virtual ChildrenList get_selected_children()const
-       {
-               if(!view->children_tree) return ChildrenList();
-
-               Glib::RefPtr<Gtk::TreeSelection> selection=view->children_tree->get_selection();
-
-               if(!selection)
-                       return ChildrenList();
-
-               ChildrenList ret;
-
-               selection->selected_foreach_iter(
-                       sigc::bind(
-                               sigc::ptr_fun(
-                                       &studio::CanvasViewSelectionManager::__child_grabber
-                               ),
-                               &ret
-                       )
-               );
-
-               /*
-               Gtk::TreeModel::Children::iterator iter(view->children_tree_store()->children().begin());
-               iter++;
-               Gtk::TreeModel::Children children = iter->children();
-               for(iter = children.begin(); iter != children.end(); ++iter)
-               {
-                       Gtk::TreeModel::Row row = *iter;
-                       if(selection->is_selected(row))
-                               ret.push_back((synfigapp::ValueDesc)row[children_tree_model.value_desc]);
-               }
-               */
-               return ret;
-       }
-
-       //! Returns the first value_node selected or an empty handle if none are selected.
-       virtual ChildrenList::value_type get_selected_child()const
-       {
-               if(!view->children_tree) return ChildrenList::value_type();
-
-               ChildrenList children(get_selected_children());
-
-               if(children.empty())
-                       return ChildrenList::value_type();
-
-               return children.front();
-       }
-
-       //! Sets which value_nodes should be selected
-       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*/)
-       {
-               return;
-       }
-
-       //! Clears the value_node selection list
-       virtual void clear_selected_children()
-       {
-               return;
-       }
-
-       int get_selected_layer_parameter_count()const
-       {
-               return get_selected_layer_parameters().size();
-       }
-
-       LayerParamList get_selected_layer_parameters()const
-       {
-               if(!view->layer_tree) return LayerParamList();
-
-               Glib::RefPtr<Gtk::TreeSelection> selection=view->layer_tree->get_selection();
-
-               if(!selection)
-                       return LayerParamList();
-
-               LayerParamList ret;
-
-               Gtk::TreeModel::Children children = const_cast<CanvasView*>(view)->layer_tree_store()->children();
-               Gtk::TreeModel::Children::iterator iter;
-               for(iter = children.begin(); iter != children.end(); ++iter)
-               {
-                       Gtk::TreeModel::Row row = *iter;
-                       Gtk::TreeModel::Children::iterator iter;
-                       for(iter=row.children().begin();iter!=row.children().end();iter++)
-                       {
-                               Gtk::TreeModel::Row row = *iter;
-                               if(selection->is_selected(row))
-                                       ret.push_back(LayerParam(row[layer_tree_model.layer],(Glib::ustring)row[layer_tree_model.id]));
-                       }
-               }
-               return ret;
-       }
-
-       LayerParam get_selected_layer_parameter() const
-       {
-               if(!view->layer_tree) return LayerParam();
-               return get_selected_layer_parameters().front();
-       }
-
-       void set_selected_layer_parameters(const LayerParamList &/*layer_param_list*/)
-       {
-               return;
-       }
-
-       void set_selected_layer_param(const LayerParam &/*layer_param*/)
-       {
-               return;
-       }
-
-       void clear_selected_layer_parameters()
-       {
-               return;
-       }
-
-}; // END of class SelectionManager
-
-CanvasView::IsWorking::IsWorking(CanvasView &canvas_view_):
-       canvas_view_(canvas_view_)
-{
-       if(!canvas_view_.working_depth)
-               canvas_view_.stopbutton->set_sensitive(true);
-       canvas_view_.working_depth++;
-       canvas_view_.cancel=false;
-}
-
-CanvasView::IsWorking::~IsWorking()
-{
-       canvas_view_.working_depth--;
-       if(!canvas_view_.working_depth)
-               canvas_view_.stopbutton->set_sensitive(false);
-}
-
-CanvasView::IsWorking::operator bool()const
-{
-       if(canvas_view_.cancel)
-               return false;
-       return true;
-}
-
-/* === M E T H O D S ======================================================= */
-
-CanvasView::CanvasView(etl::loose_handle<Instance> instance,etl::handle<synfigapp::CanvasInterface> canvas_interface_):
-       smach_                                  (this),
-       instance_                               (instance),
-       canvas_interface_               (canvas_interface_),
-       //layer_tree_store_             (LayerTreeStore::create(canvas_interface_)),
-       //children_tree_store_  (ChildrenTreeStore::create(canvas_interface_)),
-       //keyframe_tree_store_  (KeyframeTreeStore::create(canvas_interface_)),
-       time_adjustment_                (0,0,25,0,0,0),
-       time_window_adjustment_ (0,0,25,0,0,0),
-       statusbar                               (manage(new class Gtk::Statusbar())),
-       quality_adjustment_             (8,1,10,1,1,0),
-       future_onion_adjustment_ (0,0,2,1,1,0),
-       past_onion_adjustment_  (0,0,2,1,1,0),
-
-       timeslider                              (new Widget_Timeslider),
-       widget_kf_list                  (new Widget_Keyframe_List),
-
-       ui_interface_                   (new CanvasViewUIInterface(this)),
-       selection_manager_              (new CanvasViewSelectionManager(this)),
-       is_playing_                             (false),
-
-       working_depth                   (0),
-       cancel                                  (false),
-
-       canvas_properties               (*this,canvas_interface_),
-       canvas_options                  (this),
-       render_settings                 (*this,canvas_interface_),
-       waypoint_dialog                 (*this,canvas_interface_->get_canvas()),
-       keyframe_dialog                 (*this,canvas_interface_),
-       preview_dialog                  (new Dialog_Preview),
-       sound_dialog                    (new Dialog_SoundSelect(*this,canvas_interface_))
-{
-       layer_tree=0;
-       children_tree=0;
-       duck_refresh_flag=true;
-       toggling_ducks_=false;
-       changing_resolution_=false;
-       updating_quality_=false;
-       toggling_show_grid=false;
-       toggling_snap_grid=false;
-       toggling_onion_skin=false;
-
-       disp_audio = new Widget_Sound();
-
-       //synfig::info("Canvasview: Entered constructor");
-       // Minor hack
-       get_canvas()->set_time(0);
-       //layer_tree_store_->rebuild();
-
-       // Set up the UI and Selection managers
-       canvas_interface()->set_ui_interface(get_ui_interface());
-       canvas_interface()->set_selection_manager(get_selection_manager());
-       rebuild_ducks_queued=false;
-
-       //notebook=manage(new class Gtk::Notebook());
-       //Gtk::VPaned *vpaned = manage(new class Gtk::VPaned());
-       //vpaned->pack1(*create_work_area(), Gtk::EXPAND|Gtk::SHRINK);
-       //vpaned->pack2(*notebook, Gtk::SHRINK);
-       //vpaned->show_all();
-
-       //notebook->show();
-
-       //notebook->append_page(*create_layer_tree(),_("Layers"));
-       //notebook->append_page(*create_children_tree(),_("Children"));
-       //notebook->append_page(*create_keyframe_tree(),_("Keyframes"));
-
-       //synfig::info("Canvasview: Before big chunk of allocation and tabling stuff");
-       //create all allocated stuff for this canvas
-       audio = new AudioContainer();
-
-       Gtk::Table *layout_table= manage(new class Gtk::Table(1, 4, false));
-       //layout_table->attach(*vpaned, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       layout_table->attach(*create_work_area(), 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       layout_table->attach(*create_display_bar(), 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       init_menus();
-       //layout_table->attach(*App::ui_manager()->get_widget("/menu-main"), 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-
-       layout_table->attach(*create_time_bar(), 0, 1, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       layout_table->attach(*create_status_bar(), 0, 1, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-
-       update_title();
-
-       layout_table->show();
-       add(*layout_table);
-
-       //set_transient_for(*App::toolbox);
-
-       smach_.set_default_state(&state_normal);
-
-       //synfig::info("Canvasview: Before Signals");
-       /*
- --    ** -- Signals -------------------------------------------------------------
-       */
-
-       canvas_interface()->signal_dirty_preview().connect(sigc::mem_fun(*this,&studio::CanvasView::on_dirty_preview));
-       canvas_interface()->signal_mode_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::on_mode_changed));
-
-       canvas_interface()->signal_time_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::on_time_changed));
-
-       //canvas_interface()->signal_time_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::refresh_tables));
-       canvas_interface()->signal_id_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::on_id_changed));
-       canvas_interface()->signal_rend_desc_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::refresh_rend_desc));
-       waypoint_dialog.signal_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::on_waypoint_changed));
-       waypoint_dialog.signal_delete().connect(sigc::mem_fun(*this,&studio::CanvasView::on_waypoint_delete));
-
-       //MODIFIED TIME ADJUSTMENT STUFF....
-       time_window_adjustment().set_child_adjustment(&time_adjustment());
-       time_window_adjustment().signal_value_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::refresh_time_window));
-       time_adjustment().signal_value_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::time_was_changed));
-
-       work_area->signal_layer_selected().connect(sigc::mem_fun(*this,&studio::CanvasView::workarea_layer_selected));
-       work_area->signal_input_device_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::on_input_device_changed));
-
-       canvas_interface()->signal_canvas_added().connect(
-               sigc::hide(
-                       sigc::mem_fun(*instance,&studio::Instance::refresh_canvas_tree)
-               )
-       );
-       canvas_interface()->signal_canvas_removed().connect(
-               sigc::hide(
-                       sigc::mem_fun(*instance,&studio::Instance::refresh_canvas_tree)
-               )
-       );
-
-       canvas_interface()->signal_layer_param_changed().connect(
-               sigc::hide(
-                       sigc::hide(
-                               SLOT_EVENT(EVENT_REFRESH_DUCKS)
-                       )
-               )
-       );
-
-       //MUCH TIME STUFF TAKES PLACE IN HERE
-       refresh_rend_desc();
-       refresh_time_window();
-
-       /*! \todo We shouldn't need to do this at construction --
-       **      This should be performed at the first time the window
-       **      becomes visible.
-       */
-       work_area->queue_render_preview();
-
-       // If the canvas is really big, zoom out so that we can fit it all in the window
-       /*! \todo In other words, this is a zoom-to-fit, and should be
-       ** in its own function.
-       */
-       int w=get_canvas()->rend_desc().get_w()+70;
-       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 initialized
-               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);
-       }
-       if(w>700)w=700;
-       if(h>600)h=600;
-       set_default_size(w,h);
-       property_window_position().set_value(Gtk::WIN_POS_NONE);
-
-       std::list<Gtk::TargetEntry> listTargets;
-       listTargets.push_back( Gtk::TargetEntry("STRING") );
-       listTargets.push_back( Gtk::TargetEntry("text/plain") );
-       listTargets.push_back( Gtk::TargetEntry("image") );
-
-       drag_dest_set(listTargets);
-       signal_drag_data_received().connect( sigc::mem_fun(*this, &studio::CanvasView::on_drop_drag_data_received) );
-
-       /*
-       Time length(get_canvas()->rend_desc().get_time_end()-get_canvas()->rend_desc().get_time_start());
-       if(length<10.0)
-       {
-               time_window_adjustment().set_page_increment(length);
-               time_window_adjustment().set_page_size(length);
-       }
-       else
-       {
-               time_window_adjustment().set_page_increment(10.0);
-               time_window_adjustment().set_page_size(10.0);
-       }
-       */
-
-       //synfig::info("Canvasview: Before Sound Hookup");
-       //load sound info from meta data
-       {
-               //synfig::warning("Should load Audio: %s with %s offset",apath.c_str(),aoffset.c_str());
-
-               on_audio_file_notify(); //redundant setting of the metadata, but oh well, it's no big deal :)
-               on_audio_offset_notify();
-
-               //signal connection - since they are all associated with the canvas view
-
-               //hook in signals for sound options box
-               sound_dialog->signal_file_changed().connect(sigc::mem_fun(*this,&CanvasView::on_audio_file_change));
-               sound_dialog->signal_offset_changed().connect(sigc::mem_fun(*this,&CanvasView::on_audio_offset_change));
-
-               //attach to the preview when it's visible
-               //preview_dialog->get_widget().signal_play().connect(sigc::mem_fun(*this,&CanvasView::play_audio));
-               //preview_dialog->get_widget().signal_stop().connect(sigc::mem_fun(*this,&CanvasView::stop_audio));
-
-               //hook to metadata signals
-               get_canvas()->signal_meta_data_changed("audiofile").connect(sigc::mem_fun(*this,&CanvasView::on_audio_file_notify));
-               get_canvas()->signal_meta_data_changed("audiooffset").connect(sigc::mem_fun(*this,&CanvasView::on_audio_offset_notify));
-
-               //universal_scrubber=std::auto_ptr<UniversalScrubber>(new UniversalScrubber(this));
-       }
-
-       //synfig::info("Canvasview: Before Final time set up");
-       //MORE TIME STUFF
-       time_window_adjustment().set_value(get_canvas()->rend_desc().get_time_start());
-       time_window_adjustment().value_changed();
-
-       GRAB_HINT_DATA("canvas_view");
-       /*
-       {
-       set_skip_taskbar_hint(true);
-       set_skip_pager_hint(true);
-       set_type_hint(Gdk::WINDOW_TYPE_HINT_UTILITY);
-       }
-       */
-
-       refresh_rend_desc();
-       hide_tables();
-
-       on_time_changed();
-       //synfig::info("Canvasview: Constructor Done");
-}
-
-CanvasView::~CanvasView()
-{
-       signal_deleted()();
-
-       App::ui_manager()->remove_action_group(action_group);
-
-       // Shut down the smach
-       smach_.egress();
-       smach_.set_default_state(0);
-
-       // We want to ensure that the UI_Manager and
-       // the selection manager get destructed right now.
-       ui_interface_.reset();
-       selection_manager_.reset();
-
-       // Delete any external widgets
-       for(;!ext_widget_book_.empty();ext_widget_book_.erase(ext_widget_book_.begin()))
-       {
-               if(ext_widget_book_.begin()->second)
-                       delete ext_widget_book_.begin()->second;
-       }
-
-       //delete preview
-       audio.reset();
-
-       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();
-
-       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
-               synfig::info("CanvasView::~CanvasView(): Deleted");
-}
-
-std::list<int>&
-CanvasView::get_pixel_sizes()
-{
-       // prime factors of 120 are 2, 2, 2, 3, 5 - see TILE_SIZE in synfig-core/trunk/src/synfig/target_tile.h
-       static int pixel_size_array[] = {2,3,4,5,6,8,10,12,15,20,24,30,40,60,120};
-       static list<int> pixel_sizes = list<int>(pixel_size_array, pixel_size_array + sizeof(pixel_size_array) / sizeof(int));
-
-       return pixel_sizes;
-}
-
-Gtk::Widget *
-CanvasView::create_time_bar()
-{
-       Gtk::Image *icon;
-
-       //Setup the Time Slider and the Time window scroll
-       Gtk::HScrollbar *time_window_scroll = manage(new class Gtk::HScrollbar(time_window_adjustment()));
-       //Gtk::HScrollbar *time_scroll = manage(new class Gtk::HScrollbar(time_adjustment()));
-       //TIME BAR TEMPORARY POSITION
-       //Widget_Timeslider *time_scroll = manage(new Widget_Timeslider);
-       timeslider->set_time_adjustment(&time_adjustment());
-       timeslider->set_bounds_adjustment(&time_window_adjustment());
-       //layout_table->attach(*timeslider, 0, 1, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL);
-       //Setup the keyframe list widget
-       widget_kf_list->set_time_adjustment(&time_adjustment());
-       widget_kf_list->set_canvas_interface(canvas_interface());
-       widget_kf_list->show();
-
-       tooltips.set_tip(*time_window_scroll,_("Moves the time window"));
-       tooltips.set_tip(*timeslider,_("Changes the current time"));
-       time_window_scroll->show();
-       timeslider->show();
-       //time_window_scroll->set_flags(Gtk::CAN_FOCUS); // Uncomment this produce bad render of the HScroll
-       timeslider->set_flags(Gtk::CAN_FOCUS);
-
-       //time_scroll->signal_value_changed().connect(sigc::mem_fun(*work_area, &studio::WorkArea::render_preview_hook));
-       //time_scroll->set_update_policy(Gtk::UPDATE_DISCONTINUOUS);
-
-       //Setup the Animation Mode Button and the Keyframe Lock button
-       Gtk::IconSize iconsize=Gtk::IconSize::from_name("synfig-small_icon");
-       SMALL_BUTTON(animatebutton,"gtk-yes",_("Animate"));
-       animatebutton->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::on_animate_button_pressed));
-       animatebutton->show();
-
-       //Setup the audio display
-       disp_audio->set_size_request(-1,32); //disp_audio->show();
-       disp_audio->set_time_adjustment(&time_adjustment());
-       disp_audio->signal_start_scrubbing().connect(
-               sigc::mem_fun(*audio,&AudioContainer::start_scrubbing)
-       );
-       disp_audio->signal_scrub().connect(
-               sigc::mem_fun(*audio,&AudioContainer::scrub)
-       );
-       disp_audio->signal_stop_scrubbing().connect(
-               sigc::mem_fun(*audio,&AudioContainer::stop_scrubbing)
-       );
-       //Setup the current time widget
-       current_time_widget=manage(new Widget_Time);
-       current_time_widget->set_value(get_time());
-       current_time_widget->set_fps(get_canvas()->rend_desc().get_frame_rate());
-       current_time_widget->signal_value_changed().connect(
-               sigc::mem_fun(*this,&CanvasView::on_current_time_widget_changed)
-       );
-       current_time_widget->set_size_request(0,-1); // request horizontal shrink
-       tooltips.set_tip(*current_time_widget,_("Current time"));
-       current_time_widget->show();
-
-       //Setup the FrameDial widget
-       framedial = manage(new class FrameDial());
-       framedial->signal_seek_begin().connect(
-                       sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_time), Time::begin())
-       );
-       framedial->signal_seek_prev_frame().connect(
-                       sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_frame), -1)
-       );
-       framedial->signal_play_stop().connect(
-                       sigc::mem_fun(*this, &studio::CanvasView::on_play_stop_pressed)
-       );
-       framedial->signal_seek_next_frame().connect(
-                       sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_frame), 1)
-       );
-       framedial->signal_seek_end().connect(
-                       sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_time), Time::end())
-       );
-       framedial->show();
-
-       //Setup the KeyFrameDial widget
-       KeyFrameDial *keyframedial = Gtk::manage(new class KeyFrameDial());
-       keyframedial->signal_seek_prev_keyframe().connect(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::jump_to_prev_keyframe));
-       keyframedial->signal_seek_next_keyframe().connect(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::jump_to_next_keyframe));
-       keyframedial->signal_lock_keyframe().connect(sigc::mem_fun(*this, &studio::CanvasView::on_keyframe_button_pressed));
-       keyframedial->show();
-       keyframebutton=keyframedial->get_lock_button();
-
-       timebar = Gtk::manage(new class Gtk::Table(5, 4, false));
-
-       //Adjust both widgets to be the same as the
-       int header_height = 0;
-       if(getenv("SYNFIG_TIMETRACK_HEADER_HEIGHT"))
-               header_height = atoi(getenv("SYNFIG_TIMETRACK_HEADER_HEIGHT"));
-       if (header_height < 3)
-               header_height = 24;
-       timeslider->set_size_request(-1,header_height-header_height/3+1);
-       widget_kf_list->set_size_request(-1,header_height/3+1);
-
-       //Attach widgets to the timebar
-       //timebar->attach(*manage(disp_audio), 1, 5, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
-       timebar->attach(*current_time_widget, 0, 1, 0, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       timebar->attach(*framedial, 0, 1, 2, 3, Gtk::SHRINK, Gtk::SHRINK);
-       timebar->attach(*timeslider, 1, 3, 1, 2, Gtk::FILL|Gtk::SHRINK, Gtk::FILL|Gtk::SHRINK);
-       timebar->attach(*widget_kf_list, 1, 3, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::SHRINK);
-       timebar->attach(*time_window_scroll, 1, 3, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
-       timebar->attach(*keyframedial, 3, 4, 0, 2, Gtk::SHRINK, Gtk::SHRINK);
-       timebar->attach(*animatebutton, 4, 5, 0, 2, Gtk::SHRINK, Gtk::SHRINK);
-       //timebar->attach(*keyframebutton, 1, 2, 3, 4, Gtk::SHRINK, Gtk::SHRINK);
-
-       timebar->show();
-
-       return timebar;
-}
-
-Gtk::Widget *
-CanvasView::create_work_area()
-{
-       work_area=std::auto_ptr<WorkArea>(new class studio::WorkArea(canvas_interface_));
-       work_area->set_instance(get_instance());
-       work_area->set_canvas(get_canvas());
-       work_area->set_canvas_view(this);
-       work_area->set_progress_callback(get_ui_interface().get());
-       work_area->signal_popup_menu().connect(sigc::mem_fun(*this, &studio::CanvasView::popup_main_menu));
-       work_area->show();
-       return work_area.get();
-}
-
-Gtk::Widget*
-CanvasView::create_status_bar()
-{
-       Gtk::Image *icon;
-       Gtk::IconSize iconsize=Gtk::IconSize::from_name("synfig-small_icon");
-       cancel=false;
-
-       // Create the status bar at the bottom of the window
-       Gtk::Table *statusbartable= manage(new class Gtk::Table(5, 1, false));
-//     statusbar = manage(new class Gtk::Statusbar()); // This is already done at construction
-       progressbar =manage(new class Gtk::ProgressBar());
-       SMALL_BUTTON(stopbutton,"gtk-stop",_("Stop"));
-       SMALL_BUTTON(refreshbutton,"gtk-refresh",_("Refresh"));
-       //SMALL_BUTTON(treetogglebutton,"gtk-go-down",_("Toggle Layer Tree"));
-//     NEW_SMALL_BUTTON(raisebutton,"gtk-go-up",_("Raise Layer"));
-//     NEW_SMALL_BUTTON(lowerbutton,"gtk-go-down",_("Lower Layer"));
-       //statusbartable->attach(*treetogglebutton, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-//     statusbartable->attach(*lowerbutton, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-//     statusbartable->attach(*raisebutton, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-
-       statusbartable->attach(*statusbar, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       statusbartable->attach(*progressbar, 2, 3, 0, 1, Gtk::SHRINK, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       statusbartable->attach(*refreshbutton, 3, 4, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       statusbartable->attach(*stopbutton, 4, 5, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       statusbar->set_has_resize_grip(false);
-       statusbar->show();
-       stopbutton->show();
-       refreshbutton->show();
-       progressbar->show();
-       stopbutton->set_sensitive(false);
-
-       //refreshbutton->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::on_refresh_pressed));
-       //stopbutton->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::stop));
-       //treetogglebutton->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::toggle_tables));
-
-       refreshbutton->signal_clicked().connect(SLOT_EVENT(EVENT_REFRESH));
-       stopbutton->signal_clicked().connect(SLOT_EVENT(EVENT_STOP));
-
-       statusbartable->show_all();
-       return statusbartable;
-}
-
-Gtk::Widget*
-CanvasView::create_display_bar()
-{
-       displaybar = manage(new class Gtk::Table(16, 1, false));
-       Gtk::IconSize iconsize=Gtk::IconSize::from_name("synfig-small_icon_16x16");
-       // Setup the ToggleDuckDial widget
-       toggleducksdial = Gtk::manage(new class ToggleDucksDial(iconsize));
-
-       Duck::Type m = work_area->get_type_mask();
-       toggleducksdial->update_toggles(m);
-
-       toggleducksdial->signal_ducks_position().connect(
-                       sigc::bind(sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),Duck::TYPE_POSITION)
-                       );
-       toggleducksdial->signal_ducks_vertex().connect(
-                       sigc::bind(sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),Duck::TYPE_VERTEX)
-                       );
-       toggleducksdial->signal_ducks_tangent().connect(
-                       sigc::bind(sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),Duck::TYPE_TANGENT)
-                       );
-       toggleducksdial->signal_ducks_radius().connect(
-                       sigc::bind(sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),Duck::TYPE_RADIUS)
-                       );
-       toggleducksdial->signal_ducks_width().connect(
-                       sigc::bind(sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),Duck::TYPE_WIDTH)
-                       );
-       toggleducksdial->signal_ducks_angle().connect(
-                       sigc::bind(sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),Duck::TYPE_ANGLE)
-                       );
-       toggleducksdial->show();
-
-       // Set up the ResolutionDial widget
-       resolutiondial=Gtk::manage(new class ResolutionDial(iconsize));
-
-       resolutiondial->update_lowres(work_area->get_low_resolution_flag());
-       resolutiondial->signal_increase_resolution().connect(
-                       sigc::mem_fun(*this, &studio::CanvasView::decrease_low_res_pixel_size));
-       resolutiondial->signal_decrease_resolution().connect(
-                       sigc::mem_fun(*this, &studio::CanvasView::increase_low_res_pixel_size));
-       resolutiondial->signal_use_low_resolution().connect(
-                       sigc::mem_fun(*this, &studio::CanvasView::toggle_low_res_pixel_flag));
-       resolutiondial->show();
-
-       // Set up some separators
-       Gtk::VSeparator *separator1 = Gtk::manage(new class Gtk::VSeparator());
-       separator1->show();
-       Gtk::VSeparator *separator2 = Gtk::manage(new class Gtk::VSeparator());
-       separator2->show();
-       Gtk::VSeparator *separator3 = Gtk::manage(new class Gtk::VSeparator());
-       separator3->show();
-       Gtk::VSeparator *separator4 = Gtk::manage(new class Gtk::VSeparator());
-       separator4->show();
-       Gtk::VSeparator *separator5 = Gtk::manage(new class Gtk::VSeparator());
-       separator5->show();
-
-       // Set up quality spin button
-       quality_spin=Gtk::manage(new class Gtk::SpinButton(quality_adjustment_));
-       quality_spin->signal_value_changed().connect(
-                       sigc::mem_fun(*this, &studio::CanvasView::update_quality));
-       tooltips.set_tip(*quality_spin, _("Quality (lower is better)"));
-       quality_spin->show();
-
-       // Set up the show grid toggle button
-       show_grid = Gtk::manage(new class Gtk::ToggleButton());
-       show_grid->set_active(work_area->grid_status());
-       Gtk::Image *icon = manage(new Gtk::Image(Gtk::StockID("synfig-toggle_show_grid"), iconsize));
-       icon->set_padding(0, 0);
-       icon->show();
-       show_grid->add(*icon);
-       show_grid->signal_toggled().connect(
-                       sigc::mem_fun(*this, &studio::CanvasView::toggle_show_grid));
-       tooltips.set_tip(*show_grid, _("Show grid when enabled"));
-       show_grid->set_relief(Gtk::RELIEF_NONE);
-       show_grid->show();
-
-       // Set up the snap to grid toggle button
-       snap_grid = Gtk::manage(new class Gtk::ToggleButton());
-       snap_grid->set_active(work_area->grid_status());
-       Gtk::Image *icon2 = manage(new Gtk::Image(Gtk::StockID("synfig-toggle_snap_grid"), iconsize));
-       icon2->set_padding(0, 0);
-       icon2->show();
-       snap_grid->add(*icon2);
-       snap_grid->signal_toggled().connect(
-                       sigc::mem_fun(*this, &studio::CanvasView::toggle_snap_grid));
-       tooltips.set_tip(*snap_grid, _("Snap grid when enabled"));
-       snap_grid->set_relief(Gtk::RELIEF_NONE);
-       snap_grid->show();
-
-       // Set up the onion skin toggle button
-       onion_skin = Gtk::manage(new class Gtk::ToggleButton());
-       onion_skin->set_active(work_area->get_onion_skin());
-       Gtk::Image *icon3 = manage(new Gtk::Image(Gtk::StockID("synfig-toggle_onion_skin"), iconsize));
-       icon3->set_padding(0, 0);
-       icon3->show();
-       onion_skin->add(*icon3);
-       onion_skin->signal_toggled().connect(
-                       sigc::mem_fun(*this, &studio::CanvasView::toggle_onion_skin));
-       tooltips.set_tip(*onion_skin, _("Shows onion skin when enabled"));
-       onion_skin->set_relief(Gtk::RELIEF_NONE);
-       onion_skin->show();
-
-       // Set up past onion skin spin button
-       past_onion_spin=Gtk::manage(new class Gtk::SpinButton(past_onion_adjustment_));
-       past_onion_spin->signal_value_changed().connect(
-                       sigc::mem_fun(*this, &studio::CanvasView::set_onion_skins));
-       tooltips.set_tip(*past_onion_spin, _("Past onion skins"));
-       past_onion_spin->show();
-
-       // Set up future onion skin spin button
-       future_onion_spin=Gtk::manage(new class Gtk::SpinButton(future_onion_adjustment_));
-       future_onion_spin->signal_value_changed().connect(
-                       sigc::mem_fun(*this, &studio::CanvasView::set_onion_skins));
-       tooltips.set_tip(*future_onion_spin, _("Future onion skins"));
-       future_onion_spin->show();
-
-       // Setup render options dialog button
-       render_options_button = Gtk::manage(new class Gtk::Button());
-       Gtk::Image *icon4 = manage(new Gtk::Image(Gtk::StockID("synfig-render_options"), iconsize));
-       icon4->set_padding(0, 0);
-       icon4->show();
-       render_options_button->add(*icon4);
-       render_options_button->signal_clicked().connect(
-                       sigc::mem_fun0(render_settings,&studio::RenderSettings::present));
-       tooltips.set_tip(*render_options_button, _("Shows the Render Settings Dialog"));
-       render_options_button->set_relief(Gtk::RELIEF_NONE);
-       render_options_button->show();
-
-       // Setup preview options dialog button
-       preview_options_button = Gtk::manage(new class Gtk::Button());
-       Gtk::Image *icon5 = manage(new Gtk::Image(Gtk::StockID("synfig-preview_options"), iconsize));
-       icon5->set_padding(0, 0);
-       icon5->show();
-       preview_options_button->add(*icon5);
-       preview_options_button->signal_clicked().connect(
-                       sigc::mem_fun(*this,&CanvasView::on_preview_option));
-       tooltips.set_tip(*preview_options_button, _("Shows the Preview Settings Dialog"));
-       preview_options_button->set_relief(Gtk::RELIEF_NONE);
-       preview_options_button->show();
-
-
-       displaybar->attach(*toggleducksdial, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
-       displaybar->attach(*separator1, 1, 2, 0, 1, Gtk::FILL, Gtk::FILL);
-       displaybar->attach(*resolutiondial, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
-       displaybar->attach(*separator2, 3, 4, 0, 1, Gtk::FILL, Gtk::FILL);
-       displaybar->attach(*quality_spin, 4, 5, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
-       displaybar->attach(*separator3, 5, 6, 0, 1, Gtk::FILL, Gtk::FILL);
-       displaybar->attach(*show_grid, 6, 7, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
-       displaybar->attach(*snap_grid, 7, 8, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
-       displaybar->attach(*separator4, 8, 9, 0, 1, Gtk::FILL, Gtk::FILL);
-       displaybar->attach(*past_onion_spin, 9, 10, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
-       displaybar->attach(*onion_skin, 10, 11, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
-       displaybar->attach(*future_onion_spin, 11, 12, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
-       displaybar->attach(*separator5, 12, 13, 0, 1, Gtk::FILL, Gtk::FILL);
-       displaybar->attach(*render_options_button, 13, 14, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
-       displaybar->attach(*preview_options_button, 14, 15, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
-
-       displaybar->show();
-
-       return displaybar;
-
-}
-
-void
-CanvasView::on_current_time_widget_changed()
-{
-       set_time(current_time_widget->get_value());
-
-       // show the value being used - it will have been rounded to nearest frame
-       // this was already being done elsewhere, but only if the time was really changed;
-       // if the current time was 6f and the user edited it to 6.1f, then the 6.1f would
-       // be left in the display without the following line to fix it
-       current_time_widget->set_value(get_time());
-       current_time_widget->set_position(-1); // leave the cursor at the end
-}
-
-//     Gtk::Widget*
-//     CanvasView::create_children_tree()
-//     {
-//             // Create the layer tree
-//             children_tree=manage(new class ChildrenTree());
-//
-//             // Set up the layer tree
-//             //children_tree->set_model(children_tree_store());
-//             if(children_tree)children_tree->set_time_adjustment(time_adjustment());
-//             if(children_tree)children_tree->show();
-//
-//             // Connect Signals
-//             if(children_tree)children_tree->signal_edited_value().connect(sigc::mem_fun(*this, &studio::CanvasView::on_edited_value));
-//             if(children_tree)children_tree->signal_user_click().connect(sigc::mem_fun(*this, &studio::CanvasView::on_children_user_click));
-//             if(children_tree)children_tree->signal_waypoint_clicked_childrentree().connect(sigc::mem_fun(*this, &studio::CanvasView::on_waypoint_clicked_canvasview));
-//             if(children_tree)children_tree->get_selection()->signal_changed().connect(SLOT_EVENT(EVENT_REFRESH_DUCKS));
-//
-//             return children_tree;
-//     }
-
-//     Gtk::Widget*
-//     CanvasView::create_keyframe_tree()
-//     {
-//             keyframe_tree=manage(new KeyframeTree());
-//
-//             //keyframe_tree->get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
-//             //keyframe_tree->show();
-//             //keyframe_tree->set_model(keyframe_tree_store());
-//             keyframe_tree->set_editable(true);
-//             //keyframe_tree->signal_edited().connect(sigc::hide_return(sigc::mem_fun(*canvas_interface(), &synfigapp::CanvasInterface::update_keyframe)));
-//
-//             keyframe_tree->signal_event().connect(sigc::mem_fun(*this, &studio::CanvasView::on_keyframe_tree_event));
-//
-//             Gtk::ScrolledWindow *scroll_layer_tree = manage(new class Gtk::ScrolledWindow());
-//             scroll_layer_tree->set_flags(Gtk::CAN_FOCUS);
-//             scroll_layer_tree->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
-//             scroll_layer_tree->add(*keyframe_tree);
-//             scroll_layer_tree->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
-//             //scroll_layer_tree->show();
-//
-//
-//             Gtk::Table *layout_table= manage(new Gtk::Table(1, 2, false));
-//             layout_table->attach(*scroll_layer_tree, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-//
-//             Gtk::Image *icon;
-//             Gtk::IconSize iconsize(Gtk::IconSize::from_name("synfig-small_icon"));
-//
-//             NEW_SMALL_BUTTON(button_add,"gtk-add",_("New Keyframe"));
-//             NEW_SMALL_BUTTON(button_duplicate,"synfig-duplicate",_("Duplicate Keyframe"));
-//             NEW_SMALL_BUTTON(button_delete,"gtk-delete",_("Delete Keyframe"));
-//
-//             Gtk::HBox *hbox(manage(new Gtk::HBox()));
-//             layout_table->attach(*hbox, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK, 0, 0);
-//
-//             hbox->pack_start(*button_add,Gtk::PACK_SHRINK);
-//             hbox->pack_start(*button_duplicate,Gtk::PACK_SHRINK);
-//             hbox->pack_start(*button_delete,Gtk::PACK_SHRINK);
-//
-//             /*
-//             button_raise->set_relief(Gtk::RELIEF_HALF);
-//             button_lower->set_relief(Gtk::RELIEF_HALF);
-//             button_duplicate->set_relief(Gtk::RELIEF_HALF);
-//             button_delete->set_relief(Gtk::RELIEF_HALF);
-//             */
-//
-//             button_add->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::on_keyframe_add_pressed));
-//             button_duplicate->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::on_keyframe_duplicate_pressed));
-//             button_delete->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::on_keyframe_remove_pressed));
-//
-//             //layout_table->show_all();
-//
-//             keyframe_tab_child=layout_table;
-//
-//
-//             layout_table->hide();
-//
-//             return layout_table;
-//     }
-
-//     Gtk::Widget*
-//     CanvasView::create_layer_tree()
-//     {
-//             // Create the layer tree
-//             printf("CanvasView::create_layer_tree()\n");
-//             layer_tree=manage(new class LayerTree());
-//
-//             // Set up the layer tree
-//             //layer_tree->set_model(layer_tree_store());
-//             layer_tree->set_time_adjustment(time_adjustment());
-//             layer_tree->show();
-//
-//             // Connect Signals
-//             layer_tree->signal_layer_toggle().connect(sigc::mem_fun(*this, &studio::CanvasView::on_layer_toggle));
-//             layer_tree->signal_edited_value().connect(sigc::mem_fun(*this, &studio::CanvasView::on_edited_value));
-//             layer_tree->signal_layer_user_click().connect(sigc::mem_fun(*this, &studio::CanvasView::on_layer_user_click));
-//             layer_tree->signal_param_user_click().connect(sigc::mem_fun(*this, &studio::CanvasView::on_children_user_click));
-//             layer_tree->signal_waypoint_clicked_layertree().connect(sigc::mem_fun(*this, &studio::CanvasView::on_waypoint_clicked_canvasview));
-//             layer_tree->get_selection()->signal_changed().connect(SLOT_EVENT(EVENT_REFRESH_DUCKS));
-//
-//             layer_tree->hide();
-//             return layer_tree;
-//     }
-
-void
-CanvasView::init_menus()
-{
-/*
-       mainmenu.set_accel_group(get_accel_group());
-       mainmenu.set_accel_path("<Canvas-view>");
-
-       filemenu.set_accel_group(get_accel_group());
-       filemenu.set_accel_path("<Canvas-view>/File");
-
-       editmenu.set_accel_group(get_accel_group());
-       editmenu.set_accel_path("<Canvas-view>/Edit");
-
-       layermenu.set_accel_group(get_accel_group());
-       layermenu.set_accel_path("<Canvas-view>/Layer");
-*/
-       //cache the position of desired widgets
-
-       /*Menus to worry about:
-       - filemenu
-       - editmenu
-       - layermenu
-       - duckmaskmenu
-       - mainmenu
-       - canvasmenu
-       - viewmenu
-       */
-       action_group = Gtk::ActionGroup::create("canvasview");
-
-       //action_group->add( Gtk::Action::create("MenuFile", _("_File")) );
-       action_group->add( Gtk::Action::create("new", Gtk::Stock::NEW),
-               sigc::hide_return(sigc::ptr_fun(&studio::App::new_instance))
-       );
-       action_group->add( Gtk::Action::create("open", Gtk::Stock::OPEN),
-               sigc::hide_return(sigc::mem_fun(*get_instance().get(), &studio::Instance::open))
-       );
-       action_group->add( Gtk::Action::create("save", Gtk::Stock::SAVE),
-               hide_return(sigc::mem_fun(*get_instance().get(), &studio::Instance::save))
-       );
-       action_group->add( Gtk::Action::create("save-as", Gtk::Stock::SAVE_AS),
-               sigc::hide_return(sigc::mem_fun(*get_instance().get(), &studio::Instance::dialog_save_as))
-       );
-       action_group->add( Gtk::Action::create("revert", Gtk::Stock::REVERT_TO_SAVED),
-               sigc::hide_return(sigc::mem_fun(*get_instance().get(), &studio::Instance::safe_revert))
-       );
-       action_group->add( Gtk::Action::create("cvs-add", Gtk::StockID("synfig-cvs_add")),
-               sigc::hide_return(sigc::mem_fun(*get_instance(), &studio::Instance::dialog_cvs_add))
-       );
-       action_group->add( Gtk::Action::create("cvs-update", Gtk::StockID("synfig-cvs_update")),
-               sigc::hide_return(sigc::mem_fun(*get_instance(), &studio::Instance::dialog_cvs_update))
-       );
-       action_group->add( Gtk::Action::create("cvs-revert", Gtk::StockID("synfig-cvs_revert")),
-               sigc::hide_return(sigc::mem_fun(*get_instance(), &studio::Instance::dialog_cvs_revert))
-       );
-       action_group->add( Gtk::Action::create("cvs-commit", Gtk::StockID("synfig-cvs_commit")),
-               sigc::hide_return(sigc::mem_fun(*get_instance(), &studio::Instance::dialog_cvs_commit))
-       );
-       action_group->add( Gtk::Action::create("import", _("Import")),
-               sigc::hide_return(sigc::mem_fun(*this, &studio::CanvasView::image_import))
-       );
-       action_group->add( Gtk::Action::create("render", _("Render")),
-               sigc::mem_fun0(render_settings,&studio::RenderSettings::present)
-       );
-       action_group->add( Gtk::Action::create("preview", _("Preview")),
-               sigc::mem_fun(*this,&CanvasView::on_preview_option)
-       );
-       action_group->add( Gtk::Action::create("sound", _("Sound File")),
-               sigc::mem_fun(*this,&CanvasView::on_audio_option)
-       );
-       action_group->add( Gtk::Action::create("options", _("Options")),
-               sigc::mem_fun0(canvas_options,&studio::CanvasOptions::present)
-       );
-       action_group->add( Gtk::Action::create("close", Gtk::StockID("gtk-close"), _("Close Window")),
-               sigc::hide_return(sigc::mem_fun(*this,&studio::CanvasView::close_view))
-       );
-       action_group->add( Gtk::Action::create("close-document", Gtk::StockID("gtk-close"), _("Close Document")),
-               sigc::hide_return(sigc::mem_fun(*this,&studio::CanvasView::close_instance))
-       );
-       action_group->add( Gtk::Action::create("quit", Gtk::StockID("gtk-quit"), _("Quit")),
-               sigc::hide_return(sigc::ptr_fun(&studio::App::quit))
-       );
-
-       //action_group->add( Gtk::Action::create("undo", Gtk::StockID("gtk-undo")),
-       //      SLOT_EVENT(EVENT_UNDO)
-       //);
-
-       //action_group->add( Gtk::Action::create("redo", Gtk::StockID("gtk-redo")),
-       //      SLOT_EVENT(EVENT_REDO)
-       //);
-
-       action_group->add( Gtk::Action::create("select-all-ducks", _("Select All Ducks")),
-               sigc::mem_fun(*work_area,&studio::WorkArea::select_all_ducks)
-       );
-
-       action_group->add( Gtk::Action::create("unselect-all-ducks", _("Unselect All Ducks")),
-               sigc::mem_fun(*work_area,&studio::WorkArea::unselect_all_ducks)
-       );
-
-       action_group->add( Gtk::Action::create("select-all-layers", _("Select All Layers")),
-               sigc::mem_fun(*this,&CanvasView::on_select_layers)
-       );
-
-       action_group->add( Gtk::Action::create("unselect-all-layers", _("Unselect All Layers")),
-               sigc::mem_fun(*this,&CanvasView::on_unselect_layers)
-       );
-
-       action_group->add( Gtk::Action::create("stop", Gtk::StockID("gtk-stop")),
-               SLOT_EVENT(EVENT_STOP)
-       );
-
-       action_group->add( Gtk::Action::create("refresh", Gtk::StockID("gtk-refresh")),
-               SLOT_EVENT(EVENT_REFRESH)
-       );
-
-       action_group->add( Gtk::Action::create("properties", Gtk::StockID("gtk-properties")),
-               sigc::mem_fun0(canvas_properties,&studio::CanvasProperties::present)
-       );
-
-       // Preview Quality Menu
-       {
-               int i;
-               action_group->add( Gtk::RadioAction::create(quality_group,"quality-00", _("Use Parametric Renderer")),
-                       sigc::bind(
-                               sigc::mem_fun(*work_area, &studio::WorkArea::set_quality),
-                               0
-                       )
-               );
-               for(i=1;i<=10;i++)
-               {
-                       String note;
-                       if (i == 1) note = _(" (best)");
-                       if (i == 10) note = _(" (fastest)");
-                       Glib::RefPtr<Gtk::RadioAction> action(Gtk::RadioAction::create(quality_group,strprintf("quality-%02d",i),
-                                                                                                                                                  strprintf(_("Set Quality to %d"),i) + note));
-                       if (i==8)                       // default quality
-                       {
-                               action->set_active();
-                               work_area->set_quality(i);
-                       }
-                       action_group->add( action,
-                               sigc::bind(
-                                       sigc::mem_fun(*this, &studio::CanvasView::set_quality),
-                                       i
-                               )
-                       );
-               }
-       }
-
-       // Low-Res Quality Menu
-       {
-               int i;
-               for(list<int>::iterator iter = CanvasView::get_pixel_sizes().begin(); iter != CanvasView::get_pixel_sizes().end(); iter++)
-               {
-                       i = *iter;
-                       Glib::RefPtr<Gtk::RadioAction> action(Gtk::RadioAction::create(low_res_pixel_size_group,strprintf("lowres-pixel-%d",i),
-                                                                                                                                                  strprintf(_("Set Low-Res pixel size to %d"),i)));
-                       if(i==2)                        // default pixel size
-                       {
-                               action->set_active();
-                               work_area->set_low_res_pixel_size(i);
-                       }
-                       action_group->add( action,
-                               sigc::bind(
-                                       sigc::mem_fun(*work_area, &studio::WorkArea::set_low_res_pixel_size),
-                                       i
-                               )
-                       );
-               }
-
-               Glib::RefPtr<Gtk::Action> action;
-
-               action=Gtk::Action::create("decrease-low-res-pixel-size", _("Decrease Low-Res Pixel Size"));
-               action_group->add( action,sigc::mem_fun(this, &studio::CanvasView::decrease_low_res_pixel_size));
-
-               action=Gtk::Action::create("increase-low-res-pixel-size",  _("Increase Low-Res Pixel Size"));
-               action_group->add( action, sigc::mem_fun(this, &studio::CanvasView::increase_low_res_pixel_size));
-
-       }
-
-       action_group->add( Gtk::Action::create("play", Gtk::Stock::MEDIA_PLAY),
-               sigc::mem_fun(*this, &studio::CanvasView::play)
-       );
-
-       action_group->add( Gtk::Action::create("dialog-flipbook", _("Preview Window")),
-               sigc::mem_fun0(*preview_dialog, &studio::Dialog_Preview::present)
-       );
-
-       {
-               Glib::RefPtr<Gtk::ToggleAction> action;
-
-               grid_show_toggle = Gtk::ToggleAction::create("toggle-grid-show", _("Show Grid"));
-               grid_show_toggle->set_active(work_area->grid_status());
-               action_group->add(grid_show_toggle, sigc::mem_fun(*this, &studio::CanvasView::toggle_show_grid));
-
-               grid_snap_toggle = Gtk::ToggleAction::create("toggle-grid-snap", _("Snap to Grid"));
-               grid_snap_toggle->set_active(work_area->get_grid_snap());
-               action_group->add(grid_snap_toggle, sigc::mem_fun(*this, &studio::CanvasView::toggle_snap_grid));
-
-               action = Gtk::ToggleAction::create("toggle-guide-show", _("Show Guides"));
-               action->set_active(work_area->get_show_guides());
-               action_group->add(action, sigc::mem_fun(*work_area, &studio::WorkArea::toggle_guide_snap));
-
-               action = Gtk::ToggleAction::create("toggle-low-res", _("Use Low-Res"));
-               action->set_active(work_area->get_low_resolution_flag());
-               action_group->add(action, sigc::mem_fun(*this, &studio::CanvasView::toggle_low_res_pixel_flag));
-
-               action = Gtk::ToggleAction::create("toggle-onion-skin", _("Show Onion Skin"));
-               action->set_active(work_area->get_onion_skin());
-               action_group->add(action, sigc::mem_fun(*this, &studio::CanvasView::toggle_onion_skin));
-       }
-
-       action_group->add( Gtk::Action::create("canvas-zoom-fit", Gtk::StockID("gtk-zoom-fit")),
-               sigc::mem_fun(*work_area, &studio::WorkArea::zoom_fit)
-       );
-       action_group->add( Gtk::Action::create("canvas-zoom-100", Gtk::StockID("gtk-zoom-100")),
-               sigc::mem_fun(*work_area, &studio::WorkArea::zoom_norm)
-       );
-
-       {
-               Glib::RefPtr<Gtk::Action> action;
-
-               action=Gtk::Action::create("seek-next-frame", Gtk::Stock::GO_FORWARD,_("Next Frame"),_("Next Frame"));
-               action_group->add(action,sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_frame),1));
-               action=Gtk::Action::create("seek-prev-frame", Gtk::Stock::GO_BACK,_("Prev Frame"),_("Prev Frame"));
-               action_group->add( action, sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_frame),-1));
-
-               action=Gtk::Action::create("seek-next-second", Gtk::Stock::GO_FORWARD,_("Seek Forward"),_("Seek Forward"));
-               action_group->add(action,sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_time),Time(1)));
-               action=Gtk::Action::create("seek-prev-second", Gtk::Stock::GO_BACK,_("Seek Backward"),_("Seek Backward"));
-               action_group->add( action, sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_time),Time(-1)));
-
-               action=Gtk::Action::create("seek-end", Gtk::Stock::GOTO_LAST,_("Seek to End"),_("Seek to End"));
-               action_group->add(action,sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_time),Time::end()));
-
-               action=Gtk::Action::create("seek-begin", Gtk::Stock::GOTO_FIRST,_("Seek to Begin"),_("Seek to Begin"));
-               action_group->add( action, sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_time),Time::begin()));
-
-               action=Gtk::Action::create("jump-next-keyframe", Gtk::Stock::GO_FORWARD,_("Jump to Next Keyframe"),_("Jump to Next Keyframe"));
-               action_group->add( action,sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::jump_to_next_keyframe));
-
-               action=Gtk::Action::create("jump-prev-keyframe", Gtk::Stock::GO_BACK,_("Jump to Prev Keyframe"),_("Jump to Prev Keyframe"));
-               action_group->add( action,sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::jump_to_prev_keyframe));
-
-               action=Gtk::Action::create("canvas-zoom-in", Gtk::Stock::ZOOM_IN);
-               action_group->add( action,sigc::mem_fun(*work_area, &studio::WorkArea::zoom_in));
-
-               action=Gtk::Action::create("canvas-zoom-out", Gtk::Stock::ZOOM_OUT);
-               action_group->add( action, sigc::mem_fun(*work_area, &studio::WorkArea::zoom_out) );
-
-               action=Gtk::Action::create("time-zoom-in", Gtk::Stock::ZOOM_IN, _("Zoom In on Timeline"));
-               action_group->add( action, sigc::mem_fun(*this, &studio::CanvasView::time_zoom_in) );
-
-               action=Gtk::Action::create("time-zoom-out", Gtk::Stock::ZOOM_OUT, _("Zoom Out on Timeline"));
-               action_group->add( action, sigc::mem_fun(*this, &studio::CanvasView::time_zoom_out) );
-
-       }
-
-       {
-               Glib::RefPtr<Gtk::ToggleAction> action;
-
-#define DUCK_MASK(lower,upper,string)                                                                                          \
-               action=Gtk::ToggleAction::create("mask-" #lower "-ducks", string);                      \
-               action->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_##upper));      \
-               action_group->add(action,                                                                                                       \
-                       sigc::bind(                                                                                                                             \
-                               sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),            \
-                               Duck::TYPE_##upper))
-
-               DUCK_MASK(position,POSITION,_("Show Position Ducks"));
-               DUCK_MASK(tangent,TANGENT,_("Show Tangent Ducks"));
-               DUCK_MASK(vertex,VERTEX,_("Show Vertex Ducks"));
-               DUCK_MASK(radius,RADIUS,_("Show Radius Ducks"));
-               DUCK_MASK(width,WIDTH,_("Show Width Ducks"));
-               DUCK_MASK(angle,ANGLE,_("Show Angle Ducks"));
-
-#undef DUCK_MASK
-       }
-
-       add_accel_group(App::ui_manager()->get_accel_group());
-
-/*     // Here is where we add the actions that may have conflicting
-       // keyboard accelerators.
-       {
-               Glib::RefPtr<Gtk::ActionGroup> accel_action_group(Gtk::ActionGroup::create("canvas_view"));
-               Glib::RefPtr<Gtk::Action> action;
-
-               action=Gtk::Action::create("seek-next-frame", Gtk::StockID("gtk-forward"),_("Next Frame"),_("Next Frame"));
-               accel_action_group->add(action,sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek),1));
-
-               action=Gtk::Action::create("seek-prev-frame", Gtk::StockID("gtk-forward"),_("Prev Frame"),_("Prev Frame"));
-               accel_action_group->add( action, sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek),-1));
-
-               action=Gtk::Action::create("jump-next-keyframe", Gtk::StockID("gtk-forward"),_("Jump to Next Keyframe"),_("Jump to Next Keyframe"));
-               accel_action_group->add( action,sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::jump_to_next_keyframe));
-
-               action=Gtk::Action::create("jump-prev-keyframe", Gtk::StockID("gtk-back"),_("Jump to Prev Keyframe"),_("Jump to Prev Keyframe"));
-               accel_action_group->add( action,sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::jump_to_prev_keyframe));
-
-               action=Gtk::Action::create("canvas-zoom-in", Gtk::StockID("gtk-zoom-in"));
-               accel_action_group->add( action,sigc::mem_fun(*work_area, &studio::WorkArea::zoom_in));
-
-               action=Gtk::Action::create("canvas-zoom-out", Gtk::StockID("gtk-zoom-out"));
-               accel_action_group->add( action, sigc::mem_fun(*work_area, &studio::WorkArea::zoom_out) );
-
-               action=Gtk::Action::create("time-zoom-in", Gtk::StockID("gtk-zoom-in"), _("Zoom In on Timeline"));
-               accel_action_group->add( action, sigc::mem_fun(*this, &studio::CanvasView::time_zoom_in) );
-
-               action=Gtk::Action::create("time-zoom-out", Gtk::StockID("gtk-zoom-out"), _("Zoom Out on Timeline"));
-               accel_action_group->add( action, sigc::mem_fun(*this, &studio::CanvasView::time_zoom_out) );
-
-               Glib::RefPtr<Gtk::UIManager> accel_ui_manager(Gtk::UIManager::create());
-
-               Glib::ustring ui_info =
-               "
-               <ui>
-                       <accelerator action='seek-next-frame' />
-                       <accelerator action='seek-prev-frame' />
-                       <accelerator action='jump-next-keyframe' />
-                       <accelerator action='jump-prev-keyframe' />
-                       <accelerator action='canvas-zoom-in' />
-                       <accelerator action='canvas-zoom-out' />
-                       <accelerator action='time-zoom-in' />
-                       <accelerator action='time-zoom-out' />
-               </ui>
-               ";
-
-               accel_ui_manager->add_ui_from_string(ui_info);
-               add_accel_group(accel_ui_manager->get_accel_group());
-
-               accel_ui_manager->insert_action_group(accel_action_group);
-               set_ref_obj("accel_ui_manager",accel_ui_manager);
-               set_ref_obj("accel_action_group",accel_action_group);
-       }
-*/
-
-#if 0
-//
-//     //Test some key stuff
-//
-//     filemenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-save"),
-//             hide_return(sigc::mem_fun(*get_instance().get(), &studio::Instance::save))));
-//     filemenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-save-as"),sigc::hide_return(sigc::mem_fun(*get_instance(), &studio::Instance::dialog_save_as))));
-//     filemenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-revert-to-saved"),hide_return(sigc::mem_fun(*get_instance().get(), &studio::Instance::safe_revert))));
-//     filemenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
-//
-//     filemenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-cvs_add"),sigc::hide_return(sigc::mem_fun(*get_instance(), &studio::Instance::dialog_cvs_add))));
-//     filemenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-cvs_update"),sigc::hide_return(sigc::mem_fun(*get_instance(), &studio::Instance::dialog_cvs_update))));
-//     filemenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-cvs_commit"),sigc::hide_return(sigc::mem_fun(*get_instance(), &studio::Instance::dialog_cvs_commit))));
-//
-//     filemenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
-//     filemenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Import..."),Gtk::AccelKey('I',Gdk::CONTROL_MASK),sigc::hide_return(sigc::mem_fun(*this, &studio::CanvasView::image_import))));
-//     filemenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
-//     filemenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Render"),Gtk::AccelKey("F9"),
-//             sigc::mem_fun(render_settings,&studio::RenderSettings::present)
-//     ));
-//     filemenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Preview"),Gtk::AccelKey("F11"),
-//             sigc::mem_fun(*this,&CanvasView::on_preview_option)
-//     ));
-//     filemenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Sound File"),
-//             sigc::mem_fun(*this,&CanvasView::on_audio_option)
-//     ));
-//
-//     filemenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
-//     filemenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Options"),Gtk::AccelKey("F12"),
-//             sigc::mem_fun(canvas_options,&studio::CanvasOptions::present)
-//     ));
-//     filemenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
-//     filemenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Close View"),
-//             sigc::hide_return(sigc::mem_fun(*this,&studio::CanvasView::close_view))
-//     ));
-//     filemenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Close Document"),
-//             sigc::hide_return(sigc::mem_fun(*this,&studio::CanvasView::close_document))
-//     ));
-//
-//     editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-undo"),Gtk::AccelKey('Z',Gdk::CONTROL_MASK),SLOT_EVENT(EVENT_UNDO)));
-//     editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-redo"),Gtk::AccelKey('R',Gdk::CONTROL_MASK),SLOT_EVENT(EVENT_REDO)));
-//     editmenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
-//     editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-cut"),NOT_IMPLEMENTED_SLOT));
-//     editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-copy"),NOT_IMPLEMENTED_SLOT));
-//     editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-paste"),NOT_IMPLEMENTED_SLOT));
-//     editmenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
-//     editmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Select All Ducks"),Gtk::AccelKey('E',Gdk::CONTROL_MASK),sigc::mem_fun(*work_area,&studio::WorkArea::select_all_ducks)));
-//     editmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Unselect All Ducks"),Gtk::AccelKey('E',Gdk::CONTROL_MASK),sigc::mem_fun(*work_area,&studio::WorkArea::unselect_all_ducks)));
-//     editmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Select All Layers"),Gtk::AccelKey('A',Gdk::CONTROL_MASK),sigc::mem_fun(*this,&CanvasView::on_select_layers)));
-//     editmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Unselect All Layers"),Gtk::AccelKey('D',Gdk::CONTROL_MASK),sigc::mem_fun(*this,&CanvasView::on_unselect_layers)));
-//     editmenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
-//
-//     //editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-stop"),Gtk::AccelKey(GDK_Escape,static_cast<Gdk::ModifierType>(0)),sigc::hide_return(sigc::mem_fun(*this, &studio::CanvasView::stop))));
-//     //editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-refresh"),Gtk::AccelKey('k',Gdk::CONTROL_MASK),sigc::hide_return(sigc::mem_fun(*this, &studio::CanvasView::on_refresh_pressed))));
-//     editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-stop"),Gtk::AccelKey(GDK_Escape,static_cast<Gdk::ModifierType>(0)),SLOT_EVENT(EVENT_STOP)));
-//     editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-refresh"),Gtk::AccelKey('k',Gdk::CONTROL_MASK),SLOT_EVENT(EVENT_REFRESH)));
-//     editmenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
-//     editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-properties"),Gtk::AccelKey("F8"),
-//             sigc::mem_fun(canvas_properties,&studio::CanvasProperties::present)
-//     ));
-//
-//     build_new_layer_menu(newlayermenu);
-//     layermenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("New"),newlayermenu));
-//
-//
-//     {
-//             synfigapp::Action::ParamList param_list;
-//             param_list.add("canvas",Canvas::Handle(get_canvas()));
-//             param_list.add("canvas_interface",canvas_interface());
-//             add_actions_to_menu(&canvasmenu, param_list,synfigapp::Action::CATEGORY_CANVAS);
-//     }
-//
-//
-//     //canvasmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Keyframe Dialog"),sigc::mem_fun(keyframe_dialog,&studio::Dialog_Keyframe::present)));
-//
-//     // Duck Mask Menu
-//     if(1)
-//             {
-//             duckmaskmenu.items().push_back(Gtk::Menu_Helpers::TearoffMenuElem());
-//
-//             duckmaskmenu.items().push_back(Gtk::Menu_Helpers::CheckMenuElem(_("Position Ducks"),Gtk::AccelKey('1',Gdk::MOD1_MASK)));
-//             duck_mask_position=static_cast<Gtk::CheckMenuItem*>(&duckmaskmenu.items().back());
-//             duck_mask_position->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_POSITION));
-//             duck_mask_position->signal_toggled().connect(
-//                     sigc::bind(
-//                             sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),
-//                             Duck::TYPE_POSITION
-//                     )
-//             );
-//
-//             duckmaskmenu.items().push_back(Gtk::Menu_Helpers::CheckMenuElem(_("Vertex Ducks"),Gtk::AccelKey('2',Gdk::MOD1_MASK)));
-//             duck_mask_vertex=static_cast<Gtk::CheckMenuItem*>(&duckmaskmenu.items().back());
-//             duck_mask_vertex->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_VERTEX));
-//             duck_mask_vertex->signal_toggled().connect(
-//                     sigc::bind(
-//                             sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),
-//                             Duck::TYPE_VERTEX
-//                     )
-//             );
-//
-//             duckmaskmenu.items().push_back(Gtk::Menu_Helpers::CheckMenuElem(_("Tangent Ducks"),Gtk::AccelKey('3',Gdk::MOD1_MASK)));
-//             duck_mask_tangent=static_cast<Gtk::CheckMenuItem*>(&duckmaskmenu.items().back());
-//             duck_mask_tangent->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_TANGENT));
-//             duck_mask_tangent->signal_toggled().connect(
-//                     sigc::bind(
-//                             sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),
-//                             Duck::TYPE_TANGENT
-//                     )
-//             );
-//
-//             duckmaskmenu.items().push_back(Gtk::Menu_Helpers::CheckMenuElem(_("Radius Ducks"),Gtk::AccelKey('4',Gdk::MOD1_MASK)));
-//             duck_mask_radius=static_cast<Gtk::CheckMenuItem*>(&duckmaskmenu.items().back());
-//             duck_mask_radius->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_RADIUS));
-//             duck_mask_radius->signal_toggled().connect(
-//                     sigc::bind(
-//                             sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),
-//                             Duck::TYPE_RADIUS
-//                     )
-//             );
-//
-//             duckmaskmenu.items().push_back(Gtk::Menu_Helpers::CheckMenuElem(_("Width Ducks"),Gtk::AccelKey('5',Gdk::MOD1_MASK)));
-//             duck_mask_width=static_cast<Gtk::CheckMenuItem*>(&duckmaskmenu.items().back());
-//             duck_mask_width->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_WIDTH));
-//             duck_mask_width->signal_toggled().connect(
-//                     sigc::bind(
-//                             sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),
-//                             Duck::TYPE_WIDTH
-//                     )
-//             );
-//
-//             duckmaskmenu.items().push_back(Gtk::Menu_Helpers::CheckMenuElem(_("Angle Ducks"),Gtk::AccelKey('6',Gdk::MOD1_MASK)));
-//             duck_mask_angle=static_cast<Gtk::CheckMenuItem*>(&duckmaskmenu.items().back());
-//             duck_mask_angle->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_ANGLE));
-//             duck_mask_angle->signal_toggled().connect(
-//                     sigc::bind(
-//                             sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),
-//                             Duck::TYPE_ANGLE
-//                     )
-//             );
-//
-//             viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Mask Ducks"),duckmaskmenu));
-//     }
-//
-//     // Preview Quality Menu
-//     if(1)
-//     {
-//             qualitymenu.items().push_back(Gtk::Menu_Helpers::TearoffMenuElem());
-//             int i;
-//             qualitymenu.items().push_back(Gtk::Menu_Helpers::MenuElem(strprintf(_("Use Parametric Renderer"),0),
-//                     sigc::bind(
-//                             sigc::mem_fun(*work_area, &studio::WorkArea::set_quality),
-//                             0
-//                     )
-//             ));
-//             for(i=1;i<=10;i++)
-//             {
-//                     qualitymenu.items().push_back(Gtk::Menu_Helpers::MenuElem(strprintf(_("Set Quality to %d"),i),Gtk::AccelKey('0'+(i%10),Gdk::CONTROL_MASK),
-//                             sigc::bind(
-//                                     sigc::mem_fun(*work_area, &studio::WorkArea::set_quality),
-//                                     i
-//                             )
-//                     ));
-//             }
-//             viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Preview Quality"),qualitymenu));
-//     }
-//
-//     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)));
-//
-//     viewmenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
-//
-//     viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Toggle Grid Show"),Gtk::AccelKey('g',Gdk::CONTROL_MASK),
-//             sigc::mem_fun(*work_area, &studio::WorkArea::toggle_grid)));
-//     viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Toggle Grid Snap"),Gtk::AccelKey('l',Gdk::CONTROL_MASK),
-//             sigc::mem_fun(*work_area, &studio::WorkArea::toggle_grid_snap)));
-//     viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Toggle Guide Snap"),Gtk::AccelKey('k',Gdk::CONTROL_MASK),
-//             sigc::mem_fun(*work_area, &studio::WorkArea::toggle_guide_snap)));
-//     viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Toggle Low-Res"),Gtk::AccelKey('`',Gdk::CONTROL_MASK),
-//             sigc::mem_fun(*work_area, &studio::WorkArea::toggle_low_resolution_flag)));
-//
-//     viewmenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
-//
-//     viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-zoom-in"),Gtk::AccelKey('=',static_cast<Gdk::ModifierType>(0)),
-//             sigc::mem_fun(*work_area, &studio::WorkArea::zoom_in)));
-//     viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-zoom-out"),Gtk::AccelKey('-',static_cast<Gdk::ModifierType>(0)),
-//             sigc::mem_fun(*work_area, &studio::WorkArea::zoom_out)));
-//     viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-zoom-fit"),
-//             sigc::mem_fun(*work_area, &studio::WorkArea::zoom_fit)));
-//     viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-zoom-100"),Gtk::AccelKey('`',static_cast<Gdk::ModifierType>(0)),
-//             sigc::mem_fun(*work_area, &studio::WorkArea::zoom_norm)));
-//     viewmenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
-//
-//     viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-zoom-in"),Gtk::AccelKey('+',static_cast<Gdk::ModifierType>(0)),
-//             sigc::mem_fun(*this, &studio::CanvasView::time_zoom_in)));
-//     viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-zoom-out"),Gtk::AccelKey('_',static_cast<Gdk::ModifierType>(0)),
-//             sigc::mem_fun(*this, &studio::CanvasView::time_zoom_out)));
-//
-//     viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Jump to Next Keyframe"),Gtk::AccelKey(']',static_cast<Gdk::ModifierType>(0)),
-//             sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::jump_to_next_keyframe)));
-//     viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Jump to Prev Keyframe"),Gtk::AccelKey('[',static_cast<Gdk::ModifierType>(0)),
-//             sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::jump_to_prev_keyframe)));
-//
-//     mainmenu.items().push_back(Gtk::Menu_Helpers::TearoffMenuElem());
-//     mainmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("_File"),filemenu));
-//     mainmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Edit"),editmenu));
-//     mainmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("_View"),viewmenu));
-//     mainmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Canvas"),canvasmenu));
-//     mainmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Layer"),layermenu));
-//
-//     mainmenu.accelerate(*this);
-//
-///*
-//     {
-//
-//             trackmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("New Waypoint"),NOT_IMPLEMENTED_SLOT));
-//             trackmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Delete Waypoint"),NOT_IMPLEMENTED_SLOT));
-//             trackmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Export"),NOT_IMPLEMENTED_SLOT));
-//             trackmenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
-//             trackmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Properties"),NOT_IMPLEMENTED_SLOT));
-//     }
-//*/
-//     mainmenu.show();
-//     filemenu.show();
-//     editmenu.show();
-//     canvasmenu.show();
-//     layermenu.show();
-//
-//     keyframemenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-properties"),
-//             sigc::mem_fun(*this,&studio::CanvasView::show_keyframe_dialog)
-//     ));
-//
-//
-//     get_accel_group()->unlock();
-//
-//     //Set the accelerator paths for all the menus
-//     filemenu.set_accel_path("<synfig>/File");
-//     editmenu.set_accel_path("<synfig>/Edit");
-//     layermenu.set_accel_path("<synfig>/Layer");
-//     //mainmenu.set_accel_path("<synfig-main>");
-//     canvasmenu.set_accel_path("<synfig>/Canvas");
-//     viewmenu.set_accel_path("<synfig>/View");
-//     duckmaskmenu.set_accel_path("<synfig>/DuckMask");
-#endif
-}
-
-void
-CanvasView::on_select_layers()
-{
-       Canvas::Handle canvas(get_canvas());
-       for (CanvasBase::iterator iter = canvas->begin(); iter != canvas->end(); iter++)
-               layer_tree->select_all_children_layers(*iter);
-}
-
-void
-CanvasView::on_unselect_layers()
-{
-       layer_tree->clear_selected_layers();
-}
-
-void
-CanvasView::show_keyframe_dialog()
-{
-       Glib::RefPtr<Gtk::TreeSelection> selection(keyframe_tree->get_selection());
-       if(selection->get_selected())
-       {
-               Gtk::TreeRow row(*selection->get_selected());
-
-               Keyframe keyframe(row[keyframe_tree->model.keyframe]);
-
-               keyframe_dialog.set_keyframe(keyframe);
-               keyframe_dialog.present();
-       }
-}
-
-void
-CanvasView::add_layer(synfig::String x)
-{
-       Canvas::Handle canvas;
-
-       synfigapp::SelectionManager::LayerList layer_list(get_selection_manager()->get_selected_layers());
-
-       int target_depth(0);
-
-       if(layer_list.empty())
-       {
-               canvas=get_canvas();
-       }
-       else
-       {
-               canvas=(*layer_list.begin())->get_canvas();
-               target_depth=canvas->get_depth(*layer_list.begin());
-       }
-
-       Layer::Handle layer(canvas_interface()->add_layer_to(x,canvas,target_depth));
-       if(layer)
-       {
-               get_selection_manager()->clear_selected_layers();
-               get_selection_manager()->set_selected_layer(layer);
-       }
-}
-
-void
-CanvasView::popup_layer_menu(synfig::Layer::Handle layer)
-{
-       //Gtk::Menu* menu(manage(new Gtk::Menu));
-       Gtk::Menu* menu(&parammenu);
-       menu->items().clear();
-
-       synfigapp::Action::ParamList param_list;
-       param_list.add("time",canvas_interface()->get_time());
-       param_list.add("canvas",Canvas::Handle(layer->get_canvas()));
-       param_list.add("canvas_interface",canvas_interface());
-       param_list.add("layer",layer);
-
-       //Gtk::Menu *newlayers(manage(new Gtk::Menu()));
-       //build_new_layer_menu(*newlayers);
-
-       //parammenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("New Layer"),*newlayers));
-
-       if(layer->get_name()=="PasteCanvas")
-       {
-               menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Select All Children"),
-                       sigc::bind(
-                               sigc::mem_fun(
-                                       *layer_tree,
-                                       &studio::LayerTree::select_all_children_layers
-                               ),
-                               layer
-                       )
-               ));
-       }
-
-       add_actions_to_menu(menu, param_list,synfigapp::Action::CATEGORY_LAYER);
-
-       menu->popup(3,gtk_get_current_event_time());
-}
-
-void
-CanvasView::register_layer_type(synfig::Layer::Book::value_type &/*lyr*/,std::map<synfig::String,Gtk::Menu*>* /*category_map*/)
-{
-/*     if(lyr.second.category==CATEGORY_DO_NOT_USE)
-               return;
-
-       if(category_map->count(lyr.second.category)==0)
-               (*category_map)[lyr.second.category]=manage(new Gtk::Menu());
-
-       (*category_map)[lyr.second.category]->items().push_back(Gtk::Menu_Helpers::MenuElem(lyr.second.local_name,
-               sigc::hide_return(
-                       sigc::bind(
-                               sigc::mem_fun(*this,&studio::CanvasView::add_layer),
-                               lyr.first
-                       )
-               )
-       ));
-*/
-}
-
-void
-CanvasView::build_new_layer_menu(Gtk::Menu &/*menu*/)
-{
-/*
-       std::map<synfig::String,Gtk::Menu*> category_map;
-
-       std::for_each(
-               synfig::Layer::book().begin(),
-               synfig::Layer::book().end(),
-               sigc::bind(
-                       sigc::mem_fun(
-                               *this,
-                               &studio::CanvasView::register_layer_type
-                       ),
-                       &category_map
-               )
-       );
-
-       menu.items().clear();
-       menu.items().push_back(Gtk::Menu_Helpers::TearoffMenuElem());
-
-       std::map<synfig::String,Gtk::Menu*>::iterator iter;
-       for(iter=category_map.begin();iter!=category_map.end();++iter)
-               menu.items().push_back(Gtk::Menu_Helpers::MenuElem(iter->first,*iter->second));
-
-       menu.show();
-*/
-}
-
-void
-CanvasView::popup_main_menu()
-{
-       //mainmenu.popup(0,gtk_get_current_event_time());
-       Gtk::Menu* menu = dynamic_cast<Gtk::Menu*>(App::ui_manager()->get_widget("/menu-main"));
-       if(menu)
-       {
-               //menu->set_accel_group(App::ui_manager()->get_accel_group());
-               //menu->accelerate(*this);
-               menu->popup(0,gtk_get_current_event_time());
-       }
-}
-
-void
-CanvasView::on_refresh_pressed()
-{
-       rebuild_tables();
-       rebuild_ducks();
-       work_area->queue_render_preview();
-}
-
-void
-CanvasView::workarea_layer_selected(synfig::Layer::Handle layer)
-{
-       get_selection_manager()->clear_selected_layers();
-       if(layer)
-               get_selection_manager()->set_selected_layer(layer);
-}
-
-void
-CanvasView::refresh_rend_desc()
-{
-       current_time_widget->set_fps(get_canvas()->rend_desc().get_frame_rate());
-
-       //????
-       //synfig::info("Canvasview: Refreshing render desc info");
-       if(!get_time().is_equal(time_adjustment().get_value()))
-       {
-               time_adjustment().set_value(get_time());
-               time_adjustment().value_changed();
-       }
-
-       Time length(get_canvas()->rend_desc().get_time_end()-get_canvas()->rend_desc().get_time_start());
-       if(length<DEFAULT_TIME_WINDOW_SIZE)
-       {
-               time_window_adjustment().set_page_increment(length);
-               time_window_adjustment().set_page_size(length);
-       }
-       else
-       {
-               time_window_adjustment().set_page_increment(DEFAULT_TIME_WINDOW_SIZE);
-               time_window_adjustment().set_page_size(DEFAULT_TIME_WINDOW_SIZE);
-       }
-
-       //set the FPS of the timeslider
-       timeslider->set_global_fps(get_canvas()->rend_desc().get_frame_rate());
-
-       //set the beginning and ending time of the time slider
-       Time begin_time=get_canvas()->rend_desc().get_time_start();
-       Time end_time=get_canvas()->rend_desc().get_time_end();
-
-       // Setup the time_window adjustment
-       time_window_adjustment().set_lower(begin_time);
-       time_window_adjustment().set_upper(end_time);
-       time_window_adjustment().set_step_increment(synfig::Time(1.0/get_canvas()->rend_desc().get_frame_rate()));
-
-       //Time length(get_canvas()->rend_desc().get_time_end()-get_canvas()->rend_desc().get_time_start());
-       if(length < time_window_adjustment().get_page_size())
-       {
-               time_window_adjustment().set_page_increment(length);
-               time_window_adjustment().set_page_size(length);
-       }
-
-       /*synfig::info("w: %p - [%.3f,%.3f] (%.3f,%.3f) child: %p\n",
-                               &time_window_adjustment_, time_window_adjustment_.get_lower(),
-                               time_window_adjustment_.get_upper(),time_window_adjustment_.get_value(),
-                               time_window_adjustment_.get_page_size(),time_window_adjustment_.get_child_adjustment()
-       );*/
-
-       time_window_adjustment().changed(); //only non-value stuff was changed
-
-       // Setup the time adjustment
-
-       //NOTE THESE TWO SHOULD BE CHANGED BY THE changed() CALL ABOVE
-       //time_adjustment().set_lower(time_window_adjustment().get_value());
-       //time_adjustment().set_upper(time_window_adjustment().get_value()+time_window_adjustment().get_page_size());
-
-//     time_adjustment().set_lower(get_canvas()->rend_desc().get_time_start());
-//     time_adjustment().set_upper(get_canvas()->rend_desc().get_time_end());
-       time_adjustment().set_step_increment(synfig::Time(1.0/get_canvas()->rend_desc().get_frame_rate()));
-       time_adjustment().set_page_increment(synfig::Time(1.0));
-       time_adjustment().set_page_size(0);
-
-       time_adjustment().changed();
-
-       /*synfig::info("w: %p - [%.3f,%.3f] (%.3f,%.3f) child: %p\n",
-                               &time_window_adjustment_, time_window_adjustment_.get_lower(),
-                               time_window_adjustment_.get_upper(),time_window_adjustment_.get_value(),
-                               time_window_adjustment_.get_page_size(),time_window_adjustment_.get_child_adjustment()
-       );      */
-
-       if(begin_time==end_time)
-       {
-               hide_timebar();
-       }
-       else
-       {
-               show_timebar();
-       }
-
-       //clamp time to big bounds...
-       if(time_window_adjustment().get_value() < begin_time)
-       {
-               time_window_adjustment().set_value(begin_time);
-               time_window_adjustment().value_changed();
-       }
-
-       if(time_window_adjustment().get_value() + time_window_adjustment().get_page_size() > end_time)
-       {
-               time_window_adjustment().set_value(end_time - time_window_adjustment().get_page_size());
-               time_window_adjustment().value_changed();
-       }
-
-       if(time_adjustment().get_value() < begin_time)
-       {
-               time_adjustment().set_value(begin_time);
-               time_adjustment().value_changed();
-       }
-
-       if(time_adjustment().get_value() > end_time)
-       {
-               time_adjustment().set_value(end_time);
-               time_adjustment().value_changed();
-       }
-
-       /*synfig::info("Time stats: \n"
-                               "w: %p - [%.3f,%.3f] (%.3f,%.3f) child: %p\n"
-                               "t: %p - [%.3f,%.3f] %.3f",
-                               &time_window_adjustment_, time_window_adjustment_.get_lower(),
-                               time_window_adjustment_.get_upper(),time_window_adjustment_.get_value(),
-                               time_window_adjustment_.get_page_size(),time_window_adjustment_.get_child_adjustment(),
-                               &time_adjustment_,time_adjustment_.get_lower(),time_adjustment_.get_upper(),
-                               time_adjustment_.get_value()
-       );*/
-
-       work_area->queue_render_preview();
-}
-
-bool
-CanvasView::close_view()
-{
-       if(get_instance()->get_visible_canvases()==1)
-               close_instance();
-       else
-               hide();
-       return false;
-}
-
-static bool _close_instance(etl::handle<Instance> instance)
-{
-       etl::handle<Instance> argh(instance);
-       instance->safe_close();
-       synfig::info("closed");
-       return false;
-}
-
-bool
-CanvasView::close_instance()
-{
-#ifdef SINGLE_THREADED
-       if (get_work_area()->get_updating())
-       {
-               get_work_area()->stop_updating(true); // stop and mark as cancelled
-
-               // give the workarea chances to stop updating
-               Glib::signal_timeout().connect(
-                       sigc::mem_fun(*this, &CanvasView::close_instance),
-                       250);
-       }
-       else
-#endif
-               Glib::signal_timeout().connect(
-                       sigc::bind(sigc::ptr_fun(_close_instance),
-                                          (etl::handle<Instance>)get_instance()),
-                       250);
-       return false;
-}
-
-handle<CanvasView>
-CanvasView::create(etl::loose_handle<Instance> instance, etl::handle<synfig::Canvas> canvas)
-{
-       etl::handle<studio::CanvasView> view(new CanvasView(instance,instance->synfigapp::Instance::find_canvas_interface(canvas)));
-       instance->canvas_view_list().push_front(view);
-       instance->signal_canvas_view_created()(view.get());
-       return view;
-}
-
-void
-CanvasView::update_title()
-{
-       string title;
-
-       title = strprintf("%s%s\"%s\"",
-                                         (
-                                                 get_instance()->get_action_count()
-                                                 ? "*"
-                                                 : ""
-                                         ), (
-                                                 get_instance()->has_real_filename()
-                                                 ? (etl::basename(get_instance()->get_file_name()) + " : ").c_str()
-                                                 : ""
-                                         ), (
-                                                 get_canvas()->get_name().empty()
-                                                 ? get_canvas()->get_id().c_str()
-                                                 : get_canvas()->get_name().c_str()
-                                         ));
-
-       if(get_instance()->synfigapp::Instance::in_repository())
-       {
-               title+=" (CVS";
-               if(get_instance()->synfigapp::Instance::is_modified())
-                       title+=_("-MODIFIED");
-               if(get_instance()->synfigapp::Instance::is_updated())
-                       title+=_("-UPDATED");
-               title+=')';
-       }
-
-       if(get_canvas()->is_root())
-               title+=_(" (Root)");
-
-       set_title(title);
-}
-
-void
-CanvasView::on_hide()
-{
-       smach_.egress();
-       Gtk::Window::on_hide();
-}
-
-void
-CanvasView::present()
-{
-       grab_focus();//on_focus_in_event(0);
-       Gtk::Window::present();
-}
-
-bool
-CanvasView::on_focus_in_event(GdkEventFocus*x)
-{
-       if(studio::App::get_selected_canvas_view()!=this)
-       {
-               if(studio::App::get_selected_canvas_view())
-               {
-                       studio::App::get_selected_canvas_view()->get_smach().process_event(EVENT_YIELD_TOOL_OPTIONS);
-                       App::ui_manager()->remove_action_group(App::get_selected_canvas_view()->action_group);
-               }
-
-               get_smach().process_event(EVENT_REFRESH_TOOL_OPTIONS);
-
-               studio::App::set_selected_canvas_view(this);
-
-               App::ui_manager()->insert_action_group(action_group);
-       }
-
-       // HACK ... Questionable...?
-       if(x)
-               return Gtk::Window::on_focus_in_event(x);
-
-       return true;
-}
-
-bool
-CanvasView::on_focus_out_event(GdkEventFocus*x)
-{
-       //App::ui_manager()->remove_action_group(action_group);
-       //App::ui_manager()->ensure_update();
-       return Gtk::Window::on_focus_out_event(x);
-}
-
-void
-CanvasView::refresh_tables()
-{
-//     if(layer_tree_store_)layer_tree_store_->refresh();
-//     if(children_tree_store_)children_tree_store_->refresh();
-}
-
-void
-CanvasView::rebuild_tables()
-{
-//     layer_tree_store_->rebuild();
-//     children_tree_store_->rebuild();
-}
-
-void
-CanvasView::build_tables()
-{
-//     layer_tree_store_->rebuild();
-//     children_tree_store_->rebuild();
-}
-
-void
-CanvasView::on_layer_toggle(synfig::Layer::Handle layer)
-{
-       synfigapp::Action::Handle action(synfigapp::Action::create("LayerActivate"));
-       assert(action);
-
-       if(!action)
-               return;
-
-       action->set_param("canvas",Canvas::Handle(layer->get_canvas()));
-       if(!action->set_param("canvas_interface",canvas_interface()))
-//     if(!action->set_param("canvas_interface",get_instance()->find_canvas_interface(layer->get_canvas())))
-               synfig::error("LayerActivate didn't like CanvasInterface...?");
-       action->set_param("time",get_time());
-       action->set_param("layer",layer);
-       action->set_param("new_status",!layer->active());
-
-       assert(action->is_ready());
-
-       canvas_interface()->get_instance()->perform_action(action);
-}
-
-void
-CanvasView::popup_param_menu(synfigapp::ValueDesc value_desc, float location, bool bezier)
-{
-       parammenu.items().clear();
-       get_instance()->make_param_menu(&parammenu,get_canvas(),value_desc,location,bezier);
-
-       parammenu.popup(3,gtk_get_current_event_time());
-}
-
-void
-CanvasView::add_actions_to_menu(Gtk::Menu *menu, const synfigapp::Action::ParamList &param_list,synfigapp::Action::Category category)const
-{
-       get_instance()->add_actions_to_menu(menu, param_list, category);
-}
-
-bool
-CanvasView::on_layer_user_click(int button, Gtk::TreeRow /*row*/, LayerTree::ColumnID /*column_id*/)
-{
-       switch(button)
-       {
-       case 3:
-               {
-                       Gtk::MenuItem* menu = dynamic_cast<Gtk::MenuItem*>(App::ui_manager()->get_widget("/menu-main/menu-layer"));
-                       if(menu && menu->get_submenu())
-                       {
-                               //menu->set_accel_group(App::ui_manager()->get_accel_group());
-                               //menu->accelerate(*this);
-                               menu->get_submenu()->popup(button,gtk_get_current_event_time());
-                       }
-
-                       #if 0
-                       bool multiple_selected=true;
-
-                       if(layer_tree->get_selection()->count_selected_rows()<=1)
-                               multiple_selected=false;
-
-                       // If the clicked row is not selected, then unselect
-                       // everything that isn't selected and select this row
-                       if(multiple_selected && !layer_tree->get_selection()->is_selected(row))
-                       {
-                               layer_tree->get_selection()->unselect_all();
-                               layer_tree->get_selection()->select(row);
-                               multiple_selected=false;
-                       }
-
-                       if(column_id==COLUMNID_TIME_TRACK)
-                               return false;
-
-                       //synfigapp::ValueDesc value_desc(row[layer_param_tree_model.value_desc]);
-                       //ValueNode::Handle value_node(row[layer_param_tree_model.value_node]);
-                       //ValueNode::Handle parent_value_node;
-                       //ValueBase value=row[layer_param_tree_model.value];
-
-                       //if(row.parent())
-                       //{
-                       //      parent_value_node=(*row.parent())[layer_tree_model.value_node];
-                       //}
-
-                       {
-                               Layer::Handle layer(row[layer_tree_model.layer]);
-                               synfigapp::Action::ParamList param_list;
-                               param_list.add("time",canvas_interface()->get_time());
-                               param_list.add("canvas",Canvas::Handle(row[layer_tree_model.canvas]));
-                               param_list.add("canvas_interface",canvas_interface());
-                               if(!multiple_selected)
-                                       param_list.add("layer",layer);
-                               else
-                               {
-                                       synfigapp::SelectionManager::LayerList layer_list(get_selection_manager()->get_selected_layers());
-                                       synfigapp::SelectionManager::LayerList::iterator iter;
-
-                                       for(iter=layer_list.begin();iter!=layer_list.end();++iter)
-                                               param_list.add("layer",Layer::Handle(*iter));
-                               }
-
-                               parammenu.items().clear();
-
-                               Gtk::Menu *newlayers(manage(new Gtk::Menu()));
-                               // do we need this?  the code is all #ifdef'ed out anyway
-                               // newlayers->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), newlayers));
-                               build_new_layer_menu(*newlayers);
-
-                               parammenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("New Layer"),*newlayers));
-                               if(!multiple_selected && layer->get_name()=="PasteCanvas")
-                               {
-                                       parammenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Select All Children"),
-                                               sigc::bind(
-                                                       sigc::mem_fun(
-                                                               *layer_tree,
-                                                               &studio::LayerTree::select_all_children_layers
-                                                       ),
-                                                       layer
-                                               )
-                                       ));
-                               }
-
-                               add_actions_to_menu(&parammenu, param_list,synfigapp::Action::CATEGORY_LAYER);
-                               parammenu.popup(button,gtk_get_current_event_time());
-                               return true;
-                       }
-/*
-                       else if(column_id==LayerTree::COLUMNID_TIME_TRACK && value_node && handle<synfig::ValueNode_Animated>::cast_dynamic(value_node))
-                       {
-                               // Right-click on time track with animated
-//                             trackmenu.popup(0,0);
-                               return true;
-                       }
-                       else
-                       {
-                               if(!multiple_selected)
-                               {
-                                       popup_param_menu(value_desc);
-                                       return true;
-                               }
-                               else
-                               {
-#warning update me!
-#if 0
-                                       parammenu.items().clear();
-                                       parammenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Connect"),
-                                               hide_return(sigc::mem_fun(*canvas_interface().get(),&synfigapp::CanvasInterface::connect_selected_layer_params))
-                                       ));
-                                       parammenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Disconnect"),
-                                               hide_return(sigc::mem_fun(*canvas_interface().get(),&synfigapp::CanvasInterface::disconnect_selected_layer_params))
-                                       ));
-                                       parammenu.popup(0,0);
-#endif
-                               }
-                               return true;
-                       }
-               */
-#endif
-}
-               return true;
-               break;
-
-       default:
-               return false;
-               break;
-       }
-}
-
-bool
-CanvasView::on_children_user_click(int button, Gtk::TreeRow row, ChildrenTree::ColumnID column_id)
-{
-       switch(button)
-       {
-       case 3:
-               {
-                       if(column_id==COLUMNID_TIME_TRACK)
-                               return false;
-                       if(!(bool)row[children_tree_model.is_canvas])
-                       {
-                               synfigapp::ValueDesc value_desc=row[children_tree_model.value_desc];
-                               if (!value_desc)
-                               {
-                                       //! \todo fix properly -- what is the child dialog for?
-                                       synfig::info("preventing child dialog right-click crash");
-                                       return true;
-                               }
-                               assert(value_desc);
-                               popup_param_menu(value_desc);
-                               return true;
-                       }
-               }
-               return true;
-               break;
-
-       default:
-               return false;
-               break;
-       }
-}
-
-bool
-CanvasView::on_keyframe_tree_event(GdkEvent *event)
-{
-    switch(event->type)
-    {
-       case GDK_BUTTON_PRESS:
-               switch(event->button.button)
-               {
-                       case 3:
-                       {
-                               //keyframemenu.popup(event->button.button,gtk_get_current_event_time());
-                               return true;
-                       }
-                       break;
-               }
-               break;
-       case GDK_MOTION_NOTIFY:
-               break;
-       case GDK_BUTTON_RELEASE:
-               break;
-       default:
-               break;
-       }
-       return false;
-}
-
-void
-CanvasView::refresh_time_window()
-{
-       //THESE SHOULD AUTOMATICALLY BE TAKEN CARE OF
-       //time_adjustment().set_lower(time_window_adjustment().get_value());
-       //time_adjustment().set_upper(time_window_adjustment().get_value()+time_window_adjustment().get_page_size());
-
-       time_adjustment().set_page_increment(1.0); // One second
-       time_adjustment().set_page_size(0);
-
-       if(get_canvas())
-               time_adjustment().set_step_increment(1.0/get_canvas()->rend_desc().get_frame_rate());
-       time_adjustment().changed();
-
-       //NOTE THIS SHOULD HOOK INTO THE CORRECT SIGNALS...
-       if(children_tree)
-               children_tree->queue_draw();
-}
-
-void
-CanvasView::on_time_changed()
-{
-       Time time(get_time());
-
-       current_time_widget->set_value(time);
-       try {
-               get_canvas()->keyframe_list().find(time);
-               current_time_widget->modify_text(Gtk::STATE_NORMAL,Gdk::Color("#FF0000"));
-       }catch(...){
-               current_time_widget->modify_text(Gtk::STATE_NORMAL,Gdk::Color("#000000"));
-       }
-
-       if(get_time() != time_adjustment().get_value())
-       {
-               //Recenters the window, causing it to jump (possibly undesirably... but whatever)
-               if(time < time_window_adjustment().get_value() ||
-                       time > time_window_adjustment().get_value()+time_window_adjustment().get_page_size())
-               {
-                       time_window_adjustment().set_value(
-                               time-time_window_adjustment().get_page_size()/2
-                       );
-               }
-               time_adjustment().set_value(time);
-               time_adjustment().value_changed();
-
-               // Shouldn't these trees just hook into
-               // the time changed signal...?
-               //YES THEY SHOULD...
-               if(layer_tree)layer_tree->queue_draw();
-               if(children_tree)children_tree->queue_draw();
-       }
-}
-
-void
-CanvasView::time_zoom_in()
-{
-       float frame_rate = get_canvas()->rend_desc().get_frame_rate();
-       Time min_page_size = 2/frame_rate;
-
-       time_window_adjustment().set_page_size(time_window_adjustment().get_page_size()*0.75);
-       if (time_window_adjustment().get_page_size() < min_page_size)
-               time_window_adjustment().set_page_size(min_page_size);
-       time_window_adjustment().set_page_increment(time_window_adjustment().get_page_size());
-       time_window_adjustment().changed();
-
-       refresh_time_window();
-}
-
-void
-CanvasView::time_zoom_out()
-{
-       Time length = (get_canvas()->rend_desc().get_time_end() -
-                                  get_canvas()->rend_desc().get_time_start());
-
-       time_window_adjustment().set_page_size(time_window_adjustment().get_page_size()/0.75);
-       if (time_window_adjustment().get_page_size() > length)
-               time_window_adjustment().set_page_size(length);
-       time_window_adjustment().set_page_increment(time_window_adjustment().get_page_size());
-       time_window_adjustment().changed();
-
-       refresh_time_window();
-}
-
-void
-CanvasView::time_was_changed()
-{
-       synfig::Time time((synfig::Time)(double)time_adjustment().get_value());
-       set_time(time);
-}
-
-void
-CanvasView::on_edited_value(synfigapp::ValueDesc value_desc,synfig::ValueBase new_value)
-{
-       canvas_interface()->change_value(value_desc,new_value);
-}
-
-/*
-void
-CanvasView::on_children_edited_value(const Glib::ustring&path_string,synfig::ValueBase value)
-{
-       Gtk::TreePath path(path_string);
-
-       const Gtk::TreeRow row = *(children_tree->get_model()->get_iter(path));
-
-       assert((bool)row[children_tree_model.is_value_node]);
-
-       synfigapp::ValueDesc value_desc=row[children_tree_model.value_desc];
-       assert(value_desc);
-
-       on_edited_value(value_desc,value);
-}
-*/
-
-void
-CanvasView::on_id_changed()
-{
-       update_title();
-}
-
-void
-CanvasView::on_mode_changed(synfigapp::CanvasInterface::Mode mode)
-{
-       // If the animate flag was set in mode...
-       Gtk::IconSize iconsize=Gtk::IconSize::from_name("synfig-small_icon");
-       if(mode&synfigapp::MODE_ANIMATE)
-       {
-               Gtk::Image *icon;
-               icon=manage(new Gtk::Image(Gtk::StockID("gtk-no"),iconsize));
-               animatebutton->remove();
-               animatebutton->add(*icon);
-               tooltips.set_tip(*animatebutton,_("In Animate Editing Mode"));
-               icon->set_padding(0,0);
-               icon->show();
-       }
-       else
-       {
-               Gtk::Image *icon;
-               icon=manage(new Gtk::Image(Gtk::StockID("gtk-yes"),iconsize));
-               animatebutton->remove();
-               animatebutton->add(*icon);
-               tooltips.set_tip(*animatebutton,_("Not in Animate Editing Mode"));
-               icon->set_padding(0,0);
-               icon->show();
-       }
-
-       if((mode&synfigapp::MODE_ANIMATE_FUTURE) && (mode&synfigapp::MODE_ANIMATE_PAST))
-       {
-               Gtk::Image *icon;
-               icon=manage(new Gtk::Image(Gtk::StockID("synfig-keyframe_lock_all"),Gtk::ICON_SIZE_BUTTON));
-               keyframebutton->remove();
-               keyframebutton->add(*icon);
-               tooltips.set_tip(*keyframebutton,_("All Keyframes Locked"));
-               icon->set_padding(0,0);
-               icon->show();
-       }
-       else if((mode&synfigapp::MODE_ANIMATE_FUTURE) && !(mode&synfigapp::MODE_ANIMATE_PAST))
-       {
-               Gtk::Image *icon;
-               icon=manage(new Gtk::Image(Gtk::StockID("synfig-keyframe_lock_future"),Gtk::ICON_SIZE_BUTTON));
-               keyframebutton->remove();
-               keyframebutton->add(*icon);
-               tooltips.set_tip(*keyframebutton,_("Future Keyframes Locked"));
-               icon->set_padding(0,0);
-               icon->show();
-       }
-       else if(!(mode&synfigapp::MODE_ANIMATE_FUTURE) && (mode&synfigapp::MODE_ANIMATE_PAST))
-       {
-               Gtk::Image *icon;
-               icon=manage(new Gtk::Image(Gtk::StockID("synfig-keyframe_lock_past"),Gtk::ICON_SIZE_BUTTON));
-               keyframebutton->remove();
-               keyframebutton->add(*icon);
-               tooltips.set_tip(*keyframebutton,_("Past Keyframes Locked"));
-               icon->set_padding(0,0);
-               icon->show();
-       }
-       else if(!(mode&synfigapp::MODE_ANIMATE_FUTURE) && !(mode&synfigapp::MODE_ANIMATE_PAST))
-       {
-               Gtk::Image *icon;
-               icon=manage(new Gtk::Image(Gtk::StockID("synfig-keyframe_lock_none"),Gtk::ICON_SIZE_BUTTON));
-               keyframebutton->remove();
-               keyframebutton->add(*icon);
-               tooltips.set_tip(*keyframebutton,_("No Keyframes Locked"));
-               icon->set_padding(0,0);
-               icon->show();
-       }
-
-       work_area->queue_draw();
-}
-
-void
-CanvasView::on_animate_button_pressed()
-{
-       if(get_mode()&synfigapp::MODE_ANIMATE)
-               set_mode(get_mode()-synfigapp::MODE_ANIMATE);
-       else
-               set_mode(get_mode()|synfigapp::MODE_ANIMATE);
-}
-
-void
-CanvasView::on_keyframe_button_pressed()
-{
-       synfigapp::CanvasInterface::Mode mode(get_mode());
-
-       //   future && past   -->             past
-       if((mode&synfigapp::MODE_ANIMATE_FUTURE) && (mode&synfigapp::MODE_ANIMATE_PAST))
-               set_mode(get_mode()-synfigapp::MODE_ANIMATE_FUTURE);
-       //             past   -->   future
-       else if(!(mode&synfigapp::MODE_ANIMATE_FUTURE) && (mode&synfigapp::MODE_ANIMATE_PAST))
-               set_mode((get_mode()-synfigapp::MODE_ANIMATE_PAST)|synfigapp::MODE_ANIMATE_FUTURE);
-       //   future           -->       (nothing)
-       else if((mode&synfigapp::MODE_ANIMATE_FUTURE) && !(mode&synfigapp::MODE_ANIMATE_PAST))
-               set_mode(get_mode()-synfigapp::MODE_ANIMATE_FUTURE);
-       //      (nothing)     -->   future && past
-       else if(!(mode&synfigapp::MODE_ANIMATE_FUTURE) && !(mode&synfigapp::MODE_ANIMATE_PAST))
-               set_mode(get_mode()|synfigapp::MODE_ANIMATE_FUTURE|synfigapp::MODE_ANIMATE_PAST);
-}
-
-bool
-CanvasView::duck_change_param(const synfig::Point &value,synfig::Layer::Handle layer, synfig::String param_name)
-{
-       return canvas_interface()->change_value(synfigapp::ValueDesc(layer,param_name),value);
-}
-
-bool
-CanvasView::on_duck_changed(const synfig::Point &value,const synfigapp::ValueDesc& value_desc)
-{
-       if (ValueNode_BLineCalcWidth::Handle bline_width = ValueNode_BLineCalcWidth::Handle::cast_dynamic(value_desc.get_value_node()))
-       {
-               Real old_width((*bline_width)(get_time()).get(Real()));
-               Real new_width(value.mag());
-               int scale_index(bline_width->get_link_index_from_name("scale"));
-               Real scale((*(bline_width->get_link(scale_index)))(get_time()).get(Real()));
-               return canvas_interface()->change_value(synfigapp::ValueDesc(bline_width,scale_index), new_width * scale / old_width);
-       }
-
-       if (ValueNode_BLineCalcVertex::Handle bline_vertex = ValueNode_BLineCalcVertex::Handle::cast_dynamic(value_desc.get_value_node()))
-       {
-               ValueNode_BLine::Handle bline = ValueNode_BLine::Handle::cast_dynamic(bline_vertex->get_link("bline"));
-               Real radius = 0.0;
-               if (((*(bline_vertex->get_link("loop")))(get_time()).get(bool()))){
-                       Real amount_old((*(bline_vertex->get_link("amount")))(get_time()).get(Real()));
-                       Real amount_new = synfig::find_closest_point((*bline)(get_time()), value, radius, bline->get_loop());
-                       Real difference = fmod( fmod(amount_new - amount_old, 1.0) + 1.0 , 1.0);
-                                                       //fmod is called twice to avoid negative values
-                       if (difference > 0.5) difference=difference-1.0;
-                       return canvas_interface()->change_value(synfigapp::ValueDesc(bline_vertex,bline_vertex->get_link_index_from_name("amount")), amount_old+difference);
-
-               } else {
-                       Real amount = synfig::find_closest_point((*bline)(get_time()), value, radius, bline->get_loop());
-                       return canvas_interface()->change_value(synfigapp::ValueDesc(bline_vertex,bline_vertex->get_link_index_from_name("amount")), amount);
-               }
-       }
-
-       if (ValueNode_BLineCalcTangent::Handle bline_tangent = ValueNode_BLineCalcTangent::Handle::cast_dynamic(value_desc.get_value_node()))
-       {
-               switch(value_desc.get_value_type())
-               {
-               case ValueBase::TYPE_REAL:
-               {
-                       Real old_length = (*bline_tangent)(get_time()).get(Real());
-                       Real new_length = value.mag();
-                       int scale_index(bline_tangent->get_link_index_from_name("scale"));
-                       int fixed_length_index(bline_tangent->get_link_index_from_name("fixed_length"));
-                       Real scale((*(bline_tangent->get_link(scale_index)))(get_time()).get(Real()));
-                       bool fixed_length((*(bline_tangent->get_link(fixed_length_index)))(get_time()).get(bool()));
-                       if (fixed_length)
-                               return canvas_interface()->change_value(synfigapp::ValueDesc(bline_tangent,scale_index), new_length);
-                       if (old_length == 0)
-                               return true;
-                       return canvas_interface()->change_value(synfigapp::ValueDesc(bline_tangent,scale_index), new_length * scale / old_length);
-               }
-
-               case ValueBase::TYPE_ANGLE:
-                       assert(0);                      // doesn't happen?
-                       break;
-
-               case ValueBase::TYPE_VECTOR:
-               {
-                       Vector old_tangent = (*bline_tangent)(get_time()).get(Vector());
-                       Angle old_angle = old_tangent.angle();
-                       Real old_length = old_tangent.mag();
-                       Angle new_angle = value.angle();
-                       Real new_length = value.mag();
-                       int offset_index(bline_tangent->get_link_index_from_name("offset"));
-                       int scale_index(bline_tangent->get_link_index_from_name("scale"));
-                       int fixed_length_index(bline_tangent->get_link_index_from_name("fixed_length"));
-                       Angle old_offset((*(bline_tangent->get_link(offset_index)))(get_time()).get(Angle()));
-                       Real scale((*(bline_tangent->get_link(scale_index)))(get_time()).get(Real()));
-                       bool fixed_length((*(bline_tangent->get_link(fixed_length_index)))(get_time()).get(bool()));
-                       if (fixed_length)
-                       {
-                               if (!(canvas_interface()->change_value(synfigapp::ValueDesc(bline_tangent,scale_index), new_length)))
-                                       return false;
-                       }
-                       else if (old_length != 0 && !(canvas_interface()->change_value(synfigapp::ValueDesc(bline_tangent,scale_index), new_length * scale / old_length)))
-                               return false;
-                       return canvas_interface()->change_value(synfigapp::ValueDesc(bline_tangent,offset_index), old_offset + new_angle - old_angle);
-               }
-               default:
-                       break;
-               }
-       }
-
-       if (ValueNode_Scale::Handle scale_value_node = ValueNode_Scale::Handle::cast_dynamic(value_desc.get_value_node()))
-       {
-               int link_index(scale_value_node->get_link_index_from_name("link"));
-               if(scale_value_node->is_invertible(get_time()))
-                       return canvas_interface()->change_value(
-                               synfigapp::ValueDesc(scale_value_node,link_index),
-                                       scale_value_node->get_inverse(get_time(), value)
-                                       );
-               else
-                       return false;
-       }
-
-       if (ValueNode_Range::Handle range_value_node = ValueNode_Range::Handle::cast_dynamic(value_desc.get_value_node()))
-       {
-               int link_index(range_value_node->get_link_index_from_name("link"));
-               return canvas_interface()->change_value(
-                       synfigapp::ValueDesc(range_value_node,link_index),
-                               range_value_node->get_inverse(get_time(), value)
-                               );
-       }
-
-       switch(value_desc.get_value_type())
-       {
-       case ValueBase::TYPE_REAL:
-               return canvas_interface()->change_value(value_desc,value.mag());
-       case ValueBase::TYPE_ANGLE:
-               return canvas_interface()->change_value(value_desc,Angle::tan(value[1],value[0]));
-       default:
-               return canvas_interface()->change_value(value_desc,value);
-       }
-}
-
-bool
-CanvasView::on_duck_angle_changed(const synfig::Angle &rotation,const synfigapp::ValueDesc& value_desc)
-{
-       if (ValueNode_BLineCalcTangent::Handle bline_tangent = ValueNode_BLineCalcTangent::Handle::cast_dynamic(value_desc.get_value_node()))
-       {
-               int offset_index(bline_tangent->get_link_index_from_name("offset"));
-               Angle old_offset((*(bline_tangent->get_link(offset_index)))(get_time()).get(Angle()));
-               return canvas_interface()->change_value(synfigapp::ValueDesc(bline_tangent,offset_index), old_offset + rotation);
-       }
-
-       if (ValueNode_Scale::Handle scale_value_node = ValueNode_Scale::Handle::cast_dynamic(value_desc.get_value_node()))
-       {
-               int link_index(scale_value_node->get_link_index_from_name("link"));
-               if(scale_value_node->is_invertible(get_time()))
-                       return canvas_interface()->change_value(
-                               synfigapp::ValueDesc(scale_value_node,link_index),
-                                       scale_value_node->get_inverse(get_time(), rotation)
-                                       );
-               else
-                       return false;
-
-       }
-       if (ValueNode_Range::Handle range_value_node = ValueNode_Range::Handle::cast_dynamic(value_desc.get_value_node()))
-       {
-               int link_index(range_value_node->get_link_index_from_name("link"));
-               return canvas_interface()->change_value(
-                       synfigapp::ValueDesc(range_value_node,link_index),
-                               range_value_node->get_inverse(get_time(), rotation)
-                               );
-       }
-       // \todo will this really always be the case?
-       assert(value_desc.get_value_type() == ValueBase::TYPE_ANGLE);
-       return canvas_interface()->change_value(value_desc, value_desc.get_value(get_time()).get(Angle()) + rotation);
-}
-
-void
-CanvasView::selected_layer_color_set(synfig::Color color)
-{
-       synfigapp::SelectionManager::LayerList selected_list(get_selection_manager()->get_selected_layers());
-       synfigapp::SelectionManager::LayerList::iterator iter;
-
-       // Create the action group
-       //synfigapp::PassiveGrouper group(canvas_interface()->get_instance(),_("Set Colors"));
-
-       Layer::Handle layer;
-       for(iter=selected_list.begin();iter!=selected_list.end();++iter)
-       {
-               if(*iter==layer)
-                       continue;
-               layer=*iter;
-               on_edited_value(synfigapp::ValueDesc(layer,"color"),color);
-       }
-}
-
-void
-CanvasView::rebuild_ducks_layer_(synfig::TransformStack& transform_stack, synfig::Canvas::Handle canvas, std::set<synfig::Layer::Handle>& selected_list)
-{
-       int transforms(0);
-       String layer_name;
-
-#define QUEUE_REBUILD_DUCKS            sigc::mem_fun(*this,&CanvasView::queue_rebuild_ducks)
-
-       if(!canvas)
-       {
-               synfig::warning("CanvasView::rebuild_ducks_layer_(): Layer doesn't have canvas set");
-               return;
-       }
-       for(Canvas::iterator iter(canvas->begin());iter!=canvas->end();++iter)
-       {
-               Layer::Handle layer(*iter);
-
-               if(selected_list.count(layer))
-               {
-                       if(!curr_transform_stack_set)
-                       {
-                               curr_transform_stack_set=true;
-                               curr_transform_stack=transform_stack;
-                       }
-
-                       // This layer is currently selected.
-                       duck_changed_connections.push_back(layer->signal_changed().connect(QUEUE_REBUILD_DUCKS));
-
-                       // do the bounding box thing
-                       bbox|=transform_stack.perform(layer->get_bounding_rect());
-
-                       // Grab the layer's list of parameters
-                       Layer::ParamList paramlist(layer->get_param_list());
-
-                       // Grab the layer vocabulary
-                       Layer::Vocab vocab=layer->get_param_vocab();
-                       Layer::Vocab::iterator iter;
-
-                       for(iter=vocab.begin();iter!=vocab.end();iter++)
-                       {
-                               if(!iter->get_hidden() && !iter->get_invisible_duck())
-                               {
-                                       synfigapp::ValueDesc value_desc(layer,iter->get_name());
-                                       work_area->add_to_ducks(value_desc,this,transform_stack,&*iter);
-                                       if(value_desc.is_value_node())
-                                               duck_changed_connections.push_back(value_desc.get_value_node()->signal_changed().connect(QUEUE_REBUILD_DUCKS));
-                               }
-                               if(iter->get_name()=="color")
-                               {
-                                       /*
-                                       if(!App::dialog_color->busy())
-                                       {
-                                               App::dialog_color->reset();
-                                               App::dialog_color->set_color(layer->get_param("color").get(Color()));
-                                               App::dialog_color->signal_edited().connect(
-                                                       sigc::mem_fun(
-                                                               *this,
-                                                               &studio::CanvasView::selected_layer_color_set
-                                                       )
-                                               );
-                                       }
-                                       */
-                               }
-                       }
-               }
-
-               layer_name=layer->get_name();
-
-               if(layer->active())
-               {
-                       Transform::Handle trans(layer->get_transform());
-                       if(trans)
-                       {
-                               transform_stack.push(trans);
-                               transforms++;
-                       }
-
-/*                     // Add transforms onto the stack
-                       if(layer_name=="Translate")
-                       {
-                               transform_stack.push(synfig::Transform_Translate(layer->get_param("origin").get(Vector())));
-                               transforms++;
-                       }else
-                       if(layer_name=="Zoom")
-                       {
-                               Vector scale;
-                               scale[0]=scale[1]=exp(layer->get_param("amount").get(Real()));
-                               transform_stack.push(synfig::Transform_Scale(scale,layer->get_param("center").get(Vector())));
-                               transforms++;
-                       }else
-                       if(layer_name=="stretch")
-                       {
-                               Vector scale(layer->get_param("amount").get(Vector()));
-                               transform_stack.push(synfig::Transform_Scale(scale,layer->get_param("center").get(Vector())));
-                               transforms++;
-                       }else
-                       if(layer_name=="Rotate")
-                       {
-                               transform_stack.push(synfig::Transform_Rotate(layer->get_param("amount").get(Angle()),layer->get_param("origin").get(Vector())));
-                               transforms++;
-                       }
-*/
-               }
-
-               // If this is a paste canvas layer, then we need to
-               // descend into it
-               if(layer_name=="PasteCanvas")
-               {
-                       Vector scale;
-                       scale[0]=scale[1]=exp(layer->get_param("zoom").get(Real()));
-                       Vector origin(layer->get_param("origin").get(Vector()));
-
-                       Canvas::Handle child_canvas(layer->get_param("canvas").get(Canvas::Handle()));
-                       Vector focus(layer->get_param("focus").get(Vector()));
-
-                       if(!scale.is_equal_to(Vector(1,1)))
-                               transform_stack.push(new Transform_Scale(layer->get_guid(), scale,origin+focus));
-                       if(!origin.is_equal_to(Vector(0,0)))
-                               transform_stack.push(new Transform_Translate(layer->get_guid(), origin));
-
-                       rebuild_ducks_layer_(transform_stack,child_canvas,selected_list);
-
-                       if(!origin.is_equal_to(Vector(0,0)))
-                               transform_stack.pop();
-                       if(!scale.is_equal_to(Vector(1,1)))
-                               transform_stack.pop();
-               }
-       }
-       // Remove all of the transforms we have added
-       while(transforms--) { transform_stack.pop(); }
-
-#undef QUEUE_REBUILD_DUCKS
-}
-
-void
-CanvasView::queue_rebuild_ducks()
-{
-#if 0
-       if(rebuild_ducks_queued)
-               return;
-#else
-       if(rebuild_ducks_queued)
-               queue_rebuild_ducks_connection.disconnect();
-#endif
-
-       queue_rebuild_ducks_connection=Glib::signal_timeout().connect(
-               sigc::bind_return(
-                       sigc::mem_fun(*this,&CanvasView::rebuild_ducks),
-                       false
-               ),
-               50
-       );
-
-       rebuild_ducks_queued=true;
-}
-
-void
-CanvasView::rebuild_ducks()
-{
-       /*static int i=0;
-       i++;
-       if(i>30)
-               synfig::info("%d",i/(i-i));
-       */
-
-       rebuild_ducks_queued=false;
-       //queue_rebuild_ducks_connection.disconnect();
-
-       if(work_area->is_dragging())
-       {
-               queue_rebuild_ducks();
-               return;
-       }
-
-       if(!duck_refresh_flag)
-       {
-               duck_refresh_needed=true;
-               return;
-       }
-
-       bbox=Rect::zero();
-
-       work_area->clear_ducks();
-       work_area->set_time(get_time());
-       get_canvas()->set_time(get_time());
-       curr_transform_stack.clear();
-       //curr_transform_stack.push(new Transform_Translate(Point(0,0)));
-       curr_transform_stack_set=false;
-
-       for(;!duck_changed_connections.empty();duck_changed_connections.pop_back())duck_changed_connections.back().disconnect();
-
-       //get_canvas()->set_time(get_time());
-       bool not_empty(false);
-
-       // First do the layers...
-       do{
-               synfigapp::SelectionManager::LayerList selected_list(get_selection_manager()->get_selected_layers());
-               std::set<synfig::Layer::Handle> layer_set(selected_list.begin(),selected_list.end());
-
-               if(!layer_set.empty())
-                       not_empty=true;
-
-               synfig::TransformStack transform_stack;
-
-               rebuild_ducks_layer_(transform_stack, get_canvas(), layer_set);
-
-       }while(0);
-
-       // Now do the children
-       do{
-               synfigapp::SelectionManager::ChildrenList selected_list(get_selection_manager()->get_selected_children());
-               synfigapp::SelectionManager::ChildrenList::iterator iter;
-               synfig::TransformStack transform_stack;
-
-               if(selected_list.empty())
-               {
-                       break;
-               }
-               else
-               {
-                       not_empty=true;
-                       for(iter=selected_list.begin();iter!=selected_list.end();++iter)
-                       {
-                               work_area->add_to_ducks(*iter,this,transform_stack);
-                       }
-               }
-       }while(0);
-       work_area->refresh_selected_ducks();
-       work_area->queue_draw_preview();
-}
-
-void
-CanvasView::decrease_low_res_pixel_size()
-{
-       if(changing_resolution_)
-               return;
-       changing_resolution_=true;
-       list<int> sizes = CanvasView::get_pixel_sizes();
-       int pixel_size = work_area->get_low_res_pixel_size();
-       for (list<int>::iterator iter = sizes.begin(); iter != sizes.end(); iter++)
-               if (*iter == pixel_size)
-               {
-                       if (iter == sizes.begin())
-                               // we already have the smallest low-res pixels possible - turn off low-res instead
-                               work_area->set_low_resolution_flag(false);
-                       else
-                       {
-                               iter--;
-                               Glib::RefPtr<Gtk::Action> action = action_group->get_action(strprintf("lowres-pixel-%d", *iter));
-                               action->activate(); // to make sure the radiobutton in the menu is updated too
-                               work_area->set_low_resolution_flag(true);
-                       }
-                       break;
-               }
-       // Update the "toggle-low-res" action
-       Glib::RefPtr<Gtk::ToggleAction> action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("toggle-low-res"));
-       action->set_active(work_area->get_low_resolution_flag());
-       // Update toggle low res button
-       resolutiondial->update_lowres(work_area->get_low_resolution_flag());
-       changing_resolution_=false;
-}
-
-void
-CanvasView::increase_low_res_pixel_size()
-{
-       if(changing_resolution_)
-               return;
-       changing_resolution_=true;
-       list<int> sizes = CanvasView::get_pixel_sizes();
-       int pixel_size = work_area->get_low_res_pixel_size();
-       if (!work_area->get_low_resolution_flag())
-       {
-               // We were using "hi res" so change it to low res.
-               work_area->set_low_resolution_flag(true);
-               // Update the "toggle-low-res" action
-               Glib::RefPtr<Gtk::ToggleAction> action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("toggle-low-res"));
-               action->set_active(true);
-               // Update the toggle low res button
-               resolutiondial->update_lowres(true);
-               changing_resolution_=false;
-               return;
-       }
-
-       for (list<int>::iterator iter = sizes.begin(); iter != sizes.end(); iter++)
-               if (*iter == pixel_size)
-               {
-                       iter++;
-                       if (iter != sizes.end())
-                       {
-                               Glib::RefPtr<Gtk::Action> action = action_group->get_action(strprintf("lowres-pixel-%d", *iter));
-                               action->activate(); // to make sure the radiobutton in the menu is updated too
-                               work_area->set_low_resolution_flag(true);
-                       }
-                       break;
-               }
-       // Update the "toggle-low-res" action
-       Glib::RefPtr<Gtk::ToggleAction> action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("toggle-low-res"));
-       action->set_active(work_area->get_low_resolution_flag());
-       // Update toggle low res button
-       resolutiondial->update_lowres(work_area->get_low_resolution_flag());
-       changing_resolution_=false;
-}
-
-void
-CanvasView::toggle_low_res_pixel_flag()
-{
-       if(changing_resolution_)
-               return;
-       changing_resolution_=true;
-       work_area->toggle_low_resolution_flag();
-       // Update the toggle low res button
-       resolutiondial->update_lowres(work_area->get_low_resolution_flag());
-       // Update the "toggle-low-res" action
-       Glib::RefPtr<Gtk::ToggleAction> action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("toggle-low-res"));
-       action->set_active(work_area->get_low_resolution_flag());
-       changing_resolution_=false;
-}
-
-void
-CanvasView::update_quality()
-{
-       //if(working_depth)
-       //              return;
-       if(updating_quality_)
-               return;
-       updating_quality_=true;
-       work_area->set_quality((int) quality_spin->get_value());
-       // Update Quality Radio actions
-       Glib::RefPtr<Gtk::RadioAction> action=Glib::RefPtr<Gtk::RadioAction>::cast_dynamic(
-               action_group->get_action(strprintf("quality-%02d",(int) quality_spin->get_value()))
-               );
-       action->set_active();
-
-       updating_quality_=false;
-}
-
-void
-CanvasView::set_quality(int x)
-{
-       if(updating_quality_)
-               return;
-       work_area->set_quality(x);
-       // Update the quality spin button
-       quality_spin->set_value(x);
-}
-
-void
-CanvasView::set_onion_skins()
-{
-       if(toggling_onion_skin)
-               return;
-       int onion_skins[2];
-       onion_skins[0]=past_onion_spin->get_value();
-       onion_skins[1]=future_onion_spin->get_value();
-       work_area->set_onion_skins(onion_skins);
-}
-
-void
-CanvasView::toggle_show_grid()
-{
-       if(toggling_show_grid)
-               return;
-       toggling_show_grid=true;
-       work_area->toggle_grid();
-       // Update the toggle grid show action
-       set_grid_show_toggle(work_area->grid_status());
-       // Update the toggle grid show check button
-       show_grid->set_active(work_area->grid_status());
-       toggling_show_grid=false;
-}
-
-void
-CanvasView::toggle_snap_grid()
-{
-       if(toggling_snap_grid)
-               return;
-       toggling_snap_grid=true;
-       work_area->toggle_grid_snap();
-       // Update the toggle grid snap action
-       set_grid_snap_toggle(work_area->get_grid_snap());
-       // Update the toggle grid snap check button
-       snap_grid->set_active(work_area->get_grid_snap());
-       toggling_snap_grid=false;
-}
-
-void
-CanvasView::toggle_onion_skin()
-{
-       if(toggling_onion_skin)
-               return;
-       toggling_onion_skin=true;
-       work_area->toggle_onion_skin();
-       // Update the toggle onion skin action
-       Glib::RefPtr<Gtk::ToggleAction> action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("toggle-onion-skin"));
-       action->set_active(work_area->get_onion_skin());
-       // Update the toggle grid snap check button
-       onion_skin->set_active(work_area->get_onion_skin());
-       toggling_onion_skin=false;
-}
-
-void
-CanvasView::on_dirty_preview()
-{
-       if(!is_playing_)
-       {
-               IsWorking is_working(*this);
-
-               work_area->queue_render_preview();
-       }
-}
-
-void
-CanvasView::play()
-{
-       assert(get_canvas());
-
-       // If we are already busy, don't play!
-       if(working_depth)return;
-
-       // Set us up as working
-       IsWorking is_working(*this);
-
-       etl::clock timer;
-       Time
-               time=work_area->get_time(),
-               endtime=get_canvas()->rend_desc().get_time_end();
-
-       // If we are already at the end of time, start over
-       if(time==endtime)
-               time=get_canvas()->rend_desc().get_time_start();
-
-       is_playing_=true;
-
-       work_area->clear_ducks();
-
-       for(timer.reset(); time + timer() < endtime;)
-       {
-               //Clamp the time window so we can see the time value as it races across the horizon
-               bool timewindreset = false;
-
-               while( time + timer() > Time(time_window_adjustment().get_sub_upper()) )
-               {
-                       time_window_adjustment().set_value(
-                                       min(
-                                               time_window_adjustment().get_value()+time_window_adjustment().get_page_size()/2,
-                                               time_window_adjustment().get_upper()-time_window_adjustment().get_page_size() )
-                               );
-                       timewindreset = true;
-               }
-
-               while( time + timer() < Time(time_window_adjustment().get_sub_lower()) )
-               {
-                       time_window_adjustment().set_value(
-                               max(
-                                       time_window_adjustment().get_value()-time_window_adjustment().get_page_size()/2,
-                                       time_window_adjustment().get_lower())
-                       );
-
-                       timewindreset = true;
-               }
-
-               //we need to tell people that the value changed
-               if(timewindreset) time_window_adjustment().value_changed();
-
-               //update actual time to next step
-               time_adjustment().set_value(time+timer());
-               time_adjustment().value_changed();
-
-               if(!work_area->sync_render_preview())
-                       break;
-
-               // wait for the workarea to refresh itself
-               while (studio::App::events_pending())
-                       studio::App::iteration(false);
-
-               if(get_cancel_status())
-               {
-                       is_playing_=false;
-                       return;
-               }
-       }
-       on_play_stop_pressed();
-       is_playing_=false;
-       time_adjustment().set_value(endtime);
-       time_adjustment().value_changed();
-}
-
-void
-CanvasView::show_tables()
-{
-/*
-       Smach::event_result x(process_event_key(EVENT_TABLES_SHOW));
-       if(x==Smach::RESULT_OK || x==Smach::RESULT_ACCEPT)
-       {
-               Gtk::IconSize iconsize=Gtk::IconSize::from_name("synfig-small_icon");
-               treetogglebutton->remove();
-               treetogglebutton->add(*manage(new Gtk::Image(Gtk::StockID("gtk-go-down"),iconsize)));
-               treetogglebutton->show_all();
-               notebook->show();
-       }
-*/
-}
-
-void
-CanvasView::hide_tables()
-{
-/*
-       Smach::event_result x(process_event_key(EVENT_TABLES_HIDE));
-       if(x==Smach::RESULT_OK || x==Smach::RESULT_ACCEPT)
-       {
-               Gtk::IconSize iconsize=Gtk::IconSize::from_name("synfig-small_icon");
-               treetogglebutton->remove();
-               treetogglebutton->add(*manage(new Gtk::Image(Gtk::StockID("gtk-go-up"),iconsize)));
-               treetogglebutton->show_all();
-               notebook->hide();
-       }
-*/
-}
-
-bool
-CanvasView::tables_are_visible()
-{
-//     return notebook->is_visible();
-       return false;
-}
-
-void
-CanvasView::toggle_tables()
-{
-//     if(tables_are_visible())
-//             hide_tables();
-//     else
-//             show_tables();
-}
-
-void
-CanvasView::show_timebar()
-{
-       timebar->show();
-       //current_time_widget->show(); // not needed now that belongs to the timebar
-
-       //keyframe_tab_child->show();
-       if(layer_tree)
-               layer_tree->set_show_timetrack(true);
-       if(children_tree)
-               children_tree->set_show_timetrack(true);
-}
-
-void
-CanvasView::hide_timebar()
-{
-       timebar->hide();
-       //current_time_widget->hide(); // not needed now that belongs to the timebar
-       //keyframe_tab_child->hide();
-       if(layer_tree)
-               layer_tree->set_show_timetrack(false);
-       if(children_tree)
-               children_tree->set_show_timetrack(false);
-}
-
-void
-CanvasView::set_sensitive_timebar(bool sensitive)
-{
-       timebar->set_sensitive(sensitive);
-       //current_time_widget->set_sensitive(sensitive); //not needed now that belongs to timebar
-       //keyframe_tab_child->set_sensitive(sensitive);
-       if(layer_tree)
-               layer_tree->set_sensitive(sensitive);
-       if(children_tree)
-               children_tree->set_sensitive(sensitive);
-}
-
-static void
-set_waypoint_model(std::set<synfig::Waypoint, std::less<UniqueID> > waypoints,
-                                  Waypoint::Model model,
-                                  etl::loose_handle<synfigapp::CanvasInterface> canvas_interface)
-{
-       // Create the action group
-       synfigapp::Action::PassiveGrouper group(canvas_interface->get_instance().get(),_("Change Waypoint Group"));
-
-       std::set<synfig::Waypoint, std::less<UniqueID> >::const_iterator iter;
-       for(iter=waypoints.begin();iter!=waypoints.end();++iter)
-       {
-               Waypoint waypoint(*iter);
-               waypoint.apply_model(model);
-
-               synfigapp::Action::Handle action(synfigapp::Action::create("WaypointSet"));
-
-               assert(action);
-
-               action->set_param("canvas",canvas_interface->get_canvas());
-               action->set_param("canvas_interface",canvas_interface);
-
-               action->set_param("waypoint",waypoint);
-               action->set_param("value_node",waypoint.get_parent_value_node());
-
-               if(!canvas_interface->get_instance()->perform_action(action))
-               {
-                       group.cancel();
-                       return;
-               }
-       }
-}
-
-static void
-duplicate_waypoints(std::set<synfig::Waypoint, std::less<UniqueID> > waypoints,
-                                       etl::loose_handle<synfigapp::CanvasInterface> canvas_interface)
-{
-       // Create the action group
-       synfigapp::Action::PassiveGrouper group(canvas_interface->get_instance().get(),_("Duplicate Waypoints"));
-
-       std::set<synfig::Waypoint, std::less<UniqueID> >::const_iterator iter;
-       for (iter = waypoints.begin(); iter != waypoints.end(); iter++)
-       {
-               Waypoint waypoint(*iter);
-               ValueNode::Handle value_node(iter->get_parent_value_node());
-               canvas_interface->waypoint_duplicate(value_node, waypoint);
-       }
-}
-
-static void
-remove_waypoints(std::set<synfig::Waypoint, std::less<UniqueID> > waypoints,
-                                etl::loose_handle<synfigapp::CanvasInterface> canvas_interface)
-{
-       // Create the action group
-       synfigapp::Action::PassiveGrouper group(canvas_interface->get_instance().get(),_("Remove Waypoints"));
-
-       std::set<synfig::Waypoint, std::less<UniqueID> >::const_iterator iter;
-       for (iter = waypoints.begin(); iter != waypoints.end(); iter++)
-       {
-               Waypoint waypoint(*iter);
-               ValueNode::Handle value_node(iter->get_parent_value_node());
-               canvas_interface->waypoint_remove(value_node, waypoint);
-       }
-}
-
-void
-CanvasView::on_waypoint_clicked_canvasview(synfigapp::ValueDesc value_desc,
-                                                                                  std::set<synfig::Waypoint, std::less<UniqueID> > waypoint_set,
-                                                                                  int button)
-{
-       int size = waypoint_set.size();
-       Waypoint waypoint(*(waypoint_set.begin()));
-       Time time(waypoint.get_time());
-
-       if (size == 1)
-       {
-               waypoint_dialog.set_value_desc(value_desc);
-               waypoint_dialog.set_waypoint(waypoint);
-       }
-
-       switch(button)
-       {
-       case -1:
-               if (size == 1)
-                       waypoint_dialog.show();
-               break;
-       case 2:
-       {
-               Gtk::Menu* waypoint_menu(manage(new Gtk::Menu()));
-               waypoint_menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), waypoint_menu));
-
-               Gtk::Menu* interp_menu_in(manage(new Gtk::Menu()));
-               Gtk::Menu* interp_menu_out(manage(new Gtk::Menu()));
-               Gtk::Menu* interp_menu_both(manage(new Gtk::Menu()));
-
-               {
-                       Waypoint::Model model;
-
-                       model.reset(); model.set_before(INTERPOLATION_TCB);
-                       interp_menu_in->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_TCB"),
-                               sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
-                       model.reset(); model.set_after(INTERPOLATION_TCB);
-                       interp_menu_out->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_TCB"),
-                               sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
-                       model.set_before(INTERPOLATION_TCB);
-                       interp_menu_both->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_TCB"),
-                               sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
-
-                       model.reset(); model.set_before(INTERPOLATION_LINEAR);
-                       interp_menu_in->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Linear"),
-                               sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
-                       model.reset(); model.set_after(INTERPOLATION_LINEAR);
-                       interp_menu_out->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Linear"),
-                               sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
-                       model.set_before(INTERPOLATION_LINEAR);
-                       interp_menu_both->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Linear"),
-                               sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
-
-                       model.reset(); model.set_before(INTERPOLATION_HALT);
-                       interp_menu_in->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Ease In"),
-                               sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
-                       model.reset(); model.set_after(INTERPOLATION_HALT);
-                       interp_menu_out->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Ease Out"),
-                               sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
-                       model.set_before(INTERPOLATION_HALT);
-                       interp_menu_both->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Ease In/Out"),
-                               sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
-
-                       model.reset(); model.set_before(INTERPOLATION_CONSTANT);
-                       interp_menu_in->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Constant"),
-                               sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
-                       model.reset(); model.set_after(INTERPOLATION_CONSTANT);
-                       interp_menu_out->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Constant"),
-                               sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
-                       model.set_before(INTERPOLATION_CONSTANT);
-                       interp_menu_both->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Constant"),
-                               sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
-               }
-
-               // ------------------------------------------------------------------------
-               if (size == 1)
-               {
-                       const synfigapp::ValueDesc value_desc(synfig::ValueNode_Animated::Handle::cast_reinterpret(waypoint.get_parent_value_node()), time);
-                       get_instance()->make_param_menu(waypoint_menu,canvas_interface()->get_canvas(),value_desc,0.5f);
-
-                       // ------------------------------------------------------------------------
-                       waypoint_menu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
-               }
-
-               // ------------------------------------------------------------------------
-               waypoint_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Jump To"),
-                       sigc::bind(sigc::mem_fun(*canvas_interface(), &synfigapp::CanvasInterface::set_time), time)));
-
-               waypoint_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Duplicate"),
-                        sigc::bind(sigc::ptr_fun(duplicate_waypoints), waypoint_set, canvas_interface())));
-
-               waypoint_menu->items().push_back(Gtk::Menu_Helpers::MenuElem((size == 1) ? _("_Remove") : strprintf(_("_Remove %d Waypoints"), size),
-                        sigc::bind(sigc::ptr_fun(remove_waypoints), waypoint_set, canvas_interface())));
-
-               if (size == 1 && value_desc.is_valid())
-                       waypoint_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Edit"),
-                               sigc::mem_fun(waypoint_dialog,&Gtk::Widget::show)));
-
-               // ------------------------------------------------------------------------
-               waypoint_menu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
-
-               // ------------------------------------------------------------------------
-               waypoint_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Both"), *interp_menu_both));
-               waypoint_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_In"),   *interp_menu_in));
-               waypoint_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Out"),  *interp_menu_out));
-
-               // ------------------------------------------------------------------------
-               waypoint_menu->popup(button+1,gtk_get_current_event_time());
-       }
-       break;
-
-       default:
-               break;
-       }
-}
-
-void
-CanvasView::on_waypoint_changed()
-{
-       synfigapp::Action::ParamList param_list;
-       param_list.add("canvas",get_canvas());
-       param_list.add("canvas_interface",canvas_interface());
-       param_list.add("value_node",waypoint_dialog.get_value_desc().get_value_node());
-       param_list.add("waypoint",waypoint_dialog.get_waypoint());
-//     param_list.add("time",canvas_interface()->get_time());
-
-       get_instance()->process_action("WaypointSetSmart", param_list);
-}
-
-void
-CanvasView::on_waypoint_delete()
-{
-       synfigapp::Action::ParamList param_list;
-       param_list.add("canvas",get_canvas());
-       param_list.add("canvas_interface",canvas_interface());
-       param_list.add("value_node",waypoint_dialog.get_value_desc().get_value_node());
-       param_list.add("waypoint",waypoint_dialog.get_waypoint());
-//     param_list.add("time",canvas_interface()->get_time());
-
-       get_instance()->process_action("WaypointRemove", param_list);
-}
-
-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)
-{
-       // We will make this true once we have a solid drop
-       bool success(false);
-       //synfig::info("Dropped data of type \"%s\"",selection_data.get_data_type());
-       //synfig::info("Dropped data of target \"%s\"",gdk_atom_name(selection_data->target));
-       //synfig::info("selection=\"%s\"",gdk_atom_name(selection_data->selection));
-
-       if ((selection_data_.get_length() >= 0) && (selection_data_.get_format() == 8))
-       {
-               if(synfig::String(selection_data_.get_data_type())=="STRING")do
-               {
-                       synfig::String selection_data((gchar *)(selection_data_.get_data()));
-
-                       Layer::Handle layer(synfig::Layer::create("Text"));
-                       if(!layer)
-                               break;
-                       if(!layer->set_param("text",ValueBase(selection_data)))
-                               break;
-
-                       synfigapp::Action::Handle       action(synfigapp::Action::create("LayerAdd"));
-
-                       assert(action);
-                       if(!action)
-                               break;
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",canvas_interface());
-                       action->set_param("new",layer);
-
-                       if(!get_instance()->perform_action(action))
-                               break;
-
-                       // Ok, we have successfully imported at least one item.
-                       success=true;
-               } while(0); // END of "STRING"
-
-               if(synfig::String(selection_data_.get_data_type())=="text/plain")
-               {
-                       synfig::String selection_data((gchar *)(selection_data_.get_data()));
-
-                       // For some reason, GTK hands us a list of URLs separated
-                       // by not only Carriage-Returns, but also Line-Feeds.
-                       // Line-Feeds will mess us up. Remove all the line-feeds.
-                       while(selection_data.find_first_of('\r')!=synfig::String::npos)
-                               selection_data.erase(selection_data.begin()+selection_data.find_first_of('\r'));
-
-                       std::stringstream stream(selection_data);
-
-                       //synfigapp::PassiveGrouper group(canvas_interface()->get_instance(),_("Insert Image"));
-                       while(stream)
-                       {
-                               synfig::String filename,URI;
-                               getline(stream,filename);
-
-                               // If we don't have a filename, move on.
-                               if(filename.empty())
-                                       continue;
-
-                               // Make sure this URL is of the "file://" type.
-                               URI=String(filename.begin(),filename.begin()+sizeof("file://")-1);
-                               if(URI!="file://")
-                               {
-                                       synfig::warning("Unknown URI (%s) in \"%s\"",URI.c_str(),filename.c_str());
-                                       continue;
-                               }
-
-                               // Strip the "file://" part from the filename
-                               filename=synfig::String(filename.begin()+sizeof("file://")-1,filename.end());
-
-                               String ext(filename_extension(filename));
-                               if (ext.size()) ext = ext.substr(1); // skip initial '.'
-
-                               // If this is a SIF file, then we need to do things slightly differently
-                               if(ext=="sketch")
-                               {
-                                       if(work_area->load_sketch(filename))
-                                       {
-                                               success=true;
-                                               work_area->queue_draw();
-                                       }
-                               }
-                               else
-                               {
-                                       String errors, warnings;
-                                       if(canvas_interface()->import(filename, errors, warnings, App::resize_imported_images))
-                                               success=true;
-                                       if (warnings != "")
-                                               App::dialog_warning_blocking(_("Warnings"), strprintf("%s:\n\n%s", _("Warnings"), warnings.c_str()));
-                               }
-
-                               continue;
-                       }
-               } // END of "text/plain"
-       }
-       else
-               ui_interface_->error("Drop failed: bad selection data");
-
-       // Finish the drag
-       context->drag_finish(success, false, time);
-}
-
-void
-CanvasView::on_keyframe_add_pressed()
-{
-       synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeAdd"));
-
-       if(!action)
-       {
-               ui_interface_->error("I am unable to find the appropriate action");
-               return;
-       }
-
-       action->set_param("canvas",get_canvas());
-       action->set_param("canvas_interface",canvas_interface());
-       action->set_param("keyframe",Keyframe(get_time()));
-
-       canvas_interface()->get_instance()->perform_action(action);
-}
-
-void
-CanvasView::on_keyframe_duplicate_pressed()
-{
-       const KeyframeTreeStore::Model model;
-       const Gtk::TreeRow row(*keyframe_tree->get_selection()->get_selected());
-       Keyframe keyframe;
-       if(!row)
-       {
-               ui_interface_->error("I am unable to duplicate the keyframe");
-               return;
-       }
-       keyframe=row[model.keyframe];
-
-       synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeDuplicate"));
-
-       if(!action)
-       {
-               ui_interface_->error("I am unable to find the appropriate action");
-               return;
-       }
-
-       action->set_param("canvas",get_canvas());
-       action->set_param("canvas_interface",canvas_interface());
-       action->set_param("keyframe",keyframe);
-       action->set_param("time",get_time());
-
-       canvas_interface()->get_instance()->perform_action(action);
-}
-
-void
-CanvasView::on_keyframe_remove_pressed()
-{
-       const KeyframeTreeStore::Model model;
-       const Gtk::TreeRow row(*keyframe_tree->get_selection()->get_selected());
-       Keyframe keyframe;
-       if(!row)
-       {
-               ui_interface_->error("I am unable to remove the keyframe");
-               return;
-       }
-       keyframe=row[model.keyframe];
-
-       synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeRemove"));
-
-       if(!action)
-       {
-               ui_interface_->error("I am unable to find the appropriate action");
-               return;
-       }
-
-       action->set_param("canvas",get_canvas());
-       action->set_param("canvas_interface",canvas_interface());
-       action->set_param("keyframe",keyframe);
-
-       canvas_interface()->get_instance()->perform_action(action);
-}
-
-void
-CanvasView::toggle_duck_mask(Duckmatic::Type type)
-{
-       if(toggling_ducks_)
-               return;
-       toggling_ducks_=true;
-       bool is_currently_on(work_area->get_type_mask()&type);
-
-       if(is_currently_on)
-               work_area->set_type_mask(work_area->get_type_mask()-type);
-       else
-               work_area->set_type_mask(work_area->get_type_mask()|type);
-
-       work_area->queue_draw();
-       try
-       {
-               // Update the toggle ducks actions
-               Glib::RefPtr<Gtk::ToggleAction> action;
-               action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("mask-position-ducks"));
-               action->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_POSITION));
-               action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("mask-tangent-ducks"));
-               action->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_TANGENT));
-               action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("mask-vertex-ducks"));
-               action->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_VERTEX));
-               action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("mask-radius-ducks"));
-               action->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_RADIUS));
-               action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("mask-width-ducks"));
-               action->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_WIDTH));
-               action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("mask-angle-ducks"));
-               action->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_ANGLE));
-               // Update toggle ducks buttons
-               toggleducksdial->update_toggles(work_area->get_type_mask());
-       }
-       catch(...)
-       {
-               toggling_ducks_=false;
-       }
-       toggling_ducks_=false;
-}
-
-void
-CanvasView::image_import()
-{
-       // String filename(dirname(get_canvas()->get_file_name()));
-       String filename("*.*");
-       String errors, warnings;
-       if(App::dialog_open_file(_("Import Image"), filename, IMAGE_DIR_PREFERENCE))
-       {
-               canvas_interface()->import(filename, errors, warnings, App::resize_imported_images);
-               if (warnings != "")
-                       App::dialog_warning_blocking(_("Warnings"), strprintf("%s:\n\n%s", _("Warnings"), warnings.c_str()));
-       }
-}
-
-Smach::event_result
-CanvasView::process_event_key(EventKey x)
-{
-       return smach_.process_event(x);
-}
-
-void
-CanvasView::on_input_device_changed(GdkDevice* device)
-{
-       if(!device)
-       {
-               get_smach().egress();
-       }
-       assert(device);
-
-       synfigapp::InputDevice::Handle input_device;
-       input_device=synfigapp::Main::select_input_device(device->name);
-       App::toolbox->change_state(input_device->get_state());
-       process_event_key(EVENT_INPUT_DEVICE_CHANGED);
-}
-
-void
-CanvasView::on_preview_option()
-{
-       Dialog_PreviewOptions *po = dynamic_cast<Dialog_PreviewOptions *>(get_ext_widget("prevoptions"));
-
-       Canvas::Handle  canv = get_canvas();
-
-       if(canv)
-       {
-               RendDesc &r = canv->rend_desc();
-               if(r.get_frame_rate())
-               {
-                       float rate = 1/r.get_frame_rate();
-                       float beg = r.get_time_start() + r.get_frame_start()*rate;
-                       float end = r.get_time_start() + r.get_frame_end()*rate;
-
-                       if(!po)
-                       {
-                               po = new Dialog_PreviewOptions;
-                               po->set_zoom(work_area->get_zoom()/2);
-                               po->set_fps(r.get_frame_rate()/2);
-                               po->set_begintime(beg);
-                               po->set_begin_override(false);
-                               po->set_endtime(end);
-                               po->set_end_override(false);
-
-                               set_ext_widget("prevoptions",po);
-                       }
-                       /*po->set_zoom(work_area->get_zoom()/2);
-                       po->set_fps(r.get_frame_rate()/2);
-                       po->set_begintime(beg);
-                       po->set_begin_override(false);
-                       po->set_endtime(end);
-                       po->set_end_override(false);*/
-
-                       po->set_global_fps(r.get_frame_rate());
-                       po->signal_finish().connect(sigc::mem_fun(*this,&CanvasView::on_preview_create));
-                       po->present();
-               }
-       }
-}
-
-void
-CanvasView::on_preview_create(const PreviewInfo &info)
-{
-       //set all the options
-       etl::handle<Preview>    prev = new Preview;
-
-       prev->set_canvasview(this);
-       prev->set_zoom(info.zoom);
-       prev->set_fps(info.fps);
-       prev->set_overbegin(info.overbegin);
-       prev->set_begintime(info.begintime);
-       prev->set_overend(info.overend);
-       prev->set_endtime(info.endtime);
-       prev->set_quality(work_area->get_quality());
-
-       //render it out...
-       prev->render();
-
-       Dialog_Preview *pd = preview_dialog.get();
-       assert(pd);
-
-       pd->set_default_size(700,510);
-       pd->set_preview(prev.get());
-       pd->present();
-}
-
-void
-CanvasView::on_audio_option()
-{
-       synfig::warning("Launching Audio Options");
-       sound_dialog->set_global_fps(get_canvas()->rend_desc().get_frame_rate());
-       sound_dialog->present();
-}
-
-void
-CanvasView::on_audio_file_change(const std::string &f)
-{
-       //save in meta data - always even when not valid...
-       canvas_interface()->set_meta_data("audiofile",f);
-}
-
-void
-CanvasView::on_audio_offset_change(const synfig::Time &t)
-{
-       canvas_interface()->set_meta_data("audiooffset",t.get_string());
-}
-
-void
-CanvasView::on_audio_file_notify()
-{
-       std::string file(get_canvas()->get_meta_data("audiofile"));
-       if(!file.c_str()) return;
-
-       if(!audio->load(file,dirname(get_canvas()->get_file_name())+string("/")))
-       {
-               if(file != "") synfig::warning("Could not load the file: %s", file.c_str());
-               get_canvas()->erase_meta_data("audiofile");
-               disp_audio->hide();
-               disp_audio->set_profile(etl::handle<AudioProfile>());
-       }else
-       {
-               //save in canvasview
-               synfig::warning("Getting the profile of the music stuff");
-
-               //profile specific stuff for the preview widget
-               //similar for other attachments
-               Dialog_Preview *pd = preview_dialog.get();
-               pd->get_widget().set_audio(audio);
-
-               handle<AudioProfile>    prof = audio->get_profile();
-
-               if(!prof)
-               {
-                       synfig::warning("Agh, I couldn't build the profile captain!");
-               }
-               pd->get_widget().set_audioprofile(prof);
-
-               disp_audio->set_profile(audio->get_profile());
-               disp_audio->show();
-
-               synfig::warning("successfully set the profiles and stuff");
-       }
-       disp_audio->queue_draw();
-}
-
-void
-CanvasView::on_audio_offset_notify()
-{
-       Time t(get_canvas()->get_meta_data("audiooffset"),get_canvas()->rend_desc().get_frame_rate());
-       audio->set_offset(t);
-       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());
-}
-
-void
-CanvasView::play_audio(float t)
-{
-       if(audio.get())
-       {
-               synfig::info("Playing audio at %f s",t);
-               audio->play(t);
-       }
-}
-
-void
-CanvasView::stop_audio()
-{
-       if(audio.get())
-       {
-               audio->stop();
-       }
-}
-
-bool
-CanvasView::on_audio_scrub()
-{
-       disp_audio->draw();
-       return true;
-}
-
-Glib::RefPtr<Glib::ObjectBase>
-CanvasView::get_ref_obj(const synfig::String& x)
-{
-       return ref_obj_book_[x];
-}
-
-Glib::RefPtr<const Glib::ObjectBase>
-CanvasView::get_ref_obj(const synfig::String& x)const
-{
-       return ref_obj_book_.find(x)->second;
-}
-
-void
-CanvasView::set_ref_obj(const synfig::String& x, Glib::RefPtr<Glib::ObjectBase> y)
-{
-       ref_obj_book_[x]=y;
-}
-
-Glib::RefPtr<Gtk::TreeModel>
-CanvasView::get_tree_model(const synfig::String& x)
-{
-       return Glib::RefPtr<Gtk::TreeModel>::cast_dynamic(ref_obj_book_["_tree_model_"+x]);
-}
-
-Glib::RefPtr<const Gtk::TreeModel>
-CanvasView::get_tree_model(const synfig::String& x)const
-{
-       return Glib::RefPtr<Gtk::TreeModel>::cast_dynamic(ref_obj_book_.find("_tree_model_"+x)->second);
-}
-
-void
-CanvasView::set_tree_model(const synfig::String& x, Glib::RefPtr<Gtk::TreeModel> y)
-{
-       ref_obj_book_["_tree_model_"+x]=Glib::RefPtr<Glib::ObjectBase>::cast_static(y);
-}
-
-Gtk::Widget*
-CanvasView::get_ext_widget(const synfig::String& x)
-{
-       return ext_widget_book_[x];
-}
-
-void
-CanvasView::set_ext_widget(const synfig::String& x, Gtk::Widget* y)
-{
-       ext_widget_book_[x]=y;
-       if(x=="layers_cmp")
-       {
-               layer_tree=dynamic_cast<LayerTree*>(y);
-
-               layer_tree->get_selection()->signal_changed().connect(SLOT_EVENT(EVENT_LAYER_SELECTION_CHANGED));
-               layer_tree->get_selection()->signal_changed().connect(SLOT_EVENT(EVENT_REFRESH_DUCKS));
-               layer_tree->signal_layer_user_click().connect(sigc::mem_fun(*this, &studio::CanvasView::on_layer_user_click));
-               layer_tree->signal_param_user_click().connect(sigc::mem_fun(*this, &studio::CanvasView::on_children_user_click));
-               layer_tree->signal_waypoint_clicked_layertree().connect(sigc::mem_fun(*this, &studio::CanvasView::on_waypoint_clicked_canvasview));
-       }
-       if(x=="children")
-       {
-               children_tree=dynamic_cast<ChildrenTree*>(y);
-               if(children_tree)children_tree->signal_user_click().connect(sigc::mem_fun(*this, &studio::CanvasView::on_children_user_click));
-               if(children_tree)children_tree->signal_waypoint_clicked_childrentree().connect(sigc::mem_fun(*this, &studio::CanvasView::on_waypoint_clicked_canvasview));
-               if(children_tree)children_tree->get_selection()->signal_changed().connect(SLOT_EVENT(EVENT_REFRESH_DUCKS));
-       }
-       if(x=="keyframes")
-               keyframe_tree=dynamic_cast<KeyframeTree*>(y);
-}
-
-bool
-CanvasView::on_delete_event(GdkEventAny* event __attribute__ ((unused)))
-{
-       close_view();
-
-       //! \todo This causes the window to be deleted straight away - but what if we prompt 'save?' and the user cancels?
-       //                Is there ever any need to pass on the delete event to the window here?
-       // if(event) return Gtk::Window::on_delete_event(event);
-
-       return true;
-}
-
-//! Modify the play stop button apearence and play stop the animation
-void
-CanvasView::on_play_stop_pressed()
-{
-       Gtk::Image *icon;
-       Gtk::Button *stop_button;
-       stop_button=framedial->get_play_button();
-       bool play_flag;
-       if(!is_playing())
-       {
-               icon = manage(new Gtk::Image(Gtk::Stock::MEDIA_STOP, Gtk::IconSize::from_name("synfig-small_icon")));
-               stop_button->set_relief(Gtk::RELIEF_NORMAL);
-               play_flag=true;
-       }
-       else
-       {
-               icon = manage(new Gtk::Image(Gtk::Stock::MEDIA_PLAY, Gtk::IconSize::from_name("synfig-small_icon")));
-               stop_button->set_relief(Gtk::RELIEF_NONE);
-               play_flag=false;
-       }
-       stop_button->remove();
-       stop_button->add(*icon);
-       icon->set_padding(0, 0);
-       icon->show();
-       if(play_flag) play(); else stop();
-}
diff --git a/synfig-studio/src/gtkmm/canvasview.h b/synfig-studio/src/gtkmm/canvasview.h
deleted file mode 100644 (file)
index 11005d3..0000000
+++ /dev/null
@@ -1,743 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file canvasview.h
-**     \brief Template Header
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 2008 Chris Moore
-**     Copyright (c) 2009 Carlos López
-**
-**     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_GTKMM_CANVASVIEW_H
-#define __SYNFIG_STUDIO_GTKMM_CANVASVIEW_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/window.h>
-#include <gtkmm/image.h>
-#include <gtkmm/tooltips.h>
-#include <gtkmm/table.h>
-#include <gtkmm/statusbar.h>
-#include <gtkmm/progressbar.h>
-#include <gtkmm/button.h>
-#include <gtkmm/menu.h>
-#include <gtkmm/treeview.h>
-#include <gtkmm/treestore.h>
-#include <gtkmm/scrolledwindow.h>
-#include <gtkmm/notebook.h>
-#include <gdkmm/device.h>
-#include <gtkmm/spinbutton.h>
-
-#include <synfigapp/canvasinterface.h>
-#include <synfigapp/selectionmanager.h>
-
-#include <synfig/canvas.h>
-#include <synfig/string.h>
-#include <synfig/time.h>
-
-#include "instance.h"
-#include "canvasproperties.h"
-#include "canvasoptions.h"
-#include "render.h"
-#include "cellrenderer_timetrack.h"
-#include "app.h"
-
-#include "layertreestore.h"
-#include "layertree.h"
-#include "childrentreestore.h"
-#include "childrentree.h"
-#include "keyframetreestore.h"
-#include "keyframetree.h"
-
-#include "dialog_waypoint.h"
-#include "dialog_keyframe.h"
-#include "framedial.h"
-#include "toggleducksdial.h"
-#include "resolutiondial.h"
-#include "widget_keyframe_list.h"
-
-#include "duckmatic.h"
-#include <gtkmm/scale.h>
-
-#include <gtkmm/uimanager.h>
-
-#include "smach.h"
-
-#include <memory>
-#include <set>
-#include <map>
-#include <gtkmm/toggleaction.h>
-#include <gtkmm/radioaction.h>
-#include <synfig/rect.h>
-
-#include "adjust_window.h"
-
-#include <synfig/transform.h>
-
-/* === M A C R O S ========================================================= */
-
-#ifndef DEBUGPOINT_CLASS
-#if    _DEBUG
-#define DEBUGPOINT_CLASS(x)            struct debugpointclass_ ## x { debugpointclass_ ## x () { DEBUGPOINT(); } ~debugpointclass_ ## x () { DEBUGPOINT(); } } badfthguae_ ## x ;
-#else
-#define DEBUGPOINT_CLASS(x)
-#endif
-#endif
-
-/* === T Y P E D E F S ===================================================== */
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-namespace synfig {
-       class TransformStack;
-}
-
-namespace studio {
-
-class CanvasViewUIInterface;
-class CanvasViewSelectionManager;
-
-class CellRenderer_TimeTrack;
-class CellRenderer_ValueBase;
-class UniversalScrubber;
-class WorkArea;
-
-class Duckmatic;
-
-class Preview;
-struct PreviewInfo;
-class AudioContainer;
-
-class Widget_Sound;
-class Widget_Timeslider;
-class Widget_Time;
-
-class Dialog_SoundSelect;
-class Dialog_Preview;
-
-class Dock_Layers;
-class Dock_Children;
-class Dock_Keyframes;
-
-class CanvasView : public Gtk::Window, public etl::shared_object
-{
-       friend class UniversalScrubber;
-       friend class Dock_Layers;
-       friend class Dock_Children;
-       friend class Dock_Keyframes;
-
-       friend class CanvasViewUIInterface;
-       friend class CanvasViewSelectionManager;
-
-       friend class Duckmatic;
-
-       /*
- -- ** -- P U B L I C   T Y P E S ---------------------------------------------
-       */
-
-public:
-
-       typedef etl::handle<CanvasView> Handle;
-
-       typedef etl::handle<const CanvasView> ConstHandle;
-
-       typedef etl::loose_handle<CanvasView> LooseHandle;
-
-       typedef LayerTreeStore::Model LayerTreeModel;
-
-       typedef ChildrenTreeStore::Model ChildrenTreeModel;
-
-       //! Create an instance of this class whenever doing a longer task.
-       /*! Make sure that you check the bool value of this class occasionally
-       **      to make sure the action has not been canceled. */
-       class IsWorking
-       {
-               CanvasView &canvas_view_;
-
-       public:
-               IsWorking(CanvasView &canvas_view_);
-               ~IsWorking();
-               operator bool()const;
-       };
-       friend class IsWorking;
-
-       typedef synfigapp::CanvasInterface::Mode Mode;
-
-       void set_grid_snap_toggle(bool flag) { grid_snap_toggle->set_active(flag); }
-       void set_grid_show_toggle(bool flag) { grid_show_toggle->set_active(flag); }
-
-       /*
- -- ** -- P R I V A T E   D A T A ---------------------------------------------
-       */
-
-public:
-       std::auto_ptr<WorkArea> work_area;
-
-       WorkArea* get_work_area() { return work_area.get(); }
-private:
-
-       synfig::TransformStack curr_transform_stack;
-       bool curr_transform_stack_set;
-
-       synfig::Rect bbox;
-
-       // DEBUGPOINT_CLASS(1);
-
-       //! State Machine
-       Smach smach_;
-
-       // DEBUGPOINT_CLASS(2);
-
-       etl::loose_handle<Instance> instance_;
-       etl::handle<synfigapp::CanvasInterface> canvas_interface_;
-
-       // DEBUGPOINT_CLASS(3);
-
-       //! Sound and information to play it
-       etl::handle<AudioContainer>             audio;
-       studio::Widget_Sound                    *disp_audio; //should this be put into thing too?
-
-       sigc::connection                                playcon;
-       sigc::connection                                stopcon;
-
-       std::auto_ptr<UniversalScrubber> universal_scrubber;
-
-       //! Tooltip controller
-       Gtk::Tooltips tooltips;
-
-       // DEBUGPOINT_CLASS(4);
-
-       //! TreeModel for the layers
-       LayerTreeModel layer_tree_model;
-
-       //! TreeModel for the the children
-       ChildrenTreeModel children_tree_model;
-
-       //Glib::RefPtr<LayerTreeStore> layer_tree_store_;
-
-       //Glib::RefPtr<ChildrenTreeStore> children_tree_store_;
-
-       //Glib::RefPtr<KeyframeTreeStore> keyframe_tree_store_;
-
-       // DEBUGPOINT_CLASS(5);
-
-       //std::map<synfig::String,Glib::RefPtr<Gtk::TreeModel> > tree_model_book_;
-       std::map<synfig::String,Glib::RefPtr<Glib::ObjectBase> > ref_obj_book_;
-       std::map<synfig::String,Gtk::Widget*> ext_widget_book_;
-
-       //! The time adjustment's scope is defined by the time_window adjustment
-       Gtk::Adjustment time_adjustment_;
-
-       //! The time_window adjustment governs the position of the time window on the whole time line
-       //Gtk::Adjustment time_window_adjustment_;
-       studio::Adjust_Window time_window_adjustment_;
-
-       LayerTree *layer_tree;
-
-       ChildrenTree *children_tree;
-
-       KeyframeTree *keyframe_tree;
-
-       Gtk::Widget *keyframe_tab_child;
-
-       Gtk::ProgressBar *progressbar;
-       Gtk::Statusbar *statusbar;
-
-       Gtk::TreeRow children_canvas_row;
-       Gtk::TreeRow children_valuenode_row;
-
-       Gtk::Button *stopbutton;
-       Gtk::Button *refreshbutton;
-       Gtk::Button *treetogglebutton;  // not used
-       Gtk::Notebook *notebook; // not used
-       Gtk::Table *timebar;
-       Gtk::Table *displaybar;
-       Gtk::Button *animatebutton;
-       Gtk::Button *keyframebutton;
-       FrameDial *framedial;
-       ToggleDucksDial *toggleducksdial;
-       bool toggling_ducks_;
-       ResolutionDial *resolutiondial;
-       bool changing_resolution_;
-       Gtk::Adjustment quality_adjustment_;
-       Gtk::SpinButton *quality_spin;
-       Gtk::Adjustment future_onion_adjustment_;
-       Gtk::Adjustment past_onion_adjustment_;
-       Gtk::SpinButton *past_onion_spin;
-       Gtk::SpinButton *future_onion_spin;
-       bool updating_quality_;
-       Gtk::ToggleButton *show_grid;
-       Gtk::ToggleButton *snap_grid;
-       Gtk::ToggleButton *onion_skin;
-       Gtk::Button *render_options_button;
-       Gtk::Button *preview_options_button;
-       bool toggling_show_grid;
-       bool toggling_snap_grid;
-       bool toggling_onion_skin;
-       //! Shows current time and allows edition
-       Widget_Time *current_time_widget;
-       void on_current_time_widget_changed();
-
-       //! Time slider class. Same than the Time track panel
-       std::auto_ptr<Widget_Timeslider> timeslider;
-
-       //!Keyframe list slider
-       std::auto_ptr<Widget_Keyframe_List> widget_kf_list;
-
-       std::list<sigc::connection> duck_changed_connections;
-
-/*     DEBUGPOINT_CLASS(8);
-
-       Gtk::Menu duckmaskmenu;
-       DEBUGPOINT_CLASS(77);
-       Gtk::Menu qualitymenu;
-       DEBUGPOINT_CLASS(6);
-
-       Gtk::Menu filemenu;
-       DEBUGPOINT_CLASS(777);
-       Gtk::Menu editmenu;
-       DEBUGPOINT_CLASS(71);
-       Gtk::Menu canvasmenu;
-       DEBUGPOINT_CLASS(73);
-public:
-       Gtk::Menu layermenu;
-private:
-       DEBUGPOINT_CLASS(74);
-       Gtk::Menu newlayermenu;
-       DEBUGPOINT_CLASS(76);
-       Gtk::Menu viewmenu;
-
-       DEBUGPOINT_CLASS(99);
-       Gtk::Menu keyframemenu;
-
-       Gtk::Menu parammenu;
-       DEBUGPOINT_CLASS(9);
-       Gtk::Menu trackmenu;
-       DEBUGPOINT_CLASS(7);
-
-       Gtk::CheckMenuItem* duck_mask_position;
-       Gtk::CheckMenuItem* duck_mask_vertex;
-       Gtk::CheckMenuItem* duck_mask_tangent;
-       Gtk::CheckMenuItem* duck_mask_radius;
-       Gtk::CheckMenuItem* duck_mask_width;
-       Gtk::CheckMenuItem* duck_mask_angle;
-*/
-       //! Menu members
-       Gtk::Menu parammenu;
-
-       Glib::RefPtr<Gtk::ToggleAction> grid_snap_toggle;
-       Glib::RefPtr<Gtk::ToggleAction> grid_show_toggle;
-
-       Gtk::RadioButtonGroup quality_group;
-       Gtk::RadioButtonGroup low_res_pixel_size_group;
-
-       Glib::RefPtr<Gtk::ActionGroup> action_group;
-
-       etl::handle<synfigapp::UIInterface> ui_interface_;
-       etl::handle<synfigapp::SelectionManager> selection_manager_;
-
-       bool is_playing_;
-
-       sigc::signal<void> signal_deleted_;
-
-       bool rebuild_ducks_queued;
-       sigc::connection queue_rebuild_ducks_connection;
-
-       /*
- -- ** -- P U B L I C   D A T A -----------------------------------------------
-       */
-
-public:
-       void queue_rebuild_ducks();
-       sigc::signal<void>& signal_deleted() { return signal_deleted_; }
-
-       Gtk::Menu mainmenu;
-
-       bool duck_refresh_flag;
-       bool duck_refresh_needed;
-
-       //! This is for the IsWorking class.
-       int working_depth;
-
-       bool cancel;
-
-       /*
- -- ** -- D I A L O G S -------------------------------------------------------
-       */
-
-public:
-
-       CanvasProperties canvas_properties;
-       CanvasOptions canvas_options;
-       RenderSettings render_settings;
-       Dialog_Waypoint waypoint_dialog;
-       Dialog_Keyframe keyframe_dialog;
-
-       std::auto_ptr<Dialog_Preview>                   preview_dialog;
-       //std::auto_ptr<Dialog_PreviewOptions>  previewoption_dialog;
-       std::auto_ptr<Dialog_SoundSelect>               sound_dialog;
-
-       /*
- -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
-       */
-
-private:
-
-       // Constructor is private to force the use of the "create()" constructor
-       CanvasView(etl::loose_handle<Instance> instance,etl::handle<synfigapp::CanvasInterface> canvas_interface);
-
-       //! Constructor Helper
-       // Gtk::Widget* create_layer_tree();
-
-       //! Constructor Helper
-       // Gtk::Widget* create_children_tree();
-
-       //! Constructor Helper
-       // Gtk::Widget* create_keyframe_tree();
-
-       //! Constructor Helper
-       Gtk::Widget* create_status_bar();
-
-       //! Constructor Helper - Initializes all of the menus
-       void init_menus();
-
-       bool duck_change_param(const synfig::Point &value,synfig::Layer::Handle layer, synfig::String param_name);
-
-       void refresh_time_window();
-
-       void time_was_changed();
-
-       void refresh_rend_desc();
-
-       void toggle_duck_mask(Duckmatic::Type type);
-
-       Gtk::Widget *create_work_area();
-
-       Gtk::Widget *create_time_bar();
-
-       Gtk::Widget *create_display_bar();
-
-       //! Pop up menu for the bezier (bline, draw) tool (?)
-       void popup_param_menu_bezier(float location, synfigapp::ValueDesc value_desc)
-       { popup_param_menu(value_desc,location,true); }
-
-       //! Pop up menu for the tools but not the bezier ones.
-       void popup_param_menu(synfigapp::ValueDesc value_desc, float location=0, bool bezier=false);
-
-       void workarea_layer_selected(synfig::Layer::Handle layer);
-
-       void selected_layer_color_set(synfig::Color color);
-
-       void register_layer_type(synfig::Layer::Book::value_type &lyr,std::map<synfig::String,Gtk::Menu*>*);
-
-       //! Rebuilds the "new layer" menu
-       void build_new_layer_menu(Gtk::Menu &menu);
-
-       void rebuild_ducks_layer_(synfig::TransformStack& transform_stack, synfig::Canvas::Handle canvas, std::set<synfig::Layer::Handle>& selected_list);
-
-       void decrease_low_res_pixel_size();
-       void increase_low_res_pixel_size();
-       void toggle_low_res_pixel_flag();
-       void set_quality(int x);
-       void set_onion_skins();
-       void toggle_show_grid();
-       void toggle_snap_grid();
-       void toggle_onion_skin();
-
-       /*
- -- ** -- P U B L I C   M E T H O D S -----------------------------------------
-       */
-
-public:
-       const synfig::TransformStack& get_curr_transform_stack()const { return curr_transform_stack; }
-
-       const synfig::Rect& get_bbox()const { return bbox; }
-
-       Glib::RefPtr<Glib::ObjectBase> get_ref_obj(const synfig::String& x);
-       Glib::RefPtr<const Glib::ObjectBase> get_ref_obj(const synfig::String& x)const;
-       void set_ref_obj(const synfig::String& x, Glib::RefPtr<Glib::ObjectBase> y);
-
-       Glib::RefPtr<Gtk::TreeModel> get_tree_model(const synfig::String& x);
-       Glib::RefPtr<const Gtk::TreeModel> get_tree_model(const synfig::String& x)const;
-       void set_tree_model(const synfig::String& x, Glib::RefPtr<Gtk::TreeModel> y);
-
-       Gtk::Widget* get_ext_widget(const synfig::String& x);
-       void set_ext_widget(const synfig::String& x, Gtk::Widget* y);
-
-       //std::map<synfig::String,Gtk::Widget*>& tree_view_book() { return tree_view_book_; }
-       //std::map<synfig::String,Gtk::Widget*>& ext_widget_book() { return tree_view_book_; }
-
-       void popup_main_menu();
-
-       Smach& get_smach() { return smach_; }
-
-       const Smach& get_smach()const { return smach_; }
-
-       Smach::event_result process_event_key(EventKey x);
-
-       void popup_layer_menu(synfig::Layer::Handle layer);
-
-       virtual ~CanvasView();
-
-       void set_mode(Mode x) { canvas_interface()->set_mode(x); }
-
-       Mode get_mode()const { return canvas_interface()->get_mode(); }
-
-       Gtk::Adjustment &time_adjustment() { return time_adjustment_; }
-
-       const Gtk::Adjustment &time_adjustment()const { return time_adjustment_; }
-
-       studio::Adjust_Window &time_window_adjustment() { return time_window_adjustment_; }
-
-       const studio::Adjust_Window &time_window_adjustment()const { return time_window_adjustment_; }
-
-       etl::handle<synfigapp::UIInterface> get_ui_interface() { return ui_interface_;}
-
-       etl::handle<synfigapp::SelectionManager> get_selection_manager() { return selection_manager_; }
-
-       Glib::RefPtr<Gtk::TreeModel> layer_tree_store() { return get_tree_model("layers"); }
-
-       Glib::RefPtr<const Gtk::TreeModel> layer_tree_store()const { return get_tree_model("layers"); }
-
-       Glib::RefPtr<Gtk::TreeModel> children_tree_store() { return get_tree_model("children"); }
-
-       Glib::RefPtr<const Gtk::TreeModel> children_tree_store()const { return get_tree_model("children"); }
-
-       Glib::RefPtr<Gtk::TreeModel> keyframe_tree_store() { return get_tree_model("keyframes"); }
-
-       Glib::RefPtr<const Gtk::TreeModel> keyframe_tree_store()const { return get_tree_model("keyframes"); }
-
-       void set_time(synfig::Time t) { canvas_interface_->set_time(t); }
-
-       synfig::Time get_time() { return canvas_interface_->get_time(); }
-
-       etl::handle<synfig::Canvas> get_canvas()const { return canvas_interface_->get_canvas(); }
-
-       etl::handle<Instance> get_instance()const { return instance_; }
-
-       etl::handle<synfigapp::CanvasInterface> canvas_interface() { return canvas_interface_; }
-
-       etl::handle<const synfigapp::CanvasInterface> canvas_interface()const { return canvas_interface_; }
-
-       void add_actions_to_menu(Gtk::Menu *menu,   const synfigapp::Action::ParamList &param_list, synfigapp::Action::Category category=synfigapp::Action::CATEGORY_ALL)const;
-
-       //! Updates the title of the window
-       void update_title();
-
-       //! Closes this document
-       bool close_instance();
-
-       //! Closes this canvas view
-       bool close_view();
-
-       //!     Stops the currently executing action
-       /*! \see get_cancel_status(), reset_cancel_status(), IsWorking */
-       void stop() { cancel=true; }
-
-       //! Returns the cancel status
-       /*! \see stop(), reset_cancel_status(), IsWorking */
-       bool get_cancel_status()const { return cancel; }
-
-       //! Resets the cancel status
-       /*! \see stop(), get_cancel_status(), IsWorking */
-       void reset_cancel_status() { cancel=false; }
-
-       void new_child_canvas();
-
-       //! Rebuilds layer_tree_store_ from the Canvas. Maintains selected items.
-       void rebuild_tables();
-
-       //! Builds layer_tree_store_ from the Canvas. Does not maintain selected items.
-       void build_tables();
-
-       //! Refreshes the data for the tables
-       void refresh_tables();
-
-       //void rebuild_layer_table();
-       //void build_layer_table();
-       //void refresh_layer_table();
-
-//     void rebuild_canvas_table();
-//     void build_canvas_table();
-//     void refresh_canvas_table();
-
-//     void rebuild_valuenode_table();
-//     void build_valuenode_table();
-//     void refresh_valuenode_table();
-
-       //! \writeme
-       void rebuild_ducks();
-
-       //bool add_to_ducks(synfigapp::ValueDesc value_desc, synfig::ParamDesc *param_desc=NULL);
-
-       //! Starts "playing" the animation in real-time
-       void play();
-
-       //! Shows the tables (Layer/Children)
-       void show_tables();
-
-       //! Hides the tables (Layer/Children)
-       void hide_tables();
-
-       //! Toggles the tables
-       void toggle_tables();
-
-       //! Gets the table status
-       bool tables_are_visible();
-
-       //! Shows the time bar
-       void show_timebar();
-
-       //! Hides the time bar
-       void hide_timebar();
-
-       //t Enables or disables interaction with the timebar
-       void set_sensitive_timebar(bool sensitive);
-
-       void time_zoom_in();
-       void time_zoom_out();
-
-       void add_layer(synfig::String x);
-
-       void show_keyframe_dialog();
-
-       void play_audio(float t);
-       void stop_audio();
-
-       void image_import();
-
-       void on_waypoint_clicked_canvasview(synfigapp::ValueDesc,std::set<synfig::Waypoint,std::less<synfig::UniqueID> >, int button);
-
-       void preview_option() {on_preview_option();}
-
-       void present();
-
-       bool is_playing() { return is_playing_; }
-
-       void update_quality();
-
-
-
-       /*
- -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
-       */
-
-private:
-
-       void on_select_layers();
-       void on_unselect_layers();
-
-       void on_input_device_changed(GdkDevice*);
-
-       virtual void on_hide();
-
-       virtual bool on_focus_in_event(GdkEventFocus*);
-       virtual bool on_focus_out_event(GdkEventFocus*);
-
-       //bool on_children_tree_event(GdkEvent *event);
-
-       bool on_keyframe_tree_event(GdkEvent *event);
-
-       //void on_children_edited_value(const Glib::ustring&path_string,synfig::ValueBase value);
-
-       void on_dirty_preview();
-
-       bool on_children_user_click(int, Gtk::TreeRow, ChildrenTree::ColumnID);
-
-       bool on_layer_user_click(int, Gtk::TreeRow, LayerTree::ColumnID);
-
-//     void on_layer_toggle(const Glib::ustring& path_string, Gtk::TreeModelColumn<bool> column);
-
-       void on_mode_changed(synfigapp::CanvasInterface::Mode mode);
-
-//     void on_layer_waypoint_clicked(const Glib::ustring &, synfig::ValueNode_Animated::WaypointList::iterator);
-
-       //void on_children_waypoint_clicked(const Glib::ustring &, synfig::ValueNode_Animated::WaypointList::iterator);
-
-       void on_waypoint_changed();
-
-       void on_waypoint_delete();
-
-       void on_refresh_pressed();
-
-       void on_id_changed();
-
-       void on_time_changed();
-
-       /*
-       void on_layer_raise_pressed();
-       void on_layer_lower_pressed();
-       void on_layer_duplicate_pressed();
-       void on_layer_delete_pressed();
-       */
-
-       void on_keyframe_add_pressed();
-
-       void on_keyframe_duplicate_pressed();
-
-       void on_keyframe_remove_pressed();
-
-       void on_animate_button_pressed();
-
-       void on_keyframe_button_pressed();
-
-       void on_preview_option();
-       void on_preview_create(const PreviewInfo &);
-
-       void on_audio_option();
-       void on_audio_file_change(const std::string &f);
-       void on_audio_offset_change(const synfig::Time &t);
-
-       void on_audio_file_notify();
-       void on_audio_offset_notify();
-
-       bool on_duck_changed(const synfig::Point &value,const synfigapp::ValueDesc& value_desc);
-       bool on_duck_angle_changed(const synfig::Angle &rotation,const synfigapp::ValueDesc& value_desc);
-
-       void on_layer_toggle(synfig::Layer::Handle);
-
-       void on_edited_value(synfigapp::ValueDesc,synfig::ValueBase);
-
-       void on_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& selection_data, guint info, guint time);
-
-       //void on_audio_play();
-       bool on_audio_scrub();
-
-       void on_play_stop_pressed();
-
-protected:
-       bool close_instance_when_safe();
-       bool on_delete_event(GdkEventAny* event);
-
-       /*
- -- ** -- S T A T I C   P U B L I C   M E T H O D S ---------------------------
-       */
-
-public:
-
-       static etl::handle<studio::CanvasView> create(etl::loose_handle<Instance> instance,etl::handle<synfig::Canvas> canvas);
-       static std::list<int>& get_pixel_sizes();
-
-}; // END of class CanvasView
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/cellrenderer_gradient.cpp b/synfig-studio/src/gtkmm/cellrenderer_gradient.cpp
deleted file mode 100644 (file)
index 708c362..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file cellrenderer_gradient.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include <gtkmm/entry.h>
-#include <gtkmm/button.h>
-#include "cellrenderer_gradient.h"
-#include "widget_gradient.h"
-#include "app.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-CellRenderer_Gradient::CellRenderer_Gradient():
-       Glib::ObjectBase        (typeid(CellRenderer_Gradient)),
-       Gtk::CellRendererText   (),
-       property_gradient_(*this,"gradient",synfig::Gradient())
-{
-       assert(0); //CHECK: This class does not appear to be used.
-       //CellRendererText::signal_edited().connect(sigc::mem_fun(*this,&studio::CellRenderer_Gradient::string_edited_));
-}
-
-CellRenderer_Gradient::~CellRenderer_Gradient()
-{
-}
-
-
-void
-CellRenderer_Gradient::render_vfunc(
-               const Glib::RefPtr<Gdk::Drawable>& window,
-               Gtk::Widget& /*widget*/,
-               const Gdk::Rectangle& /*background_area*/,
-               const Gdk::Rectangle& ca,
-               const Gdk::Rectangle& /*expose_area*/,
-               Gtk::CellRendererState /*flags*/)
-{
-       if(!window)
-               return;
-       render_gradient_to_window(window,ca,property_gradient_.get_value());
-}
-
-
-Gtk::CellEditable*
-CellRenderer_Gradient::start_editing_vfunc(
-       GdkEvent* /*event*/,
-       Gtk::Widget& /*widget*/,
-       const Glib::ustring& /*path*/,
-       const Gdk::Rectangle& /*background_area*/,
-       const Gdk::Rectangle& /*cell_area*/,
-       Gtk::CellRendererState /*flags*/)
-{
-       return 0;
-}
diff --git a/synfig-studio/src/gtkmm/cellrenderer_gradient.h b/synfig-studio/src/gtkmm/cellrenderer_gradient.h
deleted file mode 100644 (file)
index 10b54c5..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file cellrenderer_gradient.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_CELLRENDERER_GRADIENT_H
-#define __SYNFIG_STUDIO_CELLRENDERER_GRADIENT_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/entry.h>
-#include <gtkmm/cellrenderertext.h>
-
-#include <sigc++/signal.h>
-#include <sigc++/slot.h>
-
-#include <synfig/gradient.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 Gtk { class Entry; class Button; };
-
-namespace studio {
-
-class CellRenderer_Gradient : public Gtk::CellRendererText
-{
-       sigc::signal<void, const Glib::ustring&> signal_secondary_click_;
-       sigc::signal<void, const Glib::ustring&, synfig::Gradient> signal_edited_;
-
-       Glib::Property<synfig::Gradient> property_gradient_;
-
-public:
-       sigc::signal<void, const Glib::ustring&, synfig::Gradient> &signal_edited()
-       {return signal_edited_; }
-
-       Glib::PropertyProxy<synfig::Gradient> property_gradient() { return property_gradient_.get_proxy();}
-
-       CellRenderer_Gradient();
-       ~CellRenderer_Gradient();
-
-protected:
-
-       virtual void
-       render_vfunc(
-               const Glib::RefPtr<Gdk::Drawable>& window,
-               Gtk::Widget& widget,
-               const Gdk::Rectangle& background_area,
-               const Gdk::Rectangle& ca,
-               const Gdk::Rectangle& expose_area,
-               Gtk::CellRendererState flags);
-
-       virtual Gtk::CellEditable* start_editing_vfunc(GdkEvent* event,
-                                                 Gtk::Widget& widget,
-                                                 const Glib::ustring& path,
-                                                 const Gdk::Rectangle& background_area,
-                                                 const Gdk::Rectangle& cell_area,
-                                                 Gtk::CellRendererState flags);
-
-}; // END of class CellRenderer_Gradient
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/cellrenderer_time.cpp b/synfig-studio/src/gtkmm/cellrenderer_time.cpp
deleted file mode 100644 (file)
index 5567a35..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file cellrenderer_time.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 <config.h>
-#endif
-
-#include <gtkmm/entry.h>
-#include <gtkmm/button.h>
-#include "cellrenderer_time.h"
-#include "app.h"
-#include "widget_time.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-CellRenderer_Time::CellRenderer_Time():
-       Glib::ObjectBase        (typeid(CellRenderer_Time)),
-       Gtk::CellRendererText   (),
-       property_time_(*this,"time",synfig::Time(0)),
-       property_fps_(*this,"fps", float(0))
-{
-       CellRendererText::signal_edited().connect(sigc::mem_fun(*this,&studio::CellRenderer_Time::string_edited_));
-}
-
-CellRenderer_Time::~CellRenderer_Time()
-{
-       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
-               synfig::info("CellRenderer_Time::~CellRenderer_Time(): Deleted");
-}
-
-void
-CellRenderer_Time::string_edited_(const Glib::ustring&path,const Glib::ustring&str)
-{
-       signal_edited_(path,Time((String)str,(Real)Time(property_fps_)));
-}
-
-void
-CellRenderer_Time::render_vfunc(
-               const Glib::RefPtr<Gdk::Drawable>& window,
-               Gtk::Widget& widget,
-               const Gdk::Rectangle& background_area,
-               const Gdk::Rectangle& ca,
-               const Gdk::Rectangle& expose_area,
-               Gtk::CellRendererState flags)
-{
-       if(!window)
-               return;
-       //int   height = ca.get_height();
-
-       Gtk::StateType state = Gtk::STATE_INSENSITIVE;
-       if(property_editable())
-               state = Gtk::STATE_NORMAL;
-       if((flags & Gtk::CELL_RENDERER_SELECTED) != 0)
-               state = (widget.has_focus()) ? Gtk::STATE_SELECTED : Gtk::STATE_ACTIVE;
-
-       const Time time(property_time_);
-       const float fps((Real)Time(property_fps_));
-
-       property_text()=(Glib::ustring)time.get_string(fps,App::get_time_format());
-
-       CellRendererText::render_vfunc(window,widget,background_area,ca,expose_area,flags);
-}
-
-
-Gtk::CellEditable*
-CellRenderer_Time::start_editing_vfunc(
-       GdkEvent* event,
-       Gtk::Widget& widget,
-       const Glib::ustring& path,
-       const Gdk::Rectangle& background_area,
-       const Gdk::Rectangle& cell_area,
-       Gtk::CellRendererState flags)
-{
-       // If we aren't editable, then there is nothing to do
-       if(!property_editable())
-               return 0;
-
-       const Time time(property_time_);
-       const float fps((Real)Time(property_fps_));
-
-       property_text()=(Glib::ustring)time.get_string(fps,App::get_time_format()|Time::FORMAT_FULL);
-#if 0
-       Widget_Time* widget_time(manage(new Widget_Time));
-       widget_time->set_fps(fps);
-       widget_time->set_value(time);
-       widget_time->signal_editing_done().connect(sigc::mem_fun(*this, &CellRenderer_Time::on_value_editing_done));
-       return widget_time;
-#else
-       return CellRendererText::start_editing_vfunc(event,widget,path,background_area,cell_area,flags);
-#endif
-}
diff --git a/synfig-studio/src/gtkmm/cellrenderer_time.h b/synfig-studio/src/gtkmm/cellrenderer_time.h
deleted file mode 100644 (file)
index 149f7d8..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file cellrenderer_time.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_CELLRENDERER_TIME_H
-#define __SYNFIG_STUDIO_CELLRENDERER_TIME_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/entry.h>
-#include <gtkmm/cellrenderertext.h>
-
-#include <sigc++/signal.h>
-#include <sigc++/slot.h>
-
-#include <synfig/time.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 Gtk { class Entry; class Button; };
-
-namespace studio {
-
-class CellRenderer_Time : public Gtk::CellRendererText
-{
-       sigc::signal<void, const Glib::ustring&> signal_secondary_click_;
-       sigc::signal<void, const Glib::ustring&, synfig::Time> signal_edited_;
-
-       Glib::Property<synfig::Time> property_time_;
-       Glib::Property<synfig::Time> property_fps_;
-
-       void string_edited_(const Glib::ustring&,const Glib::ustring&);
-
-       void on_value_editing_done();
-
-public:
-       sigc::signal<void, const Glib::ustring&, synfig::Time> &signal_edited()
-       {return signal_edited_; }
-
-       Glib::PropertyProxy<synfig::Time> property_time() { return property_time_.get_proxy();}
-       Glib::PropertyProxy<synfig::Time> property_fps() { return property_fps_.get_proxy();}
-
-       CellRenderer_Time();
-       ~CellRenderer_Time();
-
-protected:
-
-       virtual void
-       render_vfunc(
-               const Glib::RefPtr<Gdk::Drawable>& window,
-               Gtk::Widget& widget,
-               const Gdk::Rectangle& background_area,
-               const Gdk::Rectangle& ca,
-               const Gdk::Rectangle& expose_area,
-               Gtk::CellRendererState flags);
-
-       virtual Gtk::CellEditable* start_editing_vfunc(GdkEvent* event,
-                                                 Gtk::Widget& widget,
-                                                 const Glib::ustring& path,
-                                                 const Gdk::Rectangle& background_area,
-                                                 const Gdk::Rectangle& cell_area,
-                                                 Gtk::CellRendererState flags);
-
-}; // END of class CellRenderer_Time
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/cellrenderer_timetrack.cpp b/synfig-studio/src/gtkmm/cellrenderer_timetrack.cpp
deleted file mode 100644 (file)
index 8382465..0000000
+++ /dev/null
@@ -1,906 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file cellrenderer_timetrack.cpp
-**     \brief Template Header
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 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 <config.h>
-#endif
-
-#include <gtkmm/label.h>
-#include "cellrenderer_timetrack.h"
-#include <gtk/gtk.h>
-#include <gtkmm/spinbutton.h>
-#include <gtkmm/combo.h>
-#include <ETL/stringf>
-#include "widget_value.h"
-#include "app.h"
-#include <gtkmm/menu.h>
-#include <gtkmm/optionmenu.h>
-#include "widget_time.h"
-#include "widget_timeslider.h"
-
-#include <synfigapp/canvasinterface.h>
-#include "instance.h"
-
-#include "general.h"
-
-#endif
-
-using namespace synfig;
-using namespace std;
-using namespace etl;
-using namespace studio;
-
-/* === M A C R O S ========================================================= */
-
-/* === G L O B A L S ======================================================= */
-
-static char stipple_xpm[] = { 2, 0 };
-
-//mode for modifier keys
-enum MODMODE
-{
-       NONE = 0,
-       SELECT_MASK = Gdk::CONTROL_MASK,
-       COPY_MASK = Gdk::SHIFT_MASK,
-       DELETE_MASK = Gdk::MOD1_MASK
-};
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-CellRenderer_TimeTrack::CellRenderer_TimeTrack():
-       Glib::ObjectBase        (typeid(CellRenderer_TimeTrack)),
-       Gtk::CellRenderer       (),
-       adjustment_                     (10,10,20,0,0,0),
-
-       property_valuedesc_     (*this,"value_desc",synfigapp::ValueDesc()),
-       property_canvas_        (*this,"canvas",synfig::Canvas::Handle()),
-       property_adjustment_(*this,"adjustment",&adjustment_),
-       property_enable_timing_info_(*this,"enable-timing-info", false)
-{
-       dragging=false;
-       selection=false;
-}
-
-CellRenderer_TimeTrack::~CellRenderer_TimeTrack()
-{
-       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
-               synfig::info("CellRenderer_TimeTrack::~CellRenderer_TimeTrack(): Deleted");
-}
-
-void
-CellRenderer_TimeTrack::set_adjustment(Gtk::Adjustment &x)
-{
-       property_adjustment_=&x;
-//     x.signal_value_changed().connect(sigc::mem_fun(*this,&Gtk::Widget::queue_draw));
-}
-
-synfig::Canvas::Handle
-CellRenderer_TimeTrack::get_canvas()const
-{
-       return const_cast<CellRenderer_TimeTrack*>(this)->property_canvas().get_value();
-}
-
-Gtk::Adjustment *
-CellRenderer_TimeTrack::get_adjustment()
-{
-       return (Gtk::Adjustment*)property_adjustment_;
-}
-
-const Gtk::Adjustment *
-CellRenderer_TimeTrack::get_adjustment()const
-{
-       return (const Gtk::Adjustment*)property_adjustment_;
-}
-
-bool
-CellRenderer_TimeTrack::is_selected(const Waypoint& waypoint)const
-{
-       return selected==waypoint;
-}
-
-const synfig::Time get_time_offset_from_vdesc(const synfigapp::ValueDesc &v)
-{
-#ifdef ADJUST_WAYPOINTS_FOR_TIME_OFFSET
-       if(getenv("SYNFIG_SHOW_CANVAS_PARAM_WAYPOINTS") ||
-          v.get_value_type() != synfig::ValueBase::TYPE_CANVAS)
-               return synfig::Time::zero();
-
-       synfig::Canvas::Handle canvasparam = v.get_value().get(Canvas::Handle());
-       if(!canvasparam)
-               return synfig::Time::zero();
-
-       if (!v.parent_is_layer_param())
-               return synfig::Time::zero();
-
-       synfig::Layer::Handle layer = v.get_layer();
-
-       if (layer->get_name()!="PasteCanvas")
-               return synfig::Time::zero();
-
-       return layer->get_param("time_offset").get(Time());
-#else // ADJUST_WAYPOINTS_FOR_TIME_OFFSET
-       return synfig::Time::zero();
-#endif
-}
-
-//kind of a hack... pointer is ugly
-const synfig::Node::time_set *get_times_from_vdesc(const synfigapp::ValueDesc &v)
-{
-       if(!getenv("SYNFIG_SHOW_CANVAS_PARAM_WAYPOINTS") &&
-          v.get_value_type() == synfig::ValueBase::TYPE_CANVAS)
-       {
-               synfig::Canvas::Handle canvasparam = v.get_value().get(Canvas::Handle());
-
-               if(canvasparam)
-                       return &canvasparam->get_times();
-       }
-
-       ValueNode *base_value = v.get_value_node().get();
-
-       ValueNode_DynamicList *parent_value_node =
-                       v.parent_is_value_node() ?
-                               dynamic_cast<ValueNode_DynamicList *>(v.get_parent_value_node().get()) :
-                               0;
-
-       //we want a dynamic list entry to override the normal...
-       if(parent_value_node)
-       {
-               return &parent_value_node->list[v.get_index()].get_times();
-       }else if(base_value) //don't render stuff if it's just animated...
-       {
-               return &base_value->get_times();
-       }
-       return 0;
-}
-
-bool get_closest_time(const synfig::Node::time_set &tset, const Time &t, const Time &range, Time &out)
-{
-       Node::time_set::const_iterator  i,j,end = tset.end();
-
-       // stop the crash mentioned in bug #1689282
-       // doesn't solve the underlying problem though, I don't think
-       if (tset.size() == 0)
-       {
-               synfig::error(__FILE__":%d: tset.size() == 0",__LINE__);
-               return false;
-       }
-
-       //TODO add in RangeGet so it's not so damn hard to click on points
-
-       i = tset.upper_bound(t); //where t is the lower bound, t < [first,i)
-       j = i; --j;
-
-       double dist = Time::end();
-       double closest = 0;
-
-       if(i != end)
-       {
-               closest = i->get_time();
-               dist = abs(i->get_time() - t);
-       }
-
-       if(j != end && (abs(j->get_time() - t) < dist) )
-       {
-               closest = j->get_time();
-               dist = abs(j->get_time() - t);
-       }
-
-       if( dist <= range/2 )
-       {
-               out = closest;
-               return true;
-       }
-
-       return false;
-}
-
-void
-CellRenderer_TimeTrack::render_vfunc(
-               const Glib::RefPtr<Gdk::Drawable>& window,
-               Gtk::Widget& widget,
-               const Gdk::Rectangle& /*background_area*/,
-               const Gdk::Rectangle& area_,
-               const Gdk::Rectangle& /*expose_area*/,
-               Gtk::CellRendererState /*flags*/)
-{
-       if(!window)
-               return;
-
-       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(window));
-       Glib::RefPtr<Gdk::GC> inactive_gc(Gdk::GC::create(window));
-       Gtk::Adjustment *adjustment=get_adjustment();
-       // Gtk::StateType state = Gtk::STATE_ACTIVE;
-       // Gtk::ShadowType shadow;
-
-       Gdk::Color
-               curr_time_color("#0000ff"),
-               inactive_color("#000000"),
-               keyframe_color("#a07f7f");
-       Gdk::Color activepoint_color[2];
-
-       activepoint_color[0]=Gdk::Color("#ff0000");
-       activepoint_color[1]=Gdk::Color("#00ff00");
-
-       inactive_gc->set_rgb_fg_color(inactive_color);
-       inactive_gc->set_stipple(Gdk::Bitmap::create(stipple_xpm,2,2));
-       inactive_gc->set_fill(Gdk::STIPPLED);
-
-       synfig::Canvas::Handle canvas(property_canvas().get_value());
-
-       synfigapp::ValueDesc value_desc = property_value_desc().get_value();
-       synfig::ValueNode *base_value = value_desc.get_value_node().get();
-       // synfig::ValueNode_Animated *value_node=dynamic_cast<synfig::ValueNode_Animated*>(base_value);
-
-       synfig::ValueNode_DynamicList *parent_value_node(0);
-       if(property_value_desc().get_value().parent_is_value_node())
-               parent_value_node=dynamic_cast<synfig::ValueNode_DynamicList*>(property_value_desc().get_value().get_parent_value_node().get());
-
-       // If the canvas is defined, then load up the keyframes
-       if(canvas)
-       {
-               const synfig::KeyframeList& keyframe_list(canvas->keyframe_list());
-               synfig::KeyframeList::const_iterator iter;
-
-               for(iter=keyframe_list.begin();iter!=keyframe_list.end();++iter)
-               {
-                       if(!iter->get_time().is_valid())
-                               continue;
-
-                       const int x((int)((float)area_.get_width()/(adjustment->get_upper()-adjustment->get_lower())*(iter->get_time()-adjustment->get_lower())));
-                       if(iter->get_time()>=adjustment->get_lower() && iter->get_time()<adjustment->get_upper())
-                       {
-                               gc->set_rgb_fg_color(keyframe_color);
-                               window->draw_rectangle(gc, true, area_.get_x()+x, area_.get_y(), 1, area_.get_height()+1);
-                       }
-               }
-       }
-
-       //render all the time points that exist
-       {
-               const synfig::Node::time_set *tset = get_times_from_vdesc(value_desc);
-
-               if(tset)
-               {
-                       const synfig::Time time_offset = get_time_offset_from_vdesc(value_desc);
-                       synfig::Node::time_set::const_iterator  i = tset->begin(), end = tset->end();
-
-                       float   lower = adjustment->get_lower(),
-                                       upper = adjustment->get_upper();
-
-                       Glib::RefPtr<Gdk::GC>   gc = Gdk::GC::create(widget.get_window());
-
-                       Gdk::Rectangle area(area_);
-                       gc->set_clip_rectangle(area);
-                       gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-
-                       bool valselected = sel_value.get_value_node() == base_value && !sel_times.empty();
-
-                       float cfps = get_canvas()->rend_desc().get_frame_rate();
-
-                       vector<Time>    drawredafter;
-
-                       Time diff = actual_time - actual_dragtime;//selected_time-drag_time;
-                       for(; i != end; ++i)
-                       {
-                               //find the coordinate in the drawable space...
-                               Time t_orig = i->get_time();
-                               if(!t_orig.is_valid()) continue;
-                               Time t = t_orig - time_offset;
-                               if(t<adjustment->get_lower() || t>adjustment->get_upper()) continue;
-
-                               //if it found it... (might want to change comparison, and optimize
-                               //                                       sel_times.find to not produce an overall nlogn solution)
-
-                               bool selected=false;
-                               //not dragging... just draw as per normal
-                               //if move dragging draw offset
-                               //if copy dragging draw both...
-
-                               if(valselected && sel_times.find(t_orig) != sel_times.end())
-                               {
-                                       if(dragging) //skip if we're dragging because we'll render it later
-                                       {
-                                               if(mode & COPY_MASK) // draw both blue and red moved
-                                               {
-                                                       drawredafter.push_back(t + diff.round(cfps));
-                                                       gc->set_rgb_fg_color(Gdk::Color("#00EEEE"));
-                                               }else if(mode & DELETE_MASK) //it's just red...
-                                               {
-                                                       gc->set_rgb_fg_color(Gdk::Color("#EE0000"));
-                                                       selected=true;
-                                               }else //move - draw the red on top of the others...
-                                               {
-                                                       drawredafter.push_back(t + diff.round(cfps));
-                                                       continue;
-                                               }
-                                       }else
-                                       {
-                                               gc->set_rgb_fg_color(Gdk::Color("#EE0000"));
-                                               selected=true;
-                                       }
-                               }else
-                               {
-                                       gc->set_rgb_fg_color(Gdk::Color("#00EEEE"));
-                               }
-
-                               //synfig::info("Displaying time: %.3f s",(float)t);
-                               const int x = (int)((t-lower)*area.get_width()/(upper-lower));
-
-                               //should draw me a grey filled circle...
-                               Gdk::Rectangle area2(
-                                       area.get_x() - area.get_height()/2 + x + 1,
-                                       area.get_y() + 1,
-                                       area.get_height()-2,
-                                       area.get_height()-2
-                               );
-                               render_time_point_to_window(window,area2,*i - time_offset,selected);
-
-                               /*window->draw_arc(gc,true,
-                               area.get_x() + x - area.get_height()/4, area.get_y() + area.get_height()/8,
-                               area.get_height()/2, area.get_height()*3/4,
-                               0, 64*360);
-
-                               gc->set_rgb_fg_color(Gdk::Color("#000000"));
-                               window->draw_arc(gc,false,
-                               area.get_x() + x - area.get_height()/4, area.get_y() + area.get_height()/8,
-                               area.get_height()/2, area.get_height()*3/4,
-                               0, 64*360);
-                               */
-                       }
-
-                       {
-                               vector<Time>::iterator i = drawredafter.begin(), end = drawredafter.end();
-                               for(; i != end; ++i)
-                               {
-                                       //find the coordinate in the drawable space...
-                                       Time t = *i;
-
-                                       if(!t.is_valid())
-                                               continue;
-
-                                       //synfig::info("Displaying time: %.3f s",(float)t);
-                                       const int x = (int)((t-lower)*area.get_width()/(upper-lower));
-
-                                       //should draw me a grey filled circle...
-
-                                       Gdk::Rectangle area2(
-                                               area.get_x() - area.get_height()/2 + x + 1,
-                                               area.get_y() + 1,
-                                               area.get_height()-2,
-                                               area.get_height()-2
-                                       );
-                                       render_time_point_to_window(window,area2,*i,true);
-/*                                     gc->set_rgb_fg_color(Gdk::Color("#EE0000"));
-                                       window->draw_arc(gc,true,
-                                       area.get_x() + x - area.get_height()/4, area.get_y() + area.get_height()/8,
-                                       area.get_height()/2, area.get_height()*3/4,
-                                       0, 64*360);
-
-                                       gc->set_rgb_fg_color(Gdk::Color("#000000"));
-                                       window->draw_arc(gc,false,
-                                       area.get_x() + x - area.get_height()/4, area.get_y() + area.get_height()/8,
-                                       area.get_height()/2, area.get_height()*3/4,
-                                       0, 64*360);
-*/
-                               }
-                       }
-               }
-       }
-
-       /* THIS IS NOW HANDLED ENTIRELY BY THE TIMEPOINT SYSTEM
-       // This this is an animated value node, then render the waypoints
-       if(value_node)
-       {
-               //now render the actual waypoints
-               synfig::ValueNode_Animated::WaypointList::iterator iter;
-               for(
-                       iter=value_node->waypoint_list().begin();
-                       iter!=value_node->waypoint_list().end();
-                       iter++
-               )
-               {
-                       if(!iter->get_time().is_valid())
-                               continue;
-                       int x;
-                       bool selected=false;
-                       if(is_selected(*iter))
-                       {
-                               Time t(iter->get_time());
-
-
-                               if(dragging)
-                                       t=(t+selected_time-drag_time).round(get_canvas()->rend_desc().get_frame_rate());
-
-                               x=(int)((float)area.get_width()/(adjustment->get_upper()-adjustment->get_lower())*(t-adjustment->get_lower()));
-                               shadow=Gtk::SHADOW_IN;
-                               selected=true;
-                       }
-                       else
-                       {
-                               x=(int)((float)area.get_width()/(adjustment->get_upper()-adjustment->get_lower())*(iter->get_time()-adjustment->get_lower()));
-                               shadow=Gtk::SHADOW_OUT;
-                               selected=false;
-                       }
-
-
-                       widget.get_style()->paint_diamond(
-                               Glib::RefPtr<Gdk::Window>::cast_static(window),
-                               state,
-                               shadow,
-                               area,
-                               widget,
-                               "solid",
-                               area.get_x()+x-area.get_height()/4,
-                               area.get_y()+area.get_height()/4,
-                               area.get_height()/2,
-                               area.get_height()/2
-                       );
-               }
-       }
-       */
-               Gdk::Rectangle area(area_);
-       // If the parent of this value node is a dynamic list, then
-       // render the on and off times
-       if(parent_value_node)
-       {
-               const int index(property_value_desc().get_value().get_index());
-               const synfig::ValueNode_DynamicList::ListEntry& list_entry(parent_value_node->list[index]);
-               const synfig::ValueNode_DynamicList::ListEntry::ActivepointList& activepoint_list(list_entry.timing_info);
-               synfig::ValueNode_DynamicList::ListEntry::ActivepointList::const_iterator iter,next;
-
-               bool is_off(false);
-               if(!activepoint_list.empty())
-                       is_off=!activepoint_list.front().state;
-
-               int xstart(0);
-
-               int x=0,prevx=0;
-               for(next=activepoint_list.begin(),iter=next++;iter!=activepoint_list.end();iter=next++)
-               {
-                       x=((int)((float)area.get_width()/(adjustment->get_upper()-adjustment->get_lower())*(iter->time-adjustment->get_lower())));
-                       if(x<0)x=0;
-                       if(x>area.get_width())x=area.get_width();
-
-                       bool status_at_time=0;
-                       if(next!=activepoint_list.end())
-                       {
-                               status_at_time=!list_entry.status_at_time((iter->time+next->time)/2.0);
-                       }
-                       else
-                               status_at_time=!list_entry.status_at_time(Time::end());
-
-                       if(!is_off && status_at_time)
-                       {
-                               xstart=x;
-                               is_off=true;
-                       }
-                       else
-                       if(is_off && !status_at_time)
-                       {
-                               window->draw_rectangle(inactive_gc, true, area.get_x()+xstart, area.get_y(), x-xstart, area.get_height());
-                               is_off=false;
-                       }
-
-                       /*
-                       if(!is_off && iter!=activepoint_list.end() && next->state==false && iter->state==false)
-                       {
-                               xstart=x;
-                               is_off=true;
-                       }
-                       else if(is_off && next!=activepoint_list.end() && iter->state==false && next->state==true)
-                       {
-                               window->draw_rectangle(inactive_gc, true, area.get_x()+xstart, area.get_y(), x-xstart, area.get_height());
-                               is_off=false;
-                       }
-                       else if(is_off && iter!=activepoint_list.end() && iter->state==true)
-                       {
-                               window->draw_rectangle(inactive_gc, true, area.get_x()+xstart, area.get_y(), prevx-xstart, area.get_height());
-                               is_off=false;
-                       }
-                       */
-
-
-
-                       if(iter->time>=adjustment->get_lower() && iter->time<adjustment->get_upper())
-                       {
-                               int w(1);
-                               if(selected==*iter)
-                                       w=3;
-                               gc->set_rgb_fg_color(activepoint_color[iter->state]);
-                               window->draw_rectangle(gc, true, area.get_x()+x-w/2, area.get_y(), w, area.get_height());
-                       }
-                       prevx=x;
-               }
-               if(is_off)
-               {
-                       window->draw_rectangle(inactive_gc, true, area.get_x()+xstart, area.get_y(), area.get_width()-xstart, area.get_height());
-               }
-       }
-
-       // Render a line that defines the current tick in time
-       {
-               gc->set_rgb_fg_color(curr_time_color);
-
-               const int x((int)((float)area.get_width()/(adjustment->get_upper()-adjustment->get_lower())*(adjustment->get_value()-adjustment->get_lower())));
-
-               if(adjustment->get_value()>=adjustment->get_lower() && adjustment->get_value()<adjustment->get_upper())
-                       window->draw_rectangle(gc, true, area.get_x()+x, area.get_y(), 1, area.get_height());
-       }
-}
-
-synfig::ValueNode_Animated::WaypointList::iterator
-CellRenderer_TimeTrack::find_waypoint(const synfig::Time& /*t*/,const synfig::Time& scope)
-{
-       synfig::ValueNode_Animated *value_node=dynamic_cast<synfig::ValueNode_Animated*>(property_value_desc().get_value().get_value_node().get());
-
-    Time nearest(Time::end());
-
-       synfig::ValueNode_Animated::WaypointList::iterator iter,ret;
-
-       if(value_node)
-       {
-               for(
-                       iter=value_node->waypoint_list().begin();
-                       iter!=value_node->waypoint_list().end();
-                       iter++
-                       )
-               {
-                       Time val=abs(iter->get_time()-selected_time);
-                       if(val<nearest)
-                       {
-                               nearest=val;
-                               ret=iter;
-                       }
-               }
-
-               if(nearest!=Time::end() && nearest<scope)
-               {
-                       return ret;
-               }
-       }
-       throw int();
-}
-
-bool
-CellRenderer_TimeTrack::activate_vfunc(
-       GdkEvent* event,
-       Gtk::Widget& /*widget*/,
-       const Glib::ustring& treepath,
-       const Gdk::Rectangle& /*background_area*/,
-       const Gdk::Rectangle& cell_area,
-       Gtk::CellRendererState /*flags*/)
-{
-       path=treepath;
-       synfig::ValueNode_Animated::WaypointList::iterator iter;
-    Time nearest=1000000000;
-       Gtk::Adjustment *adjustment=get_adjustment();
-
-       // synfig::ValueNode_Animated *value_node=dynamic_cast<synfig::ValueNode_Animated*>(property_value_desc().get_value().get_value_node().get());
-
-       synfig::Canvas::Handle canvas(get_canvas());
-
-       synfig::ValueNode_DynamicList *parent_value_node(0);
-       if(property_value_desc().get_value().parent_is_value_node())
-               parent_value_node=dynamic_cast<synfig::ValueNode_DynamicList*>(property_value_desc().get_value().get_parent_value_node().get());
-
-       Time deltatime = 0;
-       Time curr_time;
-       switch(event->type)
-       {
-       case GDK_MOTION_NOTIFY:
-               curr_time=((float)event->motion.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();
-
-               mode = NONE;
-               {
-                       Gdk::ModifierType mod;
-                       Gdk::Event(event).get_state(mod);
-                       mode = mod;
-               }
-               break;
-       case GDK_BUTTON_PRESS:
-       case GDK_BUTTON_RELEASE:
-       default:
-               curr_time=((float)event->button.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();
-               {
-                       Gdk::ModifierType mod;
-                       Gdk::Event(event).get_state(mod);
-                       mode = mod;
-               }
-               break;
-       }
-       actual_time = curr_time;
-       if(canvas)
-               curr_time=curr_time.round(canvas->rend_desc().get_frame_rate());
-       selected_time=curr_time;
-
-    Time pixel_width((adjustment->get_upper()-adjustment->get_lower())/cell_area.get_width());
-
-    switch(event->type)
-    {
-       case GDK_BUTTON_PRESS:
-               //selected_time=((float)event->button.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();
-
-               //Deal with time point selection, but only if they aren't involved in the insanity...
-               if(/*!value_node && */event->button.button == 1)
-               {
-                       Time stime;
-
-                       /*!     UI specification:
-
-                               When nothing is selected, clicking on a point in either normal mode or
-                                       additive mode will select the time point closest to the click.
-                                       Subtractive click will do nothing
-
-                               When things are already selected, clicking on a selected point does
-                                       nothing (in both normal and add mode).  Add mode clicking on an unselected
-                                       point adds it to the set.  Normal clicking on an unselected point will
-                                       select only that one time point.  Subtractive clicking on any point
-                                       will remove it from the the set if it is included.
-                       */
-
-                       synfigapp::ValueDesc valdesc = property_value_desc().get_value();
-                       const Node::time_set *tset = get_times_from_vdesc(valdesc);
-                       const synfig::Time time_offset = get_time_offset_from_vdesc(valdesc);
-
-                       bool clickfound = tset && get_closest_time(*tset,actual_time+time_offset,pixel_width*cell_area.get_height(),stime);
-                       bool selectmode = mode & SELECT_MASK;
-
-                       //NOTE LATER ON WE SHOULD MAKE IT SO MULTIPLE VALUENODES CAN BE SELECTED AT ONCE
-                       //we want to jump to the value desc if we're not currently on it
-                       //      but only if we want to add the point
-                       if(clickfound && !(sel_value == valdesc))
-                       {
-                               sel_value = valdesc;
-                               sel_times.clear();
-                       }
-
-                       //now that we've made sure we're selecting the correct value, deal with the already selected points
-                       set<Time>::iterator foundi = clickfound ? sel_times.find(stime) : sel_times.end();
-                       bool found = foundi != sel_times.end();
-
-                       //remove all other points from our list... (only select the one we need)
-                       if(!selectmode && !found)
-                       {
-                               sel_times.clear();
-                       }
-
-                       if(found && selectmode) //remove a single already selected point
-                       {
-                               sel_times.erase(foundi);
-                       }else if(clickfound) //otherwise look at adding it
-                       {
-                               //for replace the list was cleared earlier, and for add it wasn't so it works
-                               sel_times.insert(stime);
-                       }
-               }
-
-               selection=false;
-               try
-               {
-                       iter=find_waypoint(selected_time,pixel_width*cell_area.get_height()/2);
-                       selected_waypoint=iter;
-                       selected=*iter;
-
-                       selection=true;
-               }
-               catch(int)
-               {
-                       selection=false;
-                       selected=synfig::UniqueID::nil();
-               }
-
-               if((!sel_times.empty() || selection) && event->button.button==1)
-               {
-                       dragging=true;
-                       drag_time=selected_time;
-                       actual_dragtime=actual_time;
-               }
-               //selected_time=iter->time;
-
-               /*
-               // Activepoint Selection
-               if(parent_value_node)
-               {
-                       const int index(property_value_desc().get_value().get_index());
-                       const synfig::ValueNode_DynamicList::ListEntry::ActivepointList& activepoint_list(parent_value_node->list[index].timing_info);
-                       synfig::ValueNode_DynamicList::ListEntry::ActivepointList::const_iterator iter;
-
-                       for(iter=activepoint_list.begin();iter!=activepoint_list.end();++iter)
-                       {
-                               Time val=abs(iter->time-selected_time);
-                               if(val<nearest)
-                               {
-                                       nearest=val;
-                                       selected=*iter;
-                                       selection=true;
-                               }
-                       }
-                       // Perhaps I should signal if we selected this activepoint?
-               }*/
-
-                       if(event->button.button==3)
-                       {
-                               Time stime;
-                               synfigapp::ValueDesc valdesc = property_value_desc().get_value();
-                               const Node::time_set *tset = get_times_from_vdesc(valdesc);
-                               synfig::Time time_offset = get_time_offset_from_vdesc(valdesc);
-
-                               bool clickfound = tset && get_closest_time(*tset,actual_time+time_offset,pixel_width*cell_area.get_height(),stime);
-
-                               etl::handle<synfig::Node> node;
-                               if(!getenv("SYNFIG_SHOW_CANVAS_PARAM_WAYPOINTS") &&
-                                  valdesc.get_value(stime).get_type()==ValueBase::TYPE_CANVAS)
-                               {
-                                       node=Canvas::Handle(valdesc.get_value(stime).get(Canvas::Handle()));
-                               }
-                               else //if(valdesc.is_value_node())
-                               {
-                                       node=valdesc.get_value_node();
-                               }
-
-                               if(clickfound && node)
-                                       signal_waypoint_clicked_cellrenderer()(node, stime, time_offset, 2);
-                       }
-
-               break;
-       case GDK_MOTION_NOTIFY:
-               //if(selection && dragging)
-               //      selected_time=((float)event->motion.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();
-               return true;
-
-               break;
-       case GDK_BUTTON_RELEASE:
-               {
-                       //selected_time=((float)event->button.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();
-                       dragging=false;
-
-                       /*if(event->button.button==3 && selection)
-                       {
-                               signal_waypoint_clicked_cellrenderer()(path,*selected_waypoint,event->button.button-1);
-                               return true;
-                       }
-                       */
-
-                       //Time point stuff...
-                       if(event->button.button == 1)
-                       {
-                               bool delmode = (mode & DELETE_MASK) && !(mode & COPY_MASK);
-                               deltatime = actual_time - actual_dragtime;
-                               if(sel_times.size() != 0 && (delmode || !deltatime.is_equal(Time(0))))
-                               {
-                                       synfigapp::Action::ParamList param_list;
-                                       param_list.add("canvas",canvas_interface()->get_canvas());
-                                       param_list.add("canvas_interface",canvas_interface());
-
-                                       if(!getenv("SYNFIG_SHOW_CANVAS_PARAM_WAYPOINTS") &&
-                                          sel_value.get_value_type() == synfig::ValueBase::TYPE_CANVAS)
-                                       {
-                                               param_list.add("addcanvas",sel_value.get_value().get(Canvas::Handle()));
-                                       }else
-                                       {
-                                               param_list.add("addvaluedesc",sel_value);
-                                       }
-
-                                       set<Time>       newset;
-                                       std::set<synfig::Time>::iterator i = sel_times.begin(), end = sel_times.end();
-                                       for(; i != end; ++i)
-                                       {
-                                               param_list.add("addtime",*i);
-
-                                               newset.insert((*i + deltatime).round(get_canvas()->rend_desc().get_frame_rate()));
-                                       }
-
-                                       if(!delmode)
-                                               param_list.add("deltatime",deltatime);
-                               //      param_list.add("time",canvas_interface()->get_time());
-
-                                       if(mode & COPY_MASK) //copy
-                                       {
-                                               etl::handle<studio::Instance>::cast_static(canvas_interface()->get_instance())
-                                                       ->process_action("TimepointsCopy", param_list);
-                                       }else if(delmode) //DELETE
-                                       {
-                                               etl::handle<studio::Instance>::cast_static(canvas_interface()->get_instance())
-                                                       ->process_action("TimepointsDelete", param_list);
-                                       }else //MOVE
-                                       {
-                                               etl::handle<studio::Instance>::cast_static(canvas_interface()->get_instance())
-                                                       ->process_action("TimepointsMove", param_list);
-                                       }
-
-                                       //now replace all the selected with the new selected
-                                       sel_times = newset;
-                               }
-                       }
-
-
-
-                       /*if(value_node && selection)
-                       {
-                               if(selected_time==drag_time && event->button.button!=3)
-                                       signal_waypoint_clicked_cellrenderer()(path,*selected_waypoint,event->button.button-1);
-                               else
-                               if(event->button.button==1)
-                               {
-                                       synfig::Waypoint waypoint(*selected_waypoint);
-                                       Time newtime((waypoint.get_time()+(selected_time-drag_time)).round(canvas->rend_desc().get_frame_rate()));
-                                       if(waypoint.get_time()!=newtime)
-                                       {
-                                               waypoint.set_time(newtime);
-                                               signal_waypoint_changed_(waypoint,value_node);
-                                       }
-                               }
-                       }*/
-
-                       //if(selection)
-                       //      selected_time=iter->time;
-                       //selected_time=iter->get_time();
-                       return true;
-               }
-       default:
-               //std::cerr<<"unknown event type "<<event->type<<std::endl;
-               return false;
-               break;
-       }
-
-
-
-       return false;
-}
-
-
-
-// The following three functions don't get documented correctly by
-// doxygen 1.5.[23] because of a bug with any function whose name
-// begins with 'property'.  Fixed in doxygen 1.5.4 apparently.  See
-// http://bugzilla.gnome.org/show_bug.cgi?id=471185 .
-Glib::PropertyProxy<synfigapp::ValueDesc>
-CellRenderer_TimeTrack::property_value_desc()
-{
-       return Glib::PropertyProxy<synfigapp::ValueDesc>(this,"value_desc");
-}
-
-Glib::PropertyProxy<synfig::Canvas::Handle>
-CellRenderer_TimeTrack::property_canvas()
-{
-       return Glib::PropertyProxy<synfig::Canvas::Handle>(this,"canvas");
-}
-
-Glib::PropertyProxy<Gtk::Adjustment* >
-CellRenderer_TimeTrack::property_adjustment()
-{
-       return Glib::PropertyProxy<Gtk::Adjustment* >(this,"adjustment");
-}
-
-void
-CellRenderer_TimeTrack::set_canvas_interface(etl::loose_handle<synfigapp::CanvasInterface>     h)
-{
-       canvas_interface_ = h;
-}
diff --git a/synfig-studio/src/gtkmm/cellrenderer_timetrack.h b/synfig-studio/src/gtkmm/cellrenderer_timetrack.h
deleted file mode 100644 (file)
index 519ac8d..0000000
+++ /dev/null
@@ -1,207 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file cellrenderer_timetrack.h
-**     \brief Template Header
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 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
-*/
-/* ========================================================================= */
-
-/* === S T A R T =========================================================== */
-
-#ifndef __SYNFIG_GTKMM_CELLRENDERER_TIMETRACK_H
-#define __SYNFIG_GTKMM_CELLRENDERER_TIMETRACK_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtk/gtk.h>
-#include <gtkmm/ruler.h>
-#include <gtkmm/arrow.h>
-#include <gtkmm/image.h>
-#include <gdkmm/pixbufloader.h>
-#include <gtkmm/viewport.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/scrolledwindow.h>
-#include <gtkmm/table.h>
-#include <gtkmm/statusbar.h>
-#include <gtkmm/button.h>
-#include <gtkmm/progressbar.h>
-#include <gtkmm/paned.h>
-#include <gtkmm/treeview.h>
-#include <gtkmm/treestore.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/box.h>
-#include <gtkmm/scrollbar.h>
-#include <gtkmm/cellrenderer.h>
-
-#include <gtkmm/dialog.h>
-#include <gtkmm/menu.h>
-
-
-#include <synfigapp/canvasinterface.h>
-#include <synfigapp/value_desc.h>
-#include <synfig/valuenode_animated.h>
-#include <synfig/valuenode_dynamiclist.h>
-#include <synfig/string.h>
-#include <synfig/time.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 Widget_ValueBase;
-
-/*! \class CellRenderer_TimeTrack
-**     \brief A cell renderer that displays the waypoints for Animated ValueNodes.
-*/
-class CellRenderer_TimeTrack :
-       public Gtk::CellRenderer
-{
-
-       /*
- --    ** -- P R I V A T E   D A T A ---------------------------------------------
-       */
-
-private:
-       //! Time adjustment window
-       Gtk::Adjustment adjustment_;
-
-       //! Signal for when the user clicks on a waypoint
-       sigc::signal<void, const etl::handle<synfig::Node>&, const synfig::Time&, const synfig::Time&, int> signal_waypoint_clicked_cellrenderer_;
-
-       sigc::signal<void, synfig::Waypoint, synfig::ValueNode::Handle> signal_waypoint_changed_;
-
-       //! Iterator for selected waypoint. (Should this be an UniqueID instead?)
-       synfig::ValueNode_Animated::WaypointList::iterator selected_waypoint;
-
-       synfig::UniqueID selected;
-
-       //! selected information for time... (will work for way points etc...)
-       //TODO: make multiple... on both time and value select...
-       std::set<synfig::Time>  sel_times;
-       synfigapp::ValueDesc            sel_value;
-       synfig::Time                            actual_time;
-       synfig::Time                            actual_dragtime;
-       int                                             mode;
-
-       //! ???
-       synfig::Time selected_time;
-
-       //! The path to the current item in the tree model
-       Glib::ustring path;
-
-       //! ???
-       bool selection;
-
-       bool dragging;
-
-       synfig::Time drag_time;
-
-       etl::loose_handle<synfigapp::CanvasInterface>   canvas_interface_;
-
-       /*
- --    ** -- P R O P E R T I E S -------------------------------------------------
-       */
-
-private:
-
-       //! ValueBase Desc
-       Glib::Property<synfigapp::ValueDesc> property_valuedesc_;
-
-       //! Canvas
-       Glib::Property<synfig::Canvas::Handle> property_canvas_;
-
-       //! ??? \see adjustment_
-       Glib::Property<Gtk::Adjustment* > property_adjustment_;
-
-       //! \writeme
-       Glib::Property<bool> property_enable_timing_info_;
-
-       /*
- --    ** -- P R O P E R T Y   I N T E R F A C E S -------------------------------
-       */
-
-public:
-
-       Glib::PropertyProxy<synfigapp::ValueDesc> property_value_desc();
-
-       Glib::PropertyProxy<synfig::Canvas::Handle> property_canvas();
-
-       Glib::PropertyProxy<Gtk::Adjustment* > property_adjustment();
-
-       /*
- --    ** -- S I G N A L   I N T E R F A C E S -----------------------------------
-       */
-
-public:
-
-       sigc::signal<void, const etl::handle<synfig::Node>&, const synfig::Time&, const synfig::Time&, int> &signal_waypoint_clicked_cellrenderer()
-       {return signal_waypoint_clicked_cellrenderer_; }
-
-       sigc::signal<void, synfig::Waypoint, synfig::ValueNode::Handle> &signal_waypoint_changed()
-       {return signal_waypoint_changed_; }
-
-       /*
- --    ** -- P U B L I C   M E T H O D S -----------------------------------------
-       */
-
-public:
-
-       CellRenderer_TimeTrack();
-    ~CellRenderer_TimeTrack();
-
-       void set_adjustment(Gtk::Adjustment &x);
-       Gtk::Adjustment *get_adjustment();
-       const Gtk::Adjustment *get_adjustment()const;
-
-       etl::loose_handle<synfigapp::CanvasInterface>   canvas_interface()const {return canvas_interface_;}
-       void set_canvas_interface(etl::loose_handle<synfigapp::CanvasInterface> h); //this should only be called by smart people
-
-       synfig::Canvas::Handle get_canvas()const;
-
-       bool is_selected(const synfig::Waypoint& waypoint)const;
-
-       synfig::ValueNode_Animated::WaypointList::iterator find_waypoint(const synfig::Time& t, const synfig::Time& scope=synfig::Time::end());
-
-       virtual void
-       render_vfunc(
-               const Glib::RefPtr<Gdk::Drawable>& window,
-               Gtk::Widget& widget,
-               const Gdk::Rectangle& background_area,
-               const Gdk::Rectangle& ca,
-               const Gdk::Rectangle& expose_area,
-               Gtk::CellRendererState flags);
-
-       virtual bool
-       activate_vfunc( GdkEvent* event,
-                                       Gtk::Widget& widget,
-                                       const Glib::ustring& path,
-                                       const Gdk::Rectangle& background_area,
-                                       const Gdk::Rectangle& cell_area,
-                                       Gtk::CellRendererState flags);
-
-}; // END of class CellRenderer_TimeTrack
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/cellrenderer_value.cpp b/synfig-studio/src/gtkmm/cellrenderer_value.cpp
deleted file mode 100644 (file)
index f0403fd..0000000
+++ /dev/null
@@ -1,604 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file cellrenderer_value.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 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 <config.h>
-#endif
-
-#include <gtkmm/label.h>
-#include <ETL/stringf>
-#include <gtkmm/celleditable.h>
-#include <gtkmm/editable.h>
-#include <gtkmm/entry.h>
-#include <gtkmm/eventbox.h>
-#include <gtk/gtkentry.h> /* see XXX below */
-
-#include "app.h"
-#include "widget_value.h"
-#include "widget_vector.h"
-#include "widget_filename.h"
-#include "widget_enum.h"
-#include "widget_color.h"
-#include "widget_canvaschooser.h"
-#include "widget_time.h"
-
-#include "cellrenderer_gradient.h"
-#include "cellrenderer_value.h"
-
-#include "widget_gradient.h"
-#include "dialog_gradient.h"
-#include "dialog_color.h"
-#include <gtkmm/textview.h>
-
-#include "general.h"
-
-#endif
-
-using namespace synfig;
-using namespace etl;
-using namespace std;
-using namespace studio;
-
-/* === M A C R O S ========================================================= */
-
-#define DIGITS         15
-
-/* === G L O B A L S ======================================================= */
-
-class studio::ValueBase_Entry : public Gtk::EventBox, public Gtk::CellEditable
-{
-       Glib::ustring path;
-       Widget_ValueBase *valuewidget;
-       bool edit_done_called;
-       Gtk::Widget *parent;
-public:
-       ValueBase_Entry():
-               Glib::ObjectBase  (typeid(ValueBase_Entry)),
-               Gtk::EventBox     (),
-               Gtk::CellEditable ()
-       {
-               parent=0;
-               edit_done_called=false;
-/*
-                 Gtk::HBox *const hbox = new Gtk::HBox(false, 0);
-                 add(*Gtk::manage(hbox));
-
-                 Gtk::Entry *entry_ = new Gtk::Entry();
-                       entry_->set_text("bleh");
-                 hbox->pack_start(*Gtk::manage(entry_), Gtk::PACK_EXPAND_WIDGET);
-                 entry_->set_has_frame(false);
-                 entry_->gobj()->is_cell_renderer = true; // XXX
-
-*/
-               valuewidget=manage(new class Widget_ValueBase());
-               valuewidget->inside_cellrenderer();
-               add(*valuewidget);
-               valuewidget->show();
-
-               //set_flags(Gtk::CAN_FOCUS);
-               //set_events(Gdk::KEY_PRESS_MASK | Gdk::KEY_RELEASE_MASK);
-
-               /*
-               set_events(//(Gdk::ALL_EVENTS_MASK)
-               ~(      Gdk::EXPOSURE_MASK
-                       | Gdk::ENTER_NOTIFY_MASK
-                       | Gdk::LEAVE_NOTIFY_MASK
-                       | Gdk::FOCUS_CHANGE_MASK
-                       | Gdk::STRUCTURE_MASK
-                       | Gdk::PROPERTY_CHANGE_MASK
-                       | Gdk::VISIBILITY_NOTIFY_MASK
-                       | Gdk::PROXIMITY_IN_MASK
-                       | Gdk::PROXIMITY_OUT_MASK
-                       | Gdk::SUBSTRUCTURE_MASK
-               )
-               );
-               */
-               //signal_editing_done().connect(sigc::mem_fun(*this, &studio::ValueBase_Entry::hide));
-               //signal_remove_widget().connect(sigc::mem_fun(*this, &studio::ValueBase_Entry::hide));
-
-               show_all_children();
-
-               //signal_show().connect(sigc::mem_fun(*this, &ValueBase_Entry::grab_focus));
-       }
-       ~ValueBase_Entry()
-       {
-       }
-
-       void on_editing_done()
-       {
-               hide();
-               if(parent)parent->grab_focus();
-               if(!edit_done_called)
-               {
-                       edit_done_called=true;
-                       Gtk::CellEditable::on_editing_done();
-               }
-               else
-               {
-                       synfig::error("on_editing_done(): Called twice!");
-               }
-       }
-       void set_parent(Gtk::Widget*x) { parent=x; }
-       void on_remove_widget()
-       {
-               hide();
-               edit_done_called=true;
-               if(parent)parent->grab_focus();
-               Gtk::CellEditable::on_remove_widget();
-       }
-       void start_editing_vfunc(GdkEvent */*event*/)
-       {
-               valuewidget->signal_activate().connect(sigc::mem_fun(*this, &studio::ValueBase_Entry::editing_done));
-               show();
-               //valuewidget->grab_focus();
-               //get_window()->set_focus(*valuewidget);
-       }
-       bool on_event(GdkEvent *event)
-       {
-               if(event->any.type==GDK_BUTTON_PRESS ||
-                       event->any.type==GDK_2BUTTON_PRESS ||
-                       event->any.type==GDK_KEY_PRESS ||
-                       event->any.type==GDK_KEY_RELEASE ||
-                       event->any.type==GDK_SCROLL ||
-                       event->any.type==GDK_3BUTTON_PRESS)
-                       return true;
-               return Gtk::EventBox::on_event(event);
-       }
-       void on_grab_focus()
-       {
-               Gtk::EventBox::on_grab_focus();
-               if(valuewidget)
-                       valuewidget->grab_focus();
-       }
-       void set_path(const Glib::ustring &p)
-       {
-               path=p;
-       }
-       void set_value(const synfig::ValueBase &data)
-       {
-               if(valuewidget)
-                       valuewidget->set_value(data);
-               //valuewidget->grab_focus();
-       }
-       void set_canvas(const etl::handle<synfig::Canvas> &data)
-       {
-               assert(data);
-               if(valuewidget)
-                       valuewidget->set_canvas(data);
-       }
-       void set_param_desc(const synfig::ParamDesc &data)
-       {
-               if(valuewidget)
-                       valuewidget->set_param_desc(data);
-       }
-
-       const synfig::ValueBase &get_value()
-       {
-               if(valuewidget)
-                       return valuewidget->get_value();
-
-               warning("%s:%d this code shouldn't be reached", __FILE__, __LINE__);
-               return *(new synfig::ValueBase());
-       }
-
-       const Glib::ustring &get_path()
-       {
-               return path;
-       }
-
-};
-
-/* === P R O C E D U R E S ================================================= */
-
-bool get_paragraph(synfig::String& text)
-{
-       Gtk::Dialog dialog(
-               _("Paragraph"),         // Title
-               true,           // Modal
-               true            // use_separator
-       );
-       Gtk::Label label(_("Enter Paragraph Text Here:"));
-       label.show();
-       dialog.get_vbox()->pack_start(label);
-
-
-       Glib::RefPtr<Gtk::TextBuffer> text_buffer(Gtk::TextBuffer::create());
-       text_buffer->set_text(text);
-
-       Gtk::TextView text_view(text_buffer);
-       text_view.show();
-       dialog.get_vbox()->pack_start(text_view);
-
-/*
-       Gtk::Entry entry;
-       entry.set_text(text);
-       entry.show();
-       entry.set_activates_default(true);
-       dialog.get_vbox()->pack_start(entry);
-*/
-
-       dialog.add_button(Gtk::StockID("gtk-ok"),Gtk::RESPONSE_OK);
-       dialog.add_button(Gtk::StockID("gtk-cancel"),Gtk::RESPONSE_CANCEL);
-       dialog.set_default_response(Gtk::RESPONSE_OK);
-
-       //text_entry.signal_activate().connect(sigc::bind(sigc::mem_fun(dialog,&Gtk::Dialog::response),Gtk::RESPONSE_OK));
-
-       dialog.show();
-
-       if(dialog.run()!=Gtk::RESPONSE_OK)
-               return false;
-
-       text=text_buffer->get_text();
-
-       return true;
-}
-
-/* === M E T H O D S ======================================================= */
-
-CellRenderer_ValueBase::CellRenderer_ValueBase():
-       Glib::ObjectBase        (typeid(CellRenderer_ValueBase)),
-       Gtk::CellRendererText   (),
-       property_value_ (*this,"value",synfig::ValueBase()),
-       property_canvas_(*this,"canvas",etl::handle<synfig::Canvas>()),
-       property_param_desc_(*this,"param_desc",synfig::ParamDesc())
-{
-       CellRendererText::signal_edited().connect(sigc::mem_fun(*this,&CellRenderer_ValueBase::string_edited_));
-       value_entry=new ValueBase_Entry();
-       value_entry->hide();
-
-       Pango::AttrList attr_list;
-       {
-               Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*8));
-               pango_size.set_start_index(0);
-               pango_size.set_end_index(64);
-               attr_list.change(pango_size);
-       }
-       property_attributes()=attr_list;
-
-       property_foreground()=Glib::ustring("#7f7f7f");
-       property_inconsistent()=false;
-}
-
-CellRenderer_ValueBase::~CellRenderer_ValueBase()
-{
-       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
-               synfig::info("CellRenderer_ValueBase::~CellRenderer_ValueBase(): Deleted");
-}
-
-void
-CellRenderer_ValueBase::string_edited_(const Glib::ustring&path,const Glib::ustring&str)
-{
-       ValueBase old_value=property_value_.get_value();
-       ValueBase value;
-
-       if(old_value.get_type()==ValueBase::TYPE_TIME)
-       {
-               value=ValueBase(Time((String)str,get_canvas()->rend_desc().get_frame_rate()));
-       }
-       else
-               value=ValueBase((String)str);
-
-       if(old_value!=value)
-               signal_edited_(path,value);
-}
-
-void
-CellRenderer_ValueBase::render_vfunc(
-               const Glib::RefPtr<Gdk::Drawable>& window,
-               Gtk::Widget& widget,
-               const Gdk::Rectangle& background_area,
-               const Gdk::Rectangle& ca,
-               const Gdk::Rectangle& expose_area,
-               Gtk::CellRendererState flags)
-{
-       if(!window)
-               return;
-//     const unsigned int cell_xpad = property_xpad();
-//     const unsigned int cell_ypad = property_ypad();
-
-       //int x_offset = 0, y_offset = 0;
-//     int     width = ca.get_width();
-       int     height = ca.get_height();
-//     get_size(widget, ca, x_offset, y_offset, width, height);
-
-//     width  -= cell_xpad * 2;
-//     height -= cell_ypad * 2;
-
-//     if(width <= 0 || height <= 0)
-//             return;
-
-       Gtk::StateType state = Gtk::STATE_INSENSITIVE;
-       if(property_editable())
-               state = Gtk::STATE_NORMAL;
-       if((flags & Gtk::CELL_RENDERER_SELECTED) != 0)
-               state = (widget.has_focus()) ? Gtk::STATE_SELECTED : Gtk::STATE_ACTIVE;
-
-       ValueBase data=property_value_.get_value();
-
-       switch(data.get_type())
-       {
-       case ValueBase::TYPE_REAL:
-               if(((synfig::ParamDesc)property_param_desc_).get_is_distance())
-               {
-                       Distance x(data.get(Real()),Distance::SYSTEM_UNITS);
-                       x.convert(App::distance_system,get_canvas()->rend_desc());
-                       property_text()=(Glib::ustring)x.get_string(6).c_str();
-               }
-               else
-                       property_text()=(Glib::ustring)strprintf("%.6f",data.get(Real()));
-               break;
-       case ValueBase::TYPE_TIME:
-               property_text()=(Glib::ustring)data.get(Time()).get_string(get_canvas()->rend_desc().get_frame_rate(),App::get_time_format());
-               break;
-       case ValueBase::TYPE_ANGLE:
-               property_text()=(Glib::ustring)strprintf("%.2f DEG",(Real)Angle::deg(data.get(Angle())).get());
-               break;
-       case ValueBase::TYPE_INTEGER:
-               if(((synfig::ParamDesc)property_param_desc_).get_hint()!="enum")
-               {
-                       property_text()=(Glib::ustring)strprintf("%i",data.get(int()));
-               }
-               else
-               {
-                       property_text()=(Glib::ustring)strprintf("(%i)",data.get(int()));
-                       std::list<synfig::ParamDesc::EnumData> enum_list=((synfig::ParamDesc)property_param_desc_).get_enum_list();
-                       std::list<synfig::ParamDesc::EnumData>::iterator iter;
-
-                       for(iter=enum_list.begin();iter!=enum_list.end();iter++)
-                               if(iter->value==data.get(int()))
-                               {
-                                       // don't show the key_board s_hortcut under_scores
-                                       String local_name = iter->local_name;
-                                       String::size_type pos = local_name.find_first_of('_');
-                                       if (pos != String::npos)
-                                               property_text() = local_name.substr(0,pos) + local_name.substr(pos+1);
-                                       else
-                                               property_text() = local_name;
-                                       break;
-                               }
-               }
-
-               break;
-       case ValueBase::TYPE_VECTOR:
-               {
-                       Vector vector=data.get(Vector());
-                       Distance x(vector[0],Distance::SYSTEM_UNITS),y(vector[1],Distance::SYSTEM_UNITS);
-                       x.convert(App::distance_system,get_canvas()->rend_desc());
-                       y.convert(App::distance_system,get_canvas()->rend_desc());
-                       property_text()=static_cast<Glib::ustring>(strprintf("%s,%s",x.get_string(6).c_str(),y.get_string(6).c_str()));
-               }
-               break;
-
-       case ValueBase::TYPE_STRING:
-
-               if(data.get_type()==ValueBase::TYPE_STRING)
-               {
-                       if(!data.get(synfig::String()).empty())
-                               property_text()=static_cast<Glib::ustring>(data.get(synfig::String()));
-                       else
-                               property_text()=Glib::ustring("<empty>");
-               }
-               break;
-       case ValueBase::TYPE_CANVAS:
-               if(data.get(etl::handle<synfig::Canvas>()))
-               {
-                       if(data.get(etl::handle<synfig::Canvas>())->is_inline())
-                               property_text()=_("<Inline Canvas>");
-                       else
-                               property_text()=(Glib::ustring)data.get(etl::handle<synfig::Canvas>())->get_id();
-               }
-               else
-                       property_text()="<No Image Selected>";
-               break;
-       case ValueBase::TYPE_COLOR:
-               {
-                       render_color_to_window(window,ca,data.get(Color()));
-                       return;
-               }
-               break;
-       case ValueBase::TYPE_BOOL:
-               {
-                       widget.get_style()->paint_check(
-                               Glib::RefPtr<Gdk::Window>::cast_static(window), state,
-                               data.get(bool())?Gtk::SHADOW_IN:Gtk::SHADOW_OUT,
-                               ca, widget, "cellcheck",
-                               ca.get_x()/* + x_offset + cell_xpad*/,
-                               ca.get_y()/* + y_offset + cell_ypad*/,
-                               height-1,height-1);
-                       return;
-               }
-               break;
-       case ValueBase::TYPE_NIL:
-               //property_text()=(Glib::ustring)" ";
-               return;
-               break;
-       case ValueBase::TYPE_SEGMENT:
-               property_text()=(Glib::ustring)_("Segment");
-               break;
-       case ValueBase::TYPE_GRADIENT:
-               render_gradient_to_window(window,ca,data.get(Gradient()));
-               return;
-               break;
-       case ValueBase::TYPE_LIST:
-               property_text()=(Glib::ustring)_("List");
-               break;
-       case ValueBase::TYPE_BLINEPOINT:
-               property_text()=(Glib::ustring)_("BLine Point");
-               break;
-       default:
-               property_text()=static_cast<Glib::ustring>(_("UNKNOWN"));
-               break;
-       }
-       CellRendererText::render_vfunc(window,widget,background_area,ca,expose_area,flags);
-}
-
-
-/*
-bool
-CellRenderer_ValueBase::activate_vfunc(        GdkEvent* event,
-       Gtk::Widget& widget,
-       const Glib::ustring& path,
-       const Gdk::Rectangle& background_area,
-       const Gdk::Rectangle& cell_area,
-       Gtk::CellRendererState flags)
-{
-       ValueBase data=(ValueBase)property_value_.get_value();
-
-       switch(data.type)
-       {
-       case ValueBase::TYPE_BOOL:
-               if(property_editable())
-                       signal_edited_(path,ValueBase(!data.get(bool())));
-       return true;
-       case ValueBase::TYPE_STRING:
-               return CellRendererText::activate_vfunc(event,widget,path,background_area,cell_area,flags);
-       }
-       return false;
-}
-*/
-
-void
-CellRenderer_ValueBase::gradient_edited(synfig::Gradient gradient, Glib::ustring path)
-{
-       ValueBase old_value(property_value_.get_value());
-       ValueBase value(gradient);
-       if(old_value!=value)
-               signal_edited_(path,value);
-}
-
-void
-CellRenderer_ValueBase::color_edited(synfig::Color color, Glib::ustring path)
-{
-       ValueBase old_value(property_value_.get_value());
-       ValueBase value(color);
-       if(old_value!=value)
-               signal_edited_(path,value);
-}
-
-Gtk::CellEditable*
-CellRenderer_ValueBase::start_editing_vfunc(
-       GdkEvent* event __attribute__ ((unused)),
-       Gtk::Widget& widget,
-       const Glib::ustring& path,
-       const Gdk::Rectangle& background_area __attribute__ ((unused)),
-       const Gdk::Rectangle& cell_area __attribute__ ((unused)),
-       Gtk::CellRendererState flags __attribute__ ((unused)))
-{
-       edit_value_done_called = false;
-       // If we aren't editable, then there is nothing to do
-       if(!property_editable())
-               return 0;
-
-       ValueBase data=property_value_.get_value();
-
-       switch(data.get_type())
-       {
-       case ValueBase::TYPE_BOOL:
-               signal_edited_(path,ValueBase(!data.get(bool())));
-       return NULL;
-       //case ValueBase::TYPE_TIME:
-       //      property_text()=(Glib::ustring)data.get(Time()).get_string(get_canvas()->rend_desc().get_frame_rate(),App::get_time_format()|Time::FORMAT_FULL);
-       //      return CellRendererText::start_editing_vfunc(event,widget,path,background_area,cell_area,flags);
-
-       case ValueBase::TYPE_GRADIENT:
-               App::dialog_gradient->reset();
-               App::dialog_gradient->set_gradient(data.get(Gradient()));
-               App::dialog_gradient->signal_edited().connect(
-                       sigc::bind(
-                               sigc::mem_fun(*this,&studio::CellRenderer_ValueBase::gradient_edited),
-                               path
-                       )
-               );
-               App::dialog_gradient->set_default_button_set_sensitive(true);
-               App::dialog_gradient->present();
-
-               return NULL;
-
-       case ValueBase::TYPE_COLOR:
-               App::dialog_color->reset();
-               App::dialog_color->set_color(data.get(Color()));
-               App::dialog_color->signal_edited().connect(
-                       sigc::bind(
-                               sigc::mem_fun(*this,&studio::CellRenderer_ValueBase::color_edited),
-                               path
-                       )
-               );
-               App::dialog_color->present();
-
-               return NULL;
-       case ValueBase::TYPE_STRING:
-               if(get_param_desc().get_hint()=="paragraph")
-               {
-                       synfig::String string;
-                       string=data.get(string);
-                       if(get_paragraph(string))
-                               signal_edited_(path,ValueBase(string));
-                       return NULL;
-               }
-               // if(get_param_desc().get_hint()!="filename")
-                       // return CellRendererText::start_editing_vfunc(event,widget,path,background_area,cell_area,flags);
-       default:
-               {
-                       assert(get_canvas());
-                       //delete value_entry;
-                       value_entry=manage(new ValueBase_Entry());
-                       value_entry->set_path(path);
-                       value_entry->set_canvas(get_canvas());
-                       value_entry->set_param_desc(get_param_desc());
-                       value_entry->set_value(data);
-                       value_entry->set_parent(&widget);
-                       value_entry->signal_editing_done().connect(sigc::mem_fun(*this, &CellRenderer_ValueBase::on_value_editing_done));
-                       return value_entry;
-               }
-       }
-       return NULL;
-}
-
-void
-CellRenderer_ValueBase::on_value_editing_done()
-{
-       if (edit_value_done_called)
-       {
-               synfig::error("on_value_editing_done(): Called twice!");
-               return;
-       }
-
-       edit_value_done_called = true;
-
-       if(value_entry)
-       {
-               ValueBase old_value(property_value_.get_value());
-               ValueBase value(value_entry->get_value());
-
-               if(old_value!=value)
-                       signal_edited_(value_entry->get_path(),value);
-
-               //delete value_entry;
-               //value_entry=0;
-       }
-}
diff --git a/synfig-studio/src/gtkmm/cellrenderer_value.h b/synfig-studio/src/gtkmm/cellrenderer_value.h
deleted file mode 100644 (file)
index 14a425d..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file cellrenderer_value.h
-**     \brief Template File
-**
-**     $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_GTKMM_CELLRENDERER_VALUE_H
-#define __SYNFIG_GTKMM_CELLRENDERER_VALUE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtk/gtk.h>
-#include <gtkmm/ruler.h>
-#include <gtkmm/arrow.h>
-#include <gtkmm/image.h>
-#include <gdkmm/pixbufloader.h>
-#include <gtkmm/viewport.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/scrolledwindow.h>
-#include <gtkmm/table.h>
-#include <gtkmm/statusbar.h>
-#include <gtkmm/button.h>
-#include <gtkmm/label.h>
-#include <gtkmm/paned.h>
-#include <gtkmm/treeview.h>
-#include <gtkmm/treestore.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/box.h>
-#include <gtkmm/spinbutton.h>
-#include <gtkmm/cellrenderer.h>
-#include <gtkmm/checkbutton.h>
-
-#include <gtkmm/colorselection.h>
-#include <gtkmm/optionmenu.h>
-
-//#include <synfig/synfig.h>
-#include <synfig/paramdesc.h>
-#include <synfig/value.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 Widget_Color;
-class Widget_CanvasChooser;
-class Widget_Enum;
-class Widget_Filename;
-class Widget_Vector;
-class Widget_Time;
-
-class ValueBase_Entry;
-
-class CellRenderer_ValueBase : public Gtk::CellRendererText
-{
-       sigc::signal<void, const Glib::ustring&> signal_secondary_click_;
-       sigc::signal<void, const Glib::ustring&, synfig::ValueBase> signal_edited_;
-
-       Glib::Property<synfig::ValueBase> property_value_;
-       Glib::Property<etl::handle<synfig::Canvas> > property_canvas_;
-       Glib::Property<synfig::ParamDesc> property_param_desc_;
-
-       void string_edited_(const Glib::ustring&,const Glib::ustring&);
-
-       void gradient_edited(synfig::Gradient gradient, Glib::ustring path);
-       void color_edited(synfig::Color color, Glib::ustring path);
-
-       bool edit_value_done_called;
-public:
-       sigc::signal<void, const Glib::ustring&> &signal_secondary_click()
-       {return signal_secondary_click_; }
-
-       sigc::signal<void, const Glib::ustring&, synfig::ValueBase> &signal_edited()
-       {return signal_edited_; }
-
-       Glib::PropertyProxy<synfig::ValueBase> property_value() { return property_value_.get_proxy();}
-       Glib::PropertyProxy<etl::handle<synfig::Canvas> > property_canvas() { return property_canvas_.get_proxy();}
-       Glib::PropertyProxy<synfig::ParamDesc> property_param_desc() { return property_param_desc_.get_proxy(); }
-       Glib::PropertyProxy<bool> property_inconsistent() { return property_foreground_set(); }
-
-       etl::handle<synfig::Canvas> get_canvas()const { return property_canvas_; }
-       synfig::ParamDesc get_param_desc()const { return property_param_desc_; }
-
-       CellRenderer_ValueBase();
-       ~CellRenderer_ValueBase();
-
-       ValueBase_Entry *value_entry;
-
-       void on_value_editing_done();
-
-       virtual void
-       render_vfunc(
-               const Glib::RefPtr<Gdk::Drawable>& window,
-               Gtk::Widget& widget,
-               const Gdk::Rectangle& background_area,
-               const Gdk::Rectangle& ca,
-               const Gdk::Rectangle& expose_area,
-               Gtk::CellRendererState flags);
-
-       virtual Gtk::CellEditable* start_editing_vfunc(GdkEvent* event,
-                                                 Gtk::Widget& widget,
-                                                 const Glib::ustring& path,
-                                                 const Gdk::Rectangle& background_area,
-                                                 const Gdk::Rectangle& cell_area,
-                                                 Gtk::CellRendererState flags);
-
-}; // END of class CellRenderer_ValueBase
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/childrentree.cpp b/synfig-studio/src/gtkmm/childrentree.cpp
deleted file mode 100644 (file)
index 01ef95e..0000000
+++ /dev/null
@@ -1,439 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file childrentree.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 <config.h>
-#endif
-
-#include "childrentree.h"
-#include "cellrenderer_value.h"
-#include "cellrenderer_timetrack.h"
-#include <synfigapp/action.h>
-#include <synfigapp/instance.h>
-#include <gtkmm/scrolledwindow.h>
-#include <synfig/timepointcollect.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 ========================================================= */
-
-#ifndef SMALL_BUTTON
-#define SMALL_BUTTON(button,stockid,tooltip)   \
-       button = manage(new class Gtk::Button());       \
-       icon=manage(new Gtk::Image(Gtk::StockID(stockid),iconsize));    \
-       button->add(*icon);     \
-       tooltips_.set_tip(*button,tooltip);     \
-       icon->set_padding(0,0);\
-       icon->show();   \
-       button->set_relief(Gtk::RELIEF_NONE); \
-       button->show()
-#endif
-
-#ifndef NORMAL_BUTTON
-#define NORMAL_BUTTON(button,stockid,tooltip)  \
-       button = manage(new class Gtk::Button());       \
-       icon=manage(new Gtk::Image(Gtk::StockID(stockid),Gtk::ICON_SIZE_BUTTON));       \
-       button->add(*icon);     \
-       tooltips_.set_tip(*button,tooltip);     \
-       icon->set_padding(0,0);\
-       icon->show();   \
-       /*button->set_relief(Gtk::RELIEF_NONE);*/ \
-       button->show()
-#endif
-
-#define NEW_SMALL_BUTTON(x,y,z)        Gtk::Button *SMALL_BUTTON(x,y,z)
-
-#define NOT_IMPLEMENTED_SLOT sigc::mem_fun(*reinterpret_cast<studio::CanvasViewUIInterface*>(get_ui_interface().get()),&studio::CanvasViewUIInterface::not_implemented)
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-ChildrenTree::ChildrenTree()
-{
-       const ChildrenTreeStore::Model model;
-
-       {       // --- N A M E --------------------------------------------------------
-               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("ID")) );
-
-               // Set up the icon cell-renderer
-               Gtk::CellRendererPixbuf* icon_cellrenderer = Gtk::manage( new Gtk::CellRendererPixbuf() );
-               column->pack_start(*icon_cellrenderer,false);
-               column->add_attribute(icon_cellrenderer->property_pixbuf(), model.icon);
-
-               // Pack the label into the column
-               column->pack_start(model.label,true);
-
-               // Finish setting up the column
-               column->set_reorderable();
-               column->set_resizable();
-               column->set_clickable();
-               column->set_min_width(150);
-               column->set_sort_column(model.label);
-               tree_view.append_column(*column);
-
-       }
-       {       // --- T Y P E --------------------------------------------------------
-               int cols_count = tree_view.append_column(_("Type"),model.type);
-               Gtk::TreeViewColumn* column = tree_view.get_column(cols_count-1);
-               if(column)
-               {
-                       column->set_reorderable();
-                       column->set_resizable();
-                       column->set_clickable();
-                       column->set_sort_column(model.type);
-               }
-       }
-       {       // --- V A L U E  -----------------------------------------------------
-               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("ValueBase")) );
-
-               // Set up the value cell-renderer
-               cellrenderer_value=ChildrenTreeStore::add_cell_renderer_value(column);
-               cellrenderer_value->signal_edited().connect(sigc::mem_fun(*this, &studio::ChildrenTree::on_edited_value));
-               cellrenderer_value->property_value()=synfig::ValueBase();
-
-               // Finish setting up the column
-               tree_view.append_column(*column);
-               column->set_sizing(Gtk::TREE_VIEW_COLUMN_AUTOSIZE);
-               column->set_min_width(150);
-               column->set_reorderable();
-               column->set_resizable();
-               column->set_clickable(false);
-       }
-       {       // --- T I M E   T R A C K --------------------------------------------
-               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Time Track")) );
-               column_time_track=column;
-
-               // Set up the value-node cell-renderer
-               cellrenderer_time_track=ChildrenTreeStore::add_cell_renderer_value_node(column);
-               cellrenderer_time_track->property_mode()=Gtk::CELL_RENDERER_MODE_ACTIVATABLE;
-               cellrenderer_time_track->signal_waypoint_clicked_cellrenderer().connect(sigc::mem_fun(*this, &studio::ChildrenTree::on_waypoint_clicked_childrentree) );
-               column->add_attribute(cellrenderer_time_track->property_value_desc(), model.value_desc);
-               column->add_attribute(cellrenderer_time_track->property_canvas(), model.canvas);
-
-               //column->pack_start(*cellrenderer_time_track);
-
-               // Finish setting up the column
-               column->set_reorderable();
-               column->set_resizable();
-               tree_view.append_column(*column);
-       }
-
-       // This makes things easier to read.
-       tree_view.set_rules_hint();
-
-       // Make us more sensitive to several events
-       tree_view.add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::BUTTON1_MOTION_MASK | Gdk::BUTTON2_MOTION_MASK|Gdk::POINTER_MOTION_MASK);
-
-       tree_view.signal_event().connect(sigc::mem_fun(*this, &studio::ChildrenTree::on_tree_event));
-
-       // Create a scrolled window for that tree
-       Gtk::ScrolledWindow *scroll_children_tree = manage(new class Gtk::ScrolledWindow());
-       scroll_children_tree->set_flags(Gtk::CAN_FOCUS);
-       scroll_children_tree->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
-       scroll_children_tree->add(tree_view);
-       scroll_children_tree->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
-       scroll_children_tree->show();
-
-       attach(*scroll_children_tree, 0, 3, 0, 1, Gtk::EXPAND|Gtk::FILL,Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       hbox=manage(new Gtk::HBox());
-
-       attach(*hbox, 0, 1, 1, 2, Gtk::FILL|Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-
-       tree_view.set_enable_search(true);
-       tree_view.set_search_column(model.label);
-
-/*  // Buttons to raise/lower/duplicate/delete children valuenodes
-       //   Commented out because these functions are not implemented
-    //   and children sort themselves alphabetically
-
-       Gtk::Image *icon;
-       //Gtk::IconSize iconsize(Gtk::IconSize::from_name("synfig-small_icon"));
-       Gtk::IconSize iconsize(Gtk::ICON_SIZE_SMALL_TOOLBAR);
-
-       SMALL_BUTTON(button_raise,"gtk-go-up",_("Raise"));
-       SMALL_BUTTON(button_lower,"gtk-go-down",_("Lower"));
-       SMALL_BUTTON(button_duplicate,"synfig-duplicate",_("Duplicate"));
-       SMALL_BUTTON(button_delete,"gtk-delete",_("Delete"));
-
-       hbox->pack_start(*button_raise,Gtk::PACK_SHRINK);
-       hbox->pack_start(*button_lower,Gtk::PACK_SHRINK);
-       hbox->pack_start(*button_duplicate,Gtk::PACK_SHRINK);
-       hbox->pack_start(*button_delete,Gtk::PACK_SHRINK);
-
-       button_raise->signal_clicked().connect(sigc::mem_fun(*this, &studio::ChildrenTree::on_raise_pressed));
-       button_lower->signal_clicked().connect(sigc::mem_fun(*this, &studio::ChildrenTree::on_lower_pressed));
-       button_duplicate->signal_clicked().connect(sigc::mem_fun(*this, &studio::ChildrenTree::on_duplicate_pressed));
-       button_delete->signal_clicked().connect(sigc::mem_fun(*this, &studio::ChildrenTree::on_delete_pressed));
-
-       button_raise->set_sensitive(false);
-       button_lower->set_sensitive(false);
-       button_duplicate->set_sensitive(false);
-       button_delete->set_sensitive(false);
-*/
-
-       get_selection()->signal_changed().connect(sigc::mem_fun(*this, &studio::ChildrenTree::on_selection_changed));
-
-       tree_view.set_reorderable(true);
-
-       hbox->show();
-       tree_view.show();
-
-       tooltips_.enable();
-
-       //get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
-}
-
-ChildrenTree::~ChildrenTree()
-{
-}
-
-void
-ChildrenTree::set_show_timetrack(bool x)
-{
-       column_time_track->set_visible(x);
-}
-
-void
-ChildrenTree::set_model(Glib::RefPtr<ChildrenTreeStore> children_tree_store)
-{
-       children_tree_store_=children_tree_store;
-       tree_view.set_model(children_tree_store_);
-       cellrenderer_time_track->set_canvas_interface(children_tree_store_->canvas_interface()); // am I smart people?  (cellrenderer_timetrack.h:176)
-       children_tree_store_->canvas_interface()->signal_dirty_preview().connect(sigc::mem_fun(*this,&studio::ChildrenTree::on_dirty_preview));
-}
-
-void
-ChildrenTree::set_time_adjustment(Gtk::Adjustment &adjustment)
-{
-       cellrenderer_time_track->set_adjustment(adjustment);
-}
-
-void
-ChildrenTree::on_dirty_preview()
-{
-}
-
-void
-ChildrenTree::on_selection_changed()
-{
-       if(0)
-               {
-               button_raise->set_sensitive(false);
-               button_lower->set_sensitive(false);
-               button_duplicate->set_sensitive(false);
-               button_delete->set_sensitive(false);
-               return;
-       }
-}
-
-void
-ChildrenTree::on_edited_value(const Glib::ustring&path_string,synfig::ValueBase value)
-{
-       Gtk::TreePath path(path_string);
-
-       const Gtk::TreeRow row = *(tree_view.get_model()->get_iter(path));
-
-       row[model.value]=value;
-//     signal_edited_value()(row[model.value_desc],value);
-}
-
-void
-ChildrenTree::on_waypoint_clicked_childrentree(const etl::handle<synfig::Node>& node __attribute__ ((unused)),
-                                                                                          const synfig::Time& time __attribute__ ((unused)),
-                                                                                          const synfig::Time& time_offset __attribute__ ((unused)),
-                                                                                          int button __attribute__ ((unused)))
-{
-       std::set<synfig::Waypoint, std::less<UniqueID> > waypoint_set;
-       synfig::waypoint_collect(waypoint_set,time,node);
-
-       synfigapp::ValueDesc value_desc;
-
-       if (waypoint_set.size() == 1)
-       {
-               ValueNode::Handle value_node(waypoint_set.begin()->get_parent_value_node());
-               assert(value_node);
-
-               Gtk::TreeRow row;
-               if (children_tree_store_->find_first_value_node(value_node, row) && row)
-                       value_desc = static_cast<synfigapp::ValueDesc>(row[model.value_desc]);
-       }
-
-       if (!waypoint_set.empty())
-               signal_waypoint_clicked_childrentree()(value_desc,waypoint_set,button);
-}
-
-bool
-ChildrenTree::on_tree_event(GdkEvent *event)
-{
-    switch(event->type)
-    {
-       case GDK_BUTTON_PRESS:
-               {
-                       Gtk::TreeModel::Path path;
-                       Gtk::TreeViewColumn *column;
-                       int cell_x, cell_y;
-                       if(!tree_view.get_path_at_pos(
-                               int(event->button.x),int(event->button.y),      // x, y
-                               path, // TreeModel::Path&
-                               column, //TreeViewColumn*&
-                               cell_x,cell_y //int&cell_x,int&cell_y
-                               )
-                       ) break;
-                       const Gtk::TreeRow row = *(tree_view.get_model()->get_iter(path));
-
-                       if(column->get_first_cell_renderer()==cellrenderer_time_track)
-                       {
-                               Gdk::Rectangle rect;
-                               tree_view.get_cell_area(path,*column,rect);
-                               cellrenderer_time_track->property_value_desc()=row[model.value_desc];
-                               cellrenderer_time_track->property_canvas()=row[model.canvas];
-                               cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
-                               queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
-                               return true;
-                       }
-                       else if(column->get_first_cell_renderer()==cellrenderer_value)
-                               return signal_user_click()(event->button.button,row,COLUMNID_VALUE);
-                       else
-                               return signal_user_click()(event->button.button,row,COLUMNID_ID);
-
-               }
-               break;
-
-       case GDK_MOTION_NOTIFY:
-               {
-                       Gtk::TreeModel::Path path;
-                       Gtk::TreeViewColumn *column;
-                       int cell_x, cell_y;
-                       if(!tree_view.get_path_at_pos(
-                               (int)event->button.x,(int)event->button.y,      // x, y
-                               path, // TreeModel::Path&
-                               column, //TreeViewColumn*&
-                               cell_x,cell_y //int&cell_x,int&cell_y
-                               )
-                       ) break;
-
-                       if(!tree_view.get_model()->get_iter(path))
-                               break;
-
-                       Gtk::TreeRow row = *(tree_view.get_model()->get_iter(path));
-
-                       if(cellrenderer_time_track==column->get_first_cell_renderer())
-                       {
-                               // Movement on TimeLine
-                               Gdk::Rectangle rect;
-                               tree_view.get_cell_area(path,*column,rect);
-                               cellrenderer_time_track->property_value_desc()=row[model.value_desc];
-                               cellrenderer_time_track->property_canvas()=row[model.canvas];
-                               cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
-                               queue_draw();
-                               //queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
-                               return true;
-                       }
-                       else
-                       if(last_tooltip_path.get_depth()<=0 || path!=last_tooltip_path)
-                       {
-                               tooltips_.unset_tip(*this);
-                               Glib::ustring tooltips_string(row[model.tooltip]);
-                               last_tooltip_path=path;
-                               if(!tooltips_string.empty())
-                               {
-                                       tooltips_.set_tip(*this,tooltips_string);
-                                       tooltips_.force_window();
-                               }
-                       }
-               }
-               break;
-       case GDK_BUTTON_RELEASE:
-               {
-                       Gtk::TreeModel::Path path;
-                       Gtk::TreeViewColumn *column;
-                       int cell_x, cell_y;
-                       if(!tree_view.get_path_at_pos(
-                                  (int)event->button.x,(int)event->button.y,   // x, y
-                                  path, // TreeModel::Path&
-                                  column, //TreeViewColumn*&
-                                  cell_x,cell_y //int&cell_x,int&cell_y
-                                  )
-                               ) break;
-
-                       if(!tree_view.get_model()->get_iter(path))
-                               break;
-
-                       Gtk::TreeRow row = *(tree_view.get_model()->get_iter(path));
-
-                       if(column && cellrenderer_time_track == column->get_first_cell_renderer())
-                       {
-                               Gdk::Rectangle rect;
-                               tree_view.get_cell_area(path,*column,rect);
-                               cellrenderer_time_track->property_value_desc()=row[model.value_desc];
-                               cellrenderer_time_track->property_canvas()=row[model.canvas];
-                               cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
-                               queue_draw();
-                               queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
-                               return true;
-                       }
-               }
-               break;
-       default:
-               break;
-       }
-       return false;
-}
-
-void
-ChildrenTree::on_raise_pressed()
-{
-}
-
-void
-ChildrenTree::on_lower_pressed()
-{
-}
-
-void
-ChildrenTree::on_duplicate_pressed()
-{
-}
-
-void
-ChildrenTree::on_delete_pressed()
-{
-}
diff --git a/synfig-studio/src/gtkmm/childrentree.h b/synfig-studio/src/gtkmm/childrentree.h
deleted file mode 100644 (file)
index d307fd0..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file childrentree.h
-**     \brief Template Header
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === S T A R T =========================================================== */
-
-#ifndef __SYNFIG_STUDIO_CHILDRENTREE_H
-#define __SYNFIG_STUDIO_CHILDRENTREE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/treeview.h>
-#include <gtkmm/treestore.h>
-#include <gtkmm/tooltips.h>
-#include <gtkmm/table.h>
-#include <gtkmm/box.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/scale.h>
-#include <gtkmm/button.h>
-
-#include <synfigapp/canvasinterface.h>
-#include <synfigapp/value_desc.h>
-#include "childrentreestore.h"
-#include <synfig/valuenode_animated.h>
-
-#include "widget_value.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 CellRenderer_TimeTrack;
-class CellRenderer_ValueBase;
-
-class ChildrenTree : public Gtk::Table
-{
-       /*
- -- ** -- P U B L I C   T Y P E S ---------------------------------------------
-       */
-
-public:
-
-       typedef studio::ColumnID ColumnID;
-
-       /*
- -- ** -- P U B L I C  D A T A ------------------------------------------------
-       */
-
-public:
-
-       ChildrenTreeStore::Model model;
-
-       /*
- -- ** -- P R I V A T E   D A T A ---------------------------------------------
-       */
-
-private:
-
-       Gtk::Tooltips tooltips_;
-
-       Gtk::TreePath last_tooltip_path;
-
-       Gtk::TreeView tree_view;
-
-       Gtk::HBox *hbox;
-
-       Glib::RefPtr<ChildrenTreeStore> children_tree_store_;
-
-       CellRenderer_TimeTrack *cellrenderer_time_track;
-
-       Gtk::TreeView::Column* column_time_track;
-
-       CellRenderer_ValueBase *cellrenderer_value;
-
-       sigc::signal<void,synfigapp::ValueDesc,synfig::ValueBase> signal_edited_value_;
-
-       sigc::signal<bool, int, Gtk::TreeRow, ColumnID> signal_user_click_;
-
-       sigc::signal<void,synfigapp::ValueDesc,std::set<synfig::Waypoint,std::less<synfig::UniqueID> >,int> signal_waypoint_clicked_childrentree_;
-
-       Gtk::Button *button_raise;
-       Gtk::Button *button_lower;
-       Gtk::Button *button_duplicate;
-       Gtk::Button *button_delete;
-
-       Widget_ValueBase blend_method_widget;
-
-       /*
- -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
-       */
-
-private:
-
-       /*
- -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
-       */
-
-private:
-
-       void on_edited_value(const Glib::ustring&path_string,synfig::ValueBase value);
-
-       void on_waypoint_clicked_childrentree(const etl::handle<synfig::Node>& node,const synfig::Time&,const synfig::Time&,int button);
-
-       bool on_tree_event(GdkEvent *event);
-
-       void on_selection_changed();
-
-       void on_dirty_preview();
-
-       //! \todo Implement raise/lower/duplicate/delete functions
-       void on_raise_pressed();
-
-       void on_lower_pressed();
-
-       void on_duplicate_pressed();
-
-       void on_delete_pressed();
-
-       /*
- -- ** -- P U B L I C   M E T H O D S -----------------------------------------
-       */
-
-public:
-
-       Gtk::HBox& get_hbox() { return *hbox; }
-
-       Gtk::TreeView& get_tree_view() { return tree_view; }
-
-       Glib::RefPtr<Gtk::TreeSelection> get_selection() { return tree_view.get_selection(); }
-       Glib::SignalProxy1< bool,GdkEvent* >  signal_event () { return tree_view.signal_event(); }
-
-       ChildrenTree();
-       ~ChildrenTree();
-
-       void set_model(Glib::RefPtr<ChildrenTreeStore> children_tree_store_);
-
-       void set_time_adjustment(Gtk::Adjustment &adjustment);
-
-       void set_show_timetrack(bool x=true);
-
-       //! Signal called with a value has been edited.
-       sigc::signal<void,synfigapp::ValueDesc,synfig::ValueBase>& signal_edited_value() { return signal_edited_value_; }
-
-       sigc::signal<bool,int, Gtk::TreeRow, ColumnID>& signal_user_click() { return signal_user_click_; }
-
-       sigc::signal<void,synfigapp::ValueDesc,std::set<synfig::Waypoint,std::less<synfig::UniqueID> >,int>& signal_waypoint_clicked_childrentree() { return signal_waypoint_clicked_childrentree_; }
-
-       etl::handle<synfigapp::SelectionManager> get_selection_manager() { return children_tree_store_->canvas_interface()->get_selection_manager(); }
-
-}; // END of ChildrenTree
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/childrentreestore.cpp b/synfig-studio/src/gtkmm/childrentreestore.cpp
deleted file mode 100644 (file)
index cf8798f..0000000
+++ /dev/null
@@ -1,389 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file childrentreestore.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \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
-**     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 <config.h>
-#endif
-
-#include "childrentreestore.h"
-#include "iconcontroller.h"
-#include <gtkmm/button.h>
-#include <synfig/paramdesc.h>
-#include <ETL/clock>
-
-#include "general.h"
-
-class Profiler : private etl::clock
-{
-       const std::string name;
-public:
-       Profiler(const std::string& name):name(name) { reset(); }
-       ~Profiler() { float time(operator()()); synfig::info("%s: took %f msec",name.c_str(),time*1000); }
-};
-
-#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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-static ChildrenTreeStore::Model& ModelHack()
-{
-       static ChildrenTreeStore::Model* model(0);
-       if(!model)model=new ChildrenTreeStore::Model;
-       return *model;
-}
-
-ChildrenTreeStore::ChildrenTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_):
-       Gtk::TreeStore                  (ModelHack()),
-       CanvasTreeStore                 (canvas_interface_)
-{
-       canvas_row=*append();
-       canvas_row[model.label]=_("Canvases");
-       canvas_row[model.is_canvas] = false;
-       canvas_row[model.is_value_node] = false;
-
-       value_node_row=*append();
-       value_node_row[model.label]=_("ValueBase Nodes");
-       value_node_row[model.is_canvas] = false;
-       value_node_row[model.is_value_node] = false;
-
-       // Connect all the signals
-       canvas_interface()->signal_value_node_changed().connect(sigc::mem_fun(*this,&studio::ChildrenTreeStore::on_value_node_changed));
-       canvas_interface()->signal_value_node_renamed().connect(sigc::mem_fun(*this,&studio::ChildrenTreeStore::on_value_node_renamed));
-       canvas_interface()->signal_value_node_added().connect(sigc::mem_fun(*this,&studio::ChildrenTreeStore::on_value_node_added));
-       canvas_interface()->signal_value_node_deleted().connect(sigc::mem_fun(*this,&studio::ChildrenTreeStore::on_value_node_deleted));
-       canvas_interface()->signal_value_node_replaced().connect(sigc::mem_fun(*this,&studio::ChildrenTreeStore::on_value_node_replaced));
-       canvas_interface()->signal_canvas_added().connect(sigc::mem_fun(*this,&studio::ChildrenTreeStore::on_canvas_added));
-       canvas_interface()->signal_canvas_removed().connect(sigc::mem_fun(*this,&studio::ChildrenTreeStore::on_canvas_removed));
-
-       rebuild();
-}
-
-ChildrenTreeStore::~ChildrenTreeStore()
-{
-}
-
-Glib::RefPtr<ChildrenTreeStore>
-ChildrenTreeStore::create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_)
-{
-       return Glib::RefPtr<ChildrenTreeStore>(new ChildrenTreeStore(canvas_interface_));
-}
-
-void
-ChildrenTreeStore::rebuild()
-{
-       // Profiler profiler("ChildrenTreeStore::rebuild()");
-       rebuild_value_nodes();
-       rebuild_canvases();
-}
-
-void
-ChildrenTreeStore::refresh()
-{
-       // Profiler profiler("ChildrenTreeStore::refresh()");
-       refresh_value_nodes();
-       refresh_canvases();
-}
-
-void
-ChildrenTreeStore::rebuild_value_nodes()
-{
-       Gtk::TreeModel::Children children(value_node_row.children());
-
-       while(!children.empty())erase(children.begin());
-
-       clear_changed_queue();
-
-       std::for_each(
-               canvas_interface()->get_canvas()->value_node_list().rbegin(), canvas_interface()->get_canvas()->value_node_list().rend(),
-               sigc::mem_fun(*this, &studio::ChildrenTreeStore::on_value_node_added)
-       );
-}
-
-void
-ChildrenTreeStore::refresh_value_nodes()
-{
-       Gtk::TreeModel::Children children(value_node_row.children());
-
-       Gtk::TreeModel::Children::iterator iter;
-
-       if(!children.empty())
-               for(iter = children.begin(); iter != children.end(); ++iter)
-               {
-                       Gtk::TreeRow row=*iter;
-                       refresh_row(row);
-               }
-}
-
-void
-ChildrenTreeStore::rebuild_canvases()
-{
-       Gtk::TreeModel::Children children(canvas_row.children());
-
-       while(!children.empty())erase(children.begin());
-
-       std::for_each(
-               canvas_interface()->get_canvas()->children().rbegin(), canvas_interface()->get_canvas()->children().rend(),
-               sigc::mem_fun(*this, &studio::ChildrenTreeStore::on_canvas_added)
-       );
-}
-
-void
-ChildrenTreeStore::refresh_canvases()
-{
-       rebuild_canvases();
-}
-
-void
-ChildrenTreeStore::refresh_row(Gtk::TreeModel::Row &row, bool /*do_children*/)
-{
-       CanvasTreeStore::refresh_row(row,false);
-
-       if((bool)row[model.is_value_node])
-       {
-               changed_set_.erase(row[model.value_node]);
-       }
-
-}
-
-void
-ChildrenTreeStore::on_canvas_added(synfig::Canvas::Handle canvas)
-{
-       Gtk::TreeRow row = *(prepend(canvas_row.children()));
-
-       row[model.icon] = Gtk::Button().render_icon(Gtk::StockID("synfig-canvas"),Gtk::ICON_SIZE_SMALL_TOOLBAR);
-       row[model.id] = canvas->get_id();
-       row[model.name] = canvas->get_name();
-
-       if(!canvas->get_id().empty())
-               row[model.label] = canvas->get_id();
-       else
-       if(!canvas->get_name().empty())
-               row[model.label] = canvas->get_name();
-       else
-               row[model.label] = _("[Unnamed]");
-
-       row[model.canvas] = canvas;
-       row[model.type] = _("Canvas");
-       //row[model.is_canvas] = true;
-       //row[model.is_value_node] = false;
-}
-
-void
-ChildrenTreeStore::on_canvas_removed(synfig::Canvas::Handle /*canvas*/)
-{
-       rebuild_canvases();
-}
-
-void
-ChildrenTreeStore::on_value_node_added(synfig::ValueNode::Handle value_node)
-{
-//     if(value_node->get_id().find("Unnamed")!=String::npos)
-//             return;
-
-       Gtk::TreeRow row = *prepend(value_node_row.children());
-
-       set_row(row,synfigapp::ValueDesc(canvas_interface()->get_canvas(),value_node->get_id()),false);
-}
-
-void
-ChildrenTreeStore::on_value_node_deleted(synfig::ValueNode::Handle value_node)
-{
-       Gtk::TreeIter iter;
-       //int i(0);
-
-       if(find_first_value_node(value_node,iter))
-       {
-               erase(iter);
-       }
-       //rebuild_value_nodes();
-}
-
-bool
-ChildrenTreeStore::execute_changed_value_nodes()
-{
-       // Profiler profiler("ChildrenTreeStore::execute_changed_value_nodes()");
-       if(!replaced_set_.empty())
-               rebuild_value_nodes();
-
-       etl::clock timer;
-       timer.reset();
-
-       while(!changed_set_.empty())
-       {
-               ValueNode::Handle value_node(*changed_set_.begin());
-               changed_set_.erase(value_node);
-
-               Gtk::TreeIter iter;
-
-               try
-               {
-                       Gtk::TreeIter iter;
-                       int i(0);
-
-                       if(!value_node->is_exported() && find_first_value_node(value_node,iter))
-                       {
-                               rebuild_value_nodes();
-                               continue;
-                       }
-
-                       if(value_node->is_exported() && find_first_value_node(value_node,iter)) do
-                       {
-                               Gtk::TreeRow row(*iter);
-                               i++;
-                               refresh_row(row);
-                       }while(find_next_value_node(value_node,iter));
-
-                       if(!i)
-                       {
-                               refresh_value_nodes();
-                               return false;
-                       }
-
-               }
-               catch(...)
-               {
-                       rebuild_value_nodes();
-                       return false;
-               }
-
-               // If we are taking too long...
-               if(timer()>4)
-               {
-                       refresh_value_nodes();
-                       return false;
-               }
-       }
-
-       return false;
-}
-
-void
-ChildrenTreeStore::on_value_node_changed(synfig::ValueNode::Handle value_node)
-{
-
-       if(!value_node->is_exported())
-               return;
-       changed_connection.disconnect();
-//     if(!execute_changed_queued())
-//             changed_connection=Glib::signal_idle().connect(sigc::mem_fun(*this,&ChildrenTreeStore::execute_changed_value_nodes));
-       changed_connection=Glib::signal_timeout().connect(sigc::mem_fun(*this,&ChildrenTreeStore::execute_changed_value_nodes),150);
-
-       changed_set_.insert(value_node);
-       /*
-       try
-       {
-               Gtk::TreeIter iter;
-               int i(0);
-               while(find_next_value_node(value_node,iter))
-               {
-                       Gtk::TreeRow row(*iter);
-                       i++;
-                       refresh_row(row);
-               }
-               if(!i)
-               {
-                       refresh_value_nodes();
-               }
-       }
-       catch(...)
-       {
-               rebuild_value_nodes();
-       }
-       */
-}
-
-void
-ChildrenTreeStore::on_value_node_renamed(synfig::ValueNode::Handle value_node __attribute__ ((unused)))
-{
-       rebuild_value_nodes();
-}
-
-void
-ChildrenTreeStore::on_value_node_replaced(synfig::ValueNode::Handle replaced_value_node,synfig::ValueNode::Handle /*new_value_node*/)
-{
-       changed_connection.disconnect();
-       //if(!execute_changed_queued())
-//             changed_connection=Glib::signal_idle().connect(sigc::mem_fun(*this,&ChildrenTreeStore::execute_changed_value_nodes));
-               changed_connection=Glib::signal_timeout().connect(sigc::mem_fun(*this,&ChildrenTreeStore::execute_changed_value_nodes),150);
-
-       replaced_set_.insert(replaced_value_node);
-}
-
-void
-ChildrenTreeStore::set_value_impl(const Gtk::TreeModel::iterator& iter, int column, const Glib::ValueBase& value)
-{
-       if(column>=get_n_columns_vfunc())
-       {
-               g_warning("LayerTreeStore::set_value_impl: Bad column (%d)",column);
-               return;
-       }
-
-       if(!g_value_type_compatible(G_VALUE_TYPE(value.gobj()),get_column_type_vfunc(column)))
-       {
-               g_warning("LayerTreeStore::set_value_impl: Bad value type");
-               return;
-       }
-
-       try
-       {
-               if(column==model.value.index())
-               {
-                       Glib::Value<synfig::ValueBase> x;
-                       g_value_init(x.gobj(),model.value.type());
-                       g_value_copy(value.gobj(),x.gobj());
-
-                       synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
-                       if(value_desc)
-                       {
-                               canvas_interface()->change_value(value_desc,x.get());
-                               row_changed(get_path(*iter),*iter);
-                       }
-
-                       return;
-               }
-               else
-                       CanvasTreeStore::set_value_impl(iter,column, value);
-       }
-       catch(std::exception x)
-       {
-               g_warning("%s", x.what());
-       }
-}
diff --git a/synfig-studio/src/gtkmm/childrentreestore.h b/synfig-studio/src/gtkmm/childrentreestore.h
deleted file mode 100644 (file)
index 5d0412a..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file childrentreestore.h
-**     \brief Template Header
-**
-**     $Id$
-**
-**     \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
-**     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_CHILDRENTREESTORE_H
-#define __SYNFIG_STUDIO_CHILDRENTREESTORE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/treestore.h>
-#include <synfigapp/canvasinterface.h>
-#include "canvastreestore.h"
-#include <synfig/value.h>
-#include <synfig/valuenode.h>
-#include <set>
-
-/* === 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 ChildrenTreeStore : public CanvasTreeStore
-{
-       /*
- -- ** -- P U B L I C   T Y P E S ---------------------------------------------
-       */
-
-public:
-
-       /*
- -- ** -- P U B L I C  D A T A ------------------------------------------------
-       */
-
-public:
-
-       //! TreeModel for the layers
-       const Model model;
-
-       /*
- -- ** -- P R I V A T E   D A T A ---------------------------------------------
-       */
-
-private:
-
-       Gtk::TreeModel::Row value_node_row;
-       Gtk::TreeModel::Row canvas_row;
-
-       std::set<synfig::ValueNode::Handle> changed_set_;
-
-       std::set<synfig::ValueNode::Handle> replaced_set_;
-
-       /*
- -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
-       */
-
-private:
-
-       sigc::connection changed_connection;
-       bool execute_changed_queued()const { return !changed_set_.empty() || !replaced_set_.empty(); }
-       bool execute_changed_value_nodes();
-       void clear_changed_queue() { changed_set_.clear(); replaced_set_.clear(); }
-
-       /*
- -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
-       */
-
-private:
-
-       void on_value_node_added(synfig::ValueNode::Handle value_node);
-       void on_value_node_deleted(synfig::ValueNode::Handle value_node);
-       void on_value_node_changed(synfig::ValueNode::Handle value_node);
-       void on_value_node_renamed(synfig::ValueNode::Handle value_node);
-       void on_value_node_replaced(synfig::ValueNode::Handle replaced_value_node,synfig::ValueNode::Handle new_value_node);
-       void on_canvas_added(synfig::Canvas::Handle canvas);
-       void on_canvas_removed(synfig::Canvas::Handle canvas);
-
-       void set_value_impl(const Gtk::TreeModel::iterator& iter, int column, const Glib::ValueBase& value);
-
-       /*
- -- ** -- P U B L I C   M E T H O D S -----------------------------------------
-       */
-
-public:
-
-       ChildrenTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
-       ~ChildrenTreeStore();
-
-       void rebuild();
-
-       void refresh();
-
-       void rebuild_value_nodes();
-
-       void refresh_value_nodes();
-
-       void rebuild_canvases();
-
-       void refresh_canvases();
-
-       void refresh_row(Gtk::TreeModel::Row &row, bool do_children=false);
-
-       Gtk::TreeModel::Row get_canvas_row()const { return canvas_row; }
-
-       Gtk::TreeModel::Row get_value_node_row()const { return value_node_row; }
-
-       /*
- -- ** -- S T A T I C   P U B L I C   M E T H O D S ---------------------------
-       */
-
-public:
-
-       static Glib::RefPtr<ChildrenTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
-}; // END of class ChildrenTreeStore
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/compview.cpp b/synfig-studio/src/gtkmm/compview.cpp
deleted file mode 100644 (file)
index 6605944..0000000
+++ /dev/null
@@ -1,616 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file compview.cpp
-**     \brief writeme
-**
-**     $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
-**
-** === N O T E S ===========================================================
-**
-** ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "compview.h"
-#include "app.h"
-#include <gtkmm/scrolledwindow.h>
-#include <cassert>
-#include <iostream>
-#include "instance.h"
-#include <sigc++/signal.h>
-#include <sigc++/hide.h>
-#include <sigc++/slot.h>
-#include "canvasview.h"
-#include <synfigapp/action.h>
-
-#include "general.h"
-
-#endif
-
-/* === M A C R O S ========================================================= */
-
-#define ADD_TOOLBOX_BUTTON(button,stockid,tooltip)     \
-       Gtk::Button *button = manage(new class Gtk::Button());  \
-       button->add(*manage(new Gtk::Image(Gtk::StockID(stockid),Gtk::IconSize(4))));   \
-       tooltips.set_tip(*button,tooltip);      \
-       button->show_all()
-
-using namespace std;
-using namespace etl;
-using namespace synfig;
-using namespace studio;
-
-#define COLUMNID_JUMP          (787584)
-#define ColumnID       int
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-CompView::CompView():
-       Gtk::Window(Gtk::WINDOW_TOPLEVEL),
-       dialog_settings(this,"compview")
-{
-       assert(0); //CHECK: This class does not appear to be used.
-       init_menu();
-       set_type_hint(Gdk::WINDOW_TYPE_HINT_UTILITY);
-
-       Gtk::Table *table = manage(new class Gtk::Table(2, 1, false));
-
-
-       table->attach(*create_instance_selector(), 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK, 0, 0);
-
-       notebook=manage(new class Gtk::Notebook());
-
-       table->attach(*notebook, 0, 1, 1,2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       notebook->append_page(*create_canvas_tree(),_("Canvases"));
-       notebook->append_page(*create_action_tree(),_("History"));
-
-
-
-/*
-
-       studio::Instance::ImageColumnModel image_column_model;
-       image_list=manage(new class Gtk::TreeView());
-       image_list->append_column(_("Name"),image_column_model.name);
-       image_list->signal_row_activated().connect(sigc::mem_fun(*this,&CompView::on_image_activate));
-       image_list->set_rules_hint();
-
-       Gtk::Table *image_page = manage(new class Gtk::Table(2, 1, false));
-       Gtk::ScrolledWindow *image_list_scroll = manage(new class Gtk::ScrolledWindow());
-       image_list_scroll->set_flags(Gtk::CAN_FOCUS);
-       image_list_scroll->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
-       image_list_scroll->add(*image_list);
-       image_page->attach(*image_list_scroll, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       Gtk::HBox *image_buttons=manage(new class Gtk::HBox());
-       image_page->attach(*image_buttons, 0, 1, 1,2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK, 0, 0);
-       ADD_TOOLBOX_BUTTON(button_image_new,"gtk-new",_("Create a new image"));
-       ADD_TOOLBOX_BUTTON(button_image_delete,"gtk-delete",_("Delete image"));
-       ADD_TOOLBOX_BUTTON(button_image_rename,"gtk-rename",_("Rename image"));
-       ADD_TOOLBOX_BUTTON(button_image_copy,"gtk-copy",_("Duplicate image"));
-       button_image_new->signal_clicked().connect(sigc::mem_fun(*this,&CompView::new_image));
-       button_image_delete->signal_clicked().connect(sigc::mem_fun(*this,&CompView::delete_image));
-       button_image_rename->signal_clicked().connect(sigc::mem_fun(*this,&CompView::rename_image));
-       button_image_copy->signal_clicked().connect(sigc::mem_fun(*this,&CompView::copy_image));
-       image_buttons->pack_start(*button_image_new);
-       image_buttons->pack_start(*button_image_delete);
-       image_buttons->pack_start(*button_image_rename);
-       image_buttons->pack_start(*button_image_copy);
-
-       studio::Instance::ValueNodeColumnModel valuenode_column_model;
-       valuenode_list=manage(new class Gtk::TreeView());
-       valuenode_list->append_column(_("Name"),valuenode_column_model.name);
-       valuenode_list->signal_row_activated().connect(sigc::mem_fun(*this,&CompView::on_valuenode_activate));
-       valuenode_list->set_rules_hint();
-
-       Gtk::Table *valuenode_page = manage(new class Gtk::Table(2, 1, false));
-       Gtk::ScrolledWindow *valuenode_list_scroll = manage(new class Gtk::ScrolledWindow());
-       valuenode_list_scroll->set_flags(Gtk::CAN_FOCUS);
-       valuenode_list_scroll->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
-       valuenode_list_scroll->add(*valuenode_list);
-       valuenode_page->attach(*valuenode_list_scroll, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       Gtk::HBox *valuenode_buttons=manage(new class Gtk::HBox());
-       valuenode_page->attach(*valuenode_buttons, 0, 1, 1,2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK, 0, 0);
-       ADD_TOOLBOX_BUTTON(button_valuenode_new,"gtk-new",_("Create a new value_node"));
-       ADD_TOOLBOX_BUTTON(button_valuenode_delete,"gtk-delete",_("Delete value_node"));
-       ADD_TOOLBOX_BUTTON(button_valuenode_rename,"gtk-rename",_("Rename value_node"));
-       ADD_TOOLBOX_BUTTON(button_valuenode_copy,"gtk-copy",_("Duplicate value_node"));
-       button_valuenode_new->signal_clicked().connect(sigc::mem_fun(*this,&CompView::new_value_node));
-       button_valuenode_delete->signal_clicked().connect(sigc::mem_fun(*this,&CompView::delete_value_node));
-       button_valuenode_rename->signal_clicked().connect(sigc::mem_fun(*this,&CompView::rename_value_node));
-       button_valuenode_copy->signal_clicked().connect(sigc::mem_fun(*this,&CompView::copy_value_node));
-       valuenode_buttons->pack_start(*button_valuenode_new);
-       valuenode_buttons->pack_start(*button_valuenode_delete);
-       valuenode_buttons->pack_start(*button_valuenode_rename);
-       valuenode_buttons->pack_start(*button_valuenode_copy);
-
-
-       notebook->append_page(*image_page,_("Images"));
-       notebook->append_page(*valuenode_page,_("ValueNodes"));
-
-       image_page->show_all();
-       valuenode_page->show_all();
-*/
-//     notebook->set_current_page(0);
-       signal_delete_event().connect(sigc::hide(sigc::mem_fun(*this, &CompView::close)));
-       App::signal_instance_created().connect(sigc::mem_fun(*this,&studio::CompView::new_instance));
-       App::signal_instance_deleted().connect(sigc::mem_fun(*this,&studio::CompView::delete_instance));
-       App::signal_instance_selected().connect(sigc::mem_fun(*this,&studio::CompView::set_selected_instance_signal));
-
-       table->show_all();
-       add(*table);
-
-
-       set_title(_("Canvas Browser"));
-       set_modal(false);
-       set_resizable(true);
-       property_window_position().set_value(Gtk::WIN_POS_NONE);
-       set_default_size(200,300);
-}
-
-CompView::~CompView()
-{
-}
-
-etl::loose_handle<studio::CanvasView>
-CompView::get_selected_canvas_view()
-{
-       return get_selected_instance()->find_canvas_view(get_selected_canvas());
-}
-
-Gtk::Widget*
-CompView::create_canvas_tree()
-{
-       studio::Instance::CanvasTreeModel canvas_tree_model;
-       canvas_tree=manage(new class Gtk::TreeView());
-       {
-               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("ID")) );
-//             Gtk::CellRendererPixbuf* icon_cellrenderer = Gtk::manage( new Gtk::CellRendererPixbuf() );
-
-               //column->pack_start(*icon_cellrenderer,false);
-               column->pack_start(canvas_tree_model.icon, false); //false = don't expand.
-               column->pack_start(canvas_tree_model.label);
-
-//#ifdef NDEBUG
-//             column->add_attribute(icon_cellrenderer->property_pixbuf(), canvas_tree_model.icon);
-//#endif
-
-               canvas_tree->append_column(*column);
-       }
-       canvas_tree->set_rules_hint();
-       canvas_tree->signal_row_activated().connect(sigc::mem_fun(*this,&CompView::on_row_activate));
-       canvas_tree->signal_event().connect(sigc::mem_fun(*this,&CompView::on_tree_event));
-       canvas_tree->add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
-       canvas_tree->add_events(Gdk::BUTTON1_MOTION_MASK);
-       canvas_tree->show();
-
-       Gtk::ScrolledWindow *scrolledwindow = manage(new class Gtk::ScrolledWindow());
-       scrolledwindow->set_flags(Gtk::CAN_FOCUS);
-       scrolledwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
-       scrolledwindow->add(*canvas_tree);
-       scrolledwindow->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
-       scrolledwindow->show();
-
-       return scrolledwindow;
-}
-
-Gtk::Widget*
-CompView::create_action_tree()
-{
-       studio::HistoryTreeStore::Model history_tree_model;
-       action_tree=manage(new class Gtk::TreeView());
-       {
-               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column("") );
-
-               Gtk::CellRendererToggle* toggle_cr = Gtk::manage( new Gtk::CellRendererToggle() );
-               toggle_cr->signal_toggled().connect(sigc::mem_fun(*this, &studio::CompView::on_action_toggle) );
-
-               column->pack_start(*toggle_cr); //false = don't expand.
-               column->add_attribute(toggle_cr->property_active(),history_tree_model.is_active);
-               column->set_resizable();
-               column->set_clickable();
-
-               action_tree->append_column(*column);
-       }
-       /*{
-               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Canvas")) );
-               Gtk::CellRendererText *text_cr=Gtk::manage(new Gtk::CellRendererText());
-               text_cr->property_foreground()=Glib::ustring("#7f7f7f");
-
-               column->pack_start(*text_cr);
-               column->add_attribute(text_cr->property_text(),history_tree_model.canvas_id);
-               column->add_attribute(text_cr->property_foreground_set(),history_tree_model.is_redo);
-
-               action_tree->append_column(*column);
-       }*/
-       {
-               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Jump")) );
-
-               Gtk::CellRendererText* cell_renderer_jump=Gtk::manage(new Gtk::CellRendererText());
-               column->pack_start(*cell_renderer_jump,true);
-
-               cell_renderer_jump->property_text()=_("(JMP)");
-               cell_renderer_jump->property_foreground()="#003a7f";
-
-               column->set_resizable();
-               column->set_clickable();
-
-               column->set_sort_column(COLUMNID_JUMP);
-
-               action_tree->append_column(*column);
-               //column->clicked();
-       }
-       {
-               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Action")) );
-
-               Gtk::CellRendererText *text_cr=Gtk::manage(new Gtk::CellRendererText());
-               text_cr->property_foreground()=Glib::ustring("#7f7f7f");
-
-
-
-               //column->pack_start(history_tree_model.icon, false); //false = don't expand.
-               column->pack_start(*text_cr);
-               column->add_attribute(text_cr->property_text(),history_tree_model.name);
-               column->add_attribute(text_cr->property_foreground_set(),history_tree_model.is_redo);
-
-               action_tree->append_column(*column);
-       }
-
-
-       action_tree->set_rules_hint();
-//     action_tree->signal_row_activated().connect(sigc::mem_fun(*this,&CompView::on_row_activate));
-       action_tree->signal_event().connect(sigc::mem_fun(*this,&CompView::on_action_event));
-//     action_tree->add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
-//     action_tree->add_events(Gdk::BUTTON1_MOTION_MASK);
-       action_tree->show();
-
-       Gtk::ScrolledWindow *scrolledwindow = manage(new class Gtk::ScrolledWindow());
-       scrolledwindow->set_flags(Gtk::CAN_FOCUS);
-       scrolledwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
-       scrolledwindow->add(*action_tree);
-       scrolledwindow->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
-       scrolledwindow->show();
-
-       Gtk::Button* clear_button(manage(new Gtk::Button(_("Clear Undo"))));
-       clear_button->signal_pressed().connect(sigc::mem_fun(*this,&studio::CompView::clear_history));
-
-       Gtk::Button* clear_redo_button(manage(new Gtk::Button(_("Clear Redo"))));
-       clear_redo_button->signal_pressed().connect(sigc::mem_fun(*this,&studio::CompView::clear_redo));
-
-       Gtk::Table* table(manage(new Gtk::Table()));
-       table->attach(*scrolledwindow, 0, 2, 0,1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       table->attach(*clear_button, 0, 1, 1,2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK, 0, 0);
-       table->attach(*clear_redo_button, 1, 2, 1,2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK, 0, 0);
-
-       table->show_all();
-
-       return table;
-}
-
-Gtk::Widget*
-CompView::create_instance_selector()
-{
-       instance_selector=manage(new class Gtk::OptionMenu());
-       instance_selector->show();
-       instance_selector->set_menu(instance_list_menu);
-       return instance_selector;
-}
-
-bool
-CompView::close()
-{
-       hide();
-       return true;
-}
-
-void
-CompView::clear_history()
-{
-       if(selected_instance && App::dialog_yes_no(_("Clear History"), _("You will not be able to undo any changes that you have made!\nAre you sure you want to clear the undo stack?")))
-       {
-               selected_instance->clear_undo_stack();
-       }
-}
-
-void
-CompView::clear_redo()
-{
-       if(selected_instance && App::dialog_yes_no(_("Clear History"), _("You will not be able to redo any changes that you have made!\nAre you sure you want to clear the redo stack?")))
-       {
-               selected_instance->clear_redo_stack();
-       }
-}
-
-void
-CompView::init_menu()
-{
-       menu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
-       menu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-canvas_new"),
-               sigc::mem_fun(*this,&CompView::menu_new_canvas)));
-       menu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-delete"),
-               sigc::mem_fun(*this,&CompView::menu_delete)));
-       menu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-rename"),
-               sigc::mem_fun(*this,&CompView::menu_rename)));
-}
-
-etl::loose_handle<synfig::Canvas>
-CompView::get_selected_canvas()
-{
-       Glib::RefPtr<Gtk::TreeSelection> selection=canvas_tree->get_selection();
-
-       if(!selection || !selection->get_selected())
-               return 0;
-
-       studio::Instance::CanvasTreeModel canvas_tree_model;
-
-       return static_cast<etl::handle<synfig::Canvas> >((*selection->get_selected())[canvas_tree_model.canvas]);
-}
-
-void
-CompView::menu_new_canvas()
-{
-#warning Update Me!
-#if 0
-       get_selected_canvas_view()->new_child_canvas();
-#endif
-}
-
-void
-CompView::menu_delete()
-{
-       studio::App::dialog_not_implemented();
-}
-
-void
-CompView::menu_rename()
-{
-       studio::App::dialog_not_implemented();
-}
-
-void
-CompView::set_selected_instance_signal(etl::handle<studio::Instance> x)
-{
-       set_selected_instance(x);
-}
-
-void
-CompView::set_selected_instance_(etl::handle<studio::Instance> instance)
-{
-       if(studio::App::shutdown_in_progress)
-               return;
-
-       selected_instance=instance;
-       if(instance)
-       {
-               canvas_tree->set_model(instance->canvas_tree_store());
-               action_tree->set_model(instance->history_tree_store());
-               canvas_tree->show();
-               action_tree->show();
-       }
-       else
-       {
-               canvas_tree->set_model(Glib::RefPtr< Gtk::TreeModel >());
-               action_tree->set_model(Glib::RefPtr< Gtk::TreeModel >());
-               canvas_tree->hide();
-               action_tree->hide();
-       }
-}
-
-void
-CompView::set_selected_instance(etl::loose_handle<studio::Instance> x)
-{
-       if(studio::App::shutdown_in_progress)
-               return;
-
-       // if it's already selected, don't select it again
-       if (x==selected_instance)
-               return;
-
-       std::list<etl::handle<studio::Instance> >::iterator iter;
-
-       if(x)
-       {
-               int i;
-               for(i=0,iter=studio::App::instance_list.begin();iter!=studio::App::instance_list.end() && ((*iter)!=x);iter++,i++);
-
-               assert(*iter==x);
-
-               instance_selector->set_history(i);
-       }
-       else
-               instance_selector->set_history(0);
-
-       set_selected_instance_(x);
-}
-
-void
-CompView::new_instance(etl::handle<studio::Instance> instance)
-{
-       if(studio::App::shutdown_in_progress)
-               return;
-
-       assert(instance);
-
-       etl::loose_handle<studio::Instance> loose_instance(instance);
-
-       instance->synfigapp::Instance::signal_filename_changed().connect(sigc::mem_fun(*this,&CompView::refresh_instances));
-       instance->synfigapp::Instance::signal_filename_changed().connect(
-               sigc::bind<etl::loose_handle<studio::Instance> >(
-                       sigc::mem_fun(*this,&CompView::set_selected_instance),
-                       loose_instance
-               )
-       );
-
-       {
-               std::string name=basename(instance->get_file_name());
-
-               instance_list_menu.items().push_back(Gtk::Menu_Helpers::MenuElem(name,
-                       sigc::bind<etl::loose_handle<studio::Instance> >(sigc::mem_fun(&studio::App::set_selected_instance),loose_instance)     ));
-       }
-}
-
-void
-CompView::delete_instance(etl::handle<studio::Instance> instance)
-{
-       if(studio::App::shutdown_in_progress)
-               return;
-
-       refresh_instances();
-
-       if(selected_instance==instance)
-       {
-               set_selected_instance(0);
-               instance_selector->set_history(0);
-       }
-}
-
-void
-CompView::refresh_instances()
-{
-       if(studio::App::shutdown_in_progress)
-               return;
-
-       if(!instance_list_menu.items().empty())
-               instance_list_menu.items().clear();
-
-       std::list<etl::handle<studio::Instance> >::iterator iter;
-       for(iter=studio::App::instance_list.begin();iter!=studio::App::instance_list.end();iter++)
-       {
-               std::string name=basename((*iter)->get_file_name());
-
-               instance_list_menu.items().push_back(Gtk::Menu_Helpers::MenuElem(name,
-                       sigc::bind<etl::loose_handle<studio::Instance> >(sigc::mem_fun(&studio::App::set_selected_instance),*iter)      ));
-       }
-       instance_selector->set_menu(instance_list_menu);
-}
-
-void
-CompView::on_row_activate(const Gtk::TreeModel::Path &path, Gtk::TreeViewColumn *)
-{
-       assert(get_selected_instance());
-       studio::Instance::CanvasTreeModel canvas_tree_model;
-       const Gtk::TreeRow row = *(get_selected_instance()->canvas_tree_store()->get_iter(path));
-       if(row[canvas_tree_model.is_canvas])
-               get_selected_instance()->focus(row[canvas_tree_model.canvas]);
-       else
-               studio::App::dialog_not_implemented();
-}
-
-bool
-CompView::on_action_event(GdkEvent *event)
-{
-       studio::HistoryTreeStore::Model model;
-    switch(event->type)
-    {
-       case GDK_BUTTON_PRESS:
-       case GDK_2BUTTON_PRESS:
-               {
-                       Gtk::TreeModel::Path path;
-                       Gtk::TreeViewColumn *column;
-                       int cell_x, cell_y;
-                       if(!action_tree->get_path_at_pos(
-                               int(event->button.x),int(event->button.y),      // x, y
-                               path, // TreeModel::Path&
-                               column, //TreeViewColumn*&
-                               cell_x,cell_y //int&cell_x,int&cell_y
-                               )
-                       ) break;
-                       const Gtk::TreeRow row = *(action_tree->get_model()->get_iter(path));
-
-                       //signal_user_click()(event->button.button,row,(ColumnID)column->get_sort_column_id());
-                       if((ColumnID)column->get_sort_column_id()==COLUMNID_JUMP)
-                       {
-                               etl::handle<synfigapp::Action::Undoable> action(row[model.action]);
-                               if((bool)row[model.is_undo])
-                               {
-                                       while(get_selected_instance()->undo_action_stack().size() && get_selected_instance()->undo_action_stack().front()!=action)
-                                               get_selected_instance()->undo();
-                               }
-                               else if((bool)row[model.is_redo])
-                               {
-                                       while(get_selected_instance()->redo_action_stack().size() && get_selected_instance()->undo_action_stack().front()!=action)
-                                               get_selected_instance()->redo();
-                               }
-                       }
-               }
-
-       case GDK_BUTTON_RELEASE:
-               break;
-       default:
-               break;
-       }
-       return false;
-}
-
-bool
-CompView::on_tree_event(GdkEvent *event)
-{
-    switch(event->type)
-    {
-       case GDK_BUTTON_PRESS:
-               switch(event->button.button)
-               {
-               case 3:
-               if(get_selected_canvas())
-               {
-                       menu.items().clear();
-
-                       synfigapp::Action::ParamList param_list;
-                       param_list.add("canvas",synfig::Canvas::Handle(get_selected_canvas()));
-                       param_list.add("canvas_interface",get_selected_instance()->find_canvas_interface(get_selected_canvas()));
-                       get_selected_instance()->find_canvas_view(get_selected_canvas())->add_actions_to_menu(&menu, param_list,synfigapp::Action::CATEGORY_CANVAS);
-                       menu.popup(0,0);
-                       menu.show();
-                       break;
-               }
-               default:
-                       break;
-               }
-               break;
-       case GDK_MOTION_NOTIFY:
-               break;
-       case GDK_BUTTON_RELEASE:
-               break;
-       default:
-               break;
-       }
-       return false;
-}
-
-void
-CompView::on_action_toggle(const Glib::ustring& path_string)
-{
-       studio::HistoryTreeStore::Model history_tree_model;
-
-       Gtk::TreePath path(path_string);
-
-       const Gtk::TreeRow row = *(selected_instance->history_tree_store()->get_iter(path));
-
-       handle<synfigapp::Action::Undoable> action=row[history_tree_model.action];
-
-       selected_instance->synfigapp::Instance::set_action_status(action,!action->is_active());
-}
diff --git a/synfig-studio/src/gtkmm/compview.h b/synfig-studio/src/gtkmm/compview.h
deleted file mode 100644 (file)
index fbfdb1d..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file compview.h
-**     \brief Header File
-**
-**     $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
-**
-** === N O T E S ===========================================================
-**
-** ========================================================================= */
-
-/* === S T A R T =========================================================== */
-
-#ifndef __SYNFIG_COMPVIEW_H
-#define __SYNFIG_COMPVIEW_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/window.h>
-#include <gtkmm/image.h>
-#include <gtkmm/tooltips.h>
-#include <gtkmm/table.h>
-#include <gtkmm/button.h>
-#include <gtkmm/menu.h>
-#include <gtkmm/optionmenu.h>
-#include <gtkmm/notebook.h>
-#include <gtkmm/treeview.h>
-#include <gtkmm/box.h>
-
-#include <ETL/handle>
-
-#include "dialogsettings.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 synfig { class Canvas; };
-
-namespace studio {
-
-class Instance;
-class CanvasView;
-
-class CompView : public Gtk::Window
-{
-       DialogSettings dialog_settings;
-
-       Gtk::Tooltips tooltips;
-
-       Gtk::OptionMenu *instance_selector;
-       Gtk::Notebook *notebook;
-
-       Gtk::TreeView *canvas_tree;
-       Gtk::TreeView *action_tree;
-
-       Gtk::Menu       instance_list_menu;
-       Gtk::Menu       menu;
-
-       etl::loose_handle<studio::Instance>     selected_instance;
-
-       void set_selected_instance_(etl::handle<studio::Instance> x);
-
-       void clear_history();
-       void clear_redo();
-
-public:
-       CompView();
-       ~CompView();
-
-       etl::loose_handle<studio::Instance> get_selected_instance() { return selected_instance; }
-
-       etl::loose_handle<synfig::Canvas> get_selected_canvas();
-
-       etl::loose_handle<studio::CanvasView> get_selected_canvas_view();
-
-       void set_selected_instance(etl::loose_handle<studio::Instance> x);
-
-       void set_selected_instance_signal(etl::handle<studio::Instance> x);
-
-       void new_instance(etl::handle<studio::Instance> x);
-
-       void delete_instance(etl::handle<studio::Instance> x);
-
-       void refresh_instances();
-
-       bool close();
-
-private:
-
-       Gtk::Widget* create_canvas_tree();
-       Gtk::Widget* create_action_tree();
-       Gtk::Widget* create_instance_selector();
-
-       void on_row_activate(const Gtk::TreeModel::Path &path, Gtk::TreeViewColumn *);
-       bool on_tree_event(GdkEvent *event);
-
-       bool on_action_event(GdkEvent *event);
-
-       void init_menu();
-
-       void menu_new_canvas();
-       void menu_delete();
-       void menu_rename();
-
-       void on_action_toggle(const Glib::ustring& path);
-};
-
-};
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/devicetracker.cpp b/synfig-studio/src/gtkmm/devicetracker.cpp
deleted file mode 100644 (file)
index 48bfa13..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file devicetracker.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**  Copyright (c) 2009 Gerco Ballintijn
-**
-**     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
-*/
-/* ========================================================================= */
-
-// FIXME: The code here doesn't use the GTKmm layer but uses GTK+ directly
-// since the GTKmm wrapper for Gdk::Device is incomplete. When the wrapper
-// gets fixed, this code should be updated accoordingly.
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "devicetracker.h"
-#include <gdk/gdk.h>
-#include <gtk/gtk.h>
-#include <synfigapp/main.h>
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-using namespace synfig;
-using namespace synfigapp;
-using namespace studio;
-
-/* === M A C R O S ========================================================= */
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-DeviceTracker::DeviceTracker()
-{
-       GList*  device_list;
-       GList*  iter;
-       device_list=gdk_devices_list();
-
-       for(iter=device_list;iter;iter=g_list_next(iter))
-       {
-               GdkDevice* device=reinterpret_cast<GdkDevice*>(iter->data);
-
-               synfigapp::InputDevice::Handle input_device;
-               input_device=synfigapp::Main::add_input_device(device->name,synfigapp::InputDevice::Type(device->source));
-               //Disable all extended devices by default. This tries to fix several
-               // bugs reported in track and forums
-               if(     input_device->get_type()==synfigapp::InputDevice::TYPE_MOUSE  ||
-                       input_device->get_type()==synfigapp::InputDevice::TYPE_PEN    ||
-                       input_device->get_type()==synfigapp::InputDevice::TYPE_ERASER ||
-                       input_device->get_type()==synfigapp::InputDevice::TYPE_CURSOR  ) {
-                       input_device->set_mode(synfigapp::InputDevice::MODE_DISABLED);
-                       //synfigapp::Main::select_input_device(input_device);
-               }
-       }
-       // Once all devices are disabled be sure that the core pointer is the
-       // one selected. The user should decide later whether enable and save the
-       // rest of input devices found.
-       synfigapp::Main::select_input_device(gdk_device_get_core_pointer()->name);
-}
-
-DeviceTracker::~DeviceTracker()
-{
-}
-
-void
-DeviceTracker::save_preferences()
-{
-       GList * device_list = gdk_devices_list();
-       for (GList * itr = device_list; itr; itr = g_list_next(itr))
-       {
-               GdkDevice * gdk_device = reinterpret_cast<GdkDevice*>(itr->data);
-
-               InputDevice::Handle synfig_device = synfigapp::Main::find_input_device(gdk_device->name);
-               if (synfig_device == NULL)
-                       continue;
-
-               synfig_device->set_mode(InputDevice::Mode(gdk_device->mode));
-               if (gdk_device->num_axes > 0) {
-                       vector<synfigapp::InputDevice::AxisUse> axes;
-                       axes.resize(gdk_device->num_axes);
-                       for (int i = 0; i < gdk_device->num_axes; i++)
-                               axes[i] = InputDevice::AxisUse(gdk_device->axes[i].use);
-                       synfig_device->set_axes(axes);
-               }
-
-               if (gdk_device->num_keys > 0) {
-                       vector<synfigapp::InputDevice::DeviceKey> keys;
-                       keys.resize(gdk_device->num_keys);
-                       for (int i = 0; i < gdk_device->num_keys; i++) {
-                               keys[i].keyval = gdk_device->keys[i].keyval;
-                               keys[i].modifiers = gdk_device->keys[i].modifiers;
-                       }
-                       synfig_device->set_keys(keys);
-               }
-       }
-}
-
-void
-DeviceTracker::load_preferences()
-{
-       GList * device_list = gdk_devices_list();
-       for (GList * itr = device_list; itr; itr = g_list_next(itr))
-       {
-               GdkDevice * gdk_device = reinterpret_cast<GdkDevice*>(itr->data);
-
-               InputDevice::Handle synfig_device = synfigapp::Main::find_input_device(gdk_device->name);
-               if (synfig_device == NULL)
-                       continue;
-
-               gdk_device_set_mode(gdk_device, GdkInputMode(synfig_device->get_mode()));
-
-               const std::vector<synfigapp::InputDevice::AxisUse> axes = synfig_device->get_axes();
-               for (int axis = 0; axis < (int) axes.size(); axis++)
-                       gdk_device_set_axis_use(gdk_device, axis, GdkAxisUse(axes[axis]));
-
-               const std::vector<synfigapp::InputDevice::DeviceKey> keys = synfig_device->get_keys();
-               for (int key = 0; key < (int) keys.size(); key++)
-                       gdk_device_set_key(gdk_device, key, keys[key].keyval,
-                                       GdkModifierType(keys[key].modifiers));
-       }
-}
diff --git a/synfig-studio/src/gtkmm/devicetracker.h b/synfig-studio/src/gtkmm/devicetracker.h
deleted file mode 100644 (file)
index 14c0272..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file devicetracker.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_DEVICETRACKER_H
-#define __SYNFIG_DEVICETRACKER_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <synfig/string.h>
-#include <synfigapp/inputdevice.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 DeviceTracker
-{
-public:
-       DeviceTracker();
-       ~DeviceTracker();
-
-       void save_preferences();
-       void load_preferences();
-
-}; // END of class DeviceTracker
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/dialog_color.cpp b/synfig-studio/src/gtkmm/dialog_color.cpp
deleted file mode 100644 (file)
index 6953a75..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dialog_color.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "dialog_color.h"
-#include "widget_color.h"
-#include <synfig/general.h>
-#include <synfigapp/main.h>
-#include <gtkmm/button.h>
-#include "app.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Dialog_Color::Dialog_Color():
-       Dialog(_("Colors"), false, true),
-       dialog_settings(this, "color"),
-       busy_(false)
-{
-       set_type_hint(Gdk::WINDOW_TYPE_HINT_UTILITY);
-
-       create_color_edit_widget();
-       create_set_color_button("synfig-set_outline_color", _("Set as Outline"), 0,
-                       sigc::mem_fun(*this, &Dialog_Color::on_set_oc_pressed));
-       create_set_color_button("synfig-set_fill_color", _("Set as Fill"), 1,
-                       sigc::mem_fun(*this, &Dialog_Color::on_set_fc_pressed));
-       create_close_button();
-
-       add_accel_group(App::ui_manager()->get_accel_group());
-       show_all_children();
-}
-
-Dialog_Color::~Dialog_Color()
-{
-}
-
-void
-Dialog_Color::create_color_edit_widget()
-{
-       color_edit_widget = manage(new Widget_ColorEdit());
-       color_edit_widget->signal_value_changed().connect(sigc::mem_fun(*this,
-                       &studio::Dialog_Color::on_color_changed));
-       get_vbox()->pack_start(*color_edit_widget);
-}
-
-void
-Dialog_Color::create_set_color_button(const char *stock_id,
-               const Glib::ustring& tip_text, int index,
-               const sigc::slot0<void>& callback)
-{
-       Gtk::Button *set_color_button = manage(new Gtk::Button());
-       Gtk::Image *set_color_icon = manage(new Gtk::Image(Gtk::StockID(stock_id),
-                       Gtk::IconSize::IconSize(Gtk::ICON_SIZE_BUTTON)));
-       set_color_button->add(*set_color_icon);
-       set_color_icon->show();
-       tooltips.set_tip(*set_color_button, tip_text);
-       set_color_button->show();
-       add_action_widget(*set_color_button, index);
-       set_color_button->signal_clicked().connect(callback);
-}
-
-void
-Dialog_Color::create_close_button()
-{
-       Gtk::Button *close_button(manage(new Gtk::Button(Gtk::StockID("gtk-close"))));
-       close_button->show();
-       add_action_widget(*close_button, 2);
-       close_button->signal_clicked().connect(sigc::hide_return(sigc::mem_fun(*this,
-                       &Dialog_Color::on_close_pressed)));
-       signal_delete_event().connect(sigc::hide(sigc::mem_fun(*this,
-                       &Dialog_Color::on_close_pressed)));
-}
-
-void
-Dialog_Color::on_color_changed()
-{
-       busy_ = true;
-       signal_edited_(get_color());
-       busy_ = false;
-}
-
-void
-Dialog_Color::on_set_oc_pressed()
-{
-       busy_ = true;
-       synfigapp::Main::set_outline_color(get_color());
-       busy_ = false;
-}
-
-void
-Dialog_Color::on_set_fc_pressed()
-{
-       busy_ = true;
-       synfigapp::Main::set_fill_color(get_color());
-       busy_ = false;
-}
-
-bool
-Dialog_Color::on_close_pressed()
-{
-       busy_ = false;
-       grab_focus();
-       reset();
-       hide();
-       return true;
-}
-
-void
-Dialog_Color::reset()
-{
-       signal_edited_.clear();
-}
diff --git a/synfig-studio/src/gtkmm/dialog_color.h b/synfig-studio/src/gtkmm/dialog_color.h
deleted file mode 100644 (file)
index ee350cf..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dialog_color.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_DIALOG_COLOR_H
-#define __SYNFIG_STUDIO_DIALOG_COLOR_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtk/gtk.h>
-#include <gtkmm/dialog.h>
-#include <gtkmm/tooltips.h>
-#include <sigc++/functors/slot.h>
-
-#include "widget_coloredit.h"
-#include "dialogsettings.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 Widget_Color;
-
-class Dialog_Color : public Gtk::Dialog
-{
-       DialogSettings dialog_settings;
-       Gtk::Tooltips tooltips;
-
-       Widget_ColorEdit* color_edit_widget;
-
-       sigc::signal<void,synfig::Color> signal_edited_;
-
-       bool busy_;
-
-       void create_color_edit_widget();
-       void create_set_color_button(const char *stock_id,
-                       const Glib::ustring& tip_text, int index,
-                       const sigc::slot0<void>& callback);
-       void create_close_button();
-
-       void on_color_changed();
-       void on_set_oc_pressed();
-       void on_set_fc_pressed();
-       bool on_close_pressed();
-
-public:
-       Dialog_Color();
-       ~Dialog_Color();
-
-       sigc::signal<void,synfig::Color>& signal_edited() { return signal_edited_; }
-
-       void set_color(const synfig::Color& x) { color_edit_widget->set_value(x); }
-       synfig::Color get_color() const { return color_edit_widget->get_value(); }
-       void reset();
-
-       bool busy() const { return busy_; }
-
-}; // END of Dialog_Color
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/dialog_gradient.cpp b/synfig-studio/src/gtkmm/dialog_gradient.cpp
deleted file mode 100644 (file)
index fe060b9..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dialog_gradient.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "dialog_gradient.h"
-#include "widget_gradient.h"
-#include <gtkmm/frame.h>
-#include <gtkmm/table.h>
-#include <gtkmm/label.h>
-#include <synfig/general.h>
-#include <synfigapp/canvasinterface.h>
-#include <synfigapp/value_desc.h>
-#include <synfigapp/main.h>
-#include "widget_color.h"
-#include <gtkmm/spinbutton.h>
-#include "app.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Dialog_Gradient::Dialog_Gradient():
-       Dialog(_("Gradient Editor"),false,true),
-       dialog_settings(this,"gradient"),
-       adjustment_pos(0,0.0,1.0,0.001,0.001,0)
-{
-       set_type_hint(Gdk::WINDOW_TYPE_HINT_DIALOG);
-       set_keep_above(false);
-
-       set_role("gradient_editor");
-
-       // Setup the buttons
-       set_default_button = manage(new class Gtk::Button(Gtk::StockID(_("Set as Default"))));
-       set_default_button->show();
-       add_action_widget(*set_default_button,2);
-       set_default_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Gradient::on_set_default_pressed));
-
-       Gtk::Button *cancel_button(manage(new class Gtk::Button(Gtk::StockID("gtk-close"))));
-       cancel_button->show();
-       add_action_widget(*cancel_button,0);
-       cancel_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Gradient::hide));
-
-       Gtk::Table* table(manage(new Gtk::Table(2,2,false)));
-       get_vbox()->pack_start(*table);
-
-       widget_gradient=manage(new Widget_Gradient());
-       widget_gradient->set_editable();
-       widget_gradient->signal_cpoint_selected().connect(sigc::mem_fun(*this,&studio::Dialog_Gradient::on_cpoint_selected));
-       widget_gradient->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Gradient::on_changed));
-       //table->attach(*manage(new Gtk::Label(_("Not yet fully implemented"))), 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       table->attach(*widget_gradient, 0, 1, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       widget_color=manage(new Widget_ColorEdit());
-       widget_color->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Gradient::on_values_adjusted));
-       widget_color->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Gradient::on_changed));
-       widget_color->signal_activated().connect(sigc::mem_fun(*this,&studio::Dialog_Gradient::on_values_adjusted));
-       table->attach(*widget_color, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-
-       spinbutton_pos=manage(new class Gtk::SpinButton(adjustment_pos,0.0001,4));
-       spinbutton_pos->set_update_policy(Gtk::UPDATE_ALWAYS);
-       adjustment_pos.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Gradient::on_values_adjusted));
-       adjustment_pos.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Gradient::on_changed));
-       table->attach(*spinbutton_pos, 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-
-
-       add_accel_group(App::ui_manager()->get_accel_group());
-
-       show_all_children();
-}
-
-Dialog_Gradient::~Dialog_Gradient()
-{
-}
-
-void
-Dialog_Gradient::set_gradient(const synfig::Gradient& x)
-{
-       widget_gradient->set_value(x);
-}
-
-void
-Dialog_Gradient::reset()
-{
-       value_changed_connection.disconnect();
-       signal_edited_.clear();
-}
-
-void
-Dialog_Gradient::on_set_default_pressed()
-{
-       synfigapp::Main::set_gradient(get_gradient());
-}
-
-void
-Dialog_Gradient::on_changed()
-{
-       signal_edited_(get_gradient());
-}
-
-void
-Dialog_Gradient::on_cpoint_selected(synfig::Gradient::CPoint x)
-{
-       widget_color->set_value(x.color);
-       adjustment_pos.set_value(x.pos);
-}
-
-void
-Dialog_Gradient::on_values_adjusted()
-{
-       synfig::Gradient::CPoint x(widget_gradient->get_selected_cpoint());
-       x.color=widget_color->get_value();
-       x.pos=adjustment_pos.get_value();
-       widget_gradient->update_cpoint(x);
-}
-
-static void
-dialog_gradient_value_desc_edit(synfig::Gradient /*g*/,synfigapp::ValueDesc /*x*/,handle<synfigapp::CanvasInterface> /*canvas_interface*/)
-{
-//     canvas_interface->connect_value(x,ValueBase(g));
-}
-
-void
-Dialog_Gradient::edit(const synfigapp::ValueDesc &x, etl::handle<synfigapp::CanvasInterface> canvas_interface, synfig::Time time)
-{
-       reset();
-       if(x.is_const())
-               set_gradient(x.get_value().get(Gradient()));
-       else if(x.is_value_node())
-               set_gradient((*x.get_value_node())(time).get(Gradient()));
-
-       signal_edited().connect(
-               sigc::bind(
-                       sigc::bind(
-                               sigc::ptr_fun(dialog_gradient_value_desc_edit),
-                               canvas_interface
-                       ),
-                       x
-               )
-       );
-
-       present();
-}
diff --git a/synfig-studio/src/gtkmm/dialog_gradient.h b/synfig-studio/src/gtkmm/dialog_gradient.h
deleted file mode 100644 (file)
index 698ba3c..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dialog_gradient.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_DIALOG_GRADIENT_H
-#define __SYNFIG_STUDIO_DIALOG_GRADIENT_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtk/gtk.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/table.h>
-#include <gtkmm/button.h>
-#include <gtkmm/dialog.h>
-#include <gtkmm/drawingarea.h>
-#include <gtkmm/optionmenu.h>
-#include <gtkmm/checkbutton.h>
-
-#include <synfig/gamma.h>
-#include <synfig/time.h>
-
-#include "widget_gradient.h"
-#include "widget_coloredit.h"
-
-#include <synfigapp/value_desc.h>
-#include <synfig/time.h>
-
-#include "dialogsettings.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 Gtk { class Menu; class SpinButton; class Adjustment; };
-
-namespace synfigapp {
-class CanvasInterface;
-};
-
-namespace studio {
-
-class Widget_Gradient;
-class Widget_ColorEdit;
-
-class Dialog_Gradient : public Gtk::Dialog
-{
-       DialogSettings dialog_settings;
-
-       Gtk::SpinButton *spinbutton_pos;
-
-       Gtk::Adjustment adjustment_pos;
-
-
-       sigc::signal<void,synfig::Gradient> signal_edited_;
-
-       sigc::connection value_changed_connection;
-
-       void on_set_default_pressed();
-
-       void on_cpoint_selected(synfig::Gradient::CPoint x);
-       void on_values_adjusted();
-
-       Widget_Gradient* widget_gradient;
-       Widget_ColorEdit* widget_color;
-       Gtk::Button *set_default_button;
-
-       void on_changed();
-
-public:
-
-       sigc::signal<void,synfig::Gradient>& signal_edited() { return signal_edited_; }
-
-       void set_gradient(const synfig::Gradient& x);
-
-       const synfig::Gradient& get_gradient()const { return widget_gradient->get_value(); }
-
-       void set_default_button_set_sensitive(bool sensitive) { set_default_button->set_sensitive(sensitive); }
-
-       void reset();
-
-
-       Dialog_Gradient();
-       ~Dialog_Gradient();
-       //! Interface to external calls to fill in the Gradient Editor Dialog
-       //! when a Constant ValueNode or a Animated ValueNode is double cliked.
-       void edit(const synfigapp::ValueDesc &x, etl::handle<synfigapp::CanvasInterface> canvas_interface, synfig::Time time=0);
-}; // END of Dialog_Gradient
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/dialog_keyframe.cpp b/synfig-studio/src/gtkmm/dialog_keyframe.cpp
deleted file mode 100644 (file)
index b746490..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dialog_keyframe.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "dialog_keyframe.h"
-#include <gtkmm/scrolledwindow.h>
-#include <gtkmm/button.h>
-#include "widget_waypointmodel.h"
-#include <synfigapp/action.h>
-#include <synfigapp/instance.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Dialog_Keyframe::Dialog_Keyframe(Gtk::Window& parent, etl::handle<synfigapp::CanvasInterface> canvas_interface):
-       Gtk::Dialog(_("Keyframe Dialog"),parent,false,true),
-       canvas_interface(canvas_interface)
-{
-       // Set up the buttons
-       {
-               Gtk::Button *ok_button(manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))));
-               ok_button->show();
-               add_action_widget(*ok_button,2);
-               ok_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Keyframe::on_ok_pressed));
-
-               Gtk::Button *apply_button(manage(new class Gtk::Button(Gtk::StockID("gtk-apply"))));
-               apply_button->show();
-               add_action_widget(*apply_button,1);
-               apply_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Keyframe::on_apply_pressed));
-
-               Gtk::Button *delete_button(manage(new class Gtk::Button(Gtk::StockID("gtk-delete"))));
-               delete_button->show();
-               add_action_widget(*delete_button,3);
-               delete_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Keyframe::on_delete_pressed));
-
-               Gtk::Button *cancel_button(manage(new class Gtk::Button(Gtk::StockID("gtk-close"))));
-               cancel_button->show();
-               add_action_widget(*cancel_button,0);
-               cancel_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Keyframe::hide));
-       }
-
-       Gtk::Table *table=manage(new Gtk::Table(2,2,false));
-
-       get_vbox()->pack_start(*table);
-
-/*  // \todo Allow setting descriptions for keyframes
-
-       entry_description.set_text(_("Not yet implemented"));
-
-       table->attach(*manage(new Gtk::Label(_("Description"))), 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       table->attach(entry_description, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-*/
-
-       table->show_all();
-
-       widget_waypoint_model=Gtk::manage(new Widget_WaypointModel());
-       widget_waypoint_model->show();
-       table->attach(*widget_waypoint_model, 0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-
-}
-
-Dialog_Keyframe::~Dialog_Keyframe()
-{
-}
-
-const synfig::Keyframe&
-Dialog_Keyframe::get_keyframe()const
-{
-       return keyframe_;
-}
-
-void
-Dialog_Keyframe::set_keyframe(const synfig::Keyframe& x)
-{
-       keyframe_=x;
-}
-
-void
-Dialog_Keyframe::on_ok_pressed()
-{
-       on_apply_pressed();
-       hide();
-}
-
-
-void
-Dialog_Keyframe::on_delete_pressed()
-{
-       synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeRemove"));
-
-       assert(action);
-
-       action->set_param("canvas",canvas_interface->get_canvas());
-       action->set_param("canvas_interface",canvas_interface);
-       action->set_param("keyframe",keyframe_);
-       action->set_param("model",widget_waypoint_model->get_waypoint_model());
-
-       if(canvas_interface->get_instance()->perform_action(action))
-       {
-               hide();
-       }
-}
-
-
-void
-Dialog_Keyframe::on_apply_pressed()
-{
-       if(widget_waypoint_model->get_waypoint_model().is_trivial())
-               return;
-
-       synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeWaypointSet"));
-
-       assert(action);
-
-       action->set_param("canvas",canvas_interface->get_canvas());
-       action->set_param("canvas_interface",canvas_interface);
-       action->set_param("keyframe",keyframe_);
-       action->set_param("model",widget_waypoint_model->get_waypoint_model());
-
-       if(!canvas_interface->get_instance()->perform_action(action))
-       {
-       }
-}
diff --git a/synfig-studio/src/gtkmm/dialog_keyframe.h b/synfig-studio/src/gtkmm/dialog_keyframe.h
deleted file mode 100644 (file)
index 1222fd6..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dialog_keyframe.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_DIALOG_KEYFRAME_H
-#define __SYNFIG_STUDIO_DIALOG_KEYFRAME_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/dialog.h>
-#include <gtkmm/window.h>
-#include <gtkmm/tooltips.h>
-#include <gtkmm/table.h>
-#include <gtkmm/entry.h>
-
-#include <synfigapp/canvasinterface.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 Widget_WaypointModel;
-
-class Dialog_Keyframe : public Gtk::Dialog
-{
-       Gtk::Tooltips tooltips_;
-       etl::handle<synfigapp::CanvasInterface> canvas_interface;
-
-       synfig::Keyframe keyframe_;
-
-       Gtk::Entry entry_description;
-
-       Widget_WaypointModel* widget_waypoint_model;
-
-       void on_ok_pressed();
-       void on_apply_pressed();
-       void on_delete_pressed();
-
-public:
-       Dialog_Keyframe(Gtk::Window& parent,etl::handle<synfigapp::CanvasInterface> canvas_interface);
-       ~Dialog_Keyframe();
-
-       const synfig::Keyframe& get_keyframe()const;
-       void set_keyframe(const synfig::Keyframe& x);
-
-private:
-
-}; // END of class Dialog_Keyframe
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/dialog_preview.cpp b/synfig-studio/src/gtkmm/dialog_preview.cpp
deleted file mode 100644 (file)
index 0782869..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dialog_preview.cpp
-**     \brief Preview dialog File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "dialog_preview.h"
-#include "preview.h"
-#include <gtkmm/spinbutton.h>
-#include <gtkmm/alignment.h>
-#include <gtkmm/frame.h>
-#include <gtkmm/box.h>
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-using namespace synfig;
-using namespace studio;
-using namespace Gtk;
-
-/* === M A C R O S ========================================================= */
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-/* === E N T R Y P O I N T ================================================= */
-
-//dialog_preview stuff...
-Dialog_Preview::Dialog_Preview()
-:Dialog(_("Preview Window"),false,true),
-settings(this,"preview")
-{
-       get_vbox()->pack_start(preview);
-}
-
-Dialog_Preview::~Dialog_Preview()
-{
-}
-
-void Dialog_Preview::set_preview(etl::handle<Preview> prev)
-{
-       get_window().clear();
-       preview.set_preview(prev);
-       //preview.update();
-}
-
-void Dialog_Preview::on_hide()
-{
-       Dialog::on_hide();
-       preview.stop();
-       preview.stoprender();
-}
-
-//dialog_previewoptions stuff
-Dialog_PreviewOptions::Dialog_PreviewOptions()
-:Dialog(_("Preview Options"),false,true),
-adj_zoom(0.5,0.1,5.0,0.1,0.2),
-adj_fps(15,1,120,1,5),
-check_overbegin(_("_Begin Time"),false),
-check_overend(_("_End Time"),false),
-settings(this,"prevoptions")
-{
-       //framerate = 15.0f;
-       //zoom = 0.2f;
-
-       //set the fps of the time widgets
-       Gtk::Alignment *dialogPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
-       dialogPadding->set_padding(12, 12, 12, 12);
-       get_vbox()->add(*dialogPadding);
-
-       Gtk::VBox *dialogBox = manage(new Gtk::VBox(false, 12));
-       dialogPadding->add(*dialogBox);
-
-       Gtk::Frame *generalFrame = manage(new Gtk::Frame(_("General Settings")));
-       generalFrame->set_shadow_type(Gtk::SHADOW_NONE);
-       ((Gtk::Label *) generalFrame->get_label_widget())->set_markup(_("<b>General Settings</b>"));
-       dialogBox->pack_start(*generalFrame, false, false, 0);
-
-       Gtk::Alignment *generalPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
-       generalPadding->set_padding(6, 0, 24, 0);
-       generalFrame->add(*generalPadding);
-
-       Gtk::Table *generalTable = manage(new Gtk::Table(2, 2, false));
-       generalTable->set_row_spacings(6);
-       generalTable->set_col_spacings(12);
-       generalPadding->add(*generalTable);
-
-       Gtk::Label *zoomLabel = manage(new Gtk::Label(_("_Zoom")));
-       zoomLabel->set_alignment(0, 0.5);
-       zoomLabel->set_use_underline(TRUE);
-       Gtk::SpinButton *zoomSpinner = manage(new Gtk::SpinButton(adj_zoom, 0.1, 2));
-       zoomLabel->set_mnemonic_widget(*zoomSpinner);
-       zoomSpinner->set_alignment(1);
-       generalTable->attach(*zoomLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       generalTable->attach(*zoomSpinner, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
-       Gtk::Label *fpsLabel = manage(new Gtk::Label(_("_Frames per second")));
-       fpsLabel->set_alignment(0, 0.5);
-       fpsLabel->set_use_underline(TRUE);
-       Gtk::SpinButton *fpsSpinner = manage(new Gtk::SpinButton(adj_fps, 1, 1));
-       fpsLabel->set_mnemonic_widget(*fpsSpinner);
-       fpsSpinner->set_alignment(1);
-       generalTable->attach(*fpsLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       generalTable->attach(*fpsSpinner, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
-       Gtk::Frame *timeFrame = manage(new Gtk::Frame(_("Time Settings")));
-       timeFrame->set_shadow_type(Gtk::SHADOW_NONE);
-       ((Gtk::Label *) timeFrame->get_label_widget())->set_markup(_("<b>Time Settings</b>"));
-       dialogBox->pack_start(*timeFrame, false, false, 0);
-
-       Gtk::Alignment *timePadding = manage(new Gtk::Alignment(0, 0, 1, 1));
-       timePadding->set_padding(6, 0, 24, 0);
-       timeFrame->add(*timePadding);
-
-       Gtk::Table *timeTable = manage(new Gtk::Table(2, 2, false));
-       timeTable->set_row_spacings(6);
-       timeTable->set_col_spacings(12);
-       timePadding->add(*timeTable);
-
-       check_overbegin.set_alignment(0, 0.5);
-       check_overbegin.set_use_underline(TRUE);
-       check_overend.set_alignment(0, 0.5);
-       check_overend.set_use_underline(TRUE);
-       time_begin.set_alignment(1);
-       time_end.set_alignment(1);
-       timeTable->attach(check_overbegin, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       timeTable->attach(time_begin, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       timeTable->attach(check_overend, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       timeTable->attach(time_end, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
-       check_overbegin.signal_toggled().connect(sigc::mem_fun(*this,&Dialog_PreviewOptions::on_overbegin_toggle));
-       check_overend.signal_toggled().connect(sigc::mem_fun(*this,&Dialog_PreviewOptions::on_overend_toggle));
-
-       Gtk::Button *cancelButton = manage(new Gtk::Button(Gtk::StockID("gtk-cancel")));
-       cancelButton->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_PreviewOptions::on_cancel_pressed));
-       add_action_widget(*cancelButton, 1);
-
-       Gtk::Button *okbutton = manage(new Gtk::Button(Gtk::StockID("gtk-go-forward")));
-       okbutton->set_label(_("Preview"));
-       okbutton->signal_clicked().connect(sigc::mem_fun(*this,&Dialog_PreviewOptions::on_ok_pressed));
-       add_action_widget(*okbutton, 0);
-
-       time_begin.set_sensitive(false);
-       time_end.set_sensitive(false);
-       show_all();
-}
-
-Dialog_PreviewOptions::~Dialog_PreviewOptions()
-{
-}
-
-void Dialog_PreviewOptions::on_ok_pressed()
-{
-       PreviewInfo     i;
-       i.zoom = get_zoom();
-       i.fps = get_fps();
-       i.overbegin = get_begin_override();
-       i.overend = get_end_override();
-       if(i.overbegin) i.begintime = (float)get_begintime();
-       if(i.overend)   i.endtime = (float)get_endtime();
-
-       hide();
-       signal_finish_(i);
-       signal_finish_.clear();
-}
-
-void
-Dialog_PreviewOptions::on_cancel_pressed()
-{
-       hide();
-}
-
-void Dialog_PreviewOptions::on_overbegin_toggle()
-{
-       time_begin.set_sensitive(get_begin_override());
-}
-
-void Dialog_PreviewOptions::on_overend_toggle()
-{
-       time_end.set_sensitive(get_end_override());
-}
-
-void studio::Dialog_PreviewOptions::set_global_fps(float f)
-{
-       globalfps = f;
-       time_begin.set_fps(f);
-       time_end.set_fps(f);
-}
diff --git a/synfig-studio/src/gtkmm/dialog_preview.h b/synfig-studio/src/gtkmm/dialog_preview.h
deleted file mode 100644 (file)
index 78e7543..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dialog_preview.h
-**     \brief Preview dialog 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_GTKMM_DIALOG_PREVIEW_H
-#define __SYNFIG_GTKMM_DIALOG_PREVIEW_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/adjustment.h>
-#include <gtkmm/dialog.h>
-#include <gtkmm/menu.h>
-#include <gtkmm/spinbutton.h>
-#include <gtkmm/dialogsettings.h>
-
-#include "preview.h"
-#include <gtkmm/widget_time.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 {
-
-struct PreviewInfo
-{
-       float zoom,fps,begintime,endtime;
-       bool overbegin,overend;
-};
-
-class Dialog_Preview : public Gtk::Dialog
-{
-       Widget_Preview  preview;
-       DialogSettings  settings;
-
-       //etl::handle<synfig::Canvas> canvas;
-
-public:
-       Dialog_Preview();
-       ~Dialog_Preview();
-
-    void set_preview(etl::handle<Preview> prev);
-
-       Widget_Preview &get_widget() {return preview;}
-       const Widget_Preview &get_widget() const {return preview;}
-
-       virtual void on_hide();
-       //other forwarding functions...
-}; // END of Dialog_Preview
-
-class Dialog_PreviewOptions : public Gtk::Dialog
-{
-       //all the info needed to construct a render description...
-       Gtk::Adjustment adj_zoom;       // factor at which to resize the window...
-
-       Gtk::Adjustment adj_fps;        // how often to take samples of the animation
-
-       studio::Widget_Time time_begin;
-       studio::Widget_Time time_end;
-
-       Gtk::CheckButton check_overbegin;
-       Gtk::CheckButton check_overend;
-
-       DialogSettings  settings;
-
-       float   globalfps;
-
-       // for finishing
-       void on_ok_pressed();
-       void on_cancel_pressed();
-
-       //for ui stuff
-       void on_overbegin_toggle();
-       void on_overend_toggle();
-
-       sigc::signal<void,const PreviewInfo &>  signal_finish_;
-public:
-       Dialog_PreviewOptions();
-       ~Dialog_PreviewOptions();
-
-       float get_zoom() const { return adj_zoom.get_value(); }
-       void set_zoom(float z) { adj_zoom.set_value(z); }
-
-       float get_fps() const { return adj_fps.get_value(); }
-       void set_fps(float z) { adj_fps.set_value(z); }
-
-       float get_global_fps() const { return globalfps; }
-       void set_global_fps(float f);
-
-       synfig::Time get_begintime() const { return time_begin.get_value(); }
-       void set_begintime(const synfig::Time &t) { time_begin.set_value(t); }
-
-       synfig::Time get_endtime() const { return time_end.get_value(); }
-       void set_endtime(const synfig::Time &t) { time_end.set_value(t); }
-
-       bool get_begin_override() const { return check_overbegin.get_active(); }
-       void set_begin_override(bool o) { check_overbegin.set_active(o); }
-
-       bool get_end_override() const { return check_overend.get_active(); }
-       void set_end_override(bool o) { check_overend.set_active(o); }
-
-       sigc::signal<void,const PreviewInfo &>  &signal_finish() {return signal_finish_;}
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/dialog_setup.cpp b/synfig-studio/src/gtkmm/dialog_setup.cpp
deleted file mode 100644 (file)
index 6272cb3..0000000
+++ /dev/null
@@ -1,839 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dialog_setup.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 2008 Chris Moore
-**     Copyright (c) 2008, 2009 Carlos López
-**
-**     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 <config.h>
-#endif
-
-#include "dialog_setup.h"
-#include "app.h"
-#include <gtkmm/scale.h>
-#include <gtkmm/table.h>
-#include <gtkmm/frame.h>
-#include <gtkmm/notebook.h>
-#include "widget_enum.h"
-#include "autorecover.h"
-
-#include <ETL/stringf>
-#include <ETL/misc>
-#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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-static void
-attach_label(Gtk::Table *table, String str, guint col, guint xpadding, guint ypadding)
-{
-       Gtk::Label* label(manage(new Gtk::Label((str + ":").c_str())));
-       label->set_alignment(Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
-       table->attach(*label, 0, 1, col, col+1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
-}
-
-Dialog_Setup::Dialog_Setup():
-       Dialog(_("Synfig Studio Setup"),false,true),
-       adj_gamma_r(2.2,0.1,3.0,0.025,0.025,0.025),
-       adj_gamma_g(2.2,0.1,3.0,0.025,0.025,0.025),
-       adj_gamma_b(2.2,0.1,3.0,0.025,0.025,0.025),
-       adj_recent_files(15,1,50,1,1,0),
-       adj_undo_depth(100,10,5000,1,1,1),
-       toggle_use_colorspace_gamma(_("Visually Linear Color Selection")),
-#ifdef SINGLE_THREADED
-       toggle_single_threaded(_("Use Only a Single Thread")),
-#endif
-       toggle_restrict_radius_ducks(_("Restrict Real-Valued Ducks to Top Right Quadrant")),
-       toggle_resize_imported_images(_("Scale New Imported Images to Fit Canvas")),
-       adj_pref_x_size(480,1,10000,1,10,0),
-       adj_pref_y_size(270,1,10000,1,10,0),
-       adj_pref_fps(24.0,1.0,100,0.1,1,0)
-
-       {
-       // Setup the buttons
-
-       Gtk::Button *ok_button(manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))));
-       ok_button->show();
-       add_action_widget(*ok_button,2);
-       ok_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Setup::on_ok_pressed));
-
-       Gtk::Button *apply_button(manage(new class Gtk::Button(Gtk::StockID("gtk-apply"))));
-       apply_button->show();
-       add_action_widget(*apply_button,1);
-       apply_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Setup::on_apply_pressed));
-
-       Gtk::Button *cancel_button(manage(new class Gtk::Button(Gtk::StockID("gtk-close"))));
-       cancel_button->show();
-       add_action_widget(*cancel_button,0);
-       cancel_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Setup::hide));
-
-
-       // Notebook
-       Gtk::Notebook *notebook=manage(new class Gtk::Notebook());
-       get_vbox()->pack_start(*notebook);
-
-
-       // Gamma
-       Gtk::Table *gamma_table=manage(new Gtk::Table(2,2,false));
-       notebook->append_page(*gamma_table,_("Gamma"));
-
-       gamma_table->attach(gamma_pattern, 0, 2, 0, 1, Gtk::EXPAND, Gtk::SHRINK|Gtk::FILL, 0, 0);
-
-       Gtk::HScale* scale_gamma_r(manage(new Gtk::HScale(adj_gamma_r)));
-       gamma_table->attach(*manage(new Gtk::Label(_("Red"))), 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       gamma_table->attach(*scale_gamma_r, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       adj_gamma_r.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Setup::on_gamma_r_change));
-
-       Gtk::HScale* scale_gamma_g(manage(new Gtk::HScale(adj_gamma_g)));
-       gamma_table->attach(*manage(new Gtk::Label(_("Green"))), 0, 1, 2, 3, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       gamma_table->attach(*scale_gamma_g, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       adj_gamma_g.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Setup::on_gamma_g_change));
-
-       Gtk::HScale* scale_gamma_b(manage(new Gtk::HScale(adj_gamma_b)));
-       gamma_table->attach(*manage(new Gtk::Label(_("Blue"))), 0, 1, 3, 4, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       gamma_table->attach(*scale_gamma_b, 1, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       adj_gamma_b.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Setup::on_gamma_b_change));
-
-       gamma_table->attach(*manage(new Gtk::Label(_("Black Level"))), 0, 1, 4, 5, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       gamma_table->attach(black_level_selector, 1, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       black_level_selector.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Setup::on_black_level_change));
-
-       //gamma_table->attach(*manage(new Gtk::Label(_("Red-Blue Level"))), 0, 1, 5, 6, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       //gamma_table->attach(red_blue_level_selector, 1, 2, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       //red_blue_level_selector.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Setup::on_red_blue_level_change));
-
-
-       // Misc
-       Gtk::Table *misc_table=manage(new Gtk::Table(2,2,false));
-       notebook->append_page(*misc_table,_("Misc."));
-
-       int xpadding(8), ypadding(8);
-
-       // Misc - Timestamp
-       timestamp_menu=manage(new class Gtk::Menu());
-       attach_label(misc_table, _("Timestamp"), 0, xpadding, ypadding);
-       misc_table->attach(timestamp_optionmenu, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
-
-#define ADD_TIMESTAMP(desc,x)                                                                  \
-       timestamp_menu->items().push_back(                                                      \
-               Gtk::Menu_Helpers::MenuElem(                                                    \
-                       desc,                                                                                           \
-                       sigc::bind(                                                                                     \
-                               sigc::mem_fun(                                                                  \
-                                       *this,                                                                          \
-                                       &studio::Dialog_Setup::set_time_format),        \
-                               x)));
-       ADD_TIMESTAMP("HH:MM:SS.FF",            Time::FORMAT_VIDEO      );
-       ADD_TIMESTAMP("(HHh MMm SSs) FFf",      Time::FORMAT_NORMAL     );
-       ADD_TIMESTAMP("(HHhMMmSSs)FFf",         Time::FORMAT_NORMAL     | Time::FORMAT_NOSPACES );
-       ADD_TIMESTAMP("HHh MMm SSs FFf",        Time::FORMAT_NORMAL     | Time::FORMAT_FULL             );
-       ADD_TIMESTAMP("HHhMMmSSsFFf",           Time::FORMAT_NORMAL     | Time::FORMAT_NOSPACES | Time::FORMAT_FULL);
-       ADD_TIMESTAMP("FFf",                            Time::FORMAT_FRAMES );
-
-       timestamp_optionmenu.set_menu(*timestamp_menu);
-
-#undef ADD_TIMESTAMP
-
-       {
-               ParamDesc param_desc;
-               param_desc
-                       .set_hint("enum")
-                       .add_enum_value(Distance::SYSTEM_UNITS,"u",_("Units"))
-                       .add_enum_value(Distance::SYSTEM_PIXELS,"px",_("Pixels"))
-                       .add_enum_value(Distance::SYSTEM_POINTS,"pt",_("Points"))
-                       .add_enum_value(Distance::SYSTEM_INCHES,"in",_("Inches"))
-                       .add_enum_value(Distance::SYSTEM_METERS,"m",_("Meters"))
-                       .add_enum_value(Distance::SYSTEM_CENTIMETERS,"cm",_("Centimeters"))
-                       .add_enum_value(Distance::SYSTEM_MILLIMETERS,"mm",_("Millimeters"));
-
-               widget_enum=manage(new Widget_Enum());
-               widget_enum->set_param_desc(param_desc);
-
-               attach_label(misc_table, _("Unit System"), 1, xpadding, ypadding);
-               misc_table->attach(*widget_enum, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
-       }
-
-       // Misc - recent files
-       Gtk::SpinButton* recent_files_spinbutton(manage(new Gtk::SpinButton(adj_recent_files,1,0)));
-       attach_label(misc_table, _("Recent Files"), 2, xpadding, ypadding);
-       misc_table->attach(*recent_files_spinbutton, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
-
-       // Misc - use_colorspace_gamma
-       misc_table->attach(toggle_use_colorspace_gamma, 0, 2, 7, 8, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
-
-#ifdef SINGLE_THREADED
-       // Misc - single_threaded
-       misc_table->attach(toggle_single_threaded, 0, 2, 10, 11, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
-#endif
-
-       // Misc - auto backup interval
-       attach_label(misc_table, _("Auto Backup Interval (0 to disable)"), 3, xpadding, ypadding);
-       misc_table->attach(auto_backup_interval, 1, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
-
-       // Misc - restrict_radius_ducks
-       misc_table->attach(toggle_restrict_radius_ducks, 0, 2, 8, 9, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
-
-       // Misc - resize_imported_images
-       misc_table->attach(toggle_resize_imported_images, 0, 2, 9, 10, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
-
-       // Misc - browser_command
-       attach_label(misc_table, _("Browser Command"), 4, xpadding, ypadding);
-       misc_table->attach(textbox_browser_command, 1, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
-
-       // Document
-       Gtk::Table *document_table = manage(new Gtk::Table(2, 4, false));
-       notebook->append_page(*document_table, _("Document"));
-
-       // Document - Preferred file name prefix
-       attach_label(document_table, _("New Document filename prefix"), 0, xpadding, ypadding);
-       document_table->attach(textbox_custom_filename_prefix, 1, 4, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
-       tooltips_.set_tip(textbox_custom_filename_prefix, _("File name prefix for the new created document"));
-
-       // Document - New Document X size
-       pref_x_size_spinbutton = Gtk::manage(new Gtk::SpinButton(adj_pref_x_size, 1, 0));
-       attach_label(document_table, _("New Document X size"),1, xpadding, ypadding);
-       document_table->attach(*pref_x_size_spinbutton, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
-       tooltips_.set_tip(*pref_x_size_spinbutton, _("Width in pixels of the new created document"));
-
-       // Document - New Document Y size
-       pref_y_size_spinbutton = Gtk::manage(new Gtk::SpinButton(adj_pref_y_size, 1, 0));
-       attach_label(document_table,_("New Document Y size"), 2, xpadding, ypadding);
-       document_table->attach(*pref_y_size_spinbutton, 1, 2, 2, 3,Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
-       tooltips_.set_tip(*pref_y_size_spinbutton, _("High in pixels of the new created document"));
-
-       //Document - Template for predefined sizes of canvases.
-       size_template_combo = Gtk::manage(new Gtk::ComboBoxText());
-       Gtk::Label* label(manage(new Gtk::Label(_("Predefined Resolutions:"))));
-       label->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
-       document_table->attach(*label, 2, 3, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
-       document_table->attach(*size_template_combo, 2, 3, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
-       size_template_combo->signal_changed().connect(sigc::mem_fun(*this, &studio::Dialog_Setup::on_size_template_combo_change));
-       size_template_combo->prepend_text(_("4096x3112 Full Aperture 4K"));
-       size_template_combo->prepend_text(_("2048x1556 Full Aperture Native 2K"));
-       size_template_combo->prepend_text(_("1920x1080 HDTV 1080p/i"));
-       size_template_combo->prepend_text(_("1280x720  HDTV 720p"));
-       size_template_combo->prepend_text(_("720x576   DVD PAL"));
-       size_template_combo->prepend_text(_("720x480   DVD NTSC"));
-       size_template_combo->prepend_text(_("720x540   Web 720x"));
-       size_template_combo->prepend_text(_("720x405   Web 720x HD"));
-       size_template_combo->prepend_text(_("640x480   Web 640x"));
-       size_template_combo->prepend_text(_("640x360   Web 640x HD"));
-       size_template_combo->prepend_text(_("480x360   Web 480x"));
-       size_template_combo->prepend_text(_("480x270   Web 480x HD"));
-       size_template_combo->prepend_text(_("360x270   Web 360x"));
-       size_template_combo->prepend_text(_("360x203   Web 360x HD"));
-       size_template_combo->prepend_text(DEFAULT_PREDEFINED_SIZE);
-
-       //Document - Template for predefined fps
-       fps_template_combo = Gtk::manage(new Gtk::ComboBoxText());
-       Gtk::Label* label1(manage(new Gtk::Label(_("Predefined FPS:"))));
-       label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
-       document_table->attach(*label1, 2, 3, 3, 4, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
-       document_table->attach(*fps_template_combo,2, 3, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
-       fps_template_combo->signal_changed().connect(sigc::mem_fun(*this, &studio::Dialog_Setup::on_fps_template_combo_change));
-       //Document - Fill the FPS combo box with proper strings (not localised)
-       float f[8];
-       f[0] = 60;
-       f[1] = 50;
-       f[2] = 30;
-       f[3] = 25;
-       f[4] = 24.967;
-       f[5] = 24;
-       f[6] = 15;
-       f[7] = 12;
-       for (int i=0; i<8; i++)
-               fps_template_combo->prepend_text(strprintf("%5.3f", f[i]));
-
-       fps_template_combo->prepend_text(DEFAULT_PREDEFINED_FPS);
-
-       // Document - New Document FPS
-       pref_fps_spinbutton = Gtk::manage(new Gtk::SpinButton(adj_pref_fps, 1, 3));
-       attach_label(document_table,_("New Document FPS"), 4, xpadding, ypadding);
-       document_table->attach(*pref_fps_spinbutton, 1, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
-       tooltips_.set_tip(*pref_fps_spinbutton, _("Frames per second of the new created document"));
-
-       show_all_children();
-}
-
-Dialog_Setup::~Dialog_Setup()
-{
-}
-
-void
-Dialog_Setup::on_ok_pressed()
-{
-    on_apply_pressed();
-       hide();
-}
-
-void
-Dialog_Setup::on_apply_pressed()
-{
-       App::gamma.set_all(1.0/adj_gamma_r.get_value(),1.0/adj_gamma_g.get_value(),1.0/adj_gamma_b.get_value(),black_level_selector.get_value(),red_blue_level_selector.get_value());
-
-       App::set_max_recent_files((int)adj_recent_files.get_value());
-
-       // Set the time format
-       App::set_time_format(get_time_format());
-
-       // Set the use_colorspace_gamma flag
-       App::use_colorspace_gamma=toggle_use_colorspace_gamma.get_active();
-
-#ifdef SINGLE_THREADED
-       // Set the single_threaded flag
-       App::single_threaded=toggle_single_threaded.get_active();
-#endif
-
-       // Set the auto backup interval
-       App::auto_recover->set_timeout(auto_backup_interval.get_value() * 1000);
-
-       App::distance_system=Distance::System(widget_enum->get_value());
-
-       // Set the restrict_radius_ducks flag
-       App::restrict_radius_ducks=toggle_restrict_radius_ducks.get_active();
-
-       // Set the resize_imported_images flag
-       App::resize_imported_images=toggle_resize_imported_images.get_active();
-
-       // Set the browser_command textbox
-       App::browser_command=textbox_browser_command.get_text();
-
-       // Set the preferred file name prefix
-       App::custom_filename_prefix=textbox_custom_filename_prefix.get_text();
-
-       // Set the preferred new Document X dimension
-       App::preferred_x_size=int(adj_pref_x_size.get_value());
-
-       // Set the preferred new Document Y dimension
-       App::preferred_y_size=int(adj_pref_y_size.get_value());
-
-       // Set the preferred Predefined size
-       App::predefined_size=size_template_combo->get_active_text();
-
-       // Set the preferred Predefined fps
-       App::predefined_fps=fps_template_combo->get_active_text();
-
-       // Set the preferred FPS
-       App::preferred_fps=Real(adj_pref_fps.get_value());
-
-       App::save_settings();
-}
-
-void
-Dialog_Setup::on_gamma_r_change()
-{
-       gamma_pattern.set_gamma_r(1.0/adj_gamma_r.get_value());
-       gamma_pattern.refresh();
-       gamma_pattern.queue_draw();
-}
-
-void
-Dialog_Setup::on_gamma_g_change()
-{
-       gamma_pattern.set_gamma_g(1.0/adj_gamma_g.get_value());
-       gamma_pattern.refresh();
-       gamma_pattern.queue_draw();
-}
-
-void
-Dialog_Setup::on_gamma_b_change()
-{
-       gamma_pattern.set_gamma_b(1.0/adj_gamma_b.get_value());
-       gamma_pattern.refresh();
-       gamma_pattern.queue_draw();
-}
-
-void
-Dialog_Setup::on_black_level_change()
-{
-       gamma_pattern.set_black_level(black_level_selector.get_value());
-       gamma_pattern.refresh();
-       gamma_pattern.queue_draw();
-}
-
-void
-Dialog_Setup::on_red_blue_level_change()
-{
-       gamma_pattern.set_red_blue_level(red_blue_level_selector.get_value());
-       gamma_pattern.refresh();
-       gamma_pattern.queue_draw();
-}
-
-void
-Dialog_Setup::on_size_template_combo_change()
-{
-       String selection(size_template_combo->get_active_text());
-       if(selection==DEFAULT_PREDEFINED_SIZE)
-       {
-               pref_y_size_spinbutton->set_sensitive(true);
-               pref_x_size_spinbutton->set_sensitive(true);
-               return;
-       }
-       String::size_type locx=selection.find_first_of("x"); // here should be some comparison with string::npos
-       String::size_type locspace=selection.find_first_of(" ");
-       String x_size(selection.substr(0,locx));
-       String y_size(selection.substr(locx+1,locspace));
-       int x=atoi(x_size.c_str());
-       int y=atoi(y_size.c_str());
-       adj_pref_x_size.set_value(x);
-       adj_pref_y_size.set_value(y);
-       pref_y_size_spinbutton->set_sensitive(false);
-       pref_x_size_spinbutton->set_sensitive(false);
-
-       return;
-}
-
-void
-Dialog_Setup::on_fps_template_combo_change()
-{
-       String selection(fps_template_combo->get_active_text());
-       if(selection==DEFAULT_PREDEFINED_FPS)
-       {
-               pref_fps_spinbutton->set_sensitive(true);
-               return;
-       }
-       adj_pref_fps.set_value(atof(selection.c_str()));
-       pref_fps_spinbutton->set_sensitive(false);
-       return;
-}
-
-void
-Dialog_Setup::refresh()
-{
-       // Refresh the temporary gamma; do this before adjusting the sliders,
-       // or variables will be used before their initialization.
-       gamma_pattern.set_gamma_r(App::gamma.get_gamma_r());
-       gamma_pattern.set_gamma_g(App::gamma.get_gamma_g());
-       gamma_pattern.set_gamma_b(App::gamma.get_gamma_b());
-       gamma_pattern.set_black_level(App::gamma.get_black_level());
-       gamma_pattern.set_red_blue_level(App::gamma.get_red_blue_level());
-
-       adj_gamma_r.set_value(1.0/App::gamma.get_gamma_r());
-       adj_gamma_g.set_value(1.0/App::gamma.get_gamma_g());
-       adj_gamma_b.set_value(1.0/App::gamma.get_gamma_b());
-       black_level_selector.set_value(App::gamma.get_black_level());
-       red_blue_level_selector.set_value(App::gamma.get_red_blue_level());
-
-       gamma_pattern.refresh();
-
-       adj_recent_files.set_value(App::get_max_recent_files());
-
-       // Refresh the time format
-       set_time_format(App::get_time_format());
-
-       widget_enum->set_value(App::distance_system);
-
-       // Refresh the status of the use_colorspace_gamma flag
-       toggle_use_colorspace_gamma.set_active(App::use_colorspace_gamma);
-
-#ifdef SINGLE_THREADED
-       // Refresh the status of the single_threaded flag
-       toggle_single_threaded.set_active(App::single_threaded);
-#endif
-
-       // Refresh the value of the auto backup interval
-       auto_backup_interval.set_value(App::auto_recover->get_timeout() / 1000);
-
-       // Refresh the status of the restrict_radius_ducks flag
-       toggle_restrict_radius_ducks.set_active(App::restrict_radius_ducks);
-
-       // Refresh the status of the resize_imported_images flag
-       toggle_resize_imported_images.set_active(App::resize_imported_images);
-
-       // Refresh the browser_command textbox
-       textbox_browser_command.set_text(App::browser_command);
-
-       // Refresh the preferred filename prefix
-       textbox_custom_filename_prefix.set_text(App::custom_filename_prefix);
-
-       // Refresh the preferred new Document X dimension
-       adj_pref_x_size.set_value(App::preferred_x_size);
-
-       // Refresh the preferred new Document Y dimension
-       adj_pref_y_size.set_value(App::preferred_y_size);
-
-       // Refresh the preferred Predefined size
-       size_template_combo->set_active_text(App::predefined_size);
-
-       //Refresh the preferred FPS
-       adj_pref_fps.set_value(App::preferred_fps);
-
-       //Refresh the predefined FPS
-       fps_template_combo->set_active_text(App::predefined_fps);
-}
-
-GammaPattern::GammaPattern():
-       tile_w(80),
-       tile_h(80)
-{
-       set_size_request(tile_w*4,tile_h*3);
-       signal_expose_event().connect(sigc::mem_fun(*this, &studio::GammaPattern::redraw));
-}
-
-GammaPattern::~GammaPattern()
-{
-}
-
-void
-GammaPattern::refresh()
-{
-       black[0].set_rgb_p(
-               r_F32_to_F32(0.0),
-               g_F32_to_F32(0.0),
-               b_F32_to_F32(0.0)
-       );
-       white[0].set_rgb_p(
-               r_F32_to_F32(1.0),
-               g_F32_to_F32(1.0),
-               b_F32_to_F32(1.0)
-       );
-       gray50[0].set_rgb_p(
-               r_F32_to_F32(0.5),
-               g_F32_to_F32(0.5),
-               b_F32_to_F32(0.5)
-       );
-       gray25[0].set_rgb_p(
-               r_F32_to_F32(0.25),
-               g_F32_to_F32(0.25),
-               b_F32_to_F32(0.25)
-       );
-
-       // Reds
-       black[1].set_rgb(black[0].get_red(),0,0);
-       gray25[1].set_rgb(gray25[0].get_red(),0,0);
-       gray50[1].set_rgb(gray50[0].get_red(),0,0);
-       white[1].set_rgb(white[0].get_red(),0,0);
-
-       // Greens
-       black[2].set_rgb(0,black[0].get_green(),0);
-       gray25[2].set_rgb(0,gray25[0].get_green(),0);
-       gray50[2].set_rgb(0,gray50[0].get_green(),0);
-       white[2].set_rgb(0,white[0].get_green(),0);
-
-       // blues
-       black[3].set_rgb(0,0,black[0].get_blue());
-       gray25[3].set_rgb(0,0,gray25[0].get_blue());
-       gray50[3].set_rgb(0,0,gray50[0].get_blue());
-       white[3].set_rgb(0,0,white[0].get_blue());
-}
-
-bool
-GammaPattern::redraw(GdkEventExpose */*bleh*/)
-{
-       static const char hlines[] = { 3, 0 };
-
-       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
-
-       int i;
-       Gdk::Color trueblack("#000000");
-
-       // 50% Pattern
-       for(i=0;i<4;i++)
-       {
-               gc->set_rgb_fg_color(black[i]);
-               get_window()->draw_rectangle(gc, true, i*tile_w, 0, tile_w, tile_h);
-
-               gc->set_stipple(Gdk::Bitmap::create(hlines,2,2));
-               gc->set_fill(Gdk::STIPPLED);
-               gc->set_rgb_fg_color(white[i]);
-               get_window()->draw_rectangle(gc, true, i*tile_w, 0, tile_w, tile_h);
-
-               gc->set_fill(Gdk::SOLID);
-               gc->set_rgb_fg_color(gray50[i]);
-
-               get_window()->draw_rectangle(gc, true, i*tile_w+tile_w/4, tile_h/4, tile_w-tile_w/2, tile_h-tile_h/2);
-       }
-
-       // 25% Pattern
-       for(i=0;i<4;i++)
-       {
-               gc->set_rgb_fg_color(black[i]);
-               get_window()->draw_rectangle(gc, true, i*tile_w, tile_h, tile_w, tile_h);
-
-               gc->set_stipple(Gdk::Bitmap::create(hlines,2,2));
-               gc->set_fill(Gdk::STIPPLED);
-               gc->set_rgb_fg_color(gray50[i]);
-               get_window()->draw_rectangle(gc, true, i*tile_w, tile_h, tile_w, tile_h);
-
-               gc->set_fill(Gdk::SOLID);
-               gc->set_rgb_fg_color(gray25[i]);
-
-               get_window()->draw_rectangle(gc, true, i*tile_w+tile_w/4, tile_h+tile_h/4, tile_w-tile_w/2, tile_h-tile_h/2);
-       }
-
-       // Black-level Pattern
-       gc->set_rgb_fg_color(trueblack);
-       get_window()->draw_rectangle(gc, true, 0, tile_h*2, tile_w*4, tile_h);
-       gc->set_fill(Gdk::SOLID);
-       for(i=0;i<4;i++)
-       {
-               gc->set_rgb_fg_color(black[i]);
-
-               get_window()->draw_rectangle(gc, true, i*tile_w+tile_w/4, tile_h*2+tile_h/4, tile_w-tile_w/2, tile_h-tile_h/2);
-       }
-
-       return true;
-}
-
-
-BlackLevelSelector::BlackLevelSelector()
-{
-       set_size_request(-1,24);
-       signal_expose_event().connect(sigc::mem_fun(*this, &studio::BlackLevelSelector::redraw));
-
-       add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
-       add_events(Gdk::BUTTON1_MOTION_MASK);
-       add_events(Gdk::BUTTON1_MOTION_MASK);
-}
-
-BlackLevelSelector::~BlackLevelSelector()
-{
-}
-
-bool
-BlackLevelSelector::redraw(GdkEventExpose */*bleh*/)
-{
-       const int w(get_width()),h(get_height());
-
-       Gdk::Color color;
-
-       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
-
-       int i;
-
-       // Draw the gradient
-       for(i=0;i<w;i++)
-       {
-               color.set_rgb(i*65536/w,i*65536/w,i*65536/w);
-
-               gc->set_rgb_fg_color(color);
-               get_window()->draw_rectangle(gc, true, i, 0, 1, h);
-       }
-
-       // Draw a frame
-       gc->set_rgb_fg_color(Gdk::Color("#000000"));
-       get_window()->draw_rectangle(gc, false, 0, 0, w-1, h-1);
-
-       // Draw the position of the current value
-       i=(int)(level*w+0.5);
-       gc->set_rgb_fg_color(Gdk::Color("#ff0000"));
-       get_window()->draw_rectangle(gc, true, i, 1, 1, h-1);
-
-       // Print out the value
-       Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_pango_context()));
-       layout->set_text(etl::strprintf("%0.01f%%",level*100.0f));
-       layout->set_alignment(Pango::ALIGN_CENTER);
-       gc->set_rgb_fg_color(Gdk::Color("#a00000"));
-       get_window()->draw_layout(gc, w/2, 4, layout);
-
-       return true;
-}
-
-
-
-bool
-BlackLevelSelector::on_event(GdkEvent *event)
-{
-       int x(round_to_int(event->button.x));
-       //int y(round_to_int(event->button.y));
-
-    switch(event->type)
-    {
-       case GDK_MOTION_NOTIFY:
-               level=(float)x/(float)get_width();
-               if(level<0.0f)level=0.0f;
-               if(level>1.0f)level=1.0f;
-               signal_value_changed_();
-               queue_draw();
-               return true;
-               break;
-       case GDK_BUTTON_PRESS:
-       case GDK_BUTTON_RELEASE:
-               if(event->button.button==1)
-               {
-                       level=(float)x/(float)get_width();
-                       if(level<0.0f)level=0.0f;
-                       if(level>1.0f)level=1.0f;
-                       signal_value_changed_();
-                       queue_draw();
-                       return true;
-               }
-               break;
-       default:
-               break;
-       }
-
-       return false;
-}
-
-
-void
-Dialog_Setup::set_time_format(synfig::Time::Format x)
-{
-       time_format=x;
-       if (x <= Time::FORMAT_VIDEO)
-               timestamp_optionmenu.set_history(0);
-       else if (x == (Time::FORMAT_NORMAL))
-               timestamp_optionmenu.set_history(1);
-       else if (x == (Time::FORMAT_NORMAL | Time::FORMAT_NOSPACES))
-               timestamp_optionmenu.set_history(2);
-       else if (x == (Time::FORMAT_NORMAL | Time::FORMAT_FULL))
-               timestamp_optionmenu.set_history(3);
-       else if (x == (Time::FORMAT_NORMAL | Time::FORMAT_NOSPACES | Time::FORMAT_FULL))
-               timestamp_optionmenu.set_history(4);
-       else if (x == (Time::FORMAT_FRAMES))
-               timestamp_optionmenu.set_history(5);
-       else
-               timestamp_optionmenu.set_history(1);
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-RedBlueLevelSelector::RedBlueLevelSelector()
-{
-       set_size_request(-1,24);
-       signal_expose_event().connect(sigc::mem_fun(*this, &studio::RedBlueLevelSelector::redraw));
-
-       add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
-       add_events(Gdk::BUTTON1_MOTION_MASK);
-       add_events(Gdk::BUTTON1_MOTION_MASK);
-}
-
-RedBlueLevelSelector::~RedBlueLevelSelector()
-{
-}
-
-bool
-RedBlueLevelSelector::redraw(GdkEventExpose */*bleh*/)
-{
-       const int w(get_width()),h(get_height());
-
-       Gdk::Color color;
-
-       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
-
-       int i;
-
-       // Draw the gradient
-       for(i=0;i<w;i++)
-       {
-               float red_blue(((float(i)/float(w)+0.5f)-1.0f)/2.0f+1.0f);
-               float blue_red(2.0f-(red_blue));
-               if(red_blue>1.0f)red_blue=1.0f;
-               if(blue_red>1.0f)blue_red=1.0f;
-
-               color.set_rgb(
-                       round_to_int(min(red_blue,1.0f)*65535),
-                       round_to_int(sqrt(min(red_blue,blue_red))*65535),
-                       round_to_int(min(blue_red,1.0f)*65535)
-               );
-
-               gc->set_rgb_fg_color(color);
-               get_window()->draw_rectangle(gc, true, i, 0, 1, h);
-       }
-
-       // Draw a frame
-       gc->set_rgb_fg_color(Gdk::Color("#000000"));
-       get_window()->draw_rectangle(gc, false, 0, 0, w-1, h-1);
-
-       // Draw the position of the current value
-       i=(int)(((level-1.0f)*2.0f+1.0f-0.5f)*w+0.5);
-       gc->set_rgb_fg_color(Gdk::Color("#00ff00"));
-       get_window()->draw_rectangle(gc, true, i, 1, 1, h-1);
-
-       // Print out the value
-       Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_pango_context()));
-       layout->set_text(etl::strprintf("%0.02f",level));
-       layout->set_alignment(Pango::ALIGN_CENTER);
-       gc->set_rgb_fg_color(Gdk::Color("#a00000"));
-       get_window()->draw_layout(gc, w/2, 4, layout);
-
-       return true;
-}
-
-
-
-bool
-RedBlueLevelSelector::on_event(GdkEvent *event)
-{
-       int x(round_to_int(event->button.x));
-       //int y(round_to_int(event->button.y));
-
-    switch(event->type)
-    {
-       case GDK_MOTION_NOTIFY:
-               level=(((float)(x)/(float)get_width()+0.5)-1.0f)/2.0f+1.0f;
-               if(level<0.5f)level=0.5f;
-               if(level>1.5f)level=1.5f;
-               signal_value_changed_();
-               queue_draw();
-               return true;
-               break;
-       case GDK_BUTTON_PRESS:
-       case GDK_BUTTON_RELEASE:
-               if(event->button.button==1)
-               {
-                       level=(((float)(x)/(float)get_width()+0.5)-1.0f)/2.0f+1.0f;
-                       if(level<0.5f)level=0.5f;
-                       if(level>1.5f)level=1.5f;
-                       signal_value_changed_();
-                       queue_draw();
-                       return true;
-               }
-               break;
-       default:
-               break;
-       }
-
-       return false;
-}
diff --git a/synfig-studio/src/gtkmm/dialog_setup.h b/synfig-studio/src/gtkmm/dialog_setup.h
deleted file mode 100644 (file)
index 530e4fa..0000000
+++ /dev/null
@@ -1,222 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dialog_setup.h
-**     \brief Template Header
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 2008 Chris Moore
-**     Copyright (c) 2008, 2009 Carlos López
-**
-**     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_DIALOG_SETUP_H
-#define __SYNFIG_STUDIO_DIALOG_SETUP_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtk/gtk.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/table.h>
-#include <gtkmm/button.h>
-#include <gtkmm/dialog.h>
-#include <gtkmm/drawingarea.h>
-#include <gtkmm/optionmenu.h>
-#include <gtkmm/checkbutton.h>
-#include <gtkmm/widget_time.h>
-#include <gtkmm/tooltips.h>
-#include <gtkmm/comboboxtext.h>
-#include <gtkmm/spinbutton.h>
-
-#include <synfig/gamma.h>
-#include <synfig/time.h>
-#include <algorithm>
-
-/* === M A C R O S ========================================================= */
-#ifndef DEFAULT_PREDEFINED_SIZE
-#define DEFAULT_PREDEFINED_SIZE _("Custom Size")
-#endif
-#ifndef DEFAULT_PREDEFINED_FPS
-#define DEFAULT_PREDEFINED_FPS _("Custom fps")
-#endif
-
-/* === T Y P E D E F S ===================================================== */
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-namespace Gtk { class Menu; };
-
-namespace studio {
-
-class GammaPattern : public Gtk::DrawingArea
-{
-       float gamma_r;
-       float gamma_g;
-       float gamma_b;
-       float black_level;
-       float red_blue_level;
-
-       int tile_w, tile_h;
-
-       Gdk::Color black[4],white[4],gray50[4],gray25[4];
-
-       float r_F32_to_F32(float x)const { float f((pow(x,gamma_r)*std::min(red_blue_level,1.0f)*(1.0f-black_level)+black_level)); if(f<0)f=0; if(f>1)f=1; return f; }
-       float g_F32_to_F32(float x)const { float f((pow(x,gamma_g)*sqrt(std::min(2.0f-red_blue_level,red_blue_level))*(1.0f-black_level)+black_level)); if(f<0)f=0; if(f>1)f=1; return f; }
-       float b_F32_to_F32(float x)const { float f((pow(x,gamma_b)*std::min(2.0f-red_blue_level,1.0f)*(1.0f-black_level)+black_level)); if(f<0)f=0; if(f>1)f=1; return f; }
-
-public:
-
-       void refresh();
-
-       void set_gamma_r(float x) { gamma_r=x; }
-       void set_gamma_g(float x) { gamma_g=x; };
-       void set_gamma_b(float x) { gamma_b=x; };
-       void set_black_level(float x) { black_level=x; };
-       void set_red_blue_level(float x) { red_blue_level=x; };
-
-       float get_gamma_r()const { return gamma_r; }
-       float get_gamma_g()const { return gamma_g; }
-       float get_gamma_b()const { return gamma_b; }
-       float get_black_level()const { return black_level; }
-       float get_red_blue_level()const { return red_blue_level; }
-
-       GammaPattern();
-
-       ~GammaPattern();
-
-       bool redraw(GdkEventExpose*bleh=NULL);
-}; // END of class GammaPattern
-
-class BlackLevelSelector : public Gtk::DrawingArea
-{
-       float level;
-
-       sigc::signal<void> signal_value_changed_;
-
-public:
-
-       BlackLevelSelector();
-
-       ~BlackLevelSelector();
-
-       sigc::signal<void>& signal_value_changed() { return signal_value_changed_; }
-
-       void set_value(float x) { level=x; queue_draw(); }
-
-       const float &get_value()const { return level; }
-
-       bool redraw(GdkEventExpose*bleh=NULL);
-
-       bool on_event(GdkEvent *event);
-}; // END of class BlackLevelSelector
-
-class RedBlueLevelSelector : public Gtk::DrawingArea
-{
-       float level;
-
-       sigc::signal<void> signal_value_changed_;
-
-public:
-
-       RedBlueLevelSelector();
-
-       ~RedBlueLevelSelector();
-
-       sigc::signal<void>& signal_value_changed() { return signal_value_changed_; }
-
-       void set_value(float x) { level=x; queue_draw(); }
-
-       const float &get_value()const { return level; }
-
-       bool redraw(GdkEventExpose*bleh=NULL);
-
-       bool on_event(GdkEvent *event);
-}; // END of class RedBlueSelector
-
-class Widget_Enum;
-
-class Dialog_Setup : public Gtk::Dialog
-{
-
-       void on_ok_pressed();
-       void on_apply_pressed();
-
-       void on_gamma_r_change();
-       void on_gamma_g_change();
-       void on_gamma_b_change();
-       void on_black_level_change();
-       void on_red_blue_level_change();
-       void on_size_template_combo_change();
-       void on_fps_template_combo_change();
-
-       GammaPattern gamma_pattern;
-       BlackLevelSelector black_level_selector;
-       RedBlueLevelSelector red_blue_level_selector;
-       Gtk::OptionMenu timestamp_optionmenu;
-
-       Gtk::Adjustment adj_gamma_r;
-       Gtk::Adjustment adj_gamma_g;
-       Gtk::Adjustment adj_gamma_b;
-
-       Gtk::Adjustment adj_recent_files;
-       Gtk::Adjustment adj_undo_depth;
-
-       Gtk::CheckButton toggle_use_colorspace_gamma;
-#ifdef SINGLE_THREADED
-       Gtk::CheckButton toggle_single_threaded;
-#endif
-
-       synfig::Time::Format time_format;
-
-       Gtk::Menu *timestamp_menu;
-       Widget_Enum *widget_enum;
-
-       Widget_Time auto_backup_interval;
-
-       Gtk::CheckButton toggle_restrict_radius_ducks;
-       Gtk::CheckButton toggle_resize_imported_images;
-
-       Gtk::Entry textbox_browser_command;
-
-       Gtk::ComboBoxText* size_template_combo;
-       Gtk::ComboBoxText* fps_template_combo;
-       Gtk::Entry textbox_custom_filename_prefix;
-       Gtk::Adjustment adj_pref_x_size;
-       Gtk::Adjustment adj_pref_y_size;
-       Gtk::Adjustment adj_pref_fps;
-       Gtk::SpinButton* pref_fps_spinbutton;
-       Gtk::SpinButton* pref_y_size_spinbutton;
-       Gtk::SpinButton* pref_x_size_spinbutton;
-       Gtk::Tooltips tooltips_;
-public:
-
-       void set_time_format(synfig::Time::Format time_format);
-
-       const synfig::Time::Format& get_time_format()const { return time_format; }
-
-       Dialog_Setup();
-       ~Dialog_Setup();
-
-    void refresh();
-
-}; // END of Dialog_Waypoint
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/dialog_soundselect.cpp b/synfig-studio/src/gtkmm/dialog_soundselect.cpp
deleted file mode 100644 (file)
index 0892616..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dialog_soundselect.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2008 David Roden
-**
-**     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 <config.h>
-#endif
-
-#include "dialog_soundselect.h"
-#include <gtkmm/alignment.h>
-#include <gtkmm/frame.h>
-#include <gtkmm/label.h>
-#include <gtkmm/table.h>
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-using namespace synfig;
-
-/* === M A C R O S ========================================================= */
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-/* === E N T R Y P O I N T ================================================= */
-
-studio::Dialog_SoundSelect::Dialog_SoundSelect(Gtk::Window &parent, etl::handle<synfigapp::CanvasInterface> ci)
-:Dialog(_("Sound Select"), parent, false, true),
-canvas_interface(ci)
-{
-       Gtk::Alignment *dialogPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
-       dialogPadding->set_padding(12, 12, 12, 12);
-       get_vbox()->pack_start(*dialogPadding, false, false, 0);
-
-       Gtk::Frame *soundFrame = manage(new Gtk::Frame(_("Sound Parameters")));
-       ((Gtk::Label *) soundFrame->get_label_widget())->set_markup(_("<b>Sound Parameters</b>"));
-       soundFrame->set_shadow_type(Gtk::SHADOW_NONE);
-       dialogPadding->add(*soundFrame);
-
-       Gtk::Alignment *framePadding = manage(new Gtk::Alignment(0, 0, 1, 1));
-       framePadding->set_padding(6, 0, 24, 0);
-       soundFrame->add(*framePadding);
-
-       Gtk::Label *fileLabel = manage(new Gtk::Label(_("_Sound File"), true));
-       fileLabel->set_alignment(0, 0.5);
-       fileLabel->set_mnemonic_widget(soundfile);
-       Gtk::Label *offsetLabel = manage(new Gtk::Label(_("Time _Offset"), true));
-       offsetLabel->set_alignment(0, 0.5);
-       offsetLabel->set_mnemonic_widget(offset);
-
-       Gtk::Table *table = manage(new Gtk::Table(2, 2, false));
-       table->set_row_spacings(6);
-       table->set_col_spacings(12);
-       framePadding->add(*table);
-
-       table->attach(*fileLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::SHRINK | Gtk::FILL, 0, 0);
-       table->attach(soundfile, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK | Gtk::FILL, 0, 0);
-       table->attach(*offsetLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::SHRINK | Gtk::FILL, 0, 0);
-       table->attach(offset, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK | Gtk::FILL, 0, 0);
-
-       okbutton = manage(new Gtk::Button(Gtk::StockID("gtk-ok")));
-       add_action_widget(*okbutton, 0);
-
-       get_vbox()->show_all();
-
-       offset.set_value(0);
-
-       okbutton->signal_clicked().connect(sigc::mem_fun(*this,&Dialog_SoundSelect::on_ok));
-}
-
-studio::Dialog_SoundSelect::~Dialog_SoundSelect()
-{
-}
-
-void studio::Dialog_SoundSelect::on_file()
-{
-       signal_file_changed_(soundfile.get_value());
-}
-
-void studio::Dialog_SoundSelect::on_offset()
-{
-       signal_offset_changed_(offset.get_value());
-}
-
-void studio::Dialog_SoundSelect::on_ok()
-{
-       hide();
-
-       //signal_finish_(a);
-       signal_file_changed_(soundfile.get_value());
-       signal_offset_changed_(offset.get_value());
-}
-
-void studio::Dialog_SoundSelect::set_global_fps(float f)
-{
-       offset.set_fps(f);
-}
diff --git a/synfig-studio/src/gtkmm/dialog_soundselect.h b/synfig-studio/src/gtkmm/dialog_soundselect.h
deleted file mode 100644 (file)
index d23ce93..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dialog_soundselect.h
-**     \brief Sound Select Header
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2008 David Roden
-**
-**     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_DIALOG_SOUNDSELECT_H
-#define __SYNFIG_DIALOG_SOUNDSELECT_H
-
-/* === H E A D E R S ======================================================= */
-#include "dockdialog.h"
-#include "widget_filename.h"
-#include "widget_time.h"
-
-#include <synfigapp/canvasinterface.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 {
-
-struct AudioBaseInfo
-{
-       std::string             file;
-       synfig::Time            offset;
-};
-
-class Dialog_SoundSelect : public Gtk::Dialog
-{
-       Widget_Filename         soundfile;
-       Widget_Time                     offset;
-       Gtk::Button                     *okbutton;
-
-       etl::handle<synfigapp::CanvasInterface> canvas_interface;
-
-       sigc::signal<void,const std::string &>  signal_file_changed_;
-       sigc::signal<void,const synfig::Time &> signal_offset_changed_;
-
-       void on_file();
-       void on_offset();
-       void on_ok();
-
-public:
-       Dialog_SoundSelect(Gtk::Window &parent,etl::handle<synfigapp::CanvasInterface> ci );
-       ~Dialog_SoundSelect();
-
-       //float get_global_fps() const { return globalfps; }
-       void set_global_fps(float f);
-
-       synfig::Time get_offset() const { return offset.get_value(); }
-       void set_offset(const synfig::Time &t) {offset.set_value(t); }
-
-       std::string get_file() const { return soundfile.get_value(); }
-       void set_file(const std::string &f) {soundfile.set_value(f); }
-
-       sigc::signal<void,const std::string &> &signal_file_changed() { return signal_file_changed_; }
-       sigc::signal<void,const synfig::Time &> &signal_offset_changed() { return signal_offset_changed_; }
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/dialog_targetparam.cpp b/synfig-studio/src/gtkmm/dialog_targetparam.cpp
deleted file mode 100644 (file)
index 29cce71..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dialog_targetparam.cpp
-**     \brief Implementation for the TargetParam Dialog
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2010 Carlos López González
-**
-**     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 <config.h>
-#endif
-
-#include "dialog_targetparam.h"
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace studio;
-
-/* === M A C R O S ========================================================= */
-
-/* === G L O B A L S ======================================================= */
-//! Allowed video codecs
-/*! \warning This variable is linked to allowed_video_codecs_description,
- *  if you change this you must change the other acordingly.
- *  \warning These codecs are linked to the filename extensions for
- *  mod_ffmpeg. If you change this you must change the others acordingly.
- */
-const char* allowed_video_codecs[] =
-{
-       "flv", "h263p", "huffyuv", "libtheora", "libx264", "libxvid",
-       "mjpeg", "mpeg1video", "mpeg2video", "mpeg4", "msmpeg4",
-       "msmpeg4v1", "msmpeg4v2", "wmv1", "wmv2", NULL
-};
-
-//! Allowed video codecs description.
-/*! \warning This variable is linked to allowed_video_codecs,
- *  if you change this you must change the other acordingly.
- */
-const char* allowed_video_codecs_description[] =
-{
-       "Flash Video (FLV) / Sorenson Spark / Sorenson H.263.",
-       "H.263+ / H.263-1998 / H.263 version 2.",
-       "Huffyuv / HuffYUV.",
-       "libtheora Theora.",
-       "libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10.",
-       "libxvidcore MPEG-4 part 2.",
-       "MJPEG (Motion JPEG).",
-       "raw MPEG-1 video.",
-       "raw MPEG-2 video.",
-       "MPEG-4 part 2.",
-       "MPEG-4 part 2 Microsoft variant version 3.",
-       "MPEG-4 part 2 Microsoft variant version 1.",
-       "MPEG-4 part 2 Microsoft variant version 2.",
-       "Windows Media Video 7.",
-       "Windows Media Video 8.",
-       NULL
-};
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-/* === E N T R Y P O I N T ================================================= */
-
-Dialog_TargetParam::Dialog_TargetParam(synfig::TargetParam &tparam)
-{
-       set_title("TargetParam Dialog");
-       set_tparam(tparam);
-       // Available Video Codecs Combo Box Text.
-       vcodec = Gtk::manage(new Gtk::ComboBoxText());
-       Gtk::Label* label(manage(new Gtk::Label(_("Available Video Codecs:"))));
-       label->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
-       get_vbox()->pack_start(*label, true, true, 0);
-       for (int i = 0; allowed_video_codecs[i] != NULL &&
-                                       allowed_video_codecs_description[i] != NULL; i++)
-               vcodec->append_text(allowed_video_codecs_description[i]);
-       for (int i = 0; allowed_video_codecs[i] != NULL &&
-                                       allowed_video_codecs_description[i] != NULL; i++)
-               if(!get_tparam().video_codec.compare(allowed_video_codecs[i]))
-                       vcodec->set_active_text(allowed_video_codecs_description[i]);
-
-       get_vbox()->pack_start(*vcodec, true, true, 0);
-
-       //Bitrate Spin Button
-       Gtk::Adjustment* bradj(manage(new class Gtk::Adjustment(double(tparam.bitrate), 10.0,1000.0)));
-       bitrate = Gtk::manage(new class Gtk::SpinButton(*bradj));
-       Gtk::Label* label2(manage(new Gtk::Label(_("Video Bit Rate:"))));
-       label2->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
-       get_vbox()->pack_start(*label2, true, true, 0);
-       get_vbox()->pack_start(*bitrate,true, true, 0);
-
-       get_vbox()->show_all();
-
-       ok_button = manage(new class Gtk::Button(Gtk::StockID("gtk-ok")));
-       ok_button->show();
-       add_action_widget(*ok_button,Gtk::RESPONSE_OK);
-       ok_button->signal_clicked().connect(sigc::mem_fun(*this,&Dialog_TargetParam::on_ok));
-
-       cancel_button = manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
-       cancel_button->show();
-       add_action_widget(*cancel_button,Gtk::RESPONSE_CANCEL);
-       cancel_button->signal_clicked().connect(sigc::mem_fun(*this,&Dialog_TargetParam::on_cancel));
-
-}
-
-void
-Dialog_TargetParam::on_ok()
-{
-       std::string codecnamed = vcodec->get_active_text();
-       for (int i = 0; allowed_video_codecs[i] != NULL &&
-                                       allowed_video_codecs_description[i] != NULL; i++)
-               if(!codecnamed.compare(allowed_video_codecs_description[i]))
-                       tparam_.video_codec=allowed_video_codecs[i];
-       tparam_.bitrate=bitrate->get_value();
-       hide();
-}
-
-void
-Dialog_TargetParam::on_cancel()
-{
-       hide();
-}
-
-Dialog_TargetParam::~Dialog_TargetParam()
-{
-}
-
diff --git a/synfig-studio/src/gtkmm/dialog_targetparam.h b/synfig-studio/src/gtkmm/dialog_targetparam.h
deleted file mode 100644 (file)
index 8fa8cfb..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dialog_targetparam.h
-**     \brief Targetparam Dialog Header
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2010 Carlos López González
-**
-**     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_DIALOG_TARGETPARAM_H
-#define __SYNFIG_STUDIO_DIALOG_TARGETPARAM_H
-
-/* === H E A D E R S ======================================================= */
-#include <gtkmm/dialog.h>
-#include <gtkmm/button.h>
-#include <gtkmm/comboboxtext.h>
-#include <gtkmm/spinbutton.h>
-
-#include <synfig/targetparam.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 Dialog_TargetParam : public Gtk::Dialog
-{
-       synfig::TargetParam tparam_;
-       Gtk::Button *ok_button;
-       Gtk::Button *cancel_button;
-       Gtk::SpinButton *bitrate;
-       Gtk::ComboBoxText *vcodec;
-
-       void on_ok();
-       void on_cancel();
-
-public:
-       Dialog_TargetParam(synfig::TargetParam &tparam);
-       ~Dialog_TargetParam();
-
-       synfig::TargetParam get_tparam() const { return tparam_; }
-       void set_tparam(const synfig::TargetParam &tp) {tparam_=tp; }
-
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
-
-
-
diff --git a/synfig-studio/src/gtkmm/dialog_tooloptions.cpp b/synfig-studio/src/gtkmm/dialog_tooloptions.cpp
deleted file mode 100644 (file)
index da759c8..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dialog_tooloptions.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include <gtkmm/label.h>
-#include <gtkmm/scrolledwindow.h>
-#include <synfig/general.h>
-#include "dialog_tooloptions.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Dialog_ToolOptions::Dialog_ToolOptions():
-       Dockable("tool_options",_("Tool Options"),Gtk::StockID("synfig-about")),
-       empty_label(_("This tool has no options"))
-{
-       add(sub_vbox_);
-
-       set_widget(empty_label);
-       empty_label.show();
-}
-
-Dialog_ToolOptions::~Dialog_ToolOptions()
-{
-}
-
-void
-Dialog_ToolOptions::clear()
-{
-       Dockable::clear();
-       set_local_name(_("Tool Options"));
-       add(sub_vbox_);
-       set_widget(empty_label);
-       empty_label.show();
-
-       set_stock_id(Gtk::StockID("synfig-about"));
-}
-
-void
-Dialog_ToolOptions::set_widget(Gtk::Widget&x)
-{
-       if(!sub_vbox_.children().empty())
-               sub_vbox_.children().clear();
-
-       sub_vbox_.show();
-       sub_vbox_.pack_start(x,false,false);
-       x.show();
-}
-
-void
-Dialog_ToolOptions::set_name(const synfig::String& name)
-{
-       set_stock_id(Gtk::StockID("synfig-"+name));
-}
diff --git a/synfig-studio/src/gtkmm/dialog_tooloptions.h b/synfig-studio/src/gtkmm/dialog_tooloptions.h
deleted file mode 100644 (file)
index 69680e0..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dialog_tooloptions.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_DIALOG_TOOLOPTIONS_H
-#define __SYNFIG_STUDIO_DIALOG_TOOLOPTIONS_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/dialog.h>
-#include <gtkmm/label.h>
-#include <gtkmm/scrolledwindow.h>
-#include "dockable.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 Dialog_ToolOptions : public Dockable
-{
-       Gtk::Label empty_label;
-       Gtk::VBox sub_vbox_;
-
-public:
-
-       void clear();
-       void set_widget(Gtk::Widget&);
-       void set_name(const synfig::String& name);
-
-       Dialog_ToolOptions();
-       ~Dialog_ToolOptions();
-}; // END of Dialog_ToolOptions
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/dialog_waypoint.cpp b/synfig-studio/src/gtkmm/dialog_waypoint.cpp
deleted file mode 100644 (file)
index 5fbf61c..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dialog_waypoint.cpp
-**     \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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include <gtkmm/label.h>
-#include "dialog_waypoint.h"
-#include <gtk/gtk.h>
-#include <gtkmm/spinbutton.h>
-#include <gtkmm/combo.h>
-#include <ETL/stringf>
-#include "widget_value.h"
-#include "app.h"
-#include <gtkmm/menu.h>
-#include <gtkmm/optionmenu.h>
-#include "widget_time.h"
-#include "widget_waypoint.h"
-
-#include "general.h"
-
-#endif
-
-using namespace synfig;
-using namespace std;
-using namespace etl;
-using namespace studio;
-
-/* === M A C R O S ========================================================= */
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Dialog_Waypoint::Dialog_Waypoint(Gtk::Window& parent,etl::handle<synfig::Canvas> canvas):
-       Dialog(_("Waypoint Editor"),parent,false,true),
-       canvas(canvas)
-{
-       assert(canvas);
-    waypointwidget=manage(new class Widget_Waypoint(canvas));
-       get_vbox()->pack_start(*waypointwidget);
-
-       Gtk::Button *ok_button(manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))));
-       ok_button->show();
-       add_action_widget(*ok_button,2);
-       ok_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Waypoint::on_ok_pressed));
-
-       Gtk::Button *apply_button(manage(new class Gtk::Button(Gtk::StockID("gtk-apply"))));
-       apply_button->show();
-       add_action_widget(*apply_button,1);
-       apply_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Waypoint::on_apply_pressed));
-
-       Gtk::Button *delete_button(manage(new class Gtk::Button(Gtk::StockID("gtk-delete"))));
-       delete_button->show();
-       add_action_widget(*delete_button,3);
-       delete_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Waypoint::on_delete_pressed));
-
-       Gtk::Button *cancel_button(manage(new class Gtk::Button(Gtk::StockID("gtk-close"))));
-       cancel_button->show();
-       add_action_widget(*cancel_button,0);
-       cancel_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Waypoint::hide));
-
-
-       waypointwidget->show_all();
-}
-
-Dialog_Waypoint::~Dialog_Waypoint()
-{
-}
-
-void
-Dialog_Waypoint::on_ok_pressed()
-{
-       hide();
-    signal_changed_();
-}
-
-void
-Dialog_Waypoint::on_apply_pressed()
-{
-    signal_changed_();
-}
-
-void
-Dialog_Waypoint::on_delete_pressed()
-{
-       hide();
-    signal_delete_();
-}
-
-void
-Dialog_Waypoint::set_waypoint(synfig::ValueNode_Animated::Waypoint x)
-{
-       waypointwidget->set_waypoint(x);
-}
-
-const synfig::ValueNode_Animated::Waypoint &
-Dialog_Waypoint::get_waypoint()const
-{
-       return waypointwidget->get_waypoint();
-}
-
-void
-Dialog_Waypoint::set_value_desc(synfigapp::ValueDesc value_desc)
-{
-       value_desc_=value_desc;
-       if(value_desc.get_value_node() && value_desc.get_value_node()->get_parent_canvas())
-               waypointwidget->set_canvas(value_desc.get_value_node()->get_parent_canvas());
-}
-
-void
-Dialog_Waypoint::reset()
-{
-}
diff --git a/synfig-studio/src/gtkmm/dialog_waypoint.h b/synfig-studio/src/gtkmm/dialog_waypoint.h
deleted file mode 100644 (file)
index bbeab02..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dialog_waypoint.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_GTKMM_DIALOG_WAYPOINT_H
-#define __SYNFIG_GTKMM_DIALOG_WAYPOINT_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtk/gtk.h>
-#include <gtkmm/ruler.h>
-#include <gtkmm/arrow.h>
-#include <gtkmm/image.h>
-#include <gdkmm/pixbufloader.h>
-#include <gtkmm/viewport.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/scrolledwindow.h>
-#include <gtkmm/table.h>
-#include <gtkmm/statusbar.h>
-#include <gtkmm/button.h>
-#include <gtkmm/progressbar.h>
-#include <gtkmm/paned.h>
-#include <gtkmm/treeview.h>
-#include <gtkmm/treestore.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/box.h>
-#include <gtkmm/scrollbar.h>
-#include <gtkmm/cellrenderer.h>
-
-#include <gtkmm/dialog.h>
-#include <gtkmm/menu.h>
-
-
-#include <synfigapp/value_desc.h>
-#include <synfig/valuenode_animated.h>
-#include <synfig/valuenode_dynamiclist.h>
-#include <synfig/string.h>
-#include <synfig/time.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 Widget_ValueBase;
-class Widget_Waypoint;
-
-class Dialog_Waypoint : public Gtk::Dialog
-{
-       Widget_Waypoint *waypointwidget;
-       etl::handle<synfig::Canvas> canvas;
-       synfig::ValueNode_Animated::WaypointList::iterator waypoint;
-       synfigapp::ValueDesc value_desc_;
-
-       sigc::signal<void> signal_changed_;
-
-       sigc::signal<void> signal_delete_;
-       void on_ok_pressed();
-       void on_apply_pressed();
-       void on_delete_pressed();
-
-public:
-       Dialog_Waypoint(Gtk::Window& parent,etl::handle<synfig::Canvas> canvas);
-       ~Dialog_Waypoint();
-
-    void reset();
-
-       void set_value_desc(synfigapp::ValueDesc value_desc);
-       synfigapp::ValueDesc get_value_desc()const { return value_desc_; }
-
-       void set_waypoint(synfig::ValueNode_Animated::Waypoint x);
-       const synfig::ValueNode_Animated::Waypoint &get_waypoint()const;
-
-       sigc::signal<void> &signal_changed()
-       {return signal_changed_; }
-
-       sigc::signal<void> &signal_delete()
-       {return signal_delete_; }
-}; // END of Dialog_Waypoint
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/dialogsettings.cpp b/synfig-studio/src/gtkmm/dialogsettings.cpp
deleted file mode 100644 (file)
index 7f38a83..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dialogsettings.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 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 <config.h>
-#endif
-
-#include "dialogsettings.h"
-#include <synfigapp/main.h>
-#include <gdkmm/general.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-DialogSettings::DialogSettings(Gtk::Window* window,const synfig::String& name):
-       window(window),
-       name(name)
-{
-       synfigapp::Main::settings().add_domain(this,"window."+name);
-}
-
-DialogSettings::~DialogSettings()
-{
-       synfigapp::Main::settings().remove_domain("window."+name);
-}
-
-bool
-DialogSettings::get_value(const synfig::String& key, synfig::String& value)const
-{
-       if(key=="pos")
-       {
-               // if(!window->is_visible())return false;
-               int x,y; window->get_position(x,y);
-               value=strprintf("%d %d",x,y);
-               return true;
-       }
-       if(key=="size")
-       {
-               // if(!window->is_visible())return false;
-               int x,y; window->get_size(x,y);
-               value=strprintf("%d %d",x,y);
-               return true;
-       }
-       if(key=="x")
-       {
-               int x,y; window->get_position(x,y);
-               value=strprintf("%d",x);
-               return true;
-       }
-       if(key=="y")
-       {
-               int x,y; window->get_position(x,y);
-               value=strprintf("%d",y);
-               return true;
-       }
-       if(key=="w")
-       {
-               int x,y; window->get_size(x,y);
-               value=strprintf("%d",x);
-               return true;
-       }
-       if(key=="h")
-       {
-               int x,y; window->get_size(x,y);
-               value=strprintf("%d",y);
-               return true;
-       }
-       if(key=="visible")
-       {
-               value=window->is_visible()?"1":"0";
-               return true;
-       }
-
-       return synfigapp::Settings::get_value(key,value);
-}
-
-bool
-DialogSettings::set_value(const synfig::String& key,const synfig::String& value)
-{
-       int screen_w(Gdk::screen_width());
-       int screen_h(Gdk::screen_height());
-
-       if(value.empty())
-               return false;
-
-       if(key=="pos")
-       {
-               int x,y;
-               if(!strscanf(value,"%d %d",&x, &y))
-                       return false;
-
-               if (x > screen_w) x = screen_w - 150; if (x < 0) x = 0;
-               if (y > screen_h) y = screen_h - 150; if (y < 0) y = 0;
-
-               window->move(x,y);
-               return true;
-       }
-       if(key=="size")
-       {
-               int x,y;
-               if(!strscanf(value,"%d %d",&x, &y))
-                       return false;
-
-               if (x > screen_w) x = 150; if (x < 0) x = 0;
-               if (y > screen_h) y = 150; if (y < 0) y = 0;
-
-               window->set_default_size(x,y);
-               return true;
-       }
-       if(key=="x")
-       {
-               int x,y; window->get_position(x,y);
-               x=atoi(value.c_str());
-               window->move(x,y);
-               return true;
-       }
-       if(key=="y")
-       {
-               int x,y; window->get_position(x,y);
-               y=atoi(value.c_str());
-               window->move(x,y);
-               return true;
-       }
-       if(key=="w")
-       {
-               int x,y; window->get_size(x,y);
-               x=atoi(value.c_str());
-               window->set_default_size(x,y);
-               return true;
-       }
-       if(key=="h")
-       {
-               int x,y; window->get_size(x,y);
-               y=atoi(value.c_str());
-               window->set_default_size(x,y);
-               return true;
-       }
-       if(key=="visible")
-       {
-               if(value=="0")
-                       window->hide();
-               else
-                       window->present();
-               return true;
-       }
-
-       return synfigapp::Settings::set_value(key,value);
-}
-
-synfigapp::Settings::KeyList
-DialogSettings::get_key_list()const
-{
-       synfigapp::Settings::KeyList ret(synfigapp::Settings::get_key_list());
-
-       ret.push_back("size");
-       ret.push_back("pos");
-       ret.push_back("visible");
-
-       return ret;
-}
diff --git a/synfig-studio/src/gtkmm/dialogsettings.h b/synfig-studio/src/gtkmm/dialogsettings.h
deleted file mode 100644 (file)
index 3a32ed4..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dialogsettings.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_DIALOGSETTINGS_H
-#define __SYNFIG_DIALOGSETTINGS_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <synfigapp/settings.h>
-#include <gtkmm/window.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 DialogSettings : public synfigapp::Settings
-{
-       Gtk::Window* window;
-       synfig::String name;
-public:
-       DialogSettings(Gtk::Window* window,const synfig::String& name);
-       virtual ~DialogSettings();
-
-       virtual bool get_value(const synfig::String& key, synfig::String& value)const;
-       virtual bool set_value(const synfig::String& key,const synfig::String& value);
-       virtual KeyList get_key_list()const;
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/dock_canvases.cpp b/synfig-studio/src/gtkmm/dock_canvases.cpp
deleted file mode 100644 (file)
index f230820..0000000
+++ /dev/null
@@ -1,251 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_canvases.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "dock_canvases.h"
-#include "app.h"
-#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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Dock_Canvases::Dock_Canvases():
-       Dockable("canvases",_("Canvas Browser"),Gtk::StockID("synfig-canvas"))
-{
-
-       App::signal_instance_created().connect(sigc::mem_fun(*this,&studio::Dock_Canvases::new_instance));
-       App::signal_instance_deleted().connect(sigc::mem_fun(*this,&studio::Dock_Canvases::delete_instance));
-       App::signal_instance_selected().connect(sigc::mem_fun(*this,&studio::Dock_Canvases::set_selected_instance_signal));
-
-
-       add(*create_canvas_tree());
-
-/*  // \todo Implement canvas management in canvas browser
-       add_button(
-               Gtk::StockID("synfig-canvas_new"),
-               _("Insert a new canvas")
-       )->signal_clicked().connect(
-               sigc::mem_fun(
-                       *this,
-                       &Dock_Canvases::menu_new_canvas
-               )
-       );
-
-       add_button(
-               Gtk::StockID("gtk-delete"),
-               _("Remove selected canvas")
-       )->signal_clicked().connect(
-               sigc::mem_fun(
-                       *this,
-                       &Dock_Canvases::menu_delete
-               )
-       );
-
-       add_button(
-               Gtk::StockID("synfig-rename"),
-               _("Rename selected canvas")
-       )->signal_clicked().connect(
-               sigc::mem_fun(
-                       *this,
-                       &Dock_Canvases::menu_rename
-               )
-       );
-*/
-}
-
-Dock_Canvases::~Dock_Canvases()
-{
-}
-
-Gtk::Widget*
-Dock_Canvases::create_canvas_tree()
-{
-       studio::Instance::CanvasTreeModel canvas_tree_model;
-       canvas_tree=manage(new class Gtk::TreeView());
-       {
-               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("ID")) );
-//             Gtk::CellRendererPixbuf* icon_cellrenderer = Gtk::manage( new Gtk::CellRendererPixbuf() );
-
-               //column->pack_start(*icon_cellrenderer,false);
-               column->pack_start(canvas_tree_model.icon, false); //false = don't expand.
-               column->pack_start(canvas_tree_model.label);
-
-//#ifdef NDEBUG
-//             column->add_attribute(icon_cellrenderer->property_pixbuf(), canvas_tree_model.icon);
-//#endif
-
-               canvas_tree->append_column(*column);
-       }
-       canvas_tree->set_rules_hint();
-       canvas_tree->signal_row_activated().connect(sigc::mem_fun(*this,&Dock_Canvases::on_row_activate));
-       //canvas_tree->signal_event().connect(sigc::mem_fun(*this,&Dock_Canvases::on_tree_event));
-       canvas_tree->add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
-       canvas_tree->add_events(Gdk::BUTTON1_MOTION_MASK);
-       canvas_tree->show();
-       canvas_tree->set_headers_visible(false);
-
-       Gtk::ScrolledWindow *scrolledwindow = manage(new class Gtk::ScrolledWindow());
-       scrolledwindow->set_flags(Gtk::CAN_FOCUS);
-       scrolledwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
-       scrolledwindow->add(*canvas_tree);
-       scrolledwindow->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
-       scrolledwindow->show_all();
-
-       return scrolledwindow;
-}
-
-etl::loose_handle<studio::CanvasView>
-Dock_Canvases::get_selected_canvas_view()
-{
-       return get_selected_instance()->find_canvas_view(get_selected_canvas());
-}
-
-etl::loose_handle<synfig::Canvas>
-Dock_Canvases::get_selected_canvas()
-{
-       Glib::RefPtr<Gtk::TreeSelection> selection=canvas_tree->get_selection();
-
-       if(!selection || !selection->get_selected())
-               return 0;
-
-       studio::Instance::CanvasTreeModel canvas_tree_model;
-
-       return static_cast<etl::handle<synfig::Canvas> >((*selection->get_selected())[canvas_tree_model.canvas]);
-}
-
-
-
-void
-Dock_Canvases::set_selected_instance_signal(etl::handle<studio::Instance> x)
-{
-       set_selected_instance(x);
-}
-
-void
-Dock_Canvases::set_selected_instance_(etl::handle<studio::Instance> instance)
-{
-       if(studio::App::shutdown_in_progress)
-               return;
-
-       selected_instance=instance;
-       if(instance)
-       {
-               canvas_tree->set_model(instance->canvas_tree_store());
-               canvas_tree->show();
-       }
-       else
-       {
-               canvas_tree->set_model(Glib::RefPtr< Gtk::TreeModel >());
-               canvas_tree->hide();
-       }
-}
-
-void
-Dock_Canvases::set_selected_instance(etl::loose_handle<studio::Instance> x)
-{
-       if(studio::App::shutdown_in_progress)
-               return;
-
-       // if it's already selected, don't select it again
-       if (x==selected_instance)
-               return;
-
-       set_selected_instance_(x);
-}
-
-void
-Dock_Canvases::new_instance(etl::handle<studio::Instance> instance)
-{
-       if(studio::App::shutdown_in_progress)
-               return;
-
-       assert(instance);
-
-       etl::loose_handle<studio::Instance> loose_instance(instance);
-
-       instance->synfigapp::Instance::signal_filename_changed().connect(sigc::mem_fun(*this,&Dock_Canvases::refresh_instances));
-       instance->synfigapp::Instance::signal_filename_changed().connect(
-               sigc::bind<etl::loose_handle<studio::Instance> >(
-                       sigc::mem_fun(*this,&Dock_Canvases::set_selected_instance),
-                       loose_instance
-               )
-       );
-
-       present();
-
-}
-
-void
-Dock_Canvases::delete_instance(etl::handle<studio::Instance> instance)
-{
-       if(studio::App::shutdown_in_progress)
-               return;
-
-       refresh_instances();
-
-       if(selected_instance==instance)
-       {
-               set_selected_instance(0);
-       }
-}
-
-void
-Dock_Canvases::refresh_instances()
-{
-       if(studio::App::shutdown_in_progress)
-               return;
-}
-
-void
-Dock_Canvases::on_row_activate(const Gtk::TreeModel::Path &path, Gtk::TreeViewColumn *)
-{
-       assert(get_selected_instance());
-       studio::Instance::CanvasTreeModel canvas_tree_model;
-       const Gtk::TreeRow row = *(get_selected_instance()->canvas_tree_store()->get_iter(path));
-       if(row[canvas_tree_model.is_canvas])
-               get_selected_instance()->focus(row[canvas_tree_model.canvas]);
-       else
-               studio::App::dialog_not_implemented();
-}
diff --git a/synfig-studio/src/gtkmm/dock_canvases.h b/synfig-studio/src/gtkmm/dock_canvases.h
deleted file mode 100644 (file)
index 34bdbaa..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_canvases.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_DIALOG_CANVASES_H
-#define __SYNFIG_STUDIO_DIALOG_CANVASES_H
-
-/* === H E A D E R S ======================================================= */
-
-#include "dockable.h"
-#include <gtkmm/treeview.h>
-#include "instance.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 Dock_Canvases : public Dockable
-{
-       Gtk::TreeView *canvas_tree;
-       //Gtk::Menu     menu;
-       etl::loose_handle<studio::Instance>     selected_instance;
-
-private:
-
-       void set_selected_instance_(etl::handle<studio::Instance> x);
-
-       etl::loose_handle<studio::Instance> get_selected_instance() { return selected_instance; }
-
-       etl::loose_handle<synfig::Canvas> get_selected_canvas();
-
-       etl::loose_handle<studio::CanvasView> get_selected_canvas_view();
-
-       void set_selected_instance(etl::loose_handle<studio::Instance> x);
-
-       void set_selected_instance_signal(etl::handle<studio::Instance> x);
-
-       void new_instance(etl::handle<studio::Instance> x);
-
-       void delete_instance(etl::handle<studio::Instance> x);
-
-       void refresh_instances();
-
-       bool close();
-
-       void on_row_activate(const Gtk::TreeModel::Path &path, Gtk::TreeViewColumn *);
-       //bool on_tree_event(GdkEvent *event);
-
-
-
-       void on_action_toggle(const Glib::ustring& path);
-       Gtk::Widget* create_canvas_tree();
-
-public:
-
-       Dock_Canvases();
-       ~Dock_Canvases();
-}; // END of Dock_Canvases
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/dock_canvasspecific.cpp b/synfig-studio/src/gtkmm/dock_canvasspecific.cpp
deleted file mode 100644 (file)
index dc655ef..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_canvasspecific.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "app.h"
-#include "dock_canvasspecific.h"
-
-#include <gtkmm/scrolledwindow.h>
-#include <cassert>
-#include "instance.h"
-#include <sigc++/signal.h>
-#include <sigc++/adaptors/hide.h>
-//#include <sigc++/hide.h>
-#include <sigc++/slot.h>
-#include "metadatatreestore.h"
-#include "canvasview.h"
-#include <ETL/clock>
-
-#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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Dock_CanvasSpecific::Dock_CanvasSpecific(const synfig::String& name,const synfig::String& local_name,Gtk::StockID stock_id_):
-       Dockable(name,local_name,stock_id_)
-{
-       App::signal_instance_created().connect(sigc::mem_fun(*this,&Dock_CanvasSpecific::init_instance));
-}
-
-Dock_CanvasSpecific::~Dock_CanvasSpecific()
-{
-}
-
-etl::loose_handle<studio::CanvasView>
-Dock_CanvasSpecific::get_canvas_view()
-{
-       return App::get_selected_canvas_view();
-}
-
-etl::loose_handle<synfigapp::CanvasInterface>
-Dock_CanvasSpecific::get_canvas_interface()
-{
-       if(get_canvas_view())
-               return get_canvas_view()->canvas_interface();
-       return 0;
-}
-
-void
-Dock_CanvasSpecific::init_canvas_view_vfunc(etl::loose_handle<CanvasView> /*canvas_view*/)
-{
-}
-
-void
-Dock_CanvasSpecific::init_instance_vfunc(etl::loose_handle<Instance> /*instance*/)
-{
-}
-
-void
-Dock_CanvasSpecific::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> /*canvas_view*/)
-{
-}
-
-void
-Dock_CanvasSpecific::init_instance(etl::handle<Instance> instance)
-{
-       etl::clock timer;timer.reset();
-       instance->signal_canvas_view_created().connect(sigc::mem_fun(*this,&Dock_CanvasSpecific::init_canvas_view));
-       init_instance_vfunc(instance);
-       // synfig::info("%s init_instance() took %f seconds",get_local_name().c_str(),float(timer()));
-}
-
-void
-Dock_CanvasSpecific::delete_instance(etl::handle<Instance> /*instance*/)
-{
-       changed_canvas_view_vfunc(0);
-}
-
-void
-Dock_CanvasSpecific::init_canvas_view(CanvasView* canvas_view)
-{
-       /*
-       canvas_view->signal_focus_in_event().connect(
-               sigc::hide(
-                       sigc::bind_return(
-                               sigc::mem_fun(
-                                       *this,
-                                       &Dock_CanvasSpecific::canvas_view_changed
-                               ),
-                               false
-                       )
-               )
-       );
-       */
-       // synfig::info("%s init_canvas_view() Starting init...",get_local_name().c_str());
-       etl::clock timer;timer.reset();
-       App::signal_canvas_view_focus().connect(
-               sigc::hide(
-                       sigc::mem_fun(
-                               *this,
-                               &Dock_CanvasSpecific::canvas_view_changed
-                       )
-               )
-       );
-       init_canvas_view_vfunc(canvas_view);
-       // synfig::info("%s init_canvas_view() took %f seconds",get_local_name().c_str(),float(timer()));
-}
-
-void
-Dock_CanvasSpecific::canvas_view_changed()
-{
-       etl::loose_handle<CanvasView> canvas_view(App::get_selected_canvas_view());
-/*     if(canvas_view)
-       {
-               canvas_delete_connection.disconnect();
-               canvas_delete_connection=canvas_view->signal_deleted().connect(
-                       sigc::bind(
-                               sigc::mem_fun(
-                                       *this,
-                                       &Dock_CanvasSpecific::changed_canvas_view
-                               ),
-                               etl::loose_handle<CanvasView>(0)
-                       )
-               );
-       }
-*/
-
-// #ifdef _DEBUG
-//     synfig::info("%s canvas_view_changed: start",get_local_name().c_str());
-// #endif
-       changed_canvas_view_vfunc(canvas_view);
-// #ifdef _DEBUG
-//     synfig::info("%s canvas_view_changed: end",get_local_name().c_str());
-// #endif
-}
diff --git a/synfig-studio/src/gtkmm/dock_canvasspecific.h b/synfig-studio/src/gtkmm/dock_canvasspecific.h
deleted file mode 100644 (file)
index 24efc78..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_canvasspecific.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_DOCK_CANVASSPECIFIC_H
-#define __SYNFIG_STUDIO_DOCK_CANVASSPECIFIC_H
-
-/* === H E A D E R S ======================================================= */
-
-#include "dockable.h"
-#include <gtkmm/treeview.h>
-#include "instance.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 CanvasView;
-class Instance;
-
-class Dock_CanvasSpecific : public Dockable
-{
-       sigc::connection canvas_delete_connection;
-protected:
-       virtual void init_instance_vfunc(etl::loose_handle<Instance> instance);
-
-       virtual void init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
-       virtual void changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
-
-private:
-       void init_canvas_view(CanvasView* canvas_view);
-       void init_instance(etl::handle<Instance> instance);
-       void delete_instance(etl::handle<Instance> instance);
-       void canvas_view_changed();
-       void changed_canvas_view(etl::loose_handle<CanvasView> canvas_view) { return changed_canvas_view_vfunc(canvas_view); }
-public:
-
-       etl::loose_handle<studio::CanvasView> get_canvas_view();
-       etl::loose_handle<synfigapp::CanvasInterface> get_canvas_interface();
-
-       Dock_CanvasSpecific(const synfig::String& name,const synfig::String& local_name,Gtk::StockID stock_id_=Gtk::StockID(" "));
-       virtual ~Dock_CanvasSpecific();
-}; // END of Dock_CanvasSpecific
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/dock_children.cpp b/synfig-studio/src/gtkmm/dock_children.cpp
deleted file mode 100644 (file)
index 0b65306..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_children.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \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
-**     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 <config.h>
-#endif
-
-#include "dock_children.h"
-#include "app.h"
-
-#include <gtkmm/scrolledwindow.h>
-#include <cassert>
-#include "instance.h"
-#include <sigc++/signal.h>
-#include <sigc++/hide.h>
-#include <sigc++/retype_return.h>
-#include <sigc++/slot.h>
-#include "childrentreestore.h"
-#include "childrentree.h"
-#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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Dock_Children::Dock_Children():
-       Dock_CanvasSpecific("children",_("Children"),Gtk::StockID("synfig-children"))
-{
-    //! \todo the combination of set_use_scrolled(false) and
-       //!       add(*tree_view) causes crashes when
-       //!       Dockable::prev_widget_ is left referencing a
-       //!       ChildrenTree that has already been destroyed.
-       // set_use_scrolled(false);
-}
-
-Dock_Children::~Dock_Children()
-{
-}
-
-void
-Dock_Children::init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
-{
-       Glib::RefPtr<ChildrenTreeStore> children_tree_store;
-       children_tree_store=ChildrenTreeStore::create(canvas_view->canvas_interface());
-
-       ChildrenTree* children_tree(new ChildrenTree());
-       children_tree->set_model(children_tree_store);
-       children_tree->set_time_adjustment(canvas_view->time_adjustment());
-
-
-       canvas_view->set_tree_model(get_name(),children_tree_store);
-       canvas_view->set_ext_widget(get_name(),children_tree);
-}
-
-void
-Dock_Children::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
-{
-       if(canvas_view)
-       {
-               Gtk::Widget* tree_view(canvas_view->get_ext_widget(get_name()));
-
-               add(*tree_view);
-               tree_view->show();
-       }
-       else clear_previous();
-
-}
diff --git a/synfig-studio/src/gtkmm/dock_children.h b/synfig-studio/src/gtkmm/dock_children.h
deleted file mode 100644 (file)
index a65d3da..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_children.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_DOCK_CHILDREN_H
-#define __SYNFIG_STUDIO_DOCK_CHILDREN_H
-
-/* === H E A D E R S ======================================================= */
-
-#include "dockable.h"
-#include <gtkmm/treeview.h>
-#include "instance.h"
-#include "dock_canvasspecific.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 Dock_Children : public Dock_CanvasSpecific
-{
-protected:
-       virtual void init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
-       virtual void changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
-
-public:
-
-
-       Dock_Children();
-       ~Dock_Children();
-}; // END of Dock_Children
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/dock_curves.cpp b/synfig-studio/src/gtkmm/dock_curves.cpp
deleted file mode 100644 (file)
index 142b842..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_curves.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "dock_curves.h"
-#include "app.h"
-
-#include <gtkmm/scrolledwindow.h>
-#include <cassert>
-#include "instance.h"
-#include <sigc++/signal.h>
-#include <sigc++/hide.h>
-#include <sigc++/slot.h>
-#include "canvasview.h"
-#include "layerparamtreestore.h"
-#include "workarea.h"
-#include "widget_curves.h"
-#include "layerparamtreestore.h"
-#include <gtkmm/table.h>
-#include <gtkmm/scrollbar.h>
-#include "widget_timeslider.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Dock_Curves::Dock_Curves():
-       Dock_CanvasSpecific("curves",_("Curves"),Gtk::StockID("synfig-curves"))
-{
-       last_widget_curves_=0;
-       table_=0;
-
-       hscrollbar_=new Gtk::HScrollbar();
-       vscrollbar_=new Gtk::VScrollbar();
-       widget_timeslider_= new Widget_Timeslider();
-}
-
-Dock_Curves::~Dock_Curves()
-{
-       if(table_)delete table_;
-       delete hscrollbar_;
-       delete vscrollbar_;
-       delete widget_timeslider_;
-}
-
-static void
-_curve_selection_changed(Gtk::TreeView* param_tree_view,Widget_Curves* curves)
-{
-       LayerParamTreeStore::Model model;
-       Gtk::TreeIter iter;
-       if(!param_tree_view->get_selection()->count_selected_rows())
-       {
-               curves->clear();
-               curves->refresh();
-               return;
-       }
-
-       std::list<synfigapp::ValueDesc> value_descs;
-
-       iter=param_tree_view->get_selection()->get_selected();
-       value_descs.push_back((*iter)[model.value_desc]);
-       curves->set_value_descs(value_descs);
-}
-
-void
-Dock_Curves::init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
-{
-       Widget_Curves* curves(new Widget_Curves());
-       curves->set_time_adjustment(canvas_view->time_adjustment());
-
-       Gtk::TreeView* param_tree_view(
-               static_cast<Gtk::TreeView*>(canvas_view->get_ext_widget("params"))
-       );
-
-       param_tree_view->get_selection()->signal_changed().connect(
-               sigc::bind(
-                       sigc::bind(
-                               sigc::ptr_fun(
-                                       _curve_selection_changed
-                               ),curves
-                       ),param_tree_view
-               )
-       );
-
-       canvas_view->set_ext_widget(get_name(),curves);
-}
-
-void
-Dock_Curves::refresh_selected_param()
-{
-/*     Gtk::TreeView* tree_view(
-               static_cast<Gtk::TreeView*>(get_canvas_view()->get_ext_widget(get_name()))
-       );
-       Gtk::TreeModel::iterator iter(tree_view->get_selection()->get_selected());
-
-       if(iter)
-       {
-               LayerParamTreeStore::Model model;
-               get_canvas_view()->work_area->set_selected_value_node(
-                       (synfig::ValueNode::Handle)(*iter)[model.value_node]
-               );
-       }
-       else
-       {
-               get_canvas_view()->work_area->set_selected_value_node(0);
-       }
-*/
-}
-
-void
-Dock_Curves::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
-{
-       if(table_)
-       {
-               table_->hide();
-               delete table_;
-               hscrollbar_->unset_adjustment();
-               vscrollbar_->unset_adjustment();
-               //widget_timeslider_->unset_adjustment();
-               table_=0;
-       }
-
-
-       if(canvas_view)
-       {
-               last_widget_curves_=dynamic_cast<Widget_Curves*>(
-                       canvas_view->get_ext_widget(get_name())
-               );
-
-               vscrollbar_->set_adjustment(last_widget_curves_->get_range_adjustment());
-               hscrollbar_->set_adjustment(canvas_view->time_window_adjustment());
-               widget_timeslider_->set_time_adjustment(&canvas_view->time_adjustment());
-               widget_timeslider_->set_bounds_adjustment(&canvas_view->time_window_adjustment());
-               widget_timeslider_->set_global_fps(canvas_view->get_canvas()->rend_desc().get_frame_rate());
-
-               table_=new Gtk::Table(2,2);
-               table_->attach(*widget_timeslider_, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::SHRINK);
-               table_->attach(*last_widget_curves_, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
-               table_->attach(*hscrollbar_, 0, 1, 2, 3, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::SHRINK);
-               table_->attach(*vscrollbar_, 1, 2, 0, 2, Gtk::FILL|Gtk::SHRINK, Gtk::FILL|Gtk::EXPAND);
-               add(*table_);
-
-               //add(*last_widget_curves_);
-               last_widget_curves_->show();
-               table_->show_all();
-               show_all();
-       }
-       else
-       {
-               //clear_previous();
-       }
-}
diff --git a/synfig-studio/src/gtkmm/dock_curves.h b/synfig-studio/src/gtkmm/dock_curves.h
deleted file mode 100644 (file)
index dbe913f..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_curves.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_DOCK_CURVES_H
-#define __SYNFIG_STUDIO_DOCK_CURVES_H
-
-/* === H E A D E R S ======================================================= */
-
-#include "dockable.h"
-#include <gtkmm/treeview.h>
-#include "instance.h"
-#include "dock_canvasspecific.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 Gtk { class Table; class HScrollbar; class VScrollbar; };
-
-namespace studio {
-
-class Widget_Curves;
-class Widget_Timeslider;
-
-class Dock_Curves : public Dock_CanvasSpecific
-{
-       Gtk::Table* table_;
-       Gtk::HScrollbar* hscrollbar_;
-       Gtk::VScrollbar* vscrollbar_;
-
-       Widget_Timeslider* widget_timeslider_;
-       Widget_Curves* last_widget_curves_;
-
-protected:
-       virtual void init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
-       virtual void changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
-
-       void refresh_selected_param();
-
-public:
-
-
-       Dock_Curves();
-       ~Dock_Curves();
-}; // END of Dock_Keyframes
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/dock_history.cpp b/synfig-studio/src/gtkmm/dock_history.cpp
deleted file mode 100644 (file)
index cddf07b..0000000
+++ /dev/null
@@ -1,447 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_history.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 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 <config.h>
-#endif
-
-#include "dock_history.h"
-#include "app.h"
-
-
-
-#include <gtkmm/scrolledwindow.h>
-#include <cassert>
-#include "instance.h"
-#include <sigc++/signal.h>
-#include <sigc++/hide.h>
-#include <sigc++/slot.h>
-#include <synfigapp/action.h>
-#include "historytreestore.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 ========================================================= */
-#define COLUMNID_JUMP          (787584)
-#define ColumnID       int
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Dock_History::Dock_History():
-       Dock_CanvasSpecific("history",_("History"),Gtk::StockID("gtk-undo")),
-       action_group(Gtk::ActionGroup::create("action_group_dock_history"))
-{
-       App::signal_instance_deleted().connect(sigc::mem_fun(*this,&studio::Dock_History::delete_instance));
-       App::signal_instance_selected().connect(sigc::mem_fun(*this,&studio::Dock_History::set_selected_instance_signal));
-
-       action_group->add(Gtk::Action::create(
-               "clear-undo",
-               Gtk::StockID("synfig-clear_undo"),
-               _("Clear Undo Stack"),
-               _("Clear the undo stack")
-       ),
-               sigc::mem_fun(
-                       *this,
-                       &Dock_History::clear_undo
-               )
-       );
-       action_group->add(Gtk::Action::create(
-               "clear-redo",
-               Gtk::StockID("synfig-clear_redo"),
-               _("Clear Redo Stack"),
-               _("Clear the redo stack")
-       ),
-               sigc::mem_fun(
-                       *this,
-                       &Dock_History::clear_redo
-               )
-       );
-       action_group->add(Gtk::Action::create(
-               "clear-undo-and-redo",
-               Gtk::Stock::CLEAR,
-               _("Clear Undo and Redo Stacks"),
-               _("Clear the undo and redo stacks")
-       ),
-               sigc::mem_fun(
-                       *this,
-                       &Dock_History::clear_undo_and_redo
-               )
-       );
-       action_group->add(Gtk::Action::create(
-               "undo",
-               Gtk::StockID("gtk-undo"),
-               _("Undo"),
-               _("Undo the previous action")
-       ),
-               sigc::ptr_fun(studio::App::undo)
-       );
-       action_group->add(Gtk::Action::create(
-               "redo",
-               Gtk::StockID("gtk-redo"),
-               _("Redo"),
-               _("Redo the previously undone action")
-       ),
-               sigc::ptr_fun(studio::App::redo)
-       );
-
-       action_group->add( Gtk::Action::create("toolbar-history", _("History")) );
-       App::ui_manager()->insert_action_group(action_group);
-
-       Glib::ustring ui_info =
-       "<ui>"
-       "       <toolbar action='toolbar-history'>"
-       "       <toolitem action='undo' />"
-       "       <toolitem action='redo' />"
-       "       <toolitem action='clear-undo' />"
-       "       <toolitem action='clear-redo' />"
-       "       <toolitem action='clear-undo-and-redo' />"
-       "       </toolbar>"
-       "</ui>"
-       ;
-
-       App::ui_manager()->add_ui_from_string(ui_info);
-
-       action_group->set_sensitive(false);
-
-       set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-history")));
-       add(*create_action_tree());
-}
-
-Dock_History::~Dock_History()
-{
-}
-
-void
-Dock_History::init_instance_vfunc(etl::loose_handle<Instance> instance)
-{
-       instance->signal_undo_redo_status_changed().connect(
-               sigc::mem_fun(*this,&Dock_History::update_undo_redo)
-       );
-}
-
-Gtk::Widget*
-Dock_History::create_action_tree()
-{
-       studio::HistoryTreeStore::Model history_tree_model;
-       action_tree=manage(new class Gtk::TreeView());
-       {
-               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column("") );
-
-               Gtk::CellRendererToggle* toggle_cr = Gtk::manage( new Gtk::CellRendererToggle() );
-               toggle_cr->signal_toggled().connect(sigc::mem_fun(*this, &studio::Dock_History::on_action_toggle) );
-
-               column->pack_start(*toggle_cr); //false = don't expand.
-               column->add_attribute(toggle_cr->property_active(),history_tree_model.is_active);
-               column->set_resizable();
-               column->set_clickable();
-
-               action_tree->append_column(*column);
-       }
-       /*{
-               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Canvas")) );
-               Gtk::CellRendererText *text_cr=Gtk::manage(new Gtk::CellRendererText());
-               text_cr->property_foreground()=Glib::ustring("#7f7f7f");
-
-               column->pack_start(*text_cr);
-               column->add_attribute(text_cr->property_text(),history_tree_model.canvas_id);
-               column->add_attribute(text_cr->property_foreground_set(),history_tree_model.is_redo);
-
-               action_tree->append_column(*column);
-       }*/
-       {
-               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Jump")) );
-
-               Gtk::CellRendererText* cell_renderer_jump=Gtk::manage(new Gtk::CellRendererText());
-               column->pack_start(*cell_renderer_jump,true);
-
-               cell_renderer_jump->property_text()=_("(JMP)");
-               cell_renderer_jump->property_foreground()="#003a7f";
-
-               column->set_resizable();
-               column->set_clickable();
-
-               column->set_sort_column(COLUMNID_JUMP);
-
-               action_tree->append_column(*column);
-               //column->clicked();
-       }
-       {
-               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Action")) );
-
-               Gtk::CellRendererText *text_cr=Gtk::manage(new Gtk::CellRendererText());
-               text_cr->property_foreground()=Glib::ustring("#7f7f7f");
-
-
-
-               //column->pack_start(history_tree_model.icon, false); //false = don't expand.
-               column->pack_start(*text_cr);
-               column->add_attribute(text_cr->property_text(),history_tree_model.name);
-               column->add_attribute(text_cr->property_foreground_set(),history_tree_model.is_redo);
-
-               action_tree->append_column(*column);
-       }
-
-       action_tree->set_enable_search(true);
-       action_tree->set_search_column(history_tree_model.name);
-       action_tree->set_search_equal_func(sigc::ptr_fun(&studio::HistoryTreeStore::search_func));
-
-       action_tree->set_rules_hint();
-//     action_tree->signal_row_activated().connect(sigc::mem_fun(*this,&Dock_History::on_row_activate));
-       action_tree->signal_event().connect(sigc::mem_fun(*this,&Dock_History::on_action_event));
-//     action_tree->add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
-//     action_tree->add_events(Gdk::BUTTON1_MOTION_MASK);
-       action_tree->show();
-
-       Gtk::ScrolledWindow *scrolledwindow = manage(new class Gtk::ScrolledWindow());
-       scrolledwindow->set_flags(Gtk::CAN_FOCUS);
-       scrolledwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
-       scrolledwindow->add(*action_tree);
-       scrolledwindow->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
-       scrolledwindow->show_all();
-
-/*     {
-               Gtk::Widget& widget(*action_tree);
-               Pango::FontDescription font(widget.get_modifier_style()->get_font());
-               font.set_size(Pango::SCALE*5);
-               widget.get_modifier_style()->set_font(font);
-               widget.modify_font(font);
-       }
-*/
-       return scrolledwindow;
-}
-
-void
-Dock_History::clear_undo()
-{
-       if(selected_instance && App::dialog_yes_no(_("Clear History"),
-                       _("You will not be able to undo any changes that you have made!\nAre you sure you want to clear the undo stack?")))
-               selected_instance->clear_undo_stack();
-}
-
-void
-Dock_History::clear_redo()
-{
-       if(selected_instance && App::dialog_yes_no(_("Clear History"),
-                       _("You will not be able to redo any changes that you have made!\nAre you sure you want to clear the redo stack?")))
-               selected_instance->clear_redo_stack();
-}
-
-void
-Dock_History::clear_undo_and_redo()
-{
-       if(selected_instance && App::dialog_yes_no(_("Clear History"),
-                       _("You will not be able to undo or redo any changes that you have made!\nAre you sure you want to clear the undo and redo stacks?")))
-       {
-               selected_instance->clear_undo_stack();
-               selected_instance->clear_redo_stack();
-       }
-}
-
-void
-Dock_History::update_undo_redo()
-{
-       etl::handle<Instance> instance=App::get_selected_instance();
-       if(instance)
-       {
-               action_group->get_action("undo")->set_sensitive(instance->get_undo_status());
-               action_group->get_action("clear-undo")->set_sensitive(instance->get_undo_status());
-               action_group->get_action("redo")->set_sensitive(instance->get_redo_status());
-               action_group->get_action("clear-redo")->set_sensitive(instance->get_redo_status());
-               action_group->get_action("clear-undo-and-redo")->set_sensitive(instance->get_undo_status() || instance->get_redo_status());
-       }
-}
-
-void
-Dock_History::on_undo_tree_changed()
-{
-       Gtk::TreeModel::Children children(selected_instance->history_tree_store()->children());
-
-       if (!children.size())
-               return;
-
-       studio::HistoryTreeStore::Model model;
-
-       Gtk::TreeModel::Children::iterator iter, prev = children.end();
-       for (iter = children.begin(); iter != children.end(); prev = iter++)
-               if ((*iter)[model.is_redo])
-               {
-                       if (prev == children.end())
-                               action_tree->get_selection()->unselect_all();
-                       else
-                       {
-                               action_tree->scroll_to_row(Gtk::TreePath(prev), 0.5);
-                               action_tree->get_selection()->select(prev);
-                       }
-                       return;
-               }
-
-       action_tree->scroll_to_row(Gtk::TreePath(prev), 0.5);
-       action_tree->get_selection()->select(prev);
-}
-
-void
-Dock_History::set_selected_instance_(etl::handle<studio::Instance> instance)
-{
-       if(studio::App::shutdown_in_progress)
-               return;
-
-       if (on_undo_tree_changed_connection)
-               on_undo_tree_changed_connection.disconnect();
-
-       selected_instance=instance;
-       if(instance)
-       {
-               on_undo_tree_changed_connection = selected_instance->history_tree_store()->signal_undo_tree_changed().connect(
-                       sigc::mem_fun(*this,&Dock_History::on_undo_tree_changed));
-
-               action_tree->set_model(instance->history_tree_store());
-               action_tree->show();
-               update_undo_redo();
-               action_group->set_sensitive(true);
-       }
-       else
-       {
-               action_tree->set_model(Glib::RefPtr< Gtk::TreeModel >());
-               action_tree->hide();
-               action_group->set_sensitive(false);
-       }
-}
-
-void
-Dock_History::set_selected_instance_signal(etl::handle<studio::Instance> x)
-{
-       set_selected_instance(x);
-}
-
-void
-Dock_History::set_selected_instance(etl::loose_handle<studio::Instance> x)
-{
-       if(studio::App::shutdown_in_progress)
-               return;
-
-       // if it's already selected, don't select it again
-       if (x==selected_instance)
-               return;
-
-       std::list<etl::handle<studio::Instance> >::iterator iter;
-
-       set_selected_instance_(x);
-}
-
-void
-Dock_History::delete_instance(etl::handle<studio::Instance> instance)
-{
-       if(studio::App::shutdown_in_progress)
-               return;
-
-       if(selected_instance==instance)
-       {
-               set_selected_instance(0);
-       }
-}
-
-bool
-Dock_History::on_action_event(GdkEvent *event)
-{
-       studio::HistoryTreeStore::Model model;
-    switch(event->type)
-    {
-       case GDK_BUTTON_PRESS:
-       case GDK_2BUTTON_PRESS:
-               {
-                       Gtk::TreeModel::Path path;
-                       Gtk::TreeViewColumn *column;
-                       int cell_x, cell_y;
-                       if(!action_tree->get_path_at_pos(
-                               int(event->button.x),int(event->button.y),      // x, y
-                               path, // TreeModel::Path&
-                               column, //TreeViewColumn*&
-                               cell_x,cell_y //int&cell_x,int&cell_y
-                               )
-                       ) break;
-                       const Gtk::TreeRow row = *(action_tree->get_model()->get_iter(path));
-
-                       //signal_user_click()(event->button.button,row,(ColumnID)column->get_sort_column_id());
-                       if((ColumnID)column->get_sort_column_id()==COLUMNID_JUMP)
-                       {
-                               etl::handle<synfigapp::Action::Undoable> action(row[model.action]);
-                               try{
-                               if((bool)row[model.is_undo])
-                               {
-                                       while(get_selected_instance()->undo_action_stack().size() && get_selected_instance()->undo_action_stack().front()!=action)
-                                               if(get_selected_instance()->undo()==false)
-                                                       throw int();
-                               }
-                               else if((bool)row[model.is_redo])
-                               {
-                                       while(get_selected_instance()->redo_action_stack().size() && get_selected_instance()->undo_action_stack().front()!=action)
-                                               if(get_selected_instance()->redo()==false)
-                                                       throw int();
-                               }
-                               }
-                               catch(int)
-                               {
-                                       return true;
-                               }
-                       }
-               }
-
-       case GDK_BUTTON_RELEASE:
-               break;
-       default:
-               break;
-       }
-       return false;
-}
-
-void
-Dock_History::on_action_toggle(const Glib::ustring& path_string)
-{
-       studio::HistoryTreeStore::Model history_tree_model;
-
-       Gtk::TreePath path(path_string);
-
-       const Gtk::TreeRow row = *(selected_instance->history_tree_store()->get_iter(path));
-
-       handle<synfigapp::Action::Undoable> action=row[history_tree_model.action];
-
-       selected_instance->synfigapp::Instance::set_action_status(action,!action->is_active());
-}
diff --git a/synfig-studio/src/gtkmm/dock_history.h b/synfig-studio/src/gtkmm/dock_history.h
deleted file mode 100644 (file)
index 00154b2..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_history.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_DIALOG_HISTORY_H
-#define __SYNFIG_STUDIO_DIALOG_HISTORY_H
-
-/* === H E A D E R S ======================================================= */
-
-#include "dockable.h"
-#include <gtkmm/treeview.h>
-#include "instance.h"
-#include <gtkmm/actiongroup.h>
-#include "dock_canvasspecific.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 Dock_History : public Dock_CanvasSpecific
-{
-       Glib::RefPtr<Gtk::ActionGroup> action_group;
-       Gtk::TreeView *action_tree;
-
-       etl::loose_handle<studio::Instance>     selected_instance;
-
-       sigc::connection on_undo_tree_changed_connection;
-
-       void on_undo_tree_changed();
-
-       void set_selected_instance_(etl::handle<studio::Instance> x);
-
-
-       void set_selected_instance(etl::loose_handle<studio::Instance> x);
-
-       void set_selected_instance_signal(etl::handle<studio::Instance> x);
-
-       void delete_instance(etl::handle<studio::Instance> x);
-
-       Gtk::Widget* create_action_tree();
-
-public:
-
-       etl::loose_handle<studio::Instance> get_selected_instance() { return selected_instance; }
-
-       void clear_undo();
-       void clear_redo();
-       void clear_undo_and_redo();
-
-       bool on_action_event(GdkEvent *event);
-       void on_action_toggle(const Glib::ustring& path);
-
-       void update_undo_redo();
-
-       Dock_History();
-       ~Dock_History();
-protected:
-       virtual void init_instance_vfunc(etl::loose_handle<Instance> instance);
-
-}; // END of Dock_History
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/dock_info.cpp b/synfig-studio/src/gtkmm/dock_info.cpp
deleted file mode 100644 (file)
index 42c8a82..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_info.cpp
-**     \brief Dock Info File
-**
-**     $Id$
-**
-**     \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
-**     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 <config.h>
-#endif
-
-#include "dock_info.h"
-#include "canvasview.h"
-#include "workarea.h"
-
-#include <synfig/canvas.h>
-#include <synfig/color.h>              // for gamma_in()
-#include <synfig/context.h>
-
-#include <gtkmm/separator.h>
-#include <gtkmm/invisible.h>
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-using namespace synfig;
-
-/* === M A C R O S ========================================================= */
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-/* === E N T R Y P O I N T ================================================= */
-
-void studio::Dock_Info::on_mouse_move()
-{
-       Point pos = get_canvas_view()->work_area->get_cursor_pos();
-
-       Distance xv(pos[0],Distance::SYSTEM_UNITS);
-       xv.convert(App::distance_system, get_canvas_view()->get_canvas()->rend_desc());
-
-       Distance yv(pos[1],Distance::SYSTEM_UNITS);
-       yv.convert(App::distance_system, get_canvas_view()->get_canvas()->rend_desc());
-
-       //get the color and set the labels
-
-       x.set_text(xv.get_string(3));
-       y.set_text(yv.get_string(3));
-
-       Color c = get_canvas_view()->get_canvas()->get_context().get_color(pos);
-       float cr = c.get_r(),cg = c.get_g(), cb = c.get_b();
-
-       if(use_colorspace_gamma())
-       {
-               cr = gamma_in(cr);
-               cg = gamma_in(cg);
-               cb = gamma_in(cb);
-       }
-
-       r.set_text(strprintf("%.1f%%",cr*100));
-       g.set_text(strprintf("%.1f%%",cg*100));
-       b.set_text(strprintf("%.1f%%",cb*100));
-       a.set_text(strprintf("%.1f%%",c.get_a()*100));
-}
-
-studio::Dock_Info::Dock_Info()
-:Dock_CanvasSpecific("info",_("Info"),Gtk::StockID("synfig-info"))
-{
-       set_use_scrolled(false);
-
-       Gtk::Table *table = manage(new Gtk::Table);
-
-       //pos labels
-       table->attach(*manage(new Gtk::Label(_("X: "))),0,1,0,2,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
-       table->attach(*manage(new Gtk::Label(_("Y: "))),0,1,2,4,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
-
-       //pos
-       table->attach(x,1,2,0,2,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
-       table->attach(y,1,2,2,4,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
-
-       //separator
-       table->attach(*manage(new Gtk::VSeparator),2,3,0,4,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
-
-       //color label
-       table->attach(*manage(new Gtk::Label(_("R: "))),3,4,0,1,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
-       table->attach(*manage(new Gtk::Label(_("G: "))),3,4,1,2,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
-       table->attach(*manage(new Gtk::Label(_("B: "))),3,4,2,3,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
-       table->attach(*manage(new Gtk::Label(_("A: "))),3,4,3,4,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
-
-       //color
-       table->attach(r,4,5,0,1,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
-       table->attach(g,4,5,1,2,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
-       table->attach(b,4,5,2,3,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
-       table->attach(a,4,5,3,4,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
-
-       table->attach(*manage(new Gtk::Label),0,5,4,5);
-
-       table->show_all();
-
-       add(*table);
-}
-
-studio::Dock_Info::~Dock_Info()
-{
-}
-
-void studio::Dock_Info::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
-{
-       mousecon.disconnect();
-
-       if(canvas_view && canvas_view->get_work_area())
-       {
-               mousecon = get_canvas_view()->work_area->signal_cursor_moved().connect(sigc::mem_fun(*this,&Dock_Info::on_mouse_move));
-       }
-}
diff --git a/synfig-studio/src/gtkmm/dock_info.h b/synfig-studio/src/gtkmm/dock_info.h
deleted file mode 100644 (file)
index 4ecd337..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_info.h
-**     \brief Info Dock 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_DOCK_INFO_H
-#define __SYNFIG_DOCK_INFO_H
-
-/* === H E A D E R S ======================================================= */
-#include "dock_canvasspecific.h"
-#include "sigc++/signal.h"
-
-#include "widget_distance.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 Dock_Info : public Dock_CanvasSpecific
-{
-       Gtk::Label  r,g,b,a;
-       Gtk::Label      x,y;
-
-       sigc::connection mousecon;
-
-       void on_mouse_move();
-
-public:
-       Dock_Info();
-       ~Dock_Info();
-
-       virtual void changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/dock_keyframes.cpp b/synfig-studio/src/gtkmm/dock_keyframes.cpp
deleted file mode 100644 (file)
index 44e9893..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_keyframes.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "dock_keyframes.h"
-#include "app.h"
-
-#include <gtkmm/scrolledwindow.h>
-#include <cassert>
-#include "instance.h"
-#include <sigc++/signal.h>
-#include <sigc++/hide.h>
-#include <sigc++/slot.h>
-#include "keyframetreestore.h"
-#include "keyframetree.h"
-#include "canvasview.h"
-#include "keyframeactionmanager.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Dock_Keyframes::Dock_Keyframes():
-       Dock_CanvasSpecific("keyframes",_("Keyframes"),Gtk::StockID("synfig-keyframes")),
-       action_group(Gtk::ActionGroup::create("action_group_dock_keyframes")),
-       keyframe_action_manager(new KeyframeActionManager)
-{
-       keyframe_action_manager->set_ui_manager(App::ui_manager());
-       keyframe_action_manager->signal_show_keyframe_properties().connect(
-               sigc::mem_fun(*this,&Dock_Keyframes::show_keyframe_properties)
-       );
-
-    Glib::ustring ui_info =
-       "<ui>"
-       "       <toolbar action='toolbar-keyframe'>"
-       "       <toolitem action='action-KeyframeAdd' />"
-       "       <toolitem action='action-KeyframeDuplicate' />"
-       "       <toolitem action='action-KeyframeRemove' />"
-       "       <toolitem action='keyframe-properties' />"
-       "       </toolbar>"
-       "</ui>"
-       ;
-
-       App::ui_manager()->add_ui_from_string(ui_info);
-
-       set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-keyframe")));
-}
-
-Dock_Keyframes::~Dock_Keyframes()
-{
-}
-
-void
-Dock_Keyframes::show_keyframe_properties()
-{
-       if(get_canvas_view())
-               get_canvas_view()->show_keyframe_dialog();
-}
-
-void
-Dock_Keyframes::init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
-{
-       Glib::RefPtr<KeyframeTreeStore> keyframe_tree_store;
-       keyframe_tree_store=KeyframeTreeStore::create(canvas_view->canvas_interface());
-
-       KeyframeTree* keyframe_tree(new KeyframeTree());
-       keyframe_tree->set_model(keyframe_tree_store);
-       keyframe_tree->set_editable(true);
-
-       canvas_view->set_tree_model(get_name(),keyframe_tree_store);
-       canvas_view->set_ext_widget(get_name(),keyframe_tree);
-}
-
-void
-Dock_Keyframes::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
-{
-       if(canvas_view)
-       {
-               Gtk::Widget* tree_view(canvas_view->get_ext_widget(get_name()));
-
-               add(*tree_view);
-               tree_view->show();
-
-               keyframe_action_manager->set_keyframe_tree(dynamic_cast<KeyframeTree*>(canvas_view->get_ext_widget(get_name())));
-               keyframe_action_manager->set_canvas_interface(canvas_view->canvas_interface());
-               keyframe_action_manager->refresh();
-       }
-       else
-       {
-               clear_previous();
-
-               keyframe_action_manager->set_keyframe_tree(0);
-               keyframe_action_manager->set_canvas_interface(0);
-               keyframe_action_manager->refresh();
-       }
-}
diff --git a/synfig-studio/src/gtkmm/dock_keyframes.h b/synfig-studio/src/gtkmm/dock_keyframes.h
deleted file mode 100644 (file)
index 37c99c4..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_keyframes.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_DOCK_KEYFRAMES_H
-#define __SYNFIG_STUDIO_DOCK_KEYFRAMES_H
-
-/* === H E A D E R S ======================================================= */
-
-#include "dockable.h"
-#include "dock_canvasspecific.h"
-#include <gtkmm/treeview.h>
-#include "instance.h"
-#include <gtkmm/actiongroup.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 KeyframeTreeStore;
-class KeyframeTree;
-
-class KeyframeActionManager;
-
-class Dock_Keyframes : public Dock_CanvasSpecific
-{
-       Glib::RefPtr<Gtk::ActionGroup> action_group;
-
-       /*
-       void add_keyframe_pressed();
-       void duplicate_keyframe_pressed();
-       void delete_keyframe_pressed();
-       */
-
-       void show_keyframe_properties();
-
-       KeyframeActionManager* keyframe_action_manager;
-
-protected:
-       virtual void init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
-       virtual void changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
-
-
-public:
-
-
-       Dock_Keyframes();
-       ~Dock_Keyframes();
-}; // END of Dock_Keyframes
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/dock_layergroups.cpp b/synfig-studio/src/gtkmm/dock_layergroups.cpp
deleted file mode 100644 (file)
index d847ff7..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_layergroups.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "dock_layergroups.h"
-#include "app.h"
-
-#include <gtkmm/scrolledwindow.h>
-#include <cassert>
-#include "instance.h"
-#include <sigc++/signal.h>
-#include <sigc++/hide.h>
-#include <sigc++/retype_return.h>
-#include <sigc++/slot.h>
-#include "canvasview.h"
-
-#include "layergrouptreestore.h"
-#include "layergrouptree.h"
-#include "groupactionmanager.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Dock_LayerGroups::Dock_LayerGroups():
-       Dock_CanvasSpecific("groups",_("Groups"),Gtk::StockID("synfig-group")),
-       action_group_group_ops(Gtk::ActionGroup::create("action_group_dock_layergroups")),
-       group_action_manager(new GroupActionManager)
-{
-       group_action_manager->set_ui_manager(App::ui_manager());
-
-       action_group_group_ops->add( Gtk::Action::create("toolbar-groups", _("Group Ops")) );
-
-       action_group_add=Gtk::Action::create("action-group_add", Gtk::Stock::ADD,_("Add a New Group"),_("Add a New Group"));
-       action_group_group_ops->add(action_group_add);
-       action_group_add->set_sensitive(false);
-
-       App::ui_manager()->insert_action_group(action_group_group_ops);
-
-    Glib::ustring ui_info =
-       "<ui>"
-       "       <toolbar action='toolbar-groups'>"
-       "       <toolitem action='action-GroupRemove' />"
-       "       <toolitem action='action-group_add' />"
-       "       </toolbar>"
-       "</ui>"
-       ;
-
-       App::ui_manager()->add_ui_from_string(ui_info);
-
-       set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-groups")));
-}
-
-Dock_LayerGroups::~Dock_LayerGroups()
-{
-       delete group_action_manager;
-}
-
-void
-Dock_LayerGroups::init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
-{
-       Glib::RefPtr<LayerGroupTreeStore> layer_group_tree_store;
-       layer_group_tree_store=LayerGroupTreeStore::create(canvas_view->canvas_interface());
-
-       LayerGroupTree* layer_group_tree(new LayerGroupTree());
-       layer_group_tree->set_model(layer_group_tree_store);
-       layer_group_tree->signal_popup_layer_menu().connect(sigc::mem_fun(*canvas_view,&CanvasView::popup_layer_menu));
-
-       canvas_view->set_tree_model(get_name(),layer_group_tree_store);
-       canvas_view->set_ext_widget(get_name(),layer_group_tree);
-}
-
-void
-Dock_LayerGroups::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
-{
-       if(canvas_view)
-       {
-               Gtk::Widget* tree_view(canvas_view->get_ext_widget(get_name()));
-
-               add(*tree_view);
-               tree_view->show();
-
-               group_action_manager->set_group_tree(dynamic_cast<LayerGroupTree*>(tree_view));
-               group_action_manager->set_canvas_interface(canvas_view->canvas_interface());
-               group_action_manager->refresh();
-       }
-       else
-       {
-               clear_previous();
-               group_action_manager->clear();
-               group_action_manager->set_canvas_interface(0);
-               group_action_manager->set_group_tree(0);
-       }
-}
diff --git a/synfig-studio/src/gtkmm/dock_layergroups.h b/synfig-studio/src/gtkmm/dock_layergroups.h
deleted file mode 100644 (file)
index bdb4f22..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_layergroups.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_DOCK_LAYERGROUPS_H
-#define __SYNFIG_STUDIO_DOCK_LAYERGROUPS_H
-
-/* === H E A D E R S ======================================================= */
-
-#include "dockable.h"
-#include <gtkmm/treeview.h>
-#include "instance.h"
-#include "dock_canvasspecific.h"
-#include <gtkmm/actiongroup.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 Gtk { class HScale; }
-
-namespace studio {
-
-class GroupActionManager ;
-
-class Dock_LayerGroups : public Dock_CanvasSpecific
-{
-       Glib::RefPtr<Gtk::ActionGroup> action_group_group_ops;
-       Glib::RefPtr<Gtk::Action> action_group_add;
-
-       GroupActionManager *group_action_manager;
-protected:
-       virtual void init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
-       virtual void changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
-
-private:
-
-public:
-
-
-       Dock_LayerGroups();
-       ~Dock_LayerGroups();
-}; // END of Dock_LayerGroups
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/dock_layers.cpp b/synfig-studio/src/gtkmm/dock_layers.cpp
deleted file mode 100644 (file)
index 2c75e83..0000000
+++ /dev/null
@@ -1,295 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_layers.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 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 <config.h>
-#endif
-
-#include "dock_layers.h"
-#include "app.h"
-
-#include <gtkmm/scrolledwindow.h>
-#include <cassert>
-#include "instance.h"
-#include <sigc++/signal.h>
-#include <sigc++/hide.h>
-#include <sigc++/retype_return.h>
-#include <sigc++/slot.h>
-#include "layertreestore.h"
-#include "layertree.h"
-#include "canvasview.h"
-#include "layeractionmanager.h"
-//#include <ETL/ref_count>
-
-#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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/*static void do_nothing(reference_counter x)
-{
-       synfig::info(__FILE__":%d:ref_count.count()=%d",__LINE__,x.count());
-}*/
-
-/* === M E T H O D S ======================================================= */
-
-Dock_Layers::Dock_Layers():
-       Dock_CanvasSpecific("layers",_("Layers"),Gtk::StockID("synfig-layer")),
-       layer_action_manager(new LayerActionManager)
-{
-       if(layer_action_manager)layer_action_manager->set_ui_manager(App::ui_manager());
-
-       action_group_new_layers=Gtk::ActionGroup::create("action_group_new_layers");
-       action_group_layer_ops=Gtk::ActionGroup::create("action_group_layer_ops");
-
-       std::map<synfig::String,synfig::String> category_map;
-
-       // Build layer creation actions
-       synfig::Layer::Book::iterator iter;
-       for(iter=synfig::Layer::book().begin();iter!=synfig::Layer::book().end();++iter)
-       {
-               synfig::Layer::Book::value_type lyr(*iter);
-
-               if(lyr.second.category==CATEGORY_DO_NOT_USE)
-                       continue;
-
-               action_group_new_layers->add(Gtk::Action::create(
-                       strprintf("layer-new-%s",lyr.first.c_str()),
-                       layer_icon(lyr.first.c_str()),
-                       lyr.second.local_name,lyr.second.local_name
-               ),
-                       sigc::hide_return(
-                               sigc::bind(
-                                       sigc::mem_fun(*this,&studio::Dock_Layers::add_layer),
-                                       lyr.first
-                               )
-                       )
-               );
-
-               category_map[lyr.second.category]+=strprintf("<menuitem action='layer-new-%s' />",lyr.first.c_str());
-
-               //(*category_map)[lyr.second.category]->items().push_back(Gtk::Menu_Helpers::MenuElem(lyr.second.local_name,
-               //));
-       }
-
-       {
-               Glib::RefPtr<Gtk::ActionGroup> action_group_categories(Gtk::ActionGroup::create("layer-category"));
-               synfig::String layer_ui_info;
-
-               layer_ui_info+="<ui><popup action='menu-main'><menu action='menu-layer'><menu action='menu-layer-new'>";
-
-               std::map<synfig::String,synfig::String>::iterator iter;
-               for(iter=category_map.begin();iter!=category_map.end();++iter)
-               {
-                       layer_ui_info+=strprintf("<menu action='%s'>%s</menu>",iter->first.c_str(),iter->second.c_str());
-                       action_group_categories->add(Gtk::Action::create(iter->first.c_str(),dgettext("synfig", iter->first.c_str())));
-               }
-
-               layer_ui_info+="</menu></menu></popup></ui>";
-
-               App::ui_manager()->insert_action_group(action_group_categories);
-               App::ui_manager()->insert_action_group(action_group_new_layers);
-
-               try
-               {
-                       App::ui_manager()->add_ui_from_string(layer_ui_info);
-               }
-               catch(Glib::MarkupError x)
-               {
-                       error("%s:%d caught MarkupError code %d: %s", __FILE__, __LINE__, x.code(), x.what().c_str());
-                       error("%s:%d with markup: \"%s\"", __FILE__, __LINE__, layer_ui_info.c_str());
-                       exit(1);
-               }
-       }
-
-       if(layer_action_manager)
-               action_group_layer_ops->add(layer_action_manager->get_action_select_all_child_layers());
-
-       action_group_layer_ops->add( Gtk::Action::create("toolbar-layer", _("Layer Ops")) );
-       App::ui_manager()->insert_action_group(action_group_layer_ops);
-
-    Glib::ustring ui_info =
-       "<ui>"
-       "       <toolbar action='toolbar-layer'>"
-       "       <toolitem action='action-LayerRaise' />"
-       "       <toolitem action='action-LayerLower' />"
-       "       <separator />"
-       "       <toolitem action='action-LayerDuplicate' />"
-       "       <toolitem action='action-LayerEncapsulate' />"
-       "       <toolitem action='select-all-child-layers' />"
-       "       <toolitem action='action-LayerRemove' />"
-       "       <separator />"
-       "       <toolitem action='cut' />"
-       "       <toolitem action='copy' />"
-       "       <toolitem action='paste' />"
-       "       </toolbar>"
-       "</ui>"
-       ;
-
-       App::ui_manager()->add_ui_from_string(ui_info);
-
-       action_group_new_layers->set_sensitive(false);
-
-       set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-layer")));
-
-
-
-
-
-       /*
-       reference_counter ref_count;
-       synfig::info(__FILE__":%d:ref_count.count()=%d",__LINE__,ref_count.count());
-
-       {
-               sigc::signal<void> tmp_signal;
-
-               tmp_signal.connect(
-                       sigc::bind(
-                               sigc::ptr_fun(do_nothing),
-                               ref_count
-                       )
-               );
-
-       synfig::info(__FILE__":%d:ref_count.count()=%d",__LINE__,ref_count.count());
-               tmp_signal();
-       synfig::info(__FILE__":%d:ref_count.count()=%d",__LINE__,ref_count.count());
-
-               tmp_signal.clear();
-       synfig::info(__FILE__":%d:ref_count.count()=%d",__LINE__,ref_count.count());
-
-               tmp_signal();
-       synfig::info(__FILE__":%d:ref_count.count()=%d",__LINE__,ref_count.count());
-               tmp_signal.connect(
-                       sigc::bind(
-                               sigc::ptr_fun(do_nothing),
-                               ref_count
-                       )
-               );
-       synfig::info(__FILE__":%d:ref_count.count()=%d",__LINE__,ref_count.count());
-       }
-       synfig::info(__FILE__":%d:ref_count.count()=%d",__LINE__,ref_count.count());
-       assert(ref_count.count()==1);
-       */
-}
-
-
-Dock_Layers::~Dock_Layers()
-{
-       delete layer_action_manager;
-}
-
-
-void
-Dock_Layers::init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
-{
-       Glib::RefPtr<LayerTreeStore> layer_tree_store;
-       layer_tree_store=LayerTreeStore::create(canvas_view->canvas_interface());
-
-       canvas_view->set_tree_model(get_name(),layer_tree_store);
-       LayerTree* layer_tree(new LayerTree());
-       layer_tree->set_time_adjustment(canvas_view->time_adjustment());
-
-       layer_tree->signal_edited_value().connect(
-               sigc::hide_return(
-                       sigc::mem_fun(*canvas_view->canvas_interface(), &synfigapp::CanvasInterface::change_value)
-               )
-       );
-
-       // (a) should be before (b), (b) should be before (c)
-       canvas_view->set_ext_widget(get_name()+"_cmp",layer_tree); // (a)
-       canvas_view->set_ext_widget(get_name(),&layer_tree->get_layer_tree_view());
-       canvas_view->set_ext_widget("params",&layer_tree->get_param_tree_view());
-
-       layer_tree->set_model(layer_tree_store); // (b)
-       canvas_view->set_tree_model("params",layer_tree->get_param_tree_view().get_model()); // (c)
-
-       /*
-       canvas_view->layermenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-delete"),Gtk::AccelKey("Delete"),
-               sigc::mem_fun(*layer_tree, &LayerTree::on_delete_pressed))
-       );
-       */
-
-       // Hide the time bar
-       if(canvas_view->get_canvas()->rend_desc().get_time_start()==canvas_view->get_canvas()->rend_desc().get_time_end())
-               canvas_view->hide_timebar();
-       layer_tree_store->rebuild();
-       present();
-}
-
-void
-Dock_Layers::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
-{
-       if(canvas_view)
-       {
-               Gtk::Widget* tree_view(canvas_view->get_ext_widget(get_name()));
-
-               add(*tree_view);
-               tree_view->show();
-               action_group_new_layers->set_sensitive(true);
-               if(layer_action_manager)
-               {
-                       layer_action_manager->set_layer_tree(dynamic_cast<LayerTree*>(canvas_view->get_ext_widget(get_name()+"_cmp")));
-                       layer_action_manager->set_canvas_interface(canvas_view->canvas_interface());
-                       layer_action_manager->refresh();
-               }
-       }
-       else
-       {
-               action_group_new_layers->set_sensitive(false);
-               if(layer_action_manager)
-               {
-                       layer_action_manager->clear();
-                       layer_action_manager->set_canvas_interface(0);
-                       layer_action_manager->set_layer_tree(0);
-               }
-
-               clear_previous();
-       }
-}
-
-void
-Dock_Layers::add_layer(synfig::String id)
-{
-       etl::loose_handle<CanvasView> canvas_view(get_canvas_view());
-       if(canvas_view)
-       {
-               canvas_view->add_layer(id);
-       }
-}
diff --git a/synfig-studio/src/gtkmm/dock_layers.h b/synfig-studio/src/gtkmm/dock_layers.h
deleted file mode 100644 (file)
index b5eda42..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_layers.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_DOCK_LAYERS_H
-#define __SYNFIG_STUDIO_DOCK_LAYERS_H
-
-/* === H E A D E R S ======================================================= */
-
-#include "dockable.h"
-#include <gtkmm/treeview.h>
-#include "instance.h"
-#include "dock_canvasspecific.h"
-#include <gtkmm/actiongroup.h>
-#include <list>
-
-/* === 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 Gtk { class HScale; }
-
-namespace studio {
-
-class LayerActionManager;
-
-class Dock_Layers : public Dock_CanvasSpecific
-{
-       Glib::RefPtr<Gtk::ActionGroup> action_group_new_layers;
-       Glib::RefPtr<Gtk::ActionGroup> action_group_layer_ops;
-
-       Gtk::HScale *layer_amount_hscale;
-
-       LayerActionManager* layer_action_manager;
-
-protected:
-       virtual void init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
-       virtual void changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
-
-private:
-
-       void add_layer(synfig::String id);
-       void increase_amount();
-       void decrease_amount();
-
-public:
-
-
-       Dock_Layers();
-       ~Dock_Layers();
-}; // END of Dock_Layers
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/dock_metadata.cpp b/synfig-studio/src/gtkmm/dock_metadata.cpp
deleted file mode 100644 (file)
index 3dce59a..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_metadata.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "dock_metadata.h"
-#include "app.h"
-
-#include <gtkmm/scrolledwindow.h>
-#include <cassert>
-#include "instance.h"
-#include <sigc++/signal.h>
-#include <sigc++/hide.h>
-#include <sigc++/slot.h>
-#include "metadatatreestore.h"
-#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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Dock_MetaData::Dock_MetaData():
-       Dock_CanvasSpecific("meta_data",_("Canvas MetaData"),Gtk::StockID("synfig-meta_data")),
-       tree_view(manage(new Gtk::TreeView()))
-{
-       MetaDataTreeStore::Model model;
-
-       tree_view->append_column(_("Key"),model.key);
-       tree_view->append_column_editable(_("Data"),model.data);
-       tree_view->set_rules_hint();
-
-       Gtk::ScrolledWindow *scrolledwindow = manage(new class Gtk::ScrolledWindow());
-       scrolledwindow->set_flags(Gtk::CAN_FOCUS);
-       scrolledwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
-       scrolledwindow->add(*tree_view);
-       scrolledwindow->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
-       scrolledwindow->show();
-
-       add(*scrolledwindow);
-
-       add_button(
-               Gtk::StockID("gtk-add"),
-               _("Add new MetaData entry")
-       )->signal_clicked().connect(
-               sigc::mem_fun(
-                       *this,
-                       &Dock_MetaData::on_add_pressed
-               )
-       );
-
-       add_button(
-               Gtk::StockID("gtk-delete"),
-               _("Remove selected MetaData entry")
-       )->signal_clicked().connect(
-               sigc::mem_fun(
-                       *this,
-                       &Dock_MetaData::on_delete_pressed
-               )
-       );
-}
-
-Dock_MetaData::~Dock_MetaData()
-{
-}
-
-void
-Dock_MetaData::init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
-{
-       canvas_view->set_tree_model(get_name(),MetaDataTreeStore::create(canvas_view->canvas_interface()));
-}
-
-void
-Dock_MetaData::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
-{
-       if(canvas_view)
-       {
-               tree_view->set_model(canvas_view->get_tree_model(get_name()));
-               tree_view->show();
-       }
-       else
-       {
-               tree_view->set_model(Glib::RefPtr<Gtk::TreeModel>());
-               tree_view->hide();
-       }
-}
-
-void
-Dock_MetaData::on_add_pressed()
-{
-       if(get_canvas_interface())
-       {
-               synfig::String key;
-               if(App::dialog_entry(_("New MetaData Entry"), _("Please enter the name of the key"),key) && !key.empty())
-               {
-                       get_canvas_interface()->set_meta_data(key," ");
-               }
-       }
-}
-
-void
-Dock_MetaData::on_delete_pressed()
-{
-}
diff --git a/synfig-studio/src/gtkmm/dock_metadata.h b/synfig-studio/src/gtkmm/dock_metadata.h
deleted file mode 100644 (file)
index 285b845..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_metadata.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_DOCK_METADATA_H
-#define __SYNFIG_STUDIO_DOCK_METADATA_H
-
-/* === H E A D E R S ======================================================= */
-
-#include "dockable.h"
-#include <gtkmm/treeview.h>
-#include "instance.h"
-#include "dock_canvasspecific.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 CanvasView;
-class Instance;
-
-class Dock_MetaData : public Dock_CanvasSpecific
-{
-
-       Gtk::TreeView *tree_view;
-
-
-       void on_add_pressed();
-       void on_delete_pressed();
-
-protected:
-
-       virtual void init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
-       virtual void changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
-
-public:
-
-
-       Dock_MetaData();
-       ~Dock_MetaData();
-}; // END of Dock_MetaData
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/dock_navigator.cpp b/synfig-studio/src/gtkmm/dock_navigator.cpp
deleted file mode 100644 (file)
index ad5061e..0000000
+++ /dev/null
@@ -1,522 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_navigator.cpp
-**     \brief Dock Nagivator File
-**
-**     $Id$
-**
-**     \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
-**     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 <config.h>
-#endif
-
-#include "dock_navigator.h"
-#include "canvasview.h"
-#include "workarea.h"
-
-#include <cassert>
-#include <synfig/canvas.h>
-#include <synfig/context.h>
-#include <synfig/target_scanline.h>
-#include <synfig/surface.h>
-
-#include <gtkmm/separator.h>
-
-#include "asyncrenderer.h"
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-using namespace synfig;
-
-/* === M A C R O S ========================================================= */
-
-const double log_10_2 = log(2.0);
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-/* === E N T R Y P O I N T ================================================= */
-studio::Widget_NavView::Widget_NavView(CanvasView::LooseHandle cv)
-:canvview(cv),
-adj_zoom(0,-4,4,1,2),
-scrolling(false),
-surface(new synfig::Surface)
-{
-       attach(drawto,0,4,0,1);
-
-       attach(*manage(new Gtk::HSeparator),0,4,1,2,Gtk::SHRINK|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
-
-       //zooming stuff
-       attach(zoom_print,0,1,2,3,Gtk::SHRINK|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
-       zoom_print.set_size_request(40,-1);
-
-       Gtk::HScale *s = manage(new Gtk::HScale(adj_zoom));
-       s->set_draw_value(false);
-       //s->set_update_policy(Gtk::UPDATE_DELAYED);
-       //s->signal_event().connect(sigc::mem_fun(*this,&Dock_Navigator::on_scroll_event));
-       attach(*s,1,4,2,3,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
-
-       show_all();
-
-       adj_zoom.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_NavView::on_number_modify));
-
-       if(cv)
-       {
-               drawto.signal_expose_event().connect(sigc::mem_fun(*this,&Widget_NavView::on_expose_draw));
-               drawto.signal_event().connect(sigc::mem_fun(*this,&Widget_NavView::on_mouse_event));
-
-               drawto.add_events(Gdk::BUTTON_MOTION_MASK|Gdk::BUTTON_PRESS_MASK);
-
-               //get_canvas_view()->canvas_interface()->signal_dirty_preview()
-               //                              .connect(sigc::mem_fun(*this,&Widget_NavView::on_dirty_preview));
-               get_canvas_view()->work_area->signal_rendering()
-                                               .connect(sigc::mem_fun(*this,&Widget_NavView::on_dirty_preview));
-
-               get_canvas_view()->work_area->signal_view_window_changed()
-                                               .connect(sigc::mem_fun(*this,&Widget_NavView::on_workarea_view_change));
-
-               //update with this canvas' view
-               on_workarea_view_change();
-
-               dirty = true;
-               queue_draw();
-       }
-
-       adj_zoom.set_value(0);
-}
-
-studio::Widget_NavView::~Widget_NavView()
-{
-}
-
-
-static void freegu8(const guint8 *p)
-{
-       delete [] p;
-}
-
-void studio::Widget_NavView::on_start_render()
-{
-       if(dirty)
-       {
-               //synfig::warning("Nav: Starting render");
-               //synfig::warning("Nav: Rendering canvas");
-               etl::handle<Target_Scanline>    targ = surface_target(surface.get());
-
-               targ->set_canvas(get_canvas_view()->get_canvas());
-               targ->set_remove_alpha();
-               targ->set_avoid_time_sync();
-               targ->set_quality(get_canvas_view()->get_work_area()->get_quality());
-               //synfig::info("Set the quality level to: %d", get_canvas_view()->get_work_area()->get_quality());
-
-               //this should set it to render a single frame
-               RendDesc        r = get_canvas_view()->get_canvas()->rend_desc();
-               r.set_time(get_canvas_view()->canvas_interface()->get_time());
-
-               //this changes the size of the canvas to the closest thing we can find
-               int sw = r.get_w(), sh = r.get_h();
-
-               //synfig::warning("Nav: source image is %d x %d", sw,sh);
-
-               //resize so largest dimension is 128
-               int dw = sw > sh ? 128 : sw*128/sh,
-                       dh = sh > sw ? 128 : sh*128/sw;
-
-               //synfig::warning("Nav: dest image is %d x %d", dw,dh);
-
-               r.set_w(dw);
-               r.set_h(dh);
-
-               //get the pw and ph
-               //float pw = r.get_pw();
-               //float ph = r.get_ph();
-               //synfig::warning("Nav: pixel size is %f x %f", pw,ph);
-
-               //this renders that single frame
-               targ->set_rend_desc(&r);
-
-               //synfig::warning("Nav: Building async renderer and starting it...");
-
-               renderer = new AsyncRenderer(targ);
-               renderer->signal_success().connect(sigc::mem_fun(*this,&Widget_NavView::on_finish_render));
-               dirty = false;
-               renderer->start();
-       }
-}
-
-void studio::Widget_NavView::on_finish_render()
-{
-       //convert it into our pixmap
-       PixelFormat pf(PF_RGB);
-
-       //synfig::warning("Nav: It hath succeeded!!!");
-
-       //assert(renderer && renderer->has_success());
-       //synfig::warning("Nav: now we know it really succeeded");
-       if(!*surface)
-       {
-               synfig::warning("dock_navigator: Bad surface");
-               return;
-       }
-
-       int w = 0, h = 0;
-       int dw = surface->get_w();
-       int dh = surface->get_h();
-
-       if(prev)
-       {
-               w = prev->get_width();
-               h = prev->get_height();
-       }
-
-       if(w != dw || h != dh || !prev)
-       {
-               const int total_bytes(dw*dh*synfig::channels(pf));
-
-               //synfig::warning("Nav: Updating the pixbuf to be the right size, etc. (%d bytes)", total_bytes);
-
-               prev.clear();
-               guint8 *bytes = new guint8[total_bytes]; //24 bits per pixel
-
-               //convert into our buffered dataS
-               //synfig::warning("Nav: converting color format into buffer");
-               convert_color_format((unsigned char *)bytes, (*surface)[0], dw*dh, pf, App::gamma);
-
-               prev =
-               Gdk::Pixbuf::create_from_data(
-                       bytes,  // pointer to the data
-                       Gdk::COLORSPACE_RGB, // the colorspace
-                       ((pf&PF_A)==PF_A), // has alpha?
-                       8, // bits per sample
-                       dw,     // width
-                       dh,     // height
-                       dw*synfig::channels(pf), // stride (pitch)
-                       sigc::ptr_fun(freegu8)
-               );
-       }
-       else
-       {
-               //synfig::warning("Nav: Don't need to resize");
-               //convert into our buffered dataS
-               //synfig::warning("Nav: converting color format into buffer");
-               if(prev) //just in case we're stupid
-               {
-                       convert_color_format((unsigned char *)prev->get_pixels(), (*surface)[0], dw*dh, pf, App::gamma);
-               }
-       }
-       queue_draw();
-}
-
-/*     zoom slider is on exponential scale
-
-       map: -4,4 -> small number,1600 with 100 at 0
-
-       f(x) = 100*2^x
-*/
-
-static double unit_to_zoom(double f)
-{
-       return pow(2.0,f);
-}
-
-static double zoom_to_unit(double f)
-{
-       if(f > 0)
-       {
-               return log(f) / log_10_2;
-       }else return -999999.0;
-}
-
-bool studio::Widget_NavView::on_expose_draw(GdkEventExpose */*exp*/)
-{
-#ifdef SINGLE_THREADED
-       // don't redraw if the previous redraw is still running single-threaded
-       // or we end up destroying the renderer that's rendering it
-       if (App::single_threaded && renderer && renderer->updating)
-               return false;
-#endif
-
-       //print out the zoom
-       //HACK kind of...
-       //zoom_print.set_text(strprintf("%.1f%%",100*unit_to_zoom(adj_zoom.get_value())));
-
-       //draw the good stuff
-       on_start_render();
-
-       //if we've got a preview etc. display it...
-       if(get_canvas_view() && prev)
-       {
-               //axis transform from units to pixel coords
-               float xaxis = 0, yaxis = 0;
-
-               int canvw = get_canvas_view()->get_canvas()->rend_desc().get_w();
-               //int canvh = get_canvas_view()->get_canvas()->rend_desc().get_h();
-
-               float pw = get_canvas_view()->get_canvas()->rend_desc().get_pw();
-               float ph = get_canvas_view()->get_canvas()->rend_desc().get_ph();
-
-               int w = prev->get_width();
-               int h = prev->get_height();
-
-               //scale up/down to the nearest pixel ratio...
-               //and center in center
-               int offx=0, offy=0;
-
-               float sx, sy;
-               int nw,nh;
-
-               sx = drawto.get_width() / (float)w;
-               sy = drawto.get_height() / (float)h;
-
-               //synfig::warning("Nav redraw: now to scale the bitmap: %.3f x %.3f",sx,sy);
-
-               //round to smallest scale (fit entire thing in window without distortion)
-               if(sx > sy) sx = sy;
-               //else sy = sx;
-
-               //scaling and stuff
-               // the point to navpixel space conversion should be:
-               //              (navpixels / canvpixels) * (canvpixels / canvsize)
-               //      or (navpixels / prevpixels) * (prevpixels / navpixels)
-               xaxis = sx * w / (float)canvw;
-               yaxis = xaxis/ph;
-               xaxis /= pw;
-
-               //scale to a new pixmap and then copy over to the window
-               nw = (int)(w*sx);
-               nh = (int)(h*sx);
-
-               //must now center to be cool
-               offx = (drawto.get_width() - nw)/2;
-               offy = (drawto.get_height() - nh)/2;
-
-               //trivial escape
-               if(nw == 0 || nh == 0)return true;
-
-               //draw to drawing area
-               Glib::RefPtr<Gdk::GC>   gc = Gdk::GC::create(drawto.get_window());
-
-               //synfig::warning("Nav: Scaling pixmap to off (%d,%d) with size (%d,%d)", offx,offy,nw, nh);
-               Glib::RefPtr<Gdk::Pixbuf> scalepx = prev->scale_simple(nw,nh,Gdk::INTERP_NEAREST);
-
-               //synfig::warning("Nav: Drawing scaled bitmap");
-               drawto.get_window()->draw_pixbuf(
-                       gc, //GC
-                       scalepx, //pixbuf
-                       0, 0,   // Source X and Y
-                       offx, offy,     // Dest X and Y
-                       -1,-1,  // Width and Height
-                       Gdk::RGB_DITHER_MAX, // RgbDither
-                       2, 2 // Dither offset X and Y
-               );
-
-               //draw fancy red rectangle around focus point
-               const Point &wtl = get_canvas_view()->work_area->get_window_tl(),
-                                       &wbr = get_canvas_view()->work_area->get_window_br();
-
-               gc->set_rgb_fg_color(Gdk::Color("#ff0000"));
-               gc->set_line_attributes(2,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-
-               //it must be clamped to the drawing area though
-               int l=0,rw=0,t=0,rh=0;
-               const Point fp = -get_canvas_view()->work_area->get_focus_point();
-
-               //get focus point in normal space
-               rw = (int)(abs((wtl[0]-wbr[0])*xaxis));
-               rh = (int)(abs((wtl[1]-wbr[1])*yaxis));
-
-               //transform into pixel space
-               l = (int)(drawto.get_width()/2 + fp[0]*xaxis - rw/2);
-               t = (int)(drawto.get_height()/2 + fp[1]*yaxis - rh/2);
-
-               //coord system:
-               // tl : (offx,offy)
-               // axis multipliers = xaxis,yaxis
-               //synfig::warning("Nav: tl (%f,%f), br (%f,%f)", wtl[0],wtl[1],wbr[0],wbr[1]);
-               //synfig::warning("Nav: tl (%f,%f), br (%f,%f)", wtl[0],wtl[1],wbr[0],wbr[1]);
-               //synfig::warning("Nav: Drawing Rectangle (%d,%d) with dim (%d,%d)", l,t,rw,rh);
-               drawto.get_window()->draw_rectangle(gc,false,l,t,rw,rh);
-       }
-
-       return false; //draw everything else too
-}
-
-void studio::Widget_NavView::on_dirty_preview()
-{
-       dirty = true;
-       queue_draw();
-}
-
-bool studio::Widget_NavView::on_scroll_event(GdkEvent *event)
-{
-       if(get_canvas_view() && get_canvas_view()->get_work_area())
-       {
-               double z = unit_to_zoom(adj_zoom.get_value());
-
-               switch(event->type)
-               {
-                       case GDK_BUTTON_PRESS:
-                       {
-                               if(event->button.button == 1)
-                               {
-                                       scrolling = true;
-                                       get_canvas_view()->get_work_area()->set_zoom(z);
-                                       scrolling = false;
-                               }
-                               break;
-                       }
-
-                       case GDK_MOTION_NOTIFY:
-                       {
-                               if(Gdk::ModifierType(event->motion.state) & Gdk::BUTTON1_MASK)
-                               {
-                                       scrolling = true;
-                                       get_canvas_view()->get_work_area()->set_zoom(z);
-                                       scrolling = false;
-                               }
-                               break;
-                       }
-
-                       default:
-                               break;
-               }
-       }
-
-       return false;
-}
-
-void studio::Widget_NavView::on_number_modify()
-{
-       double z = unit_to_zoom(adj_zoom.get_value());
-       zoom_print.set_text(strprintf("%.1f%%",z*100.0));
-       //synfig::warning("Updating zoom to %f",adj_zoom.get_value());
-
-       if(get_canvas_view() && z != get_canvas_view()->get_work_area()->get_zoom())
-       {
-               scrolling = true;
-               get_canvas_view()->get_work_area()->set_zoom(z);
-               scrolling = false;
-       }
-}
-
-void studio::Widget_NavView::on_workarea_view_change()
-{
-       double wz = get_canvas_view()->get_work_area()->get_zoom();
-       double z = zoom_to_unit(wz);
-
-       //synfig::warning("Updating zoom to %f -> %f",wz,z);
-       if(!scrolling && z != adj_zoom.get_value())
-       {
-               adj_zoom.set_value(z);
-               //adj_zoom.value_changed();
-       }
-       queue_draw();
-}
-
-bool studio::Widget_NavView::on_mouse_event(GdkEvent * e)
-{
-       Point p;
-       bool    setpos = false;
-
-       if(e->type == GDK_BUTTON_PRESS && e->button.button == 1)
-       {
-               p[0] = e->button.x - drawto.get_width()/2;
-               p[1] = e->button.y - drawto.get_height()/2;
-
-               setpos = true;
-       }
-
-       if(e->type == GDK_MOTION_NOTIFY && (Gdk::ModifierType(e->motion.state) & Gdk::BUTTON1_MASK))
-       {
-               p[0] = e->motion.x - drawto.get_width()/2;
-               p[1] = e->motion.y - drawto.get_height()/2;
-
-               setpos = true;
-       }
-
-       if(setpos && prev && get_canvas_view())
-       {
-               const Point &tl = get_canvas_view()->get_canvas()->rend_desc().get_tl();
-               const Point &br = get_canvas_view()->get_canvas()->rend_desc().get_br();
-
-               float max = abs((br[0]-tl[0]) / drawto.get_width());
-
-               if((float(prev->get_width()) / drawto.get_width()) < (float(prev->get_height()) / drawto.get_height()))
-                       max = abs((br[1]-tl[1]) / drawto.get_height());
-
-               float signx = (br[0]-tl[0]) < 0 ? -1 : 1;
-               float signy = (br[1]-tl[1]) < 0 ? -1 : 1;
-
-               Point pos;
-
-               pos[0] = p[0] * max * signx;
-               pos[1] = p[1] * max * signy;
-
-               get_canvas_view()->get_work_area()->set_focus_point(-pos);
-
-               return true;
-       }
-
-       return false;
-}
-
-//Navigator Dock Definitions
-
-studio::Dock_Navigator::Dock_Navigator()
-:Dock_CanvasSpecific("navigator",_("Navigator"),Gtk::StockID("synfig-navigator"))
-{
-       add(dummy);
-}
-
-studio::Dock_Navigator::~Dock_Navigator()
-{
-}
-
-void studio::Dock_Navigator::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
-{
-       if(canvas_view)
-       {
-               Widget *v = canvas_view->get_ext_widget("navview");
-
-               if(!v)
-               {
-                       v = new Widget_NavView(canvas_view);
-                       canvas_view->set_ext_widget("navview",v);
-               }
-
-               add(*v);
-       }else
-       {
-               clear_previous();
-               //add(dummy);
-       }
-}
diff --git a/synfig-studio/src/gtkmm/dock_navigator.h b/synfig-studio/src/gtkmm/dock_navigator.h
deleted file mode 100644 (file)
index 95e3fa1..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_navigator.h
-**     \brief Navigator Dock 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_DOCK_NAVIGATOR_H
-#define __SYNFIG_DOCK_NAVIGATOR_H
-
-/* === H E A D E R S ======================================================= */
-#include "sigc++/signal.h"
-
-#include <gtkmm/drawingarea.h>
-#include <gdkmm/pixbuf.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/label.h>
-
-#include <synfig/renddesc.h>
-
-#include "canvasview.h"
-#include "dock_canvasspecific.h"
-#include "widget_distance.h"
-
-#include <ETL/smart_ptr>
-
-/* === 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 AsyncRenderer;
-
-class Widget_NavView : public Gtk::Table
-{
-       //handle to out parent canvas
-       CanvasView::LooseHandle         canvview;
-
-       Glib::RefPtr<Gdk::Pixbuf>       prev;
-       bool dirty;
-
-       //The drawing stuff
-       Gtk::DrawingArea        drawto;
-
-       //The input stuff
-       Gtk::Adjustment         adj_zoom;
-       Gtk::Label                      zoom_print;
-
-       //zoom window stuff
-       bool                            scrolling;
-
-       //asynchronous rendering stuff
-       etl::handle<AsyncRenderer>      renderer;
-       etl::smart_ptr<synfig::Surface> surface;
-       bool                                            rendering;
-
-       //drawing functionality
-       void on_start_render(); //breaks out into asynchronous rendering
-       void on_finish_render();
-       void on_draw(); //renders the small thing we have
-       void on_dirty_preview(); //dirties the preview for rerender
-
-       //for the zoom buttons
-       void on_zoom_in();
-       void on_zoom_out();
-
-       //handles the zoom scroller
-       bool on_scroll_event(GdkEvent *event);
-       void on_number_modify();
-
-       //
-       bool on_mouse_event(GdkEvent * e);
-
-       //draws the gotten bitmap on the draw area
-       bool on_expose_draw(GdkEventExpose *exp=0);
-
-       //for when the canvasview view changes (boolean value scrolling solves cyclic problems)
-       void on_workarea_view_change();
-
-public:
-       Widget_NavView(CanvasView::LooseHandle cv = CanvasView::LooseHandle());
-       ~Widget_NavView();
-
-       etl::loose_handle<studio::CanvasView> get_canvas_view() {return canvview;}
-};
-
-class Dock_Navigator : public Dock_CanvasSpecific
-{
-       Widget_NavView  dummy;
-
-public:
-       Dock_Navigator();
-       ~Dock_Navigator();
-
-       virtual void changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/dock_params.cpp b/synfig-studio/src/gtkmm/dock_params.cpp
deleted file mode 100644 (file)
index 7b3d360..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_params.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "dock_params.h"
-#include "app.h"
-
-#include <gtkmm/scrolledwindow.h>
-#include <cassert>
-#include "instance.h"
-#include <sigc++/signal.h>
-#include <sigc++/hide.h>
-#include <sigc++/slot.h>
-#include "canvasview.h"
-#include "layerparamtreestore.h"
-#include "workarea.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Dock_Params::Dock_Params():
-       Dock_CanvasSpecific("params",_("Params"),Gtk::Stock::INDEX/*Gtk::StockID("synfig-params")*/),
-       action_group(Gtk::ActionGroup::create("action_group_dock_params"))
-{
-}
-
-Dock_Params::~Dock_Params()
-{
-}
-
-
-void
-Dock_Params::init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
-{
-       Gtk::TreeView* tree_view(
-               static_cast<Gtk::TreeView*>(canvas_view->get_ext_widget(get_name()))
-       );
-
-       if(tree_view)
-       {
-               tree_view->get_selection()->signal_changed().connect(
-                       sigc::mem_fun(
-                               *this,
-                               &Dock_Params::refresh_selected_param
-                       )
-               );
-       }
-}
-
-void
-Dock_Params::refresh_selected_param()
-{
-       Gtk::TreeView* tree_view(
-               static_cast<Gtk::TreeView*>(get_canvas_view()->get_ext_widget(get_name()))
-       );
-       Gtk::TreeModel::iterator iter(tree_view->get_selection()->get_selected());
-
-       if(iter)
-       {
-               LayerParamTreeStore::Model model;
-               get_canvas_view()->work_area->set_selected_value_node(
-                       (synfig::ValueNode::Handle)(*iter)[model.value_node]
-               );
-       }
-       else
-       {
-               get_canvas_view()->work_area->set_selected_value_node(0);
-       }
-}
-
-void
-Dock_Params::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
-{
-       if(canvas_view)
-       {
-               Gtk::Widget* tree_view(canvas_view->get_ext_widget(get_name()));
-
-               add(*tree_view);
-               tree_view->show();
-               show_all();
-       }
-       else clear_previous();
-}
diff --git a/synfig-studio/src/gtkmm/dock_params.h b/synfig-studio/src/gtkmm/dock_params.h
deleted file mode 100644 (file)
index 7ad9f61..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_params.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_DOCK_PARAMS_H
-#define __SYNFIG_STUDIO_DOCK_PARAMS_H
-
-/* === H E A D E R S ======================================================= */
-
-#include "dockable.h"
-#include <gtkmm/treeview.h>
-#include "instance.h"
-#include "dock_canvasspecific.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 Dock_Params : public Dock_CanvasSpecific
-{
-       Glib::RefPtr<Gtk::ActionGroup> action_group;
-
-protected:
-       virtual void init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
-       virtual void changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
-
-       void refresh_selected_param();
-
-public:
-
-
-       Dock_Params();
-       ~Dock_Params();
-}; // END of Dock_Keyframes
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/dock_timetrack.cpp b/synfig-studio/src/gtkmm/dock_timetrack.cpp
deleted file mode 100644 (file)
index 29105e4..0000000
+++ /dev/null
@@ -1,494 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_timetrack.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 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 <config.h>
-#endif
-
-#include "dock_timetrack.h"
-#include "app.h"
-
-#include <gtkmm/scrolledwindow.h>
-#include <cassert>
-#include "instance.h"
-#include <sigc++/signal.h>
-#include <sigc++/hide.h>
-#include <sigc++/slot.h>
-#include "canvasview.h"
-#include "layerparamtreestore.h"
-#include "workarea.h"
-#include "widget_timeslider.h"
-#include "widget_keyframe_list.h"
-#include "layerparamtreestore.h"
-#include "general.h"
-#include <synfig/timepointcollect.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 ========================================================= */
-
-/* === C L A S S E S ======================================================= */
-
-class TimeTrackView : public Gtk::TreeView
-{
-       CellRenderer_TimeTrack *cellrenderer_time_track;
-
-       Glib::RefPtr<LayerParamTreeStore> param_tree_store_;
-
-       Gtk::TreeView *mimic_tree_view;
-public:
-
-       sigc::signal<void,synfigapp::ValueDesc,std::set<synfig::Waypoint, std::less<UniqueID> >,int> signal_waypoint_clicked_timetrackview;
-
-       LayerParamTreeStore::Model model;
-
-       void set_canvas_view(handle<CanvasView> canvas_view)
-       {
-               cellrenderer_time_track->set_adjustment(canvas_view->time_adjustment());
-       }
-
-       TimeTrackView()
-       {
-               int label_index(append_column_editable(_("Name"),model.label));
-               Gtk::TreeView::Column* label_column = get_column(label_index-1);
-
-               {       // --- T I M E   T R A C K --------------------------------------------
-                       Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Time Track")) );
-
-                       // Set up the value-node cell-renderer
-                       cellrenderer_time_track=LayerParamTreeStore::add_cell_renderer_value_node(column);
-                       cellrenderer_time_track->property_mode()=Gtk::CELL_RENDERER_MODE_ACTIVATABLE;
-                       cellrenderer_time_track->signal_waypoint_clicked_cellrenderer().connect(sigc::mem_fun(*this, &TimeTrackView::on_waypoint_clicked_timetrackview));
-                       cellrenderer_time_track->signal_waypoint_changed().connect(sigc::mem_fun(*this, &TimeTrackView::on_waypoint_changed) );
-                       column->add_attribute(cellrenderer_time_track->property_value_desc(), model.value_desc);
-                       column->add_attribute(cellrenderer_time_track->property_canvas(), model.canvas);
-                       //column->add_attribute(cellrenderer_time_track->property_visible(), model.is_value_node);
-
-                       //column->pack_start(*cellrenderer_time_track);
-
-                       // Finish setting up the column
-                       column->set_reorderable();
-                       column->set_resizable();
-                       column->set_min_width(200);
-
-                       append_column(*column);
-               }
-               set_rules_hint();
-
-               set_expander_column(*label_column);
-               label_column->set_visible(false);
-               set_headers_visible(false);
-               set_size_request(-1,64);
-       }
-
-       bool
-       on_event(GdkEvent *event)
-       {
-               switch(event->type)
-               {
-               case GDK_SCROLL:
-                       if(mimic_tree_view)
-                       {
-                               if(event->scroll.direction==GDK_SCROLL_DOWN)
-                               {
-                                       mimic_tree_view->get_vadjustment()->set_value(
-                                               std::min(
-                                                       mimic_tree_view->get_vadjustment()->get_value()+
-                                                       mimic_tree_view->get_vadjustment()->get_step_increment(),
-                                                       mimic_tree_view->get_vadjustment()->get_upper()-
-                                                       mimic_tree_view->get_vadjustment()->get_page_size()
-                                               )
-                                       );
-                                       mimic_tree_view->get_vadjustment()->value_changed();
-                               }
-                               else if(event->scroll.direction==GDK_SCROLL_UP)
-                               {
-                                       mimic_tree_view->get_vadjustment()->set_value(
-                                               std::max(
-                                                       mimic_tree_view->get_vadjustment()->get_value()-
-                                                       mimic_tree_view->get_vadjustment()->get_step_increment(),
-                                                       mimic_tree_view->get_vadjustment()->get_lower()
-                                               )
-                                       );
-                                       mimic_tree_view->get_vadjustment()->value_changed();
-                               }
-                       }
-                       break;
-               case GDK_BUTTON_PRESS:
-                       {
-                               Gtk::TreeModel::Path path;
-                               Gtk::TreeViewColumn *column;
-                               int cell_x, cell_y;
-                               if(!get_path_at_pos(
-                                       int(event->button.x),int(event->button.y),      // x, y
-                                       path, // TreeModel::Path&
-                                       column, //TreeViewColumn*&
-                                       cell_x,cell_y //int&cell_x,int&cell_y
-                                       )
-                               ) break;
-                               const Gtk::TreeRow row = *(get_model()->get_iter(path));
-
-                               if(column && column->get_first_cell_renderer()==cellrenderer_time_track)
-                               {
-                                       Gdk::Rectangle rect;
-                                       get_cell_area(path,*column,rect);
-                                       cellrenderer_time_track->property_value_desc()=row[model.value_desc];
-                                       cellrenderer_time_track->property_canvas()=row[model.canvas];
-                                       cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
-                                       queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
-                                       return true;
-                                       //return signal_param_user_click()(event->button.button,row,COLUMNID_TIME_TRACK);
-                               }
-                       }
-                       break;
-
-               case GDK_MOTION_NOTIFY:
-                       {
-                               Gtk::TreeModel::Path path;
-                               Gtk::TreeViewColumn *column;
-                               int cell_x, cell_y;
-                               if(!get_path_at_pos(
-                                       (int)event->motion.x,(int)event->motion.y,      // x, y
-                                       path, // TreeModel::Path&
-                                       column, //TreeViewColumn*&
-                                       cell_x,cell_y //int&cell_x,int&cell_y
-                                       )
-                               ) break;
-
-                               if(!get_model()->get_iter(path))
-                                       break;
-
-                               Gtk::TreeRow row = *(get_model()->get_iter(path));
-
-                               if ((event->motion.state&GDK_BUTTON1_MASK || event->motion.state&GDK_BUTTON3_MASK) &&
-                                       column &&
-                                       cellrenderer_time_track == column->get_first_cell_renderer())
-                               {
-                                       Gdk::Rectangle rect;
-                                       get_cell_area(path,*column,rect);
-                                       cellrenderer_time_track->property_value_desc()=row[model.value_desc];
-                                       cellrenderer_time_track->property_canvas()=row[model.canvas];
-                                       cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
-                                       queue_draw();
-                                       //queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
-                                       return true;
-                               }
-/*                             else
-                               if(last_tooltip_path.get_depth()<=0 || path!=last_tooltip_path)
-                               {
-                                       tooltips_.unset_tip(*this);
-                                       Glib::ustring tooltips_string(row[layer_model.tooltip]);
-                                       last_tooltip_path=path;
-                                       if(!tooltips_string.empty())
-                                       {
-                                               tooltips_.set_tip(*this,tooltips_string);
-                                               tooltips_.force_window();
-                                       }
-                               }
-*/
-                               return true;
-                       }
-                       break;
-               case GDK_BUTTON_RELEASE:
-                       {
-                               Gtk::TreeModel::Path path;
-                               Gtk::TreeViewColumn *column;
-                               int cell_x, cell_y;
-                               if(!get_path_at_pos(
-                                       (int)event->button.x,(int)event->button.y,      // x, y
-                                       path, // TreeModel::Path&
-                                       column, //TreeViewColumn*&
-                                       cell_x,cell_y //int&cell_x,int&cell_y
-                                       )
-                               ) break;
-
-                               if(!get_model()->get_iter(path))
-                                       break;
-
-                               Gtk::TreeRow row = *(get_model()->get_iter(path));
-
-                               if(column && cellrenderer_time_track==column->get_first_cell_renderer())
-                               {
-                                       Gdk::Rectangle rect;
-                                       get_cell_area(path,*column,rect);
-                                       cellrenderer_time_track->property_value_desc()=row[model.value_desc];
-                                       cellrenderer_time_track->property_canvas()=row[model.canvas];
-                                       cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
-                                       queue_draw();
-                                       queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
-                                       return true;
-                               }
-                       }
-                       break;
-               default:
-                       break;
-               }
-               mimic_resync();
-               return Gtk::TreeView::on_event(event);
-       }
-
-       void
-       queue_draw_msg()
-       {
-               synfig::info("*************QUEUE_DRAW***************** (time track view)");
-               Widget::queue_draw();
-       }
-       void set_model(Glib::RefPtr<LayerParamTreeStore> store)
-       {
-               Gtk::TreeView::set_model(store);
-               param_tree_store_=store;
-               cellrenderer_time_track->set_canvas_interface(param_tree_store_->canvas_interface());
-               store->signal_changed().connect(sigc::mem_fun(*this, &TimeTrackView::queue_draw));
-       }
-
-       void
-       on_waypoint_changed( synfig::Waypoint waypoint , synfig::ValueNode::Handle value_node)
-       {
-               // \todo is this code used?
-               assert(0);
-
-               synfigapp::Action::ParamList param_list;
-               param_list.add("canvas",param_tree_store_->canvas_interface()->get_canvas());
-               param_list.add("canvas_interface",param_tree_store_->canvas_interface());
-               param_list.add("value_node",value_node);
-               param_list.add("waypoint",waypoint);
-       //      param_list.add("time",canvas_interface()->get_time());
-
-               etl::handle<studio::Instance>::cast_static(param_tree_store_->canvas_interface()->get_instance())->process_action("WaypointSetSmart", param_list);
-       }
-
-       void mimic(Gtk::TreeView *param_tree_view)
-       {
-               mimic_tree_view=param_tree_view;
-               param_tree_view->signal_row_expanded().connect(
-                       sigc::hide<0>(
-                       sigc::hide_return(
-                               sigc::bind<-1>(
-                                       sigc::mem_fun(
-                                               *this,
-                                               &Gtk::TreeView::expand_row
-                                       ),
-                                       false
-                               )
-                       ))
-               );
-               param_tree_view->signal_row_collapsed().connect(
-                       sigc::hide<0>(
-                       sigc::hide_return(
-                                       sigc::mem_fun(
-                                               *this,
-                                               &Gtk::TreeView::collapse_row
-                                       )
-                       ))
-               );
-               mimic_resync();
-       }
-
-       void mimic_resync()
-       {
-               if(mimic_tree_view)
-               {
-                       Gtk::Adjustment &adjustment(*mimic_tree_view->get_vadjustment());
-                       set_vadjustment(adjustment);
-
-                       if(adjustment.get_page_size()>get_height())
-                               adjustment.set_page_size(get_height());
-
-                       int row_height = 0;
-                       if(getenv("SYNFIG_TIMETRACK_ROW_HEIGHT"))
-                               row_height = atoi(getenv("SYNFIG_TIMETRACK_ROW_HEIGHT"));
-                       if (row_height < 3)
-                               row_height = 18;
-
-                       cellrenderer_time_track->set_fixed_size(-1,row_height);
-               }
-       }
-
-       void
-       on_waypoint_clicked_timetrackview(const etl::handle<synfig::Node>& node,
-                                                                         const synfig::Time& time,
-                                                                         const synfig::Time& time_offset __attribute__ ((unused)),
-                                                                         int button)
-       {
-               std::set<synfig::Waypoint, std::less<UniqueID> > waypoint_set;
-               synfig::waypoint_collect(waypoint_set,time,node);
-
-               synfigapp::ValueDesc value_desc;
-
-               if (waypoint_set.size() == 1)
-               {
-                       ValueNode::Handle value_node(waypoint_set.begin()->get_parent_value_node());
-                       assert(value_node);
-
-                       Gtk::TreeRow row;
-                       if (param_tree_store_->find_first_value_node(value_node, row) && row)
-                               value_desc = static_cast<synfigapp::ValueDesc>(row[model.value_desc]);
-               }
-
-               if (!waypoint_set.empty())
-                       signal_waypoint_clicked_timetrackview(value_desc,waypoint_set,button);
-       }
-};
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Dock_Timetrack::Dock_Timetrack():
-       Dock_CanvasSpecific("timetrack",_("Timetrack"),Gtk::StockID("synfig-timetrack"))
-{
-       table_=0;
-       widget_timeslider_= new Widget_Timeslider();
-       widget_kf_list_= new Widget_Keyframe_List();
-
-       int header_height = 0;
-       if(getenv("SYNFIG_TIMETRACK_HEADER_HEIGHT"))
-               header_height = atoi(getenv("SYNFIG_TIMETRACK_HEADER_HEIGHT"));
-       if (header_height < 3)
-               header_height = 24;
-
-       widget_timeslider_->set_size_request(-1,header_height-header_height/3+1);
-       widget_kf_list_->set_size_request(-1,header_height/3+1);
-
-       hscrollbar_=new Gtk::HScrollbar();
-       vscrollbar_=new Gtk::VScrollbar();
-}
-
-Dock_Timetrack::~Dock_Timetrack()
-{
-       if(table_)delete table_;
-       delete hscrollbar_;
-       delete vscrollbar_;
-       delete widget_timeslider_;
-       delete widget_kf_list_;
-}
-
-void
-Dock_Timetrack::init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
-{
-       LayerParamTreeStore::Model model;
-
-       Glib::RefPtr<LayerParamTreeStore> tree_store(
-               Glib::RefPtr<LayerParamTreeStore>::cast_dynamic(
-                       canvas_view->get_tree_model("params")
-               )
-       );
-
-       TimeTrackView* tree_view(new TimeTrackView());
-       tree_view->set_canvas_view(canvas_view);
-       tree_view->set_model(tree_store);
-       Gtk::TreeView* param_tree_view(dynamic_cast<Gtk::TreeView*>(canvas_view->get_ext_widget("params")));
-       tree_view->mimic(param_tree_view);
-
-       tree_view->signal_waypoint_clicked_timetrackview.connect(sigc::mem_fun(*canvas_view, &studio::CanvasView::on_waypoint_clicked_canvasview));
-
-       canvas_view->time_adjustment().signal_value_changed().connect(sigc::mem_fun(*tree_view,&Gtk::TreeView::queue_draw));
-       canvas_view->time_adjustment().signal_changed().connect(sigc::mem_fun(*tree_view,&Gtk::TreeView::queue_draw));
-
-       canvas_view->set_ext_widget(get_name(),tree_view);
-}
-
-void
-Dock_Timetrack::refresh_selected_param()
-{
-/*     Gtk::TreeView* tree_view(
-               static_cast<Gtk::TreeView*>(get_canvas_view()->get_ext_widget(get_name()))
-       );
-       Gtk::TreeModel::iterator iter(tree_view->get_selection()->get_selected());
-
-       if(iter)
-       {
-               LayerParamTreeStore::Model model;
-               get_canvas_view()->work_area->set_selected_value_node(
-                       (synfig::ValueNode::Handle)(*iter)[model.value_node]
-               );
-       }
-       else
-       {
-               get_canvas_view()->work_area->set_selected_value_node(0);
-       }
-*/
-}
-
-void
-Dock_Timetrack::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
-{
-       if(table_)
-       {
-               table_->hide();
-               delete table_;
-               hscrollbar_->unset_adjustment();
-               vscrollbar_->unset_adjustment();
-               //widget_timeslider_->unset_adjustment();
-               table_=0;
-       }
-
-       if(canvas_view)
-       {
-               TimeTrackView* tree_view(dynamic_cast<TimeTrackView*>(canvas_view->get_ext_widget(get_name())));
-       Gtk::TreeView* param_tree_view(dynamic_cast<Gtk::TreeView*>(canvas_view->get_ext_widget("params")));
-       tree_view->set_vadjustment(*param_tree_view->get_vadjustment());
-
-               assert(tree_view);
-
-
-               widget_timeslider_->set_time_adjustment(&canvas_view->time_adjustment());
-               widget_timeslider_->set_bounds_adjustment(&canvas_view->time_window_adjustment());
-               widget_timeslider_->set_global_fps(canvas_view->get_canvas()->rend_desc().get_frame_rate());
-
-               widget_kf_list_->set_time_adjustment(&canvas_view->time_adjustment());
-               widget_kf_list_->set_canvas_interface(canvas_view->canvas_interface());
-
-               vscrollbar_->set_adjustment(*tree_view->get_vadjustment());
-               hscrollbar_->set_adjustment(canvas_view->time_window_adjustment());
-               table_=new Gtk::Table(2,3);
-               table_->attach(*widget_timeslider_, 0, 1, 1, 2, Gtk::FILL|Gtk::SHRINK, Gtk::FILL|Gtk::SHRINK);
-               table_->attach(*widget_kf_list_, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::SHRINK);
-               table_->attach(*tree_view, 0, 1, 2, 3, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
-               table_->attach(*hscrollbar_, 0, 1, 3, 4, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::SHRINK);
-               table_->attach(*vscrollbar_, 1, 2, 0, 3, Gtk::FILL|Gtk::SHRINK, Gtk::FILL|Gtk::EXPAND);
-               add(*table_);
-
-               //add(*last_widget_curves_);
-               table_->show_all();
-               show_all();
-       }
-       else
-       {
-               //clear_previous();
-       }
-}
diff --git a/synfig-studio/src/gtkmm/dock_timetrack.h b/synfig-studio/src/gtkmm/dock_timetrack.h
deleted file mode 100644 (file)
index 9da19fd..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_timetrack.h
-**     \brief Template Header
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**  Copyright (c) 2009 Carlos López
-**
-**     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_DOCK_TIMETRACK_H
-#define __SYNFIG_STUDIO_DOCK_TIMETRACK_H
-
-/* === H E A D E R S ======================================================= */
-
-#include "dockable.h"
-#include <gtkmm/treeview.h>
-#include "instance.h"
-#include "dock_canvasspecific.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 Widget_Timeslider;
-class Widget_Keyframe_List;
-
-class Dock_Timetrack : public Dock_CanvasSpecific
-{
-       Gtk::HScrollbar* hscrollbar_;
-       Gtk::VScrollbar* vscrollbar_;
-       Widget_Timeslider* widget_timeslider_;
-       Widget_Keyframe_List* widget_kf_list_;
-       Gtk::Table* table_;
-
-protected:
-       virtual void init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
-       virtual void changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
-
-       void refresh_selected_param();
-
-public:
-
-
-       Dock_Timetrack();
-       ~Dock_Timetrack();
-}; // END of Dock_Timetrack
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/dockable.cpp b/synfig-studio/src/gtkmm/dockable.cpp
deleted file mode 100644 (file)
index f0a3dce..0000000
+++ /dev/null
@@ -1,380 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dockable.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "app.h"
-#include <sigc++/hide.h>
-
-#include "dockable.h"
-#include "dockmanager.h"
-#include "dockbook.h"
-#include "dockdialog.h"
-#include <synfig/general.h>
-#include <gtkmm/table.h>
-#include <gtk/gtk.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 ========================================================= */
-
-#ifdef WIN32
-#      ifdef IMAGE_DIR
-#              undef IMAGE_DIR
-#              define IMAGE_DIR "share\\pixmaps"
-#      endif
-#endif
-
-#ifndef IMAGE_DIR
-#      define IMAGE_DIR "/usr/local/share/pixmaps"
-#endif
-
-#ifndef IMAGE_EXT
-#      define IMAGE_EXT        "png"
-#endif
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Dockable::Dockable(const synfig::String& name,const synfig::String& local_name,Gtk::StockID stock_id_):
-//     Gtk::Window(Gtk::WINDOW_TOPLEVEL),
-       name_(name),
-       local_name_(local_name),
-//     dialog_settings(this,name),
-       title_label_(local_name,Gtk::ALIGN_LEFT),
-       stock_id_(stock_id_)
-{
-       parent_=0;
-       scrolled_=0;
-
-       use_scrolled_=true;
-
-       attach_dnd_to(title_label_);
-
-       toolbar_=0;
-       //button_box_.show();
-
-       Gtk::Table* table(this);
-
-       {
-               title_label_.set_padding(0,0);
-               //title_label_.show();
-               Gtk::EventBox* event_box(manage(new Gtk::EventBox()));
-               event_box->set_border_width(0);
-               event_box->add(title_label_);
-               //table->attach(*event_box, 0, 1, 0,1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-
-               header_box_.pack_start(*event_box);
-
-               attach_dnd_to(*event_box);
-               event_box->show();
-       //      event_box->set_events(Gdk::ALL_EVENTS_MASK); //!< \todo change this to only allow what is necessary for DnD
-
-
-               Gtk::Button* bttn_close(manage(new Gtk::Button(_("X"))));
-               //table->attach(*bttn_close, 1, 2, 0,1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-               header_box_.pack_end(*bttn_close,false,false);
-               bttn_close->show();
-               bttn_close->set_relief(Gtk::RELIEF_NONE);
-               bttn_close->signal_clicked().connect(sigc::mem_fun(*this,&Dockable::detach));
-               bttn_close->set_border_width(0);
-               dynamic_cast<Gtk::Misc*>(bttn_close->get_child())->set_padding(0,0);
-       }
-
-       prev_widget_=manage(new Gtk::Label(" "));
-
-       //table->attach(header_box_, 0, 1, 0,1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       table->attach(*prev_widget_, 0, 1, 1,2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       //table->attach(*toolbar_, 0, 1, 2,3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       set_toolbar(*manage(new Gtk::Toolbar));
-       table->show();
-
-       prev_widget_->show();
-
-       set_size_request(175,120);
-
-}
-
-Dockable::~Dockable()
-{
-       if(scrolled_)
-       {
-               delete scrolled_;
-               scrolled_=0;
-       }
-}
-
-void
-Dockable::attach_dnd_to(Gtk::Widget& widget)
-{
-       std::list<Gtk::TargetEntry> listTargets;
-       listTargets.push_back( Gtk::TargetEntry("DOCK") );
-
-       widget.drag_source_set(listTargets);
-       widget.drag_source_set_icon(get_stock_id());
-       widget.drag_dest_set(listTargets);
-
-
-       widget.signal_drag_data_get().connect(sigc::mem_fun(*this,&Dockable::on_drag_data_get));
-       widget.signal_drag_end().connect(sigc::mem_fun(*this,&Dockable::on_drag_end));
-       widget.signal_drag_begin().connect(sigc::mem_fun(*this,&Dockable::on_drag_begin));
-       widget.signal_drag_data_received().connect(sigc::mem_fun(*this,&Dockable::on_drag_data_received));
-}
-
-void
-Dockable::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time)
-{
-       if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
-       {
-               Dockable& dockable(**reinterpret_cast<Dockable**>(const_cast<guint8*>(selection_data.get_data())));
-
-               if(dockable.parent_ != parent_)
-                       parent_->add(dockable,parent_->page_num(*this));
-               else
-                       parent_->reorder_child(dockable,parent_->page_num(*this));
-               dockable.present();
-               context->drag_finish(true, false, time);
-               return;
-       }
-
-       context->drag_finish(false, false, time);
-}
-
-void
-Dockable::on_drag_end(const Glib::RefPtr<Gdk::DragContext>&/*context*/)
-{
-       if(!dnd_success_)
-       {
-               detach();
-               present();
-       }
-}
-
-void
-Dockable::on_drag_begin(const Glib::RefPtr<Gdk::DragContext>&/*context*/)
-{
-       dnd_success_=false;
-}
-
-void
-Dockable::on_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, Gtk::SelectionData& selection_data, guint /*info*/, guint /*time*/)
-{
-       Dockable* tmp(this);
-       dnd_success_=true;
-
-       selection_data.set(8, reinterpret_cast<const guchar*>(&tmp), 4);
-}
-
-void
-Dockable::set_local_name(const synfig::String& local_name)
-{
-       //set_title(local_name);
-       title_label_.set_text(local_name);
-}
-
-void
-Dockable::clear()
-{
-       //if(!toolbar_->children().empty())
-       //      toolbar_->children().clear();
-       set_toolbar(*manage(new Gtk::Toolbar));
-
-}
-
-void
-Dockable::set_toolbar(Gtk::Toolbar& toolbar)
-{
-       if(toolbar_)remove(*toolbar_);
-       toolbar_=0;
-       toolbar_=&toolbar;
-       if(toolbar_)
-       {
-               attach(*toolbar_, 0, 1, 2,3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-               gtk_toolbar_set_icon_size(toolbar_->gobj(),GtkIconSize(1)/*GTK_ICON_SIZE_MENU*/);
-               toolbar_->show();
-       }
-}
-
-bool
-Dockable::clear_previous()
-{
-       prev_widget_=0;
-       prev_widget_delete_connection.disconnect();
-       return false;
-}
-
-void
-Dockable::add(Gtk::Widget& x)
-{
-       if(prev_widget_)
-       {
-               remove(*prev_widget_);
-               clear_previous();
-       }
-
-       if(scrolled_)
-       {
-               delete scrolled_;
-               scrolled_=0;
-       }
-
-       if(use_scrolled_)
-       {
-               scrolled_=new Gtk::ScrolledWindow;
-
-               scrolled_->add(x);
-
-               attach(*scrolled_, 0, 1, 1,2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-               x.show();
-
-               scrolled_->show();
-
-               scrolled_->set_shadow_type(Gtk::SHADOW_NONE);
-               scrolled_->set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC);
-               prev_widget_=scrolled_;
-       }
-       else
-       {
-               attach(x, 0, 1, 1,2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-               x.show();
-               prev_widget_=&x;
-       }
-       prev_widget_delete_connection=prev_widget_->signal_delete_event().connect(
-               sigc::hide(
-                       sigc::mem_fun(
-                               *this,
-                               &Dockable::clear_previous
-                       )
-               )
-       );
-}
-
-Gtk::ToolButton*
-Dockable::add_button(const Gtk::StockID& stock_id, const synfig::String& tooltip)
-{
-       if(!toolbar_)
-               set_toolbar(*manage(new Gtk::Toolbar));
-
-       //Gtk::IconSize iconsize(4);
-       //Gtk::IconSize iconsize(Gtk::IconSize::from_name("synfig-small_icon"));
-
-       Gtk::ToolButton* ret(manage(new Gtk::ToolButton(stock_id)));
-       //Gtk::Image* icon(manage(new Gtk::Image(stock_id,iconsize)));
-       //ret->add(*icon);
-       //ret->set_relief(Gtk::RELIEF_HALF);
-       //ret->set_relief(Gtk::RELIEF_NONE);
-       ret->set_label(tooltip);
-       if (toolbar_->get_tooltips_object())
-               toolbar_->get_tooltips_object()->set_tip(*ret,tooltip);
-
-       ret->show();
-       //icon->show();
-       toolbar_->set_tooltips(true);
-
-       toolbar_->append(*ret);
-       //button_box_.pack_start(*ret,false,false);
-       //get_action_area()->pack_start(*ret,false,false);
-       //add_action_widget(*ret,1);
-       return ret;
-}
-
-
-void
-Dockable::detach()
-{
-       if(parent_)
-               parent_->remove(*this);
-}
-
-void
-Dockable::present()
-{
-       if(parent_)
-       {
-               parent_->set_current_page(parent_->page_num(*this));
-               parent_->present();
-       }
-       else
-       {
-               DockDialog* dock_dialog(new DockDialog());
-               dock_dialog->get_dock_book().add(*this);
-/*             //hack: always display composition selector on top of canvas browser
-               if(get_name()=="canvases")
-                       dock_dialog->set_composition_selector(true);
-*/
-               dock_dialog->present();
-       }
-}
-
-Gtk::Widget*
-Dockable::create_tab_label()
-{
-       Gtk::EventBox* event_box(manage(new Gtk::EventBox()));
-
-       attach_dnd_to(*event_box);
-
-       {
-               Gtk::StockID stock_id(get_stock_id());
-               Gtk::StockItem item;
-
-               // Check to make sure the icon is valid
-               if(Gtk::Stock::lookup(stock_id,item))
-               {
-                       Gtk::Image* icon(manage(new Gtk::Image(stock_id,Gtk::IconSize(4))));
-                       event_box->add(*icon);
-                       tooltips_.set_tip(*event_box,get_local_name());
-                       icon->show();
-               }
-               else
-               {
-                       // Bad icon, try to make a label
-
-                       Glib::ustring text(get_local_name());
-
-                       Gtk::Label* label(manage(new Gtk::Label(text)));
-                       event_box->add(*label);
-                       label->show();
-               }
-       }
-
-       return event_box;
-}
diff --git a/synfig-studio/src/gtkmm/dockable.h b/synfig-studio/src/gtkmm/dockable.h
deleted file mode 100644 (file)
index e1a2ad1..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dockable.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_DOCKABLE_H
-#define __SYNFIG_STUDIO_DOCKABLE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/stockid.h>
-#include <gtkmm/button.h>
-#include "dialogsettings.h"
-#include <synfig/string.h>
-#include <gtkmm/table.h>
-#include <gtkmm/tooltips.h>
-#include <gtkmm/label.h>
-#include <gtkmm/frame.h>
-#include <gtkmm/handlebox.h>
-#include <gtkmm/box.h>
-#include <gtkmm/scrolledwindow.h>
-#include <gtkmm/toolbar.h>
-#include <gtkmm/toolbutton.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 DockManager;
-class DockBook;
-
-class Dockable : public Gtk::Table
-{
-       friend class DockManager;
-       friend class DockBook;
-
-
-       sigc::signal<void> signal_stock_id_changed_;
-       sigc::connection prev_widget_delete_connection;
-protected:
-
-//     DialogSettings dialog_settings;
-
-
-private:
-
-       Gtk::Toolbar *toolbar_;
-
-       synfig::String name_;
-       synfig::String local_name_;
-       Gtk::Tooltips tooltips_;
-       Gtk::Frame frame_;
-       Gtk::Label title_label_;
-       //Gtk::HBox button_box_;
-       Gtk::HBox header_box_;
-
-       //Gtk::HandleBox handle_box_;
-       Gtk::ScrolledWindow *scrolled_;
-       Gtk::Widget *prev_widget_;
-
-       bool use_scrolled_;
-
-       Gtk::StockID stock_id_;
-
-       DockBook* parent_;
-
-       bool dnd_success_;
-
-public:
-
-       void set_toolbar(Gtk::Toolbar& toolbar);
-
-       void set_use_scrolled(bool x) { use_scrolled_=x; }
-
-       Dockable(const synfig::String& name,const synfig::String& local_name,Gtk::StockID stock_id_=Gtk::StockID(" "));
-       ~Dockable();
-
-       sigc::signal<void>& signal_stock_id_changed() { return signal_stock_id_changed_; }
-
-       const synfig::String& get_name()const { return name_; }
-       const synfig::String& get_local_name()const { return local_name_; }
-
-       const Gtk::StockID& get_stock_id()const { return stock_id_; }
-       void set_stock_id(Gtk::StockID x) { stock_id_=x; signal_stock_id_changed()(); }
-
-       void set_local_name(const synfig::String&);
-
-       void clear();
-
-       Gtk::Tooltips& get_tooltips() { return tooltips_; }
-
-       //DialogSettings& settings() { return dialog_settings; }
-       //const DialogSettings& settings()const { return dialog_settings; }
-
-       void add(Gtk::Widget& x);
-
-       Gtk::ToolButton* add_button(const Gtk::StockID& stock_id, const synfig::String& tooltip=synfig::String());
-
-       void detach();
-
-       void present();
-
-       void attach_dnd_to(Gtk::Widget& widget);
-
-       bool clear_previous();
-       virtual Gtk::Widget* create_tab_label();
-
-private:
-
-       void on_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, Gtk::SelectionData& selection_data, guint info, guint time);
-       void on_drag_end(const Glib::RefPtr<Gdk::DragContext>&context);
-       void on_drag_begin(const Glib::RefPtr<Gdk::DragContext>&context);
-       void on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time);
-
-}; // END of studio::Dockable
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/dockbook.cpp b/synfig-studio/src/gtkmm/dockbook.cpp
deleted file mode 100644 (file)
index 707352e..0000000
+++ /dev/null
@@ -1,253 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dockbook.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \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
-**     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 <config.h>
-#endif
-
-#include "dockbook.h"
-#include "dockable.h"
-#include "app.h"
-#include "dockmanager.h"
-
-#include <gtkmm/image.h>
-#include <gtkmm/eventbox.h>
-#include <gtkmm/menu.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-DockBook::DockBook()
-{
-       std::list<Gtk::TargetEntry> listTargets;
-       listTargets.push_back( Gtk::TargetEntry("DOCK") );
-
-       drag_dest_set(listTargets);
-       //set_sensitive(true);
-       set_flags(get_flags()|Gtk::RECEIVES_DEFAULT|Gtk::HAS_GRAB);
-       //add_events(Gdk::ALL_EVENTS_MASK);
-       //set_extension_events(Gdk::EXTENSION_EVENTS_ALL);
-       set_show_tabs(true);
-       deleting_=false;
-}
-
-DockBook::~DockBook()
-{
-       deleting_=true;
-       clear();
-}
-
-void
-DockBook::clear()
-{
-       while(get_n_pages())
-               remove(static_cast<Dockable&>(*get_nth_page(get_n_pages()-1)));
-}
-
-void
-DockBook::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time)
-{
-       if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
-       {
-               Dockable& dockable(**reinterpret_cast<Dockable**>(const_cast<guint8*>(selection_data.get_data())));
-               if(dockable.parent_!=this)
-                       add(dockable);
-               dockable.present();
-               context->drag_finish(true, false, time);
-               return;
-       }
-
-       context->drag_finish(false, false, time);
-}
-
-void
-DockBook::add(Dockable& dockable, int position)
-{
-       dockable.detach();
-
-       if(position==-1)
-               append_page(dockable, " ");
-       else
-               insert_page(dockable, " ", position);
-
-       refresh_tab(&dockable);
-
-       dockable.signal_stock_id_changed().connect(
-               sigc::bind(
-                       sigc::mem_fun(
-                               *this,
-                               &DockBook::refresh_tab
-                       ),
-                       &dockable
-               )
-       );
-
-       dockable.parent_=this;
-
-       dockable.show();
-
-       signal_changed_();
-}
-
-void
-DockBook::refresh_tab(Dockable* dockable)
-{
-       Gtk::Widget* label(dockable->create_tab_label());
-
-       label->signal_button_press_event().connect(
-               sigc::bind(
-                       sigc::mem_fun(
-                               *this,
-                               &DockBook::tab_button_pressed
-                       ),
-                       dockable
-               )
-       );
-
-       set_tab_label(*dockable, *label);
-       label->show();
-}
-
-
-void
-DockBook::remove(Dockable& dockable)
-{
-       dockable.hide();
-       remove_page(dockable);
-       dockable.parent_=0;
-
-       if(!deleting_)
-       {
-               signal_changed_();
-
-               if(get_n_pages()==0)
-                       signal_empty()();
-       }
-}
-
-void
-DockBook::present()
-{
-       show();
-}
-
-synfig::String
-DockBook::get_local_contents()const
-{
-       synfig::String ret;
-
-       for(int i(0);i!=const_cast<DockBook*>(this)->get_n_pages();i++)
-       {
-               Dockable& dockable(static_cast<Dockable&>(*const_cast<DockBook*>(this)->get_nth_page(i)));
-
-               if(i)
-                       ret+=", ";
-               ret+=dockable.get_local_name();
-       }
-
-       return ret;
-}
-
-synfig::String
-DockBook::get_contents()const
-{
-       synfig::String ret;
-
-       for(int i(0);i!=const_cast<DockBook*>(this)->get_n_pages();i++)
-       {
-               Dockable& dockable(static_cast<Dockable&>(*const_cast<DockBook*>(this)->get_nth_page(i)));
-
-               if(i)
-                       ret+=' ';
-               ret+=dockable.get_name();
-       }
-
-       return ret;
-}
-
-void
-DockBook::set_contents(const synfig::String& x)
-{
-       synfig::String str(x);
-       while(!str.empty())
-       {
-               synfig::String::size_type separator=str.find_first_of(' ');
-               synfig::String dock;
-               if(separator==synfig::String::npos)
-               {
-                       dock=str;
-                       str.clear();
-               }
-               else
-               {
-                       dock=String(str.begin(),str.begin()+separator);
-                       str=String(str.begin()+separator+1,str.end());
-               }
-
-               try
-               {
-                       add(App::dock_manager->find_dockable(dock));
-               }catch(...) { }
-       }
-}
-
-bool
-DockBook::tab_button_pressed(GdkEventButton* event, Dockable* dockable)
-{
-       if(event->button!=3)
-               return false;
-
-       Gtk::Menu *tabmenu=manage(new class Gtk::Menu());
-       tabmenu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), tabmenu));
-
-       tabmenu->items().push_back(
-               Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-close"),
-                       sigc::mem_fun(*dockable,&Dockable::detach)
-               )
-       );
-
-       tabmenu->popup(event->button,gtk_get_current_event_time());
-
-       return true;
-}
diff --git a/synfig-studio/src/gtkmm/dockbook.h b/synfig-studio/src/gtkmm/dockbook.h
deleted file mode 100644 (file)
index c8b76a8..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dockbook.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_DOCKBOOK_H
-#define __SYNFIG_STUDIO_DOCKBOOK_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/notebook.h>
-#include <synfig/string.h>
-#include <gtkmm/tooltips.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 DockManager;
-class Dockable;
-
-class DockBook : public Gtk::Notebook
-{
-       friend class DockManager;
-       friend class Dockable;
-
-       sigc::signal<void> signal_empty_;
-       sigc::signal<void> signal_changed_;
-
-       Gtk::Tooltips tooltips_;
-
-       bool deleting_;
-
-protected:
-public:
-       DockBook();
-       ~DockBook();
-
-       sigc::signal<void>& signal_empty() { return signal_empty_; }
-       sigc::signal<void>& signal_changed() { return signal_changed_; }
-
-       void add(Dockable& dockable, int position=-1);
-       void remove(Dockable& dockable);
-
-       void present();
-
-       void clear();
-
-       synfig::String get_local_contents()const;
-
-       synfig::String get_contents()const;
-       void set_contents(const synfig::String& x);
-
-       void refresh_tabs_headers();
-
-       void refresh_tab(Dockable*);
-
-       bool tab_button_pressed(GdkEventButton* event, Dockable* dockable);
-       void on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time);
-}; // END of studio::DockBook
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/dockdialog.cpp b/synfig-studio/src/gtkmm/dockdialog.cpp
deleted file mode 100644 (file)
index 614e8db..0000000
+++ /dev/null
@@ -1,564 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dockdialog.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 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 <config.h>
-#endif
-
-#include "app.h"
-#include <sigc++/adaptors/hide.h>
-
-#include "dockdialog.h"
-#include "dockbook.h"
-#include "dockmanager.h"
-#include "toolbox.h"
-#include "widget_compselect.h"
-#include <synfig/general.h>
-#include <synfig/uniqueid.h>
-#include <gtkmm/table.h>
-#include <sigc++/hide.h>
-#include <sigc++/slot.h>
-#include <sigc++/retype_return.h>
-#include <sigc++/retype.h>
-#include "canvasview.h"
-#include <gtkmm/paned.h>
-#include <gtkmm/box.h>
-#include <synfigapp/main.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 ========================================================= */
-
-#define GRAB_HINT_DATA(y,default)      { \
-               String x; \
-               if(synfigapp::Main::settings().get_value(String("pref.")+y+"_hints",x)) \
-               { \
-                       set_type_hint((Gdk::WindowTypeHint)atoi(x.c_str()));    \
-               } else {\
-                       set_type_hint(default); \
-               } \
-       }
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-DockDialog::DockDialog():
-       Gtk::Window(Gtk::WINDOW_TOPLEVEL)
-{
-       composition_selector_=false;
-       is_deleting=false;
-       is_horizontal=false;
-       last_dock_book=0;
-       box=0;
-
-       widget_comp_select=new Widget_CompSelect();
-
-       // Give ourselves an ID that is most likely unique
-       set_id(synfig::UniqueID().get_uid()^reinterpret_cast<long>(this));
-
-       set_role(strprintf("dock_dialog_%d",get_id()));
-       GRAB_HINT_DATA(
-               "dock_dialog",
-#ifdef __APPLE__
-               Gdk::WINDOW_TYPE_HINT_NORMAL
-#else
-               Gdk::WINDOW_TYPE_HINT_UTILITY
-#endif
-       );
-       set_keep_above(false);
-
-       //! \todo can we set dialog windows transient for all normal windows, not just the toolbox?
-       //! paragraph 3 of http://standards.freedesktop.org/wm-spec/1.3/ar01s07.html suggests we can
-       // this seems to have bad effects on KDE, so leave it disabled by default
-       if(getenv("SYNFIG_TRANSIENT_DIALOGS"))
-               set_transient_for(*App::toolbox);
-
-       // Set up the window
-       //set_type_hint(Gdk::WINDOW_TYPE_HINT_UTILITY);
-       set_title(_("Dock Panel"));
-
-       // Register with the dock manager
-       App::dock_manager->dock_dialog_list_.push_back(this);
-
-
-       // connect our signals
-       signal_delete_event().connect(
-               sigc::hide(
-                       sigc::mem_fun(*this,&DockDialog::close)
-               )
-       );
-
-/*
-       App::signal_canvas_view_focus().connect(
-               sigc::hide(
-                       sigc::mem_fun(
-                               *this,
-                               &DockDialog::refresh_accel_group
-                       )
-               )
-       );
-*/
-
-       add_accel_group(App::ui_manager()->get_accel_group());
-       App::signal_present_all().connect(sigc::mem_fun0(*this,&DockDialog::present));
-
-}
-
-DockDialog::~DockDialog()
-{
-       empty_sig.disconnect();
-
-       is_deleting=true;
-
-       // Remove all of the dock books
-       for(;!dock_book_list.empty();dock_book_list.pop_front())
-       {
-               dock_book_list.front()->clear();
-
-               //! \todo Fix this UGLY HACK
-               // The following line really should be uncommented,
-               // but it causes crashes. Without it, a small
-               // memory hole is created--but at least it doesn't crash
-               // delete dock_book_list.front();
-
-               // Oddly enough, the following line should
-               // theoretically do the same thing after this
-               // class is destroyed, but it doesn't seem to
-               // cause a crash.  It does, however, trigger this warning:
-               //
-               //   A floating object was finalized. This means that someone
-               //   called g_object_unref() on an object that had only a
-               //   floating reference; the initial floating reference is not
-               //   owned by anyone and must be removed with g_object_ref_sink().
-               //
-               // manage(dock_book_list.front());
-       }
-
-       // Remove us from the dock manager
-       if(App::dock_manager)try{
-               std::list<DockDialog*>::iterator iter;
-               for(iter=App::dock_manager->dock_dialog_list_.begin();iter!=App::dock_manager->dock_dialog_list_.end();++iter)
-                       if(*iter==this)
-                       {
-                               App::dock_manager->dock_dialog_list_.erase(iter);
-                               break;
-                       }
-       }
-       catch(...)
-       {
-               synfig::warning("DockDialog::~DockDialog(): Exception thrown when trying to remove from dock manager...?");
-       }
-
-       delete widget_comp_select;
-}
-
-void
-DockDialog::drop_on_prepend(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time)
-{
-       if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
-       {
-               Dockable& dockable(**reinterpret_cast<Dockable**>(const_cast<guint8*>(selection_data.get_data())));
-               prepend_dock_book()->add(dockable);
-               context->drag_finish(true, false, time);
-               return;
-       }
-
-       context->drag_finish(false, false, time);
-}
-
-void
-DockDialog::drop_on_append(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time)
-{
-       if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
-       {
-               Dockable& dockable(**reinterpret_cast<Dockable**>(const_cast<guint8*>(selection_data.get_data())));
-               append_dock_book()->add(dockable);
-               context->drag_finish(true, false, time);
-               return;
-       }
-
-       context->drag_finish(false, false, time);
-}
-
-
-void
-DockDialog::on_hide()
-{
-       Gtk::Window::on_hide();
-       close();
-}
-
-DockBook*
-DockDialog::prepend_dock_book()
-{
-       if(is_deleting)return 0;
-
-       dock_book_list.push_front(new DockBook);
-       last_dock_book=dock_book_list.front();
-
-
-       last_dock_book->signal_empty().connect(
-               sigc::bind(
-                       sigc::mem_fun(*this,&DockDialog::erase_dock_book),
-                       last_dock_book
-               )
-       );
-
-       dock_book_sizes_.insert(dock_book_sizes_.begin(),225);
-       refresh();
-       return last_dock_book;
-}
-
-DockBook*
-DockDialog::append_dock_book()
-{
-       if(is_deleting)return 0;
-
-       dock_book_list.push_back(new DockBook);
-       last_dock_book=dock_book_list.back();
-       last_dock_book->signal_empty().connect(
-               sigc::bind(
-                       sigc::mem_fun(*this,&DockDialog::erase_dock_book),
-                       last_dock_book
-               )
-       );
-       last_dock_book->signal_changed().connect(
-               sigc::mem_fun(*this,&DockDialog::refresh_title)
-       );
-       last_dock_book->signal_changed().connect(
-               sigc::mem_fun(*this,&DockDialog::refresh_title)
-       );
-       dock_book_sizes_.push_back(225);
-
-       //last_dock_book->show();
-       refresh();
-       return last_dock_book;
-}
-
-void
-DockDialog::erase_dock_book(DockBook* dock_book)
-{
-       if(is_deleting)return;
-
-       std::list<DockBook*>::iterator iter;
-       for(iter=dock_book_list.begin();iter!=dock_book_list.end();++iter)
-               if(*iter==dock_book)
-               {
-                       dock_book_list.erase(iter);
-
-                       if(dock_book_list.empty())
-                       {
-                               last_dock_book=0;
-                               close();
-                               return;
-                       }
-                       else
-                       {
-                               if(last_dock_book==dock_book)
-                                       last_dock_book=dock_book_list.front();
-                       }
-
-                       refresh();
-
-                       return;
-               }
-}
-
-void
-DockDialog::refresh()
-{
-       // synfig::info("dock_book_list.size()=%d",dock_book_list.size());
-       //remove();
-
-       if(dock_book_list.empty())
-               return;
-
-       if(box)delete box;
-       box=(manage(is_horizontal?(Gtk::Box*)new Gtk::HBox:(Gtk::Box*)new Gtk::VBox));
-       add(*box);
-
-       box->pack_start(*widget_comp_select,false,true);
-
-       Gtk::Button* append_button(manage(new Gtk::Button));
-       Gtk::Button* prepend_button(manage(new Gtk::Button));
-
-       std::list<Gtk::TargetEntry> listTargets;
-       listTargets.push_back( Gtk::TargetEntry("DOCK") );
-
-       append_button->drag_dest_set(listTargets);
-       prepend_button->drag_dest_set(listTargets);
-
-       append_button->signal_drag_data_received().connect(
-               sigc::mem_fun(*this,&DockDialog::drop_on_append)
-       );
-
-       prepend_button->signal_drag_data_received().connect(
-               sigc::mem_fun(*this,&DockDialog::drop_on_prepend)
-       );
-
-       box->pack_start(*prepend_button,false,true);
-       box->pack_end(*append_button,false,true);
-
-       //prepend_button->show();
-       //append_button->show();
-       panels_.clear();
-
-       if(dock_book_list.size()==1)
-       {
-               box->pack_start(get_dock_book(),true,true);
-       }
-       else
-       {
-               Gtk::Paned* parent(manage(is_horizontal?(Gtk::Paned*)new Gtk::HPaned:(Gtk::Paned*)new Gtk::VPaned));
-
-               panels_.push_back(parent);
-
-               if(panels_.size()<=dock_book_sizes_.size())
-                       panels_.back()->set_position(dock_book_sizes_[panels_.size()-1]);
-               panels_.back()->property_position().signal_changed().connect(
-                       sigc::mem_fun(*this,&DockDialog::rebuild_sizes)
-               );
-               //parent->show();
-               parent->add1(*dock_book_list.front());
-               //dock_book_list.front()->show();
-
-               box->pack_start(*parent,true,true);
-
-               std::list<DockBook*>::iterator iter,next;
-               for(next=dock_book_list.begin(),next++,iter=next++;next!=dock_book_list.end();iter=next++)
-               {
-                       Gtk::Paned* current(manage(is_horizontal?(Gtk::Paned*)new Gtk::HPaned:(Gtk::Paned*)new Gtk::VPaned));
-                       panels_.push_back(current);
-
-                       if(panels_.size()<=dock_book_sizes_.size())
-                               panels_.back()->set_position(dock_book_sizes_[panels_.size()-1]);
-                       panels_.back()->property_position().signal_changed().connect(
-                               sigc::mem_fun(*this,&DockDialog::rebuild_sizes)
-                       );
-
-
-                       parent->add2(*current);
-
-                       current->add1(**iter);
-                       //(*iter)->show();
-                       //current->show();
-
-                       parent=current;
-               }
-               parent->add2(**iter);
-               //(*iter)->show();
-       }
-
-       box->show_all();
-       if(!composition_selector_)
-               widget_comp_select->hide();
-       rebuild_sizes();
-}
-
-void
-DockDialog::rebuild_sizes()
-{
-       unsigned int i=0;
-       dock_book_sizes_.clear();
-       for(i=0;i<panels_.size();i++)
-       {
-               dock_book_sizes_.push_back(panels_[i]->get_position());
-       }
-}
-
-void
-DockDialog::set_dock_book_sizes(const std::vector<int>& new_sizes)
-{
-       unsigned int i=0;
-       for(i=0;i<panels_.size() && i<new_sizes.size();i++)
-       {
-               panels_[i]->set_position(new_sizes[i]);
-       }
-       dock_book_sizes_=new_sizes;
-       //rebuild_sizes();
-}
-
-void
-DockDialog::refresh_accel_group()
-{
-/*
-       if(last_accel_group_)
-       {
-               last_accel_group_->unlock();
-               remove_accel_group(last_accel_group_);
-               last_accel_group_=Glib::RefPtr<Gtk::AccelGroup>();
-       }
-
-       etl::loose_handle<CanvasView> canvas_view(App::get_selected_canvas_view());
-       if(canvas_view)
-       {
-               last_accel_group_=canvas_view->get_accel_group();
-               last_accel_group_->lock();
-               add_accel_group(last_accel_group_);
-       }
-*/
-       etl::loose_handle<CanvasView> canvas_view(App::get_selected_canvas_view());
-       if(canvas_view)
-       {
-               canvas_view->mainmenu.accelerate(*this);
-       }
-}
-
-bool
-DockDialog::close()
-{
-       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
-               synfig::info("DockDialog::close(): Deleted");
-
-       empty_sig.disconnect();
-       //get_dock_book().clear();
-       delete this;
-       return true;
-}
-
-DockBook&
-DockDialog::get_dock_book()
-{
-       if(!last_dock_book)
-               return *append_dock_book();
-       return *last_dock_book;
-}
-
-const DockBook&
-DockDialog::get_dock_book()const
-{
-       return *last_dock_book;
-}
-
-
-synfig::String
-DockDialog::get_contents()const
-{
-       synfig::String ret;
-
-       std::list<DockBook*>::const_iterator iter;
-       for(iter=dock_book_list.begin();iter!=dock_book_list.end();++iter)
-       {
-               if(!ret.empty())
-                       ret+=is_horizontal?" | ":" - ";
-               ret+=(*iter)->get_contents();
-       }
-
-
-       return ret;
-}
-
-void
-DockDialog::set_contents(const synfig::String& z)
-{
-       int x,y;
-       get_size(x,y);
-
-       synfig::String str(z);
-       while(!str.empty())
-       {
-               synfig::String::size_type separator=str.find_first_of('-');
-               {
-                       synfig::String::size_type sep2=str.find_first_of('|');
-                       if(separator!=synfig::String::npos || sep2!=synfig::String::npos)
-                       {
-                               if((separator==synfig::String::npos || sep2<separator) && sep2!=synfig::String::npos)
-                               {
-                                       separator=sep2;
-                                       is_horizontal=true;
-                               }
-                               else
-                                       is_horizontal=false;
-                       }
-               }
-
-               synfig::String book_contents;
-               if(separator==synfig::String::npos)
-               {
-                       book_contents=str;
-                       str.clear();
-               }
-               else
-               {
-                       book_contents=String(str.begin(),str.begin()+separator);
-                       str=String(str.begin()+separator+1,str.end());
-               }
-
-               try
-               {
-                       append_dock_book()->set_contents(book_contents);
-               }catch(...) { }
-       }
-
-       resize(x,y);
-}
-
-void
-DockDialog::set_composition_selector(bool x)
-{
-       if(x==get_composition_selector())
-               return;
-       composition_selector_=x;
-       if(x)
-               widget_comp_select->show();
-       else
-               widget_comp_select->hide();
-}
-
-void
-DockDialog::refresh_title()
-{
-       if(is_deleting)return;
-       if(dock_book_list.size())
-       {
-               synfig::String title;
-
-               std::list<DockBook*>::const_iterator iter;
-               for(iter=dock_book_list.begin();iter!=dock_book_list.end();++iter)
-               {
-                       if(!title.empty())
-                               title+=", ";
-                       title+=(*iter)->get_local_contents();
-               }
-               set_title(title);
-       }
-       else
-               set_title(_("Empty Dock Panel"));
-}
diff --git a/synfig-studio/src/gtkmm/dockdialog.h b/synfig-studio/src/gtkmm/dockdialog.h
deleted file mode 100644 (file)
index 551ecba..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dockdialog.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_DOCK_DIALOG_H
-#define __SYNFIG_STUDIO_DOCK_DIALOG_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/stockid.h>
-#include <gtkmm/button.h>
-#include "dialogsettings.h"
-#include <synfig/string.h>
-#include <gtkmm/dialog.h>
-#include <gtkmm/tooltips.h>
-#include <gtkmm/label.h>
-#include <gtkmm/frame.h>
-#include <gtkmm/handlebox.h>
-#include <gtkmm/scrolledwindow.h>
-#include <gtkmm/accelgroup.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 Gtk { class Box; class Paned;  };
-namespace studio {
-
-class DockManager;
-class DockBook;
-class Dockable;
-class Widget_CompSelect;
-class CanvasView;
-
-class DockDialog : public Gtk::Window
-{
-       friend class DockManager;
-       friend class DockBook;
-       friend class Dockable;
-       sigc::connection empty_sig;
-
-       bool composition_selector_;
-
-       bool is_deleting;
-
-       bool is_horizontal;
-
-private:
-       std::list<DockBook*> dock_book_list;
-
-       std::vector<Gtk::Paned*>        panels_;
-       std::vector<int>                        dock_book_sizes_;
-
-
-       DockBook* last_dock_book;
-
-       Widget_CompSelect* widget_comp_select;
-       Gtk::Box *box;
-
-       int id_;
-
-       void on_hide();
-
-       void refresh();
-
-       void refresh_title();
-
-       void set_id(int x) { id_=x; }
-
-       void refresh_accel_group();
-
-       void drop_on_append(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time);
-       void drop_on_prepend(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time);
-
-public:
-
-       const std::vector<int>& get_dock_book_sizes()const { return dock_book_sizes_;}
-       void set_dock_book_sizes(const std::vector<int>&);
-       void rebuild_sizes();
-
-       bool close();
-
-       int get_id()const { return id_; }
-
-       DockBook* append_dock_book();
-       DockBook* prepend_dock_book();
-       void erase_dock_book(DockBook*);
-
-       void set_composition_selector(bool x);
-       bool get_composition_selector()const { return composition_selector_; }
-
-       DockDialog();
-       ~DockDialog();
-
-       DockBook& get_dock_book();
-       const DockBook& get_dock_book()const;
-
-       synfig::String get_contents()const;
-       void set_contents(const synfig::String& x);
-}; // END of studio::DockDialog
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/dockmanager.cpp b/synfig-studio/src/gtkmm/dockmanager.cpp
deleted file mode 100644 (file)
index 8a5198c..0000000
+++ /dev/null
@@ -1,328 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dockmanager.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 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 <config.h>
-#endif
-
-#include "dockmanager.h"
-#include <stdexcept>
-#include "dockable.h"
-#include "dockdialog.h"
-#include <synfigapp/settings.h>
-#include <synfigapp/main.h>
-#include <gdkmm/general.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 ========================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-class studio::DockSettings : public synfigapp::Settings
-{
-       DockManager* dock_manager;
-
-public:
-       DockSettings(DockManager* dock_manager):dock_manager(dock_manager)
-       {
-               synfigapp::Main::settings().add_domain(this,"dock");
-       }
-
-       virtual ~DockSettings()
-       {
-               synfigapp::Main::settings().remove_domain("dock");
-       }
-#define SCALE_FACTOR   (1280)
-       virtual bool get_value(const synfig::String& key_, synfig::String& value)const
-       {
-               int screen_w(Gdk::screen_width());
-               int screen_h(Gdk::screen_height());
-
-               if(key_.size()>6 && String(key_.begin(),key_.begin()+6)=="dialog")try
-               {
-                       synfig::String key(key_.begin()+7,key_.end());
-                       synfig::String::size_type separator=key.find_first_of('.');
-                       int id(atoi(synfig::String(key.begin(),key.begin()+separator).c_str()));
-                       key=synfig::String(key.begin()+separator+1,key.end());
-
-                       DockDialog& dock_dialog(dock_manager->find_dock_dialog(id));
-
-                       if(key=="contents_size")
-                       {
-                               dock_dialog.rebuild_sizes();
-                               vector<int>::const_iterator iter(dock_dialog.get_dock_book_sizes().begin());
-                               vector<int>::const_iterator end(dock_dialog.get_dock_book_sizes().end());
-                               value.clear();
-                               for(;iter!=end;++iter)
-                                       value+=strprintf("%d ",(*iter)*SCALE_FACTOR/screen_h);
-                               return true;
-                       }
-                       if(key=="pos")
-                       {
-                               int x,y; dock_dialog.get_position(x,y);
-                               value=strprintf("%d %d",x*SCALE_FACTOR/screen_w,y*SCALE_FACTOR/screen_h);
-                               return true;
-                       }
-                       if(key=="size")
-                       {
-                               int x,y; dock_dialog.get_size(x,y);
-                               value=strprintf("%d %d",x*SCALE_FACTOR/screen_w,y*SCALE_FACTOR/screen_h);
-                               return true;
-                       }
-                       if(key=="contents")
-                       {
-                               value=dock_dialog.get_contents();
-                               return true;
-                       }
-                       if(key=="comp_selector")
-                       {
-                               value=dock_dialog.get_composition_selector()?"1":"0";
-                               return true;
-                       }
-               }catch (...) { return false; }
-               return synfigapp::Settings::get_value(key_,value);
-       }
-
-       virtual bool set_value(const synfig::String& key_,const synfig::String& value)
-       {
-               int screen_w(Gdk::screen_width());
-               int screen_h(Gdk::screen_height());
-
-               if(key_.size()>6 && String(key_.begin(),key_.begin()+6)=="dialog")
-               {
-                       synfig::String key(key_.begin()+7,key_.end());
-                       synfig::String::size_type separator=key.find_first_of('.');
-                       int id(atoi(synfig::String(key.begin(),key.begin()+separator).c_str()));
-                       key=synfig::String(key.begin()+separator+1,key.end());
-
-                       DockDialog& dock_dialog(dock_manager->find_dock_dialog(id));
-
-                       if(key=="contents_size")
-                       {
-                               try {
-                               int width, height;
-                               Gtk::IconSize::lookup(Gtk::IconSize(4),width,height);
-                               vector<int> data;
-                               String::size_type n=0;
-                               String value_(value);
-                               while(value_.size() && value_.size()>n){
-                                       value_=String(value_.begin()+n,value_.end());
-                                       int size;
-                                       if(!strscanf(value_,"%d",&size))
-                                               break;
-                                       if (size > SCALE_FACTOR) size = SCALE_FACTOR - 150;
-                                       if (size < 0) size = 0;
-                                       size=size*screen_h/SCALE_FACTOR;
-
-                                       // prevent errors like this, by allowing space for at least the dockable's icon:
-                                       // ** CRITICAL **: clearlooks_style_draw_box_gap: assertion `height >= -1' failed
-                                       if (size < height + 9) size = height + 9;
-
-                                       data.push_back(size);
-
-                                       n=value_.find(" ");
-                                       if(n==String::npos)
-                                               break;
-                                       n++;
-                               }
-                               dock_dialog.set_dock_book_sizes(data);
-                               }
-                               catch(...)
-                               {
-                                       synfig::error("Exception caught!!!");
-                                       return false;
-                               }
-                               return true;
-                       }
-                       if(key=="pos")
-                       {
-                               int x,y;
-                               if(!strscanf(value,"%d %d",&x, &y))
-                                       return false;
-                               if (x > SCALE_FACTOR) x = SCALE_FACTOR - 150; if (x < 0) x = 0;
-                               if (y > SCALE_FACTOR) y = SCALE_FACTOR - 150; if (y < 0) y = 0;
-                               x=x*screen_w/SCALE_FACTOR;
-                               y=y*screen_h/SCALE_FACTOR;
-                               if(getenv("SYNFIG_WINDOW_POSITION_X_OFFSET"))
-                                       x += atoi(getenv("SYNFIG_WINDOW_POSITION_X_OFFSET"));
-                               if(getenv("SYNFIG_WINDOW_POSITION_Y_OFFSET"))
-                                       y += atoi(getenv("SYNFIG_WINDOW_POSITION_Y_OFFSET"));
-                               dock_dialog.move(x,y);
-                               return true;
-                       }
-                       if(key=="size")
-                       {
-                               int x,y;
-                               if(!strscanf(value,"%d %d",&x, &y))
-                                       return false;
-                               if (x > SCALE_FACTOR) x = 150; if (x < 0) x = 0;
-                               if (y > SCALE_FACTOR) y = 150; if (y < 0) y = 0;
-                               x=x*screen_w/SCALE_FACTOR;
-                               y=y*screen_h/SCALE_FACTOR;
-                               dock_dialog.set_default_size(x,y);
-                               dock_dialog.resize(x,y);
-                               return true;
-                       }
-                       if(key=="contents")
-                       {
-                               dock_dialog.set_contents(value);
-                               return true;
-                       }
-                       if(key=="comp_selector")
-                       {
-                               if(value.empty() || value[0]=='0')
-                                       dock_dialog.set_composition_selector(false);
-                               else
-                                       dock_dialog.set_composition_selector(true);
-                               return true;
-                       }
-               }
-               return synfigapp::Settings::set_value(key_,value);
-       }
-
-       virtual KeyList get_key_list()const
-       {
-               synfigapp::Settings::KeyList ret(synfigapp::Settings::get_key_list());
-
-               std::list<DockDialog*>::const_iterator iter;
-               for(iter=dock_manager->dock_dialog_list_.begin();iter!=dock_manager->dock_dialog_list_.end();++iter)
-               {
-                       ret.push_back(strprintf("dialog.%d.contents",(*iter)->get_id()));
-                       ret.push_back(strprintf("dialog.%d.comp_selector",(*iter)->get_id()));
-                       ret.push_back(strprintf("dialog.%d.pos",(*iter)->get_id()));
-                       ret.push_back(strprintf("dialog.%d.size",(*iter)->get_id()));
-                       ret.push_back(strprintf("dialog.%d.contents_size",(*iter)->get_id()));
-               }
-               return ret;
-       }
-};
-
-/* === M E T H O D S ======================================================= */
-
-DockManager::DockManager():
-       dock_settings(new DockSettings(this))
-{
-}
-
-DockManager::~DockManager()
-{
-       while(!dock_dialog_list_.empty())
-       {
-               dock_dialog_list_.back()->close();
-       }
-       while(!dockable_list_.empty())
-       {
-               Dockable* dockable(dockable_list_.back());
-               // synfig::info("DockManager::~DockManager(): Deleting dockable \"%s\"",dockable->get_name().c_str());
-               dockable_list_.pop_back();
-               delete dockable;
-       }
-}
-
-void
-DockManager::register_dockable(Dockable& x)
-{
-       dockable_list_.push_back(&x);
-       // synfig::info("DockManager::register_dockable(): Registered dockable \"%s\"",dockable_list_.back()->get_name().c_str());
-       signal_dockable_registered()(&x);
-}
-
-bool
-DockManager::unregister_dockable(Dockable& x)
-{
-       std::list<Dockable*>::iterator iter;
-       for(iter=dockable_list_.begin();iter!=dockable_list_.end();++iter)
-       {
-               if(&x==*iter)
-               {
-                       x.detach();
-                       dockable_list_.erase(iter);
-                       synfig::info("DockManager::unregister_dockable(): \"%s\" has been Unregistered",x.get_name().c_str());
-                       return true;
-               }
-       }
-       return false;
-}
-
-Dockable&
-DockManager::find_dockable(const synfig::String& x)
-{
-       std::list<Dockable*>::iterator iter;
-       for(iter=dockable_list_.begin();iter!=dockable_list_.end();++iter)
-               if((*iter)->get_name()==x)
-                       return **iter;
-
-       throw std::runtime_error("DockManager::find_dockable(): not found");
-}
-
-void
-DockManager::present(synfig::String x)
-{
-       try
-       {
-               find_dockable(x).present();
-       }
-       catch(...)
-       {
-       }
-}
-
-DockDialog&
-DockManager::find_dock_dialog(int id)
-{
-       std::list<DockDialog*>::iterator iter;
-       for(iter=dock_dialog_list_.begin();iter!=dock_dialog_list_.end();++iter)
-               if((*iter)->get_id()==id)
-                       return **iter;
-
-       DockDialog* dock_dialog(new DockDialog());
-       dock_dialog->set_id(id);
-       dock_dialog->show();
-       return *dock_dialog;
-}
-
-const DockDialog&
-DockManager::find_dock_dialog(int id)const
-{
-       std::list<DockDialog*>::const_iterator iter;
-       for(iter=dock_dialog_list_.begin();iter!=dock_dialog_list_.end();++iter)
-               if((*iter)->get_id()==id)
-                       return **iter;
-
-       throw std::runtime_error("DockManager::find_dock_dialog(int id)const: not found");
-}
diff --git a/synfig-studio/src/gtkmm/dockmanager.h b/synfig-studio/src/gtkmm/dockmanager.h
deleted file mode 100644 (file)
index 98df376..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dockmanager.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_DOCKMANAGER_H
-#define __SYNFIG_DOCKMANAGER_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <vector>
-#include <list>
-#include <synfig/string.h>
-#include <sigc++/signal.h>
-#include <sigc++/object.h>
-#include <ETL/smart_ptr>
-
-/* === 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 Dockable;
-class DockDialog;
-class DockSettings;
-
-class DockManager : public sigc::trackable
-{
-       friend class Dockable;
-       friend class DockDialog;
-       friend class DockSettings;
-
-       std::list<Dockable*> dockable_list_;
-       std::list<DockDialog*> dock_dialog_list_;
-
-       sigc::signal<void,Dockable*> signal_dockable_registered_;
-
-       etl::smart_ptr<DockSettings> dock_settings;
-
-public:
-       DockManager();
-       ~DockManager();
-
-       DockDialog& find_dock_dialog(int id);
-       const DockDialog& find_dock_dialog(int id)const;
-
-       sigc::signal<void,Dockable*>& signal_dockable_registered() { return signal_dockable_registered_; }
-
-       void register_dockable(Dockable& x);
-       bool unregister_dockable(Dockable& x);
-       Dockable& find_dockable(const synfig::String& x);
-       void present(synfig::String x);
-
-}; // END of class DockManager
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/duck.cpp b/synfig-studio/src/gtkmm/duck.cpp
deleted file mode 100644 (file)
index 14ea8d0..0000000
+++ /dev/null
@@ -1,300 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file duck.cpp
-**     \brief Template 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 <config.h>
-#endif
-
-#include "duck.h"
-#include <ETL/misc>
-
-#include <synfig/valuenode_bline.h>
-#include <synfig/valuenode_blinecalctangent.h>
-#include <synfig/valuenode_blinecalcvertex.h>
-#include <synfig/valuenode_blinecalcwidth.h>
-#include <synfig/valuenode_composite.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 ======================================================= */
-
-int studio::Duck::duck_count(0);
-
-struct _DuckCounter
-{
-       static int counter;
-       ~_DuckCounter()
-       {
-               if(counter)
-                       synfig::error("%d ducks not yet deleted!",counter);
-       }
-} _duck_counter;
-
-int _DuckCounter::counter(0);
-
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Duck::Duck():
-       rotations(synfig::Angle::deg(0)),
-       origin(0,0),
-       scalar(1),
-       editable(false),
-       radius_(false),
-       tangent_(false),
-       hover_(false),
-       ignore_(false)
-{ duck_count++; _DuckCounter::counter++; }
-
-Duck::Duck(const synfig::Point &point):
-       type_(TYPE_NONE),
-       point(point),
-       rotations(synfig::Angle::deg(0)),
-       origin(0,0),
-       scalar(1),
-       guid_(0),
-       editable(false),
-       radius_(false),
-       tangent_(false),
-       hover_(false),
-       ignore_(false)
-{ duck_count++; _DuckCounter::counter++;}
-
-Duck::Duck(const synfig::Point &point,const synfig::Point &origin):
-       point(point),
-       rotations(synfig::Angle::deg(0)),
-       origin(origin),
-       scalar(1),
-       guid_(0),
-       editable(false),
-       radius_(true),
-       tangent_(false),
-       hover_(false),
-       ignore_(false)
-{ duck_count++; _DuckCounter::counter++;}
-
-Duck::~Duck() { duck_count--; _DuckCounter::counter--;}
-
-synfig::GUID
-Duck::get_data_guid()const
-{
-       if(value_desc_.is_value_node())
-               return value_desc_.get_value_node()->get_guid();
-       return synfig::GUID::hasher(get_name());
-}
-
-void
-Duck::set_name(const synfig::String &x)
-{
-       name=x;
-       if(guid_==synfig::GUID::zero())
-       {
-               guid_=synfig::GUID::hasher(name);
-       }
-}
-
-
-bool
-Duck::operator==(const Duck &rhs)const
-{
-       if(this==&rhs)
-               return true;
-       return
-               name==rhs.name &&
-               scalar==rhs.scalar &&
-               type_==rhs.type_ &&
-               transform_stack_.size()==rhs.transform_stack_.size();
-               //true;
-               //(origin_duck?*origin_duck==*rhs.origin_duck:origin==rhs.origin) &&
-               //(shared_point?*shared_point==*rhs.shared_point:point==rhs.point) ;
-}
-
-synfig::Point
-Duck::get_trans_point()const
-{
-       return transform_stack_.perform(get_sub_trans_point());
-}
-
-void
-Duck::set_trans_point(const synfig::Point &x)
-{
-       set_sub_trans_point(transform_stack_.unperform(x));
-}
-
-void
-Duck::set_trans_point(const synfig::Point &x, const synfig::Time &time)
-{
-       set_sub_trans_point(transform_stack_.unperform(x), time);
-}
-
-//! Sets the origin point.
-void
-Duck::set_origin(const synfig::Point &x)
-{
-       origin=x; origin_duck=0;
-}
-
-//! Sets the origin point as another duck
-void
-Duck::set_origin(const etl::handle<Duck> &x)
-{
-       origin_duck=x;
-}
-
-//! Retrieves the origin location
-synfig::Point
-Duck::get_origin()const
-{
-       return origin_duck?origin_duck->get_point():origin;
-}
-
-//! Retrieves the origin duck
-const etl::handle<Duck> &
-Duck::get_origin_duck() const
-{
-       return origin_duck;
-}
-
-//! Retrieves the origin location
-synfig::Point
-Duck::get_trans_origin()const
-{
-       return transform_stack_.perform(get_sub_trans_origin());
-}
-
-synfig::Point
-Duck::get_sub_trans_point()const
-{
-       return get_point()*get_scalar()+get_sub_trans_origin();
-}
-
-void
-Duck::set_sub_trans_point(const synfig::Point &x, const synfig::Time &time)
-{
-       if (get_type() == Duck::TYPE_TANGENT ||
-               get_type() == Duck::TYPE_ANGLE)
-       {
-               Angle old_angle = get_point().angle();
-               set_point((x-get_sub_trans_origin())/get_scalar());
-               Angle change = get_point().angle() - old_angle;
-               while (change < Angle::deg(-180)) change += Angle::deg(360);
-               while (change > Angle::deg(180)) change -= Angle::deg(360);
-               int old_halves = round_to_int(Angle::deg(rotations).get()/180);
-               rotations += change;
-               int new_halves = round_to_int(Angle::deg(rotations).get()/180);
-               if (old_halves != new_halves &&
-                       (new_halves > 1 || new_halves < -1 ||
-                        old_halves > 1 || old_halves < -1))
-                       synfig::info("rotation: %.2f turns", new_halves/2.0);
-       } else if(get_type() == Duck::TYPE_VERTEX || get_type() == Duck::TYPE_POSITION)
-       {
-               set_point((x-get_sub_trans_origin())/get_scalar());
-
-               ValueNode_BLineCalcVertex::Handle bline_vertex;
-               ValueNode_Composite::Handle composite;
-
-               if ((bline_vertex = ValueNode_BLineCalcVertex::Handle::cast_dynamic(get_value_desc().get_value_node())) ||
-                       ((composite = ValueNode_Composite::Handle::cast_dynamic(get_value_desc().get_value_node())) &&
-                        composite->get_type() == ValueBase::TYPE_BLINEPOINT &&
-                        (bline_vertex = ValueNode_BLineCalcVertex::Handle::cast_dynamic(composite->get_link("point")))))
-               {
-                       synfig::Point closest_point = get_point();
-                       synfig::Real radius = 0.0;
-                       ValueNode_BLine::Handle bline = ValueNode_BLine::Handle::cast_dynamic(bline_vertex->get_link(bline_vertex->get_link_index_from_name("bline")));
-                       synfig::find_closest_point(
-                               (*bline)(time),
-                               get_point(),
-                               radius,
-                               bline->get_loop(),
-                               &closest_point);
-                       set_point(closest_point);
-               }
-       }
-       else set_point((x-get_sub_trans_origin())/get_scalar());
-}
-
-void
-Duck::set_sub_trans_point(const synfig::Point &x)
-{
-       if (get_type() == Duck::TYPE_TANGENT ||
-               get_type() == Duck::TYPE_ANGLE)
-       {
-               Angle old_angle = get_point().angle();
-               set_point((x-get_sub_trans_origin())/get_scalar());
-               Angle change = get_point().angle() - old_angle;
-               while (change < Angle::deg(-180)) change += Angle::deg(360);
-               while (change > Angle::deg(180)) change -= Angle::deg(360);
-               int old_halves = round_to_int(Angle::deg(rotations).get()/180);
-               rotations += change;
-               int new_halves = round_to_int(Angle::deg(rotations).get()/180);
-               if (old_halves != new_halves &&
-                       (new_halves > 1 || new_halves < -1 ||
-                        old_halves > 1 || old_halves < -1))
-                       synfig::info("rotation: %.2f turns", new_halves/2.0);
-       }
-       else set_point((x-get_sub_trans_origin())/get_scalar());
-}
-
-synfig::Point
-Duck::get_sub_trans_origin()const
-{
-       return origin_duck?origin_duck->get_sub_trans_point():origin;
-}
-
-#ifdef _DEBUG
-synfig::String
-Duck::type_name(Type id)
-{
-       String ret;
-
-       if (id & TYPE_POSITION) { if (!ret.empty()) ret += ", "; ret += "position"; }
-       if (id & TYPE_TANGENT ) { if (!ret.empty()) ret += ", "; ret += "tangent" ; }
-       if (id & TYPE_RADIUS  ) { if (!ret.empty()) ret += ", "; ret += "radius"  ; }
-       if (id & TYPE_WIDTH       ) { if (!ret.empty()) ret += ", "; ret += "width"   ; }
-       if (id & TYPE_ANGLE       ) { if (!ret.empty()) ret += ", "; ret += "angle"   ; }
-       if (id & TYPE_VERTEX  ) { if (!ret.empty()) ret += ", "; ret += "vertex"  ; }
-
-       if (ret.empty())
-               ret = "none";
-
-       return ret;
-}
-#endif // _DEBUG
diff --git a/synfig-studio/src/gtkmm/duck.h b/synfig-studio/src/gtkmm/duck.h
deleted file mode 100644 (file)
index 9a054f3..0000000
+++ /dev/null
@@ -1,307 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file duck.h
-**     \brief Template Header
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === S T A R T =========================================================== */
-
-#ifndef __SYNFIG_DUCKMATIC_DUCK_H
-#define __SYNFIG_DUCKMATIC_DUCK_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <list>
-
-#include <ETL/smart_ptr>
-#include <ETL/handle>
-
-#include <synfig/vector.h>
-#include <synfig/string.h>
-#include <synfig/real.h>
-#include <sigc++/signal.h>
-#include <sigc++/object.h>
-#include <synfig/time.h>
-#include <ETL/smart_ptr>
-#include <synfigapp/value_desc.h>
-#include <synfig/transform.h>
-
-/* === M A C R O S ========================================================= */
-
-#ifdef HASH_MAP_H
-#include HASH_MAP_H
-#include FUNCTIONAL_H
-
-#ifndef __STRING_HASH__
-#define __STRING_HASH__
-class StringHash
-{
-# ifdef FUNCTIONAL_HASH_ON_STRING
-       HASH_MAP_NAMESPACE::hash<synfig::String> hasher_;
-# else  // FUNCTIONAL_HASH_ON_STRING
-       HASH_MAP_NAMESPACE::hash<const char*> hasher_;
-# endif  // FUNCTIONAL_HASH_ON_STRING
-public:
-       size_t operator()(const synfig::String& x)const
-       {
-# ifdef FUNCTIONAL_HASH_ON_STRING
-               return hasher_(x);
-# else  // FUNCTIONAL_HASH_ON_STRING
-               return hasher_(x.c_str());
-# endif  // FUNCTIONAL_HASH_ON_STRING
-       }
-};
-#endif
-#else
-#include <map>
-#endif
-
-#include <set>
-
-/* === 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 Duckmatic;
-
-/*! \class Duck
-**     \writeme */
-class Duck : public etl::shared_object
-{
-       friend class Duckmatic;
-
-public:
-       enum Type
-       {
-               TYPE_NONE               =       (0),    //  0
-               TYPE_POSITION   =       (1<<0), //  1
-               TYPE_TANGENT    =       (1<<1), //  2
-               TYPE_RADIUS             =       (1<<2), //  4
-               TYPE_WIDTH              =       (1<<3), //  8
-               TYPE_ANGLE              =       (1<<4), // 16
-               TYPE_VERTEX             =       (1<<5), // 32
-
-               TYPE_ALL                =       (~0),
-
-               TYPE_DEFAULT    =       0xdefadefa
-       };
-
-       typedef etl::handle<Duck> Handle;
-       typedef etl::loose_handle<Duck> LooseHandle;
-
-private:
-
-       sigc::signal<bool,const synfig::Point &> signal_edited_;
-       sigc::signal<bool,const synfig::Angle &> signal_edited_angle_;
-       sigc::signal<void> signal_user_click_[5];
-
-       Type type_;
-
-       synfig::Point point;
-       synfig::Angle rotations;
-
-       etl::smart_ptr<synfig::Point> shared_point;
-
-       synfig::Point origin;
-       synfig::String name;
-       synfig::Real scalar;
-
-       etl::handle<Duck> origin_duck;
-
-       etl::handle<Duck> connect_duck;
-       etl::handle<Duck> box_duck;
-
-       synfig::GUID guid_;
-
-       // Flags
-       bool editable;
-       bool radius_;
-       bool tangent_;
-       bool hover_;
-       bool ignore_;
-
-       synfig::TransformStack transform_stack_;
-
-       synfigapp::ValueDesc value_desc_;
-
-       static int duck_count;
-public:
-       Duck();
-       Duck(const synfig::Point &point);
-       Duck(const synfig::Point &point,const synfig::Point &origin);
-       ~Duck();
-
-       sigc::signal<bool,const synfig::Point &> &signal_edited() { return signal_edited_; }
-       sigc::signal<bool,const synfig::Angle &> &signal_edited_angle() { return signal_edited_angle_; }
-       sigc::signal<void> &signal_user_click(int i=0) { assert(i>=0); assert(i<5); return signal_user_click_[i]; }
-
-       void set_guid(const synfig::GUID& x) { guid_=x; }
-       const synfig::GUID& get_guid()const { return guid_; }
-
-       synfig::GUID get_data_guid()const;
-
-       //! Changes the editable flag. If set, the duck will not be able to be moved.
-       void set_editable(bool x) { editable=x; }
-
-       //! Retrieves the status of the editable flag
-       bool get_editable()const { return editable; }
-
-       //! \writeme
-       void set_tangent(bool x) { tangent_=x; type_=TYPE_TANGENT; }
-
-       //! \writeme
-       bool get_tangent()const { return tangent_; }
-
-       //! Sets whether to show the duck as if it is being hovered over
-       void set_hover(bool h) { hover_=h; }
-
-       //! Retrieves whether to show the duck as if it is being hovered over
-       bool get_hover()const { return hover_; }
-
-       //! Sets whether to ignore the duck when checking for user interaction
-       void set_ignore(bool i) { ignore_=i; }
-
-       //! Retrieves whether to ignore the duck when checking for user interaction
-       bool get_ignore()const { return ignore_; }
-
-       void set_connect_duck(const etl::handle<Duck>& x) { connect_duck=x; }
-       void set_box_duck(const etl::handle<Duck>& x) { box_duck=x; }
-
-       const etl::handle<Duck>& get_connect_duck()const { return connect_duck; }
-       const etl::handle<Duck>& get_box_duck()const { return box_duck; }
-
-       void set_value_desc(synfigapp::ValueDesc x) { value_desc_=x; }
-
-       synfigapp::ValueDesc& get_value_desc() { return value_desc_; }
-
-       void set_transform_stack(const synfig::TransformStack& x) { transform_stack_=x; }
-
-       const synfig::TransformStack& get_transform_stack()const { return transform_stack_; }
-
-       //! \writeme
-       void set_type(Type x) { type_=x; }
-
-       //! \writeme
-       Type get_type()const { return type_; }
-
-       //! Sets the scalar multiplier for the duck with respect to the origin
-       void set_scalar(synfig::Vector::value_type n) { scalar=n; }
-
-       //! Retrieves the scalar value
-       synfig::Vector::value_type get_scalar()const { return scalar; }
-
-       void set_shared_point(const etl::smart_ptr<synfig::Point>&x) { shared_point=x; }
-
-       //! Sets the location of the duck with respect to the origin
-       void set_point(const synfig::Point &x) { (shared_point?*shared_point:point)=x; }
-
-       //! Returns the location of the duck
-       synfig::Point get_point()const { return shared_point?*shared_point:point; }
-
-       synfig::Angle get_rotations()const { return rotations; };
-       void set_rotations(const synfig::Angle &x) { rotations=x; };
-
-       synfig::Point get_trans_point()const;
-
-       void set_trans_point(const synfig::Point &x);
-       void set_trans_point(const synfig::Point &x, const synfig::Time &time);
-
-       synfig::Point get_sub_trans_point()const;
-       void set_sub_trans_point(const synfig::Point &x);
-       void set_sub_trans_point(const synfig::Point &x, const synfig::Time &time);
-       synfig::Point get_sub_trans_origin()const;
-
-       //! Sets the origin point.
-       void set_origin(const synfig::Point &x);
-
-       //! Sets the origin point as another duck
-       void set_origin(const etl::handle<Duck> &x);
-
-       //! Retrieves the origin location
-       synfig::Point get_origin()const;
-
-       //! Retrieves the origin duck
-       const etl::handle<Duck> & get_origin_duck() const;
-
-       //! Retrieves the origin location
-       synfig::Point get_trans_origin()const;
-
-       void set_radius(bool r) { radius_=r; }
-       bool is_radius()const { return radius_; }
-
-       //! Sets the name of the duck
-       void set_name(const synfig::String &x);
-
-       //! Retrieves the name of the duck
-       synfig::String get_name()const { return name; }
-
-       bool operator==(const Duck &rhs)const;
-
-#ifdef _DEBUG
-       //!     Returns a string containing the name of the given Type
-       static synfig::String type_name(Type id);
-
-       //!     Returns a string containing the name of the type
-       synfig::String type_name()const { return type_name(get_type()); }
-#endif // _DEBUG
-
-}; // END of class Duck
-
-//! Combine Flags
-inline Duck::Type
-operator|(Duck::Type lhs, const Duck::Type rhs)
-{ return static_cast<Duck::Type>(int(lhs)|int(rhs)); }
-
-//! Exclude Flags
-inline Duck::Type
-operator-(Duck::Type lhs, const Duck::Type rhs)
-{ return static_cast<Duck::Type>(int(lhs)&~int(rhs)); }
-
-inline Duck::Type&
-operator|=(Duck::Type& lhs, const Duck::Type rhs)
-{ *reinterpret_cast<int*>(&lhs)|=int(rhs); return lhs; }
-
-inline Duck::Type
-operator&(const Duck::Type lhs, const Duck::Type rhs)
-{ return static_cast<Duck::Type>(int(lhs)&int(rhs)); }
-
-class DuckMap : public
-#ifdef HASH_MAP_H
-HASH_MAP_CLASS<synfig::GUID,etl::handle<studio::Duck>,synfig::GUIDHash>
-{
-       typedef HASH_MAP_CLASS<synfig::GUID,etl::handle<studio::Duck>,synfig::GUIDHash> PARENT_TYPE;
-#else
-std::map<synfig::GUID,etl::handle<studio::Duck> >
-{
-       typedef std::map<synfig::GUID,etl::handle<studio::Duck> > PARENT_TYPE;
-#endif
-public:
-       void insert(const Duck::Handle& x) { operator[](x->get_guid())=x;  }
-}; // END of class DuckMap
-
-typedef std::list<Duck::Handle> DuckList;
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/duckmatic.cpp b/synfig-studio/src/gtkmm/duckmatic.cpp
deleted file mode 100644 (file)
index 786aa11..0000000
+++ /dev/null
@@ -1,1923 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file duckmatic.cpp
-**     \brief Template 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 <config.h>
-#endif
-#include <fstream>
-#include <iostream>
-#include <algorithm>
-
-#include <ETL/hermite>
-
-#include "duckmatic.h"
-#include <synfigapp/value_desc.h>
-#include <synfig/general.h>
-#include <synfig/paramdesc.h>
-#include <synfig/valuenode_timedswap.h>
-#include <synfig/valuenode_animated.h>
-#include <synfig/valuenode_composite.h>
-#include <synfig/valuenode_scale.h>
-#include <synfig/valuenode_bline.h>
-#include <synfig/valuenode_blinecalctangent.h>
-#include <synfig/valuenode_blinecalcvertex.h>
-#include <synfig/valuenode_blinecalcwidth.h>
-
-#include <synfig/curve_helper.h>
-
-#include <sigc++/retype_return.h>
-#include <sigc++/retype.h>
-#include <sigc++/hide.h>
-#include <sigc++/bind.h>
-
-#include "canvasview.h"
-
-#include "onemoment.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 ========================================================= */
-
-/* 0.33333333333333333 makes for nice short tangent handles,
-   1.0 makes them draw as their real length */
-#define TANGENT_HANDLE_SCALE 0.33333333333333333
-
-/* leave this alone or the bezier won't lie on top of the bline */
-#define TANGENT_BEZIER_SCALE 0.33333333333333333
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-/* === E N T R Y P O I N T ================================================= */
-
-Duckmatic::Duckmatic():
-       type_mask(Duck::TYPE_ALL-Duck::TYPE_WIDTH),
-       grid_snap(false),
-       guide_snap(false),
-       grid_size(1.0/4.0,1.0/4.0),
-       show_persistent_strokes(true)
-{
-       axis_lock=false;
-       drag_offset_=Point(0,0);
-       clear_duck_dragger();
-}
-
-Duckmatic::~Duckmatic()
-{
-       clear_ducks();
-
-       if (Duck::duck_count)
-               synfig::error("%d ducks not yet deleted!", Duck::duck_count);
-
-       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
-               synfig::info("Duckmatic::~Duckmatic(): Deleted");
-}
-
-void
-Duckmatic::clear_ducks()
-{
-       duck_data_share_map.clear();
-       duck_map.clear();
-
-       //duck_list_.clear();
-       bezier_list_.clear();
-       stroke_list_.clear();
-
-       if(show_persistent_strokes)
-               stroke_list_=persistent_stroke_list_;
-}
-
-//! Returns \a true if the given duck is currently selected
-bool
-Duckmatic::duck_is_selected(const etl::handle<Duck> &duck)const
-{
-       return duck && selected_ducks.count(duck->get_guid());
-}
-
-void
-Duckmatic::set_grid_size(const synfig::Vector &s)
-{
-       if(grid_size!=s)
-       {
-               grid_size=s;
-               signal_grid_changed();
-       }
-}
-
-void
-Duckmatic::set_grid_snap(bool x)
-{
-       if(grid_snap!=x)
-       {
-               grid_snap=x;
-               signal_grid_changed();
-       }
-}
-
-void
-Duckmatic::set_guide_snap(bool x)
-{
-       if(guide_snap!=x)
-       {
-               guide_snap=x;
-               signal_grid_changed();
-       }
-}
-
-Duckmatic::GuideList::iterator
-Duckmatic::find_guide_x(synfig::Point pos, float radius)
-{
-       GuideList::iterator iter,best(guide_list_x_.end());
-       float dist(radius);
-       for(iter=guide_list_x_.begin();iter!=guide_list_x_.end();++iter)
-       {
-               float amount(abs(*iter-pos[0]));
-               if(amount<dist)
-               {
-                       dist=amount;
-                       best=iter;
-               }
-       }
-       return best;
-}
-
-Duckmatic::GuideList::iterator
-Duckmatic::find_guide_y(synfig::Point pos, float radius)
-{
-       GuideList::iterator iter,best(guide_list_y_.end());
-       float dist(radius);
-       for(iter=guide_list_y_.begin();iter!=guide_list_y_.end();++iter)
-       {
-               float amount(abs(*iter-pos[1]));
-               if(amount<=dist)
-               {
-                       dist=amount;
-                       best=iter;
-               }
-       }
-       return best;
-}
-
-void
-Duckmatic::clear_selected_ducks()
-{
-       selected_ducks.clear();
-       signal_duck_selection_changed_();
-}
-
-etl::handle<Duckmatic::Duck>
-Duckmatic::get_selected_duck()const
-{
-       if(selected_ducks.empty() || duck_map.empty())
-               return 0;
-       return duck_map.find(*selected_ducks.begin())->second;
-}
-
-void
-Duckmatic::refresh_selected_ducks()
-{
-/*
-       std::set<etl::handle<Duck> >::iterator iter;
-       std::set<etl::handle<Duck> > new_set;
-       if(duck_list().empty())
-       {
-               selected_duck_list.clear();
-               signal_duck_selection_changed_();
-               return;
-       }
-
-       for(iter=selected_duck_list.begin();iter!=selected_duck_list.end();++iter)
-       {
-               etl::handle<Duck> similar(find_similar_duck(*iter));
-               if(similar)
-               {
-                       new_set.insert(similar);
-               }
-       }
-       selected_duck_list=new_set;
-*/
-       GUIDSet old_set(selected_ducks);
-       GUIDSet::const_iterator iter;
-
-       for(iter=old_set.begin();iter!=old_set.end();++iter)
-       {
-               if(duck_map.count(*iter)==0)
-                       selected_ducks.erase(*iter);
-       }
-
-       signal_duck_selection_changed_();
-}
-
-bool
-Duckmatic::is_duck_group_selectable(const etl::handle<Duck>& x)const
-{
-       const Type type(get_type_mask());
-
-       if (((x->get_type() && (!(type & x->get_type()))) ||
-                !x->get_editable()))
-               return false;
-
-       synfigapp::ValueDesc value_desc(x->get_value_desc());
-       if(value_desc.parent_is_layer_param() && type & Duck::TYPE_POSITION)
-       {
-               Layer::Handle layer(value_desc.get_layer());
-               String layer_name(layer->get_name());
-
-               if (layer_name == "outline" || layer_name == "region" || layer_name == "plant" ||
-                       layer_name == "polygon" || layer_name == "curve_gradient")
-                       return false;
-
-               if((layer_name=="PasteCanvas"|| layer_name=="paste_canvas") &&
-                  !layer->get_param("children_lock").get(bool()))
-                       return false;
-       }
-       else if (value_desc.parent_is_value_node())
-       {
-               if (ValueNode_BLineCalcVertex::Handle::cast_dynamic(value_desc.get_value_node()))
-                       return false;
-               if (value_desc.parent_is_linkable_value_node())
-               {
-                       LinkableValueNode::Handle parent_value_node(value_desc.get_parent_value_node());
-                       if (ValueNode_Composite::Handle::cast_dynamic(parent_value_node))
-                       {
-                               if (parent_value_node->get_type() == ValueBase::TYPE_BLINEPOINT &&
-                                       ValueNode_BLineCalcVertex::Handle::cast_dynamic(
-                                               parent_value_node->get_link("point")))
-                                       return false;
-                       }
-                       else if (ValueNode_BLine::Handle::cast_dynamic(parent_value_node))
-                       {
-                               ValueNode_Composite::Handle composite(ValueNode_Composite::Handle::cast_dynamic(
-                                                                                                                 value_desc.get_value_node()));
-                               if (composite &&
-                                       ValueNode_BLineCalcVertex::Handle::cast_dynamic(composite->get_link("point")))
-                                       return false;
-                       }
-               }
-       }
-       return true;
-}
-
-void
-Duckmatic::select_all_ducks()
-{
-       DuckMap::const_iterator iter;
-       for(iter=duck_map.begin();iter!=duck_map.end();++iter)
-               if(is_duck_group_selectable(iter->second))
-                       select_duck(iter->second);
-               else
-                       unselect_duck(iter->second);
-}
-
-void
-Duckmatic::unselect_all_ducks()
-{
-       DuckMap::const_iterator iter;
-       for(iter=duck_map.begin();iter!=duck_map.end();++iter)
-               unselect_duck(iter->second);
-}
-
-void
-Duckmatic::toggle_select_ducks_in_box(const synfig::Vector& tl,const synfig::Vector& br)
-{
-       Vector vmin, vmax;
-       vmin[0]=std::min(tl[0],br[0]);
-       vmin[1]=std::min(tl[1],br[1]);
-       vmax[0]=std::max(tl[0],br[0]);
-       vmax[1]=std::max(tl[1],br[1]);
-
-       DuckMap::const_iterator iter;
-       for(iter=duck_map.begin();iter!=duck_map.end();++iter)
-       {
-               Point p(iter->second->get_trans_point());
-               if(p[0]<=vmax[0] && p[0]>=vmin[0] && p[1]<=vmax[1] && p[1]>=vmin[1] &&
-                  is_duck_group_selectable(iter->second))
-                       toggle_select_duck(iter->second);
-       }
-}
-
-void
-Duckmatic::select_ducks_in_box(const synfig::Vector& tl,const synfig::Vector& br)
-{
-       Vector vmin, vmax;
-       vmin[0]=std::min(tl[0],br[0]);
-       vmin[1]=std::min(tl[1],br[1]);
-       vmax[0]=std::max(tl[0],br[0]);
-       vmax[1]=std::max(tl[1],br[1]);
-
-//     Type type(get_type_mask());
-
-       DuckMap::const_iterator iter;
-       for(iter=duck_map.begin();iter!=duck_map.end();++iter)
-       {
-               Point p(iter->second->get_trans_point());
-               if(p[0]<=vmax[0] && p[0]>=vmin[0] && p[1]<=vmax[1] && p[1]>=vmin[1])
-               {
-                       if(is_duck_group_selectable(iter->second))
-                               select_duck(iter->second);
-               }
-       }
-}
-
-int
-Duckmatic::count_selected_ducks()const
-{
-       return selected_ducks.size();
-}
-
-void
-Duckmatic::select_duck(const etl::handle<Duck> &duck)
-{
-       if(duck)
-       {
-               selected_ducks.insert(duck->get_guid());
-               signal_duck_selection_changed_();
-       }
-}
-
-DuckList
-Duckmatic::get_selected_ducks()const
-{
-       DuckList ret;
-       GUIDSet::const_iterator iter;
-       const Type type(get_type_mask());
-
-       for(iter=selected_ducks.begin();iter!=selected_ducks.end();++iter)
-       {
-               const DuckMap::const_iterator d_iter(duck_map.find(*iter));
-
-               if(d_iter==duck_map.end())
-                       continue;
-
-               if(( d_iter->second->get_type() && (!(type & d_iter->second->get_type())) ) )
-                       continue;
-
-               ret.push_back(d_iter->second);
-       }
-       return ret;
-}
-
-DuckList
-Duckmatic::get_duck_list()const
-{
-       DuckList ret;
-       DuckMap::const_iterator iter;
-       for(iter=duck_map.begin();iter!=duck_map.end();++iter) if (iter->second->get_type()&Duck::TYPE_POSITION) ret.push_back(iter->second);
-       for(iter=duck_map.begin();iter!=duck_map.end();++iter) if (iter->second->get_type()&Duck::TYPE_VERTEX  ) ret.push_back(iter->second);
-       for(iter=duck_map.begin();iter!=duck_map.end();++iter) if (iter->second->get_type()&Duck::TYPE_TANGENT ) ret.push_back(iter->second);
-       for(iter=duck_map.begin();iter!=duck_map.end();++iter)
-               if (!(iter->second->get_type()&Duck::TYPE_POSITION) &&
-                       !(iter->second->get_type()&Duck::TYPE_VERTEX) &&
-                       !(iter->second->get_type()&Duck::TYPE_TANGENT))
-                       ret.push_back(iter->second);
-       return ret;
-}
-
-void
-Duckmatic::unselect_duck(const etl::handle<Duck> &duck)
-{
-       if(duck && selected_ducks.count(duck->get_guid()))
-       {
-               selected_ducks.erase(duck->get_guid());
-               signal_duck_selection_changed_();
-       }
-}
-
-void
-Duckmatic::toggle_select_duck(const etl::handle<Duck> &duck)
-{
-       if(duck_is_selected(duck))
-               unselect_duck(duck);
-       else
-               select_duck(duck);
-}
-
-void
-Duckmatic::translate_selected_ducks(const synfig::Vector& vector)
-{
-       if(duck_dragger_)
-               duck_dragger_->duck_drag(this,vector);
-}
-
-void
-Duckmatic::start_duck_drag(const synfig::Vector& offset)
-{
-       if(duck_dragger_)
-               duck_dragger_->begin_duck_drag(this,offset);
-
-       //drag_offset_=offset;
-       drag_offset_=find_duck(offset)->get_trans_point();
-}
-
-void
-Duckmatic::update_ducks()
-{
-       Time time(get_time());
-       DuckList duck_list(get_duck_list());
-       const DuckList selected_ducks(get_selected_ducks());
-       DuckList::const_iterator iter;
-       for (iter=selected_ducks.begin(); iter!=selected_ducks.end(); ++iter)
-       {
-               etl::handle<Duck> duck(*iter);
-               if (duck->get_type() == Duck::TYPE_VERTEX || duck->get_type() == Duck::TYPE_POSITION)
-               {
-                       ValueNode_BLineCalcVertex::Handle bline_vertex;
-                       ValueNode_Composite::Handle composite;
-
-                       if ((bline_vertex = ValueNode_BLineCalcVertex::Handle::cast_dynamic(duck->get_value_desc().get_value_node())) ||
-                               ((composite = ValueNode_Composite::Handle::cast_dynamic(duck->get_value_desc().get_value_node())) &&
-                                composite->get_type() == ValueBase::TYPE_BLINEPOINT &&
-                                (bline_vertex = ValueNode_BLineCalcVertex::Handle::cast_dynamic(composite->get_link("point")))))
-                       {
-                               DuckList::iterator iter;
-                               for (iter=duck_list.begin(); iter!=duck_list.end(); iter++)
-                                       if ( (*iter)->get_origin_duck()==duck  /*&& !duck_is_selected(*iter)*/ )
-                                       {
-                                               synfig::Real radius = 0.0;
-                                               ValueNode_BLine::Handle bline(ValueNode_BLine::Handle::cast_dynamic(bline_vertex->get_link(bline_vertex->get_link_index_from_name("bline"))));
-                                               Real amount = synfig::find_closest_point((*bline)(time), duck->get_point(), radius, bline->get_loop());
-
-                                               int vertex_amount_index(bline_vertex->get_link_index_from_name("amount"));
-                                               ValueNode::Handle vertex_amount_value_node(bline_vertex->get_link(vertex_amount_index));
-
-
-                                               ValueNode::Handle duck_value_node((*iter)->get_value_desc().get_value_node());
-                                               if (ValueNode_BLineCalcTangent::Handle bline_tangent = ValueNode_BLineCalcTangent::Handle::cast_dynamic(duck_value_node))
-                                               {
-                                                       if (bline_tangent->get_link(bline_tangent->get_link_index_from_name("amount")) == vertex_amount_value_node)
-                                                       {
-                                                               switch (bline_tangent->get_type())
-                                                               {
-                                                               case ValueBase::TYPE_ANGLE:
-                                                               {
-                                                                       Angle angle((*bline_tangent)(time, amount).get(Angle()));
-                                                                       (*iter)->set_point(Point(Angle::cos(angle).get(), Angle::sin(angle).get()));
-                                                                       (*iter)->set_rotations(Angle::deg(0)); //hack: rotations are a relative value
-                                                                       break;
-                                                               }
-                                                               case ValueBase::TYPE_REAL:
-                                                                       (*iter)->set_point(Point((*bline_tangent)(time, amount).get(Real()), 0));
-                                                                       break;
-                                                               case ValueBase::TYPE_VECTOR:
-                                                                       (*iter)->set_point((*bline_tangent)(time, amount).get(Vector()));
-                                                                       break;
-                                                               default:
-                                                                       break;
-                                                               }
-                                                       }
-                                               }
-                                               else if (ValueNode_BLineCalcWidth::Handle bline_width = ValueNode_BLineCalcWidth::Handle::cast_dynamic(duck_value_node))
-                                               {
-                                                       if (bline_width->get_link(bline_width->get_link_index_from_name("amount")) == vertex_amount_value_node)
-                                                               (*iter)->set_point(Point((*bline_width)(time, amount).get(Real()), 0));
-                                               }
-                                       }
-                       }
-               }
-       }
-}
-
-
-bool
-Duckmatic::end_duck_drag()
-{
-       if(duck_dragger_)
-               return duck_dragger_->end_duck_drag(this);
-       return false;
-}
-
-Point
-Duckmatic::snap_point_to_grid(const synfig::Point& x, float radius)const
-{
-       Point ret(x);
-
-       GuideList::const_iterator guide_x,guide_y;
-       bool has_guide_x(false), has_guide_y(false);
-
-       guide_x=find_guide_x(ret,radius);
-       if(guide_x!=guide_list_x_.end())
-               has_guide_x=true;
-
-       guide_y=find_guide_y(ret,radius);
-       if(guide_y!=guide_list_y_.end())
-               has_guide_y=true;
-
-       if(get_grid_snap())
-       {
-               Point snap(
-                       floor(ret[0]/get_grid_size()[0]+0.5)*get_grid_size()[0],
-                       floor(ret[1]/get_grid_size()[1]+0.5)*get_grid_size()[1]);
-
-               if(abs(snap[0]-ret[0])<=radius && (!has_guide_x || abs(snap[0]-ret[0])<=abs(*guide_x-ret[0])))
-                       ret[0]=snap[0],has_guide_x=false;
-               if(abs(snap[1]-ret[1])<=radius && (!has_guide_y || abs(snap[1]-ret[1])<=abs(*guide_y-ret[1])))
-                       ret[1]=snap[1],has_guide_y=false;
-       }
-
-       if(guide_snap)
-       {
-               if(has_guide_x)
-                       ret[0]=*guide_x;
-               if(has_guide_y)
-                       ret[1]=*guide_y;
-       }
-
-       if(axis_lock)
-       {
-               ret-=drag_offset_;
-               if(abs(ret[0])<abs(ret[1]))
-                       ret[0]=0;
-               else
-                       ret[1]=0;
-               ret+=drag_offset_;
-       }
-
-       return ret;
-}
-
-void
-DuckDrag_Translate::begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& offset)
-{
-       last_translate_=Vector(0,0);
-       {
-               drag_offset_=duckmatic->find_duck(offset)->get_trans_point();
-
-               snap=Vector(0,0);
-       }
-
-       const DuckList selected_ducks(duckmatic->get_selected_ducks());
-       DuckList::const_iterator iter;
-
-       positions.clear();
-       for(iter=selected_ducks.begin();iter!=selected_ducks.end();++iter)
-       {
-               Point p((*iter)->get_trans_point());
-               positions.push_back(p);
-       }
-}
-
-bool
-DuckDrag_Translate::end_duck_drag(Duckmatic* duckmatic)
-{
-       if(last_translate_.mag()>0.0001)
-       {
-               duckmatic->signal_edited_selected_ducks();
-               return true;
-       }
-       else
-       {
-               duckmatic->signal_user_click_selected_ducks(0);
-               return false;
-       }
-}
-
-void
-DuckDrag_Translate::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector)
-{
-       const DuckList selected_ducks(duckmatic->get_selected_ducks());
-       DuckList::const_iterator iter;
-
-       synfig::Vector vect(duckmatic->snap_point_to_grid(vector)-drag_offset_);
-       int i;
-       Time time(duckmatic->get_time());
-
-       // drag the vertex and position ducks first
-       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)
-                       (*iter)->set_trans_point(positions[i]+vect, time);
-
-       // then drag the others
-       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)
-                       (*iter)->set_trans_point(positions[i]+vect, time);
-
-       // then patch up the tangents for the vertices we've moved
-       duckmatic->update_ducks();
-
-       last_translate_=vect;
-}
-
-void
-Duckmatic::signal_edited_selected_ducks()
-{
-       const DuckList ducks(get_selected_ducks());
-       DuckList::const_iterator iter;
-
-       synfig::GUIDSet old_set(selected_ducks);
-
-       // If we have more than 20 things to move, then display
-       // something to explain that it may take a moment
-       smart_ptr<OneMoment> wait; if(ducks.size()>20)wait.spawn();
-
-       // Go ahead and call everyone's signals
-       for(iter=ducks.begin();iter!=ducks.end();++iter)
-       {
-               if ((*iter)->get_type() == Duck::TYPE_ANGLE)
-               {
-                       if(!(*iter)->signal_edited_angle()((*iter)->get_rotations()))
-                       {
-                               selected_ducks=old_set;
-                               throw String("Bad edit");
-                       }
-               }
-               else if (App::restrict_radius_ducks &&
-                                (*iter)->is_radius())
-               {
-                       Point point((*iter)->get_point());
-                       bool changed = false;
-
-                       if (point[0] < 0)
-                       {
-                               point[0] = 0;
-                               changed = true;
-                       }
-                       if (point[1] < 0)
-                       {
-                               point[1] = 0;
-                               changed = true;
-                       }
-
-                       if (changed) (*iter)->set_point(point);
-
-                       if(!(*iter)->signal_edited()(point))
-                       {
-                               selected_ducks=old_set;
-                               throw String("Bad edit");
-                       }
-               }
-               else
-               {
-                       if(!(*iter)->signal_edited()((*iter)->get_point()))
-                       {
-                               selected_ducks=old_set;
-                               throw String("Bad edit");
-                       }
-               }
-       }
-       selected_ducks=old_set;
-}
-
-void
-Duckmatic::signal_user_click_selected_ducks(int button)
-{
-       const DuckList ducks(get_selected_ducks());
-       DuckList::const_iterator iter;
-
-       for(iter=ducks.begin();iter!=ducks.end();++iter)
-       {
-               (*iter)->signal_user_click(button)();
-       }
-}
-
-void
-Duckmatic::add_duck(const etl::handle<Duck> &duck)
-{
-       //if(!duck_map.count(duck->get_guid()))
-       {
-               if(duck_data_share_map.count(duck->get_data_guid()))
-               {
-                       duck->set_shared_point(duck_data_share_map[duck->get_data_guid()]);
-               }
-               else
-               {
-                       etl::smart_ptr<synfig::Point> point(new Point(duck->get_point()));
-                       duck->set_shared_point(point);
-                       duck_data_share_map[duck->get_data_guid()]=point;
-               }
-
-               duck_map.insert(duck);
-       }
-
-       last_duck_guid=duck->get_guid();
-}
-
-void
-Duckmatic::add_bezier(const etl::handle<Bezier> &bezier)
-{
-       bezier_list_.push_back(bezier);
-}
-
-void
-Duckmatic::add_stroke(etl::smart_ptr<std::list<synfig::Point> > stroke_point_list, const synfig::Color& color)
-{
-       assert(stroke_point_list);
-
-       std::list<etl::handle<Stroke> >::iterator iter;
-
-       for(iter=stroke_list_.begin();iter!=stroke_list_.end();++iter)
-       {
-               if((*iter)->stroke_data==stroke_point_list)
-                       return;
-       }
-
-       etl::handle<Stroke> stroke(new Stroke());
-
-       stroke->stroke_data=stroke_point_list;
-       stroke->color=color;
-
-       stroke_list_.push_back(stroke);
-}
-
-void
-Duckmatic::add_persistent_stroke(etl::smart_ptr<std::list<synfig::Point> > stroke_point_list, const synfig::Color& color)
-{
-       add_stroke(stroke_point_list,color);
-       persistent_stroke_list_.push_back(stroke_list_.back());
-}
-
-void
-Duckmatic::clear_persistent_strokes()
-{
-       persistent_stroke_list_.clear();
-}
-
-void
-Duckmatic::set_show_persistent_strokes(bool x)
-{
-       if(x!=show_persistent_strokes)
-       {
-               show_persistent_strokes=x;
-               if(x)
-                       stroke_list_=persistent_stroke_list_;
-               else
-                       stroke_list_.clear();
-       }
-}
-
-void
-Duckmatic::erase_duck(const etl::handle<Duck> &duck)
-{
-       duck_map.erase(duck->get_guid());
-}
-
-etl::handle<Duckmatic::Duck>
-Duckmatic::find_similar_duck(etl::handle<Duck> duck)
-{
-       DuckMap::const_iterator iter(duck_map.find(duck->get_guid()));
-       if(iter!=duck_map.end())
-               return iter->second;
-       return 0;
-
-/*     std::list<handle<Duck> >::reverse_iterator iter;
-
-       for(iter=duck_list_.rbegin();iter!=duck_list_.rend();++iter)
-       {
-               if(*iter!=duck && **iter==*duck)
-               {
-                       //synfig::info("Found similar duck! (iter:%08x vs. duck:%08x)",iter->get(), duck.get());
-                       return *iter;
-               }
-       }
-       return 0;
-*/
-}
-
-etl::handle<Duckmatic::Duck>
-Duckmatic::add_similar_duck(etl::handle<Duck> duck)
-{
-       etl::handle<Duck> similar(find_similar_duck(duck));
-       if(!similar)
-       {
-               add_duck(duck);
-               return duck;
-       }
-       return similar;
-}
-
-void
-Duckmatic::erase_bezier(const etl::handle<Bezier> &bezier)
-{
-       std::list<handle<Bezier> >::iterator iter;
-
-       for(iter=bezier_list_.begin();iter!=bezier_list_.end();++iter)
-       {
-               if(*iter==bezier)
-               {
-                       bezier_list_.erase(iter);
-                       return;
-               }
-       }
-       synfig::warning("Unable to find bezier to erase!");
-}
-
-etl::handle<Duckmatic::Duck>
-Duckmatic::last_duck()const
-{
-       DuckMap::const_iterator iter(duck_map.find(last_duck_guid));
-       if(iter!=duck_map.end())
-               return iter->second;
-       return 0;
-}
-
-etl::handle<Duckmatic::Bezier>
-Duckmatic::last_bezier()const
-{
-       return bezier_list_.back();
-}
-
-etl::handle<Duckmatic::Duck>
-Duckmatic::find_duck(synfig::Point point, synfig::Real radius, Duck::Type type)
-{
-       if(radius==0)radius=10000000;
-
-       if(type==Duck::TYPE_DEFAULT)
-               type=get_type_mask();
-
-       Real closest(10000000);
-       etl::handle<Duck> ret;
-
-       DuckMap::const_iterator iter;
-
-       for(iter=duck_map.begin();iter!=duck_map.end();++iter)
-       {
-               const Duck::Handle& duck(iter->second);
-
-               if(duck->get_ignore() ||
-                  (duck->get_type() && !(type & duck->get_type())))
-                       continue;
-
-               Real dist((duck->get_trans_point()-point).mag_squared());
-
-               if(duck->get_type()&Duck::TYPE_VERTEX)
-                       dist*=1.0001;
-               else if(duck->get_type()&Duck::TYPE_TANGENT && duck->get_scalar()>0)
-                       dist*=1.00005;
-               else if(duck->get_type()&Duck::TYPE_RADIUS)
-                       dist*=0.9999;
-
-               if(dist<=closest)
-               {
-                       closest=dist;
-                       ret=duck;
-               }
-       }
-
-       if(radius==0 || closest<radius*radius)
-               return ret;
-
-       return 0;
-}
-
-etl::handle<Duckmatic::Bezier>
-Duckmatic::find_bezier(synfig::Point point, synfig::Real radius,float* location)
-{
-       return find_bezier(point,radius,radius,location);
-}
-
-etl::handle<Duckmatic::Bezier>
-Duckmatic::find_bezier(synfig::Point pos, synfig::Real scale, synfig::Real radius, float* location)
-{
-       if(radius==0)radius=10000000;
-       Real closest(10000000);
-       etl::handle<Bezier> ret;
-
-       bezier<Point>   curve;
-
-       Real    d,step;
-       float   time = 0;
-       float   best_time = 0;
-
-       for(std::list<handle<Bezier> >::const_iterator iter=bezier_list().begin();iter!=bezier_list().end();++iter)
-       {
-               curve[0] = (*iter)->p1->get_trans_point();
-               curve[1] = (*iter)->c1->get_trans_point();
-               curve[2] = (*iter)->c2->get_trans_point();
-               curve[3] = (*iter)->p2->get_trans_point();
-               curve.sync();
-
-#if 0
-               // I don't know why this doesn't work
-               time=curve.find_closest(pos,6);
-               d=((curve(time)-pos).mag_squared());
-
-#else
-               //set the step size based on the size of the picture
-               d = (curve[1] - curve[0]).mag() + (curve[2]-curve[1]).mag()     + (curve[3]-curve[2]).mag();
-
-               step = d/(2*scale); //want to make the distance between lines happy
-
-               step = max(step,0.01); //100 samples should be plenty
-               step = min(step,0.1); //10 is minimum
-
-               d = find_closest(curve,pos,step,&closest,&time);
-#endif
-
-               if(d < closest)
-               {
-                       closest = d;
-                       ret = *iter;
-                       best_time=time;
-               }
-       }
-
-       if(closest < radius*radius)
-       {
-               if(location)
-                       *location = best_time;  // We need to square-root this because we were dealing with squared distances
-
-               return ret;
-       }
-
-       return 0;
-}
-
-bool
-Duckmatic::save_sketch(const synfig::String& filename)const
-{
-       ChangeLocale change_locale(LC_NUMERIC, "C");
-       std::ofstream file(filename.c_str());
-
-       if(!file)return false;
-
-       file<<"SKETCH"<<endl;
-
-       std::list<etl::handle<Stroke> >::const_iterator iter;
-
-       for(iter=persistent_stroke_list_.begin();iter!=persistent_stroke_list_.end();++iter)
-       {
-               file<<"C "
-                       <<(*iter)->color.get_r()<<' '
-                       <<(*iter)->color.get_g()<<' '
-                       <<(*iter)->color.get_b()
-               <<endl;
-               std::list<synfig::Point>::const_iterator viter;
-               for(viter=(*iter)->stroke_data->begin();viter!=(*iter)->stroke_data->end();++viter)
-               {
-                       file<<"V "
-                               <<(*viter)[0]<<' '
-                               <<(*viter)[1]
-                       <<endl;
-               }
-       }
-       if(!file)return false;
-       sketch_filename_=filename;
-       signal_sketch_saved_();
-       return true;
-}
-
-bool
-Duckmatic::load_sketch(const synfig::String& filename)
-{
-       ChangeLocale change_locale(LC_NUMERIC, "C");
-       std::ifstream file(filename.c_str());
-
-       if(!file)
-               return false;
-
-       std::string line;
-       getline(file,line);
-
-       if(line!="SKETCH")
-       {
-               synfig::error("Not a sketch");
-               return false;
-       }
-
-       etl::smart_ptr<std::list<synfig::Point> > stroke_data;
-
-       while(file)
-       {
-               getline(file,line);
-
-               if(line.empty())
-                       continue;
-
-               switch(line[0])
-               {
-               case 'C':
-               case 'c':
-                       {
-                               stroke_data.spawn();
-                               float r,g,b;
-                               if(!strscanf(line,"C %f %f %f",&r, &g, &b))
-                               {
-                                       synfig::warning("Bad color line \"%s\"",line.c_str());
-                                       r=0;g=0;b=0;
-                               }
-                               add_persistent_stroke(stroke_data, synfig::Color(r,g,b));
-                       }
-                       break;
-               case 'V':
-               case 'v':
-                       if(!stroke_data)
-                       {
-                               stroke_data.spawn();
-                               add_persistent_stroke(stroke_data, synfig::Color(0,0,0));
-                       }
-                       float x,y;
-                       if(!strscanf(line,"V %f %f",&x, &y))
-                               synfig::warning("Bad vertex \"%s\"",line.c_str());
-                       else
-                               stroke_data->push_back(synfig::Vector(x,y));
-                       break;
-               default:
-                       synfig::warning("Unexpected sketch token '%c'",line[0]);
-                       break;
-               }
-       }
-
-       sketch_filename_=filename;
-       return true;
-}
-
-Duckmatic::Push::Push(Duckmatic *duckmatic_):
-       duckmatic_(duckmatic_)
-{
-       duck_map=duckmatic_->duck_map;
-       bezier_list_=duckmatic_->bezier_list_;
-       duck_data_share_map=duckmatic_->duck_data_share_map;
-       stroke_list_=duckmatic_->stroke_list_;
-       duck_dragger_=duckmatic_->duck_dragger_;
-       needs_restore=true;
-}
-
-Duckmatic::Push::~Push()
-{
-       if(needs_restore)
-               restore();
-}
-
-void
-Duckmatic::Push::restore()
-{
-       duckmatic_->duck_map=duck_map;
-       duckmatic_->bezier_list_=bezier_list_;
-       duckmatic_->duck_data_share_map=duck_data_share_map;
-       duckmatic_->stroke_list_=stroke_list_;
-       duckmatic_->duck_dragger_=duck_dragger_;
-       needs_restore=false;
-}
-
-inline String guid_string(const synfigapp::ValueDesc& x)
-{
-       if(x.parent_is_layer_param())
-               return strprintf("%s",x.get_layer()->get_guid().get_string().c_str())+x.get_param_name();
-       //if(x.is_value_node())
-               return strprintf("%s",x.get_value_node()->get_guid().get_string().c_str());
-}
-
-inline synfig::GUID calc_duck_guid(const synfigapp::ValueDesc& x,const synfig::TransformStack& transform_stack)
-{
-       synfig::GUID ret(0);
-
-       if(x.parent_is_layer_param())
-       {
-               ret=x.get_layer()->get_guid()^synfig::GUID::hasher(x.get_param_name());
-       }
-       else
-       {
-               ret=x.get_value_node()->get_guid();
-       }
-
-       ret^=transform_stack.get_guid();
-       return ret;
-}
-
-/*
-Duck::Handle
-Duckmatic::create_duck_from(const synfigapp::ValueDesc& value_desc,etl::handle<CanvasView> canvas_view, const synfig::TransformStack& transform_stack, int modifier, synfig::ParamDesc *param_desc)
-{
-       synfig::GUID duck_guid(calc_duck_guid(value_desc,transform_stack)^synfig::GUID::hasher(modifier));
-       etl::handle<Duck> duck=new Duck();
-
-       return duck;
-}
-*/
-
-bool
-Duckmatic::add_to_ducks(const synfigapp::ValueDesc& value_desc,etl::handle<CanvasView> canvas_view, const synfig::TransformStack& transform_stack, synfig::ParamDesc *param_desc, int multiple)
-{
-       ValueBase::Type type=value_desc.get_value_type();
-#define REAL_COOKIE            reinterpret_cast<synfig::ParamDesc*>(28)
-       switch(type)
-       {
-       case ValueBase::TYPE_REAL:
-
-               if(!param_desc || param_desc==REAL_COOKIE || !param_desc->get_origin().empty())
-               {
-                       etl::handle<Duck> duck=new Duck();
-                       duck->set_transform_stack(transform_stack);
-                       duck->set_radius(true);
-                       duck->set_type(Duck::TYPE_RADIUS);
-
-                       // put the duck on the right hand side of the center
-                       duck->set_point(Point(value_desc.get_value(get_time()).get(Real()), 0));
-                       duck->set_name(guid_string(value_desc));
-                       if(value_desc.is_value_node())
-                       {
-                               // If the ValueNode can be directly manipulated,
-                               // then set it as so.
-                               duck->set_editable(synfigapp::is_editable(value_desc.get_value_node()));
-                       }
-                       else
-                       {
-                               duck->set_editable(true);
-                       }
-
-                       if(param_desc && param_desc!=REAL_COOKIE)
-                       {
-                               if(!param_desc->get_origin().empty())
-                               {
-                                       synfigapp::ValueDesc value_desc_origin(value_desc.get_layer(),param_desc->get_origin());
-                                       /*
-                                       duck->set_origin(value_desc_origin.get_value(get_time()).get(synfig::Point()));
-                                       */
-                                       add_to_ducks(value_desc_origin,canvas_view, transform_stack);
-                                       duck->set_origin(last_duck());
-                               }
-                               duck->set_scalar(param_desc->get_scalar());
-                       }
-
-                       duck->signal_edited().clear(); // value_desc.get_value_type() == ValueBase::TYPE_REAL:
-                       duck->signal_edited().connect(
-                               sigc::bind(
-                                       sigc::mem_fun(
-                                               *canvas_view,
-                                               &studio::CanvasView::on_duck_changed),
-                                       value_desc));
-                       duck->set_value_desc(value_desc);
-
-                       duck->signal_user_click(2).connect(
-                               sigc::bind(
-                                       sigc::bind(
-                                               sigc::bind(
-                                                       sigc::mem_fun(
-                                                               *canvas_view,
-                                                               &studio::CanvasView::popup_param_menu),
-                                                       false),
-                                               0.0f),
-                                       value_desc));
-
-                       duck->set_guid(calc_duck_guid(value_desc,transform_stack)^synfig::GUID::hasher(multiple));
-
-                       add_duck(duck);
-
-                       return true;
-               }
-               break;
-
-       case ValueBase::TYPE_ANGLE:
-
-               if(!param_desc || param_desc==REAL_COOKIE || !param_desc->get_origin().empty())
-               {
-                       etl::handle<Duck> duck=new Duck();
-                       duck->set_type(Duck::TYPE_ANGLE);
-                       duck->set_transform_stack(transform_stack);
-                       synfig::Angle angle;
-
-                       angle=value_desc.get_value(get_time()).get(Angle());
-                       duck->set_point(Point(Angle::cos(angle).get(),Angle::sin(angle).get()));
-                       duck->set_name(guid_string(value_desc));
-                       if(value_desc.is_value_node())
-                       {
-                               ValueNode::Handle value_node=value_desc.get_value_node();
-                               //duck->set_name(strprintf("%x",value_node.get()));
-
-                               // If the ValueNode can be directly manipulated,
-                               // then set it as so.
-                               duck->set_editable(synfigapp::is_editable(value_desc.get_value_node()));
-                       }
-                       else
-                       {
-                               //angle=(value_desc.get_value().get(Angle()));
-                               //duck->set_point(Point(Angle::cos(angle).get(),Angle::sin(angle).get()));
-                               //duck->set_name(strprintf("%x",value_desc.get_layer().get())+value_desc.get_param_name());
-                               duck->set_editable(true);
-                       }
-
-                       if(param_desc && param_desc!=REAL_COOKIE)
-                       {
-                               if(!param_desc->get_origin().empty())
-                               {
-                                       synfigapp::ValueDesc value_desc_origin(value_desc.get_layer(),param_desc->get_origin());
-                                       /*
-                                       duck->set_origin(value_desc_origin.get_value(get_time()).get(synfig::Point()));
-                                       */
-                                       add_to_ducks(value_desc_origin,canvas_view, transform_stack);
-                                       duck->set_origin(last_duck());
-                               }
-                               duck->set_scalar(param_desc->get_scalar());
-                       }
-
-                       duck->signal_edited().clear(); // value_desc.get_value_type() == ValueBase::TYPE_ANGLE:
-                       duck->signal_edited_angle().clear();
-                       duck->signal_edited_angle().connect(
-                               sigc::bind(
-                                       sigc::mem_fun(
-                                               *canvas_view,
-                                               &studio::CanvasView::on_duck_angle_changed),
-                                       value_desc));
-                       duck->set_value_desc(value_desc);
-
-                       duck->signal_user_click(2).connect(
-                               sigc::bind(
-                                       sigc::bind(
-                                               sigc::bind(
-                                                       sigc::mem_fun(
-                                                               *canvas_view,
-                                                               &studio::CanvasView::popup_param_menu),
-                                                       false),
-                                               0.0f),
-                                       value_desc));
-                       duck->set_guid(calc_duck_guid(value_desc,transform_stack)^synfig::GUID::hasher(multiple));
-
-                       add_duck(duck);
-
-                       return true;
-               }
-               break;
-
-       case ValueBase::TYPE_VECTOR:
-               {
-                       etl::handle<Duck> duck=new Duck();
-                       duck->set_transform_stack(transform_stack);
-
-                       duck->set_point(value_desc.get_value(get_time()).get(Point()));
-                       duck->set_name(guid_string(value_desc));
-                       if(value_desc.is_value_node())
-                       {
-                               //duck->set_name(strprintf("%x",value_desc.get_value_node().get()));
-
-                               // If the ValueNode can be directly manipulated,
-                               // then set it as so.
-                               duck->set_editable(synfigapp::is_editable(value_desc.get_value_node()));
-                       }
-                       else
-                       {
-                               //duck->set_point(value_desc.get_value().get(Point()));
-                               //duck->set_name(strprintf("%x",value_desc.get_layer().get())+value_desc.get_param_name());
-                               duck->set_editable(true);
-                       }
-
-                       // If we were passed a parameter description
-                       if(param_desc)
-                       {
-                               if(!param_desc->get_connect().empty())
-                               {
-                                       synfigapp::ValueDesc value_desc_origin(value_desc.get_layer(),param_desc->get_connect());
-                                       Duck::Handle connect_duck;
-                                       if(duck_map.find(calc_duck_guid(value_desc_origin,transform_stack)^synfig::GUID::hasher(0))!=duck_map.end())
-                                       {
-                                               connect_duck=duck_map[calc_duck_guid(value_desc_origin,transform_stack)^synfig::GUID::hasher(0)];
-                                       }
-                                       else
-                                       {
-                                               add_to_ducks(value_desc_origin,canvas_view, transform_stack);
-                                               connect_duck=last_duck();
-                                       }
-                                       duck->set_connect_duck(connect_duck);
-                               }
-                               if(!param_desc->get_box().empty())
-                               {
-                                       synfigapp::ValueDesc value_desc_origin(value_desc.get_layer(),param_desc->get_box());
-                                       add_to_ducks(value_desc_origin,canvas_view, transform_stack);
-                                       duck->set_box_duck(last_duck());
-                               }
-
-                               // If we have an origin
-                               if(!param_desc->get_origin().empty())
-                               {
-                                       synfigapp::ValueDesc value_desc_origin(value_desc.get_layer(),param_desc->get_origin());
-                                       /*
-                                       duck->set_origin(value_desc_origin.get_value(get_time()).get(synfig::Point()));
-                                       */
-                                       add_to_ducks(value_desc_origin,canvas_view, transform_stack);
-                                       duck->set_origin(last_duck());
-                                       duck->set_type(Duck::TYPE_VERTEX);
-                               }
-                               else
-                                       duck->set_type(Duck::TYPE_POSITION);
-
-                               duck->set_scalar(param_desc->get_scalar());
-                       }
-                       else
-                               duck->set_type(Duck::TYPE_POSITION);
-
-                       duck->signal_edited().clear(); // value_desc.get_value_type() == ValueBase::TYPE_VECTOR:
-                       duck->signal_edited().connect(
-                               sigc::bind(
-                                       sigc::mem_fun(
-                                               *canvas_view,
-                                               &studio::CanvasView::on_duck_changed),
-                                       value_desc));
-                       duck->set_value_desc(value_desc);
-
-                       duck->signal_user_click(2).connect(
-                               sigc::bind(
-                                       sigc::bind(
-                                               sigc::bind(
-                                                       sigc::mem_fun(
-                                                               *canvas_view,
-                                                               &studio::CanvasView::popup_param_menu),
-                                                       false),
-                                               1.0f),
-                                       value_desc));
-                       duck->set_guid(calc_duck_guid(value_desc,transform_stack)^synfig::GUID::hasher(multiple));
-                       add_duck(duck);
-
-                       return true;
-               }
-               break;
-       case ValueBase::TYPE_SEGMENT:
-               {
-                       etl::handle<Bezier> bezier(new Bezier());
-                       ValueNode_Composite::Handle value_node;
-
-                       if(value_desc.is_value_node() &&
-                               (value_node=ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node())))
-                       {
-                               if(!add_to_ducks(synfigapp::ValueDesc(value_node,0),canvas_view,transform_stack))
-                                       return false;
-                               bezier->p1=last_duck();
-                               bezier->p1->set_type(Duck::TYPE_VERTEX);
-                               if(!add_to_ducks(synfigapp::ValueDesc(value_node,1),canvas_view,transform_stack))
-                                       return false;
-                               bezier->c1=last_duck();
-                               bezier->c1->set_type(Duck::TYPE_TANGENT);
-                               bezier->c1->set_origin(bezier->p1);
-                               bezier->c1->set_scalar(TANGENT_BEZIER_SCALE);
-                               bezier->c1->set_tangent(true);
-
-                               if(!add_to_ducks(synfigapp::ValueDesc(value_node,2),canvas_view,transform_stack))
-                                       return false;
-                               bezier->p2=last_duck();
-                               bezier->p2->set_type(Duck::TYPE_VERTEX);
-                               if(!add_to_ducks(synfigapp::ValueDesc(value_node,3),canvas_view,transform_stack))
-                                       return false;
-                               bezier->c2=last_duck();
-                               bezier->c2->set_type(Duck::TYPE_TANGENT);
-                               bezier->c2->set_origin(bezier->p2);
-                               bezier->c2->set_scalar(-TANGENT_BEZIER_SCALE);
-                               bezier->c2->set_tangent(true);
-
-                               bezier->signal_user_click(2).connect(
-                                       sigc::bind(
-                                               sigc::mem_fun(
-                                                       *canvas_view,
-                                                       &studio::CanvasView::popup_param_menu_bezier),
-                                               value_desc));
-
-                               add_bezier(bezier);
-                       }
-                       else if(value_desc.get_value().is_valid())
-                       {
-                               Segment segment=value_desc.get_value();
-                               etl::handle<Duck> duck_p,duck_c;
-                               synfig::String name;
-                               if(param_desc)
-                               {
-                                       name=param_desc->get_local_name();
-                               }
-                               else
-                               {
-                                       name=guid_string(value_desc);
-                               }
-
-                               duck_p=new Duck(segment.p1);
-                               duck_p->set_name(name+".P1");
-                               duck_p->set_type(Duck::TYPE_VERTEX);
-                               add_duck(duck_p);
-
-                               duck_c=new Duck(segment.t1);
-                               duck_c->set_name(name+".T1");
-                               duck_c->set_type(Duck::TYPE_TANGENT);
-                               add_duck(duck_c);
-                               duck_c->set_origin(duck_p);
-                               duck_c->set_scalar(TANGENT_HANDLE_SCALE);
-                               duck_c->set_tangent(true);
-
-                               bezier->p1=duck_p;
-                               bezier->c1=duck_c;
-
-                               duck_p=new Duck(segment.p2);
-                               duck_p->set_name(name+".P2");
-                               duck_p->set_type(Duck::TYPE_VERTEX);
-                               add_duck(duck_p);
-
-                               duck_c=new Duck(segment.t2);
-                               duck_c->set_type(Duck::TYPE_TANGENT);
-                               duck_c->set_name(name+".T2");
-                               add_duck(duck_c);
-                               duck_c->set_origin(duck_p);
-                               duck_c->set_scalar(-TANGENT_HANDLE_SCALE);
-                               duck_c->set_tangent(true);
-
-                               bezier->p2=duck_p;
-                               bezier->c2=duck_c;
-                               add_bezier(bezier);
-                       }
-
-                       return true;
-               }
-               break;
-       case ValueBase::TYPE_BLINEPOINT:
-       {
-
-               if(value_desc.is_value_node() &&
-                       ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node()))
-               {
-                       ValueNode_Composite::Handle value_node;
-                       value_node=ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node());
-
-                       if(!add_to_ducks(synfigapp::ValueDesc(value_node,0),canvas_view,transform_stack))
-                               return false;
-                       etl::handle<Duck> vertex_duck(last_duck());
-                       vertex_duck->set_type(Duck::TYPE_VERTEX);
-                       if(!add_to_ducks(synfigapp::ValueDesc(value_node,4),canvas_view,transform_stack))
-                               return false;
-                       etl::handle<Duck> t1_duck(last_duck());
-
-                       t1_duck->set_origin(vertex_duck);
-                       t1_duck->set_scalar(-TANGENT_HANDLE_SCALE);
-                       t1_duck->set_tangent(true);
-
-                       etl::handle<Duck> t2_duck;
-
-                       // If the tangents are split
-                       if((*value_node->get_link("split"))(get_time()).get(bool()))
-                       {
-                               if(!add_to_ducks(synfigapp::ValueDesc(value_node,5),canvas_view,transform_stack))
-                                       return false;
-                               t2_duck=last_duck();
-                               t2_duck->set_origin(vertex_duck);
-                               t2_duck->set_scalar(TANGENT_HANDLE_SCALE);
-                               t2_duck->set_tangent(true);
-                       }
-                       else
-                       {
-                               if(!add_to_ducks(synfigapp::ValueDesc(value_node,4),canvas_view,transform_stack))
-                                       return false;
-                               t2_duck=last_duck();
-                               t2_duck->set_origin(vertex_duck);
-                               t2_duck->set_scalar(TANGENT_HANDLE_SCALE);
-                               t2_duck->set_tangent(true);
-                       }
-                       return true;
-               }
-
-       }
-       break;
-       case ValueBase::TYPE_LIST:
-       {
-               // Check for BLine
-               if (value_desc.is_value_node() &&
-                       ValueNode_BLine::Handle::cast_dynamic(value_desc.get_value_node()))
-               {
-                       ValueNode_BLine::Handle value_node;
-                       value_node=ValueNode_BLine::Handle::cast_dynamic(value_desc.get_value_node());
-
-                       int i,first=-1;
-
-                       etl::handle<Bezier> bezier;
-                       etl::handle<Duck> first_duck;
-                       etl::handle<Duck> duck, tduck;
-
-                       for (i = 0; i < value_node->link_count(); i++)
-                       {
-                               float amount(value_node->list[i].amount_at_time(get_time()));
-
-                               // skip vertices that aren't fully on
-                               if (amount < 0.9999f)
-                                       continue;
-
-                               // remember the index of the first vertex we didn't skip
-                               if (first == -1)
-                                       first = i;
-
-                               BLinePoint bline_point((*value_node->get_link(i))(get_time()));
-
-                               // try casting the vertex to Composite - this tells us whether it is composite or not
-                               ValueNode_Composite::Handle composite_vertex_value_node(
-                                       ValueNode_Composite::Handle::cast_dynamic(value_node->get_link(i)));
-
-                               // add the vertex duck - it's a composite
-                               if(composite_vertex_value_node)
-                               {
-                                       if (add_to_ducks(synfigapp::ValueDesc(composite_vertex_value_node,0),canvas_view,transform_stack))
-                                       {
-                                               duck=last_duck();
-                                               if(i==first)
-                                                       first_duck=duck;
-                                               duck->set_type(Duck::TYPE_VERTEX);
-
-                                               duck->signal_user_click(2).clear();
-                                               duck->signal_user_click(2).connect(
-                                                       sigc::bind(
-                                                               sigc::bind(
-                                                                       sigc::bind(
-                                                                               sigc::mem_fun(
-                                                                                       *canvas_view,
-                                                                                       &studio::CanvasView::popup_param_menu),
-                                                                               false),
-                                                                       1.0f),
-                                                               synfigapp::ValueDesc(value_node,i)));
-                                               duck->set_value_desc(synfigapp::ValueDesc(value_node,i));
-
-                                               if(param_desc)
-                                               {
-                                                       if(!param_desc->get_origin().empty())
-                                                       {
-                                                               synfigapp::ValueDesc value_desc_origin(value_desc.get_layer(),param_desc->get_origin());
-                                                               add_to_ducks(value_desc_origin,canvas_view, transform_stack);
-                                                               duck->set_origin(last_duck());
-/*
-                                                               ValueBase value(synfigapp::ValueDesc(value_desc.get_layer(),param_desc->get_origin()).get_value(get_time()));
-                                                               if(value.same_type_as(synfig::Point()))
-                                                                       duck->set_origin(value.get(synfig::Point()));
-*/
-                                                       }
-                                               }
-                                       }
-                                       else
-                                               return false;
-                               }
-                               // else it's not a composite
-                               else
-                               {
-                                       duck=new Duck(bline_point.get_vertex());
-                                       if(i==first)
-                                               first_duck=duck;
-                                       duck->set_transform_stack(transform_stack);
-                                       duck->set_editable(false);
-                                       //duck->set_name(strprintf("%x-vertex",value_node->get_link(i).get()));
-                                       duck->set_name(guid_string(synfigapp::ValueDesc(value_node,i))+".v");
-
-                                       duck->set_type(Duck::TYPE_VERTEX);
-                                       if(param_desc)
-                                       {
-                                               if(!param_desc->get_origin().empty())
-                                               {
-                                                       synfigapp::ValueDesc value_desc_origin(value_desc.get_layer(),param_desc->get_origin());
-                                                       add_to_ducks(value_desc_origin,canvas_view, transform_stack);
-                                                       duck->set_origin(last_duck());
-/*
-                                                       ValueBase value(synfigapp::ValueDesc(value_desc.get_layer(),param_desc->get_origin()).get_value(get_time()));
-                                                       if(value.same_type_as(synfig::Point()))
-                                                               duck->set_origin(value.get(synfig::Point()));
-*/
-                                               }
-                                       }
-                                       duck->set_guid(calc_duck_guid(synfigapp::ValueDesc(value_node,i),transform_stack)^synfig::GUID::hasher(".v"));
-                                       duck=add_similar_duck(duck);
-//                                     add_duck(duck);
-                               }
-
-                               // Add the width duck if it is a parameter with a hint (ie. "width") or if it isn't a parameter
-                               if ((param_desc && !param_desc->get_hint().empty()) ||
-                                       !param_desc)
-                               {
-                                       etl::handle<Duck> width;
-                                       if (add_to_ducks(synfigapp::ValueDesc(composite_vertex_value_node,1),canvas_view,transform_stack,REAL_COOKIE))
-                                       {
-                                               width=last_duck();
-                                               width->set_origin(duck);
-                                               width->set_type(Duck::TYPE_WIDTH);
-                                               width->set_name(guid_string(synfigapp::ValueDesc(value_node,i))+".w");
-
-                                               // if the bline is a layer's parameter, scale the width duck by the layer's "width" parameter
-                                               if (param_desc)
-                                               {
-                                                       ValueBase value(synfigapp::ValueDesc(value_desc.get_layer(),param_desc->get_hint()).get_value(get_time()));
-                                                       if(value.same_type_as(synfig::Real()))
-                                                               width->set_scalar(value.get(synfig::Real())*0.5f);
-                                                       // if it doesn't have a "width" parameter, scale by 0.5f instead
-                                                       else
-                                                               width->set_scalar(0.5f);
-                                               }
-                                               // otherwise just present the raw unscaled width
-                                               else
-                                                       width->set_scalar(0.5f);
-                                       }
-                                       else
-                                               synfig::error("Unable to add width duck!");
-                               }
-
-                               // each bezier uses t2 of one point and t1 of the next
-                               // the first time through this loop we won't have the t2 duck from the previous vertex
-                               // and so we don't make a bezier.  instead we skip on to t2 for this point
-                               if(bezier)
-                               {
-                                       // Add the tangent1 duck
-                                       if(composite_vertex_value_node)
-                                       {
-                                               if(!add_to_ducks(synfigapp::ValueDesc(composite_vertex_value_node,4),canvas_view,transform_stack))
-                                                       return false;
-                                               tduck=last_duck();
-                                       }
-                                       else
-                                       {
-                                               tduck=new Duck(bline_point.get_tangent1());
-                                               tduck->set_transform_stack(transform_stack);
-                                               tduck->set_editable(false);
-                                               tduck->set_name(guid_string(synfigapp::ValueDesc(value_node,i))+".t1");
-//                                             tduck->set_name(strprintf("%x-tangent1",value_node->get_link(i).get()));
-                                               tduck->set_guid(calc_duck_guid(synfigapp::ValueDesc(value_node,i),transform_stack)^synfig::GUID::hasher(".t1"));
-                                               tduck=add_similar_duck(tduck);
-//                                             add_duck(duck);
-                                       }
-
-                                       tduck->set_origin(duck);
-                                       tduck->set_scalar(-TANGENT_BEZIER_SCALE);
-                                       tduck->set_tangent(true);
-
-                                       bezier->p2=duck;
-                                       bezier->c2=tduck;
-
-                                       bezier->signal_user_click(2).connect(
-                                               sigc::bind(
-                                                       sigc::mem_fun(
-                                                               *canvas_view,
-                                                               &studio::CanvasView::popup_param_menu_bezier),
-                                                       synfigapp::ValueDesc(value_node,i)));
-
-                                       duck->signal_user_click(2).clear();
-                                       duck->signal_user_click(2).connect(
-                                               sigc::bind(
-                                                       sigc::bind(
-                                                               sigc::bind(
-                                                                       sigc::mem_fun(
-                                                                               *canvas_view,
-                                                                               &studio::CanvasView::popup_param_menu),
-                                                                       false),
-                                                               1.0f),
-                                                       synfigapp::ValueDesc(value_node,i)));
-                                       duck->set_value_desc(synfigapp::ValueDesc(value_node,i));
-
-                                       add_bezier(bezier);
-                                       bezier=0;
-                               }
-
-                               // don't start a new bezier for the last point in the line if we're not looped
-                               if(i+1>=value_node->link_count() && !value_node->get_loop())
-                                       continue;
-
-                               bezier=new Bezier();
-
-                               // Add the tangent2 duck
-                               if(composite_vertex_value_node)
-                               {
-                                       int i=bline_point.get_split_tangent_flag()?5:4;
-                                       if(!add_to_ducks(synfigapp::ValueDesc(composite_vertex_value_node,i),canvas_view,transform_stack,0,2))
-                                               return false;
-                                       tduck=last_duck();
-                               }
-                               else
-                               {
-                                       if(bline_point.get_split_tangent_flag())
-                                               tduck=new Duck(bline_point.get_tangent2());
-                                       else
-                                               tduck=new Duck(bline_point.get_tangent1());
-
-                                       tduck->set_transform_stack(transform_stack);
-                                       tduck->set_name(guid_string(synfigapp::ValueDesc(value_node,i))+".t2");
-                                       tduck->set_guid(calc_duck_guid(synfigapp::ValueDesc(value_node,i),transform_stack)^synfig::GUID::hasher(".t2"));
-                                       tduck->set_editable(false);
-                                       tduck=add_similar_duck(tduck);
-//                                     add_duck(duck);
-                                       if(param_desc)
-                                       {
-                                               synfigapp::ValueDesc value_desc_origin(value_desc.get_layer(),param_desc->get_origin());
-                                               add_to_ducks(value_desc_origin,canvas_view, transform_stack);
-                                               duck->set_origin(last_duck());
-/*
-                                               ValueBase value(synfigapp::ValueDesc(value_desc.get_layer(),param_desc->get_origin()).get_value(get_time()));
-                                               if(value.same_type_as(synfig::Point()))
-                                                       duck->set_origin(value.get(synfig::Point()));
-*/
-//                                             if(!param_desc->get_origin().empty())
-//                                                     duck->set_origin(synfigapp::ValueDesc(value_desc.get_layer(),param_desc->get_origin()).get_value(get_time()).get(synfig::Point()));
-                                       }
-                                       duck->signal_user_click(2).clear();
-                                       duck->signal_user_click(2).connect(
-                                               sigc::bind(
-                                                       sigc::bind(
-                                                               sigc::bind(
-                                                                       sigc::mem_fun(
-                                                                               *canvas_view,
-                                                                               &studio::CanvasView::popup_param_menu),
-                                                                       false),
-                                                               1.0f),
-                                                       synfigapp::ValueDesc(value_node,i)));
-                                       duck->set_value_desc(synfigapp::ValueDesc(value_node,i));
-
-                               }
-
-                               tduck->set_origin(duck);
-                               tduck->set_scalar(TANGENT_BEZIER_SCALE);
-                               tduck->set_tangent(true);
-
-                               bezier->p1=duck;
-                               bezier->c1=tduck;
-                       }
-
-                       // Loop if necessary
-                       if(bezier && value_node->get_loop())
-                       {
-                               BLinePoint bline_point((*value_node->get_link(first))(get_time()));
-
-                               ValueNode_Composite::Handle composite_vertex_value_node(
-                                       ValueNode_Composite::Handle::cast_dynamic(
-                                               value_node->get_link(first)));
-
-                               // Add the vertex duck
-                               duck=first_duck;
-
-                               // Add the tangent1 duck
-                               if(composite_vertex_value_node)
-                               {
-                                       if(!add_to_ducks(synfigapp::ValueDesc(composite_vertex_value_node,4),canvas_view,transform_stack))
-                                               return false;
-                                       tduck=last_duck();
-                               }
-                               else
-                               {
-                                       tduck=new Duck(bline_point.get_tangent1());
-                                       tduck->set_transform_stack(transform_stack);
-                                       tduck->set_editable(false);
-                                       tduck->set_name(guid_string(synfigapp::ValueDesc(value_node,first))+".t1");
-                                       //tduck->set_name(strprintf("%x-tangent1",value_node->get_link(first).get()));
-                                       tduck=add_similar_duck(tduck);
-                                       tduck->set_guid(calc_duck_guid(synfigapp::ValueDesc(value_node,first),transform_stack)^synfig::GUID::hasher(".t1"));
-                                       //add_duck(duck);
-                               }
-
-                               tduck->set_origin(duck);
-                               tduck->set_scalar(-TANGENT_BEZIER_SCALE);
-                               tduck->set_tangent(true);
-
-                               bezier->p2=duck;
-                               bezier->c2=tduck;
-
-                               bezier->signal_user_click(2).connect(
-                                       sigc::bind(
-                                               sigc::mem_fun(
-                                                       *canvas_view,
-                                                       &studio::CanvasView::popup_param_menu_bezier),
-                                               synfigapp::ValueDesc(value_node,first)));
-
-                               duck->signal_user_click(2).clear();
-                               duck->signal_user_click(2).connect(
-                                       sigc::bind(
-                                               sigc::bind(
-                                                       sigc::bind(
-                                                               sigc::mem_fun(
-                                                                       *canvas_view,
-                                                                       &studio::CanvasView::popup_param_menu),
-                                                               false),
-                                                       1.0f),
-                                               synfigapp::ValueDesc(value_node,first)));
-                               duck->set_value_desc(synfigapp::ValueDesc(value_node,first));
-
-                               add_bezier(bezier);
-                               bezier=0;
-                       }
-                       return true;
-               }
-               else // Check for DynamicList
-               if(value_desc.is_value_node() &&
-                       ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_value_node()))
-               {
-                       ValueNode_DynamicList::Handle value_node;
-                       value_node=ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_value_node());
-                       int i;
-
-                       if(value_node->get_contained_type()==ValueBase::TYPE_VECTOR)
-                       {
-                               Bezier bezier;
-                               etl::handle<Duck> first_duck, duck;
-                               int first = -1;
-                               for(i=0;i<value_node->link_count();i++)
-                               {
-                                       if(!value_node->list[i].status_at_time(get_time()))
-                                               continue;
-                                       if(!add_to_ducks(synfigapp::ValueDesc(value_node,i),canvas_view,transform_stack))
-                                               return false;
-                                       duck = last_duck();
-
-                                       // remember the index of the first vertex we didn't skip
-                                       if (first == -1)
-                                       {
-                                               first = i;
-                                               first_duck = duck;
-                                       }
-
-                                       if(param_desc && !param_desc->get_origin().empty())
-                                       {
-                                               synfigapp::ValueDesc value_desc_origin(value_desc.get_layer(),param_desc->get_origin());
-                                               add_to_ducks(value_desc_origin,canvas_view, transform_stack);
-                                               duck->set_origin(last_duck());
-/*
-                                               ValueBase value(synfigapp::ValueDesc(value_desc.get_layer(),param_desc->get_origin()).get_value(get_time()));
-                                               if(value.same_type_as(synfig::Point()))
-                                                       duck->set_origin(value.get(synfig::Point()));
-*/
-//                                             if(!param_desc->get_origin().empty())
-//                                                     last_duck()->set_origin(synfigapp::ValueDesc(value_desc.get_layer(),param_desc->get_origin()).get_value(get_time()).get(synfig::Point()));
-                                       }
-                                       duck->set_type(Duck::TYPE_VERTEX);
-                                       bezier.p1=bezier.p2;bezier.c1=bezier.c2;
-                                       bezier.p2=bezier.c2=duck;
-
-                                       if (first != i)
-                                       {
-                                               handle<Bezier> bezier_(new Bezier());
-                                               bezier_->p1=bezier.p1;
-                                               bezier_->c1=bezier.c1;
-                                               bezier_->p2=bezier.p2;
-                                               bezier_->c2=bezier.c2;
-                                               add_bezier(bezier_);
-                                               last_bezier()->signal_user_click(2).connect(
-                                                       sigc::bind(
-                                                               sigc::mem_fun(
-                                                                       *canvas_view,
-                                                                       &studio::CanvasView::popup_param_menu_bezier),
-                                                               synfigapp::ValueDesc(value_node,i)));
-                                       }
-                               }
-
-                               if (value_node->get_loop() && first != -1 && first_duck != duck)
-                               {
-                                       duck = first_duck;
-
-                                       bezier.p1=bezier.p2;bezier.c1=bezier.c2;
-                                       bezier.p2=bezier.c2=duck;
-
-                                       handle<Bezier> bezier_(new Bezier());
-                                       bezier_->p1=bezier.p1;
-                                       bezier_->c1=bezier.c1;
-                                       bezier_->p2=bezier.p2;
-                                       bezier_->c2=bezier.c2;
-                                       add_bezier(bezier_);
-                                       last_bezier()->signal_user_click(2).connect(
-                                               sigc::bind(
-                                                       sigc::mem_fun(
-                                                               *canvas_view,
-                                                               &studio::CanvasView::popup_param_menu_bezier),
-                                                       synfigapp::ValueDesc(value_node,first)));
-                               }
-                       }
-                       else if(value_node->get_contained_type()==ValueBase::TYPE_SEGMENT)
-                       {
-                               for(i=0;i<value_node->link_count();i++)
-                               {
-                                       if(!value_node->list[i].status_at_time(get_time()))
-                                               continue;
-                                       if(!add_to_ducks(synfigapp::ValueDesc(value_node,i),canvas_view,transform_stack))
-                                               return false;
-                               }
-                       }
-                       else
-                               return false;
-               }
-               else
-               {
-                       // WRITEME
-               }
-
-               return true;
-       }
-
-       break;
-       default:
-               break;
-       }
-       return false;
-}
diff --git a/synfig-studio/src/gtkmm/duckmatic.h b/synfig-studio/src/gtkmm/duckmatic.h
deleted file mode 100644 (file)
index e10db0c..0000000
+++ /dev/null
@@ -1,453 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file duckmatic.h
-**     \brief Template Header
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 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
-*/
-/* ========================================================================= */
-
-/* === S T A R T =========================================================== */
-
-#ifndef __SYNFIG_STUDIO_DUCKMATIC_H
-#define __SYNFIG_STUDIO_DUCKMATIC_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <list>
-#include <map>
-#include <set>
-
-#include <ETL/smart_ptr>
-#include <ETL/handle>
-
-#include <synfig/vector.h>
-#include <synfig/string.h>
-#include <synfig/real.h>
-#include <sigc++/signal.h>
-#include <sigc++/object.h>
-#include <synfig/time.h>
-#include <synfig/color.h>
-#include <ETL/smart_ptr>
-
-#include "duck.h"
-#include <synfig/color.h>
-#include <synfig/guidset.h>
-
-/* === M A C R O S ========================================================= */
-
-#ifdef HASH_MAP_H
-#include HASH_MAP_H
-#include FUNCTIONAL_H
-
-#ifndef __STRING_HASH__
-#define __STRING_HASH__
-class StringHash
-{
-# ifdef FUNCTIONAL_HASH_ON_STRING
-       HASH_MAP_NAMESPACE::hash<synfig::String> hasher_;
-# else  // FUNCTIONAL_HASH_ON_STRING
-       HASH_MAP_NAMESPACE::hash<const char*> hasher_;
-# endif  // FUNCTIONAL_HASH_ON_STRING
-public:
-       size_t operator()(const synfig::String& x)const
-       {
-# ifdef FUNCTIONAL_HASH_ON_STRING
-               return hasher_(x);
-# else  // FUNCTIONAL_HASH_ON_STRING
-               return hasher_(x.c_str());
-# endif  // FUNCTIONAL_HASH_ON_STRING
-       }
-};
-#endif
-#else
-#include <map>
-#endif
-
-/* === T Y P E D E F S ===================================================== */
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-namespace synfigapp { class ValueDesc; }
-namespace synfig { class ParamDesc; }
-
-namespace studio
-{
-
-class CanvasView;
-class Duckmatic;
-
-class DuckDrag_Base : public etl::shared_object
-{
-public:
-       virtual void begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& begin)=0;
-       virtual bool end_duck_drag(Duckmatic* duckmatic)=0;
-       virtual void duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector)=0;
-};
-
-class DuckDrag_Translate : public DuckDrag_Base
-{
-       synfig::Vector last_translate_;
-       synfig::Vector drag_offset_;
-       synfig::Vector snap;
-       std::vector<synfig::Vector> positions;
-
-public:
-       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 Duckmatic
-**
-**     This class helps organize any of the devices displayed in
-**     the work area that the user may want to interact with.
-**     This includes ducks, beziers, and strokes
-**
-**     \note At some point I'll probably rename this class to "DuckOMatic".
-*/
-class Duckmatic
-{
-       friend class DuckDrag_Base;
-       friend class DuckDrag_Translate;
-
-       /*
- -- ** -- P U B L I C   T Y P E S ---------------------------------------------
-       */
-
-public:
-
-#ifdef HASH_MAP_H
-typedef HASH_MAP_CLASS<synfig::GUID,etl::smart_ptr<synfig::Point>,synfig::GUIDHash> DuckDataMap;
-#else
-typedef std::map<synfig::GUID,etl::smart_ptr<synfig::Point> > DuckDataMap;
-#endif
-
-       typedef studio::DuckMap DuckMap;
-
-       typedef studio::Duck Duck;
-
-       struct Stroke;
-
-       struct Bezier;
-
-       class Push;
-
-       friend class Push;
-
-       typedef Duck::Type Type;
-
-       typedef std::list<float> GuideList;
-
-       /*
- -- ** -- P R I V A T E   D A T A ---------------------------------------------
-       */
-
-private:
-
-       Type type_mask;
-
-       DuckMap duck_map;
-
-       DuckDataMap duck_data_share_map;
-
-       std::list<etl::handle<Stroke> > stroke_list_;
-
-       std::list<etl::handle<Stroke> > persistent_stroke_list_;
-
-       synfig::GUIDSet selected_ducks;
-
-       synfig::GUID last_duck_guid;
-
-       std::list<etl::handle<Bezier> > bezier_list_;
-
-       //! I cannot recall what this is for
-       //synfig::Vector snap;
-
-       etl::handle<DuckDrag_Base> duck_dragger_;
-
-       sigc::signal<void> signal_duck_selection_changed_;
-
-       sigc::signal<void> signal_strokes_changed_;
-
-       sigc::signal<void> signal_grid_changed_;
-
-       mutable sigc::signal<void> signal_sketch_saved_;
-
-       GuideList guide_list_x_;
-       GuideList guide_list_y_;
-
-       mutable synfig::String sketch_filename_;
-
-       /*
- -- ** -- P R O T E C T E D   D A T A -----------------------------------------
-       */
-
-protected:
-
-       etl::handle<Bezier> selected_bezier;
-
-       synfig::Time cur_time;
-
-       //! This flag is set if operations should snap to the grid
-       /*! \todo perhaps there should be two of these flags, one for each axis?
-       **      \see show_grid, grid_size */
-       bool grid_snap;
-
-       bool guide_snap;
-
-       //! This vector describes the grid size.
-       /*! \see grid_snap, show_grid */
-       synfig::Vector grid_size;
-
-       bool show_persistent_strokes;
-
-       bool axis_lock;
-
-       /*
- -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
-       */
-
-private:
-
-       synfig::Vector last_translate_;
-       synfig::Vector drag_offset_;
-
-       //etl::handle<Duck> selected_duck;
-
-
-       /*
- -- ** -- P U B L I C   M E T H O D S -----------------------------------------
-       */
-
-public:
-
-       Duckmatic();
-       virtual ~Duckmatic();
-
-       sigc::signal<void>& signal_duck_selection_changed() { return signal_duck_selection_changed_; }
-       sigc::signal<void>& signal_strokes_changed() { return signal_strokes_changed_; }
-       sigc::signal<void>& signal_grid_changed() { return signal_grid_changed_; }
-       sigc::signal<void>& signal_sketch_saved() { return signal_sketch_saved_; }
-
-       GuideList& get_guide_list_x() { return guide_list_x_; }
-       GuideList& get_guide_list_y() { return guide_list_y_; }
-       const GuideList& get_guide_list_x()const { return guide_list_x_; }
-       const GuideList& get_guide_list_y()const { return guide_list_y_; }
-
-       void set_guide_snap(bool x=true);
-       bool get_guide_snap()const { return guide_snap; }
-       void toggle_guide_snap() { set_guide_snap(!get_guide_snap()); }
-
-       //! Sets the state of the grid snap flag
-       void set_grid_snap(bool x=true);
-
-       //! Gets the state of the grid snap flag
-       bool get_grid_snap()const { return grid_snap; }
-
-       void enable_grid_snap() { set_grid_snap(true); }
-
-       void disable_grid_snap() { set_grid_snap(false); }
-
-       void toggle_grid_snap() { set_grid_snap(!grid_snap); }
-
-       synfig::Point snap_point_to_grid(const synfig::Point& x, float radius=0.1)const;
-
-       bool get_show_persistent_strokes()const { return show_persistent_strokes; }
-       void set_show_persistent_strokes(bool x);
-
-       //! Sets the size of the grid
-       void set_grid_size(const synfig::Vector &s);
-
-       //! Returns the size of the grid
-       const synfig::Vector &get_grid_size()const { return grid_size; }
-
-
-       const synfig::Time &get_time()const { return cur_time; }
-
-       bool get_axis_lock()const { return axis_lock; }
-       void set_axis_lock(bool x) { axis_lock=x; }
-
-       void set_time(synfig::Time x) { cur_time=x; }
-
-       bool is_duck_group_selectable(const etl::handle<Duck>& x)const;
-
-       //const DuckMap& duck_map()const { return duck_map; }
-       DuckList get_duck_list()const;
-
-       const std::list<etl::handle<Bezier> >& bezier_list()const { return bezier_list_; }
-
-       const std::list<etl::handle<Stroke> >& stroke_list()const { return stroke_list_; }
-
-       const std::list<etl::handle<Stroke> >& persistent_stroke_list()const { return persistent_stroke_list_; }
-
-       std::list<etl::handle<Stroke> >& persistent_stroke_list() { return persistent_stroke_list_; }
-
-       //! \todo We should modify this to support multiple selections
-       etl::handle<Duck> get_selected_duck()const;
-
-       DuckList get_selected_ducks()const;
-
-       //! Returns \a true if the given duck is currently selected
-       bool duck_is_selected(const etl::handle<Duck> &duck)const;
-
-
-       void refresh_selected_ducks();
-
-       void clear_selected_ducks();
-
-       int count_selected_ducks()const;
-
-       void toggle_select_duck(const etl::handle<Duck> &duck);
-
-       void select_duck(const etl::handle<Duck> &duck);
-
-       void toggle_select_ducks_in_box(const synfig::Vector& tl,const synfig::Vector& br);
-
-       void select_ducks_in_box(const synfig::Vector& tl,const synfig::Vector& br);
-
-       void unselect_duck(const etl::handle<Duck> &duck);
-
-       void start_duck_drag(const synfig::Vector& offset);
-       void translate_selected_ducks(const synfig::Vector& vector);
-       void update_ducks();
-       bool end_duck_drag();
-
-       void signal_edited_selected_ducks();
-
-       void signal_user_click_selected_ducks(int button);
-
-
-       etl::handle<Duck> find_similar_duck(etl::handle<Duck> duck);
-       etl::handle<Duck> add_similar_duck(etl::handle<Duck> duck);
-
-       void add_stroke(etl::smart_ptr<std::list<synfig::Point> > stroke_point_list, const synfig::Color& color=synfig::Color(0,0,0));
-
-       void add_persistent_stroke(etl::smart_ptr<std::list<synfig::Point> > stroke_point_list, const synfig::Color& color=synfig::Color(0,0,0));
-
-       void clear_persistent_strokes();
-
-       void add_duck(const etl::handle<Duck> &duck);
-
-       void add_bezier(const etl::handle<Bezier> &bezier);
-
-       void erase_duck(const etl::handle<Duck> &duck);
-
-       void erase_bezier(const etl::handle<Bezier> &bezier);
-
-       //! Returns the last duck added
-       etl::handle<Duck> last_duck()const;
-
-       etl::handle<Bezier> last_bezier()const;
-
-       //! \note parameter is in canvas coordinates
-       /*!     A radius of "zero" will have an unlimited radius */
-       etl::handle<Duck> find_duck(synfig::Point pos, synfig::Real radius=0, Duck::Type type=Duck::TYPE_DEFAULT);
-
-       GuideList::iterator find_guide_x(synfig::Point pos, float radius=0.1);
-       GuideList::iterator find_guide_y(synfig::Point pos, float radius=0.1);
-       GuideList::const_iterator find_guide_x(synfig::Point pos, float radius=0.1)const { return const_cast<Duckmatic*>(this)->find_guide_x(pos,radius); }
-       GuideList::const_iterator find_guide_y(synfig::Point pos, float radius=0.1)const { return const_cast<Duckmatic*>(this)->find_guide_y(pos,radius); }
-
-       //! \note parameter is in canvas coordinates
-       /*!     A radius of "zero" will have an unlimited radius */
-       //etl::handle<Bezier> find_bezier(synfig::Point pos, synfig::Real radius=0);
-
-       //! \note parameter is in canvas coordinates
-       /*!     A radius of "zero" will have an unlimited radius */
-       etl::handle<Bezier> find_bezier(synfig::Point pos, synfig::Real radius=0, float* location=0);
-
-       etl::handle<Bezier> find_bezier(synfig::Point pos, synfig::Real scale, synfig::Real radius, float* location=0);
-
-       bool add_to_ducks(const synfigapp::ValueDesc& value_desc,etl::handle<CanvasView> canvas_view, const synfig::TransformStack& transform_stack_, synfig::ParamDesc *param_desc=0, int multiple=0);
-
-       //! \writeme
-       void set_type_mask(Type x) { type_mask=x; }
-
-       //! \writeme
-       Type get_type_mask()const { return type_mask; }
-
-       void select_all_ducks();
-       void unselect_all_ducks();
-
-       void clear_ducks();
-
-       bool save_sketch(const synfig::String& filename)const;
-       bool load_sketch(const synfig::String& filename);
-       const synfig::String& get_sketch_filename()const { return sketch_filename_; }
-
-       void set_duck_dragger(etl::handle<DuckDrag_Base> x) { duck_dragger_=x; }
-       etl::handle<DuckDrag_Base> get_duck_dragger()const { return duck_dragger_; }
-       void clear_duck_dragger() { duck_dragger_=new DuckDrag_Translate(); }
-}; // END of class Duckmatic
-
-
-/*! \class Duckmatic::Push
-**     \writeme */
-class Duckmatic::Push
-{
-       Duckmatic *duckmatic_;
-       DuckMap duck_map;
-       std::list<etl::handle<Bezier> > bezier_list_;
-       std::list<etl::handle<Stroke> > stroke_list_;
-       DuckDataMap duck_data_share_map;
-       etl::handle<DuckDrag_Base> duck_dragger_;
-
-       bool needs_restore;
-
-public:
-       Push(Duckmatic *duckmatic_);
-       ~Push();
-       void restore();
-}; // END of class Duckmatic::Push
-
-/*! \struct Duckmatic::Bezier
-**     \writeme */
-struct Duckmatic::Bezier : public etl::shared_object
-{
-private:
-       sigc::signal<void,float> signal_user_click_[5];
-public:
-
-       etl::handle<Duck> p1,p2,c1,c2;
-       bool is_valid()const { return p1 && p2 && c1 && c2; }
-
-       sigc::signal<void,float> &signal_user_click(int i=0) { assert(i>=0); assert(i<5); return signal_user_click_[i]; }
-}; // END of struct Duckmatic::Bezier
-
-/*! \struct Duckmatic::Stroke
-**     \writeme */
-struct Duckmatic::Stroke : public etl::shared_object
-{
-private:
-       sigc::signal<void,float> signal_user_click_[5];
-public:
-
-       etl::smart_ptr<std::list<synfig::Point> > stroke_data;
-
-       synfig::Color color;
-
-       bool is_valid()const { return (bool)stroke_data; }
-
-       sigc::signal<void,float> &signal_user_click(int i=0) { assert(i>=0); assert(i<5); return signal_user_click_[i]; }
-}; // END of struct Duckmatic::Stroke
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/ducktransform_rotate.h b/synfig-studio/src/gtkmm/ducktransform_rotate.h
deleted file mode 100644 (file)
index 5a4a338..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file ducktransform_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_DUCK_TRANSFORM_ROTATE_H
-#define __SYNFIG_STUDIO_DUCK_TRANSFORM_ROTATE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include "duckmatic.h"
-#include <synfig/angle.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 Transform_Rotate : public synfig::Transform
-{
-private:
-       synfig::Angle angle;
-       synfig::Vector origin;
-       synfig::Real sin_val;
-       synfig::Real cos_val;
-
-public:
-       Transform_Rotate(const synfig::GUID& guid, const synfig::Angle& angle,const synfig::Vector& origin=synfig::Vector(0,0)):
-               Transform(guid),
-               angle(angle),
-               origin(origin),
-               sin_val(synfig::Angle::sin(angle).get()),
-               cos_val(synfig::Angle::cos(angle).get())
-       {
-       }
-
-       synfig::Vector perform(const synfig::Vector& x)const
-       {
-               synfig::Point pos(x-origin);
-               return synfig::Point(cos_val*pos[0]-sin_val*pos[1],sin_val*pos[0]+cos_val*pos[1])+origin;
-       }
-       synfig::Vector unperform(const synfig::Vector& x)const
-       {
-               synfig::Point pos(x-origin);
-               return synfig::Point(cos_val*pos[0]+sin_val*pos[1],-sin_val*pos[0]+cos_val*pos[1])+origin;
-       }
-};
-
-};
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/ducktransform_scale.h b/synfig-studio/src/gtkmm/ducktransform_scale.h
deleted file mode 100644 (file)
index 348a580..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file ducktransform_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_DUCK_TRANSFORM_SCALE_H
-#define __SYNFIG_STUDIO_DUCK_TRANSFORM_SCALE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include "duckmatic.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 Transform_Scale : public synfig::Transform
-{
-private:
-       synfig::Vector scale;
-       synfig::Vector origin;
-public:
-       Transform_Scale(const synfig::GUID& guid, const synfig::Vector& scale,const synfig::Vector& origin=synfig::Vector(0,0)):
-               Transform(guid), scale(scale), origin(origin) { }
-       synfig::Vector perform(const synfig::Vector& x)const { return synfig::Vector((x[0]-origin[0])*scale[0]+origin[0],(x[1]-origin[1])*scale[1]+origin[1]); }
-       synfig::Vector unperform(const synfig::Vector& x)const { return synfig::Vector((x[0]-origin[0])/scale[0]+origin[0],(x[1]-origin[1])/scale[1]+origin[1]); }
-};
-
-};
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/ducktransform_translate.h b/synfig-studio/src/gtkmm/ducktransform_translate.h
deleted file mode 100644 (file)
index fffd910..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file ducktransform_translate.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_DUCK_TRANSFORM_TRANSLATE_H
-#define __SYNFIG_STUDIO_DUCK_TRANSFORM_TRANSLATE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include "duckmatic.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 Transform_Translate : public synfig::Transform
-{
-private:
-       synfig::Vector origin;
-       std::vector<synfig::Vector> positions;
-
-public:
-       Transform_Translate(const synfig::GUID& guid, const synfig::Vector& origin):Transform(guid), origin(origin) { }
-       synfig::Vector perform(const synfig::Vector& x)const { return x+origin; }
-       synfig::Vector unperform(const synfig::Vector& x)const { return x-origin; }
-}; // END of class synfig::Transform_Translate
-
-}; // END of namespace studio
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/event_layerclick.h b/synfig-studio/src/gtkmm/event_layerclick.h
deleted file mode 100644 (file)
index e32c4cc..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file event_layerclick.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_EVENT_LAYERCLICK_H
-#define __SYNFIG_EVENT_LAYERCLICK_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <synfig/vector.h>
-#include "event_mouse.h"
-#include <synfig/layer.h>
-#include "smach.h"
-#include <gdkmm/types.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 {
-
-struct EventLayerClick : public Smach::event
-{
-       synfig::Point pos;
-       MouseButton button;
-       etl::loose_handle<synfig::Layer> layer;
-       Gdk::ModifierType modifier;
-
-       EventLayerClick(etl::loose_handle<synfig::Layer> layer, MouseButton button, const synfig::Point& pos, Gdk::ModifierType modifier=Gdk::ModifierType(0)):
-               Smach::event(EVENT_WORKAREA_LAYER_CLICKED),
-               pos(pos),
-               button(button),
-               layer(layer),
-               modifier(modifier)
-       { }
-}; // END of EventLayerClick
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/event_mouse.h b/synfig-studio/src/gtkmm/event_mouse.h
deleted file mode 100644 (file)
index 106f8aa..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file event_mouse.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_EVENT_MOUSE_H
-#define __SYNFIG_EVENT_MOUSE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <synfig/vector.h>
-#include "smach.h"
-#include <gdkmm/types.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 {
-
-enum MouseButton
-{
-       BUTTON_NONE,
-       BUTTON_LEFT,
-       BUTTON_MIDDLE,
-       BUTTON_RIGHT,
-       BUTTON_UP,
-       BUTTON_DOWN,
-
-       BUTTON_END
-};
-
-struct EventMouse : public Smach::event
-{
-       synfig::Point pos;
-       MouseButton button;
-       float pressure;
-       Gdk::ModifierType modifier;
-
-       EventMouse(EventKey id, MouseButton button, const synfig::Point& pos, Gdk::ModifierType modifier=Gdk::ModifierType(0)):
-               Smach::event(id),
-               pos(pos),
-               button(button),
-               pressure(button==BUTTON_NONE?0.0f:1.0f),
-               modifier(modifier)
-       { }
-
-       EventMouse(EventKey id, MouseButton button, const synfig::Point& pos, float pressure, Gdk::ModifierType modifier=Gdk::ModifierType(0)):
-               Smach::event(id),
-               pos(pos),
-               button(button),
-               pressure(pressure),
-               modifier(modifier)
-       { }
-}; // END of EventMouse
-
-struct EventBox : public Smach::event
-{
-       synfig::Point p1,p2;
-       MouseButton button;
-       Gdk::ModifierType modifier;
-
-       EventBox(EventKey id, const synfig::Point& p1,const synfig::Point& p2,MouseButton button=BUTTON_NONE, Gdk::ModifierType modifier=Gdk::ModifierType(0)):
-               Smach::event(id),
-               p1(p1),
-               p2(p2),
-               button(button),
-               modifier(modifier)
-       { }
-
-       EventBox(const synfig::Point& p1,const synfig::Point& p2,MouseButton button=BUTTON_NONE, Gdk::ModifierType modifier=Gdk::ModifierType(0)):
-               Smach::event(EVENT_WORKAREA_BOX),
-               p1(p1),
-               p2(p2),
-               button(button),
-               modifier(modifier)
-       { }
-}; // END of EventBox
-
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/eventkey.h b/synfig-studio/src/gtkmm/eventkey.h
deleted file mode 100644 (file)
index 639f6d1..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file eventkey.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_EVENTKEY_H
-#define __SYNFIG_STUDIO_EVENTKEY_H
-
-/* === H E A D E R S ======================================================= */
-
-/* === 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 {
-
-enum EventKey
-{
-       EVENT_NIL,
-       EVENT_REFRESH,
-       EVENT_DIRTY,
-       EVENT_STOP,
-       EVENT_UNDO,
-       EVENT_REDO,
-       EVENT_REFRESH_DUCKS,
-       EVENT_REFRESH_TOOL_OPTIONS,
-       EVENT_YIELD_TOOL_OPTIONS,
-       EVENT_INPUT_DEVICE_CHANGED,
-       EVENT_TABLES_HIDE,
-       EVENT_LAYER_SELECTION_CHANGED,
-       EVENT_TABLES_SHOW,
-
-
-       EVENT_WORKAREA_START=1000,              //!< Not a valid event
-       EVENT_WORKAREA_LAYER_CLICKED,
-       EVENT_WORKAREA_MULTIPLE_DUCKS_CLICKED,
-       EVENT_WORKAREA_MOUSE_MOTION,
-       EVENT_WORKAREA_MOUSE_BUTTON_DOWN,
-       EVENT_WORKAREA_MOUSE_BUTTON_DRAG,
-       EVENT_WORKAREA_MOUSE_BUTTON_UP,
-       EVENT_WORKAREA_BOX,
-       EVENT_WORKAREA_END,             //!< Not a valid event
-
-       EVENT_WORKAREA_STROKE,
-
-       EVENT_END               //!< Not a valid event
-};
-
-};
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/framedial.cpp b/synfig-studio/src/gtkmm/framedial.cpp
deleted file mode 100644 (file)
index 6437930..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file framedial.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**  Copyright (c) 2008 Chris Moore
-**  Copyright (c) 2009 Gerco Ballintijn
-**     Copyright (c) 2009 Carlos López
-**
-**     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 <config.h>
-#endif
-
-#include "framedial.h"
-#include <gtkmm/image.h>
-#include <gtkmm/stock.h>
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace studio;
-
-/* === M A C R O S ========================================================= */
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-FrameDial::FrameDial(): Gtk::Table(5, 1, false)
-{
-       Gtk::IconSize iconsize = Gtk::IconSize::from_name("synfig-small_icon");
-
-       seek_begin = create_icon(iconsize, Gtk::Stock::MEDIA_PREVIOUS,
-                                       _("Seek to Begin"));
-       seek_prev_frame = create_icon(iconsize, Gtk::Stock::MEDIA_REWIND,
-                                       _("Previous Frame"));
-       play_stop = create_icon(iconsize, Gtk::Stock::MEDIA_PLAY,
-                                       _("Play"));
-       seek_next_frame = create_icon(iconsize, Gtk::Stock::MEDIA_FORWARD,
-                                       _("Next Frame"));
-       seek_end = create_icon(iconsize, Gtk::Stock::MEDIA_NEXT,
-                                       _("Seek to End"));
-
-       attach(*seek_begin, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       attach(*seek_prev_frame, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       attach(*play_stop, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       attach(*seek_next_frame, 3, 4, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       attach(*seek_end, 4, 5, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-}
-
-Gtk::Button *
-FrameDial::create_icon(Gtk::IconSize size, const Gtk::BuiltinStockID & stockid,
-               const char * tooltip)
-{
-       Gtk::Button *button = manage(new class Gtk::Button());
-       Gtk::Image *icon = manage(new Gtk::Image(stockid, size));
-       button->add(*icon);
-       tooltips.set_tip(*button, tooltip);
-       icon->set_padding(0, 0);
-       icon->show();
-       button->set_relief(Gtk::RELIEF_NONE);
-       button->show();
-
-       return button;
-}
-
diff --git a/synfig-studio/src/gtkmm/framedial.h b/synfig-studio/src/gtkmm/framedial.h
deleted file mode 100644 (file)
index 4fc51ca..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file zoomdial.h
-**     \brief Template Header
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**  Copyright (c) 2008 Chris Moore
-**  Copyright (c) 2009 Gerco Ballintijn
-**     Copyright (c) 2009 Carlos López
-**
-**     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_FRAMEDIAL_H
-#define __SYNFIG_STUDIO_FRAMEDIAL_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/tooltips.h>
-#include <gtkmm/table.h>
-#include <gtkmm/button.h>
-
-#include "general.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 FrameDial : public Gtk::Table
-{
-       Gtk::Tooltips tooltips;
-
-       Gtk::Button *seek_begin;
-       Gtk::Button *seek_prev_frame;
-       Gtk::Button *play_stop;
-       Gtk::Button *seek_next_frame;
-       Gtk::Button *seek_end;
-
-       Gtk::Button *create_icon(Gtk::IconSize size, const Gtk::BuiltinStockID & stockid,
-                       const char * tooltip);
-
-public:
-       FrameDial();
-
-       Glib::SignalProxy0<void> signal_seek_begin()            { return seek_begin->signal_clicked(); }
-       Glib::SignalProxy0<void> signal_seek_prev_frame()       { return seek_prev_frame->signal_clicked(); }
-       Glib::SignalProxy0<void> signal_play_stop()                     { return play_stop->signal_clicked(); }
-       Glib::SignalProxy0<void> signal_seek_next_frame()       { return seek_next_frame->signal_clicked(); }
-       Glib::SignalProxy0<void> signal_seek_end()                      { return seek_end->signal_clicked(); }
-
-       Gtk::Button *get_play_button() { return play_stop; }
-
-}; // END of class FrameDial
-
-}; // END of namespace studio
-
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/general.h b/synfig-studio/src/gtkmm/general.h
deleted file mode 100644 (file)
index 154a614..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file gtkmm/general.h
-**     \brief General header file for synfigstudio
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2007 Paul Wise
-**
-**     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 __SYNFIGSTUDIO_GENERAL_H
-#define __SYNFIGSTUDIO_GENERAL_H
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef ENABLE_NLS
-#include <libintl.h>
-#endif
-
-/* === M A C R O S ========================================================= */
-
-#undef _
-#undef gettext_noop
-#undef N_
-#ifdef ENABLE_NLS
-#define _(x) gettext(x)
-#define gettext_noop(x) x
-#define N_(x) gettext_noop(x)
-#else
-#define _(x) (x)
-#define N_(x) (x)
-#endif
-
-/* === T Y P E D E F S ===================================================== */
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/groupactionmanager.cpp b/synfig-studio/src/gtkmm/groupactionmanager.cpp
deleted file mode 100644 (file)
index 54eab18..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file groupactionmanager.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \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
-**     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 <config.h>
-#endif
-
-#include "groupactionmanager.h"
-#include "layergrouptree.h"
-#include <synfigapp/action_param.h>
-#include "instance.h"
-#include <gtkmm/stock.h>
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-using namespace synfig;
-using namespace studio;
-
-static const guint no_prev_popup((guint)-1);
-
-/* === M A C R O S ========================================================= */
-
-//#define ONE_ACTION_GROUP 1
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-GroupActionManager::GroupActionManager():
-       action_group_(Gtk::ActionGroup::create("action_group_group_action_manager")),
-       popup_id_(no_prev_popup),
-       queued(false)
-{
-}
-
-GroupActionManager::~GroupActionManager()
-{
-}
-
-void
-GroupActionManager::set_ui_manager(const Glib::RefPtr<Gtk::UIManager> &x)
-{
-       clear();
-
-#ifdef ONE_ACTION_GROUP
-       if(ui_manager_) get_ui_manager()->remove_action_group(action_group_);
-       ui_manager_=x;
-       if(ui_manager_) get_ui_manager()->insert_action_group(action_group_);
-#else
-       ui_manager_=x;
-#endif
-}
-
-void
-GroupActionManager::set_group_tree(LayerGroupTree* x)
-{
-       selection_changed_connection.disconnect();
-       group_tree_=x;
-       if(group_tree_)
-       {
-               selection_changed_connection=group_tree_->get_selection()->signal_changed().connect(
-                       sigc::mem_fun(*this,&GroupActionManager::queue_refresh)
-               );
-       }
-}
-
-void
-GroupActionManager::set_canvas_interface(const etl::handle<synfigapp::CanvasInterface> &x)
-{
-       canvas_interface_=x;
-}
-
-void
-GroupActionManager::clear()
-{
-       if(ui_manager_)
-       {
-               // Clear out old stuff
-               if(popup_id_!=no_prev_popup)
-               {
-                       get_ui_manager()->remove_ui(popup_id_);
-                       popup_id_=no_prev_popup;
-                       action_group_->set_sensitive(false);
-#ifdef ONE_ACTION_GROUP
-                       while(!action_group_->get_actions().empty())action_group_->remove(*action_group_->get_actions().begin());
-                       action_group_->set_sensitive(true);
-#else
-                       get_ui_manager()->remove_action_group(action_group_);
-                       action_group_=Gtk::ActionGroup::create("action_group_group_action_manager");
-#endif
-               }
-       }
-}
-
-void
-GroupActionManager::queue_refresh()
-{
-       if(queued)
-               return;
-
-       //queue_refresh_connection.disconnect();
-       queue_refresh_connection=Glib::signal_idle().connect(
-               sigc::bind_return(
-                       sigc::mem_fun(*this,&GroupActionManager::refresh),
-                       false
-               )
-       );
-
-       queued=true;
-}
-
-void
-GroupActionManager::refresh()
-{
-       if(queued)
-       {
-               queued=false;
-               //queue_refresh_connection.disconnect();
-       }
-
-
-       clear();
-
-       // Make sure we are ready
-       if(!ui_manager_ || !group_tree_ || !canvas_interface_)
-       {
-               synfig::error("GroupActionManager::refresh(): Not ready!");
-               return;
-       }
-
-       if(group_tree_->get_selection()->count_selected_rows()==0)
-               return;
-
-       String ui_info;
-
-       {
-               {
-                       action_group_->add(
-                               Gtk::Action::create(
-                                       "action-group_add",
-                                       Gtk::Stock::ADD,
-                                       _("Add a New Group"),
-                                       _("Add a New Group")
-                               ),
-                               sigc::mem_fun(
-                                       *this,
-                                       &GroupActionManager::on_action_add
-                               )
-                       );
-               }
-
-
-//             bool multiple_selected(group_tree_->get_selection()->count_selected_rows()>1);
-               LayerGroupTree::LayerList selected_layers(group_tree_->get_selected_layers());
-               std::list<synfig::String> selected_groups(group_tree_->get_selected_groups());
-
-               synfig::info("selected_layers.size()=%d",selected_layers.size());
-               synfig::info("selected_groups.size()=%d",selected_groups.size());
-
-               {
-                       bool canvas_set(false);
-                       synfigapp::Action::ParamList param_list;
-                       param_list.add("time",get_canvas_interface()->get_time());
-                       param_list.add("canvas_interface",get_canvas_interface());
-
-                       {
-                               LayerGroupTree::LayerList::iterator iter;
-
-                               for(iter=selected_layers.begin();iter!=selected_layers.end();++iter)
-                               {
-                                       if(!canvas_set)
-                                       {
-                                               param_list.add("canvas",Canvas::Handle(Layer::Handle(*iter)->get_canvas()));
-                                               canvas_set=true;
-                                       }
-                                       param_list.add("layer",Layer::Handle(*iter));
-                               }
-                       }
-
-                       {
-                               std::list<synfig::String>::iterator iter;
-
-                               for(iter=selected_groups.begin();iter!=selected_groups.end();++iter)
-                               {
-                                       param_list.add("group",(synfig::String)*iter);
-                               }
-                       }
-
-                       if(!canvas_set)
-                       {
-                               param_list.add("canvas",Canvas::Handle(get_canvas_interface()->get_canvas()));
-                               canvas_set=true;
-                       }
-
-                       handle<studio::Instance>::cast_static(get_canvas_interface()->get_instance())->
-                               add_actions_to_group(action_group_, ui_info,   param_list, synfigapp::Action::CATEGORY_GROUP);
-                       }
-       }
-
-       if(true)
-       {
-               ui_info="<ui><popup action='menu-main'><menu action='menu-group'>"+ui_info+"</menu></popup></ui>";
-               popup_id_=get_ui_manager()->add_ui_from_string(ui_info);
-       }
-       else
-       {
-               get_ui_manager()->ensure_update();
-       }
-
-#ifdef ONE_ACTION_GROUP
-#else
-       get_ui_manager()->insert_action_group(action_group_);
-#endif
-}
-
-void
-GroupActionManager::on_action_add()
-{
-       LayerGroupTreeStore::Model model;
-
-       String group_name;
-
-       Gtk::TreeIter selected_iter;
-
-       if(group_tree_->get_selection()->count_selected_rows())
-       {
-               selected_iter=(
-                       group_tree_->get_model()->get_iter(
-                               (*group_tree_->get_selection()->get_selected_rows().begin())
-                       )
-               );
-               if(selected_iter && selected_iter->parent())
-                       group_name=(Glib::ustring)(*selected_iter->parent())[model.group_name]+'.';
-       }
-
-       group_name+=_("UnnamedGroup");
-
-       Gtk::TreePath path(group_tree_->get_model()->on_group_added(group_name));
-
-       group_tree_->expand_to_path(path);
-       group_tree_->set_cursor(path,true);
-}
diff --git a/synfig-studio/src/gtkmm/groupactionmanager.h b/synfig-studio/src/gtkmm/groupactionmanager.h
deleted file mode 100644 (file)
index 0e232f9..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file groupactionmanager.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_GROUP_ACTION_MANAGER_H
-#define __SYNFIG_GROUP_ACTION_MANAGER_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/uimanager.h>
-#include <gtkmm/treeview.h>
-#include <synfigapp/canvasinterface.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 LayerGroupTree;
-
-class GroupActionManager
-{
-       Glib::RefPtr<Gtk::UIManager> ui_manager_;
-       LayerGroupTree* group_tree_;
-       etl::handle<synfigapp::CanvasInterface> canvas_interface_;
-
-       Glib::RefPtr<Gtk::ActionGroup>  action_group_;
-       Gtk::UIManager::ui_merge_id     popup_id_;
-
-       sigc::connection selection_changed_connection;
-
-       bool queued;
-       sigc::connection queue_refresh_connection;
-
-private:
-
-       void on_action_add();
-
-public:
-       void queue_refresh();
-
-       GroupActionManager();
-       ~GroupActionManager();
-
-       void set_ui_manager(const Glib::RefPtr<Gtk::UIManager> &x);
-       Glib::RefPtr<Gtk::UIManager> get_ui_manager()const { return ui_manager_; }
-
-       void set_group_tree(LayerGroupTree* x);
-       LayerGroupTree* get_group_tree()const { return group_tree_; }
-
-       void set_canvas_interface(const etl::handle<synfigapp::CanvasInterface> &x);
-       etl::handle<synfigapp::CanvasInterface> get_canvas_interface()const { return canvas_interface_; }
-
-       void refresh();
-       void clear();
-}; // END of GroupActionManager
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/historytreestore.cpp b/synfig-studio/src/gtkmm/historytreestore.cpp
deleted file mode 100644 (file)
index 1f0eb9c..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file historytreestore.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 <config.h>
-#endif
-
-#include "historytreestore.h"
-#include <synfig/valuenode.h>
-#include "iconcontroller.h"
-#include <synfig/valuenode_timedswap.h>
-#include <gtkmm/button.h>
-#include <synfigapp/action.h>
-#include "instance.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-static HistoryTreeStore::Model& ModelHack()
-{
-       static HistoryTreeStore::Model* model(0);
-       if(!model)model=new HistoryTreeStore::Model;
-       return *model;
-}
-
-HistoryTreeStore::HistoryTreeStore(etl::loose_handle<studio::Instance> instance_):
-       Gtk::TreeStore  (ModelHack()),
-       instance_               (instance_)
-{
-       instance_->signal_undo().connect(sigc::mem_fun(*this,&studio::HistoryTreeStore::on_undo));
-       instance_->signal_redo().connect(sigc::mem_fun(*this,&studio::HistoryTreeStore::on_redo));
-       instance_->signal_undo_stack_cleared().connect(sigc::mem_fun(*this,&studio::HistoryTreeStore::on_undo_stack_cleared));
-       instance_->signal_redo_stack_cleared().connect(sigc::mem_fun(*this,&studio::HistoryTreeStore::on_redo_stack_cleared));
-       instance_->signal_new_action().connect(sigc::mem_fun(*this,&studio::HistoryTreeStore::on_new_action));
-       instance_->signal_action_status_changed().connect(sigc::mem_fun(*this,&studio::HistoryTreeStore::on_action_status_changed));
-}
-
-HistoryTreeStore::~HistoryTreeStore()
-{
-       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
-               synfig::info("HistoryTreeStore::~HistoryTreeStore(): Deleted");
-}
-
-Glib::RefPtr<HistoryTreeStore>
-HistoryTreeStore::create(etl::loose_handle<studio::Instance> instance_)
-{
-       return Glib::RefPtr<HistoryTreeStore>(new HistoryTreeStore(instance_));
-}
-
-void
-HistoryTreeStore::rebuild()
-{
-       synfigapp::Action::Stack::const_iterator iter;
-
-       clear();
-
-       for(iter=instance()->undo_action_stack().begin();iter!=instance()->undo_action_stack().end();++iter)
-       {
-               insert_action(*(prepend()),*iter,true,true,false);
-       }
-       curr_row=*children().end();
-       for(iter=instance()->redo_action_stack().begin();iter!=instance()->redo_action_stack().end();++iter)
-       {
-               insert_action(*(append()),*iter,true,false,true);
-       }
-
-       signal_undo_tree_changed()();
-}
-
-void
-HistoryTreeStore::insert_action(Gtk::TreeRow row,etl::handle<synfigapp::Action::Undoable> action, bool /*is_active*/, bool is_undo, bool is_redo)
-{
-       assert(action);
-
-       row[model.action] = action;
-       row[model.name] = static_cast<Glib::ustring>(action->get_local_name());
-       row[model.is_active] = action->is_active();
-       row[model.is_undo] = is_undo;
-       row[model.is_redo] = is_redo;
-
-       synfigapp::Action::CanvasSpecific *specific_action;
-       specific_action=dynamic_cast<synfigapp::Action::CanvasSpecific*>(action.get());
-       if(specific_action)
-       {
-               row[model.canvas] = specific_action->get_canvas();
-               row[model.canvas_id] = specific_action->get_canvas()->get_id();
-       }
-
-       etl::handle<synfigapp::Action::Group> group;
-       group=etl::handle<synfigapp::Action::Group>::cast_dynamic(action);
-       if(group)
-       {
-               synfigapp::Action::ActionList::const_iterator iter;
-               for(iter=group->action_list().begin();iter!=group->action_list().end();++iter)
-               {
-                       Gtk::TreeRow child_row = *(append(row.children()));
-                       insert_action(child_row,*iter,true,is_undo,is_redo);
-               }
-       }
-
-       //row[model.icon] = Gtk::Button().render_icon(Gtk::StockID("synfig-canvas"),Gtk::ICON_SIZE_SMALL_TOOLBAR);
-}
-
-
-void
-HistoryTreeStore::on_undo()
-{
-       refresh();
-}
-
-void
-HistoryTreeStore::on_redo()
-{
-       refresh();
-}
-
-void
-HistoryTreeStore::on_undo_stack_cleared()
-{
-       Gtk::TreeModel::Children::iterator iter,next;
-       Gtk::TreeModel::Children children_(children());
-
-       for(next=children_.begin(),iter=next++; iter != children_.end(); iter=(next!=children_.end())?next++:next)
-       {
-               Gtk::TreeModel::Row row = *iter;
-               if(row[model.is_undo])
-                       erase(iter);
-       }
-}
-
-void
-HistoryTreeStore::on_redo_stack_cleared()
-{
-       Gtk::TreeModel::Children::iterator iter,next;
-       Gtk::TreeModel::Children children_(children());
-
-       for(next=children_.begin(),iter=next++; iter != children_.end(); iter=(next!=children_.end())?next++:next)
-       {
-               Gtk::TreeModel::Row row = *iter;
-               if(row[model.is_redo])
-                       erase(iter);
-       }
-}
-
-void
-HistoryTreeStore::on_new_action(etl::handle<synfigapp::Action::Undoable> action)
-{
-//     Gtk::TreeRow row = *(append());
-       Gtk::TreeRow row;
-       Gtk::TreeModel::Children::iterator iter;
-       for(iter=children().begin(); iter != children().end(); ++iter)
-       {
-               Gtk::TreeModel::Row row = *iter;
-               if(row[model.is_redo])
-               {
-                       break;
-               }
-       }
-
-       row=*insert(iter);
-
-       insert_action(row,action);
-
-       signal_undo_tree_changed()();
-}
-
-void
-HistoryTreeStore::on_action_status_changed(etl::handle<synfigapp::Action::Undoable> action)
-{
-       Gtk::TreeModel::Children::iterator iter;
-       Gtk::TreeModel::Children children_(children());
-
-       for(iter=children_.begin(); iter != children_.end(); ++iter)
-       {
-               Gtk::TreeModel::Row row = *iter;
-               if(action == (etl::handle<synfigapp::Action::Undoable>)row[model.action])
-               {
-                       row[model.is_active]=action->is_active();
-                       return;
-               }
-       }
-}
-
-bool
-HistoryTreeStore::search_func(const Glib::RefPtr<Gtk::TreeModel>&,int,const Glib::ustring& x,const Gtk::TreeModel::iterator& iter)
-{
-       const Model model;
-
-       Glib::ustring substr(x.uppercase());
-       Glib::ustring name((*iter)[model.name]);
-       name=name.uppercase();
-
-       return name.find(substr)==Glib::ustring::npos;
-}
diff --git a/synfig-studio/src/gtkmm/historytreestore.h b/synfig-studio/src/gtkmm/historytreestore.h
deleted file mode 100644 (file)
index 31a4b13..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file historytreestore.h
-**     \brief Template Header
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === S T A R T =========================================================== */
-
-#ifndef __SYNFIG_STUDIO_HISTORYTREESTORE_H
-#define __SYNFIG_STUDIO_HISTORYTREESTORE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/treestore.h>
-#include <synfigapp/canvasinterface.h>
-#include <gdkmm/pixbuf.h>
-#include <synfigapp/action.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 Instance;
-
-class HistoryTreeStore : virtual public Gtk::TreeStore
-{
-       /*
- -- ** -- P U B L I C   T Y P E S ---------------------------------------------
-       */
-
-public:
-
-       class Model : public Gtk::TreeModel::ColumnRecord
-       {
-       public:
-       public:
-               Gtk::TreeModelColumn<etl::handle<synfigapp::Action::Undoable> > action;
-               Gtk::TreeModelColumn<Glib::ustring> name;
-               Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
-               Gtk::TreeModelColumn<bool> is_active;
-               Gtk::TreeModelColumn<bool> is_undo;
-               Gtk::TreeModelColumn<bool> is_redo;
-
-               Gtk::TreeModelColumn<Glib::ustring> canvas_id;
-               Gtk::TreeModelColumn<synfig::Canvas::Handle> canvas;
-
-               Model()
-               {
-                       add(action);
-                       add(name);
-                       add(icon);
-                       add(is_active);
-                       add(is_undo);
-                       add(is_redo);
-                       add(canvas_id);
-                       add(canvas);
-               }
-       };
-
-       /*
- -- ** -- P U B L I C  D A T A ------------------------------------------------
-       */
-
-public:
-
-       const Model model;
-
-       /*
- -- ** -- P R I V A T E   D A T A ---------------------------------------------
-       */
-
-private:
-
-       etl::loose_handle<studio::Instance> instance_;
-       Gtk::TreeIter curr_row;
-
-       /*
- -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
-       */
-
-private:
-
-       /*
- -- ** -- P R I V A T E   D A T A ---------------------------------------------
-       */
-
-private:
-
-       sigc::signal<void> signal_undo_tree_changed_;
-
-       /*
- -- ** -- S I G N A L   I N T E R F A C E S -----------------------------------
-       */
-
-public:
-
-       sigc::signal<void>& signal_undo_tree_changed() { return signal_undo_tree_changed_; }
-
-       /*
- -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
-       */
-
-private:
-
-       void on_undo();
-
-       void on_redo();
-
-       void on_undo_stack_cleared();
-
-       void on_redo_stack_cleared();
-
-       void on_new_action(etl::handle<synfigapp::Action::Undoable> action);
-
-       void on_action_status_changed(etl::handle<synfigapp::Action::Undoable> action);
-
-       /*
- -- ** -- P U B L I C   M E T H O D S -----------------------------------------
-       */
-
-public:
-
-       HistoryTreeStore(etl::loose_handle<studio::Instance> instance_);
-       ~HistoryTreeStore();
-
-       etl::loose_handle<studio::Instance> instance() { return instance_; }
-       etl::loose_handle<const studio::Instance> instance()const { return instance_; }
-
-       void rebuild();
-
-       void refresh() { rebuild(); }
-
-       void insert_action(Gtk::TreeRow row,etl::handle<synfigapp::Action::Undoable> action, bool is_active=true, bool is_undo=true, bool is_redo=false);
-
-       static bool search_func(const Glib::RefPtr<TreeModel>&,int,const Glib::ustring&,const TreeModel::iterator&);
-
-       /*
- -- ** -- P R O T E C T E D   M E T H O D S -----------------------------------
-       */
-
-public:
-
-       static Glib::RefPtr<HistoryTreeStore> create(etl::loose_handle<studio::Instance> instance);
-
-}; // END of class HistoryTreeStore
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/iconcontroller.cpp b/synfig-studio/src/gtkmm/iconcontroller.cpp
deleted file mode 100644 (file)
index de86bbb..0000000
+++ /dev/null
@@ -1,442 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file iconcontroller.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 2008 Chris Moore
-**  Copyright (c) 2008 Paul Wise
-**  Copyright (c) 2009 Gerco Ballintijn
-**     Copyright (c) 2009 Carlos López
-**     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 <config.h>
-#endif
-
-#include "iconcontroller.h"
-#include <synfig/valuenode_const.h>
-#include <gtkmm/button.h>
-#include <gtkmm/window.h>
-#include <synfigapp/action.h>
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace etl;
-using namespace std;
-using namespace studio;
-using namespace synfig;
-
-/* === M A C R O S ========================================================= */
-
-#ifdef WIN32
-#      ifdef IMAGE_DIR
-#              undef IMAGE_DIR
-#              define IMAGE_DIR "share\\pixmaps"
-#      endif
-#endif
-
-#ifndef IMAGE_DIR
-#      define IMAGE_DIR "/usr/local/share/pixmaps"
-#endif
-
-
-#ifndef IMAGE_EXT
-#      define IMAGE_EXT        "png"
-#endif
-
-/* === M E T H O D S ======================================================= */
-
-static Glib::RefPtr<Gdk::Pixbuf> _tree_pixbuf_table_value_type[(int)synfig::ValueBase::TYPE_END];
-
-#ifdef WIN32
-IconController::IconController(const synfig::String& basepath)
-#else
-IconController::IconController(const synfig::String& /*basepath*/)
-#endif
-{
-       Gtk::IconSource icon_source;
-       icon_source.set_direction_wildcarded();
-       icon_source.set_state_wildcarded();
-       icon_source.set_size_wildcarded();
-       icon_factory=Gtk::IconFactory::create();
-
-       std::string path_to_icons;
-#ifdef WIN32
-       path_to_icons=basepath+ETL_DIRECTORY_SEPARATOR+".."+ETL_DIRECTORY_SEPARATOR+IMAGE_DIR;
-#else
-       path_to_icons=IMAGE_DIR;
-#endif
-
-       char* synfig_root=getenv("SYNFIG_ROOT");
-       if(synfig_root) {
-               path_to_icons=synfig_root;
-               path_to_icons+=ETL_DIRECTORY_SEPARATOR;
-               path_to_icons+="share";
-               path_to_icons+=ETL_DIRECTORY_SEPARATOR;
-               path_to_icons+="pixmaps";
-               path_to_icons+=ETL_DIRECTORY_SEPARATOR;
-               path_to_icons+="synfigstudio";
-       }
-       path_to_icons+=ETL_DIRECTORY_SEPARATOR;
-
-       try{
-       Gtk::Window::set_default_icon_from_file(path_to_icons+"synfig_icon."+IMAGE_EXT);
-       } catch(...)
-       {
-               synfig::warning("Unable to open "+path_to_icons+"synfig_icon."+IMAGE_EXT);
-       }
-
-#define INIT_STOCK_ICON(name,iconfile,desc){                                                   \
-       Gtk::StockItem stockitem(Gtk::StockID("synfig-" #name),desc); \
-       Gtk::Stock::add(stockitem);                                                             \
-       Gtk::IconSet icon_set;                                                                  \
-       icon_source.set_filename(path_to_icons+iconfile);                                                       \
-       icon_set.add_source(icon_source);                                               \
-       icon_factory->add(stockitem.get_stock_id(),icon_set); \
-       }
-
-#define INIT_STOCK_ICON_CLONE(name,stockid,desc){                                                      \
-       Gtk::StockItem stockitem(Gtk::StockID("synfig-" #name),desc); \
-       Gtk::Stock::add(stockitem);                                                             \
-       Gtk::IconSet icon_set;                                                                  \
-       if(Gtk::Stock::lookup(stockitem.get_stock_id(),icon_set))       \
-       icon_factory->add(stockitem.get_stock_id(),icon_set); \
-       }
-
-#define INIT_STOCK_ITEM(name,desc)                                                     \
-       stock_##name=Gtk::StockItem(Gtk::StockID("synfig-" #name),desc);                        \
-       Gtk::Stock::add(stock_##name);
-
-       INIT_STOCK_ICON(bool,"bool_icon."IMAGE_EXT,_("Bool"));
-       INIT_STOCK_ICON(integer,"integer_icon."IMAGE_EXT,_("Integer"));
-       INIT_STOCK_ICON(angle,"angle_icon."IMAGE_EXT,_("Angle"));
-       INIT_STOCK_ICON(time,"time_icon."IMAGE_EXT,_("Time"));
-       INIT_STOCK_ICON(real,"real_icon."IMAGE_EXT,_("Real"));
-       INIT_STOCK_ICON(vector,"vector_icon."IMAGE_EXT,_("Vector"));
-       INIT_STOCK_ICON(color,"color_icon."IMAGE_EXT,_("Color"));
-       INIT_STOCK_ICON(segment,"segment_icon."IMAGE_EXT,_("Segment"));
-       INIT_STOCK_ICON(blinepoint,"blinepoint_icon."IMAGE_EXT,_("BLine Point"));
-       INIT_STOCK_ICON(list,"list_icon."IMAGE_EXT,_("Rename"));
-       INIT_STOCK_ICON(canvas,"canvas_icon."IMAGE_EXT,_("Canvas"));
-       INIT_STOCK_ICON(string,"string_icon."IMAGE_EXT,_("Rename"));
-
-       INIT_STOCK_ICON(reset_colors,"reset_colors_icon."IMAGE_EXT,_("Reset Colors"));
-       INIT_STOCK_ICON(swap_colors,"swap_colors_icon."IMAGE_EXT,_("Swap Colors"));
-       INIT_STOCK_ICON(value_node,"valuenode_icon."IMAGE_EXT,_("ValueNode"));
-       INIT_STOCK_ICON(about,"about_icon."IMAGE_EXT,_("About"));
-       INIT_STOCK_ICON(rename,"rename_icon."IMAGE_EXT,_("Rename"));
-       INIT_STOCK_ICON(canvas_pointer,"canvas_pointer_icon."IMAGE_EXT,_("Rename"));
-       INIT_STOCK_ICON(canvas_new,"canvas_icon."IMAGE_EXT,_("New Canvas"));
-       INIT_STOCK_ICON(saveall,"saveall_icon."IMAGE_EXT,_("Save All"));
-       INIT_STOCK_ICON(layer,"layer_icon."IMAGE_EXT,_("Layer"));
-       INIT_STOCK_ICON(layer_pastecanvas,"pastecanvas_icon."IMAGE_EXT,_("Paste Canvas"));
-       INIT_STOCK_ICON(plant,"plant_icon."IMAGE_EXT,"");
-       INIT_STOCK_ICON(group,"group_icon."IMAGE_EXT,_("Group"));
-       INIT_STOCK_ICON(grid_enable,"grid_enable_icon."IMAGE_EXT,_("Show Grid"));
-       INIT_STOCK_ICON(grid_disable,"grid_disable_icon."IMAGE_EXT,_("Hide Grid"));
-       INIT_STOCK_ICON(grid_snap_enable,"grid_snap_enable_icon."IMAGE_EXT,_("Enable Grid Snap"));
-       INIT_STOCK_ICON(grid_snap_disable,"grid_snap_disable_icon."IMAGE_EXT,_("Disable Grid Snap"));
-       INIT_STOCK_ICON(duplicate,"duplicate_icon."IMAGE_EXT,_("Duplicate"));
-       INIT_STOCK_ICON(encapsulate,"encapsulate_icon."IMAGE_EXT,_("Encapsulate"));
-       INIT_STOCK_ICON(select_all_child_layers,"select_all_child_layers_icon."IMAGE_EXT,_("Select All Child Layers"));
-
-       INIT_STOCK_ICON(clear_undo,"clear_undo_icon."IMAGE_EXT,_("Clear Undo Stack"));
-       INIT_STOCK_ICON(clear_redo,"clear_redo_icon."IMAGE_EXT,_("Clear Redo Stack"));
-
-       INIT_STOCK_ICON(children,"children_icon."IMAGE_EXT,_("Children"));
-       INIT_STOCK_ICON(curves,"curves_icon."IMAGE_EXT,_("Curves"));
-       INIT_STOCK_ICON(keyframes,"keyframe_icon."IMAGE_EXT,_("Keyframes"));
-       INIT_STOCK_ICON(meta_data,"meta_data_icon."IMAGE_EXT,_("MetaData"));
-       INIT_STOCK_ICON(navigator,"navigator_icon."IMAGE_EXT,_("Navigator"));
-       INIT_STOCK_ICON(timetrack,"time_track_icon."IMAGE_EXT,_("Time Track"));
-
-       INIT_STOCK_ICON(keyframe_lock_all,"keyframe_lock_all."IMAGE_EXT,_("All Keyframes Locked"));
-       INIT_STOCK_ICON(keyframe_lock_past,"keyframe_lock_past."IMAGE_EXT,_("Past Keyframes Locked"));
-       INIT_STOCK_ICON(keyframe_lock_future,"keyframe_lock_future."IMAGE_EXT,_("Future Keyframes Locked"));
-       INIT_STOCK_ICON(keyframe_lock_none,"keyframe_lock_none."IMAGE_EXT,_("No Keyframes Locked"));
-
-       INIT_STOCK_ICON(set_outline_color,"set_outline_color."IMAGE_EXT,_("Set as Outline"));
-       INIT_STOCK_ICON(set_fill_color,"set_fill_color."IMAGE_EXT,_("Set as Fill"));
-
-       INIT_STOCK_ICON(seek_begin,"seek_begin."IMAGE_EXT,_("Seek to Begin"));
-       INIT_STOCK_ICON(seek_prev_frame,"seek_prev_frame."IMAGE_EXT,_("Previous Frame"));
-       INIT_STOCK_ICON(seek_next_frame,"seek_next_frame."IMAGE_EXT,_("Next Frame"));
-       INIT_STOCK_ICON(seek_end,"seek_end."IMAGE_EXT,_("Seek to End"));
-
-       INIT_STOCK_ICON(toggle_duck_position,"duck_position_icon."IMAGE_EXT,_("Toggle position ducks"));
-       INIT_STOCK_ICON(toggle_duck_vertex,"duck_vertex_icon."IMAGE_EXT,_("Toggle vertex ducks"));
-       INIT_STOCK_ICON(toggle_duck_tangent,"duck_tangent_icon."IMAGE_EXT,_("Toggle tangent ducks"));
-       INIT_STOCK_ICON(toggle_duck_radius,"duck_radius_icon."IMAGE_EXT,_("Toggle radius ducks"));
-       INIT_STOCK_ICON(toggle_duck_width,"duck_width_icon."IMAGE_EXT,_("Toggle width ducks"));
-       INIT_STOCK_ICON(toggle_duck_angle,"duck_angle_icon."IMAGE_EXT,_("Toggle angle ducks"));
-
-       INIT_STOCK_ICON(toggle_show_grid,"show_grid_icon."IMAGE_EXT,_("Toggle show grid"));
-       INIT_STOCK_ICON(toggle_snap_grid,"snap_grid_icon."IMAGE_EXT,_("Toggle snap grid"));
-
-       INIT_STOCK_ICON(toggle_onion_skin,"onion_skin_icon."IMAGE_EXT,_("Toggle onion skin"));
-
-       INIT_STOCK_ICON(increase_resolution,"incr_resolution_icon."IMAGE_EXT,_("Increase resolution"));
-       INIT_STOCK_ICON(decrease_resolution,"decr_resolution_icon."IMAGE_EXT,_("Decrease resolution"));
-
-       INIT_STOCK_ICON(preview_options,"preview_options_icon."IMAGE_EXT,_("Preview Options Dialog"));
-       INIT_STOCK_ICON(render_options,"render_options_icon."IMAGE_EXT,_("Render Options Dialog"));
-
-       INIT_STOCK_ICON_CLONE(cvs_add,"gtk-add",_("CVS Add"));
-       INIT_STOCK_ICON_CLONE(cvs_update,"gtk-open",_("CVS Update"));
-       INIT_STOCK_ICON_CLONE(cvs_commit,"gtk-save",_("CVS Commit"));
-       INIT_STOCK_ICON_CLONE(cvs_revert,"gtk-revert",_("CVS Revert"));
-
-       // Tools
-       INIT_STOCK_ICON(normal,"normal_icon."IMAGE_EXT,_("Normal Tool"));
-       INIT_STOCK_ICON(transform,"transform_icon."IMAGE_EXT,_("Transform Tool"));
-       INIT_STOCK_ICON(polygon,"polyline_icon."IMAGE_EXT,_("Polygon Tool"));
-       INIT_STOCK_ICON(bline,"bline_icon."IMAGE_EXT,_("BLine Tool"));
-       INIT_STOCK_ICON(eyedrop,"eyedrop_icon."IMAGE_EXT,_("Eyedrop Tool"));
-       INIT_STOCK_ICON(fill,"fill_icon."IMAGE_EXT,_("Fill Tool"));
-       INIT_STOCK_ICON(draw,"draw_icon."IMAGE_EXT,_("Draw Tool"));
-       INIT_STOCK_ICON(sketch,"sketch_icon."IMAGE_EXT,_("Sketch Tool"));
-       INIT_STOCK_ICON(circle,"circle_icon."IMAGE_EXT,_("Circle Tool"));
-       INIT_STOCK_ICON(rectangle,"rectangle_icon."IMAGE_EXT,_("Rectangle Tool"));
-       INIT_STOCK_ICON(smooth_move,"smooth_move_icon."IMAGE_EXT,_("SmoothMove Tool"));
-       INIT_STOCK_ICON(rotate,"rotate_icon."IMAGE_EXT,"Rotate Tool");
-       INIT_STOCK_ICON(width,"width_icon."IMAGE_EXT,_("Width Tool"));
-       INIT_STOCK_ICON(scale,"scale_icon."IMAGE_EXT,"Scale Tool");
-       INIT_STOCK_ICON(zoom,"zoom_icon."IMAGE_EXT,_("Zoom Tool"));
-       INIT_STOCK_ICON(info,"info_icon."IMAGE_EXT,_("Info Tool"));
-       INIT_STOCK_ICON(mirror,"mirror_icon."IMAGE_EXT,_("Mirror Tool"));
-       INIT_STOCK_ICON(text,"text_icon."IMAGE_EXT,"Text Tool");
-       INIT_STOCK_ICON(gradient,"gradient_icon."IMAGE_EXT,_("Gradient Tool"));
-       INIT_STOCK_ICON(star,"star_icon."IMAGE_EXT,_("Star Tool"));
-
-#undef INIT_STOCK_ICON
-#undef INIT_STOCK_ICON
-
-       icon_factory->add_default();
-
-       Gtk::IconSize::register_new("synfig-small_icon",12,12);
-       Gtk::IconSize::register_new("synfig-small_icon_16x16",16,16);
-
-       for(int i(0);i<(int)ValueBase::TYPE_END;i++)
-               _tree_pixbuf_table_value_type[i]=Gtk::Button().render_icon(value_icon(ValueBase::Type(i)),Gtk::ICON_SIZE_SMALL_TOOLBAR);
-
-}
-
-IconController::~IconController()
-{
-       for(int i(0);i<(int)ValueBase::TYPE_END;i++)
-               _tree_pixbuf_table_value_type[i]=Glib::RefPtr<Gdk::Pixbuf>();
-
-       icon_factory->remove_default();
-}
-
-Gdk::Cursor
-IconController::get_normal_cursor()
-{
-       return Gdk::Cursor(Gdk::TOP_LEFT_ARROW);
-}
-
-Gdk::Cursor
-IconController::get_tool_cursor(const Glib::ustring& name,const Glib::RefPtr<Gdk::Window>& window)
-{
-       //this function is never called
-       //it is commented out in WorkArea::refresh_cursor()
-       assert(0);
-       // \todo Do we still need it?
-
-       Glib::RefPtr<Gdk::Pixmap> pixmap;
-       pixmap=Gdk::Pixmap::create(window, 64, 64, 8);
-       pixmap->set_colormap(window->get_colormap());
-       //pixmap->set_colormap(Gdk::Colormap::create(pixmap->get_visual(),false));
-       Glib::RefPtr<Gdk::Pixbuf> pixbuf;
-       pixbuf=Gtk::Button().render_icon(Gtk::StockID("synfig-"+name),Gtk::ICON_SIZE_SMALL_TOOLBAR);
-
-       pixbuf->render_to_drawable_alpha(
-               pixmap,
-               0,0,    // SOURCE X,Y
-               0,0,    // DEST X Y
-               -1,-1,  // WIDTH HEIGHT
-               Gdk::PIXBUF_ALPHA_FULL, // (ignored)
-               64,             //int alpha_threshold,
-               Gdk::RGB_DITHER_MAX,            //RgbDither dither,
-               2,2     //int x_dither, int y_dither
-       );
-/*
-       pixmap->draw_pixbuf(
-               Glib::RefPtr<const Gdk::GC>(0), // GC
-               pixbuf,
-               0, 0, // Source X,Y
-               0, 0, // Dest X,Y
-               -1, -1, // Width, Height
-               Gdk::RGB_DITHER_MAX, // Dither
-               0,0 // Dither X,Y
-       );
-*/
-
-       Gdk::Color FG("#000000");
-       Gdk::Color BG("#FF00FF");
-
-       return Gdk::Cursor(pixmap, pixmap, FG, BG, 0, 0);
-}
-
-Gtk::StockID
-studio::value_icon(synfig::ValueBase::Type type)
-{
-               switch(type)
-               {
-               case ValueBase::TYPE_BOOL:
-                       return Gtk::StockID("synfig-bool");
-                       break;
-               case ValueBase::TYPE_INTEGER:
-                       return Gtk::StockID("synfig-integer");
-                       break;
-               case ValueBase::TYPE_ANGLE:
-                       return Gtk::StockID("synfig-angle");
-                       break;
-               case ValueBase::TYPE_TIME:
-                       return Gtk::StockID("synfig-time");
-                       break;
-               case ValueBase::TYPE_REAL:
-                       return Gtk::StockID("synfig-real");
-                       break;
-               case ValueBase::TYPE_VECTOR:
-                       return Gtk::StockID("synfig-vector");
-                       break;
-               case ValueBase::TYPE_COLOR:
-                       return Gtk::StockID("synfig-color");
-                       break;
-               case ValueBase::TYPE_SEGMENT:
-                       return Gtk::StockID("synfig-segment");
-                       break;
-               case ValueBase::TYPE_BLINEPOINT:
-                       return Gtk::StockID("synfig-blinepoint");
-                       break;
-               case ValueBase::TYPE_LIST:
-                       return Gtk::StockID("synfig-list");
-                       break;
-               case ValueBase::TYPE_CANVAS:
-                       return Gtk::StockID("synfig-canvas_pointer");
-                       break;
-               case ValueBase::TYPE_STRING:
-                       return Gtk::StockID("synfig-string");
-                       break;
-               case ValueBase::TYPE_GRADIENT:
-                       return Gtk::StockID("synfig-gradient");
-                       break;
-               case ValueBase::TYPE_NIL:
-               default:
-                       return Gtk::StockID("synfig-unknown");
-                       break;
-               }
-}
-
-Gtk::StockID
-studio::valuenode_icon(etl::handle<synfig::ValueNode> value_node)
-{
-       if(handle<ValueNode_Const>::cast_dynamic(value_node))
-       {
-               return value_icon(value_node->get_type());
-       }
-       else
-       {
-               return Gtk::StockID("synfig-value_node");
-       }
-}
-
-Glib::RefPtr<Gdk::Pixbuf>
-studio::get_tree_pixbuf(synfig::ValueBase::Type type)
-{
-       //return Gtk::Button().render_icon(value_icon(type),Gtk::ICON_SIZE_SMALL_TOOLBAR);
-       return _tree_pixbuf_table_value_type[int(type)];
-}
-
-#ifdef WIN32
-#define TEMPORARY_DELETE_MACRO DELETE
-#undef DELETE
-#endif
-
-Gtk::StockID
-studio::get_action_stock_id(const synfigapp::Action::BookEntry& action)
-{
-       Gtk::StockID stock_id;
-       if(action.task=="add")                          stock_id=Gtk::Stock::ADD;
-       else if(action.task=="connect")         stock_id=Gtk::Stock::CONNECT;
-       else if(action.task=="disconnect")      stock_id=Gtk::Stock::DISCONNECT;
-       else if(action.task=="insert")          stock_id=Gtk::Stock::ADD;
-       else if(action.task=="lower")           stock_id=Gtk::Stock::GO_DOWN;
-       else if(action.task=="move_bottom")     stock_id=Gtk::Stock::GOTO_BOTTOM;
-       else if(action.task=="move_top")        stock_id=Gtk::Stock::GOTO_TOP;
-       else if(action.task=="raise")           stock_id=Gtk::Stock::GO_UP;
-       else if(action.task=="remove")          stock_id=Gtk::Stock::DELETE;
-       else if(action.task=="set_off")         stock_id=Gtk::Stock::NO;
-       else if(action.task=="set_on")          stock_id=Gtk::Stock::YES;
-       else                                                            stock_id=Gtk::StockID("synfig-"+
-                                                                                                                         action.task);
-       return stock_id;
-}
-
-#ifdef WIN32
-#define DELETE TEMPORARY_DELETE_MACRO
-#undef TEMPORARY_DELETE_MACRO
-#endif
-
-Gtk::StockID
-studio::layer_icon(const synfig::String &layer)
-{
-       if(layer=="PasteCanvas" || layer=="pastecanvas" || layer=="paste_canvas")
-               return Gtk::StockID("synfig-layer_pastecanvas");
-       else if(layer=="rotate")
-               return Gtk::StockID("synfig-rotate");
-       else if(layer=="zoom")
-               return Gtk::StockID("synfig-zoom");
-       else if(layer=="region")
-               return Gtk::StockID("synfig-bline");
-       else if(layer=="polygon")
-               return Gtk::StockID("synfig-polygon");
-       else if(layer=="outline")
-               return Gtk::StockID("synfig-width");
-       else if(layer=="circle")
-               return Gtk::StockID("synfig-circle");
-       else if(layer=="rectangle")
-               return Gtk::StockID("synfig-rectangle");
-       else if(layer=="star")
-               return Gtk::StockID("synfig-star");
-       else if(layer=="plant")
-               return Gtk::StockID("synfig-plant");
-       else if(layer=="text")
-               return Gtk::StockID("synfig-text");
-       else if(layer.find("gradient")!=String::npos)
-               return Gtk::StockID("synfig-gradient");
-       else
-               return Gtk::StockID("synfig-layer");
-}
-
-Glib::RefPtr<Gdk::Pixbuf>
-studio::get_tree_pixbuf_layer(const synfig::String &layer)
-{
-       return Gtk::Button().render_icon(layer_icon(layer),Gtk::ICON_SIZE_SMALL_TOOLBAR);
-}
diff --git a/synfig-studio/src/gtkmm/iconcontroller.h b/synfig-studio/src/gtkmm/iconcontroller.h
deleted file mode 100644 (file)
index fa48cf1..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file iconcontroller.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_ICONCONTROLLER_H
-#define __SYNFIG_STUDIO_ICONCONTROLLER_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/stock.h>
-#include <gtkmm/iconfactory.h>
-#include <gtkmm/iconset.h>
-#include <gdkmm/cursor.h>
-
-#include <synfig/value.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 synfig { class ValueNode; class Layer; }
-
-namespace synfigapp { namespace Action { class BookEntry; };};
-
-namespace studio {
-
-
-class IconController
-{
-       Glib::RefPtr<Gtk::IconFactory> icon_factory;
-public:
-       IconController(const synfig::String& basepath);
-       ~IconController();
-
-       static Gdk::Cursor get_normal_cursor();
-       static Gdk::Cursor get_tool_cursor(const Glib::ustring& name,const Glib::RefPtr<Gdk::Window>& window);
-};
-
-Gtk::StockID layer_icon(const synfig::String &layer);
-Glib::RefPtr<Gdk::Pixbuf> get_tree_pixbuf_layer(const synfig::String &layer);
-
-Gtk::StockID value_icon(synfig::ValueBase::Type type);
-Gtk::StockID valuenode_icon(etl::handle<synfig::ValueNode> value_node);
-Glib::RefPtr<Gdk::Pixbuf> get_tree_pixbuf(synfig::ValueBase::Type type);
-Gtk::StockID get_action_stock_id(const synfigapp::Action::BookEntry& action);
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/instance.cpp b/synfig-studio/src/gtkmm/instance.cpp
deleted file mode 100644 (file)
index 62d63a0..0000000
+++ /dev/null
@@ -1,1150 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file gtkmm/instance.cpp
-**     \brief writeme
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 2008 Chris Moore
-**     Copyright (c) 2008 Carlos López
-**     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 <config.h>
-#endif
-
-#include "instance.h"
-#include <cassert>
-#include <gtkmm/stock.h>
-#include <gtkmm/image.h>
-#include <iostream>
-#include <gtkmm/button.h>
-#include "canvasview.h"
-#include "app.h"
-#include <sigc++/signal.h>
-#include <sigc++/adaptors/hide.h>
-#include "toolbox.h"
-#include "onemoment.h"
-#include <synfig/savecanvas.h>
-
-#include "autorecover.h"
-#include <sigc++/retype_return.h>
-#include <sigc++/retype.h>
-//#include <sigc++/hide.h>
-#include <synfig/valuenode_composite.h>
-#include <synfig/valuenode_duplicate.h>
-#include "widget_waypointmodel.h"
-#include <gtkmm/actiongroup.h>
-#include "iconcontroller.h"
-#include "workarea.h"
-#include <sys/stat.h>
-#include <errno.h>
-#include <ETL/stringf>
-
-#include "general.h"
-
-#endif
-
-using namespace std;
-using namespace etl;
-using namespace synfig;
-using namespace studio;
-using namespace sigc;
-
-/* === M A C R O S ========================================================= */
-
-/* === G L O B A L S ======================================================= */
-
-int studio::Instance::instance_count_=0;
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Instance::Instance(synfig::Canvas::Handle canvas):
-       synfigapp::Instance             (canvas),
-       canvas_tree_store_              (Gtk::TreeStore::create(canvas_tree_model)),
-       history_tree_store_             (HistoryTreeStore::create(this)),
-       undo_status_(false),
-       redo_status_(false)
-{
-       id_=instance_count_++;
-
-       // Connect up all the signals
-       signal_filename_changed().connect(sigc::mem_fun(*this,&studio::Instance::update_all_titles));
-       signal_unsaved_status_changed().connect(sigc::hide(sigc::mem_fun(*this,&studio::Instance::update_all_titles)));
-       signal_undo_status().connect(sigc::mem_fun(*this,&studio::Instance::set_undo_status));
-       signal_redo_status().connect(sigc::mem_fun(*this,&studio::Instance::set_redo_status));
-
-       signal_saved().connect(
-               sigc::hide_return(
-                       sigc::ptr_fun(
-                               studio::AutoRecover::auto_backup
-                       )
-               )
-       );
-
-       refresh_canvas_tree();
-}
-
-Instance::~Instance()
-{
-}
-
-int
-Instance::get_visible_canvases()const
-{
-       int count(0);
-       CanvasViewList::const_iterator iter;
-       for(iter=canvas_view_list_.begin();iter!=canvas_view_list_.end();++iter)
-               if((*iter)->is_visible())
-                       count++;
-       return count;
-}
-
-handle<Instance>
-Instance::create(synfig::Canvas::Handle canvas)
-{
-       // Construct a new instance
-       handle<Instance> instance(new Instance(canvas));
-
-       // Add the new instance to the application's instance list
-       App::instance_list.push_back(instance);
-
-       // Set up the instance with the default UI manager
-       instance->synfigapp::Instance::set_ui_interface(App::get_ui_interface());
-
-       // Signal the new instance
-       App::signal_instance_created()(instance);
-
-       // And then make sure that is has been selected
-       App::set_selected_instance(instance);
-
-       // Create the initial window for the root canvas
-       instance->focus(canvas);
-
-       return instance;
-}
-
-handle<CanvasView>
-Instance::find_canvas_view(etl::handle<synfig::Canvas> canvas)
-{
-       if(!canvas)
-               return 0;
-
-       while(canvas->is_inline())
-               canvas=canvas->parent();
-
-       CanvasViewList::iterator iter;
-
-       for(iter=canvas_view_list().begin();iter!=canvas_view_list().end();iter++)
-               if((*iter)->get_canvas()==canvas)
-                       return *iter;
-
-       return CanvasView::create(this,canvas);
-}
-
-void
-Instance::focus(etl::handle<synfig::Canvas> canvas)
-{
-       handle<CanvasView> canvas_view=find_canvas_view(canvas);
-       assert(canvas_view);
-       canvas_view->present();
-}
-
-void
-Instance::set_undo_status(bool x)
-{
-       undo_status_=x;
-       App::toolbox->update_undo_redo();
-       signal_undo_redo_status_changed()();
-}
-
-void
-Instance::set_redo_status(bool x)
-{
-       redo_status_=x;
-       App::toolbox->update_undo_redo();
-       signal_undo_redo_status_changed()();
-}
-
-bool
-studio::Instance::save_as(const synfig::String &file_name)
-{
-       if(synfigapp::Instance::save_as(file_name))
-       {
-               // after changing the filename, update the render settings with the new filename
-               list<handle<CanvasView> >::iterator iter;
-               for(iter=canvas_view_list().begin();iter!=canvas_view_list().end();iter++)
-                       (*iter)->render_settings.set_entry_filename();
-               App::add_recent_file(etl::handle<Instance>(this));
-               return true;
-       }
-       return false;
-}
-
-void
-studio::Instance::open()
-{
-       App::dialog_open(get_file_name());
-}
-
-Instance::Status
-studio::Instance::save()
-{
-       // if we don't have a real filename yet then we need to ask where to save it
-       if (!has_real_filename())
-       {
-               if (dialog_save_as())
-                       return STATUS_OK;
-               else
-                       return STATUS_CANCEL;
-       }
-
-       if (synfigapp::Instance::save())
-       {
-               App::add_recent_file(etl::handle<Instance>(this));
-               return STATUS_OK;
-       }
-       string msg(strprintf(_("Unable to save to '%s'"), get_file_name().c_str()));
-       App::dialog_error_blocking(_("Save - Error"), msg.c_str());
-       return STATUS_ERROR;
-}
-
-// the filename will be set to "Synfig Animation 1" or some such when first created
-// and will be changed to an absolute path once it has been saved
-// so if it still begins with "Synfig Animation " then we don't have a real filename yet
-bool
-studio::Instance::has_real_filename()
-{
-       return get_file_name().find(App::custom_filename_prefix.c_str()) != 0;
-}
-
-bool
-studio::Instance::dialog_save_as()
-{
-       string filename = get_file_name();
-       Canvas::Handle canvas(get_canvas());
-
-       {
-               OneMoment one_moment;
-               std::set<Node*>::iterator iter;
-               for(iter=canvas->parent_set.begin();iter!=canvas->parent_set.end();++iter)
-               {
-                       synfig::Node* node(*iter);
-                       for(;!node->parent_set.empty();node=*node->parent_set.begin())
-                       {
-                               Layer::Handle parent_layer(dynamic_cast<Layer*>(node));
-                               if(parent_layer && parent_layer->get_canvas()->get_root()!=get_canvas())
-                               {
-                                       //! \todo Fix big involving "Save As" with referenced compositions
-                                       string msg(strprintf(_("There is currently a bug when using \"SaveAs\"\n"
-                                               "on a composition that is being referenced by other\n"
-                                               "files that are currently open. Close these\n"
-                                               "other files first before trying to use \"SaveAs\".")));
-                                       App::dialog_error_blocking(_("SaveAs - Error"), msg.c_str());
-
-                                       return false;
-                               }
-                               if(parent_layer)
-                                       break;
-                       }
-               }
-       }
-
-       if (has_real_filename())
-               filename = absolute_path(filename);
-
-       // show the canvas' name if it has one, else its ID
-       while (App::dialog_save_file((_("Choose a Filename to Save As") +
-                                                                 String(" (") +
-                                                                 (canvas->get_name().empty() ? canvas->get_id() : canvas->get_name()) +
-                                                                 ") ..."),
-                                                                filename, ANIMATION_DIR_PREFERENCE))
-       {
-               // If the filename still has wildcards, then we should
-               // continue looking for the file we want
-               string base_filename = basename(filename);
-               if (find(base_filename.begin(),base_filename.end(),'*')!=base_filename.end())
-                       continue;
-
-               if (filename_extension(filename) == "")
-                       filename+=".sifz";
-
-               try
-               {
-                       String ext(filename_extension(filename));
-                       if(ext!=".sif" && ext!=".sifz" && !App::dialog_yes_no(_("Unknown extension"),
-                               _("You have given the file name an extension\nwhich I do not recognize. Are you sure this is what you want?")))
-                               continue;
-               }
-               catch(...)
-               {
-                       continue;
-               }
-
-               {
-                       struct stat     s;
-                       int stat_return = stat(filename.c_str(), &s);
-
-                       // if stat() fails with something other than 'file doesn't exist', there's been a real
-                       // error of some kind.  let's give up now and ask for a new path.
-                       if (stat_return == -1 && errno != ENOENT)
-                       {
-                               perror(filename.c_str());
-                               string msg(strprintf(_("Unable to check whether '%s' exists."), filename.c_str()));
-                               App::dialog_error_blocking(_("SaveAs - Error"),msg.c_str());
-                               continue;
-                       }
-
-                       // if the file exists and the user doesn't want to overwrite it, keep prompting for a filename
-                       string msg(strprintf(_("A file named '%s' already exists.\n\n"
-                                                                       "Do you want to replace it with the file you are saving?"), filename.c_str()));
-                       if ((stat_return == 0) &&
-                               !App::dialog_yes_no(_("File exists"),msg.c_str()))
-                               continue;
-               }
-
-               if(save_as(filename))
-               {
-                       synfig::set_file_version(ReleaseVersion(RELEASE_VERSION_END-1));
-                       return true;
-               }
-               string msg(strprintf(_("Unable to save to '%s'"), filename.c_str()));
-               App::dialog_error_blocking(_("SaveAs - Error"),msg.c_str());
-       }
-
-       return false;
-}
-
-void
-Instance::update_all_titles()
-{
-       list<handle<CanvasView> >::iterator iter;
-       for(iter=canvas_view_list().begin();iter!=canvas_view_list().end();iter++)
-               (*iter)->update_title();
-}
-
-void
-Instance::close()
-{
-       // This will increase the reference count so we don't get DELETED
-       // until we are ready
-       handle<Instance> me(this);
-
-       // Make sure we aren't selected as the current instance
-       if(studio::App::get_selected_instance()==this)
-               studio::App::set_selected_instance(0);
-
-       // Turn-off/clean-up auto recovery
-       studio::App::auto_recover->clear_backup(get_canvas());
-
-       // Remove us from the active instance list
-       std::list<etl::handle<studio::Instance> >::iterator iter;
-       for(iter=studio::App::instance_list.begin();iter!=studio::App::instance_list.end();iter++)
-               if(*iter==this)
-                       break;
-       assert(iter!=studio::App::instance_list.end());
-       if(iter!=studio::App::instance_list.end())
-               studio::App::instance_list.erase(iter);
-
-       // Send out a signal that we are being deleted
-       studio::App::signal_instance_deleted()(this);
-
-       // Hide all of the canvas views
-       for(std::list<etl::handle<CanvasView> >::iterator iter=canvas_view_list().begin();iter!=canvas_view_list().end();iter++)
-               (*iter)->hide();
-
-       // Consume pending events before deleting the canvas views
-       while(studio::App::events_pending())studio::App::iteration(false);
-
-       // Delete all of the canvas views
-       canvas_view_list().clear();
-
-       // If there is another open instance to select,
-       // go ahead and do so. If not, never mind.
-       if(studio::App::instance_list.empty())
-       {
-               studio::App::set_selected_canvas_view(0);
-               studio::App::set_selected_instance(0);
-       }
-       else
-               studio::App::instance_list.front()->canvas_view_list().front()->present();
-}
-
-void
-Instance::insert_canvas(Gtk::TreeRow row, synfig::Canvas::Handle canvas)
-{
-       CanvasTreeModel canvas_tree_model;
-       assert(canvas);
-
-       row[canvas_tree_model.icon] = Gtk::Button().render_icon(Gtk::StockID("synfig-canvas"),Gtk::ICON_SIZE_SMALL_TOOLBAR);
-       row[canvas_tree_model.id] = canvas->get_id();
-       row[canvas_tree_model.name] = canvas->get_name();
-       if(canvas->is_root())
-               row[canvas_tree_model.label] = basename(canvas->get_file_name());
-       else
-       if(!canvas->get_id().empty())
-               row[canvas_tree_model.label] = canvas->get_id();
-       else
-       if(!canvas->get_name().empty())
-               row[canvas_tree_model.label] = canvas->get_name();
-       else
-               row[canvas_tree_model.label] = _("[Unnamed]");
-
-       row[canvas_tree_model.canvas] = canvas;
-       row[canvas_tree_model.is_canvas] = true;
-       row[canvas_tree_model.is_value_node] = false;
-
-       {
-               synfig::Canvas::Children::iterator iter;
-               synfig::Canvas::Children &children(canvas->children());
-
-               for(iter=children.begin();iter!=children.end();iter++)
-                       insert_canvas(*(canvas_tree_store()->append(row.children())),*iter);
-       }       
-}
-
-void
-Instance::refresh_canvas_tree()
-{
-       canvas_tree_store()->clear();
-       Gtk::TreeRow row = *(canvas_tree_store()->prepend());
-       insert_canvas(row,get_canvas());
-}
-
-void
-Instance::dialog_cvs_commit()
-{
-       calc_repository_info();
-       if(!in_repository())
-       {
-               App::dialog_error_blocking(_("Error"),_("You must first add this composition to the repository"));
-               return;
-       }
-       try
-       {
-               string message;
-
-               if(synfigapp::Instance::get_action_count())
-               {
-                       if(!App::dialog_yes_no(_("CVS Commit"), _("This will save any changes you have made. Are you sure?")))
-                               return;
-                       save();
-               }
-
-               if(!is_modified())
-               {
-                       App::dialog_error_blocking(_("Error"),_("The local copy of the file hasn't been changed since the last update.\nNothing to commit!"));
-                       return;
-               }
-
-               if(!App::dialog_entry(_("CVS Commit"),_("Enter a log message describing the changes you have made"), message))
-                       return;
-
-               OneMoment one_moment;
-               cvs_commit(message);
-       }
-       catch(...)
-       {
-               App::dialog_error_blocking(_("Error"),_("An error has occurred when trying to COMMIT"));
-       }
-       update_all_titles();
-}
-
-void
-Instance::dialog_cvs_add()
-{
-       calc_repository_info();
-       if(in_repository())
-       {
-               App::dialog_error_blocking(_("Error"),_("This composition has already been added to the repository"));
-               return;
-       }
-       try
-       {
-               string message;
-
-               //if(!App::dialog_entry(_("CVS Add"),_("Enter a log message describing the file"), message))
-               //      return;
-               OneMoment one_moment;
-               cvs_add();
-       }
-       catch(...)
-       {
-               App::dialog_error_blocking(_("Error"),_("An error has occurred when trying to ADD"));
-       }
-       update_all_titles();
-}
-
-void
-Instance::dialog_cvs_update()
-{
-       calc_repository_info();
-       if(!in_repository())
-       {
-               App::dialog_error_blocking(_("Error"),_("This file is not under version control, so there is nothing to update from!"));
-               return;
-       }
-       if(!is_updated())
-       {
-               App::dialog_error_blocking(_("Info"),_("This file is up-to-date"));
-               return;
-       }
-
-       try
-       {
-               String filename(get_file_name());
-               if(synfigapp::Instance::get_action_count())
-               {
-                       if(!App::dialog_yes_no(_("CVS Update"), _("This will save any changes you have made. Are you sure?")))
-                               return;
-                       save();
-               }
-               OneMoment one_moment;
-               time_t oldtime=get_original_timestamp();
-               cvs_update();
-               calc_repository_info();
-               // If something has been updated...
-               if(oldtime!=get_original_timestamp())
-               {
-                       revert();
-               }
-       }
-       catch(...)
-       {
-               App::dialog_error_blocking(_("Error"),_("An error has occurred when trying to UPDATE"));
-       }
-       //update_all_titles();
-}
-
-void
-Instance::dialog_cvs_revert()
-{
-       calc_repository_info();
-       if(!in_repository())
-       {
-               App::dialog_error_blocking(_("Error"),_("This file is not under version control, so there is nothing to revert to!"));
-               return;
-       }
-       try
-       {
-               String filename(get_file_name());
-               if(!App::dialog_yes_no(_("CVS Revert"),
-                       _("This will abandon all changes you have made\nsince the last time you performed a commit\noperation. This cannot be undone! Are you sure\nyou want to do this?")
-               ))
-                       return;
-
-               OneMoment one_moment;
-
-               // Remove the old file
-               if(remove(get_file_name().c_str())!=0)
-               {
-                       App::dialog_error_blocking(_("Error"),_("Unable to remove previous version"));
-                       return;
-               }
-
-               cvs_update();
-               revert();
-       }
-       catch(...)
-       {
-               App::dialog_error_blocking(_("Error"),_("An error has occurred when trying to UPDATE"));
-       }
-       //update_all_titles();
-}
-
-void
-Instance::_revert(Instance *instance)
-{
-       OneMoment one_moment;
-
-       String filename(instance->get_file_name());
-
-       Canvas::Handle canvas(instance->get_canvas());
-
-       instance->close();
-
-       if(canvas->count()!=1)
-       {
-               one_moment.hide();
-               App::dialog_error_blocking(_("Error: Revert Failed"),_("The revert operation has failed. This can be due to it being\nreferenced by another composition that is already open, or\nbecause of an internal error in Synfig Studio. Try closing any\ncompositions that might reference this composition and try\nagain, or restart Synfig Studio."));
-               one_moment.show();
-       }
-       canvas=0;
-
-       App::open(filename);
-}
-
-void
-Instance::revert()
-{
-       // Schedule a revert to occur in a few moments
-       Glib::signal_timeout().connect(
-               sigc::bind_return(
-                       sigc::bind(
-                               sigc::ptr_fun(&Instance::_revert),
-                               this
-                       ),
-                       false
-               )
-               ,500
-       );
-}
-
-bool
-Instance::safe_revert()
-{
-       if(synfigapp::Instance::get_action_count())
-               if(!App::dialog_yes_no(_("Revert to saved"), _("You will lose any changes you have made since your last save.\nAre you sure?")))
-                       return false;
-       revert();
-       return true;
-}
-
-bool
-Instance::safe_close()
-{
-       handle<CanvasView> canvas_view = find_canvas_view(get_canvas());
-       handle<synfigapp::UIInterface> uim=canvas_view->get_ui_interface();
-
-       // if the animation is currently playing, closing the window will cause a crash,
-       // so don't allow it
-       if (canvas_view->is_playing())
-       {
-               canvas_view->present();
-               App::dialog_error_blocking("Close Error", "The animation is currently playing so the window cannot be closed.");
-               return false;
-       }
-       if(get_action_count())
-               do
-               {
-                       string str=strprintf(_("Would you like to save your changes to %s?"),basename(get_file_name()).c_str() );
-                       int answer=uim->yes_no_cancel(get_canvas()->get_name(),str,synfigapp::UIInterface::RESPONSE_YES);
-                       if(answer==synfigapp::UIInterface::RESPONSE_YES)
-                       {
-                               enum Status status = save();
-                               if (status == STATUS_OK) break;
-                               else if (status == STATUS_CANCEL) return false;
-                       }
-                       if(answer==synfigapp::UIInterface::RESPONSE_NO)
-                               break;
-                       if(answer==synfigapp::UIInterface::RESPONSE_CANCEL)
-                               return false;
-               } while (true);
-
-       if(is_modified())
-       {
-               string str=strprintf(_("%s has changes not yet on the CVS repository.\nWould you like to commit these changes?"),basename(get_file_name()).c_str());
-               int answer=uim->yes_no_cancel(get_canvas()->get_name(),str,synfigapp::UIInterface::RESPONSE_YES);
-
-               if(answer==synfigapp::UIInterface::RESPONSE_YES)
-                       dialog_cvs_commit();
-               if(answer==synfigapp::UIInterface::RESPONSE_CANCEL)
-                       return false;
-       }
-
-       close();
-
-       return true;
-}
-
-void
-Instance::add_actions_to_group(const Glib::RefPtr<Gtk::ActionGroup>& action_group, synfig::String& ui_info,   const synfigapp::Action::ParamList &param_list, synfigapp::Action::Category category)const
-{
-       synfigapp::Action::CandidateList candidate_list;
-       synfigapp::Action::CandidateList::iterator iter;
-
-       candidate_list=compile_candidate_list(param_list,category);
-
-       candidate_list.sort();
-
-       // if(candidate_list.empty())
-       //      synfig::warning("%s:%d Action CandidateList is empty!", __FILE__, __LINE__);
-
-       for(iter=candidate_list.begin();iter!=candidate_list.end();++iter)
-       {
-               Gtk::StockID stock_id(get_action_stock_id(*iter));
-
-               if(!(iter->category&synfigapp::Action::CATEGORY_HIDDEN))
-               {
-                       action_group->add(Gtk::Action::create(
-                               "action-"+iter->name,
-                               stock_id,
-                               iter->local_name,iter->local_name
-                       ),
-                               sigc::bind(
-                                       sigc::bind(
-                                               sigc::mem_fun(
-                                                       *const_cast<studio::Instance*>(this),
-                                                       &studio::Instance::process_action
-                                               ),
-                                               param_list
-                                       ),
-                                       iter->name
-                               )
-                       );
-                       ui_info+=strprintf("<menuitem action='action-%s' />",iter->name.c_str());
-               }
-       }
-}
-
-void
-Instance::add_actions_to_menu(Gtk::Menu *menu, const synfigapp::Action::ParamList &param_list,synfigapp::Action::Category category)const
-{
-       synfigapp::Action::CandidateList candidate_list;
-       synfigapp::Action::CandidateList::iterator iter;
-
-       candidate_list=compile_candidate_list(param_list,category);
-
-       candidate_list.sort();
-
-       if(candidate_list.empty())
-               synfig::warning("%s:%d Action CandidateList is empty!", __FILE__, __LINE__);
-
-       for(iter=candidate_list.begin();iter!=candidate_list.end();++iter)
-       {
-               if(!(iter->category&synfigapp::Action::CATEGORY_HIDDEN))
-               {
-                       Gtk::Image* image(manage(new Gtk::Image()));
-                       Gtk::Stock::lookup(get_action_stock_id(*iter),Gtk::ICON_SIZE_MENU,*image);
-
-                       menu->items().push_back(
-                               Gtk::Menu_Helpers::ImageMenuElem(
-                                       iter->local_name,
-                                       *image,
-                                       sigc::bind(
-                                               sigc::bind(
-                                                       sigc::mem_fun(
-                                                               *const_cast<studio::Instance*>(this),
-                                                               &studio::Instance::process_action
-                                                       ),
-                                                       param_list
-                                               ),
-                                               iter->name
-                                       )
-                               )
-                       );
-               }
-       }
-}
-
-void
-Instance::add_actions_to_menu(Gtk::Menu *menu, const synfigapp::Action::ParamList &param_list,const synfigapp::Action::ParamList &param_list2,synfigapp::Action::Category category)const
-{
-       synfigapp::Action::CandidateList candidate_list;
-       synfigapp::Action::CandidateList candidate_list2;
-
-       synfigapp::Action::CandidateList::iterator iter;
-
-       candidate_list=compile_candidate_list(param_list,category);
-       candidate_list2=compile_candidate_list(param_list2,category);
-
-       candidate_list.sort();
-
-       if(candidate_list.empty())
-               synfig::warning("%s:%d Action CandidateList is empty!", __FILE__, __LINE__);
-       if(candidate_list2.empty())
-               synfig::warning("%s:%d Action CandidateList2 is empty!", __FILE__, __LINE__);
-
-       // Separate out the candidate lists so that there are no conflicts
-       for(iter=candidate_list.begin();iter!=candidate_list.end();++iter)
-       {
-               synfigapp::Action::CandidateList::iterator iter2(candidate_list2.find(iter->name));
-               if(iter2!=candidate_list2.end())
-                       candidate_list2.erase(iter2);
-       }
-
-       for(iter=candidate_list2.begin();iter!=candidate_list2.end();++iter)
-       {
-               if(!(iter->category&synfigapp::Action::CATEGORY_HIDDEN))
-               {
-                       Gtk::Image* image(manage(new Gtk::Image()));
-                       Gtk::Stock::lookup(get_action_stock_id(*iter),Gtk::ICON_SIZE_MENU,*image);
-
-                       menu->items().push_back(
-                               Gtk::Menu_Helpers::ImageMenuElem(
-                                       iter->local_name,
-                                       *image,
-                                       sigc::bind(
-                                               sigc::bind(
-                                                       sigc::mem_fun(
-                                                               *const_cast<studio::Instance*>(this),
-                                                               &studio::Instance::process_action
-                                                       ),
-                                                       param_list2
-                                               ),
-                                               iter->name
-                                       )
-                               )
-                       );
-               }
-       }
-
-       for(iter=candidate_list.begin();iter!=candidate_list.end();++iter)
-       {
-               if(!(iter->category&synfigapp::Action::CATEGORY_HIDDEN))
-               {
-                       Gtk::Image* image(manage(new Gtk::Image()));
-                       Gtk::Stock::lookup(get_action_stock_id(*iter),Gtk::ICON_SIZE_MENU,*image);
-
-                       menu->items().push_back(
-                               Gtk::Menu_Helpers::ImageMenuElem(
-                                       iter->local_name,
-                                       *image,
-                                       sigc::bind(
-                                               sigc::bind(
-                                                       sigc::mem_fun(
-                                                               *const_cast<studio::Instance*>(this),
-                                                               &studio::Instance::process_action
-                                                       ),
-                                                       param_list
-                                               ),
-                                               iter->name
-                                       )
-                               )
-                       );
-               }
-       }
-}
-
-void
-Instance::process_action(synfig::String name, synfigapp::Action::ParamList param_list)
-{
-       //// debug actions
-       // synfig::info("%s:%d process_action: '%s'", __FILE__, __LINE__, name.c_str());
-
-       assert(synfigapp::Action::book().count(name));
-
-       synfigapp::Action::BookEntry entry(synfigapp::Action::book().find(name)->second);
-
-       synfigapp::Action::Handle action(entry.factory());
-
-       if(!action)
-       {
-               synfig::error("Bad Action");
-               return;
-       }
-
-       action->set_param_list(param_list);
-
-       synfigapp::Action::ParamVocab param_vocab(entry.get_param_vocab());
-       synfigapp::Action::ParamVocab::const_iterator iter;
-
-       for(iter=param_vocab.begin();iter!=param_vocab.end();++iter)
-       {
-               if(!iter->get_mutual_exclusion().empty() && param_list.count(iter->get_mutual_exclusion()))
-                       continue;
-
-               // If the parameter is optionally user-supplied,
-               // and has not been already provided in the param_list,
-               // then we should go ahead and see if we can
-               // provide that data.
-               if(iter->get_user_supplied() && param_list.count(iter->get_name())==0)
-               {
-                       switch(iter->get_type())
-                       {
-                       case synfigapp::Action::Param::TYPE_STRING:
-                       {
-                               String str;
-                               if(!studio::App::dialog_entry(entry.local_name, iter->get_local_name()+": "+iter->get_desc(),str))
-                                       return;
-                               action->set_param(iter->get_name(),str);
-                               break;
-                       }
-                       default:
-                               synfig::error("Unsupported user-supplied action parameter");
-                               return;
-                               break;
-                       }
-               }
-       }
-
-       if(!action->is_ready())
-       {
-               synfig::error("Action not ready");
-               return;
-       }
-
-       perform_action(action);
-}
-
-void
-Instance::make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas, synfigapp::ValueDesc value_desc, float location, bool bezier)
-{
-       Gtk::Menu& parammenu(*menu);
-
-       etl::handle<synfigapp::CanvasInterface> canvas_interface(find_canvas_interface(canvas));
-
-       if(!canvas_interface)
-               return;
-
-       synfigapp::Action::ParamList param_list,param_list2;
-       param_list=canvas_interface->generate_param_list(value_desc);
-       param_list.add("origin",location);
-
-#ifdef BLINEPOINT_MENU_IS_VERTEX_MENU
-       if(value_desc.get_value_type()==ValueBase::TYPE_BLINEPOINT && value_desc.is_value_node() && ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node()))
-       {
-               param_list2=canvas_interface->generate_param_list(
-                       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")
-                       )
-               );
-               param_list2.add("origin",location);
-       }
-#endif // BLINEPOINT_MENU_IS_VERTEX_MENU
-
-       // Populate the convert menu by looping through
-       // the ValueNode book and find the ones that are
-       // relevant.
-
-       // show the 'Convert' sub-menu if this valuedesc is anything other than either:
-       //   the 'Index' parameter of a Duplicate layer
-       // or
-       //   a Duplicate ValueNode whose parent is not a (layer or ValueNode)
-       if (!((value_desc.parent_is_layer_param() &&
-                  value_desc.get_layer()->get_name() == "duplicate" &&
-                  value_desc.get_param_name() == "index") ||
-                 (value_desc.is_value_node() &&
-                  ValueNode_Duplicate::Handle::cast_dynamic(value_desc.get_value_node()) &&
-                  !(value_desc.parent_is_layer_param() ||
-                        value_desc.parent_is_value_node()))))
-       {
-               Gtk::Menu *convert_menu=manage(new Gtk::Menu());
-               LinkableValueNode::Book::const_iterator iter;
-               for(iter=LinkableValueNode::book().begin();iter!=LinkableValueNode::book().end();++iter)
-               {
-                       if(iter->second.check_type(value_desc.get_value_type()))
-                       {
-                               convert_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(iter->second.local_name,
-                                       sigc::hide_return(
-                                               sigc::bind(
-                                                       sigc::bind(
-                                                               sigc::mem_fun(*canvas_interface.get(),&synfigapp::CanvasInterface::convert),
-                                                               iter->first
-                                                       ),
-                                                       value_desc
-                                               )
-                                       )
-                               ));
-                       }
-               }
-
-               parammenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::CONVERT,*convert_menu));
-       }
-
-       synfigapp::Action::Category categories = synfigapp::Action::CATEGORY_VALUEDESC|synfigapp::Action::CATEGORY_VALUENODE;
-       if (bezier)
-       {
-               categories = categories|synfigapp::Action::CATEGORY_BEZIER;
-
-               const DuckList selected_ducks(find_canvas_view(canvas)->get_work_area()->get_selected_ducks());
-               for(DuckList::const_iterator iter=selected_ducks.begin();iter!=selected_ducks.end();++iter)
-               {
-                       synfigapp::ValueDesc value_desc((*iter)->get_value_desc());
-                       if(value_desc.is_valid())
-                               param_list.add("selected_value_desc",value_desc);
-               }
-       }
-
-       if(param_list2.empty())
-               add_actions_to_menu(&parammenu, param_list,categories);
-       else
-               add_actions_to_menu(&parammenu, param_list2,param_list,categories);
-
-       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=synfigapp::ValueDesc(ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node()),0);
-       }
-
-       if(value_desc.is_value_node() && ValueNode_Animated::Handle::cast_dynamic(value_desc.get_value_node()))
-       {
-               ValueNode_Animated::Handle value_node(ValueNode_Animated::Handle::cast_dynamic(value_desc.get_value_node()));
-
-               try
-               {
-                       // try to find a waypoint at the current time - if we
-                       // can't, we don't want the menu entry - an exception is thrown
-                       WaypointList::iterator iter(value_node->find(canvas->get_time()));
-                       std::set<synfig::Waypoint, std::less<UniqueID> > waypoint_set;
-                       waypoint_set.insert(*iter);
-
-                       parammenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Edit Waypoint"),
-                               sigc::bind(
-                                       sigc::bind(
-                                               sigc::bind(
-                                                       sigc::mem_fun(*find_canvas_view(canvas),&studio::CanvasView::on_waypoint_clicked_canvasview),
-                                                       -1
-                                               ),
-                                               waypoint_set
-                                       ),
-                                       value_desc
-                               )
-                       ));
-               }
-               catch(...)
-               {
-               }
-       }
-}
-
-void
-edit_several_waypoints(etl::handle<CanvasView> canvas_view, std::list<synfigapp::ValueDesc> value_desc_list)
-{
-       etl::handle<synfigapp::CanvasInterface> canvas_interface(canvas_view->canvas_interface());
-
-       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 || widget_waypoint_model.get_waypoint_model().is_trivial())
-               return;
-       synfigapp::Action::PassiveGrouper group(canvas_interface->get_instance().get(),_("Set Waypoints"));
-
-       std::list<synfigapp::ValueDesc>::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,canvas_interface->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",canvas_view->get_canvas());
-                       action->set_param("canvas_interface",canvas_interface);
-
-                       if(!canvas_interface->get_instance()->perform_action(action))
-                       {
-                               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)
-                       {
-                               canvas_view->get_ui_interface()->error(_("Unable to find WaypointSetSmart action"));
-                               group.cancel();
-                               return;
-                       }
-
-                       action->set_param("canvas",canvas_view->get_canvas());
-                       action->set_param("canvas_interface",canvas_interface);
-                       action->set_param("value_node",ValueNode::Handle(value_node));
-                       action->set_param("time",canvas_interface->get_time());
-                       action->set_param("model",widget_waypoint_model.get_waypoint_model());
-
-                       if(!canvas_interface->get_instance()->perform_action(action))
-                       {
-                               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;
-               }
-
-       }
-}
-
-void
-Instance::make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas,const std::list<synfigapp::ValueDesc>& value_desc_list)
-{
-       etl::handle<synfigapp::CanvasInterface> canvas_interface(find_canvas_interface(canvas));
-
-       synfigapp::Action::ParamList param_list;
-       param_list=canvas_interface->generate_param_list(value_desc_list);
-
-       add_actions_to_menu(menu, param_list,synfigapp::Action::CATEGORY_VALUEDESC|synfigapp::Action::CATEGORY_VALUENODE);
-
-       // Add the edit waypoints option if that might be useful
-       if(canvas->rend_desc().get_time_end()-Time::epsilon()>canvas->rend_desc().get_time_start())
-       {
-               menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Edit Waypoints"),
-                       sigc::bind(
-                               sigc::bind(
-                                       sigc::ptr_fun(
-                                               &edit_several_waypoints
-                                       ),
-                                       value_desc_list
-                               ),
-                               find_canvas_view(canvas)
-                       )
-               ));
-       }
-}
diff --git a/synfig-studio/src/gtkmm/instance.h b/synfig-studio/src/gtkmm/instance.h
deleted file mode 100644 (file)
index 16842c1..0000000
+++ /dev/null
@@ -1,237 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file gtkmm/instance.h
-**     \brief writeme
-**
-**     $Id$
-**
-**     \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
-**     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_INSTANCE_H
-#define __SYNFIG_STUDIO_INSTANCE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <ETL/handle>
-#include <gtkmm/treeview.h>
-#include <gtkmm/treestore.h>
-#include <synfigapp/instance.h>
-#include <sigc++/object.h>
-#include <synfigapp/value_desc.h>
-#include "historytreestore.h"
-#include <synfig/canvas.h>
-
-/* === M A C R O S ========================================================= */
-#define DEFAULT_FILENAME_PREFIX _("Synfig Animation ") // will be followed by a different number for each document
-
-/* === T Y P E D E F S ===================================================== */
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-namespace Gtk { class Menu; class ActionGroup; };
-
-namespace studio {
-
-class CanvasView;
-
-
-class Instance : public synfigapp::Instance
-{
-public:
-       typedef std::list< etl::handle<CanvasView> > CanvasViewList;
-
-       enum Status
-       {
-               STATUS_OK,
-               STATUS_ERROR,
-               STATUS_CANCEL
-       };
-
-       class CanvasTreeModel : public Gtk::TreeModel::ColumnRecord
-       {
-       public:
-               Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
-               Gtk::TreeModelColumn<Glib::ustring> label;
-               Gtk::TreeModelColumn<Glib::ustring> name;
-               Gtk::TreeModelColumn<Glib::ustring> id;
-
-               Gtk::TreeModelColumn<synfig::Canvas::Handle> canvas;
-               Gtk::TreeModelColumn<bool> is_canvas;
-
-               Gtk::TreeModelColumn<synfig::ValueNode::Handle> value_node;
-               Gtk::TreeModelColumn<bool> is_value_node;
-               Gtk::TreeModelColumn<synfig::ValueBase> value;
-               Gtk::TreeModelColumn<Glib::ustring> type;
-               Gtk::TreeModelColumn<int> link_id;
-               Gtk::TreeModelColumn<int> link_count;
-
-               Gtk::TreeModelColumn<bool> is_editable;
-
-               Gtk::TreeModelColumn<synfigapp::ValueDesc> value_desc;
-
-               CanvasTreeModel()
-               {
-                       add(value);
-                       add(name);
-                       add(label);
-                       add(icon);
-                       add(type);
-                       add(id);
-                       add(canvas);
-                       add(value_node);
-                       add(is_canvas);
-                       add(is_value_node);
-
-                       add(is_editable);
-                       add(value_desc);
-                       add(link_count);
-                       add(link_id);
-               }
-       } canvas_tree_model;
-
-private:
-
-       sigc::signal<void,CanvasView*> signal_canvas_view_created_;
-       sigc::signal<void,CanvasView*> signal_canvas_view_deleted_;
-
-       sigc::signal<void> signal_undo_redo_status_changed_;
-
-       //! Tree containing the canvases -- used for the "canvas browser"
-       Glib::RefPtr<Gtk::TreeStore> canvas_tree_store_;
-
-       //! Tree containing the actions -- used for the "canvas browser"
-       Glib::RefPtr<HistoryTreeStore> history_tree_store_;
-
-       //! Instance number
-       int     id_;
-
-       //! Used to calculate instance ID
-       static int instance_count_;
-
-       //! List of canvas view windows
-       CanvasViewList canvas_view_list_;
-
-       bool undo_status_;
-       bool redo_status_;
-
-       void set_undo_status(bool x);
-       void set_redo_status(bool x);
-
-       static void _revert(Instance *);
-
-protected:
-
-       Instance(synfig::Canvas::Handle);
-
-public:
-
-       sigc::signal<void>& signal_undo_redo_status_changed() { return signal_undo_redo_status_changed_; }
-
-       ~Instance();
-
-       sigc::signal<void,CanvasView*>& signal_canvas_view_created() { return signal_canvas_view_created_; }
-       sigc::signal<void,CanvasView*>& signal_canvas_view_deleted() { return signal_canvas_view_deleted_; }
-
-       bool get_undo_status()const { return undo_status_; }
-
-       bool get_redo_status()const { return redo_status_; }
-
-       int get_visible_canvases()const;
-
-       Glib::RefPtr<Gtk::TreeStore> canvas_tree_store() { return canvas_tree_store_; }
-
-       Glib::RefPtr<const Gtk::TreeStore> canvas_tree_store()const { return canvas_tree_store_; }
-
-       Glib::RefPtr<HistoryTreeStore> history_tree_store() { return history_tree_store_; }
-
-       Glib::RefPtr<const HistoryTreeStore> history_tree_store()const { return history_tree_store_; }
-
-       //! Returns the number of instances that are currently open in the program
-       static int get_count() { return instance_count_; }
-
-       //etl::handle<synfig::Canvas> get_canvas()const { return synfigapp::Instance::get_canvas(); }
-
-       etl::handle<CanvasView> find_canvas_view(etl::handle<synfig::Canvas> canvas);
-
-       //! Sets the focus to a specific canvas
-       void focus(etl::handle<synfig::Canvas> canvas);
-
-       CanvasViewList & canvas_view_list() { return canvas_view_list_; }
-
-       const CanvasViewList & canvas_view_list()const { return canvas_view_list_; }
-
-       bool save_as(const synfig::String &filename);
-
-       //! returns true if the instance has a real filename associated with it, rather than the made up "synfig animation 1" or some such
-       bool has_real_filename();
-
-       //! Opens a "Save As" dialog, and then saves the composition to that file
-       //! returns true if the save was successful
-       bool dialog_save_as();
-
-       void open();
-
-       Status save();
-
-       void dialog_cvs_commit();
-
-       void dialog_cvs_add();
-
-       void dialog_cvs_update();
-
-       void dialog_cvs_revert();
-
-       //! Closes the instance of this composition
-       void close();
-
-       void revert();
-
-       void update_all_titles();
-
-       void refresh_canvas_tree();
-
-       bool safe_revert();
-       bool safe_close();
-
-       void add_actions_to_menu(Gtk::Menu *menu,   const synfigapp::Action::ParamList &param_list, synfigapp::Action::Category category=synfigapp::Action::CATEGORY_ALL)const;
-       void add_actions_to_menu(Gtk::Menu *menu, const synfigapp::Action::ParamList &param_list1,const synfigapp::Action::ParamList &param_list2, synfigapp::Action::Category category=synfigapp::Action::CATEGORY_ALL)const;
-
-       void add_actions_to_group(const Glib::RefPtr<Gtk::ActionGroup>& action_group, synfig::String& ui_info,   const synfigapp::Action::ParamList &param_list, synfigapp::Action::Category category=synfigapp::Action::CATEGORY_ALL)const;
-
-       void process_action(synfig::String name, synfigapp::Action::ParamList param_list);
-
-       void make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas, synfigapp::ValueDesc value_desc, float location=0.5f, bool bezier=false);
-
-       void make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas,const std::list<synfigapp::ValueDesc>& value_desc_list);
-
-
-       static void edit_waypoint(synfigapp::ValueDesc value_desc,synfig::Waypoint waypoint);
-
-private:
-       void insert_canvas(Gtk::TreeRow row,synfig::Canvas::Handle canvas);
-
-public:
-       static etl::handle<Instance> create(synfig::Canvas::Handle canvas);
-}; // END class Instance
-
-}; // END namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/ipc.cpp b/synfig-studio/src/gtkmm/ipc.cpp
deleted file mode 100644 (file)
index 4d1db56..0000000
+++ /dev/null
@@ -1,343 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file ipc.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \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
-**     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 <config.h>
-#endif
-
-#include "ipc.h"
-
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-
-#ifdef HAVE_SYS_ERRNO_H
-#include <sys/errno.h>
-#endif
-
-#include <synfig/main.h>
-#include "app.h"
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef _WIN32
-#include <windows.h>
-#define BUFSIZE   128
-#define read   _read
-#endif
-
-#include "toolbox.h"
-#include <glibmm/dispatcher.h>
-#include <synfig/mutex.h>
-#include <synfig/string.h>
-#include <glibmm/thread.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 ======================================================= */
-
-#ifdef _WIN32
-#define WIN32_PIPE_PATH "\\\\.\\pipe\\SynfigStudio.Cmd"
-static synfig::Mutex cmd_mutex;
-static std::list<synfig::String> cmd_queue;
-static Glib::Dispatcher* cmd_dispatcher;
-static void
-pipe_listen_thread()
-{
-       for(;;)
-       {
-               HANDLE pipe_handle;
-               pipe_handle=CreateNamedPipe(
-                       WIN32_PIPE_PATH, // pipe name
-                       PIPE_ACCESS_INBOUND, // Access type
-                       PIPE_READMODE_BYTE /*|PIPE_NOWAIT*/,
-                       PIPE_UNLIMITED_INSTANCES,
-                       BUFSIZE,
-                       BUFSIZE,
-                       NMPWAIT_USE_DEFAULT_WAIT,
-                       NULL
-               );
-               if(pipe_handle==INVALID_HANDLE_VALUE)
-               {
-                       synfig::error("IPC(): Call to CreateNamedPipe failed. Ignore next error. GetLastError=%d",GetLastError());
-                       return;
-               }
-
-               bool connected;
-               connected=ConnectNamedPipe(pipe_handle,NULL)?true:(GetLastError()==ERROR_PIPE_CONNECTED);
-               DWORD read_bytes;
-               bool success;
-
-               Glib::Thread::yield();
-
-               if(connected)
-               do {
-                       String data;
-                       char c;
-                       do
-                       {
-                               success= ReadFile(
-                                       pipe_handle,
-                                       &c,             // buffer pointer
-                                       1,              // buffer size
-                                       &read_bytes,
-                                       NULL
-                               );
-                               if(success && read_bytes==1 && c!='\n')
-                                       data+=c;
-                       }while(c!='\n');
-                       synfig::Mutex::Lock lock(cmd_mutex);
-                       cmd_queue.push_back(data);
-                       cmd_dispatcher->emit();
-               } while(success && read_bytes);
-
-               CloseHandle(pipe_handle);
-       }
-}
-
-static void
-empty_cmd_queue()
-{
-       synfig::Mutex::Lock lock(cmd_mutex);
-       while(!cmd_queue.empty())
-       {
-               IPC::process_command(cmd_queue.front());
-               cmd_queue.pop_front();
-       }
-}
-
-#endif
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-IPC::IPC()
-{
-#ifdef _WIN32
-
-       cmd_dispatcher=new Glib::Dispatcher;
-       cmd_dispatcher->connect(sigc::ptr_fun(empty_cmd_queue));
-
-       Glib::Thread::create(
-               sigc::ptr_fun(pipe_listen_thread),
-               false
-       );
-
-#else
-
-       remove(fifo_path().c_str());
-       fd=-1;
-
-       if(mkfifo(fifo_path().c_str(), S_IRWXU)!=0)
-       {
-               synfig::error("IPC(): mkfifo failed for "+fifo_path());
-       }
-
-       {
-               fd=open(fifo_path().c_str(),O_RDWR);
-
-
-               if(fd<0)
-               {
-                       synfig::error("IPC(): Failed to open fifo \"%s\". (errno=?)",fifo_path().c_str());
-                       //synfig::error("IPC(): Failed to open fifo \"%s\". (errno=%d)",fifo_path().c_str(),::errno);
-               }
-               else
-               {
-                       file=SmartFILE(fdopen(fd,"r"));
-
-                       Glib::signal_io().connect(
-                               sigc::mem_fun(this,&IPC::fifo_activity),
-                               fd,
-                               Glib::IO_IN|Glib::IO_PRI|Glib::IO_ERR|Glib::IO_HUP|Glib::IO_NVAL
-                       );
-               }
-       }
-#endif
-}
-
-IPC::~IPC()
-{
-       //if(file)
-       //      fclose(file.get());
-
-       remove(fifo_path().c_str());
-
-       //if(fd>=0)
-       //      close(fd);
-}
-
-synfig::String
-IPC::fifo_path()
-{
-#ifdef _WIN32
-       return WIN32_PIPE_PATH;
-#else
-       return Glib::build_filename(App::get_user_app_directory(),"fifo");
-#endif
-}
-
-bool
-IPC::fifo_activity(Glib::IOCondition cond)
-{
-       if(cond&(Glib::IO_ERR|Glib::IO_HUP|Glib::IO_NVAL))
-       {
-               if(cond&(Glib::IO_ERR))
-                       synfig::error("IPC::fifo_activity(): IO_ERR");
-               if(cond&(Glib::IO_HUP))
-                       synfig::error("IPC::fifo_activity(): IO_HUP");
-               if(cond&(Glib::IO_NVAL))
-                       synfig::error("IPC::fifo_activity(): IO_NVAL");
-               return false;
-       }
-
-       String command;
-       {
-               char tmp;
-               do {
-                       if(read(fd,&tmp,sizeof(tmp))<=0)
-                               break;
-                       if(tmp!='\n')
-                               command+=tmp;
-               } while(tmp!='\n');
-       }
-
-       synfig::info("%s:%d: fifo activity: '%s'", __FILE__, __LINE__, command.c_str());
-       process_command(command);
-       return true;
-}
-
-bool
-IPC::process_command(const synfig::String& command_line)
-{
-       if(command_line.empty())
-               return false;
-
-       char cmd = command_line[0];
-
-       String args(command_line.begin()+1,command_line.end());
-
-       // erase leading spaces
-       while (!args.empty() && args[0] == ' ')
-               args.erase(args.begin());
-
-       // erase trailing newlines and spaces
-       while (!args.empty() && (args[args.size()-1] == '\n' || args[args.size()-1] == ' '))
-               args.erase(args.end()-1);
-
-       switch(toupper(cmd))
-       {
-               case 'F': // Focus/Foreground
-                       App::signal_present_all()();
-                       break;
-               case 'N': // New file
-                       App::signal_present_all()();
-                       App::new_instance();
-                       break;
-               case 'O': // Open <arg>
-                       App::signal_present_all()();
-                       App::open(args);
-                       break;
-               case 'X': // Quit
-               case 'Q': // Quit
-                       App::quit();
-                       break;
-               default:
-                       synfig::warning("Received unknown command '%c' with arg '%s'",cmd,args.c_str());
-                       break;
-       }
-
-       return true;
-}
-
-synfig::SmartFILE
-IPC::make_connection()
-{
-       SmartFILE ret;
-#ifdef _WIN32
-       HANDLE pipe_handle;
-       pipe_handle=CreateFile(
-               fifo_path().c_str(),
-               GENERIC_WRITE, // desired access
-               0, // share mode
-               NULL, // security attributes
-               OPEN_EXISTING, // creation disposition
-               FILE_ATTRIBUTE_NORMAL, // flags and attributes
-               NULL  // template file
-       );
-       if(pipe_handle==INVALID_HANDLE_VALUE)
-       {
-               DWORD error = GetLastError();
-#ifndef _DEBUG
-               if( error != ERROR_FILE_NOT_FOUND )
-#endif
-                       synfig::warning("IPC::make_connection(): Unable to connect to previous instance. GetLastError=%d",error);
-       }
-       int fd=_open_osfhandle(reinterpret_cast<long int>(pipe_handle),_O_APPEND|O_WRONLY);
-#else
-       struct stat file_stat;
-       if(stat(fifo_path().c_str(),&file_stat)!=0)
-               return ret;
-
-       if(!S_ISFIFO(file_stat.st_mode))
-               return ret;
-
-       int fd=open(fifo_path().c_str(),O_WRONLY|O_NONBLOCK);
-#endif
-
-       if(fd>=0)
-               ret=SmartFILE(fdopen(fd,"w"));
-
-#ifdef _DEBUG
-       // synfig::info("uplink fd=%d",fd);
-#endif
-
-       return ret;
-}
diff --git a/synfig-studio/src/gtkmm/ipc.h b/synfig-studio/src/gtkmm/ipc.h
deleted file mode 100644 (file)
index 59c401e..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file ipc.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_IPC_H
-#define __SYNFIG_IPC_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <synfig/smartfile.h>
-#include <glibmm/main.h>
-#include <synfig/string.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 IPC
-{
-private:
-
-       int fd;
-       synfig::SmartFILE file;
-
-       bool fifo_activity(Glib::IOCondition cond);
-
-public:
-       IPC();
-       ~IPC();
-
-       static synfig::String fifo_path();
-       static synfig::SmartFILE make_connection();
-
-       static bool process_command(const synfig::String& cmd);
-}; // END of class IPC
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/keyframeactionmanager.cpp b/synfig-studio/src/gtkmm/keyframeactionmanager.cpp
deleted file mode 100644 (file)
index aaddf1f..0000000
+++ /dev/null
@@ -1,251 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file keyframeactionmanager.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \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
-**     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 <config.h>
-#endif
-
-#include "keyframeactionmanager.h"
-#include "keyframetree.h"
-#include <synfigapp/action_param.h>
-#include "instance.h"
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-using namespace synfig;
-using namespace studio;
-
-static const guint no_prev_popup((guint)-1);
-
-/* === M A C R O S ========================================================= */
-
-//#define ONE_ACTION_GROUP 1
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-KeyframeActionManager::KeyframeActionManager():
-       action_group_(Gtk::ActionGroup::create("action_group_keyframe_action_manager")),
-       popup_id_(no_prev_popup),
-       queued(false)
-{
-}
-
-KeyframeActionManager::~KeyframeActionManager()
-{
-}
-
-void
-KeyframeActionManager::set_ui_manager(const Glib::RefPtr<Gtk::UIManager> &x)
-{
-       clear();
-
-#ifdef ONE_ACTION_GROUP
-       if(ui_manager_) get_ui_manager()->remove_action_group(action_group_);
-       ui_manager_=x;
-       if(ui_manager_) get_ui_manager()->insert_action_group(action_group_);
-#else
-       ui_manager_=x;
-#endif
-}
-
-void
-KeyframeActionManager::set_keyframe_tree(KeyframeTree* x)
-{
-       selection_changed_connection.disconnect();
-       keyframe_tree_=x;
-       if(keyframe_tree_)
-       {
-               selection_changed_connection=keyframe_tree_->get_selection()->signal_changed().connect(
-                       sigc::mem_fun(*this,&KeyframeActionManager::queue_refresh)
-               );
-       }
-}
-
-void
-KeyframeActionManager::set_canvas_interface(const etl::handle<synfigapp::CanvasInterface> &x)
-{
-       time_changed_connection.disconnect();
-       canvas_interface_=x;
-       if(canvas_interface_)
-       {
-               canvas_interface_->signal_time_changed().connect(
-                       sigc::mem_fun(*this,&KeyframeActionManager::queue_refresh)
-               );
-       }
-}
-
-void
-KeyframeActionManager::clear()
-{
-       if(ui_manager_)
-       {
-               // Clear out old stuff
-               if(popup_id_!=no_prev_popup)
-               {
-                       get_ui_manager()->remove_ui(popup_id_);
-                       popup_id_=no_prev_popup;
-#ifdef ONE_ACTION_GROUP
-                       while(!action_group_->get_actions().empty())action_group_->remove(*action_group_->get_actions().begin());
-#else
-                       get_ui_manager()->remove_action_group(action_group_);
-                       action_group_=Gtk::ActionGroup::create("action_group_keyframe_action_manager");
-#endif
-               }
-       }
-}
-
-void
-KeyframeActionManager::queue_refresh()
-{
-       if(queued)
-               return;
-
-       //queue_refresh_connection.disconnect();
-       queue_refresh_connection=Glib::signal_idle().connect(
-               sigc::bind_return(
-                       sigc::mem_fun(*this,&KeyframeActionManager::refresh),
-                       false
-               )
-       );
-
-       queued=true;
-}
-
-void
-KeyframeActionManager::on_keyframe_properties()
-{
-       signal_show_keyframe_properties_();
-}
-
-void
-KeyframeActionManager::on_add_keyframe()
-{
-       synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeAdd"));
-
-       if(!action)
-               return;
-
-       action->set_param("canvas",canvas_interface_->get_canvas());
-       action->set_param("canvas_interface",canvas_interface_);
-       action->set_param("keyframe",Keyframe(canvas_interface_->get_time()));
-
-       canvas_interface_->get_instance()->perform_action(action);
-}
-
-void
-KeyframeActionManager::refresh()
-{
-       KeyframeTreeStore::Model model;
-
-       if(queued)
-       {
-               queued=false;
-               //queue_refresh_connection.disconnect();
-       }
-
-
-       clear();
-
-       // Make sure we are ready
-       if(!ui_manager_ || !keyframe_tree_ || !canvas_interface_)
-       {
-               synfig::error("KeyframeActionManager::refresh(): Not ready!");
-               return;
-       }
-
-       String ui_info;
-
-       {
-               synfigapp::Action::ParamList param_list;
-               param_list.add("time",get_canvas_interface()->get_time());
-               param_list.add("canvas",get_canvas_interface()->get_canvas());
-               param_list.add("canvas_interface",get_canvas_interface());
-               if(keyframe_tree_->get_selection()->count_selected_rows()==1)
-               {
-                       Keyframe keyframe((*keyframe_tree_->get_selection()->get_selected())[model.keyframe]);
-                       param_list.add("keyframe",keyframe);
-               }
-
-               handle<studio::Instance>::cast_static(
-                       get_canvas_interface()->get_instance()
-               )->add_actions_to_group(
-                       action_group_,
-                       ui_info,
-                       param_list,
-                       synfigapp::Action::CATEGORY_KEYFRAME
-               );
-       }
-       if(action_group_->get_action("action-KeyframeAdd"))
-       {
-               action_group_->remove(action_group_->get_action("action-KeyframeAdd"));
-       }
-
-               action_group_->add(Gtk::Action::create(
-                       "action-KeyframeAdd",
-                       Gtk::StockID("gtk-add"),
-                       _("Add New Keyframe"),_("Add New Keyframe")
-               ),
-                       sigc::mem_fun(*this,&KeyframeActionManager::on_add_keyframe)
-               );
-
-       try
-       {
-               canvas_interface_->get_canvas()->keyframe_list().find(canvas_interface_->get_time());
-               action_group_->get_action("action-KeyframeAdd")->set_sensitive(false);
-               if(action_group_->get_action("action-KeyframeDuplicate"))
-                       action_group_->get_action("action-KeyframeDuplicate")->set_sensitive(false);
-       }
-       catch(...)
-       {
-       }
-
-       {
-               Glib::RefPtr<Gtk::Action> action(Gtk::Action::create("keyframe-properties", Gtk::StockID("gtk-properties"),
-                                                                                                                        _("Keyframe Properties"), _("Keyframe Properties")));
-               action_group_->add(action,sigc::mem_fun(*this,&KeyframeActionManager::on_keyframe_properties));
-               if(keyframe_tree_->get_selection()->count_selected_rows()==0)
-                       action->set_sensitive(false);
-       }
-
-       ui_info="<ui><popup action='menu-main'><menu action='menu-keyframe'>"+ui_info+"</menu></popup></ui>";
-       popup_id_=get_ui_manager()->add_ui_from_string(ui_info);
-#ifdef ONE_ACTION_GROUP
-#else
-       get_ui_manager()->insert_action_group(action_group_);
-#endif
-}
diff --git a/synfig-studio/src/gtkmm/keyframeactionmanager.h b/synfig-studio/src/gtkmm/keyframeactionmanager.h
deleted file mode 100644 (file)
index 9048a42..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file keyframeactionmanager.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_KEYFRAME_ACTION_MANAGER_H
-#define __SYNFIG_KEYFRAME_ACTION_MANAGER_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/uimanager.h>
-#include <gtkmm/treeview.h>
-#include <synfigapp/canvasinterface.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 KeyframeTree;
-
-class KeyframeActionManager
-{
-       sigc::signal<void> signal_show_keyframe_properties_;
-
-       Glib::RefPtr<Gtk::UIManager> ui_manager_;
-       //Glib::RefPtr<Gtk::TreeSelection> tree_selection_;
-       KeyframeTree* keyframe_tree_;
-       etl::handle<synfigapp::CanvasInterface> canvas_interface_;
-
-       Glib::RefPtr<Gtk::ActionGroup>  action_group_;
-       Gtk::UIManager::ui_merge_id     popup_id_;
-
-
-       sigc::connection selection_changed_connection;
-
-       bool queued;
-       sigc::connection queue_refresh_connection;
-       sigc::connection time_changed_connection;
-
-       void on_add_keyframe();
-       void on_keyframe_properties();
-
-public:
-       sigc::signal<void>& signal_show_keyframe_properties() { return signal_show_keyframe_properties_; }
-
-       void queue_refresh();
-
-       KeyframeActionManager();
-       ~KeyframeActionManager();
-
-       void set_ui_manager(const Glib::RefPtr<Gtk::UIManager> &x);
-       Glib::RefPtr<Gtk::UIManager> get_ui_manager()const { return ui_manager_; }
-
-       void set_keyframe_tree(KeyframeTree* x);
-       KeyframeTree* get_keyframe_tree()const { return keyframe_tree_; }
-
-       void set_canvas_interface(const etl::handle<synfigapp::CanvasInterface> &x);
-       etl::handle<synfigapp::CanvasInterface> get_canvas_interface()const { return canvas_interface_; }
-
-       void refresh();
-       void clear();
-}; // END of KeyframeActionManager
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/keyframedial.cpp b/synfig-studio/src/gtkmm/keyframedial.cpp
deleted file mode 100644 (file)
index c7b5c56..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file keyframedial.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2009 Gerco Ballintijn
-**     Copyright (c) 2009 Carlos Lopez
-**
-**     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 <config.h>
-#endif
-
-#include "keyframedial.h"
-#include <gtkmm/image.h>
-#include <gtkmm/stock.h>
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace studio;
-
-/* === M A C R O S ========================================================= */
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-KeyFrameDial::KeyFrameDial(): Gtk::Table(1, 3, false)
-{
-       Gtk::IconSize iconsize = Gtk::IconSize::from_name("synfig-small_icon");
-
-       seek_prev_keyframe = create_icon(iconsize, Gtk::Stock::GO_BACK, _("Previous KeyFrame"));
-       seek_next_keyframe = create_icon(iconsize, Gtk::Stock::GO_FORWARD, _("Next KeyFrame"));
-       lock_keyframe = create_icon(Gtk::ICON_SIZE_BUTTON, "synfig-keyframe_lock_all",_("All Keyframes Locked"));
-
-       attach(*seek_prev_keyframe, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       attach(*seek_next_keyframe, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       attach(*lock_keyframe, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-}
-
-Gtk::Button *
-KeyFrameDial::create_icon(Gtk::IconSize iconsize, const char * stockid,
-               const char * tooltip)
-{
-       Gtk::Button *button = manage(new class Gtk::Button());
-       Gtk::Image *icon = manage(new Gtk::Image(Gtk::StockID(stockid), iconsize));
-       button->add(*icon);
-       tooltips.set_tip(*button, tooltip);
-       icon->set_padding(0, 0);
-       icon->show();
-       button->set_relief(Gtk::RELIEF_NONE);
-       button->show();
-
-       return button;
-}
-
-Gtk::Button *
-KeyFrameDial::create_icon(Gtk::IconSize iconsize, const Gtk::BuiltinStockID & stockid,
-               const char * tooltip)
-{
-       Gtk::Button *button = manage(new class Gtk::Button());
-       Gtk::Image *icon = manage(new Gtk::Image(stockid, iconsize));
-       button->add(*icon);
-       tooltips.set_tip(*button, tooltip);
-       icon->set_padding(0, 0);
-       icon->show();
-       button->set_relief(Gtk::RELIEF_NONE);
-       button->show();
-
-       return button;
-}
diff --git a/synfig-studio/src/gtkmm/keyframedial.h b/synfig-studio/src/gtkmm/keyframedial.h
deleted file mode 100644 (file)
index a6491c9..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file keyframedial.h
-**     \brief Template Header
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2008 Chris Moore
-**     Copyright (c) 2009 Gerco Ballintijn
-**     Copyright (c) 2009 Carlos Lopez
-**
-**     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_KEYFRAMEDIAL_H
-#define __SYNFIG_STUDIO_KEYFRAMEDIAL_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/tooltips.h>
-#include <gtkmm/table.h>
-#include <gtkmm/button.h>
-
-#include "general.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 KeyFrameDial : public Gtk::Table
-{
-       Gtk::Tooltips tooltips;
-
-       Gtk::Button *seek_prev_keyframe;
-       Gtk::Button *seek_next_keyframe;
-       Gtk::Button *lock_keyframe;
-
-       Gtk::Button *create_icon(Gtk::IconSize iconsize, const char * stockid, const char * tooltip);
-       Gtk::Button *create_icon(Gtk::IconSize iconsize, const Gtk::BuiltinStockID & stockid, const char * tooltip);
-
-public:
-
-       KeyFrameDial();
-       Glib::SignalProxy0<void> signal_seek_prev_keyframe()  { return seek_prev_keyframe->signal_clicked(); }
-       Glib::SignalProxy0<void> signal_seek_next_keyframe()  { return seek_next_keyframe->signal_clicked(); }
-       Glib::SignalProxy0<void> signal_lock_keyframe()  { return lock_keyframe->signal_clicked(); }
-       Gtk::Button *get_lock_button() { return lock_keyframe; }
-
-}; // END of class KeyFrameDial
-
-}; // END of namespace studio
-
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/keyframetree.cpp b/synfig-studio/src/gtkmm/keyframetree.cpp
deleted file mode 100644 (file)
index e480292..0000000
+++ /dev/null
@@ -1,291 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file keyframetree.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 <config.h>
-#endif
-
-#include "keyframetree.h"
-#include "cellrenderer_time.h"
-#include <gtkmm/treemodelsort.h>
-#include <ETL/misc>
-
-#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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-KeyframeTree::KeyframeTree()
-{
-       const KeyframeTreeStore::Model model;
-
-       {
-               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Time")) );
-
-               cell_renderer_time = Gtk::manage( new CellRenderer_Time() );
-               column->pack_start(*cell_renderer_time,true);
-               column->add_attribute(cell_renderer_time->property_time(), model.time);
-               cell_renderer_time->signal_edited().connect(sigc::mem_fun(*this,&studio::KeyframeTree::on_edited_time));
-
-               column->set_reorderable();
-               column->set_resizable();
-               column->set_clickable();
-               column->set_sort_column(model.time);
-
-               append_column(*column);
-       }
-       {
-               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Length")) );
-
-               cell_renderer_time_delta = Gtk::manage( new CellRenderer_Time() );
-               column->pack_start(*cell_renderer_time_delta,true);
-               column->add_attribute(cell_renderer_time_delta->property_time(), model.time_delta);
-               cell_renderer_time_delta->signal_edited().connect(sigc::mem_fun(*this,&studio::KeyframeTree::on_edited_time_delta));
-
-               column->set_reorderable();
-               column->set_resizable();
-               column->set_clickable(false);
-               // column->set_sort_column(model.time_delta);
-
-               append_column(*column);
-       }
-       {
-               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Jump")) );
-
-               Gtk::CellRendererText* cell_renderer_jump=Gtk::manage(new Gtk::CellRendererText());
-               column->pack_start(*cell_renderer_jump,true);
-               cell_renderer_jump->property_text()=_("(JMP)");
-               cell_renderer_jump->property_foreground()="#003a7f";
-
-               column->set_reorderable();
-               column->set_resizable();
-               column->set_clickable(false);
-               column->set_sort_column(COLUMNID_JUMP); // without this, (JMP) needs a double click?!
-
-               append_column(*column);
-       }
-       {
-               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Description")) );
-
-               cell_renderer_description=Gtk::manage(new Gtk::CellRendererText());
-               column->pack_start(*cell_renderer_description,true);
-               column->add_attribute(cell_renderer_description->property_text(), model.description);
-               cell_renderer_description->signal_edited().connect(sigc::mem_fun(*this,&studio::KeyframeTree::on_edited_description));
-
-               column->set_reorderable();
-               column->set_resizable();
-               column->set_clickable();
-               column->set_sort_column(model.description);
-
-               append_column(*column);
-       }
-
-       set_enable_search(true);
-       set_search_column(model.description);
-
-       // This makes things easier to read.
-       set_rules_hint();
-
-       // Make us more sensitive to several events
-       add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
-}
-
-KeyframeTree::~KeyframeTree()
-{
-       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
-               synfig::info("KeyframeTree::~KeyframeTree(): Deleted");
-}
-
-void
-KeyframeTree::on_rend_desc_changed()
-{
-       cell_renderer_time->property_fps().set_value(keyframe_tree_store_->canvas_interface()->get_canvas()->rend_desc().get_frame_rate());
-       queue_draw();
-}
-
-void
-KeyframeTree::set_model(Glib::RefPtr<KeyframeTreeStore> keyframe_tree_store)
-{
-       keyframe_tree_store_=keyframe_tree_store;
-       KeyframeTreeStore::Model model;
-
-       if(true)
-       {
-               Glib::RefPtr<Gtk::TreeModelSort> sorted_store(Gtk::TreeModelSort::create(keyframe_tree_store_));
-               sorted_store->set_default_sort_func(sigc::ptr_fun(&studio::KeyframeTreeStore::time_sorter));
-               sorted_store->set_sort_func(model.time,                 sigc::ptr_fun(&studio::KeyframeTreeStore::time_sorter));
-               sorted_store->set_sort_func(model.description,  sigc::ptr_fun(&studio::KeyframeTreeStore::description_sorter));
-               Gtk::TreeView::set_model(sorted_store);
-       }
-       else
-               Gtk::TreeView::set_model(keyframe_tree_store);
-
-       keyframe_tree_store_->canvas_interface()->signal_rend_desc_changed().connect(
-               sigc::mem_fun(
-                       *this,
-                       &studio::KeyframeTree::on_rend_desc_changed
-               )
-       );
-       cell_renderer_time->property_fps().set_value(keyframe_tree_store_->canvas_interface()->get_canvas()->rend_desc().get_frame_rate());
-       cell_renderer_time_delta->property_fps().set_value(keyframe_tree_store_->canvas_interface()->get_canvas()->rend_desc().get_frame_rate());
-}
-
-void
-KeyframeTree::set_editable(bool x)
-{
-       editable_=x;
-
-       if(editable_)
-       {
-               cell_renderer_time->property_editable()=true;
-               cell_renderer_time_delta->property_editable()=true;
-               cell_renderer_description->property_editable()=true;
-       }
-       else
-       {
-               cell_renderer_time->property_editable()=false;
-               cell_renderer_time_delta->property_editable()=false;
-               cell_renderer_description->property_editable()=false;
-       }
-}
-
-void
-KeyframeTree::on_edited_time(const Glib::ustring&path_string,synfig::Time time)
-{
-       Gtk::TreePath path(path_string);
-
-       const Gtk::TreeRow row(*(get_model()->get_iter(path)));
-
-       synfig::Keyframe keyframe(row[model.keyframe]);
-       if(time!=keyframe.get_time())
-       {
-               row[model.time]=time;
-               //keyframe.set_time(time);
-               //signal_edited_time()(keyframe,time);
-               //signal_edited()(keyframe);
-       }
-}
-
-void
-KeyframeTree::on_edited_time_delta(const Glib::ustring&path_string,synfig::Time time)
-{
-       Gtk::TreePath path(path_string);
-
-       const Gtk::TreeRow row(*(get_model()->get_iter(path)));
-
-       if(row)row[model.time_delta]=time;
-}
-
-void
-KeyframeTree::on_edited_description(const Glib::ustring&path_string,const Glib::ustring &desc)
-{
-       Gtk::TreePath path(path_string);
-
-       const Gtk::TreeRow row = *(get_model()->get_iter(path));
-
-       const synfig::String description(desc);
-       synfig::Keyframe keyframe(row[model.keyframe]);
-       if(description!=keyframe.get_description())
-       {
-               row[model.description]=desc;
-               keyframe.set_description(description);
-               signal_edited_description()(keyframe,description);
-               signal_edited()(keyframe);
-       }
-}
-
-bool
-KeyframeTree::on_event(GdkEvent *event)
-{
-    switch(event->type)
-    {
-       case GDK_BUTTON_PRESS:
-               {
-                       Gtk::TreeModel::Path path;
-                       Gtk::TreeViewColumn *column;
-                       int cell_x, cell_y;
-                       int wx(round_to_int(event->button.x)),wy(round_to_int(event->button.y));
-                       //tree_to_widget_coords (,, wx, wy);
-                       if(!get_path_at_pos(
-                               wx,wy,  // x, y
-                               path, // TreeModel::Path&
-                               column, //TreeViewColumn*&
-                               cell_x,cell_y //int&cell_x,int&cell_y
-                               )
-                       ) break;
-                       const Gtk::TreeRow row = *(get_model()->get_iter(path));
-
-                       signal_user_click()(event->button.button,row,(ColumnID)column->get_sort_column_id());
-                       if((ColumnID)column->get_sort_column_id()==COLUMNID_JUMP)
-                       {
-                               keyframe_tree_store_->canvas_interface()->set_time(row[model.time]);
-                       }
-               }
-               break;
-       case GDK_2BUTTON_PRESS:
-               {
-                       Gtk::TreeModel::Path path;
-                       Gtk::TreeViewColumn *column;
-                       int cell_x, cell_y;
-                       if(!get_path_at_pos(
-                               int(event->button.x),int(event->button.y),      // x, y
-                               path, // TreeModel::Path&
-                               column, //TreeViewColumn*&
-                               cell_x,cell_y //int&cell_x,int&cell_y
-                               )
-                       ) break;
-                       const Gtk::TreeRow row = *(get_model()->get_iter(path));
-
-                       {
-                               keyframe_tree_store_->canvas_interface()->set_time(row[model.time]);
-                               return true;
-                       }
-               }
-               break;
-
-       case GDK_BUTTON_RELEASE:
-               break;
-       default:
-               break;
-       }
-       return false;
-}
diff --git a/synfig-studio/src/gtkmm/keyframetree.h b/synfig-studio/src/gtkmm/keyframetree.h
deleted file mode 100644 (file)
index 31d820e..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file keyframetree.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_KEYFRAMETREE_H
-#define __SYNFIG_STUDIO_KEYFRAMETREE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/treeview.h>
-#include <gtkmm/treestore.h>
-#include <synfigapp/canvasinterface.h>
-#include <synfigapp/value_desc.h>
-#include "keyframetreestore.h"
-#include <synfig/keyframe.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 CellRenderer_Time;
-
-class KeyframeTree : public Gtk::TreeView
-{
-       /*
- -- ** -- P U B L I C   T Y P E S ---------------------------------------------
-       */
-
-public:
-
-       enum ColumnID
-       {
-               COLUMNID_TIME,
-               COLUMNID_DESCRIPTION,
-               COLUMNID_JUMP,
-
-               COLUMNID_END                    //!< \internal
-       };
-
-       /*
- -- ** -- P U B L I C  D A T A ------------------------------------------------
-       */
-
-public:
-
-       KeyframeTreeStore::Model model;
-
-       /*
- -- ** -- P R I V A T E   D A T A ---------------------------------------------
-       */
-
-private:
-
-       Glib::RefPtr<KeyframeTreeStore> keyframe_tree_store_;
-
-       CellRenderer_Time *cell_renderer_time;
-
-       CellRenderer_Time *cell_renderer_time_delta;
-
-       Gtk::CellRendererText *cell_renderer_description;
-
-       sigc::signal<void,synfig::Keyframe> signal_edited_;
-
-       sigc::signal<void,synfig::Keyframe,synfig::Time> signal_edited_time_;
-
-       sigc::signal<void,synfig::Keyframe,synfig::String> signal_edited_description_;
-
-       sigc::signal<void, int, Gtk::TreeRow, ColumnID> signal_user_click_;
-
-       bool editable_;
-
-       /*
- -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
-       */
-
-private:
-
-       /*
- -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
-       */
-
-private:
-
-       void on_edited_time(const Glib::ustring&path_string,synfig::Time time);
-
-       void on_edited_time_delta(const Glib::ustring&path_string,synfig::Time time);
-
-       void on_edited_description(const Glib::ustring&path_string,const Glib::ustring &description);
-
-       bool on_event(GdkEvent *event);
-
-       void on_rend_desc_changed();
-
-       /*
- -- ** -- P U B L I C   M E T H O D S -----------------------------------------
-       */
-
-public:
-
-       KeyframeTree();
-       ~KeyframeTree();
-
-       void set_model(Glib::RefPtr<KeyframeTreeStore> keyframe_tree_store_);
-
-       void set_editable(bool x=true);
-
-       bool get_editable()const { return editable_; }
-
-       //! Signal called when a keyframe has been edited in any way
-       sigc::signal<void,synfig::Keyframe>& signal_edited() { return signal_edited_; }
-
-       //! Signal called when a time has been edited.
-       sigc::signal<void,synfig::Keyframe,synfig::Time>& signal_edited_time() { return signal_edited_time_; }
-
-       //! Signal called when a description has been edited.
-       sigc::signal<void,synfig::Keyframe,synfig::String>& signal_edited_description() { return signal_edited_description_; }
-
-       sigc::signal<void,int, Gtk::TreeRow, ColumnID>& signal_user_click() { return signal_user_click_; }
-}; // END of KeyframeTree
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/keyframetreestore.cpp b/synfig-studio/src/gtkmm/keyframetreestore.cpp
deleted file mode 100644 (file)
index 4e84001..0000000
+++ /dev/null
@@ -1,901 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file keyframetreestore.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 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 <config.h>
-#endif
-
-#include "keyframetreestore.h"
-#include <synfig/valuenode.h>
-#include "iconcontroller.h"
-#include <synfig/valuenode_timedswap.h>
-#include <gtkmm/button.h>
-#include <gtkmm/treerowreference.h>
-#include <synfig/canvas.h>
-#include <synfig/keyframe.h>
-#include <time.h>
-#include <cstdlib>
-#include <ETL/smart_ptr>
-#include <synfigapp/action.h>
-#include <synfigapp/instance.h>
-#include "onemoment.h"
-#include <synfig/exception.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 ======================================================= */
-
-// KeyframeTreeStore_Class KeyframeTreeStore::keyframe_tree_store_class_;
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-struct _keyframe_iterator
-{
-       synfig::KeyframeList::iterator iter;
-       int ref_count;
-       int index;
-};
-
-/*
-Gtk::TreeModel::iterator keyframe_iter_2_model_iter(synfig::KeyframeList::iterator iter,int index)
-{
-       Gtk::TreeModel::iterator ret;
-
-       _keyframe_iterator*& data(static_cast<_keyframe_iterator*&>(ret->gobj()->user_data));
-       data=new _keyframe_iterator();
-       data->ref_count=1;
-       data->iter=iter;
-       data->index=index;
-
-       return ret;
-}
-*/
-
-synfig::KeyframeList::iterator model_iter_2_keyframe_iter(Gtk::TreeModel::iterator iter)
-{
-       _keyframe_iterator* data(static_cast<_keyframe_iterator*>(iter->gobj()->user_data));
-       if(!data)
-               throw std::runtime_error("bad data");
-       return data->iter;
-}
-
-int get_index_from_model_iter(Gtk::TreeModel::iterator iter)
-{
-       _keyframe_iterator* data(static_cast<_keyframe_iterator*>(iter->gobj()->user_data));
-       if(!data)
-               throw std::runtime_error("bad data");
-       return data->index;
-}
-
-
-/*
-#ifndef TreeRowReferenceHack
-class TreeRowReferenceHack
-{
-       GtkTreeRowReference *gobject_;
-public:
-       TreeRowReferenceHack():
-               gobject_(0)
-       {
-       }
-
-       TreeRowReferenceHack(const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path):
-               gobject_ ( gtk_tree_row_reference_new(model->gobj(), const_cast<GtkTreePath*>(path.gobj())) )
-       {
-       }
-
-       TreeRowReferenceHack(const TreeRowReferenceHack &x):
-               gobject_ ( x.gobject_?gtk_tree_row_reference_copy(x.gobject_):0 )
-       {
-
-       }
-
-       void swap(TreeRowReferenceHack & other)
-       {
-               GtkTreeRowReference *const temp = gobject_;
-               gobject_ = other.gobject_;
-               other.gobject_ = temp;
-       }
-
-       const TreeRowReferenceHack &
-       operator=(const TreeRowReferenceHack &rhs)
-       {
-               TreeRowReferenceHack temp (rhs);
-               swap(temp);
-               return *this;
-       }
-
-       ~TreeRowReferenceHack()
-       {
-               if(gobject_)
-                       gtk_tree_row_reference_free(gobject_);
-       }
-
-       Gtk::TreeModel::Path get_path() { return Gtk::TreeModel::Path(gtk_tree_row_reference_get_path(gobject_),false); }
-       GtkTreeRowReference *gobj() { return gobject_; }
-};
-#endif
-*/
-
-/* === P R O C E D U R E S ================================================= */
-
-void clear_iterator(GtkTreeIter* iter)
-{
-       iter->stamp=0;
-       iter->user_data=iter->user_data2=iter->user_data3=0;
-}
-
-/* === M E T H O D S ======================================================= */
-
-const Glib::Class&
-KeyframeTreeStore_Class::init()
-{
-       if(!gtype_)
-       {
-               class_init_func_ = &KeyframeTreeStore_Class::class_init_function;
-
-               const GTypeInfo derived_info =
-               {
-                       sizeof(GObjectClass),
-                       NULL,
-                       NULL,
-                       class_init_func_,
-                       NULL,
-                       NULL,
-                       sizeof(GObject),
-                       0,
-                       0,
-                       NULL
-               };
-
-               gtype_ = g_type_register_static(G_TYPE_OBJECT, "KeyframeTreeStore", &derived_info, GTypeFlags(0));
-               Gtk::TreeModel::add_interface(get_type());
-       }
-       return *this;
-}
-
-void
-KeyframeTreeStore_Class::class_init_function(gpointer /*g_class*/, gpointer /*class_data*/)
-{
-       // ???
-}
-
-KeyframeTreeStore::KeyframeTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_):
-       Glib::ObjectBase        ("KeyframeTreeStore"),
-       //! \todo what is going on here?  why the need for this KeyframeTreeStore_Class at all?
-       // Glib::Object         (Glib::ConstructParams(keyframe_tree_store_class_.init(), (char*) 0, (char*) 0)),
-       canvas_interface_       (canvas_interface_)
-{
-       reset_stamp();
-       //reset_path_table();
-
-       canvas_interface()->signal_keyframe_added().connect(sigc::mem_fun(*this,&studio::KeyframeTreeStore::add_keyframe));
-       canvas_interface()->signal_keyframe_removed().connect(sigc::mem_fun(*this,&studio::KeyframeTreeStore::remove_keyframe));
-       canvas_interface()->signal_keyframe_changed().connect(sigc::mem_fun(*this,&studio::KeyframeTreeStore::change_keyframe));
-}
-
-KeyframeTreeStore::~KeyframeTreeStore()
-{
-       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
-               synfig::info("KeyframeTreeStore::~KeyframeTreeStore(): Deleted");
-}
-
-Glib::RefPtr<KeyframeTreeStore>
-KeyframeTreeStore::create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_)
-{
-       KeyframeTreeStore *store(new KeyframeTreeStore(canvas_interface_));
-       Glib::RefPtr<KeyframeTreeStore> ret(store);
-       assert(ret);
-       return ret;
-}
-
-void
-KeyframeTreeStore::reset_stamp()
-{
-       stamp_=time(0)+reinterpret_cast<long>(this);
-}
-
-/*
-void
-KeyframeTreeStore::reset_path_table()
-{
-       Gtk::TreeModel::Children::iterator iter;
-       const Gtk::TreeModel::Children children(children());
-       path_table_.clear();
-       for(iter = children.begin(); iter != children.end(); ++iter)
-       {
-               Gtk::TreeModel::Row row(*iter);
-               path_table_[(Keyframe)row[model.keyframe]]=TreeRowReferenceHack(Glib::RefPtr<KeyframeTreeStore>(this),Gtk::TreePath(row));
-       }
-}
-*/
-
-
-inline bool
-KeyframeTreeStore::iterator_sane(const GtkTreeIter* iter)const
-{
-       if(iter && iter->stamp==stamp_)
-               return true;
-       g_warning("KeyframeTreeStore::iterator_sane(): Bad iterator stamp");
-       return false;
-}
-
-inline bool
-KeyframeTreeStore::iterator_sane(const Gtk::TreeModel::iterator& iter)const
-{
-       return iterator_sane(iter->gobj());
-}
-
-inline void
-KeyframeTreeStore::dump_iterator(const GtkTreeIter* /*gtk_iter*/, const Glib::ustring &/*name*/)const
-{
-#if 0
-       if(!gtk_iter)
-       {
-               g_warning("KeyframeTreeStore::dump_iterator: \"%s\" is NULL (Root?)",name.c_str());
-               return;
-       }
-
-       _keyframe_iterator *iter(static_cast<_keyframe_iterator*>(gtk_iter->user_data));
-
-       if(gtk_iter->stamp!=stamp_ || !iter)
-       {
-               g_warning("KeyframeTreeStore::dump_iterator: \"%s\" is INVALID",name.c_str());
-               return;
-       }
-
-       if((unsigned)iter->index>=canvas_interface()->get_canvas()->keyframe_list().size())
-               g_warning("KeyframeTreeStore::dump_iterator: \"%s\"(%p) has bad index(index:%d)",name.c_str(),gtk_iter,iter->index);
-
-       g_warning("KeyframeTreeStore::dump_iterator: \"%s\"(%p) ref:%d, index:%d, time:%s",name.c_str(),gtk_iter,iter->ref_count,iter->index,iter->iter->get_time().get_string().c_str());
-#endif
-}
-
-inline void
-KeyframeTreeStore::dump_iterator(const Gtk::TreeModel::iterator& iter, const Glib::ustring &name)const
-{
-       dump_iterator(iter->gobj(),name);
-}
-
-int
-KeyframeTreeStore::time_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs)
-{
-       const Model model;
-
-       _keyframe_iterator *rhs_iter(static_cast<_keyframe_iterator*>(rhs->gobj()->user_data));
-       _keyframe_iterator *lhs_iter(static_cast<_keyframe_iterator*>(lhs->gobj()->user_data));
-
-       Time diff(rhs_iter->iter->get_time()-lhs_iter->iter->get_time());
-       if(diff<0)
-               return -1;
-       if(diff>0)
-               return 1;
-       return 0;
-}
-
-int
-KeyframeTreeStore::description_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs)
-{
-       const Model model;
-
-       _keyframe_iterator *rhs_iter(static_cast<_keyframe_iterator*>(rhs->gobj()->user_data));
-       _keyframe_iterator *lhs_iter(static_cast<_keyframe_iterator*>(lhs->gobj()->user_data));
-
-       int comp = rhs_iter->iter->get_description().compare(lhs_iter->iter->get_description());
-       if (comp > 0) return 1;
-       if (comp < 0) return -1;
-       return 0;
-}
-
-void
-KeyframeTreeStore::set_value_impl(const Gtk::TreeModel::iterator& row, int column, const Glib::ValueBase& value)
-{
-       if(!iterator_sane(row))
-               return;
-
-       if(column>=get_n_columns_vfunc())
-       {
-               g_warning("KeyframeTreeStore::set_value_impl: Bad column (%d)",column);
-               return;
-       }
-
-       if(!g_value_type_compatible(G_VALUE_TYPE(value.gobj()),get_column_type_vfunc(column)))
-       {
-               g_warning("KeyframeTreeStore::set_value_impl: Bad value type");
-               return;
-       }
-
-       _keyframe_iterator *iter(static_cast<_keyframe_iterator*>(row.gobj()->user_data));
-
-       try
-       {
-               if(column==model.time_delta.index())
-               {
-                       Glib::Value<synfig::Time> x;
-                       g_value_init(x.gobj(),model.time.type());
-                       g_value_copy(value.gobj(),x.gobj());
-
-                       Time new_delta(x.get());
-                       if(new_delta<=Time::zero()+Time::epsilon())
-                       {
-                               // Bad value
-                               return;
-                       }
-
-                       Time old_delta((*row)[model.time_delta]);
-                       if(old_delta<=Time::zero()+Time::epsilon())
-                       {
-                               // Bad old delta
-                               return;
-                       }
-                       // row(row) on the next line is bad - don't use it, because it leaves 'row' uninitialized
-                       //Gtk::TreeModel::iterator row(row);
-                       //row++;
-                       //if(!row)return;
-
-                       Time change_delta(new_delta-old_delta);
-
-                       if(change_delta<=Time::zero()+Time::epsilon() &&change_delta>=Time::zero()-Time::epsilon())
-                       {
-                               // Not an error, just no change
-                               return;
-                       }
-
-                       {
-                               Keyframe keyframe((*row)[model.keyframe]);
-                               synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeSetDelta"));
-
-                               if(!action)return;
-
-                               action->set_param("canvas",canvas_interface()->get_canvas());
-                               action->set_param("canvas_interface",canvas_interface());
-                               action->set_param("keyframe",keyframe);
-                               action->set_param("delta",change_delta);
-
-                               canvas_interface()->get_instance()->perform_action(action);
-                       }
-
-                       return;
-               }
-               else
-               if(column==model.time.index())
-               {
-                       OneMoment one_moment;
-
-                       Glib::Value<synfig::Time> x;
-                       g_value_init(x.gobj(),model.time.type());
-                       g_value_copy(value.gobj(),x.gobj());
-                       synfig::Keyframe keyframe(*iter->iter);
-
-                       synfig::info("KeyframeTreeStore::set_value_impl():old_time=%s",keyframe.get_time().get_string().c_str());
-                       keyframe.set_time(x.get());
-                       synfig::info("KeyframeTreeStore::set_value_impl():new_time=%s",keyframe.get_time().get_string().c_str());
-
-                       synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeSet"));
-
-                       if(!action)
-                               return;
-
-                       action->set_param("canvas",canvas_interface()->get_canvas());
-                       action->set_param("canvas_interface",canvas_interface());
-                       action->set_param("keyframe",keyframe);
-
-                       canvas_interface()->get_instance()->perform_action(action);
-               }
-               else if(column==model.description.index())
-               {
-                       Glib::Value<Glib::ustring> x;
-                       g_value_init(x.gobj(),model.description.type());
-                       g_value_copy(value.gobj(),x.gobj());
-                       synfig::Keyframe keyframe(*iter->iter);
-                       keyframe.set_description(x.get());
-
-                       synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeSet"));
-
-                       if(!action)
-                               return;
-
-                       action->set_param("canvas",canvas_interface()->get_canvas());
-                       action->set_param("canvas_interface",canvas_interface());
-                       action->set_param("keyframe",keyframe);
-
-                       canvas_interface()->get_instance()->perform_action(action);
-               }
-               else if(column==model.keyframe.index())
-               {
-                       g_warning("KeyframeTreeStore::set_value_impl: This column is read-only");
-               }
-               else
-               {
-                       assert(0);
-               }
-       }
-       catch(std::exception x)
-       {
-               g_warning("%s", x.what());
-       }
-}
-
-Gtk::TreeModelFlags
-KeyframeTreeStore::get_flags_vfunc ()
-{
-       return Gtk::TREE_MODEL_LIST_ONLY;
-}
-
-int
-KeyframeTreeStore::get_n_columns_vfunc ()
-{
-       return model.size();
-}
-
-GType
-KeyframeTreeStore::get_column_type_vfunc (int index)
-{
-       return model.types()[index];
-}
-
-bool
-KeyframeTreeStore::iter_next_vfunc (const iterator& xiter, iterator& iter_next) const
-{
-       if(!iterator_sane(xiter)) return false;
-
-       _keyframe_iterator *iter(static_cast<_keyframe_iterator*>(xiter.gobj()->user_data));
-
-       if(iter->iter==canvas_interface()->get_canvas()->keyframe_list().end())
-               return false;
-
-       _keyframe_iterator *next(new _keyframe_iterator());
-       iter_next.gobj()->user_data=static_cast<gpointer>(next);
-       next->ref_count=1;
-       next->index=iter->index+1;
-       next->iter=iter->iter;
-       ++next->iter;
-
-       if(next->iter==canvas_interface()->get_canvas()->keyframe_list().end())
-               return false;
-
-       iter_next.gobj()->stamp=stamp_;
-
-       return true;
-}
-
-/*
-bool
-KeyframeTreeStore::iter_next_vfunc (GtkTreeIter* gtk_iter)
-{
-       if(!iterator_sane(gtk_iter)) return false;
-
-       _keyframe_iterator *iter(static_cast<_keyframe_iterator*>(gtk_iter->user_data));
-
-       // If we are already at the end, then we are very invalid
-       if(iter->iter==canvas_interface()->get_canvas()->keyframe_list().end())
-               return false;
-
-       ++(iter->iter);
-
-       if(iter->iter==canvas_interface()->get_canvas()->keyframe_list().end())
-       {
-               --(iter->iter);
-               return false;
-       }
-       (iter->index)++;
-       return true;
-}
-
-bool
-KeyframeTreeStore::iter_children_vfunc (GtkTreeIter* gtk_iter, const GtkTreeIter* parent)
-{
-       dump_iterator(gtk_iter,"gtk_iter");
-       dump_iterator(parent,"parent");
-
-       if(!parent || !iterator_sane(parent))
-       {
-               clear_iterator(gtk_iter);
-               return false;
-       }
-
-       _keyframe_iterator *iter(new _keyframe_iterator());
-       iter->ref_count=1;
-       iter->index=0;
-       iter->iter=canvas_interface()->get_canvas()->keyframe_list().begin();
-
-       gtk_iter->user_data=static_cast<gpointer>(iter);
-       gtk_iter->stamp=stamp_;
-
-       return true;
-}
-
-bool
-KeyframeTreeStore::iter_has_child_vfunc (const GtkTreeIter*parent)
-{
-       dump_iterator(parent,"parent");
-
-       if(parent)
-               return false;
-
-       return true;
-}
-
-int
-KeyframeTreeStore::iter_n_children_vfunc (const GtkTreeIter* parent)
-{
-       dump_iterator(parent,"parent");
-
-       if(parent)
-               return 0;
-
-       return canvas_interface()->get_canvas()->keyframe_list().size();
-}
-*/
-
-int
-KeyframeTreeStore::iter_n_root_children_vfunc () const
-{
-       return canvas_interface()->get_canvas()->keyframe_list().size();
-}
-
-bool
-KeyframeTreeStore::iter_nth_root_child_vfunc (int n, iterator& xiter)const
-{
-       if(canvas_interface()->get_canvas()->keyframe_list().size()==0)
-       {
-               return false;
-       }
-
-       if(n<0)
-       {
-               g_warning("KeyframeTreeStore::iter_nth_root_child_vfunc: Out of range (negative index)");
-               return false;
-       }
-       if(n && (unsigned)n>=canvas_interface()->get_canvas()->keyframe_list().size())
-       {
-               g_warning("KeyframeTreeStore::iter_nth_child_vfunc: Out of range (large index)");
-               return false;
-       }
-
-       _keyframe_iterator *iter(new _keyframe_iterator());
-       iter->ref_count=1;
-       iter->index=n;
-       iter->iter=canvas_interface()->get_canvas()->keyframe_list().begin();
-       while(n--)
-       {
-               if(iter->iter==canvas_interface()->get_canvas()->keyframe_list().end())
-               {
-                       g_warning("KeyframeTreeStore::iter_nth_child_vfunc: >>>BUG<<< in %s on line %d",__FILE__,__LINE__);
-                       delete iter;
-                       return false;
-               }
-               ++iter->iter;
-       }
-       xiter.gobj()->user_data=static_cast<gpointer>(iter);
-       xiter.gobj()->stamp=stamp_;
-       return true;
-}
-
-/*
-bool
-KeyframeTreeStore::iter_nth_child_vfunc (GtkTreeIter* gtk_iter, const GtkTreeIter* parent, int n)
-{
-       dump_iterator(parent,"parent");
-
-       if(parent)
-       {
-               g_warning("KeyframeTreeStore::iter_nth_child_vfunc: I am a list");
-               clear_iterator(gtk_iter);
-               return false;
-       }
-
-
-
-       _keyframe_iterator *iter(new _keyframe_iterator());
-       iter->ref_count=1;
-       iter->index=n;
-       iter->iter=canvas_interface()->get_canvas()->keyframe_list().begin();
-       while(n--)
-       {
-               if(iter->iter==canvas_interface()->get_canvas()->keyframe_list().end())
-               {
-                       g_warning("KeyframeTreeStore::iter_nth_child_vfunc: >>>BUG<<< in %s on line %d",__FILE__,__LINE__);
-                       delete iter;
-                       clear_iterator(gtk_iter);
-                       return false;
-               }
-               ++iter->iter;
-       }
-
-       gtk_iter->user_data=static_cast<gpointer>(iter);
-       gtk_iter->stamp=stamp_;
-       return true;
-}
-
-bool
-KeyframeTreeStore::iter_parent_vfunc (GtkTreeIter* gtk_iter, const GtkTreeIter* child)
-{
-       dump_iterator(child,"child");
-       iterator_sane(child);
-       clear_iterator(gtk_iter);
-       return false;
-}
-*/
-
-void
-KeyframeTreeStore::ref_node_vfunc (iterator& xiter)const
-{
-       GtkTreeIter* gtk_iter(xiter.gobj());
-       if(!gtk_iter || !iterator_sane(gtk_iter)) return;
-
-       _keyframe_iterator *iter(static_cast<_keyframe_iterator*>(gtk_iter->user_data));
-       iter->ref_count++;
-}
-
-void
-KeyframeTreeStore::unref_node_vfunc (iterator& xiter)const
-{
-       GtkTreeIter* gtk_iter(xiter.gobj());
-       if(!gtk_iter || !iterator_sane(gtk_iter)) return;
-
-       _keyframe_iterator *iter(static_cast<_keyframe_iterator*>(gtk_iter->user_data));
-       iter->ref_count--;
-       if(!iter->ref_count)
-       {
-               delete iter;
-
-               // Make this iterator invalid
-               gtk_iter->stamp=0;
-       }
-}
-
-Gtk::TreeModel::Path
-KeyframeTreeStore::get_path_vfunc (const iterator& gtk_iter)const
-{
-       Gtk::TreeModel::Path path;
-
-       // If this is the root node, then return
-       // a root path
-       if(!iterator_sane(gtk_iter))
-               return path;
-
-       _keyframe_iterator *iter(static_cast<_keyframe_iterator*>(gtk_iter->gobj()->user_data));
-
-       path.append_index(iter->index);
-
-       return path;
-}
-
-bool
-KeyframeTreeStore::get_iter_vfunc (const Gtk::TreeModel::Path& path, iterator& iter)const
-{
-       if(path.get_depth()>=1)
-               return iter_nth_root_child_vfunc(path.front(),iter);
-
-       // Error case
-       g_warning("KeyframeTreeStore::get_iter_vfunc(): Bad path \"%s\"",path.to_string().c_str());
-       //clear_iterator(iter);
-       return false;
-}
-
-bool
-KeyframeTreeStore::iter_is_valid (const iterator& iter) const
-{
-       return iterator_sane(iter);
-}
-
-void
-KeyframeTreeStore::get_value_vfunc (const Gtk::TreeModel::iterator& gtk_iter, int column, Glib::ValueBase& value)const
-{
-       dump_iterator(gtk_iter,"gtk_iter");
-       if(!iterator_sane(gtk_iter))
-               return;
-
-       _keyframe_iterator *iter(static_cast<_keyframe_iterator*>(gtk_iter->gobj()->user_data));
-
-       switch(column)
-       {
-       case 0:         // Time
-       {
-               Glib::Value<synfig::Time> x;
-               g_value_init(x.gobj(),x.value_type());
-               x.set(iter->iter->get_time());
-               g_value_init(value.gobj(),x.value_type());
-               g_value_copy(x.gobj(),value.gobj());
-               return;
-       }
-       case 3:         // Time Delta
-       {
-               Glib::Value<synfig::Time> x;
-               g_value_init(x.gobj(),x.value_type());
-
-               synfig::Keyframe prev_keyframe(*iter->iter);
-               synfig::Keyframe keyframe;
-               {
-                       KeyframeList::iterator tmp(iter->iter);
-                       tmp++;
-                       if(tmp==get_canvas()->keyframe_list().end())
-                       {
-                               x.set(Time(0));
-                               g_value_init(value.gobj(),x.value_type());
-                               g_value_copy(x.gobj(),value.gobj());
-                               return;
-                       }
-                       keyframe=*tmp;
-               }
-
-               Time delta(0);
-               try {
-                       delta=keyframe.get_time()-prev_keyframe.get_time();
-               }catch(...) { }
-               x.set(delta);
-               g_value_init(value.gobj(),x.value_type());
-               g_value_copy(x.gobj(),value.gobj());
-               return;
-       }
-       case 1:         // Description
-       {
-               g_value_init(value.gobj(),G_TYPE_STRING);
-               g_value_set_string(value.gobj(),iter->iter->get_description().c_str());
-               return;
-       }
-       case 2:         // Keyframe
-       {
-               Glib::Value<synfig::Keyframe> x;
-               g_value_init(x.gobj(),x.value_type());
-               x.set(*iter->iter);
-               g_value_init(value.gobj(),x.value_type());
-               g_value_copy(x.gobj(),value.gobj());
-               return;
-       }
-       default:
-               break;
-       }
-}
-
-Gtk::TreeModel::Row
-KeyframeTreeStore::find_row(const synfig::Keyframe &keyframe)
-{
-       Gtk::TreeModel::Row row(*(children().begin()));
-       dump_iterator(row,"find_row,begin");
-       const GtkTreeIter *gtk_iter(row.gobj());
-       if(!iterator_sane(gtk_iter))
-               throw std::runtime_error(_("Unable to find Keyframe in table"));
-
-       _keyframe_iterator *iter(static_cast<_keyframe_iterator*>(gtk_iter->user_data));
-
-       synfig::KeyframeList &keyframe_list(canvas_interface()->get_canvas()->keyframe_list());
-       if(keyframe_list.empty())
-               throw std::runtime_error(_("There are no keyframes n this canvas"));
-
-       iter->index=0;
-
-       for(iter->iter=keyframe_list.begin();iter->iter!=keyframe_list.end() && *iter->iter!=keyframe;++iter->iter)
-       {
-               iter->index++;
-       }
-       if(iter->iter==keyframe_list.end())
-               throw std::runtime_error(_("Unable to find Keyframe in table"));
-       return row;
-}
-
-void
-KeyframeTreeStore::add_keyframe(synfig::Keyframe keyframe)
-{
-       try
-       {
-               Gtk::TreeRow row(find_row(keyframe));
-               dump_iterator(row.gobj(),"add_keyframe,row");
-               Gtk::TreePath path(get_path(row));
-
-               row_inserted(path,row);
-
-               old_keyframe_list=get_canvas()->keyframe_list();
-               //old_keyframe_list.add(keyframe);
-               //old_keyframe_list.sort();
-       }
-       catch(std::exception x)
-       {
-               g_warning("%s", x.what());
-       }
-}
-
-void
-KeyframeTreeStore::remove_keyframe(synfig::Keyframe keyframe)
-{
-       try
-       {
-               if(1)
-               {
-                       Gtk::TreeRow row(find_row(keyframe));
-                       dump_iterator(row,"remove_keyframe,row");
-                       Gtk::TreePath path(get_path(row));
-                       row_deleted(path);
-
-                       old_keyframe_list.erase(keyframe);
-               }
-               else
-               {
-                       g_warning("KeyframeTreeStore::remove_keyframe: Keyframe not in table");
-               }
-       }
-       catch(std::exception x)
-       {
-               g_warning("%s", x.what());
-       }
-}
-
-void
-KeyframeTreeStore::change_keyframe(synfig::Keyframe keyframe)
-{
-       try
-       {
-               Gtk::TreeRow row(find_row(keyframe));
-
-               unsigned int new_index(get_index_from_model_iter(row));
-               unsigned int old_index(0);
-               synfig::KeyframeList::iterator iter;
-               for(old_index=0,iter=old_keyframe_list.begin();iter!=old_keyframe_list.end() && (UniqueID)*iter!=(UniqueID)keyframe;++iter,old_index++)
-                       ;
-
-               if(iter!=old_keyframe_list.end() && new_index!=old_index)
-               {
-                       std::vector<int> new_order;
-                       for(unsigned int i=0;i<old_keyframe_list.size();i++)
-                       {
-                               new_order.push_back(i);
-                       }
-                       if(new_order.size()>new_index)
-                       {
-                               new_order.erase(new_order.begin()+new_index);
-                               new_order.insert(new_order.begin()+old_index,new_index);
-
-                               //new_order[old_index]=
-
-                               rows_reordered (Path(), iterator(), &new_order[0]);
-                       }
-                       old_keyframe_list=get_canvas()->keyframe_list();
-
-                       row=find_row(keyframe);
-               }
-
-               dump_iterator(row,"change_keyframe,row");
-               row_changed(get_path(row),row);
-       }
-       catch(std::exception x)
-       {
-               g_warning("%s", x.what());
-       }
-}
diff --git a/synfig-studio/src/gtkmm/keyframetreestore.h b/synfig-studio/src/gtkmm/keyframetreestore.h
deleted file mode 100644 (file)
index c3efccf..0000000
+++ /dev/null
@@ -1,224 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file keyframetreestore.h
-**     \brief Template Header
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === S T A R T =========================================================== */
-
-#ifndef __SYNFIG_STUDIO_KEYFRAMETREESTORE_H
-#define __SYNFIG_STUDIO_KEYFRAMETREESTORE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/liststore.h>
-#include <synfigapp/canvasinterface.h>
-#include <gdkmm/pixbuf.h>
-#include <synfig/keyframe.h>
-#include <map>
-
-/* === 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 ======================================= */
-
-//class TreeRowReferenceHack;
-//#define TreeRowReferenceHack Gtk::TreeRowReference
-
-namespace studio {
-
-class KeyframeTreeStore_Class;
-
-class KeyframeTreeStore :
-       public Glib::Object,
-       public Gtk::TreeModel,
-       public Gtk::TreeDragSource,
-       public Gtk::TreeDragDest
-{
-       /*
- -- ** -- P U B L I C   T Y P E S ---------------------------------------------
-       */
-
-public:
-
-       class Model : public Gtk::TreeModel::ColumnRecord
-       {
-       public:
-               Gtk::TreeModelColumn<synfig::Time> time;
-               Gtk::TreeModelColumn<Glib::ustring> description;
-               Gtk::TreeModelColumn<synfig::Keyframe> keyframe;
-               Gtk::TreeModelColumn<synfig::Time> time_delta;
-
-               Model()
-               {
-                       add(time);
-                       add(description);
-                       add(keyframe);
-                       add(time_delta);
-               }
-       };
-
-       /*
- -- ** -- P U B L I C  D A T A ------------------------------------------------
-       */
-
-public:
-
-       const Model model;
-
-       /*
- -- ** -- P R I V A T E   D A T A ---------------------------------------------
-       */
-
-private:
-
-       etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
-
-       //! Unique stamp for this TreeModel.
-       int stamp_;
-
-       static KeyframeTreeStore_Class keyframe_tree_store_class_;
-
-       //std::map<synfig::Keyframe,TreeRowReferenceHack> path_table_;
-
-       synfig::KeyframeList old_keyframe_list;
-
-       /*
- -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
-       */
-
-private:
-
-       void add_keyframe(synfig::Keyframe);
-
-       void remove_keyframe(synfig::Keyframe);
-
-       void change_keyframe(synfig::Keyframe);
-
-       static int sorter(const Gtk::TreeModel::iterator &,const Gtk::TreeModel::iterator &);
-
-       bool iterator_sane(const GtkTreeIter* iter)const;
-
-       bool iterator_sane(const Gtk::TreeModel::iterator& iter)const;
-
-       void dump_iterator(const GtkTreeIter* iter, const Glib::ustring &name)const;
-
-       void dump_iterator(const Gtk::TreeModel::iterator& iter, const Glib::ustring &name)const;
-
-       //! Resets the iterator stamp for this model.
-       /*!     This should be called whenever the class is
-       **      constructed     or when large numbers of
-       **      iterators become invalid. */
-       void reset_stamp();
-
-       //void reset_path_table();
-
-       /*
- -- ** -- V I R T U A L   F U N C T I O N S -----------------------------------
-       */
-
-protected:
-
-       virtual void set_value_impl (const Gtk::TreeModel::iterator& row, int column, const Glib::ValueBase& value);
-       virtual Gtk::TreeModelFlags  get_flags_vfunc ();
-       virtual int  get_n_columns_vfunc ();
-       virtual GType  get_column_type_vfunc (int index);
-       virtual bool iter_next_vfunc (const iterator& iter, iterator& iter_next) const;
-       virtual bool  get_iter_vfunc (const Gtk::TreeModel::Path& path, iterator& iter_next)const;
-       virtual bool  iter_nth_root_child_vfunc (int n, iterator& iter)const;
-       virtual Gtk::TreeModel::Path  get_path_vfunc (const iterator& iter)const;
-       virtual void  ref_node_vfunc (iterator& iter)const;
-       virtual void  unref_node_vfunc (iterator& iter)const;
-       virtual void  get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const;
-       virtual bool    iter_is_valid (const iterator& iter) const;
-       virtual int     iter_n_root_children_vfunc () const;
-
-       //virtual bool  iter_nth_child_vfunc (GtkTreeIter* iter, const GtkTreeIter* parent, int n);
-       //virtual bool  iter_children_vfunc (GtkTreeIter* iter, const GtkTreeIter* parent);
-       //virtual bool  iter_has_child_vfunc (const GtkTreeIter* iter);
-       //virtual int  iter_n_children_vfunc (const GtkTreeIter* iter);
-       //virtual bool  iter_parent_vfunc (GtkTreeIter* iter, const GtkTreeIter* child);
-
-       /*
-       virtual bool  get_sort_column_id_vfunc (int* sort_column_id, Gtk::SortType* order);
-       virtual void  set_sort_column_id_vfunc (int sort_column_id, Gtk::SortType order);
-       virtual void  set_sort_func_vfunc (int sort_column_id, GtkTreeIterCompareFunc func, void* data, GtkDestroyNotify destroy);
-       virtual void  set_default_sort_func_vfunc (GtkTreeIterCompareFunc func, void* data, GtkDestroyNotify destroy);
-       virtual bool  has_default_sort_func_vfunc ();
-       */
-
-       /*
- -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
-       */
-
-private:
-
-       /*
- -- ** -- P U B L I C   M E T H O D S -----------------------------------------
-       */
-
-public:
-
-       KeyframeTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
-       ~KeyframeTreeStore();
-
-       etl::loose_handle<synfigapp::CanvasInterface> canvas_interface() { return canvas_interface_; }
-       etl::loose_handle<const synfigapp::CanvasInterface> canvas_interface()const { return canvas_interface_; }
-
-       synfig::Canvas::Handle get_canvas() { return canvas_interface()->get_canvas(); }
-       synfig::Canvas::Handle get_canvas()const { return canvas_interface()->get_canvas(); }
-
-       Gtk::TreeModel::Row find_row(const synfig::Keyframe &keyframe);
-
-       /*
- -- ** -- S T A T I C  M E T H O D S ------------------------------------------
-       */
-
-public:
-
-       static Glib::RefPtr<KeyframeTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
-
-       static int time_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs);
-       static int description_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs);
-
-}; // END of class KeyframeTreeStore
-
-//! \internal
-class KeyframeTreeStore_Class : public Glib::Class
-{
-public:
-       struct KeyframeTreeStoreClass
-       {
-               GObjectClass parent_class;
-       };
-
-       friend class KeyframeTreeStore;
-
-       const Glib::Class& init();
-
-       static void class_init_function(gpointer g_blass, gpointer class_data);
-}; // END of CustomTreeStore_Class
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/keymapsettings.cpp b/synfig-studio/src/gtkmm/keymapsettings.cpp
deleted file mode 100644 (file)
index 787b054..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file keymapsettings.cpp
-**     \brief Contains Info for Key Map settings
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "keymapsettings.h"
-
-#include <gtkmm/accelkey.h>
-#include <gtkmm/accelmap.h>
-#include <gtk/gtkaccelmap.h>
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-//using namespace etl;
-//using namespace synfig;
-using namespace studio;
-
-using namespace Gtk;
-//using namespace Gtk::Menu_Helpers;
-
-/* === M A C R O S ========================================================= */
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-/* === E N T R Y P O I N T ================================================= */
-
-// KeyMapSettings Definitions
-KeyMapSettings::KeyMapSettings()
-{
-}
-
-KeyMapSettings::~KeyMapSettings()
-{
-}
-
-bool KeyMapSettings::set_key(const char *path, guint key, Gdk::ModifierType mod, bool replace)
-{
-       if(gtk_accel_map_lookup_entry(path,NULL))
-       {
-               return AccelMap::change_entry(path,key,mod,replace);
-       }else
-       {
-               AccelMap::add_entry(path,key,mod);
-               return true;
-       }
-}
-
-bool KeyMapSettings::get_key(const char *path, Gtk::AccelKey *key)
-{
-       GtkAccelKey     ac;
-       if(gtk_accel_map_lookup_entry(path,&ac))
-       {
-               *key = AccelKey(ac.accel_key,(Gdk::ModifierType)ac.accel_mods,string(path));
-               return true;
-       }
-
-       return false;
-}
-
-bool KeyMapSettings::load(const char *filename)
-{
-       string n(filename);
-       n += ".skm";
-
-       AccelMap::load(filename);
-
-       return true;
-}
-
-bool KeyMapSettings::save(const char *filename)
-{
-       string n(filename);
-       n += ".skm";
-
-       AccelMap::save(filename);
-
-       return true;
-}
diff --git a/synfig-studio/src/gtkmm/keymapsettings.h b/synfig-studio/src/gtkmm/keymapsettings.h
deleted file mode 100644 (file)
index f216095..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file keymapsettings.h
-**     \brief Defines the structures for managing key map settings
-**
-**     $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_KEYMAPSETTINGS_H
-#define __SYNFIG_KEYMAPSETTINGS_H
-
-/* === H E A D E R S ======================================================= */
-#include <gtkmm/dialog.h>
-
-#include <set>
-#include <map>
-#include <string>
-
-#include <gtkmm/accelkey.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 {
-
-//a dialog for viewing and setting options, though it can also be used just as is
-class KeyMapSettings : public Gtk::Dialog
-{
-       struct AcKeyInfo
-       {
-               guint                           key;
-               Gdk::ModifierType       mod;
-
-               bool                            on;
-
-               AcKeyInfo(guint k = 0, Gdk::ModifierType m = Gdk::ModifierType())
-               :key(k),mod(m) {}
-       };
-
-       //std::map<const char *,AcKeyInfo>      pathmap; //uses string info from paths set
-       //std::set<std::string>                         accelpaths;
-
-       bool unsaved; //Assume as such...
-
-public:
-
-       KeyMapSettings();
-       ~KeyMapSettings();
-
-       //void add_path(const char *path);
-
-       bool set_key(const char *path, guint key, Gdk::ModifierType mod, bool replace = true);
-       bool get_key(const char *path, Gtk::AccelKey *key);
-
-       // These files must be sent a filename without extension (so the key map can be obtained)
-       bool load(const char *filename);
-       bool save(const char *filename);
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/layeractionmanager.cpp b/synfig-studio/src/gtkmm/layeractionmanager.cpp
deleted file mode 100644 (file)
index c3a3be4..0000000
+++ /dev/null
@@ -1,524 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file layeractionmanager.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 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 <config.h>
-#endif
-
-#include "layeractionmanager.h"
-#include "layertree.h"
-#include <synfig/context.h>
-#include <synfig/layer_pastecanvas.h>
-#include <synfigapp/action_param.h>
-#include "instance.h"
-#include <synfigapp/selectionmanager.h>
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-using namespace synfig;
-using namespace studio;
-
-static const guint no_prev_popup((guint)-1);
-
-/* === M A C R O S ========================================================= */
-
-//#define ONE_ACTION_GROUP 1
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-LayerActionManager::LayerActionManager():
-       action_group_(Gtk::ActionGroup::create("action_group_layer_action_manager")),
-       popup_id_(no_prev_popup),
-       action_group_copy_paste(Gtk::ActionGroup::create("action_group_copy_paste")),
-       queued(false)
-{
-       action_cut_=Gtk::Action::create(
-               "cut",
-               Gtk::StockID("gtk-cut")
-       );
-       action_cut_->signal_activate().connect(
-               sigc::mem_fun(
-                       *this,
-                       &LayerActionManager::cut
-               )
-       );
-       action_copy_=Gtk::Action::create(
-               "copy",
-               Gtk::StockID("gtk-copy")
-       );
-       action_copy_->signal_activate().connect(
-               sigc::mem_fun(
-                       *this,
-                       &LayerActionManager::copy
-               )
-       );
-       action_paste_=Gtk::Action::create(
-               "paste",
-               Gtk::StockID("gtk-paste")
-       );
-       action_paste_->signal_activate().connect(
-               sigc::mem_fun(
-                       *this,
-                       &LayerActionManager::paste
-               )
-       );
-
-
-       action_amount_inc_=Gtk::Action::create(
-               "amount-inc",
-               Gtk::StockID("gtk-add"),
-               _("Increase Amount"),_("Increase Amount")
-       );
-       action_amount_inc_->signal_activate().connect(
-               sigc::mem_fun(
-                       *this,
-                       &LayerActionManager::amount_inc
-               )
-       );
-
-       action_amount_dec_=Gtk::Action::create(
-               "amount-dec",
-               Gtk::StockID("gtk-remove"),
-               _("Decrease Amount"),_("Decrease Amount")
-       );
-       action_amount_dec_->signal_activate().connect(
-               sigc::mem_fun(
-                       *this,
-                       &LayerActionManager::amount_dec
-               )
-       );
-
-       action_amount_=Gtk::Action::create(
-               "amount",
-               Gtk::StockID("gtk-index"),
-               _("Amount"),_("Amount")
-       );
-
-       action_select_all_child_layers_=Gtk::Action::create(
-               "select-all-child-layers",
-               Gtk::StockID("synfig-select_all_child_layers"),
-               _("Select All Child Layers"),_("Select All Child Layers")
-       );
-       action_select_all_child_layers_->set_sensitive(false);
-}
-
-LayerActionManager::~LayerActionManager()
-{
-}
-
-void
-LayerActionManager::set_ui_manager(const Glib::RefPtr<Gtk::UIManager> &x)
-{
-       clear();
-
-#ifdef ONE_ACTION_GROUP
-       if(ui_manager_) get_ui_manager()->remove_action_group(action_group_);
-       ui_manager_=x;
-       if(ui_manager_) get_ui_manager()->insert_action_group(action_group_);
-#else
-       ui_manager_=x;
-#endif
-}
-
-void
-LayerActionManager::set_layer_tree(LayerTree* x)
-{
-       selection_changed_connection.disconnect();
-       layer_tree_=x;
-       if(layer_tree_)
-       {
-               selection_changed_connection=layer_tree_->get_selection()->signal_changed().connect(
-                       sigc::mem_fun(*this,&LayerActionManager::queue_refresh)
-               );
-       }
-}
-
-void
-LayerActionManager::set_canvas_interface(const etl::handle<synfigapp::CanvasInterface> &x)
-{
-       canvas_interface_=x;
-}
-
-void
-LayerActionManager::clear()
-{
-       if(ui_manager_)
-       {
-               // Clear out old stuff
-               if(popup_id_!=no_prev_popup)
-               {
-                       get_ui_manager()->remove_ui(popup_id_);
-                       if(action_group_)get_ui_manager()->ensure_update();
-                       popup_id_=no_prev_popup;
-                       if(action_group_)while(!action_group_->get_actions().empty())action_group_->remove(*action_group_->get_actions().begin());
-#ifdef ONE_ACTION_GROUP
-#else
-                       if(action_group_)get_ui_manager()->remove_action_group(action_group_);
-                       action_group_=Gtk::ActionGroup::create("action_group_layer_action_manager");
-#endif
-               }
-       }
-
-       while(!update_connection_list.empty())
-       {
-               update_connection_list.front().disconnect();
-               update_connection_list.pop_front();
-       }
-}
-
-void
-LayerActionManager::queue_refresh()
-{
-       if(queued)
-               return;
-
-       //queue_refresh_connection.disconnect();
-       queue_refresh_connection=Glib::signal_idle().connect(
-               sigc::bind_return(
-                       sigc::mem_fun(*this,&LayerActionManager::refresh),
-                       false
-               )
-       );
-
-       queued=true;
-}
-
-void
-LayerActionManager::refresh()
-{
-       if(queued)
-       {
-               queued=false;
-               //queue_refresh_connection.disconnect();
-       }
-
-
-       clear();
-
-       // Make sure we are ready
-       if(!ui_manager_ || !layer_tree_ || !canvas_interface_)
-       {
-               synfig::error("LayerActionManager::refresh(): Not ready!");
-               return;
-       }
-
-       String ui_info;
-
-       action_paste_->set_sensitive(!clipboard_.empty());
-       action_group_->add(action_paste_);
-
-       if(layer_tree_->get_selection()->count_selected_rows()!=0)
-       {
-               bool multiple_selected(layer_tree_->get_selection()->count_selected_rows()>1);
-               Layer::Handle layer(layer_tree_->get_selected_layer());
-
-               {
-                       bool canvas_set(false);
-                       synfigapp::Action::ParamList param_list;
-                       param_list.add("time",get_canvas_interface()->get_time());
-                       param_list.add("canvas_interface",get_canvas_interface());
-                       {
-                               synfigapp::SelectionManager::LayerList layer_list(layer_tree_->get_selected_layers());
-                               synfigapp::SelectionManager::LayerList::iterator iter;
-                               action_copy_->set_sensitive(!layer_list.empty());
-                               action_cut_->set_sensitive(!layer_list.empty());
-                               action_group_->add(action_copy_);
-                               action_group_->add(action_cut_);
-
-                               action_amount_inc_->set_sensitive(!layer_list.empty());
-                               action_amount_dec_->set_sensitive(!layer_list.empty());
-                               action_amount_->set_sensitive(!layer_list.empty());
-                               action_group_->add(action_amount_inc_);
-                               action_group_->add(action_amount_dec_);
-                               action_group_->add(action_amount_);
-
-                               for(iter=layer_list.begin();iter!=layer_list.end();++iter)
-                               {
-                                       update_connection_list.push_back(
-                                               (*iter)->signal_changed().connect(
-                                                       sigc::mem_fun(*this, &LayerActionManager::queue_refresh)
-                                               )
-                                       );
-
-                                       if(!canvas_set)
-                                       {
-                                               param_list.add("canvas",Canvas::Handle((*iter)->get_canvas()));
-                                               canvas_set=true;
-                                               update_connection_list.push_back(
-                                                       (*iter)->get_canvas()->signal_changed().connect(
-                                                               sigc::mem_fun(*this, &LayerActionManager::queue_refresh)
-                                                       )
-                                               );
-                                       }
-                                       param_list.add("layer",Layer::Handle(*iter));
-                               }
-                       }
-
-                       if(!multiple_selected && layer->get_name()=="PasteCanvas")
-                       {
-                               if (select_all_child_layers_connection)
-                                       select_all_child_layers_connection.disconnect();
-
-                               select_all_child_layers_connection = action_select_all_child_layers_->signal_activate().connect(
-                                       sigc::bind(sigc::mem_fun(*layer_tree_,
-                                                                                        &studio::LayerTree::select_all_children_layers),
-                                                          Layer::LooseHandle(layer)));
-
-                               action_select_all_child_layers_->set_sensitive(true);
-
-                               ui_info+="<menuitem action='select-all-child-layers'/>";
-                       }
-                       else
-                               action_select_all_child_layers_->set_sensitive(false);
-
-                       handle<studio::Instance>::cast_static(get_canvas_interface()->get_instance())->
-                               add_actions_to_group(action_group_, ui_info,   param_list, synfigapp::Action::CATEGORY_LAYER);
-               }
-       }
-
-       ui_info=("<ui>"
-                          "<popup action='menu-main'>"
-                            "<menu action='menu-layer'>" +
-                                  ui_info +
-                                  "<separator/>"
-                              "<menuitem action='cut' />"
-                                  "<menuitem action='copy' />"
-                                  "<menuitem action='paste' />"
-                                  "<separator/>"
-                            "</menu>"
-                          "</popup>" +
-                        "</ui>");
-       popup_id_=get_ui_manager()->add_ui_from_string(ui_info);
-#ifdef ONE_ACTION_GROUP
-#else
-       get_ui_manager()->insert_action_group(action_group_);
-#endif
-}
-
-void
-LayerActionManager::cut()
-{
-       copy();
-       if(action_group_->get_action("action-LayerRemove"))
-               action_group_->get_action("action-LayerRemove")->activate();
-}
-
-void
-LayerActionManager::copy()
-{
-       synfigapp::SelectionManager::LayerList layer_list(layer_tree_->get_selected_layers());
-       clipboard_.clear();
-       synfig::GUID guid;
-
-       while(!layer_list.empty())
-       {
-               clipboard_.push_back(layer_list.front()->clone(guid));
-               layer_list.pop_front();
-       }
-
-       action_paste_->set_sensitive(!clipboard_.empty());
-
-       //queue_refresh();
-}
-
-void
-LayerActionManager::paste()
-{
-       synfig::GUID guid;
-
-       // Create the action group
-       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Paste"));
-
-       Canvas::Handle canvas(get_canvas_interface()->get_canvas());
-       int depth(0);
-
-       // we are temporarily using the layer to hold something
-       Layer::Handle layer(layer_tree_->get_selected_layer());
-       if(layer)
-       {
-               depth=layer->get_depth();
-               canvas=layer->get_canvas();
-       }
-
-       synfigapp::SelectionManager::LayerList layer_selection;
-
-       for(std::list<synfig::Layer::Handle>::iterator iter=clipboard_.begin();iter!=clipboard_.end();++iter)
-       {
-               layer=(*iter)->clone(guid);
-               layer_selection.push_back(layer);
-               synfigapp::Action::Handle       action(synfigapp::Action::create("LayerAdd"));
-
-               assert(action);
-               if(!action)
-                       return;
-
-               action->set_param("canvas",canvas);
-               action->set_param("canvas_interface",etl::loose_handle<synfigapp::CanvasInterface>(get_canvas_interface()));
-               action->set_param("new",layer);
-
-               if(!action->is_ready())
-               {
-                       return;
-               }
-
-               if(!get_instance()->perform_action(action))
-               {
-                       return;
-               }
-
-               etl::handle<Layer_PasteCanvas> paste = etl::handle<Layer_PasteCanvas>::cast_dynamic(layer);
-               if (paste) paste->update_renddesc();
-
-               // synfig::info("DEPTH=%d",depth);
-
-               // Action to move the layer (if necessary)
-               if(depth>0)
-               {
-                       synfigapp::Action::Handle       action(synfigapp::Action::create("LayerMove"));
-
-                       assert(action);
-                       if(!action)
-                               return;
-
-                       action->set_param("canvas",canvas);
-                       action->set_param("canvas_interface",etl::loose_handle<synfigapp::CanvasInterface>(get_canvas_interface()));
-                       action->set_param("layer",layer);
-                       action->set_param("new_index",depth);
-
-                       if(!action->is_ready())
-                       {
-                               //get_ui_interface()->error(_("Move Action Not Ready"));
-                               //return 0;
-                               return;
-                       }
-
-                       if(!get_instance()->perform_action(action))
-                       {
-                               //get_ui_interface()->error(_("Move Action Not Ready"));
-                               //return 0;
-                               return;
-                       }
-               }
-               depth++;
-
-               // automatically export the Index parameter of Duplicate layers when pasting
-               int index = 1;
-               export_dup_nodes(layer, canvas, index);
-       }
-       get_canvas_interface()->get_selection_manager()->clear_selected_layers();
-       get_canvas_interface()->get_selection_manager()->set_selected_layers(layer_selection);
-}
-
-void
-LayerActionManager::export_dup_nodes(synfig::Layer::Handle layer, Canvas::Handle canvas, int &index)
-{
-       // automatically export the Index parameter of Duplicate layers when pasting
-       if (layer->get_name() == "duplicate")
-               while (true)
-               {
-                       String name = strprintf(_("Index %d"), index++);
-                       try
-                       {
-                               canvas->find_value_node(name);
-                       }
-                       catch (Exception::IDNotFound x)
-                       {
-                               get_canvas_interface()->add_value_node(layer->dynamic_param_list().find("index")->second, name);
-                               break;
-                       }
-               }
-       else
-       {
-               Layer::ParamList param_list(layer->get_param_list());
-               for (Layer::ParamList::const_iterator iter(param_list.begin())
-                                ; iter != param_list.end()
-                                ; iter++)
-                       if (layer->dynamic_param_list().count(iter->first)==0 && iter->second.get_type()==ValueBase::TYPE_CANVAS)
-                       {
-                               Canvas::Handle subcanvas(iter->second.get(Canvas::Handle()));
-                               if (subcanvas && subcanvas->is_inline())
-                                       for (Context iter = subcanvas->get_context(); iter != subcanvas->end(); iter++)
-                                               export_dup_nodes(*iter, canvas, index);
-                       }
-
-               for (Layer::DynamicParamList::const_iterator iter(layer->dynamic_param_list().begin())
-                                ; iter != layer->dynamic_param_list().end()
-                                ; iter++)
-                       if (iter->second->get_type()==ValueBase::TYPE_CANVAS)
-                       {
-                               Canvas::Handle canvas((*iter->second)(0).get(Canvas::Handle()));
-                               if (canvas->is_inline())
-                                       //! \todo do we need to implement this?  and if so, shouldn't we check all canvases, not just the one at t=0s?
-                                       warning("%s:%d not yet implemented - do we need to export duplicate valuenodes in dynamic canvas parameters?", __FILE__, __LINE__);
-                       }
-       }
-}
-
-void
-LayerActionManager::amount_inc()
-{
-       float adjust(0.1);
-
-       // Create the action group
-       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Increase Amount"));
-       synfigapp::SelectionManager::LayerList layer_list(layer_tree_->get_selected_layers());
-
-       for (; !layer_list.empty(); layer_list.pop_front())
-       {
-               ValueBase value(layer_list.front()->get_param("amount"));
-               if(value.same_type_as(Real()))
-                       get_canvas_interface()->change_value(synfigapp::ValueDesc(layer_list.front(),"amount"),value.get(Real())+adjust);
-       }
-}
-
-void
-LayerActionManager::amount_dec()
-{
-       float adjust(-0.1);
-
-       // Create the action group
-       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Decrease Amount"));
-       synfigapp::SelectionManager::LayerList layer_list(layer_tree_->get_selected_layers());
-
-       for (; !layer_list.empty(); layer_list.pop_front())
-       {
-               ValueBase value(layer_list.front()->get_param("amount"));
-               if(value.same_type_as(Real()))
-                       get_canvas_interface()->change_value(synfigapp::ValueDesc(layer_list.front(),"amount"),value.get(Real())+adjust);
-       }
-}
diff --git a/synfig-studio/src/gtkmm/layeractionmanager.h b/synfig-studio/src/gtkmm/layeractionmanager.h
deleted file mode 100644 (file)
index 91c400f..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file layeractionmanager.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_LAYER_ACTION_MANAGER_H
-#define __SYNFIG_LAYER_ACTION_MANAGER_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/uimanager.h>
-#include <gtkmm/treeview.h>
-#include <synfigapp/canvasinterface.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 LayerTree;
-
-class LayerActionManager
-{
-       Glib::RefPtr<Gtk::UIManager> ui_manager_;
-       //Glib::RefPtr<Gtk::TreeSelection> tree_selection_;
-       LayerTree* layer_tree_;
-       etl::handle<synfigapp::CanvasInterface> canvas_interface_;
-
-       Glib::RefPtr<Gtk::ActionGroup>  action_group_;
-       Gtk::UIManager::ui_merge_id     popup_id_;
-
-
-       Glib::RefPtr<Gtk::ActionGroup> action_group_copy_paste;
-
-       Glib::RefPtr<Gtk::Action>       action_cut_;
-       Glib::RefPtr<Gtk::Action>       action_copy_;
-       Glib::RefPtr<Gtk::Action>       action_paste_;
-
-       Glib::RefPtr<Gtk::Action>       action_amount_inc_;
-       Glib::RefPtr<Gtk::Action>       action_amount_dec_;
-       Glib::RefPtr<Gtk::Action>       action_amount_;
-
-       Glib::RefPtr<Gtk::Action>       action_select_all_child_layers_;
-       sigc::connection                        select_all_child_layers_connection;
-
-       std::list<synfig::Layer::Handle> clipboard_;
-
-       sigc::connection selection_changed_connection;
-
-       bool queued;
-       sigc::connection queue_refresh_connection;
-
-       std::list<sigc::connection> update_connection_list;
-
-       void cut();
-       void copy();
-       void paste();
-       void export_dup_nodes(synfig::Layer::Handle, synfig::Canvas::Handle, int &);
-
-       void amount_inc();
-       void amount_dec();
-
-public:
-       void queue_refresh();
-
-       LayerActionManager();
-       ~LayerActionManager();
-
-       void set_ui_manager(const Glib::RefPtr<Gtk::UIManager> &x);
-       Glib::RefPtr<Gtk::UIManager> get_ui_manager()const { return ui_manager_; }
-
-       void set_layer_tree(LayerTree* x);
-       LayerTree* get_layer_tree()const { return layer_tree_; }
-
-       void set_canvas_interface(const etl::handle<synfigapp::CanvasInterface> &x);
-       etl::handle<synfigapp::CanvasInterface> get_canvas_interface()const { return canvas_interface_; }
-
-       etl::loose_handle<synfigapp::Instance> get_instance()const { return canvas_interface_->get_instance(); }
-
-       void refresh();
-       void clear();
-
-       Glib::RefPtr<Gtk::Action> get_action_select_all_child_layers() { return action_select_all_child_layers_; }
-}; // END of LayerActionManager
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/layergrouptree.cpp b/synfig-studio/src/gtkmm/layergrouptree.cpp
deleted file mode 100644 (file)
index 3dd323e..0000000
+++ /dev/null
@@ -1,334 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file layergrouptree.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 <config.h>
-#endif
-
-#include <synfig/layer.h>
-#include "layergrouptree.h"
-#include <gtkmm/treemodelsort.h>
-#include <ETL/misc>
-
-#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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-LayerGroupTree::LayerGroupTree()
-{
-       const LayerGroupTreeStore::Model model;
-
-
-       {       // --- O N / O F F ----------------------------------------------------
-               int index;
-               index=append_column_editable(_(" "),model.active);
-               //Gtk::TreeView::Column* column = get_column(index-1);
-       }
-       {       // --- I C O N --------------------------------------------------------
-               int index;
-               index=append_column(_(" "),model.icon);
-               Gtk::TreeView::Column* column = get_column(index-1);
-               set_expander_column(*column);
-       }
-       {       // --- N A M E --------------------------------------------------------
-               int index;
-               index=append_column_editable(_("Name"),model.label);
-               label_column = get_column(index-1);
-
-               //column->set_sort_column(layer_model.index);
-
-               //set_expander_column(*column);
-               //column->set_reorderable();
-               //column->set_resizable();
-               //column->set_clickable(false);
-
-               //Gtk::CellRendererPixbuf* icon_cellrenderer = Gtk::manage( new Gtk::CellRendererPixbuf() );
-               //column->pack_start(*icon_cellrenderer,false);
-               //column->add_attribute(icon_cellrenderer->property_pixbuf(), layer_model.icon);
-       }
-
-       set_enable_search(true);
-       set_search_column(model.label);
-       set_search_equal_func(sigc::ptr_fun(&studio::LayerGroupTreeStore::search_func));
-
-       // This makes things easier to read.
-       set_rules_hint();
-
-       // Make us more sensitive to several events
-       add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::BUTTON1_MOTION_MASK | Gdk::BUTTON2_MOTION_MASK|Gdk::POINTER_MOTION_MASK);
-
-       set_reorderable(true);
-
-       get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
-
-       //set_flags(get_flags()|Gtk::RECEIVES_DEFAULT|Gtk::HAS_GRAB);
-
-       //std::list<Gtk::TargetEntry> listTargets;
-       //listTargets.push_back( Gtk::TargetEntry("LAYER") );
-       //listTargets.push_back( Gtk::TargetEntry("GROUP") );
-       //drag_dest_set(listTargets);
-}
-
-LayerGroupTree::~LayerGroupTree()
-{
-       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
-               synfig::info("LayerGroupTree::~LayerGroupTree(): Deleted");
-}
-
-void
-LayerGroupTree::set_model(Glib::RefPtr<LayerGroupTreeStore> layer_group_tree_store)
-{
-       layer_group_tree_store_=layer_group_tree_store;
-       LayerGroupTreeStore::Model model;
-
-#if 0
-       {
-               Glib::RefPtr<Gtk::TreeModelSort> sorted_store(Gtk::TreeModelSort::create(layer_group_tree_store_));
-               sorted_store->set_default_sort_func(sigc::ptr_fun(&studio::LayerGroupTreeStore::time_sorter));
-               sorted_store->set_sort_func(model.time.index(),sigc::ptr_fun(&studio::LayerGroupTreeStore::time_sorter));
-               sorted_store->set_sort_column(model.time.index(), Gtk::SORT_ASCENDING);
-               Gtk::TreeView::set_model(sorted_store);
-       }
-#else
-               Gtk::TreeView::set_model(layer_group_tree_store);
-#endif
-}
-
-void
-LayerGroupTree::set_editable(bool x)
-{
-       editable_=x;
-/*
-       if(editable_)
-       {
-               cell_renderer_time->property_editable()=true;
-               cell_renderer_time_delta->property_editable()=true;
-               cell_renderer_description->property_editable()=true;
-       }
-       else
-       {
-               cell_renderer_time->property_editable()=false;
-               cell_renderer_time_delta->property_editable()=false;
-               cell_renderer_description->property_editable()=false;
-       }
-*/
-}
-/*
-void
-LayerGroupTree::on_edited_time(const Glib::ustring&path_string,synfig::Time time)
-{
-       Gtk::TreePath path(path_string);
-
-       const Gtk::TreeRow row(*(get_model()->get_iter(path)));
-
-       synfig::Keyframe keyframe(row[model.keyframe]);
-       if(time!=keyframe.get_time())
-       {
-               row[model.time]=time;
-               //keyframe.set_time(time);
-               //signal_edited_time()(keyframe,time);
-               //signal_edited()(keyframe);
-       }
-}
-
-void
-LayerGroupTree::on_edited_time_delta(const Glib::ustring&path_string,synfig::Time time)
-{
-       Gtk::TreePath path(path_string);
-
-       const Gtk::TreeRow row(*(get_model()->get_iter(path)));
-
-       if(row)row[model.time_delta]=time;
-}
-
-void
-LayerGroupTree::on_edited_description(const Glib::ustring&path_string,const Glib::ustring &desc)
-{
-       Gtk::TreePath path(path_string);
-
-       const Gtk::TreeRow row = *(get_model()->get_iter(path));
-
-       const synfig::String description(desc);
-       synfig::Keyframe keyframe(row[model.keyframe]);
-       if(description!=keyframe.get_description())
-       {
-               row[model.description]=desc;
-               keyframe.set_description(description);
-               signal_edited_description()(keyframe,description);
-               signal_edited()(keyframe);
-       }
-}
-*/
-
-bool
-LayerGroupTree::on_event(GdkEvent *event)
-{
-    switch(event->type)
-    {
-       case GDK_BUTTON_PRESS:
-               {
-                       Gtk::TreeModel::Path path;
-                       Gtk::TreeViewColumn *column;
-                       int cell_x, cell_y;
-                       int wx(round_to_int(event->button.x)),wy(round_to_int(event->button.y));
-                       //tree_to_widget_coords (,, wx, wy);
-                       if(!get_path_at_pos(
-                               wx,wy,  // x, y
-                               path, // TreeModel::Path&
-                               column, //TreeViewColumn*&
-                               cell_x,cell_y //int&cell_x,int&cell_y
-                               )
-                       ) break;
-                       const Gtk::TreeRow row = *(get_model()->get_iter(path));
-
-                       if(row[model.is_layer] && event->button.button==3)
-                       {
-                               signal_popup_layer_menu()((Layer::Handle)row[model.layer]);
-                               return true;
-                       }
-
-                       /*signal_user_click()(event->button.button,row,(ColumnID)column->get_sort_column_id());
-                       if((ColumnID)column->get_sort_column_id()==COLUMNID_JUMP)
-                       {
-                               layer_group_tree_store_->canvas_interface()->set_time(row[model.time]);
-                       }*/
-               }
-               break;
-       case GDK_2BUTTON_PRESS:
-               {
-                       Gtk::TreeModel::Path path;
-                       Gtk::TreeViewColumn *column;
-                       int cell_x, cell_y;
-                       if(!get_path_at_pos(
-                               int(event->button.x),int(event->button.y),      // x, y
-                               path, // TreeModel::Path&
-                               column, //TreeViewColumn*&
-                               cell_x,cell_y //int&cell_x,int&cell_y
-                               )
-                       ) break;
-                       const Gtk::TreeRow row = *(get_model()->get_iter(path));
-
-                       LayerList layer_list(row[model.all_layers]);
-                       if(!layer_list.empty())
-                       {
-                               if(!(event->button.state&GDK_CONTROL_MASK))
-                               {
-                                       layer_group_tree_store_->canvas_interface()->get_selection_manager()->clear_selected_layers();
-                               }
-                               layer_group_tree_store_->canvas_interface()->get_selection_manager()->set_selected_layers(layer_list);
-                               return true;
-                       }
-               }
-               break;
-       case GDK_BUTTON_RELEASE:
-               break;
-       default:
-               break;
-       }
-       return Gtk::TreeView::on_event(event);
-       //return false;
-}
-
-static inline void __group_grabber(const Gtk::TreeModel::iterator& iter, std::list<synfig::String>* ret)
-{
-       const LayerGroupTreeStore::Model model;
-       if((bool)(*iter)[model.is_group])
-               ret->push_back((Glib::ustring)(*iter)[model.group_name]);
-}
-
-std::list<synfig::String>
-LayerGroupTree::get_selected_groups()const
-{
-       Glib::RefPtr<Gtk::TreeSelection> selection=const_cast<LayerGroupTree&>(*this).get_selection();
-
-       if(!selection)
-               return std::list<synfig::String>();
-
-       std::list<synfig::String> ret;
-
-       selection->selected_foreach_iter(
-               sigc::bind(
-                       sigc::ptr_fun(
-                               &__group_grabber
-                       ),
-                       &ret
-               )
-       );
-
-       return ret;
-}
-
-static inline void __layer_grabber(const Gtk::TreeModel::iterator& iter, LayerGroupTree::LayerList* ret)
-{
-       const LayerGroupTreeStore::Model model;
-       if((bool)(*iter)[model.is_layer])
-               ret->push_back((Layer::Handle)(*iter)[model.layer]);
-}
-
-LayerGroupTree::LayerList
-LayerGroupTree::get_selected_layers()const
-{
-       Glib::RefPtr<Gtk::TreeSelection> selection=const_cast<LayerGroupTree&>(*this).get_selection();
-
-       if(!selection)
-               return LayerList();
-
-       LayerList ret;
-
-       selection->selected_foreach_iter(
-               sigc::bind(
-                       sigc::ptr_fun(
-                               &__layer_grabber
-                       ),
-                       &ret
-               )
-       );
-
-       return ret;
-}
-
-void
-LayerGroupTree::set_cursor(const Gtk::TreeModel::Path& path, bool start_editing)
-{
-       Gtk::TreeView::set_cursor(path, *label_column, start_editing);
-}
diff --git a/synfig-studio/src/gtkmm/layergrouptree.h b/synfig-studio/src/gtkmm/layergrouptree.h
deleted file mode 100644 (file)
index a17c470..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file layergrouptree.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_LAYERGROUPTREE_H
-#define __SYNFIG_STUDIO_LAYERGROUPTREE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/treeview.h>
-#include <gtkmm/treestore.h>
-#include <synfigapp/canvasinterface.h>
-#include <synfigapp/value_desc.h>
-#include "layergrouptreestore.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 synfig { class Layer; }
-
-namespace studio {
-
-class LayerGroupTree : public Gtk::TreeView
-{
-       /*
- -- ** -- P U B L I C   T Y P E S ---------------------------------------------
-       */
-
-public:
-
-       typedef std::list<synfig::Layer::Handle> LayerList;
-
-       /*
- -- ** -- P U B L I C  D A T A ------------------------------------------------
-       */
-
-public:
-
-       LayerGroupTreeStore::Model model;
-
-       /*
- -- ** -- P R I V A T E   D A T A ---------------------------------------------
-       */
-
-private:
-
-       Glib::RefPtr<LayerGroupTreeStore> layer_group_tree_store_;
-
-       Gtk::CellRendererText *cell_renderer_description;
-
-       bool editable_;
-
-
-       sigc::signal<void,etl::handle<synfig::Layer> > signal_popup_layer_menu_;
-
-//     sigc::signal<void,LayerList> signal_select_layers_;
-       Gtk::TreeView::Column* label_column;
-
-       /*
- -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
-       */
-
-private:
-
-       /*
- -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
-       */
-
-private:
-
-       bool on_event(GdkEvent *event);
-
-       /*
- -- ** -- P U B L I C   M E T H O D S -----------------------------------------
-       */
-
-public:
-
-       LayerGroupTree();
-       ~LayerGroupTree();
-       void set_cursor(const Gtk::TreeModel::Path& path, bool start_editing=false);
-
-       Glib::RefPtr<LayerGroupTreeStore> get_model() { return layer_group_tree_store_; }
-
-       sigc::signal<void,etl::handle<synfig::Layer> >& signal_popup_layer_menu() { return signal_popup_layer_menu_; }
-
-//     sigc::signal<void,LayerList>& signal_select_layers() { return signal_select_layers_; }
-
-       void set_model(Glib::RefPtr<LayerGroupTreeStore> layer_group_tree_store_);
-
-       void set_editable(bool x=true);
-
-       bool get_editable()const { return editable_; }
-
-       std::list<synfig::String> get_selected_groups()const;
-
-       LayerList get_selected_layers()const;
-}; // END of LayerGroupTree
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/layergrouptreestore.cpp b/synfig-studio/src/gtkmm/layergrouptreestore.cpp
deleted file mode 100644 (file)
index 9c947c6..0000000
+++ /dev/null
@@ -1,1031 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file layergrouptreestore.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 <config.h>
-#endif
-
-#include "layergrouptreestore.h"
-#include "iconcontroller.h"
-#include <gtkmm/button.h>
-#include <synfig/paramdesc.h>
-#include <synfigapp/action.h>
-#include <synfigapp/instance.h>
-#include "app.h"
-#include "instance.h"
-#include <synfigapp/action_system.h>
-#include "dockmanager.h"
-#include "dockable.h"
-
-#include <gtk/gtkversion.h>
-#include <ETL/clock>
-#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 ========================================================= */
-
-#define GROUP_NEST_CHAR        '.'
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-static LayerGroupTreeStore::Model& ModelHack()
-{
-       static LayerGroupTreeStore::Model* model(0);
-       if(!model)model=new LayerGroupTreeStore::Model;
-       return *model;
-}
-
-LayerGroupTreeStore::LayerGroupTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_):
-       Gtk::TreeStore                  (ModelHack()),
-       canvas_interface_               (canvas_interface_)
-{
-       layer_icon=Gtk::Button().render_icon(Gtk::StockID("synfig-layer"),Gtk::ICON_SIZE_SMALL_TOOLBAR);
-       group_icon=Gtk::Button().render_icon(Gtk::StockID("synfig-group"),Gtk::ICON_SIZE_SMALL_TOOLBAR);
-
-       // Connect Signals to Terminals
-       canvas_interface()->signal_layer_status_changed().connect(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_layer_status_changed));
-       canvas_interface()->signal_layer_new_description().connect(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_layer_new_description));
-
-       canvas_interface()->get_canvas()->signal_group_added().connect(sigc::hide_return(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_group_added)));
-       canvas_interface()->get_canvas()->signal_group_removed().connect(sigc::hide_return(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_group_removed)));
-       canvas_interface()->get_canvas()->signal_group_changed().connect(sigc::hide_return(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_group_changed)));
-
-       canvas_interface()->get_canvas()->signal_group_pair_added().connect(sigc::hide_return(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_group_pair_added)));
-       canvas_interface()->get_canvas()->signal_group_pair_removed().connect(sigc::hide_return(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_group_pair_removed)));
-
-       rebuild();
-}
-
-LayerGroupTreeStore::~LayerGroupTreeStore()
-{
-       //clear();
-
-       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
-               synfig::info("LayerGroupTreeStore::~LayerGroupTreeStore(): Deleted");
-}
-
-bool
-LayerGroupTreeStore::search_func(const Glib::RefPtr<TreeModel>&,int,const Glib::ustring& x,const TreeModel::iterator& iter)
-{
-       const Model model;
-
-       Glib::ustring substr(x.uppercase());
-       Glib::ustring label((*iter)[model.label]);
-       label=label.uppercase();
-
-       return label.find(substr)==Glib::ustring::npos;
-}
-
-
-Glib::RefPtr<LayerGroupTreeStore>
-LayerGroupTreeStore::create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_)
-{
-       return Glib::RefPtr<LayerGroupTreeStore>(new LayerGroupTreeStore(canvas_interface_));
-}
-
-void
-LayerGroupTreeStore::get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const
-{
-       if(column==model.child_layers.index())
-       {
-               Glib::Value<LayerList> x;
-               g_value_init(x.gobj(),x.value_type());
-
-               if((bool)(*iter)[model.is_group])
-               {
-                       set<Layer::Handle> layer_set(canvas_interface()->get_canvas()->get_layers_in_group((Glib::ustring)(*iter)[model.group_name]));
-
-                       x.set(LayerList(layer_set.begin(),layer_set.end()));
-               }
-               else if((bool)(*iter)[model.is_layer])
-               {
-                       LayerList layer_list;
-                       layer_list.push_back((Layer::Handle)(*iter)[model.layer]);
-                       x.set(layer_list);
-               }
-
-               g_value_init(value.gobj(),x.value_type());
-               value=x;
-       }
-       else if(column==model.all_layers.index())
-       {
-               Glib::Value<LayerList> x;
-               g_value_init(x.gobj(),x.value_type());
-
-               if((bool)(*iter)[model.is_group])
-               {
-                       LayerList layer_list;
-                       Gtk::TreeModel::iterator child_iter(iter->children().begin());
-                       for(;child_iter;++child_iter)
-                       {
-                               LayerList layer_list2((LayerList)(*child_iter)[model.all_layers]);
-                               for(;layer_list2.size();layer_list2.pop_front())
-                                       layer_list.push_back(layer_list2.front());
-                       }
-                       x.set(layer_list);
-               }
-               else if((bool)(*iter)[model.is_layer])
-               {
-                       LayerList layer_list;
-                       layer_list.push_back((Layer::Handle)(*iter)[model.layer]);
-                       x.set(layer_list);
-               }
-
-               g_value_init(value.gobj(),x.value_type());
-               value=x;
-       }
-       else if(column==model.group_name.index())
-       {
-               if((bool)(*iter)[model.is_group])
-                       return Gtk::TreeStore::get_value_vfunc(iter,column,value);
-               return get_value_vfunc(iter->parent(),column,value);
-       }
-       else if(column==model.parent_group_name.index())
-       {
-               if(iter->parent())
-                       return get_value_vfunc(iter->parent(),model.group_name.index(),value);
-               Glib::Value<Glib::ustring> x;
-               g_value_init(x.gobj(),x.value_type());
-               x.set(Glib::ustring());
-               g_value_init(value.gobj(),x.value_type());
-               value=x;
-       }
-       else if(column==model.label.index())
-       {
-               if((bool)(*iter)[model.is_group])
-               {
-                       Glib::Value<Glib::ustring> x;
-                       g_value_init(x.gobj(),x.value_type());
-
-                       Glib::ustring group_name((*iter)[model.group_name]);
-
-                       // Get rid of any parent group crap
-                       while(group_name.find(GROUP_NEST_CHAR)!=Glib::ustring::npos)
-                               group_name=Glib::ustring(group_name,group_name.find(GROUP_NEST_CHAR)+1,Glib::ustring::npos);
-
-                       x.set(group_name);
-
-                       g_value_init(value.gobj(),x.value_type());
-
-                       value=x;
-               }
-               else if((bool)(*iter)[model.is_layer])
-               {
-                       synfig::Layer::Handle layer((*iter)[model.layer]);
-
-                       if(!layer)return;
-
-                       Glib::Value<Glib::ustring> x;
-                       g_value_init(x.gobj(),x.value_type());
-
-                       x.set(layer->get_non_empty_description());
-
-                       g_value_init(value.gobj(),x.value_type());
-                       //g_value_copy(x.gobj(),value.gobj());
-                       value=x;
-               }
-       }
-       else
-       if(column==model.tooltip.index())
-       {
-               synfig::Layer::Handle layer((*iter)[model.layer]);
-
-               if(!layer)return;
-
-               Glib::Value<Glib::ustring> x;
-               g_value_init(x.gobj(),x.value_type());
-
-
-               x.set(layer->get_local_name());
-
-               g_value_init(value.gobj(),x.value_type());
-               //g_value_copy(x.gobj(),value.gobj());
-               value=x;
-       }
-       else
-       if(column==model.canvas.index())
-       {
-               synfig::Layer::Handle layer((*iter)[model.layer]);
-
-               if(!layer)return;
-
-               Glib::Value<Canvas::Handle> x;
-               g_value_init(x.gobj(),x.value_type());
-
-
-               x.set(layer->get_canvas());
-
-               g_value_init(value.gobj(),x.value_type());
-               //g_value_copy(x.gobj(),value.gobj());
-               value=x;
-       }
-       else
-       if(column==model.active.index())
-       {
-               Glib::Value<bool> x;
-               g_value_init(x.gobj(),x.value_type());
-
-               if((bool)(*iter)[model.is_layer])
-               {
-                       synfig::Layer::Handle layer((*iter)[model.layer]);
-                       x.set(layer->active());
-               }
-               else if((bool)(*iter)[model.is_group])
-               {
-                       int activecount(0),total(0);
-                       Gtk::TreeModel::iterator child_iter(iter->children().begin());
-                       for(;child_iter;++child_iter)
-                       {
-                               total++;
-                               if((*child_iter)[model.active])
-                                       activecount++;
-                       }
-                       x.set(activecount>total/2);
-               }
-               else
-                       x.set(false);
-
-               g_value_init(value.gobj(),x.value_type());
-               g_value_copy(x.gobj(),value.gobj());
-       }
-       else
-       if(column==model.icon.index())
-       {
-               Glib::Value<Glib::RefPtr<Gdk::Pixbuf> > x;
-               g_value_init(x.gobj(),x.value_type());
-
-               if((bool)(*iter)[model.is_layer])
-               {
-                       synfig::Layer::Handle layer((*iter)[model.layer]);
-                       if(!layer)return;
-                       //x.set(layer_icon);
-                       x.set(get_tree_pixbuf_layer(layer->get_name()));
-               }
-               if((bool)(*iter)[model.is_group])
-                       x.set(group_icon);
-
-               g_value_init(value.gobj(),x.value_type());
-               g_value_copy(x.gobj(),value.gobj());
-       }
-       else
-               Gtk::TreeStore::get_value_vfunc(iter,column,value);
-}
-
-void
-LayerGroupTreeStore::set_value_impl(const Gtk::TreeModel::iterator& iter, int column, const Glib::ValueBase& value)
-{
-       //if(!iterator_sane(row))
-       //      return;
-
-       if(column>=get_n_columns_vfunc())
-       {
-               g_warning("LayerGroupTreeStore::set_value_impl: Bad column (%d)",column);
-               return;
-       }
-
-       if(!g_value_type_compatible(G_VALUE_TYPE(value.gobj()),get_column_type_vfunc(column)))
-       {
-               g_warning("LayerGroupTreeStore::set_value_impl: Bad value type");
-               return;
-       }
-
-       try
-       {
-               if(column==model.label.index())
-               {
-                       Glib::Value<Glib::ustring> x;
-                       g_value_init(x.gobj(),model.label.type());
-                       g_value_copy(value.gobj(),x.gobj());
-
-                       if((bool)(*iter)[model.is_layer])
-                       {
-                               synfig::Layer::Handle layer((*iter)[model.layer]);
-                               if(!layer)
-                                       return;
-                               synfig::String new_desc(x.get());
-
-                               if(new_desc==layer->get_local_name())
-                                       new_desc=synfig::String();
-
-                               if(new_desc==layer->get_description())
-                                       return;
-
-                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerSetDesc"));
-
-                               if(!action)
-                                       return;
-
-                               action->set_param("canvas",canvas_interface()->get_canvas());
-                               action->set_param("canvas_interface",canvas_interface());
-                               action->set_param("layer",layer);
-                               action->set_param("new_description",synfig::String(x.get()));
-
-                               canvas_interface()->get_instance()->perform_action(action);
-                               return;
-                       }
-                       else if((bool)(*iter)[model.is_group])
-                       {
-                               synfig::String group((Glib::ustring)(*iter)[model.label]);
-                               synfig::String new_group(x.get());
-
-                               if(x.get()==group)
-                                       return;
-
-                               Glib::ustring group_name((*iter)[model.group_name]);
-                               group=group_name;
-                               new_group.clear();
-
-                               // Get rid of any parent group crap
-                               while(group_name.find(GROUP_NEST_CHAR)!=Glib::ustring::npos)
-                               {
-                                       new_group+=Glib::ustring(group_name,0,group_name.find(GROUP_NEST_CHAR)+1);
-                                       group_name=Glib::ustring(group_name,group_name.find(GROUP_NEST_CHAR)+1,Glib::ustring::npos);
-                               }
-                               new_group+=x.get();
-
-                               synfig::info("Renaming group \"%s\" to \"%s\"...",group.c_str(),new_group.c_str());
-
-                               // Check to see if this group is real or not.
-                               // If it isn't real, then renaming it is a cinch.
-                               // We know it isn't real if it doesn't have any
-                               // children yet.
-                               if(iter->children().empty())
-                               {
-                                       (*iter)[model.group_name]=new_group;
-                               }
-                               else
-                               {
-                                       synfigapp::Action::Handle action(synfigapp::Action::create("GroupRename"));
-
-                                       if(!action)
-                                               return;
-
-                                       action->set_param("canvas",canvas_interface()->get_canvas());
-                                       action->set_param("canvas_interface",canvas_interface());
-                                       action->set_param("group",group);
-                                       action->set_param("new_group",new_group);
-
-                                       canvas_interface()->get_instance()->perform_action(action);
-                               }
-                               return;
-                       }
-                       return;
-               }
-               else
-               if(column==model.active.index())
-               {
-                       Glib::Value<bool> x;
-                       g_value_init(x.gobj(),model.active.type());
-                       g_value_copy(value.gobj(),x.gobj());
-
-                       if((bool)(*iter)[model.is_layer])
-                       {
-                               synfig::Layer::Handle layer((*iter)[model.layer]);
-                               if(!layer)return;
-
-                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerActivate"));
-
-                               if(!action)
-                                       return;
-
-                               action->set_param("canvas",canvas_interface()->get_canvas());
-                               action->set_param("canvas_interface",canvas_interface());
-                               action->set_param("layer",layer);
-                               action->set_param("new_status",bool(x.get()));
-
-
-                               canvas_interface()->get_instance()->perform_action(action);
-                               return;
-                       }
-                       else if(!iter->children().empty())
-                       {
-                               synfigapp::Action::PassiveGrouper group(
-                                       get_canvas_interface()->get_instance().get(),
-                                       String(
-                                               x.get()?_("Activate "):_("Deactivate ")
-                                       )+(Glib::ustring)(*iter)[model.label]
-                               );
-
-                               Gtk::TreeModel::iterator child_iter(iter->children().begin());
-
-                               for(;child_iter;++child_iter)
-                                       (*child_iter)[model.active]=x.get();
-
-                               Gtk::TreeStore::set_value_impl(iter,column, value);
-                       }
-               }
-               else
-                       Gtk::TreeStore::set_value_impl(iter,column, value);
-
-       }
-       catch(std::exception x)
-       {
-               g_warning("%s", x.what());
-       }
-}
-
-
-
-
-bool
-LayerGroupTreeStore::row_draggable_vfunc (const TreeModel::Path& /*path*/)const
-{
-       //if(!get_iter(path)) return false;
-//     Gtk::TreeModel::Row row(*get_iter(path));
-
-       return true;
-}
-
-bool
-LayerGroupTreeStore::drag_data_get_vfunc (const TreeModel::Path& path, Gtk::SelectionData& selection_data)const
-{
-       if(!const_cast<LayerGroupTreeStore*>(this)->get_iter(path)) return false;
-       //synfig::info("Dragged data of type \"%s\"",selection_data.get_data_type());
-       //synfig::info("Dragged data of target \"%s\"",gdk_atom_name(selection_data->target));
-       //synfig::info("Dragged selection=\"%s\"",gdk_atom_name(selection_data->selection));
-
-       Gtk::TreeModel::Row row(*const_cast<LayerGroupTreeStore*>(this)->get_iter(path));
-
-       if((bool)row[model.is_layer])
-       {
-               Layer* layer(((Layer::Handle)row[model.layer]).get());
-               assert(layer);
-
-               std::vector<Layer*> layers;
-
-               layers.push_back(layer);
-
-               selection_data.set("LAYER", 8, reinterpret_cast<const guchar*>(&layers.front()), sizeof(void*)*layers.size());
-
-               return true;
-       }
-       else if((bool)row[model.is_group])
-       {
-               synfig::String group((Glib::ustring)row[model.group_name]);
-               if(group.empty())
-                       return false;
-
-               selection_data.set("GROUP", 8, reinterpret_cast<const guchar*>(&*group.begin()), sizeof(void*)*group.size());
-
-               return true;
-       }
-
-       return false;
-}
-
-bool
-LayerGroupTreeStore::drag_data_delete_vfunc (const TreeModel::Path& /*path*/)
-{
-       return true;
-}
-
-bool
-LayerGroupTreeStore::row_drop_possible_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)const
-{
-       Gtk::TreeIter iter(const_cast<LayerGroupTreeStore*>(this)->get_iter(dest));
-       if(!iter) return false;
-
-       if(synfig::String(selection_data.get_data_type())=="LAYER")
-               return true;
-
-       if(synfig::String(selection_data.get_data_type())=="GROUP")
-       {
-               synfig::String dest_group((Glib::ustring)(*iter)[model.group_name]);
-               synfig::String src_group(reinterpret_cast<const gchar*>(selection_data.get_data()));
-               //synfig::String src_group(const_cast<gchar*>(selection_data.get_data()));
-
-               // Avoid putting a group inside of itself
-               if(dest_group.size()>src_group.size() && src_group==String(dest_group,0,src_group.size()))
-                       return false;
-               return true;
-       }
-
-       return false;
-       //synfig::info("possible_drop -- data of type \"%s\"",selection_data.get_data_type());
-       //synfig::info("possible_drop -- data of target \"%s\"",gdk_atom_name(selection_data->target));
-       //synfig::info("possible_drop -- selection=\"%s\"",gdk_atom_name(selection_data->selection));
-
-       //Gtk::TreeModel::Row row(*get_iter(dest));
-
-/*     if(synfig::String(selection_data.get_data_type())=="LAYER" && (bool)true)
-               return true;
-*/
-       return false;
-}
-
-bool
-LayerGroupTreeStore::drag_data_received_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)
-{
-       if(!get_iter(dest)) return false;
-//     bool ret=false;
-       //int i(0);
-
-       Gtk::TreeModel::Row row(*get_iter(dest));
-
-       //synfig::info("Dropped data of type \"%s\"",selection_data.get_data_type());
-       //synfig::info("Dropped data of target \"%s\"",gdk_atom_name(selection_data->target));
-       //synfig::info("Dropped selection=\"%s\"",gdk_atom_name(selection_data->selection));
-       synfigapp::Action::PassiveGrouper passive_grouper(canvas_interface()->get_instance().get(),_("Regroup"));
-
-       if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
-       {
-               synfig::String dest_group;
-
-               dest_group=(Glib::ustring)row[model.group_name];
-
-               if(dest_group.empty())
-                       return false;
-
-               if(synfig::String(selection_data.get_data_type())=="LAYER")
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("GroupAddLayers"));
-
-                       if(!action)
-                               return false;
-
-                       action->set_param("canvas",canvas_interface()->get_canvas());
-                       action->set_param("canvas_interface",canvas_interface());
-                       action->set_param("group",dest_group);
-
-                       for(unsigned int i=0;i<selection_data.get_length()/sizeof(void*);i++)
-                       {
-                               Layer::Handle layer(reinterpret_cast<Layer**>(const_cast<guint8*>(selection_data.get_data()))[i]);
-                               assert(layer);
-
-                               action->set_param("layer",layer);
-                       }
-                       if(!canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               passive_grouper.cancel();
-                               return false;
-                       }
-                       return true;
-               }
-               if(synfig::String(selection_data.get_data_type())=="GROUP")
-               {
-                       synfig::String src_group(reinterpret_cast<const gchar*>(selection_data.get_data()));
-                       synfig::String group(src_group);
-
-                       // Get rid of any parent group crap
-                       while(group.find(GROUP_NEST_CHAR)!=Glib::ustring::npos)
-                               group=Glib::ustring(group,group.find(GROUP_NEST_CHAR)+1,Glib::ustring::npos);
-
-                       group=dest_group+GROUP_NEST_CHAR+group;
-
-                       synfigapp::Action::Handle action(synfigapp::Action::create("GroupRename"));
-
-                       if(!action)
-                               return false;
-
-                       action->set_param("canvas",canvas_interface()->get_canvas());
-                       action->set_param("canvas_interface",canvas_interface());
-                       action->set_param("group",src_group);
-                       action->set_param("new_group",group);
-
-                       if(!canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               passive_grouper.cancel();
-                               return false;
-                       }
-                       return true;
-               }
-       }
-/*     // Save the selection data
-       synfigapp::SelectionManager::LayerList selected_layer_list=canvas_interface()->get_selection_manager()->get_selected_layers();
-
-       if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
-       {
-               Canvas::Handle dest_canvas;
-               Layer::Handle dest_layer;
-
-               dest_canvas=(Canvas::Handle)(row[model.canvas]);
-               dest_layer=(Layer::Handle)(row[model.layer]);
-               assert(dest_canvas);
-
-               if(!dest_layer)
-                       return false;
-
-               int dest_layer_depth=dest_layer->get_depth();
-
-               if(synfig::String(selection_data.get_data_type())=="LAYER")for(i=0;i<selection_data.get_length()/sizeof(void*);i++)
-               {
-                       //synfig::info("dest_layer_depth=%d",dest_layer_depth);
-
-                       Layer::Handle src(reinterpret_cast<Layer**>(const_cast<guint8*>(selection_data.get_data()))[i]);
-                       assert(src);
-                       if(dest_layer==src)
-                               continue;
-
-                       // In this case, we are just moving.
-//                     if(dest_canvas==src->get_canvas())
-                       {
-                               if(dest_canvas==src->get_canvas() && dest_layer_depth && dest_layer_depth>src->get_depth())
-                                       dest_layer_depth--;
-                               if(dest_canvas==src->get_canvas() && dest_layer_depth==src->get_depth())
-                                       continue;
-
-                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerMove"));
-                               action->set_param("canvas",dest_canvas);
-                               action->set_param("canvas_interface",canvas_interface());
-                               action->set_param("layer",src);
-                               action->set_param("new_index",dest_layer_depth);
-                               action->set_param("dest_canvas",dest_canvas);
-                               if(canvas_interface()->get_instance()->perform_action(action))
-                               {
-                                       ret=true;
-                               }
-                               else
-                               {
-                                       passive_grouper.cancel();
-                                       return false;
-                               }
-                               continue;
-                       }
-               }
-       }
-       synfig::info("I supposedly moved %d layers",i);
-
-       // Reselect the previously selected layers
-       canvas_interface()->get_selection_manager()->set_selected_layers(selected_layer_list);
-
-       return ret;
-       */
-       return false;
-}
-
-
-
-
-
-
-
-void
-LayerGroupTreeStore::rebuild()
-{
-       rebuilding=true;
-       // etl::clock timer;timer.reset();
-       try {
-
-               // Clear out the current list
-               clear();
-               Canvas::Handle canvas(canvas_interface()->get_canvas());
-               std::set<String> groups(canvas->get_groups());
-               for(;groups.size();groups.erase(groups.begin()))
-               {
-                       String group(*groups.begin());
-                       Gtk::TreeRow row(on_group_added(group));
-                       std::set<Layer::Handle> layers(canvas->get_layers_in_group(group));
-
-                       for(;layers.size();layers.erase(layers.begin()))
-                       {
-                               Gtk::TreeRow layer_row(*(prepend(row.children())));
-                               Layer::Handle layer(*layers.begin());
-                               set_row_layer(layer_row,layer);
-                       }
-               }
-
-               // Go ahead and add all the layers
-               /*std::for_each(
-                       canvas_interface()->get_canvas()->rbegin(), canvas_interface()->get_canvas()->rend(),
-                       sigc::mem_fun(*this, &studio::LayerGroupTreeStore::on_layer_added)
-               );*/
-       }
-       catch(...)
-       {
-               rebuilding=false;
-               throw;
-       }
-       rebuilding=false;
-       // synfig::info("LayerGroupTreeStore::rebuild() took %f seconds",float(timer()));
-}
-
-void
-LayerGroupTreeStore::refresh()
-{
-       rebuild();
-}
-
-void
-LayerGroupTreeStore::refresh_row(Gtk::TreeModel::Row &row)
-{
-       if((bool)row[model.is_layer])
-       {
-               Layer::Handle layer=row[model.layer];
-
-
-               //if(layer->dynamic_param_list().count("z_depth"))
-               //      row[model.z_depth]=Time::begin();
-       }
-
-       Gtk::TreeModel::Children children = row.children();
-       Gtk::TreeModel::Children::iterator iter;
-
-       if(!children.empty())
-               for(iter = children.begin(); iter && iter != children.end(); ++iter)
-               {
-                       Gtk::TreeRow row=*iter;
-                       refresh_row(row);
-               }
-}
-
-
-void
-LayerGroupTreeStore::set_row_layer(Gtk::TreeRow &row,synfig::Layer::Handle &handle)
-{
-       row[model.is_layer] = true;
-       row[model.is_group] = false;
-       row[model.layer] = handle;
-}
-
-Gtk::TreeRow
-LayerGroupTreeStore::on_group_added(synfig::String group)
-{
-       // Check to see if this group perhaps already
-       // exists
-       {
-               Gtk::TreeModel::Children::iterator iter;
-               if(find_group_row(group,  iter))
-                       return *iter;
-       }
-
-       if(group.find(GROUP_NEST_CHAR)!=String::npos)
-       {
-               Gtk::TreeModel::Children::iterator iter;
-               String parent_name;
-               do
-               {
-                       if(parent_name.size())
-                               parent_name+=GROUP_NEST_CHAR;
-                       parent_name+=string(group,0,group.find(GROUP_NEST_CHAR));
-
-                       if(!find_group_row(parent_name, iter))
-                               iter=on_group_added(parent_name);
-
-                       group=String(group,group.find(GROUP_NEST_CHAR)+1,String::npos);
-               }while(group.find(GROUP_NEST_CHAR)!=String::npos);
-
-               if(parent_name.size())
-                       parent_name+=GROUP_NEST_CHAR;
-               parent_name+=group;
-
-               if(iter)
-               {
-                       Gtk::TreeRow row(*(prepend(iter->children())));
-                       row[model.group_name]=parent_name;
-                       row[model.is_layer]=false;
-                       row[model.is_group]=true;
-                       on_activity();
-                       return row;
-               }
-       }
-
-       Gtk::TreeRow row(*(append()));
-       row[model.group_name]=group;
-       row[model.is_layer]=false;
-       row[model.is_group]=true;
-       on_activity();
-       return row;
-}
-
-bool
-LayerGroupTreeStore::on_group_removed(synfig::String group)
-{
-       Gtk::TreeModel::Children::iterator iter;
-       if(find_group_row(group,iter) && iter->children().size()==0)
-               erase(iter);
-       else
-               return false;
-
-       return true;
-}
-
-bool
-LayerGroupTreeStore::on_group_changed(synfig::String /*group*/)
-{
-       return true;
-}
-
-void
-LayerGroupTreeStore::on_group_pair_added(synfig::String group, etl::handle<synfig::Layer> layer)
-{
-       if(!layer->get_canvas())
-               return;
-       Gtk::TreeModel::Children::iterator iter;
-       if(!find_group_row(group, iter))
-               iter=on_group_added(group);
-
-       Gtk::TreeRow layer_row(*(append(iter->children())));
-       set_row_layer(layer_row,layer);
-       on_activity();
-}
-
-void
-LayerGroupTreeStore::on_group_pair_removed(synfig::String group, etl::handle<synfig::Layer> layer)
-{
-       if(!layer->get_canvas())
-               return;
-       Gtk::TreeModel::Children::iterator iter;
-       if(!find_group_row(group, iter))
-               return;
-
-       Gtk::TreeModel::Children::iterator prev,layer_iter;
-
-       if(!find_layer_row_(layer, layer->get_canvas(), iter->children(), layer_iter, prev))
-               return;
-
-       erase(layer_iter);
-
-       on_activity();
-}
-
-void
-LayerGroupTreeStore::on_activity()
-{
-       // If we aren't rebuilding and the last action
-       // had something to do with groups, then go
-       // a head and present the groups dialog.
-       if(!rebuilding && canvas_interface()->get_instance()->get_most_recent_action() && canvas_interface()->get_instance()->get_most_recent_action()->get_name().find("Group")!=String::npos)
-       try
-       {
-               App::dock_manager->find_dockable("groups").present();
-       }
-       catch(...) { }
-}
-
-void
-LayerGroupTreeStore::on_layer_status_changed(synfig::Layer::Handle handle,bool /*x*/)
-{
-       Gtk::TreeModel::Children::iterator iter;
-       if(find_layer_row(handle,iter))
-               (*iter)[model.layer]=handle;
-       else
-       {
-               // Not need to send a warning when a layer changes its status and
-               // it is not found in any group.
-               //synfig::warning("Couldn't find layer to be activated in layer list. Rebuilding index...");
-               rebuild();
-       }
-}
-
-
-void
-LayerGroupTreeStore::on_layer_new_description(synfig::Layer::Handle handle,synfig::String desc)
-{
-       Gtk::TreeModel::Children::iterator iter;
-       if(find_layer_row(handle,iter))
-       {
-               Gtk::TreeRow row(*iter);
-
-               Layer::Handle layer(row[model.layer]);
-
-               if(desc.empty())
-               {
-                       //row[model.label]=layer->get_local_name();
-                       row[model.tooltip]=Glib::ustring(_("Layer"));
-               }
-               else
-                       //row[model.label]=layer->get_description();
-                       row[model.tooltip]=layer->get_local_name();
-       }
-       else
-       {
-               rebuild();
-       }
-}
-
-bool
-LayerGroupTreeStore::find_layer_row_(const synfig::Layer::Handle &layer, synfig::Canvas::Handle canvas, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter, Gtk::TreeModel::Children::iterator &prev)
-{
-       assert(layer);
-
-       //if(layer->get_canvas()==canvas)
-       {
-               for(iter=prev=layers.begin(); iter && iter != layers.end(); prev=iter++)
-               {
-                       Gtk::TreeModel::Row row = *iter;
-                       if((bool)row[model.is_layer] && layer==(synfig::Layer::Handle)row[model.layer])
-                               return true;
-               }
-
-               iter=children().end();
-               //return false;
-       }
-
-       Gtk::TreeModel::Children::iterator iter2;
-
-       for(iter2 = layers.begin(); iter2 && iter2 != layers.end(); ++iter2)
-       {
-               Gtk::TreeModel::Row row = *iter2;
-               assert((bool)true);
-
-               if(row.children().empty())
-                       continue;
-
-               /*Canvas::Handle canvas((*row.children().begin())[model.canvas]);
-               if(!canvas)
-                       continue;
-               */
-
-               if(find_layer_row_(layer,canvas,iter2->children(),iter,prev))
-                       return true;
-       }
-
-       iter=children().end();
-       return false;
-}
-
-bool
-LayerGroupTreeStore::find_layer_row(const synfig::Layer::Handle &layer, Gtk::TreeModel::Children::iterator &iter)
-{
-       Gtk::TreeModel::Children::iterator prev;
-       return find_layer_row_(layer,canvas_interface()->get_canvas(),children(),iter,prev);
-}
-
-bool
-LayerGroupTreeStore::find_group_row(const synfig::String &group, Gtk::TreeModel::Children::iterator &iter)
-{
-       Gtk::TreeModel::Children::iterator prev;
-       return find_group_row_(group,children(),iter,prev);
-}
-
-bool
-LayerGroupTreeStore::find_group_row_(const synfig::String &group, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter, Gtk::TreeModel::Children::iterator &prev)
-{
-       //if(layer->get_canvas()==canvas)
-       {
-               for(iter=prev=layers.begin(); iter && iter != layers.end(); prev=iter++)
-               {
-                       Gtk::TreeModel::Row row = *iter;
-                       if((bool)row[model.is_group] && group==(Glib::ustring)row[model.group_name])
-                               return true;
-               }
-
-               iter=children().end();
-               //return false;
-       }
-
-       Gtk::TreeModel::Children::iterator iter2;
-
-       for(iter2 = layers.begin(); iter2 && iter2 != layers.end(); ++iter2)
-       {
-               Gtk::TreeModel::Row row = *iter2;
-               assert((bool)true);
-
-               if(row.children().empty())
-                       continue;
-
-               if(find_group_row_(group,iter2->children(),iter,prev))
-                       return true;
-       }
-
-       iter=children().end();
-       return false;
-}
-
-bool
-LayerGroupTreeStore::find_prev_layer_row(const synfig::Layer::Handle &layer, Gtk::TreeModel::Children::iterator &prev)
-{
-       Gtk::TreeModel::Children::iterator iter;
-       if(!find_layer_row_(layer,canvas_interface()->get_canvas(),children(),iter,prev))
-               return false;
-       if(iter==children().begin())
-               return false;
-       return true;
-}
diff --git a/synfig-studio/src/gtkmm/layergrouptreestore.h b/synfig-studio/src/gtkmm/layergrouptreestore.h
deleted file mode 100644 (file)
index cd0c196..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file layergrouptreestore.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_LAYERGROUPTREESTORE_H
-#define __SYNFIG_STUDIO_LAYERGROUPTREESTORE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/treestore.h>
-#include <synfigapp/canvasinterface.h>
-#include <synfig/value.h>
-#include <synfig/valuenode.h>
-#include <gtkmm/treeview.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 LayerGroupTreeStore :  public Gtk::TreeStore
-{
-       /*
- -- ** -- P U B L I C   T Y P E S ---------------------------------------------
-       */
-
-public:
-       typedef std::list<synfig::Layer::Handle> LayerList;
-
-       class Model : public Gtk::TreeModel::ColumnRecord
-       {
-       public:
-               Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
-               Gtk::TreeModelColumn<Glib::ustring> label;
-               Gtk::TreeModelColumn<Glib::ustring> tooltip;
-
-               Gtk::TreeModelColumn<Glib::ustring> group_name;
-               Gtk::TreeModelColumn<Glib::ustring> parent_group_name;
-
-               Gtk::TreeModelColumn<synfig::Canvas::Handle> canvas;
-
-               Gtk::TreeModelColumn<bool>                                              active;
-               Gtk::TreeModelColumn<bool>                                              is_layer;
-               Gtk::TreeModelColumn<bool>                                              is_group;
-               Gtk::TreeModelColumn<synfig::Layer::Handle>             layer;
-
-               Gtk::TreeModelColumn<LayerList>         all_layers;
-               Gtk::TreeModelColumn<LayerList>         child_layers;
-
-               Model()
-               {
-                       add(icon);
-                       add(label);
-                       add(group_name);
-                       add(parent_group_name);
-                       add(canvas);
-                       add(tooltip);
-                       add(active);
-                       add(layer);
-                       add(is_layer);
-                       add(is_group);
-                       add(all_layers);
-                       add(child_layers);
-               }
-       };
-
-       /*
- -- ** -- P U B L I C  D A T A ------------------------------------------------
-       */
-
-public:
-
-       //! TreeModel for the layers
-       const Model model;
-
-       bool rebuilding;
-
-       /*
- -- ** -- P R I V A T E   D A T A ---------------------------------------------
-       */
-
-private:
-
-       etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
-
-       Glib::RefPtr<Gdk::Pixbuf> layer_icon;
-       Glib::RefPtr<Gdk::Pixbuf> group_icon;
-
-       /*
- -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
-       */
-
-private:
-
-       /*
- -- ** -- P R O T E C T E D   M E T H O D S -----------------------------------
-       */
-
-private:
-
-       virtual void set_value_impl (const Gtk::TreeModel::iterator& row, int column, const Glib::ValueBase& value);
-       virtual void  get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const;
-
-       virtual bool  row_draggable_vfunc (const TreeModel::Path& path)const;
-       virtual bool  drag_data_get_vfunc (const TreeModel::Path& path, Gtk::SelectionData& selection_data)const;
-       virtual bool  drag_data_delete_vfunc (const TreeModel::Path& path);
-       virtual bool  drag_data_received_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data);
-       virtual bool  row_drop_possible_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)const;
-
-
-       void on_group_pair_added(synfig::String group, etl::handle<synfig::Layer> layer);
-       void on_group_pair_removed(synfig::String group, etl::handle<synfig::Layer> layer);
-
-       void on_activity();
-
-       /*
- -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
-       */
-
-private:
-
-       bool on_layer_tree_event(GdkEvent *event);
-
-       void on_layer_new_description(synfig::Layer::Handle handle,synfig::String desc);
-
-       void on_layer_status_changed(synfig::Layer::Handle handle,bool);
-
-       bool find_layer_row_(const synfig::Layer::Handle &handle, synfig::Canvas::Handle canvas, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter, Gtk::TreeModel::Children::iterator &prev);
-
-       bool find_group_row_(const synfig::String &group, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter, Gtk::TreeModel::Children::iterator &prev);
-
-       bool on_group_removed(synfig::String group);
-       bool on_group_changed(synfig::String group);
-
-       /*
- -- ** -- P U B L I C   M E T H O D S -----------------------------------------
-       */
-
-public:
-
-       LayerGroupTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
-       ~LayerGroupTreeStore();
-
-       Gtk::TreeRow on_group_added(synfig::String group);
-       etl::loose_handle<synfigapp::CanvasInterface> canvas_interface() { return canvas_interface_; }
-       etl::loose_handle<const synfigapp::CanvasInterface> canvas_interface()const { return canvas_interface_; }
-       etl::loose_handle<synfigapp::CanvasInterface> get_canvas_interface()const { return canvas_interface_; }
-
-       bool find_layer_row(const synfig::Layer::Handle &handle, Gtk::TreeModel::Children::iterator &iter);
-
-       bool find_group_row(const synfig::String &group, Gtk::TreeModel::Children::iterator &iter);
-
-       bool find_prev_layer_row(const synfig::Layer::Handle &handle, Gtk::TreeModel::Children::iterator &iter);
-
-       void rebuild();
-
-       void refresh();
-
-       void refresh_row(Gtk::TreeModel::Row &row);
-
-       void set_row_layer(Gtk::TreeRow &row,synfig::Layer::Handle &handle);
-
-       static bool search_func(const Glib::RefPtr<TreeModel>&,int,const Glib::ustring&,const TreeModel::iterator&);
-
-       /*
- -- ** -- S T A T I C   P U B L I C   M E T H O D S ---------------------------
-       */
-
-public:
-
-       static Glib::RefPtr<LayerGroupTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
-
-}; // END of class LayerGroupTreeStore
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/layerparamtreestore.cpp b/synfig-studio/src/gtkmm/layerparamtreestore.cpp
deleted file mode 100644 (file)
index 8fe850a..0000000
+++ /dev/null
@@ -1,577 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file layerparamtreestore.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 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 <config.h>
-#endif
-
-#include "layerparamtreestore.h"
-#include "iconcontroller.h"
-#include <gtkmm/button.h>
-#include <synfig/paramdesc.h>
-#include "layertree.h"
-#include <synfigapp/action_system.h>
-#include <synfigapp/instance.h>
-#include "app.h"
-#include <ETL/clock>
-
-#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 ========================================================= */
-
-class Profiler : private etl::clock
-{
-       const std::string name;
-public:
-       Profiler(const std::string& name):name(name) { reset(); }
-       ~Profiler() { float time(operator()()); synfig::info("%s: took %f msec",name.c_str(),time*1000); }
-};
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-static LayerParamTreeStore::Model& ModelHack()
-{
-       static LayerParamTreeStore::Model* model(0);
-       if(!model)model=new LayerParamTreeStore::Model;
-       return *model;
-}
-
-LayerParamTreeStore::LayerParamTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_,LayerTree* layer_tree):
-       Gtk::TreeStore                  (ModelHack()),
-       CanvasTreeStore                 (canvas_interface_),
-       layer_tree                              (layer_tree)
-{
-       queued=0;
-       // Connect all the signals
-       canvas_interface()->signal_value_node_changed().connect(sigc::mem_fun(*this,&studio::LayerParamTreeStore::on_value_node_changed));
-       canvas_interface()->signal_value_node_renamed().connect(sigc::mem_fun(*this,&studio::LayerParamTreeStore::on_value_node_renamed));
-       canvas_interface()->signal_value_node_added().connect(sigc::mem_fun(*this,&studio::LayerParamTreeStore::on_value_node_added));
-       canvas_interface()->signal_value_node_deleted().connect(sigc::mem_fun(*this,&studio::LayerParamTreeStore::on_value_node_deleted));
-       canvas_interface()->signal_value_node_replaced().connect(sigc::mem_fun(*this,&studio::LayerParamTreeStore::on_value_node_replaced));
-       canvas_interface()->signal_layer_param_changed().connect(sigc::mem_fun(*this,&studio::LayerParamTreeStore::on_layer_param_changed));
-
-       canvas_interface()->signal_value_node_child_added().connect(sigc::mem_fun(*this,&studio::LayerParamTreeStore::on_value_node_child_added));
-       canvas_interface()->signal_value_node_child_removed().connect(sigc::mem_fun(*this,&studio::LayerParamTreeStore::on_value_node_child_removed));
-
-
-       layer_tree->get_selection()->signal_changed().connect(sigc::mem_fun(*this,&LayerParamTreeStore::queue_rebuild));
-
-       signal_changed().connect(sigc::mem_fun(*this,&LayerParamTreeStore::queue_refresh));
-       rebuild();
-}
-
-LayerParamTreeStore::~LayerParamTreeStore()
-{
-       while(!changed_connection_list.empty())
-       {
-               changed_connection_list.back().disconnect();
-               changed_connection_list.pop_back();
-       }
-
-       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
-               synfig::info("LayerParamTreeStore::~LayerParamTreeStore(): Deleted");
-}
-
-Glib::RefPtr<LayerParamTreeStore>
-LayerParamTreeStore::create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_, LayerTree*layer_tree)
-{
-       return Glib::RefPtr<LayerParamTreeStore>(new LayerParamTreeStore(canvas_interface_,layer_tree));
-}
-
-
-
-void
-LayerParamTreeStore::get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const
-{
-       if(column<0)
-       {
-               synfig::error("LayerParamTreeStore::get_value_vfunc(): Bad column!");
-               return;
-       }
-
-/*     if(column==model.label.index())
-       {
-               synfig::Layer::Handle layer((*iter)[model.layer]);
-
-               if(!layer)return;
-
-               Glib::Value<Glib::ustring> x;
-               g_value_init(x.gobj(),x.value_type());
-
-               x.set(layer->get_non_empty_description());
-
-               g_value_init(value.gobj(),x.value_type());
-               g_value_copy(x.gobj(),value.gobj());
-       }
-       else
-*/
-       if(column==model.label.index())
-       {
-               synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
-               Glib::ustring label;
-
-               if(!(*iter)[model.is_toplevel])
-                       return CanvasTreeStore::get_value_vfunc(iter,column,value);
-               synfig::ParamDesc param_desc((*iter)[model.param_desc]);
-               label=param_desc.get_local_name();
-
-               if(!(*iter)[model.is_inconsistent])
-               if(value_desc.is_value_node() && value_desc.get_value_node()->is_exported())
-               {
-                       label+=strprintf(" (%s)",value_desc.get_value_node()->get_id().c_str());
-               }
-
-               Glib::Value<Glib::ustring> x;
-               g_value_init(x.gobj(),x.value_type());
-
-               x.set(label);
-
-               g_value_init(value.gobj(),x.value_type());
-               g_value_copy(x.gobj(),value.gobj());
-       }
-       else
-       if(column==model.is_toplevel.index())
-       {
-               Glib::Value<bool> x;
-               g_value_init(x.gobj(),x.value_type());
-
-               TreeModel::Path path(get_path(iter));
-
-               x.set(path.get_depth()<=1);
-
-               g_value_init(value.gobj(),x.value_type());
-               g_value_copy(x.gobj(),value.gobj());
-       }
-       else
-       if(column==model.is_inconsistent.index())
-       {
-               if((*iter)[model.is_toplevel])
-               {
-                       CanvasTreeStore::get_value_vfunc(iter,column,value);
-                       return;
-               }
-
-               Glib::Value<bool> x;
-               g_value_init(x.gobj(),x.value_type());
-
-               x.set(false);
-
-               g_value_init(value.gobj(),x.value_type());
-               g_value_copy(x.gobj(),value.gobj());
-       }
-       else
-       CanvasTreeStore::get_value_vfunc(iter,column,value);
-}
-
-
-
-void
-LayerParamTreeStore::set_value_impl(const Gtk::TreeModel::iterator& iter, int column, const Glib::ValueBase& value)
-{
-       //if(!iterator_sane(row))
-       //      return;
-
-       if(column>=get_n_columns_vfunc())
-       {
-               g_warning("LayerTreeStore::set_value_impl: Bad column (%d)",column);
-               return;
-       }
-
-       if(!g_value_type_compatible(G_VALUE_TYPE(value.gobj()),get_column_type_vfunc(column)))
-       {
-               g_warning("LayerTreeStore::set_value_impl: Bad value type");
-               return;
-       }
-
-       try
-       {
-               if(column==model.value.index())
-               {
-                       Glib::Value<synfig::ValueBase> x;
-                       g_value_init(x.gobj(),model.value.type());
-                       g_value_copy(value.gobj(),x.gobj());
-
-                       if((bool)(*iter)[model.is_toplevel])
-                       {
-                               synfigapp::Action::PassiveGrouper group(canvas_interface()->get_instance().get(),_("Set Layer Params"));
-
-                               synfig::ParamDesc param_desc((*iter)[model.param_desc]);
-
-                               LayerList::iterator iter2(layer_list.begin());
-
-                               for(;iter2!=layer_list.end();++iter2)
-                               {
-                                       if(!canvas_interface()->change_value(synfigapp::ValueDesc(*iter2,param_desc.get_name()),x.get()))
-                                       {
-                                               // ERROR!
-                                               group.cancel();
-                                               App::dialog_error_blocking(_("Error"),_("Unable to set all layer parameters."));
-
-                                               return;
-                                       }
-                               }
-                       }
-                       else
-                       {
-                               canvas_interface()->change_value((*iter)[model.value_desc],x.get());
-                       }
-                       return;
-               }
-               else
-/*
-               if(column==model.active.index())
-               {
-                       synfig::Layer::Handle layer((*iter)[model.layer]);
-
-                       if(!layer)return;
-
-                       Glib::Value<bool> x;
-                       g_value_init(x.gobj(),model.active.type());
-                       g_value_copy(value.gobj(),x.gobj());
-
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerActivate"));
-
-                       if(!action)
-                               return;
-
-                       action->set_param("canvas",canvas_interface()->get_canvas());
-                       action->set_param("canvas_interface",canvas_interface());
-                       action->set_param("layer",layer);
-                       action->set_param("new_status",bool(x.get()));
-
-                       canvas_interface()->get_instance()->perform_action(action);
-                       return;
-               }
-               else
-*/
-               CanvasTreeStore::set_value_impl(iter,column, value);
-       }
-       catch(std::exception x)
-       {
-               g_warning("%s", x.what());
-       }
-}
-
-
-
-
-
-
-
-
-
-
-void
-LayerParamTreeStore::rebuild()
-{
-       // Profiler profiler("LayerParamTreeStore::rebuild()");
-       if(queued)queued=0;
-       clear();
-       layer_list=layer_tree->get_selected_layers();
-
-       if(layer_list.size()<=0)
-               return;
-
-       // Get rid of all the connections,
-       // and clear the connection map.
-       //while(!connection_map.empty())connection_map.begin()->second.disconnect(),connection_map.erase(connection_map.begin());
-       while(!changed_connection_list.empty())
-       {
-               changed_connection_list.back().disconnect();
-               changed_connection_list.pop_back();
-       }
-
-       struct REBUILD_HELPER
-       {
-               ParamVocab vocab;
-               Layer::Handle layer_0;
-
-               static ParamVocab::iterator find_param_desc(ParamVocab& vocab, const synfig::String& x)
-               {
-                       ParamVocab::iterator iter;
-
-                       for(iter=vocab.begin();iter!=vocab.end();++iter)
-                               if(iter->get_name()==x)
-                                       break;
-                       return iter;
-               }
-
-               void process_vocab(synfig::Layer::Handle layer_n)
-               {
-                       ParamVocab x = layer_n->get_param_vocab();
-                       ParamVocab::iterator iter;
-
-                       for(iter=vocab.begin();iter!=vocab.end();++iter)
-                       {
-                               String name(iter->get_name());
-                               ParamVocab::iterator iter2(find_param_desc(x,name));
-                               if(iter2==x.end() ||
-                                  layer_0->get_param(name).get_type() != layer_n->get_param(name).get_type())
-                               {
-                                       // remove it and start over
-                                       vocab.erase(iter);
-                                       iter=vocab.begin();
-                                       iter--;
-                                       continue;
-                               }
-                       }
-               }
-
-       } rebuild_helper;
-
-
-       {
-               LayerList::iterator iter(layer_list.begin());
-               rebuild_helper.vocab=(*iter)->get_param_vocab();
-               rebuild_helper.layer_0=*iter;
-
-               for(++iter;iter!=layer_list.end();++iter)
-               {
-                       rebuild_helper.process_vocab(*iter);
-                       changed_connection_list.push_back(
-                               (*iter)->signal_changed().connect(
-                                       sigc::mem_fun(
-                                               *this,
-                                               &LayerParamTreeStore::changed
-                                       )
-                               )
-                       );
-               }
-       }
-
-       ParamVocab::iterator iter;
-       for(iter=rebuild_helper.vocab.begin();iter!=rebuild_helper.vocab.end();++iter)
-       {
-               if(iter->get_hidden())
-                       continue;
-
-               /*
-               if(iter->get_animation_only())
-               {
-                       int length(layer_list.front()->get_canvas()->rend_desc().get_frame_end()-layer_list.front()->get_canvas()->rend_desc().get_frame_start());
-                       if(!length)
-                               continue;
-               }
-               */
-               Gtk::TreeRow row(*(append()));
-               synfigapp::ValueDesc value_desc(layer_list.front(),iter->get_name());
-               CanvasTreeStore::set_row(row,value_desc);
-               if(value_desc.is_value_node())
-               {
-                       changed_connection_list.push_back(
-                               value_desc.get_value_node()->signal_changed().connect(
-                                       sigc::mem_fun(
-                                               this,
-                                               &LayerParamTreeStore::changed
-                                       )
-                               )
-                       );
-               }
-               if(value_desc.get_value_type()==ValueBase::TYPE_CANVAS)
-               {
-                       Canvas::Handle canvas_handle = value_desc.get_value().get(Canvas::Handle());
-                       if(canvas_handle) changed_connection_list.push_back(
-                               canvas_handle->signal_changed().connect(
-                                       sigc::mem_fun(
-                                               this,
-                                               &LayerParamTreeStore::changed
-                                       )
-                               )
-                       );
-               }
-               //row[model.label] = iter->get_local_name();
-               row[model.param_desc] = *iter;
-               row[model.canvas] = layer_list.front()->get_canvas();
-               row[model.is_inconsistent] = false;
-               //row[model.is_toplevel] = true;
-
-
-               LayerList::iterator iter2(layer_list.begin());
-               ValueBase value((*iter2)->get_param(iter->get_name()));
-               for(++iter2;iter2!=layer_list.end();++iter2)
-               {
-                       if(value!=((*iter2)->get_param(iter->get_name())))
-                       {
-                               row[model.is_inconsistent] = true;
-                               while(!row.children().empty() && erase(row.children().begin()))
-                                       ;
-                               break;
-                       }
-               }
-       }
-}
-
-void
-LayerParamTreeStore::queue_refresh()
-{
-       if(queued)
-               return;
-       queued=1;
-       queue_connection.disconnect();
-       queue_connection=Glib::signal_timeout().connect(
-               sigc::bind_return(
-                       sigc::mem_fun(*this,&LayerParamTreeStore::refresh),
-                       false
-               )
-       ,150);
-
-}
-
-void
-LayerParamTreeStore::queue_rebuild()
-{
-       if(queued==2)
-               return;
-       queued=2;
-       queue_connection.disconnect();
-       queue_connection=Glib::signal_timeout().connect(
-               sigc::bind_return(
-                       sigc::mem_fun(*this,&LayerParamTreeStore::rebuild),
-                       false
-               )
-       ,150);
-
-}
-
-void
-LayerParamTreeStore::refresh()
-{
-       if(queued)queued=0;
-
-       Gtk::TreeModel::Children children_(children());
-
-       Gtk::TreeModel::Children::iterator iter;
-
-       if(!children_.empty())
-               for(iter = children_.begin(); iter && iter != children_.end(); ++iter)
-               {
-                       Gtk::TreeRow row=*iter;
-                       refresh_row(row);
-               }
-}
-
-void
-LayerParamTreeStore::refresh_row(Gtk::TreeModel::Row &row)
-{
-       if(row[model.is_toplevel])
-       {
-               row[model.is_inconsistent] = false;
-               ParamDesc param_desc(row[model.param_desc]);
-
-               LayerList::iterator iter2(layer_list.begin());
-               ValueBase value((*iter2)->get_param(param_desc.get_name()));
-               for(++iter2;iter2!=layer_list.end();++iter2)
-               {
-                       if(value!=((*iter2)->get_param(param_desc.get_name())))
-                       {
-                               row[model.is_inconsistent] = true;
-                               while(!row.children().empty() && erase(row.children().begin()))
-                                       ;
-                               return;
-                       }
-               }
-       }
-
-       //handle<ValueNode> value_node=row[model.value_node];
-       //if(value_node)
-       {
-               CanvasTreeStore::refresh_row(row);
-               return;
-       }
-}
-
-void
-LayerParamTreeStore::set_row(Gtk::TreeRow row,synfigapp::ValueDesc value_desc)
-{
-       Gtk::TreeModel::Children children = row.children();
-       while(!children.empty() && erase(children.begin()))
-               ;
-
-       CanvasTreeStore::set_row(row,value_desc);
-}
-
-void
-LayerParamTreeStore::on_value_node_added(synfig::ValueNode::Handle /*value_node*/)
-{
-//     queue_refresh();
-}
-
-void
-LayerParamTreeStore::on_value_node_deleted(synfig::ValueNode::Handle /*value_node*/)
-{
-//     queue_refresh();
-}
-
-void
-LayerParamTreeStore::on_value_node_child_added(synfig::ValueNode::Handle /*value_node*/,synfig::ValueNode::Handle /*child*/)
-{
-       queue_rebuild();
-}
-
-void
-LayerParamTreeStore::on_value_node_child_removed(synfig::ValueNode::Handle /*value_node*/,synfig::ValueNode::Handle /*child*/)
-{
-       rebuild();
-}
-
-void
-LayerParamTreeStore::on_value_node_changed(synfig::ValueNode::Handle /*value_node*/)
-{
-       queue_refresh();
-}
-
-void
-LayerParamTreeStore::on_value_node_renamed(synfig::ValueNode::Handle /*value_node*/)
-{
-       rebuild();
-}
-
-void
-LayerParamTreeStore::on_value_node_replaced(synfig::ValueNode::Handle /*replaced_value_node*/,synfig::ValueNode::Handle /*new_value_node*/)
-{
-       queue_rebuild();
-}
-
-void
-LayerParamTreeStore::on_layer_param_changed(synfig::Layer::Handle /*handle*/,synfig::String /*param_name*/)
-{
-       queue_refresh();
-}
diff --git a/synfig-studio/src/gtkmm/layerparamtreestore.h b/synfig-studio/src/gtkmm/layerparamtreestore.h
deleted file mode 100644 (file)
index ce96cbe..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file layerparamtreestore.h
-**     \brief Template Header
-**
-**     $Id$
-**
-**     \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
-**     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_LAYERPARAMTREESTORE_H
-#define __SYNFIG_STUDIO_LAYERPARAMTREESTORE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/treestore.h>
-#include <synfigapp/canvasinterface.h>
-#include "canvastreestore.h"
-#include <synfig/value.h>
-#include <synfig/valuenode.h>
-#include <synfig/paramdesc.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 LayerTree;
-
-class LayerParamTreeStore : public CanvasTreeStore
-{
-       /*
- -- ** -- P U B L I C   T Y P E S ---------------------------------------------
-       */
-
-public:
-       typedef std::list<synfig::Layer::Handle> LayerList;
-
-       /*
- -- ** -- P U B L I C  D A T A ------------------------------------------------
-       */
-
-public:
-
-       //! TreeModel for the layer parameters
-       class Model : public CanvasTreeStore::Model
-       {
-       public:
-
-               Gtk::TreeModelColumn<synfig::ParamDesc> param_desc;
-
-               Gtk::TreeModelColumn<bool>      is_inconsistent;
-               Gtk::TreeModelColumn<bool>      is_toplevel;
-
-               Model()
-               {
-                       add(param_desc);
-                       add(is_inconsistent);
-                       add(is_toplevel);
-               }
-       };
-
-       Model model;
-
-
-       /*
- -- ** -- P R I V A T E   D A T A ---------------------------------------------
-       */
-
-private:
-
-       int queued;
-
-       LayerTree* layer_tree;
-
-       LayerList layer_list;
-
-       sigc::connection queue_connection;
-
-       std::list<sigc::connection> changed_connection_list;
-
-       sigc::signal<void> signal_changed_;
-
-       /*
- -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
-       */
-
-private:
-
-protected:
-       virtual void  get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const;
-       virtual void set_value_impl (const Gtk::TreeModel::iterator& row, int column, const Glib::ValueBase& value);
-       virtual void set_row(Gtk::TreeRow row,synfigapp::ValueDesc value_desc);
-
-       /*
- -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
-       */
-
-private:
-
-       void on_value_node_child_added(synfig::ValueNode::Handle value_node,synfig::ValueNode::Handle child);
-       void on_value_node_child_removed(synfig::ValueNode::Handle value_node,synfig::ValueNode::Handle child);
-
-       void on_value_node_added(synfig::ValueNode::Handle value_node);
-       void on_value_node_deleted(synfig::ValueNode::Handle value_node);
-       virtual void on_value_node_changed(synfig::ValueNode::Handle value_node);
-       virtual void on_value_node_renamed(synfig::ValueNode::Handle value_node);
-       void on_value_node_replaced(synfig::ValueNode::Handle replaced_value_node,synfig::ValueNode::Handle new_value_node);
-       void on_layer_param_changed(synfig::Layer::Handle handle,synfig::String param_name);
-
-       /*
- -- ** -- P U B L I C   M E T H O D S -----------------------------------------
-       */
-
-public:
-
-       LayerParamTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_,
-               LayerTree* layer_tree);
-       ~LayerParamTreeStore();
-
-       void rebuild();
-
-       void refresh();
-
-       void queue_refresh();
-
-       void queue_rebuild();
-
-       void refresh_row(Gtk::TreeModel::Row &row);
-
-       sigc::signal<void>& signal_changed() { return signal_changed_; }
-
-       void changed() { signal_changed_(); }
-
-       /*
- -- ** -- S T A T I C   P U B L I C   M E T H O D S ---------------------------
-       */
-
-public:
-
-       static Glib::RefPtr<LayerParamTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_, LayerTree*layer_tree);
-}; // END of class LayerParamTreeStore
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/layertree.cpp b/synfig-studio/src/gtkmm/layertree.cpp
deleted file mode 100644 (file)
index a69f234..0000000
+++ /dev/null
@@ -1,1232 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file layertree.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 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 <config.h>
-#endif
-
-#include "layertree.h"
-#include "layerparamtreestore.h"
-#include "cellrenderer_value.h"
-#include "cellrenderer_timetrack.h"
-#include <synfigapp/action.h>
-#include <synfigapp/instance.h>
-#include <gtkmm/scrolledwindow.h>
-#include <gtkmm/paned.h>
-#include "app.h"
-#include "instance.h"
-#include <gtkmm/treemodelsort.h>
-
-#ifdef TIMETRACK_IN_PARAMS_PANEL
-#  include <synfig/timepointcollect.h>
-#endif // TIMETRACK_IN_PARAMS_PANEL
-
-#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 SMALL_BUTTON
-#define SMALL_BUTTON(button,stockid,tooltip)   \
-       button = manage(new class Gtk::Button());       \
-       icon=manage(new Gtk::Image(Gtk::StockID(stockid),iconsize));    \
-       button->add(*icon);     \
-       tooltips_.set_tip(*button,tooltip);     \
-       icon->set_padding(0,0);\
-       icon->show();   \
-       button->set_relief(Gtk::RELIEF_NONE); \
-       button->show()
-#endif
-
-#ifndef NORMAL_BUTTON
-#define NORMAL_BUTTON(button,stockid,tooltip)  \
-       button = manage(new class Gtk::Button());       \
-       icon=manage(new Gtk::Image(Gtk::StockID(stockid),Gtk::ICON_SIZE_BUTTON));       \
-       button->add(*icon);     \
-       tooltips_.set_tip(*button,tooltip);     \
-       icon->set_padding(0,0);\
-       icon->show();   \
-       /*button->set_relief(Gtk::RELIEF_NONE);*/ \
-       button->show()
-#endif
-
-#define NEW_SMALL_BUTTON(x,y,z)        Gtk::Button *SMALL_BUTTON(x,y,z)
-
-#define NOT_IMPLEMENTED_SLOT sigc::mem_fun(*reinterpret_cast<studio::CanvasViewUIInterface*>(get_ui_interface().get()),&studio::CanvasViewUIInterface::not_implemented)
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-LayerTree::LayerTree():
-       layer_amount_adjustment_(1,0,1,0.01,0.01,0)
-{
-       param_tree_view_=new Gtk::TreeView;
-       layer_tree_view_=new Gtk::TreeView;
-
-       //Gtk::HPaned* hpaned(manage(new Gtk::HPaned()));
-       //hpaned->show();
-       //attach(*hpaned, 0, 3, 0, 1, Gtk::EXPAND|Gtk::FILL,Gtk::EXPAND|Gtk::FILL, 0, 0);
-       //attach(*create_layer_tree(), 0, 3, 0, 1, Gtk::EXPAND|Gtk::FILL,Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       create_layer_tree();
-       create_param_tree();
-
-       //hpaned->pack1(*create_layer_tree(),false,false);
-       //hpaned->pack2(*create_param_tree(),true,false);
-       //hpaned->set_position(200);
-       hbox=manage(new Gtk::HBox());
-
-       attach(*hbox, 0, 1, 1, 2, Gtk::FILL|Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       attach(blend_method_widget, 2, 3, 1, 2,Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-
-       layer_amount_hscale=manage(new Gtk::HScale(layer_amount_adjustment_));
-       layer_amount_hscale->set_digits(2);
-       layer_amount_hscale->set_value_pos(Gtk::POS_LEFT);
-       layer_amount_hscale->set_sensitive(false);
-       layer_amount_hscale->set_update_policy( Gtk::UPDATE_DISCONTINUOUS);
-       attach(*layer_amount_hscale, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK, 1, 1);
-       layer_amount_adjustment_.signal_value_changed().connect(sigc::mem_fun(*this, &studio::LayerTree::on_amount_value_changed));
-
-       Gtk::Image *icon;
-       //Gtk::IconSize iconsize(Gtk::IconSize::from_name("synfig-small_icon"));
-       Gtk::IconSize iconsize(Gtk::ICON_SIZE_SMALL_TOOLBAR);
-
-       SMALL_BUTTON(button_raise,"gtk-go-up","Raise");
-       SMALL_BUTTON(button_lower,"gtk-go-down","Lower");
-       SMALL_BUTTON(button_duplicate,"synfig-duplicate","Duplicate");
-       SMALL_BUTTON(button_encapsulate,"synfig-encapsulate","Encapsulate");
-       SMALL_BUTTON(button_delete,"gtk-delete","Delete");
-
-       hbox->pack_start(*button_raise,Gtk::PACK_SHRINK);
-       hbox->pack_start(*button_lower,Gtk::PACK_SHRINK);
-       hbox->pack_start(*button_duplicate,Gtk::PACK_SHRINK);
-       hbox->pack_start(*button_encapsulate,Gtk::PACK_SHRINK);
-       hbox->pack_start(*button_delete,Gtk::PACK_SHRINK);
-
-       // button_raise->signal_clicked().connect(sigc::mem_fun(*this, &studio::LayerTree::on_raise_pressed));
-       // button_lower->signal_clicked().connect(sigc::mem_fun(*this, &studio::LayerTree::on_lower_pressed));
-       // button_duplicate->signal_clicked().connect(sigc::mem_fun(*this, &studio::LayerTree::on_duplicate_pressed));
-       // button_encapsulate->signal_clicked().connect(sigc::mem_fun(*this, &studio::LayerTree::on_encapsulate_pressed));
-       // button_delete->signal_clicked().connect(sigc::mem_fun(*this, &studio::LayerTree::on_delete_pressed));
-
-       button_raise->set_sensitive(false);
-       button_lower->set_sensitive(false);
-       button_duplicate->set_sensitive(false);
-       button_encapsulate->set_sensitive(false);
-       button_delete->set_sensitive(false);
-
-       get_selection()->signal_changed().connect(sigc::mem_fun(*this, &studio::LayerTree::on_selection_changed));
-
-       get_layer_tree_view().set_reorderable(true);
-       get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
-       //get_param_tree_view().get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
-       get_layer_tree_view().show();
-       get_param_tree_view().show();
-
-       hbox->show();
-       layer_amount_hscale->show();
-       blend_method_widget.show();
-
-       tooltips_.enable();
-       disable_amount_changed_signal=false;
-
-       blend_method_widget.set_param_desc(ParamDesc(Color::BlendMethod(),"blend_method"));
-
-       blend_method_widget.set_value((int)Color::BLEND_COMPOSITE);
-       blend_method_widget.set_size_request(150,-1);
-       blend_method_widget.set_sensitive(false);
-       blend_method_widget.signal_activate().connect(sigc::mem_fun(*this, &studio::LayerTree::on_blend_method_changed));
-}
-
-LayerTree::~LayerTree()
-{
-       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
-               synfig::info("LayerTree::~LayerTree(): Deleted");
-}
-
-Gtk::Widget*
-LayerTree::create_layer_tree()
-{
-       const LayerTreeStore::Model model;
-
-       {       // --- O N / O F F ----------------------------------------------------
-               //int index;
-               //index=get_layer_tree_view().append_column_editable(_(" "),layer_model.active);
-               //Gtk::TreeView::Column* column = get_layer_tree_view().get_column(index-1);
-
-               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_(" ")) );
-
-               // Set up the icon cell-renderer
-               Gtk::CellRendererToggle* cellrenderer = Gtk::manage( new Gtk::CellRendererToggle() );
-               cellrenderer->signal_toggled().connect(sigc::mem_fun(*this, &studio::LayerTree::on_layer_toggle));
-
-               column->pack_start(*cellrenderer,false);
-               column->add_attribute(cellrenderer->property_active(), layer_model.active);
-               get_layer_tree_view().append_column(*column);
-       }
-
-       {       // --- I C O N --------------------------------------------------------
-               int index;
-               index=get_layer_tree_view().append_column(_("Z"),layer_model.icon);
-               Gtk::TreeView::Column* column = get_layer_tree_view().get_column(index-1);
-               get_layer_tree_view().set_expander_column(*column);
-
-               column->set_sort_column(layer_model.z_depth);
-               //column->set_reorderable();
-               //column->set_resizable();
-               //column->set_clickable();
-
-               //Gtk::CellRendererPixbuf* icon_cellrenderer = Gtk::manage( new Gtk::CellRendererPixbuf() );
-               //column->pack_start(*icon_cellrenderer,false);
-               //column->add_attribute(icon_cellrenderer->property_pixbuf(), layer_model.icon);
-       }
-       //get_layer_tree_view().append_column(_("Z"),layer_model.z_depth);
-       {       // --- N A M E --------------------------------------------------------
-               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Name")) );
-
-               // Set up the icon cell-renderer
-               Gtk::CellRendererText* cellrenderer = Gtk::manage( new Gtk::CellRendererText() );
-               column->pack_start(*cellrenderer,false);
-               column->add_attribute(cellrenderer->property_text(), layer_model.label);
-               cellrenderer->signal_edited().connect(sigc::mem_fun(*this, &studio::LayerTree::on_layer_renamed));
-               cellrenderer->property_editable()=true;
-
-               column->set_reorderable();
-               // column->set_resizable();
-               column->set_clickable(true);
-               column->set_sort_column(layer_model.label);
-
-               get_layer_tree_view().append_column(*column);
-
-               //              int index;
-//             index=get_layer_tree_view().append_column_editable(_("Layer"),layer_model.label);
-               //Gtk::TreeView::Column* column = get_layer_tree_view().get_column(index-1);
-
-               //get_layer_tree_view().set_expander_column(*column);
-
-               //Gtk::CellRendererPixbuf* icon_cellrenderer = Gtk::manage( new Gtk::CellRendererPixbuf() );
-               //column->pack_start(*icon_cellrenderer,false);
-               //column->add_attribute(icon_cellrenderer->property_pixbuf(), layer_model.icon);
-       }
-       {       // --- Z D E P T H ----------------------------------------------------
-               int index;
-               index=get_layer_tree_view().append_column(_("Z"),layer_model.z_depth);
-               column_z_depth=get_layer_tree_view().get_column(index-1);
-
-               column_z_depth->set_reorderable();
-               column_z_depth->set_resizable();
-               column_z_depth->set_clickable();
-
-               column_z_depth->set_sort_column(layer_model.z_depth);
-       }
-
-       get_layer_tree_view().set_enable_search(true);
-       get_layer_tree_view().set_search_column(layer_model.label);
-       get_layer_tree_view().set_search_equal_func(sigc::ptr_fun(&studio::LayerTreeStore::search_func));
-
-       std::list<Gtk::TargetEntry> listTargets;
-       listTargets.push_back( Gtk::TargetEntry("LAYER") );
-       get_layer_tree_view().drag_dest_set(listTargets);
-
-       // This makes things easier to read.
-       get_layer_tree_view().set_rules_hint();
-
-       // Make us more sensitive to several events
-       //get_layer_tree_view().add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::BUTTON1_MOTION_MASK | Gdk::BUTTON2_MOTION_MASK|Gdk::POINTER_MOTION_MASK);
-
-       get_layer_tree_view().signal_event().connect(sigc::mem_fun(*this, &studio::LayerTree::on_layer_tree_event));
-       get_layer_tree_view().show();
-
-       Gtk::ScrolledWindow *scroll = manage(new class Gtk::ScrolledWindow());
-       scroll->set_flags(Gtk::CAN_FOCUS);
-       scroll->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
-       //scroll->add(get_layer_tree_view());
-       scroll->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
-       scroll->show();
-
-       return scroll;
-}
-
-Gtk::Widget*
-LayerTree::create_param_tree()
-{
-       Pango::AttrList attr_list;
-       {
-               Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*8));
-               pango_size.set_start_index(0);
-               pango_size.set_end_index(64);
-               attr_list.change(pango_size);
-       }
-
-       Gtk::IconSize icon_size(Gtk::ICON_SIZE_SMALL_TOOLBAR);
-
-       {       // --- N A M E --------------------------------------------------------
-               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Name")) );
-
-               // Set up the icon cell-renderer
-               Gtk::CellRendererPixbuf* icon_cellrenderer = Gtk::manage( new Gtk::CellRendererPixbuf() );
-               column->pack_start(*icon_cellrenderer,false);
-               column->add_attribute(icon_cellrenderer->property_pixbuf(), param_model.icon);
-
-               // Pack the label into the column
-               //column->pack_start(layer_model.label,true);
-               Gtk::CellRendererText* text_cellrenderer = Gtk::manage( new Gtk::CellRendererText() );
-               column->pack_start(*text_cellrenderer,false);
-               column->add_attribute(text_cellrenderer->property_text(), param_model.label);
-               text_cellrenderer->property_attributes()=attr_list;
-
-               text_cellrenderer->property_foreground()=Glib::ustring("#7f7f7f");
-               column->add_attribute(text_cellrenderer->property_foreground_set(),param_model.is_inconsistent);
-
-               // Pack the label into the column
-               //column->pack_start(param_model.label,true);
-
-               // Set up the value-node icon cell-renderer to be on the far right
-               Gtk::CellRendererPixbuf* valuenode_icon_cellrenderer = Gtk::manage( new Gtk::CellRendererPixbuf() );
-               column->pack_end(*valuenode_icon_cellrenderer,false);
-               valuenode_icon_cellrenderer->property_pixbuf()=Gtk::Button().render_icon(Gtk::StockID("synfig-value_node"),icon_size);
-               column->add_attribute(valuenode_icon_cellrenderer->property_visible(), param_model.is_shared);
-
-               // Finish setting up the column
-               column->set_reorderable();
-               column->set_resizable();
-               column->set_clickable();
-
-               get_param_tree_view().append_column(*column);
-       }
-       {       // --- V A L U E  -----------------------------------------------------
-               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Value")) );
-
-               // Set up the value cell-renderer
-               cellrenderer_value=LayerParamTreeStore::add_cell_renderer_value(column);
-               cellrenderer_value->signal_edited().connect(sigc::mem_fun(*this, &studio::LayerTree::on_edited_value));
-               cellrenderer_value->property_value()=synfig::ValueBase();
-               column->add_attribute(cellrenderer_value->property_param_desc(), param_model.param_desc);
-               column->add_attribute(cellrenderer_value->property_inconsistent(),param_model.is_inconsistent);
-               //cellrenderer_value->property_canvas()=canvas_interface->get_canvas(); // Is this line necessary?
-               cellrenderer_value->property_attributes()=attr_list;
-
-               // Finish setting up the column
-               get_param_tree_view().append_column(*column);
-               column->set_sizing(Gtk::TREE_VIEW_COLUMN_AUTOSIZE);
-               column->set_clickable();
-               column->set_min_width(120);
-               column->set_reorderable();
-               column->set_resizable();
-       }
-       {       // --- T Y P E --------------------------------------------------------
-               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Type")) );
-               Gtk::CellRendererText* text_cellrenderer = Gtk::manage( new Gtk::CellRendererText() );
-               column->pack_start(*text_cellrenderer,false);
-               column->add_attribute(text_cellrenderer->property_text(), param_model.type);
-               text_cellrenderer->property_attributes()=attr_list;
-               get_param_tree_view().append_column(*column);
-               column->set_reorderable();
-               column->set_resizable();
-               column->set_clickable();
-               column->set_sort_column(param_model.type);
-       }
-#ifdef TIMETRACK_IN_PARAMS_PANEL
-       {       // --- T I M E   T R A C K --------------------------------------------
-               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Time Track")) );
-               column_time_track=column;
-
-               // Set up the value-node cell-renderer
-               cellrenderer_time_track=LayerParamTreeStore::add_cell_renderer_value_node(column);
-               cellrenderer_time_track->property_mode()=Gtk::CELL_RENDERER_MODE_ACTIVATABLE;
-               cellrenderer_time_track->signal_waypoint_clicked_cellrenderer().connect(sigc::mem_fun(*this, &studio::LayerTree::on_waypoint_clicked_layertree) );
-               cellrenderer_time_track->signal_waypoint_changed().connect(sigc::mem_fun(*this, &studio::LayerTree::on_waypoint_changed) );
-               column->add_attribute(cellrenderer_time_track->property_value_desc(), param_model.value_desc);
-               column->add_attribute(cellrenderer_time_track->property_canvas(), param_model.canvas);
-               column->add_attribute(cellrenderer_time_track->property_visible(), param_model.is_value_node);
-
-               // Finish setting up the column
-               column->set_reorderable();
-               column->set_resizable();
-               column->set_min_width(200);
-
-               if (!getenv("SYNFIG_DISABLE_PARAMS_PANEL_TIMETRACK"))
-                       get_param_tree_view().append_column(*column);
-       }
-#endif // TIMETRACK_IN_PARAMS_PANEL
-
-       // This makes things easier to read.
-       get_param_tree_view().set_rules_hint();
-
-       // Make us more sensitive to several events
-       get_param_tree_view().add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::BUTTON1_MOTION_MASK | Gdk::BUTTON2_MOTION_MASK|Gdk::POINTER_MOTION_MASK);
-
-       get_param_tree_view().signal_event().connect(sigc::mem_fun(*this, &studio::LayerTree::on_param_tree_event));
-       get_param_tree_view().show();
-
-       Gtk::ScrolledWindow *scroll = manage(new class Gtk::ScrolledWindow());
-       scroll->set_flags(Gtk::CAN_FOCUS);
-       scroll->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
-       //scroll->add(get_param_tree_view());
-       scroll->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
-       scroll->show();
-
-       //column_time_track->set_visible(false);
-
-       return scroll;
-}
-
-void
-LayerTree::on_waypoint_changed( synfig::Waypoint waypoint , synfig::ValueNode::Handle value_node)
-{
-       synfigapp::Action::ParamList param_list;
-       param_list.add("canvas",layer_tree_store_->canvas_interface()->get_canvas());
-       param_list.add("canvas_interface",layer_tree_store_->canvas_interface());
-       param_list.add("value_node",value_node);
-       param_list.add("waypoint",waypoint);
-//     param_list.add("time",canvas_interface()->get_time());
-
-       etl::handle<studio::Instance>::cast_static(layer_tree_store_->canvas_interface()->get_instance())->process_action("WaypointSetSmart", param_list);
-}
-
-void
-LayerTree::select_layer(synfig::Layer::Handle layer)
-{
-       Gtk::TreeModel::Children::iterator iter;
-       if(layer_tree_store_->find_layer_row(layer,iter))
-       {
-               if(sorted_layer_tree_store_)
-                       iter=sorted_layer_tree_store_->convert_child_iter_to_iter(iter);
-
-               Gtk::TreePath path(iter);
-               for(int i=path.get_depth();i;i--)
-               {
-                       int j;
-                       path=Gtk::TreePath(iter);
-                       for(j=i;j;j--)
-                               path.up();
-                       get_layer_tree_view().expand_row(path,false);
-               }
-               get_layer_tree_view().scroll_to_row(Gtk::TreePath(iter));
-               get_layer_tree_view().get_selection()->select(iter);
-       }
-}
-
-void
-LayerTree::select_all_children(Gtk::TreeModel::Children::iterator iter)
-{
-       get_layer_tree_view().get_selection()->select(iter);
-       if((bool)(*iter)[layer_model.children_lock])
-               return;
-       get_layer_tree_view().expand_row(layer_tree_store_->get_path(iter),false);
-       Gtk::TreeModel::Children children(iter->children());
-       for(iter=children.begin();iter!=children.end();++iter)
-               select_all_children(iter);
-}
-
-void
-LayerTree::select_all_children_layers(synfig::Layer::Handle layer)
-{
-       Gtk::TreeModel::Children::iterator iter;
-       if(layer_tree_store_->find_layer_row(layer,iter))
-               select_all_children(iter);
-}
-
-void
-LayerTree::select_layers(const LayerList &layer_list)
-{
-       LayerList::const_iterator iter;
-       for(iter = layer_list.begin(); iter != layer_list.end(); ++iter)
-               select_layer(*iter);
-}
-
-static inline void __layer_grabber(const Gtk::TreeModel::iterator& iter, LayerTree::LayerList* ret)
-{
-       const LayerTreeStore::Model layer_tree_model;
-       ret->push_back((Layer::Handle)(*iter)[layer_tree_model.layer]);
-}
-
-LayerTree::LayerList
-LayerTree::get_selected_layers()const
-{
-       Glib::RefPtr<Gtk::TreeSelection> selection=const_cast<Gtk::TreeView&>(get_layer_tree_view()).get_selection();
-
-       if(!selection)
-               return LayerList();
-
-       LayerList ret;
-
-       selection->selected_foreach_iter(
-               sigc::bind(
-                       sigc::ptr_fun(
-                               &__layer_grabber
-                       ),
-                       &ret
-               )
-       );
-
-       return ret;
-}
-
-synfig::Layer::Handle
-LayerTree::get_selected_layer()const
-{
-       LayerList layers(get_selected_layers());
-
-       if(layers.empty())
-               return 0;
-
-       return *layers.begin();
-}
-
-void
-LayerTree::clear_selected_layers()
-{
-       get_layer_tree_view().get_selection()->unselect_all();
-}
-
-void
-LayerTree::set_show_timetrack(bool x)
-{
-       //column_time_track->set_visible(x);
-//     column_time_track->set_visible(false);
-       column_z_depth->set_visible(x);
-}
-
-void
-LayerTree::set_model(Glib::RefPtr<LayerTreeStore> layer_tree_store)
-{
-       layer_tree_store_=layer_tree_store;
-
-       if(false)
-       {
-               sorted_layer_tree_store_=Gtk::TreeModelSort::create(layer_tree_store);
-
-               sorted_layer_tree_store_->set_default_sort_func(sigc::ptr_fun(&studio::LayerTreeStore::z_sorter));
-
-               //sorted_store->set_sort_func(model.time.index(),sigc::mem_fun(&studio::KeyframeTreeStore::time_sorter));
-               //sorted_store->set_sort_column(model.time.index(), Gtk::SORT_ASCENDING);
-
-               get_layer_tree_view().set_model(sorted_layer_tree_store_);
-       }
-       else
-               get_layer_tree_view().set_model(layer_tree_store_);
-
-       layer_tree_store_->canvas_interface()->signal_dirty_preview().connect(sigc::mem_fun(*this,&studio::LayerTree::on_dirty_preview));
-
-       //layer_tree_store_->canvas_interface()->signal_dirty_preview().connect(sigc::mem_fun(*this,&studio::LayerTree::on_dirty_preview));
-
-       layer_tree_store_->canvas_interface()->signal_time_changed().connect(
-               sigc::mem_fun(
-                       &get_param_tree_view(),
-                       &Gtk::Widget::queue_draw
-               )
-       );
-       if(!param_tree_store_)
-       {
-               param_tree_store_=LayerParamTreeStore::create(layer_tree_store_->canvas_interface(), this);
-               get_param_tree_view().set_model(param_tree_store_);
-       }
-
-#ifdef TIMETRACK_IN_PARAMS_PANEL
-       if(cellrenderer_time_track && layer_tree_store_ && layer_tree_store_->canvas_interface())
-               cellrenderer_time_track->set_canvas_interface(layer_tree_store_->canvas_interface());
-#endif // TIMETRACK_IN_PARAMS_PANEL
-}
-
-void
-LayerTree::set_time_adjustment(Gtk::Adjustment &adjustment)
-{
-#ifdef TIMETRACK_IN_PARAMS_PANEL
-       cellrenderer_time_track->set_adjustment(adjustment);
-#endif // TIMETRACK_IN_PARAMS_PANEL
-       adjustment.signal_value_changed().connect(sigc::mem_fun(get_param_tree_view(),&Gtk::TreeView::queue_draw));
-       adjustment.signal_changed().connect(sigc::mem_fun(get_param_tree_view(),&Gtk::TreeView::queue_draw));
-}
-
-void
-LayerTree::on_dirty_preview()
-{
-/*
-       if(quick_layer && !disable_amount_changed_signal)
-       {
-               layer_amount_hscale->set_sensitive(true);
-               disable_amount_changed_signal=true;
-               layer_amount_adjustment_.set_value(quick_layer->get_param("amount").get(Real()));
-               disable_amount_changed_signal=false;
-               if(quick_layer->get_param("blend_method").is_valid())
-               {
-                       blend_method_widget.set_sensitive(true);
-                       disable_amount_changed_signal=true;
-                       blend_method_widget.set_value(quick_layer->get_param("blend_method"));
-                       disable_amount_changed_signal=false;
-               }
-       }
-*/
-}
-
-void
-LayerTree::on_selection_changed()
-{
-       synfigapp::SelectionManager::LayerList layer_list(get_selection_manager()->get_selected_layers());
-
-       Gtk::TreeIter iter;
-       if(last_top_selected_layer && !layer_tree_store_->find_layer_row(last_top_selected_layer,iter))
-       {
-               if(layer_list.empty())
-               {
-                       last_top_selected_layer=0;
-                       layer_tree_view_->get_selection()->select(last_top_selected_path);
-                       return;
-               }
-       }
-
-       {
-               if(!layer_list.empty())
-               {
-                       last_top_selected_layer=layer_list.front();
-                       last_top_selected_path=*layer_tree_view_->get_selection()->get_selected_rows().begin();
-               }
-               else
-               {
-                       last_top_selected_layer=0;
-               }
-       }
-
-       if(layer_list.empty())
-       {
-               button_raise->set_sensitive(false);
-               button_lower->set_sensitive(false);
-               button_duplicate->set_sensitive(false);
-               button_encapsulate->set_sensitive(false);
-               button_delete->set_sensitive(false);
-               layer_amount_hscale->set_sensitive(false);
-               blend_method_widget.set_sensitive(false);
-               return;
-       }
-
-       button_raise->set_sensitive(true);
-       button_lower->set_sensitive(true);
-       button_duplicate->set_sensitive(true);
-       button_encapsulate->set_sensitive(true);
-       button_delete->set_sensitive(true);
-
-       if(layer_list.size()==1 && (*layer_list.begin())->get_param("amount").is_valid()&& (*layer_list.begin())->get_param("amount").same_type_as(Real()))
-       {
-               quick_layer=*layer_list.begin();
-       }
-       else
-               quick_layer=0;
-
-       if(quick_layer)
-       {
-               layer_amount_hscale->set_sensitive(true);
-               disable_amount_changed_signal=true;
-               layer_amount_adjustment_.set_value(quick_layer->get_param("amount").get(Real()));
-               disable_amount_changed_signal=false;
-               if(quick_layer->get_param("blend_method").is_valid())
-               {
-                       blend_method_widget.set_sensitive(true);
-                       disable_amount_changed_signal=true;
-                       blend_method_widget.set_value(quick_layer->get_param("blend_method"));
-                       disable_amount_changed_signal=false;
-               }
-               else
-                       blend_method_widget.set_sensitive(false);
-       }
-       else
-       {
-               layer_amount_hscale->set_sensitive(false);
-               blend_method_widget.set_sensitive(false);
-       }
-}
-
-void
-LayerTree::on_blend_method_changed()
-{
-       if(disable_amount_changed_signal)
-               return;
-       if(!quick_layer)
-               return;
-
-       if(quick_layer->get_param("blend_method").is_valid())
-       {
-               disable_amount_changed_signal=true;
-               signal_edited_value()(synfigapp::ValueDesc(quick_layer,"blend_method"),blend_method_widget.get_value());
-               disable_amount_changed_signal=false;
-       }
-}
-
-void
-LayerTree::on_amount_value_changed()
-{
-       if(disable_amount_changed_signal)
-               return;
-       if(!quick_layer)
-               return;
-
-       disable_amount_changed_signal=true;
-       signal_edited_value()(synfigapp::ValueDesc(quick_layer,"amount"),synfig::ValueBase(layer_amount_adjustment_.get_value()));
-       disable_amount_changed_signal=false;
-}
-
-void
-LayerTree::on_edited_value(const Glib::ustring&path_string,synfig::ValueBase value)
-{
-       Gtk::TreePath path(path_string);
-
-       const Gtk::TreeRow row = *(get_param_tree_view().get_model()->get_iter(path));
-       if(!row)
-               return;
-       row[param_model.value]=value;
-       //signal_edited_value()(row[param_model.value_desc],value);
-}
-
-void
-LayerTree::on_layer_renamed(const Glib::ustring&path_string,const Glib::ustring& value)
-{
-       Gtk::TreePath path(path_string);
-
-       const Gtk::TreeRow row = *(get_layer_tree_view().get_model()->get_iter(path));
-       if(!row)
-               return;
-       row[layer_model.label]=value;
-       get_layer_tree_view().columns_autosize();
-}
-
-void
-LayerTree::on_layer_toggle(const Glib::ustring& path_string)
-{
-       Gtk::TreePath path(path_string);
-
-       const Gtk::TreeRow row = *(get_layer_tree_view().get_model()->get_iter(path));
-       bool active=static_cast<bool>(row[layer_model.active]);
-       row[layer_model.active]=!active;
-}
-
-#ifdef TIMETRACK_IN_PARAMS_PANEL
-void
-LayerTree::on_waypoint_clicked_layertree(const etl::handle<synfig::Node>& node __attribute__ ((unused)),
-                                                                                const synfig::Time& time __attribute__ ((unused)),
-                                                                                const synfig::Time& time_offset __attribute__ ((unused)),
-                                                                                int button __attribute__ ((unused)))
-{
-       std::set<synfig::Waypoint, std::less<UniqueID> > waypoint_set;
-       synfig::waypoint_collect(waypoint_set,time,node);
-
-       synfigapp::ValueDesc value_desc;
-
-       if (waypoint_set.size() == 1)
-       {
-               ValueNode::Handle value_node(waypoint_set.begin()->get_parent_value_node());
-               assert(value_node);
-
-               Gtk::TreeRow row;
-               if (param_tree_store_->find_first_value_node(value_node, row) && row)
-                       value_desc = static_cast<synfigapp::ValueDesc>(row[param_tree_store_->model.value_desc]);
-       }
-
-       if (!waypoint_set.empty())
-               signal_waypoint_clicked_layertree()(value_desc,waypoint_set,button);
-}
-#endif // TIMETRACK_IN_PARAMS_PANEL
-
-bool
-LayerTree::on_layer_tree_event(GdkEvent *event)
-{
-    switch(event->type)
-    {
-       case GDK_BUTTON_PRESS:
-               {
-                       Gtk::TreeModel::Path path;
-                       Gtk::TreeViewColumn *column;
-                       int cell_x, cell_y;
-                       if(!get_layer_tree_view().get_path_at_pos(
-                               int(event->button.x),int(event->button.y),      // x, y
-                               path, // TreeModel::Path&
-                               column, //TreeViewColumn*&
-                               cell_x,cell_y //int&cell_x,int&cell_y
-                               )
-                       ) break;
-                       const Gtk::TreeRow row = *(get_layer_tree_view().get_model()->get_iter(path));
-
-#ifdef TIMETRACK_IN_PARAMS_PANEL
-                       if(column->get_first_cell_renderer()==cellrenderer_time_track)
-                               return signal_layer_user_click()(event->button.button,row,COLUMNID_TIME_TRACK);
-                       else
-#endif // TIMETRACK_IN_PARAMS_PANEL
-                       if(column->get_first_cell_renderer()==cellrenderer_value)
-                               return signal_layer_user_click()(event->button.button,row,COLUMNID_VALUE);
-                       else
-                               return signal_layer_user_click()(event->button.button,row,COLUMNID_NAME);
-
-               }
-               break;
-
-       case GDK_MOTION_NOTIFY:
-               {
-                       Gtk::TreeModel::Path path;
-                       Gtk::TreeViewColumn *column;
-                       int cell_x, cell_y;
-                       if(!get_layer_tree_view().get_path_at_pos(
-                               (int)event->button.x,(int)event->button.y,      // x, y
-                               path, // TreeModel::Path&
-                               column, //TreeViewColumn*&
-                               cell_x,cell_y //int&cell_x,int&cell_y
-                               )
-                       ) break;
-
-                       if(!get_layer_tree_view().get_model()->get_iter(path))
-                               break;
-
-                       Gtk::TreeRow row = *(get_layer_tree_view().get_model()->get_iter(path));
-
-#ifdef TIMETRACK_IN_PARAMS_PANEL
-                       if(cellrenderer_time_track==column->get_first_cell_renderer())
-                               // Movement on TimeLine
-                               return true;
-                       else
-#endif // TIMETRACK_IN_PARAMS_PANEL
-                       if(last_tooltip_path.get_depth()<=0 || path!=last_tooltip_path)
-                       {
-                               tooltips_.unset_tip(*this);
-                               Glib::ustring tooltips_string(row[layer_model.tooltip]);
-                               last_tooltip_path=path;
-                               if(!tooltips_string.empty())
-                               {
-                                       tooltips_.set_tip(*this,tooltips_string);
-                                       tooltips_.force_window();
-                               }
-                       }
-               }
-               break;
-       case GDK_BUTTON_RELEASE:
-               break;
-       default:
-               break;
-       }
-       return false;
-}
-
-bool
-LayerTree::on_param_tree_event(GdkEvent *event)
-{
-    switch(event->type)
-    {
-       case GDK_BUTTON_PRESS:
-               {
-                       Gtk::TreeModel::Path path;
-                       Gtk::TreeViewColumn *column;
-                       int cell_x, cell_y;
-                       if(!get_param_tree_view().get_path_at_pos(
-                               int(event->button.x),int(event->button.y),      // x, y
-                               path, // TreeModel::Path&
-                               column, //TreeViewColumn*&
-                               cell_x,cell_y //int&cell_x,int&cell_y
-                               )
-                       ) break;
-                       const Gtk::TreeRow row = *(get_param_tree_view().get_model()->get_iter(path));
-
-#ifdef TIMETRACK_IN_PARAMS_PANEL
-                       if(column && column->get_first_cell_renderer()==cellrenderer_time_track)
-                       {
-                               Gdk::Rectangle rect;
-                               get_param_tree_view().get_cell_area(path,*column,rect);
-                               cellrenderer_time_track->property_value_desc()=row[param_model.value_desc];
-                               cellrenderer_time_track->property_canvas()=row[param_model.canvas];
-                               cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
-                               get_param_tree_view().queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
-                               return true;
-                               //return signal_param_user_click()(event->button.button,row,COLUMNID_TIME_TRACK);
-                       }
-                       else
-#endif // TIMETRACK_IN_PARAMS_PANEL
-                       {
-                               if(event->button.button==3)
-                               {
-                                       LayerList layer_list(get_selected_layers());
-                                       if(layer_list.size()<=1)
-                                       {
-                                               synfigapp::ValueDesc value_desc(row[param_model.value_desc]);
-                                               Gtk::Menu* menu(manage(new Gtk::Menu()));
-                                               menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), menu));
-                                               App::get_instance(param_tree_store_->canvas_interface()->get_canvas())->make_param_menu(menu,param_tree_store_->canvas_interface()->get_canvas(),value_desc,0.5f);
-                                               menu->popup(event->button.button,gtk_get_current_event_time());
-                                               return true;
-                                       }
-                                       Gtk::Menu* menu(manage(new Gtk::Menu()));
-                                       menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), menu));
-                                       std::list<synfigapp::ValueDesc> value_desc_list;
-                                       ParamDesc param_desc(row[param_model.param_desc]);
-                                       for(;!layer_list.empty();layer_list.pop_back())
-                                               value_desc_list.push_back(synfigapp::ValueDesc(layer_list.back(),param_desc.get_name()));
-                                       App::get_instance(param_tree_store_->canvas_interface()->get_canvas())->make_param_menu(menu,param_tree_store_->canvas_interface()->get_canvas(),value_desc_list);
-                                       menu->popup(event->button.button,gtk_get_current_event_time());
-                                       return true;
-                               }
-                               else
-                               {
-                                       if(column->get_first_cell_renderer()==cellrenderer_value)
-                                               return signal_param_user_click()(event->button.button,row,COLUMNID_VALUE);
-                                       else
-                                               return signal_param_user_click()(event->button.button,row,COLUMNID_NAME);
-                               }
-                       }
-               }
-               break;
-
-       case GDK_MOTION_NOTIFY:
-               {
-                       Gtk::TreeModel::Path path;
-                       Gtk::TreeViewColumn *column;
-                       int cell_x, cell_y;
-                       if(!get_param_tree_view().get_path_at_pos(
-                               (int)event->motion.x,(int)event->motion.y,      // x, y
-                               path, // TreeModel::Path&
-                               column, //TreeViewColumn*&
-                               cell_x,cell_y //int&cell_x,int&cell_y
-                               )
-                       ) break;
-
-                       if(!get_param_tree_view().get_model()->get_iter(path))
-                               break;
-
-                       Gtk::TreeRow row = *(get_param_tree_view().get_model()->get_iter(path));
-
-#ifdef TIMETRACK_IN_PARAMS_PANEL
-                       if((event->motion.state&GDK_BUTTON1_MASK ||event->motion.state&GDK_BUTTON3_MASK) && column && cellrenderer_time_track==column->get_first_cell_renderer())
-                       {
-                               Gdk::Rectangle rect;
-                               get_param_tree_view().get_cell_area(path,*column,rect);
-                               cellrenderer_time_track->property_value_desc()=row[param_model.value_desc];
-                               cellrenderer_time_track->property_canvas()=row[param_model.canvas];
-                               cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
-                               get_param_tree_view().queue_draw();
-                               //get_param_tree_view().queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
-                               return true;
-                       }
-                       else
-#endif // TIMETRACK_IN_PARAMS_PANEL
-                       if(last_tooltip_path.get_depth()<=0 || path!=last_tooltip_path)
-                       {
-                               tooltips_.unset_tip(*this);
-                               Glib::ustring tooltips_string(row[layer_model.tooltip]);
-                               last_tooltip_path=path;
-                               if(!tooltips_string.empty())
-                               {
-                                       tooltips_.set_tip(*this,tooltips_string);
-                                       tooltips_.force_window();
-                               }
-                       }
-               }
-               break;
-       case GDK_BUTTON_RELEASE:
-               {
-                       Gtk::TreeModel::Path path;
-                       Gtk::TreeViewColumn *column;
-                       int cell_x, cell_y;
-                       if(!get_param_tree_view().get_path_at_pos(
-                               (int)event->button.x,(int)event->button.y,      // x, y
-                               path, // TreeModel::Path&
-                               column, //TreeViewColumn*&
-                               cell_x,cell_y //int&cell_x,int&cell_y
-                               )
-                       ) break;
-
-                       if(!get_param_tree_view().get_model()->get_iter(path))
-                               break;
-
-                       Gtk::TreeRow row = *(get_param_tree_view().get_model()->get_iter(path));
-
-#ifdef TIMETRACK_IN_PARAMS_PANEL
-                       if(column && cellrenderer_time_track==column->get_first_cell_renderer())
-                       {
-                               Gdk::Rectangle rect;
-                               get_param_tree_view().get_cell_area(path,*column,rect);
-                               cellrenderer_time_track->property_value_desc()=row[param_model.value_desc];
-                               cellrenderer_time_track->property_canvas()=row[param_model.canvas];
-                               cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
-                               get_param_tree_view().queue_draw();
-                               get_param_tree_view().queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
-                               return true;
-
-                       }
-#endif // TIMETRACK_IN_PARAMS_PANEL
-               }
-               break;
-       default:
-               break;
-       }
-       return false;
-}
-
-// void
-// LayerTree::on_raise_pressed()
-// {
-//     synfigapp::Action::ParamList param_list;
-//     param_list.add("time",layer_tree_store_->canvas_interface()->get_time());
-//     param_list.add("canvas",layer_tree_store_->canvas_interface()->get_canvas());
-//     param_list.add("canvas_interface",layer_tree_store_->canvas_interface());
-//
-//     {
-//             synfigapp::SelectionManager::LayerList layer_list(get_selection_manager()->get_selected_layers());
-//             synfigapp::SelectionManager::LayerList::iterator iter;
-//
-//             for(iter=layer_list.begin();iter!=layer_list.end();++iter)
-//                     param_list.add("layer",Layer::Handle(*iter));
-//     }
-//     synfigapp::Action::Handle action(synfigapp::Action::create("LayerRaise"));
-//     action->set_param_list(param_list);
-//     layer_tree_store_->canvas_interface()->get_instance()->perform_action(action);
-// }
-
-// void
-// LayerTree::on_lower_pressed()
-// {
-//     synfigapp::Action::ParamList param_list;
-//     param_list.add("time",layer_tree_store_->canvas_interface()->get_time());
-//     param_list.add("canvas",layer_tree_store_->canvas_interface()->get_canvas());
-//     param_list.add("canvas_interface",layer_tree_store_->canvas_interface());
-//
-//     {
-//             synfigapp::SelectionManager::LayerList layer_list(get_selection_manager()->get_selected_layers());
-//             synfigapp::SelectionManager::LayerList::iterator iter;
-//
-//             for(iter=layer_list.begin();iter!=layer_list.end();++iter)
-//                     param_list.add("layer",Layer::Handle(*iter));
-//     }
-//
-//     synfigapp::Action::Handle action(synfigapp::Action::create("LayerLower"));
-//     action->set_param_list(param_list);
-//     layer_tree_store_->canvas_interface()->get_instance()->perform_action(action);
-// }
-
-// void
-// LayerTree::on_duplicate_pressed()
-// {
-//     synfigapp::Action::ParamList param_list;
-//     param_list.add("time",layer_tree_store_->canvas_interface()->get_time());
-//     param_list.add("canvas",layer_tree_store_->canvas_interface()->get_canvas());
-//     param_list.add("canvas_interface",layer_tree_store_->canvas_interface());
-//
-//     {
-//             synfigapp::SelectionManager::LayerList layer_list(get_selection_manager()->get_selected_layers());
-//             synfigapp::SelectionManager::LayerList::iterator iter;
-//
-//             for(iter=layer_list.begin();iter!=layer_list.end();++iter)
-//                     param_list.add("layer",Layer::Handle(*iter));
-//     }
-//
-//     synfigapp::Action::Handle action(synfigapp::Action::create("LayerDuplicate"));
-//     action->set_param_list(param_list);
-//     layer_tree_store_->canvas_interface()->get_instance()->perform_action(action);
-// }
-
-// void
-// LayerTree::on_encapsulate_pressed()
-// {
-//     synfigapp::Action::ParamList param_list;
-//     param_list.add("time",layer_tree_store_->canvas_interface()->get_time());
-//     param_list.add("canvas",layer_tree_store_->canvas_interface()->get_canvas());
-//     param_list.add("canvas_interface",layer_tree_store_->canvas_interface());
-//
-//     {
-//             synfigapp::SelectionManager::LayerList layer_list(get_selection_manager()->get_selected_layers());
-//             synfigapp::SelectionManager::LayerList::iterator iter;
-//
-//             for(iter=layer_list.begin();iter!=layer_list.end();++iter)
-//                     param_list.add("layer",Layer::Handle(*iter));
-//     }
-//
-//     synfigapp::Action::Handle action(synfigapp::Action::create("LayerEncapsulate"));
-//     action->set_param_list(param_list);
-//     layer_tree_store_->canvas_interface()->get_instance()->perform_action(action);
-// }
-
-// void
-// LayerTree::on_delete_pressed()
-// {
-//     synfigapp::Action::ParamList param_list;
-//     param_list.add("time",layer_tree_store_->canvas_interface()->get_time());
-//     param_list.add("canvas",layer_tree_store_->canvas_interface()->get_canvas());
-//     param_list.add("canvas_interface",layer_tree_store_->canvas_interface());
-//
-//     {
-//             synfigapp::SelectionManager::LayerList layer_list(get_selection_manager()->get_selected_layers());
-//             synfigapp::SelectionManager::LayerList::iterator iter;
-//
-//             for(iter=layer_list.begin();iter!=layer_list.end();++iter)
-//                     param_list.add("layer",Layer::Handle(*iter));
-//     }
-//
-//     synfigapp::Action::Handle action(synfigapp::Action::create("LayerRemove"));
-//     action->set_param_list(param_list);
-//     layer_tree_store_->canvas_interface()->get_instance()->perform_action(action);
-// }
-
-/*
-void
-LayerTree::on_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&context, Gtk::SelectionData& selection_data, guint info, guint time)
-{
-       synfig::info("Dragged data of type \"%s\"",selection_data.get_data_type());
-       synfig::info("Dragged data of target \"%s\"",gdk_atom_name(selection_data->target));
-       synfig::info("Dragged selection=\"%s\"",gdk_atom_name(selection_data->selection));
-
-       Gtk::TreeModel::Path path;
-       Gtk::TreeViewColumn *column;
-       int cell_x, cell_y;
-       if(get_selection()
-       Gtk::TreeRow row = *(get_selection()->get_selected());
-
-       if(synfig::String(gdk_atom_name(selection_data->target))=="LAYER" && (bool)row[model.is_layer])
-       {
-               Layer* layer(((Layer::Handle)row[model.layer]).get());
-               assert(layer);
-               selection_data.set(8, reinterpret_cast<const guchar*>(&layer), sizeof(layer));
-               return;
-       }
-}
-
-void
-LayerTree::on_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, Gtk::SelectionData& selection_data, guint info, guint time)
-{
-       synfig::info("Dropped data of type \"%s\"",selection_data.get_data_type());
-       synfig::info("Dropped data of target \"%s\"",gdk_atom_name(selection_data->target));
-       synfig::info("Dropped selection=\"%s\"",gdk_atom_name(selection_data->selection));
-       synfig::info("Dropped x=%d, y=%d",x,y);
-       bool success=false;
-       bool dropped_on_specific_row=false;
-
-       Gtk::TreeModel::Path path;
-       Gtk::TreeViewColumn *column;
-       int cell_x, cell_y;
-       if(!get_path_at_pos(
-               x,y,    // x, y
-               path, // TreeModel::Path&
-               column, //TreeViewColumn*&
-               cell_x,cell_y //int&cell_x,int&cell_y
-               )
-       )
-       {
-               dropped_on_specific_row=false;
-       }
-       else
-               dropped_on_specific_row=true;
-
-       Gtk::TreeRow row = *(get_model()->get_iter(path));
-
-       if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
-       {
-               if(synfig::String(selection_data.get_data_type())=="LAYER")do
-               {
-                       Layer::Handle src(*reinterpret_cast<Layer**>(selection_data.get_data()));
-                       assert(src);
-
-                       Canvas::Handle dest_canvas;
-                       Layer::Handle dest_layer;
-
-                       if(dropped_on_specific_row)
-                       {
-                               dest_canvas=(Canvas::Handle)(row[model.canvas]);
-                               dest_layer=(Layer::Handle)(row[model.layer]);
-                               assert(dest_canvas);
-                       }
-                       else
-                               dest_canvas=layer_tree_store_->canvas_interface()->get_canvas();
-
-                       // In this case, we are just moving.
-                       if(dest_canvas==src->get_canvas())
-                       {
-                               if(!dest_layer || dest_layer==src)
-                                       break;
-
-                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerMove"));
-                               action->set_param("canvas",dest_canvas);
-                               action->set_param("canvas_interface",layer_tree_store_->canvas_interface());
-                               action->set_param("layer",src);
-                               action->set_param("new_index",dest_canvas->get_depth(dest_layer));
-                               if(layer_tree_store_->canvas_interface()->get_instance()->perform_action(action))
-                                       success=true;
-                               else
-                                       success=false;
-                               break;
-                       }
-               }while(0);
-       }
-
-       // Finish the drag
-       context->drag_finish(success, false, time);
-}
-*/
-
-/*bool
-LayerTree::on_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context,int x, int    y, guint    time)
-{
-       return get_layer_tree_view().on_drag_motion(context,x,y,time);
-}
-
-void
-LayerTree::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, Gtk::SelectionData& selection_data, guint info, guint time)
-{
-       get_layer_tree_view().on_drag_data_received(context,x,y,selection_data,info,time);
-*/
-/*
-       if(context->gobj()->source_window==context->gobj()->dest_window)
-       {
-               Gtk::TreeView::on_drag_data_received(context,x,y,selection_data,info,time);
-               return;
-       }
-
-       Gtk::TreeModel::Path path;
-       Gtk::TreeViewColumn *column;
-       int cell_x, cell_y;
-       if(!get_path_at_pos(
-               x,y,    // x, y
-               path, // TreeModel::Path&
-               column, //TreeViewColumn*&
-               cell_x,cell_y //int&cell_x,int&cell_y
-               )
-       )
-       {
-               context->drag_finish(false, false, time);
-       }
-
-       if(layer_tree_store_->row_drop_possible(path,selection_data))
-       {
-               if(layer_tree_store_->drag_data_received(path,selection_data))
-                       context->drag_finish(true, false, time);
-       }
-       context->drag_finish(false, false, time);
-}
-*/
diff --git a/synfig-studio/src/gtkmm/layertree.h b/synfig-studio/src/gtkmm/layertree.h
deleted file mode 100644 (file)
index 97b2d27..0000000
+++ /dev/null
@@ -1,261 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file layertree.h
-**     \brief Template Header
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === S T A R T =========================================================== */
-
-#ifndef __SYNFIG_STUDIO_LAYERTREE_H
-#define __SYNFIG_STUDIO_LAYERTREE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/treeview.h>
-#include <gtkmm/treestore.h>
-#include <gtkmm/tooltips.h>
-#include <gtkmm/table.h>
-#include <gtkmm/box.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/scale.h>
-#include <gtkmm/button.h>
-
-#include <synfigapp/canvasinterface.h>
-#include <synfigapp/value_desc.h>
-#include "layertreestore.h"
-#include "layerparamtreestore.h"
-#include <synfig/valuenode_animated.h>
-
-#include "widget_value.h"
-
-/* === M A C R O S ========================================================= */
-
-// comment this out if you don't want the params dialog to have a 'timetrack' column
-// (alternatively, export SYNFIG_DISABLE_PARAMS_PANEL_TIMETRACK=1 in environment at runtime)
-#define TIMETRACK_IN_PARAMS_PANEL
-
-/* === T Y P E D E F S ===================================================== */
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-namespace Gtk { class TreeModelSort; };
-
-namespace studio {
-
-class CellRenderer_TimeTrack;
-class CellRenderer_ValueBase;
-
-class LayerTree : public Gtk::Table
-{
-       /*
- -- ** -- P U B L I C   T Y P E S ---------------------------------------------
-       */
-
-public:
-
-       typedef studio::ColumnID ColumnID;
-/*     enum ColumnID
-       {
-               COLUMNID_NAME,
-               COLUMNID_VALUE,
-               COLUMNID_TIME_TRACK,
-
-               COLUMNID_END                    //!< \internal
-       };
-*/
-       typedef std::list<synfig::Layer::Handle> LayerList;
-
-       /*
- -- ** -- P U B L I C  D A T A ------------------------------------------------
-       */
-
-public:
-
-       //LayerTreeStore::Model model;
-
-       LayerTreeStore::Model layer_model;
-       LayerParamTreeStore::Model param_model;
-
-       synfig::Layer::Handle last_top_selected_layer;
-       Gtk::TreePath last_top_selected_path;
-
-       /*
- -- ** -- P R I V A T E   D A T A ---------------------------------------------
-       */
-
-private:
-
-       Gtk::Tooltips tooltips_;
-       Gtk::TreePath last_tooltip_path;
-
-       Gtk::TreeView* layer_tree_view_;
-
-       Gtk::TreeView* param_tree_view_;
-
-       Gtk::HBox *hbox;
-
-       Gtk::Adjustment layer_amount_adjustment_;
-
-       Gtk::HScale *layer_amount_hscale;
-
-       synfig::Layer::Handle quick_layer;
-
-       Glib::RefPtr<LayerTreeStore> layer_tree_store_;
-
-       Glib::RefPtr<LayerParamTreeStore> param_tree_store_;
-
-       Glib::RefPtr<Gtk::TreeModelSort> sorted_layer_tree_store_;
-
-#ifdef TIMETRACK_IN_PARAMS_PANEL
-       CellRenderer_TimeTrack *cellrenderer_time_track;
-#endif // TIMETRACK_IN_PARAMS_PANEL
-
-       Gtk::TreeView::Column* column_time_track;
-
-       Gtk::TreeView::Column* column_z_depth;
-
-       CellRenderer_ValueBase *cellrenderer_value;
-
-       sigc::signal<void,synfig::Layer::Handle> signal_layer_toggle_;
-
-       sigc::signal<void,synfigapp::ValueDesc,synfig::ValueBase> signal_edited_value_;
-
-       sigc::signal<bool, int, Gtk::TreeRow, ColumnID> signal_layer_user_click_;
-
-       sigc::signal<bool, int, Gtk::TreeRow, ColumnID> signal_param_user_click_;
-
-       sigc::signal<void,synfigapp::ValueDesc,std::set<synfig::Waypoint,std::less<synfig::UniqueID> >,int> signal_waypoint_clicked_layertree_;
-
-       bool disable_amount_changed_signal;
-
-       Gtk::Button *button_raise;
-       Gtk::Button *button_lower;
-       Gtk::Button *button_duplicate;
-       Gtk::Button *button_encapsulate;
-       Gtk::Button *button_delete;
-
-       Widget_ValueBase blend_method_widget;
-
-       /*
- -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
-       */
-
-private:
-
-       Gtk::Widget* create_layer_tree();
-       Gtk::Widget* create_param_tree();
-
-       /*
- -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
-       */
-
-private:
-
-       void on_edited_value(const Glib::ustring&path_string,synfig::ValueBase value);
-
-       void on_layer_renamed(const Glib::ustring&path_string,const Glib::ustring& value);
-
-       void on_layer_toggle(const Glib::ustring& path_string);
-
-       void on_waypoint_clicked_layertree(const etl::handle<synfig::Node>& node, const synfig::Time&, const synfig::Time&, int button);
-
-       void on_waypoint_changed( synfig::Waypoint waypoint , synfig::ValueNode::Handle value_node);
-
-       bool on_layer_tree_event(GdkEvent *event);
-
-       bool on_param_tree_event(GdkEvent *event);
-
-       void on_selection_changed();
-
-       void on_dirty_preview();
-
-       void on_amount_value_changed();
-
-       void on_blend_method_changed();
-
-public:
-
-       // void on_raise_pressed();
-
-       // void on_lower_pressed();
-
-       // void on_duplicate_pressed();
-
-       // void on_encapsulate_pressed();
-
-       // void on_delete_pressed();
-
-       /*
- -- ** -- P U B L I C   M E T H O D S -----------------------------------------
-       */
-
-public:
-
-       //Gtk::TreeView* get_param_tree_view() { return param_tree_view_; }
-       //Gtk::TreeView& param_tree_view() { return *param_tree_view_; }
-       Gtk::HBox& get_hbox() { return *hbox; }
-
-       Gtk::TreeView& get_layer_tree_view() { return *layer_tree_view_; }
-       Gtk::TreeView& get_param_tree_view() { return *param_tree_view_; }
-
-       const Gtk::TreeView& get_layer_tree_view()const { return *layer_tree_view_; }
-       const Gtk::TreeView& get_param_tree_view()const { return *param_tree_view_; }
-
-       Glib::RefPtr<Gtk::TreeSelection> get_selection() { return get_layer_tree_view().get_selection(); }
-       Glib::SignalProxy1< bool,GdkEvent* >  signal_event () { return get_layer_tree_view().signal_event(); }
-
-       LayerTree();
-       ~LayerTree();
-
-       void set_model(Glib::RefPtr<LayerTreeStore> layer_tree_store_);
-
-       void set_time_adjustment(Gtk::Adjustment &adjustment);
-
-       void set_show_timetrack(bool x=true);
-
-       //! Signal called when layer is toggled.
-       sigc::signal<void,synfig::Layer::Handle>& signal_layer_toggle() { return signal_layer_toggle_; }
-
-       //! Signal called with a value has been edited.
-       sigc::signal<void,synfigapp::ValueDesc,synfig::ValueBase>& signal_edited_value() { return signal_edited_value_; }
-
-       sigc::signal<bool,int, Gtk::TreeRow, ColumnID>& signal_layer_user_click() { return signal_layer_user_click_; }
-
-       sigc::signal<bool,int, Gtk::TreeRow, ColumnID>& signal_param_user_click() { return signal_param_user_click_; }
-
-       sigc::signal<void,synfigapp::ValueDesc,std::set<synfig::Waypoint,std::less<synfig::UniqueID> >,int>& signal_waypoint_clicked_layertree() { return signal_waypoint_clicked_layertree_; }
-
-       etl::handle<synfigapp::SelectionManager> get_selection_manager() { return layer_tree_store_->canvas_interface()->get_selection_manager(); }
-
-       void select_layer(synfig::Layer::Handle layer);
-       void select_layers(const LayerList& layer_list);
-       void select_all_children_layers(synfig::Layer::Handle layer);
-       void select_all_children(Gtk::TreeModel::Children::iterator iter);
-       LayerList get_selected_layers()const;
-       synfig::Layer::Handle get_selected_layer()const;
-       void clear_selected_layers();
-
-}; // END of LayerTree
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/layertreestore.cpp b/synfig-studio/src/gtkmm/layertreestore.cpp
deleted file mode 100644 (file)
index 16b7fc8..0000000
+++ /dev/null
@@ -1,1081 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file layertreestore.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 <config.h>
-#endif
-
-#include "layertreestore.h"
-#include "iconcontroller.h"
-#include <gtkmm/button.h>
-#include <synfig/paramdesc.h>
-#include <synfigapp/action.h>
-#include <synfigapp/instance.h>
-#include "app.h"
-#include "instance.h"
-#include <synfig/layer_pastecanvas.h>
-#include <synfigapp/action_system.h>
-
-#include <gtk/gtkversion.h>
-#include <ETL/clock>
-#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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-static LayerTreeStore::Model& ModelHack()
-{
-       static LayerTreeStore::Model* model(0);
-       if(!model)model=new LayerTreeStore::Model;
-       return *model;
-}
-
-LayerTreeStore::LayerTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_):
-       Gtk::TreeStore                  (ModelHack()),
-       queued                                  (false),
-       canvas_interface_               (canvas_interface_)
-{
-       layer_icon=Gtk::Button().render_icon(Gtk::StockID("synfig-layer"),Gtk::ICON_SIZE_SMALL_TOOLBAR);
-
-       // Connect Signals to Terminals
-       canvas_interface()->signal_layer_status_changed().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_status_changed));
-       canvas_interface()->signal_layer_lowered().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_lowered));
-       canvas_interface()->signal_layer_raised().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_raised));
-       canvas_interface()->signal_layer_removed().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_removed));
-       canvas_interface()->signal_layer_inserted().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_inserted));
-       canvas_interface()->signal_layer_moved().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_moved));
-       //canvas_interface()->signal_layer_param_changed().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_param_changed));
-       canvas_interface()->signal_layer_new_description().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_new_description));
-
-       canvas_interface()->signal_time_changed().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::refresh));
-
-       //canvas_interface()->signal_value_node_changed().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_value_node_changed));
-       //canvas_interface()->signal_value_node_added().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_value_node_added));
-       //canvas_interface()->signal_value_node_deleted().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_value_node_deleted));
-       //canvas_interface()->signal_value_node_replaced().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_value_node_replaced));
-
-       set_default_sort_func(sigc::ptr_fun(index_sorter));
-
-//     rebuild();
-}
-
-LayerTreeStore::~LayerTreeStore()
-{
-       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
-               synfig::info("LayerTreeStore::~LayerTreeStore(): Deleted");
-}
-
-int
-LayerTreeStore::z_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs)
-{
-       const Model model;
-
-       float diff((float)(*rhs)[model.z_depth]-(float)(*lhs)[model.z_depth]);
-
-       if(diff<0)
-               return -1;
-       if(diff>0)
-               return 1;
-       return 0;
-}
-
-int
-LayerTreeStore::index_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs)
-{
-       const Model model;
-
-       return ((int)(*rhs)[model.index]-(int)(*lhs)[model.index]);
-}
-
-bool
-LayerTreeStore::search_func(const Glib::RefPtr<TreeModel>&,int,const Glib::ustring& x,const TreeModel::iterator& iter)
-{
-       const Model model;
-
-       Glib::ustring substr(x.uppercase());
-       Glib::ustring label((*iter)[model.label]);
-       label=label.uppercase();
-
-       return label.find(substr)==Glib::ustring::npos;
-}
-
-
-Glib::RefPtr<LayerTreeStore>
-LayerTreeStore::create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_)
-{
-       return Glib::RefPtr<LayerTreeStore>(new LayerTreeStore(canvas_interface_));
-}
-
-void
-LayerTreeStore::get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const
-{
-       if(column==model.index.index())
-       {
-               synfig::Layer::Handle layer((*iter)[model.layer]);
-
-               if(!layer)return;
-
-               Glib::Value<int> x;
-               g_value_init(x.gobj(),x.value_type());
-
-               x.set(layer->get_depth());
-
-               g_value_init(value.gobj(),x.value_type());
-               g_value_copy(x.gobj(),value.gobj());
-       }
-       else if(column==model.z_depth.index())
-       {
-               synfig::Layer::Handle layer((*iter)[model.layer]);
-
-               if(!layer)return;
-
-               Glib::Value<float> x;
-               g_value_init(x.gobj(),x.value_type());
-
-               x.set(layer->get_z_depth(canvas_interface()->get_time())*1.0001+layer->get_depth());
-
-               g_value_init(value.gobj(),x.value_type());
-               g_value_copy(x.gobj(),value.gobj());
-       }
-       else if(column==model.children_lock.index())
-       {
-               synfig::Layer::Handle layer((*iter)[model.layer]);
-
-               if(!layer)return;
-
-               Glib::Value<bool> x;
-               g_value_init(x.gobj(),x.value_type());
-               x.set(false);
-
-               ValueBase v(layer->get_param("children_lock"));
-               if(v.same_type_as(bool()))
-                       x.set(v.get(bool()));
-
-               g_value_init(value.gobj(),x.value_type());
-               g_value_copy(x.gobj(),value.gobj());
-       }
-       else if(column==model.label.index())
-       {
-               synfig::Layer::Handle layer((*iter)[model.layer]);
-
-               if(!layer)return;
-
-               Glib::Value<Glib::ustring> x;
-               g_value_init(x.gobj(),x.value_type());
-
-               x.set(layer->get_non_empty_description());
-
-               g_value_init(value.gobj(),x.value_type());
-               //g_value_copy(x.gobj(),value.gobj());
-               value=x;
-       }
-       else if(column==model.tooltip.index())
-       {
-               synfig::Layer::Handle layer((*iter)[model.layer]);
-
-               if(!layer)return;
-
-               Glib::Value<Glib::ustring> x;
-               g_value_init(x.gobj(),x.value_type());
-
-
-               x.set(layer->get_local_name());
-
-               g_value_init(value.gobj(),x.value_type());
-               //g_value_copy(x.gobj(),value.gobj());
-               value=x;
-       }
-       else if(column==model.canvas.index())
-       {
-               synfig::Layer::Handle layer((*iter)[model.layer]);
-
-               if(!layer)return;
-
-               Glib::Value<Canvas::Handle> x;
-               g_value_init(x.gobj(),x.value_type());
-
-
-               x.set(layer->get_canvas());
-
-               g_value_init(value.gobj(),x.value_type());
-               //g_value_copy(x.gobj(),value.gobj());
-               value=x;
-       }
-       else if(column==model.active.index())
-       {
-               synfig::Layer::Handle layer((*iter)[model.layer]);
-
-               if(!layer)return;
-
-               Glib::Value<bool> x;
-               g_value_init(x.gobj(),x.value_type());
-
-               x.set(layer->active());
-
-               g_value_init(value.gobj(),x.value_type());
-               g_value_copy(x.gobj(),value.gobj());
-       }
-       else if(column==model.icon.index())
-       {
-               synfig::Layer::Handle layer((*iter)[model.layer]);
-               if(!layer)return;
-
-               Glib::Value<Glib::RefPtr<Gdk::Pixbuf> > x;
-               g_value_init(x.gobj(),x.value_type());
-
-               //x.set(layer_icon);
-               x.set(get_tree_pixbuf_layer(layer->get_name()));
-
-               g_value_init(value.gobj(),x.value_type());
-               g_value_copy(x.gobj(),value.gobj());
-       }
-       else
-               Gtk::TreeStore::get_value_vfunc(iter,column,value);
-}
-
-void
-LayerTreeStore::set_value_impl(const Gtk::TreeModel::iterator& iter, int column, const Glib::ValueBase& value)
-{
-       //if(!iterator_sane(row))
-       //      return;
-
-       if(column>=get_n_columns_vfunc())
-       {
-               g_warning("LayerTreeStore::set_value_impl: Bad column (%d)",column);
-               return;
-       }
-
-       if(!g_value_type_compatible(G_VALUE_TYPE(value.gobj()),get_column_type_vfunc(column)))
-       {
-               g_warning("LayerTreeStore::set_value_impl: Bad value type");
-               return;
-       }
-
-       try
-       {
-               if(column==model.label.index())
-               {
-                       Glib::Value<Glib::ustring> x;
-                       g_value_init(x.gobj(),model.label.type());
-                       g_value_copy(value.gobj(),x.gobj());
-
-                       synfig::Layer::Handle layer((*iter)[model.layer]);
-                       if(!layer)
-                               return;
-                       synfig::String new_desc(x.get());
-
-                       if(new_desc==layer->get_local_name())
-                               new_desc=synfig::String();
-
-                       if(new_desc==layer->get_description())
-                               return;
-
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerSetDesc"));
-
-                       if(!action)
-                               return;
-
-                       action->set_param("canvas",canvas_interface()->get_canvas());
-                       action->set_param("canvas_interface",canvas_interface());
-                       action->set_param("layer",layer);
-                       action->set_param("new_description",synfig::String(x.get()));
-
-                       canvas_interface()->get_instance()->perform_action(action);
-                       return;
-               }
-               else if(column==model.active.index())
-               {
-                       synfig::Layer::Handle layer((*iter)[model.layer]);
-
-                       if(!layer)return;
-
-                       Glib::Value<bool> x;
-                       g_value_init(x.gobj(),model.active.type());
-                       g_value_copy(value.gobj(),x.gobj());
-
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerActivate"));
-
-                       if(!action)
-                               return;
-
-                       action->set_param("canvas",canvas_interface()->get_canvas());
-                       action->set_param("canvas_interface",canvas_interface());
-                       action->set_param("layer",layer);
-                       action->set_param("new_status",bool(x.get()));
-
-                       canvas_interface()->get_instance()->perform_action(action);
-                       return;
-               }
-               else
-                       Gtk::TreeStore::set_value_impl(iter,column, value);
-
-       }
-       catch(std::exception x)
-       {
-               g_warning("%s", x.what());
-       }
-}
-
-
-
-
-bool
-LayerTreeStore::row_draggable_vfunc (const TreeModel::Path& /*path*/)const
-{
-       //if(!get_iter(path)) return false;
-//     Gtk::TreeModel::Row row(*get_iter(path));
-
-       return true;
-//     return (bool)true;
-}
-
-bool
-LayerTreeStore::drag_data_get_vfunc (const TreeModel::Path& path, Gtk::SelectionData& selection_data)const
-{
-       if(!const_cast<LayerTreeStore*>(this)->get_iter(path)) return false;
-       //synfig::info("Dragged data of type \"%s\"",selection_data.get_data_type());
-       //synfig::info("Dragged data of target \"%s\"",gdk_atom_name(selection_data->target));
-       //synfig::info("Dragged selection=\"%s\"",gdk_atom_name(selection_data->selection));
-
-       Gtk::TreeModel::Row row(*const_cast<LayerTreeStore*>(this)->get_iter(path));
-
-       if((bool)true)
-       {
-               Layer* layer(((Layer::Handle)row[model.layer]).get());
-               assert(layer);
-               bool included(false);
-
-               //gtk_selection_data_set (selection_data, gdk_atom_intern("LAYER",false), 8, reinterpret_cast<const guchar*>(&layer), sizeof(layer));
-
-               std::vector<Layer*> layers;
-               // The following is a hack for multiple row DND
-               {
-                       synfigapp::SelectionManager::LayerList bleh(get_canvas_interface()->get_selection_manager()->get_selected_layers());
-                       if(bleh.empty())
-                       {
-                               selection_data.set("LAYER", 8, reinterpret_cast<const guchar*>(&layer), sizeof(layer));
-                               return true;
-                       }
-                       while(!bleh.empty())
-                       {
-                               if(bleh.back().get()==layer)
-                                       included=true;
-                               layers.push_back(bleh.back().get());
-                               bleh.pop_back();
-                       }
-               }
-               if(!included)
-                       layers.push_back(layer);
-               selection_data.set("LAYER", 8, reinterpret_cast<const guchar*>(&layers.front()), sizeof(void*)*layers.size());
-
-               return true;
-       }
-       return false;
-}
-
-bool
-LayerTreeStore::drag_data_delete_vfunc (const TreeModel::Path& /*path*/)
-{
-       return true;
-}
-
-bool
-LayerTreeStore::row_drop_possible_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)const
-{
-       //if(!const_cast<LayerTreeStore*>(this)->get_iter(dest)) return false;
-
-       //synfig::info("possible_drop -- data of type \"%s\"",selection_data.get_data_type());
-       //synfig::info("possible_drop -- data of target \"%s\"",gdk_atom_name(selection_data->target));
-       //synfig::info("possible_drop -- selection=\"%s\"",gdk_atom_name(selection_data->selection));
-
-       //Gtk::TreeModel::Row row(*get_iter(dest));
-
-       if(synfig::String(selection_data.get_data_type())=="LAYER" && (bool)true)
-       {
-               //Layer::Handle src(reinterpret_cast<Layer**>(const_cast<guint8*>(selection_data.get_data()))[i]);
-               //assert(src);
-
-               //return true;
-               TreeModel::Path dest_parent(dest);
-               if(!dest_parent.up() || dest.get_depth()==1)
-               {
-                       //row=(*get_iter(dest));
-                       //dest_canvas=(Canvas::Handle)(row[model.canvas]);
-                       return true;
-               }
-               else if((bool)const_cast<LayerTreeStore*>(this)->get_iter(dest_parent))
-                       return (bool)(Canvas::Handle)(*const_cast<LayerTreeStore*>(this)->get_iter(dest_parent))[model.contained_canvas];
-       }
-       return false;
-}
-
-bool
-LayerTreeStore::drag_data_received_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)
-{
-
-       //if(!dest_parent.up() || !get_iter(dest)) return false;
-
-       bool ret=false;
-       int i(0);
-
-
-       //synfig::info("Dropped data of type \"%s\"",selection_data.get_data_type());
-       //synfig::info("Dropped data of target \"%s\"",gdk_atom_name(selection_data->target));
-       //synfig::info("Dropped selection=\"%s\"",gdk_atom_name(selection_data->selection));
-       synfigapp::Action::PassiveGrouper passive_grouper(canvas_interface()->get_instance().get(),_("Move Layers"));
-
-       // Save the selection data
-       synfigapp::SelectionManager::LayerList selected_layer_list=canvas_interface()->get_selection_manager()->get_selected_layers();
-
-       if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
-       {
-               Gtk::TreeModel::Row row;
-               Canvas::Handle dest_canvas;
-
-               int dest_layer_depth=dest.back();
-
-               TreeModel::Path dest_parent(dest);
-               if(!dest_parent.up() || !get_iter(dest_parent))
-               {
-                       TreeModel::Path dest_(dest);
-                       if(!get_iter(dest_))
-                               dest_.prev();
-
-                       if(!get_iter(dest_))
-                               return false;
-
-                       {
-                               row=(*get_iter(dest_));
-                               dest_canvas=(Canvas::Handle)(row[model.canvas]);
-                       }
-               }
-               else
-               {
-                       row=(*get_iter(dest_parent));
-                       dest_canvas=row[model.contained_canvas];
-               }
-
-               assert(dest_canvas);
-
-               Layer::Handle dest_layer(row[model.layer]);
-
-               if(synfig::String(selection_data.get_data_type())=="LAYER")for(unsigned int i=0;i<selection_data.get_length()/sizeof(void*);i++)
-               {
-                       //synfig::info("dest_layer_depth=%d",dest_layer_depth);
-
-                       Layer::Handle src(reinterpret_cast<Layer**>(const_cast<guint8*>(selection_data.get_data()))[i]);
-                       assert(src);
-                       if(dest_layer==src)
-                               continue;
-
-                       if(dest_canvas==src->get_canvas() && src->get_depth()<dest_layer_depth)
-                               dest_layer_depth--;
-
-                       // In this case, we are just moving.
-//                     if(dest_canvas==src->get_canvas())
-                       {
-                               //if(dest_canvas==src->get_canvas() && dest_layer_depth && dest_layer_depth>src->get_depth())
-                               //      dest_layer_depth--;
-                               if(dest_canvas==src->get_canvas() && dest_layer_depth==src->get_depth())
-                                       continue;
-
-                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerMove"));
-                               action->set_param("canvas",dest_canvas);
-                               action->set_param("canvas_interface",canvas_interface());
-                               action->set_param("layer",src);
-                               action->set_param("new_index",dest_layer_depth);
-                               action->set_param("dest_canvas",dest_canvas);
-                               if(canvas_interface()->get_instance()->perform_action(action))
-                                       ret=true;
-                               else
-                               {
-                                       passive_grouper.cancel();
-                                       return false;
-                               }
-                               continue;
-                       }
-                       /*else // In this case we need to remove and then add
-                       {
-
-                               synfigapp::Action::Handle action;
-                               action=synfigapp::Action::create("LayerRemove");
-                               action->set_param("canvas",Canvas::Handle(src->get_canvas()));
-                               if(!action->set_param("canvas_interface",App::get_instance(src->get_canvas())->find_canvas_interface(src->get_canvas())))
-                                       action->set_param("canvas_interface",canvas_interface());
-                               action->set_param("layer",src);
-                               if(!canvas_interface()->get_instance()->perform_action(action))
-                               {
-                                       passive_grouper.cancel();
-                                       ret=false;
-                                       return false;
-                               }
-
-                               action=synfigapp::Action::create("LayerAdd");
-                               action->set_param("canvas",dest_canvas);
-                               action->set_param("canvas_interface",canvas_interface());
-                               action->set_param("new",src);
-                               if(!canvas_interface()->get_instance()->perform_action(action))
-                               {
-                                       passive_grouper.cancel();
-                                       ret=false;
-                                       return false;
-                               }
-
-                               if(dest_layer_depth!=0)
-                               {
-                                       action=synfigapp::Action::create("LayerMove");
-                                       action->set_param("canvas",dest_canvas);
-                                       action->set_param("canvas_interface",canvas_interface());
-                                       action->set_param("layer",src);
-                                       action->set_param("new_index",dest_layer_depth);
-                                       if(!canvas_interface()->get_instance()->perform_action(action))
-                                       {
-                                               passive_grouper.cancel();
-                                               ret=false;
-                                               return false;
-                                       }
-                               }
-                               ret=true;
-                       }
-                       */
-               }
-       }
-       synfig::info("I supposedly moved %d layers",i);
-
-       // Reselect the previously selected layers
-       canvas_interface()->get_selection_manager()->set_selected_layers(selected_layer_list);
-
-       return ret;
-}
-
-void
-LayerTreeStore::queue_rebuild()
-{
-       if (queued) return;
-       queued = false;
-       queue_connection.disconnect();
-       queue_connection=Glib::signal_timeout().connect(
-               sigc::bind_return(
-                       sigc::mem_fun(*this,&LayerTreeStore::rebuild),
-                       false
-               )
-       ,150);
-}
-
-void
-LayerTreeStore::rebuild()
-{
-       if (queued) queued = false;
-
-       // disconnect any subcanvas_changed connections
-       std::map<synfig::Layer::Handle, sigc::connection>::iterator iter;
-       for (iter = subcanvas_changed_connections.begin(); iter != subcanvas_changed_connections.end(); iter++)
-               iter->second.disconnect();
-       subcanvas_changed_connections.clear();
-
-       //etl::clock timer;timer.reset();
-
-       //synfig::warning("---------rebuilding layer table---------");
-       // Save the selection data
-       synfigapp::SelectionManager::LayerList layer_list=canvas_interface()->get_selection_manager()->get_selected_layers();
-
-       // Clear out the current list
-       clear();
-
-       // Go ahead and add all the layers
-       std::for_each(
-               canvas_interface()->get_canvas()->rbegin(), canvas_interface()->get_canvas()->rend(),
-               sigc::mem_fun(*this, &studio::LayerTreeStore::on_layer_added)
-       );
-
-       // Reselect the previously selected layers
-       if(!layer_list.empty())
-               canvas_interface()->get_selection_manager()->set_selected_layers(layer_list);
-
-       //synfig::info("LayerTreeStore::rebuild() took %f seconds",float(timer()));
-}
-
-void
-LayerTreeStore::refresh()
-{
-       etl::clock timer;timer.reset();
-
-       Gtk::TreeModel::Children children_(children());
-
-       Gtk::TreeModel::Children::iterator iter;
-
-       if(!children_.empty())
-               for(iter = children_.begin(); iter && iter != children_.end(); ++iter)
-               {
-                       Gtk::TreeRow row=*iter;
-                       refresh_row(row);
-               }
-       //synfig::info("LayerTreeStore::refresh() took %f seconds",float(timer()));
-}
-
-void
-LayerTreeStore::refresh_row(Gtk::TreeModel::Row &row)
-{
-       Layer::Handle layer=row[model.layer];
-       /*
-       {
-               row[model.name] = layer->get_local_name();
-               if(layer->get_description().empty())
-               {
-                       row[model.label] = layer->get_local_name();
-                       row[model.tooltip] = Glib::ustring("Layer");
-               }
-               else
-               {
-                       row[model.label] = layer->get_description();
-                       row[model.tooltip] = layer->get_local_name();
-               }
-       }
-       */
-
-       if(layer->dynamic_param_list().count("z_depth"))
-               row[model.z_depth]=Time::begin();
-       //      row_changed(get_path(row),row);
-
-       Gtk::TreeModel::Children children = row.children();
-       Gtk::TreeModel::Children::iterator iter;
-
-       if(!children.empty())
-               for(iter = children.begin(); iter && iter != children.end(); ++iter)
-               {
-                       Gtk::TreeRow row=*iter;
-                       refresh_row(row);
-               }
-}
-
-
-void
-LayerTreeStore::set_row_layer(Gtk::TreeRow &row,synfig::Layer::Handle &handle)
-{
-       //row[model.id] = handle->get_name();
-       //row[model.name] = handle->get_local_name();
-       /*if(handle->get_description().empty())
-       {
-               //row[model.label] = handle->get_local_name();
-               row[model.tooltip] = Glib::ustring("Layer");
-       }
-       else
-       {
-               //row[model.label] = handle->get_description();
-               row[model.tooltip] = handle->get_local_name();
-       }*/
-
-       //row[model.active] = handle->active();
-       row[model.layer] = handle;
-       //row[model.canvas] = handle->get_canvas();
-       //row[model.icon] = layer_icon;
-
-       synfig::Layer::ParamList paramlist=handle->get_param_list();
-
-       synfig::Layer::Vocab vocab=handle->get_param_vocab();
-       synfig::Layer::Vocab::iterator iter;
-
-       for(iter=vocab.begin();iter!=vocab.end();++iter)
-       {
-               if(iter->get_hidden())
-                       continue;
-               if(handle->get_param(iter->get_name()).get_type()!=ValueBase::TYPE_CANVAS)
-                       continue;
-
-               {
-                       Canvas::Handle canvas;
-                       canvas=handle->get_param(iter->get_name()).get(canvas);
-                       if(!canvas)
-                               continue;
-
-                       Canvas::reverse_iterator iter;
-                       row[model.contained_canvas]=canvas;
-
-                       for(iter=canvas->rbegin();iter!=canvas->rend();++iter)
-                       {
-                               Gtk::TreeRow row_(*(prepend(row.children())));
-                               set_row_layer(row_,*iter);
-                       }
-                       continue;
-               }
-
-               /*
-               etl::handle<ValueNode> value_node;
-               if(handle.constant()->dynamic_param_list().count(iter->get_name()))
-                       value_node=handle->dynamic_param_list()[iter->get_name()];
-
-               Gtk::TreeRow child_row = *(append(row.children()));
-               set_row_param(
-                       child_row,
-                       handle,
-                       iter->get_name(),
-                       iter->get_local_name(),
-                       paramlist[iter->get_name()],
-                       value_node,
-                       &*iter
-               );
-               */
-       }
-}
-
-void
-LayerTreeStore::on_layer_added(synfig::Layer::Handle layer)
-{
-       if (etl::handle<Layer_PasteCanvas>::cast_dynamic(layer))
-               subcanvas_changed_connections[layer] =
-                       (etl::handle<Layer_PasteCanvas>::cast_dynamic(layer))->signal_subcanvas_changed().connect(
-                               sigc::mem_fun(*this,&studio::LayerTreeStore::queue_rebuild)
-                       );
-
-       assert(layer);
-       Gtk::TreeRow row;
-       if(canvas_interface()->get_canvas()==layer->get_canvas())
-       {
-               row=*(prepend());
-       }
-       else
-       {
-               Gtk::TreeModel::Children::iterator iter;
-               if(!find_canvas_row(layer->get_canvas(),iter))
-               {
-                       rebuild();
-                       return;
-               }
-               row=*(prepend(iter->children()));
-       }
-       set_row_layer(row,layer);
-}
-
-void
-LayerTreeStore::on_layer_removed(synfig::Layer::Handle handle)
-{
-       if (etl::handle<Layer_PasteCanvas>::cast_dynamic(handle))
-       {
-               subcanvas_changed_connections[handle].disconnect();
-               subcanvas_changed_connections.erase(handle);
-       }
-       Gtk::TreeModel::Children::iterator iter;
-       if(find_layer_row(handle,iter))
-               erase(iter);
-       else
-       {
-               synfig::error("LayerTreeStore::on_layer_removed():Unable to find layer to be removed, forced to rebuild...");
-               rebuild();
-       }
-}
-
-void
-LayerTreeStore::on_layer_inserted(synfig::Layer::Handle handle,int depth)
-{
-       if(depth==0)
-       {
-               on_layer_added(handle);
-               return;
-       }
-
-       Gtk::TreeModel::Children children_(children());
-       if(canvas_interface()->get_canvas()!=handle->get_canvas())
-       {
-               Gtk::TreeModel::Children::iterator iter;
-               if(!find_canvas_row(handle->get_canvas(),iter))
-               {
-                       synfig::error("LayerTreeStore::on_layer_inserted():Unable to find canvas row, forced to rebuild...");
-                       rebuild();
-                       return;
-               }
-               children_=iter->children();
-       }
-
-       Gtk::TreeModel::Children::iterator iter(children_.begin());
-       while(depth-- && iter)
-       {
-               ++iter;
-               if(!iter || iter==children_.end())
-               {
-                       synfig::error("LayerTreeStore::on_layer_inserted():Unable to achieve desired depth, forced to rebuild...");
-                       rebuild();
-                       return;
-               }
-       }
-
-       Gtk::TreeModel::Row row(*insert(iter));
-       set_row_layer(row,handle);
-}
-
-void
-LayerTreeStore::on_layer_status_changed(synfig::Layer::Handle handle,bool /*x*/)
-{
-       Gtk::TreeModel::Children::iterator iter;
-       if(find_layer_row(handle,iter))
-               (*iter)[model.layer]=handle;
-       else
-       {
-               synfig::warning("Couldn't find layer to be activated in layer list. Rebuilding index...");
-               rebuild();
-       }
-}
-
-void
-LayerTreeStore::on_layer_lowered(synfig::Layer::Handle layer)
-{
-       Gtk::TreeModel::Children::iterator iter, iter2;
-       if(find_layer_row(layer,iter))
-       {
-               // Save the selection data
-               //synfigapp::SelectionManager::LayerList layer_list=canvas_interface()->get_selection_manager()->get_selected_layers();
-               iter2=iter;
-               iter2++;
-               if(!iter2)
-               {
-                       rebuild();
-                       return;
-               }
-
-               //Gtk::TreeModel::Row row(*iter);
-               Gtk::TreeModel::Row row2 = *iter2;
-               synfig::Layer::Handle layer2=row2[model.layer];
-
-               erase(iter2);
-               row2=*insert(iter);
-               set_row_layer(row2,layer2);
-
-       }
-       else
-               rebuild();
-}
-
-void
-LayerTreeStore::on_layer_raised(synfig::Layer::Handle layer)
-{
-       Gtk::TreeModel::Children::iterator iter, iter2;
-
-       Gtk::TreeModel::Children children_(children());
-
-       if(find_layer_row_(layer, canvas_interface()->get_canvas(), children_, iter,iter2))
-       {
-               if(iter!=iter2)
-               {
-                       //Gtk::TreeModel::Row row = *iter;
-                       Gtk::TreeModel::Row row2 = *iter2;
-                       synfig::Layer::Handle layer2=row2[model.layer];
-
-                       erase(iter2);
-                       iter++;
-                       row2=*insert(iter);
-                       set_row_layer(row2,layer2);
-
-                       return;
-               }
-       }
-
-       rebuild();
-}
-
-void
-LayerTreeStore::on_layer_moved(synfig::Layer::Handle layer,int depth, synfig::Canvas::Handle /*canvas*/)
-{
-       on_layer_removed(layer);
-       on_layer_inserted(layer,depth);
-}
-
-void
-LayerTreeStore::on_layer_param_changed(synfig::Layer::Handle handle,synfig::String param_name)
-{
-       if(param_name=="z_depth")
-       {
-               Gtk::TreeModel::Children::iterator iter;
-               if(find_layer_row(handle,iter))
-               {
-                       (*iter)[model.z_depth]=Time::begin();
-               }
-       }
-
-       /*
-       Gtk::TreeModel::Children::iterator iter;
-       if(find_layer_row(handle,iter))
-       {
-               Gtk::TreeModel::Children children(iter->children());
-
-               for(iter = children.begin(); iter && iter != children.end(); ++iter)
-               {
-                       if((Glib::ustring)(*iter)[model.param_name]==param_name)
-                       {
-                               Gtk::TreeRow row=*iter;
-                               refresh_row(row);
-                               return;
-                       }
-               }
-       }
-       rebuild();
-       */
-}
-
-void
-LayerTreeStore::on_layer_new_description(synfig::Layer::Handle handle,synfig::String desc)
-{
-       Gtk::TreeModel::Children::iterator iter;
-       if(find_layer_row(handle,iter))
-       {
-               Gtk::TreeRow row(*iter);
-
-               Layer::Handle layer(row[model.layer]);
-
-               if(desc.empty())
-               {
-                       //row[model.label]=layer->get_local_name();
-                       row[model.tooltip]=Glib::ustring(_("Layer"));
-               }
-               else
-                       //row[model.label]=layer->get_description();
-                       row[model.tooltip]=layer->get_local_name();
-       }
-       else
-       {
-               rebuild();
-       }
-}
-
-bool
-LayerTreeStore::find_canvas_row_(synfig::Canvas::Handle canvas, synfig::Canvas::Handle parent, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter)
-{
-       if(canvas==parent)
-               return false;
-
-       {
-               for(iter=layers.begin(); iter && iter != layers.end(); ++iter)
-               {
-                       Gtk::TreeModel::Row row = *iter;
-                       if(canvas==(synfig::Canvas::Handle)row[model.contained_canvas])
-                               return true;
-               }
-
-               iter=children().end();
-               //return false;
-       }
-
-       Gtk::TreeModel::Children::iterator iter2;
-       //Gtk::TreeModel::Children::iterator iter3;
-
-       for(iter2 = layers.begin(); iter2 && iter2 != layers.end(); ++iter2)
-       {
-               Gtk::TreeModel::Row row = *iter2;
-               assert((bool)true);
-
-               if(row.children().empty())
-                       continue;
-
-               Canvas::Handle sub_canvas((*row.children().begin())[model.canvas]);
-               if(!sub_canvas)
-                       continue;
-
-               if(find_canvas_row_(canvas,sub_canvas,iter2->children(),iter))
-                       return true;
-       }
-
-       iter=children().end();
-       return false;
-}
-
-bool
-LayerTreeStore::find_canvas_row(synfig::Canvas::Handle canvas, Gtk::TreeModel::Children::iterator &iter)
-{
-       return find_canvas_row_(canvas,canvas_interface()->get_canvas(),children(),iter);
-}
-
-
-bool
-LayerTreeStore::find_layer_row_(const synfig::Layer::Handle &layer, synfig::Canvas::Handle /*canvas*/, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter, Gtk::TreeModel::Children::iterator &prev)
-{
-       assert(layer);
-
-       //if(layer->get_canvas()==canvas)
-       {
-               for(iter=prev=layers.begin(); iter && iter != layers.end(); prev=iter++)
-               {
-                       Gtk::TreeModel::Row row = *iter;
-                       if(layer==(synfig::Layer::Handle)row[model.layer])
-                               return true;
-               }
-
-               iter=children().end();
-               //return false;
-       }
-
-       Gtk::TreeModel::Children::iterator iter2;
-
-       for(iter2 = layers.begin(); iter2 && iter2 != layers.end(); ++iter2)
-       {
-               Gtk::TreeModel::Row row = *iter2;
-               assert((bool)true);
-
-               if(row.children().empty())
-                       continue;
-
-               Canvas::Handle canvas((*row.children().begin())[model.canvas]);
-               if(!canvas)
-                       continue;
-
-               if(find_layer_row_(layer,canvas,iter2->children(),iter,prev))
-                       return true;
-       }
-
-       iter=children().end();
-       return false;
-}
-
-bool
-LayerTreeStore::find_layer_row(const synfig::Layer::Handle &layer, Gtk::TreeModel::Children::iterator &iter)
-{
-       Gtk::TreeModel::Children::iterator prev;
-       return find_layer_row_(layer,canvas_interface()->get_canvas(),children(),iter,prev);
-}
-
-bool
-LayerTreeStore::find_prev_layer_row(const synfig::Layer::Handle &layer, Gtk::TreeModel::Children::iterator &prev)
-{
-       Gtk::TreeModel::Children::iterator iter;
-       if(!find_layer_row_(layer,canvas_interface()->get_canvas(),children(),iter,prev))
-               return false;
-       if(iter==children().begin())
-               return false;
-       return true;
-}
diff --git a/synfig-studio/src/gtkmm/layertreestore.h b/synfig-studio/src/gtkmm/layertreestore.h
deleted file mode 100644 (file)
index 5b33309..0000000
+++ /dev/null
@@ -1,226 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file layertreestore.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_LAYERTREESTORE_H
-#define __SYNFIG_STUDIO_LAYERTREESTORE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/treestore.h>
-#include <synfigapp/canvasinterface.h>
-#include <synfig/value.h>
-#include <synfig/valuenode.h>
-#include <gtkmm/treeview.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 LayerTreeStore : virtual public Gtk::TreeStore
-{
-       /*
- -- ** -- P U B L I C   T Y P E S ---------------------------------------------
-       */
-
-public:
-
-       class Model : public Gtk::TreeModel::ColumnRecord
-       {
-       public:
-               Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
-               Gtk::TreeModelColumn<Glib::ustring> label;
-               Gtk::TreeModelColumn<Glib::ustring> name;
-               Gtk::TreeModelColumn<Glib::ustring> id;
-
-               Gtk::TreeModelColumn<synfig::Canvas::Handle> canvas;
-
-               Gtk::TreeModelColumn<Glib::ustring> tooltip;
-
-
-               Gtk::TreeModelColumn<bool>                                              active;
-               Gtk::TreeModelColumn<synfig::Layer::Handle>             layer;
-               Gtk::TreeModelColumn<synfig::Canvas::Handle>                    contained_canvas;
-
-               Gtk::TreeModelColumn<bool>                                              children_lock;
-
-               Gtk::TreeModelColumn<float> z_depth;
-               Gtk::TreeModelColumn<int> index;
-
-               Model()
-               {
-                       add(icon);
-                       add(label);
-                       add(name);
-                       add(id);
-                       add(canvas);
-                       add(tooltip);
-                       add(active);
-                       add(layer);
-                       add(contained_canvas);
-                       add(z_depth);
-                       add(index);
-                       add(children_lock);
-               }
-       };
-
-       /*
- -- ** -- P U B L I C  D A T A ------------------------------------------------
-       */
-
-public:
-
-       //! TreeModel for the layers
-       const Model model;
-
-       /*
- -- ** -- P R I V A T E   D A T A ---------------------------------------------
-       */
-
-private:
-
-       bool queued;
-
-       sigc::connection queue_connection;
-
-       std::map<synfig::Layer::Handle, sigc::connection> subcanvas_changed_connections;
-
-       etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
-
-       Glib::RefPtr<Gdk::Pixbuf> layer_icon;
-
-       /*
- -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
-       */
-
-private:
-
-       /*
- -- ** -- P R O T E C T E D   M E T H O D S -----------------------------------
-       */
-
-private:
-       virtual void  set_value_impl (const Gtk::TreeModel::iterator& row, int column, const Glib::ValueBase& value);
-       virtual void  get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const;
-
-       virtual bool  row_draggable_vfunc (const TreeModel::Path& path)const;
-       virtual bool  drag_data_get_vfunc (const TreeModel::Path& path, Gtk::SelectionData& selection_data)const;
-       virtual bool  drag_data_delete_vfunc (const TreeModel::Path& path);
-       virtual bool  drag_data_received_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data);
-       virtual bool  row_drop_possible_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)const;
-
-       /*
- -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
-       */
-
-private:
-
-       bool on_layer_tree_event(GdkEvent *event);
-
-       void on_layer_new_description(synfig::Layer::Handle handle,synfig::String desc);
-
-       void on_layer_added(synfig::Layer::Handle handle);
-
-       void on_layer_removed(synfig::Layer::Handle handle);
-
-       void on_layer_inserted(synfig::Layer::Handle handle,int depth);
-
-       void on_layer_moved(synfig::Layer::Handle handle,int depth, synfig::Canvas::Handle canvas);
-
-       void on_layer_status_changed(synfig::Layer::Handle handle,bool);
-
-       void on_layer_lowered(synfig::Layer::Handle handle);
-
-       void on_layer_raised(synfig::Layer::Handle handle);
-
-       void on_layer_param_changed(synfig::Layer::Handle handle,synfig::String param_name);
-
-       //void on_value_node_added(synfig::ValueNode::Handle value_node);
-
-       //void on_value_node_deleted(synfig::ValueNode::Handle value_node);
-
-       //void on_value_node_changed(synfig::ValueNode::Handle value_node);
-
-       //void on_value_node_replaced(synfig::ValueNode::Handle replaced_value_node,synfig::ValueNode::Handle new_value_node);
-
-       bool find_layer_row_(const synfig::Layer::Handle &handle, synfig::Canvas::Handle canvas, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter, Gtk::TreeModel::Children::iterator &prev);
-
-       bool find_canvas_row_(synfig::Canvas::Handle canvas, synfig::Canvas::Handle parent, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter);
-
-       /*
- -- ** -- P U B L I C   M E T H O D S -----------------------------------------
-       */
-
-public:
-
-       LayerTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
-       ~LayerTreeStore();
-
-       etl::loose_handle<synfigapp::CanvasInterface> canvas_interface() { return canvas_interface_; }
-       etl::loose_handle<const synfigapp::CanvasInterface> canvas_interface()const { return canvas_interface_; }
-       etl::loose_handle<synfigapp::CanvasInterface> get_canvas_interface()const { return canvas_interface_; }
-
-       bool find_canvas_row(synfig::Canvas::Handle canvas, Gtk::TreeModel::Children::iterator &iter);
-
-       bool find_layer_row(const synfig::Layer::Handle &handle, Gtk::TreeModel::Children::iterator &iter);
-
-       bool find_prev_layer_row(const synfig::Layer::Handle &handle, Gtk::TreeModel::Children::iterator &iter);
-
-       void queue_rebuild();
-
-       void rebuild();
-
-       void refresh();
-
-       void refresh_row(Gtk::TreeModel::Row &row);
-
-       void set_row_layer(Gtk::TreeRow &row,synfig::Layer::Handle &handle);
-
-       static int z_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs);
-       static int index_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs);
-
-       //void set_row_param(Gtk::TreeRow &row,synfig::Layer::Handle &handle,const std::string& name, const std::string& local_name, const synfig::ValueBase &value, etl::handle<synfig::ValueNode> value_node,synfig::ParamDesc *param_desc);
-
-       //virtual void set_row(Gtk::TreeRow row,synfigapp::ValueDesc value_desc);
-       static bool search_func(const Glib::RefPtr<TreeModel>&,int,const Glib::ustring&,const TreeModel::iterator&);
-
-       /*
- -- ** -- S T A T I C   P U B L I C   M E T H O D S ---------------------------
-       */
-
-public:
-
-       static Glib::RefPtr<LayerTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
-
-
-}; // END of class LayerTreeStore
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/main.cpp b/synfig-studio/src/gtkmm/main.cpp
deleted file mode 100644 (file)
index 36bf16d..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file gtkmm/main.cpp
-**     \brief Synfig Studio Entrypoint
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 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 <config.h>
-#endif
-
-#include "app.h"
-#include <iostream>
-#include "ipc.h"
-#include <stdexcept>
-
-#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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-/* === E N T R Y P O I N T ================================================= */
-
-int main(int argc, char **argv)
-{
-
-#ifdef ENABLE_NLS
-       setlocale(LC_ALL, "");
-       bindtextdomain("synfigstudio", LOCALEDIR);
-       bind_textdomain_codeset("synfigstudio", "UTF-8");
-       textdomain("synfigstudio");
-#endif
-
-       {
-               SmartFILE file(IPC::make_connection());
-               if(file)
-               {
-                       cout << endl;
-                       cout << "   " << _("synfig studio is already running") << endl << endl;
-                       cout << "   " << _("the existing process will be used") << endl << endl;;
-
-                       // Hey, another copy of us is open!
-                       // don't bother opening us, just go ahead and
-                       // tell the other copy to load it all up
-                       if (argc>1)
-                               fprintf(file.get(),"F\n");
-
-                       while(--argc)
-                               if((argv)[argc] && (argv)[argc][0]!='-')
-                                       fprintf(file.get(),"O %s\n",etl::absolute_path((argv)[argc]).c_str());
-
-                       fprintf(file.get(),"F\n");
-
-                       return 0;
-               }
-       }
-
-       cout << endl;
-       cout << "   " << _("synfig studio -- starting up application...") << endl << endl;
-
-       try
-       {
-               studio::App app(&argc, &argv);
-
-               app.run();
-       }
-       catch(int ret)
-       {
-               std::cerr<<"Application shutdown with errors ("<<ret<<')'<<std::endl;
-               return ret;
-       }
-       catch(string str)
-       {
-               std::cerr<<"Uncaught Exception:string: "<<str<<std::endl;
-               throw;
-       }
-       catch(std::exception x)
-       {
-               std::cerr<<"Standard Exception: "<<x.what()<<std::endl;
-               throw;
-       }
-       catch(Glib::Exception& x)
-       {
-               std::cerr<<"GLib Exception: "<<x.what()<<std::endl;
-               throw;
-       }
-       catch(...)
-       {
-               std::cerr<<"Uncaught Exception"<<std::endl;
-               throw;
-       }
-
-       std::cerr<<"Application appears to have terminated successfully"<<std::endl;
-
-       return 0;
-}
diff --git a/synfig-studio/src/gtkmm/metadatatreestore.cpp b/synfig-studio/src/gtkmm/metadatatreestore.cpp
deleted file mode 100644 (file)
index 98bb7c6..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file metadatatreestore.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 <config.h>
-#endif
-
-#include "metadatatreestore.h"
-#include <synfigapp/canvasinterface.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-static MetaDataTreeStore::Model& ModelHack()
-{
-       static MetaDataTreeStore::Model* model(0);
-       if(!model)model=new MetaDataTreeStore::Model;
-       return *model;
-}
-
-MetaDataTreeStore::MetaDataTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_):
-       Gtk::TreeStore  (ModelHack()),
-       canvas_interface_               (canvas_interface_)
-{
-       // Connect the signal
-       get_canvas()->signal_meta_data_changed().connect(sigc::mem_fun(*this,&MetaDataTreeStore::meta_data_changed));
-
-       rebuild();
-}
-
-MetaDataTreeStore::~MetaDataTreeStore()
-{
-       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
-               synfig::info("MetaDataTreeStore::~MetaDataTreeStore(): Deleted");
-}
-
-Glib::RefPtr<MetaDataTreeStore>
-MetaDataTreeStore::create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_)
-{
-       return Glib::RefPtr<MetaDataTreeStore>(new MetaDataTreeStore(canvas_interface_));
-}
-
-void
-MetaDataTreeStore::meta_data_changed(synfig::String /*key*/)
-{
-       rebuild();
-}
-
-void
-MetaDataTreeStore::rebuild()
-{
-       clear();
-
-       std::list<String> keys(get_canvas()->get_meta_data_keys());
-
-       for(;!keys.empty();keys.pop_front())
-       {
-               Gtk::TreeRow row(*append());
-               row[model.key]=keys.front();
-       }
-}
-
-void
-MetaDataTreeStore::get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const
-{
-       if(column>=get_n_columns_vfunc())
-       {
-               g_warning("MetaDataTreeStore::set_value_impl: Bad column (%d)",column);
-               return;
-       }
-
-       if(column==model.data.index())
-       {
-               synfig::String key((Glib::ustring)(*iter)[model.key]);
-               g_value_init(value.gobj(),G_TYPE_STRING);
-               g_value_set_string(value.gobj(),get_canvas()->get_meta_data(key).c_str());
-               return;
-       }
-       else
-               Gtk::TreeStore::get_value_vfunc(iter,column,value);
-}
-
-void
-MetaDataTreeStore::set_value_impl(const Gtk::TreeModel::iterator& iter, int column, const Glib::ValueBase& value)
-{
-       if(column>=get_n_columns_vfunc())
-       {
-               g_warning("MetaDataTreeStore::set_value_impl: Bad column (%d)",column);
-               return;
-       }
-
-       if(!g_value_type_compatible(G_VALUE_TYPE(value.gobj()),get_column_type_vfunc(column)))
-       {
-               g_warning("MetaDataTreeStore::set_value_impl: Bad value type");
-               return;
-       }
-
-       if(column==model.data.index())
-       {
-               Glib::Value<Glib::ustring> x;
-               g_value_init(x.gobj(),model.data.type());
-               g_value_copy(value.gobj(),x.gobj());
-
-               synfig::String key((Glib::ustring)(*iter)[model.key]);
-               synfig::String new_data(x.get());
-
-               get_canvas_interface()->set_meta_data(key,new_data);
-       }
-       else
-               Gtk::TreeStore::set_value_impl(iter,column, value);
-}
diff --git a/synfig-studio/src/gtkmm/metadatatreestore.h b/synfig-studio/src/gtkmm/metadatatreestore.h
deleted file mode 100644 (file)
index 6ad41d4..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file metadatatreestore.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_METADATATREESTORE_H
-#define __SYNFIG_STUDIO_METADATATREESTORE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/treestore.h>
-#include <synfigapp/canvasinterface.h>
-#include <gdkmm/pixbuf.h>
-#include <synfigapp/action.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 synfigapp { class CanvasInterface; }
-
-namespace studio {
-
-class MetaDataTreeStore : virtual public Gtk::TreeStore
-{
-       /*
- -- ** -- P U B L I C   T Y P E S ---------------------------------------------
-       */
-
-public:
-
-       class Model : public Gtk::TreeModel::ColumnRecord
-       {
-       public:
-       public:
-               Gtk::TreeModelColumn<Glib::ustring> key;
-               Gtk::TreeModelColumn<Glib::ustring> data;
-
-               Model()
-               {
-                       add(key);
-                       add(data);
-               }
-       };
-
-       /*
- -- ** -- P U B L I C  D A T A ------------------------------------------------
-       */
-
-public:
-
-       const Model model;
-
-       /*
- -- ** -- P R I V A T E   D A T A ---------------------------------------------
-       */
-
-private:
-
-       etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
-
-       /*
- -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
-       */
-
-private:
-
-       /*
- -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
-       */
-
-private:
-
-       void meta_data_changed(synfig::String key);
-
-       /*
- -- ** -- P U B L I C   M E T H O D S -----------------------------------------
-       */
-
-public:
-
-       ~MetaDataTreeStore();
-
-       etl::loose_handle<synfigapp::CanvasInterface> get_canvas_interface() { return canvas_interface_; }
-       etl::loose_handle<const synfigapp::CanvasInterface> get_canvas_interface()const { return canvas_interface_; }
-       synfig::Canvas::Handle get_canvas()const { return canvas_interface_->get_canvas(); }
-       synfig::Canvas::Handle get_canvas() { return canvas_interface_->get_canvas(); }
-
-       void rebuild();
-
-       void refresh() { rebuild(); }
-
-       /*
- -- ** -- P R O T E C T E D   M E T H O D S -----------------------------------
-       */
-
-protected:
-       MetaDataTreeStore(etl::loose_handle<synfigapp::CanvasInterface>);
-       void get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const;
-       void set_value_impl(const Gtk::TreeModel::iterator& iter, int column, const Glib::ValueBase& value);
-
-public:
-
-       static Glib::RefPtr<MetaDataTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface>);
-
-}; // END of class MetaDataTreeStore
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/mod_mirror/mod_mirror.cpp b/synfig-studio/src/gtkmm/mod_mirror/mod_mirror.cpp
deleted file mode 100644 (file)
index 03667bf..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file mod_mirror.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "mod_mirror.h"
-#include "state_mirror.h"
-
-#include "../app.h"
-#include "../statemanager.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-bool
-studio::ModMirror::start_vfunc()
-{
-       App::get_state_manager()->add_state(&state_mirror);
-       return true;
-}
-
-bool
-studio::ModMirror::stop_vfunc()
-{
-       return true;
-}
diff --git a/synfig-studio/src/gtkmm/mod_mirror/mod_mirror.h b/synfig-studio/src/gtkmm/mod_mirror/mod_mirror.h
deleted file mode 100644 (file)
index 25240f5..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file mod_mirror.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_MOD_MIRROR_H
-#define __SYNFIG_MOD_MIRROR_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <ETL/handle>
-#include "../module.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 State_Mirror;
-
-class ModMirror : public Module
-{
-       friend class State_Mirror;
-
-protected:
-       virtual bool start_vfunc();
-       virtual bool stop_vfunc();
-
-public:
-       virtual ~ModMirror() { stop(); }
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/mod_mirror/state_mirror.cpp b/synfig-studio/src/gtkmm/mod_mirror/state_mirror.cpp
deleted file mode 100644 (file)
index bcb0a3a..0000000
+++ /dev/null
@@ -1,336 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_mirror.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include <gtkmm/dialog.h>
-#include <gtkmm/entry.h>
-
-#include <synfig/valuenode_dynamiclist.h>
-#include <synfigapp/action_system.h>
-
-#include "state_mirror.h"
-#include "../state_normal.h"
-#include "../canvasview.h"
-#include "../workarea.h"
-#include "../app.h"
-
-#include <synfigapp/action.h>
-#include "../event_mouse.h"
-#include "../event_layerclick.h"
-#include "../toolbox.h"
-#include "../dialog_tooloptions.h"
-#include <gtkmm/optionmenu.h>
-#include "../duck.h"
-#include <synfigapp/main.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 ========================================================= */
-
-enum Axis {
-       AXIS_X,
-       AXIS_Y
-} ;
-
-/* === G L O B A L S ======================================================= */
-
-StateMirror studio::state_mirror;
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-class DuckDrag_Mirror : public DuckDrag_Base
-{
-       synfig::Vector center;
-
-       std::vector<synfig::Vector> positions;
-
-public:
-       Axis axis;
-
-       DuckDrag_Mirror();
-       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::StateMirror_Context : public sigc::trackable
-{
-       etl::handle<CanvasView> canvas_view_;
-       CanvasView::IsWorking is_working;
-
-       synfigapp::Settings& settings;
-
-       sigc::connection keypress_connect;
-       sigc::connection keyrelease_connect;
-
-       etl::handle<DuckDrag_Mirror> duck_dragger_;
-
-       Gtk::Table options_table;
-
-       Gtk::RadioButton::Group radiobutton_group;
-       Gtk::RadioButton radiobutton_axis_x;
-       Gtk::RadioButton radiobutton_axis_y;
-
-public:
-
-       Axis get_axis()const { return radiobutton_axis_x.get_active()?AXIS_X:AXIS_Y; }
-       void set_axis(Axis a)
-       {
-               if(a==AXIS_X)
-                       radiobutton_axis_x.set_active(true);
-               else
-                       radiobutton_axis_y.set_active(true);
-
-               duck_dragger_->axis=get_axis();
-       }
-
-       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();
-
-       StateMirror_Context(CanvasView* canvas_view);
-
-       ~StateMirror_Context();
-
-       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
-       etl::handle<synfigapp::CanvasInterface> 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();
-
-       bool key_event(GdkEventKey *event);
-};     // END of class StateMirror_Context
-
-/* === M E T H O D S ======================================================= */
-
-StateMirror::StateMirror():
-       Smach::state<StateMirror_Context>("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()
-{
-}
-
-void
-StateMirror_Context::load_settings()
-{
-       String value;
-
-       settings.get_value("mirror.axis",value);
-       set_axis((Axis)atoi(value.c_str()));
-}
-
-void
-StateMirror_Context::save_settings()
-{
-       settings.set_value("mirror.lock_aspect",strprintf("%d",(int)get_axis()));
-}
-
-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")),
-       radiobutton_axis_y(radiobutton_group,_("Vertical"))
-{
-       // Set up the tool options dialog
-       options_table.attach(*manage(new Gtk::Label(_("Mirror Tool"))), 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(radiobutton_axis_x, 0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(radiobutton_axis_y, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(*manage(new Gtk::Label(_("(Shift key toggles axis)"))), 0, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       radiobutton_axis_x.signal_toggled().connect(sigc::mem_fun(*this,&StateMirror_Context::update_axes));
-       radiobutton_axis_y.signal_toggled().connect(sigc::mem_fun(*this,&StateMirror_Context::update_axes));
-
-       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_);
-
-       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_work_area()->set_cursor(Gdk::SB_H_DOUBLE_ARROW);
-//     get_work_area()->reset_cursor();
-
-       App::toolbox->refresh();
-
-       set_axis(AXIS_X);
-       load_settings();
-}
-
-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
-}
-
-void
-StateMirror_Context::refresh_tool_options()
-{
-       App::dialog_tool_options->clear();
-       App::dialog_tool_options->set_widget(options_table);
-       App::dialog_tool_options->set_local_name(_("Mirror Tool"));
-       App::dialog_tool_options->set_name("mirror");
-}
-
-Smach::event_result
-StateMirror_Context::event_refresh_tool_options(const Smach::event& /*x*/)
-{
-       refresh_tool_options();
-       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_work_area()->reset_cursor();
-
-       keypress_connect.disconnect();
-       keyrelease_connect.disconnect();
-
-       App::dialog_tool_options->clear();
-
-       App::toolbox->refresh();
-}
-
-DuckDrag_Mirror::DuckDrag_Mirror():
-       axis(AXIS_X)
-{
-}
-
-#ifndef EPSILON
-#define EPSILON        0.0000001
-#endif
-
-void
-DuckDrag_Mirror::begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& /*offset*/)
-{
-       const DuckList selected_ducks(duckmatic->get_selected_ducks());
-       DuckList::const_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());
-               positions.push_back(p);
-       }
-
-}
-
-void
-DuckDrag_Mirror::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector)
-{
-       center=vector;
-       int i;
-
-       const DuckList selected_ducks(duckmatic->get_selected_ducks());
-       DuckList::const_iterator iter;
-
-       Time time(duckmatic->get_time());
-
-       // do the Vertex and Position ducks first
-       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)
-               {
-                       Vector p(positions[i]);
-
-                       if              (axis==AXIS_X) p[0] = -(p[0]-center[0]) + center[0];
-                       else if (axis==AXIS_Y) p[1] = -(p[1]-center[1]) + center[1];
-
-                       (*iter)->set_trans_point(p);
-               }
-
-       // then do the other ducks
-       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)
-               {
-                       // we don't need to mirror radius ducks - they're one-dimensional
-                       if ((*iter)->is_radius())
-                               continue;
-
-                       Vector p(positions[i]);
-
-                       if              (axis==AXIS_X) p[0] = -(p[0]-center[0]) + center[0];
-                       else if (axis==AXIS_Y) p[1] = -(p[1]-center[1]) + center[1];
-
-                       (*iter)->set_trans_point(p);
-               }
-}
-
-bool
-DuckDrag_Mirror::end_duck_drag(Duckmatic* duckmatic)
-{
-       duckmatic->signal_edited_selected_ducks();
-       return true;
-}
diff --git a/synfig-studio/src/gtkmm/mod_mirror/state_mirror.h b/synfig-studio/src/gtkmm/mod_mirror/state_mirror.h
deleted file mode 100644 (file)
index f1a6364..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_mirror.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_MIRROR_H
-#define __SYNFIG_STUDIO_STATE_MIRROR_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 StateMirror_Context;
-
-class StateMirror : public Smach::state<StateMirror_Context>
-{
-public:
-       StateMirror();
-       ~StateMirror();
-}; // END of class StateMirror
-
-extern StateMirror state_mirror;
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/mod_palette/dock_palbrowse.cpp b/synfig-studio/src/gtkmm/mod_palette/dock_palbrowse.cpp
deleted file mode 100644 (file)
index dbaff71..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_palbrowse.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "dock_palbrowse.h"
-#include "dock_paledit.h"
-#include "mod_palette.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Dock_PalBrowse::Dock_PalBrowse():
-       Dockable("pal_browse",_("Palette Browser")/*,Gtk::StockID("gtk-select-color")*/)
-{
-}
-
-Dock_PalBrowse::~Dock_PalBrowse()
-{
-}
diff --git a/synfig-studio/src/gtkmm/mod_palette/dock_palbrowse.h b/synfig-studio/src/gtkmm/mod_palette/dock_palbrowse.h
deleted file mode 100644 (file)
index 9e039d3..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_palbrowse.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_DOCK_PAL_BROWSE_H
-#define __SYNFIG_STUDIO_DOCK_PAL_BROWSE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include "../dockable.h"
-#include <synfig/palette.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 synfigapp {
-class CanvasInterface;
-};
-
-namespace studio {
-
-/*
-
-The palette browser was intended to be a way to manage and select a single
-palette from a set of palettes that you could save to files. The palette
-editor was for editing individual palettes. Unfortunately the palette
-browser was never implemented.
-
-*/
-
-class Dock_PalBrowse : public Dockable
-{
-public:
-       Dock_PalBrowse();
-       ~Dock_PalBrowse();
-}; // END of Dock_PalBrowse
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/mod_palette/dock_paledit.cpp b/synfig-studio/src/gtkmm/mod_palette/dock_paledit.cpp
deleted file mode 100644 (file)
index 718bdee..0000000
+++ /dev/null
@@ -1,396 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_paledit.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \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
-**     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 <config.h>
-#endif
-
-#include "dock_paledit.h"
-#include "../widget_color.h"
-#include <gtkmm/frame.h>
-#include <gtkmm/table.h>
-#include <gtkmm/label.h>
-#include <synfig/general.h>
-#include <synfigapp/canvasinterface.h>
-#include <synfigapp/value_desc.h>
-#include "../widget_color.h"
-#include <gtkmm/spinbutton.h>
-#include <gtkmm/menu.h>
-#include <synfigapp/main.h>
-#include "../app.h"
-#include "../dialog_color.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 ======================================================= */
-/*
-class studio::PaletteSettings : public synfigapp::Settings
-{
-       Dock_PalEdit* dialog_palette;
-       synfig::String name;
-public:
-       PaletteSettings(Dock_PalEdit* window,const synfig::String& name):
-               dialog_palette(window),
-               name(name)
-       {
-               dialog_palette->dialog_settings.add_domain(this,name);
-       }
-
-       virtual ~PaletteSettings()
-       {
-               dialog_palette->dialog_settings.remove_domain(name);
-       }
-
-       virtual bool get_value(const synfig::String& key, synfig::String& value)const
-       {
-               int i(atoi(key.c_str()));
-               if(i<0 || i>=dialog_palette->size())
-                       return false;
-               Color c(dialog_palette->get_color(i));
-               value=strprintf("%f %f %f %f",c.get_r(),c.get_g(),c.get_b(),c.get_a());
-               return true;
-       }
-
-       virtual bool set_value(const synfig::String& key,const synfig::String& value)
-       {
-               int i(atoi(key.c_str()));
-               if(i<0)
-                       return false;
-               if(i>=dialog_palette->size())
-                       dialog_palette->palette_.resize(i+1);
-               float r,g,b,a;
-               if(!strscanf(value,"%f %f %f %f",&r,&g,&b,&a))
-                       return false;
-               dialog_palette->set_color(Color(r,g,b,a),i);
-               return true;
-       }
-
-       virtual KeyList get_key_list()const
-       {
-               synfigapp::Settings::KeyList ret(synfigapp::Settings::get_key_list());
-
-               int i;
-               for(i=0;i<dialog_palette->size();i++)
-                       ret.push_back(strprintf("%03d",i));
-               return ret;
-       }
-};
-*/
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Dock_PalEdit::Dock_PalEdit():
-       Dockable("pal_edit",_("Palette Editor"),Gtk::StockID("gtk-select-color")),
-       //palette_settings(new PaletteSettings(this,"colors")),
-       table(2,2,false)
-{
-       action_group=Gtk::ActionGroup::create("action_group_pal_edit");
-       action_group->add(Gtk::Action::create(
-               "palette-add-color",
-               Gtk::StockID("gtk-add"),
-               _("Add Color"),
-               _("Add current outline color\nto the palette")
-       ),
-               sigc::mem_fun(
-                       *this,
-                       &Dock_PalEdit::on_add_pressed
-               )
-       );
-
-       App::ui_manager()->insert_action_group(action_group);
-
-    Glib::ustring ui_info =
-       "<ui>"
-       "       <toolbar action='toolbar-palette'>"
-       "       <toolitem action='palette-add-color' />"
-       "       </toolbar>"
-       "</ui>"
-       ;
-
-       App::ui_manager()->add_ui_from_string(ui_info);
-
-       set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-palette")));
-
-       /*
-       add_button(
-               Gtk::StockID("gtk-add"),
-               _("Add current outline color\nto the palette")
-       )->signal_clicked().connect(
-               sigc::mem_fun(
-                       *this,
-                       &Dock_PalEdit::on_add_pressed
-               )
-       );
-       */
-
-       add(table);
-       table.set_homogeneous(true);
-
-       set_default_palette();
-
-       show_all_children();
-}
-
-Dock_PalEdit::~Dock_PalEdit()
-{
-       //delete palette_settings;
-}
-
-void
-Dock_PalEdit::set_palette(const synfig::Palette& x)
-{
-       palette_=x;
-       refresh();
-}
-
-void
-Dock_PalEdit::on_add_pressed()
-{
-       add_color(synfigapp::Main::get_outline_color());
-}
-
-void
-Dock_PalEdit::show_menu(int i)
-{
-       Gtk::Menu* menu(manage(new Gtk::Menu()));
-       menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), menu));
-
-       menu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-select-color"),
-               sigc::bind(
-                       sigc::mem_fun(*this,&studio::Dock_PalEdit::edit_color),
-                       i
-               )
-       ));
-
-       menu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-delete"),
-               sigc::bind(
-                       sigc::mem_fun(*this,&studio::Dock_PalEdit::erase_color),
-                       i
-               )
-       ));
-
-       menu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
-
-       menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Load Default Palette"),
-               sigc::mem_fun(*this,&studio::Dock_PalEdit::set_default_palette)
-       ));
-
-       menu->popup(3,gtk_get_current_event_time());
-}
-
-int
-Dock_PalEdit::add_color(const synfig::Color& x)
-{
-       palette_.push_back(x);
-       signal_changed()();
-       refresh();
-       return size()-1;
-}
-
-void
-Dock_PalEdit::set_color(synfig::Color x, int i)
-{
-       palette_[i].color=x;
-       signal_changed()();
-       refresh();
-}
-
-Color
-Dock_PalEdit::get_color(int i)const
-{
-       return palette_[i].color;
-}
-
-void
-Dock_PalEdit::erase_color(int i)
-{
-       palette_.erase(palette_.begin()+i);
-       signal_changed()();
-       refresh();
-}
-
-void
-Dock_PalEdit::refresh()
-{
-       const int width(12);
-
-       // Clear the table
-       table.foreach(sigc::mem_fun(table,&Gtk::Table::remove));
-
-       for(int i=0;i<size();i++)
-       {
-               Widget_Color* widget_color(manage(new Widget_Color()));
-               widget_color->set_value(get_color(i));
-               widget_color->set_size_request(12,12);
-               widget_color->signal_activate().connect(
-                       sigc::bind(
-                               sigc::mem_fun(*this,&studio::Dock_PalEdit::select_fill_color),
-                               i
-                       )
-               );
-               widget_color->signal_middle_click().connect(
-                       sigc::bind(
-                               sigc::mem_fun(*this,&studio::Dock_PalEdit::select_outline_color),
-                               i
-                       )
-               );
-               widget_color->signal_right_click().connect(
-                       sigc::bind(
-                               sigc::mem_fun(*this,&studio::Dock_PalEdit::show_menu),
-                               i
-                       )
-               );
-               int c(i%width),r(i/width);
-               table.attach(*widget_color, c, c+1, r, r+1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       }
-       table.show_all();
-       queue_draw();
-}
-
-
-void
-Dock_PalEdit::edit_color(int i)
-{
-       App::dialog_color->reset();
-       App::dialog_color->set_color(get_color(i));
-       App::dialog_color->signal_edited().connect(
-               sigc::bind(
-                       sigc::mem_fun(*this,&studio::Dock_PalEdit::set_color),
-                       i
-               )
-       );
-       App::dialog_color->present();
-}
-
-void
-Dock_PalEdit::select_fill_color(int i)
-{
-       synfigapp::Main::set_fill_color(get_color(i));
-}
-
-void
-Dock_PalEdit::select_outline_color(int i)
-{
-       synfigapp::Main::set_outline_color(get_color(i));
-}
-
-void
-Dock_PalEdit::set_default_palette()
-{
-       int width=12;
-
-       palette_.clear();
-
-       // Greys
-       palette_.push_back(Color::alpha());
-       for(int i=0;i<width-1;i++)
-       {
-               Color c(
-                       float(i)/(float)(width-2),
-                       float(i)/(float)(width-2),
-                       float(i)/(float)(width-2)
-               );
-               palette_.push_back(c);
-       }
-
-       // Tans
-       for(int i=0;i<width;i++)
-       {
-               float x(float(i)/(float)(width-1));
-               const Color tan1(0.2,0.05,0);
-               const Color tan2(0.85,0.64,0.20);
-
-               palette_.push_back(Color::blend(tan2,tan1,x));
-       }
-
-       // Solids
-       palette_.push_back(Color::red());
-       palette_.push_back(Color(1.0f,0.25f,0.0f));     // Orange
-       palette_.push_back(Color::yellow());
-       palette_.push_back(Color(0.25f,1.00f,0.0f));    // yellow-green
-       palette_.push_back(Color::green());
-       palette_.push_back(Color(0.0f,1.00f,0.25f));    // green-blue
-       palette_.push_back(Color::cyan());
-       palette_.push_back(Color(0.0f,0.25f,1.0f));     // Sea Blue
-       palette_.push_back(Color::blue());
-       palette_.push_back(Color(0.25f,0.0f,1.0f));
-       palette_.push_back(Color::magenta());
-       palette_.push_back(Color(1.0f,0.0f,0.25f));
-
-
-       const int levels(3);
-
-       // Colors
-       for(int j=0;j<levels;j++)
-       for(int i=0;i<width;i++)
-       {
-               Color c(Color::red());
-               c.set_hue(c.get_hue()-Angle::rot(float(i)/(float)(width)));
-               c=c.clamped();
-               float s(float(levels-j)/float(levels));
-               s*=s;
-               c.set_r(c.get_r()*s);
-               c.set_g(c.get_g()*s);
-               c.set_b(c.get_b()*s);
-               palette_.push_back(c);
-       }
-
-
-       /*
-       const int levels(3);
-
-       for(int i=0;i<levels*levels*levels;i++)
-       {
-               Color c(
-                       float(i%levels)/(float)(levels-1),
-                       float(i/levels%levels)/(float)(levels-1),
-                       float(i/(levels*levels))/(float)(levels-1)
-               );
-               palette_.push_back(c);
-       }
-       */
-       refresh();
-}
-
-int
-Dock_PalEdit::size()const
-{
-       return palette_.size();
-}
diff --git a/synfig-studio/src/gtkmm/mod_palette/dock_paledit.h b/synfig-studio/src/gtkmm/mod_palette/dock_paledit.h
deleted file mode 100644 (file)
index cd825ee..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file dock_paledit.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_DOCK_PAL_EDIT_H
-#define __SYNFIG_STUDIO_DOCK_PAL_EDIT_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtk/gtk.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/table.h>
-#include <gtkmm/button.h>
-#include <gtkmm/dialog.h>
-#include <gtkmm/drawingarea.h>
-#include <gtkmm/optionmenu.h>
-#include <gtkmm/checkbutton.h>
-
-#include <synfig/gamma.h>
-#include <synfig/time.h>
-
-#include "../widget_coloredit.h"
-
-#include <synfigapp/value_desc.h>
-#include <synfig/time.h>
-
-#include "../dockable.h"
-#include <vector>
-#include <gtkmm/actiongroup.h>
-
-#include <synfig/palette.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 synfigapp {
-class CanvasInterface;
-};
-
-namespace studio {
-
-class Widget_Color;
-class PaletteSettings;
-
-class Dock_PalEdit : public Dockable
-{
-       friend class PaletteSettings;
-
-       Glib::RefPtr<Gtk::ActionGroup> action_group;
-
-       synfig::Palette palette_;
-
-       Gtk::Table table;
-
-       void on_add_pressed();
-
-       void show_menu(int i);
-
-       sigc::signal<void> signal_changed_;
-
-
-private:
-       int add_color(const synfig::Color& x);
-       void set_color(synfig::Color x, int i);
-       void erase_color(int i);
-
-       void select_fill_color(int i);
-       void select_outline_color(int i);
-       synfig::Color get_color(int i)const;
-       void edit_color(int i);
-public:
-       void set_palette(const synfig::Palette& x);
-       const synfig::Palette& get_palette()const { return palette_; }
-
-       int size()const;
-
-       void set_default_palette();
-
-       void refresh();
-
-       const sigc::signal<void>& signal_changed() { return signal_changed_; }
-
-       Dock_PalEdit();
-       ~Dock_PalEdit();
-}; // END of Dock_PalEdit
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/mod_palette/mod_palette.cpp b/synfig-studio/src/gtkmm/mod_palette/mod_palette.cpp
deleted file mode 100644 (file)
index 53d5fc5..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file mod_palette.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "mod_palette.h"
-#include "dock_paledit.h"
-#include "dock_palbrowse.h"
-
-#include "../app.h"
-#include "../dockmanager.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-bool
-studio::ModPalette::start_vfunc()
-{
-       dock_pal_edit=new Dock_PalEdit();
-       App::get_dock_manager()->register_dockable(*dock_pal_edit);
-
-       //dock_pal_browse=new Dock_PalBrowse();
-       //App::get_dock_manager()->register_dockable(*dock_pal_browse);
-
-       return true;
-}
-
-bool
-studio::ModPalette::stop_vfunc()
-{
-       //App::get_dock_manager()->unregister_dockable(*dock_pal_browse);
-       App::get_dock_manager()->unregister_dockable(*dock_pal_edit);
-
-       delete dock_pal_edit;
-       //delete dock_pal_browse;
-
-       return true;
-}
diff --git a/synfig-studio/src/gtkmm/mod_palette/mod_palette.h b/synfig-studio/src/gtkmm/mod_palette/mod_palette.h
deleted file mode 100644 (file)
index 7b18442..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file mod_palette.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_MOD_PALETTE_H
-#define __SYNFIG_MOD_PALETTE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <ETL/handle>
-#include "../module.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 Dock_PalEdit;
-class Dock_PalBrowse;
-
-class ModPalette : public Module
-{
-       friend class Dock_PalEdit;
-       friend class Dock_PalBrowse;
-
-       Dock_PalEdit*   dock_pal_edit;
-       Dock_PalBrowse* dock_pal_browse;
-
-protected:
-       virtual bool start_vfunc();
-       virtual bool stop_vfunc();
-
-public:
-       virtual ~ModPalette() { stop(); }
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/module.cpp b/synfig-studio/src/gtkmm/module.cpp
deleted file mode 100644 (file)
index ad95ae4..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file gtkmm/module.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "module.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Module::Module():status_(false)
-{
-}
-
-Module::~Module()
-{
-       stop();
-}
-
-bool
-Module::get_status()const
-{
-       return status_;
-}
-
-bool
-Module::start()
-{
-       if(!get_status())
-               status_=start_vfunc();
-       return get_status();
-}
-
-bool
-Module::stop()
-{
-       if(get_status() && count()<=1 && stop_vfunc())
-       {
-               status_=false;
-               return true;
-       }
-       return false;
-}
diff --git a/synfig-studio/src/gtkmm/module.h b/synfig-studio/src/gtkmm/module.h
deleted file mode 100644 (file)
index e814bc4..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file gtkmm/module.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_MODULE_H
-#define __SYNFIG_MODULE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <ETL/handle>
-
-/* === 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 Module : public etl::shared_object
-{
-       bool status_;
-
-protected:
-       Module();
-
-public:
-       virtual ~Module();
-
-       bool start();
-
-       bool stop();
-
-       bool get_status()const;
-
-protected:
-
-       virtual bool start_vfunc()=0;
-       virtual bool stop_vfunc()=0;
-};
-
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/onemoment.cpp b/synfig-studio/src/gtkmm/onemoment.cpp
deleted file mode 100644 (file)
index 75efc2b..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file onemoment.cpp
-**     \brief writeme
-**
-**     $Id$
-**
-**     \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
-**     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
-**
-** === N O T E S ===========================================================
-**
-** ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include <iostream>
-#include <string>
-
-#include <ETL/stringf>
-
-#include <gtkmm/image.h>
-#include <gdkmm/pixbufloader.h>
-#include <gtkmm/button.h>
-#include <gtkmm/label.h>
-#include <gtkmm/fixed.h>
-
-#include <synfig/general.h>
-
-#include "onemoment.h"
-#include "app.h"
-
-#include "general.h"
-
-#endif
-
-using namespace std;
-using namespace etl;
-using namespace studio;
-
-/* === M A C R O S ========================================================= */
-
-#ifndef VERSION
-#define VERSION        "unknown"
-#define PACKAGE        "synfigstudio"
-#endif
-
-#ifdef WIN32
-#      ifdef IMAGE_DIR
-#              undef IMAGE_DIR
-#              define IMAGE_DIR "share\\pixmaps"
-#      endif
-#endif
-
-#ifndef IMAGE_DIR
-#      define IMAGE_DIR "/usr/local/share/pixmaps"
-#endif
-
-#ifndef IMAGE_EXT
-#      define IMAGE_EXT        "png"
-#endif
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-OneMoment::OneMoment():
-       Gtk::Window(getenv("SYNFIG_DISABLE_POPUP_WINDOWS") ? Gtk::WINDOW_TOPLEVEL : Gtk::WINDOW_POPUP)
-{
-       // Create the Label
-       Gtk::Label *label = manage(new class Gtk::Label(_("One Moment, Please...")));
-
-       set_title(_("One Moment, Please..."));
-       set_modal(false);
-       property_window_position().set_value(Gtk::WIN_POS_CENTER);
-       set_resizable(false);
-       add(*label);
-
-       Pango::AttrList attr_list;
-       Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*16));
-       pango_size.set_start_index(0);
-       pango_size.set_end_index(64);
-       attr_list.change(pango_size);
-
-       label->set_attributes(attr_list);
-
-       label->set_size_request(400,60);
-
-       get_root_window()->set_decorations(Gdk::DECOR_BORDER);
-
-       // show everything off
-       show_all();
-
-       present();
-       while(studio::App::events_pending())studio::App::iteration(false);
-}
-
-OneMoment::~OneMoment()
-{
-       hide();
-}
diff --git a/synfig-studio/src/gtkmm/onemoment.h b/synfig-studio/src/gtkmm/onemoment.h
deleted file mode 100644 (file)
index e6e1dd9..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file onemoment.h
-**     \brief Header File
-**
-**     $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
-**
-** === N O T E S ===========================================================
-**
-** ========================================================================= */
-
-/* === S T A R T =========================================================== */
-
-#ifndef __SYNFIG_GTKMM_ONEMOMENT_H
-#define __SYNFIG_GTKMM_ONEMOMENT_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/window.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 synfig { class ProgressCallback; };
-
-namespace studio {
-
-class OneMoment : public Gtk::Window
-{
-public:
-
-       OneMoment();
-       ~OneMoment();
-};
-
-}
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/preview.cpp b/synfig-studio/src/gtkmm/preview.cpp
deleted file mode 100644 (file)
index d681d3e..0000000
+++ /dev/null
@@ -1,893 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file preview.cpp
-**     \brief Preview implementation file
-**
-**     $Id$
-**
-**     \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
-**     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 <config.h>
-#endif
-
-#include "preview.h"
-#include "app.h"
-#include "audiocontainer.h"
-#include <gtkmm/stock.h>
-#include <gtkmm/separator.h>
-
-#include <synfig/target_scanline.h>
-#include <synfig/surface.h>
-
-#include <algorithm>
-#include "asyncrenderer.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-/* === E N T R Y P O I N T ================================================= */
-
-class studio::Preview::Preview_Target : public Target_Scanline
-{
-       Surface surface;
-
-       sigc::signal<void, const Preview_Target *>              signal_frame_done_;
-
-       int scanline;
-
-       double  tbegin,tend;
-
-       int             nframes,curframe;
-
-public:
-
-       Preview_Target()
-       {
-               set_remove_alpha();
-               tbegin = tend = 0;
-               scanline = 0;
-               nframes = curframe = 0;
-       }
-
-       const RendDesc &get_rend_desc() const { return desc; }
-
-       virtual bool set_rend_desc(RendDesc *r)
-       {
-               if(Target_Scanline::set_rend_desc(r))
-               {
-                       /*synfig::warning("Succeeded in setting the desc to new one: %d x %d, %.2f fps [%.2f,%.2f]",
-                                                       desc.get_w(),desc.get_h(),desc.get_frame_rate(),
-                                       (float)desc.get_time_start(),(float)desc.get_time_end());*/
-
-                       surface.set_wh(desc.get_w(),desc.get_h());
-
-                       curframe = 0;
-                       nframes = (int)floor((desc.get_time_end() - desc.get_time_start())*desc.get_frame_rate());
-
-                       tbegin = desc.get_time_start();
-                       tend = tbegin + nframes/desc.get_frame_rate();
-
-                       return true;
-               }
-               return false;
-       }
-
-       virtual bool start_frame(ProgressCallback */*cb*/=NULL)
-       {
-               return true;
-       }
-
-       virtual void end_frame()
-       {
-               //ok... notify our subscribers...
-               signal_frame_done_(this);
-               curframe += 1;
-               //synfig::warning("Finished the frame stuff, and changed time to %.3f",t);
-       }
-
-       virtual Color * start_scanline(int scanline)
-       {
-               return surface[scanline];
-       }
-
-       virtual bool end_scanline() {return true;}
-
-       sigc::signal<void, const Preview_Target *>      &signal_frame_done() {return signal_frame_done_;}
-
-       const Surface &get_surface() const {return surface;}
-
-       float get_time() const
-       {
-               double time = ((nframes-curframe)/(double)nframes)*tbegin
-                                       + ((curframe)/(double)nframes)*tend;
-               return time;
-       }
-};
-
-studio::Preview::Preview(const studio::CanvasView::LooseHandle &h, float zoom, float f)
-:canvasview(h),zoom(zoom),fps(f)
-{
-       overbegin = false;
-       overend = false;
-}
-
-void studio::Preview::set_canvasview(const studio::CanvasView::LooseHandle &h)
-{
-       canvasview = h;
-
-       if(canvasview)
-       {
-               //perhaps reset override values...
-               const RendDesc &r = canvasview->get_canvas()->rend_desc();
-               if(r.get_frame_rate())
-               {
-                       float rate = 1/r.get_frame_rate();
-                       overbegin = false; begintime = r.get_time_start() + r.get_frame_start()*rate;
-                       overend = false; endtime = r.get_time_start() + r.get_frame_end()*rate;
-               }
-       }
-}
-
-studio::Preview::~Preview()
-{
-       signal_destroyed_(this); //tell anything that attached to us, we're dying
-}
-
-void studio::Preview::render()
-{
-       if(canvasview)
-       {
-               //render using the preview target
-               etl::handle<Preview_Target>     target = new Preview_Target;
-
-               //connect our information to his...
-               //synfig::warning("Connecting to the end frame function...");
-               target->signal_frame_done().connect(sigc::mem_fun(*this,&Preview::frame_finish));
-
-               //set the options
-               //synfig::warning("Setting Canvas");
-               target->set_canvas(get_canvas());
-               target->set_quality(quality);
-
-               //render description
-               RendDesc desc = get_canvas()->rend_desc();
-
-               //set the global fps of the preview
-               set_global_fps(desc.get_frame_rate());
-
-               desc.clear_flags();
-
-               int neww = (int)floor(desc.get_w()*zoom+0.5),
-                       newh = (int)floor(desc.get_h()*zoom+0.5);
-               float newfps = fps;
-
-               /*synfig::warning("Setting the render description: %d x %d, %f fps, [%f,%f]",
-                                               neww,newh,newfps, overbegin?begintime:(float)desc.get_time_start(),
-                                               overend?endtime:(float)desc.get_time_end());*/
-
-               desc.set_w(neww);
-               desc.set_h(newh);
-               desc.set_frame_rate(newfps);
-
-               if(overbegin)
-               {
-                       desc.set_time_start(std::max(begintime,(float)desc.get_time_start()));
-                       //synfig::warning("Set start time to %.2f...",(float)desc.get_time_start());
-               }
-               if(overend)
-               {
-                       desc.set_time_end(std::min(endtime,(float)desc.get_time_end()));
-                       //synfig::warning("Set end time to %.2f...",(float)desc.get_time_end());
-               }
-
-               //setting the description
-
-               //HACK - add on one extra frame because the renderer can't render the last frame
-               desc.set_time_end(desc.get_time_end() + 1.000001/fps);
-
-               target->set_rend_desc(&desc);
-
-               //... first we must clear our current selves of space
-               frames.resize(0);
-
-               //now tell it to go... with inherited prog. reporting...
-               //synfig::info("Rendering Asynchronously...");
-               if(renderer) renderer->stop();
-               renderer = new AsyncRenderer(target);
-               renderer->start();
-       }
-}
-
-static void free_guint8(const guint8 *mem)
-{
-       free((void*)mem);
-}
-
-void studio::Preview::frame_finish(const Preview_Target *targ)
-{
-       //copy image with time to next frame (can just push back)
-       FlipbookElem    fe;
-       float time = targ->get_time();
-       const Surface &surf = targ->get_surface();
-       const RendDesc& r = targ->get_rend_desc();
-
-       //synfig::warning("Finished a frame at %f s",time);
-
-       //copy EVERYTHING!
-       PixelFormat pf(PF_RGB);
-       const int total_bytes(r.get_w()*r.get_h()*synfig::channels(pf));
-
-       //synfig::warning("Creating a buffer");
-       unsigned char *buffer((unsigned char*)malloc(total_bytes));
-
-       if(!buffer)
-               return;
-
-       //convert all the pixels to the pixbuf... buffer... thing...
-       //synfig::warning("Converting...");
-       convert_color_format(buffer, surf[0], surf.get_w()*surf.get_h(), pf, App::gamma);
-
-       //load time
-       fe.t = time;
-       //uses and manages the memory for the buffer...
-       //synfig::warning("Create a pixmap...");
-       fe.buf =
-       Gdk::Pixbuf::create_from_data(
-               buffer, // pointer to the data
-               Gdk::COLORSPACE_RGB, // the colorspace
-               ((pf&PF_A)==PF_A), // has alpha?
-               8, // bits per sample
-               surf.get_w(),   // width
-               surf.get_h(),   // height
-               surf.get_w()*synfig::channels(pf), // stride (pitch)
-               sigc::ptr_fun(free_guint8)
-       );
-
-       //add the flipbook element to the list (assume time is correct)
-       //synfig::info("Prev: Adding %f s to the list", time);
-       frames.push_back(fe);
-
-       signal_changed()();
-}
-
-#define IMAGIFY_BUTTON(button,stockid,tooltip)                                 \
-       icon=manage(new Gtk::Image(Gtk::StockID(stockid),Gtk::ICON_SIZE_BUTTON));       \
-       button->add(*icon);     \
-       tooltips.set_tip(*button,tooltip);      \
-       icon->set_padding(0,0);\
-       icon->show();
-
-Widget_Preview::Widget_Preview()
-:Gtk::Table(5,5,false),
-adj_time_scrub(0,0,1000,1,10,0),
-scr_time_scrub(adj_time_scrub),
-b_loop(/*_("Loop")*/),
-currentindex(0),
-audiotime(0),
-adj_sound(0,0,4),
-l_lasttime("0s"),
-playing(false)
-{
-       //connect to expose events
-       //signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Preview::redraw));
-
-       //manage all the change in values etc...
-       adj_time_scrub.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_Preview::slider_move));
-       scr_time_scrub.signal_event().connect(sigc::mem_fun(*this,&Widget_Preview::scroll_move_event));
-       draw_area.signal_expose_event().connect(sigc::mem_fun(*this,&Widget_Preview::redraw));
-
-       disp_sound.set_time_adjustment(&adj_sound);
-       timedisp = -1;
-
-       //Set up signals to modify time value as it should be...
-       disp_sound.signal_start_scrubbing().connect(sigc::mem_fun(*this,&Widget_Preview::scrub_updated));
-       disp_sound.signal_scrub().connect(sigc::mem_fun(*this,&Widget_Preview::scrub_updated));
-
-       /*
-       ---------------------------------
-       |                                                               |
-       |                                                               |
-       |                                                               |
-       |                                                               |
-       |                                                               |
-       |                                                               |
-       |                                                               |
-       ---------------------------------
-       |loop|play|stop                                 | hbox
-       |lastl|lastt|rerender|haltrend  | hbox
-       |
-       |sound                                                  |
-       */
-
-       Gtk::HBox *hbox = 0;
-       Gtk::Button *button = 0;
-       Gtk::Image *icon = 0;
-
-       //should set up the dialog using attach etc.
-       attach(draw_area, 0, 1, 0, 1);
-       attach(scr_time_scrub, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
-
-       #if 1
-
-       //2nd row
-       hbox = manage(new Gtk::HBox);
-
-       button = &b_loop;
-       IMAGIFY_BUTTON(button,Gtk::Stock::REFRESH,_("Toggle Looping"));
-       hbox->pack_start(b_loop,Gtk::PACK_SHRINK,0);
-       //attach(b_loop,0,1,2,3,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK);
-
-       button = manage(new Gtk::Button(/*_("Play")*/));
-       button->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Preview::play));
-       IMAGIFY_BUTTON(button,Gtk::Stock::GO_FORWARD,_("Play"));
-       hbox->pack_start(*button,Gtk::PACK_SHRINK,0);
-       //attach(*button,1,2,2,3,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK);
-
-       button = manage(new Gtk::Button(/*_("Stop")*/));
-       button->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Preview::stop));
-       IMAGIFY_BUTTON(button,Gtk::Stock::NO,_("Stop"));
-       hbox->pack_start(*button,Gtk::PACK_SHRINK,0);
-       //attach(*button,2,3,2,3,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK);
-
-       //attack the stop render and erase all buttons to same line...
-       {
-               Gtk::VSeparator *vsep = manage(new Gtk::VSeparator);
-               hbox->pack_start(*vsep,Gtk::PACK_SHRINK,0);
-       }
-
-       button = manage(new Gtk::Button(/*_("Halt Render")*/));
-       button->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Preview::stoprender));
-       IMAGIFY_BUTTON(button,Gtk::Stock::STOP,_("Halt Render"));
-       hbox->pack_start(*button,Gtk::PACK_SHRINK,0);
-       //attach(*button,2,3,3,4,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK);
-
-       button = manage(new Gtk::Button(/*_("Re-Preview")*/));
-       button->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Preview::repreview));
-       IMAGIFY_BUTTON(button,Gtk::Stock::CONVERT,_("Re-Preview"));
-       hbox->pack_start(*button,Gtk::PACK_SHRINK,0);
-       //attach(*button,0,2,4,5,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK);
-
-       button = manage(new Gtk::Button(/*_("Erase All")*/));
-       button->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Preview::eraseall));
-       IMAGIFY_BUTTON(button,Gtk::Stock::DELETE,_("Erase All"));
-       hbox->pack_start(*button,Gtk::PACK_SHRINK,0);
-       //attach(*button,2,3,4,5,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK);
-
-       hbox->show_all();
-       attach(*hbox,0,1,2,3,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
-
-       //3rd row
-       hbox = manage(new Gtk::HBox);
-       {
-               Gtk::Label *label = manage(new Gtk::Label(_("Last Rendered: ")));
-               //label->show();
-               hbox->pack_start(*label,Gtk::PACK_SHRINK,10);
-               //attach(*manage(new Gtk::Label(_("Last Rendered: "))),0,1,3,4,Gtk::SHRINK,Gtk::SHRINK);
-       }
-       //l_lasttime.show();
-       hbox->pack_start(l_lasttime,Gtk::PACK_SHRINK,0);
-       hbox->show_all();
-       attach(*hbox,0,1,3,4,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK);
-       //attach(l_lasttime,0,1,3,4,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK);
-
-       //5th row
-       disp_sound.set_size_request(-1,32);
-       attach(disp_sound,0,1,4,5,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK);
-
-       show_all();
-
-       //if(draw_area.get_window()) gc_area = Gdk::GC::create(draw_area.get_window());
-       #endif
-}
-
-studio::Widget_Preview::~Widget_Preview()
-{
-}
-
-void studio::Widget_Preview::update()
-{
-       //the meat goes in this locker...
-       double time = adj_time_scrub.get_value();
-
-       //find the frame and display it...
-       if(preview)
-       {
-               //synfig::warning("Updating at %.3f s",time);
-
-               //use time to find closest frame...
-               studio::Preview::FlipBook::const_iterator       beg = preview->begin(),end = preview->end();
-               studio::Preview::FlipBook::const_iterator       i;
-
-               i = beg;
-
-               //go to current hint if need be...
-               if(currentindex >= 0 && currentindex < (int)preview->numframes())
-               {
-                       i = beg+currentindex;
-               }
-
-               //we can't have a picture if there are none to get
-               if(beg != end)
-               {
-                       //don't bother with binary search it will just be slower...
-
-                       //synfig::info("Search for time %f",time);
-
-                       //incrementally go in either direction
-                       //(bias downward towards beg, because that's what we want)
-                       for(;i != end;++i)
-                       {
-                               //synfig::info("Look at %f",i->t);
-                               if(i->t > time) break;
-                               //synfig::info("Go past...");
-                       }
-
-                       //if(i!=beg)--i;
-
-                       //bias down, so we can't be at end... and it still is valid...
-                       for(;i != beg;)
-                       {
-                               --i;
-                               //synfig::info("Look at %f",i->t);
-                               if(i->t <= time) break;
-                               //synfig::info("Go past...");
-                       }
-
-                       /*i = preview->begin(); end = preview->end();
-                       if(i == end) return;
-
-                       j = i;
-                       for(;i != end; j = i++)
-                       {
-                               if(i->t > time) break;
-                       }*/
-
-                       //we should be at a valid edge since we biased downward
-
-                       //don't get the closest, round down... (if we can)
-                       if(i == end)
-                       {
-                               synfig::error("i == end....");
-                               //assert(0);
-                               currentbuf.clear();
-                               currentindex = 0;
-                               timedisp = -1;
-                       }else
-                       {
-                               currentbuf = i->buf;
-                               currentindex = i-beg;
-                               if(timedisp != i->t)
-                               {
-                                       timedisp = i->t;
-                                       //synfig::warning("Update at: %f seconds (%f s)",time,timedisp);
-                                       preview_draw();
-                                       //synfig::warning("success!");
-                               }
-                       }
-               }
-       }
-
-       if(disp_sound.get_profile() && adj_sound.get_value() != time)
-       {
-               //timeupdate = time;
-
-               //Set the position of the sound (short circuited for sound modifying the time)
-
-               disp_sound.set_position(time);
-               disp_sound.queue_draw();
-       }
-}
-void studio::Widget_Preview::preview_draw()
-{
-       draw_area.queue_draw();//on_expose_event();
-}
-
-bool studio::Widget_Preview::redraw(GdkEventExpose */*heh*/)
-{
-       //And render the drawing area
-       Glib::RefPtr<Gdk::Pixbuf> pxnew, px = currentbuf;
-
-       if(!px || draw_area.get_height() == 0
-               || px->get_height() == 0 || px->get_width() == 0 /*|| is_visible()*/) //made not need this line
-               return true;
-
-       //figure out the scaling factors...
-       float sx, sy;
-       int nw,nh;
-
-       sx = draw_area.get_width() / (float)px->get_width();
-       sy = draw_area.get_height() / (float)px->get_height();
-
-       //synfig::info("widget_preview redraw: now to scale the bitmap: %.3f x %.3f",sx,sy);
-
-       //round to smallest scale (fit entire thing in window without distortion)
-       if(sx > sy) sx = sy;
-       //else sy = sx;
-
-       //scale to a new pixmap and then copy over to the window
-       nw = (int)(px->get_width()*sx);
-       nh = (int)(px->get_height()*sx);
-
-       if(nw == 0 || nh == 0)return true;
-
-       pxnew = px->scale_simple(nw,nh,Gdk::INTERP_NEAREST);
-
-       //synfig::info("Now to draw to the window...");
-       //copy to window
-       Glib::RefPtr<Gdk::Window>       wind = draw_area.get_window();
-       Glib::RefPtr<Gdk::Drawable> surf = Glib::RefPtr<Gdk::Drawable>::cast_static(wind);
-       Glib::RefPtr<Gdk::GC>           gc = Gdk::GC::create(wind);
-
-       {
-               Gdk::Rectangle r(0,0,draw_area.get_width(),draw_area.get_height());
-               draw_area.get_window()->begin_paint_rect(r);
-       }
-
-       if(!wind) synfig::warning("The destination window is broken...");
-       if(!surf) synfig::warning("The destination is not drawable...");
-
-       if(surf)
-       {
-               /* Options for drawing...
-                       1) store with alpha, then clear and render with alpha every frame
-                               - more time consuming
-                               + more expandable
-                       2) store with just pixel info
-                               - less expandable
-                               + faster
-                               + better memory footprint
-               */
-               //px->composite(const Glib::RefPtr<Gdk::Pixbuf>& dest, int dest_x, int dest_y, int dest_width, int dest_height, double offset_x, double offset_y, double scale_x, double scale_y, InterpType interp_type, int overall_alpha) const
-
-               surf->draw_pixbuf(
-                       gc, //GC
-                       pxnew, //pixbuf
-                       0, 0,   // Source X and Y
-                       0, 0,   // Dest X and Y
-                       -1,-1,  // Width and Height
-                       Gdk::RGB_DITHER_NONE, // RgbDither
-                       0, 0 // Dither offset X and Y
-               );
-
-               if(timedisp >= 0)
-               {
-                       Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_pango_context()));
-                       Glib::ustring timecode(Time((double)timedisp).round(preview->get_global_fps())
-                                                                                                                       .get_string(preview->get_global_fps(),
-                                                                                                                                                       App::get_time_format()));
-                       //synfig::info("Time for preview draw is: %s for time %g", timecode.c_str(), adj_time_scrub.get_value());
-
-                       gc->set_rgb_fg_color(Gdk::Color("#FF0000"));
-                       layout->set_text(timecode);
-                       surf->draw_layout(gc,4,4,layout);
-               }
-       }
-
-       draw_area.get_window()->end_paint();
-
-       //synfig::warning("Refresh the draw area");
-       //make sure the widget refreshes
-
-       return false;
-}
-
-bool studio::Widget_Preview::play_update()
-{
-       float diff = timer.pop_time();
-       //synfig::info("Play update: diff = %.2f",diff);
-
-       if(playing)
-       {
-               //we go to the next one...
-               double time = adj_time_scrub.get_value() + diff;
-
-               //adjust it to be synced with the audio if it can...
-               {
-                       double newtime = audiotime;
-                       if(audio && audio->is_playing()) audio->get_current_time(newtime);
-
-                       if(newtime != audiotime)
-                       {
-                               //synfig::info("Adjusted time from %.3lf to %.3lf", time,newtime);
-                               time = audiotime = newtime;
-                       }
-               }
-
-               //Looping conditions...
-               if(time >= adj_time_scrub.get_upper())
-               {
-                       if(get_loop_flag())
-                       {
-                               time = adj_time_scrub.get_lower();// + time-adj_time_scrub.get_upper();
-                               currentindex = 0;
-                       }else
-                       {
-                               time = adj_time_scrub.get_upper();
-                               adj_time_scrub.set_value(time);
-                               play_stop();
-                               update();
-
-                               //synfig::info("Play Stopped: time set to %f",adj_time_scrub.get_value());
-                               return false;
-                       }
-               }
-
-               //set the new time...
-               adj_time_scrub.set_value(time);
-               adj_time_scrub.value_changed();
-
-               //update the window to the correct image we might want to do this later...
-               //update();
-               //synfig::warning("Did update pu");
-       }
-       return true;
-}
-
-void studio::Widget_Preview::slider_move()
-{
-       //if(!playing)
-       {
-               update();
-               //synfig::warning("Did update sm");
-       }
-}
-
-//for other things updating the value changed signal...
-void studio::Widget_Preview::scrub_updated(double t)
-{
-       stop();
-
-       //Attempt at being more accurate... the time is adjusted to be exactly where the sound says it is
-       //double oldt = t;
-       if(audio)
-       {
-               if(!audio->isPaused())
-               {
-                       audio->get_current_time(t);
-               }
-       }
-
-       //synfig::info("Scrubbing to %.3f, setting adj to %.3f",oldt,t);
-
-       if(adj_time_scrub.get_value() != t)
-       {
-               adj_time_scrub.set_value(t);
-               adj_time_scrub.value_changed();
-       }
-}
-
-void studio::Widget_Preview::disconnect_preview(Preview *prev)
-{
-       if(prev == preview)
-       {
-               preview = 0;
-               prevchanged.disconnect();
-       }
-}
-
-void studio::Widget_Preview::set_preview(etl::handle<Preview>  prev)
-{
-       preview = prev;
-
-       synfig::info("Setting preview");
-
-       //stop playing the mini animation...
-       stop();
-
-       if(preview)
-       {
-               //set the internal values
-               float rate = preview->get_fps();
-               synfig::info("  FPS = %f",rate);
-               if(rate)
-               {
-                       float start = preview->get_begintime();
-                       float end = preview->get_endtime();
-
-                       rate = 1/rate;
-
-                       adj_time_scrub.set_lower(start);
-                       adj_time_scrub.set_upper(end);
-                       adj_time_scrub.set_value(start);
-                       adj_time_scrub.set_step_increment(rate);
-                       adj_time_scrub.set_page_increment(10*rate);
-
-                       //if the begin time and the end time are the same there is only a single frame
-                       singleframe = end==start;
-               }else
-               {
-                       adj_time_scrub.set_lower(0);
-                       adj_time_scrub.set_upper(0);
-                       adj_time_scrub.set_value(0);
-                       adj_time_scrub.set_step_increment(0);
-                       adj_time_scrub.set_page_increment(0);
-                       singleframe = true;
-               }
-
-               //connect so future information will be found...
-               prevchanged = prev->signal_changed().connect(sigc::mem_fun(*this,&Widget_Preview::whenupdated));
-               prev->signal_destroyed().connect(sigc::mem_fun(*this,&Widget_Preview::disconnect_preview));
-               update();
-               //synfig::warning("Did update sp");
-               queue_draw();
-       }
-}
-
-void studio::Widget_Preview::whenupdated()
-{
-       l_lasttime.set_text((Time((double)(--preview->end())->t)
-                                                       .round(preview->get_global_fps())
-                                                       .get_string(preview->get_global_fps(),App::get_time_format())));
-       update();
-}
-
-void studio::Widget_Preview::clear()
-{
-       preview = 0;
-       prevchanged.disconnect();
-}
-
-void studio::Widget_Preview::play()
-{
-       if(preview && !playing)
-       {
-               //synfig::info("Playing at %lf",adj_time_scrub.get_value());
-               //audiotime = adj_time_scrub.get_value();
-               playing = true;
-
-               //adj_time_scrub.set_value(adj_time_scrub.get_lower());
-               update(); //we don't want to call play update because that will try to advance the timer
-               //synfig::warning("Did update p");
-
-               //approximate length of time in seconds, right?
-               double rate = /*std::min(*/adj_time_scrub.get_step_increment()/*,1/30.0)*/;
-               int timeout = (int)floor(1000*rate);
-
-               //synfig::info("        rate = %.3lfs = %d ms",rate,timeout);
-
-               signal_play_(adj_time_scrub.get_value());
-
-               //play the audio...
-               if(audio) audio->play(adj_time_scrub.get_value());
-
-               timecon = Glib::signal_timeout().connect(sigc::mem_fun(*this,&Widget_Preview::play_update),timeout);
-               timer.reset();
-       }
-
-}
-
-void studio::Widget_Preview::play_stop()
-{
-       playing = false;
-       signal_stop()();
-       if(audio) audio->stop(); //!< stop the audio
-       //synfig::info("Stopping...");
-}
-
-void studio::Widget_Preview::stop()
-{
-       //synfig::warning("stopping");
-       play_stop();
-       timecon.disconnect();
-}
-
-bool studio::Widget_Preview::scroll_move_event(GdkEvent *event)
-{
-       switch(event->type)
-       {
-               case GDK_BUTTON_PRESS:
-               {
-                       if(event->button.button == 1 || event->button.button == 3)
-                       {
-                               stop();
-                       }
-               }
-
-               default: break;
-       }
-
-       return false;
-}
-
-void studio::Widget_Preview::set_audioprofile(etl::handle<AudioProfile> p)
-{
-       disp_sound.set_profile(p);
-}
-
-void studio::Widget_Preview::set_audio(etl::handle<AudioContainer> a)
-{
-       audio = a;
-
-       //disconnect any previous signals
-       scrstartcon.disconnect(); scrstopcon.disconnect(); scrubcon.disconnect();
-
-       //connect the new signals
-       scrstartcon = disp_sound.signal_start_scrubbing().connect(sigc::mem_fun(*a,&AudioContainer::start_scrubbing));
-       scrstopcon = disp_sound.signal_stop_scrubbing().connect(sigc::mem_fun(*a,&AudioContainer::stop_scrubbing));
-       scrubcon = disp_sound.signal_scrub().connect(sigc::mem_fun(*a,&AudioContainer::scrub));
-}
-
-void studio::Widget_Preview::seek(float t)
-{
-       stop();
-       adj_time_scrub.set_value(t);
-}
-
-void studio::Widget_Preview::repreview()
-{
-       if(preview)
-       {
-               stoprender();
-               stop();
-               preview->get_canvasview()->preview_option();
-       }
-}
-
-void studio::Widget_Preview::stoprender()
-{
-       if(preview)
-       {
-               // don't crash if the render has already been stopped
-               if (!preview->renderer)
-                       return;
-
-#ifdef SINGLE_THREADED
-               if (preview->renderer->updating)
-                       preview->renderer->stop();
-               else
-#endif
-                       preview->renderer.detach();
-       }
-}
-
-void studio::Widget_Preview::eraseall()
-{
-       stop();
-       stoprender();
-
-       currentbuf.clear();
-       currentindex = 0;
-       timedisp = 0;
-       queue_draw();
-
-       if(preview)
-       {
-               preview->clear();
-       }
-}
diff --git a/synfig-studio/src/gtkmm/preview.h b/synfig-studio/src/gtkmm/preview.h
deleted file mode 100644 (file)
index 962a537..0000000
+++ /dev/null
@@ -1,260 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file preview.h
-**     \brief Previews an animation
-**
-**     $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_PREVIEW_H
-#define __SYNFIG_PREVIEW_H
-
-/* === H E A D E R S ======================================================= */
-#include <ETL/handle>
-#include <ETL/clock> /* indirectly includes winnt.h on WIN32 - needs to be included before gtkmm headers, which fix this */
-
-#include <gtkmm/drawingarea.h>
-#include <gtkmm/table.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/image.h>
-#include <gdkmm/pixbuf.h>
-#include <gtkmm/dialog.h>
-#include <gtkmm/scrollbar.h>
-#include <gtkmm/checkbutton.h>
-#include <gtkmm/canvasview.h>
-#include <gtkmm/tooltips.h>
-
-#include <synfig/time.h>
-#include <synfig/vector.h>
-#include <synfig/general.h>
-#include <synfig/renddesc.h>
-#include <synfig/canvas.h>
-
-#include "widget_sound.h"
-
-#include <vector>
-
-/* === 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 AsyncRenderer;
-
-class Preview : public sigc::trackable, public etl::shared_object
-{
-public:
-       struct FlipbookElem
-       {
-               float                                           t;
-               Glib::RefPtr<Gdk::Pixbuf>       buf; //at whatever resolution they are rendered at (resized at run time)
-       };
-
-       etl::handle<studio::AsyncRenderer>      renderer;
-
-       sigc::signal<void, Preview *>   signal_destroyed_;      //so things can reference us without fear
-
-       typedef std::vector<FlipbookElem>        FlipBook;
-private:
-
-       FlipBook                        frames;
-
-       studio::CanvasView::LooseHandle canvasview;
-
-       //synfig::RendDesc              description; //for rendering the preview...
-       float   zoom,fps;
-       float   begintime,endtime;
-       bool    overbegin,overend;
-       int             quality;
-
-       float   global_fps;
-
-       //expose the frame information etc.
-       class Preview_Target;
-       void frame_finish(const Preview_Target *);
-
-       sigc::signal0<void>     sig_changed;
-
-public:
-
-       Preview(const studio::CanvasView::LooseHandle &h = studio::CanvasView::LooseHandle(),
-                               float zoom = 0.5f, float fps = 15);
-       ~Preview();
-
-       float   get_zoom() const {return zoom;}
-       void    set_zoom(float z){zoom = z;}
-
-       float   get_fps() const {return fps;}
-       void    set_fps(float f){fps = f;}
-
-       float   get_global_fps() const {return global_fps;}
-       void    set_global_fps(float f){global_fps = f;}
-
-       float   get_begintime() const
-       {
-               if(overbegin)
-                       return begintime;
-               else if(canvasview)
-                       return get_canvas()->rend_desc().get_time_start();
-               else return -1;
-       }
-
-       float   get_endtime() const
-       {
-               if(overend)
-                       return endtime;
-               else if(canvasview)
-                       return get_canvas()->rend_desc().get_time_end();
-               else return -1;
-       }
-
-       void    set_begintime(float t)  {begintime = t;}
-       void    set_endtime(float t)    {endtime = t;}
-
-       bool get_overbegin() const {return overbegin;}
-       void set_overbegin(bool b) {overbegin = b;}
-
-       bool get_overend() const {return overend;}
-       void set_overend(bool b) {overend = b;}
-
-       int             get_quality() const {return quality;}
-       void    set_quality(int i)      {quality = i;}
-
-       synfig::Canvas::Handle  get_canvas() const {return canvasview->get_canvas();}
-       studio::CanvasView::Handle      get_canvasview() const {return canvasview;}
-
-       void set_canvasview(const studio::CanvasView::LooseHandle &h);
-
-       //signal interface
-       sigc::signal<void, Preview *> & signal_destroyed() { return signal_destroyed_; }
-       //sigc::signal<void, const synfig::RendDesc &>  &signal_desc_change() {return signal_desc_change_;}
-
-       //functions for exposing iterators through the preview
-       FlipBook::iterator      begin()         {return frames.begin();}
-       FlipBook::iterator      end()           {return frames.end();}
-
-       FlipBook::const_iterator        begin() const {return frames.begin();}
-       FlipBook::const_iterator        end() const       {return frames.end();}
-
-       void clear() {frames.clear();}
-
-       unsigned int                            numframes() const  {return frames.size();}
-
-       void render();
-
-       sigc::signal0<void>     &signal_changed() { return sig_changed; }
-};
-
-class Widget_Preview : public Gtk::Table
-{
-       Gtk::DrawingArea        draw_area;
-       Gtk::Adjustment         adj_time_scrub; //the adjustment for the managed scrollbar
-       Gtk::HScrollbar         scr_time_scrub;
-       Gtk::ToggleButton       b_loop;
-       Gtk::Tooltips           tooltips;
-
-       //Glib::RefPtr<Gdk::GC>         gc_area;
-       Glib::RefPtr<Gdk::Pixbuf>       currentbuf;
-       int                                                     currentindex;
-       //double                                                timeupdate;
-       double                                          timedisp;
-       double                                          audiotime;
-
-       //sound stuff
-       etl::handle<AudioContainer>     audio;
-       sigc::connection        scrstartcon;
-       sigc::connection        scrstopcon;
-       sigc::connection        scrubcon;
-
-       //preview encapsulation
-       etl::handle<Preview>    preview;
-       sigc::connection                prevchanged;
-
-       Widget_Sound                    disp_sound;
-       Gtk::Adjustment                 adj_sound;
-
-       Gtk::Label                              l_lasttime;
-
-       //only for internal stuff, doesn't set anything
-       bool    playing;
-       bool    singleframe;
-
-       //for accurate time tracking
-       etl::clock      timer;
-
-       //int           curindex; //for later
-       sigc::connection        timecon;
-
-       void slider_move(); //later to be a time_slider that's cooler
-       bool play_update();
-       void play_stop();
-       //bool play_frameupdate();
-       void update();
-
-       void scrub_updated(double t);
-
-       void repreview();
-
-       void whenupdated();
-
-       void eraseall();
-
-       bool scroll_move_event(GdkEvent *);
-       void disconnect_preview(Preview *);
-
-       bool redraw(GdkEventExpose *heh = 0);
-       void preview_draw();
-
-       sigc::signal<void,float>        signal_play_;
-       sigc::signal<void>                      signal_stop_;
-       sigc::signal<void,float>        signal_seek_;
-
-public:
-
-       Widget_Preview();
-       ~Widget_Preview();
-
-       //sets a signal to identify disconnection (so we don't hold onto it)...
-       void set_preview(etl::handle<Preview> prev);
-       void set_audioprofile(etl::handle<AudioProfile> p);
-       void set_audio(etl::handle<AudioContainer> a);
-
-       void clear();
-
-       void play();
-       void stop();
-       void seek(float t);
-
-       void stoprender();
-
-       sigc::signal<void,float>        &signal_play() {return signal_play_;}
-       sigc::signal<void>      &signal_stop() {return signal_stop_;}
-       sigc::signal<void,float>        &signal_seek() {return signal_seek_;}
-
-       bool get_loop_flag() const {return b_loop.get_active();}
-       void set_loop_flag(bool b) {return b_loop.set_active(b);}
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/renddesc.cpp b/synfig-studio/src/gtkmm/renddesc.cpp
deleted file mode 100644 (file)
index c88ac87..0000000
+++ /dev/null
@@ -1,620 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file gtkmm/renddesc.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \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
-**     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 <config.h>
-#endif
-
-#include "renddesc.h"
-#include <gtkmm/label.h>
-#include <gtkmm/frame.h>
-#include <gtkmm/alignment.h>
-#include <gtkmm/box.h>
-#include <ETL/misc>
-#include <synfig/general.h>
-//#include <gtkmm/separator.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 ========================================================= */
-
-#ifndef SYNFIG_MAX_PIXEL_WIDTH
-#define SYNFIG_MAX_PIXEL_WIDTH (~(1<<31))
-#endif
-
-#ifndef SYNFIG_MAX_PIXEL_HEIGHT
-#define SYNFIG_MAX_PIXEL_HEIGHT        (~(1<<31))
-#endif
-
-#ifndef DPM2DPI
-#define DPM2DPI(x)     ((x)/39.3700787402)
-#define DPI2DPM(x)     ((x)*39.3700787402)
-#endif
-
-#ifndef METERS2INCHES
-#define METERS2INCHES(x)       ((x)*39.3700787402)
-#define INCHES2METERS(x)       ((x)/39.3700787402)
-#endif
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Widget_RendDesc::Widget_RendDesc():
-       Gtk::Notebook(),
-       adjustment_width(1,1,SYNFIG_MAX_PIXEL_WIDTH),
-       adjustment_height(1,1,SYNFIG_MAX_PIXEL_HEIGHT),
-       adjustment_xres(0,0.0000000001,10000000),
-       adjustment_yres(0,0.0000000001,10000000),
-       adjustment_phy_width(0,0.0000000001,10000000),
-       adjustment_phy_height(0,0.0000000001,10000000),
-       adjustment_fps(0,0.0000000001,10000000),
-       adjustment_span(0,0.0000000001,10000000)
-{
-       update_lock=0;
-
-       create_widgets();
-       connect_signals();
-
-       Gtk::Label *image_tab_label = manage(new Gtk::Label(_("Image")));
-       Gtk::Label *time_tab_label = manage(new Gtk::Label(_("Time")));
-       Gtk::Label *other_tab_label = manage(new Gtk::Label(_("Other")));
-       Gtk::Widget *imageTab = create_image_tab();
-       Gtk::Widget *timeTab = create_time_tab();
-       Gtk::Widget *otherTab = create_other_tab();
-       append_page(*imageTab, *image_tab_label);
-       append_page(*timeTab, *time_tab_label);
-       append_page(*otherTab, *other_tab_label);
-}
-
-Widget_RendDesc::~Widget_RendDesc()
-{
-}
-
-void Widget_RendDesc::set_rend_desc(const synfig::RendDesc &rend_desc)
-{
-       if(update_lock)return;
-
-       rend_desc_=rend_desc;
-       refresh();
-}
-
-void
-Widget_RendDesc::refresh()
-{
-       UpdateLock lock(update_lock);
-       adjustment_width.set_value(rend_desc_.get_w());
-       adjustment_height.set_value(rend_desc_.get_h());
-       adjustment_phy_width.set_value(METERS2INCHES(rend_desc_.get_physical_w()));
-       adjustment_phy_height.set_value(METERS2INCHES(rend_desc_.get_physical_h()));
-       adjustment_xres.set_value(DPM2DPI(rend_desc_.get_x_res()));
-       adjustment_yres.set_value(DPM2DPI(rend_desc_.get_y_res()));
-       entry_start_time->set_fps(rend_desc_.get_frame_rate());
-       entry_start_time->set_value(rend_desc_.get_time_start());
-       entry_end_time->set_fps(rend_desc_.get_frame_rate());
-       entry_end_time->set_value(rend_desc_.get_time_end());
-
-       adjustment_fps.set_value(rend_desc_.get_frame_rate());
-       adjustment_span.set_value(rend_desc_.get_span());
-       entry_tl->set_value(rend_desc_.get_tl());
-       entry_br->set_value(rend_desc_.get_br());
-       entry_focus->set_value(rend_desc_.get_focus());
-
-       toggle_px_aspect->set_active((bool)(rend_desc_.get_flags()&RendDesc::PX_ASPECT));
-       toggle_px_width->set_active((bool)(rend_desc_.get_flags()&RendDesc::PX_W));
-       toggle_px_height->set_active((bool)(rend_desc_.get_flags()&RendDesc::PX_H));
-
-       toggle_im_aspect->set_active((bool)(rend_desc_.get_flags()&RendDesc::IM_ASPECT));
-       toggle_im_width->set_active((bool)(rend_desc_.get_flags()&RendDesc::IM_W));
-       toggle_im_height->set_active((bool)(rend_desc_.get_flags()&RendDesc::IM_H));
-       toggle_im_span->set_active((bool)(rend_desc_.get_flags()&RendDesc::IM_SPAN));
-}
-
-void Widget_RendDesc::apply_rend_desc(const synfig::RendDesc &rend_desc)
-{
-       set_rend_desc(rend_desc);
-}
-
-const synfig::RendDesc &
-Widget_RendDesc::get_rend_desc()
-{
-       return rend_desc_;
-}
-
-void
-Widget_RendDesc::on_width_changed()
-{
-       if(update_lock)return;
-       UpdateLock lock(update_lock);
-       rend_desc_.set_w(round_to_int(adjustment_width.get_value()));
-       refresh();
-       signal_changed()();
-}
-
-void
-Widget_RendDesc::on_lock_changed()
-{
-       if(update_lock)return;
-       UpdateLock lock(update_lock);
-
-#define DO_TOGGLE(x,y) if(toggle_ ## x->get_active()) \
-               rend_desc_.set_flags(rend_desc_.get_flags()|RendDesc:: y); \
-       else \
-               rend_desc_.set_flags(rend_desc_.get_flags()&~RendDesc:: y)
-
-       DO_TOGGLE(px_aspect,PX_ASPECT);
-       DO_TOGGLE(px_width,PX_W);
-       DO_TOGGLE(px_height,PX_H);
-
-       DO_TOGGLE(im_aspect,IM_ASPECT);
-       DO_TOGGLE(im_width,IM_W);
-       DO_TOGGLE(im_height,IM_H);
-       DO_TOGGLE(im_span,IM_SPAN);
-
-#undef DO_TOGGLE
-
-       refresh();
-       signal_changed()();
-}
-
-void
-Widget_RendDesc::on_height_changed()
-{
-       if(update_lock)return;
-       UpdateLock lock(update_lock);
-       rend_desc_.set_h(round_to_int(adjustment_height.get_value()));
-       refresh();
-       signal_changed()();
-}
-
-void
-Widget_RendDesc::on_phy_width_changed()
-{
-       if(update_lock)return;
-       UpdateLock lock(update_lock);
-       rend_desc_.set_physical_w(INCHES2METERS(adjustment_phy_width.get_value()));
-       refresh();
-       signal_changed()();
-}
-
-void
-Widget_RendDesc::on_phy_height_changed()
-{
-       if(update_lock)return;
-       UpdateLock lock(update_lock);
-       rend_desc_.set_physical_h(INCHES2METERS(adjustment_phy_height.get_value()));
-       refresh();
-       signal_changed()();
-}
-
-void
-Widget_RendDesc::on_xres_changed()
-{
-       if(update_lock)return;
-       UpdateLock lock(update_lock);
-       rend_desc_.set_x_res(DPI2DPM(adjustment_xres.get_value()));
-       refresh();
-       signal_changed()();
-}
-
-void
-Widget_RendDesc::on_yres_changed()
-{
-       if(update_lock)return;
-       UpdateLock lock(update_lock);
-       rend_desc_.set_y_res(DPI2DPM(adjustment_yres.get_value()));
-       refresh();
-       signal_changed()();
-}
-
-void
-Widget_RendDesc::on_start_time_changed()
-{
-       if(update_lock)return;
-       UpdateLock lock(update_lock);
-       rend_desc_.set_time_start(entry_start_time->get_value());
-       refresh();
-       signal_changed()();
-}
-
-void
-Widget_RendDesc::on_end_time_changed()
-{
-       if(update_lock)return;
-       UpdateLock lock(update_lock);
-       rend_desc_.set_time_end(entry_end_time->get_value());
-       refresh();
-       signal_changed()();
-}
-
-/*
-void
-Widget_RendDesc::on_start_frame_changed()
-{
-       if(update_lock)return;
-       UpdateLock lock(update_lock);
-       rend_desc_.set_frame_start((int)(adjustment_start_frame.get_value()+0.5));
-       refresh();
-       signal_changed()();
-}
-
-void
-Widget_RendDesc::on_end_frame_changed()
-{
-       if(update_lock)return;
-       UpdateLock lock(update_lock);
-       rend_desc_.set_frame_end((int)(adjustment_end_frame.get_value()+0.5));
-       refresh();
-       signal_changed()();
-}
-*/
-
-void
-Widget_RendDesc::on_fps_changed()
-{
-       if(update_lock)return;
-       UpdateLock lock(update_lock);
-       rend_desc_.set_frame_rate((int)(adjustment_fps.get_value()+0.5));
-       refresh();
-       signal_changed()();
-}
-
-void
-Widget_RendDesc::on_tl_changed()
-{
-       if(update_lock)return;
-       UpdateLock lock(update_lock);
-       rend_desc_.set_tl(entry_tl->get_value());
-       refresh();
-       signal_changed()();
-}
-
-void
-Widget_RendDesc::on_br_changed()
-{
-       if(update_lock)return;
-       UpdateLock lock(update_lock);
-       rend_desc_.set_br(entry_br->get_value());
-       refresh();
-       signal_changed()();
-}
-
-void
-Widget_RendDesc::on_focus_changed()
-{
-       if(update_lock)return;
-       UpdateLock lock(update_lock);
-       rend_desc_.set_focus(entry_focus->get_value());
-       refresh();
-       signal_changed()();
-}
-
-void
-Widget_RendDesc::on_span_changed()
-{
-       if(update_lock)return;
-       UpdateLock lock(update_lock);
-       rend_desc_.set_span(adjustment_span.get_value());
-       refresh();
-       signal_changed()();
-}
-
-void
-Widget_RendDesc::disable_time_section()
-{
-       time_frame->set_sensitive(false);
-
-/*
-       Gtk::Table::TableList &list=time_table->children();
-       Gtk::Table::TableList::iterator iter;
-       for(iter=list.begin();iter!=list.end();iter++)
-               iter->get_widget()->set_sensitive(false);
-*/
-}
-
-void
-Widget_RendDesc::enable_time_section()
-{
-       time_frame->set_sensitive(true);
-
-/*
-       Gtk::Table::TableList &list=time_table->children();
-       Gtk::Table::TableList::iterator iter;
-       for(iter=list.begin();iter!=list.end();iter++)
-               iter->get_widget()->set_sensitive(true);
-
-*/
-}
-
-void
-Widget_RendDesc::create_widgets()
-{
-       entry_width=manage(new Gtk::SpinButton(adjustment_width,1,0));
-       entry_width->set_alignment(1);
-       entry_height=manage(new Gtk::SpinButton(adjustment_height,1,0));
-       entry_height->set_alignment(1);
-       entry_xres=manage(new Gtk::SpinButton(adjustment_xres,0.5,1));
-       entry_xres->set_alignment(1);
-       entry_yres=manage(new Gtk::SpinButton(adjustment_yres,0.5,1));
-       entry_yres->set_alignment(1);
-       entry_phy_width=manage(new Gtk::SpinButton(adjustment_phy_width,0.25,2));
-       entry_phy_width->set_alignment(1);
-       entry_phy_height=manage(new Gtk::SpinButton(adjustment_phy_height,0.25,2));
-       entry_phy_height->set_alignment(1);
-       entry_span=manage(new Gtk::SpinButton(adjustment_span,0.1,4));
-       entry_span->set_alignment(1);
-       entry_tl=manage(new Widget_Vector());
-       entry_br=manage(new Widget_Vector());
-       entry_fps=manage(new Gtk::SpinButton(adjustment_fps,1,5));
-       entry_start_time=manage(new Widget_Time());
-       entry_end_time=manage(new Widget_Time());
-       //entry_start_frame=manage(new Gtk::SpinButton(adjustment_start_frame,1,0));
-       //entry_end_frame=manage(new Gtk::SpinButton(adjustment_end_frame,1,0));
-       entry_focus=manage(new Widget_Vector());
-       toggle_px_aspect=manage(new Gtk::CheckButton(_("_Pixel Aspect"), true));
-       toggle_px_aspect->set_alignment(0, 0.5);
-       toggle_px_width=manage(new Gtk::CheckButton(_("Pi_xel Width"), true));
-       toggle_px_width->set_alignment(0, 0.5);
-       toggle_px_height=manage(new Gtk::CheckButton(_("Pix_el Height"), true));
-       toggle_px_height->set_alignment(0, 0.5);
-       toggle_im_aspect=manage(new Gtk::CheckButton(_("Image _Aspect"), true));
-       toggle_im_aspect->set_alignment(0, 0.5);
-       toggle_im_width=manage(new Gtk::CheckButton(_("Image _Width"), true));
-       toggle_im_width->set_alignment(0, 0.5);
-       toggle_im_height=manage(new Gtk::CheckButton(_("Image _Height"), true));
-       toggle_im_height->set_alignment(0, 0.5);
-       toggle_im_span=manage(new Gtk::CheckButton(_("Image _Span"), true));
-       toggle_im_span->set_alignment(0, 0.5);
-}
-
-void
-Widget_RendDesc::connect_signals()
-{
-       entry_width->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_width_changed));
-       entry_height->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_height_changed));
-       entry_xres->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_xres_changed));
-       entry_yres->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_yres_changed));
-       entry_phy_width->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_phy_width_changed));
-       entry_phy_height->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_phy_height_changed));
-       entry_span->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_span_changed));
-       entry_tl->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_tl_changed));
-       entry_br->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_br_changed));
-       entry_fps->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_fps_changed));
-       entry_start_time->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_start_time_changed));
-       entry_end_time->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_end_time_changed));
-       //entry_start_frame->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_start_frame_changed));
-       //entry_end_frame->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_end_frame_changed));
-       entry_focus->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_focus_changed));
-       toggle_px_aspect->signal_toggled().connect(sigc::mem_fun(*this, &studio::Widget_RendDesc::on_lock_changed));
-       toggle_px_width->signal_toggled().connect(sigc::mem_fun(*this, &studio::Widget_RendDesc::on_lock_changed));
-       toggle_px_height->signal_toggled().connect(sigc::mem_fun(*this, &studio::Widget_RendDesc::on_lock_changed));
-       toggle_im_aspect->signal_toggled().connect(sigc::mem_fun(*this, &studio::Widget_RendDesc::on_lock_changed));
-       toggle_im_width->signal_toggled().connect(sigc::mem_fun(*this, &studio::Widget_RendDesc::on_lock_changed));
-       toggle_im_height->signal_toggled().connect(sigc::mem_fun(*this, &studio::Widget_RendDesc::on_lock_changed));
-       toggle_im_span->signal_toggled().connect(sigc::mem_fun(*this, &studio::Widget_RendDesc::on_lock_changed));
-}
-
-Gtk::Widget *
-Widget_RendDesc::create_image_tab()
-{
-       Gtk::Alignment *paddedPanel = manage(new Gtk::Alignment(0, 0, 1, 1));
-       paddedPanel->set_padding(12, 12, 12, 12);
-
-       Gtk::VBox *panelBox = manage(new Gtk::VBox(false, 12));
-       paddedPanel->add(*panelBox);
-
-       Gtk::Frame *imageFrame = manage(new Gtk::Frame(_("Image Size")));
-       imageFrame->set_shadow_type(Gtk::SHADOW_NONE);
-       ((Gtk::Label *) imageFrame->get_label_widget())->set_markup(_("<b>Image Size</b>"));
-       panelBox->pack_start(*imageFrame, false, false, 0);
-
-       Gtk::Alignment *tablePadding = manage(new Gtk::Alignment(0, 0, 1, 1));
-       tablePadding->set_padding(6, 0, 24, 0);
-       Gtk::Table *imageSizeTable = manage(new Gtk::Table(2, 6, false));
-       imageSizeTable->set_row_spacings(6);
-       imageSizeTable->set_col_spacings(12);
-       tablePadding->add(*imageSizeTable);
-       imageFrame->add(*tablePadding);
-
-       Gtk::Label *size_width_label = manage(new Gtk::Label(_("_Width"), 0, 0.5, true));
-       size_width_label->set_mnemonic_widget(*entry_width);
-
-       Gtk::Label *size_height_label = manage(new Gtk::Label(_("_Height"), 0, 0.5, true));
-       size_height_label->set_mnemonic_widget(*entry_height);
-
-       Gtk::Label *size_xres_label = manage(new Gtk::Label(_("_XRes"), 0, 0.5, true));
-       size_xres_label->set_mnemonic_widget(*entry_xres);
-
-       Gtk::Label *size_yres_label = manage(new Gtk::Label(_("_YRes"), 0, 0.5, true));
-       size_yres_label->set_mnemonic_widget(*entry_yres);
-
-       Gtk::Label *size_physwidth_label = manage(new Gtk::Label(_("_Physical Width"), 0, 0.5, true));
-       size_physwidth_label->set_mnemonic_widget(*entry_phy_width);
-
-       Gtk::Label *size_physheight_label = manage(new Gtk::Label(_("Phy_sical Height"), 0, 0.5, true));
-       size_physheight_label->set_mnemonic_widget(*entry_phy_height);
-
-       Gtk::Label *size_span = manage(new Gtk::Label(_("I_mage Span"), 0, 0.5, true));
-       size_span->set_mnemonic_widget(*entry_span);
-
-       imageSizeTable->attach(*size_width_label, 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       imageSizeTable->attach(*size_height_label, 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       imageSizeTable->attach(*entry_width, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       imageSizeTable->attach(*entry_height, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       imageSizeTable->attach(*size_xres_label, 2, 3, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       imageSizeTable->attach(*size_yres_label, 2, 3, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       imageSizeTable->attach(*entry_xres, 3, 4, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       imageSizeTable->attach(*entry_yres, 3, 4, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
-       imageSizeTable->attach(*size_physwidth_label, 4, 5, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       imageSizeTable->attach(*size_physheight_label, 4, 5, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       imageSizeTable->attach(*entry_phy_width, 5, 6, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       imageSizeTable->attach(*entry_phy_height, 5, 6, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
-       imageSizeTable->attach(*size_span, 0, 1, 2, 3, Gtk::SHRINK|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       imageSizeTable->attach(*entry_span, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       Gtk::Frame *imageAreaFrame = manage(new Gtk::Frame(_("Image Area")));
-       imageAreaFrame->set_shadow_type(Gtk::SHADOW_NONE);
-       ((Gtk::Label *) imageAreaFrame->get_label_widget())->set_markup(_("<b>Image Area</b>"));
-       panelBox->pack_start(*imageAreaFrame, false, false, 0);
-
-       Gtk::Alignment *imageAreaPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
-       imageAreaPadding->set_padding(6, 0, 24, 0);
-       imageAreaFrame->add(*imageAreaPadding);
-
-       Gtk::Table *imageAreaTable = manage(new Gtk::Table(2, 2, false));
-       imageAreaTable->set_row_spacings(6);
-       imageAreaTable->set_col_spacings(12);
-       imageAreaPadding->add(*imageAreaTable);
-
-       Gtk::Label *imageAreaTopLeftLabel = manage(new Gtk::Label(_("_Top Left"), 0, 0.5, true));
-       imageAreaTopLeftLabel->set_mnemonic_widget(*entry_tl);
-
-       Gtk::Label *imageAreaBottomRightLabel = manage(new Gtk::Label(_("_Bottom Right"), 0, 0.5, true));
-       imageAreaBottomRightLabel->set_mnemonic_widget(*entry_br);
-
-       imageAreaTable->attach(*imageAreaTopLeftLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       imageAreaTable->attach(*imageAreaBottomRightLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       imageAreaTable->attach(*entry_tl, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       imageAreaTable->attach(*entry_br, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
-       paddedPanel->show_all();
-       return paddedPanel;
-}
-
-Gtk::Widget *
-Widget_RendDesc::create_time_tab()
-{
-       Gtk::Alignment *paddedPanel = manage(new Gtk::Alignment(0, 0, 1, 1));
-       paddedPanel->set_padding(12, 12, 12, 12);
-
-       Gtk::VBox *panelBox = manage(new Gtk::VBox(false, 12)); // for future widgets
-       paddedPanel->add(*panelBox);
-
-       time_frame = manage(new Gtk::Frame(_("Time Settings")));
-       time_frame->set_shadow_type(Gtk::SHADOW_NONE);
-       ((Gtk::Label *) time_frame->get_label_widget())->set_markup(_("<b>Time Settings</b>"));
-       panelBox->pack_start(*time_frame, false, false, 0);
-
-       Gtk::Alignment *timeFramePadding = manage(new Gtk::Alignment(0, 0, 1, 1));
-       timeFramePadding->set_padding(6, 0, 24, 0);
-       time_frame->add(*timeFramePadding);
-
-       Gtk::Table *timeFrameTable = manage(new Gtk::Table(3, 2, false));
-       timeFrameTable->set_row_spacings(6);
-       timeFrameTable->set_col_spacings(12);
-       timeFramePadding->add(*timeFrameTable);
-
-       Gtk::Label *timeFPSLabel = manage(new Gtk::Label(_("_Frames per second"), 0, 0.5, true));
-       timeFPSLabel->set_mnemonic_widget(*entry_fps);
-       timeFrameTable->attach(*timeFPSLabel, 0, 1, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       timeFrameTable->attach(*entry_fps, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
-       Gtk::Label *timeStartLabel = manage(new Gtk::Label(_("_Start Time"), 0, 0.5, true));
-       timeStartLabel->set_mnemonic_widget(*entry_start_time);
-       timeFrameTable->attach(*timeStartLabel, 0, 1, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       timeFrameTable->attach(*entry_start_time, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
-       Gtk::Label *timeEndLabel = manage(new Gtk::Label(_("_End Time"), 0, 0.5, true));
-       timeEndLabel->set_mnemonic_widget(*entry_end_time);
-       timeFrameTable->attach(*timeEndLabel, 0, 1, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       timeFrameTable->attach(*entry_end_time, 1, 2, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
-       paddedPanel->show_all();
-       return paddedPanel;
-}
-
-Gtk::Widget *
-Widget_RendDesc::create_other_tab()
-{
-       Gtk::Alignment *paddedPanel = manage(new Gtk::Alignment(0, 0, 1, 1));
-       paddedPanel->set_padding(12, 12, 12, 12);
-
-       Gtk::VBox *panelBox = manage(new Gtk::VBox(false, 12));
-       paddedPanel->add(*panelBox);
-
-       Gtk::Frame *lockFrame = manage(new Gtk::Frame(_("Locks and Links")));
-       lockFrame->set_shadow_type(Gtk::SHADOW_NONE);
-       ((Gtk::Label *) lockFrame->get_label_widget())->set_markup(_("<b>Locks and Links</b>"));
-       panelBox->pack_start(*lockFrame, false, false, 0);
-
-       Gtk::Alignment *lockPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
-       lockPadding->set_padding(6, 0, 24, 0);
-       lockFrame->add(*lockPadding);
-
-       Gtk::Table *lockTable = manage(new Gtk::Table(2, 4, false));
-       lockTable->set_row_spacings(6);
-       lockTable->set_col_spacings(12);
-       lockPadding->add(*lockTable);
-
-       lockTable->attach(*toggle_im_width, 0, 1, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       lockTable->attach(*toggle_im_height, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       lockTable->attach(*toggle_im_aspect, 2, 3, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       lockTable->attach(*toggle_im_span, 3, 4, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
-       lockTable->attach(*toggle_px_width, 0, 1, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       lockTable->attach(*toggle_px_height, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       lockTable->attach(*toggle_px_aspect, 2, 3, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
-       Gtk::Frame *focusFrame = manage(new Gtk::Frame(_("Focus Point")));
-       focusFrame->set_shadow_type(Gtk::SHADOW_NONE);
-       ((Gtk::Label *) focusFrame->get_label_widget())->set_markup(_("<b>Focus Point</b>"));
-       panelBox->pack_start(*focusFrame, false, false, 0);
-
-       Gtk::Alignment *focusPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
-       focusPadding->set_padding(6, 0, 24, 0);
-       focusFrame->add(*focusPadding);
-
-       Gtk::HBox *focusBox = manage(new Gtk::HBox(false, 12));
-       focusPadding->add(*focusBox);
-
-       Gtk::Label *focusLabel = manage(new Gtk::Label(_("_Focus Point"), 0, 0.5, true));
-       focusLabel->set_mnemonic_widget(*entry_focus);
-       focusBox->pack_start(*focusLabel, false, false, 0);
-       focusBox->pack_start(*entry_focus, true, true, 0);
-
-       paddedPanel->show_all();
-       return paddedPanel;
-}
-
-/*
- * vim:ts=4:sw=4
- */
diff --git a/synfig-studio/src/gtkmm/renddesc.h b/synfig-studio/src/gtkmm/renddesc.h
deleted file mode 100644 (file)
index 48d0793..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file gtkmm/renddesc.h
-**     \brief Header File
-**
-**     $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
-**
-** === N O T E S ===========================================================
-**
-** ========================================================================= */
-
-/* === S T A R T =========================================================== */
-
-#ifndef __SYNFIG_GTKMM_RENDDESC_H
-#define __SYNFIG_GTKMM_RENDDESC_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/table.h>
-#include <gtkmm/frame.h>
-#include <synfig/renddesc.h>
-#include <gtkmm/spinbutton.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/checkbutton.h>
-#include <gtkmm/notebook.h>
-#include "widget_vector.h"
-#include "widget_time.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 Widget_RendDesc : public Gtk::Notebook
-{
-       synfig::RendDesc rend_desc_;
-       sigc::signal<void> signal_changed_;
-
-       Gtk::Adjustment adjustment_width;
-       Gtk::Adjustment adjustment_height;
-       Gtk::Adjustment adjustment_xres;
-       Gtk::Adjustment adjustment_yres;
-       Gtk::Adjustment adjustment_phy_width;
-       Gtk::Adjustment adjustment_phy_height;
-       Gtk::Adjustment adjustment_fps;
-       //Gtk::Adjustment adjustment_start_time;
-       //Gtk::Adjustment adjustment_end_time;
-       //Gtk::Adjustment adjustment_start_frame;
-       //Gtk::Adjustment adjustment_end_frame;
-       Gtk::Adjustment adjustment_span;
-
-       Gtk::SpinButton *entry_width;
-       Gtk::SpinButton *entry_height;
-       Gtk::SpinButton *entry_xres;
-       Gtk::SpinButton *entry_yres;
-       Gtk::SpinButton *entry_phy_width;
-       Gtk::SpinButton *entry_phy_height;
-       Gtk::SpinButton *entry_fps;
-//     Gtk::SpinButton *entry_start_time;
-//     Gtk::SpinButton *entry_end_time;
-//     Gtk::SpinButton *entry_start_frame;
-//     Gtk::SpinButton *entry_end_frame;
-       Gtk::SpinButton *entry_span;
-
-       Gtk::CheckButton *toggle_px_aspect;
-       Gtk::CheckButton *toggle_px_width;
-       Gtk::CheckButton *toggle_px_height;
-
-       Gtk::CheckButton *toggle_im_aspect;
-       Gtk::CheckButton *toggle_im_width;
-       Gtk::CheckButton *toggle_im_height;
-       Gtk::CheckButton *toggle_im_span;
-
-       /* Gtk::Table *time_table; */
-       Gtk::Frame *time_frame;
-
-       Widget_Vector *entry_tl;
-       Widget_Vector *entry_br;
-
-       Widget_Vector *entry_focus;
-
-       Widget_Time *entry_start_time;
-       Widget_Time *entry_end_time;
-
-       mutable int update_lock;
-
-       struct UpdateLock
-       {
-               int &locked;
-               UpdateLock(int &locked):locked(locked){locked++;}
-               ~UpdateLock(){locked--;}
-       };
-
-public:
-
-       sigc::signal<void> &signal_changed() { return signal_changed_; }
-
-       Widget_RendDesc();
-       ~Widget_RendDesc();
-
-       //! Sets the RendDesc
-       void set_rend_desc(const synfig::RendDesc &rend_desc);
-
-       //! Applies the given RendDesc to the current RendDesc
-       void apply_rend_desc(const synfig::RendDesc &rend_desc);
-
-       //! Retrieves the current RendDesc
-       const synfig::RendDesc &get_rend_desc();
-
-       void disable_time_section();
-
-       void enable_time_section();
-
-       void refresh();
-private:
-
-       void on_width_changed();
-       void on_height_changed();
-       void on_xres_changed();
-       void on_yres_changed();
-       void on_phy_width_changed();
-       void on_phy_height_changed();
-       void on_tl_changed();
-       void on_br_changed();
-       void on_fps_changed();
-       void on_start_time_changed();
-       void on_end_time_changed();
-       //void on_start_frame_changed();
-       //void on_end_frame_changed();
-       void on_lock_changed();
-       void on_focus_changed();
-       void on_span_changed();
-
-       void create_widgets();
-       void connect_signals();
-       Gtk::Widget *create_image_tab();
-       Gtk::Widget *create_time_tab();
-       Gtk::Widget *create_other_tab();
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/render.cpp b/synfig-studio/src/gtkmm/render.cpp
deleted file mode 100644 (file)
index e958682..0000000
+++ /dev/null
@@ -1,380 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file gtkmm/render.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 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 <config.h>
-#endif
-
-#include "render.h"
-#include "app.h"
-#include <gtkmm/frame.h>
-#include <gtkmm/alignment.h>
-#include <synfig/target_scanline.h>
-#include <synfig/canvas.h>
-#include "asyncrenderer.h"
-#include "dialog_targetparam.h"
-
-#include "general.h"
-
-#include <fstream>
-
-#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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-RenderSettings::RenderSettings(Gtk::Window& parent, etl::handle<synfigapp::CanvasInterface> canvas_interface):
-       Gtk::Dialog(_("Render Settings"),parent,false,true),
-       canvas_interface_(canvas_interface),
-       adjustment_quality(3,0,9),
-       entry_quality(adjustment_quality,1,0),
-       adjustment_antialias(1,1,31),
-       entry_antialias(adjustment_antialias,1,0),
-       toggle_single_frame(_("Use _current frame"), true),
-       tparam("libxvid",200)
-{
-       widget_rend_desc.show();
-       widget_rend_desc.signal_changed().connect(sigc::mem_fun(*this,&studio::RenderSettings::on_rend_desc_changed));
-       widget_rend_desc.set_rend_desc(canvas_interface_->get_canvas()->rend_desc());
-
-       canvas_interface->signal_rend_desc_changed().connect(sigc::mem_fun(*this,&RenderSettings::on_rend_desc_changed));
-
-       menu_target=manage(new class Gtk::Menu());
-
-       menu_target->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Auto"),
-                       sigc::bind(sigc::mem_fun(*this,&RenderSettings::set_target),String())
-               ));
-
-       synfig::Target::Book::iterator iter;
-       synfig::Target::Book book(synfig::Target::book());
-
-       for(iter=book.begin();iter!=book.end();iter++)
-       {
-               menu_target->items().push_back(Gtk::Menu_Helpers::MenuElem(iter->first,
-                       sigc::bind(sigc::mem_fun(*this,&RenderSettings::set_target),iter->first)
-               ));
-       }
-       optionmenu_target.set_menu(*menu_target);
-
-       optionmenu_target.set_history(0);
-
-       Gtk::Alignment *dialogPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
-       dialogPadding->set_padding(12, 12, 12, 12);
-       get_vbox()->pack_start(*dialogPadding, false, false, 0);
-
-       Gtk::VBox *dialogBox = manage(new Gtk::VBox(false, 12));
-       dialogPadding->add(*dialogBox);
-
-       Gtk::Button *choose_button(manage(new class Gtk::Button(Gtk::StockID(_("Choose...")))));
-       choose_button->show();
-       choose_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::RenderSettings::on_choose_pressed));
-
-       Gtk::Button *tparam_button(manage(new class Gtk::Button(Gtk::StockID(_("Parameters...")))));
-       tparam_button->show();
-       tparam_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::RenderSettings::on_targetparam_pressed));
-
-       Gtk::Frame *target_frame=manage(new Gtk::Frame(_("Target")));
-       target_frame->set_shadow_type(Gtk::SHADOW_NONE);
-       ((Gtk::Label *) target_frame->get_label_widget())->set_markup(_("<b>Target</b>"));
-       dialogBox->pack_start(*target_frame);
-       Gtk::Alignment *targetPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
-       targetPadding->set_padding(6, 0, 24, 0);
-       target_frame->add(*targetPadding);
-
-       Gtk::Table *target_table = manage(new Gtk::Table(2, 3, false));
-       target_table->set_row_spacings(6);
-       target_table->set_col_spacings(12);
-       targetPadding->add(*target_table);
-
-       Gtk::Label *filenameLabel = manage(new Gtk::Label(_("_Filename"), true));
-       filenameLabel->set_alignment(0, 0.5);
-       filenameLabel->set_mnemonic_widget(entry_filename);
-       target_table->attach(*filenameLabel, 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       target_table->attach(entry_filename, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       target_table->attach(*choose_button, 2, 3, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-
-       Gtk::Label *targetLabel = manage(new Gtk::Label(_("_Target"), true));
-       targetLabel->set_alignment(0, 0.5);
-       targetLabel->set_mnemonic_widget(optionmenu_target);
-       target_table->attach(*targetLabel, 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       target_table->attach(optionmenu_target, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       target_table->attach(*tparam_button, 2, 3, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-
-       toggle_single_frame.signal_toggled().connect(sigc::mem_fun(*this, &studio::RenderSettings::on_single_frame_toggle));
-
-       Gtk::Frame *settings_frame=manage(new Gtk::Frame(_("Settings")));
-       settings_frame->set_shadow_type(Gtk::SHADOW_NONE);
-       ((Gtk::Label *) settings_frame->get_label_widget())->set_markup(_("<b>Settings</b>"));
-       dialogBox->pack_start(*settings_frame);
-
-       Gtk::Alignment *settingsPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
-       settingsPadding->set_padding(6, 0, 24, 0);
-       settings_frame->add(*settingsPadding);
-
-       Gtk::Table *settings_table=manage(new Gtk::Table(2,2,false));
-       settings_table->set_row_spacings(6);
-       settings_table->set_col_spacings(12);
-       settingsPadding->add(*settings_table);
-
-       Gtk::Label *qualityLabel = manage(new Gtk::Label(_("_Quality"), true));
-       qualityLabel->set_alignment(0, 0.5);
-       qualityLabel->set_mnemonic_widget(entry_quality);
-       settings_table->attach(*qualityLabel, 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       settings_table->attach(entry_quality, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-
-       Gtk::Label *antiAliasLabel = manage(new Gtk::Label(_("_Anti-Aliasing"), true));
-       antiAliasLabel->set_alignment(0, 0.5);
-       antiAliasLabel->set_mnemonic_widget(entry_antialias);
-       settings_table->attach(*antiAliasLabel, 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       settings_table->attach(entry_antialias, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-
-       toggle_single_frame.set_alignment(0, 0.5);
-       settings_table->attach(toggle_single_frame, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-
-       dialogBox->pack_start(widget_rend_desc);
-
-
-       Gtk::Button *render_button(manage(new class Gtk::Button(Gtk::StockID("Render"))));
-       render_button->show();
-       add_action_widget(*render_button,1);
-       render_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::RenderSettings::on_render_pressed));
-
-       Gtk::Button *cancel_button(manage(new class Gtk::Button(Gtk::StockID("gtk-cancel"))));
-       cancel_button->show();
-       add_action_widget(*cancel_button,0);
-       cancel_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::RenderSettings::on_cancel_pressed));
-
-       //set_default_response(1);
-
-       set_title(_("Render Settings")+String(" - ")+canvas_interface_->get_canvas()->get_name());
-
-       toggle_single_frame.set_active(false);
-       widget_rend_desc.enable_time_section();
-
-       set_entry_filename();
-
-       get_vbox()->show_all();
-}
-
-RenderSettings::~RenderSettings()
-{
-}
-
-void
-RenderSettings::set_entry_filename()
-{
-       String filename(filename_sans_extension(canvas_interface_->get_canvas()->get_file_name()));
-
-       // if this isn't the root canvas, append (<canvasname>) to the filename
-       etl::handle<synfig::Canvas> canvas = canvas_interface_->get_canvas();
-       if (!canvas->is_root())
-       {
-               if(canvas->get_name().empty())
-                       filename+=" ("+canvas->get_id()+')';
-               else
-                       filename+=" ("+canvas->get_name()+')';
-       }
-
-       filename += ".png";
-
-       try
-       {
-               entry_filename.set_text((filename));
-       }
-       catch(...)
-       {
-               synfig::warning("Averted crash!");
-               entry_filename.set_text("output.png");
-       }
-}
-
-void
-RenderSettings::on_rend_desc_changed()
-{
-       widget_rend_desc.set_rend_desc(canvas_interface_->get_canvas()->rend_desc());
-}
-
-void
-RenderSettings::set_target(synfig::String name)
-{
-       target_name=name;
-}
-
-void
-RenderSettings::on_choose_pressed()
-{
-       String filename=entry_filename.get_text();
-       if(App::dialog_save_file("Save Render As", filename, RENDER_DIR_PREFERENCE))
-               entry_filename.set_text(filename);
-}
-
-void
-RenderSettings::on_targetparam_pressed()
-{
-       Dialog_TargetParam *dialogtp = new Dialog_TargetParam(tparam);
-       if(dialogtp->run()==Gtk::RESPONSE_OK)
-               tparam=dialogtp->get_tparam();
-
-       delete dialogtp;
-}
-
-void
-RenderSettings::on_render_pressed()
-{
-       String filename=entry_filename.get_text();
-       synfig::String calculated_target_name(target_name);
-
-       if(filename.empty())
-       {
-               canvas_interface_->get_ui_interface()->error(_("You must supply a filename!"));
-               return;
-       }
-
-       // If the target type is not yet defined,
-       // try to figure it out from the outfile.
-       if(calculated_target_name.empty())
-       {
-               try
-               {
-                       String ext(filename_extension(filename));
-                       if (ext.size()) ext=ext.substr(1); // skip initial '.'
-                       synfig::info("render target filename: '%s'; extension: '%s'", filename.c_str(), ext.c_str());
-                       if(Target::ext_book().count(ext))
-                       {
-                               calculated_target_name=Target::ext_book()[ext];
-                               synfig::info("'%s' is a known extension - using target '%s'", ext.c_str(), calculated_target_name.c_str());
-                       }
-                       else
-                       {
-                               calculated_target_name=ext;
-                               synfig::info("unknown extension");
-                       }
-               }
-               catch(std::runtime_error x)
-               {
-                       canvas_interface_->get_ui_interface()->error(_("Unable to determine proper target from filename."));
-                       return;
-               }
-       }
-
-       if(filename.empty() && calculated_target_name!="null")
-       {
-               canvas_interface_->get_ui_interface()->error(_("A filename is required for this target"));
-               return;
-       }
-
-       Target::Handle target=Target::create(calculated_target_name,filename, tparam);
-       if(!target)
-       {
-               canvas_interface_->get_ui_interface()->error(_("Unable to create target for ")+filename);
-               return;
-       }
-       // This is the only way I've found to avoid send a non writable
-       // filename path to the renderer.
-       fstream filetest (filename.c_str(), fstream::out);
-       if (filetest.fail())
-       {
-               canvas_interface_->get_ui_interface()->error(_("Unable to create file for ")+filename);
-               return;
-       }
-
-       hide();
-
-       target->set_canvas(canvas_interface_->get_canvas());
-       RendDesc rend_desc(widget_rend_desc.get_rend_desc());
-       rend_desc.set_antialias((int)adjustment_antialias.get_value());
-
-       // If we are to only render the current frame
-       if(toggle_single_frame.get_active())
-               rend_desc.set_time(canvas_interface_->get_time());
-
-       target->set_rend_desc(&rend_desc);
-       target->set_quality((int)adjustment_quality.get_value());
-       if( !target->init() ){
-               canvas_interface_->get_ui_interface()->error(_("Target initialization failure"));
-               return;
-       }
-
-       canvas_interface_->get_ui_interface()->task(_("Rendering ")+filename);
-
-       if(async_renderer)
-       {
-               async_renderer->stop();
-               async_renderer.detach();
-       }
-       async_renderer=new AsyncRenderer(target);
-       async_renderer->signal_finished().connect( sigc::mem_fun(*this,&RenderSettings::on_finished));
-       async_renderer->start();
-       /*
-       if(!target->render(canvas_interface_->get_ui_interface().get()))
-       {
-               canvas_interface_->get_ui_interface()->error(_("Render Failure"));
-               canvas_interface_->get_ui_interface()->amount_complete(0,10000);
-               return;
-       }
-
-       // Success!
-       canvas_interface_->get_ui_interface()->task(filename+_(" rendered successfully"));
-       canvas_interface_->get_ui_interface()->amount_complete(0,10000);
-       */
-       return;
-}
-
-void
-RenderSettings::on_finished()
-{
-       canvas_interface_->get_ui_interface()->task(_("File rendered successfully"));
-       canvas_interface_->get_ui_interface()->amount_complete(0,10000);
-}
-
-void
-RenderSettings::on_cancel_pressed()
-{
-       hide();
-}
-
-void
-RenderSettings::on_single_frame_toggle()
-{
-       if(toggle_single_frame.get_active())
-               widget_rend_desc.disable_time_section();
-       else
-               widget_rend_desc.enable_time_section();
-}
diff --git a/synfig-studio/src/gtkmm/render.h b/synfig-studio/src/gtkmm/render.h
deleted file mode 100644 (file)
index 729251b..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file gtkmm/render.h
-**     \brief Template Header
-**
-**     $Id$
-**
-**     \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
-**     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_GTKMM_RENDER_H
-#define __SYNFIG_STUDIO_GTKMM_RENDER_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/dialog.h>
-#include <gtkmm/tooltips.h>
-#include <gtkmm/table.h>
-#include <gtkmm/entry.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/spinbutton.h>
-#include <gtkmm/checkbutton.h>
-#include <gtkmm/tooltips.h>
-#include <gtkmm/optionmenu.h>
-
-#include <synfig/string.h>
-#include <synfig/targetparam.h>
-
-#include <synfigapp/canvasinterface.h>
-
-#include "renddesc.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 AsyncRenderer;
-
-class RenderSettings : public Gtk::Dialog
-{
-       Gtk::Tooltips tooltips;
-
-       etl::handle<synfigapp::CanvasInterface> canvas_interface_;
-       Widget_RendDesc widget_rend_desc;
-
-       Gtk::Entry entry_filename;
-
-       Gtk::Adjustment adjustment_quality;
-       Gtk::SpinButton entry_quality;
-
-       Gtk::Adjustment adjustment_antialias;
-       Gtk::SpinButton entry_antialias;
-
-       Gtk::CheckButton toggle_single_frame;
-
-       Gtk::OptionMenu optionmenu_target;
-       Gtk::Menu *menu_target;
-
-       synfig::String target_name;
-
-       void set_target(synfig::String name);
-
-       etl::handle<AsyncRenderer> async_renderer;
-
-       synfig::TargetParam tparam;
-
-public:
-       RenderSettings(Gtk::Window& parent,etl::handle<synfigapp::CanvasInterface> canvas_interface);
-       ~RenderSettings();
-       void set_entry_filename();
-
-private:
-
-       void on_rend_desc_changed();
-       void on_single_frame_toggle();
-       void on_choose_pressed();
-       void on_render_pressed();
-       void on_cancel_pressed();
-       void on_targetparam_pressed();
-
-       void on_finished();
-}; // END of class RenderSettings
-
-}; // END of namespace studio
-
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/renderer_bbox.cpp b/synfig-studio/src/gtkmm/renderer_bbox.cpp
deleted file mode 100644 (file)
index 727ad02..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file renderer_bbox.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "renderer_bbox.h"
-#include "workarea.h"
-#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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Renderer_BBox::Renderer_BBox()
-{
-}
-
-Renderer_BBox::~Renderer_BBox()
-{
-}
-
-const synfig::Rect&
-Renderer_BBox::get_bbox()
-{
-       return get_work_area()->get_canvas_view()->get_bbox();
-}
-
-void
-Renderer_BBox::render_vfunc(
-       const Glib::RefPtr<Gdk::Drawable>& drawable,
-       const Gdk::Rectangle& /*expose_area*/
-)
-{
-       assert(get_work_area());
-       if(!get_work_area())
-               return;
-
-//     const synfig::RendDesc &rend_desc(get_work_area()->get_canvas()->rend_desc());
-
-       const synfig::Vector focus_point(get_work_area()->get_focus_point());
-
-//     std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> >& tile_book(get_tile_book());
-
-       int drawable_w,drawable_h;
-       drawable->get_size(drawable_w,drawable_h);
-
-       // Calculate the window coordinates of the top-left
-       // corner of the canvas.
-//     const synfig::Vector::value_type
-//             x(focus_point[0]/get_pw()+drawable_w/2-get_w()/2),
-//             y(focus_point[1]/get_ph()+drawable_h/2-get_h()/2);
-
-       /*const synfig::Vector::value_type window_startx(window_tl[0]);
-       const synfig::Vector::value_type window_endx(window_br[0]);
-       const synfig::Vector::value_type window_starty(window_tl[1]);
-       const synfig::Vector::value_type window_endy(window_br[1]);
-       */
-//     const int
-//             tile_w(get_work_area()->get_tile_w()),
-//             tile_h(get_work_area()->get_tile_h());
-
-//     const int
-//             w(get_w()),
-//             h(get_h());
-
-       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(drawable));
-
-       //const synfig::Vector grid_size(get_grid_size());
-
-       const synfig::Vector::value_type window_startx(get_work_area()->get_window_tl()[0]);
-//     const synfig::Vector::value_type window_endx(get_work_area()->get_window_br()[0]);
-       const synfig::Vector::value_type window_starty(get_work_area()->get_window_tl()[1]);
-//     const synfig::Vector::value_type window_endy(get_work_area()->get_window_br()[1]);
-       const float pw(get_pw()),ph(get_ph());
-
-       const synfig::Point curr_point(get_bbox().get_min());
-       const synfig::Point drag_point(get_bbox().get_max());
-       if(get_bbox().area()<10000000000000000.0)
-       {
-               gc->set_function(Gdk::INVERT);
-               gc->set_rgb_fg_color(Gdk::Color("#FFFFFF"));
-               //gc->set_line_attributes(1,Gdk::LINE_ON_OFF_DASH,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-               gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-
-               Point tl(std::min(drag_point[0],curr_point[0]),std::min(drag_point[1],curr_point[1]));
-               Point br(std::max(drag_point[0],curr_point[0]),std::max(drag_point[1],curr_point[1]));
-
-               tl[0]=(tl[0]-window_startx)/pw;
-               tl[1]=(tl[1]-window_starty)/ph;
-               br[0]=(br[0]-window_startx)/pw;
-               br[1]=(br[1]-window_starty)/ph;
-               if(tl[0]>br[0])
-                       swap(tl[0],br[0]);
-               if(tl[1]>br[1])
-                       swap(tl[1],br[1]);
-
-               drawable->draw_rectangle(gc,false,
-                       round_to_int(tl[0]),
-                       round_to_int(tl[1]),
-                       round_to_int(br[0]-tl[0]),
-                       round_to_int(br[1]-tl[1])
-               );
-       }
-}
diff --git a/synfig-studio/src/gtkmm/renderer_bbox.h b/synfig-studio/src/gtkmm/renderer_bbox.h
deleted file mode 100644 (file)
index d3d5952..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file renderer_bbox.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_RENDERER_BBOX_H
-#define __SYNFIG_RENDERER_BBOX_H
-
-/* === H E A D E R S ======================================================= */
-
-#include "workarearenderer.h"
-#include <vector>
-#include <synfig/vector.h>
-#include <synfig/rect.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 Renderer_BBox : public studio::WorkAreaRenderer
-{
-       synfig::Rect bbox;
-
-public:
-       Renderer_BBox();
-       ~Renderer_BBox();
-
-       const synfig::Rect& get_bbox();
-
-       void render_vfunc(const Glib::RefPtr<Gdk::Drawable>& drawable,const Gdk::Rectangle& expose_area );
-
-protected:
-       //bool get_enabled_vfunc()const;
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/renderer_canvas.cpp b/synfig-studio/src/gtkmm/renderer_canvas.cpp
deleted file mode 100644 (file)
index 9608079..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file renderer_canvas.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 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 <config.h>
-#endif
-
-#include "renderer_canvas.h"
-#include "workarea.h"
-#include <ETL/misc>
-
-#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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Renderer_Canvas::~Renderer_Canvas()
-{
-}
-std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> >&
-Renderer_Canvas::get_tile_book()
-{
-       return get_work_area()->get_tile_book();
-}
-
-bool
-Renderer_Canvas::get_full_frame()const
-{
-       return get_work_area()->get_full_frame();
-}
-
-int Renderer_Canvas::get_refreshes()const
-{
-       return get_work_area()->get_refreshes();
-}
-
-bool
-Renderer_Canvas::get_canceled()const
-{
-       return get_work_area()->get_canceled();
-}
-
-bool
-Renderer_Canvas::get_queued()const
-{
-       return get_work_area()->get_queued();
-}
-
-bool
-Renderer_Canvas::get_rendering()const
-{
-       return get_work_area()->get_rendering();
-}
-
-void
-Renderer_Canvas::render_vfunc(
-       const Glib::RefPtr<Gdk::Drawable>& drawable,
-       const Gdk::Rectangle& /*expose_area*/
-)
-{
-       assert(get_work_area());
-       if(!get_work_area())
-               return;
-
-//     const synfig::RendDesc &rend_desc(get_work_area()->get_canvas()->rend_desc());
-
-       const synfig::Vector focus_point(get_work_area()->get_focus_point());
-
-       std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> >& tile_book(get_tile_book());
-
-       int drawable_w,drawable_h;
-       drawable->get_size(drawable_w,drawable_h);
-
-       // Calculate the window coordinates of the top-left
-       // corner of the canvas.
-       const synfig::Vector::value_type
-               x(focus_point[0]/get_pw()+drawable_w/2-get_w()/2),
-               y(focus_point[1]/get_ph()+drawable_h/2-get_h()/2);
-
-       /*const synfig::Vector::value_type window_startx(window_tl[0]);
-       const synfig::Vector::value_type window_endx(window_br[0]);
-       const synfig::Vector::value_type window_starty(window_tl[1]);
-       const synfig::Vector::value_type window_endy(window_br[1]);
-       */
-       const int
-               tile_w(get_work_area()->get_tile_w()),
-               tile_h(get_work_area()->get_tile_h());
-
-       const int
-               w(get_w()),
-               h(get_h());
-
-       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(drawable));
-
-       if(!tile_book.empty())
-       {
-               if(get_full_frame())
-               {
-                       if(tile_book[0].first)
-                       {
-                               drawable->draw_pixbuf(
-                                       gc, //GC
-                                       tile_book[0].first, //pixbuf
-                                       0, 0,   // Source X and Y
-                                       round_to_int(x),round_to_int(y),        // Dest X and Y
-                                       -1,-1,  // Width and Height
-                                       Gdk::RGB_DITHER_MAX,            // RgbDither
-                                       2, 2 // Dither offset X and Y
-                                       );
-                       }
-                       if(tile_book[0].second!=get_refreshes() && get_canceled()==false && get_rendering()==false && get_queued()==false)
-                               get_work_area()->async_update_preview();
-               }
-               else
-               {
-                       int div = get_work_area()->get_low_res_pixel_size();
-                       const int width_in_tiles(w/tile_w+(((get_work_area()->get_low_resolution_flag())?((w/div)%(tile_w/div)):(w%tile_w))?1:0));
-                       const int height_in_tiles(h/tile_h+(h%tile_h?1:0));
-
-                       int u(0),v(0),tx,ty;
-                       int u1(0),v1(0),u2(width_in_tiles), v2(height_in_tiles);
-
-                       bool needs_refresh(false);
-
-                       u1=int(-x/tile_w);
-                       v1=int(-y/tile_h);
-                       u2=int((-x+drawable_w)/tile_w+1);
-                       v2=int((-y+drawable_h)/tile_h+1);
-                       if(u2>width_in_tiles)u2=width_in_tiles;
-                       if(v2>height_in_tiles)v2=height_in_tiles;
-                       if(u1<0)u1=0;
-                       if(v1<0)v1=0;
-
-                       for(v=v1;v<v2;v++)
-                       {
-                               for(u=u1;u<u2;u++)
-                               {
-                                       int index=v*width_in_tiles+u;
-                                       if(int(tile_book.size())>index && tile_book[index].first)
-                                       {
-                                               tx=u*tile_w;
-                                               ty=v*tile_w;
-
-                                               drawable->draw_pixbuf(
-                                                       gc, //GC
-                                                       tile_book[index].first, //pixbuf
-                                                       0, 0,   // Source X and Y
-                                                       round_to_int(x)+tx,round_to_int(y)+ty,  // Dest X and Y
-                                                       -1,-1,  // Width and Height
-                                                       Gdk::RGB_DITHER_MAX,            // RgbDither
-                                                       2, 2 // Dither offset X and Y
-                                                       );
-                                       }
-                                       if(tile_book[index].second!=get_refreshes())
-                                               needs_refresh=true;
-                               }
-                       }
-                       if(needs_refresh==true && get_canceled()==false && get_rendering()==false && get_queued()==false)
-                       {
-                               //queue_render_preview();
-                               get_work_area()->async_update_preview();
-                               //update_preview();
-                               //return true;
-                       }
-
-               }
-       }
-
-       // Draw the border around the rendered region
-       {
-               gc->set_rgb_fg_color(Gdk::Color("#000000"));
-               gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-               drawable->draw_rectangle(
-                       gc,
-                       false,  // Fill?
-                       round_to_int(x),round_to_int(y),        // x,y
-                       w,h     //w,h
-               );
-       }
-}
diff --git a/synfig-studio/src/gtkmm/renderer_canvas.h b/synfig-studio/src/gtkmm/renderer_canvas.h
deleted file mode 100644 (file)
index ad2509e..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file renderer_canvas.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_RENDERER_CANVAS_H
-#define __SYNFIG_RENDERER_CANVAS_H
-
-/* === H E A D E R S ======================================================= */
-
-#include "workarearenderer.h"
-#include <vector>
-
-/* === 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 Renderer_Canvas : public studio::WorkAreaRenderer
-{
-
-public:
-       ~Renderer_Canvas();
-
-       std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> >& get_tile_book();
-
-       bool get_full_frame()const;
-
-       int get_refreshes()const;
-       bool get_canceled()const;
-       bool get_queued()const;
-       bool get_rendering()const;
-
-       void render_vfunc(const Glib::RefPtr<Gdk::Drawable>& drawable,const Gdk::Rectangle& expose_area );
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/renderer_dragbox.cpp b/synfig-studio/src/gtkmm/renderer_dragbox.cpp
deleted file mode 100644 (file)
index a177154..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file renderer_dragbox.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "renderer_dragbox.h"
-#include "workarea.h"
-#include <ETL/misc>
-
-#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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Renderer_Dragbox::~Renderer_Dragbox()
-{
-}
-
-const synfig::Point&
-Renderer_Dragbox::get_drag_point()const
-{
-       return get_work_area()->get_drag_point();
-}
-
-const synfig::Point&
-Renderer_Dragbox::get_curr_point()const
-{
-       return get_work_area()->get_cursor_pos();
-}
-
-bool
-Renderer_Dragbox::get_enabled_vfunc()const
-{
-       return get_work_area()->get_dragging_mode()==WorkArea::DRAG_BOX;
-}
-
-
-void
-Renderer_Dragbox::render_vfunc(
-       const Glib::RefPtr<Gdk::Drawable>& drawable,
-       const Gdk::Rectangle& /*expose_area*/
-)
-{
-       assert(get_work_area());
-       if(!get_work_area())
-               return;
-
-       // const synfig::RendDesc &rend_desc(get_work_area()->get_canvas()->rend_desc());
-
-       const synfig::Vector focus_point(get_work_area()->get_focus_point());
-
-//     std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> >& tile_book(get_tile_book());
-
-       int drawable_w,drawable_h;
-       drawable->get_size(drawable_w,drawable_h);
-
-       // Calculate the window coordinates of the top-left
-       // corner of the canvas.
-       // const synfig::Vector::value_type
-       //      x(focus_point[0]/get_pw()+drawable_w/2-get_w()/2),
-       //      y(focus_point[1]/get_ph()+drawable_h/2-get_h()/2);
-
-       /*const synfig::Vector::value_type window_startx(window_tl[0]);
-       const synfig::Vector::value_type window_endx(window_br[0]);
-       const synfig::Vector::value_type window_starty(window_tl[1]);
-       const synfig::Vector::value_type window_endy(window_br[1]);
-       */
-       // const int
-       //      tile_w(get_work_area()->get_tile_w()),
-       //      tile_h(get_work_area()->get_tile_h());
-
-       // const int
-       //      w(get_w()),
-       //      h(get_h());
-
-       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(drawable));
-
-       //const synfig::Vector grid_size(get_grid_size());
-
-       const synfig::Vector::value_type window_startx(get_work_area()->get_window_tl()[0]);
-       // const synfig::Vector::value_type window_endx(get_work_area()->get_window_br()[0]);
-       const synfig::Vector::value_type window_starty(get_work_area()->get_window_tl()[1]);
-       // const synfig::Vector::value_type window_endy(get_work_area()->get_window_br()[1]);
-       const float pw(get_pw()),ph(get_ph());
-
-       const synfig::Point& curr_point(get_curr_point());
-       const synfig::Point& drag_point(get_drag_point());
-
-       {
-               gc->set_function(Gdk::COPY);
-               gc->set_rgb_fg_color(Gdk::Color("#000000"));
-               gc->set_line_attributes(1,Gdk::LINE_ON_OFF_DASH,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-               //gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-
-               Point tl(std::min(drag_point[0],curr_point[0]),std::min(drag_point[1],curr_point[1]));
-               Point br(std::max(drag_point[0],curr_point[0]),std::max(drag_point[1],curr_point[1]));
-
-               tl[0]=(tl[0]-window_startx)/pw;
-               tl[1]=(tl[1]-window_starty)/ph;
-               br[0]=(br[0]-window_startx)/pw;
-               br[1]=(br[1]-window_starty)/ph;
-               if(tl[0]>br[0])
-                       swap(tl[0],br[0]);
-               if(tl[1]>br[1])
-                       swap(tl[1],br[1]);
-
-               drawable->draw_rectangle(gc,false,
-                       round_to_int(tl[0]),
-                       round_to_int(tl[1]),
-                       round_to_int(br[0]-tl[0]),
-                       round_to_int(br[1]-tl[1])
-               );
-       }
-}
diff --git a/synfig-studio/src/gtkmm/renderer_dragbox.h b/synfig-studio/src/gtkmm/renderer_dragbox.h
deleted file mode 100644 (file)
index 497b903..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file renderer_dragbox.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_RENDERER_DRAGBOX_H
-#define __SYNFIG_RENDERER_DRAGBOX_H
-
-/* === H E A D E R S ======================================================= */
-
-#include "workarearenderer.h"
-#include <vector>
-#include <synfig/vector.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 Renderer_Dragbox : public studio::WorkAreaRenderer
-{
-
-public:
-       ~Renderer_Dragbox();
-
-       void render_vfunc(const Glib::RefPtr<Gdk::Drawable>& drawable,const Gdk::Rectangle& expose_area );
-
-       const synfig::Point& get_drag_point()const;
-       const synfig::Point& get_curr_point()const;
-
-protected:
-       bool get_enabled_vfunc()const;
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/renderer_ducks.cpp b/synfig-studio/src/gtkmm/renderer_ducks.cpp
deleted file mode 100644 (file)
index fdc6487..0000000
+++ /dev/null
@@ -1,489 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file renderer_ducks.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 2008 Chris Moore
-**  Copyright (c) 2008 Gerald Young
-**
-**     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 <config.h>
-#endif
-
-#include "renderer_ducks.h"
-#include "workarea.h"
-#include "duckmatic.h"
-#include <ETL/bezier>
-#include <ETL/misc>
-#include "widget_color.h"
-#include <synfig/distance.h>
-#include "app.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Renderer_Ducks::~Renderer_Ducks()
-{
-}
-
-/*
-bool
-Renderer_Ducks::get_enabled_vfunc()const
-{
-       return get_work_area()->grid_status();
-}
-*/
-
-struct ScreenDuck
-{
-       synfig::Point pos;
-       Gdk::Color color;
-       bool selected;
-       bool hover;
-       Real width;
-
-       ScreenDuck():width(0) { }
-};
-
-void
-Renderer_Ducks::render_vfunc(
-       const Glib::RefPtr<Gdk::Drawable>& drawable,
-       const Gdk::Rectangle& /*expose_area*/
-)
-{
-       assert(get_work_area());
-       if(!get_work_area())
-               return;
-
-       const synfig::Vector focus_point(get_work_area()->get_focus_point());
-
-
-       int drawable_w,drawable_h;
-       drawable->get_size(drawable_w,drawable_h);
-
-       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(drawable));
-
-
-       const synfig::Vector::value_type window_startx(get_work_area()->get_window_tl()[0]);
-       const synfig::Vector::value_type window_starty(get_work_area()->get_window_tl()[1]);
-
-       const float pw(get_pw()),ph(get_ph());
-
-       const std::list<etl::handle<Duckmatic::Bezier> >& bezier_list(get_work_area()->bezier_list());
-       const bool solid_lines(get_work_area()->solid_lines);
-
-       const std::list<handle<Duckmatic::Stroke> >& stroke_list(get_work_area()->stroke_list());
-
-       Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_work_area()->get_pango_context()));
-
-       // Render the strokes
-       for(std::list<handle<Duckmatic::Stroke> >::const_iterator iter=stroke_list.begin();iter!=stroke_list.end();++iter)
-       {
-               Point window_start(window_startx,window_starty);
-               vector<Gdk::Point> points;
-               std::list<synfig::Point>::iterator iter2;
-               Point holder;
-
-               for(iter2=(*iter)->stroke_data->begin();iter2!=(*iter)->stroke_data->end();++iter2)
-               {
-                       holder=*iter2-window_start;
-                       holder[0]/=pw;holder[1]/=ph;
-                       points.push_back(Gdk::Point(round_to_int(holder[0]),round_to_int(holder[1])));
-               }
-
-               gc->set_rgb_fg_color(colorconv_synfig2gdk((*iter)->color));
-               gc->set_function(Gdk::COPY);
-               gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-
-               // Draw the stroke
-               drawable->draw_lines(gc, Glib::ArrayHandle<Gdk::Point>(points));
-       }
-
-
-
-       // Render the beziers
-       for(std::list<handle<Duckmatic::Bezier> >::const_iterator iter=bezier_list.begin();iter!=bezier_list.end();++iter)
-       {
-               Point window_start(window_startx,window_starty);
-               Point p1((*iter)->p1->get_trans_point()-window_start);
-               Point p2((*iter)->p2->get_trans_point()-window_start);
-               Point c1((*iter)->c1->get_trans_point()-window_start);
-               Point c2((*iter)->c2->get_trans_point()-window_start);
-               p1[0]/=pw;p1[1]/=ph;
-               p2[0]/=pw;p2[1]/=ph;
-               c1[0]/=pw;c1[1]/=ph;
-               c2[0]/=pw;c2[1]/=ph;
-               bezier<Point> curve(p1,c1,c2,p2);
-               vector<Gdk::Point> points;
-
-               float f;
-               Point pt;
-               for(f=0;f<1.0;f+=1.0/17.0)
-               {
-                       pt=curve(f);
-                       points.push_back(Gdk::Point(round_to_int(pt[0]),round_to_int(pt[1])));
-               }
-               points.push_back(Gdk::Point(round_to_int(p2[0]),round_to_int(p2[1])));
-
-               // Draw the curve
-/*             if(solid_lines)
-               {
-                       gc->set_rgb_fg_color(DUCK_COLOR_BEZIER_1);
-                       gc->set_function(Gdk::COPY);
-                       gc->set_line_attributes(3,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-                       drawable->draw_lines(gc, Glib::ArrayHandle<Gdk::Point>(points));
-                       gc->set_rgb_fg_color(DUCK_COLOR_BEZIER_2);
-                       gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-                       drawable->draw_lines(gc, Glib::ArrayHandle<Gdk::Point>(points));
-               }
-               else
-*/
-               {
-//                     gc->set_rgb_fg_color(Gdk::Color("#ffffff"));
-//                     gc->set_function(Gdk::INVERT);
-//                     gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-//                     drawable->draw_lines(gc, Glib::ArrayHandle<Gdk::Point>(points));
-                       gc->set_rgb_fg_color(DUCK_COLOR_BEZIER_1);
-                       gc->set_function(Gdk::COPY);
-                       gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-                       drawable->draw_lines(gc, Glib::ArrayHandle<Gdk::Point>(points));
-                       gc->set_rgb_fg_color(DUCK_COLOR_BEZIER_2);
-                       gc->set_line_attributes(1,Gdk::LINE_ON_OFF_DASH,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-                       drawable->draw_lines(gc, Glib::ArrayHandle<Gdk::Point>(points));
-
-               }
-       }
-
-
-       const DuckList duck_list(get_work_area()->get_duck_list());
-       //Gtk::StateType state = Gtk::STATE_ACTIVE;
-       Gtk::ShadowType shadow=Gtk::SHADOW_OUT;
-       std::list<ScreenDuck> screen_duck_list;
-       const float radius((abs(pw)+abs(ph))*4);
-
-       etl::handle<Duck> hover_duck(get_work_area()->find_duck(get_work_area()->get_cursor_pos(),radius, get_work_area()->get_type_mask()));
-
-       // Render the ducks
-       for(std::list<handle<Duck> >::const_iterator iter=duck_list.begin();iter!=duck_list.end();++iter)
-       {
-
-               // If this type of duck has been masked, then skip it
-               if((*iter)->get_type() && (!(get_work_area()->get_type_mask() & (*iter)->get_type())))
-                       continue;
-
-//             Real x,y;
-       //      Gdk::Rectangle area;
-               Point sub_trans_point((*iter)->get_sub_trans_point());
-               Point sub_trans_origin((*iter)->get_sub_trans_origin());
-
-               if (App::restrict_radius_ducks &&
-                       (*iter)->is_radius())
-               {
-                       if (sub_trans_point[0] < sub_trans_origin[0])
-                               sub_trans_point[0] = sub_trans_origin[0];
-                       if (sub_trans_point[1] < sub_trans_origin[1])
-                               sub_trans_point[1] = sub_trans_origin[1];
-               }
-
-               Point point((*iter)->get_transform_stack().perform(sub_trans_point));
-               Point origin((*iter)->get_transform_stack().perform(sub_trans_origin));
-
-               point[0]=(point[0]-window_startx)/pw;
-               point[1]=(point[1]-window_starty)/ph;
-
-               bool has_connect(false);
-               if((*iter)->get_tangent() || (*iter)->get_type()&Duck::TYPE_ANGLE)
-               {
-                       has_connect=true;
-               }
-               if((*iter)->get_connect_duck())
-               {
-                       has_connect=true;
-                       origin=(*iter)->get_connect_duck()->get_trans_point();
-               }
-
-               origin[0]=(origin[0]-window_startx)/pw;
-               origin[1]=(origin[1]-window_starty)/ph;
-
-               bool selected(get_work_area()->duck_is_selected(*iter));
-               bool hover(*iter==hover_duck || (*iter)->get_hover());
-
-               shadow = selected?Gtk::SHADOW_IN:Gtk::SHADOW_OUT;
-
-               if(get_work_area()->get_selected_value_node())
-               {
-                       synfigapp::ValueDesc value_desc((*iter)->get_value_desc());
-                       if (value_desc.is_valid() &&
-                               ((value_desc.is_value_node()            && get_work_area()->get_selected_value_node() == value_desc.get_value_node()) ||
-                                (value_desc.parent_is_value_node()     && get_work_area()->get_selected_value_node() == value_desc.get_parent_value_node())))
-                       {
-                               gc->set_function(Gdk::COPY);
-                               gc->set_rgb_fg_color(DUCK_COLOR_SELECTED);
-                               //gc->set_line_attributes(1,Gdk::LINE_ON_OFF_DASH,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-                               gc->set_line_attributes(2,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-
-                               drawable->draw_rectangle(gc,false,
-                                       round_to_int(point[0]-5),
-                                       round_to_int(point[1]-5),
-                                       10,
-                                       10
-                               );
-                       }
-
-               }
-
-               if((*iter)->get_box_duck())
-               {
-                       Point boxpoint((*iter)->get_box_duck()->get_trans_point());
-                       boxpoint[0]=(boxpoint[0]-window_startx)/pw;
-                       boxpoint[1]=(boxpoint[1]-window_starty)/ph;
-                       Point tl(min(point[0],boxpoint[0]),min(point[1],boxpoint[1]));
-
-                       gc->set_function(Gdk::COPY);
-                       gc->set_rgb_fg_color(DUCK_COLOR_BOX_1);
-                       gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-                       drawable->draw_rectangle(gc,false,
-                               round_to_int(tl[0]),
-                               round_to_int(tl[1]),
-                               round_to_int(abs(boxpoint[0]-point[0])),
-                               round_to_int(abs(boxpoint[1]-point[1]))
-                       );
-                       gc->set_function(Gdk::COPY);
-                       gc->set_rgb_fg_color(DUCK_COLOR_BOX_2);
-                       gc->set_line_attributes(1,Gdk::LINE_ON_OFF_DASH,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-                       drawable->draw_rectangle(gc,false,
-                               round_to_int(tl[0]),
-                               round_to_int(tl[1]),
-                               round_to_int(abs(boxpoint[0]-point[0])),
-                               round_to_int(abs(boxpoint[1]-point[1]))
-                       );
-               }
-
-               ScreenDuck screen_duck;
-               screen_duck.pos=point;
-               screen_duck.selected=selected;
-               screen_duck.hover=hover;
-
-               if(!(*iter)->get_editable())
-                       screen_duck.color=(DUCK_COLOR_NOT_EDITABLE);
-               else if((*iter)->get_tangent())
-                       screen_duck.color=((*iter)->get_scalar()<0 ? DUCK_COLOR_TANGENT_1 : DUCK_COLOR_TANGENT_2);
-               else if((*iter)->get_type()&Duck::TYPE_VERTEX)
-                       screen_duck.color=DUCK_COLOR_VERTEX;
-               else if((*iter)->get_type()&Duck::TYPE_RADIUS)
-                       screen_duck.color=DUCK_COLOR_RADIUS;
-               else if((*iter)->get_type()&Duck::TYPE_WIDTH)
-                       screen_duck.color=DUCK_COLOR_WIDTH;
-               else if((*iter)->get_type()&Duck::TYPE_ANGLE)
-                       screen_duck.color=(DUCK_COLOR_ANGLE);
-               else
-                       screen_duck.color=DUCK_COLOR_OTHER;
-
-               screen_duck_list.push_front(screen_duck);
-
-               if(has_connect)
-               {
-                       if(solid_lines)
-                       {
-                               gc->set_line_attributes(3,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-                               gc->set_rgb_fg_color(DUCK_COLOR_CONNECT_OUTSIDE);
-                               gc->set_function(Gdk::COPY);
-                               drawable->draw_line(gc, (int)origin[0],(int)origin[1],(int)(point[0]),(int)(point[1]));
-                               gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-                               gc->set_rgb_fg_color(DUCK_COLOR_CONNECT_INSIDE);
-                               drawable->draw_line(gc, (int)origin[0],(int)origin[1],(int)(point[0]),(int)(point[1]));
-                       }
-                       else
-                       {
-//                             gc->set_rgb_fg_color(Gdk::Color("#ffffff"));
-//                             gc->set_function(Gdk::INVERT);
-//                             drawable->draw_line(gc, (int)origin[0],(int)origin[1],(int)(point[0]),(int)(point[1]));
-                               gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-                               gc->set_rgb_fg_color(DUCK_COLOR_CONNECT_OUTSIDE);
-                               gc->set_function(Gdk::COPY);
-                               drawable->draw_line(gc, (int)origin[0],(int)origin[1],(int)(point[0]),(int)(point[1]));
-                               gc->set_line_attributes(1,Gdk::LINE_ON_OFF_DASH,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-                               gc->set_rgb_fg_color(DUCK_COLOR_CONNECT_INSIDE);
-                               drawable->draw_line(gc, (int)origin[0],(int)origin[1],(int)(point[0]),(int)(point[1]));
-                       }
-               }
-
-               if((*iter)->is_radius())
-               {
-                       const Real mag((point-origin).mag());
-                       const int d(round_to_int(mag*2));
-                       const int x(round_to_int(origin[0]-mag));
-                       const int y(round_to_int(origin[1]-mag));
-
-                       if(solid_lines)
-                       {
-                               gc->set_rgb_fg_color(Gdk::Color("#000000"));
-                               gc->set_function(Gdk::COPY);
-                               gc->set_line_attributes(3,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-                               drawable->draw_arc(
-                                       gc,
-                                       false,
-                                       x,
-                                       y,
-                                       d,
-                                       d,
-                                       0,
-                                       360*64
-                               );
-                               gc->set_rgb_fg_color(Gdk::Color("#afafaf"));
-                       }
-                       else
-                       {
-                               gc->set_rgb_fg_color(Gdk::Color("#ffffff"));
-                               gc->set_function(Gdk::INVERT);
-                       }
-                       gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-
-                       drawable->draw_arc(
-                               gc,
-                               false,
-                               x,
-                               y,
-                               d,
-                               d,
-                               0,
-                               360*64
-                       );
-
-                       if(hover)
-                       {
-                               Real mag;
-                               if (App::restrict_radius_ducks)
-                               {
-                                       Point sub_trans_point((*iter)->get_sub_trans_point());
-                                       Point sub_trans_origin((*iter)->get_sub_trans_origin());
-
-                                       if (sub_trans_point[0] < sub_trans_origin[0])
-                                               sub_trans_point[0] = sub_trans_origin[0];
-                                       if (sub_trans_point[1] < sub_trans_origin[1])
-                                               sub_trans_point[1] = sub_trans_origin[1];
-
-                                       Point point((*iter)->get_transform_stack().perform(sub_trans_point));
-                                       Point origin((*iter)->get_transform_stack().perform(sub_trans_origin));
-
-                                       mag = (point-origin).mag();
-                               }
-                               else
-                                       mag = ((*iter)->get_trans_point()-(*iter)->get_trans_origin()).mag();
-
-                               Distance real_mag(mag, Distance::SYSTEM_UNITS);
-                               real_mag.convert(App::distance_system,get_work_area()->get_rend_desc());
-                               layout->set_text(real_mag.get_string());
-
-                               gc->set_rgb_fg_color(DUCK_COLOR_WIDTH_TEXT_1);
-                               drawable->draw_layout(
-                                       gc,
-                                       round_to_int(point[0])+1+6,
-                                       round_to_int(point[1])+1-8,
-                                       layout
-                               );
-                               gc->set_rgb_fg_color(DUCK_COLOR_WIDTH_TEXT_2);
-                               drawable->draw_layout(
-                                       gc,
-                                       round_to_int(point[0])+6,
-                                       round_to_int(point[1])-8,
-                                       layout
-                               );
-                       }
-
-               }
-
-       }
-
-
-       for(;screen_duck_list.size();screen_duck_list.pop_front())
-       {
-               int radius=4;
-               int outline=1;
-               Gdk::Color color(screen_duck_list.front().color);
-
-               if(!screen_duck_list.front().selected)
-               {
-                       color.set_red(color.get_red()*2/3);
-                       color.set_green(color.get_green()*2/3);
-                       color.set_blue(color.get_blue()*2/3);
-               }
-
-               if(screen_duck_list.front().hover && !screen_duck_list.back().hover && screen_duck_list.size()>1)
-               {
-                       screen_duck_list.push_back(screen_duck_list.front());
-                       continue;
-               }
-
-               if(screen_duck_list.front().hover)
-               {
-                       radius+=2;
-                       outline++;
-               }
-
-               gc->set_function(Gdk::COPY);
-               gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-               gc->set_rgb_fg_color(DUCK_COLOR_OUTLINE);
-               drawable->draw_arc(
-                       gc,
-                       true,
-                       round_to_int(screen_duck_list.front().pos[0]-radius),
-                       round_to_int(screen_duck_list.front().pos[1]-radius),
-                       radius*2,
-                       radius*2,
-                       0,
-                       360*64
-               );
-
-
-               gc->set_rgb_fg_color(color);
-
-               drawable->draw_arc(
-                       gc,
-                       true,
-                       round_to_int(screen_duck_list.front().pos[0]-radius+outline),
-                       round_to_int(screen_duck_list.front().pos[1]-radius+outline),
-                       radius*2-outline*2,
-                       radius*2-outline*2,
-                       0,
-                       360*64
-               );
-       }
-}
diff --git a/synfig-studio/src/gtkmm/renderer_ducks.h b/synfig-studio/src/gtkmm/renderer_ducks.h
deleted file mode 100644 (file)
index 32a6efd..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file renderer_ducks.h
-**     \brief Template Header
-**
-**     $Id$
-**
-**     \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
-**     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_RENDERER_DUCKS_H
-#define __SYNFIG_RENDERER_DUCKS_H
-
-/* === H E A D E R S ======================================================= */
-
-#include "workarearenderer.h"
-#include <vector>
-
-/* === M A C R O S ========================================================= */
-
-#define DUCK_COLOR_NOT_EDITABLE        Gdk::Color("#cfcfcf")
-
-#define DUCK_COLOR_ANGLE               Gdk::Color("#0000ff")
-#define DUCK_COLOR_RADIUS              Gdk::Color("#00ffff")
-#define DUCK_COLOR_TANGENT_1   Gdk::Color("#ffff00")
-#define DUCK_COLOR_TANGENT_2   Gdk::Color("#ff0000")
-#define DUCK_COLOR_VERTEX              Gdk::Color("#ff7f00")
-#define DUCK_COLOR_WIDTH               Gdk::Color("#ff00ff")
-#define DUCK_COLOR_OTHER               Gdk::Color("#00ff00")
-
-#define DUCK_COLOR_OUTLINE             Gdk::Color("#000000") // the outline around each duck
-
-#define DUCK_COLOR_BEZIER_1            Gdk::Color("#000000") // the 2 colors used to draw bezier curves
-#define DUCK_COLOR_BEZIER_2            Gdk::Color("#afafaf")
-
-#define DUCK_COLOR_BOX_1               Gdk::Color("#ffffff") // the 2 colors used to draw boxes
-#define DUCK_COLOR_BOX_2               Gdk::Color("#000000")
-
-#define DUCK_COLOR_SELECTED            Gdk::Color("#ff0000") // the color of the box drawn when a valuenode is selected
-
-#define DUCK_COLOR_CONNECT_INSIDE      Gdk::Color("#9fefef") // the color of the inside of the line connecting a vertex duck to the tangent ducks
-#define DUCK_COLOR_CONNECT_OUTSIDE     Gdk::Color("#000000") // the color of the outside of the line connecting a vertex duck to the tangent ducks
-
-#define DUCK_COLOR_WIDTH_TEXT_1        Gdk::Color("#000000") // the color of the text's shadow when hovering over a width duck
-#define DUCK_COLOR_WIDTH_TEXT_2        Gdk::Color("#ff00ff") // the color of the text when hovering over a width duck
-
-/* === 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 Renderer_Ducks : public studio::WorkAreaRenderer
-{
-
-public:
-       ~Renderer_Ducks();
-
-       void render_vfunc(const Glib::RefPtr<Gdk::Drawable>& drawable,const Gdk::Rectangle& expose_area );
-
-protected:
-//     bool get_enabled_vfunc()const;
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/renderer_grid.cpp b/synfig-studio/src/gtkmm/renderer_grid.cpp
deleted file mode 100644 (file)
index b00a593..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file renderer_grid.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "renderer_grid.h"
-#include "workarea.h"
-#include <ETL/misc>
-
-#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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Renderer_Grid::~Renderer_Grid()
-{
-}
-
-bool
-Renderer_Grid::get_enabled_vfunc()const
-{
-       return get_work_area()->grid_status();
-}
-
-synfig::Vector
-Renderer_Grid::get_grid_size()const
-{
-       return get_work_area()->get_grid_size();
-}
-
-void
-Renderer_Grid::render_vfunc(
-       const Glib::RefPtr<Gdk::Drawable>& drawable,
-       const Gdk::Rectangle& /*expose_area*/
-)
-{
-       assert(get_work_area());
-       if(!get_work_area())
-               return;
-
-//     const synfig::RendDesc &rend_desc(get_work_area()->get_canvas()->rend_desc());
-
-       const synfig::Vector focus_point(get_work_area()->get_focus_point());
-
-//     std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> >& tile_book(get_tile_book());
-
-       int drawable_w,drawable_h;
-       drawable->get_size(drawable_w,drawable_h);
-
-       // Calculate the window coordinates of the top-left
-       // corner of the canvas.
-//     const synfig::Vector::value_type
-//             x(focus_point[0]/get_pw()+drawable_w/2-get_w()/2),
-//             y(focus_point[1]/get_ph()+drawable_h/2-get_h()/2);
-
-       /*const synfig::Vector::value_type window_startx(window_tl[0]);
-       const synfig::Vector::value_type window_endx(window_br[0]);
-       const synfig::Vector::value_type window_starty(window_tl[1]);
-       const synfig::Vector::value_type window_endy(window_br[1]);
-       */
-//     const int
-//             tile_w(get_work_area()->get_tile_w()),
-//             tile_h(get_work_area()->get_tile_h());
-
-//     const int
-//             w(get_w()),
-//             h(get_h());
-
-       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(drawable));
-
-       const synfig::Vector grid_size(get_grid_size());
-
-       const synfig::Vector::value_type window_startx(get_work_area()->get_window_tl()[0]);
-       const synfig::Vector::value_type window_endx(get_work_area()->get_window_br()[0]);
-       const synfig::Vector::value_type window_starty(get_work_area()->get_window_tl()[1]);
-       const synfig::Vector::value_type window_endy(get_work_area()->get_window_br()[1]);
-       const float pw(get_pw()),ph(get_ph());
-
-       // Draw out the grid
-       if(grid_size[0]>pw*3.5 && grid_size[1]>ph*3.5)
-       {
-               synfig::Vector::value_type x,y;
-
-               x=floor(window_startx/grid_size[0])*grid_size[0];
-               y=floor(window_starty/grid_size[1])*grid_size[1];
-
-               gc->set_function(Gdk::COPY);
-               gc->set_rgb_fg_color(Gdk::Color("#9f9f9f"));
-               gc->set_line_attributes(1,Gdk::LINE_ON_OFF_DASH,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-
-               if(x<window_endx)
-                       for(;x<window_endx;x+=grid_size[0])
-                       {
-                               drawable->draw_line(gc,
-                                       round_to_int((x-window_startx)/pw),
-                                       0,
-                                       round_to_int((x-window_startx)/pw),
-                                       drawable_h
-                               );
-                       }
-               else
-                       for(;x>window_endx;x-=grid_size[0])
-                       {
-                               drawable->draw_line(gc,
-                                       round_to_int((x-window_startx)/pw),
-                                       0,
-                                       round_to_int((x-window_startx)/pw),
-                                       drawable_h
-                               );
-                       }
-
-               if(y<window_endy)
-                       for(;y<window_endy;y+=grid_size[1])
-                       {
-                               drawable->draw_line(gc,
-                                       0,
-                                       round_to_int((y-window_starty)/ph),
-                                       drawable_w,
-                                       round_to_int((y-window_starty)/ph)
-                               );
-                       }
-               else
-                       for(;y>window_endy;y-=grid_size[1])
-                       {
-                               drawable->draw_line(gc,
-                                       0,
-                                       round_to_int((y-window_starty)/ph),
-                                       drawable_w,
-                                       round_to_int((y-window_starty)/ph)
-                               );
-                       }
-       }
-}
diff --git a/synfig-studio/src/gtkmm/renderer_grid.h b/synfig-studio/src/gtkmm/renderer_grid.h
deleted file mode 100644 (file)
index 9cb96c4..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file renderer_grid.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_RENDERER_GRID_H
-#define __SYNFIG_RENDERER_GRID_H
-
-/* === H E A D E R S ======================================================= */
-
-#include "workarearenderer.h"
-#include <vector>
-
-/* === 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 Renderer_Grid : public studio::WorkAreaRenderer
-{
-
-public:
-       ~Renderer_Grid();
-
-       synfig::Vector get_grid_size()const;
-
-       void render_vfunc(const Glib::RefPtr<Gdk::Drawable>& drawable,const Gdk::Rectangle& expose_area );
-
-protected:
-       bool get_enabled_vfunc()const;
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/renderer_guides.cpp b/synfig-studio/src/gtkmm/renderer_guides.cpp
deleted file mode 100644 (file)
index c1f5d9f..0000000
+++ /dev/null
@@ -1,284 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file renderer_guides.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "renderer_guides.h"
-#include "workarea.h"
-#include <ETL/misc>
-
-#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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Renderer_Guides::Renderer_Guides():
-       dragging(false)
-{
-
-}
-
-Renderer_Guides::~Renderer_Guides()
-{
-}
-
-bool
-Renderer_Guides::get_enabled_vfunc()const
-{
-       return get_work_area()->get_show_guides();
-}
-
-std::list<float>&
-Renderer_Guides::get_guide_list_x()
-{
-       return get_work_area()->get_guide_list_x();
-}
-
-std::list<float>&
-Renderer_Guides::get_guide_list_y()
-{
-       return get_work_area()->get_guide_list_y();
-}
-
-bool
-Renderer_Guides::event_vfunc(GdkEvent* event)
-{
-       synfig::Point mouse_pos;
-       // float bezier_click_pos;
-       // const float radius((abs(get_pw())+abs(get_ph()))*4);
-       int button_pressed(0);
-       float pressure(0);
-       bool is_mouse(false);
-       Gdk::ModifierType modifier(Gdk::ModifierType(0));
-
-       // Handle input stuff
-       if(
-               event->any.type==GDK_MOTION_NOTIFY ||
-               event->any.type==GDK_BUTTON_PRESS ||
-               event->any.type==GDK_2BUTTON_PRESS ||
-               event->any.type==GDK_3BUTTON_PRESS ||
-               event->any.type==GDK_BUTTON_RELEASE
-       )
-       {
-               GdkDevice *device;
-               if(event->any.type==GDK_MOTION_NOTIFY)
-               {
-                       device=event->motion.device;
-                       modifier=Gdk::ModifierType(event->motion.state);
-               }
-               else
-               {
-                       device=event->button.device;
-                       modifier=Gdk::ModifierType(event->button.state);
-               }
-
-               // Make sure we recognize the device
-               /*if(curr_input_device)
-               {
-                       if(curr_input_device!=device)
-                       {
-                               assert(device);
-                               curr_input_device=device;
-                               signal_input_device_changed()(curr_input_device);
-                       }
-               }
-               else*/ if(device)
-               {
-                       //curr_input_device=device;
-                       //signal_input_device_changed()(curr_input_device);
-               }
-
-               //assert(curr_input_device);
-
-               // Calculate the position of the
-               // input device in canvas coordinates
-               // and the buttons
-               if(!event->button.axes)
-               {
-                       mouse_pos=synfig::Point(screen_to_comp_coords(synfig::Point(event->button.x,event->button.y)));
-                       button_pressed=event->button.button;
-                       pressure=1.0f;
-                       is_mouse=true;
-                       if(isnan(event->button.x) || isnan(event->button.y))
-                               return false;
-               }
-               else
-               {
-                       double x(event->button.axes[0]);
-                       double y(event->button.axes[1]);
-                       if(isnan(x) || isnan(y))
-                               return false;
-
-                       pressure=event->button.axes[2];
-                       //synfig::info("pressure=%f",pressure);
-                       pressure-=0.04f;
-                       pressure/=1.0f-0.04f;
-
-
-                       assert(!isnan(pressure));
-
-                       mouse_pos=synfig::Point(screen_to_comp_coords(synfig::Point(x,y)));
-
-                       button_pressed=event->button.button;
-
-                       if(button_pressed==1 && pressure<0 && (event->any.type!=GDK_BUTTON_RELEASE && event->any.type!=GDK_BUTTON_PRESS))
-                               button_pressed=0;
-                       if(pressure<0)
-                               pressure=0;
-
-                       //if(event->any.type==GDK_BUTTON_PRESS && button_pressed)
-                       //      synfig::info("Button pressed on input device = %d",event->button.button);
-
-                       //if(event->button.axes[2]>0.1)
-                       //      button_pressed=1;
-                       //else
-                       //      button_pressed=0;
-               }
-       }
-       switch(event->type)
-    {
-       case GDK_BUTTON_PRESS:
-               break;
-       case GDK_MOTION_NOTIFY:
-               break;
-       case GDK_BUTTON_RELEASE:
-               break;
-       default:
-               break;
-       }
-
-       return false;
-}
-
-void
-Renderer_Guides::render_vfunc(
-       const Glib::RefPtr<Gdk::Drawable>& drawable,
-       const Gdk::Rectangle& /*expose_area*/
-)
-{
-       assert(get_work_area());
-       if(!get_work_area())
-               return;
-
-       // const synfig::RendDesc &rend_desc(get_work_area()->get_canvas()->rend_desc());
-
-       const synfig::Vector focus_point(get_work_area()->get_focus_point());
-
-       //std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> >& tile_book(get_tile_book());
-
-       int drawable_w,drawable_h;
-       drawable->get_size(drawable_w,drawable_h);
-
-       // Calculate the window coordinates of the top-left
-       // corner of the canvas.
-       // const synfig::Vector::value_type
-       //      x(focus_point[0]/get_pw()+drawable_w/2-get_w()/2),
-       //      y(focus_point[1]/get_ph()+drawable_h/2-get_h()/2);
-
-       /*const synfig::Vector::value_type window_startx(window_tl[0]);
-       const synfig::Vector::value_type window_endx(window_br[0]);
-       const synfig::Vector::value_type window_starty(window_tl[1]);
-       const synfig::Vector::value_type window_endy(window_br[1]);
-       */
-       // const int
-       //      tile_w(get_work_area()->get_tile_w()),
-       //      tile_h(get_work_area()->get_tile_h());
-
-       // const int
-       //      w(get_w()),
-       //      h(get_h());
-
-       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(drawable));
-
-       //const synfig::Vector grid_size(get_grid_size());
-
-       const synfig::Vector::value_type window_startx(get_work_area()->get_window_tl()[0]);
-       // const synfig::Vector::value_type window_endx(get_work_area()->get_window_br()[0]);
-       const synfig::Vector::value_type window_starty(get_work_area()->get_window_tl()[1]);
-       // const synfig::Vector::value_type window_endy(get_work_area()->get_window_br()[1]);
-       const float pw(get_pw()),ph(get_ph());
-
-       // Draw out the guides
-       {
-               gc->set_function(Gdk::COPY);
-               gc->set_rgb_fg_color(Gdk::Color("#9f9fff"));
-               gc->set_line_attributes(1,Gdk::LINE_ON_OFF_DASH,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-
-               Duckmatic::GuideList::const_iterator iter;
-
-               // vertical
-               for(iter=get_guide_list_x().begin();iter!=get_guide_list_x().end();++iter)
-               {
-                       const float x((*iter-window_startx)/pw);
-
-                       if(iter==get_work_area()->curr_guide)
-                               gc->set_rgb_fg_color(Gdk::Color("#ff6f6f"));
-                       else
-                               gc->set_rgb_fg_color(Gdk::Color("#6f6fff"));
-
-                       drawable->draw_line(gc,
-                               round_to_int(x),
-                               0,
-                               round_to_int(x),
-                               drawable_h
-                       );
-               }
-               // horizontal
-               for(iter=get_guide_list_y().begin();iter!=get_guide_list_y().end();++iter)
-               {
-                       const float y((*iter-window_starty)/ph);
-
-                       if(iter==get_work_area()->curr_guide)
-                               gc->set_rgb_fg_color(Gdk::Color("#ff6f6f"));
-                       else
-                               gc->set_rgb_fg_color(Gdk::Color("#6f6fff"));
-
-                       drawable->draw_line(gc,
-                               0,
-                               round_to_int(y),
-                               drawable_w,
-                               round_to_int(y)
-                       );
-               }
-       }
-}
diff --git a/synfig-studio/src/gtkmm/renderer_guides.h b/synfig-studio/src/gtkmm/renderer_guides.h
deleted file mode 100644 (file)
index d7c7ce0..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file renderer_guides.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_RENDERER_GUIDES_H
-#define __SYNFIG_RENDERER_GUIDES_H
-
-/* === H E A D E R S ======================================================= */
-
-#include "workarearenderer.h"
-#include <vector>
-
-/* === 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 Renderer_Guides : public studio::WorkAreaRenderer
-{
-       bool dragging;
-public:
-       Renderer_Guides();
-       ~Renderer_Guides();
-
-       std::list<float>& get_guide_list_x();
-       std::list<float>& get_guide_list_y();
-
-       void render_vfunc(const Glib::RefPtr<Gdk::Drawable>& drawable,const Gdk::Rectangle& expose_area );
-       bool event_vfunc(GdkEvent* event);
-
-protected:
-       bool get_enabled_vfunc()const;
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/renderer_timecode.cpp b/synfig-studio/src/gtkmm/renderer_timecode.cpp
deleted file mode 100644 (file)
index 48cc42b..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file renderer_timecode.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \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
-**     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 <config.h>
-#endif
-
-#include "renderer_timecode.h"
-#include "workarea.h"
-#include <pangomm/layout.h>
-#include <pangomm/context.h>
-#include <pango/pango.h>
-#include "app.h"
-#include <cassert>
-
-#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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Renderer_Timecode::~Renderer_Timecode()
-{
-}
-
-bool
-Renderer_Timecode::get_enabled_vfunc()const
-{
-       Canvas::Handle canvas(get_work_area()->get_canvas());
-       return (canvas->rend_desc().get_time_start()!=canvas->rend_desc().get_time_end() ||
-               canvas->get_time()!=canvas->rend_desc().get_time_start());
-}
-
-synfig::Vector
-Renderer_Timecode::get_grid_size()const
-{
-       return get_work_area()->get_grid_size();
-}
-
-void
-Renderer_Timecode::render_vfunc(
-       const Glib::RefPtr<Gdk::Drawable>& drawable,
-       const Gdk::Rectangle& /*expose_area*/
-)
-{
-       assert(get_work_area());
-       if(!get_work_area())
-               return;
-
-       //const synfig::RendDesc &rend_desc(get_work_area()->get_canvas()->rend_desc());
-
-       const synfig::Vector focus_point(get_work_area()->get_focus_point());
-
-       //std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> >& tile_book(get_tile_book());
-
-       int drawable_w,drawable_h;
-       drawable->get_size(drawable_w,drawable_h);
-
-       // Calculate the window coordinates of the top-left
-       // corner of the canvas.
-//     const synfig::Vector::value_type
-//             x(focus_point[0]/get_pw()+drawable_w/2-get_w()/2),
-//             y(focus_point[1]/get_ph()+drawable_h/2-get_h()/2);
-
-       /*const synfig::Vector::value_type window_startx(window_tl[0]);
-       const synfig::Vector::value_type window_endx(window_br[0]);
-       const synfig::Vector::value_type window_starty(window_tl[1]);
-       const synfig::Vector::value_type window_endy(window_br[1]);
-       */
-//     const int
-//             tile_w(get_work_area()->get_tile_w()),
-//             tile_h(get_work_area()->get_tile_h());
-
-//     const int
-//             w(get_w()),
-//             h(get_h());
-
-       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(drawable));
-
-       //const synfig::Vector grid_size(get_grid_size());
-
-//     const synfig::Vector::value_type window_startx(get_work_area()->get_window_tl()[0]);
-//     const synfig::Vector::value_type window_endx(get_work_area()->get_window_br()[0]);
-//     const synfig::Vector::value_type window_starty(get_work_area()->get_window_tl()[1]);
-//     const synfig::Vector::value_type window_endy(get_work_area()->get_window_br()[1]);
-//     const float pw(get_pw()),ph(get_ph());
-
-       Canvas::Handle canvas(get_work_area()->get_canvas());
-       synfig::Time cur_time(canvas->get_time());
-
-       // Print out the timecode
-       {
-               Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_work_area()->get_pango_context()));
-
-/*             Glib::ustring timecode(cur_time.get_string(rend_desc.get_frame_rate(),App::get_time_format()));
-
-               try
-               {
-                       timecode+="\n"+canvas->keyframe_list().find(cur_time)->get_description();
-                       gc->set_rgb_fg_color(Gdk::Color("#FF0000"));
-               }
-               catch(synfig::Exception::NotFound)
-               {
-                       return;
-                       gc->set_rgb_fg_color(Gdk::Color("#000000"));
-               }
-
-               layout->set_text(timecode);
-*/
-
-               gc->set_rgb_fg_color(Gdk::Color("#5f0000"));
-               try
-               {
-                       int w, h;
-                       layout->set_text(canvas->keyframe_list().find(cur_time)->get_description());
-                       layout->get_size(w, h);
-                       get_work_area()->timecode_width = int(w*1.0/Pango::SCALE);
-                       get_work_area()->timecode_height = int(h*1.0/Pango::SCALE);
-               }
-               catch(synfig::Exception::NotFound)
-               {
-                       get_work_area()->timecode_width = get_work_area()->timecode_height = 0;
-                       return;
-               }
-               catch(...) {
-                       assert(0);
-               }
-
-               drawable->draw_layout(gc, 4, 4, layout);
-       }
-}
diff --git a/synfig-studio/src/gtkmm/renderer_timecode.h b/synfig-studio/src/gtkmm/renderer_timecode.h
deleted file mode 100644 (file)
index cfd9a0b..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file renderer_timecode.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_RENDERER_TIMECODE_H
-#define __SYNFIG_RENDERER_TIMECODE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include "workarearenderer.h"
-#include <vector>
-
-/* === 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 Renderer_Timecode : public studio::WorkAreaRenderer
-{
-
-public:
-       ~Renderer_Timecode();
-
-       synfig::Vector get_grid_size()const;
-
-       void render_vfunc(const Glib::RefPtr<Gdk::Drawable>& drawable,const Gdk::Rectangle& expose_area );
-
-protected:
-       bool get_enabled_vfunc()const;
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/resolutiondial.cpp b/synfig-studio/src/gtkmm/resolutiondial.cpp
deleted file mode 100644 (file)
index b7ef2c9..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file resolutiondial.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2009 Gerco Ballintijn
-**     Copyright (c) 2009 Carlos Lopez
-**
-**     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 <config.h>
-#endif
-
-#include "resolutiondial.h"
-#include <gtkmm/image.h>
-#include <gtkmm/stock.h>
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace studio;
-
-/* === M A C R O S ========================================================= */
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-ResolutionDial::ResolutionDial(Gtk::IconSize & size): Gtk::Table(3, 1, false)
-{
-
-       increase_resolution = create_icon(size, Gtk::StockID("synfig-increase_resolution"), _("Increase Display Resolution"));
-       decrease_resolution = create_icon(size, Gtk::StockID("synfig-decrease_resolution"), _("Decrease Display Resolution"));
-       use_low_resolution = create_check(_("Low Res"), _("Use Low Resolution when enabled"));
-
-       attach(*decrease_resolution, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       attach(*use_low_resolution, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       attach(*increase_resolution, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-}
-
-Gtk::Button *
-ResolutionDial::create_icon(Gtk::IconSize size, const Gtk::StockID & stockid,
-               const char * tooltip)
-{
-       Gtk::Button *button = manage(new class Gtk::Button());
-       Gtk::Image *icon = manage(new Gtk::Image(stockid, size));
-       button->add(*icon);
-       tooltips.set_tip(*button, tooltip);
-       icon->set_padding(0, 0);
-       icon->show();
-       button->set_relief(Gtk::RELIEF_NONE);
-       button->show();
-
-       return button;
-}
-
-Gtk::CheckButton *
-ResolutionDial::create_check(const char *label, const char * tooltip)
-{
-       Gtk::CheckButton *cbutton = manage(new class Gtk::CheckButton());
-       cbutton->set_label(label);
-       tooltips.set_tip(*cbutton, tooltip);
-       cbutton->show();
-
-       return cbutton;
-}
-
-void
-ResolutionDial::update_lowres(bool flag)
-{
-       use_low_resolution->set_active(flag);
-}
diff --git a/synfig-studio/src/gtkmm/resolutiondial.h b/synfig-studio/src/gtkmm/resolutiondial.h
deleted file mode 100644 (file)
index 611eb11..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file resolutiondial.h
-**     \brief Template Header
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2008 Chris Moore
-**     Copyright (c) 2009 Gerco Ballintijn
-**     Copyright (c) 2009 Carlos Lopez
-**
-**     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_RESOLUTIONDIAL_H
-#define __SYNFIG_STUDIO_RESOLUTIONDIAL_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/tooltips.h>
-#include <gtkmm/table.h>
-#include <gtkmm/checkbutton.h>
-#include "duckmatic.h"
-
-#include "general.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 ResolutionDial : public Gtk::Table
-{
-       Gtk::Tooltips tooltips;
-
-       Gtk::Button *increase_resolution;
-       Gtk::Button *decrease_resolution;
-       Gtk::CheckButton *use_low_resolution;
-
-       Gtk::Button *create_icon(Gtk::IconSize size, const Gtk::StockID & stockid, const char * tooltip);
-       Gtk::CheckButton *create_check(const char *text, const char *tooltip);
-
-public:
-
-       ResolutionDial(Gtk::IconSize & size);
-
-       void update_lowres(bool flag);
-       Glib::SignalProxy0<void> signal_increase_resolution()  { return increase_resolution->signal_clicked(); }
-       Glib::SignalProxy0<void> signal_decrease_resolution()  { return decrease_resolution->signal_clicked(); }
-       Glib::SignalProxy0<void> signal_use_low_resolution()   { return use_low_resolution-> signal_toggled(); }
-
-}; // END of class ResolutionDial
-
-}; // END of namespace studio
-
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/smach.h b/synfig-studio/src/gtkmm/smach.h
deleted file mode 100644 (file)
index f113147..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file smach.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_SMACH_H
-#define __SYNFIG_SMACH_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <ETL/smach>
-#include "eventkey.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 CanvasView;
-
-typedef etl::smach<CanvasView,EventKey> Smach;
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/splash.cpp b/synfig-studio/src/gtkmm/splash.cpp
deleted file mode 100644 (file)
index fe87f01..0000000
+++ /dev/null
@@ -1,252 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file splash.cpp
-**     \brief writeme
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007 Chris Moore
-**     Copyright (c) 2008 Paul Wise
-**
-**     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
-**
-** === N O T E S ===========================================================
-**
-** ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include <iostream>
-#include <string>
-
-#include <ETL/stringf>
-
-#include <gtkmm/image.h>
-#include <gtkmm/label.h>
-#include <gtkmm/frame.h>
-#include <gtkmm/fixed.h>
-
-#include <synfig/general.h>
-
-#include "splash.h"
-#include "app.h"
-
-#include "general.h"
-
-#endif
-
-using namespace std;
-using namespace etl;
-using namespace studio;
-
-/* === M A C R O S ========================================================= */
-
-#ifndef VERSION
-#define VERSION        "unknown"
-#define PACKAGE        "synfigstudio"
-#endif
-
-#ifdef WIN32
-#      ifdef IMAGE_DIR
-#              undef IMAGE_DIR
-#              define IMAGE_DIR "share\\pixmaps"
-#      endif
-#endif
-
-#ifndef IMAGE_DIR
-#      define IMAGE_DIR "/usr/local/share/pixmaps"
-#endif
-
-#ifndef IMAGE_EXT
-#      define IMAGE_EXT        "png"
-#endif
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-class studio::SplashProgress : public synfig::ProgressCallback
-{
-       Splash &splash;
-
-public:
-
-       SplashProgress(Splash &splash):splash(splash) { }
-
-       virtual bool task(const std::string &task)
-       {
-               if(splash.tasklabel)
-               {
-                       splash.tasklabel->set_label(task);
-                       splash.tasklabel->show();
-               }
-               else
-               {
-                       cerr<<task<<endl;
-               }
-
-               while(studio::App::events_pending())studio::App::iteration(false);
-               return true;
-       }
-
-       virtual bool error(const std::string &task)
-       {
-               if(splash.tasklabel)
-               {
-                       splash.tasklabel->set_label(_("ERROR:")+task);
-                       splash.tasklabel->show();
-               }
-               else
-               {
-                       cerr<<task<<endl;
-               }
-
-               while(studio::App::events_pending())studio::App::iteration(false);
-               return true;
-       }
-
-       virtual bool warning(const std::string &task)
-       {
-               if(splash.tasklabel)
-               {
-                       splash.tasklabel->set_label(_("WARNING:")+task);
-                       splash.tasklabel->show();
-               }
-               else
-               {
-                       cerr<<task<<endl;
-               }
-
-               while(studio::App::events_pending())studio::App::iteration(false);
-               return true;
-       }
-
-       virtual bool amount_complete(int current, int total)
-       {
-               if(splash.progressbar)
-               {
-                       splash.progressbar->set_fraction((float)current/(float)total);
-                       splash.progressbar->show();
-               }
-               else
-                       cerr<<current<<'/'<<total<<endl;
-
-               while(studio::App::events_pending())studio::App::iteration(false);
-               return true;
-       }
-}; // END of class SplashProgress
-
-/* === M E T H O D S ======================================================= */
-
-Splash::Splash():
-       Gtk::Window(getenv("SYNFIG_DISABLE_POPUP_WINDOWS") ? Gtk::WINDOW_TOPLEVEL : Gtk::WINDOW_POPUP)
-{
-       std::string imagepath;
-#ifdef WIN32
-       imagepath=App::get_base_path()+ETL_DIRECTORY_SEPARATOR+IMAGE_DIR;
-#else
-       imagepath=IMAGE_DIR;
-#endif
-       char* synfig_root=getenv("SYNFIG_ROOT");
-       if(synfig_root) {
-               imagepath=synfig_root;
-               imagepath+=ETL_DIRECTORY_SEPARATOR;
-               imagepath+="share";
-               imagepath+=ETL_DIRECTORY_SEPARATOR;
-               imagepath+="pixmaps";
-               imagepath+=ETL_DIRECTORY_SEPARATOR;
-               imagepath+="synfigstudio";
-       }
-       imagepath+=ETL_DIRECTORY_SEPARATOR;
-
-       // Create the splash image
-       Gtk::Image* splash_image = manage(new class Gtk::Image());
-       splash_image->set(imagepath+"splash_screen."IMAGE_EXT);
-       splash_image->set_alignment(0.5,0.5);
-       splash_image->set_padding(0,0);
-
-       // Get the image size
-       int image_w = 350; int image_h = 0;
-       Glib::RefPtr<Gdk::Pixbuf> pixbuf = splash_image->get_pixbuf();
-       if( pixbuf ){
-               image_w = pixbuf->get_width();
-               image_h = pixbuf->get_height();
-       }
-
-       // Create the progress bar
-       progressbar = manage(new class Gtk::ProgressBar());
-       progressbar->set_size_request(image_w,24);
-
-       // Create the current task label
-       tasklabel = manage(new class Gtk::Label());
-       tasklabel->set_size_request(image_w,24);
-       tasklabel->set_use_underline(false);
-
-       // Create the Gtk::Fixed container and put all of the widgets into it
-       Gtk::Fixed* fixed = manage(new class Gtk::Fixed());
-       if( pixbuf ) fixed->put(*splash_image, 0, 0);
-       fixed->put(*progressbar, 0, image_h+24);
-       fixed->put(*tasklabel, 0, image_h);
-
-       // Create shadow around the outside of the window
-       Gtk::Frame* frame = manage(new class Gtk::Frame());
-       frame->set_shadow_type(Gtk::SHADOW_OUT);
-       frame->add(*fixed);
-
-       // Set up the parameters for this pop-up window
-       set_title("Synfig Studio "VERSION);
-       set_modal(false);
-       property_window_position().set_value(Gtk::WIN_POS_CENTER);
-       set_resizable(false);
-       set_type_hint(Gdk::WINDOW_TYPE_HINT_SPLASHSCREEN);
-       set_auto_startup_notification(false);
-       try {
-               set_icon_from_file(imagepath+"synfig_icon."+IMAGE_EXT);
-       } catch(...) {
-               synfig::warning("Unable to open "+imagepath+"synfig_icon."+IMAGE_EXT);
-       }
-       add(*frame);
-
-       // show everything off
-       if( pixbuf ) splash_image->show();
-       fixed->show();
-       frame->show();
-
-       // Once the splash is shown, we want startup stuff to continue as normal
-       signal_map().connect(sigc::mem_fun(*this, &Splash::enable_startup_notification));
-
-       cb=new SplashProgress(*this);
-}
-
-Splash::~Splash()
-{
-       delete cb;
-}
-
-synfig::ProgressCallback *
-Splash::get_callback()
-{
-       return cb;
-}
-
-void
-Splash::enable_startup_notification(){
-       set_auto_startup_notification(true);
-}
diff --git a/synfig-studio/src/gtkmm/splash.h b/synfig-studio/src/gtkmm/splash.h
deleted file mode 100644 (file)
index 5f0b9e7..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file splash.h
-**     \brief Header File
-**
-**     $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
-**
-** === N O T E S ===========================================================
-**
-** ========================================================================= */
-
-/* === S T A R T =========================================================== */
-
-#ifndef __SYNFIG_GTKMM_SPLASH_H
-#define __SYNFIG_GTKMM_SPLASH_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/window.h>
-#include <gtkmm/label.h>
-#include <gtkmm/button.h>
-#include <gtkmm/progressbar.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 synfig { class ProgressCallback; };
-
-namespace studio {
-
-class SplashProgress;
-
-class Splash : public Gtk::Window
-{
-       friend class SplashProgress;
-
-       SplashProgress *cb;
-
-       Gtk::Label *tasklabel;
-       Gtk::ProgressBar *progressbar;
-
-public:
-
-       synfig::ProgressCallback *get_callback();
-
-       void enable_startup_notification();
-
-       Splash();
-       ~Splash();
-};
-
-}
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/state_bline.cpp b/synfig-studio/src/gtkmm/state_bline.cpp
deleted file mode 100644 (file)
index ee0ca20..0000000
+++ /dev/null
@@ -1,1414 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_bline.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 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 <config.h>
-#endif
-
-#include <gtkmm/dialog.h>
-#include <gtkmm/entry.h>
-
-#include <synfig/valuenode_dynamiclist.h>
-
-#include "state_bline.h"
-#include "state_normal.h"
-#include "canvasview.h"
-#include "workarea.h"
-#include "app.h"
-#include <synfig/valuenode_bline.h>
-#include <ETL/hermite>
-#include <ETL/calculus>
-#include <utility>
-#include "event_mouse.h"
-#include "event_layerclick.h"
-#include "toolbox.h"
-#include "dialog_tooloptions.h"
-#include <gtkmm/spinbutton.h>
-#include <synfig/transform.h>
-#include <synfigapp/main.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 ========================================================= */
-
-// if defined, show the first duck as green while drawing
-#define DISTINGUISH_FIRST_DUCK
-
-/* === G L O B A L S ======================================================= */
-
-StateBLine studio::state_bline;
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-class studio::StateBLine_Context : public sigc::trackable
-{
-       etl::handle<CanvasView> canvas_view_;
-       CanvasView::IsWorking is_working;
-
-       bool prev_table_status;
-       bool loop_;
-       bool prev_workarea_layer_status_;
-
-       int depth;
-       Canvas::Handle canvas;
-
-       Gtk::Menu menu;
-
-       Duckmatic::Push duckmatic_push;
-
-       etl::handle<Duck> curr_duck;
-
-       etl::handle<Duck> next_duck;
-
-       std::list<synfig::ValueNode_Const::Handle> bline_point_list;
-       synfigapp::Settings& settings;
-
-       bool on_vertex_change(const synfig::Point &point, synfig::ValueNode_Const::Handle value_node);
-       bool on_tangent1_change(const synfig::Point &point, synfig::ValueNode_Const::Handle value_node);
-       bool on_tangent2_change(const synfig::Point &point, synfig::ValueNode_Const::Handle value_node);
-
-
-       void popup_handle_menu(synfig::ValueNode_Const::Handle value_node);
-       void popup_vertex_menu(synfig::ValueNode_Const::Handle value_node);
-       void popup_bezier_menu(float location, synfig::ValueNode_Const::Handle value_node);
-
-       void bline_detach_handle(synfig::ValueNode_Const::Handle value_node);
-       void bline_attach_handle(synfig::ValueNode_Const::Handle value_node);
-       void bline_delete_vertex(synfig::ValueNode_Const::Handle value_node);
-       void bline_insert_vertex(synfig::ValueNode_Const::Handle value_node,float origin=0.5);
-       void loop_bline();
-       void unloop_bline();
-
-       void refresh_ducks(bool x=true);
-
-       Gtk::Table options_table;
-       Gtk::Entry entry_id;
-       Gtk::CheckButton checkbutton_layer_region;
-       Gtk::CheckButton checkbutton_layer_outline;
-       Gtk::CheckButton checkbutton_layer_curve_gradient;
-       Gtk::CheckButton checkbutton_layer_plant;
-       Gtk::CheckButton checkbutton_layer_link_origins;
-       Gtk::CheckButton checkbutton_auto_export;
-       Gtk::Button button_make;
-       Gtk::Button button_clear;
-       Gtk::Adjustment  adj_feather;
-       Gtk::SpinButton  spin_feather;
-
-
-
-public:
-
-       int layers_to_create()const
-       {
-               return
-                       get_layer_region_flag() +
-                       get_layer_outline_flag() +
-                       get_layer_curve_gradient_flag() +
-                       get_layer_plant_flag();
-       }
-
-       void sanity_check()
-       {
-               if(layers_to_create()==0)
-                       set_layer_region_flag(true);
-       }
-
-       bool get_auto_export_flag()const { return checkbutton_auto_export.get_active(); }
-       void set_auto_export_flag(bool x) { return checkbutton_auto_export.set_active(x); }
-
-       bool get_layer_region_flag()const { return checkbutton_layer_region.get_active(); }
-       void set_layer_region_flag(bool x) { return checkbutton_layer_region.set_active(x); }
-
-       bool get_layer_outline_flag()const { return checkbutton_layer_outline.get_active(); }
-       void set_layer_outline_flag(bool x) { return checkbutton_layer_outline.set_active(x); }
-
-       bool get_layer_curve_gradient_flag()const { return checkbutton_layer_curve_gradient.get_active(); }
-       void set_layer_curve_gradient_flag(bool x) { return checkbutton_layer_curve_gradient.set_active(x); }
-
-       bool get_layer_plant_flag()const { return checkbutton_layer_plant.get_active(); }
-       void set_layer_plant_flag(bool x) { return checkbutton_layer_plant.set_active(x); }
-
-       bool get_layer_link_origins_flag()const { return checkbutton_layer_link_origins.get_active(); }
-       void set_layer_link_origins_flag(bool x) { return checkbutton_layer_link_origins.set_active(x); }
-
-       Real get_feather() const { return adj_feather.get_value(); }
-       void set_feather(Real x) { return adj_feather.set_value(x); }
-       synfig::String get_id()const { return entry_id.get_text(); }
-       void set_id(const synfig::String& x) { return entry_id.set_text(x); }
-
-       Smach::event_result event_stop_handler(const Smach::event& x);
-
-       Smach::event_result event_refresh_handler(const Smach::event& x);
-
-       Smach::event_result event_mouse_click_handler(const Smach::event& x);
-       Smach::event_result event_mouse_release_handler(const Smach::event& x);
-       Smach::event_result event_mouse_motion_handler(const Smach::event& x);
-       Smach::event_result event_refresh_tool_options(const Smach::event& x);
-
-       Smach::event_result event_hijack(const Smach::event& /*x*/) { return Smach::RESULT_ACCEPT; }
-
-       void refresh_tool_options();
-
-       StateBLine_Context(CanvasView* canvas_view);
-
-       ~StateBLine_Context();
-
-       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
-       etl::handle<synfigapp::CanvasInterface> 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();}
-       const synfig::TransformStack& get_transform_stack()const { return canvas_view_->get_curr_transform_stack(); }
-
-       void load_settings();
-       void save_settings();
-       void reset();
-       void increment_id();
-       //void on_user_click(synfig::Point point);
-
-       bool run_();
-       bool run();
-
-       bool egress_on_selection_change;
-       Smach::event_result event_layer_selection_changed_handler(const Smach::event& /*x*/)
-       {
-               if(egress_on_selection_change)
-                       throw &state_normal; //throw Smach::egress_exception();
-               return Smach::RESULT_OK;
-       }
-
-};     // END of class StateBLine_Context
-
-
-/* === M E T H O D S ======================================================= */
-
-StateBLine::StateBLine():
-       Smach::state<StateBLine_Context>("bline")
-{
-       insert(event_def(EVENT_LAYER_SELECTION_CHANGED,         &StateBLine_Context::event_layer_selection_changed_handler));
-       insert(event_def(EVENT_STOP,                                            &StateBLine_Context::event_stop_handler));
-       insert(event_def(EVENT_REFRESH,                                         &StateBLine_Context::event_refresh_handler));
-       insert(event_def(EVENT_REFRESH_DUCKS,                           &StateBLine_Context::event_hijack));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,      &StateBLine_Context::event_mouse_click_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_UP,        &StateBLine_Context::event_mouse_release_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_MOTION,           &StateBLine_Context::event_mouse_motion_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DRAG,      &StateBLine_Context::event_mouse_motion_handler));
-       insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,            &StateBLine_Context::event_refresh_tool_options));
-}
-
-StateBLine::~StateBLine()
-{
-}
-
-void
-StateBLine_Context::load_settings()
-{
-       String value;
-
-       if(settings.get_value("bline.layer_region",value) && value=="0")
-               set_layer_region_flag(false);
-       else
-               set_layer_region_flag(true);
-
-       if(settings.get_value("bline.layer_outline",value) && value=="0")
-               set_layer_outline_flag(false);
-       else
-               set_layer_outline_flag(true);
-
-       if(settings.get_value("bline.layer_curve_gradient",value) && value=="1")
-               set_layer_curve_gradient_flag(true);
-       else
-               set_layer_curve_gradient_flag(false);
-
-       if(settings.get_value("bline.layer_plant",value) && value=="1")
-               set_layer_plant_flag(true);
-       else
-               set_layer_plant_flag(false);
-
-       if(settings.get_value("bline.layer_link_origins",value) && value=="0")
-               set_layer_link_origins_flag(false);
-       else
-               set_layer_link_origins_flag(true);
-
-       if(settings.get_value("bline.auto_export",value) && value=="1")
-               set_auto_export_flag(true);
-       else
-               set_auto_export_flag(false);
-
-       if(settings.get_value("bline.id",value))
-               set_id(value);
-       else
-               set_id("NewBLine");
-
-       if(settings.get_value("bline.feather",value))
-       {
-               Real n = atof(value.c_str());
-               set_feather(n);
-       }
-
-       sanity_check();
-}
-
-void
-StateBLine_Context::save_settings()
-{
-       sanity_check();
-       settings.set_value("bline.layer_outline",get_layer_outline_flag()?"1":"0");
-       settings.set_value("bline.layer_region",get_layer_region_flag()?"1":"0");
-       settings.set_value("bline.layer_curve_gradient",get_layer_curve_gradient_flag()?"1":"0");
-       settings.set_value("bline.layer_plant",get_layer_plant_flag()?"1":"0");
-       settings.set_value("bline.layer_link_origins",get_layer_link_origins_flag()?"1":"0");
-       settings.set_value("bline.auto_export",get_auto_export_flag()?"1":"0");
-       settings.set_value("bline.id",get_id().c_str());
-       settings.set_value("bline.feather",strprintf("%f",get_feather()));
-}
-
-void
-StateBLine_Context::reset()
-{
-       loop_=false;
-       bline_point_list.clear();
-       refresh_ducks();
-}
-
-void
-StateBLine_Context::increment_id()
-{
-       String id(get_id());
-       int number=1;
-       int digits=0;
-
-       if(id.empty())
-               id="NewBLine";
-
-       // If there is a number
-       // already at the end of the
-       // id, then remove it.
-       if(id[id.size()-1]<='9' && id[id.size()-1]>='0')
-       {
-               // figure out how many digits it is
-               for (digits = 0;
-                        (int)id.size()-1 >= digits && id[id.size()-1-digits] <= '9' && id[id.size()-1-digits] >= '0';
-                        digits++)
-                       ;
-
-               String str_number;
-               str_number=String(id,id.size()-digits,id.size());
-               id=String(id,0,id.size()-digits);
-               // synfig::info("---------------- \"%s\"",str_number.c_str());
-
-               number=atoi(str_number.c_str());
-       }
-       else
-       {
-               number=1;
-               digits=3;
-       }
-
-       number++;
-
-       // Add the number back onto the id
-       {
-               const String format(strprintf("%%0%dd",digits));
-               id+=strprintf(format.c_str(),number);
-       }
-
-       // Set the ID
-       set_id(id);
-}
-
-
-StateBLine_Context::StateBLine_Context(CanvasView* canvas_view):
-       canvas_view_(canvas_view),
-       is_working(*canvas_view),
-       loop_(false),
-       prev_workarea_layer_status_(get_work_area()->get_allow_layer_clicks()),
-       duckmatic_push(get_work_area()),
-       settings(synfigapp::Main::get_selected_input_device()->settings()),
-       entry_id(),
-       checkbutton_layer_region(_("Create Region BLine")),
-       checkbutton_layer_outline(_("Create Outline BLine")),
-       checkbutton_layer_curve_gradient(_("Create Curve Gradient BLine")),
-       checkbutton_layer_plant(_("Create Plant BLine")),
-       checkbutton_layer_link_origins(_("Link Origins")),
-       checkbutton_auto_export(_("Auto Export")),
-       button_make(_("Make")),
-       button_clear(_("Clear")),
-       adj_feather(0,0,10000,0.01,0.1),
-       spin_feather(adj_feather,0.01,4)
-{
-       depth=-1;
-       egress_on_selection_change=true;
-       load_settings();
-
-       // Set up the tool options dialog
-       options_table.attach(*manage(new Gtk::Label(_("BLine Tool"))),  0, 2,  0,  1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(entry_id,                                                                  0, 2,  1,  2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_outline,                                 0, 2,  2,  3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_region,                                  0, 2,  3,  4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_plant,                                   0, 2,  4,  5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_curve_gradient,                  0, 2,  5,  6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_link_origins,                    0, 2,  6,  7, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_auto_export,                                   0, 2,  7,  8, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(*manage(new Gtk::Label(_("Feather"))),     0, 1, 10, 11, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(spin_feather,                                                              1, 2, 10, 11, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       //options_table.attach(button_make, 0, 2, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       //button_make.signal_pressed().connect(sigc::mem_fun(*this,&StateBLine_Context::run));
-       options_table.show_all();
-       refresh_tool_options();
-       App::dialog_tool_options->present();
-
-       // Turn off layer clicking
-       get_work_area()->set_allow_layer_clicks(false);
-
-       // clear out the ducks
-       get_work_area()->clear_ducks();
-
-       // Refresh the work area
-       get_work_area()->queue_draw();
-
-       // Hide the tables if they are showing
-       prev_table_status=get_canvas_view()->tables_are_visible();
-       if(prev_table_status)get_canvas_view()->hide_tables();
-
-       // Disable the time bar
-       get_canvas_view()->set_sensitive_timebar(false);
-
-       // Connect a signal
-       //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateBLine_Context::on_user_click));
-       get_work_area()->set_cursor(Gdk::CROSSHAIR);
-
-       App::toolbox->refresh();
-}
-
-void
-StateBLine_Context::refresh_tool_options()
-{
-       App::dialog_tool_options->clear();
-       App::dialog_tool_options->set_widget(options_table);
-       App::dialog_tool_options->set_local_name(_("BLine Tool"));
-       App::dialog_tool_options->set_name("bline");
-
-       App::dialog_tool_options->add_button(
-               Gtk::StockID("gtk-execute"),
-               _("Make BLine and/or Region")
-       )->signal_clicked().connect(
-               sigc::hide_return(sigc::mem_fun(
-                       *this,
-                       &StateBLine_Context::run
-               ))
-       );
-
-       App::dialog_tool_options->add_button(
-               Gtk::StockID("gtk-clear"),
-               _("Clear current BLine")
-       )->signal_clicked().connect(
-               sigc::mem_fun(
-                       *this,
-                       &StateBLine_Context::reset
-               )
-       );
-}
-
-Smach::event_result
-StateBLine_Context::event_refresh_tool_options(const Smach::event& /*x*/)
-{
-       refresh_tool_options();
-       return Smach::RESULT_ACCEPT;
-}
-
-StateBLine_Context::~StateBLine_Context()
-{
-       run();
-
-       save_settings();
-       App::dialog_tool_options->clear();
-
-       get_work_area()->reset_cursor();
-
-       // Restore layer clicking
-       get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_);
-
-       // Enable the time bar
-       get_canvas_view()->set_sensitive_timebar(true);
-
-       // Bring back the tables if they were out before
-       if(prev_table_status)get_canvas_view()->show_tables();
-
-//     get_canvas_view()->get_smach().process_event(EVENT_REFRESH_DUCKS);
-
-       // Refresh the work area
-       get_work_area()->queue_draw();
-
-       App::toolbox->refresh();
-}
-
-Smach::event_result
-StateBLine_Context::event_stop_handler(const Smach::event& /*x*/)
-{
-//     synfig::info("STATE RotoBLine: Received Stop Event");
-//     run();
-       reset();
-//     throw Smach::egress_exception();
-//     get_canvas_view()->get_smach().pop_state();
-       return Smach::RESULT_ACCEPT;
-}
-
-Smach::event_result
-StateBLine_Context::event_refresh_handler(const Smach::event& /*x*/)
-{
-//     synfig::info("STATE RotoBLine: Received Refresh Event");
-       refresh_ducks();
-       return Smach::RESULT_ACCEPT;
-}
-
-bool
-StateBLine_Context::run()
-{
-       sanity_check();
-
-       String err;
-       bool success(false);
-       for(int i=5;i>0 && !success;i--)try
-       {
-               success=run_();
-       }
-       catch(String s)
-       {
-               err=s;
-       }
-       if(!success && !err.empty())
-       {
-               get_canvas_view()->get_ui_interface()->error(err);
-       }
-       return success;
-}
-
-bool
-StateBLine_Context::run_()
-{
-       curr_duck=0;
-       next_duck=0;
-
-       // Now we need to generate it
-
-       if(bline_point_list.empty())
-       {
-               return false;
-       }
-       if(bline_point_list.size()<2)
-       {
-               //get_canvas_view()->get_ui_interface()->error(_("You need at least two (2) points to create a BLine"));
-               return false;
-       }
-
-       do
-       {
-
-               // Create the action group
-               synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("New BLine"));
-
-               std::vector<BLinePoint> new_list;
-               std::list<synfig::ValueNode_Const::Handle>::iterator iter;
-               const synfig::TransformStack& transform(get_transform_stack());
-
-               for(iter=bline_point_list.begin();iter!=bline_point_list.end();++iter)
-               {
-                       BLinePoint bline_point((*iter)->get_value().get(BLinePoint()));
-                       Point new_vertex(transform.unperform(bline_point.get_vertex()));
-
-                       bline_point.set_tangent1(
-                               transform.unperform(
-                                       bline_point.get_tangent1()+bline_point.get_vertex()
-                               ) -new_vertex
-                       );
-
-                       bline_point.set_tangent2(
-                               transform.unperform(
-                                       bline_point.get_tangent2()+bline_point.get_vertex()
-                               ) -new_vertex
-                       );
-
-                       bline_point.set_vertex(new_vertex);
-
-                       new_list.push_back(bline_point);
-               }
-
-               ValueNode_BLine::Handle value_node_bline(ValueNode_BLine::create(new_list));
-               assert(value_node_bline);
-
-               ValueNode_Const::Handle value_node_origin(ValueNode_Const::create(Vector()));
-               assert(value_node_origin);
-
-               // Set the looping flag
-               value_node_bline->set_loop(loop_);
-
-               // Add the BLine to the canvas
-               if(get_auto_export_flag() && !get_canvas_interface()->add_value_node(value_node_bline,get_id()))
-               {
-                       //get_canvas_view()->get_ui_interface()->error(_("Unable to add value node"));
-                       group.cancel();
-                       increment_id();
-                       throw String(_("Unable to add value node"));
-                       return false;
-               }
-
-               Layer::Handle layer;
-
-               // we are temporarily using the layer to hold something
-               layer=get_canvas_view()->get_selection_manager()->get_selected_layer();
-
-               if(layer)
-               {
-                       if(depth<0)
-                               depth=layer->get_depth();
-                       if(!canvas)
-                               canvas=layer->get_canvas();
-               }
-               else
-                       depth=0;
-
-               if(!canvas)
-                       canvas=get_canvas_view()->get_canvas();
-
-               value_node_bline->set_member_canvas(canvas);
-
-               synfigapp::SelectionManager::LayerList layer_selection;
-               if (!getenv("SYNFIG_TOOLS_CLEAR_SELECTION"))
-                       layer_selection = get_canvas_view()->get_selection_manager()->get_selected_layers();
-
-               // count how many layers we're going to be creating
-               int layers_to_create = this->layers_to_create();
-
-               ///////////////////////////////////////////////////////////////////////////
-               //   C U R V E   G R A D I E N T
-               ///////////////////////////////////////////////////////////////////////////
-
-               if(get_layer_curve_gradient_flag())
-               {
-                       synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
-                       Layer::Handle layer(get_canvas_interface()->add_layer_to("curve_gradient",canvas,depth));
-                       if (!layer)
-                       {
-                               group.cancel();
-                               throw String(_("Unable to create layer"));
-                       }
-                       layer_selection.push_back(layer);
-                       layer->set_description(get_id()+_(" Gradient"));
-                       get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
-                       {
-                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                               assert(action);
-
-                               action->set_param("canvas",get_canvas());
-                               action->set_param("canvas_interface",get_canvas_interface());
-                               action->set_param("layer",layer);
-                               if(!action->set_param("param",String("bline")))
-                                       synfig::error("LayerParamConnect didn't like \"param\"");
-                               if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
-                                       synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                               if(!get_canvas_interface()->get_instance()->perform_action(action))
-                               {
-                                       //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                                       group.cancel();
-                                       throw String(_("Unable to create Gradient layer"));
-                                       return false;
-                               }
-                       }
-
-                       // only link the curve gradient's origin parameter if the option is selected and we're creating more than one layer
-                       if (get_layer_link_origins_flag() && layers_to_create > 1)
-                       {
-                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                               assert(action);
-
-                               action->set_param("canvas",get_canvas());
-                               action->set_param("canvas_interface",get_canvas_interface());
-                               action->set_param("layer",layer);
-                               if(!action->set_param("param",String("origin")))
-                                       synfig::error("LayerParamConnect didn't like \"param\"");
-                               if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
-                                       synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                               if(!get_canvas_interface()->get_instance()->perform_action(action))
-                               {
-                                       //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                                       group.cancel();
-                                       throw String(_("Unable to create Gradient layer"));
-                                       return false;
-                               }
-                       }
-               }
-
-               ///////////////////////////////////////////////////////////////////////////
-               //   P L A N T
-               ///////////////////////////////////////////////////////////////////////////
-
-               if(get_layer_plant_flag())
-               {
-                       synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
-                       Layer::Handle layer(get_canvas_interface()->add_layer_to("plant",canvas,depth));
-                       if (!layer)
-                       {
-                               group.cancel();
-                               throw String(_("Unable to create layer"));
-                       }
-                       layer_selection.push_back(layer);
-                       layer->set_description(get_id()+_(" Plant"));
-                       get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
-                       {
-                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                               assert(action);
-
-                               action->set_param("canvas",get_canvas());
-                               action->set_param("canvas_interface",get_canvas_interface());
-                               action->set_param("layer",layer);
-                               if(!action->set_param("param",String("bline")))
-                                       synfig::error("LayerParamConnect didn't like \"param\"");
-                               if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
-                                       synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                               if(!get_canvas_interface()->get_instance()->perform_action(action))
-                               {
-                                       //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                                       group.cancel();
-                                       throw String(_("Unable to create Plant layer"));
-                                       return false;
-                               }
-                       }
-
-                       // only link the plant's origin parameter if the option is selected and we're creating more than one layer
-                       if (get_layer_link_origins_flag() && layers_to_create > 1)
-                       {
-                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                               assert(action);
-
-                               action->set_param("canvas",get_canvas());
-                               action->set_param("canvas_interface",get_canvas_interface());
-                               action->set_param("layer",layer);
-                               if(!action->set_param("param",String("origin")))
-                                       synfig::error("LayerParamConnect didn't like \"param\"");
-                               if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
-                                       synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                               if(!get_canvas_interface()->get_instance()->perform_action(action))
-                               {
-                                       //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                                       group.cancel();
-                                       throw String(_("Unable to create Plant layer"));
-                                       return false;
-                               }
-                       }
-               }
-
-               ///////////////////////////////////////////////////////////////////////////
-               //   R E G I O N
-               ///////////////////////////////////////////////////////////////////////////
-
-               if(get_layer_region_flag())
-               {
-                       synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
-                       Layer::Handle layer(get_canvas_interface()->add_layer_to("region",canvas,depth));
-                       if (!layer)
-                       {
-                               group.cancel();
-                               throw String(_("Unable to create layer"));
-                       }
-                       layer_selection.push_back(layer);
-                       layer->set_description(get_id()+_(" Region"));
-                       get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
-                       if(get_feather())
-                       {
-                               layer->set_param("feather",get_feather());
-                               get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
-                       }
-
-                       // I don't know if it's safe to reuse the same LayerParamConnect action, so I'm
-                       // using 2 separate ones.
-                       {
-                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                               assert(action);
-
-                               action->set_param("canvas",get_canvas());
-                               action->set_param("canvas_interface",get_canvas_interface());
-                               action->set_param("layer",layer);
-                               if(!action->set_param("param",String("bline")))
-                                       synfig::error("LayerParamConnect didn't like \"param\"");
-                               if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
-                                       synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                               if(!get_canvas_interface()->get_instance()->perform_action(action))
-                               {
-                                       //get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
-                                       group.cancel();
-                                       throw String(_("Unable to create Region layer"));
-                                       return false;
-                               }
-                       }
-
-                       // only link the region's origin parameter if the option is selected and we're creating more than one layer
-                       if (get_layer_link_origins_flag() && layers_to_create > 1)
-                       {
-                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                               assert(action);
-
-                               action->set_param("canvas",get_canvas());
-                               action->set_param("canvas_interface",get_canvas_interface());
-                               action->set_param("layer",layer);
-                               if(!action->set_param("param",String("origin")))
-                                       synfig::error("LayerParamConnect didn't like \"param\"");
-                               if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
-                                       synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                               if(!get_canvas_interface()->get_instance()->perform_action(action))
-                               {
-                                       //get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
-                                       group.cancel();
-                                       throw String(_("Unable to create Region layer"));
-                                       return false;
-                               }
-                       }
-               }
-
-               ///////////////////////////////////////////////////////////////////////////
-               //   O U T L I N E
-               ///////////////////////////////////////////////////////////////////////////
-
-               if(get_layer_outline_flag())
-               {
-                       synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
-                       Layer::Handle layer(get_canvas_interface()->add_layer_to("outline",canvas,depth));
-                       if (!layer)
-                       {
-                               group.cancel();
-                               throw String(_("Unable to create layer"));
-                       }
-                       layer_selection.push_back(layer);
-                       layer->set_description(get_id()+_(" Outline"));
-                       get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-                       if(get_feather())
-                       {
-                               layer->set_param("feather",get_feather());
-                               get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
-                       }
-
-                       {
-                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                               assert(action);
-
-                               action->set_param("canvas",get_canvas());
-                               action->set_param("canvas_interface",get_canvas_interface());
-                               action->set_param("layer",layer);
-                               if(!action->set_param("param",String("bline")))
-                                       synfig::error("LayerParamConnect didn't like \"param\"");
-                               if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
-                                       synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                               if(!get_canvas_interface()->get_instance()->perform_action(action))
-                               {
-                                       //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                                       group.cancel();
-                                       throw String(_("Unable to create Outline layer"));
-                                       return false;
-                               }
-                       }
-
-                       // only link the outline's origin parameter if the option is selected and we're creating more than one layer
-                       if (get_layer_link_origins_flag() && layers_to_create > 1)
-                       {
-                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                               assert(action);
-
-                               action->set_param("canvas",get_canvas());
-                               action->set_param("canvas_interface",get_canvas_interface());
-                               action->set_param("layer",layer);
-                               if(!action->set_param("param",String("origin")))
-                                       synfig::error("LayerParamConnect didn't like \"param\"");
-                               if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
-                                       synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                               if(!get_canvas_interface()->get_instance()->perform_action(action))
-                               {
-                                       //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                                       group.cancel();
-                                       throw String(_("Unable to create Outline layer"));
-                                       return false;
-                               }
-                       }
-               }
-
-               egress_on_selection_change=false;
-               get_canvas_interface()->get_selection_manager()->clear_selected_layers();
-               get_canvas_interface()->get_selection_manager()->set_selected_layers(layer_selection);
-               egress_on_selection_change=true;
-
-               //if(finish_bline_dialog.get_region_flag() || finish_bline_dialog.get_bline_flag())
-               //      get_canvas_interface()->signal_dirty_preview()();
-
-       } while(0);
-
-       reset();
-       increment_id();
-       return true;
-}
-
-Smach::event_result
-StateBLine_Context::event_mouse_motion_handler(const Smach::event& x)
-{
-       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
-
-       if(curr_duck)
-       {
-               //synfig::info("Moved Duck");
-               Point p(get_work_area()->snap_point_to_grid(event.pos));
-               curr_duck->set_trans_point(p);
-               if(next_duck)
-                       next_duck->set_trans_point(p);
-               get_work_area()->queue_draw();
-               return Smach::RESULT_ACCEPT;
-       }
-
-       return Smach::RESULT_OK;
-}
-
-Smach::event_result
-StateBLine_Context::event_mouse_release_handler(const Smach::event& /*x*/)
-{
-       if(curr_duck)
-       {
-               //synfig::info("Released current duck");
-               curr_duck->signal_edited()(curr_duck->get_point());
-               if(next_duck)
-               {
-                       //synfig::info("grabbing next duck");
-                       curr_duck=next_duck;
-                       next_duck=0;
-               }
-               return Smach::RESULT_ACCEPT;
-       }
-       return Smach::RESULT_OK;
-}
-
-Smach::event_result
-StateBLine_Context::event_mouse_click_handler(const Smach::event& x)
-{
-       // synfig::info("STATE BLINE: Received mouse button down Event");
-       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
-       switch(event.button)
-       {
-       case BUTTON_LEFT:
-               {
-                       // If we are already looped up, then don't try to add anything else
-                       if(loop_)
-                               return Smach::RESULT_OK;
-
-                       BLinePoint bline_point;
-
-                       bline_point.set_vertex(get_work_area()->snap_point_to_grid(event.pos));
-                       //bline_point.set_width(synfigapp::Main::get_bline_width());
-                       bline_point.set_width(1.0f);
-                       bline_point.set_origin(0.5f);
-                       bline_point.set_split_tangent_flag(false);
-                       bline_point.set_tangent1(Vector(0,0));
-
-                       // set the tangent
-                       /*
-                       if(bline_point_list.empty())
-                       {
-                               bline_point.set_tangent1(Vector(1,1));
-                       }
-                       else
-                       {
-                               const Vector t(event.pos-bline_point_list.back()->get_value().get(BLinePoint()).get_vertex());
-                               bline_point.set_tangent1(t);
-                       }
-
-                       if(bline_point_list.size()>1)
-                       {
-                               std::list<synfig::ValueNode_Const::Handle>::iterator iter;
-                               iter=bline_point_list.end();
-                               iter--;iter--;
-                               BLinePoint prev(bline_point_list.back()->get_value().get(BLinePoint()));
-                               prev.set_tangent1(event.pos-(*iter)->get_value().get(BLinePoint()).get_vertex());
-                               bline_point_list.back()->set_value(prev);
-                       };
-                       */
-
-                       bline_point_list.push_back(ValueNode_Const::create(bline_point));
-
-                       refresh_ducks();
-                       return Smach::RESULT_ACCEPT;
-               }
-
-       default:
-               return Smach::RESULT_OK;
-       }
-}
-
-void
-StateBLine_Context::refresh_ducks(bool button_down)
-{
-       get_work_area()->clear_ducks();
-       get_work_area()->queue_draw();
-
-       if(bline_point_list.empty())
-               return;
-
-       list<ValueNode_Const::Handle>::iterator iter;
-
-       handle<WorkArea::Bezier> bezier;
-       handle<WorkArea::Duck> duck,tduck;
-       BLinePoint bline_point;
-
-       for(iter=bline_point_list.begin();iter!=bline_point_list.end();++iter)
-       {
-               ValueNode_Const::Handle value_node(*iter);
-               bline_point=(value_node->get_value().get(BLinePoint()));
-               assert(value_node);
-
-
-               // First add the duck associated with this vertex
-               duck=new WorkArea::Duck(bline_point.get_vertex());
-               duck->set_editable(true);
-#ifdef DISTINGUISH_FIRST_DUCK
-               if (iter!=bline_point_list.begin())
-                       duck->set_type(Duck::TYPE_VERTEX);
-#else
-               duck->set_type(Duck::TYPE_VERTEX);
-#endif
-               duck->set_name(strprintf("%x-vertex",value_node.get()));
-               duck->signal_edited().connect(
-                       sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::on_vertex_change),value_node)
-               );
-               duck->signal_user_click(2).connect(
-                       sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::popup_vertex_menu),value_node)
-               );
-               duck->set_guid(value_node->get_guid()^synfig::GUID::hasher(0));
-
-               get_work_area()->add_duck(duck);
-
-               // Add the tangent1 duck
-               tduck=new WorkArea::Duck(bline_point.get_tangent1());
-               tduck->set_editable(true);
-               tduck->set_name(strprintf("%x-tangent1",value_node.get()));
-               tduck->set_origin(duck);
-               tduck->set_scalar(-0.33333333333333333);
-               tduck->set_tangent(true);
-               tduck->set_guid(value_node->get_guid()^synfig::GUID::hasher(3));
-               tduck->signal_edited().connect(
-                       sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::on_tangent1_change),value_node)
-               );
-               tduck->signal_user_click(2).connect(
-                       sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::popup_handle_menu),value_node)
-               );
-
-               // See if we need to add that duck to the previous bezier
-               if(bezier)
-               {
-                       get_work_area()->add_duck(tduck);
-                       bezier->p2=duck;
-                       bezier->c2=tduck;
-
-                       bezier->signal_user_click(2).connect(
-                               sigc::bind(
-                                       sigc::mem_fun(
-                                               *this,
-                                               &studio::StateBLine_Context::popup_bezier_menu
-                                       ),
-                                       value_node
-                               )
-                       );
-
-                       //get_work_area()->add_duck(bezier->c1);
-                       //get_work_area()->add_duck(bezier->c2);
-                       get_work_area()->add_bezier(bezier);
-
-                       bezier=0;
-               }
-
-               // Now we see if we need to create a bezier
-               list<ValueNode_Const::Handle>::iterator next(iter);
-               next++;
-
-               // If our next iterator is the end, then we don't need
-               // to add a bezier.
-               //if(next==bline_point_list.end() && !loop_)
-               //      continue;
-
-               bezier=new WorkArea::Bezier();
-
-               // Add the tangent2 duck
-               tduck=new WorkArea::Duck(bline_point.get_tangent2());
-               tduck->set_editable(true);
-               tduck->set_origin(duck);
-               tduck->set_scalar(0.33333333333333333);
-               tduck->set_tangent(true);
-               if(bline_point.get_split_tangent_flag())
-               {
-                       tduck->set_name(strprintf("%x-tangent2",value_node.get()));
-                       tduck->signal_edited().connect(
-                               sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::on_tangent2_change),value_node)
-                       );
-               }
-               else
-               {
-                       tduck->set_name(strprintf("%x-tangent1",value_node.get()));
-                       tduck->signal_edited().connect(
-                               sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::on_tangent1_change),value_node)
-                       );
-               }
-               tduck->set_guid(value_node->get_guid()^synfig::GUID::hasher(4));
-               tduck->signal_user_click(2).connect(
-                       sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::popup_handle_menu),value_node)
-               );
-
-               // Setup the next bezier
-               bezier->p1=duck;
-               bezier->c1=tduck;
-
-               get_work_area()->add_duck(tduck);
-               curr_duck=tduck;
-       }
-
-       // Add the loop, if requested
-       if(bezier && loop_)
-       {
-               curr_duck=0;
-               BLinePoint bline_point(bline_point_list.front()->get_value().get(BLinePoint()));
-
-               duck=new WorkArea::Duck(bline_point.get_vertex());
-               duck->set_editable(true);
-#ifndef DISTINGUISH_FIRST_DUCK
-               duck->set_type(Duck::TYPE_VERTEX);
-#endif
-               duck->set_name(strprintf("%x-vertex",bline_point_list.front().get()));
-               duck->signal_edited().connect(
-                       sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::on_vertex_change),bline_point_list.front())
-               );
-               duck->signal_user_click(2).connect(
-                       sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::popup_vertex_menu),bline_point_list.front())
-               );
-               get_work_area()->add_duck(duck);
-
-               // Add the tangent1 duck
-               tduck=new WorkArea::Duck(bline_point.get_tangent1());
-               tduck->set_editable(true);
-               tduck->set_name(strprintf("%x-tangent1",bline_point_list.front().get()));
-               tduck->set_origin(duck);
-               tduck->set_scalar(-0.33333333333333333);
-               tduck->set_tangent(true);
-               tduck->signal_edited().connect(
-                       sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::on_tangent1_change),bline_point_list.front())
-               );
-               tduck->signal_user_click(2).connect(
-                       sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::popup_handle_menu),bline_point_list.front())
-               );
-               get_work_area()->add_duck(tduck);
-
-               bezier->p2=duck;
-               bezier->c2=tduck;
-
-               bezier->signal_user_click(2).connect(
-                       sigc::bind(
-                               sigc::mem_fun(
-                                       *this,
-                                       &studio::StateBLine_Context::popup_bezier_menu
-                               ),
-                               bline_point_list.front()
-                       )
-               );
-
-               //get_work_area()->add_duck(bezier->c1);
-               get_work_area()->add_bezier(bezier);
-       }
-       if(bezier && !loop_)
-       {
-               duck=new WorkArea::Duck(bline_point.get_vertex());
-               duck->set_ignore(true);
-               duck->set_name("temp");
-
-               // Add the tangent1 duck
-               tduck=new WorkArea::Duck(Vector(0,0));
-               tduck->set_ignore(true);
-               tduck->set_name("ttemp");
-               tduck->set_origin(duck);
-               tduck->set_scalar(-0.33333333333333333);
-
-               tduck->set_tangent(true);
-               bezier->p2=duck;
-               bezier->c2=tduck;
-
-               get_work_area()->add_duck(bezier->p2);
-               //get_work_area()->add_duck(bezier->c2);
-               get_work_area()->add_bezier(bezier);
-
-               duck->set_guid(synfig::GUID());
-               tduck->set_guid(synfig::GUID());
-
-               next_duck=duck;
-       }
-
-       if(!button_down)
-       {
-               if(curr_duck)
-               {
-                       if(next_duck)
-                       {
-                               curr_duck=next_duck;
-                               next_duck=0;
-                       }
-               }
-       }
-       get_work_area()->queue_draw();
-}
-
-
-bool
-StateBLine_Context::on_vertex_change(const synfig::Point &point, synfig::ValueNode_Const::Handle value_node)
-{
-       BLinePoint bline_point(value_node->get_value().get(BLinePoint()));
-       bline_point.set_vertex(point);
-       value_node->set_value(bline_point);
-       //refresh_ducks();
-       return true;
-}
-
-bool
-StateBLine_Context::on_tangent1_change(const synfig::Point &point, synfig::ValueNode_Const::Handle value_node)
-{
-       BLinePoint bline_point(value_node->get_value().get(BLinePoint()));
-       bline_point.set_tangent1(point);
-       value_node->set_value(bline_point);
-       //refresh_ducks();
-       return true;
-}
-
-bool
-StateBLine_Context::on_tangent2_change(const synfig::Point &point, synfig::ValueNode_Const::Handle value_node)
-{
-       BLinePoint bline_point(value_node->get_value().get(BLinePoint()));
-       bline_point.set_tangent2(point);
-       value_node->set_value(bline_point);
-       //refresh_ducks();
-       return true;
-}
-
-void
-StateBLine_Context::loop_bline()
-{
-       loop_=true;
-
-       refresh_ducks(false);
-}
-
-void
-StateBLine_Context::unloop_bline()
-{
-       loop_=false;
-
-       refresh_ducks(false);
-}
-
-void
-StateBLine_Context::popup_vertex_menu(synfig::ValueNode_Const::Handle value_node)
-{
-       menu.items().clear();
-
-       if(loop_)
-       {
-               menu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Unloop BLine"),
-                               sigc::mem_fun(*this,&studio::StateBLine_Context::unloop_bline)
-               ));
-       } else {
-               menu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Loop BLine"),
-                               sigc::mem_fun(*this,&studio::StateBLine_Context::loop_bline)
-               ));
-       }
-
-       menu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Delete Vertex"),
-               sigc::bind(
-                       sigc::mem_fun(*this,&studio::StateBLine_Context::bline_delete_vertex),
-                       value_node
-               )
-       ));
-
-       menu.popup(0,0);
-}
-
-void
-StateBLine_Context::popup_bezier_menu(float location, synfig::ValueNode_Const::Handle value_node)
-{
-       menu.items().clear();
-
-       menu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Insert Vertex"),
-               sigc::bind(
-                       sigc::bind(
-                               sigc::mem_fun(*this,&studio::StateBLine_Context::bline_insert_vertex),
-                               location
-                       ),
-                       value_node
-               )
-       ));
-
-       menu.popup(0,0);
-}
-
-void
-StateBLine_Context::bline_insert_vertex(synfig::ValueNode_Const::Handle value_node, float origin)
-{
-       list<ValueNode_Const::Handle>::iterator iter;
-
-       for(iter=bline_point_list.begin();iter!=bline_point_list.end();++iter)
-               if(*iter==value_node)
-               {
-                       BLinePoint bline_point;
-                       BLinePoint next_bline_point((*iter)->get_value().get(BLinePoint()));
-                       BLinePoint prev_bline_point;
-
-                       list<ValueNode_Const::Handle>::iterator prev(iter);
-                       if(iter==bline_point_list.begin())
-                       {
-                               assert(loop_);
-                               prev = bline_point_list.end();
-                       }
-                       prev--;
-
-                       prev_bline_point=(*prev)->get_value().get(BLinePoint());
-
-                       etl::hermite<Vector> curve(prev_bline_point.get_vertex(),
-                                                                          next_bline_point.get_vertex(),
-                                                                          prev_bline_point.get_tangent2(),
-                                                                          next_bline_point.get_tangent1());
-                       etl::derivative< etl::hermite<Vector> > deriv(curve);
-
-                       bline_point.set_vertex(curve(origin));
-                       bline_point.set_width((next_bline_point.get_width()-prev_bline_point.get_width())*origin+prev_bline_point.get_width());
-                       bline_point.set_tangent1(deriv(origin)*std::min(1.0f-origin,origin));
-                       bline_point.set_tangent2(bline_point.get_tangent1());
-                       bline_point.set_split_tangent_flag(false);
-                       bline_point.set_origin(origin);
-
-/*
-                       bline_point.set_vertex((next_bline_point.get_vertex()+prev_bline_point.get_vertex())*0.5);
-                       bline_point.set_width((next_bline_point.get_width()+prev_bline_point.get_width())*0.5);
-                       bline_point.set_origin(origin);
-                       bline_point.set_split_tangent_flag(false);
-                       bline_point.set_tangent1((next_bline_point.get_vertex()-prev_bline_point.get_vertex())*0.5);
-*/
-
-                       bline_point_list.insert(iter,ValueNode_Const::create(bline_point));
-                       break;
-               }
-
-       if(iter==bline_point_list.end())
-       {
-               get_canvas_view()->get_ui_interface()->error(_("Unable to find where to insert vertex, internal error, please report this bug"));
-       }
-
-       refresh_ducks(false);
-}
-
-void
-StateBLine_Context::bline_delete_vertex(synfig::ValueNode_Const::Handle value_node)
-{
-       list<ValueNode_Const::Handle>::iterator iter;
-
-       for(iter=bline_point_list.begin();iter!=bline_point_list.end();++iter)
-               if(*iter==value_node)
-               {
-                       bline_point_list.erase(iter);
-                       break;
-               }
-       if(iter==bline_point_list.end())
-       {
-               get_canvas_view()->get_ui_interface()->error(_("Unable to remove vertex, internal error, please report this bug"));
-       }
-
-       refresh_ducks(false);
-}
-
-void
-StateBLine_Context::popup_handle_menu(synfig::ValueNode_Const::Handle value_node)
-{
-       menu.items().clear();
-
-       BLinePoint bline_point(value_node->get_value().get(BLinePoint()));
-
-       if(bline_point.get_split_tangent_flag())
-               menu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Merge Tangents"),
-                       sigc::bind(
-                               sigc::mem_fun(*this,&studio::StateBLine_Context::bline_attach_handle),
-                               value_node
-                       )
-               ));
-       else
-               menu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Split Tangents"),
-                       sigc::bind(
-                               sigc::mem_fun(*this,&studio::StateBLine_Context::bline_detach_handle),
-                               value_node
-                       )
-               ));
-
-       menu.popup(0,0);
-}
-
-void
-StateBLine_Context::bline_detach_handle(synfig::ValueNode_Const::Handle value_node)
-{
-       BLinePoint bline_point(value_node->get_value().get(BLinePoint()));
-       bline_point.set_split_tangent_flag(true);
-       bline_point.set_tangent2(bline_point.get_tangent1());
-       value_node->set_value(bline_point);
-       refresh_ducks(false);
-}
-
-void
-StateBLine_Context::bline_attach_handle(synfig::ValueNode_Const::Handle value_node)
-{
-       BLinePoint bline_point(value_node->get_value().get(BLinePoint()));
-       bline_point.set_tangent1((bline_point.get_tangent1()+bline_point.get_tangent2())*0.5);
-       bline_point.set_split_tangent_flag(false);
-       value_node->set_value(bline_point);
-       refresh_ducks(false);
-}
diff --git a/synfig-studio/src/gtkmm/state_bline.h b/synfig-studio/src/gtkmm/state_bline.h
deleted file mode 100644 (file)
index 0f3ce0d..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_bline.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_ROTOSCOPE_BLINE_H
-#define __SYNFIG_STUDIO_ROTOSCOPE_BLINE_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 StateBLine_Context;
-
-class StateBLine : public Smach::state<StateBLine_Context>
-{
-public:
-       StateBLine();
-       ~StateBLine();
-}; // END of class StateBLine
-
-extern StateBLine state_bline;
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/state_circle.cpp b/synfig-studio/src/gtkmm/state_circle.cpp
deleted file mode 100644 (file)
index ce155b0..0000000
+++ /dev/null
@@ -1,1066 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_circle.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 <config.h>
-#endif
-
-#include <gtkmm/dialog.h>
-#include <gtkmm/entry.h>
-
-#include <synfig/valuenode_dynamiclist.h>
-#include <synfigapp/action_system.h>
-#include <synfig/valuenode_bline.h>
-
-#include "state_circle.h"
-#include "state_normal.h"
-#include "canvasview.h"
-#include "workarea.h"
-#include "app.h"
-
-#include <synfigapp/action.h>
-#include "event_mouse.h"
-#include "event_layerclick.h"
-#include "toolbox.h"
-#include "dialog_tooloptions.h"
-#include <gtkmm/optionmenu.h>
-#include "duck.h"
-#include "widget_enum.h"
-#include <synfigapp/main.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 ========================================================= */
-enum CircleFalloff
-{
-       CIRCLE_SQUARED  =0,
-       CIRCLE_INTERPOLATION_LINEAR     =1,
-       CIRCLE_COSINE   =2,
-       CIRCLE_SIGMOND  =3,
-       CIRCLE_SQRT             =4,
-       CIRCLE_NUM_FALLOFF
-};
-
-/* === G L O B A L S ======================================================= */
-
-StateCircle studio::state_circle;
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-class studio::StateCircle_Context : public sigc::trackable
-{
-       etl::handle<CanvasView> canvas_view_;
-       CanvasView::IsWorking is_working;
-
-       Duckmatic::Push duckmatic_push;
-
-       Point point_holder;
-
-       etl::handle<Duck> point2_duck;
-
-       void refresh_ducks();
-
-       bool prev_workarea_layer_status_;
-
-       //Toolbox settings
-       synfigapp::Settings& settings;
-
-       //Toolbox display
-       Gtk::Table options_table;
-
-       Gtk::Entry              entry_id; //what to name the layer
-
-       Widget_Enum             enum_falloff;
-#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
-       Widget_Enum             enum_blend;
-#endif // BLEND_METHOD_IN_TOOL_OPTIONS
-
-       Gtk::Adjustment adj_feather;
-       Gtk::Adjustment adj_number_of_bline_points;
-       Gtk::Adjustment adj_bline_point_angle_offset;
-       Gtk::SpinButton spin_feather;
-       Gtk::SpinButton spin_number_of_bline_points;
-       Gtk::SpinButton spin_bline_point_angle_offset;
-
-       Gtk::CheckButton checkbutton_invert;
-       Gtk::CheckButton checkbutton_layer_circle;
-       Gtk::CheckButton checkbutton_layer_region;
-       Gtk::CheckButton checkbutton_layer_outline;
-       Gtk::CheckButton checkbutton_layer_curve_gradient;
-       Gtk::CheckButton checkbutton_layer_plant;
-       Gtk::CheckButton checkbutton_layer_link_origins;
-       Gtk::CheckButton checkbutton_layer_origins_at_center;
-
-public:
-
-       // this only counts the layers which will have their origins linked
-       int layers_to_create()const
-       {
-               return
-                       (get_layer_circle_flag() && get_layer_origins_at_center_flag()) +
-                       get_layer_region_flag() +
-                       get_layer_outline_flag() +
-                       get_layer_curve_gradient_flag() +
-                       get_layer_plant_flag();
-       }
-
-       synfig::String get_id()const { return entry_id.get_text(); }
-       void set_id(const synfig::String& x) { return entry_id.set_text(x); }
-
-       int get_falloff()const { return enum_falloff.get_value(); }
-       void set_falloff(int x) { return enum_falloff.set_value(x); }
-
-#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
-       int get_blend()const { return enum_blend.get_value(); }
-       void set_blend(int x) { return enum_blend.set_value(x); }
-#endif // BLEND_METHOD_IN_TOOL_OPTIONS
-
-       Real get_feather()const { return adj_feather.get_value(); }
-       void set_feather(Real f) { adj_feather.set_value(f); }
-
-       Real get_number_of_bline_points()const { return adj_number_of_bline_points.get_value(); }
-       void set_number_of_bline_points(Real f) { adj_number_of_bline_points.set_value(f); }
-
-       Real get_bline_point_angle_offset()const { return adj_bline_point_angle_offset.get_value(); }
-       void set_bline_point_angle_offset(Real f) { adj_bline_point_angle_offset.set_value(f); }
-
-       bool get_invert()const { return checkbutton_invert.get_active(); }
-       void set_invert(bool i) { checkbutton_invert.set_active(i); }
-
-       bool get_layer_circle_flag()const { return checkbutton_layer_circle.get_active(); }
-       void set_layer_circle_flag(bool x) { return checkbutton_layer_circle.set_active(x); }
-
-       bool get_layer_region_flag()const { return checkbutton_layer_region.get_active(); }
-       void set_layer_region_flag(bool x) { return checkbutton_layer_region.set_active(x); }
-
-       bool get_layer_outline_flag()const { return checkbutton_layer_outline.get_active(); }
-       void set_layer_outline_flag(bool x) { return checkbutton_layer_outline.set_active(x); }
-
-       bool get_layer_curve_gradient_flag()const { return checkbutton_layer_curve_gradient.get_active(); }
-       void set_layer_curve_gradient_flag(bool x) { return checkbutton_layer_curve_gradient.set_active(x); }
-
-       bool get_layer_plant_flag()const { return checkbutton_layer_plant.get_active(); }
-       void set_layer_plant_flag(bool x) { return checkbutton_layer_plant.set_active(x); }
-
-       bool get_layer_link_origins_flag()const { return checkbutton_layer_link_origins.get_active(); }
-       void set_layer_link_origins_flag(bool x) { return checkbutton_layer_link_origins.set_active(x); }
-
-       bool get_layer_origins_at_center_flag()const { return checkbutton_layer_origins_at_center.get_active(); }
-       void set_layer_origins_at_center_flag(bool x) { return checkbutton_layer_origins_at_center.set_active(x); }
-
-       void refresh_tool_options(); //to refresh the toolbox
-
-       //events
-       Smach::event_result event_stop_handler(const Smach::event& x);
-       Smach::event_result event_refresh_handler(const Smach::event& x);
-       Smach::event_result event_mouse_click_handler(const Smach::event& x);
-       Smach::event_result event_refresh_tool_options(const Smach::event& x);
-
-       //constructor destructor
-       StateCircle_Context(CanvasView* canvas_view);
-       ~StateCircle_Context();
-
-       //Canvas interaction
-       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
-       etl::handle<synfigapp::CanvasInterface> 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();}
-
-       //Modifying settings etc.
-       void load_settings();
-       void save_settings();
-       void reset();
-       void increment_id();
-       bool egress_on_selection_change;
-       Smach::event_result event_layer_selection_changed_handler(const Smach::event& /*x*/)
-       {
-               if(egress_on_selection_change)
-                       throw &state_normal; //throw Smach::egress_exception();
-               return Smach::RESULT_OK;
-       }
-
-       void make_circle(const Point& p1, const Point& p2);
-
-};     // END of class StateCircle_Context
-
-/* === M E T H O D S ======================================================= */
-
-StateCircle::StateCircle():
-       Smach::state<StateCircle_Context>("circle")
-{
-       insert(event_def(EVENT_LAYER_SELECTION_CHANGED,&StateCircle_Context::event_layer_selection_changed_handler));
-       insert(event_def(EVENT_STOP,&StateCircle_Context::event_stop_handler));
-       insert(event_def(EVENT_REFRESH,&StateCircle_Context::event_refresh_handler));
-       insert(event_def(EVENT_REFRESH_DUCKS,&StateCircle_Context::event_refresh_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StateCircle_Context::event_mouse_click_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DRAG,&StateCircle_Context::event_mouse_click_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_UP,&StateCircle_Context::event_mouse_click_handler));
-       insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateCircle_Context::event_refresh_tool_options));
-}
-
-StateCircle::~StateCircle()
-{
-}
-
-void
-StateCircle_Context::load_settings()
-{
-       String value;
-
-       //parse the arguments yargh!
-       if(settings.get_value("circle.id",value))
-               set_id(value);
-       else
-               set_id("Circle");
-
-       if(settings.get_value("circle.fallofftype",value) && value != "")
-               set_falloff(atoi(value.c_str()));
-       else
-               set_falloff(2);
-
-#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
-       if(settings.get_value("circle.blend",value) && value != "")
-               set_blend(atoi(value.c_str()));
-       else
-               set_blend(0);//(int)Color::BLEND_COMPOSITE); //0 should be blend composites value
-#endif // BLEND_METHOD_IN_TOOL_OPTIONS
-
-       if(settings.get_value("circle.feather",value))
-               set_feather(atof(value.c_str()));
-       else
-               set_feather(0);
-
-       if(settings.get_value("circle.number_of_bline_points",value))
-               set_number_of_bline_points(atof(value.c_str()));
-       else
-               set_number_of_bline_points(4);
-
-       if(settings.get_value("circle.bline_point_angle_offset",value))
-               set_bline_point_angle_offset(atof(value.c_str()));
-       else
-               set_bline_point_angle_offset(0);
-
-       if(settings.get_value("circle.invert",value) && value != "0")
-               set_invert(true);
-       else
-               set_invert(false);
-
-       if(settings.get_value("circle.layer_circle",value) && value=="0")
-               set_layer_circle_flag(false);
-       else
-               set_layer_circle_flag(true);
-
-       if(settings.get_value("circle.layer_region",value) && value=="1")
-               set_layer_region_flag(true);
-       else
-               set_layer_region_flag(false);
-
-       if(settings.get_value("circle.layer_outline",value) && value=="1")
-               set_layer_outline_flag(true);
-       else
-               set_layer_outline_flag(false);
-
-       if(settings.get_value("circle.layer_curve_gradient",value) && value=="1")
-               set_layer_curve_gradient_flag(true);
-       else
-               set_layer_curve_gradient_flag(false);
-
-       if(settings.get_value("circle.layer_plant",value) && value=="1")
-               set_layer_plant_flag(true);
-       else
-               set_layer_plant_flag(false);
-
-       if(settings.get_value("circle.layer_link_origins",value) && value=="0")
-               set_layer_link_origins_flag(false);
-       else
-               set_layer_link_origins_flag(true);
-
-       if(settings.get_value("circle.layer_origins_at_center",value) && value=="0")
-               set_layer_origins_at_center_flag(false);
-       else
-               set_layer_origins_at_center_flag(true);
-}
-
-void
-StateCircle_Context::save_settings()
-{
-       settings.set_value("circle.id",get_id());
-       settings.set_value("circle.fallofftype",strprintf("%d",get_falloff()));
-#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
-       settings.set_value("circle.blend",strprintf("%d",get_blend()));
-#endif // BLEND_METHOD_IN_TOOL_OPTIONS
-       settings.set_value("circle.feather",strprintf("%f",(float)get_feather()));
-       settings.set_value("circle.number_of_bline_points",strprintf("%d",(int)(get_number_of_bline_points() + 0.5)));
-       settings.set_value("circle.bline_point_angle_offset",strprintf("%f",(float)get_bline_point_angle_offset()));
-       settings.set_value("circle.invert",get_invert()?"1":"0");
-       settings.set_value("circle.layer_circle",get_layer_circle_flag()?"1":"0");
-       settings.set_value("circle.layer_outline",get_layer_outline_flag()?"1":"0");
-       settings.set_value("circle.layer_region",get_layer_region_flag()?"1":"0");
-       settings.set_value("circle.layer_curve_gradient",get_layer_curve_gradient_flag()?"1":"0");
-       settings.set_value("circle.layer_plant",get_layer_plant_flag()?"1":"0");
-       settings.set_value("circle.layer_link_origins",get_layer_link_origins_flag()?"1":"0");
-       settings.set_value("circle.layer_origins_at_center",get_layer_origins_at_center_flag()?"1":"0");
-}
-
-void
-StateCircle_Context::reset()
-{
-       refresh_ducks();
-}
-
-void
-StateCircle_Context::increment_id()
-{
-       String id(get_id());
-       int number=1;
-       int digits=0;
-
-       if(id.empty())
-               id="Circle";
-
-       // If there is a number
-       // already at the end of the
-       // id, then remove it.
-       if(id[id.size()-1]<='9' && id[id.size()-1]>='0')
-       {
-               // figure out how many digits it is
-               for (digits = 0;
-                        (int)id.size()-1 >= digits && id[id.size()-1-digits] <= '9' && id[id.size()-1-digits] >= '0';
-                        digits++)
-                       ;
-
-               String str_number;
-               str_number=String(id,id.size()-digits,id.size());
-               id=String(id,0,id.size()-digits);
-
-               number=atoi(str_number.c_str());
-       }
-       else
-       {
-               number=1;
-               digits=3;
-       }
-
-       number++;
-
-       // Add the number back onto the id
-       {
-               const String format(strprintf("%%0%dd",digits));
-               id+=strprintf(format.c_str(),number);
-       }
-
-       // Set the ID
-       set_id(id);
-}
-
-StateCircle_Context::StateCircle_Context(CanvasView* canvas_view):
-       canvas_view_(canvas_view),
-       is_working(*canvas_view),
-       duckmatic_push(get_work_area()),
-       prev_workarea_layer_status_(get_work_area()->get_allow_layer_clicks()),
-       settings(synfigapp::Main::get_selected_input_device()->settings()),
-       entry_id(),                             //   value lower upper  step page
-       adj_feather(                                    0,    0,    1, 0.01, 0.1),
-       adj_number_of_bline_points(             0,    2,  120, 1   , 1  ),
-       adj_bline_point_angle_offset(   0, -360,  360, 0.1 , 1  ),
-       spin_feather(adj_feather,0.1,3),
-       spin_number_of_bline_points(adj_number_of_bline_points,1,0),
-       spin_bline_point_angle_offset(adj_bline_point_angle_offset,1,1),
-       checkbutton_invert(_("Invert")),
-       checkbutton_layer_circle(_("Create Circle Layer")),
-       checkbutton_layer_region(_("Create Region BLine")),
-       checkbutton_layer_outline(_("Create Outline BLine")),
-       checkbutton_layer_curve_gradient(_("Create Curve Gradient BLine")),
-       checkbutton_layer_plant(_("Create Plant BLine")),
-       checkbutton_layer_link_origins(_("Link Origins")),
-       checkbutton_layer_origins_at_center(_("BLine Origins at Center"))
-{
-       egress_on_selection_change=true;
-
-       // Set up the tool options dialog
-       enum_falloff.set_param_desc(ParamDesc("falloff")
-               .set_local_name(_("Falloff"))
-               .set_description(_("Determines the falloff function for the feather"))
-               .set_hint("enum")
-               .add_enum_value(CIRCLE_INTERPOLATION_LINEAR,"linear",_("Linear"))
-               .add_enum_value(CIRCLE_SQUARED,"squared",_("Squared"))
-               .add_enum_value(CIRCLE_SQRT,"sqrt",_("Square Root"))
-               .add_enum_value(CIRCLE_SIGMOND,"sigmond",_("Sigmond"))
-               .add_enum_value(CIRCLE_COSINE,"cosine",_("Cosine")));
-
-#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
-       enum_blend.set_param_desc(ParamDesc(Color::BLEND_COMPOSITE,"blend_method")
-               .set_local_name(_("Blend Method"))
-               .set_description(_("Defines the blend method to be used for circles")));
-#endif // BLEND_METHOD_IN_TOOL_OPTIONS
-
-       load_settings();
-
-       options_table.attach(*manage(new Gtk::Label(_("Circle Tool"))),         0, 2,  0,  1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(entry_id,                                                                          0, 2,  1,  2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       options_table.attach(checkbutton_layer_circle,                                          0, 2,  2,  3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_outline,                                         0, 2,  3,  4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_region,                                          0, 2,  4,  5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_plant,                                           0, 2,  5,  6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_curve_gradient,                          0, 2,  6,  7, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_link_origins,                            0, 2,  7,  8, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_origins_at_center,                       0, 2,  8,  9, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       //invert flag
-       options_table.attach(checkbutton_invert,                                                0, 2,  9, 10, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       options_table.attach(*manage(new Gtk::Label(_("Falloff:"))),            0, 1, 10, 11, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(enum_falloff,                                      1, 2, 10, 11, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       //feather stuff
-       options_table.attach(*manage(new Gtk::Label(_("Feather:"))),            0, 1, 11, 12, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(spin_feather,                                                              1, 2, 11, 12, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
-       options_table.attach(enum_blend,                                        0, 2, 12, 13, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-#endif // BLEND_METHOD_IN_TOOL_OPTIONS
-
-       options_table.attach(*manage(new Gtk::Label(_("BLine Points:"))),       0, 1, 13, 14, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(spin_number_of_bline_points,                                       1, 2, 13, 14, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-options_table.attach(*manage(new Gtk::Label(_("Point Angle Offset:"))),        0, 1, 14, 15, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(spin_bline_point_angle_offset,                                     1, 2, 14, 15, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       options_table.show_all();
-
-       refresh_tool_options();
-       App::dialog_tool_options->present();
-
-       // Turn off layer clicking
-       get_work_area()->set_allow_layer_clicks(false);
-
-       // clear out the ducks
-       get_work_area()->clear_ducks();
-
-       // Refresh the work area
-       get_work_area()->queue_draw();
-
-       // Hide the tables if they are showing
-       //prev_table_status=get_canvas_view()->tables_are_visible();
-       //if(prev_table_status)get_canvas_view()->hide_tables();
-
-       // Disable the time bar
-       //get_canvas_view()->set_sensitive_timebar(false);
-
-       // Connect a signal
-       //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateCircle_Context::on_user_click));
-       get_work_area()->set_cursor(Gdk::CROSSHAIR);
-
-       App::toolbox->refresh();
-}
-
-void
-StateCircle_Context::refresh_tool_options()
-{
-       App::dialog_tool_options->clear();
-       App::dialog_tool_options->set_widget(options_table);
-       App::dialog_tool_options->set_local_name(_("Circle Tool"));
-       App::dialog_tool_options->set_name("circle");
-}
-
-Smach::event_result
-StateCircle_Context::event_refresh_tool_options(const Smach::event& /*x*/)
-{
-       refresh_tool_options();
-       return Smach::RESULT_ACCEPT;
-}
-
-StateCircle_Context::~StateCircle_Context()
-{
-       save_settings();
-
-       // Restore layer clicking
-       get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_);
-       get_work_area()->reset_cursor();
-
-       App::dialog_tool_options->clear();
-
-       // Enable the time bar
-       //get_canvas_view()->set_sensitive_timebar(true);
-
-       // Bring back the tables if they were out before
-       //if(prev_table_status)get_canvas_view()->show_tables();
-
-       // Refresh the work area
-       get_work_area()->queue_draw();
-
-       get_canvas_view()->queue_rebuild_ducks();
-
-       App::toolbox->refresh();
-}
-
-Smach::event_result
-StateCircle_Context::event_stop_handler(const Smach::event& /*x*/)
-{
-       //throw Smach::egress_exception();
-       throw &state_normal;
-       return Smach::RESULT_OK;
-}
-
-Smach::event_result
-StateCircle_Context::event_refresh_handler(const Smach::event& /*x*/)
-{
-       refresh_ducks();
-       return Smach::RESULT_ACCEPT;
-}
-
-void
-StateCircle_Context::make_circle(const Point& _p1, const Point& _p2)
-{
-       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("New Circle"));
-       synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
-       Layer::Handle layer;
-
-       Canvas::Handle canvas;
-       int depth(0);
-
-       // we are temporarily using the layer to hold something
-       layer=get_canvas_view()->get_selection_manager()->get_selected_layer();
-       if(layer)
-       {
-               depth=layer->get_depth();
-               canvas=layer->get_canvas();
-       }
-
-       synfigapp::SelectionManager::LayerList layer_selection;
-       if (!getenv("SYNFIG_TOOLS_CLEAR_SELECTION"))
-               layer_selection = get_canvas_view()->get_selection_manager()->get_selected_layers();
-
-       const synfig::TransformStack& transform(get_canvas_view()->get_curr_transform_stack());
-       const Point p1(transform.unperform(_p1));
-       const Point p2(transform.unperform(_p2));
-
-       Real radius((p2-p1).mag());
-       int points = get_number_of_bline_points();
-       Angle::deg offset(get_bline_point_angle_offset());
-       Angle::deg angle(360.0/points);
-       Real tangent(4 * ((points == 2)
-                                         ? 1
-                                         : ((2 * Angle::cos(angle/2).get() - Angle::cos(angle).get() - 1) / Angle::sin(angle).get())));
-       Vector origin;
-       Real x, y;
-
-       if (get_layer_origins_at_center_flag())
-       {
-               x = y = 0;
-               origin = p1;
-       }
-       else
-       {
-               x = p1[0];
-               y = p1[1];
-       }
-
-       std::vector<BLinePoint> new_list;
-       for (int i = 0; i < points; i++)
-       {
-               new_list.push_back(*(new BLinePoint));
-               new_list[i].set_width(1);
-               new_list[i].set_vertex(Point(radius*Angle::cos(angle*i + offset).get() + x,
-                                                                        radius*Angle::sin(angle*i + offset).get() + y));
-               new_list[i].set_tangent(Point(-radius*tangent*Angle::sin(angle*i + offset).get(),
-                                                                          radius*tangent*Angle::cos(angle*i + offset).get()));
-       }
-
-       ValueNode_BLine::Handle value_node_bline(ValueNode_BLine::create(new_list));
-       assert(value_node_bline);
-
-       ValueNode_Const::Handle value_node_origin(ValueNode_Const::create(origin));
-       assert(value_node_origin);
-
-       // Set the looping flag
-       value_node_bline->set_loop(true);
-
-       if(!canvas)
-               canvas=get_canvas_view()->get_canvas();
-
-       value_node_bline->set_member_canvas(canvas);
-
-       // count how many layers we're going to be creating
-       int layers_to_create = this->layers_to_create();
-
-       ///////////////////////////////////////////////////////////////////////////
-       //   C I R C L E
-       ///////////////////////////////////////////////////////////////////////////
-
-       if (get_layer_circle_flag() &&
-               get_falloff() >= 0 && get_falloff() < CIRCLE_NUM_FALLOFF)
-       {
-               layer=get_canvas_interface()->add_layer_to("circle",canvas,depth);
-               if (!layer)
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                       group.cancel();
-                       return;
-               }
-               layer_selection.push_back(layer);
-
-               layer->set_param("radius",(p2-p1).mag());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"radius");
-
-               layer->set_param("falloff",get_falloff());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"falloff");
-
-               layer->set_param("feather",get_feather());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
-
-               layer->set_param("invert",get_invert());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
-
-#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
-               layer->set_param("blend_method",get_blend());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"blend_method");
-#endif // BLEND_METHOD_IN_TOOL_OPTIONS
-
-               layer->set_description(get_id());
-               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
-               // only link the circle's origin parameter if the option is selected, we're putting bline
-               // origins at their centers, and we're creating more than one layer
-               if (get_layer_link_origins_flag() && get_layer_origins_at_center_flag() && layers_to_create > 1)
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("origin")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create Circle layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Circle layer"));
-                               return;
-                       }
-               }
-               else
-               {
-                       layer->set_param("origin",p1);
-                       get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
-               }
-       }
-
-       ///////////////////////////////////////////////////////////////////////////
-       //   C U R V E   G R A D I E N T
-       ///////////////////////////////////////////////////////////////////////////
-
-       if(get_layer_curve_gradient_flag())
-       {
-               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
-               Layer::Handle layer(get_canvas_interface()->add_layer_to("curve_gradient",canvas,depth));
-               if (!layer)
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                       group.cancel();
-                       return;
-               }
-               layer_selection.push_back(layer);
-               layer->set_description(get_id()+_(" Gradient"));
-               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
-#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
-               layer->set_param("blend_method",get_blend());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"blend_method");
-#endif // BLEND_METHOD_IN_TOOL_OPTIONS
-
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("bline")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Gradient layer"));
-                               return;
-                       }
-               }
-
-               // only link the curve gradient's origin parameter if the option is selected and we're creating more than one layer
-               if (get_layer_link_origins_flag() && layers_to_create > 1)
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("origin")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Gradient layer"));
-                               return;
-                       }
-               }
-               else
-               {
-                       layer->set_param("origin",origin);
-                       get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
-               }
-       }
-
-       ///////////////////////////////////////////////////////////////////////////
-       //   P L A N T
-       ///////////////////////////////////////////////////////////////////////////
-
-       if(get_layer_plant_flag())
-       {
-               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
-               Layer::Handle layer(get_canvas_interface()->add_layer_to("plant",canvas,depth));
-               if (!layer)
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                       group.cancel();
-                       return;
-               }
-               layer_selection.push_back(layer);
-               layer->set_description(get_id()+_(" Plant"));
-               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
-#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
-               layer->set_param("blend_method",get_blend());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"blend_method");
-#endif // BLEND_METHOD_IN_TOOL_OPTIONS
-
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("bline")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Plant layer"));
-                               return;
-                       }
-               }
-
-               // only link the plant's origin parameter if the option is selected and we're creating more than one layer
-               if (get_layer_link_origins_flag() && layers_to_create > 1)
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("origin")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Plant layer"));
-                               return;
-                       }
-               }
-               else
-               {
-                       layer->set_param("origin",origin);
-                       get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
-               }
-       }
-
-       ///////////////////////////////////////////////////////////////////////////
-       //   R E G I O N
-       ///////////////////////////////////////////////////////////////////////////
-
-       if(get_layer_region_flag())
-       {
-               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
-               Layer::Handle layer(get_canvas_interface()->add_layer_to("region",canvas,depth));
-               if (!layer)
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                       group.cancel();
-                       return;
-               }
-               layer_selection.push_back(layer);
-               layer->set_description(get_id()+_(" Region"));
-               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
-#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
-               layer->set_param("blend_method",get_blend());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"blend_method");
-#endif // BLEND_METHOD_IN_TOOL_OPTIONS
-
-               layer->set_param("feather",get_feather());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
-
-               layer->set_param("invert",get_invert());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
-
-               // I don't know if it's safe to reuse the same LayerParamConnect action, so I'm
-               // using 2 separate ones.
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("bline")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Region layer"));
-                               return;
-                       }
-               }
-
-               // only link the region's origin parameter if the option is selected and we're creating more than one layer
-               if (get_layer_link_origins_flag() && layers_to_create > 1)
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("origin")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Region layer"));
-                               return;
-                       }
-               }
-               else
-               {
-                       layer->set_param("origin",origin);
-                       get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
-               }
-       }
-
-       ///////////////////////////////////////////////////////////////////////////
-       //   O U T L I N E
-       ///////////////////////////////////////////////////////////////////////////
-
-       if (get_layer_outline_flag())
-       {
-               Layer::Handle layer(get_canvas_interface()->add_layer_to("outline",canvas,depth));
-               if (!layer)
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                       group.cancel();
-                       return;
-               }
-               layer_selection.push_back(layer);
-               layer->set_description(get_id()+_(" Outline"));
-               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
-#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
-               layer->set_param("blend_method",get_blend());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"blend_method");
-#endif // BLEND_METHOD_IN_TOOL_OPTIONS
-
-               layer->set_param("feather",get_feather());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
-
-               layer->set_param("invert",get_invert());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
-
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("bline")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Outline layer"));
-                               return;
-                       }
-               }
-
-               // only link the outline's origin parameter if the option is selected and we're creating more than one layer
-               if (get_layer_link_origins_flag() && layers_to_create > 1)
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("origin")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Outline layer"));
-                               return;
-                       }
-               }
-               else
-               {
-                       layer->set_param("origin",origin);
-                       get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
-               }
-       }
-
-       egress_on_selection_change=false;
-       get_canvas_interface()->get_selection_manager()->clear_selected_layers();
-       get_canvas_interface()->get_selection_manager()->set_selected_layers(layer_selection);
-       egress_on_selection_change=true;
-
-       reset();
-       increment_id();
-}
-
-Smach::event_result
-StateCircle_Context::event_mouse_click_handler(const Smach::event& x)
-{
-       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
-
-       if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_DOWN && event.button==BUTTON_LEFT)
-       {
-               point_holder=get_work_area()->snap_point_to_grid(event.pos);
-               etl::handle<Duck> duck=new Duck();
-               duck->set_point(point_holder);
-               duck->set_name("p1");
-               duck->set_type(Duck::TYPE_POSITION);
-               duck->set_editable(false);
-               get_work_area()->add_duck(duck);
-
-               point2_duck=new Duck();
-               point2_duck->set_point(Vector(0,0));
-               point2_duck->set_name("radius");
-               point2_duck->set_origin(duck);
-               point2_duck->set_radius(true);
-               point2_duck->set_scalar(-1);
-               point2_duck->set_type(Duck::TYPE_RADIUS);
-               point2_duck->set_hover(true);
-               get_work_area()->add_duck(point2_duck);
-
-               return Smach::RESULT_ACCEPT;
-       }
-
-       if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_DRAG && event.button==BUTTON_LEFT)
-       {
-               if (!point2_duck) return Smach::RESULT_OK;
-               point2_duck->set_point(point_holder-get_work_area()->snap_point_to_grid(event.pos));
-               get_work_area()->queue_draw();
-               return Smach::RESULT_ACCEPT;
-       }
-
-       if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_UP && event.button==BUTTON_LEFT)
-       {
-               Point point(get_work_area()->snap_point_to_grid(event.pos));
-
-               if (App::restrict_radius_ducks)
-               {
-                       if ((point[0] - point_holder[0]) < 0) point[0] = point_holder[0];
-                       if ((point[1] - point_holder[1]) < 0) point[1] = point_holder[1];
-               }
-
-               make_circle(point_holder, point);
-               get_work_area()->clear_ducks();
-               return Smach::RESULT_ACCEPT;
-       }
-
-       return Smach::RESULT_OK;
-}
-
-
-void
-StateCircle_Context::refresh_ducks()
-{
-       get_work_area()->clear_ducks();
-       get_work_area()->queue_draw();
-}
diff --git a/synfig-studio/src/gtkmm/state_circle.h b/synfig-studio/src/gtkmm/state_circle.h
deleted file mode 100644 (file)
index b33ccf3..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_circle.h
-**     \brief Circle creation state
-**
-**     $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_CIRCLE_H
-#define __SYNFIG_STUDIO_STATE_CIRCLE_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 StateCircle_Context;
-
-class StateCircle : public Smach::state<StateCircle_Context>
-{
-public:
-       StateCircle();
-       ~StateCircle();
-}; // END of class StateCircle
-
-extern StateCircle state_circle;
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/state_draw.cpp b/synfig-studio/src/gtkmm/state_draw.cpp
deleted file mode 100644 (file)
index 4482045..0000000
+++ /dev/null
@@ -1,2036 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_draw.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007 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 <config.h>
-#endif
-
-#include <gtkmm/dialog.h>
-#include <gtkmm/entry.h>
-
-#include <synfig/valuenode_dynamiclist.h>
-
-#include "state_draw.h"
-#include "state_stroke.h"
-#include "state_normal.h"
-#include "canvasview.h"
-#include "workarea.h"
-#include "app.h"
-#include <synfig/valuenode_bline.h>
-#include <synfig/valuenode_composite.h>
-#include <ETL/hermite>
-#include <ETL/calculus>
-#include <utility>
-#include "event_mouse.h"
-#include "event_layerclick.h"
-#include "toolbox.h"
-
-#include <synfigapp/blineconvert.h>
-#include <synfigapp/main.h>
-
-#include <ETL/gaussian>
-#include "dialog_tooloptions.h"
-
-#include <gtkmm/table.h>
-#include <gtkmm/label.h>
-#include <gtkmm/button.h>
-#include <gtkmm/checkbutton.h>
-#include <gtkmm/scale.h>
-#include <sigc++/connection.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 ======================================================= */
-
-StateDraw studio::state_draw;
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-class studio::StateDraw_Context : public sigc::trackable
-{
-       typedef etl::smart_ptr<std::list<synfig::Point> > StrokeData;
-       typedef etl::smart_ptr<std::list<synfig::Real> > WidthData;
-
-       typedef list< pair<StrokeData,WidthData> > StrokeQueue;
-
-       StrokeQueue stroke_queue;
-
-
-       etl::handle<CanvasView> canvas_view_;
-       CanvasView::IsWorking is_working;
-
-       bool prev_table_status;
-       bool loop_;
-       bool prev_workarea_layer_status_;
-
-       int nested;
-       sigc::connection process_queue_connection;
-
-       ValueNode_BLine::Handle last_stroke;
-       synfig::String last_stroke_id;
-
-       Gtk::Menu menu;
-
-       //Duckmatic::Push duckmatic_push;
-
-       std::list< etl::smart_ptr<std::list<synfig::Point> > > stroke_list;
-
-       void refresh_ducks();
-
-       Duckmatic::Type old_duckmask;
-
-       void fill_last_stroke();
-       Smach::event_result fill_last_stroke_and_unselect_other_layers();
-
-       Smach::event_result new_bline(std::list<synfig::BLinePoint> bline,bool loop_bline_flag,float radius);
-
-       Smach::event_result new_region(std::list<synfig::BLinePoint> bline,synfig::Real radius);
-
-       Smach::event_result extend_bline_from_begin(ValueNode_BLine::Handle value_node,std::list<synfig::BLinePoint> bline,bool complete_loop);
-       Smach::event_result extend_bline_from_end(ValueNode_BLine::Handle value_node,std::list<synfig::BLinePoint> bline,bool complete_loop);
-       void reverse_bline(std::list<synfig::BLinePoint> &bline);
-
-       synfigapp::Settings& settings;
-
-       Gtk::Table options_table;
-       Gtk::Entry entry_id;
-       Gtk::CheckButton checkbutton_pressure_width;
-       Gtk::CheckButton checkbutton_round_ends;
-       Gtk::CheckButton checkbutton_auto_loop;   // whether to loop new strokes which start and end in the same place
-       Gtk::CheckButton checkbutton_auto_extend; // whether to extend existing lines
-       Gtk::CheckButton checkbutton_auto_link;   // whether to link new ducks to existing ducks
-       Gtk::CheckButton checkbutton_region;      // whether to create regions
-       Gtk::CheckButton checkbutton_outline;     // whether to create outlines
-       Gtk::CheckButton checkbutton_auto_export;
-       Gtk::Button button_fill_last_stroke;
-
-       //pressure spinner and such
-       Gtk::Adjustment  adj_min_pressure;
-       Gtk::SpinButton  spin_min_pressure;
-       Gtk::CheckButton check_min_pressure;
-
-       Gtk::Adjustment  adj_feather;
-       Gtk::SpinButton  spin_feather;
-
-       Gtk::Adjustment  adj_globalthres;
-       Gtk::SpinButton  spin_globalthres;
-
-       Gtk::Adjustment  adj_localthres;
-       Gtk::CheckButton check_localerror;
-       void UpdateErrorBox();  //switches the stuff if need be :)
-
-       //Added by Adrian - data drive HOOOOO
-       synfigapp::BLineConverter blineconv;
-
-public:
-       synfig::String get_id()const { return entry_id.get_text(); }
-       void set_id(const synfig::String& x) { return entry_id.set_text(x); }
-
-       bool get_pressure_width_flag()const { return checkbutton_pressure_width.get_active(); }
-       void set_pressure_width_flag(bool x) { return checkbutton_pressure_width.set_active(x); }
-
-       bool get_auto_loop_flag()const { return checkbutton_auto_loop.get_active(); }
-       void set_auto_loop_flag(bool x) { return checkbutton_auto_loop.set_active(x); }
-
-       bool get_auto_extend_flag()const { return checkbutton_auto_extend.get_active(); }
-       void set_auto_extend_flag(bool x) { return checkbutton_auto_extend.set_active(x); }
-
-       bool get_auto_link_flag()const { return checkbutton_auto_link.get_active(); }
-       void set_auto_link_flag(bool x) { return checkbutton_auto_link.set_active(x); }
-
-       bool get_region_flag()const { return checkbutton_region.get_active(); }
-       void set_region_flag(bool x) { return checkbutton_region.set_active(x); }
-
-       bool get_outline_flag()const { return checkbutton_outline.get_active(); }
-       void set_outline_flag(bool x) { return checkbutton_outline.set_active(x); }
-
-       bool get_auto_export_flag()const { return checkbutton_auto_export.get_active(); }
-       void set_auto_export_flag(bool x) { return checkbutton_auto_export.set_active(x); }
-
-       Real get_min_pressure() const { return adj_min_pressure.get_value(); }
-       void set_min_pressure(Real x) { return adj_min_pressure.set_value(x); }
-
-       Real get_feather() const { return adj_feather.get_value(); }
-       void set_feather(Real x) { return adj_feather.set_value(x); }
-
-       Real get_gthres() const { return adj_globalthres.get_value(); }
-       void set_gthres(Real x) { return adj_globalthres.set_value(x); }
-
-       Real get_lthres() const { return adj_localthres.get_value(); }
-       void set_lthres(Real x) { return adj_localthres.set_value(x); }
-
-       bool get_local_error_flag() const { return check_localerror.get_active(); }
-       void set_local_error_flag(bool x) { check_localerror.set_active(x); }
-
-       bool get_min_pressure_flag()const { return check_min_pressure.get_active(); }
-       void set_min_pressure_flag(bool x) { check_min_pressure.set_active(x); }
-
-       void load_settings();
-       void save_settings();
-       void increment_id();
-
-       Smach::event_result event_stop_handler(const Smach::event& x);
-
-       Smach::event_result event_refresh_handler(const Smach::event& x);
-
-       Smach::event_result event_mouse_down_handler(const Smach::event& x);
-
-       Smach::event_result event_stroke(const Smach::event& x);
-       Smach::event_result event_refresh_tool_options(const Smach::event& x);
-       void refresh_tool_options();
-
-       Smach::event_result process_stroke(StrokeData stroke_data, WidthData width_data, bool region_flag=false);
-
-       bool process_queue();
-
-
-       StateDraw_Context(CanvasView* canvas_view);
-
-       ~StateDraw_Context();
-
-       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
-       etl::handle<synfigapp::CanvasInterface> get_canvas_interface()const{return canvas_view_->canvas_interface();}
-       synfig::Time get_time()const { return get_canvas_interface()->get_time(); }
-       synfig::Canvas::Handle get_canvas()const{return canvas_view_->get_canvas();}
-       WorkArea * get_work_area()const{return canvas_view_->get_work_area();}
-
-       //void on_user_click(synfig::Point point);
-
-//     bool run();
-};     // END of class StateDraw_Context
-
-
-/* === M E T H O D S ======================================================= */
-
-StateDraw::StateDraw():
-       Smach::state<StateDraw_Context>("draw")
-{
-       insert(event_def(EVENT_STOP,&StateDraw_Context::event_stop_handler));
-       insert(event_def(EVENT_REFRESH,&StateDraw_Context::event_refresh_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StateDraw_Context::event_mouse_down_handler));
-       insert(event_def(EVENT_WORKAREA_STROKE,&StateDraw_Context::event_stroke));
-       insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateDraw_Context::event_refresh_tool_options));
-}
-
-StateDraw::~StateDraw()
-{
-}
-
-
-void
-StateDraw_Context::load_settings()
-{
-       String value;
-
-       if(settings.get_value("draw.id",value))
-               set_id(value);
-       else
-               set_id("NewDrawing");
-
-       if(settings.get_value("draw.pressure_width",value) && value=="0")
-               set_pressure_width_flag(false);
-       else
-               set_pressure_width_flag(true);
-
-       if(settings.get_value("draw.auto_loop",value) && value=="0")
-               set_auto_loop_flag(false);
-       else
-               set_auto_loop_flag(true);
-
-       if(settings.get_value("draw.auto_extend",value) && value=="0")
-               set_auto_extend_flag(false);
-       else
-               set_auto_extend_flag(true);
-
-       if(settings.get_value("draw.auto_link",value) && value=="0")
-               set_auto_link_flag(false);
-       else
-               set_auto_link_flag(true);
-
-       if(settings.get_value("draw.region",value) && value=="0")
-               set_region_flag(false);
-       else
-               set_region_flag(true);
-
-       if(settings.get_value("draw.outline",value) && value=="0")
-               set_outline_flag(false);
-       else
-               set_outline_flag(true);
-
-       if(settings.get_value("draw.auto_export",value) && value=="1")
-               set_auto_export_flag(true);
-       else
-               set_auto_export_flag(false);
-
-       if(settings.get_value("draw.min_pressure_on",value) && value=="0")
-               set_min_pressure_flag(false);
-       else
-               set_min_pressure_flag(true);
-
-       if(settings.get_value("draw.min_pressure",value))
-       {
-               Real n = atof(value.c_str());
-               set_min_pressure(n);
-       }else
-               set_min_pressure(0);
-
-       if(settings.get_value("draw.feather",value))
-       {
-               Real n = atof(value.c_str());
-               set_feather(n);
-       }else
-               set_feather(0);
-
-       if(settings.get_value("draw.gthreshold",value))
-       {
-               Real n = atof(value.c_str());
-               set_gthres(n);
-       }
-
-       if(settings.get_value("draw.lthreshold",value))
-       {
-               Real n = atof(value.c_str());
-               set_lthres(n);
-       }
-
-       if(settings.get_value("draw.localize",value) && value == "1")
-               set_local_error_flag(true);
-       else
-               set_local_error_flag(false);
-}
-
-void
-StateDraw_Context::save_settings()
-{
-       settings.set_value("draw.id",get_id().c_str());
-       settings.set_value("draw.pressure_width",get_pressure_width_flag()?"1":"0");
-       settings.set_value("draw.auto_loop",get_auto_loop_flag()?"1":"0");
-       settings.set_value("draw.auto_extend",get_auto_extend_flag()?"1":"0");
-       settings.set_value("draw.auto_link",get_auto_link_flag()?"1":"0");
-       settings.set_value("draw.region",get_region_flag()?"1":"0");
-       settings.set_value("draw.outline",get_outline_flag()?"1":"0");
-       settings.set_value("draw.auto_export",get_auto_export_flag()?"1":"0");
-       settings.set_value("draw.min_pressure",strprintf("%f",get_min_pressure()));
-       settings.set_value("draw.feather",strprintf("%f",get_feather()));
-       settings.set_value("draw.min_pressure_on",get_min_pressure_flag()?"1":"0");
-       settings.set_value("draw.gthreshold",strprintf("%f",get_gthres()));
-       settings.set_value("draw.lthreshold",strprintf("%f",get_lthres()));
-       settings.set_value("draw.localize",get_local_error_flag()?"1":"0");
-}
-
-void
-StateDraw_Context::increment_id()
-{
-       String id(get_id());
-       int number=1;
-       int digits=0;
-
-       if(id.empty())
-               id="Drawing";
-
-       // If there is a number
-       // already at the end of the
-       // id, then remove it.
-       if(id[id.size()-1]<='9' && id[id.size()-1]>='0')
-       {
-               // figure out how many digits it is
-               for (digits = 0;
-                        (int)id.size()-1 >= digits && id[id.size()-1-digits] <= '9' && id[id.size()-1-digits] >= '0';
-                        digits++)
-                       ;
-
-               String str_number;
-               str_number=String(id,id.size()-digits,id.size());
-               id=String(id,0,id.size()-digits);
-               // synfig::info("---------------- \"%s\"",str_number.c_str());
-
-               number=atoi(str_number.c_str());
-       }
-       else
-       {
-               number=1;
-               digits=3;
-       }
-
-       number++;
-
-       // Add the number back onto the id
-       {
-               const String format(strprintf("%%0%dd",digits));
-               id+=strprintf(format.c_str(),number);
-       }
-
-       // Set the ID
-       set_id(id);
-}
-
-StateDraw_Context::StateDraw_Context(CanvasView* canvas_view):
-       canvas_view_(canvas_view),
-       is_working(*canvas_view),
-       loop_(false),
-       prev_workarea_layer_status_(get_work_area()->get_allow_layer_clicks()),
-       settings(synfigapp::Main::get_selected_input_device()->settings()),
-       entry_id(),
-       checkbutton_pressure_width(_("Pressure Width")),
-       checkbutton_auto_loop(_("Auto Loop")),
-       checkbutton_auto_extend(_("Auto Extend")),
-       checkbutton_auto_link(_("Auto Link")),
-       checkbutton_region(_("Create Region BLine")),
-       checkbutton_outline(_("Create Outline BLine")),
-       checkbutton_auto_export(_("Auto Export")),
-       button_fill_last_stroke(_("Fill Last Stroke")),
-       adj_min_pressure(0,0,1,0.01,0.1),
-       spin_min_pressure(adj_min_pressure,0.1,3),
-       check_min_pressure(_("Min Pressure")),
-       adj_feather(0,0,10000,0.01,0.1),
-       spin_feather(adj_feather,0.01,4),
-       adj_globalthres(.70f,0.01,10000,0.01,0.1),
-       spin_globalthres(adj_globalthres,0.01,3),
-       adj_localthres(20,1,100000,0.1,1),
-       check_localerror(_("LocalError"))
-
-{
-       nested=0;
-       load_settings();
-
-       UpdateErrorBox();
-
-       options_table.attach(*manage(new Gtk::Label(_("Draw Tool"))),   0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(entry_id,                                                                  0, 2,  1,  2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_outline,                                               0, 2,  2,  3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_region,                                                0, 2,  3,  4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_auto_loop,                                             0, 2,  4,  5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_auto_extend,                                   0, 2,  5,  6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_auto_link,                                             0, 2,  6,  7, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_auto_export,                                   0, 2,  7,  8, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_pressure_width,                                0, 2,  8,  9, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(check_localerror,                                                  0, 2,  9, 10, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       options_table.attach(check_min_pressure,                                                0, 1, 10, 11, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(spin_min_pressure,                                                 1, 2, 10, 11, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       options_table.attach(*manage(new Gtk::Label(_("Smooth"))),              0, 1, 11, 12, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(spin_globalthres,                                                  1, 2, 11, 12, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       options_table.attach(*manage(new Gtk::Label(_("Feather"))),     0, 1, 12, 13, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(spin_feather,                                                              1, 2, 12, 13, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       //options_table.attach(button_fill_last_stroke, 0, 2, 13, 14, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       button_fill_last_stroke.signal_pressed().connect(sigc::mem_fun(*this,&StateDraw_Context::fill_last_stroke));
-       check_localerror.signal_toggled().connect(sigc::mem_fun(*this,&StateDraw_Context::UpdateErrorBox));
-
-       options_table.show_all();
-       refresh_tool_options();
-       //App::dialog_tool_options->set_widget(options_table);
-       App::dialog_tool_options->present();
-
-
-       old_duckmask=get_work_area()->get_type_mask();
-       get_work_area()->set_type_mask(Duck::TYPE_ALL-Duck::TYPE_TANGENT-Duck::TYPE_WIDTH);
-
-       // Turn off layer clicking
-       get_work_area()->set_allow_layer_clicks(false);
-
-       // Turn off duck clicking
-       get_work_area()->set_allow_duck_clicks(false);
-
-       // clear out the ducks
-       //get_work_area()->clear_ducks();
-
-       // Refresh the work area
-       //get_work_area()->queue_draw();
-
-       // Hide the tables if they are showing
-       prev_table_status=get_canvas_view()->tables_are_visible();
-       //if(prev_table_status)get_canvas_view()->hide_tables();
-
-       // Disable the time bar
-       get_canvas_view()->set_sensitive_timebar(false);
-
-       // Connect a signal
-       //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateDraw_Context::on_user_click));
-
-       get_work_area()->set_cursor(Gdk::PENCIL);
-
-       App::toolbox->refresh();
-
-       refresh_ducks();
-}
-
-
-void StateDraw_Context::UpdateErrorBox()
-{
-       if(get_local_error_flag())
-       {
-               spin_globalthres.set_adjustment(adj_localthres);
-               spin_globalthres.set_value(adj_localthres.get_value());
-               spin_globalthres.set_increments(0.1,1);
-       }else
-       {
-               spin_globalthres.set_adjustment(adj_globalthres);
-               spin_globalthres.set_value(adj_globalthres.get_value());
-               spin_globalthres.set_increments(0.01,.1);
-       }
-
-       spin_globalthres.update();
-}
-
-void
-StateDraw_Context::refresh_tool_options()
-{
-       App::dialog_tool_options->clear();
-       App::dialog_tool_options->set_widget(options_table);
-       App::dialog_tool_options->set_local_name(_("Draw Tool"));
-       App::dialog_tool_options->set_name("draw");
-
-       App::dialog_tool_options->add_button(
-               Gtk::StockID("synfig-fill"),
-               _("Fill Last Stroke")
-       )->signal_clicked().connect(
-               sigc::mem_fun(
-                       *this,
-                       &StateDraw_Context::fill_last_stroke));
-}
-
-Smach::event_result
-StateDraw_Context::event_refresh_tool_options(const Smach::event& /*x*/)
-{
-       refresh_tool_options();
-       return Smach::RESULT_ACCEPT;
-}
-
-StateDraw_Context::~StateDraw_Context()
-{
-       save_settings();
-
-       App::dialog_tool_options->clear();
-
-       get_work_area()->set_type_mask(old_duckmask);
-
-       get_work_area()->reset_cursor();
-
-       // Restore layer clicking
-       get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_);
-
-       // Restore duck clicking
-       get_work_area()->set_allow_duck_clicks(true);
-
-       // Enable the time bar
-       get_canvas_view()->set_sensitive_timebar(true);
-
-       // Bring back the tables if they were out before
-       if(prev_table_status)get_canvas_view()->show_tables();
-
-       // Refresh the work area
-       get_work_area()->queue_draw();
-
-       App::toolbox->refresh();
-}
-
-Smach::event_result
-StateDraw_Context::event_stop_handler(const Smach::event& /*x*/)
-{
-       //throw Smach::egress_exception();
-       throw &state_normal;
-       return Smach::RESULT_OK;
-}
-
-Smach::event_result
-StateDraw_Context::event_refresh_handler(const Smach::event& /*x*/)
-{
-       refresh_ducks();
-       return Smach::RESULT_ACCEPT;
-}
-
-Smach::event_result
-StateDraw_Context::event_mouse_down_handler(const Smach::event& x)
-{
-       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
-       switch(event.button)
-       {
-       case BUTTON_LEFT:
-               {
-                       // Enter the stroke state to get the stroke
-                       get_canvas_view()->get_smach().push_state(&state_stroke);
-                       return Smach::RESULT_ACCEPT;
-               }
-
-       default:
-               return Smach::RESULT_OK;
-       }
-}
-
-#define SIMILAR_TANGENT_THRESHOLD      (0.2)
-
-struct debugclass
-{
-       synfig::String x;
-       debugclass(const synfig::String &x):x(x)
-       {
-//             synfig::warning(">>>>>>>>>>>>>>>>>>> "+x);
-       }
-       ~debugclass()
-       {
-//             synfig::warning("<<<<<<<<<<<<<<<<<<< "+x);
-       }
-};
-
-struct DepthCounter
-{
-       int &i;
-       DepthCounter(int &i):i(i) { i++; }
-       ~DepthCounter() { i--; }
-};
-
-Smach::event_result
-StateDraw_Context::event_stroke(const Smach::event& x)
-{
-//     debugclass debugger("StateDraw_Context::event_stroke(const Smach::event& x)");
-
-       const EventStroke& event(*reinterpret_cast<const EventStroke*>(&x));
-
-       assert(event.stroke_data);
-
-       get_work_area()->add_stroke(event.stroke_data,synfigapp::Main::get_outline_color());
-
-       if(nested==0)
-       {
-               DirtyTrap dirty_trap(get_work_area());
-               Smach::event_result result;
-               result=process_stroke(event.stroke_data,event.width_data,event.modifier&Gdk::CONTROL_MASK || event.modifier&Gdk::BUTTON2_MASK);
-               process_queue();
-               return result;
-       }
-
-       stroke_queue.push_back(pair<StrokeData,WidthData>(event.stroke_data,event.width_data));
-
-       return Smach::RESULT_ACCEPT;
-}
-
-bool
-StateDraw_Context::process_queue()
-{
-//     debugclass debugger("StateDraw_Context::process_queue()");
-       if(nested)
-               return true;
-       DepthCounter depth_counter(nested);
-       while(!stroke_queue.empty())
-       {
-               pair<StrokeData,WidthData> front(stroke_queue.front());
-               process_stroke(front.first,front.second);
-               stroke_queue.pop_front();
-       }
-       return false;
-}
-
-Smach::event_result
-StateDraw_Context::process_stroke(StrokeData stroke_data, WidthData width_data, bool region_flag)
-{
-//     debugclass debugger("StateDraw_Context::process_stroke");
-       DepthCounter depth_counter(nested);
-
-       const float radius(synfigapp::Main::get_bline_width().units(get_canvas()->rend_desc())+(abs(get_work_area()->get_pw())+abs(get_work_area()->get_ph()))*5);
-
-
-       // If we aren't using pressure width,
-       // then set all the width to 1
-       if(!get_pressure_width_flag())
-       {
-               std::list<synfig::Real>::iterator iter;
-               for(iter=width_data->begin();iter!=width_data->end();++iter)
-               {
-                       *iter=1.0;
-               }
-       }
-
-       //get_work_area()->add_stroke(event.stroke_data,synfigapp::Main::get_outline_color());
-       //stroke_list.push_back(event.stroke_data);
-       //refresh_ducks();
-
-       std::list<synfig::BLinePoint> bline;
-       bool loop_bline_flag(false);
-
-       //Changed by Adrian - use resident class :)
-       //synfigapp::convert_stroke_to_bline(bline, *event.stroke_data,*event.width_data, synfigapp::Main::get_bline_width());
-       blineconv.width = synfigapp::Main::get_bline_width().units(get_canvas()->rend_desc());
-
-       if(get_local_error_flag())
-       {
-               float pw = get_work_area()->get_pw();
-               float ph = get_work_area()->get_ph();
-
-               blineconv.pixelwidth = sqrt(pw*pw+ph*ph);
-               blineconv.smoothness = get_lthres();
-       }else
-       {
-               blineconv.pixelwidth = 1;
-               blineconv.smoothness = get_gthres();
-       }
-
-       blineconv(bline,*stroke_data,*width_data);
-
-       //Postprocess to require minimum pressure
-       if(get_min_pressure_flag())
-       {
-               synfigapp::BLineConverter::EnforceMinWidth(bline,get_min_pressure());
-       }
-
-       // If the start and end points are similar, then make them the same point
-       if (get_auto_loop_flag() &&
-               bline.size() > 2 &&
-               (bline.front().get_vertex() - bline.back().get_vertex()).mag() <= radius)
-       {
-               loop_bline_flag=true;
-               Vector tangent;
-               Real width(0);
-
-               while (bline.size() > 2 &&
-                          (bline.front().get_vertex() - bline.back().get_vertex()).mag() <= radius)
-               {
-                       tangent=bline.back().get_tangent1();
-                       width=bline.back().get_width();
-                       bline.pop_back();
-               }
-
-               if(abs(bline.front().get_tangent1().norm()*tangent.norm().perp())>SIMILAR_TANGENT_THRESHOLD)
-               {
-                       // If the tangents are not similar, then
-                       // split the tangents
-                       bline.front().set_split_tangent_flag(true);
-                       bline.front().set_tangent1(tangent);
-               }
-               else
-               {
-                       // If the tangents are similar, then set the tangent
-                       // to the average of the two
-                       bline.front().set_tangent((tangent+bline.front().get_tangent1())*0.5f);
-               }
-
-               // Add the widths of the two points
-               {
-                       Real tmp_width(bline.front().get_width()+width);
-                       tmp_width=tmp_width<=1?tmp_width:1;
-                       bline.front().set_width(tmp_width);
-               }
-       }
-
-       // If the bline only has one blinepoint, then there is nothing to do.
-       if(bline.size() < 2)
-       {
-               // hide the 'stroke' line we were drawing, unless the user
-               // explicitly requests that they are kept
-               if (!getenv("SYNFIG_KEEP_ABORTED_DRAW_LINES"))
-                       refresh_ducks();
-
-               return Smach::RESULT_OK;
-       }
-
-       if(region_flag)
-               return new_region(bline,radius);
-
-       return new_bline(bline,loop_bline_flag,radius);
-}
-
-Smach::event_result
-StateDraw_Context::new_bline(std::list<synfig::BLinePoint> bline,bool loop_bline_flag,float radius)
-{
-       synfigapp::SelectionManager::LayerList layer_list = get_canvas_view()->get_selection_manager()->get_selected_layers();
-
-       // Create the action group
-       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Sketch BLine"));
-
-       bool shift_origin = false;
-       Vector shift_origin_vector;
-       bool join_start_no_extend=false,join_finish_no_extend=false;
-       synfigapp::ValueDesc start_duck_value_desc,finish_duck_value_desc;
-       bool extend_start=false,extend_finish=false,complete_loop=false;
-       bool extend_start_join_same=false,extend_start_join_different=false;
-       bool extend_finish_join_same=false,extend_finish_join_different=false;
-       int start_duck_index = 0,finish_duck_index = 0; // initialized to keep the compiler happy; shouldn't be needed though
-       ValueNode_BLine::Handle start_duck_value_node_bline=NULL,finish_duck_value_node_bline=NULL;
-
-       // Find any ducks at the start or end that we might attach to
-       // (this used to only run if we didn't just draw a loop - ie. !loop_bline_flag
-       // but having loops auto-connect can be useful as well)
-       if(get_auto_extend_flag() || get_auto_link_flag())
-       {
-               etl::handle<Duck> start_duck(get_work_area()->find_duck(bline.front().get_vertex(),radius,Duck::TYPE_VERTEX));
-               etl::handle<Duck> finish_duck(get_work_area()->find_duck(bline.back().get_vertex(),radius,Duck::TYPE_VERTEX));
-
-               // check whether the start of the new line extends an
-               // existing line.  this is only the case if the new
-               // line isn't a self-contained loop, and if the new
-               // line starts at one of the ends of an existing line
-               if(start_duck)do
-               {
-                       if(!(start_duck_value_desc=start_duck->get_value_desc()))break;
-                       if(loop_bline_flag)break; // loops don't extend anything
-                       if(!start_duck_value_desc.parent_is_value_node())break;
-                       start_duck_index=start_duck_value_desc.get_index(); // which point on the line did we start drawing at
-                       start_duck_value_node_bline=ValueNode_BLine::Handle::cast_dynamic(start_duck_value_desc.get_parent_value_node());
-                       if(!get_auto_extend_flag())break;
-
-                       // don't extend looped blines
-                       if(start_duck_value_node_bline&&!start_duck_value_node_bline->get_loop()&&
-                          // did we start drawing at either end of the line?
-                          (start_duck_index==0||start_duck_index==start_duck_value_node_bline->link_count()-1))
-                       {
-                               extend_start=true;
-                               shift_origin=true;
-                               shift_origin_vector=start_duck->get_origin();
-                       }
-               }while(0);
-
-               // check whether the end of the new line extends an
-               // existing line.  this is only the case if the new
-               // line isn't a self-contained loop, and if the new
-               // line ends at one of the ends of an existing line
-               if(finish_duck)do
-               {
-                       if(!(finish_duck_value_desc=finish_duck->get_value_desc()))break;
-                       if(loop_bline_flag)break;
-                       if(!finish_duck_value_desc.parent_is_value_node())break;
-                       finish_duck_index=finish_duck_value_desc.get_index();
-                       finish_duck_value_node_bline=ValueNode_BLine::Handle::cast_dynamic(finish_duck_value_desc.get_parent_value_node());
-                       if(!get_auto_extend_flag())break;
-
-                       // don't extend looped blines
-                       if(finish_duck_value_node_bline&&!finish_duck_value_node_bline->get_loop()&&
-                          (finish_duck_index==0||finish_duck_index==finish_duck_value_node_bline->link_count()-1))
-                       {
-                               if(extend_start)
-                               {
-                                       // we've started and finished drawing at the end of a bline.  we can't
-                                       // extend both blines, so unless we started and finished at the 2 ends
-                                       // of the same bline, only extend the one we started on
-                                       if(start_duck_value_node_bline==finish_duck_value_node_bline)
-                                               complete_loop=extend_finish=true;
-                               }else{
-                                       extend_finish=true;
-                                       shift_origin=true;
-                                       shift_origin_vector=finish_duck->get_origin();
-                               }
-                       }
-               }while(0);
-
-               // if the new line's start didn't extend an existing line,
-               // check whether it needs to be linked to an existing duck
-               if(!extend_start&&get_auto_link_flag()&&start_duck&&start_duck_value_desc)
-                       switch(start_duck_value_desc.get_value_type())
-                       {
-                       case synfig::ValueBase::TYPE_BLINEPOINT:
-                               start_duck_value_desc=synfigapp::ValueDesc(LinkableValueNode::Handle::cast_dynamic(start_duck_value_desc.get_value_node()),0);
-                               // fall through
-                       case synfig::ValueBase::TYPE_VECTOR:
-                               if (shift_origin && shift_origin_vector != start_duck->get_origin())
-                                       break;
-                               shift_origin = true;
-                               shift_origin_vector = start_duck->get_origin();
-                               get_canvas_interface()->auto_export(start_duck_value_desc);
-                               if (extend_finish)
-                                       if(start_duck_value_node_bline&&start_duck_value_node_bline==finish_duck_value_node_bline)
-                                               extend_finish_join_same=true;
-                                       else
-                                               extend_finish_join_different=true;
-                               else
-                                       join_start_no_extend=true;
-                               // fall through
-                       default:break;
-                       }
-
-               // if the new line's end didn't extend an existing line,
-               // check whether it needs to be linked to an existing duck
-               if(!extend_finish&&get_auto_link_flag()&&finish_duck&&finish_duck_value_desc)
-                       switch(finish_duck_value_desc.get_value_type())
-                       {
-                       case synfig::ValueBase::TYPE_BLINEPOINT:
-                               finish_duck_value_desc=synfigapp::ValueDesc(LinkableValueNode::Handle::cast_dynamic(finish_duck_value_desc.get_value_node()),0);
-                               // fall through
-                       case synfig::ValueBase::TYPE_VECTOR:
-                               if (shift_origin && shift_origin_vector != finish_duck->get_origin())
-                                       break;
-                               shift_origin = true;
-                               shift_origin_vector = finish_duck->get_origin();
-                               get_canvas_interface()->auto_export(finish_duck_value_desc);
-                               if(extend_start)
-                                       if(finish_duck_value_node_bline&&start_duck_value_node_bline==finish_duck_value_node_bline)
-                                               extend_start_join_same=true;
-                                       else
-                                               extend_start_join_different=true;
-                               else
-                                       join_finish_no_extend=true;
-                               // fall through
-                       default:break;
-                       }
-       }
-
-       ValueNode_BLine::Handle value_node;
-       std::list<synfig::BLinePoint> trans_bline;
-
-       {
-               std::list<synfig::BLinePoint>::iterator iter;
-               const synfig::TransformStack& transform(get_canvas_view()->get_curr_transform_stack());
-
-               for(iter=bline.begin();iter!=bline.end();++iter)
-               {
-                       BLinePoint bline_point(*iter);
-                       Point new_vertex(transform.unperform(bline_point.get_vertex()));
-
-                       bline_point.set_tangent1(
-                               transform.unperform(
-                                       bline_point.get_tangent1()+bline_point.get_vertex()
-                               ) -new_vertex
-                       );
-
-                       bline_point.set_tangent2(
-                               transform.unperform(
-                                       bline_point.get_tangent2()+bline_point.get_vertex()
-                               ) -new_vertex
-                       );
-
-                       if (shift_origin)
-                               new_vertex=new_vertex-shift_origin_vector;
-
-                       bline_point.set_vertex(new_vertex);
-
-                       trans_bline.push_back(bline_point);
-               }
-               value_node=ValueNode_BLine::create(synfig::ValueBase(trans_bline,loop_bline_flag));
-
-               Canvas::Handle canvas(get_canvas_view()->get_canvas());
-               Layer::Handle layer(get_canvas_view()->get_selection_manager()->get_selected_layer());
-               if (layer) canvas=layer->get_canvas();
-               value_node->set_member_canvas(canvas);
-       }
-
-       Smach::event_result result;
-       synfig::ValueNode_DynamicList::ListEntry source;
-
-       // the new line's start extends an existing line
-       if(extend_start)
-       {
-               int target_offset = 0;
-               if(complete_loop)trans_bline.pop_back();
-               trans_bline.pop_front();
-               if(start_duck_index==0)
-               {       // We need to reverse the BLine first.
-                       reverse_bline(trans_bline);
-                       result=extend_bline_from_begin(start_duck_value_node_bline,trans_bline,complete_loop);
-                       source=start_duck_value_node_bline->list.front();
-                       target_offset=trans_bline.size();
-               }
-               else
-               {
-                       result=extend_bline_from_end(start_duck_value_node_bline,trans_bline,complete_loop);
-                       source=start_duck_value_node_bline->list.back();
-               }
-
-               if(extend_start_join_different)
-                       LinkableValueNode::Handle::cast_dynamic(source.value_node)->
-                               set_link("point",finish_duck_value_desc.get_value_node());
-               else if(extend_start_join_same)
-                       LinkableValueNode::Handle::cast_dynamic(source.value_node)->
-                               set_link("point",synfigapp::ValueDesc(LinkableValueNode::Handle::cast_dynamic(start_duck_value_node_bline->
-                                                                                                       list[target_offset+finish_duck_index].value_node),0).get_value_node());
-               return result;
-       }
-
-       // the new line's end extends an existing line
-       if(extend_finish)
-       {
-               int target_offset = 0;
-               trans_bline.pop_back();
-               if(finish_duck_index==0)
-               {
-                       result=extend_bline_from_begin(finish_duck_value_node_bline,trans_bline,false);
-                       source=finish_duck_value_node_bline->list.front();
-                       target_offset=trans_bline.size();
-               }
-               else
-               {       // We need to reverse the BLine first.
-                       reverse_bline(trans_bline);
-                       result=extend_bline_from_end(finish_duck_value_node_bline,trans_bline,false);
-                       source=finish_duck_value_node_bline->list.back();
-               }
-
-               if(extend_finish_join_different)
-                       LinkableValueNode::Handle::cast_dynamic(source.value_node)->
-                               set_link("point",start_duck_value_desc.get_value_node());
-               else if(extend_finish_join_same)
-                       LinkableValueNode::Handle::cast_dynamic(source.value_node)->
-                               set_link("point",synfigapp::ValueDesc(LinkableValueNode::Handle::cast_dynamic(finish_duck_value_node_bline->
-                                                                                                       list[target_offset+start_duck_index].value_node),0).get_value_node());
-               return result;
-       }
-
-       if (join_start_no_extend)
-               LinkableValueNode::Handle::cast_dynamic(value_node->list.front().value_node)->
-                 set_link("point",start_duck_value_desc.get_value_node());
-
-       if (join_finish_no_extend)
-               LinkableValueNode::Handle::cast_dynamic(value_node->list.back().value_node)->
-                 set_link("point",finish_duck_value_desc.get_value_node());
-
-       if(get_auto_export_flag())
-               if (!get_canvas_interface()->add_value_node(value_node,get_id()))
-               {
-                       /* it's no big deal, is it?  let's keep the shape anyway */
-                       // get_canvas_view()->get_ui_interface()->error(_("Unable to add value node"));
-                       // group.cancel();
-                       // increment_id();
-                       // return Smach::RESULT_ERROR;
-               }
-
-       last_stroke=value_node;
-       last_stroke_id=get_id();
-
-       {
-               // Create the layer(s)
-               Layer::Handle layer;
-               Canvas::Handle canvas(get_canvas_view()->get_canvas());
-               int depth(0);
-
-               // we are temporarily using the layer to hold something
-               layer=get_canvas_view()->get_selection_manager()->get_selected_layer();
-               if(layer)
-               {
-                       depth=layer->get_depth();
-                       canvas=layer->get_canvas();
-               }
-
-               // fill_last_stroke() will take care of clearing the selection if we're calling it
-               if(get_outline_flag() && get_region_flag())
-               {
-                       if (fill_last_stroke_and_unselect_other_layers() == Smach::RESULT_ERROR)
-                       {
-                               get_canvas_view()->get_selection_manager()->set_selected_layers(layer_list);
-                               get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                               group.cancel();
-                               return Smach::RESULT_ERROR;
-                       }
-               }
-               else
-                       get_canvas_interface()->get_selection_manager()->clear_selected_layers();
-
-               //int number(synfig::UniqueID().get_uid());
-
-               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
-               // if they're both defined, we'll add the region later
-               if(get_outline_flag())
-               {
-                       layer=get_canvas_interface()->add_layer_to("outline",canvas,depth);
-                       if (!layer)
-                       {
-                               get_canvas_view()->get_selection_manager()->set_selected_layers(layer_list);
-                               get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                               group.cancel();
-                               return Smach::RESULT_ERROR;
-                       }
-                       layer->set_description(get_id()+_(" Outline"));
-               }
-               else
-               {
-                       layer=get_canvas_interface()->add_layer_to("region",canvas,depth);
-                       if (!layer)
-                       {
-                               get_canvas_view()->get_selection_manager()->set_selected_layers(layer_list);
-                               get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                               group.cancel();
-                               return Smach::RESULT_ERROR;
-                       }
-                       layer->set_description(get_id()+_(" Region"));
-               }
-
-               if(get_feather())
-               {
-                       layer->set_param("feather",get_feather());
-                       get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
-               }
-               assert(layer);
-               //layer->set_description(strprintf("Stroke %d",number));
-               //get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
-               if (shift_origin)
-                       get_canvas_interface()->
-                         change_value(synfigapp::ValueDesc(layer,"origin"),shift_origin_vector);
-
-               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-
-               assert(action);
-
-               action->set_param("canvas",get_canvas());
-               action->set_param("canvas_interface",get_canvas_interface());
-               action->set_param("layer",layer);
-               if(!action->set_param("param",String("bline")))
-                       synfig::error("LayerParamConnect didn't like \"param\"");
-               if(!action->set_param("value_node",ValueNode::Handle(value_node)))
-                       synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-               if(!get_canvas_interface()->get_instance()->perform_action(action))
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                       group.cancel();
-                       increment_id();
-                       //refresh_ducks();
-                       return Smach::RESULT_ERROR;
-               }
-               layer_list.push_back(layer);
-               get_canvas_view()->get_selection_manager()->set_selected_layers(layer_list);
-               //refresh_ducks();
-       }
-
-       increment_id();
-       return Smach::RESULT_ACCEPT;
-}
-
-#ifdef _DEBUG
-static void
-debug_show_vertex_list(int iteration, std::list<synfigapp::ValueDesc>& vertex_list,
-                                          std::string title, int current)
-{
-       std::list<synfigapp::ValueDesc>::iterator i = vertex_list.begin();
-       printf("\n%s\n  ----- iter %d : ", title.c_str(), iteration);
-       int c = 0;
-       synfig::LinkableValueNode::Handle last = 0;
-       int start = -1;
-       int index;
-       int prev;
-       int dir = 0;
-       bool started = false;
-       for(;i!=vertex_list.end();i++,c++)
-       {
-               synfigapp::ValueDesc value_desc(*i);
-
-               if (value_desc.parent_is_value_node()) {
-                       if(value_desc.parent_is_linkable_value_node())
-                       {
-                               index = value_desc.get_index();
-                               // printf("<%d>", index);
-                               if (last == synfig::LinkableValueNode::Handle::cast_reinterpret(value_desc.get_parent_value_node()))
-                               {
-                                       // printf("\n%s:%d\n", __FILE__, __LINE__);
-                                       if (start != -1)
-                                       {
-                                               // printf("\n%s:%d\n", __FILE__, __LINE__);
-                                               if (c == current)
-                                               {
-                                                       // printf("\n%s:%d\n", __FILE__, __LINE__);
-                                                       if (dir)
-                                                       {
-                                                               if (started) printf(", "); else started = true;
-                                                               printf("%d--%d", start, prev);
-                                                       }
-                                                       else
-                                                       {
-                                                               if (started) printf(", "); else started = true;
-                                                               printf("%d", start);
-                                                       }
-                                                       printf(", *%d*", index);
-                                                       start = -1;
-                                               }
-                                               else if (dir == 0)
-                                               {
-                                                       // printf("\n%s:%d\n", __FILE__, __LINE__);
-                                                       if (index == start + 1)
-                                                       {
-                                                               // printf("\n%s:%d\n", __FILE__, __LINE__);
-                                                               dir = 1;
-                                                               prev = index;
-                                                       }
-                                                       else if (index == start - 1)
-                                                       {
-                                                               // printf("\n%s:%d\n", __FILE__, __LINE__);
-                                                               dir = -1;
-                                                               prev = index;
-                                                       }
-                                                       else
-                                                       {
-                                                               if (started) printf(", "); else started = true;
-                                                               printf("%d", start);
-                                                               start = index;
-                                                       }
-                                               }
-                                               else if (index == prev + dir)
-                                               {
-                                                       // printf("\n%s:%d\n", __FILE__, __LINE__);
-                                                       prev = index;
-                                               }
-                                               else
-                                               {
-                                                       // printf("\n%s:%d\n", __FILE__, __LINE__);
-                                                       if (started) printf(", "); else started = true;
-                                                       if (prev != start)
-                                                               printf("%d--%d", start, prev);
-                                                       else
-                                                               printf("%d", start);
-                                                       // printf("\n%s:%d\n", __FILE__, __LINE__);
-                                                       start = index;
-                                                       dir = 0;
-                                               }
-                                       }
-                                       else
-                                       {
-                                               // printf("\n%s:%d\n", __FILE__, __LINE__);
-                                               if (c == current)
-                                               {
-                                                       if (started) printf(", "); else started = true;
-                                                       printf("*%d*", index);
-                                               }
-                                               else
-                                               {
-                                                       // printf("\n%s:%d\n", __FILE__, __LINE__);
-                                                       start = index;
-                                                       dir = 0;
-                                               }
-                                       }
-                               }
-                               else
-                               {
-                                       // printf("\n%s:%d\n", __FILE__, __LINE__);
-                                       if (last)
-                                       {
-                                               // printf("\n%s:%d\n", __FILE__, __LINE__);
-                                               if (start != -1)
-                                               {
-                                                       if (started) printf(", "); else started = true;
-                                                       if (dir != 0)
-                                                               printf("%d--%d", start, prev);
-                                                       else
-                                                               printf("%d", start);
-                                               }
-                                               // printf("\n%s:%d\n", __FILE__, __LINE__);
-                                               printf(") ");
-                                       }
-                                       // printf("\n%s:%d\n", __FILE__, __LINE__);
-                                       last = synfig::LinkableValueNode::Handle::cast_reinterpret(value_desc.get_parent_value_node());
-                                       printf("%d:(", synfig::LinkableValueNode::Handle::cast_reinterpret(value_desc.get_parent_value_node())->link_count());
-                                       started = false;
-                                       // printf("\n%s:%d\n", __FILE__, __LINE__);
-                                       if (c == current)
-                                       {
-                                               start = -1;
-                                               printf("*%d*", index);
-                                       }
-                                       else
-                                       {
-                                               // printf("\n%s:%d\n", __FILE__, __LINE__);
-                                               start = index;
-                                               dir = 0;
-                                       }
-                                       // printf("\n%s:%d\n", __FILE__, __LINE__);
-                               }
-                               // printf("\n%s:%d\n", __FILE__, __LINE__);
-                       }
-                       else if (last)
-                               if (last) printf("?!) ");
-               }
-               else
-               {
-                       last = 0;
-                       printf("? ");
-               }
-       }
-       if (last)
-       {
-               if (started) printf(", "); else started = true;
-               if (start != -1)
-               {
-                       if (dir != 0)
-                               printf("%d--%d", start, prev);
-                       else
-                               printf("%d", start);
-               }
-               printf(")");
-       }
-       printf("\n");
-}
-#else  // _DEBUG
-#define debug_show_vertex_list(a,b,c,d)
-#endif // _DEBUG
-
-Smach::event_result
-StateDraw_Context::new_region(std::list<synfig::BLinePoint> bline, synfig::Real radius)
-{
-       // Create the action group
-       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Define Region"));
-
-       std::list<synfigapp::ValueDesc> vertex_list;
-
-       printf("new_region with %zd bline points\n", bline.size());
-
-       // First we need to come up with a rough list of
-       // BLinePoints that we are going to be using to
-       // define our region.
-       {
-               std::list<synfig::BLinePoint>::iterator iter;
-               for(iter=bline.begin();iter!=bline.end();++iter)
-               {
-                       etl::handle<Duck> duck(get_work_area()->find_duck(iter->get_vertex(),0,Duck::TYPE_VERTEX));
-
-                       if(!duck)
-                       {
-                               synfig::info(__FILE__":%d: Nothing to enclose!",__LINE__);
-                               return Smach::RESULT_OK;
-                       }
-
-                       assert(duck->get_type()==Duck::TYPE_VERTEX);
-
-                       synfigapp::ValueDesc value_desc(duck->get_value_desc());
-
-                       if(!value_desc)
-                       {
-                               synfig::info(__FILE__":%d: Got a hit, but no ValueDesc on this duck",__LINE__);
-                               continue;
-                       }
-
-                       switch(value_desc.get_value_type())
-                       {
-                       case synfig::ValueBase::TYPE_BLINEPOINT:
-                               //if(vertex_list.empty() || value_desc!=vertex_list.back())
-                               vertex_list.push_back(value_desc);
-                               assert(vertex_list.back().is_valid());
-
-                               break;
-                       default:
-                               break;
-                       }
-               }
-       }
-
-       assert(vertex_list.back().is_valid());
-
-       printf("vertex list with %zd bline points\n", vertex_list.size());
-
-       // Remove any duplicates
-       {
-       }
-
-       ValueNode_BLine::Handle value_node_bline;
-
-       // Now we need to test for the trivial case,
-       // which is where all of the vertices
-       // come from one BLine.
-       if(vertex_list.front().parent_is_linkable_value_node())
-       {
-               bool trivial_case(true);
-               ValueNode::Handle trivial_case_value_node;
-
-               trivial_case_value_node=vertex_list.front().get_parent_value_node();
-
-               std::list<synfigapp::ValueDesc>::iterator iter;
-               for(iter=vertex_list.begin();iter!=vertex_list.end();++iter)
-               {
-                       if(trivial_case_value_node!=iter->get_parent_value_node())
-                       {
-                               trivial_case=false;
-                               break;
-                       }
-               }
-
-               // \todo - re-enable this code
-               if(trivial_case && false)
-               {
-                       synfig::info("all points are on the same bline, so just fill that line");
-                       value_node_bline=ValueNode_BLine::Handle::cast_dynamic(trivial_case_value_node);
-
-                       synfig::info("the line has %d vertices", value_node_bline->link_count());
-
-                       if(value_node_bline->link_count() <= 2)
-                       {
-                               synfig::info(__FILE__":%d: Vertex list too small to make region.",__LINE__);
-                               return Smach::RESULT_OK;
-                       }
-               }
-       }
-
-       if(!value_node_bline)
-               if(vertex_list.size()<=2)
-               {
-                       synfig::info(__FILE__":%d: Vertex list too small to make region.",__LINE__);
-                       return Smach::RESULT_OK;
-               }
-
-       // Now we need to clean the list of vertices up
-       // a bit. This includes inserting missing vertices
-       // and removing extraneous ones.
-       // We can do this in multiple passes.
-       if(!value_node_bline)
-       {
-               debug_show_vertex_list(0, vertex_list, "before shifting stuff", -1);
-               // rearrange the list so that the first and last node are on different blines
-               std::list<synfigapp::ValueDesc>::iterator iter, start;
-               ValueNode::Handle last_value_node = vertex_list.back().get_parent_value_node();
-               for(iter = vertex_list.begin(); iter!=vertex_list.end(); iter++)
-                       if (iter->get_parent_value_node() != last_value_node)
-                       {
-                               vertex_list.insert(vertex_list.end(), vertex_list.begin(), iter);
-                               vertex_list.erase(vertex_list.begin(), iter);
-                               break;
-                       }
-
-               debug_show_vertex_list(0, vertex_list, "before detecting direction and limits", -1);
-               // rearrange the list so that the first and last node are on different blines
-               iter = vertex_list.begin();
-               while (iter!=vertex_list.end())
-               {
-                       // make a note of which bline we're looking at
-                       ValueNode::Handle parent_value_node = iter->get_parent_value_node();
-                       start = iter;
-                       int points_in_line = synfig::LinkableValueNode::Handle::cast_reinterpret(parent_value_node)->link_count();
-                       bool looped = (*parent_value_node)(get_time()).get_loop();
-                       int this_index, last_index = iter->get_index();
-                       int min_index = last_index, max_index = last_index;
-                       bool whole;
-                       int direction = 0;
-
-                       // printf("there are %d points in this line - first is index %d\n", points_in_line, last_index);
-
-                       // while we're looking at the same bline, keep going
-                       iter++;
-                       while (iter != vertex_list.end() && iter->get_parent_value_node() == parent_value_node)
-                       {
-                               this_index = iter->get_index();
-                               // printf("index went from %d to %d\n", last_index, this_index);
-                               if (looped)
-                               {
-                                       if (this_index - last_index > points_in_line/2)
-                                               while (this_index - last_index > points_in_line/2)
-                                                       this_index -= points_in_line;
-                                       else if (last_index - this_index > points_in_line/2)
-                                               while (last_index - this_index > points_in_line/2)
-                                                       this_index += points_in_line;
-                               }
-
-                               if (this_index < min_index) min_index = this_index;
-                               if (this_index > max_index) max_index = this_index;
-
-                               // printf("so let's imagine index went from %d to %d\n", last_index, this_index);
-                               if (this_index > last_index)
-                                       direction++;
-                               else if (this_index < last_index)
-                                       direction--;
-
-                               last_index = this_index;
-                               iter++;
-                       }
-
-                       // printf("min %d and max %d\n", min_index, max_index);
-                       whole = max_index - min_index >= points_in_line;
-                       min_index = (min_index % points_in_line + points_in_line) % points_in_line;
-                       max_index = (max_index % points_in_line + points_in_line) % points_in_line;
-                       // they drew around a shape more than once - what's the start/end point?  does it matter?
-                       if (whole) min_index = max_index = (min_index + max_index) / 2;
-                       // printf("processed min %d max %d whole %d\n", min_index, max_index, whole);
-
-                       if (direction < 0)
-                       {
-                               if (whole)
-                               {
-                                       // printf("whole (down) (%d) ", min_index);
-                                       for (int i = min_index; i >= 0; i--)
-                                       {
-                                               // printf("%d ", i);
-                                               vertex_list.insert(start, synfigapp::ValueDesc(parent_value_node, i));
-                                       }
-                                       for (int i = points_in_line - 1; i >= min_index; i--)
-                                       {
-                                               // printf("%d ", i);
-                                               vertex_list.insert(start, synfigapp::ValueDesc(parent_value_node, i));
-                                       }
-                               }
-                               else
-                               {
-                                       // printf("part (down) (%d -> %d) ", max_index, min_index);
-                                       for (int i = max_index; i != min_index; i--)
-                                       {
-                                               if (i == -1) i = points_in_line - 1;
-                                               // printf("%d ", i);
-                                               vertex_list.insert(start, synfigapp::ValueDesc(parent_value_node, i));
-                                       }
-                                       vertex_list.insert(start, synfigapp::ValueDesc(parent_value_node, min_index));
-                               }
-                       }
-                       else
-                       {
-                               if (whole)
-                               {
-                                       // printf("whole (%d) ", min_index);
-                                       for (int i = min_index; i < points_in_line; i++)
-                                       {
-                                               // printf("%d ", i);
-                                               vertex_list.insert(start, synfigapp::ValueDesc(parent_value_node, i));
-                                       }
-                                       for (int i = 0; i <= min_index; i++)
-                                       {
-                                               // printf("%d ", i);
-                                               vertex_list.insert(start, synfigapp::ValueDesc(parent_value_node, i));
-                                       }
-                               }
-                               else
-                               {
-                                       // printf("part (%d -> %d) ", min_index, max_index);
-                                       for (int i = min_index; i != max_index; i++)
-                                       {
-                                               if (i == points_in_line) i = 0;
-                                               // printf("%d ", i);
-                                               vertex_list.insert(start, synfigapp::ValueDesc(parent_value_node, i));
-                                       }
-                                       vertex_list.insert(start, synfigapp::ValueDesc(parent_value_node, max_index));
-                               }
-                       }
-                       // printf("\n");
-                       // debug_show_vertex_list(0, vertex_list, "after insert", -1);
-                       vertex_list.erase(start, iter);
-                       // debug_show_vertex_list(0, vertex_list, "after delete", -1);
-               }
-
-               debug_show_vertex_list(0, vertex_list, "continuous vertices", -1);
-
-               // \todo reenable or delete this section
-               int i=100;
-               for(bool done=false;!done && i<30;i++)
-               {
-                       debug_show_vertex_list(i, vertex_list, "in big loop", -1);
-
-                       // Set done to "true" for now. If
-                       // any updates are performed, we will
-                       // change it back to false.
-                       done=true;
-
-                       std::list<synfigapp::ValueDesc>::iterator prev,next;
-                       prev=vertex_list.end();prev--;  // Set prev to the last ValueDesc
-                       next=vertex_list.begin();
-                       iter=next++; // Set iter to the first value desc, and next to the second
-
-                       int current = 0;
-                       for(;iter!=vertex_list.end();prev=iter,iter++,next++,current++)
-                       {
-                               // we need to be able to erase(next) and can't do that if next is end()
-                               if (next == vertex_list.end()) next = vertex_list.begin();
-                               debug_show_vertex_list(i, vertex_list, "in loop around vertices", current);
-                               synfigapp::ValueDesc value_prev(*prev);
-                               synfigapp::ValueDesc value_desc(*iter);
-                               synfigapp::ValueDesc value_next(*next);
-
-                               assert(value_desc.is_valid());
-                               assert(value_next.is_valid());
-                               assert(value_prev.is_valid());
-
-                               // synfig::info("-------");
-                               // synfig::info(__FILE__":%d: value_prev 0x%08X:%d",__LINE__,value_prev.get_parent_value_node().get(),value_prev.get_index());
-                               // synfig::info(__FILE__":%d: value_desc 0x%08X:%d",__LINE__,value_desc.get_parent_value_node().get(),value_desc.get_index());
-                               // synfig::info(__FILE__":%d: value_next 0x%08X:%d",__LINE__,value_next.get_parent_value_node().get(),value_next.get_index());
-
-                               /*
-                                 if(value_prev.parent_is_value_node() && value_desc.parent_is_value_node() && value_next.parent_is_value_node())
-                                 {
-                                 // Remove random extraneous vertices
-                                 if(value_prev.get_parent_value_node()==value_next.get_parent_value_node() &&
-                                 value_prev.get_parent_value_node()!=value_desc.get_parent_value_node())
-                                 {
-                                 vertex_list.erase(iter);
-                                 done=false;
-                                 break;
-                                 }
-                                 }
-                               */
-
-                               // // Remove duplicate vertices
-
-                               // // if previous is the same as current or
-                               // //    current is the same as next, remove current
-                               // if(value_prev.get_value_node()==value_desc.get_value_node() ||
-                               //    value_desc.get_value_node()==value_next.get_value_node())
-                               // {
-                               //      vertex_list.erase(iter);
-                               //      done=false;
-                               //      printf("erased node - i = %d\n", i);
-                               //      break;
-                               // }
-
-                               // // if previous is the same as next, remove previous?  or next?
-                               // if(value_prev.get_value_node()==value_next.get_value_node())
-                               // {
-                               //      vertex_list.erase(next);
-                               //      // vertex_list.erase(prev);
-                               //      done=false;
-                               //      printf("erased node - i = %d\n", i);
-                               //      break;
-                               // }
-
-                               // if 'this' and 'next' both have parents
-                               if (value_desc.parent_is_value_node() && value_next.parent_is_value_node())
-                               {
-                                       // if they are both on the same bline - this has been handled by new code above
-                                       if (value_desc.get_parent_value_node() == value_next.get_parent_value_node())
-                                       {
-                                               // // if (next != vertex_list.end())
-                                               // {
-                                               //      printf("parent loop is %d and node loop is ??\n",
-                                               //                 (*(value_desc.get_parent_value_node()))(get_time()).get_loop()
-                                               //                 // value_desc.get_value_node().get_loop(),
-                                               //              );
-                                               //
-                                               //      // Fill in missing vertices
-                                               //      // \todo take loops into account: seeing (15, 2, 3, 4) probably means that (0, 1) is missing, not 14 through 3
-                                               //      if(value_desc.get_index()<value_next.get_index()-1)
-                                               //      {
-                                               //              debug_show_vertex_list(i, vertex_list,
-                                               //                                                         strprintf("same parent, different points this %d < next-1 %d",
-                                               //                                                                               value_desc.get_index(), ((value_next.get_index()-1))),
-                                               //                                                         current);
-                                               //              for (int index = value_desc.get_index()+1; index < value_next.get_index(); index++)
-                                               //              {
-                                               //                      printf("inserting up %d\n", index);
-                                               //                      vertex_list.insert(next, synfigapp::ValueDesc(value_desc.get_parent_value_node(), index));
-                                               //              }
-                                               //              debug_show_vertex_list(i, vertex_list, "new list", current);
-                                               //              done=false;
-                                               //              break;
-                                               //      }
-                                               //      if(value_next.get_index()<value_desc.get_index()-1)
-                                               //      {
-                                               //              debug_show_vertex_list(i, vertex_list,
-                                               //                                                         strprintf("same parent, different points next %d < this-1 %d",
-                                               //                                                                               value_next.get_index(), ((value_desc.get_index()-1))),
-                                               //                                                         current);
-                                               //              for (int index = value_desc.get_index()-1; index > value_next.get_index(); index--)
-                                               //              {
-                                               //                      printf("inserting down %d\n", index);
-                                               //                      vertex_list.insert(next, synfigapp::ValueDesc(value_desc.get_parent_value_node(), index));
-                                               //              }
-                                               //              debug_show_vertex_list(i, vertex_list, "new list", current);
-                                               //              done=false;
-                                               //              break;
-                                               //      }
-                                               // }
-                                       }
-                                       // 'this' and 'next' have different parents
-                                       else
-                                       {
-                                               ValueNode::Handle v1 = value_desc.get_value_node();
-                                               ValueNode::Handle v2 = value_desc.get_parent_value_node();
-                                               if (v1 == v2)
-                                                       printf("same\n");
-                                               else
-                                                       printf("different\n");
-
-                                               if (value_desc.get_value_node() != value_next.get_value_node())
-                                               {
-                                                       // Ensure that connections between blines are properly connected
-                                                       BLinePoint vertex(value_desc.get_value(get_time()).get(BLinePoint()));
-                                                       BLinePoint vertex_next(value_next.get_value(get_time()).get(BLinePoint()));
-
-                                                       //synfig::info("--------");
-                                                       //synfig::info(__FILE__":%d: vertex: [%f, %f]",__LINE__,vertex.get_vertex()[0],vertex.get_vertex()[1]);
-                                                       //synfig::info(__FILE__":%d: vertex_next: [%f, %f]",__LINE__,vertex_next.get_vertex()[0],vertex_next.get_vertex()[1]);
-
-                                                       // if this vertex is close to the next one, replace this vertex with a new one
-                                                       // and erase the next one
-                                                       printf("this point is %5.2f from the next point - compare with %5.2f\n",
-                                                                  (vertex.get_vertex()-vertex_next.get_vertex()).mag_squared(),
-                                                                  radius*radius);
-                                                       if((vertex.get_vertex()-vertex_next.get_vertex()).mag_squared()<radius*radius)
-                                                       {
-                                                               printf("in one - it's close\n");
-                                                               ValueNode_Composite::Handle value_node;
-                                                               ValueNode_Composite::Handle value_node_next;
-                                                               value_node=ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node().clone());
-                                                               value_node_next=ValueNode_Composite::Handle::cast_dynamic(value_next.get_value_node().clone());
-                                                               if(!value_node || !value_node_next)
-                                                               {
-                                                                       synfig::info(__FILE__":%d: Unable to properly connect blines.",__LINE__);
-                                                                       continue;
-                                                               }
-                                                               // \todo if next isn't split, don't we want to copy its 'Tangent 1' instead?
-                                                               value_node->set_link("t2",value_node_next->get_link("t2"));
-                                                               value_node->set_link("split",ValueNode_Const::create(true));
-
-                                                               // get_canvas_interface()->auto_export(value_node);
-                                                               printf("exporting\n");
-                                                               get_canvas_interface()->add_value_node(value_node,value_node->get_id() + strprintf("foo %d", rand()));
-
-                                                               assert(value_node->is_exported());
-                                                               // replace 'this' with the new valuenode
-                                                               *iter=synfigapp::ValueDesc(get_canvas(),value_node->get_id());
-                                                               printf("erasing next\n");
-                                                               printf("erasing next point\n");
-                                                               vertex_list.erase(next);
-                                                               done=false;
-                                                               break;
-                                                       } // this vertex isn't close to the next one
-                                                       else if (value_prev.parent_is_value_node())
-                                                       {
-                                                               printf("in two - it's far\n");
-                                                               // \todo this only makes sense if prev is on the same bline
-                                                               printf("this is index %d\n", value_desc.get_index());
-                                                               printf("prev is index %d\n", value_prev.get_index());
-                                                               bool positive_trend(value_desc.get_index()>value_prev.get_index());
-
-                                                               if(positive_trend)
-                                                               {
-                                                                       printf("positive trend\n");
-                                                                       printf("comparing index %d < link_count()-1 = %d-1 = %d\n",
-                                                                                  value_desc.get_index(),
-                                                                                  LinkableValueNode::Handle::cast_static(value_desc.get_parent_value_node())->link_count(),
-                                                                                  LinkableValueNode::Handle::cast_static(value_desc.get_parent_value_node())->link_count()-1);
-                                                                       if (value_desc.get_index()<LinkableValueNode::Handle::cast_static(value_desc.get_parent_value_node())->link_count()-1)
-                                                                       {
-                                                                               printf("in two - b\n");
-                                                                               printf("inserting node with index %d\n", value_desc.get_index()+1);
-                                                                               vertex_list.insert(next,
-                                                                                                                  synfigapp::ValueDesc(value_desc.get_parent_value_node(),
-                                                                                                                                                               value_desc.get_index()+1));
-                                                                               done=false;
-                                                                               break;
-                                                                       }
-                                                               }
-                                                               else // !positive_trend
-                                                               {
-                                                                       printf("negative trend\n");
-                                                                       if(value_desc.get_index()>0)
-                                                                       {
-                                                                               printf("in two - a\n");
-                                                                               printf("inserting node on this line with index %d\n",
-                                                                                          value_desc.get_index()-1);
-                                                                               vertex_list.insert(next,
-                                                                                                                  synfigapp::ValueDesc(value_desc.get_parent_value_node(),
-                                                                                                                                                               value_desc.get_index()-1));
-                                                                               done=false;
-                                                                               break;
-                                                                       }
-                                                               }
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-               }
-
-               if(vertex_list.size()<=2)
-               {
-                       synfig::info(__FILE__":%d: Vertex list too small to make region.",__LINE__);
-                       return Smach::RESULT_OK;
-               }
-
-               debug_show_vertex_list(i, vertex_list, "finished tidying list", -1);
-       }
-
-       // If we aren't the trivial case,
-       // then go ahead and create the new
-       // BLine value node
-       if(!value_node_bline)
-       {
-               synfig::info("not all points are on the same bline");
-               value_node_bline=ValueNode_BLine::create();
-
-               std::list<synfigapp::ValueDesc>::iterator iter;
-               for(iter=vertex_list.begin();iter!=vertex_list.end();++iter)
-               {
-                       // Ensure that the vertex is exported.
-                       get_canvas_interface()->auto_export(*iter);
-
-                       value_node_bline->add(iter->get_value_node());
-                       //value_node_bline->add(ValueNode_BLine::ListEntry(iter->get_value_node()));
-               }
-
-               value_node_bline->set_loop(true);
-       }
-
-       get_canvas_interface()->auto_export(value_node_bline);
-
-       // Now we create the region layer
-       // Create the layer
-       {
-               Layer::Handle layer;
-               Canvas::Handle canvas(get_canvas_view()->get_canvas());
-               int depth(0);
-
-               // we are temporarily using the layer to hold something
-               layer=get_canvas_view()->get_selection_manager()->get_selected_layer();
-               if(layer)
-               {
-                       depth=layer->get_depth();
-                       canvas=layer->get_canvas();
-               }
-
-               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
-               layer=get_canvas_interface()->add_layer_to("region",canvas,depth);
-               if (!layer)
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                       group.cancel();
-                       return Smach::RESULT_ERROR;
-               }
-
-               if(get_feather())
-               {
-                       layer->set_param("feather",get_feather());
-                       get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
-               }
-               get_canvas_interface()->signal_layer_param_changed()(layer,"color");
-
-               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-
-               assert(action);
-
-               action->set_param("canvas",get_canvas());
-               action->set_param("canvas_interface",get_canvas_interface());
-               action->set_param("layer",layer);
-               if(!action->set_param("param",String("bline")))
-                       synfig::error("LayerParamConnect didn't like \"param\"");
-               if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
-                       synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-               if(!get_canvas_interface()->get_instance()->perform_action(action))
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
-                       group.cancel();
-                       return Smach::RESULT_ERROR;
-               }
-               get_canvas_view()->get_selection_manager()->set_selected_layer(layer);
-       }
-
-       return Smach::RESULT_ACCEPT;
-}
-
-void
-StateDraw_Context::refresh_ducks()
-{
-       get_canvas_view()->queue_rebuild_ducks();
-/*
-       get_work_area()->clear_ducks();
-
-
-       std::list< etl::smart_ptr<std::list<synfig::Point> > >::iterator iter;
-
-       for(iter=stroke_list.begin();iter!=stroke_list.end();++iter)
-       {
-               get_work_area()->add_stroke(*iter);
-       }
-
-       get_work_area()->queue_draw();
-*/
-}
-
-
-Smach::event_result
-StateDraw_Context::extend_bline_from_begin(ValueNode_BLine::Handle value_node,std::list<synfig::BLinePoint> bline,bool complete_loop)
-{
-       // Create the action group
-       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Extend BLine"));
-
-       if (complete_loop)
-       {
-               synfigapp::Action::Handle action(synfigapp::Action::create("ValueNodeDynamicListLoop"));
-               assert(action);
-
-               action->set_param("canvas",get_canvas());
-               action->set_param("canvas_interface",get_canvas_interface());
-               action->set_param("value_node",ValueNode::Handle(value_node));
-
-               if(!get_canvas_interface()->get_instance()->perform_action(action))
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to set loop for bline"));
-                       group.cancel();
-                       return Smach::RESULT_ERROR;
-               }
-       }
-
-       std::list<synfig::BLinePoint>::reverse_iterator iter;
-       for(iter=bline.rbegin();!(iter==bline.rend());++iter)
-       {
-               ValueNode_Composite::Handle composite(ValueNode_Composite::create(*iter));
-
-               synfigapp::Action::Handle action(synfigapp::Action::create("ValueNodeDynamicListInsert"));
-
-               assert(action);
-               synfigapp::ValueDesc value_desc(value_node,0);
-
-               action->set_param("canvas",get_canvas());
-               action->set_param("canvas_interface",get_canvas_interface());
-               action->set_param("value_desc",value_desc);
-               if(!action->set_param("item",ValueNode::Handle(composite)))
-                       synfig::error("ACTION didn't like \"item\"");
-
-               if(!get_canvas_interface()->get_instance()->perform_action(action))
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to insert item"));
-                       group.cancel();
-                       //refresh_ducks();
-                       return Smach::RESULT_ERROR;
-               }
-       }
-       last_stroke=value_node;
-       return Smach::RESULT_ACCEPT;
-}
-
-Smach::event_result
-StateDraw_Context::extend_bline_from_end(ValueNode_BLine::Handle value_node,std::list<synfig::BLinePoint> bline,bool complete_loop)
-{
-       // Create the action group
-       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Extend BLine"));
-
-       if (complete_loop)
-       {
-               synfigapp::Action::Handle action(synfigapp::Action::create("ValueNodeDynamicListLoop"));
-               assert(action);
-
-               action->set_param("canvas",get_canvas());
-               action->set_param("canvas_interface",get_canvas_interface());
-               action->set_param("value_node",ValueNode::Handle(value_node));
-
-               if(!get_canvas_interface()->get_instance()->perform_action(action))
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to set loop for bline"));
-                       group.cancel();
-                       return Smach::RESULT_ERROR;
-               }
-       }
-
-       std::list<synfig::BLinePoint>::iterator iter;
-       for(iter=bline.begin();iter!=bline.end();++iter)
-       {
-               ValueNode_Composite::Handle composite(ValueNode_Composite::create(*iter));
-
-               synfigapp::Action::Handle action(synfigapp::Action::create("ValueNodeDynamicListInsert"));
-
-               assert(action);
-               synfigapp::ValueDesc value_desc(value_node,value_node->link_count());
-
-               action->set_param("canvas",get_canvas());
-               action->set_param("canvas_interface",get_canvas_interface());
-               action->set_param("value_desc",value_desc);
-               if(!action->set_param("item",ValueNode::Handle(composite)))
-                       synfig::error("ACTION didn't like \"item\"");
-
-               if(!get_canvas_interface()->get_instance()->perform_action(action))
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to insert item"));
-                       group.cancel();
-                       //refresh_ducks();
-                       return Smach::RESULT_ERROR;
-               }
-       }
-       last_stroke=value_node;
-       return Smach::RESULT_ACCEPT;
-}
-
-void
-StateDraw_Context::reverse_bline(std::list<synfig::BLinePoint> &bline)
-{
-       int i;
-
-       std::list<synfig::BLinePoint>::iterator iter,eiter;
-       iter=bline.begin();
-       eiter=bline.end();
-       eiter--;
-       for(i=0;i<(int)bline.size()/2;++iter,--eiter,i++)
-       {
-               iter_swap(iter,eiter);
-               iter->reverse();
-               eiter->reverse();
-       }
-}
-
-Smach::event_result
-StateDraw_Context::fill_last_stroke_and_unselect_other_layers()
-{
-       if(!last_stroke)
-               return Smach::RESULT_OK;
-
-       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Fill Stroke"));
-
-       Layer::Handle layer;
-
-       get_canvas_interface()->auto_export(last_stroke);
-
-       synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
-       Canvas::Handle canvas(get_canvas_view()->get_canvas());
-       int depth(0);
-
-       layer=get_canvas_view()->get_selection_manager()->get_selected_layer();
-       if(layer)
-       {
-               depth=layer->get_depth();
-               canvas=layer->get_canvas();
-       }
-
-       get_canvas_interface()->get_selection_manager()->clear_selected_layers();
-       layer=get_canvas_interface()->add_layer_to("region", canvas, depth);
-       if (!layer) return Smach::RESULT_ERROR;
-       layer->set_description(last_stroke_id + _(" Region"));
-
-       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-
-       assert(action);
-
-       action->set_param("canvas",get_canvas());
-       action->set_param("canvas_interface",get_canvas_interface());
-       action->set_param("layer",layer);
-       if(!action->set_param("param",String("bline")))
-               synfig::error("LayerParamConnect didn't like \"param\"");
-       if(!action->set_param("value_node",ValueNode::Handle(last_stroke)))
-               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-       if(!get_canvas_interface()->get_instance()->perform_action(action))
-       {
-               get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
-               group.cancel();
-               return Smach::RESULT_OK;
-       }
-       get_canvas_view()->get_selection_manager()->set_selected_layer(layer);
-       return Smach::RESULT_OK;
-}
-
-void
-StateDraw_Context::fill_last_stroke()
-{
-       if(!last_stroke)
-               return;
-
-       synfigapp::SelectionManager::LayerList layer_list = get_canvas_view()->get_selection_manager()->get_selected_layers();
-       fill_last_stroke_and_unselect_other_layers();
-       get_canvas_view()->get_selection_manager()->set_selected_layers(layer_list);
-}
diff --git a/synfig-studio/src/gtkmm/state_draw.h b/synfig-studio/src/gtkmm/state_draw.h
deleted file mode 100644 (file)
index 2c074a5..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_draw.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_ROTOSCOPE_H
-#define __SYNFIG_STUDIO_STATE_ROTOSCOPE_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 StateDraw_Context;
-
-class StateDraw : public Smach::state<StateDraw_Context>
-{
-public:
-       StateDraw();
-       ~StateDraw();
-}; // END of class StateDraw
-
-extern StateDraw state_draw;
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/state_eyedrop.cpp b/synfig-studio/src/gtkmm/state_eyedrop.cpp
deleted file mode 100644 (file)
index dcd57a1..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_eyedrop.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "state_eyedrop.h"
-#include "state_normal.h"
-#include "workarea.h"
-#include <synfig/context.h>
-#include "app.h"
-#include "dialog_color.h"
-#include "event_mouse.h"
-#include "event_layerclick.h"
-#include "toolbox.h"
-#include "canvasview.h"
-#include <synfigapp/main.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 ========================================================= */
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-class studio::StateEyedrop_Context
-{
-       CanvasView *canvas_view;
-       CanvasView::IsWorking is_working;
-
-public:
-       StateEyedrop_Context(CanvasView *canvas_view);
-       ~StateEyedrop_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_workarea_mouse_button_down_handler(const Smach::event& x);
-
-}; // END of class StateEyedrop_Context
-
-/* === G L O B A L S ======================================================= */
-
-StateEyedrop studio::state_eyedrop;
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-StateEyedrop::StateEyedrop():
-       Smach::state<StateEyedrop_Context>("eyedrop")
-{
-       insert(event_def(EVENT_LAYER_SELECTION_CHANGED,&StateEyedrop_Context::event_stop_handler));
-       insert(event_def(EVENT_STOP,&StateEyedrop_Context::event_stop_handler));
-       insert(event_def(EVENT_REFRESH,&StateEyedrop_Context::event_refresh_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StateEyedrop_Context::event_workarea_mouse_button_down_handler));
-}
-
-StateEyedrop::~StateEyedrop()
-{
-}
-
-StateEyedrop_Context::StateEyedrop_Context(CanvasView *canvas_view):
-       canvas_view(canvas_view),
-       is_working(*canvas_view)
-{
-       synfig::info("Entered Eyedrop State");
-       canvas_view->work_area->set_cursor(Gdk::Cursor(Gdk::CROSSHAIR));
-
-       App::toolbox->refresh();
-}
-
-StateEyedrop_Context::~StateEyedrop_Context()
-{
-       synfig::info("Left Eyedrop State");
-       canvas_view->work_area->reset_cursor();
-       App::toolbox->refresh();
-}
-
-Smach::event_result
-StateEyedrop_Context::event_stop_handler(const Smach::event& /*x*/)
-{
-       //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;
-}
-
-Smach::event_result
-StateEyedrop_Context::event_refresh_handler(const Smach::event& /*x*/)
-{
-       synfig::info("STATE EYEDROP: Received Refresh Event");
-       canvas_view->work_area->queue_render_preview();
-       return Smach::RESULT_ACCEPT;
-}
-
-Smach::event_result
-StateEyedrop_Context::event_workarea_mouse_button_down_handler(const Smach::event& x)
-{
-       synfig::info("STATE EYEDROP: Received mouse button down Event");
-       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
-       if(event.button==BUTTON_LEFT)
-       {
-               Color color(canvas_view->get_canvas()->get_context().get_color(event.pos));
-               synfigapp::Main::set_outline_color(color);
-               studio::App::dialog_color->set_color(color);
-               return Smach::RESULT_ACCEPT;
-       }
-       return Smach::RESULT_OK;
-}
diff --git a/synfig-studio/src/gtkmm/state_eyedrop.h b/synfig-studio/src/gtkmm/state_eyedrop.h
deleted file mode 100644 (file)
index 4a90021..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_eyedrop.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_STATE_EYEDROP_H
-#define __SYNFIG_STATE_EYEDROP_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 StateEyedrop_Context;
-
-class StateEyedrop : public Smach::state<StateEyedrop_Context>
-{
-public:
-       StateEyedrop();
-       ~StateEyedrop();
-}; // END of class StateEyedrop
-
-extern StateEyedrop state_eyedrop;
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/state_fill.cpp b/synfig-studio/src/gtkmm/state_fill.cpp
deleted file mode 100644 (file)
index f4df2ba..0000000
+++ /dev/null
@@ -1,182 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_fill.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "state_fill.h"
-#include "state_normal.h"
-#include "workarea.h"
-#include <synfig/context.h>
-#include "app.h"
-#include "dialog_color.h"
-#include "event_mouse.h"
-#include "event_layerclick.h"
-#include "toolbox.h"
-#include "canvasview.h"
-#include <synfigapp/main.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 ========================================================= */
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-class studio::StateFill_Context
-{
-       CanvasView *canvas_view;
-       CanvasView::IsWorking is_working;
-
-public:
-       StateFill_Context(CanvasView *canvas_view);
-       ~StateFill_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_workarea_layer_clicked_handler(const Smach::event& x);
-
-
-       etl::handle<CanvasView> get_canvas_view()const{return canvas_view;}
-       etl::handle<synfigapp::CanvasInterface> 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();}
-
-
-}; // END of class StateFill_Context
-
-/* === G L O B A L S ======================================================= */
-
-StateFill studio::state_fill;
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-StateFill::StateFill():
-       Smach::state<StateFill_Context>("fill")
-{
-       insert(event_def(EVENT_LAYER_SELECTION_CHANGED,&StateFill_Context::event_stop_handler));
-       insert(event_def(EVENT_STOP,&StateFill_Context::event_stop_handler));
-       insert(event_def(EVENT_REFRESH,&StateFill_Context::event_refresh_handler));
-       insert(event_def(EVENT_WORKAREA_LAYER_CLICKED,&StateFill_Context::event_workarea_layer_clicked_handler));
-}
-
-StateFill::~StateFill()
-{
-}
-
-StateFill_Context::StateFill_Context(CanvasView *canvas_view):
-       canvas_view(canvas_view),
-       is_working(*canvas_view)
-{
-       synfig::info("Entered Fill State");
-       canvas_view->work_area->set_cursor(Gdk::CROSSHAIR);
-
-       App::toolbox->refresh();
-}
-
-StateFill_Context::~StateFill_Context()
-{
-       synfig::info("Left Fill State");
-       canvas_view->work_area->reset_cursor();
-       App::toolbox->refresh();
-}
-
-Smach::event_result
-StateFill_Context::event_stop_handler(const Smach::event& /*x*/)
-{
-       synfig::info("STATE FILL: Received Stop Event");
-       //throw Smach::egress_exception();
-       throw &state_normal;
-       return Smach::RESULT_OK;
-//     canvas_view->get_smach().pop_state();
-//     return Smach::RESULT_ACCEPT;
-}
-
-Smach::event_result
-StateFill_Context::event_refresh_handler(const Smach::event& /*x*/)
-{
-       synfig::info("STATE FILL: Received Refresh Event");
-       canvas_view->work_area->queue_render_preview();
-       return Smach::RESULT_ACCEPT;
-}
-
-Smach::event_result
-StateFill_Context::event_workarea_layer_clicked_handler(const Smach::event& x)
-{
-       synfig::info("STATE FILL: Received layer clicked Event");
-       const EventLayerClick& event(*reinterpret_cast<const EventLayerClick*>(&x));
-
-       if(!event.layer)
-       {
-               get_canvas_view()->get_ui_interface()->warning(_("No layer here"));
-               return Smach::RESULT_ACCEPT;
-       }
-
-
-       //synfigapp::Action::Handle action(synfigapp::Action::create("ValueDescSet"));
-       synfigapp::ValueDesc value_desc(event.layer,"color");
-
-       if(!get_canvas_interface()->change_value(value_desc,ValueBase(synfigapp::Main::get_fill_color())))
-       {
-               get_canvas_view()->get_ui_interface()->warning(_("Unable to set layer color"));
-               return Smach::RESULT_ERROR;
-       }
-       /*
-       assert(action);
-
-       action->set_param("canvas",get_canvas());
-       action->set_param("canvas_interface",get_canvas_interface());
-       action->set_param("value_desc",value_desc);
-       action->set_param("time",get_canvas_interface()->get_time());
-       //action->set_param("layer",event.layer);
-       //if(!action->set_param("param",String("color")))
-       //      synfig::error("LayerParamConnect didn't like \"param\"");
-       if(!action->set_param("new_value",ValueBase(synfigapp::Main::get_fill_color())))
-               synfig::error("LayerParamConnect didn't like \"fill_color\"");
-
-       if(!get_canvas_interface()->get_instance()->perform_action(action))
-       {
-               get_canvas_view()->get_ui_interface()->warning(_("Unable to set layer color"));
-               return Smach::RESULT_ERROR;
-       }
-       get_canvas_view()->get_ui_interface()->task(_("Idle"));
-       */
-       return Smach::RESULT_ACCEPT;
-}
diff --git a/synfig-studio/src/gtkmm/state_fill.h b/synfig-studio/src/gtkmm/state_fill.h
deleted file mode 100644 (file)
index 349a1ce..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_fill.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_STATE_FILL_H
-#define __SYNFIG_STATE_FILL_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 StateFill_Context;
-
-class StateFill : public Smach::state<StateFill_Context>
-{
-public:
-       StateFill();
-       ~StateFill();
-}; // END of class StateFill
-
-extern StateFill state_fill;
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/state_gradient.cpp b/synfig-studio/src/gtkmm/state_gradient.cpp
deleted file mode 100644 (file)
index 8e36214..0000000
+++ /dev/null
@@ -1,546 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_gradient.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 <config.h>
-#endif
-
-#include <gtkmm/dialog.h>
-#include <gtkmm/entry.h>
-
-#include <synfig/valuenode_dynamiclist.h>
-#include <synfigapp/action_system.h>
-
-#include "state_gradient.h"
-#include "state_normal.h"
-#include "canvasview.h"
-#include "workarea.h"
-#include "app.h"
-
-#include <synfigapp/action.h>
-#include "event_mouse.h"
-#include "event_layerclick.h"
-#include "toolbox.h"
-#include "dialog_tooloptions.h"
-#include <gtkmm/optionmenu.h>
-#include "duck.h"
-
-#include "widget_enum.h"
-#include <synfigapp/main.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 ========================================================= */
-
-enum
-{
-       GRADIENT_INTERPOLATION_LINEAR=0,
-       GRADIENT_RADIAL=1,
-       GRADIENT_CONICAL=2,
-       GRADIENT_SPIRAL=3
-};
-
-/* === G L O B A L S ======================================================= */
-
-StateGradient studio::state_gradient;
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-class studio::StateGradient_Context : public sigc::trackable
-{
-       etl::handle<CanvasView> canvas_view_;
-       CanvasView::IsWorking is_working;
-
-       Duckmatic::Push duckmatic_push;
-
-       synfigapp::Settings& settings;
-
-       Point point_holder;
-
-       etl::handle<Duck> point2_duck;
-
-       void refresh_ducks();
-
-       bool prev_workarea_layer_status_;
-
-       Gtk::Table options_table;
-       Gtk::Entry entry_id;
-       Widget_Enum enum_type;
-#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
-       Widget_Enum     enum_blend;
-#endif // BLEND_METHOD_IN_TOOL_OPTIONS
-
-public:
-       synfig::String get_id()const { return entry_id.get_text(); }
-       void set_id(const synfig::String& x) { return entry_id.set_text(x); }
-
-       int get_type()const { return enum_type.get_value(); }
-       void set_type(int x) { return enum_type.set_value(x); }
-
-#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
-       int get_blend()const { return enum_blend.get_value(); }
-       void set_blend(int x) { return enum_blend.set_value(x); }
-#endif // BLEND_METHOD_IN_TOOL_OPTIONS
-
-       Smach::event_result event_stop_handler(const Smach::event& x);
-
-       Smach::event_result event_refresh_handler(const Smach::event& x);
-
-       Smach::event_result event_mouse_click_handler(const Smach::event& x);
-       Smach::event_result event_refresh_tool_options(const Smach::event& x);
-
-       void refresh_tool_options();
-
-       StateGradient_Context(CanvasView* canvas_view);
-
-       ~StateGradient_Context();
-
-       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
-       etl::handle<synfigapp::CanvasInterface> 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 on_user_click(synfig::Point point);
-       void load_settings();
-       void save_settings();
-       void reset();
-       void increment_id();
-
-       void make_gradient(const Point& p1, const Point& p2);
-       bool egress_on_selection_change;
-       Smach::event_result event_layer_selection_changed_handler(const Smach::event& /*x*/)
-       {
-               if(egress_on_selection_change)
-                       throw &state_normal; //throw Smach::egress_exception();
-               return Smach::RESULT_OK;
-       }
-
-};     // END of class StateGradient_Context
-
-/* === M E T H O D S ======================================================= */
-
-StateGradient::StateGradient():
-       Smach::state<StateGradient_Context>("gradient")
-{
-       insert(event_def(EVENT_LAYER_SELECTION_CHANGED,&StateGradient_Context::event_layer_selection_changed_handler));
-       insert(event_def(EVENT_STOP,&StateGradient_Context::event_stop_handler));
-       insert(event_def(EVENT_TABLES_SHOW,&StateGradient_Context::event_stop_handler));
-       insert(event_def(EVENT_REFRESH,&StateGradient_Context::event_refresh_handler));
-       insert(event_def(EVENT_REFRESH_DUCKS,&StateGradient_Context::event_refresh_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StateGradient_Context::event_mouse_click_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DRAG,&StateGradient_Context::event_mouse_click_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_UP,&StateGradient_Context::event_mouse_click_handler));
-       insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateGradient_Context::event_refresh_tool_options));
-}
-
-StateGradient::~StateGradient()
-{
-}
-
-void
-StateGradient_Context::load_settings()
-{
-       String value;
-
-       if(settings.get_value("gradient.id",value))
-               set_id(value);
-       else
-               set_id("Gradient");
-
-       if(settings.get_value("gradient.type",value))
-               set_type(atoi(value.c_str()));
-       else
-               set_type(GRADIENT_INTERPOLATION_LINEAR);
-
-#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
-       if(settings.get_value("gradient.blend",value))
-               set_blend(atoi(value.c_str()));
-       else
-               set_blend(Color::BLEND_COMPOSITE);
-#endif // BLEND_METHOD_IN_TOOL_OPTIONS
-}
-
-void
-StateGradient_Context::save_settings()
-{
-       settings.set_value("gradient.id",get_id().c_str());
-       settings.set_value("gradient.type",strprintf("%d",get_type()));
-#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
-       settings.set_value("gradient.blend",strprintf("%d",get_blend()));
-#endif // BLEND_METHOD_IN_TOOL_OPTIONS
-}
-
-void
-StateGradient_Context::reset()
-{
-       refresh_ducks();
-}
-
-void
-StateGradient_Context::increment_id()
-{
-       String id(get_id());
-       int number=1;
-       int digits=0;
-
-       if(id.empty())
-               id="Gradient";
-
-       // If there is a number
-       // already at the end of the
-       // id, then remove it.
-       if(id[id.size()-1]<='9' && id[id.size()-1]>='0')
-       {
-               // figure out how many digits it is
-               for (digits = 0;
-                        (int)id.size()-1 >= digits && id[id.size()-1-digits] <= '9' && id[id.size()-1-digits] >= '0';
-                        digits++)
-                       ;
-
-               String str_number;
-               str_number=String(id,id.size()-digits,id.size());
-               id=String(id,0,id.size()-digits);
-
-               number=atoi(str_number.c_str());
-       }
-       else
-       {
-               number=1;
-               digits=3;
-       }
-
-       number++;
-
-       // Add the number back onto the id
-       {
-               const String format(strprintf("%%0%dd",digits));
-               id+=strprintf(format.c_str(),number);
-       }
-
-       // Set the ID
-       set_id(id);
-}
-
-StateGradient_Context::StateGradient_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()),
-       prev_workarea_layer_status_(get_work_area()->get_allow_layer_clicks()),
-       entry_id()
-{
-       egress_on_selection_change=true;
-       // Set up the tool options dialog
-       options_table.attach(*manage(new Gtk::Label(_("Gradient Tool"))),       0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(entry_id,                                                                          0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       enum_type.set_param_desc(ParamDesc("type")
-               .set_local_name(_("Gradient Type"))
-               .set_description(_("Determines the type of Gradient used"))
-               .set_hint("enum")
-               .add_enum_value(GRADIENT_INTERPOLATION_LINEAR,"linear",_("Linear"))
-               .add_enum_value(GRADIENT_RADIAL,"radial",_("Radial"))
-               .add_enum_value(GRADIENT_CONICAL,"conical",_("Conical"))
-               .add_enum_value(GRADIENT_SPIRAL,"spiral",_("Spiral")));
-
-#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
-       enum_blend.set_param_desc(ParamDesc(Color::BLEND_COMPOSITE,"blend_method")
-               .set_local_name(_("Blend Method"))
-               .set_description(_("The blend method the gradient will use")));
-#endif // BLEND_METHOD_IN_TOOL_OPTIONS
-
-       load_settings();
-
-       options_table.attach(enum_type, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
-       options_table.attach(enum_blend, 0, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-#endif // BLEND_METHOD_IN_TOOL_OPTIONS
-
-       options_table.show_all();
-       refresh_tool_options();
-       App::dialog_tool_options->present();
-
-
-       // Turn off layer clicking
-       get_work_area()->set_allow_layer_clicks(false);
-
-       get_work_area()->set_cursor(Gdk::CROSSHAIR);
-
-       // clear out the ducks
-       get_work_area()->clear_ducks();
-
-       // Refresh the work area
-       get_work_area()->queue_draw();
-
-       get_work_area()->refresh_cursor();
-
-       // Hide the tables if they are showing
-       get_canvas_view()->hide_tables();
-
-       // Disable the time bar
-       //get_canvas_view()->set_sensitive_timebar(false);
-
-       // Connect a signal
-       //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateGradient_Context::on_user_click));
-
-       App::toolbox->refresh();
-}
-
-void
-StateGradient_Context::refresh_tool_options()
-{
-       App::dialog_tool_options->clear();
-       App::dialog_tool_options->set_widget(options_table);
-       App::dialog_tool_options->set_local_name(_("Gradient Tool"));
-       App::dialog_tool_options->set_name("gradient");
-}
-
-Smach::event_result
-StateGradient_Context::event_refresh_tool_options(const Smach::event& /*x*/)
-{
-       refresh_tool_options();
-       return Smach::RESULT_ACCEPT;
-}
-
-StateGradient_Context::~StateGradient_Context()
-{
-       save_settings();
-
-       // Restore layer clicking
-//     get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_);
-       get_work_area()->set_allow_layer_clicks(true);
-       get_work_area()->reset_cursor();
-
-       App::dialog_tool_options->clear();
-
-       // Enable the time bar
-       //get_canvas_view()->set_sensitive_timebar(true);
-
-       // Bring back the tables if they were out before
-       //if(prev_table_status)get_canvas_view()->show_tables();
-
-       // Refresh the work area
-       get_work_area()->queue_draw();
-
-       get_canvas_view()->queue_rebuild_ducks();
-
-       //get_canvas_view()->show_tables();
-
-       get_work_area()->refresh_cursor();
-
-       App::toolbox->refresh();
-}
-
-Smach::event_result
-StateGradient_Context::event_stop_handler(const Smach::event& /*x*/)
-{
-       //throw Smach::egress_exception();
-       throw &state_normal;
-       return Smach::RESULT_OK;
-}
-
-Smach::event_result
-StateGradient_Context::event_refresh_handler(const Smach::event& /*x*/)
-{
-       refresh_ducks();
-       return Smach::RESULT_ACCEPT;
-}
-
-void
-StateGradient_Context::make_gradient(const Point& _p1, const Point& _p2)
-{
-       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("New Gradient"));
-       synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
-       Layer::Handle layer;
-
-       Canvas::Handle canvas(get_canvas_view()->get_canvas());
-       int depth(0);
-
-       // we are temporarily using the layer to hold something
-       layer=get_canvas_view()->get_selection_manager()->get_selected_layer();
-       if(layer)
-       {
-               depth=layer->get_depth();
-               canvas=layer->get_canvas();
-       }
-       const synfig::TransformStack& transform(get_canvas_view()->get_curr_transform_stack());
-       const Point p1(transform.unperform(_p1));
-       const Point p2(transform.unperform(_p2));
-
-       switch(get_type())
-       {
-       case GRADIENT_INTERPOLATION_LINEAR:
-
-               layer=get_canvas_interface()->add_layer_to("linear_gradient",canvas,depth);
-               if (!layer)
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                       group.cancel();
-                       return;
-               }
-               layer->set_param("p1",p1);
-               get_canvas_interface()->signal_layer_param_changed()(layer,"p1");
-               layer->set_param("p2",p2);
-               get_canvas_interface()->signal_layer_param_changed()(layer,"p2");
-               break;
-       case GRADIENT_RADIAL:
-               layer=get_canvas_interface()->add_layer_to("radial_gradient",canvas,depth);
-               if (!layer)
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                       group.cancel();
-                       return;
-               }
-               layer->set_param("center",p1);
-               get_canvas_interface()->signal_layer_param_changed()(layer,"center");
-               layer->set_param("radius",(p2-p1).mag());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"radius");
-               break;
-       case GRADIENT_CONICAL:
-               layer=get_canvas_interface()->add_layer_to("conical_gradient",canvas,depth);
-               if (!layer)
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                       group.cancel();
-                       return;
-               }
-               layer->set_param("center",p1);
-               get_canvas_interface()->signal_layer_param_changed()(layer,"center");
-               {
-                       Vector diff(p2-p1);
-                       layer->set_param("angle",Angle::tan(diff[1],diff[0]));
-                       get_canvas_interface()->signal_layer_param_changed()(layer,"angle");
-               }
-               break;
-       case GRADIENT_SPIRAL:
-               layer=get_canvas_interface()->add_layer_to("spiral_gradient",canvas,depth);
-               if (!layer)
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                       group.cancel();
-                       return;
-               }
-               layer->set_param("center",p1);
-               get_canvas_interface()->signal_layer_param_changed()(layer,"center");
-               layer->set_param("radius",(p2-p1).mag());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"radius");
-               {
-                       Vector diff(p2-p1);
-                       layer->set_param("angle",Angle::tan(diff[1],diff[0]));
-                       get_canvas_interface()->signal_layer_param_changed()(layer,"angle");
-               }
-               break;
-
-       default:
-               return;
-       }
-
-#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
-       layer->set_param("blend_method",get_blend());
-       get_canvas_interface()->signal_layer_param_changed()(layer,"blend_method");
-#endif // BLEND_METHOD_IN_TOOL_OPTIONS
-
-       layer->set_description(get_id());
-       get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
-       egress_on_selection_change=false;
-       synfigapp::SelectionManager::LayerList layer_selection;
-       if (!getenv("SYNFIG_TOOLS_CLEAR_SELECTION"))
-               layer_selection = get_canvas_view()->get_selection_manager()->get_selected_layers();
-       get_canvas_interface()->get_selection_manager()->clear_selected_layers();
-       layer_selection.push_back(layer);
-       get_canvas_interface()->get_selection_manager()->set_selected_layers(layer_selection);
-       egress_on_selection_change=true;
-
-       reset();
-       increment_id();
-}
-
-Smach::event_result
-StateGradient_Context::event_mouse_click_handler(const Smach::event& x)
-{
-       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
-
-       if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_DOWN && event.button==BUTTON_LEFT)
-       {
-               point_holder=get_work_area()->snap_point_to_grid(event.pos);
-               etl::handle<Duck> duck=new Duck();
-               duck->set_point(point_holder);
-               duck->set_name("p1");
-               duck->set_type(Duck::TYPE_POSITION);
-               get_work_area()->add_duck(duck);
-
-               point2_duck=new Duck();
-               point2_duck->set_point(point_holder);
-               point2_duck->set_name("p2");
-               point2_duck->set_type(Duck::TYPE_POSITION);
-               get_work_area()->add_duck(point2_duck);
-
-               handle<Duckmatic::Bezier> bezier(new Duckmatic::Bezier());
-               bezier->p1=bezier->c1=duck;
-               bezier->p2=bezier->c2=point2_duck;
-               get_work_area()->add_bezier(bezier);
-
-               return Smach::RESULT_ACCEPT;
-       }
-
-       if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_DRAG && event.button==BUTTON_LEFT)
-       {
-               if (!point2_duck) return Smach::RESULT_OK;
-               point2_duck->set_point(get_work_area()->snap_point_to_grid(event.pos));
-               get_work_area()->queue_draw();
-               return Smach::RESULT_ACCEPT;
-       }
-
-       if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_UP && event.button==BUTTON_LEFT)
-       {
-               make_gradient(point_holder, get_work_area()->snap_point_to_grid(event.pos));
-               get_work_area()->clear_ducks();
-               return Smach::RESULT_ACCEPT;
-       }
-
-       return Smach::RESULT_OK;
-}
-
-
-void
-StateGradient_Context::refresh_ducks()
-{
-       get_work_area()->clear_ducks();
-       get_work_area()->queue_draw();
-}
diff --git a/synfig-studio/src/gtkmm/state_gradient.h b/synfig-studio/src/gtkmm/state_gradient.h
deleted file mode 100644 (file)
index 308b5ee..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_gradient.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_GRADIENT_H
-#define __SYNFIG_STUDIO_STATE_GRADIENT_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 StateGradient_Context;
-
-class StateGradient : public Smach::state<StateGradient_Context>
-{
-public:
-       StateGradient();
-       ~StateGradient();
-}; // END of class StateGradient
-
-extern StateGradient state_gradient;
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/state_normal.cpp b/synfig-studio/src/gtkmm/state_normal.cpp
deleted file mode 100644 (file)
index c763022..0000000
+++ /dev/null
@@ -1,824 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_normal.cpp
-**     \brief Template 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 <config.h>
-#endif
-
-#include <gtkmm/dialog.h>
-#include <gtkmm/entry.h>
-
-#include <synfig/valuenode_animated.h>
-#include <synfig/valuenode_blinecalcvertex.h>
-#include <synfig/valuenode_composite.h>
-#include <synfig/valuenode_const.h>
-#include <synfig/valuenode_dynamiclist.h>
-#include <synfigapp/action_system.h>
-
-#include "state_normal.h"
-#include "canvasview.h"
-#include "workarea.h"
-#include "app.h"
-
-#include <synfigapp/action.h>
-#include "event_mouse.h"
-#include "event_layerclick.h"
-#include "toolbox.h"
-#include "dialog_tooloptions.h"
-#include <gtkmm/optionmenu.h>
-#include "duck.h"
-#include <synfig/angle.h>
-#include <synfigapp/main.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 ========================================================= */
-
-#ifndef EPSILON
-#define EPSILON        0.0000001
-#endif
-
-/* === G L O B A L S ======================================================= */
-
-StateNormal studio::state_normal;
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-class DuckDrag_Combo : public DuckDrag_Base
-{
-       synfig::Vector last_move;
-       synfig::Vector drag_offset;
-       synfig::Vector center;
-       synfig::Vector snap;
-
-       synfig::Angle original_angle;
-       synfig::Real original_mag;
-
-       std::vector<synfig::Vector> last_;
-       std::vector<synfig::Vector> positions;
-
-
-       bool bad_drag;
-       bool move_only;
-
-public:
-       etl::handle<CanvasView> canvas_view_;
-       bool scale;
-       bool rotate;
-       bool constrain;
-       DuckDrag_Combo();
-       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<synfigapp::CanvasInterface> get_canvas_interface()const{return canvas_view_->canvas_interface();}
-};
-
-
-class studio::StateNormal_Context : public sigc::trackable
-{
-       etl::handle<CanvasView> canvas_view_;
-
-       synfigapp::Settings& settings;
-
-       sigc::connection keypress_connect;
-       sigc::connection keyrelease_connect;
-
-       etl::handle<DuckDrag_Combo> duck_dragger_;
-
-       Gtk::Table options_table;
-
-       Gtk::CheckButton checkbutton_rotate;
-       Gtk::CheckButton checkbutton_scale;
-       Gtk::CheckButton checkbutton_constrain;
-
-public:
-
-       bool get_rotate_flag()const { return checkbutton_rotate.get_active(); }
-       void set_rotate_flag(bool x) { checkbutton_rotate.set_active(x); refresh_rotate_flag(); }
-       void refresh_rotate_flag() { if(duck_dragger_)duck_dragger_->rotate=get_rotate_flag(); }
-
-       bool get_scale_flag()const { return checkbutton_scale.get_active(); }
-       void set_scale_flag(bool x) { checkbutton_scale.set_active(x); refresh_scale_flag(); }
-       void refresh_scale_flag() { if(duck_dragger_)duck_dragger_->scale=get_scale_flag(); }
-
-       bool get_constrain_flag()const { return checkbutton_constrain.get_active(); }
-       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(); }
-
-       StateNormal_Context(CanvasView* canvas_view);
-
-       ~StateNormal_Context();
-
-       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
-       etl::handle<synfigapp::CanvasInterface> 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();
-
-       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 ======================================================= */
-
-StateNormal::StateNormal():
-       Smach::state<StateNormal_Context>("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()
-{
-}
-
-void
-StateNormal_Context::load_settings()
-{
-       String value;
-
-       if(settings.get_value("normal.rotate",value) && value=="1")
-               set_rotate_flag(true);
-       else
-               set_rotate_flag(false);
-
-       if(settings.get_value("normal.scale",value) && value=="1")
-               set_scale_flag(true);
-       else
-               set_scale_flag(false);
-
-       if(settings.get_value("normal.constrain",value) && value=="1")
-               set_constrain_flag(true);
-       else
-               set_constrain_flag(false);
-
-}
-
-void
-StateNormal_Context::save_settings()
-{
-       settings.set_value("normal.rotate",get_rotate_flag()?"1":"0");
-       settings.set_value("normal.scale",get_scale_flag()?"1":"0");
-       settings.set_value("normal.constrain",get_constrain_flag()?"1":"0");
-}
-
-StateNormal_Context::StateNormal_Context(CanvasView* canvas_view):
-       canvas_view_(canvas_view),
-       settings(synfigapp::Main::get_selected_input_device()->settings()),
-       duck_dragger_(new DuckDrag_Combo()),
-       checkbutton_rotate(_("Rotate (Ctrl)")),
-       checkbutton_scale(_("Scale (Alt)")),
-       checkbutton_constrain(_("Constrain (Shift)"))
-{
-       duck_dragger_->canvas_view_=get_canvas_view();
-
-       // Set up the tool options dialog
-       options_table.attach(*manage(new Gtk::Label(_("Normal Tool"))), 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_rotate,                                                        0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_scale,                                                 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_constrain,                                                     0, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       checkbutton_rotate.signal_toggled().connect(sigc::mem_fun(*this,&StateNormal_Context::refresh_rotate_flag));
-       checkbutton_scale.signal_toggled().connect(sigc::mem_fun(*this,&StateNormal_Context::refresh_scale_flag));
-       checkbutton_constrain.signal_toggled().connect(sigc::mem_fun(*this,&StateNormal_Context::refresh_constrain_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_);
-
-       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);
-
-       //these will segfault
-//     get_work_area()->set_cursor(Gdk::CROSSHAIR);
-//     get_work_area()->reset_cursor();
-
-       App::toolbox->refresh();
-
-       load_settings();
-       refresh_scale_flag();
-}
-
-bool
-StateNormal_Context::key_pressed(GdkEventKey *event)
-{
-       switch(event->keyval)
-       {
-               case GDK_Control_L:
-               case GDK_Control_R:
-                       set_rotate_flag(true);
-                       break;
-               case GDK_Alt_L:
-               case GDK_Alt_R:
-                       set_scale_flag(true);
-                       break;
-               case GDK_Shift_L:
-               case GDK_Shift_R:
-                       set_constrain_flag(true);
-                       break;
-               default:
-                       break;
-       }
-       return false; //Pass on the event to other handlers, just in case
-}
-
-bool
-StateNormal_Context::key_released(GdkEventKey *event)
-{
-       switch(event->keyval)
-       {
-               case GDK_Control_L:
-               case GDK_Control_R:
-                       set_rotate_flag(false);
-                       break;
-               case GDK_Alt_L:
-               case GDK_Alt_R:
-                       set_scale_flag(false);
-                       break;
-               case GDK_Shift_L:
-               case GDK_Shift_R:
-                       set_constrain_flag(false);
-                       break;
-               default:
-                       break;
-       }
-       return false; //Pass on the event to other handlers
-}
-
-void
-StateNormal_Context::refresh_tool_options()
-{
-       App::dialog_tool_options->clear();
-       App::dialog_tool_options->set_widget(options_table);
-       App::dialog_tool_options->set_local_name(_("Normal Tool"));
-       App::dialog_tool_options->set_name("normal");
-}
-
-
-
-StateNormal_Context::~StateNormal_Context()
-{
-       save_settings();
-
-       get_work_area()->clear_duck_dragger();
-       get_work_area()->reset_cursor();
-
-       keypress_connect.disconnect();
-       keyrelease_connect.disconnect();
-
-       App::dialog_tool_options->clear();
-
-       App::toolbox->refresh();
-}
-
-DuckDrag_Combo::DuckDrag_Combo():
-       scale(false),
-       rotate(false),
-       constrain(false) // Lock aspect for scale; smooth move for translate
-{
-}
-
-void
-DuckDrag_Combo::begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& offset)
-{
-       last_move=Vector(1,1);
-
-       const DuckList selected_ducks(duckmatic->get_selected_ducks());
-       DuckList::const_iterator iter;
-
-       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<etl::handle<Duck> >::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_Combo::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector)
-{
-       if (!duckmatic) return;
-
-       if(bad_drag)
-               return;
-
-       //Override axis lock set in workarea when holding down the shift key
-       if (!move_only && (scale || rotate))
-               duckmatic->set_axis_lock(false);
-
-       synfig::Vector vect;
-       if (move_only || (!scale && !rotate))
-               vect= duckmatic->snap_point_to_grid(vector)-drag_offset+snap;
-       else
-               vect= duckmatic->snap_point_to_grid(vector)-center+snap;
-
-       last_move=vect;
-
-       const DuckList selected_ducks(duckmatic->get_selected_ducks());
-       DuckList::const_iterator iter;
-
-       Time time(duckmatic->get_time());
-
-       int i;
-       if( move_only || (!scale && !rotate) )
-       {
-               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)
-                               (*iter)->set_trans_point(positions[i]+vect, time);
-               }
-               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)
-                               (*iter)->set_trans_point(positions[i]+vect, time);
-               }
-       }
-
-       if (rotate)
-       {
-               Angle::deg angle(Angle::tan(vect[1],vect[0]));
-               angle=original_angle-angle;
-               if (constrain)
-               {
-                       float degrees = angle.get()/15;
-                       angle= Angle::deg (degrees>0?std::floor(degrees)*15:std::ceil(degrees)*15);
-               }
-               Real mag(vect.mag()/original_mag);
-               Real sine(Angle::sin(angle).get());
-               Real cosine(Angle::cos(angle).get());
-
-               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(scale)p*=mag;
-                       p+=center;
-                       (*iter)->set_trans_point(p, time);
-               }
-               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(scale)p*=mag;
-                       p+=center;
-                       (*iter)->set_trans_point(p, time);
-               }
-       } else if (scale)
-       {
-               if(!constrain)
-               {
-                       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]>-EPSILON)
-                       vect[0]=1;
-               if(vect[1]<EPSILON && vect[1]>-EPSILON)
-                       vect[1]=1;
-
-               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, time);
-               }
-               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, time);
-               }
-       }
-
-       // then patch up the tangents for the vertices we've moved
-       duckmatic->update_ducks();
-
-       last_move=vect;
-}
-
-bool
-DuckDrag_Combo::end_duck_drag(Duckmatic* duckmatic)
-{
-       if(bad_drag)return false;
-
-       //synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Rotate Ducks"));
-
-       if((last_move-Vector(1,1)).mag()>0.0001)
-       {
-               duckmatic->signal_edited_selected_ducks();
-               return true;
-       }
-       else
-       {
-               duckmatic->signal_user_click_selected_ducks(0);
-               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<const EventMouse*>(&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<const EventLayerClick*>(&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::Handle> layer_list(canvas_view_->get_selection_manager()->get_selected_layers());
-                       std::set<Layer::Handle> layers(layer_list.begin(),layer_list.end());
-                       if(layers.count(event.layer))
-                       {
-                               layers.erase(event.layer);
-                               layer_list=std::list<Layer::Handle>(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<synfigapp::ValueDesc> 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<synfigapp::ValueDesc>::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<const EventMouse*>(&x));
-
-       std::list<synfigapp::ValueDesc> 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_normal.h b/synfig-studio/src/gtkmm/state_normal.h
deleted file mode 100644 (file)
index 01b040b..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_normal.h
-**     \brief Template 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_STUDIO_STATE_NORMAL_H
-#define __SYNFIG_STUDIO_STATE_NORMAL_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 StateNormal_Context;
-
-class StateNormal : public Smach::state<StateNormal_Context>
-{
-public:
-       StateNormal();
-       ~StateNormal();
-}; // END of class StateNormal
-
-extern StateNormal state_normal;
-
-}; // 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
deleted file mode 100644 (file)
index 7c11c05..0000000
+++ /dev/null
@@ -1,945 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_polygon.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 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 <config.h>
-#endif
-
-#include <gtkmm/dialog.h>
-#include <gtkmm/entry.h>
-
-#include <synfig/valuenode_dynamiclist.h>
-#include <synfigapp/action_system.h>
-#include <synfig/valuenode_bline.h>
-
-#include "state_polygon.h"
-#include "state_normal.h"
-#include "canvasview.h"
-#include "workarea.h"
-#include "app.h"
-
-#include <synfigapp/action.h>
-#include "event_mouse.h"
-#include "event_layerclick.h"
-#include "toolbox.h"
-#include "dialog_tooloptions.h"
-#include <synfigapp/main.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 ======================================================= */
-
-StatePolygon studio::state_polygon;
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-class studio::StatePolygon_Context : public sigc::trackable
-{
-       etl::handle<CanvasView> canvas_view_;
-       CanvasView::IsWorking is_working;
-
-       bool prev_table_status;
-       bool prev_workarea_layer_status_;
-
-       Gtk::Menu menu;
-
-       Duckmatic::Push duckmatic_push;
-
-       std::list<synfig::Point> polygon_point_list;
-       synfigapp::Settings& settings;
-
-
-       bool on_polygon_duck_change(const synfig::Point &point, std::list<synfig::Point>::iterator iter);
-
-
-       void popup_handle_menu(synfigapp::ValueDesc value_desc);
-
-
-       void refresh_ducks();
-
-       Gtk::Table options_table;
-       Gtk::Entry entry_id;
-       Gtk::CheckButton checkbutton_invert;
-       Gtk::CheckButton checkbutton_layer_polygon;
-       Gtk::CheckButton checkbutton_layer_region;
-       Gtk::CheckButton checkbutton_layer_outline;
-       Gtk::CheckButton checkbutton_layer_curve_gradient;
-       Gtk::CheckButton checkbutton_layer_plant;
-       Gtk::CheckButton checkbutton_layer_link_origins;
-       Gtk::Button button_make;
-       Gtk::Adjustment  adj_feather;
-       Gtk::SpinButton  spin_feather;
-
-public:
-
-       // this counts the layers we create - they all have origins we can link
-       int layers_to_create()const
-       {
-               return
-                       get_layer_polygon_flag() +
-                       get_layer_region_flag() +
-                       get_layer_outline_flag() +
-                       get_layer_curve_gradient_flag() +
-                       get_layer_plant_flag();
-       }
-
-       synfig::String get_id()const { return entry_id.get_text(); }
-       void set_id(const synfig::String& x) { return entry_id.set_text(x); }
-
-       bool get_invert()const { return checkbutton_invert.get_active(); }
-       void set_invert(bool i) { checkbutton_invert.set_active(i); }
-
-       bool get_layer_polygon_flag()const { return checkbutton_layer_polygon.get_active(); }
-       void set_layer_polygon_flag(bool x) { return checkbutton_layer_polygon.set_active(x); }
-
-       bool get_layer_region_flag()const { return checkbutton_layer_region.get_active(); }
-       void set_layer_region_flag(bool x) { return checkbutton_layer_region.set_active(x); }
-
-       bool get_layer_outline_flag()const { return checkbutton_layer_outline.get_active(); }
-       void set_layer_outline_flag(bool x) { return checkbutton_layer_outline.set_active(x); }
-
-       bool get_layer_curve_gradient_flag()const { return checkbutton_layer_curve_gradient.get_active(); }
-       void set_layer_curve_gradient_flag(bool x) { return checkbutton_layer_curve_gradient.set_active(x); }
-
-       bool get_layer_plant_flag()const { return checkbutton_layer_plant.get_active(); }
-       void set_layer_plant_flag(bool x) { return checkbutton_layer_plant.set_active(x); }
-
-       bool get_layer_link_origins_flag()const { return checkbutton_layer_link_origins.get_active(); }
-       void set_layer_link_origins_flag(bool x) { return checkbutton_layer_link_origins.set_active(x); }
-
-       Real get_feather() const { return adj_feather.get_value(); }
-       void set_feather(Real x) { return adj_feather.set_value(x); }
-
-       Smach::event_result event_stop_handler(const Smach::event& x);
-
-       Smach::event_result event_refresh_handler(const Smach::event& x);
-
-       Smach::event_result event_mouse_click_handler(const Smach::event& x);
-       Smach::event_result event_refresh_tool_options(const Smach::event& x);
-       void refresh_tool_options();
-
-       StatePolygon_Context(CanvasView* canvas_view);
-
-       ~StatePolygon_Context();
-
-       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
-       etl::handle<synfigapp::CanvasInterface> 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 on_user_click(synfig::Point point);
-       void load_settings();
-       void save_settings();
-       void reset();
-       void increment_id();
-       bool egress_on_selection_change;
-       Smach::event_result event_layer_selection_changed_handler(const Smach::event& /*x*/)
-       {
-               if(egress_on_selection_change)
-                       throw &state_normal; //throw Smach::egress_exception();
-               return Smach::RESULT_OK;
-       }
-
-       void run();
-};     // END of class StatePolygon_Context
-
-/* === M E T H O D S ======================================================= */
-
-StatePolygon::StatePolygon():
-       Smach::state<StatePolygon_Context>("polygon")
-{
-       insert(event_def(EVENT_LAYER_SELECTION_CHANGED,&StatePolygon_Context::event_layer_selection_changed_handler));
-       insert(event_def(EVENT_STOP,&StatePolygon_Context::event_stop_handler));
-       insert(event_def(EVENT_REFRESH,&StatePolygon_Context::event_refresh_handler));
-       insert(event_def(EVENT_REFRESH_DUCKS,&StatePolygon_Context::event_refresh_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StatePolygon_Context::event_mouse_click_handler));
-       insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StatePolygon_Context::event_refresh_tool_options));
-}
-
-StatePolygon::~StatePolygon()
-{
-}
-
-void
-StatePolygon_Context::load_settings()
-{
-       String value;
-
-       if(settings.get_value("polygon.id",value))
-               set_id(value);
-       else
-               set_id("Polygon");
-
-       if(settings.get_value("polygon.invert",value) && value != "0")
-               set_invert(true);
-       else
-               set_invert(false);
-
-       if(settings.get_value("polygon.layer_polygon",value) && value=="0")
-               set_layer_polygon_flag(false);
-       else
-               set_layer_polygon_flag(true);
-
-       if(settings.get_value("polygon.layer_region",value) && value=="1")
-               set_layer_region_flag(true);
-       else
-               set_layer_region_flag(false);
-
-       if(settings.get_value("polygon.layer_outline",value) && value=="1")
-               set_layer_outline_flag(true);
-       else
-               set_layer_outline_flag(false);
-
-       if(settings.get_value("polygon.layer_curve_gradient",value) && value=="1")
-               set_layer_curve_gradient_flag(true);
-       else
-               set_layer_curve_gradient_flag(false);
-
-       if(settings.get_value("polygon.layer_plant",value) && value=="1")
-               set_layer_plant_flag(true);
-       else
-               set_layer_plant_flag(false);
-
-       if(settings.get_value("polygon.layer_link_origins",value) && value=="0")
-               set_layer_link_origins_flag(false);
-       else
-               set_layer_link_origins_flag(true);
-
-       if(settings.get_value("polygon.feather",value))
-       {
-               Real n = atof(value.c_str());
-               set_feather(n);
-       }
-}
-
-void
-StatePolygon_Context::save_settings()
-{
-       settings.set_value("polygon.id",get_id().c_str());
-       settings.set_value("polygon.invert",get_invert()?"1":"0");
-       settings.set_value("polygon.layer_polygon",get_layer_polygon_flag()?"1":"0");
-       settings.set_value("polygon.layer_outline",get_layer_outline_flag()?"1":"0");
-       settings.set_value("polygon.layer_region",get_layer_region_flag()?"1":"0");
-       settings.set_value("polygon.layer_curve_gradient",get_layer_curve_gradient_flag()?"1":"0");
-       settings.set_value("polygon.layer_plant",get_layer_plant_flag()?"1":"0");
-       settings.set_value("polygon.layer_link_origins",get_layer_link_origins_flag()?"1":"0");
-       settings.set_value("polygon.feather",strprintf("%f",get_feather()));
-}
-
-void
-StatePolygon_Context::reset()
-{
-       polygon_point_list.clear();
-       refresh_ducks();
-}
-
-void
-StatePolygon_Context::increment_id()
-{
-       String id(get_id());
-       int number=1;
-       int digits=0;
-
-       if(id.empty())
-               id="Polygon";
-
-       // If there is a number
-       // already at the end of the
-       // id, then remove it.
-       if(id[id.size()-1]<='9' && id[id.size()-1]>='0')
-       {
-               // figure out how many digits it is
-               for (digits = 0;
-                        (int)id.size()-1 >= digits && id[id.size()-1-digits] <= '9' && id[id.size()-1-digits] >= '0';
-                        digits++)
-                       ;
-
-               String str_number;
-               str_number=String(id,id.size()-digits,id.size());
-               id=String(id,0,id.size()-digits);
-
-               number=atoi(str_number.c_str());
-       }
-       else
-       {
-               number=1;
-               digits=3;
-       }
-
-       number++;
-
-       // Add the number back onto the id
-       {
-               const String format(strprintf("%%0%dd",digits));
-               id+=strprintf(format.c_str(),number);
-       }
-
-       // Set the ID
-       set_id(id);
-}
-
-StatePolygon_Context::StatePolygon_Context(CanvasView* canvas_view):
-       canvas_view_(canvas_view),
-       is_working(*canvas_view),
-       prev_workarea_layer_status_(get_work_area()->get_allow_layer_clicks()),
-       duckmatic_push(get_work_area()),
-       settings(synfigapp::Main::get_selected_input_device()->settings()),
-       entry_id(),
-       checkbutton_invert(_("Invert")),
-       checkbutton_layer_polygon(_("Create Polygon Layer")),
-       checkbutton_layer_region(_("Create Region BLine")),
-       checkbutton_layer_outline(_("Create Outline BLine")),
-       checkbutton_layer_curve_gradient(_("Create Curve Gradient BLine")),
-       checkbutton_layer_plant(_("Create Plant BLine")),
-       checkbutton_layer_link_origins(_("Link Origins")),
-       button_make(_("Make")),
-       adj_feather(0,0,10000,0.01,0.1),
-       spin_feather(adj_feather,0.01,4)
-{
-       egress_on_selection_change=true;
-       load_settings();
-
-       // Set up the tool options dialog
-       options_table.attach(*manage(new Gtk::Label(_("Polygon Tool"))),        0, 2, 0,  1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(entry_id,                                                                          0, 2, 1,  2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       options_table.attach(checkbutton_layer_polygon,                                         0, 2, 2,  3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_outline,                                         0, 2, 3,  4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_region,                                          0, 2, 4,  5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_plant,                                           0, 2, 5,  6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_curve_gradient,                          0, 2, 6,  7, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_link_origins,                            0, 2, 7,  8, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       //invert flag
-       options_table.attach(checkbutton_invert,                                                        0, 2, 8,  9, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       //feather stuff
-       options_table.attach(*manage(new Gtk::Label(_("Feather"))),             0, 1, 9, 10, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(spin_feather,                                                                      1, 2, 9, 10, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       //options_table.attach(button_make, 0, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       button_make.signal_pressed().connect(sigc::mem_fun(*this,&StatePolygon_Context::run));
-       options_table.show_all();
-       refresh_tool_options();
-       App::dialog_tool_options->present();
-
-
-       // Turn off layer clicking
-       get_work_area()->set_allow_layer_clicks(false);
-
-       // clear out the ducks
-       get_work_area()->clear_ducks();
-
-       // Refresh the work area
-       get_work_area()->queue_draw();
-
-       get_work_area()->set_cursor(Gdk::CROSSHAIR);
-
-       // Hide the tables if they are showing
-       prev_table_status=get_canvas_view()->tables_are_visible();
-       if(prev_table_status)get_canvas_view()->hide_tables();
-
-       // Disable the time bar
-       get_canvas_view()->set_sensitive_timebar(false);
-
-       // Connect a signal
-       //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StatePolygon_Context::on_user_click));
-
-       App::toolbox->refresh();
-}
-
-void
-StatePolygon_Context::refresh_tool_options()
-{
-       App::dialog_tool_options->clear();
-       App::dialog_tool_options->set_widget(options_table);
-
-       App::dialog_tool_options->set_local_name(_("Polygon Tool"));
-       App::dialog_tool_options->set_name("polygon");
-
-       App::dialog_tool_options->add_button(
-               Gtk::StockID("gtk-execute"),
-               _("Make Polygon")
-       )->signal_clicked().connect(
-               sigc::mem_fun(
-                       *this,
-                       &StatePolygon_Context::run
-               )
-       );
-
-       App::dialog_tool_options->add_button(
-               Gtk::StockID("gtk-clear"),
-               _("Clear current Polygon")
-       )->signal_clicked().connect(
-               sigc::mem_fun(
-                       *this,
-                       &StatePolygon_Context::reset
-               )
-       );
-}
-
-Smach::event_result
-StatePolygon_Context::event_refresh_tool_options(const Smach::event& /*x*/)
-{
-       refresh_tool_options();
-       return Smach::RESULT_ACCEPT;
-}
-
-StatePolygon_Context::~StatePolygon_Context()
-{
-       run();
-
-       save_settings();
-       // Restore layer clicking
-       get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_);
-
-       App::dialog_tool_options->clear();
-
-       get_work_area()->reset_cursor();
-
-       // Enable the time bar
-       get_canvas_view()->set_sensitive_timebar(true);
-
-       // Bring back the tables if they were out before
-       if(prev_table_status)get_canvas_view()->show_tables();
-
-       // Refresh the work area
-       get_work_area()->queue_draw();
-
-       App::toolbox->refresh();
-}
-
-Smach::event_result
-StatePolygon_Context::event_stop_handler(const Smach::event& /*x*/)
-{
-       synfig::info("STATE RotoPolygon: Received Stop Event");
-       //throw Smach::egress_exception();
-       reset();
-       return Smach::RESULT_ACCEPT;
-
-}
-
-Smach::event_result
-StatePolygon_Context::event_refresh_handler(const Smach::event& /*x*/)
-{
-       synfig::info("STATE RotoPolygon: Received Refresh Event");
-       refresh_ducks();
-       return Smach::RESULT_ACCEPT;
-}
-
-void
-StatePolygon_Context::run()
-{
-       if(polygon_point_list.empty())
-               return;
-
-       if(polygon_point_list.size()<3)
-       {
-               get_canvas_view()->get_ui_interface()->error("You need at least 3 points to create a polygon");
-               return;
-       }
-
-       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("New Polygon"));
-
-       Layer::Handle layer;
-
-       Canvas::Handle canvas;
-       int depth(0);
-
-       // we are temporarily using the layer to hold something
-       layer=get_canvas_view()->get_selection_manager()->get_selected_layer();
-       if(layer)
-       {
-               depth=layer->get_depth();
-               canvas=layer->get_canvas();
-       }
-
-       synfigapp::SelectionManager::LayerList layer_selection;
-       if (!getenv("SYNFIG_TOOLS_CLEAR_SELECTION"))
-               layer_selection = get_canvas_view()->get_selection_manager()->get_selected_layers();
-
-       const synfig::TransformStack& transform(get_canvas_view()->get_curr_transform_stack());
-
-       std::vector<BLinePoint> new_list;
-       std::list<synfig::Point>::iterator iter;
-       int i;
-       for(i=0,iter=polygon_point_list.begin();iter!=polygon_point_list.end();++iter,++i)
-       {
-               *iter = transform.unperform(*iter);
-               new_list.push_back(*(new BLinePoint));
-               new_list[i].set_width(1);
-               new_list[i].set_vertex(*iter);
-               new_list[i].set_tangent(Point(0,0));
-       }
-
-       ValueNode_BLine::Handle value_node_bline(ValueNode_BLine::create(new_list));
-       assert(value_node_bline);
-
-       ValueNode_Const::Handle value_node_origin(ValueNode_Const::create(Vector()));
-       assert(value_node_origin);
-
-       // Set the looping flag
-       value_node_bline->set_loop(true);
-
-       if(!canvas)
-               canvas=get_canvas_view()->get_canvas();
-
-       value_node_bline->set_member_canvas(canvas);
-
-       // count how many layers we're going to be creating
-       int layers_to_create = this->layers_to_create();
-
-       ///////////////////////////////////////////////////////////////////////////
-       //   P O L Y G O N
-       ///////////////////////////////////////////////////////////////////////////
-
-       if (get_layer_polygon_flag())
-       {
-               layer=get_canvas_interface()->add_layer_to("polygon",canvas,depth);
-               if (!layer)
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                       group.cancel();
-                       return;
-               }
-               layer_selection.push_back(layer);
-
-               layer->set_param("invert",get_invert());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
-
-               if(get_feather())
-               {
-                       layer->set_param("feather",get_feather());
-                       get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
-               }
-
-               layer->set_description(get_id());
-               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
-               layer->disconnect_dynamic_param("vector_list");
-               if(!layer->set_param("vector_list",polygon_point_list))
-               {
-                       group.cancel();
-                       get_canvas_view()->get_ui_interface()->error("Unable to set layer parameter");
-                       return;
-               }
-
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("ValueDescConvert"));
-                       synfigapp::ValueDesc value_desc(layer,"vector_list");
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("value_desc",value_desc);
-                       action->set_param("type","dynamic_list");
-                       action->set_param("time",get_canvas_interface()->get_time());
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               group.cancel();
-                               get_canvas_view()->get_ui_interface()->error("Unable to execute action \"ValueDescConvert\"");
-                               return;
-                       }
-               }
-
-               // only link the polygon's origin parameter if the option is selected and we're creating more than one layer
-               if (get_layer_link_origins_flag() && layers_to_create > 1)
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("origin")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               get_canvas_view()->get_ui_interface()->error(_("Unable to create Polygon layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Polygon layer"));
-                               return;
-                       }
-               }
-       }
-
-       ///////////////////////////////////////////////////////////////////////////
-       //   C U R V E   G R A D I E N T
-       ///////////////////////////////////////////////////////////////////////////
-
-       if(get_layer_curve_gradient_flag())
-       {
-               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
-               Layer::Handle layer(get_canvas_interface()->add_layer_to("curve_gradient",canvas,depth));
-               if (!layer)
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                       group.cancel();
-                       return;
-               }
-               layer_selection.push_back(layer);
-               layer->set_description(get_id()+_(" Gradient"));
-               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("bline")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Gradient layer"));
-                               return;
-                       }
-               }
-
-               // only link the curve gradient's origin parameter if the option is selected and we're creating more than one layer
-               if (get_layer_link_origins_flag() && layers_to_create > 1)
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("origin")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Gradient layer"));
-                               return;
-                       }
-               }
-       }
-
-       ///////////////////////////////////////////////////////////////////////////
-       //   P L A N T
-       ///////////////////////////////////////////////////////////////////////////
-
-       if(get_layer_plant_flag())
-       {
-               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
-               Layer::Handle layer(get_canvas_interface()->add_layer_to("plant",canvas,depth));
-               if (!layer)
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                       group.cancel();
-                       return;
-               }
-               layer_selection.push_back(layer);
-               layer->set_description(get_id()+_(" Plant"));
-               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("bline")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Plant layer"));
-                               return;
-                       }
-               }
-
-               // only link the plant's origin parameter if the option is selected and we're creating more than one layer
-               if (get_layer_link_origins_flag() && layers_to_create > 1)
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("origin")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Plant layer"));
-                               return;
-                       }
-               }
-       }
-
-       ///////////////////////////////////////////////////////////////////////////
-       //   R E G I O N
-       ///////////////////////////////////////////////////////////////////////////
-
-       if(get_layer_region_flag())
-       {
-               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
-               Layer::Handle layer(get_canvas_interface()->add_layer_to("region",canvas,depth));
-               if (!layer)
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                       group.cancel();
-                       return;
-               }
-               layer_selection.push_back(layer);
-               layer->set_description(get_id()+_(" Region"));
-               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
-               layer->set_param("feather",get_feather());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
-
-               layer->set_param("invert",get_invert());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
-
-               // I don't know if it's safe to reuse the same LayerParamConnect action, so I'm
-               // using 2 separate ones.
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("bline")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Region layer"));
-                               return;
-                       }
-               }
-
-               // only link the region's origin parameter if the option is selected and we're creating more than one layer
-               if (get_layer_link_origins_flag() && layers_to_create > 1)
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("origin")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Region layer"));
-                               return;
-                       }
-               }
-       }
-
-       ///////////////////////////////////////////////////////////////////////////
-       //   O U T L I N E
-       ///////////////////////////////////////////////////////////////////////////
-
-       if (get_layer_outline_flag())
-       {
-               Layer::Handle layer(get_canvas_interface()->add_layer_to("outline",canvas,depth));
-               if (!layer)
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                       group.cancel();
-                       return;
-               }
-               layer_selection.push_back(layer);
-               layer->set_description(get_id()+_(" Outline"));
-               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
-               layer->set_param("feather",get_feather());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
-
-               layer->set_param("invert",get_invert());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
-
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("bline")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Outline layer"));
-                               return;
-                       }
-               }
-
-               // only link the outline's origin parameter if the option is selected and we're creating more than one layer
-               if (get_layer_link_origins_flag() && layers_to_create > 1)
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("origin")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Outline layer"));
-                               return;
-                       }
-               }
-       }
-
-       egress_on_selection_change=false;
-       get_canvas_interface()->get_selection_manager()->clear_selected_layers();
-       get_canvas_interface()->get_selection_manager()->set_selected_layers(layer_selection);
-       egress_on_selection_change=true;
-
-       //post clean up stuff...
-       reset();
-       increment_id();
-}
-
-Smach::event_result
-StatePolygon_Context::event_mouse_click_handler(const Smach::event& x)
-{
-       synfig::info("STATE ROTOPOLYGON: Received mouse button down Event");
-       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
-       switch(event.button)
-       {
-       case BUTTON_LEFT:
-               polygon_point_list.push_back(get_work_area()->snap_point_to_grid(event.pos));
-               refresh_ducks();
-               return Smach::RESULT_ACCEPT;
-
-       default:
-               return Smach::RESULT_OK;
-       }
-}
-
-
-void
-StatePolygon_Context::refresh_ducks()
-{
-       get_work_area()->clear_ducks();
-       get_work_area()->queue_draw();
-
-       if(polygon_point_list.empty()) return;
-
-       std::list<synfig::Point>::iterator iter=polygon_point_list.begin();
-
-       etl::handle<WorkArea::Duck> duck;
-       duck=new WorkArea::Duck(*iter);
-       duck->set_editable(true);
-       duck->signal_edited().connect(
-               sigc::bind(sigc::mem_fun(*this,&studio::StatePolygon_Context::on_polygon_duck_change),iter)
-       );
-       duck->signal_user_click(0).connect(sigc::mem_fun(*this,&StatePolygon_Context::run));
-
-       get_work_area()->add_duck(duck);
-
-       for(++iter;iter!=polygon_point_list.end();++iter)
-       {
-               etl::handle<WorkArea::Bezier> bezier(new WorkArea::Bezier());
-               bezier->p1=bezier->c1=duck;
-
-               duck=new WorkArea::Duck(*iter);
-               duck->set_editable(true);
-               duck->set_name(strprintf("%x",&*iter));
-               duck->signal_edited().connect(
-                       sigc::bind(sigc::mem_fun(*this,&studio::StatePolygon_Context::on_polygon_duck_change),iter)
-               );
-
-               get_work_area()->add_duck(duck);
-
-               bezier->p2=bezier->c2=duck;
-               get_work_area()->add_bezier(bezier);
-       }
-       get_work_area()->queue_draw();
-}
-
-
-bool
-StatePolygon_Context::on_polygon_duck_change(const synfig::Point &point, std::list<synfig::Point>::iterator iter)
-{
-       *iter=point;
-       return true;
-}
diff --git a/synfig-studio/src/gtkmm/state_polygon.h b/synfig-studio/src/gtkmm/state_polygon.h
deleted file mode 100644 (file)
index c633c4e..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_polygon.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_ROTOSCOPE_POLYGON_H
-#define __SYNFIG_STUDIO_ROTOSCOPE_POLYGON_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 StatePolygon_Context;
-
-class StatePolygon : public Smach::state<StatePolygon_Context>
-{
-public:
-       StatePolygon();
-       ~StatePolygon();
-}; // END of class StatePolygon
-
-extern StatePolygon state_polygon;
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/state_rectangle.cpp b/synfig-studio/src/gtkmm/state_rectangle.cpp
deleted file mode 100644 (file)
index 4f3eccb..0000000
+++ /dev/null
@@ -1,875 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_rectangle.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 <config.h>
-#endif
-
-#include <gtkmm/dialog.h>
-#include <gtkmm/entry.h>
-
-#include <synfig/valuenode_dynamiclist.h>
-#include <synfigapp/action_system.h>
-#include <synfig/valuenode_bline.h>
-
-#include "state_rectangle.h"
-#include "state_normal.h"
-#include "canvasview.h"
-#include "workarea.h"
-#include "app.h"
-
-#include <synfigapp/action.h>
-#include "event_mouse.h"
-#include "event_layerclick.h"
-#include "toolbox.h"
-#include "dialog_tooloptions.h"
-#include <gtkmm/optionmenu.h>
-#include "duck.h"
-#include <synfigapp/main.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 ======================================================= */
-
-StateRectangle studio::state_rectangle;
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-class studio::StateRectangle_Context : public sigc::trackable
-{
-       etl::handle<CanvasView> canvas_view_;
-       CanvasView::IsWorking is_working;
-
-       Duckmatic::Push duckmatic_push;
-
-       Point point_holder;
-
-       etl::handle<Duck> point2_duck;
-
-       void refresh_ducks();
-
-       bool prev_workarea_layer_status_;
-
-       //Toolbox settings
-       synfigapp::Settings& settings;
-
-       //Toolbox display
-       Gtk::Table options_table;
-
-       Gtk::Entry              entry_id; //what to name the layer
-
-       Gtk::Adjustment adj_expand;
-       Gtk::Adjustment adj_feather;
-       Gtk::SpinButton spin_expand;
-       Gtk::SpinButton spin_feather;
-
-       Gtk::CheckButton checkbutton_invert;
-       Gtk::CheckButton checkbutton_layer_rectangle;
-       Gtk::CheckButton checkbutton_layer_region;
-       Gtk::CheckButton checkbutton_layer_outline;
-       Gtk::CheckButton checkbutton_layer_curve_gradient;
-       Gtk::CheckButton checkbutton_layer_plant;
-       Gtk::CheckButton checkbutton_layer_link_origins;
-
-public:
-
-       // this only counts the layers which use blines - they're the only
-       // ones we link the origins for
-       int layers_to_create()const
-       {
-               return
-                       get_layer_region_flag() +
-                       get_layer_outline_flag() +
-                       get_layer_curve_gradient_flag() +
-                       get_layer_plant_flag();
-       }
-
-       synfig::String get_id()const { return entry_id.get_text(); }
-       void set_id(const synfig::String& x) { return entry_id.set_text(x); }
-
-       Real get_expand()const { return adj_expand.get_value(); }
-       void set_expand(Real f) { adj_expand.set_value(f); }
-
-       Real get_feather()const { return adj_feather.get_value(); }
-       void set_feather(Real f) { adj_feather.set_value(f); }
-
-       bool get_invert()const { return checkbutton_invert.get_active(); }
-       void set_invert(bool i) { checkbutton_invert.set_active(i); }
-
-       bool get_layer_rectangle_flag()const { return checkbutton_layer_rectangle.get_active(); }
-       void set_layer_rectangle_flag(bool x) { return checkbutton_layer_rectangle.set_active(x); }
-
-       bool get_layer_region_flag()const { return checkbutton_layer_region.get_active(); }
-       void set_layer_region_flag(bool x) { return checkbutton_layer_region.set_active(x); }
-
-       bool get_layer_outline_flag()const { return checkbutton_layer_outline.get_active(); }
-       void set_layer_outline_flag(bool x) { return checkbutton_layer_outline.set_active(x); }
-
-       bool get_layer_curve_gradient_flag()const { return checkbutton_layer_curve_gradient.get_active(); }
-       void set_layer_curve_gradient_flag(bool x) { return checkbutton_layer_curve_gradient.set_active(x); }
-
-       bool get_layer_plant_flag()const { return checkbutton_layer_plant.get_active(); }
-       void set_layer_plant_flag(bool x) { return checkbutton_layer_plant.set_active(x); }
-
-       bool get_layer_link_origins_flag()const { return checkbutton_layer_link_origins.get_active(); }
-       void set_layer_link_origins_flag(bool x) { return checkbutton_layer_link_origins.set_active(x); }
-
-       void refresh_tool_options(); //to refresh the toolbox
-
-       //events
-       Smach::event_result event_stop_handler(const Smach::event& x);
-       Smach::event_result event_refresh_handler(const Smach::event& x);
-       Smach::event_result event_mouse_click_handler(const Smach::event& x);
-       Smach::event_result event_refresh_tool_options(const Smach::event& x);
-
-       //constructor destructor
-       StateRectangle_Context(CanvasView* canvas_view);
-       ~StateRectangle_Context();
-
-       //Canvas interaction
-       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
-       etl::handle<synfigapp::CanvasInterface> 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();}
-
-       //Modifying settings etc.
-       void load_settings();
-       void save_settings();
-       void reset();
-       void increment_id();
-       bool egress_on_selection_change;
-       Smach::event_result event_layer_selection_changed_handler(const Smach::event& /*x*/)
-       {
-               if(egress_on_selection_change)
-                       throw &state_normal; //throw Smach::egress_exception();
-               return Smach::RESULT_OK;
-       }
-
-       void make_rectangle(const Point& p1, const Point& p2);
-
-};     // END of class StateGradient_Context
-
-/* === M E T H O D S ======================================================= */
-
-StateRectangle::StateRectangle():
-       Smach::state<StateRectangle_Context>("rectangle")
-{
-       insert(event_def(EVENT_STOP,&StateRectangle_Context::event_stop_handler));
-       insert(event_def(EVENT_LAYER_SELECTION_CHANGED,&StateRectangle_Context::event_layer_selection_changed_handler));
-       insert(event_def(EVENT_REFRESH,&StateRectangle_Context::event_refresh_handler));
-       insert(event_def(EVENT_REFRESH_DUCKS,&StateRectangle_Context::event_refresh_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StateRectangle_Context::event_mouse_click_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DRAG,&StateRectangle_Context::event_mouse_click_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_UP,&StateRectangle_Context::event_mouse_click_handler));
-       insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateRectangle_Context::event_refresh_tool_options));
-}
-
-StateRectangle::~StateRectangle()
-{
-}
-
-void
-StateRectangle_Context::load_settings()
-{
-       String value;
-
-       //parse the arguments yargh!
-       if(settings.get_value("rectangle.id",value))
-               set_id(value);
-       else
-               set_id("Rectangle");
-
-       if(settings.get_value("rectangle.expand",value))
-               set_expand(atof(value.c_str()));
-       else
-               set_expand(0);
-
-       if(settings.get_value("rectangle.feather",value))
-               set_feather(atof(value.c_str()));
-       else
-               set_feather(0);
-
-       if(settings.get_value("rectangle.invert",value) && value != "0")
-               set_invert(true);
-       else
-               set_invert(false);
-
-       if(settings.get_value("rectangle.layer_rectangle",value) && value=="0")
-               set_layer_rectangle_flag(false);
-       else
-               set_layer_rectangle_flag(true);
-
-       if(settings.get_value("rectangle.layer_region",value) && value=="1")
-               set_layer_region_flag(true);
-       else
-               set_layer_region_flag(false);
-
-       if(settings.get_value("rectangle.layer_outline",value) && value=="1")
-               set_layer_outline_flag(true);
-       else
-               set_layer_outline_flag(false);
-
-       if(settings.get_value("rectangle.layer_curve_gradient",value) && value=="1")
-               set_layer_curve_gradient_flag(true);
-       else
-               set_layer_curve_gradient_flag(false);
-
-       if(settings.get_value("rectangle.layer_plant",value) && value=="1")
-               set_layer_plant_flag(true);
-       else
-               set_layer_plant_flag(false);
-
-       if(settings.get_value("rectangle.layer_link_origins",value) && value=="0")
-               set_layer_link_origins_flag(false);
-       else
-               set_layer_link_origins_flag(true);
-}
-
-void
-StateRectangle_Context::save_settings()
-{
-       settings.set_value("rectangle.id",get_id().c_str());
-       settings.set_value("rectangle.expand",strprintf("%f",get_expand()));
-       settings.set_value("rectangle.feather",strprintf("%f",(float)get_feather()));
-       settings.set_value("rectangle.invert",get_invert()?"1":"0");
-       settings.set_value("rectangle.layer_rectangle",get_layer_rectangle_flag()?"1":"0");
-       settings.set_value("rectangle.layer_outline",get_layer_outline_flag()?"1":"0");
-       settings.set_value("rectangle.layer_region",get_layer_region_flag()?"1":"0");
-       settings.set_value("rectangle.layer_curve_gradient",get_layer_curve_gradient_flag()?"1":"0");
-       settings.set_value("rectangle.layer_plant",get_layer_plant_flag()?"1":"0");
-       settings.set_value("rectangle.layer_link_origins",get_layer_link_origins_flag()?"1":"0");
-}
-
-void
-StateRectangle_Context::reset()
-{
-       refresh_ducks();
-}
-
-void
-StateRectangle_Context::increment_id()
-{
-       String id(get_id());
-       int number=1;
-       int digits=0;
-
-       if(id.empty())
-               id="Rectangle";
-
-       // If there is a number
-       // already at the end of the
-       // id, then remove it.
-       if(id[id.size()-1]<='9' && id[id.size()-1]>='0')
-       {
-               // figure out how many digits it is
-               for (digits = 0;
-                        (int)id.size()-1 >= digits && id[id.size()-1-digits] <= '9' && id[id.size()-1-digits] >= '0';
-                        digits++)
-                       ;
-
-               String str_number;
-               str_number=String(id,id.size()-digits,id.size());
-               id=String(id,0,id.size()-digits);
-
-               number=atoi(str_number.c_str());
-       }
-       else
-       {
-               number=1;
-               digits=3;
-       }
-
-       number++;
-
-       // Add the number back onto the id
-       {
-               const String format(strprintf("%%0%dd",digits));
-               id+=strprintf(format.c_str(),number);
-       }
-
-       // Set the ID
-       set_id(id);
-}
-
-StateRectangle_Context::StateRectangle_Context(CanvasView* canvas_view):
-       canvas_view_(canvas_view),
-       is_working(*canvas_view),
-       duckmatic_push(get_work_area()),
-       prev_workarea_layer_status_(get_work_area()->get_allow_layer_clicks()),
-       settings(synfigapp::Main::get_selected_input_device()->settings()),
-       entry_id(),
-       adj_expand(0,0,1,0.01,0.1),
-       adj_feather(0,0,1,0.01,0.1),
-       spin_expand(adj_expand,0.1,3),
-       spin_feather(adj_feather,0.1,3),
-       checkbutton_invert(_("Invert")),
-       checkbutton_layer_rectangle(_("Create Rectangle Layer")),
-       checkbutton_layer_region(_("Create Region BLine")),
-       checkbutton_layer_outline(_("Create Outline BLine")),
-       checkbutton_layer_curve_gradient(_("Create Curve Gradient BLine")),
-       checkbutton_layer_plant(_("Create Plant BLine")),
-       checkbutton_layer_link_origins(_("Link BLine Origins"))
-{
-       egress_on_selection_change=true;
-       load_settings();
-
-       // Set up the tool options dialog
-       options_table.attach(*manage(new Gtk::Label(_("Rectangle Tool"))),      0, 2,  0,  1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(entry_id,                                                                          0, 2,  1,  2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       options_table.attach(checkbutton_layer_rectangle,                                       0, 2,  2,  3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_outline,                                         0, 2,  3,  4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_region,                                          0, 2,  4,  5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_plant,                                           0, 2,  5,  6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_curve_gradient,                          0, 2,  6,  7, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_link_origins,                            0, 2,  7,  8, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       //invert flag
-       options_table.attach(checkbutton_invert,                                                        0, 2,  8,  9, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       //expand stuff
-       options_table.attach(*manage(new Gtk::Label(_("Expansion:"))),          0, 1,  9, 10, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(spin_expand,                                                                       1, 2,  9, 10, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       //feather stuff
-       options_table.attach(*manage(new Gtk::Label(_("Feather:"))),            0, 1, 10, 11, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(spin_feather,                                                                      1, 2, 10, 11, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       options_table.show_all();
-
-       //App::dialog_tool_options->set_widget(options_table);
-       refresh_tool_options();
-       App::dialog_tool_options->present();
-
-       // Turn off layer clicking
-       get_work_area()->set_allow_layer_clicks(false);
-
-       // clear out the ducks
-       get_work_area()->clear_ducks();
-
-       // Refresh the work area
-       get_work_area()->queue_draw();
-
-       get_work_area()->set_cursor(Gdk::DOTBOX);
-
-       // Hide the tables if they are showing
-       //prev_table_status=get_canvas_view()->tables_are_visible();
-       //if(prev_table_status)get_canvas_view()->hide_tables();
-
-       // Disable the time bar
-       //get_canvas_view()->set_sensitive_timebar(false);
-
-       // Connect a signal
-       //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateRectangle_Context::on_user_click));
-
-       App::toolbox->refresh();
-}
-
-void
-StateRectangle_Context::refresh_tool_options()
-{
-       App::dialog_tool_options->clear();
-       App::dialog_tool_options->set_widget(options_table);
-       App::dialog_tool_options->set_local_name(_("Rectangle Tool"));
-       App::dialog_tool_options->set_name("rectangle");
-}
-
-Smach::event_result
-StateRectangle_Context::event_refresh_tool_options(const Smach::event& /*x*/)
-{
-       refresh_tool_options();
-       return Smach::RESULT_ACCEPT;
-}
-
-StateRectangle_Context::~StateRectangle_Context()
-{
-       save_settings();
-
-       // Restore layer clicking
-       get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_);
-
-       get_work_area()->reset_cursor();
-
-       App::dialog_tool_options->clear();
-
-       // Enable the time bar
-       //get_canvas_view()->set_sensitive_timebar(true);
-
-       // Bring back the tables if they were out before
-       //if(prev_table_status)get_canvas_view()->show_tables();
-
-       // Refresh the work area
-       get_work_area()->queue_draw();
-
-       get_canvas_view()->queue_rebuild_ducks();
-
-       App::toolbox->refresh();
-}
-
-Smach::event_result
-StateRectangle_Context::event_stop_handler(const Smach::event& /*x*/)
-{
-       //throw Smach::egress_exception();
-       throw &state_normal;
-       return Smach::RESULT_OK;
-}
-
-Smach::event_result
-StateRectangle_Context::event_refresh_handler(const Smach::event& /*x*/)
-{
-       refresh_ducks();
-       return Smach::RESULT_ACCEPT;
-}
-
-void
-StateRectangle_Context::make_rectangle(const Point& _p1, const Point& _p2)
-{
-       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("New Rectangle"));
-       synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
-       Layer::Handle layer;
-
-       Canvas::Handle canvas;
-       int depth(0);
-
-       // we are temporarily using the layer to hold something
-       layer=get_canvas_view()->get_selection_manager()->get_selected_layer();
-       if(layer)
-       {
-               depth=layer->get_depth();
-               canvas=layer->get_canvas();
-       }
-
-       synfigapp::SelectionManager::LayerList layer_selection;
-       if (!getenv("SYNFIG_TOOLS_CLEAR_SELECTION"))
-               layer_selection = get_canvas_view()->get_selection_manager()->get_selected_layers();
-
-       const synfig::TransformStack& transform(get_canvas_view()->get_curr_transform_stack());
-       const Point p1(transform.unperform(_p1));
-       const Point p2(transform.unperform(_p2));
-       Real x_min, x_max, y_min, y_max;
-       if (p1[0] < p2[0]) { x_min = p1[0]; x_max = p2[0]; } else { x_min = p2[0]; x_max = p1[0]; }
-       if (p1[1] < p2[1]) { y_min = p1[1]; y_max = p2[1]; } else { y_min = p2[1]; y_max = p1[1]; }
-       x_min -= get_expand(); x_max += get_expand(); y_min -= get_expand(); y_max += get_expand();
-
-       std::vector<BLinePoint> new_list;
-       for (int i = 0; i < 4; i++)
-       {
-               new_list.push_back(*(new BLinePoint));
-               new_list[i].set_width(1);
-               new_list[i].set_vertex(Point((i==0||i==3)?x_min:x_max,
-                                                                        (i==0||i==1)?y_min:y_max));
-               new_list[i].set_tangent(Point(0,0));
-       }
-
-       ValueNode_BLine::Handle value_node_bline(ValueNode_BLine::create(new_list));
-       assert(value_node_bline);
-
-       ValueNode_Const::Handle value_node_origin(ValueNode_Const::create(Vector()));
-       assert(value_node_origin);
-
-       // Set the looping flag
-       value_node_bline->set_loop(true);
-
-       if(!canvas)
-               canvas=get_canvas_view()->get_canvas();
-
-       value_node_bline->set_member_canvas(canvas);
-
-       // count how many layers we're going to be creating
-       int layers_to_create = this->layers_to_create();
-
-       ///////////////////////////////////////////////////////////////////////////
-       //   R E C T A N G L E
-       ///////////////////////////////////////////////////////////////////////////
-
-       if (get_layer_rectangle_flag())
-       {
-               layer=get_canvas_interface()->add_layer_to("rectangle",canvas,depth);
-               if (!layer)
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                       group.cancel();
-                       return;
-               }
-               layer_selection.push_back(layer);
-
-               layer->set_param("point1",p1);
-               get_canvas_interface()->signal_layer_param_changed()(layer,"point1");
-
-               layer->set_param("point2",p2);
-               get_canvas_interface()->signal_layer_param_changed()(layer,"point2");
-
-               layer->set_param("expand",get_expand());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"expand");
-
-               layer->set_param("invert",get_invert());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
-
-               layer->set_description(get_id());
-               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-       }
-
-       ///////////////////////////////////////////////////////////////////////////
-       //   C U R V E   G R A D I E N T
-       ///////////////////////////////////////////////////////////////////////////
-
-       if(get_layer_curve_gradient_flag())
-       {
-               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
-               Layer::Handle layer(get_canvas_interface()->add_layer_to("curve_gradient",canvas,depth));
-               if (!layer)
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                       group.cancel();
-                       return;
-               }
-               layer_selection.push_back(layer);
-               layer->set_description(get_id()+_(" Gradient"));
-               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("bline")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Gradient layer"));
-                               return;
-                       }
-               }
-
-               // only link the curve gradient's origin parameter if the option is selected and we're creating more than one layer
-               if (get_layer_link_origins_flag() && layers_to_create > 1)
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("origin")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Gradient layer"));
-                               return;
-                       }
-               }
-       }
-
-       ///////////////////////////////////////////////////////////////////////////
-       //   P L A N T
-       ///////////////////////////////////////////////////////////////////////////
-
-       if(get_layer_plant_flag())
-       {
-               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
-               Layer::Handle layer(get_canvas_interface()->add_layer_to("plant",canvas,depth));
-               if (!layer)
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                       group.cancel();
-                       return;
-               }
-               layer_selection.push_back(layer);
-               layer->set_description(get_id()+_(" Plant"));
-               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("bline")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Plant layer"));
-                               return;
-                       }
-               }
-
-               // only link the plant's origin parameter if the option is selected and we're creating more than one layer
-               if (get_layer_link_origins_flag() && layers_to_create > 1)
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("origin")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Plant layer"));
-                               return;
-                       }
-               }
-       }
-
-       ///////////////////////////////////////////////////////////////////////////
-       //   R E G I O N
-       ///////////////////////////////////////////////////////////////////////////
-
-       if(get_layer_region_flag())
-       {
-               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
-               Layer::Handle layer(get_canvas_interface()->add_layer_to("region",canvas,depth));
-               if (!layer)
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                       group.cancel();
-                       return;
-               }
-               layer_selection.push_back(layer);
-               layer->set_description(get_id()+_(" Region"));
-               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
-               layer->set_param("feather",get_feather());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
-
-               layer->set_param("invert",get_invert());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
-
-               // I don't know if it's safe to reuse the same LayerParamConnect action, so I'm
-               // using 2 separate ones.
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("bline")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Region layer"));
-                               return;
-                       }
-               }
-
-               // only link the region's origin parameter if the option is selected and we're creating more than one layer
-               if (get_layer_link_origins_flag() && layers_to_create > 1)
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("origin")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Region layer"));
-                               return;
-                       }
-               }
-       }
-
-       ///////////////////////////////////////////////////////////////////////////
-       //   O U T L I N E
-       ///////////////////////////////////////////////////////////////////////////
-
-       if (get_layer_outline_flag())
-       {
-               Layer::Handle layer(get_canvas_interface()->add_layer_to("outline",canvas,depth));
-               if (!layer)
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                       group.cancel();
-                       return;
-               }
-               layer_selection.push_back(layer);
-               layer->set_description(get_id()+_(" Outline"));
-               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
-               layer->set_param("feather",get_feather());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
-
-               layer->set_param("invert",get_invert());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
-
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("bline")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Outline layer"));
-                               return;
-                       }
-               }
-
-               // only link the outline's origin parameter if the option is selected and we're creating more than one layer
-               if (get_layer_link_origins_flag() && layers_to_create > 1)
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("origin")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Outline layer"));
-                               return;
-                       }
-               }
-       }
-
-       egress_on_selection_change=false;
-       get_canvas_interface()->get_selection_manager()->clear_selected_layers();
-       get_canvas_interface()->get_selection_manager()->set_selected_layers(layer_selection);
-       egress_on_selection_change=true;
-
-       //post clean up stuff...
-       reset();
-       increment_id();
-}
-
-Smach::event_result
-StateRectangle_Context::event_mouse_click_handler(const Smach::event& x)
-{
-       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
-
-       if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_DOWN && event.button==BUTTON_LEFT)
-       {
-               point_holder=get_work_area()->snap_point_to_grid(event.pos);
-               etl::handle<Duck> duck=new Duck();
-               duck->set_point(point_holder);
-               duck->set_name("p1");
-               duck->set_type(Duck::TYPE_POSITION);
-               get_work_area()->add_duck(duck);
-
-               point2_duck=new Duck();
-               point2_duck->set_point(point_holder);
-               point2_duck->set_name("p2");
-               point2_duck->set_type(Duck::TYPE_POSITION);
-               point2_duck->set_box_duck(duck);
-               get_work_area()->add_duck(point2_duck);
-
-               return Smach::RESULT_ACCEPT;
-       }
-
-       if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_DRAG && event.button==BUTTON_LEFT)
-       {
-               if (!point2_duck) return Smach::RESULT_OK;
-               point2_duck->set_point(get_work_area()->snap_point_to_grid(event.pos));
-               get_work_area()->queue_draw();
-               return Smach::RESULT_ACCEPT;
-       }
-
-       if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_UP && event.button==BUTTON_LEFT)
-       {
-               make_rectangle(point_holder, get_work_area()->snap_point_to_grid(event.pos));
-               get_work_area()->clear_ducks();
-               return Smach::RESULT_ACCEPT;
-       }
-
-       return Smach::RESULT_OK;
-}
-
-
-void
-StateRectangle_Context::refresh_ducks()
-{
-       get_work_area()->clear_ducks();
-       get_work_area()->queue_draw();
-}
diff --git a/synfig-studio/src/gtkmm/state_rectangle.h b/synfig-studio/src/gtkmm/state_rectangle.h
deleted file mode 100644 (file)
index 131dd40..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_rectangle.h
-**     \brief Rectangle creation state
-**
-**     $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_RECTANGLE_H
-#define __SYNFIG_STUDIO_STATE_RECTANGLE_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 StateRectangle_Context;
-
-class StateRectangle : public Smach::state<StateRectangle_Context>
-{
-public:
-       StateRectangle();
-       ~StateRectangle();
-}; // END of class StateRectangle
-
-extern StateRectangle state_rectangle;
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/state_rotate.cpp b/synfig-studio/src/gtkmm/state_rotate.cpp
deleted file mode 100644 (file)
index 5463a41..0000000
+++ /dev/null
@@ -1,398 +0,0 @@
-/* === 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 <config.h>
-#endif
-
-#include <gtkmm/dialog.h>
-#include <gtkmm/entry.h>
-
-#include <synfig/valuenode_dynamiclist.h>
-#include <synfigapp/action_system.h>
-
-#include "state_rotate.h"
-#include "state_normal.h"
-#include "canvasview.h"
-#include "workarea.h"
-#include "app.h"
-
-#include <synfigapp/action.h>
-#include "event_mouse.h"
-#include "event_layerclick.h"
-#include "toolbox.h"
-#include "dialog_tooloptions.h"
-#include <gtkmm/optionmenu.h>
-#include "duck.h"
-#include <synfig/angle.h>
-#include <synfigapp/main.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 ========================================================= */
-
-#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<synfig::Vector> positions;
-
-
-       bool bad_drag;
-       bool move_only;
-
-public:
-       etl::handle<CanvasView> 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<synfigapp::CanvasInterface> get_canvas_interface()const{return canvas_view_->canvas_interface();}
-};
-
-
-class studio::StateRotate_Context : public sigc::trackable
-{
-       etl::handle<CanvasView> canvas_view_;
-       CanvasView::IsWorking is_working;
-
-       synfigapp::Settings& settings;
-
-       etl::handle<DuckDrag_Rotate> 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<CanvasView>& get_canvas_view()const{return canvas_view_;}
-       etl::handle<synfigapp::CanvasInterface> 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<StateRotate_Context>("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<etl::handle<Duck> >::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<etl::handle<Duck> >::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
deleted file mode 100644 (file)
index e2caafe..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/* === 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<StateRotate_Context>
-{
-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
deleted file mode 100644 (file)
index edfb89b..0000000
+++ /dev/null
@@ -1,389 +0,0 @@
-/* === 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 <config.h>
-#endif
-
-#include <gtkmm/dialog.h>
-#include <gtkmm/entry.h>
-
-#include <synfig/valuenode_dynamiclist.h>
-#include <synfigapp/action_system.h>
-
-#include "state_scale.h"
-#include "state_normal.h"
-#include "canvasview.h"
-#include "workarea.h"
-#include "app.h"
-
-#include <synfigapp/action.h>
-#include "event_mouse.h"
-#include "event_layerclick.h"
-#include "toolbox.h"
-#include "dialog_tooloptions.h"
-#include <gtkmm/optionmenu.h>
-#include "duck.h"
-#include <synfigapp/main.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 ======================================================= */
-
-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<synfig::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<CanvasView> canvas_view_;
-       CanvasView::IsWorking is_working;
-
-       synfigapp::Settings& settings;
-
-       etl::handle<DuckDrag_Scale> 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<CanvasView>& get_canvas_view()const{return canvas_view_;}
-       etl::handle<synfigapp::CanvasInterface> 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<StateScale_Context>("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<etl::handle<Duck> >::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<etl::handle<Duck> >::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]>-EPSILON)
-               vect[0]=1;
-       if(vect[1]<EPSILON && 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
deleted file mode 100644 (file)
index f351c12..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/* === 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<StateScale_Context>
-{
-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
deleted file mode 100644 (file)
index f8b77a3..0000000
+++ /dev/null
@@ -1,508 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_sketch.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 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 <config.h>
-#endif
-
-#include <gtkmm/dialog.h>
-#include <gtkmm/entry.h>
-
-#include <synfig/valuenode_dynamiclist.h>
-
-#include "state_sketch.h"
-#include "state_normal.h"
-#include "state_stroke.h"
-#include "canvasview.h"
-#include "workarea.h"
-#include "app.h"
-#include <synfig/valuenode_bline.h>
-#include <ETL/hermite>
-#include <ETL/calculus>
-#include <utility>
-#include "event_mouse.h"
-#include "event_layerclick.h"
-#include "toolbox.h"
-
-#include <synfigapp/blineconvert.h>
-#include <synfigapp/main.h>
-
-#include <ETL/gaussian>
-
-#include "dialog_tooloptions.h"
-
-#include <gtkmm/table.h>
-#include <gtkmm/label.h>
-#include <gtkmm/button.h>
-#include <gtkmm/checkbutton.h>
-#include <gtkmm/actiongroup.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 ======================================================= */
-
-StateSketch studio::state_sketch;
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-class studio::StateSketch_Context : public sigc::trackable
-{
-       Glib::RefPtr<Gtk::ActionGroup> action_group;
-
-       etl::handle<CanvasView> canvas_view_;
-       CanvasView::IsWorking is_working;
-
-       bool prev_table_status;
-       bool prev_workarea_layer_status_;
-
-       Gtk::Table options_table;
-       Gtk::Button button_clear_sketch;
-       Gtk::Button button_undo_stroke;
-       Gtk::Button button_save_sketch;
-       Gtk::Button button_load_sketch;
-       Gtk::CheckButton checkbutton_show_sketch;
-
-       void clear_sketch();
-       void save_sketch();
-       void load_sketch();
-       void undo_stroke();
-       void toggle_show_sketch();
-
-public:
-
-       Smach::event_result event_stop_handler(const Smach::event& x);
-
-       Smach::event_result event_refresh_handler(const Smach::event& x);
-
-       Smach::event_result event_mouse_down_handler(const Smach::event& x);
-
-       Smach::event_result event_stroke(const Smach::event& x);
-
-       Smach::event_result event_refresh_tool_options(const Smach::event& x);
-       Smach::event_result event_yield_tool_options(const Smach::event& x);
-
-       void refresh_tool_options();
-       void yield_tool_options();
-
-       StateSketch_Context(CanvasView* canvas_view);
-
-       ~StateSketch_Context();
-
-       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
-       etl::handle<synfigapp::CanvasInterface> get_canvas_interface()const{return canvas_view_->canvas_interface();}
-       synfig::Time get_time()const { return get_canvas_interface()->get_time(); }
-       synfig::Canvas::Handle get_canvas()const{return canvas_view_->get_canvas();}
-       WorkArea * get_work_area()const{return canvas_view_->get_work_area();}
-
-};     // END of class StateSketch_Context
-
-
-/* === M E T H O D S ======================================================= */
-
-StateSketch::StateSketch():
-       Smach::state<StateSketch_Context>("sketch")
-{
-       insert(event_def(EVENT_STOP,&StateSketch_Context::event_stop_handler));
-       //insert(event_def(EVENT_REFRESH,&StateSketch_Context::event_refresh_handler));
-       insert(event_def(EVENT_REFRESH_DUCKS,&StateSketch_Context::event_refresh_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StateSketch_Context::event_mouse_down_handler));
-       insert(event_def(EVENT_WORKAREA_STROKE,&StateSketch_Context::event_stroke));
-       insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateSketch_Context::event_refresh_tool_options));
-       insert(event_def(EVENT_YIELD_TOOL_OPTIONS,&StateSketch_Context::event_yield_tool_options));
-}
-
-StateSketch::~StateSketch()
-{
-}
-
-void
-StateSketch_Context::save_sketch()
-{
-       synfig::String filename(basename(get_canvas()->get_file_name())+".sketch");
-
-       while(App::dialog_save_file(_("Save Sketch"), filename, SKETCH_DIR_PREFERENCE))
-       {
-               // If the filename still has wildcards, then we should
-               // continue looking for the file we want
-               if(find(filename.begin(),filename.end(),'*')!=filename.end())
-                       continue;
-
-               if(get_work_area()->save_sketch(filename))
-                       break;
-
-               get_canvas_view()->get_ui_interface()->error(_("Unable to save sketch"));
-       }
-}
-
-void
-StateSketch_Context::load_sketch()
-{
-       synfig::String filename(basename(get_canvas()->get_file_name())+".sketch");
-
-       while(App::dialog_open_file(_("Load Sketch"), filename, SKETCH_DIR_PREFERENCE))
-       {
-               // If the filename still has wildcards, then we should
-               // continue looking for the file we want
-               if(find(filename.begin(),filename.end(),'*')!=filename.end())
-                       continue;
-
-               if(get_work_area()->load_sketch(filename))
-                       break;
-
-               get_canvas_view()->get_ui_interface()->error(_("Unable to load sketch"));
-       }
-       get_work_area()->queue_draw();
-}
-
-void
-StateSketch_Context::clear_sketch()
-{
-       get_work_area()->clear_persistent_strokes();
-
-       // if the sketch is currently shown, make sure it is updated
-       //! \todo is there a better way than this of getting Duckmatic to update its stroke_list_?
-       if (checkbutton_show_sketch.get_active())
-       {
-               get_work_area()->set_show_persistent_strokes(false);
-               get_work_area()->set_show_persistent_strokes(true);
-               get_canvas_view()->get_smach().process_event(EVENT_REFRESH);
-       }
-}
-
-void
-StateSketch_Context::undo_stroke()
-{
-       if(!get_work_area()->persistent_stroke_list().empty())
-       {
-               get_work_area()->persistent_stroke_list().pop_back();
-
-               // if the sketch is currently shown, make sure it is updated
-               //! \todo is there a better way than this of getting Duckmatic to update its stroke_list_?
-               if (checkbutton_show_sketch.get_active())
-               {
-                       get_work_area()->set_show_persistent_strokes(false);
-                       get_work_area()->set_show_persistent_strokes(true);
-                       get_canvas_view()->get_smach().process_event(EVENT_REFRESH);
-               }
-       }
-}
-
-void
-StateSketch_Context::toggle_show_sketch()
-{
-       get_work_area()->set_show_persistent_strokes(checkbutton_show_sketch.get_active());
-       get_work_area()->queue_draw();
-}
-
-StateSketch_Context::StateSketch_Context(CanvasView* canvas_view):
-       action_group(Gtk::ActionGroup::create("action_group_state_sketch")),
-       canvas_view_(canvas_view),
-       is_working(*canvas_view),
-       prev_workarea_layer_status_(get_work_area()->get_allow_layer_clicks()),
-       button_clear_sketch(_("Clear Sketch")),
-       button_undo_stroke(_("Undo Stroke")),
-       button_save_sketch(_("Save Sketch")),
-       button_load_sketch(_("Load Sketch")),
-       checkbutton_show_sketch(_("Show Sketch"))
-{
-    Glib::ustring ui_info =
-       "<ui>"
-       "       <toolbar action='toolbar-sketch'>"
-       "       <toolitem action='sketch-undo' />"
-       "       <toolitem action='sketch-clear' />"
-       "       <toolitem action='sketch-save-as' />"
-       "       <toolitem action='sketch-open' />"
-       "       </toolbar>"
-       "</ui>";
-
-       action_group->add(Gtk::Action::create(
-               "sketch-undo",
-               Gtk::StockID("gtk-undo"),
-               _("Undo Last Stroke"),
-               _("Undo Last Stroke")
-       ),
-               sigc::mem_fun(
-                       *this,
-                       &studio::StateSketch_Context::undo_stroke
-               )
-       );
-
-       action_group->add(Gtk::Action::create(
-               "sketch-clear",
-               Gtk::StockID("gtk-clear"),
-               _("Clear Sketch"),
-               _("Clear Sketch")
-       ),
-               sigc::mem_fun(
-                       *this,
-                       &studio::StateSketch_Context::clear_sketch
-               )
-       );
-
-       action_group->add(Gtk::Action::create(
-               "sketch-save-as",
-               Gtk::StockID("gtk-save-as"),
-               _("Save Sketch As..."),
-               _("Save Sketch As...")
-       ),
-               sigc::mem_fun(
-                       *this,
-                       &studio::StateSketch_Context::save_sketch
-               )
-       );
-
-       action_group->add(Gtk::Action::create(
-               "sketch-save-as",
-               Gtk::StockID("gtk-save-as"),
-               _("Save Sketch As..."),
-               _("Save Sketch As...")
-       ),
-               sigc::mem_fun(
-                       *this,
-                       &studio::StateSketch_Context::save_sketch
-               )
-       );
-
-       action_group->add(Gtk::Action::create(
-               "sketch-open",
-               Gtk::StockID("gtk-open"),
-               _("Open a Sketch"),
-               _("Open a Sketch")
-       ),
-               sigc::mem_fun(
-                       *this,
-                       &studio::StateSketch_Context::load_sketch
-               )
-       );
-
-       action_group->add( Gtk::Action::create("toolbar-sketch", "Sketch Toolbar") );
-
-       App::ui_manager()->add_ui_from_string(ui_info);
-
-       checkbutton_show_sketch.set_active(get_work_area()->get_show_persistent_strokes());
-
-       button_clear_sketch.signal_clicked().connect(sigc::mem_fun(*this,&studio::StateSketch_Context::clear_sketch));
-       button_undo_stroke.signal_clicked().connect(sigc::mem_fun(*this,&studio::StateSketch_Context::undo_stroke));
-       button_save_sketch.signal_clicked().connect(sigc::mem_fun(*this,&studio::StateSketch_Context::save_sketch));
-       button_load_sketch.signal_clicked().connect(sigc::mem_fun(*this,&studio::StateSketch_Context::load_sketch));
-       checkbutton_show_sketch.signal_clicked().connect(sigc::mem_fun(*this,&studio::StateSketch_Context::toggle_show_sketch));
-
-       options_table.attach(*manage(new Gtk::Label(_("Sketch Tool"))), 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_show_sketch,                                   0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       //options_table.attach(button_undo_stroke, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       //options_table.attach(button_clear_sketch, 0, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       //options_table.attach(button_save_sketch, 0, 1, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       //options_table.attach(button_load_sketch, 1, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       options_table.show_all();
-       refresh_tool_options();
-       App::dialog_tool_options->present();
-
-       // Turn off layer clicking
-       get_work_area()->set_allow_layer_clicks(false);
-
-       get_work_area()->set_cursor(Gdk::PENCIL);
-
-       // Turn off duck clicking
-       get_work_area()->set_allow_duck_clicks(false);
-
-       // clear out the ducks
-       //get_work_area()->clear_ducks();
-
-       // Refresh the work area
-       //get_work_area()->queue_draw();
-
-       // Hide the tables if they are showing
-       prev_table_status=get_canvas_view()->tables_are_visible();
-       //if(prev_table_status)get_canvas_view()->hide_tables();
-
-       // Disable the time bar
-       //get_canvas_view()->set_sensitive_timebar(false);
-
-       // Connect a signal
-       //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateSketch_Context::on_user_click));
-
-       App::toolbox->refresh();
-}
-
-StateSketch_Context::~StateSketch_Context()
-{
-       get_work_area()->reset_cursor();
-
-       App::dialog_tool_options->clear();
-
-       // Restore layer clicking
-       get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_);
-
-       // Restore duck clicking
-       get_work_area()->set_allow_duck_clicks(true);
-
-       // Enable the time bar
-       //get_canvas_view()->set_sensitive_timebar(true);
-
-       // Bring back the tables if they were out before
-       if(prev_table_status)get_canvas_view()->show_tables();
-
-       // Refresh the work area
-       //get_work_area()->queue_draw();
-
-       App::toolbox->refresh();
-}
-
-void
-StateSketch_Context::yield_tool_options()
-{
-       App::dialog_tool_options->clear();
-       App::ui_manager()->remove_action_group(action_group);
-}
-
-void
-StateSketch_Context::refresh_tool_options()
-{
-       App::dialog_tool_options->clear();
-       App::dialog_tool_options->set_widget(options_table);
-       App::dialog_tool_options->set_local_name(_("Sketch Tool"));
-       App::dialog_tool_options->set_name("sketch");
-
-       App::ui_manager()->insert_action_group(action_group);
-       App::dialog_tool_options->set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-sketch")));
-
-       /*
-       App::dialog_tool_options->add_button(
-               Gtk::StockID("gtk-undo"),
-               _("Undo Last Stroke")
-       )->signal_clicked().connect(
-               sigc::mem_fun(
-                       *this,
-                       &studio::StateSketch_Context::undo_stroke
-               )
-       );
-       App::dialog_tool_options->add_button(
-               Gtk::StockID("gtk-clear"),
-               _("Clear Sketch")
-       )->signal_clicked().connect(
-               sigc::mem_fun(
-                       *this,
-                       &studio::StateSketch_Context::clear_sketch
-               )
-       );
-       App::dialog_tool_options->add_button(
-               Gtk::StockID("gtk-save"),
-               _("Save Sketch to a File")
-       )->signal_clicked().connect(
-               sigc::mem_fun(
-                       *this,
-                       &studio::StateSketch_Context::save_sketch
-               )
-       );
-
-       App::dialog_tool_options->add_button(
-               Gtk::StockID("gtk-open"),
-               _("Open a Sketch")
-       )->signal_clicked().connect(
-               sigc::mem_fun(
-                       *this,
-                       &studio::StateSketch_Context::load_sketch
-               )
-       );
-       */
-       //button_clear_sketch.signal_clicked().connect(sigc::mem_fun(*this,&studio::StateSketch_Context::clear_sketch));
-       //button_undo_stroke.signal_clicked().connect(sigc::mem_fun(*this,&studio::StateSketch_Context::undo_stroke));
-       //button_save_sketch.signal_clicked().connect(sigc::mem_fun(*this,&studio::StateSketch_Context::save_sketch));
-       //button_load_sketch.signal_clicked().connect(sigc::mem_fun(*this,&studio::StateSketch_Context::load_sketch));
-       //checkbutton_show_sketch.signal_clicked().connect(sigc::mem_fun(*this,&studio::StateSketch_Context::toggle_show_sketch));
-}
-
-Smach::event_result
-StateSketch_Context::event_refresh_tool_options(const Smach::event& /*x*/)
-{
-       refresh_tool_options();
-       return Smach::RESULT_ACCEPT;
-}
-
-Smach::event_result
-StateSketch_Context::event_yield_tool_options(const Smach::event& /*x*/)
-{
-       yield_tool_options();
-       return Smach::RESULT_ACCEPT;
-}
-
-Smach::event_result
-StateSketch_Context::event_stop_handler(const Smach::event& /*x*/)
-{
-       //throw Smach::egress_exception();
-       throw &state_normal;
-       return Smach::RESULT_OK;
-}
-
-Smach::event_result
-StateSketch_Context::event_refresh_handler(const Smach::event& /*x*/)
-{
-       return Smach::RESULT_ACCEPT;
-}
-
-Smach::event_result
-StateSketch_Context::event_mouse_down_handler(const Smach::event& x)
-{
-       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
-       switch(event.button)
-       {
-       case BUTTON_LEFT:
-               {
-                       // Enter the stroke state to get the stroke
-                       get_canvas_view()->get_smach().push_state(&state_stroke);
-                       return Smach::RESULT_ACCEPT;
-               }
-
-       default:
-               return Smach::RESULT_OK;
-       }
-}
-
-Smach::event_result
-StateSketch_Context::event_stroke(const Smach::event& x)
-{
-       const EventStroke& event(*reinterpret_cast<const EventStroke*>(&x));
-
-       assert(event.stroke_data);
-
-       get_work_area()->add_persistent_stroke(event.stroke_data,synfigapp::Main::get_outline_color());
-
-       return Smach::RESULT_ACCEPT;
-}
diff --git a/synfig-studio/src/gtkmm/state_sketch.h b/synfig-studio/src/gtkmm/state_sketch.h
deleted file mode 100644 (file)
index 301c81d..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_sketch.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_SKETCH_H
-#define __SYNFIG_STUDIO_STATE_SKETCH_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 StateSketch_Context;
-
-class StateSketch : public Smach::state<StateSketch_Context>
-{
-public:
-       StateSketch();
-       ~StateSketch();
-}; // END of class StateSketch
-
-extern StateSketch state_sketch;
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/state_smoothmove.cpp b/synfig-studio/src/gtkmm/state_smoothmove.cpp
deleted file mode 100644 (file)
index f42df35..0000000
+++ /dev/null
@@ -1,388 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_smoothmove.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**  Copyright (c) 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 <config.h>
-#endif
-
-#include <gtkmm/dialog.h>
-#include <gtkmm/entry.h>
-
-#include <synfig/valuenode_blinecalcvertex.h>
-#include <synfig/valuenode_composite.h>
-#include <synfig/valuenode_dynamiclist.h>
-#include <synfigapp/action_system.h>
-
-#include "state_smoothmove.h"
-#include "state_normal.h"
-#include "canvasview.h"
-#include "workarea.h"
-#include "app.h"
-
-#include <synfigapp/action.h>
-#include "event_mouse.h"
-#include "event_layerclick.h"
-#include "toolbox.h"
-#include "dialog_tooloptions.h"
-#include <gtkmm/optionmenu.h>
-#include "duck.h"
-#include "onemoment.h"
-#include <synfigapp/main.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 ======================================================= */
-
-StateSmoothMove studio::state_smooth_move;
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-class DuckDrag_SmoothMove : public DuckDrag_Base
-{
-       float radius;
-
-       synfig::Vector last_translate_;
-       synfig::Vector drag_offset_;
-       synfig::Vector snap;
-
-       std::vector<synfig::Vector> last_;
-       std::vector<synfig::Vector> positions;
-
-public:
-       DuckDrag_SmoothMove();
-       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);
-
-       void set_radius(float x) { radius=x; }
-       float get_radius()const { return radius; }
-};
-
-
-class studio::StateSmoothMove_Context : public sigc::trackable
-{
-       etl::handle<CanvasView> canvas_view_;
-       CanvasView::IsWorking is_working;
-
-       //Duckmatic::Push duckmatic_push;
-
-       synfigapp::Settings& settings;
-
-       etl::handle<DuckDrag_SmoothMove> duck_dragger_;
-
-       Gtk::Table options_table;
-
-       Gtk::Adjustment  adj_radius;
-       Gtk::SpinButton  spin_radius;
-
-       float pressure;
-
-public:
-       float get_radius()const { return adj_radius.get_value(); }
-       void set_radius(float x) { return adj_radius.set_value(x); }
-
-       void refresh_radius() { duck_dragger_->set_radius(get_radius()*pressure); }
-
-       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();
-
-       StateSmoothMove_Context(CanvasView* canvas_view);
-
-       ~StateSmoothMove_Context();
-
-       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
-       etl::handle<synfigapp::CanvasInterface> 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 StateSmoothMove_Context
-
-/* === M E T H O D S ======================================================= */
-
-StateSmoothMove::StateSmoothMove():
-       Smach::state<StateSmoothMove_Context>("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()
-{
-}
-
-void
-StateSmoothMove_Context::load_settings()
-{
-       String value;
-
-       if(settings.get_value("smooth_move.radius",value))
-               set_radius(atof(value.c_str()));
-       else
-               set_radius(1.0f);
-}
-
-void
-StateSmoothMove_Context::save_settings()
-{
-       settings.set_value("smooth_move.radius",strprintf("%f",get_radius()));
-}
-
-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()),
-       adj_radius(1,0,100000,0.01,0.1),
-       spin_radius(adj_radius,0.1,3)
-{
-       pressure=1.0f;
-
-       // Set up the tool options dialog
-       options_table.attach(*manage(new Gtk::Label(_("SmoothMove Tool"))),     0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(*manage(new Gtk::Label(_("Radius"))),                      0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(spin_radius,                                                                       0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       spin_radius.signal_value_changed().connect(sigc::mem_fun(*this,&StateSmoothMove_Context::refresh_radius));
-
-       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_);
-
-       App::toolbox->refresh();
-
-       get_work_area()->set_cursor(Gdk::FLEUR);
-       //get_work_area()->reset_cursor();
-
-       load_settings();
-}
-
-void
-StateSmoothMove_Context::refresh_tool_options()
-{
-       App::dialog_tool_options->clear();
-       App::dialog_tool_options->set_widget(options_table);
-       App::dialog_tool_options->set_local_name(_("Smooth Move"));
-       App::dialog_tool_options->set_name("smooth_move");
-}
-
-Smach::event_result
-StateSmoothMove_Context::event_refresh_tool_options(const Smach::event& /*x*/)
-{
-       refresh_tool_options();
-       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_work_area()->reset_cursor();
-
-       App::dialog_tool_options->clear();
-
-       App::toolbox->refresh();
-}
-
-
-
-
-DuckDrag_SmoothMove::DuckDrag_SmoothMove():radius(1.0f)
-{
-}
-
-void
-DuckDrag_SmoothMove::begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& offset)
-{
-       last_translate_=Vector(0,0);
-               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);
-
-       last_.clear();
-       positions.clear();
-       const DuckList selected_ducks(duckmatic->get_selected_ducks());
-       DuckList::const_iterator iter;
-       int i;
-       for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
-       {
-               last_.push_back(Vector(0,0));
-               positions.push_back((*iter)->get_trans_point());
-       }
-}
-
-void
-DuckDrag_SmoothMove::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector)
-{
-       const DuckList selected_ducks(duckmatic->get_selected_ducks());
-       DuckList::const_iterator iter;
-       synfig::Vector vect(duckmatic->snap_point_to_grid(vector)-drag_offset_+snap);
-
-       int i;
-
-       Time time(duckmatic->get_time());
-
-       // process vertex and position ducks first
-       for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
-       {
-               // skip this duck if it is NOT a vertex or a position
-               if (((*iter)->get_type() != Duck::TYPE_VERTEX &&
-                        (*iter)->get_type() != Duck::TYPE_POSITION))
-                       continue;
-               Point p(positions[i]);
-
-               float dist(1.0f-(p-drag_offset_).mag()/get_radius());
-               if(dist<0)
-                       dist=0;
-
-               last_[i]=vect*dist;
-               (*iter)->set_trans_point(p+last_[i], time);
-       }
-
-       // then process non vertex and non position ducks
-       for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
-       {
-               // skip this duck if it IS a vertex or a position
-               if (!((*iter)->get_type() != Duck::TYPE_VERTEX &&
-                        (*iter)->get_type() != Duck::TYPE_POSITION))
-                       continue;
-               Point p(positions[i]);
-
-               float dist(1.0f-(p-drag_offset_).mag()/get_radius());
-               if(dist<0)
-                       dist=0;
-
-               last_[i]=vect*dist;
-               (*iter)->set_trans_point(p+last_[i], time);
-       }
-
-       // then patch up the tangents for the vertices we've moved
-       duckmatic->update_ducks();
-
-       last_translate_=vect;
-       //snap=Vector(0,0);
-}
-
-bool
-DuckDrag_SmoothMove::end_duck_drag(Duckmatic* duckmatic)
-{
-       //synfig::info("end_duck_drag(): Diff= %f",last_translate_.mag());
-       if(last_translate_.mag()>0.0001)
-       {
-               const DuckList selected_ducks(duckmatic->get_selected_ducks());
-               DuckList::const_iterator iter;
-
-               int i;
-
-               smart_ptr<OneMoment> wait;if(selected_ducks.size()>20)wait.spawn();
-
-               for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
-               {
-                       if(last_[i].mag()>0.0001)
-                               {
-                               if ((*iter)->get_type() == Duck::TYPE_ANGLE)
-                                       {
-                                               if(!(*iter)->signal_edited_angle()((*iter)->get_rotations()))
-                                               {
-                                                       throw String("Bad edit");
-                                               }
-                                       }
-                                       else if (App::restrict_radius_ducks &&
-                                                        (*iter)->is_radius())
-                                       {
-                                               Point point((*iter)->get_point());
-                                               bool changed = false;
-
-                                               if (point[0] < 0)
-                                               {
-                                                       point[0] = 0;
-                                                       changed = true;
-                                               }
-                                               if (point[1] < 0)
-                                               {
-                                                       point[1] = 0;
-                                                       changed = true;
-                                               }
-
-                                               if (changed) (*iter)->set_point(point);
-
-                                               if(!(*iter)->signal_edited()(point))
-                                               {
-                                                       throw String("Bad edit");
-                                               }
-                                       }
-                                       else
-                                       {
-                                               if(!(*iter)->signal_edited()((*iter)->get_point()))
-                                               {
-                                                       throw String("Bad edit");
-                                               }
-                                       }
-                               }
-               }
-               //duckmatic->get_selected_ducks()=new_set;
-               //duckmatic->refresh_selected_ducks();
-               return true;
-       }
-       else
-       {
-               duckmatic->signal_user_click_selected_ducks(0);
-               return false;
-       }
-}
diff --git a/synfig-studio/src/gtkmm/state_smoothmove.h b/synfig-studio/src/gtkmm/state_smoothmove.h
deleted file mode 100644 (file)
index 07442af..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_smoothmove.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_SMOOTHMOVE_H
-#define __SYNFIG_STUDIO_STATE_SMOOTHMOVE_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 StateSmoothMove_Context;
-
-class StateSmoothMove : public Smach::state<StateSmoothMove_Context>
-{
-public:
-       StateSmoothMove();
-       ~StateSmoothMove();
-}; // END of class StateSmoothMove
-
-extern StateSmoothMove state_smooth_move;
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/state_star.cpp b/synfig-studio/src/gtkmm/state_star.cpp
deleted file mode 100644 (file)
index 270571a..0000000
+++ /dev/null
@@ -1,1091 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_star.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 <config.h>
-#endif
-
-#include <gtkmm/dialog.h>
-#include <gtkmm/entry.h>
-
-#include <synfig/valuenode_dynamiclist.h>
-#include <synfigapp/action_system.h>
-#include <synfig/valuenode_bline.h>
-
-#include "state_star.h"
-#include "state_normal.h"
-#include "canvasview.h"
-#include "workarea.h"
-#include "app.h"
-
-#include <synfigapp/action.h>
-#include "event_mouse.h"
-#include "event_layerclick.h"
-#include "toolbox.h"
-#include "dialog_tooloptions.h"
-#include <gtkmm/optionmenu.h>
-#include "duck.h"
-#include "widget_enum.h"
-#include <synfigapp/main.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 ======================================================= */
-
-StateStar studio::state_star;
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-class studio::StateStar_Context : public sigc::trackable
-{
-       etl::handle<CanvasView> canvas_view_;
-       CanvasView::IsWorking is_working;
-
-       Duckmatic::Push duckmatic_push;
-
-       Point point_holder;
-
-       etl::handle<Duck> point2_duck;
-
-       void refresh_ducks();
-
-       bool prev_workarea_layer_status_;
-
-       //Toolbox settings
-       synfigapp::Settings& settings;
-
-       //Toolbox display
-       Gtk::Table options_table;
-
-       Gtk::Entry              entry_id; //what to name the layer
-
-       Gtk::Adjustment adj_feather;
-       Gtk::Adjustment adj_number_of_points;
-       Gtk::Adjustment adj_inner_tangent;
-       Gtk::Adjustment adj_outer_tangent;
-       Gtk::Adjustment adj_inner_width;
-       Gtk::Adjustment adj_outer_width;
-       Gtk::Adjustment adj_radius_ratio;
-       Gtk::Adjustment adj_angle_offset;
-       Gtk::SpinButton spin_feather;
-       Gtk::SpinButton spin_number_of_points;
-       Gtk::SpinButton spin_inner_tangent;
-       Gtk::SpinButton spin_outer_tangent;
-       Gtk::SpinButton spin_inner_width;
-       Gtk::SpinButton spin_outer_width;
-       Gtk::SpinButton spin_radius_ratio;
-       Gtk::SpinButton spin_angle_offset;
-
-       Gtk::CheckButton checkbutton_invert;
-       Gtk::CheckButton checkbutton_regular_polygon;
-       Gtk::CheckButton checkbutton_layer_star;
-       Gtk::CheckButton checkbutton_layer_region;
-       Gtk::CheckButton checkbutton_layer_outline;
-       Gtk::CheckButton checkbutton_layer_curve_gradient;
-       Gtk::CheckButton checkbutton_layer_plant;
-       Gtk::CheckButton checkbutton_layer_link_origins;
-       Gtk::CheckButton checkbutton_layer_origins_at_center;
-
-public:
-
-       // this only counts the layers which will have their origins linked
-       int layers_to_create()const
-       {
-               return
-                       (get_layer_star_flag() && get_layer_origins_at_center_flag()) +
-                       get_layer_region_flag() +
-                       get_layer_outline_flag() +
-                       get_layer_curve_gradient_flag() +
-                       get_layer_plant_flag();
-       }
-
-       synfig::String get_id()const { return entry_id.get_text(); }
-       void set_id(const synfig::String& x) { return entry_id.set_text(x); }
-
-       Real get_feather()const { return adj_feather.get_value(); }
-       void set_feather(Real f) { adj_feather.set_value(f); }
-
-       Real get_number_of_points()const { return adj_number_of_points.get_value(); }
-       void set_number_of_points(Real f) { adj_number_of_points.set_value(f); }
-
-       Real get_inner_tangent()const { return adj_inner_tangent.get_value(); }
-       void set_inner_tangent(Real f) { adj_inner_tangent.set_value(f); }
-
-       Real get_outer_tangent()const { return adj_outer_tangent.get_value(); }
-       void set_outer_tangent(Real f) { adj_outer_tangent.set_value(f); }
-
-       Real get_inner_width()const { return adj_inner_width.get_value(); }
-       void set_inner_width(Real f) { adj_inner_width.set_value(f); }
-
-       Real get_outer_width()const { return adj_outer_width.get_value(); }
-       void set_outer_width(Real f) { adj_outer_width.set_value(f); }
-
-       Real get_radius_ratio()const { return adj_radius_ratio.get_value(); }
-       void set_radius_ratio(Real f) { adj_radius_ratio.set_value(f); }
-
-       Real get_angle_offset()const { return adj_angle_offset.get_value(); }
-       void set_angle_offset(Real f) { adj_angle_offset.set_value(f); }
-
-       bool get_invert()const { return checkbutton_invert.get_active(); }
-       void set_invert(bool i) { checkbutton_invert.set_active(i); }
-
-       bool get_regular_polygon()const { return checkbutton_regular_polygon.get_active(); }
-       void set_regular_polygon(bool i) { checkbutton_regular_polygon.set_active(i); }
-
-       bool get_layer_star_flag()const { return checkbutton_layer_star.get_active(); }
-       void set_layer_star_flag(bool x) { return checkbutton_layer_star.set_active(x); }
-
-       bool get_layer_region_flag()const { return checkbutton_layer_region.get_active(); }
-       void set_layer_region_flag(bool x) { return checkbutton_layer_region.set_active(x); }
-
-       bool get_layer_outline_flag()const { return checkbutton_layer_outline.get_active(); }
-       void set_layer_outline_flag(bool x) { return checkbutton_layer_outline.set_active(x); }
-
-       bool get_layer_curve_gradient_flag()const { return checkbutton_layer_curve_gradient.get_active(); }
-       void set_layer_curve_gradient_flag(bool x) { return checkbutton_layer_curve_gradient.set_active(x); }
-
-       bool get_layer_plant_flag()const { return checkbutton_layer_plant.get_active(); }
-       void set_layer_plant_flag(bool x) { return checkbutton_layer_plant.set_active(x); }
-
-       bool get_layer_link_origins_flag()const { return checkbutton_layer_link_origins.get_active(); }
-       void set_layer_link_origins_flag(bool x) { return checkbutton_layer_link_origins.set_active(x); }
-
-       bool get_layer_origins_at_center_flag()const { return checkbutton_layer_origins_at_center.get_active(); }
-       void set_layer_origins_at_center_flag(bool x) { return checkbutton_layer_origins_at_center.set_active(x); }
-
-       void refresh_tool_options(); //to refresh the toolbox
-
-       //events
-       Smach::event_result event_stop_handler(const Smach::event& x);
-       Smach::event_result event_refresh_handler(const Smach::event& x);
-       Smach::event_result event_mouse_click_handler(const Smach::event& x);
-       Smach::event_result event_refresh_tool_options(const Smach::event& x);
-
-       //constructor destructor
-       StateStar_Context(CanvasView* canvas_view);
-       ~StateStar_Context();
-
-       //Canvas interaction
-       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
-       etl::handle<synfigapp::CanvasInterface> 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();}
-
-       //Modifying settings etc.
-       void load_settings();
-       void save_settings();
-       void reset();
-       void increment_id();
-       bool egress_on_selection_change;
-       Smach::event_result event_layer_selection_changed_handler(const Smach::event& /*x*/)
-       {
-               if(egress_on_selection_change)
-                       throw &state_normal; //throw Smach::egress_exception();
-               return Smach::RESULT_OK;
-       }
-
-       void make_star(const Point& p1, const Point& p2);
-
-};     // END of class StateStar_Context
-
-/* === M E T H O D S ======================================================= */
-
-StateStar::StateStar():
-       Smach::state<StateStar_Context>("star")
-{
-       insert(event_def(EVENT_LAYER_SELECTION_CHANGED,&StateStar_Context::event_layer_selection_changed_handler));
-       insert(event_def(EVENT_STOP,&StateStar_Context::event_stop_handler));
-       insert(event_def(EVENT_REFRESH,&StateStar_Context::event_refresh_handler));
-       insert(event_def(EVENT_REFRESH_DUCKS,&StateStar_Context::event_refresh_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StateStar_Context::event_mouse_click_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DRAG,&StateStar_Context::event_mouse_click_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_UP,&StateStar_Context::event_mouse_click_handler));
-       insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateStar_Context::event_refresh_tool_options));
-}
-
-StateStar::~StateStar()
-{
-}
-
-void
-StateStar_Context::load_settings()
-{
-       String value;
-
-       //parse the arguments yargh!
-       if(settings.get_value("star.id",value))
-               set_id(value);
-       else
-               set_id("Star");
-
-       if(settings.get_value("star.feather",value))
-               set_feather(atof(value.c_str()));
-       else
-               set_feather(0);
-
-       if(settings.get_value("star.number_of_points",value))
-               set_number_of_points(atof(value.c_str()));
-       else
-               set_number_of_points(5);
-
-       if(settings.get_value("star.inner_tangent",value))
-               set_inner_tangent(atof(value.c_str()));
-       else
-               set_inner_tangent(0);
-
-       if(settings.get_value("star.outer_tangent",value))
-               set_outer_tangent(atof(value.c_str()));
-       else
-               set_outer_tangent(0);
-
-       if(settings.get_value("star.inner_width",value))
-               set_inner_width(atof(value.c_str()));
-       else
-               set_inner_width(1);
-
-       if(settings.get_value("star.outer_width",value))
-               set_outer_width(atof(value.c_str()));
-       else
-               set_outer_width(1);
-
-       if(settings.get_value("star.radius_ratio",value))
-               set_radius_ratio(atof(value.c_str()));
-       else
-               set_radius_ratio(0.5);
-
-       if(settings.get_value("star.angle_offset",value))
-               set_angle_offset(atof(value.c_str()));
-       else
-               set_angle_offset(0);
-
-       if(settings.get_value("star.invert",value) && value != "0")
-               set_invert(true);
-       else
-               set_invert(false);
-
-       if(settings.get_value("star.regular_polygon",value) && value != "0")
-               set_regular_polygon(true);
-       else
-               set_regular_polygon(false);
-
-       if(settings.get_value("star.layer_star",value) && value=="0")
-               set_layer_star_flag(false);
-       else
-               set_layer_star_flag(true);
-
-       if(settings.get_value("star.layer_region",value) && value=="1")
-               set_layer_region_flag(true);
-       else
-               set_layer_region_flag(false);
-
-       if(settings.get_value("star.layer_outline",value) && value=="1")
-               set_layer_outline_flag(true);
-       else
-               set_layer_outline_flag(false);
-
-       if(settings.get_value("star.layer_curve_gradient",value) && value=="1")
-               set_layer_curve_gradient_flag(true);
-       else
-               set_layer_curve_gradient_flag(false);
-
-       if(settings.get_value("star.layer_plant",value) && value=="1")
-               set_layer_plant_flag(true);
-       else
-               set_layer_plant_flag(false);
-
-       if(settings.get_value("star.layer_link_origins",value) && value=="0")
-               set_layer_link_origins_flag(false);
-       else
-               set_layer_link_origins_flag(true);
-
-       if(settings.get_value("star.layer_origins_at_center",value) && value=="0")
-               set_layer_origins_at_center_flag(false);
-       else
-               set_layer_origins_at_center_flag(true);
-}
-
-void
-StateStar_Context::save_settings()
-{
-       settings.set_value("star.id",get_id());
-       settings.set_value("star.feather",strprintf("%f",(float)get_feather()));
-       settings.set_value("star.number_of_points",strprintf("%d",(int)(get_number_of_points() + 0.5)));
-       settings.set_value("star.inner_tangent",strprintf("%f",(float)get_inner_tangent()));
-       settings.set_value("star.outer_tangent",strprintf("%f",(float)get_outer_tangent()));
-       settings.set_value("star.inner_width",strprintf("%f",(float)get_inner_width()));
-       settings.set_value("star.outer_width",strprintf("%f",(float)get_outer_width()));
-       settings.set_value("star.radius_ratio",strprintf("%f",(float)get_radius_ratio()));
-       settings.set_value("star.angle_offset",strprintf("%f",(float)get_angle_offset()));
-       settings.set_value("star.invert",get_invert()?"1":"0");
-       settings.set_value("star.regular_polygon",get_regular_polygon()?"1":"0");
-       settings.set_value("star.layer_star",get_layer_star_flag()?"1":"0");
-       settings.set_value("star.layer_outline",get_layer_outline_flag()?"1":"0");
-       settings.set_value("star.layer_region",get_layer_region_flag()?"1":"0");
-       settings.set_value("star.layer_curve_gradient",get_layer_curve_gradient_flag()?"1":"0");
-       settings.set_value("star.layer_plant",get_layer_plant_flag()?"1":"0");
-       settings.set_value("star.layer_link_origins",get_layer_link_origins_flag()?"1":"0");
-       settings.set_value("star.layer_origins_at_center",get_layer_origins_at_center_flag()?"1":"0");
-}
-
-void
-StateStar_Context::reset()
-{
-       refresh_ducks();
-}
-
-void
-StateStar_Context::increment_id()
-{
-       String id(get_id());
-       int number=1;
-       int digits=0;
-
-       if(id.empty())
-               id="Star";
-
-       // If there is a number
-       // already at the end of the
-       // id, then remove it.
-       if(id[id.size()-1]<='9' && id[id.size()-1]>='0')
-       {
-               // figure out how many digits it is
-               for (digits = 0;
-                        (int)id.size()-1 >= digits && id[id.size()-1-digits] <= '9' && id[id.size()-1-digits] >= '0';
-                        digits++)
-                       ;
-
-               String str_number;
-               str_number=String(id,id.size()-digits,id.size());
-               id=String(id,0,id.size()-digits);
-
-               number=atoi(str_number.c_str());
-       }
-       else
-       {
-               number=1;
-               digits=3;
-       }
-
-       number++;
-
-       // Add the number back onto the id
-       {
-               const String format(strprintf("%%0%dd",digits));
-               id+=strprintf(format.c_str(),number);
-       }
-
-       // Set the ID
-       set_id(id);
-}
-
-StateStar_Context::StateStar_Context(CanvasView* canvas_view):
-       canvas_view_(canvas_view),
-       is_working(*canvas_view),
-       duckmatic_push(get_work_area()),
-       prev_workarea_layer_status_(get_work_area()->get_allow_layer_clicks()),
-       settings(synfigapp::Main::get_selected_input_device()->settings()),
-       entry_id(),             //   value lower upper  step page
-       adj_feather(                    0,    0,    1, 0.01, 0.1),
-       adj_number_of_points(   0,    2,  120, 1   , 1  ),
-       adj_inner_tangent(              0,  -10,   10, 0.01, 0.1),
-       adj_outer_tangent(              0,  -10,   10, 0.01, 0.1),
-       adj_inner_width(                0,  -10,   10, 0.01, 0.1),
-       adj_outer_width(                0,  -10,   10, 0.01, 0.1),
-       adj_radius_ratio(               0,  -10,   10, 0.01, 0.1),
-       adj_angle_offset(               0, -360,  360, 0.1 , 1  ),
-       spin_feather(adj_feather,0.1,3),
-       spin_number_of_points(adj_number_of_points,1,0),
-       spin_inner_tangent(adj_inner_tangent,1,2),
-       spin_outer_tangent(adj_outer_tangent,1,2),
-       spin_inner_width(adj_inner_width,1,2),
-       spin_outer_width(adj_outer_width,1,2),
-       spin_radius_ratio(adj_radius_ratio,1,2),
-       spin_angle_offset(adj_angle_offset,1,1),
-       checkbutton_invert(_("Invert")),
-       checkbutton_regular_polygon(_("Regular Polygon")),
-       checkbutton_layer_star(_("Create Star Layer")),
-       checkbutton_layer_region(_("Create Region BLine")),
-       checkbutton_layer_outline(_("Create Outline BLine")),
-       checkbutton_layer_curve_gradient(_("Create Curve Gradient BLine")),
-       checkbutton_layer_plant(_("Create Plant BLine")),
-       checkbutton_layer_link_origins(_("Link Origins")),
-       checkbutton_layer_origins_at_center(_("BLine Origins at Center"))
-{
-       egress_on_selection_change=true;
-
-       load_settings();
-
-       // Set up the tool options dialog
-       options_table.attach(*manage(new Gtk::Label(_("Star Tool"))),                   0, 2,  0,  1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(entry_id,                                                                                  0, 2,  1,  2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_star,                                                    0, 2,  2,  3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_outline,                                                 0, 2,  3,  4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_region,                                                  0, 2,  4,  5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_plant,                                                   0, 2,  5,  6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_curve_gradient,                                  0, 2,  6,  7, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_link_origins,                                    0, 2,  7,  8, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_layer_origins_at_center,                               0, 2,  8,  9, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_invert,                                                                0, 2,  9, 10, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_regular_polygon,                                               0, 2, 10, 11, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       options_table.attach(*manage(new Gtk::Label(_("Feather:"))),                    0, 1, 11, 12, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(spin_feather,                                                                              1, 2, 11, 12, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       options_table.attach(*manage(new Gtk::Label(_("Number of Points:"))),   0, 1, 12, 13, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(spin_number_of_points,                                                             1, 2, 12, 13, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       options_table.attach(*manage(new Gtk::Label(_("Inner Tangent:"))),              0, 1, 13, 14, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(spin_inner_tangent,                                                                1, 2, 13, 14, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       options_table.attach(*manage(new Gtk::Label(_("Outer Tangent:"))),              0, 1, 14, 15, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(spin_outer_tangent,                                                                1, 2, 14, 15, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       options_table.attach(*manage(new Gtk::Label(_("Inner Width:"))),                0, 1, 15, 16, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(spin_inner_width,                                                                  1, 2, 15, 16, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       options_table.attach(*manage(new Gtk::Label(_("Outer Width:"))),                0, 1, 16, 17, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(spin_outer_width,                                                                  1, 2, 16, 17, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       options_table.attach(*manage(new Gtk::Label(_("Radius Ratio:"))),               0, 1, 17, 18, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(spin_radius_ratio,                                                                 1, 2, 17, 18, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       options_table.attach(*manage(new Gtk::Label(_("Angle Offset:"))),               0, 1, 18, 19, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(spin_angle_offset,                                                                 1, 2, 18, 19, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       options_table.show_all();
-
-       refresh_tool_options();
-       App::dialog_tool_options->present();
-
-       // Turn off layer clicking
-       get_work_area()->set_allow_layer_clicks(false);
-
-       // clear out the ducks
-       get_work_area()->clear_ducks();
-
-       // Refresh the work area
-       get_work_area()->queue_draw();
-
-       // Hide the tables if they are showing
-       //prev_table_status=get_canvas_view()->tables_are_visible();
-       //if(prev_table_status)get_canvas_view()->hide_tables();
-
-       // Disable the time bar
-       //get_canvas_view()->set_sensitive_timebar(false);
-
-       // Connect a signal
-       //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateStar_Context::on_user_click));
-       get_work_area()->set_cursor(Gdk::STAR);
-
-       App::toolbox->refresh();
-}
-
-void
-StateStar_Context::refresh_tool_options()
-{
-       App::dialog_tool_options->clear();
-       App::dialog_tool_options->set_widget(options_table);
-       App::dialog_tool_options->set_local_name(_("Star Tool"));
-       App::dialog_tool_options->set_name("star");
-}
-
-Smach::event_result
-StateStar_Context::event_refresh_tool_options(const Smach::event& /*x*/)
-{
-       refresh_tool_options();
-       return Smach::RESULT_ACCEPT;
-}
-
-StateStar_Context::~StateStar_Context()
-{
-       save_settings();
-
-       // Restore layer clicking
-       get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_);
-       get_work_area()->reset_cursor();
-
-       App::dialog_tool_options->clear();
-
-       // Enable the time bar
-       //get_canvas_view()->set_sensitive_timebar(true);
-
-       // Bring back the tables if they were out before
-       //if(prev_table_status)get_canvas_view()->show_tables();
-
-       // Refresh the work area
-       get_work_area()->queue_draw();
-
-       get_canvas_view()->queue_rebuild_ducks();
-
-       App::toolbox->refresh();
-}
-
-Smach::event_result
-StateStar_Context::event_stop_handler(const Smach::event& /*x*/)
-{
-       //throw Smach::egress_exception();
-       throw &state_normal;
-       return Smach::RESULT_OK;
-}
-
-Smach::event_result
-StateStar_Context::event_refresh_handler(const Smach::event& /*x*/)
-{
-       refresh_ducks();
-       return Smach::RESULT_ACCEPT;
-}
-
-void
-StateStar_Context::make_star(const Point& _p1, const Point& _p2)
-{
-       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("New Star"));
-       synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
-       Layer::Handle layer;
-
-       Canvas::Handle canvas;
-       int depth(0);
-
-       // we are temporarily using the layer to hold something
-       layer=get_canvas_view()->get_selection_manager()->get_selected_layer();
-       if(layer)
-       {
-               depth=layer->get_depth();
-               canvas=layer->get_canvas();
-       }
-
-       synfigapp::SelectionManager::LayerList layer_selection;
-       if (!getenv("SYNFIG_TOOLS_CLEAR_SELECTION"))
-               layer_selection = get_canvas_view()->get_selection_manager()->get_selected_layers();
-
-       const synfig::TransformStack& transform(get_canvas_view()->get_curr_transform_stack());
-       const Point p1(transform.unperform(_p1));
-       const Point p2(transform.unperform(_p2));
-
-       Real radius_ratio(get_radius_ratio());
-       Real radius1((p2-p1).mag());
-       Real radius2(radius1 * radius_ratio);
-       int points = get_number_of_points();
-       Real inner_tangent = get_inner_tangent() * radius1;
-       Real outer_tangent = get_outer_tangent() * radius2;
-       Real inner_width = get_inner_width();
-       Real outer_width = get_outer_width();
-       Angle::deg offset(get_angle_offset());
-       bool regular(get_regular_polygon());
-       Angle::deg angle(360.0/points);
-       Vector origin;
-       Real x, y;
-
-       if (get_layer_origins_at_center_flag())
-       {
-               x = y = 0;
-               origin = p1;
-       }
-       else
-       {
-               x = p1[0];
-               y = p1[1];
-       }
-
-       std::vector<BLinePoint> new_list;
-       int point(0);
-       for (int i = 0; i < points; i++)
-       {
-               new_list.push_back(*(new BLinePoint));
-               new_list[point].set_width(outer_width);
-               new_list[point].set_vertex(Point(radius1*Angle::cos(angle*i + offset).get() + x,
-                                                                                radius1*Angle::sin(angle*i + offset).get() + y));
-               new_list[point++].set_tangent(Point(-Angle::sin(angle*i + offset).get(),
-                                                                                        Angle::cos(angle*i + offset).get()) * outer_tangent);
-
-               if (!regular)
-               {
-                       new_list.push_back(*(new BLinePoint));
-                       new_list[point].set_width(inner_width);
-                       new_list[point].set_vertex(Point(radius2*Angle::cos(angle*i + angle/2 + offset).get() + x,
-                                                                                        radius2*Angle::sin(angle*i + angle/2 + offset).get() + y));
-                       new_list[point++].set_tangent(Point(-Angle::sin(angle*i + angle/2 + offset).get(),
-                                                                                                Angle::cos(angle*i + angle/2 + offset).get()) * inner_tangent);
-               }
-       }
-
-       ValueNode_BLine::Handle value_node_bline(ValueNode_BLine::create(new_list));
-       assert(value_node_bline);
-
-       ValueNode_Const::Handle value_node_origin(ValueNode_Const::create(origin));
-       assert(value_node_origin);
-
-       // Set the looping flag
-       value_node_bline->set_loop(true);
-
-       if(!canvas)
-               canvas=get_canvas_view()->get_canvas();
-
-       value_node_bline->set_member_canvas(canvas);
-
-       // count how many layers we're going to be creating
-       int layers_to_create = this->layers_to_create();
-
-       ///////////////////////////////////////////////////////////////////////////
-       //   S T A R
-       ///////////////////////////////////////////////////////////////////////////
-
-       if (get_layer_star_flag())
-       {
-               layer=get_canvas_interface()->add_layer_to("star",canvas,depth);
-               if (!layer)
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                       group.cancel();
-                       return;
-               }
-               layer_selection.push_back(layer);
-
-               layer->set_param("radius1",radius1);
-               get_canvas_interface()->signal_layer_param_changed()(layer,"radius1");
-
-               layer->set_param("radius2",radius2);
-               get_canvas_interface()->signal_layer_param_changed()(layer,"radius2");
-
-               layer->set_param("angle",offset);
-               get_canvas_interface()->signal_layer_param_changed()(layer,"angle");
-
-               layer->set_param("points",points);
-               get_canvas_interface()->signal_layer_param_changed()(layer,"points");
-
-               layer->set_param("regular_polygon",regular);
-               get_canvas_interface()->signal_layer_param_changed()(layer,"regular_polygon");
-
-               layer->set_param("feather",get_feather());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
-
-               layer->set_param("invert",get_invert());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
-
-               layer->set_description(get_id());
-               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
-               // only link the star's origin parameter if the option is selected, we're putting bline
-               // origins at their centers, and we're creating more than one layer
-               if (get_layer_link_origins_flag() && get_layer_origins_at_center_flag() && layers_to_create > 1)
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("origin")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create Star layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Star layer"));
-                               return;
-                       }
-               }
-               else
-               {
-                       layer->set_param("origin",p1);
-                       get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
-               }
-       }
-
-       ///////////////////////////////////////////////////////////////////////////
-       //   C U R V E   G R A D I E N T
-       ///////////////////////////////////////////////////////////////////////////
-
-       if(get_layer_curve_gradient_flag())
-       {
-               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
-               Layer::Handle layer(get_canvas_interface()->add_layer_to("curve_gradient",canvas,depth));
-               if (!layer)
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                       group.cancel();
-                       return;
-               }
-               layer_selection.push_back(layer);
-               layer->set_description(get_id()+_(" Gradient"));
-               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("bline")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Gradient layer"));
-                               return;
-                       }
-               }
-
-               // only link the curve gradient's origin parameter if the option is selected and we're creating more than one layer
-               if (get_layer_link_origins_flag() && layers_to_create > 1)
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("origin")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Gradient layer"));
-                               return;
-                       }
-               }
-               else
-               {
-                       layer->set_param("origin",origin);
-                       get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
-               }
-       }
-
-       ///////////////////////////////////////////////////////////////////////////
-       //   P L A N T
-       ///////////////////////////////////////////////////////////////////////////
-
-       if(get_layer_plant_flag())
-       {
-               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
-               Layer::Handle layer(get_canvas_interface()->add_layer_to("plant",canvas,depth));
-               if (!layer)
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                       group.cancel();
-                       return;
-               }
-               layer_selection.push_back(layer);
-               layer->set_description(get_id()+_(" Plant"));
-               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("bline")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Plant layer"));
-                               return;
-                       }
-               }
-
-               // only link the plant's origin parameter if the option is selected and we're creating more than one layer
-               if (get_layer_link_origins_flag() && layers_to_create > 1)
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("origin")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Plant layer"));
-                               return;
-                       }
-               }
-               else
-               {
-                       layer->set_param("origin",origin);
-                       get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
-               }
-       }
-
-       ///////////////////////////////////////////////////////////////////////////
-       //   R E G I O N
-       ///////////////////////////////////////////////////////////////////////////
-
-       if(get_layer_region_flag())
-       {
-               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
-               Layer::Handle layer(get_canvas_interface()->add_layer_to("region",canvas,depth));
-               if (!layer)
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                       group.cancel();
-                       return;
-               }
-               layer_selection.push_back(layer);
-               layer->set_description(get_id()+_(" Region"));
-               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
-               layer->set_param("feather",get_feather());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
-
-               layer->set_param("invert",get_invert());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
-
-               // I don't know if it's safe to reuse the same LayerParamConnect action, so I'm
-               // using 2 separate ones.
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("bline")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Region layer"));
-                               return;
-                       }
-               }
-
-               // only link the region's origin parameter if the option is selected and we're creating more than one layer
-               if (get_layer_link_origins_flag() && layers_to_create > 1)
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("origin")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Region layer"));
-                               return;
-                       }
-               }
-               else
-               {
-                       layer->set_param("origin",origin);
-                       get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
-               }
-       }
-
-       ///////////////////////////////////////////////////////////////////////////
-       //   O U T L I N E
-       ///////////////////////////////////////////////////////////////////////////
-
-       if (get_layer_outline_flag())
-       {
-               Layer::Handle layer(get_canvas_interface()->add_layer_to("outline",canvas,depth));
-               if (!layer)
-               {
-                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-                       group.cancel();
-                       return;
-               }
-               layer_selection.push_back(layer);
-               layer->set_description(get_id()+_(" Outline"));
-               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
-               layer->set_param("feather",get_feather());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
-
-               layer->set_param("invert",get_invert());
-               get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
-
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("bline")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Outline layer"));
-                               return;
-                       }
-               }
-
-               // only link the outline's origin parameter if the option is selected and we're creating more than one layer
-               if (get_layer_link_origins_flag() && layers_to_create > 1)
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
-                       assert(action);
-
-                       action->set_param("canvas",get_canvas());
-                       action->set_param("canvas_interface",get_canvas_interface());
-                       action->set_param("layer",layer);
-                       if(!action->set_param("param",String("origin")))
-                               synfig::error("LayerParamConnect didn't like \"param\"");
-                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
-                               synfig::error("LayerParamConnect didn't like \"value_node\"");
-
-                       if(!get_canvas_interface()->get_instance()->perform_action(action))
-                       {
-                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
-                               group.cancel();
-                               throw String(_("Unable to create Outline layer"));
-                               return;
-                       }
-               }
-               else
-               {
-                       layer->set_param("origin",origin);
-                       get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
-               }
-       }
-
-       egress_on_selection_change=false;
-       get_canvas_interface()->get_selection_manager()->clear_selected_layers();
-       get_canvas_interface()->get_selection_manager()->set_selected_layers(layer_selection);
-       egress_on_selection_change=true;
-
-       reset();
-       increment_id();
-}
-
-Smach::event_result
-StateStar_Context::event_mouse_click_handler(const Smach::event& x)
-{
-       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
-
-       if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_DOWN && event.button==BUTTON_LEFT)
-       {
-               point_holder=get_work_area()->snap_point_to_grid(event.pos);
-               etl::handle<Duck> duck=new Duck();
-               duck->set_point(point_holder);
-               duck->set_name("p1");
-               duck->set_type(Duck::TYPE_POSITION);
-               duck->set_editable(false);
-               get_work_area()->add_duck(duck);
-
-               point2_duck=new Duck();
-               point2_duck->set_point(Vector(0,0));
-               point2_duck->set_name("radius");
-               point2_duck->set_origin(duck);
-               point2_duck->set_radius(true);
-               point2_duck->set_scalar(-1);
-               point2_duck->set_type(Duck::TYPE_RADIUS);
-               point2_duck->set_hover(true);
-               get_work_area()->add_duck(point2_duck);
-
-               return Smach::RESULT_ACCEPT;
-       }
-
-       if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_DRAG && event.button==BUTTON_LEFT)
-       {
-               if (!point2_duck) return Smach::RESULT_OK;
-               point2_duck->set_point(point_holder-get_work_area()->snap_point_to_grid(event.pos));
-               get_work_area()->queue_draw();
-               return Smach::RESULT_ACCEPT;
-       }
-
-       if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_UP && event.button==BUTTON_LEFT)
-       {
-               Point point(get_work_area()->snap_point_to_grid(event.pos));
-
-               if (App::restrict_radius_ducks)
-               {
-                       if ((point[0] - point_holder[0]) < 0) point[0] = point_holder[0];
-                       if ((point[1] - point_holder[1]) < 0) point[1] = point_holder[1];
-               }
-
-               make_star(point_holder, point);
-               get_work_area()->clear_ducks();
-               return Smach::RESULT_ACCEPT;
-       }
-
-       return Smach::RESULT_OK;
-}
-
-
-void
-StateStar_Context::refresh_ducks()
-{
-       get_work_area()->clear_ducks();
-       get_work_area()->queue_draw();
-}
diff --git a/synfig-studio/src/gtkmm/state_star.h b/synfig-studio/src/gtkmm/state_star.h
deleted file mode 100644 (file)
index 606f77d..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_star.h
-**     \brief Star creation state
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === S T A R T =========================================================== */
-
-#ifndef __SYNFIG_STUDIO_STATE_STAR_H
-#define __SYNFIG_STUDIO_STATE_STAR_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 StateStar_Context;
-
-class StateStar : public Smach::state<StateStar_Context>
-{
-public:
-       StateStar();
-       ~StateStar();
-}; // END of class StateStar
-
-extern StateStar state_star;
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/state_stroke.cpp b/synfig-studio/src/gtkmm/state_stroke.cpp
deleted file mode 100644 (file)
index a0f7eca..0000000
+++ /dev/null
@@ -1,198 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_stroke.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \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
-**     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 <config.h>
-#endif
-
-#include <gtkmm/dialog.h>
-#include <gtkmm/entry.h>
-
-#include <synfig/valuenode_dynamiclist.h>
-
-#include "state_stroke.h"
-#include "canvasview.h"
-#include "workarea.h"
-#include "app.h"
-#include <synfig/valuenode_bline.h>
-#include <ETL/hermite>
-#include <ETL/calculus>
-#include <utility>
-#include "event_mouse.h"
-#include "event_layerclick.h"
-#include "toolbox.h"
-#include <synfigapp/main.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 ======================================================= */
-
-StateStroke studio::state_stroke;
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-class studio::StateStroke_Context : public sigc::trackable
-{
-       etl::handle<CanvasView> canvas_view_;
-       CanvasView::IsWorking is_working;
-
-       Duckmatic::Push duckmatic_push;
-
-       etl::smart_ptr<std::list<synfig::Point> > stroke_data;
-
-       etl::smart_ptr<std::list<synfig::Real> > width_data;
-
-       Gdk::ModifierType modifier;
-
-public:
-
-       Smach::event_result event_stop_handler(const Smach::event& x);
-
-       Smach::event_result event_refresh_handler(const Smach::event& x);
-
-       Smach::event_result event_mouse_up_handler(const Smach::event& x);
-
-       Smach::event_result event_mouse_draw_handler(const Smach::event& x);
-       Smach::event_result event_refresh_tool_options(const Smach::event& x);
-
-       StateStroke_Context(CanvasView* canvas_view);
-
-       ~StateStroke_Context();
-
-       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
-       etl::handle<synfigapp::CanvasInterface> 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();}
-
-};     // END of class StateStroke_Context
-
-
-/* === M E T H O D S ======================================================= */
-
-StateStroke::StateStroke():
-       Smach::state<StateStroke_Context>("stroke")
-{
-       insert(event_def(EVENT_STOP,&StateStroke_Context::event_stop_handler));
-       insert(event_def(EVENT_REFRESH,&StateStroke_Context::event_refresh_handler));
-//     insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StateStroke_Context::event_mouse_down_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_UP,&StateStroke_Context::event_mouse_up_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DRAG,&StateStroke_Context::event_mouse_draw_handler));
-       insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateStroke_Context::event_refresh_tool_options));
-}
-
-StateStroke::~StateStroke()
-{
-}
-
-
-StateStroke_Context::StateStroke_Context(CanvasView* canvas_view):
-       canvas_view_(canvas_view),
-       is_working(*canvas_view),
-       duckmatic_push(get_work_area())
-{
-       width_data.spawn();
-       stroke_data.spawn();
-
-       get_work_area()->add_stroke(stroke_data, synfigapp::Main::get_outline_color());
-}
-
-StateStroke_Context::~StateStroke_Context()
-{
-       duckmatic_push.restore();
-
-       App::toolbox->refresh();
-
-       // Send the stroke data to whatever previously called this state.
-       if(stroke_data->size()>=2)
-               get_canvas_view()->get_smach().process_event(EventStroke(stroke_data,width_data,modifier));
-}
-
-Smach::event_result
-StateStroke_Context::event_refresh_tool_options(const Smach::event& /*x*/)
-{
-       return Smach::RESULT_ACCEPT;
-}
-
-Smach::event_result
-StateStroke_Context::event_stop_handler(const Smach::event& /*x*/)
-{
-       throw Smach::pop_exception();
-}
-
-Smach::event_result
-StateStroke_Context::event_refresh_handler(const Smach::event& /*x*/)
-{
-       return Smach::RESULT_ACCEPT;
-}
-
-Smach::event_result
-StateStroke_Context::event_mouse_up_handler(const Smach::event& x)
-{
-       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
-       switch(event.button)
-       {
-       case BUTTON_LEFT:
-               {
-                       modifier=event.modifier;
-                       throw Smach::pop_exception();
-               }
-
-       default:
-               return Smach::RESULT_OK;
-       }
-}
-
-Smach::event_result
-StateStroke_Context::event_mouse_draw_handler(const Smach::event& x)
-{
-       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
-       switch(event.button)
-       {
-       case BUTTON_LEFT:
-               {
-                       stroke_data->push_back(event.pos);
-                       width_data->push_back(event.pressure);
-                       get_work_area()->queue_draw();
-                       return Smach::RESULT_ACCEPT;
-               }
-
-       default:
-               return Smach::RESULT_OK;
-       }
-}
diff --git a/synfig-studio/src/gtkmm/state_stroke.h b/synfig-studio/src/gtkmm/state_stroke.h
deleted file mode 100644 (file)
index 0beade5..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_stroke.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_STROKE_H
-#define __SYNFIG_STUDIO_STATE_STROKE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include "canvasview.h"
-#include "workarea.h"
-#include <sigc++/object.h>
-#include "duckmatic.h"
-#include <synfig/blinepoint.h>
-#include <list>
-#include <ETL/smart_ptr>
-#include "eventkey.h"
-#include <gdkmm/types.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 StateStroke_Context;
-
-class StateStroke : public Smach::state<StateStroke_Context>
-{
-public:
-       StateStroke();
-       ~StateStroke();
-}; // END of class StateStroke
-
-extern StateStroke state_stroke;
-
-struct EventStroke : public Smach::event
-{
-       etl::smart_ptr<std::list<synfig::Point> > stroke_data;
-       etl::smart_ptr<std::list<synfig::Real> > width_data;
-       Gdk::ModifierType modifier;
-
-       EventStroke(etl::smart_ptr<std::list<synfig::Point> > stroke_data,
-                       etl::smart_ptr<std::list<synfig::Real> > width_data,
-                       Gdk::ModifierType modifier=Gdk::ModifierType(0)
-       ):
-               Smach::event(EVENT_WORKAREA_STROKE),
-               stroke_data(stroke_data),
-               width_data(width_data),
-               modifier(modifier)
-       { }
-}; // END of EventStroke
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/state_text.cpp b/synfig-studio/src/gtkmm/state_text.cpp
deleted file mode 100644 (file)
index f475420..0000000
+++ /dev/null
@@ -1,460 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_text.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 <config.h>
-#endif
-
-#include <gtkmm/dialog.h>
-#include <gtkmm/entry.h>
-
-#include "state_text.h"
-#include "state_normal.h"
-#include "canvasview.h"
-#include "workarea.h"
-#include "app.h"
-
-#include <synfigapp/action.h>
-#include "event_mouse.h"
-#include "event_layerclick.h"
-#include "toolbox.h"
-#include "dialog_tooloptions.h"
-#include <gtkmm/optionmenu.h>
-#include "duck.h"
-#include "widget_enum.h"
-#include <synfigapp/main.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 ======================================================= */
-
-StateText studio::state_text;
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-class studio::StateText_Context
-{
-       etl::handle<CanvasView> canvas_view;
-       CanvasView::IsWorking is_working;
-
-       Duckmatic::Push duckmatic_push;
-
-       void refresh_ducks();
-
-       bool prev_workarea_layer_status_;
-
-       //Toolbox settings
-       synfigapp::Settings& settings;
-
-       //Toolbox display
-       Gtk::Table options_table;
-
-       Gtk::Entry              entry_id; //what to name the layer
-       Gtk::Entry              entry_family;
-       Widget_Vector   widget_size;
-       Widget_Vector   widget_orientation;
-       Gtk::CheckButton checkbutton_paragraph;
-
-public:
-       synfig::String get_id()const { return entry_id.get_text(); }
-       void set_id(const synfig::String& x) { return entry_id.set_text(x); }
-
-       bool get_paragraph_flag()const { return checkbutton_paragraph.get_active(); }
-       void set_paragraph_flag(bool x) { return checkbutton_paragraph.set_active(x); }
-
-       Vector get_size() { return widget_size.get_value(); }
-       void set_size(Vector s) { return widget_size.set_value(s); }
-
-       Vector get_orientation() { return widget_orientation.get_value(); }
-       void set_orientation(Vector s) { return widget_orientation.set_value(s); }
-
-       String get_family()const { return entry_family.get_text(); }
-       void set_family(String s) { return entry_family.set_text(s); }
-
-       void refresh_tool_options(); //to refresh the toolbox
-
-       //events
-       Smach::event_result event_stop_handler(const Smach::event& x);
-       Smach::event_result event_refresh_handler(const Smach::event& x);
-       Smach::event_result event_mouse_click_handler(const Smach::event& x);
-       Smach::event_result event_refresh_tool_options(const Smach::event& x);
-       Smach::event_result event_workarea_mouse_button_down_handler(const Smach::event& x);
-
-       //constructor destructor
-       StateText_Context(CanvasView *canvas_view);
-       ~StateText_Context();
-
-       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view;}
-       etl::handle<synfigapp::CanvasInterface> get_canvas_interface()const{return canvas_view->canvas_interface();}
-       WorkArea * get_work_area()const{return canvas_view->get_work_area();}
-
-       //Modifying settings etc.
-       void load_settings();
-       void save_settings();
-       void reset();
-       void increment_id();
-       bool egress_on_selection_change;
-       Smach::event_result event_layer_selection_changed_handler(const Smach::event& /*x*/)
-       {
-               if(egress_on_selection_change)
-                       throw &state_normal; //throw Smach::egress_exception();
-               return Smach::RESULT_OK;
-       }
-
-       void make_text(const Point& point);
-
-}; // END of class StateText_Context
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-StateText::StateText():
-       Smach::state<StateText_Context>("text")
-{
-       insert(event_def(EVENT_LAYER_SELECTION_CHANGED,&StateText_Context::event_layer_selection_changed_handler));
-       insert(event_def(EVENT_STOP,&StateText_Context::event_stop_handler));
-       insert(event_def(EVENT_REFRESH,&StateText_Context::event_refresh_handler));
-       insert(event_def(EVENT_REFRESH_DUCKS,&StateText_Context::event_refresh_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StateText_Context::event_workarea_mouse_button_down_handler));
-       insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateText_Context::event_refresh_tool_options));
-}
-
-StateText::~StateText()
-{
-}
-
-void
-StateText_Context::load_settings()
-{
-       String value;
-       Vector v;
-
-       //parse the arguments yargh!
-       if(settings.get_value("text.id",value))
-               set_id(value);
-       else
-               set_id("Text");
-
-       if(settings.get_value("text.paragraph",value) && value=="1")
-               set_paragraph_flag(true);
-       else
-               set_paragraph_flag(false);
-
-       if(settings.get_value("text.size_x",value))
-               v[0] = atof(value.c_str());
-       else
-               v[0] = 0.25;
-       if(settings.get_value("text.size_y",value))
-               v[1] = atof(value.c_str());
-       else
-               v[1] = 0.25;
-       set_size(v);
-
-       if(settings.get_value("text.orient_x",value))
-               v[0] = atof(value.c_str());
-       else
-               v[0] = 0.5;
-       if(settings.get_value("text.orient_y",value))
-               v[1] = atof(value.c_str());
-       else
-               v[1] = 0.5;
-       set_orientation(v);
-
-       if(settings.get_value("text.family",value))
-               set_family(value);
-       else
-               set_family("Sans Serif");
-}
-
-void
-StateText_Context::save_settings()
-{
-       settings.set_value("text.id",get_id());
-       settings.set_value("text.paragraph",get_paragraph_flag()?"1":"0");
-       settings.set_value("text.size_x",strprintf("%f",(float)get_size()[0]));
-       settings.set_value("text.size_y",strprintf("%f",(float)get_size()[1]));
-       settings.set_value("text.orient_x",strprintf("%f",(float)get_orientation()[0]));
-       settings.set_value("text.orient_y",strprintf("%f",(float)get_orientation()[1]));
-       settings.set_value("text.family",get_family());
-}
-
-void
-StateText_Context::reset()
-{
-       refresh_ducks();
-}
-
-void
-StateText_Context::increment_id()
-{
-       String id(get_id());
-       int number=1;
-       int digits=0;
-
-       if(id.empty())
-               id="Text";
-
-       // If there is a number
-       // already at the end of the
-       // id, then remove it.
-       if(id[id.size()-1]<='9' && id[id.size()-1]>='0')
-       {
-               // figure out how many digits it is
-               for (digits = 0;
-                        (int)id.size()-1 >= digits && id[id.size()-1-digits] <= '9' && id[id.size()-1-digits] >= '0';
-                        digits++)
-                       ;
-
-               String str_number;
-               str_number=String(id,id.size()-digits,id.size());
-               id=String(id,0,id.size()-digits);
-
-               number=atoi(str_number.c_str());
-       }
-       else
-       {
-               number=1;
-               digits=3;
-       }
-
-       number++;
-
-       // Add the number back onto the id
-       {
-               const String format(strprintf("%%0%dd",digits));
-               id+=strprintf(format.c_str(),number);
-       }
-
-       // Set the ID
-       set_id(id);
-}
-
-StateText_Context::StateText_Context(CanvasView *canvas_view):
-       canvas_view(canvas_view),
-       is_working(*canvas_view),
-       duckmatic_push(get_work_area()),
-       prev_workarea_layer_status_(get_work_area()->get_allow_layer_clicks()),
-       settings(synfigapp::Main::get_selected_input_device()->settings()),
-       entry_id(),
-       checkbutton_paragraph(_("Multiline Editor"))
-{
-       egress_on_selection_change=true;
-
-       widget_size.set_digits(2);
-       widget_size.set_canvas(canvas_view->get_canvas());
-
-       widget_orientation.set_digits(2);
-
-       options_table.attach(*manage(new Gtk::Label(_("Text Tool"))),           0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(entry_id,                                                                          0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(checkbutton_paragraph,                                                     0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(*manage(new Gtk::Label(_("Size:"))),                       0, 1, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(widget_size,                                                                       1, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(*manage(new Gtk::Label(_("Orientation:"))),        0, 1, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(widget_orientation,                                                        1, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(*manage(new Gtk::Label(_("Family:"))),                     0, 1, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(entry_family,                                                                      1, 2, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       load_settings();
-
-       options_table.show_all();
-
-       refresh_tool_options();
-       App::dialog_tool_options->present();
-
-       // Turn off layer clicking
-       get_work_area()->set_allow_layer_clicks(false);
-
-       // clear out the ducks
-       get_work_area()->clear_ducks();
-
-       // Refresh the work area
-       get_work_area()->queue_draw();
-
-       // Hide the tables if they are showing
-       //prev_table_status=get_canvas_view()->tables_are_visible();
-       //if(prev_table_status)get_canvas_view()->hide_tables();
-
-       // Disable the time bar
-       //get_canvas_view()->set_sensitive_timebar(false);
-
-       // Connect a signal
-       //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateText_Context::on_user_click));
-       get_work_area()->set_cursor(Gdk::XTERM);
-
-       App::toolbox->refresh();
-}
-
-void
-StateText_Context::refresh_tool_options()
-{
-       App::dialog_tool_options->clear();
-       App::dialog_tool_options->set_widget(options_table);
-       App::dialog_tool_options->set_local_name(_("Text Tool"));
-       App::dialog_tool_options->set_name("text");
-}
-
-Smach::event_result
-StateText_Context::event_refresh_tool_options(const Smach::event& /*x*/)
-{
-       refresh_tool_options();
-       return Smach::RESULT_ACCEPT;
-}
-
-StateText_Context::~StateText_Context()
-{
-       save_settings();
-
-       // Restore layer clicking
-       get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_);
-       get_work_area()->reset_cursor();
-
-       App::dialog_tool_options->clear();
-
-       get_work_area()->queue_draw();
-
-       get_canvas_view()->queue_rebuild_ducks();
-
-       App::toolbox->refresh();
-}
-
-Smach::event_result
-StateText_Context::event_stop_handler(const Smach::event& /*x*/)
-{
-       //throw Smach::egress_exception();
-       throw &state_normal;
-       return Smach::RESULT_OK;
-}
-
-Smach::event_result
-StateText_Context::event_refresh_handler(const Smach::event& /*x*/)
-{
-       refresh_ducks();
-       return Smach::RESULT_ACCEPT;
-}
-
-void
-StateText_Context::make_text(const Point& _point)
-{
-       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("New Text"));
-       synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
-       Layer::Handle layer;
-
-       Canvas::Handle canvas(get_canvas_view()->get_canvas());
-       int depth(0);
-
-       // we are temporarily using the layer to hold something
-       layer=get_canvas_view()->get_selection_manager()->get_selected_layer();
-       if(layer)
-       {
-               depth=layer->get_depth();
-               canvas=layer->get_canvas();
-       }
-
-       synfigapp::SelectionManager::LayerList layer_selection;
-       if (!getenv("SYNFIG_TOOLS_CLEAR_SELECTION"))
-               layer_selection = get_canvas_view()->get_selection_manager()->get_selected_layers();
-
-       const synfig::TransformStack& transform(get_canvas_view()->get_curr_transform_stack());
-       const Point point(transform.unperform(_point));
-
-       String text;
-       if (get_paragraph_flag())
-               App::dialog_paragraph(_("Text Paragraph"), _("Enter text here:"), text);
-       else
-               App::dialog_entry(_("Text Entry"), _("Enter text here:"), text);
-
-       layer=get_canvas_interface()->add_layer_to("text",canvas,depth);
-       if (!layer)
-       {
-               get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
-               group.cancel();
-               return;
-       }
-       layer_selection.push_back(layer);
-
-       layer->set_param("origin",point);
-       get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
-
-       layer->set_param("text",text);
-       get_canvas_interface()->signal_layer_param_changed()(layer,"text");
-
-       layer->set_param("size",get_size());
-       get_canvas_interface()->signal_layer_param_changed()(layer,"size");
-
-       layer->set_param("orient",get_orientation());
-       get_canvas_interface()->signal_layer_param_changed()(layer,"orient");
-
-       layer->set_param("family",get_family());
-       get_canvas_interface()->signal_layer_param_changed()(layer,"family");
-
-       layer->set_description(get_id());
-       get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
-       egress_on_selection_change=false;
-       get_canvas_interface()->get_selection_manager()->clear_selected_layers();
-       get_canvas_interface()->get_selection_manager()->set_selected_layers(layer_selection);
-       egress_on_selection_change=true;
-
-       reset();
-       increment_id();
-}
-
-Smach::event_result
-StateText_Context::event_workarea_mouse_button_down_handler(const Smach::event& x)
-{
-       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
-       if(event.button==BUTTON_LEFT)
-       {
-               make_text(get_work_area()->snap_point_to_grid(event.pos));
-
-               get_work_area()->clear_ducks();
-               return Smach::RESULT_ACCEPT;
-       }
-       return Smach::RESULT_OK;
-}
-
-void
-StateText_Context::refresh_ducks()
-{
-       get_work_area()->clear_ducks();
-       get_work_area()->queue_draw();
-}
diff --git a/synfig-studio/src/gtkmm/state_text.h b/synfig-studio/src/gtkmm/state_text.h
deleted file mode 100644 (file)
index 4b05db5..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_text.h
-**     \brief Template Header
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === S T A R T =========================================================== */
-
-#ifndef __SYNFIG_STATE_TEXT_H
-#define __SYNFIG_STATE_TEXT_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 StateText_Context;
-
-class StateText : public Smach::state<StateText_Context>
-{
-public:
-       StateText();
-       ~StateText();
-}; // END of class StateText
-
-extern StateText state_text;
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/state_width.cpp b/synfig-studio/src/gtkmm/state_width.cpp
deleted file mode 100644 (file)
index 8c74daa..0000000
+++ /dev/null
@@ -1,606 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_width.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 <config.h>
-#endif
-
-#include <gtkmm/dialog.h>
-#include <gtkmm/entry.h>
-
-#include <ETL/bezier>
-
-#include <synfig/valuenode_dynamiclist.h>
-#include <synfigapp/action_system.h>
-
-#include "state_width.h"
-#include "state_normal.h"
-#include "canvasview.h"
-#include "workarea.h"
-#include "app.h"
-
-#include <synfigapp/action.h>
-#include "event_mouse.h"
-#include "event_layerclick.h"
-#include "toolbox.h"
-#include "dialog_tooloptions.h"
-#include <gtkmm/optionmenu.h>
-#include "duck.h"
-
-//#include <synfigapp/value_desc.h>
-#include <synfigapp/main.h>
-
-#include <ETL/clock>
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-using namespace synfig;
-using namespace synfigapp;
-using namespace studio;
-
-/* === M A C R O S ========================================================= */
-
-/* === G L O B A L S ======================================================= */
-
-StateWidth studio::state_width;
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-class studio::StateWidth_Context : public sigc::trackable
-{
-       etl::handle<CanvasView> canvas_view_;
-       CanvasView::IsWorking is_working;
-
-       //Point mouse_pos;
-
-       handle<Duck> center;
-       handle<Duck> radius;
-       handle<Duck> closestpoint;
-
-       map<handle<Duck>,Real>  changetable;
-
-       etl::clock      clocktime;
-       Real            lastt;
-
-       bool added;
-
-       void refresh_ducks();
-
-       bool prev_workarea_layer_clicking;
-       bool prev_workarea_duck_clicking;
-       Duckmatic::Type old_duckmask;
-
-       //Toolbox settings
-       synfigapp::Settings& settings;
-
-       //Toolbox display
-       Gtk::Table options_table;
-
-       Gtk::Adjustment adj_delta;
-       Gtk::SpinButton spin_delta;
-
-       Gtk::Adjustment adj_radius;
-       Gtk::SpinButton spin_radius;
-
-       Gtk::CheckButton check_relative;
-
-       void AdjustWidth(handle<Duckmatic::Bezier> c, float t, Real mult, bool invert);
-
-public:
-
-       Real get_delta()const { return adj_delta.get_value(); }
-       void set_delta(Real f) { adj_delta.set_value(f); }
-
-       Real get_radius()const { return adj_radius.get_value(); }
-       void set_radius(Real f) { adj_radius.set_value(f); }
-
-       bool get_relative() const { return check_relative.get_active(); }
-       void set_relative(bool r) { check_relative.set_active(r); }
-
-       void refresh_tool_options(); //to refresh the toolbox
-
-       //events
-       Smach::event_result event_stop_handler(const Smach::event& x);
-       Smach::event_result event_refresh_handler(const Smach::event& x);
-       Smach::event_result event_mouse_handler(const Smach::event& x);
-       Smach::event_result event_refresh_tool_options(const Smach::event& x);
-
-       //constructor destructor
-       StateWidth_Context(CanvasView* canvas_view);
-       ~StateWidth_Context();
-
-       //Canvas interaction
-       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
-       etl::handle<synfigapp::CanvasInterface> 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();}
-
-       //Modifying settings etc.
-       void load_settings();
-       void save_settings();
-       void reset();
-
-};     // END of class StateWidth_Context
-
-/* === M E T H O D S ======================================================= */
-
-StateWidth::StateWidth():
-       Smach::state<StateWidth_Context>("width")
-{
-       insert(event_def(EVENT_STOP,&StateWidth_Context::event_stop_handler));
-       insert(event_def(EVENT_REFRESH,&StateWidth_Context::event_refresh_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StateWidth_Context::event_mouse_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DRAG,&StateWidth_Context::event_mouse_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_UP,&StateWidth_Context::event_mouse_handler));
-       insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateWidth_Context::event_refresh_tool_options));
-}
-
-StateWidth::~StateWidth()
-{
-}
-
-void
-StateWidth_Context::load_settings()
-{
-       String value;
-
-       //parse the arguments yargh!
-       if(settings.get_value("width.delta",value))
-               set_delta(atof(value.c_str()));
-       else
-               set_delta(6);
-
-       if(settings.get_value("width.radius",value))
-               set_radius(atof(value.c_str()));
-       else
-               set_radius(15);
-
-       //defaults to false
-       if(settings.get_value("width.relative",value) && value == "1")
-               set_relative(true);
-       else
-               set_relative(false);
-}
-
-void
-StateWidth_Context::save_settings()
-{
-       settings.set_value("width.delta",strprintf("%f",get_delta()));
-       settings.set_value("width.radius",strprintf("%f",get_radius()));
-       settings.set_value("width.relative",get_relative()?"1":"0");
-}
-
-void
-StateWidth_Context::reset()
-{
-       refresh_ducks();
-}
-
-StateWidth_Context::StateWidth_Context(CanvasView* canvas_view):
-       canvas_view_(canvas_view),
-       is_working(*canvas_view),
-       prev_workarea_layer_clicking(get_work_area()->get_allow_layer_clicks()),
-       prev_workarea_duck_clicking(get_work_area()->get_allow_duck_clicks()),
-       old_duckmask(get_work_area()->get_type_mask()),
-
-       settings(synfigapp::Main::get_selected_input_device()->settings()),
-
-       adj_delta(6,0,20,0.01,0.1),
-       spin_delta(adj_delta,0.01,3),
-
-       adj_radius(200,0,1e50,1,10),
-       spin_radius(adj_radius,1,1),
-
-       check_relative(_("Relative Growth"))
-{
-       load_settings();
-
-       // Set up the tool options dialog
-       options_table.attach(*manage(new Gtk::Label(_("Width Tool"))),  0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       //expand stuff
-       options_table.attach(*manage(new Gtk::Label(_("Growth:"))),             0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(spin_delta,                                                                1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       options_table.attach(*manage(new Gtk::Label(_("Radius:"))),             0, 1, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       options_table.attach(spin_radius,                                                               1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       options_table.attach(check_relative,                                                    0, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       options_table.show_all();
-
-       refresh_tool_options();
-       App::dialog_tool_options->present();
-
-       // Turn off layer clicking
-       get_work_area()->set_allow_layer_clicks(false);
-
-       // clear out the ducks
-       //get_work_area()->clear_ducks();
-
-       // Refresh the work area
-       get_work_area()->queue_draw();
-
-       //Create the new ducks
-       added = false;
-
-       if(!center)
-       {
-               center = new Duck();
-               center->set_name("p1");
-               center->set_type(Duck::TYPE_POSITION);
-       }
-
-       if(!radius)
-       {
-               radius = new Duck();
-               radius->set_origin(center);
-               radius->set_radius(true);
-               radius->set_type(Duck::TYPE_RADIUS);
-               radius->set_name("radius");
-       }
-
-       if(!closestpoint)
-       {
-               closestpoint = new Duck();
-               closestpoint->set_name("closest");
-               closestpoint->set_type(Duck::TYPE_POSITION);
-       }
-
-       //Disable duck clicking for the maximum coolness :)
-       get_work_area()->set_allow_duck_clicks(false);
-       get_work_area()->set_type_mask((Duck::Type)((int)Duck::TYPE_WIDTH + (int)Duck::TYPE_RADIUS));
-
-       // Turn the mouse pointer to crosshairs
-       get_work_area()->set_cursor(Gdk::CROSSHAIR);
-
-       // Hide the tables if they are showing
-       //prev_table_status=get_canvas_view()->tables_are_visible();
-       //if(prev_table_status)get_canvas_view()->hide_tables();
-
-       // Disable the time bar
-       //get_canvas_view()->set_sensitive_timebar(false);
-
-       // Connect a signal
-       //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateWidth_Context::on_user_click));
-
-       App::toolbox->refresh();
-}
-
-void
-StateWidth_Context::refresh_tool_options()
-{
-       App::dialog_tool_options->clear();
-       App::dialog_tool_options->set_widget(options_table);
-       App::dialog_tool_options->set_local_name(_("Width Tool"));
-       App::dialog_tool_options->set_name("width");
-}
-
-Smach::event_result
-StateWidth_Context::event_refresh_tool_options(const Smach::event& /*x*/)
-{
-       refresh_tool_options();
-       return Smach::RESULT_ACCEPT;
-}
-
-StateWidth_Context::~StateWidth_Context()
-{
-       save_settings();
-
-       //remove ducks if need be
-       if(added)
-       {
-               get_work_area()->erase_duck(center);
-               get_work_area()->erase_duck(radius);
-               get_work_area()->erase_duck(closestpoint);
-               added = false;
-       }
-
-       // Restore Duck clicking
-       get_work_area()->set_allow_duck_clicks(prev_workarea_duck_clicking);
-
-       // Restore layer clicking
-       get_work_area()->set_allow_layer_clicks(prev_workarea_layer_clicking);
-
-       // Restore the mouse pointer
-       get_work_area()->reset_cursor();
-
-       // Restore duck masking
-       get_work_area()->set_type_mask(old_duckmask);
-
-       // Tool options be rid of ye!!
-       App::dialog_tool_options->clear();
-
-       // Enable the time bar
-       //get_canvas_view()->set_sensitive_timebar(true);
-
-       // Bring back the tables if they were out before
-       //if(prev_table_status)get_canvas_view()->show_tables();
-
-       // Refresh the work area
-       get_work_area()->queue_draw();
-
-       App::toolbox->refresh();
-}
-
-Smach::event_result
-StateWidth_Context::event_stop_handler(const Smach::event& /*x*/)
-{
-       //throw Smach::egress_exception();
-       throw &state_normal;
-       return Smach::RESULT_OK;
-}
-
-Smach::event_result
-StateWidth_Context::event_refresh_handler(const Smach::event& /*x*/)
-{
-       refresh_ducks();
-       return Smach::RESULT_ACCEPT;
-}
-
-void
-StateWidth_Context::AdjustWidth(handle<Duckmatic::Bezier> c, float t, Real mult, bool invert)
-{
-       //Leave the function if there is no curve
-       if(!c)return;
-
-       Real amount1=0,amount2=0;
-
-       //decide how much to change each width
-       /*
-       t \in [0,1]
-
-       both pressure and multiply amount are in mult
-               (may want to change this to allow different types of falloff)
-
-       rsq is the squared distance from the point on the curve (also part of the falloff)
-
-
-       */
-       //may want to provide a different falloff function...
-       if(t <= 0.2)
-               amount1 = mult;
-       else if(t >= 0.8)
-               amount2 = mult;
-       else
-       {
-               t = (t-0.2)/0.6;
-               amount1 = (1-t)*mult;
-               amount2 = t*mult;
-       }
-
-       if(invert)
-       {
-               amount1 *= -1;
-               amount2 *= -1;
-       }
-
-       handle<Duck>    p1 = c->p1;
-       handle<Duck>    p2 = c->p2;
-
-       handle<Duck>    w1,w2;
-
-       //find w1,w2
-       {
-               const DuckList dl = get_work_area()->get_duck_list();
-
-               DuckList::const_iterator i = dl.begin();
-
-               for(;i != dl.end(); ++i)
-               {
-                       if((*i)->get_type() == Duck::TYPE_WIDTH)
-                       {
-                               if((*i)->get_origin_duck() == p1)
-                               {
-                                       w1 = *i;
-                               }
-
-                               if((*i)->get_origin_duck() == p2)
-                               {
-                                       w2 = *i;
-                               }
-                       }
-               }
-       }
-
-       if(amount1 != 0 && w1)
-       {
-               Real width = w1->get_point().mag();
-
-               width += amount1;
-               w1->set_point(Vector(width,0));
-
-               //log in the list of changes...
-               //to truly be changed after everything is said and done
-               changetable[w1] = width;
-       }
-
-       if(amount2 != 0 && w2)
-       {
-               Real width = w2->get_point().mag();
-
-               width += amount2;
-               w2->set_point(Vector(width,0));
-
-               //log in the list of changes...
-               //to truly be changed after everything is said and done
-               changetable[w2] = width;
-       }
-}
-
-Smach::event_result
-StateWidth_Context::event_mouse_handler(const Smach::event& x)
-{
-       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
-
-       //handle the click
-       if( (event.key == EVENT_WORKAREA_MOUSE_BUTTON_DOWN || event.key == EVENT_WORKAREA_MOUSE_BUTTON_DRAG)
-                       && event.button == BUTTON_LEFT )
-       {
-               const Real pw = get_work_area()->get_pw();
-               const Real ph = get_work_area()->get_ph();
-               const Real scale = sqrt(pw*pw+ph*ph);
-               const Real rad = get_relative() ? scale * get_radius() : get_radius();
-
-               bool invert = (event.modifier&Gdk::CONTROL_MASK);
-
-               const Real threshold = 0.08;
-
-               float t = 0;
-               Real rsq = 0;
-
-               Real dtime = 1/60.0;
-
-               //if we're dragging get the difference in time between now and then
-               if(event.key == EVENT_WORKAREA_MOUSE_BUTTON_DRAG)
-               {
-                       dtime = min(1/15.0,clocktime());
-               }
-               clocktime.reset();
-
-               //make way for new ducks
-               //get_work_area()->clear_ducks();
-
-               //update positions
-               //mouse_pos = event.pos;
-
-               center->set_point(event.pos);
-               if(!added)get_work_area()->add_duck(center);
-
-               radius->set_scalar(rad);
-               if(!added)get_work_area()->add_duck(radius);
-
-               //the other duck is at the current duck
-               closestpoint->set_point(event.pos);
-               if(!added)get_work_area()->add_duck(closestpoint);
-
-               //get the closest curve...
-               handle<Duckmatic::Bezier>       c;
-               if(event.pressure >= threshold)
-                       c = get_work_area()->find_bezier(event.pos,scale*8,rad,&t);
-
-               //run algorithm on event.pos to get 2nd placement
-               if(!c.empty())
-               {
-                       bezier<Point> curve;
-                       Point p;
-
-                       curve[0] = c->p1->get_trans_point();
-                       curve[1] = c->c1->get_trans_point();
-                       curve[2] = c->c2->get_trans_point();
-                       curve[3] = c->p2->get_trans_point();
-
-                       p = curve(t);
-                       rsq = (p-event.pos).mag_squared();
-
-                       const Real r = rad*rad;
-
-                       if(rsq < r)
-                       {
-                               closestpoint->set_point(curve(t));
-
-                               //adjust the width...
-                               //squared falloff for radius... [0,1]
-
-                               Real ri = (r - rsq)/r;
-                               AdjustWidth(c,t,ri*event.pressure*get_delta()*dtime,invert);
-                       }
-               }
-
-               //the points have been added
-               added = true;
-
-               //draw where it is yo!
-               get_work_area()->queue_draw();
-
-               return Smach::RESULT_ACCEPT;
-       }
-
-       if(event.key == EVENT_WORKAREA_MOUSE_BUTTON_UP && event.button == BUTTON_LEFT)
-       {
-               if(added)
-               {
-                       get_work_area()->erase_duck(center);
-                       get_work_area()->erase_duck(radius);
-                       get_work_area()->erase_duck(closestpoint);
-                       added = false;
-               }
-
-               //Affect the width changes here...
-               map<handle<Duck>,Real>::iterator i = changetable.begin();
-
-               synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Sketch Width"));
-               for(; i != changetable.end(); ++i)
-               {
-                       //for each duck modify IT!!!
-                       ValueDesc desc = i->first->get_value_desc();
-
-                       if(     desc.get_value_type() == ValueBase::TYPE_REAL )
-                       {
-                               Action::Handle action(Action::create("ValueDescSet"));
-                               assert(action);
-
-                               action->set_param("canvas",get_canvas());
-                               action->set_param("canvas_interface",get_canvas_interface());
-
-                               action->set_param("value_desc",desc);
-                               action->set_param("new_value",ValueBase(i->second));
-                               action->set_param("time",get_canvas_view()->get_time());
-
-                               if(!action->is_ready() || !get_canvas_view()->get_instance()->perform_action(action))
-                               {
-                                       group.cancel();
-                                       synfig::warning("Changing the width action has failed");
-                                       return Smach::RESULT_ERROR;
-                               }
-                       }
-               }
-
-               changetable.clear();
-
-               get_work_area()->queue_draw();
-
-               return Smach::RESULT_ACCEPT;
-       }
-
-       return Smach::RESULT_OK;
-}
-
-
-void
-StateWidth_Context::refresh_ducks()
-{
-       get_work_area()->clear_ducks();
-       get_work_area()->queue_draw();
-}
diff --git a/synfig-studio/src/gtkmm/state_width.h b/synfig-studio/src/gtkmm/state_width.h
deleted file mode 100644 (file)
index f649140..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_width.h
-**     \brief Width creation state
-**
-**     $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_WIDTH_H
-#define __SYNFIG_STUDIO_STATE_WIDTH_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 StateWidth_Context;
-
-class StateWidth : public Smach::state<StateWidth_Context>
-{
-public:
-       StateWidth();
-       ~StateWidth();
-}; // END of class StateWidth
-
-extern StateWidth state_width;
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/state_zoom.cpp b/synfig-studio/src/gtkmm/state_zoom.cpp
deleted file mode 100644 (file)
index 56363e6..0000000
+++ /dev/null
@@ -1,263 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_zoom.cpp
-**     \brief Zoom Tool Implementation 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 <config.h>
-#endif
-
-#include <sigc++/signal.h>
-#include <sigc++/object.h>
-
-#include <ETL/handle>
-#include <synfig/vector.h>
-
-
-#include "state_zoom.h"
-#include "state_normal.h"
-#include "event_mouse.h"
-#include "canvasview.h"
-#include "workarea.h"
-#include "app.h"
-#include "toolbox.h"
-#include <synfigapp/main.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 ======================================================= */
-StateZoom studio::state_zoom;
-
-const float ZOOMFACTOR = 1.25f;
-
-/* === C L A S S E S & S T R U C T S ======================================= */
-
-class studio::StateZoom_Context : public sigc::trackable
-{
-       etl::handle<CanvasView> canvas_view_;
-       CanvasView::IsWorking is_working;
-
-       Point p1,p2;
-
-       bool prev_workarea_layer_status_;
-
-public:
-
-       //events
-       Smach::event_result event_stop_handler(const Smach::event& x);
-       Smach::event_result event_refresh_handler(const Smach::event& x);
-       Smach::event_result event_mouse_click_handler(const Smach::event& x);
-
-       //constructor destructor
-       StateZoom_Context(CanvasView* canvas_view);
-       ~StateZoom_Context();
-
-       //Canvas interaction
-       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
-       etl::handle<synfigapp::CanvasInterface> 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 zoom(const Point& p1, const Point& p2);
-
-};     // END of class StateZoom_Context
-
-/* === M E T H O D S ======================================================= */
-
-StateZoom::StateZoom():
-       Smach::state<StateZoom_Context>("zoom")
-{
-       insert(event_def(EVENT_STOP,&StateZoom_Context::event_stop_handler));
-       insert(event_def(EVENT_REFRESH,&StateZoom_Context::event_refresh_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StateZoom_Context::event_mouse_click_handler));
-       //insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DRAG,&StateZoom_Context::event_mouse_click_handler));
-       insert(event_def(EVENT_WORKAREA_BOX,&StateZoom_Context::event_mouse_click_handler));
-       //insert(event_def(EVENT_WORKAREA_BUTTON_CLICK,&StateZoom_Context::event_mouse_click_handler));
-       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_UP,&StateZoom_Context::event_mouse_click_handler));
-}
-
-StateZoom::~StateZoom()
-{
-}
-
-StateZoom_Context::StateZoom_Context(CanvasView* canvas_view):
-       canvas_view_(canvas_view),
-       is_working(*canvas_view),
-       prev_workarea_layer_status_(get_work_area()->get_allow_layer_clicks())
-{
-       // Turn off layer clicking
-       get_work_area()->set_allow_layer_clicks(false);
-
-       // clear out the ducks
-       get_work_area()->clear_ducks(); //???
-
-       // Refresh the work area
-       get_work_area()->queue_draw();
-
-       // Hide the tables if they are showing
-       //prev_table_status=get_canvas_view()->tables_are_visible();
-       //if(prev_table_status)get_canvas_view()->hide_tables();
-
-       // Disable the time bar
-       //get_canvas_view()->set_sensitive_timebar(false);
-
-       // Connect a signal
-       //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateZoom_Context::on_user_click));
-       get_work_area()->set_cursor(Gdk::CROSSHAIR);
-
-       App::toolbox->refresh();
-}
-
-StateZoom_Context::~StateZoom_Context()
-{
-       // Restore layer clicking
-       get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_);
-       get_work_area()->reset_cursor();
-
-       // Enable the time bar
-       //get_canvas_view()->set_sensitive_timebar(true);
-
-       // Bring back the tables if they were out before
-       //if(prev_table_status)get_canvas_view()->show_tables();
-
-       // Refresh the work area
-       get_work_area()->queue_draw();
-
-       App::toolbox->refresh();
-
-       get_canvas_view()->get_smach().process_event(EVENT_REFRESH_DUCKS);
-}
-
-Smach::event_result
-StateZoom_Context::event_stop_handler(const Smach::event& /*x*/)
-{
-       //throw Smach::egress_exception();
-       throw &state_normal;
-       return Smach::RESULT_OK;
-}
-
-Smach::event_result
-StateZoom_Context::event_refresh_handler(const Smach::event& /*x*/)
-{
-       return Smach::RESULT_ACCEPT;
-}
-
-Smach::event_result
-StateZoom_Context::event_mouse_click_handler(const Smach::event& x)
-{
-       if(x.key==EVENT_WORKAREA_BOX)
-       {
-               const EventBox& event(*reinterpret_cast<const EventBox*>(&x));
-
-               if(event.button==BUTTON_LEFT)
-               {
-                       Point tl = get_work_area()->get_window_tl();
-                       Point br = get_work_area()->get_window_br();
-                       Vector  window_span = br - tl, window_middle = (br+tl)/2;
-                       Vector  box_span = event.p2 - event.p1, box_middle = (event.p1+event.p2)/2;
-                       Point newpos;
-                       float zoom;
-
-                       if(event.modifier & Gdk::CONTROL_MASK) //zoom out...
-                       {
-                               if (window_span[0] == 0 || window_span[1] == 0) zoom = 1;
-                               else zoom = max(abs(box_span[0]/window_span[0]), abs(box_span[1]/window_span[1]));
-
-                               // focus_point is -1 times the real position for some reason...
-                               // center the window so the old contents fill the drawn box
-                               newpos = -((window_middle - box_middle)/zoom + window_middle);
-                       }
-                       else                            // zoom in
-                       {
-                               if (box_span[0] == 0 || box_span[1] == 0) zoom = 1;
-                               else zoom = min(abs(window_span[0]/box_span[0]), abs(window_span[1]/box_span[1]));
-
-                               // center the window at the center of the box
-                               newpos = -(-get_work_area()->get_focus_point() + (box_middle - window_middle));
-                       }
-
-                       get_work_area()->set_focus_point(newpos);
-                       get_work_area()->set_zoom(get_work_area()->get_zoom()*zoom);
-
-                       return Smach::RESULT_ACCEPT;
-               }
-       }
-
-       if(x.key==EVENT_WORKAREA_MOUSE_BUTTON_UP)
-       {
-               const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
-
-               if(event.button==BUTTON_LEFT)
-               {
-                       Point evpos;
-
-                       //make the event pos be in the same space...
-                       //   The weird ass inverted center normalized space...
-                       {
-                               const Point realcenter = (get_work_area()->get_window_tl() + get_work_area()->get_window_br())/2;
-                               evpos = -(event.pos - realcenter) + get_work_area()->get_focus_point();
-                       }
-
-                       /*      Zooming:
-                               focus point must zoom about the point evpos...
-
-                               trans about an origin not 0:
-                               p' = A(p - o) + o
-                       */
-
-                       Vector v = get_work_area()->get_focus_point() - evpos;
-
-                       if(event.modifier & Gdk::CONTROL_MASK) //zoom out...
-                       {
-                               v*=ZOOMFACTOR;
-                               //get_work_area()->zoom_out();
-                               get_work_area()->set_focus_point(evpos + v);
-                               get_work_area()->set_zoom(get_work_area()->get_zoom()/ZOOMFACTOR);
-                       }else //zoom in
-                       {
-                               v/=ZOOMFACTOR;
-                               //get_work_area()->zoom_in();
-                               get_work_area()->set_focus_point(evpos + v);
-                               get_work_area()->set_zoom(get_work_area()->get_zoom()*ZOOMFACTOR);
-                       }
-
-                       return Smach::RESULT_ACCEPT;
-               }
-       }
-
-       return Smach::RESULT_OK;
-}
diff --git a/synfig-studio/src/gtkmm/state_zoom.h b/synfig-studio/src/gtkmm/state_zoom.h
deleted file mode 100644 (file)
index e5e7260..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file state_zoom.h
-**     \brief Zoom tool 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_STATE_ZOOM_H
-#define __SYNFIG_STATE_ZOOM_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 StateZoom_Context;
-
-class StateZoom : public Smach::state<StateZoom_Context>
-{
-public:
-       StateZoom();
-       ~StateZoom();
-}; // END of class StateZoom
-
-extern StateZoom state_zoom;
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/statemanager.cpp b/synfig-studio/src/gtkmm/statemanager.cpp
deleted file mode 100644 (file)
index 645658a..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file statemanager.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \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
-**     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 <config.h>
-#endif
-
-#include "statemanager.h"
-#include <gtkmm/actiongroup.h>
-#include <gtkmm/action.h>
-#include <synfig/string.h>
-#include "app.h"
-#include "toolbox.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-StateManager::StateManager():
-       state_group(Gtk::ActionGroup::create("action_group_state_manager")),
-       merge_id(App::ui_manager()->new_merge_id())
-{
-       App::ui_manager()->insert_action_group(get_action_group());
-}
-
-StateManager::~StateManager()
-{
-       App::ui_manager()->remove_ui(merge_id);
-
-       for(;!merge_id_list.empty();merge_id_list.pop_back())
-               App::ui_manager()->remove_ui(merge_id_list.back());
-}
-
-void
-StateManager::change_state_(const Smach::state_base *state)
-{
-       App::toolbox->change_state_(state);
-}
-
-void
-StateManager::add_state(const Smach::state_base *state)
-{
-       String name(state->get_name());
-
-       Gtk::StockItem stock_item;
-       Gtk::Stock::lookup(Gtk::StockID("synfig-"+name),stock_item);
-
-       Glib::RefPtr<Gtk::Action> action(
-               Gtk::Action::create(
-                       "state-"+name,
-                       stock_item.get_stock_id(),
-                       stock_item.get_label(),
-                       stock_item.get_label()
-               )
-       );
-       /*action->set_sensitive(false);*/
-       state_group->add(action);
-
-       action->signal_activate().connect(
-               sigc::bind(
-                       sigc::mem_fun(*this,&studio::StateManager::change_state_),
-                       state
-               )
-       );
-
-       App::ui_manager()->ensure_update();
-
-       /*App::ui_manager()->add_ui(
-               merge_id,
-               "/main-menu/menu-state",
-               "state-"+name,
-               "state-"+name
-       );
-       */
-
-       String uid_def("<ui><popup action='menu-main'><menu action='menu-state'><menuitem action='state-"+name+"' /></menu></popup></ui>");
-       merge_id_list.push_back(App::ui_manager()->add_ui_from_string(uid_def));
-
-       App::ui_manager()->ensure_update();
-
-       App::toolbox->add_state(state);
-}
-
-Glib::RefPtr<Gtk::ActionGroup>
-StateManager::get_action_group()
-{
-       return state_group;
-}
diff --git a/synfig-studio/src/gtkmm/statemanager.h b/synfig-studio/src/gtkmm/statemanager.h
deleted file mode 100644 (file)
index 0aeb609..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file statemanager.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_STATEMANAGER_H
-#define __SYNFIG_STATEMANAGER_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <glibmm/refptr.h>
-#include <vector>
-#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 Gtk { class ActionGroup; }
-
-typedef unsigned int guint;
-
-namespace studio {
-       class StateManager
-{
-private:
-       Glib::RefPtr<Gtk::ActionGroup> state_group;
-
-       guint merge_id;
-       std::vector<guint> merge_id_list;
-
-       void change_state_(const Smach::state_base *state);
-
-public:
-       StateManager();
-
-       ~StateManager();
-
-       void add_state(const Smach::state_base *state);
-
-       Glib::RefPtr<Gtk::ActionGroup> get_action_group();
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/toggleducksdial.cpp b/synfig-studio/src/gtkmm/toggleducksdial.cpp
deleted file mode 100644 (file)
index 00ea236..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file toggleducksdial.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2009 Gerco Ballintijn
-**     Copyright (c) 2009 Carlos Lopez
-**
-**     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 <config.h>
-#endif
-
-#include "toggleducksdial.h"
-#include <gtkmm/image.h>
-#include <gtkmm/stock.h>
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace studio;
-
-/* === M A C R O S ========================================================= */
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-ToggleDucksDial::ToggleDucksDial(Gtk::IconSize & size): Gtk::Table(1, 6, false)
-{
-       ducks_position = create_label_button(size, "synfig-toggle_duck_position", _("Toggle position ducks"));
-       ducks_vertex = create_label_button(size, "synfig-toggle_duck_vertex", _("Toggle vertex ducks"));
-       ducks_tangent = create_label_button(size, "synfig-toggle_duck_tangent", _("Toggle tangent ducks"));
-       ducks_radius = create_label_button(size, "synfig-toggle_duck_radius", _("Toggle radius ducks"));
-       ducks_width = create_label_button(size, "synfig-toggle_duck_width", _("Toggle width ducks"));
-       ducks_angle = create_label_button(size, "synfig-toggle_duck_angle", _("Toggle angle ducks"));
-
-       attach(*ducks_position, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       attach(*ducks_vertex, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       attach(*ducks_tangent, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       attach(*ducks_radius, 3, 4, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       attach(*ducks_width, 4, 5, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       attach(*ducks_angle, 5, 6, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-}
-
-Gtk::ToggleButton *
-ToggleDucksDial::create_label_button(Gtk::IconSize iconsize, const char *stockid,
-               const char * tooltip)
-{
-       Gtk::ToggleButton *tbutton = manage(new class Gtk::ToggleButton());
-       Gtk::Image *icon = manage(new Gtk::Image(Gtk::StockID(stockid), iconsize));
-       tooltips.set_tip(*tbutton, tooltip);
-       tbutton->add(*icon);
-       icon->set_padding(0, 0);
-       icon->show();
-       tbutton->set_relief(Gtk::RELIEF_NONE);
-       tbutton->show();
-
-       return tbutton;
-}
-
-void
-ToggleDucksDial::update_toggles(Duck::Type mask)
-{
-       ducks_position-> set_active((mask & Duck::TYPE_POSITION));
-       ducks_vertex  -> set_active((mask & Duck::TYPE_VERTEX));
-       ducks_tangent -> set_active((mask & Duck::TYPE_TANGENT));
-       ducks_radius  -> set_active((mask & Duck::TYPE_RADIUS));
-       ducks_width   -> set_active((mask & Duck::TYPE_WIDTH));
-       ducks_angle   -> set_active((mask & Duck::TYPE_ANGLE));
-}
diff --git a/synfig-studio/src/gtkmm/toggleducksdial.h b/synfig-studio/src/gtkmm/toggleducksdial.h
deleted file mode 100644 (file)
index 832e212..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file toggleducksdial.h
-**     \brief Template Header
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2008 Chris Moore
-**     Copyright (c) 2009 Gerco Ballintijn
-**     Copyright (c) 2009 Carlos Lopez
-**
-**     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_TOOGLEDUCKSDIAL_H
-#define __SYNFIG_STUDIO_TOOGLEDUCKSDIAL_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/tooltips.h>
-#include <gtkmm/table.h>
-#include <gtkmm/togglebutton.h>
-#include "duckmatic.h"
-
-#include "general.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 ToggleDucksDial : public Gtk::Table
-{
-       Gtk::Tooltips tooltips;
-
-       Gtk::ToggleButton *ducks_position;
-       Gtk::ToggleButton *ducks_vertex;
-       Gtk::ToggleButton *ducks_tangent;
-       Gtk::ToggleButton *ducks_radius;
-       Gtk::ToggleButton *ducks_width;
-       Gtk::ToggleButton *ducks_angle;
-
-       Gtk::ToggleButton *create_label_button(Gtk::IconSize iconsize, const char * stockid, const char * tooltip);
-
-public:
-
-       ToggleDucksDial(Gtk::IconSize & size);
-       void update_toggles(Duck::Type mask);
-       Glib::SignalProxy0<void> signal_ducks_position()  { return ducks_position->signal_toggled(); }
-       Glib::SignalProxy0<void> signal_ducks_vertex()    { return ducks_vertex->  signal_toggled(); }
-       Glib::SignalProxy0<void> signal_ducks_tangent()   { return ducks_tangent-> signal_toggled(); }
-       Glib::SignalProxy0<void> signal_ducks_radius()    { return ducks_radius->  signal_toggled(); }
-       Glib::SignalProxy0<void> signal_ducks_width()     { return ducks_width->   signal_toggled(); }
-       Glib::SignalProxy0<void> signal_ducks_angle()     { return ducks_angle->   signal_toggled(); }
-
-}; // END of class ToggleDucksDial
-
-}; // END of namespace studio
-
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/toolbox.cpp b/synfig-studio/src/gtkmm/toolbox.cpp
deleted file mode 100644 (file)
index ea40e7d..0000000
+++ /dev/null
@@ -1,648 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file toolbox.cpp
-**     \brief writeme
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 2008 Chris Moore
-**  Copyright (c) 2008 Paul Wise
-**     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
-**
-** === N O T E S ===========================================================
-**
-** ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include <gtk/gtk.h>
-#include <gtkmm/uimanager.h>
-
-#include <gtkmm/ruler.h>
-#include <gtkmm/arrow.h>
-#include <gtkmm/image.h>
-#include <gdkmm/pixbufloader.h>
-#include <gtkmm/viewport.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/scrolledwindow.h>
-#include <gtkmm/table.h>
-#include <gtkmm/statusbar.h>
-#include <gtkmm/menubar.h>
-#include <gtkmm/menu.h>
-#include <gtkmm/button.h>
-#include <gtkmm/toolbar.h>
-#include <gtkmm/box.h>
-#include <gtkmm/image.h>
-#include <gtkmm/stock.h>
-#include <gtkmm/handlebox.h>
-
-#include <gtkmm/inputdialog.h>
-
-#include <sigc++/signal.h>
-#include <sigc++/hide.h>
-#include <sigc++/slot.h>
-#include <sigc++/retype_return.h>
-#include <sigc++/retype.h>
-
-#include <sstream>
-
-#include "toolbox.h"
-#include "instance.h"
-#include "app.h"
-#include "canvasview.h"
-#include "dialog_gradient.h"
-#include "dialog_color.h"
-#include "dialog_tooloptions.h"
-#include "dialog_preview.h"
-#include "dockable.h"
-#include "dockmanager.h"
-#include "dockdialog.h"
-
-#include "widget_defaults.h"
-
-#include <synfigapp/main.h>
-
-#include "general.h"
-
-#endif
-
-using namespace std;
-using namespace etl;
-using namespace synfig;
-using namespace studio;
-using namespace sigc;
-
-/* === M A C R O S ========================================================= */
-
-#define GRAB_HINT_DATA(y,default)      { \
-               String x; \
-               if(synfigapp::Main::settings().get_value(String("pref.")+y+"_hints",x)) \
-               { \
-                       set_type_hint((Gdk::WindowTypeHint)atoi(x.c_str()));    \
-               } else {\
-                       set_type_hint(default); \
-               } \
-       }
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-#define TOGGLE_TOOLBOX_BUTTON(button,stockid,tooltip)  \
-       button = manage(new class Gtk::ToggleButton()); \
-       icon=manage(new Gtk::Image(Gtk::StockID(stockid),Gtk::IconSize(4)));    \
-       button->add(*icon);     \
-       tooltips.set_tip(*button,tooltip);      \
-       icon->show();   \
-       button->show()
-
-#define TOOLBOX_BUTTON(button,stockid,tooltip) \
-       button = manage(new class Gtk::Button());       \
-       icon=manage(new Gtk::Image(Gtk::StockID(stockid),Gtk::IconSize(4)));    \
-       button->add(*icon);     \
-       tooltips.set_tip(*button,tooltip);      \
-       icon->show();   \
-       button->show()
-
-#define ADD_TOOLBOX_BUTTON(button,stockid,tooltip)     Gtk::Button *TOOLBOX_BUTTON(button,stockid,tooltip)
-
-void
-save_selected_instance()
-{
-       if(!studio::App::get_selected_instance())
-       {
-               App::dialog_error_blocking(_("Cannot save"),_("Nothing to save"));
-               return;
-       }
-
-       studio::App::get_selected_instance()->save();
-}
-
-void
-save_as_selected_instance()
-{
-       if(!studio::App::get_selected_instance())
-       {
-               App::dialog_error_blocking(_("Cannot save as"),_("Nothing to save"));
-               return;
-       }
-
-       studio::App::get_selected_instance()->dialog_save_as();
-}
-
-void
-save_all()
-{
-       std::list<etl::handle<Instance> >::iterator iter;
-       for(iter=App::instance_list.begin();iter!=App::instance_list.end();iter++)
-               (*iter)->save();
-}
-
-void
-close_selected_instance()
-{
-       etl::handle<studio::Instance> instance=studio::App::get_selected_instance();
-
-       if(!instance)
-       {
-               App::dialog_error_blocking(_("Cannot close"),_("Nothing to close"));
-               return;
-       }
-
-       instance->safe_close();
-
-       //assert(instance.unique());
-}
-
-
-static void
-show_dialog_input()
-{
-       App::dialog_input->present();
-}
-
-void _create_stock_dialog1()
-{
-       DockDialog* dock_dialog(new DockDialog);
-       dock_dialog->set_contents("canvases history");
-       dock_dialog->set_composition_selector(true);
-       dock_dialog->present();
-}
-void _create_stock_dialog2()
-{
-       DockDialog* dock_dialog(new DockDialog);
-       dock_dialog->set_contents("layers children keyframes | params");
-       dock_dialog->present();
-}
-
-Toolbox::Toolbox():
-       Gtk::Window(Gtk::WINDOW_TOPLEVEL),
-       dialog_settings(this,"toolbox")
-{
-       GRAB_HINT_DATA(
-               "toolbox",
-//#ifdef __APPLE__
-               Gdk::WINDOW_TYPE_HINT_NORMAL
-//#else
-//             Gdk::WINDOW_TYPE_HINT_UTILITY
-//#endif
-       );
-       set_keep_above(false);
-       set_role("toolbox");
-
-
-
-       recent_files_menu= manage(new class Gtk::Menu());
-
-       Gtk::Menu       *filemenu       =manage(new class Gtk::Menu());
-
-       dock_dialogs=manage(new class Gtk::Menu());
-
-       dock_dialogs->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Vertical Dock: Canvases, History"),sigc::ptr_fun(_create_stock_dialog1)));
-       dock_dialogs->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Horizontal Dock: Layers, Children, Params"),sigc::ptr_fun(_create_stock_dialog2)));
-       dock_dialogs->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
-       dock_dialogs->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Reset Windows to Original Layout"),sigc::ptr_fun(App::reset_initial_window_configuration)));
-       dock_dialogs->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
-
-
-       filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::NEW,
-               sigc::ptr_fun(&studio::App::new_instance)));
-       filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::OPEN,
-               sigc::bind(sigc::ptr_fun(&studio::App::dialog_open), "")));
-
-       filemenu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Open Recent"),*recent_files_menu));
-
-       filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-saveall"),
-               sigc::ptr_fun(save_all)));
-       filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::CLOSE,
-               sigc::ptr_fun(close_selected_instance)));
-       filemenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
-       filemenu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Panels"),*dock_dialogs));
-
-       filemenu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Input Devices..."),
-               sigc::ptr_fun(&show_dialog_input)));
-       filemenu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Setup..."),
-               sigc::ptr_fun(&studio::App::show_setup)));
-
-       filemenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
-       filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID(Gtk::Stock::QUIT),
-               sigc::ptr_fun(studio::App::quit)));
-
-#define WIKI(title,page)                                                                                       \
-       helpmenu->items().push_back(Gtk::Menu_Helpers::MenuElem(title,  \
-               sigc::bind(sigc::ptr_fun(&studio::App::open_url),String("http://synfig.org")+page)))
-
-       Gtk::Menu       *helpmenu = manage(new class Gtk::Menu());
-       helpmenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::HELP, sigc::ptr_fun(studio::App::dialog_help)));
-       helpmenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
-
-       /* TRANSLATORS: Help menu entry */ WIKI(_("Synfig Wiki"),                               /* TRANSLATORS: a wiki page */ _("/Main_Page")                          );
-       /* TRANSLATORS: Help menu entry */ WIKI(_("Tutorials"),                                 /* TRANSLATORS: a wiki page */ _("/Tutorials")                          );
-       /* TRANSLATORS: Help menu entry */ WIKI(_("Frequently Asked Questions"),/* TRANSLATORS: a wiki page */ _("/FAQ")                                        );
-       /* TRANSLATORS: Help menu entry */ WIKI(_("Get Support"),                               /* TRANSLATORS: a wiki page */ _("/Contact")                    );
-       /* TRANSLATORS: Help menu entry */ WIKI(_("Keyboard Shortcuts"),                /* TRANSLATORS: a wiki page */ _("/Keyboard_Shortcuts")         );
-       /* TRANSLATORS: Help menu entry */ WIKI(_("Mouse Shortcuts"),                   /* TRANSLATORS: a wiki page */ _("/Mouse_Shortcuts")            );
-       /* TRANSLATORS: Help menu entry */ WIKI(_("All Pages"), "/Special:Allpages" );
-
-       helpmenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
-       helpmenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-about"),
-               sigc::ptr_fun(studio::App::dialog_about)));
-
-       Gtk::MenuBar *menubar1 = manage(new class Gtk::MenuBar());
-       menubar1->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_File"),*filemenu));
-       menubar1->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Help"),*helpmenu));
-
-
-       menubar1->show();
-
-       Gtk::Image *icon;
-
-       ADD_TOOLBOX_BUTTON(button_new,"gtk-new",_("New..."));
-       ADD_TOOLBOX_BUTTON(button_open,"gtk-open",_("Open..."));
-       ADD_TOOLBOX_BUTTON(button_save,"gtk-save",_("Save"));
-       ADD_TOOLBOX_BUTTON(button_saveas,"gtk-save-as",_("Save As..."));
-       ADD_TOOLBOX_BUTTON(button_save_all,"synfig-saveall",_("Save All"));
-       TOOLBOX_BUTTON(button_undo,"gtk-undo",_("Undo"));
-       TOOLBOX_BUTTON(button_redo,"gtk-redo",_("Redo"));
-       ADD_TOOLBOX_BUTTON(button_setup,"gtk-properties",_("Setup"));
-       ADD_TOOLBOX_BUTTON(button_about,"synfig-about",_("About Synfig Studio"));
-       ADD_TOOLBOX_BUTTON(button_help,"gtk-help",_("Help"));
-
-       button_setup->signal_clicked().connect(sigc::ptr_fun(studio::App::show_setup));
-       button_about->signal_clicked().connect(sigc::ptr_fun(studio::App::dialog_about));
-       button_help->signal_clicked().connect(sigc::ptr_fun(studio::App::dialog_help));
-       button_new->signal_clicked().connect(sigc::ptr_fun(studio::App::new_instance));
-       button_open->signal_clicked().connect(sigc::bind(sigc::ptr_fun(studio::App::dialog_open), ""));
-       button_save->signal_clicked().connect(sigc::ptr_fun(save_selected_instance));
-       button_saveas->signal_clicked().connect(sigc::ptr_fun(save_as_selected_instance));
-       button_save_all->signal_clicked().connect(sigc::ptr_fun(save_all));
-       button_undo->signal_clicked().connect(sigc::ptr_fun(studio::App::undo));
-       button_redo->signal_clicked().connect(sigc::ptr_fun(studio::App::redo));
-
-       // Create the file button cluster
-       Gtk::Table *file_buttons=manage(new class Gtk::Table());
-
-       file_buttons->attach(*button_new,      0,1, 0,1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       file_buttons->attach(*button_open,     1,2, 0,1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       file_buttons->attach(*button_save,     2,3, 0,1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       file_buttons->attach(*button_saveas,   3,4, 0,1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       file_buttons->attach(*button_save_all, 4,5, 0,1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-
-       file_buttons->attach(*button_undo,     0,1, 1,2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       file_buttons->attach(*button_redo,     1,2, 1,2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       file_buttons->attach(*button_setup,    2,3, 1,2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       file_buttons->attach(*button_about,    3,4, 1,2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       file_buttons->attach(*button_help,     4,5, 1,2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-
-       file_buttons->show();
-
-       tool_table=manage(new class Gtk::Table());
-       tool_table->show();
-       Gtk::HandleBox* handle_tools(manage(new Gtk::HandleBox()));
-       handle_tools->add(*tool_table);
-       handle_tools->show();
-       handle_tools->set_handle_position(Gtk::POS_TOP);
-       handle_tools->set_snap_edge(Gtk::POS_TOP);
-
-       Widget_Defaults* widget_defaults(manage(new Widget_Defaults()));
-       widget_defaults->show();
-       Gtk::HandleBox* handle_defaults(manage(new Gtk::HandleBox()));
-       handle_defaults->add(*widget_defaults);
-       handle_defaults->show();
-       handle_defaults->set_handle_position(Gtk::POS_TOP);
-       handle_defaults->set_snap_edge(Gtk::POS_TOP);
-
-       // Create the toplevel table
-       Gtk::Table *table1 = manage(new class Gtk::Table(1, 2, false));
-       table1->set_row_spacings(0);
-       table1->set_col_spacings(0);
-       table1->attach(*menubar1,        0,1, 0,1, Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK, 0, 0);
-       table1->attach(*file_buttons,    0,1, 1,2, Gtk::FILL|Gtk::EXPAND,Gtk::EXPAND|Gtk::FILL, 0, 0);
-       table1->attach(*handle_tools,    0,1, 2,3, Gtk::FILL|Gtk::EXPAND,Gtk::EXPAND|Gtk::FILL, 0, 0);
-       table1->attach(*handle_defaults, 0,1, 3,4, Gtk::FILL|Gtk::EXPAND,Gtk::EXPAND|Gtk::FILL, 0, 0);
-       table1->show_all();
-
-
-
-       // Set the parameters for this window
-       add(*table1);
-       set_title(_("Synfig Studio"));
-       set_modal(false);
-       property_window_position().set_value(Gtk::WIN_POS_NONE);
-       signal_delete_event().connect(sigc::ptr_fun(App::shutdown_request));
-       set_resizable(false);
-
-
-
-       App::signal_instance_selected().connect(
-               sigc::hide(
-                       sigc::mem_fun(*this,&studio::Toolbox::update_undo_redo)
-               )
-       );
-
-       App::signal_recent_files_changed().connect(
-                       sigc::mem_fun(*this,&studio::Toolbox::on_recent_files_changed)
-       );
-
-       button_undo->set_sensitive(false);
-       button_redo->set_sensitive(false);
-
-       std::list<Gtk::TargetEntry> listTargets;
-       listTargets.push_back( Gtk::TargetEntry("text/plain") );
-       listTargets.push_back( Gtk::TargetEntry("image") );
-//     listTargets.push_back( Gtk::TargetEntry("image/x-sif") );
-
-       drag_dest_set(listTargets);
-       signal_drag_data_received().connect( sigc::mem_fun(*this, &studio::Toolbox::on_drop_drag_data_received) );
-
-       App::dock_manager->signal_dockable_registered().connect(sigc::mem_fun(*this,&Toolbox::dockable_registered));
-
-       changing_state_=false;
-
-
-       add_accel_group(App::ui_manager()->get_accel_group());
-
-       App::signal_present_all().connect(sigc::mem_fun0(*this,&Toolbox::present));
-}
-
-Toolbox::~Toolbox()
-{
-       hide();
-       //studio::App::cb.task(_("Toolbox: I was nailed!"));
-       //studio::App::quit();
-
-       if(studio::App::toolbox==this)
-               studio::App::toolbox=NULL;
-
-}
-
-void
-Toolbox::set_active_state(const synfig::String& statename)
-{
-       std::map<synfig::String,Gtk::ToggleButton *>::iterator iter;
-
-       changing_state_=true;
-
-       synfigapp::Main::set_state(statename);
-
-       try
-       {
-
-               for(iter=state_button_map.begin();iter!=state_button_map.end();++iter)
-               {
-                       if(iter->first==statename)
-                       {
-                               if(!iter->second->get_active())
-                                       iter->second->set_active(true);
-                       }
-                       else
-                       {
-                               if(iter->second->get_active())
-                                       iter->second->set_active(false);
-                       }
-               }
-       }
-       catch(...)
-       {
-               changing_state_=false;
-               throw;
-       }
-       changing_state_=false;
-}
-
-void
-Toolbox::change_state(const synfig::String& statename)
-{
-       etl::handle<studio::CanvasView> canvas_view(studio::App::get_selected_canvas_view());
-       if(canvas_view)
-       {
-               if(statename==canvas_view->get_smach().get_state_name())
-               {
-                       return;
-               }
-
-               if(state_button_map.count(statename))
-               {
-                       state_button_map[statename]->clicked();
-               }
-               else
-               {
-                       synfig::error("Unknown state \"%s\"",statename.c_str());
-               }
-       }
-}
-
-void
-Toolbox::change_state_(const Smach::state_base *state)
-{
-       if(changing_state_)
-               return;
-       changing_state_=true;
-
-       try
-       {
-               etl::handle<studio::CanvasView> canvas_view(studio::App::get_selected_canvas_view());
-               if(canvas_view)
-                               canvas_view->get_smach().enter(state);
-               else
-                       refresh();
-       }
-       catch(...)
-       {
-               changing_state_=false;
-               throw;
-       }
-
-       changing_state_=false;
-}
-
-void
-Toolbox::add_state(const Smach::state_base *state)
-{
-       Gtk::Image *icon;
-
-       assert(state);
-
-       String name=state->get_name();
-
-       Gtk::StockItem stock_item;
-       Gtk::Stock::lookup(Gtk::StockID("synfig-"+name),stock_item);
-
-       Gtk::ToggleButton* button;
-       button=manage(new class Gtk::ToggleButton());
-
-       icon=manage(new Gtk::Image(stock_item.get_stock_id(),Gtk::IconSize(4)));
-       button->add(*icon);
-       tooltips.set_tip(*button,stock_item.get_label());
-       icon->show();
-       button->show();
-
-       int row=state_button_map.size()/5;
-       int col=state_button_map.size()%5;
-
-       tool_table->attach(*button,col,col+1,row,row+1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-
-       state_button_map[name]=button;
-
-       button->signal_clicked().connect(
-               sigc::bind(
-                       sigc::mem_fun(*this,&studio::Toolbox::change_state_),
-                       state
-               )
-       );
-
-       refresh();
-}
-
-
-void
-Toolbox::update_undo_redo()
-{
-       etl::handle<Instance> instance=App::get_selected_instance();
-       if(instance)
-       {
-               button_undo->set_sensitive(instance->get_undo_status());
-               button_redo->set_sensitive(instance->get_redo_status());
-       }
-
-       // This should probably go elsewhere, but it should
-       // work fine here with no troubles.
-       // These next several lines just adjust the tool buttons
-       // so that they are only clickable when they should be.
-       if(instance && App::get_selected_canvas_view())
-       {
-               std::map<synfig::String,Gtk::ToggleButton *>::iterator iter;
-
-               for(iter=state_button_map.begin();iter!=state_button_map.end();++iter)
-                       iter->second->set_sensitive(true);
-       }
-       else
-       {
-               std::map<synfig::String,Gtk::ToggleButton *>::iterator iter;
-
-               for(iter=state_button_map.begin();iter!=state_button_map.end();++iter)
-                       iter->second->set_sensitive(false);
-       }
-
-       etl::handle<CanvasView> canvas_view=App::get_selected_canvas_view();
-       if(canvas_view && canvas_view->get_smach().get_state_name())
-       {
-               set_active_state(canvas_view->get_smach().get_state_name());
-       }
-       else
-               set_active_state("none");
-
-}
-
-void
-Toolbox::on_recent_files_changed()
-{
-       while(recent_files_menu->get_children().size())
-               recent_files_menu->remove(**recent_files_menu->get_children().begin());
-
-       list<string>::const_iterator iter;
-       for(iter=App::get_recent_files().begin();iter!=App::get_recent_files().end();iter++)
-       {
-               string raw = basename(*iter), quoted;
-               size_t pos = 0, last_pos = 0;
-
-               // replace _ in filenames by __ or it won't show up in the menu
-               for (pos = last_pos = 0; (pos = raw.find('_', pos)) != string::npos; last_pos = pos)
-                       quoted += raw.substr(last_pos, ++pos - last_pos) + '_';
-               quoted += raw.substr(last_pos);
-
-               recent_files_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(quoted,
-                       sigc::hide_return(sigc::bind(sigc::ptr_fun(&App::open),*iter))
-               ));
-       }
-
-       // HACK
-       show();
-}
-
-void
-Toolbox::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);
-
-       if ((selection_data_.get_length() >= 0) && (selection_data_.get_format() == 8))
-       {
-               synfig::String selection_data((gchar *)(selection_data_.get_data()));
-
-               // For some reason, GTK hands us a list of URLs separated
-               // by not only Carriage-Returns, but also Line-Feeds.
-               // Line-Feeds will mess us up. Remove all the line-feeds.
-               while(selection_data.find_first_of('\r')!=synfig::String::npos)
-                       selection_data.erase(selection_data.begin()+selection_data.find_first_of('\r'));
-
-               std::stringstream stream(selection_data);
-
-               while(stream)
-               {
-                       synfig::String filename,URI;
-                       getline(stream,filename);
-
-                       // If we don't have a filename, move on.
-                       if(filename.empty())
-                               continue;
-
-                       // Make sure this URL is of the "file://" type.
-                       URI=String(filename.begin(),filename.begin()+sizeof("file://")-1);
-                       if(URI!="file://")
-                       {
-                               synfig::warning("Unknown URI (%s) in \"%s\"",URI.c_str(),filename.c_str());
-                               continue;
-                       }
-
-                       // Strip the "file://" part from the filename
-                       filename=synfig::String(filename.begin()+sizeof("file://")-1,filename.end());
-
-                       synfig::info("Attempting to open "+filename);
-                       if(App::open(filename))
-                               success=true;
-                       else
-                               synfig::error("Drop failed: Unable to open "+filename);
-               }
-       }
-       else
-               synfig::error("Drop failed: bad selection data");
-
-       // Finish the drag
-       context->drag_finish(success, false, time);
-}
-
-void
-Toolbox::dockable_registered(Dockable* x)
-{
-       dock_dialogs->items().push_back(
-               Gtk::Menu_Helpers::MenuElem(
-                       x->get_local_name(),
-                       sigc::mem_fun(
-                               *x,
-                               &Dockable::present
-                       )
-               )
-       );
-}
diff --git a/synfig-studio/src/gtkmm/toolbox.h b/synfig-studio/src/gtkmm/toolbox.h
deleted file mode 100644 (file)
index 21696ab..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file toolbox.h
-**     \brief Header File
-**
-**     $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
-**
-** === N O T E S ===========================================================
-**
-** ========================================================================= */
-
-/* === S T A R T =========================================================== */
-
-#ifndef __SYNFIG_GTKMM_TOOLBOX_H
-#define __SYNFIG_GTKMM_TOOLBOX_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/window.h>
-#include <gtkmm/tooltips.h>
-#include <gtkmm/button.h>
-#include <gtkmm/togglebutton.h>
-#include <gtkmm/menu.h>
-#include <gtkmm/table.h>
-#include <synfig/string.h>
-#include "smach.h"
-#include <map>
-#include "dialogsettings.h"
-
-/* === M A C R O S ========================================================= */
-
-// uncomment to enable the blend method selector in the tool options
-// panel for the circle and gradient tools
-//
-// #define BLEND_METHOD_IN_TOOL_OPTIONS
-
-/* === 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 Dockable;
-class StateManager;
-
-class Toolbox : public Gtk::Window
-{
-       friend class studio::StateManager;
-
-       DialogSettings dialog_settings;
-
-       Gtk::Tooltips tooltips;
-       Gtk::Button *button_undo;
-       Gtk::Button *button_redo;
-
-       Gtk::Table *tool_table;
-
-       std::map<synfig::String,Gtk::ToggleButton *> state_button_map;
-
-       Gtk::Menu       *recent_files_menu;
-
-       Gtk::Menu       *dock_dialogs;
-
-       bool changing_state_;
-
-       void on_recent_files_changed();
-       void on_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& selection_data, guint info, guint time);
-
-       void change_state_(const Smach::state_base *state);
-
-public:
-
-       void change_state(const synfig::String& statename);
-
-       void update_undo_redo();
-
-       void refresh() { update_undo_redo(); }
-
-       void set_active_state(const synfig::String& statename);
-
-       void add_state(const Smach::state_base *state);
-
-
-       void dockable_registered(Dockable* x);
-
-       Toolbox();
-       virtual ~Toolbox();
-
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/valuelink.cpp b/synfig-studio/src/gtkmm/valuelink.cpp
deleted file mode 100644 (file)
index 3f10980..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file valuelink.cpp
-**     \brief ValueBase Link Implementation File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2004 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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "valuelink.h"
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-using namespace synfig;
-
-using studio::ValueBaseLink;
-
-/* === M A C R O S ========================================================= */
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-/* === E N T R Y P O I N T ================================================= */
-
-//structors
-ValueBaseLink::ValueBaseLink()
-{
-       assert(0); //CHECK: This class does not appear to be used.
-}
-
-ValueBaseLink::~ValueBaseLink()
-{
-}
-
-//link access
-
-ValueNode::LooseHandle ValueBaseLink::get_link_vfunc(int i)const
-{
-       /*list_type::const_iterator     it = list.begin();
-
-       while(it != list.end() && i-- > 0)
-       {
-               ++it;
-       }
-
-       if(it == list.end())
-       {
-               return ValueNode::LooseHandle();
-       }else
-       {
-               return *it;
-       }*/
-       if(i >= 0 && i < (int)list.size())
-       {
-               return list[i];
-       }else
-       {
-               return ValueNode::LooseHandle();
-       }
-}
-
-//more link access
-int ValueBaseLink::link_count()const
-{
-       return list.size();
-}
-
-String ValueBaseLink::link_local_name(int i)const
-{
-       ValueNode::LooseHandle h = get_link(i);
-
-       if(h)
-       {
-               return h->get_local_name();
-       }else return String();
-}
-
-String ValueBaseLink::link_name(int i)const
-{
-       ValueNode::LooseHandle h = get_link(i);
-
-       if(h)
-       {
-               return h->get_name();
-       }else return String();
-}
-
-int ValueBaseLink::get_link_index_from_name(const synfig::String &name)const
-{
-       throw Exception::BadLinkName(name);
-}
-
-//list management stuff
-ValueBaseLink::list_type::const_iterator ValueBaseLink::findlink(synfig::ValueNode::Handle x) const
-{
-       for(list_type::const_iterator i = list.begin(); i != list.end(); ++i)
-       {
-               if(*i == x)
-               {
-                       return i;
-               }
-       }
-
-       return list.end();
-}
-ValueBaseLink::list_type::iterator ValueBaseLink::findlink(synfig::ValueNode::Handle x)
-{
-       for(list_type::iterator i = list.begin(); i != list.end(); ++i)
-       {
-               if(*i == x)
-               {
-                       return i;
-               }
-       }
-
-       return list.end();
-}
-
-void ValueBaseLink::add(synfig::ValueNode::Handle v)
-{
-       list_type::iterator i = findlink(v);
-
-       if(i != list.end())
-       {
-               list.push_back(v);
-       }
-}
-
-void ValueBaseLink::remove(synfig::ValueNode::Handle v)
-{
-       list_type::iterator i = findlink(v);
-
-       if(i != list.end())
-       {
-               if(i != list.end()-1)
-               {
-                       *i = list.back();
-               }
-               list.pop_back();
-       }
-}
diff --git a/synfig-studio/src/gtkmm/valuelink.h b/synfig-studio/src/gtkmm/valuelink.h
deleted file mode 100644 (file)
index a2d999b..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file valuelink.h
-**     \brief ValueBase Link Header
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2004 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_VALUELINK_H
-#define __SYNFIG_VALUELINK_H
-
-/* === H E A D E R S ======================================================= */
-#include <synfig/valuenode.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 {
-
-/* NOTE: DO NOT USE THE INDEX BASED INTERFACE... THINGS WILL CHANGE
-*/
-class ValueBaseLink : public synfig::LinkableValueNode
-{
-       typedef std::vector<ValueNode::Handle> list_type;
-       list_type       list;
-
-protected:
-       //stuff I don't want
-       virtual bool set_link_vfunc(int /*i*/,synfig::ValueNode::Handle /*x*/) {return false;}
-       virtual LinkableValueNode* create_new()const {return 0;}
-
-       //new stuff I need
-       list_type::const_iterator findlink(synfig::ValueNode::Handle x) const;
-       list_type::iterator findlink(synfig::ValueNode::Handle x);
-
-public: //linkable interface
-
-       //stuff I do want
-       virtual synfig::ValueNode::LooseHandle get_link_vfunc(int i)const;
-       virtual int link_count()const;
-
-       //I have to support the thing because it's too much work otherwise
-       virtual synfig::String link_local_name(int i)const;
-       virtual synfig::String link_name(int i)const;
-
-public:
-       ValueBaseLink();
-       virtual ~ValueBaseLink();
-
-       //don't want
-       virtual int get_link_index_from_name(const synfig::String &name)const;
-
-       //new add and subtract stuff
-       virtual void add(synfig::ValueNode::Handle v);
-       virtual void remove(synfig::ValueNode::Handle v);
-
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/widget_canvaschooser.cpp b/synfig-studio/src/gtkmm/widget_canvaschooser.cpp
deleted file mode 100644 (file)
index 568c4b0..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_canvaschooser.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \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
-**     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 <config.h>
-#endif
-
-#include "widget_canvaschooser.h"
-#include <gtkmm/menu.h>
-#include "app.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Widget_CanvasChooser::Widget_CanvasChooser()
-{
-}
-
-Widget_CanvasChooser::~Widget_CanvasChooser()
-{
-}
-
-void
-Widget_CanvasChooser::set_parent_canvas(synfig::Canvas::Handle x)
-{
-       assert(x);
-       parent_canvas=x;
-}
-
-void
-Widget_CanvasChooser::set_value_(synfig::Canvas::Handle data)
-{
-       set_value(data);
-       activate();
-}
-
-void
-Widget_CanvasChooser::set_value(synfig::Canvas::Handle data)
-{
-       assert(parent_canvas);
-       canvas=data;
-
-       canvas_menu=manage(new class Gtk::Menu());
-
-       synfig::Canvas::Children::iterator iter;
-       synfig::Canvas::Children &children(parent_canvas->children());
-       String label;
-
-       if(canvas)
-       {
-               label=canvas->get_name().empty()?canvas->get_id():canvas->get_name();
-               canvas_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(label));
-       }
-
-       for(iter=children.begin();iter!=children.end();iter++)
-               if(*iter!=canvas)
-               {
-                       label=(*iter)->get_name().empty()?(*iter)->get_id():(*iter)->get_name();
-                       canvas_menu->items().push_back(
-                               Gtk::Menu_Helpers::MenuElem(
-                                       label,
-                                       sigc::bind(
-                                               sigc::mem_fun(
-                                                       *this,
-                                                       &Widget_CanvasChooser::set_value_
-                                               ),
-                                               *iter
-                                       )
-                               )
-                       );
-               }
-       canvas_menu->items().push_back(
-               Gtk::Menu_Helpers::MenuElem(
-                       _("Other..."),
-                       sigc::mem_fun(*this,&Widget_CanvasChooser::chooser_menu)
-               )
-       );
-       set_menu(*canvas_menu);
-
-       if(canvas)
-               set_history(0);
-}
-
-const etl::handle<synfig::Canvas> &
-Widget_CanvasChooser::get_value()
-{
-       return canvas;
-}
-
-void
-Widget_CanvasChooser::chooser_menu()
-{
-       String canvas_name;
-
-       if (!App::dialog_entry(_("Choose Canvas"),_("Enter the relative name of the canvas that you want"),canvas_name))
-       {
-               // the user hit 'cancel', so set the parameter back to its previous value
-               set_value_(canvas);
-               return;
-       }
-
-       if (canvas_name == "")
-       {
-               App::dialog_error_blocking(_("Error"),_("No canvas name was specified"));
-               set_value_(canvas);
-               return;
-       }
-
-       Canvas::Handle new_canvas;
-       try
-       {
-               String warnings;
-               new_canvas=parent_canvas->find_canvas(canvas_name, warnings);
-               set_value_(new_canvas);
-       }
-       catch(std::runtime_error x)
-       {
-               App::dialog_error_blocking(_("Error:Exception Thrown"),String(_("Error selecting canvas:\n\n")) + x.what());
-               set_value_(canvas);
-       }
-       catch(...)
-       {
-               App::dialog_error_blocking(_("Error"),_("Unknown Exception"));
-               set_value_(canvas);
-       }
-}
diff --git a/synfig-studio/src/gtkmm/widget_canvaschooser.h b/synfig-studio/src/gtkmm/widget_canvaschooser.h
deleted file mode 100644 (file)
index afa9287..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_canvaschooser.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_WIDGET_CANVASCHOOSER_H
-#define __SYNFIG_STUDIO_WIDGET_CANVASCHOOSER_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <synfig/canvas.h>
-#include <gtkmm/optionmenu.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 Gtk { class Menu; };
-
-namespace studio {
-
-class Widget_CanvasChooser : public Gtk::OptionMenu
-{
-       Gtk::Menu *canvas_menu;
-       synfig::Canvas::Handle parent_canvas;
-
-       synfig::Canvas::Handle canvas;
-       void set_value_(synfig::Canvas::Handle data);
-public:
-
-       Widget_CanvasChooser();
-       ~Widget_CanvasChooser();
-
-       void set_parent_canvas(synfig::Canvas::Handle x);
-       void set_value(synfig::Canvas::Handle data);
-       const synfig::Canvas::Handle &get_value();
-private:
-       void chooser_menu();
-}; // END of class Widget_CanvasChooser
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/widget_color.cpp b/synfig-studio/src/gtkmm/widget_color.cpp
deleted file mode 100644 (file)
index 1c53b5e..0000000
+++ /dev/null
@@ -1,200 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_color.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "widget_color.h"
-#include <cmath>
-#include "app.h"
-#include <gtkmm/drawingarea.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-Gdk::Color
-studio::colorconv_synfig2gdk(const synfig::Color &c_)
-{
-       const synfig::Color c(c_.clamped());
-       Gdk::Color ret;
-       ret.set_rgb(
-                       256*App::gamma.r_F32_to_U8(c.get_r()),
-                       256*App::gamma.g_F32_to_U8(c.get_g()),
-                       256*App::gamma.b_F32_to_U8(c.get_b())
-               );
-       return ret;
-}
-
-void
-studio::render_color_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::Color &color)
-{
-       const int height(ca.get_height());
-       const int width(ca.get_width());
-
-       const int square_size(height/2);
-
-       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(window));
-
-       if(color.get_alpha()!=1.0)
-       {
-               // In this case we need to render the alpha squares
-
-               const Color bg1(Color::blend(color,Color(0.75, 0.75, 0.75),1.0).clamped());
-               const Color bg2(Color::blend(color,Color(0.5, 0.5, 0.5),1.0).clamped());
-
-               Gdk::Color gdk_c1(colorconv_synfig2gdk(bg1));
-               Gdk::Color gdk_c2(colorconv_synfig2gdk(bg2));
-
-               bool toggle(false);
-               for(int i=0;i<width;i+=square_size)
-               {
-                       const int square_width(min(square_size,width-i));
-
-                       if(toggle)
-                       {
-                               gc->set_rgb_fg_color(gdk_c1);
-                               window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), square_width, square_size);
-
-                               gc->set_rgb_fg_color(gdk_c2);
-                               window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y()+square_size, square_width, square_size);
-                               toggle=false;
-                       }
-                       else
-                       {
-                               gc->set_rgb_fg_color(gdk_c2);
-                               window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), square_width, square_size);
-
-                               gc->set_rgb_fg_color(gdk_c1);
-                               window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y()+square_size, square_width, square_size);
-                               toggle=true;
-                       }
-               }
-       }
-       else
-       {
-               // In this case we have a solid color to use
-               Gdk::Color gdk_c1(colorconv_synfig2gdk(color));
-
-               gc->set_rgb_fg_color(gdk_c1);
-               window->draw_rectangle(gc, true, ca.get_x(), ca.get_y(), width-1, height-1);
-       }
-       gc->set_rgb_fg_color(Gdk::Color("#ffffff"));
-       window->draw_rectangle(gc, false, ca.get_x()+1, ca.get_y()+1, width-3, height-3);
-       gc->set_rgb_fg_color(Gdk::Color("#000000"));
-       window->draw_rectangle(gc, false, ca.get_x(), ca.get_y(), width-1, height-1);
-}
-
-/* === C L A S S E S ======================================================= */
-
-
-/* === M E T H O D S ======================================================= */
-
-Widget_Color::Widget_Color()
-{
-       color=Color(0,0,0,0);
-       set_size_request(-1,16);
-
-       signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Color::redraw));
-       add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
-
-}
-
-Widget_Color::~Widget_Color()
-{
-}
-
-void
-Widget_Color::set_value(const synfig::Color &data)
-{
-       assert(data.is_valid());
-       color=data;
-       queue_draw();
-}
-
-const synfig::Color &
-Widget_Color::get_value()
-{
-       assert(color.is_valid());
-       return color;
-}
-
-bool
-Widget_Color::on_event(GdkEvent *event)
-{
-       switch(event->type)
-       {
-       case GDK_BUTTON_PRESS:
-               if(event->button.button==1)
-               {
-                       signal_activate_();
-                       return true;
-               }
-               if(event->button.button==2)
-               {
-                       signal_middle_click_();
-                       return true;
-               }
-               if(event->button.button==3)
-               {
-                       signal_right_click_();
-                       return true;
-               }
-               break;
-
-       default:
-               break;
-       }
-       return false;
-}
-
-bool
-Widget_Color::redraw(GdkEventExpose */*bleh*/)
-{
-       //Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
-
-       const int h(get_height());
-       const int w(get_width());
-
-       render_color_to_window(get_window(),Gdk::Rectangle(0,0,w,h),color);
-
-       return true;
-}
diff --git a/synfig-studio/src/gtkmm/widget_color.h b/synfig-studio/src/gtkmm/widget_color.h
deleted file mode 100644 (file)
index 14e3db1..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_color.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_WIDGET_COLOR_H
-#define __SYNFIG_STUDIO_WIDGET_COLOR_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/box.h>
-#include <gtkmm/table.h>
-#include <gtkmm/spinbutton.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/drawingarea.h>
-#include <synfig/color.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 {
-
-
-Gdk::Color colorconv_synfig2gdk(const synfig::Color &c);
-
-void render_color_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::Color &color);
-
-class Widget_Color : public Gtk::DrawingArea
-{
-       synfig::Color color;
-
-       sigc::signal<void> signal_activate_;
-       sigc::signal<void> signal_middle_click_;
-       sigc::signal<void> signal_right_click_;
-
-protected:
-
-public:
-       sigc::signal<void>& signal_activate() { return signal_activate_; }
-       sigc::signal<void>& signal_clicked() { return signal_activate_; }
-       sigc::signal<void>& signal_middle_click() { return signal_middle_click_; }
-       sigc::signal<void>& signal_right_click() { return signal_right_click_; }
-
-       void set_value(const synfig::Color &data);
-       const synfig::Color &get_value();
-       Widget_Color();
-       ~Widget_Color();
-private:
-       bool redraw(GdkEventExpose*bleh);
-       bool on_event(GdkEvent *event);
-
-}; // END of class Widget_Color
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/widget_coloredit.cpp b/synfig-studio/src/gtkmm/widget_coloredit.cpp
deleted file mode 100644 (file)
index 5e3175a..0000000
+++ /dev/null
@@ -1,587 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_coloredit.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007 Chris Moore
-**  Copyright (c) 2008 Paul Wise
-**
-**     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 <config.h>
-#endif
-
-#include "widget_coloredit.h"
-#include <cmath>
-#include "app.h"
-#include <gtkmm/drawingarea.h>
-#include <pangomm/attributes.h>
-#include <pangomm/attrlist.h>
-#include <algorithm>
-#include <gtkmm/notebook.h>
-#include <gtkmm/box.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 ========================================================= */
-
-#define SPINBUTTON_WIDTH 100
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === C L A S S E S ======================================================= */
-
-ColorSlider::ColorSlider(const ColorSlider::Type &x):
-       type(x)
-{
-       signal_expose_event().connect(sigc::mem_fun(*this, &ColorSlider::redraw));
-       set_size_request(-1,12);
-       add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
-       add_events(Gdk::BUTTON1_MOTION_MASK);
-}
-
-void
-ColorSlider::set_type(Type x) { type=x; queue_draw(); }
-
-void
-ColorSlider::set_color(synfig::Color x) { color_=x; queue_draw(); }
-
-void
-ColorSlider::slider_color_TYPE_R(synfig::Color &color, float amount) { color.set_r(amount); }
-void
-ColorSlider::slider_color_TYPE_G(synfig::Color &color, float amount) { color.set_g(amount); }
-void
-ColorSlider::slider_color_TYPE_B(synfig::Color &color, float amount) { color.set_b(amount); }
-void
-ColorSlider::slider_color_TYPE_Y(synfig::Color &color, float amount) { color.set_y(amount); }
-void
-ColorSlider::slider_color_TYPE_U(synfig::Color &color, float amount) { color.set_u(amount-0.5f); }
-void
-ColorSlider::slider_color_TYPE_V(synfig::Color &color, float amount) { color.set_v(amount-0.5f); }
-void
-ColorSlider::slider_color_TYPE_HUE(synfig::Color &color, float amount) { color.set_uv_angle(Angle::rot(amount)); }
-void
-ColorSlider::slider_color_TYPE_SAT(synfig::Color &color, float amount) { color.set_s(amount*0.5f); }
-void
-ColorSlider::slider_color_TYPE_A(synfig::Color &color, float amount) { color.set_a(amount); }
-
-void
-ColorSlider::adjust_color(Type type, synfig::Color &color, float amount)
-{
-       static const slider_color_func jump_table[int(TYPE_END)] =
-       {
-               slider_color_TYPE_R,
-               slider_color_TYPE_G,
-               slider_color_TYPE_B,
-               slider_color_TYPE_Y,
-               slider_color_TYPE_U,
-               slider_color_TYPE_V,
-               slider_color_TYPE_HUE,
-               slider_color_TYPE_SAT,
-               slider_color_TYPE_A,
-       };
-       jump_table[int(type)](color,amount);
-}
-
-bool
-ColorSlider::redraw(GdkEventExpose */*bleh*/)
-{
-       Color color(color_);
-
-       static const slider_color_func jump_table[int(TYPE_END)] =
-       {
-               slider_color_TYPE_R,
-               slider_color_TYPE_G,
-               slider_color_TYPE_B,
-               slider_color_TYPE_Y,
-               slider_color_TYPE_U,
-               slider_color_TYPE_V,
-               slider_color_TYPE_HUE,
-               slider_color_TYPE_SAT,
-               slider_color_TYPE_A,
-       };
-
-       slider_color_func color_func(jump_table[int(type)]);
-
-       float amount;
-       switch(type)
-       {
-               case TYPE_R: amount=color.get_r(); break;
-               case TYPE_G: amount=color.get_g(); break;
-               case TYPE_B: amount=color.get_b(); break;
-               case TYPE_Y: amount=color.get_y(); break;
-               case TYPE_U: amount=color.get_u()+0.5; break;
-               case TYPE_V: amount=color.get_v()+0.5; break;
-               case TYPE_HUE: amount=Angle::rot(color.get_uv_angle()).get(); amount-=floor(amount); break;
-               case TYPE_SAT: amount=color.get_s()*2.0; break;
-               case TYPE_A: amount=color.get_a(); break;
-               default: amount=0; break;
-       }
-       if(use_colorspace_gamma() && (type<TYPE_U))
-               amount=gamma_in(amount);
-
-       const int height(get_height());
-       const int width(get_width());
-
-       Gdk::Rectangle ca(0,0,width,height);
-
-       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
-       const Color bg1(0.75, 0.75, 0.75);
-       const Color bg2(0.5, 0.5, 0.5);
-       int i;
-       for(i=width-1;i>=0;i--)
-       {
-               color_func(color,
-                                  (use_colorspace_gamma() && type<TYPE_U)
-                                  ? gamma_out(float(i)/float(width))
-                                  :              (float(i)/float(width)));
-               const Color c1(Color::blend(color,bg1,1.0).clamped());
-               const Color c2(Color::blend(color,bg2,1.0).clamped());
-               assert(c1.is_valid());
-               assert(c2.is_valid());
-
-               if((i*2/height)&1)
-               {
-                       gc->set_rgb_fg_color(colorconv_synfig2gdk(c1));
-                       get_window()->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), 1, height/2);
-
-                       gc->set_rgb_fg_color(colorconv_synfig2gdk(c2));
-                       get_window()->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y()+height/2, 1, height/2);
-               }
-               else
-               {
-                       gc->set_rgb_fg_color(colorconv_synfig2gdk(c2));
-                       get_window()->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), 1, height/2);
-
-                       gc->set_rgb_fg_color(colorconv_synfig2gdk(c1));
-                       get_window()->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y()+height/2, 1, height/2);
-               }
-       }
-
-       get_style()->paint_arrow(
-               get_window(),
-               Gtk::STATE_SELECTED,
-               Gtk::SHADOW_OUT,
-               ca,
-               *this,
-               " ",
-               Gtk::ARROW_UP,
-               1,
-               int(amount*width)-height/2,
-               0,
-               height,
-               height
-       );
-
-       gc->set_rgb_fg_color(Gdk::Color("#ffffff"));
-       get_window()->draw_rectangle(gc, false, ca.get_x()+1, ca.get_y()+1, width-3, height-3);
-       gc->set_rgb_fg_color(Gdk::Color("#000000"));
-       get_window()->draw_rectangle(gc, false, ca.get_x(), ca.get_y(), width-1, height-1);
-       return true;
-}
-
-bool
-ColorSlider::on_event(GdkEvent *event)
-{
-       const int width(get_width());
-       float x = 0;
-       if( GDK_SCROLL == event->type ){
-               Color color(color_);
-               float amount;
-               switch(type)
-               {
-                       case TYPE_R: amount=color.get_r(); break;
-                       case TYPE_G: amount=color.get_g(); break;
-                       case TYPE_B: amount=color.get_b(); break;
-                       case TYPE_Y: amount=color.get_y(); break;
-                       case TYPE_U: amount=color.get_u()+0.5; break;
-                       case TYPE_V: amount=color.get_v()+0.5; break;
-                       case TYPE_HUE: amount=Angle::rot(color.get_uv_angle()).get(); amount-=floor(amount); break;
-                       case TYPE_SAT: amount=color.get_s()*2.0; break;
-                       case TYPE_A: amount=color.get_a(); break;
-                       default: amount=0; break;
-               }
-               if(use_colorspace_gamma() && (type<TYPE_U))
-                       amount=gamma_in(amount);
-               x = amount*width;
-               switch(event->scroll.direction){
-                       case GDK_SCROLL_UP:
-                       case GDK_SCROLL_RIGHT:
-                               x+=1.0;
-                               break;
-                       case GDK_SCROLL_DOWN:
-                       case GDK_SCROLL_LEFT:
-                               x-=1.0;
-                               break;
-               }
-       } else {
-               x = float(event->button.x);
-       }
-
-       float pos(x/width);
-       if(pos<0 || x<=0)pos=0;
-       if(pos>1)pos=1;
-
-       if(use_colorspace_gamma() && (type<TYPE_U))
-               pos=gamma_out(pos);
-       if(pos<0 || event->button.x<=0)pos=0;
-       if(pos>1)pos=1;
-
-       switch(event->type)
-       {
-       case GDK_SCROLL:
-               signal_slider_moved_(type,pos);
-               queue_draw();
-               signal_activated_();
-               return true;
-
-       case GDK_BUTTON_RELEASE:
-               signal_activated_();
-               return true;
-
-       case GDK_BUTTON_PRESS:
-       case GDK_MOTION_NOTIFY:
-//             adjust_color(type,color_,pos);
-               signal_slider_moved_(type,pos);
-               queue_draw();
-               return true;
-               break;
-       default:
-               break;
-       }
-       return false;
-}
-
-/* === M E T H O D S ======================================================= */
-
-Widget_ColorEdit::Widget_ColorEdit():
-       R_adjustment(0,-10000000,10000000,1,10,0),
-       G_adjustment(0,-10000000,10000000,1,10,0),
-       B_adjustment(0,-10000000,10000000,1,10,0),
-       A_adjustment(0,-10000000,10000000,1,10,0)
-{
-       notebook=manage(new Gtk::Notebook);
-
-       Gtk::Table* rgb_table(manage(new Gtk::Table()));
-       Gtk::Table* yuv_table(manage(new Gtk::Table()));
-       Gtk::Table* main_table(this);
-
-       {
-               Gtk::VBox* rgb_box(manage(new Gtk::VBox()));
-               Gtk::VBox* yuv_box(manage(new Gtk::VBox()));
-               rgb_box->pack_start(*rgb_table,false,false);
-               yuv_box->pack_start(*yuv_table,false,false);
-               notebook->append_page(*rgb_box,_("RGB"));
-               notebook->append_page(*yuv_box,_("YUV"));
-       }
-
-       color=Color(0,0,0,0);
-
-       set_size_request(200,-1);
-       hold_signals=true;
-
-       Gtk::Label *label;
-
-       R_adjustment.set_lower(-10000000);
-       G_adjustment.set_lower(-10000000);
-       B_adjustment.set_lower(-10000000);
-       A_adjustment.set_lower(-10000000);
-
-       clamp_=true;
-
-       Pango::AttrList attr_list;
-       Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*7));
-       pango_size.set_start_index(0);
-       pango_size.set_end_index(64);
-       attr_list.change(pango_size);
-
-       widget_color.set_size_request(-1,16);
-       attach(widget_color, 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       attach(*notebook, 0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-#define SLIDER_ROW(i,n,l) \
-       slider_##n=manage(new ColorSlider(ColorSlider::TYPE_##n));      \
-       slider_##n->signal_slider_moved().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_slider_moved)); \
-       /*slider_##n->signal_activated().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::activated));*/ \
-       slider_##n->signal_activated().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_value_changed)); \
-       label=manage(new class Gtk::Label(l,0.0,0.5)); \
-       label->set_use_markup(false); \
-       label->set_use_underline(false); \
-       label->set_attributes(attr_list); \
-       table->attach(*label, 0, 1, 1+2*i, 2+2*i, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);  \
-       table->attach(*slider_##n, 0, 1, 2+2*i, 3+2*i, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0)
-
-#define ATTACH_SPIN_BUTTON(i,n) \
-       spinbutton_##n=manage(new class Gtk::SpinButton(n##_adjustment,1,0)); \
-       spinbutton_##n->set_update_policy(Gtk::UPDATE_ALWAYS); \
-       spinbutton_##n->set_size_request(SPINBUTTON_WIDTH,-1); \
-       spinbutton_##n->show(); \
-       table->attach(*spinbutton_##n, 1, 2, 1+2*i, 3+2*i, Gtk::SHRINK, Gtk::EXPAND, 2, 0)
-
-       {
-               Gtk::Table* table(rgb_table);
-               SLIDER_ROW(0,R,_("Red"));
-               ATTACH_SPIN_BUTTON(0,R);
-               SLIDER_ROW(1,G,_("Green"));
-               ATTACH_SPIN_BUTTON(1,G);
-               SLIDER_ROW(2,B,_("Blue"));
-               ATTACH_SPIN_BUTTON(2,B);
-
-               hex_color_label = manage(new Gtk::Label(_("HTML code"), 0.0, 0.5));
-               hex_color_label->set_use_markup(false);
-               hex_color_label->set_use_underline(false);
-               hex_color_label->set_attributes(attr_list);
-               table->attach(*hex_color_label, 0, 1, 7, 8, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-
-               hex_color = manage(new Gtk::Entry());
-               hex_color->set_width_chars(8);
-               hex_color->signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_hex_edited));
-               table->attach(*hex_color, 0, 1, 8, 9, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       }
-       {
-               Gtk::Table* table(yuv_table);
-               SLIDER_ROW(0,Y,_("Luma"));
-               SLIDER_ROW(1,HUE,_("Hue"));
-               SLIDER_ROW(2,SAT,_("Saturation"));
-               SLIDER_ROW(3,U,_("U"));
-               SLIDER_ROW(4,V,_("V"));
-       }
-       {
-               Gtk::Table* table(main_table);
-               SLIDER_ROW(1,A,_("Alpha"));
-               ATTACH_SPIN_BUTTON(1,A);
-       }
-
-#undef SLIDER_ROW
-#undef ATTACH_SPIN_BUTTON
-
-       spinbutton_R->signal_activate().connect(sigc::mem_fun(*spinbutton_G,&Gtk::SpinButton::grab_focus));
-       spinbutton_G->signal_activate().connect(sigc::mem_fun(*spinbutton_B,&Gtk::SpinButton::grab_focus));
-       spinbutton_B->signal_activate().connect(sigc::mem_fun(*spinbutton_A,&Gtk::SpinButton::grab_focus));
-       spinbutton_A->signal_activate().connect(sigc::mem_fun(*spinbutton_R,&Gtk::SpinButton::grab_focus));
-
-       R_adjustment.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_value_changed));
-       G_adjustment.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_value_changed));
-       B_adjustment.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_value_changed));
-       A_adjustment.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_value_changed));
-
-       show_all_children();
-
-       set_digits(1);
-       set_value(color);
-
-       hold_signals=false;
-}
-
-Widget_ColorEdit::~Widget_ColorEdit()
-{
-}
-
-void
-Widget_ColorEdit::on_slider_moved(ColorSlider::Type type, float amount)
-{
-       Color color(get_value_raw());
-
-       assert(color.is_valid());
-       ColorSlider::adjust_color(type,color,amount);
-       assert(color.is_valid());
-
-       // If a non-primary colorslider is adjusted,
-       // we want to make sure that we clamp
-       if(type>ColorSlider::TYPE_B && (color.get_r()<0 ||color.get_g()<0 ||color.get_b()<0))
-               clamp_=true;
-
-       /*
-       if(type==ColorSlider::TYPE_R && color.get_r()<0)clamp_=false;
-       if(type==ColorSlider::TYPE_G && color.get_g()<0)clamp_=false;
-       if(type==ColorSlider::TYPE_B && color.get_b()<0)clamp_=false;
-       */
-       clamp_=false;
-
-       set_value(color);
-       assert(color.is_valid());
-}
-
-void
-Widget_ColorEdit::on_hex_edited()
-{
-       Color color(get_value_raw());
-       String s = hex_color->get_text();
-       color.set_hex(s);
-       set_value(color);
-       signal_value_changed_();
-}
-
-void
-Widget_ColorEdit::on_value_changed()
-{
-       if(hold_signals)
-               return;
-
-       const Color color(get_value_raw());
-       assert(color.is_valid());
-       slider_R->set_color(color);
-       slider_G->set_color(color);
-       slider_B->set_color(color);
-       slider_Y->set_color(color);
-       slider_U->set_color(color);
-       slider_V->set_color(color);
-       slider_HUE->set_color(color);
-       slider_SAT->set_color(color);
-       slider_A->set_color(color);
-       hex_color->set_text(color.get_hex());
-       widget_color.set_value(color);
-
-       activate();
-       signal_value_changed_();
-}
-
-void
-Widget_ColorEdit::set_has_frame(bool x)
-{
-       spinbutton_R->set_has_frame(x);
-       spinbutton_G->set_has_frame(x);
-       spinbutton_B->set_has_frame(x);
-       spinbutton_A->set_has_frame(x);
-       spinbutton_R->set_size_request(SPINBUTTON_WIDTH,-1);
-       spinbutton_G->set_size_request(SPINBUTTON_WIDTH,-1);
-       spinbutton_B->set_size_request(SPINBUTTON_WIDTH,-1);
-       spinbutton_A->set_size_request(SPINBUTTON_WIDTH,-1);
-}
-
-void
-Widget_ColorEdit::set_digits(int x)
-{
-       spinbutton_R->set_digits(x);
-       spinbutton_G->set_digits(x);
-       spinbutton_B->set_digits(x);
-       spinbutton_A->set_digits(x);
-       spinbutton_R->set_size_request(SPINBUTTON_WIDTH,-1);
-       spinbutton_G->set_size_request(SPINBUTTON_WIDTH,-1);
-       spinbutton_B->set_size_request(SPINBUTTON_WIDTH,-1);
-       spinbutton_A->set_size_request(SPINBUTTON_WIDTH,-1);
-}
-
-void
-Widget_ColorEdit::set_value(const synfig::Color &data)
-{
-       assert(data.is_valid());
-       hold_signals=true;
-       clamp_=false;
-
-       color=data;
-
-       if(use_colorspace_gamma())
-       {
-               R_adjustment.set_value(gamma_in(color.get_r())*100);
-               G_adjustment.set_value(gamma_in(color.get_g())*100);
-               B_adjustment.set_value(gamma_in(color.get_b())*100);
-       }
-       else
-       {
-               R_adjustment.set_value(color.get_r()*100);
-               G_adjustment.set_value(color.get_g()*100);
-               B_adjustment.set_value(color.get_b()*100);
-       }
-       A_adjustment.set_value(color.get_a()*100);
-
-       slider_R->set_color(color);
-       slider_G->set_color(color);
-       slider_B->set_color(color);
-       slider_Y->set_color(color);
-       slider_U->set_color(color);
-       slider_V->set_color(color);
-       slider_HUE->set_color(color);
-       slider_SAT->set_color(color);
-       slider_A->set_color(color);
-       hex_color->set_text(color.get_hex());
-       widget_color.set_value(color);
-
-       hold_signals=false;
-}
-
-synfig::Color
-Widget_ColorEdit::get_value_raw()
-{
-       Color color;
-       if(use_colorspace_gamma())
-       {
-               color.set_r(gamma_out(R_adjustment.get_value()/100.0f));
-               color.set_g(gamma_out(G_adjustment.get_value()/100.0f));
-               color.set_b(gamma_out(B_adjustment.get_value()/100.0f));
-       }
-       else
-       {
-               color.set_r(R_adjustment.get_value()/100);
-               color.set_g(G_adjustment.get_value()/100);
-               color.set_b(B_adjustment.get_value()/100);
-       }
-       color.set_a(A_adjustment.get_value()/100);
-       assert(color.is_valid());
-
-       return color;
-}
-
-const synfig::Color &
-Widget_ColorEdit::get_value()
-{
-       if(use_colorspace_gamma())
-       {
-               color.set_r(gamma_out(R_adjustment.get_value()/100.0f));
-               color.set_g(gamma_out(G_adjustment.get_value()/100.0f));
-               color.set_b(gamma_out(B_adjustment.get_value()/100.0f));
-               assert(color.is_valid());
-       }
-       else
-       {
-               color.set_r(R_adjustment.get_value()/100);
-               color.set_g(G_adjustment.get_value()/100);
-               color.set_b(B_adjustment.get_value()/100);
-               assert(color.is_valid());
-       }
-       color.set_a(A_adjustment.get_value()/100);
-       assert(color.is_valid());
-
-       if(notebook->get_current_page()!=0)
-               color=color.clamped();
-
-       /*{
-               // Clamp out negative values
-               color.set_r(std::max(0.0f,(float)color.get_r()));
-               color.set_g(std::max(0.0f,(float)color.get_g()));
-               color.set_b(std::max(0.0f,(float)color.get_b()));
-       }*/
-
-       return color;
-}
diff --git a/synfig-studio/src/gtkmm/widget_coloredit.h b/synfig-studio/src/gtkmm/widget_coloredit.h
deleted file mode 100644 (file)
index 63dcfa6..0000000
+++ /dev/null
@@ -1,188 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_coloredit.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_WIDGET_COLOREDIT_H
-#define __SYNFIG_STUDIO_WIDGET_COLOREDIT_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/box.h>
-#include <gtkmm/table.h>
-#include <gtkmm/spinbutton.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/drawingarea.h>
-#include <synfig/color.h>
-#include "widget_color.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 Gtk {
-       class Notebook;
-};
-
-namespace studio {
-
-class ColorSlider : public Gtk::DrawingArea
-{
-public:
-       enum Type
-       {
-               TYPE_R,
-               TYPE_G,
-               TYPE_B,
-               TYPE_Y,
-               TYPE_U,
-               TYPE_V,
-               TYPE_HUE,
-               TYPE_SAT,
-               TYPE_A,
-
-               TYPE_END
-       };
-
-private:
-
-       sigc::signal<void,Type,float> signal_slider_moved_;
-       sigc::signal<void> signal_activated_;
-
-       Type type;
-       synfig::Color color_;
-
-public:
-
-       sigc::signal<void,Type,float>& signal_slider_moved() { return signal_slider_moved_; }
-       sigc::signal<void>& signal_activated() { return signal_activated_; }
-
-       Type
-       get_type()const { return type; }
-
-       const synfig::Color&
-       get_color()const { return color_; }
-
-
-       ColorSlider(const Type &x=TYPE_Y);
-
-       void
-       set_type(Type x);
-
-       void
-       set_color(synfig::Color x);
-
-       static void adjust_color(Type type, synfig::Color &color, float amount);
-
-private:
-       typedef void (*slider_color_func)(synfig::Color &,float);
-
-       static void slider_color_TYPE_R(synfig::Color &color, float amount);
-       static void slider_color_TYPE_G(synfig::Color &color, float amount);
-       static void slider_color_TYPE_B(synfig::Color &color, float amount);
-       static void slider_color_TYPE_Y(synfig::Color &color, float amount);
-       static void slider_color_TYPE_U(synfig::Color &color, float amount);
-       static void slider_color_TYPE_V(synfig::Color &color, float amount);
-       static void slider_color_TYPE_HUE(synfig::Color &color, float amount);
-       static void slider_color_TYPE_SAT(synfig::Color &color, float amount);
-       static void slider_color_TYPE_A(synfig::Color &color, float amount);
-
-
-       bool
-       redraw(GdkEventExpose*bleh);
-       bool on_event(GdkEvent *event);
-}; // END of class ColorSlider
-
-
-class Widget_ColorEdit : public Gtk::Table
-{
-       sigc::signal<void> signal_activated_;
-       sigc::signal<void> signal_value_changed_;
-
-       ColorSlider *slider_R;
-       ColorSlider *slider_G;
-       ColorSlider *slider_B;
-       Gtk::Label *hex_color_label;
-       Gtk::Entry *hex_color;
-
-       ColorSlider *slider_A;
-       ColorSlider *slider_Y;
-       ColorSlider *slider_U;
-       ColorSlider *slider_V;
-       ColorSlider *slider_SAT;
-       ColorSlider *slider_HUE;
-
-       Widget_Color widget_color;
-
-       bool hold_signals;
-
-       bool clamp_;
-
-       Gtk::SpinButton *spinbutton_R;
-       Gtk::SpinButton *spinbutton_G;
-       Gtk::SpinButton *spinbutton_B;
-       Gtk::SpinButton *spinbutton_A;
-
-       Gtk::Adjustment R_adjustment;
-       Gtk::Adjustment G_adjustment;
-       Gtk::Adjustment B_adjustment;
-       Gtk::Adjustment A_adjustment;
-
-       synfig::Color color;
-
-       Gtk::Notebook* notebook;
-
-protected:
-
-       void on_value_changed();
-
-public:
-
-       sigc::signal<void>& signal_activated() { return signal_activated_; }
-
-       sigc::signal<void>& signal_activate() { return signal_activated_; }
-
-       void on_slider_moved(ColorSlider::Type type, float amount);
-       void on_hex_edited();
-
-       //Glib::SignalProxy0<void> signal_activate() { return spinbutton_A->signal_activate(); }
-
-       sigc::signal<void>& signal_value_changed() { return signal_value_changed_; }
-
-       void activated() { signal_activated_(); }
-       void activate() { signal_activated_(); }
-       void set_value(const synfig::Color &data);
-       const synfig::Color &get_value();
-       synfig::Color get_value_raw();
-       void set_has_frame(bool x);
-       void set_digits(int x);
-       Widget_ColorEdit();
-       ~Widget_ColorEdit();
-}; // END of class Widget_ColorEdit
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/widget_compselect.cpp b/synfig-studio/src/gtkmm/widget_compselect.cpp
deleted file mode 100644 (file)
index 51eb3db..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_compselect.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include <gtkmm/menu.h>
-#include "widget_compselect.h"
-#include <ETL/stringf>
-#include <synfig/valuenode.h>
-#include "instance.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Widget_CompSelect::Widget_CompSelect()
-{
-       App::signal_instance_created().connect(sigc::mem_fun(*this,&studio::Widget_CompSelect::new_instance));
-       App::signal_instance_deleted().connect(sigc::mem_fun(*this,&studio::Widget_CompSelect::delete_instance));
-       App::signal_instance_selected().connect(sigc::mem_fun(*this,&studio::Widget_CompSelect::set_selected_instance_signal));
-
-       set_menu(instance_list_menu);
-       refresh();
-}
-
-Widget_CompSelect::~Widget_CompSelect()
-{
-}
-
-void
-Widget_CompSelect::set_selected_instance_signal(etl::handle<studio::Instance> x)
-{
-       set_selected_instance(x);
-}
-
-void
-Widget_CompSelect::set_selected_instance_(etl::handle<studio::Instance> instance)
-{
-       if(studio::App::shutdown_in_progress)
-               return;
-
-       selected_instance=instance;
-}
-
-void
-Widget_CompSelect::set_selected_instance(etl::loose_handle<studio::Instance> x)
-{
-       if(studio::App::shutdown_in_progress)
-               return;
-
-       // if it's already selected, don't select it again
-       if (x==selected_instance)
-               return;
-
-       std::list<etl::handle<studio::Instance> >::iterator iter;
-
-       if(x)
-       {
-               int i;
-               for(i=0,iter=studio::App::instance_list.begin();iter!=studio::App::instance_list.end() && ((*iter)!=x);iter++,i++)
-                       ;
-
-               assert(*iter==x);
-
-               set_history(i);
-       }
-       else
-               set_history(0);
-
-       set_selected_instance_(x);
-}
-
-void
-Widget_CompSelect::new_instance(etl::handle<studio::Instance> instance)
-{
-       if(studio::App::shutdown_in_progress)
-               return;
-
-       assert(instance);
-
-       etl::loose_handle<studio::Instance> loose_instance(instance);
-
-       instance->synfigapp::Instance::signal_filename_changed().connect(sigc::mem_fun(*this,&Widget_CompSelect::refresh));
-       instance->synfigapp::Instance::signal_filename_changed().connect(
-               sigc::bind<etl::loose_handle<studio::Instance> >(
-                       sigc::mem_fun(*this,&Widget_CompSelect::set_selected_instance),
-                       loose_instance
-               )
-       );
-
-       {
-               std::string name=basename(instance->get_file_name());
-
-               instance_list_menu.items().push_back(Gtk::Menu_Helpers::MenuElem(name,
-                       sigc::bind<etl::loose_handle<studio::Instance> >(sigc::ptr_fun(&studio::App::set_selected_instance),loose_instance)     ));
-       }
-
-}
-
-void
-Widget_CompSelect::delete_instance(etl::handle<studio::Instance> instance)
-{
-       refresh();
-
-       if(selected_instance==instance)
-       {
-               set_selected_instance(0);
-               set_history(0);
-       }
-}
-
-void
-Widget_CompSelect::refresh()
-{
-       remove_menu();
-
-       if(!instance_list_menu.items().empty())
-               instance_list_menu.items().clear();
-
-       if(studio::App::shutdown_in_progress)
-               return;
-
-       std::list<etl::handle<studio::Instance> >::iterator iter;
-       for(iter=studio::App::instance_list.begin();iter!=studio::App::instance_list.end();iter++)
-       {
-               std::string name=basename((*iter)->get_file_name());
-
-               instance_list_menu.items().push_back(Gtk::Menu_Helpers::MenuElem(name,
-                       sigc::bind<etl::loose_handle<studio::Instance> >(sigc::ptr_fun(&studio::App::set_selected_instance),*iter)      ));
-       }
-       set_menu(instance_list_menu);
-}
diff --git a/synfig-studio/src/gtkmm/widget_compselect.h b/synfig-studio/src/gtkmm/widget_compselect.h
deleted file mode 100644 (file)
index 4618a1b..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_compselect.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_WIDGET_COMPSELECT_H
-#define __SYNFIG_STUDIO_WIDGET_COMPSELECT_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/optionmenu.h>
-#include <gtkmm/menu.h>
-#include "app.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 Gtk { class Menu; };
-
-namespace studio {
-
-class Widget_CompSelect : public Gtk::OptionMenu
-{
-       Gtk::Menu       instance_list_menu;
-
-
-       etl::loose_handle<studio::Instance>     selected_instance;
-       void set_selected_instance_(etl::handle<studio::Instance> x);
-
-       void new_instance(etl::handle<studio::Instance> x);
-
-       void delete_instance(etl::handle<studio::Instance> x);
-
-       void set_selected_instance(etl::loose_handle<studio::Instance> x);
-
-       void set_selected_instance_signal(etl::handle<studio::Instance> x);
-
-public:
-
-       Widget_CompSelect();
-       ~Widget_CompSelect();
-
-       etl::loose_handle<studio::Instance> get_selected_instance() { return selected_instance; }
-
-       void refresh();
-}; // END of class Widget_CompSelect
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/widget_curves.cpp b/synfig-studio/src/gtkmm/widget_curves.cpp
deleted file mode 100644 (file)
index 2260dad..0000000
+++ /dev/null
@@ -1,588 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_curves.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**  Copyright (c) 2008 Gerco Ballintijn
-**
-**     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 <config.h>
-#endif
-
-#include "widget_curves.h"
-#include <cmath>
-#include "app.h"
-#include <gtkmm/drawingarea.h>
-#include <map>
-#include <vector>
-#include <ETL/misc>
-#include <sigc++/object.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/*
-void
-studio::render_color_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::Color &color)
-{
-       const int height(ca.get_height());
-       const int width(ca.get_width());
-
-       const int square_size(height/2);
-
-       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(window));
-
-       if(color.get_alpha()!=1.0)
-       {
-               // In this case we need to render the alpha squares
-
-               const Color bg1(Color::blend(color,Color(0.75, 0.75, 0.75),1.0).clamped());
-               const Color bg2(Color::blend(color,Color(0.5, 0.5, 0.5),1.0).clamped());
-
-               Gdk::Color gdk_c1(colorconv_synfig2gdk(bg1));
-               Gdk::Color gdk_c2(colorconv_synfig2gdk(bg2));
-
-               bool toggle(false);
-               for(int i=0;i<width;i+=square_size)
-               {
-                       const int square_width(min(square_size,width-i));
-
-                       if(toggle)
-                       {
-                               gc->set_rgb_fg_color(gdk_c1);
-                               window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), square_width, square_size);
-
-                               gc->set_rgb_fg_color(gdk_c2);
-                               window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y()+square_size, square_width, square_size);
-                               toggle=false;
-                       }
-                       else
-                       {
-                               gc->set_rgb_fg_color(gdk_c2);
-                               window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), square_width, square_size);
-
-                               gc->set_rgb_fg_color(gdk_c1);
-                               window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y()+square_size, square_width, square_size);
-                               toggle=true;
-                       }
-               }
-       }
-       else
-       {
-               // In this case we have a solid color to use
-               Gdk::Color gdk_c1(colorconv_synfig2gdk(color));
-
-               gc->set_rgb_fg_color(gdk_c1);
-               window->draw_rectangle(gc, true, ca.get_x(), ca.get_y(), width-1, height-1);
-       }
-       gc->set_rgb_fg_color(Gdk::Color("#ffffff"));
-       window->draw_rectangle(gc, false, ca.get_x()+1, ca.get_y()+1, width-3, height-3);
-       gc->set_rgb_fg_color(Gdk::Color("#000000"));
-       window->draw_rectangle(gc, false, ca.get_x(), ca.get_y(), width-1, height-1);
-}
-*/
-
-/* === C L A S S E S ======================================================= */
-
-
-
-struct studio::Widget_Curves::Channel
-{
-       synfig::String name;
-       Gdk::Color color;
-       std::map<synfig::Real,synfig::Real> values;
-};
-
-struct studio::Widget_Curves::CurveStruct : sigc::trackable
-{
-       synfigapp::ValueDesc value_desc;
-       std::vector<Channel> channels;
-
-       CurveStruct(const synfigapp::ValueDesc& x):
-               value_desc(x)
-       {
-               switch(value_desc.get_value_type())
-               {
-                       case ValueBase::TYPE_REAL:
-                               channels.push_back(Channel());
-                               channels.back().name="real";
-                               channels.back().color=Gdk::Color("#007f7f");
-                               break;
-                       case ValueBase::TYPE_TIME:
-                               channels.push_back(Channel());
-                               channels.back().name="time";
-                               channels.back().color=Gdk::Color("#7f7f00");
-                               break;
-                       case ValueBase::TYPE_INTEGER:
-                               channels.push_back(Channel());
-                               channels.back().name="int";
-                               channels.back().color=Gdk::Color("#7f0000");
-                               break;
-                       case ValueBase::TYPE_BOOL:
-                               channels.push_back(Channel());
-                               channels.back().name="bool";
-                               channels.back().color=Gdk::Color("#ff7f00");
-                               break;
-                       case ValueBase::TYPE_ANGLE:
-                               channels.push_back(Channel());
-                               channels.back().name="theta";
-                               channels.back().color=Gdk::Color("#004f4f");
-                               break;
-                       case ValueBase::TYPE_COLOR:
-                               channels.push_back(Channel());
-                               channels.back().name="red";
-                               channels.back().color=Gdk::Color("#7f0000");
-                               channels.push_back(Channel());
-                               channels.back().name="green";
-                               channels.back().color=Gdk::Color("#007f00");
-                               channels.push_back(Channel());
-                               channels.back().name="blue";
-                               channels.back().color=Gdk::Color("#00007f");
-                               channels.push_back(Channel());
-                               channels.back().name="alpha";
-                               channels.back().color=Gdk::Color("#000000");
-                               break;
-                       case ValueBase::TYPE_VECTOR:
-                               channels.push_back(Channel());
-                               channels.back().name="x";
-                               channels.back().color=Gdk::Color("#7f007f");
-                               channels.push_back(Channel());
-                               channels.back().name="y";
-                               channels.back().color=Gdk::Color("#007f7f");
-                               break;
-                       case ValueBase::TYPE_BLINEPOINT:
-                               channels.push_back(Channel());
-                               channels.back().name="v.x";
-                               channels.back().color=Gdk::Color("#ff7f00");
-                               channels.push_back(Channel());
-                               channels.back().name="v.y";
-                               channels.back().color=Gdk::Color("#7f3f00");
-
-                               channels.push_back(Channel());
-                               channels.back().name="width";
-                               channels.back().color=Gdk::Color("#000000");
-
-                               channels.push_back(Channel());
-                               channels.back().name="origin";
-                               channels.back().color=Gdk::Color("#ffffff");
-
-                               channels.push_back(Channel());
-                               channels.back().name="tsplit";
-                               channels.back().color=Gdk::Color("#ff00ff");
-
-                               channels.push_back(Channel());
-                               channels.back().name="t1.x";
-                               channels.back().color=Gdk::Color("#ff0000");
-                               channels.push_back(Channel());
-                               channels.back().name="t1.y";
-                               channels.back().color=Gdk::Color("#7f0000");
-
-                               channels.push_back(Channel());
-                               channels.back().name="t2.x";
-                               channels.back().color=Gdk::Color("#ffff00");
-                               channels.push_back(Channel());
-                               channels.back().name="t2.y";
-                               channels.back().color=Gdk::Color("#7f7f00");
-                               break;
-                       default:
-                               throw synfig::Exception::BadType("Bad type for curves");
-               }
-       }
-
-       void clear_all_values()
-       {
-               std::vector<Channel>::iterator iter;
-               for(iter=channels.begin();iter!=channels.end();++iter)
-                       iter->values.clear();
-       }
-
-       synfig::Real get_value(int chan, synfig::Real time, synfig::Real tolerance)
-       {
-               std::map<synfig::Real,synfig::Real>::iterator iter;
-
-               // First check to see if we have a value
-               // that is "close enough" to the time
-               // we are looking for
-               iter=channels[chan].values.lower_bound(time);
-               if(iter!=channels[chan].values.end() && iter->first-time<=tolerance)
-                       return -iter->second;
-
-               // Since that didn't work, we now need
-               // to go ahead and figure out what the
-               // actual value is at that time.
-               ValueBase value(value_desc.get_value(time));
-               switch(value.get_type())
-               {
-                       case ValueBase::TYPE_REAL:
-                               channels[0].values[time]=value.get(Real());
-                               break;
-                       case ValueBase::TYPE_TIME:
-                               channels[0].values[time]=value.get(Time());
-                               break;
-                       case ValueBase::TYPE_INTEGER:
-                               channels[0].values[time]=value.get(int());
-                               break;
-                       case ValueBase::TYPE_BOOL:
-                               channels[0].values[time]=value.get(bool());
-                               break;
-                       case ValueBase::TYPE_ANGLE:
-                               channels[0].values[time]=Angle::rad(value.get(Angle())).get();
-                               break;
-                       case ValueBase::TYPE_COLOR:
-                               channels[0].values[time]=value.get(Color()).get_r();
-                               channels[1].values[time]=value.get(Color()).get_g();
-                               channels[2].values[time]=value.get(Color()).get_b();
-                               channels[3].values[time]=value.get(Color()).get_a();
-                               break;
-                       case ValueBase::TYPE_VECTOR:
-                               channels[0].values[time]=value.get(Vector())[0];
-                               channels[1].values[time]=value.get(Vector())[1];
-                               break;
-                       case ValueBase::TYPE_BLINEPOINT:
-                               channels[0].values[time]=value.get(BLinePoint()).get_vertex()[0];
-                               channels[1].values[time]=value.get(BLinePoint()).get_vertex()[1];
-                               channels[2].values[time]=value.get(BLinePoint()).get_width();
-                               channels[3].values[time]=value.get(BLinePoint()).get_origin();
-                               channels[4].values[time]=value.get(BLinePoint()).get_split_tangent_flag();
-                               channels[5].values[time]=value.get(BLinePoint()).get_tangent1()[0];
-                               channels[6].values[time]=value.get(BLinePoint()).get_tangent1()[1];
-                               channels[7].values[time]=value.get(BLinePoint()).get_tangent2()[0];
-                               channels[8].values[time]=value.get(BLinePoint()).get_tangent2()[1];
-                               break;
-                       default:
-                               return 0;
-               }
-
-               return -channels[chan].values[time];
-       }
-
-       static bool is_not_supported(const synfigapp::ValueDesc& x)
-       {
-               return x.get_value_type() == ValueBase::TYPE_STRING
-                       || x.get_value_type() == ValueBase::TYPE_CANVAS
-                       || x.get_value_type() == ValueBase::TYPE_GRADIENT
-                       || x.get_value_type() == ValueBase::TYPE_LIST
-                       || x.get_value_type() == ValueBase::TYPE_SEGMENT;
-       }
-};
-
-/* === M E T H O D S ======================================================= */
-
-Widget_Curves::Widget_Curves():
-       range_adjustment_(new Gtk::Adjustment(-1,-2,2,0.1,0.1,2))
-{
-       set_size_request(64,64);
-
-       range_adjustment_->signal_changed().connect(
-               sigc::mem_fun(
-                       *this,
-                       &Widget_Curves::queue_draw
-               )
-       );
-       range_adjustment_->signal_value_changed().connect(
-               sigc::mem_fun(
-                       *this,
-                       &Widget_Curves::queue_draw
-               )
-       );
-       //set_vadjustment(*range_adjustment_);
-
-       signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Curves::redraw));
-       add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
-
-}
-
-Widget_Curves::~Widget_Curves()
-{
-}
-
-void
-Widget_Curves::set_time_adjustment(Gtk::Adjustment&x)
-{
-       time_adjustment_=&x;
-       time_adjustment_->signal_changed().connect(
-               sigc::mem_fun(
-                       *this,
-                       &Widget_Curves::queue_draw
-               )
-       );
-       time_adjustment_->signal_value_changed().connect(
-               sigc::mem_fun(
-                       *this,
-                       &Widget_Curves::queue_draw
-               )
-       );
-       //set_hadjustment(*time_adjustment_);
-}
-
-void
-Widget_Curves::clear()
-{
-       curve_list_.clear();
-}
-
-void
-Widget_Curves::refresh()
-{
-       std::list<CurveStruct>::iterator curve_iter;
-       for(curve_iter=curve_list_.begin();curve_iter!=curve_list_.end();++curve_iter)
-       {
-               curve_iter->clear_all_values();
-       }
-       queue_draw();
-}
-
-void
-Widget_Curves::set_value_descs(std::list<synfigapp::ValueDesc> value_descs)
-{
-       curve_list_.clear();
-
-       std::list<synfigapp::ValueDesc>::iterator iter;
-       for(iter=value_descs.begin();iter!=value_descs.end();++iter)
-       {
-               if (CurveStruct::is_not_supported(*iter))
-                       continue;
-
-               try {
-                       curve_list_.push_back(*iter);
-                       if(iter->is_value_node())
-                       {
-                               iter->get_value_node()->signal_changed().connect(
-                                       sigc::mem_fun(
-                                               *this,
-                                               &studio::Widget_Curves::refresh
-                                       )
-                               );
-                       }
-                       if(iter->parent_is_value_node())
-                       {
-                               iter->get_parent_value_node()->signal_changed().connect(
-                                       sigc::mem_fun(
-                                               *this,
-                                               &studio::Widget_Curves::refresh
-                                       )
-                               );
-                       }
-                       if(iter->parent_is_layer_param())
-                       {
-                               iter->get_layer()->signal_changed().connect(
-                                       sigc::mem_fun(
-                                               *this,
-                                               &studio::Widget_Curves::refresh
-                                       )
-                               );
-                       }
-               }catch(synfig::Exception::BadType)
-               {
-                       continue;
-               }
-       }
-       queue_draw();
-}
-
-bool
-Widget_Curves::on_event(GdkEvent *event)
-{
-       switch(event->type)
-       {
-       case GDK_SCROLL:
-               switch(event->scroll.direction)
-               {
-                       case GDK_SCROLL_UP:
-                               range_adjustment_->set_page_size(range_adjustment_->get_page_size()/1.25);
-                               range_adjustment_->changed();
-                               break;
-                       case GDK_SCROLL_DOWN:
-                               range_adjustment_->set_page_size(range_adjustment_->get_page_size()*1.25);
-                               range_adjustment_->changed();
-                               break;
-                       default:
-                               break;
-               }
-               break;
-       default:
-               return Gtk::DrawingArea::on_event(event);
-               break;
-       }
-
-       return true;
-
-/*     switch(event->type)
-       {
-       case GDK_BUTTON_PRESS:
-               if(event->button.button==1)
-               {
-                       signal_activate_();
-                       return true;
-               }
-               if(event->button.button==3)
-               {
-                       signal_secondary_();
-                       return true;
-               }
-               break;
-
-       default:
-               break;
-       }
-       return false;
-*/
-}
-
-bool
-Widget_Curves::redraw(GdkEventExpose */*bleh*/)
-{
-       const int h(get_height());
-       const int w(get_width());
-       get_window()->clear();
-
-       if(!time_adjustment_ || !range_adjustment_ || !h || !w)
-               return false;
-
-       if(!curve_list_.size())
-               return false;
-
-       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
-
-       const Real t_begin(time_adjustment_->get_lower());
-       const Real t_end(time_adjustment_->get_upper());
-       const Real dt((t_end-t_begin)/w);
-
-       const Real r_bottom(range_adjustment_->get_value());
-       const Real r_top(r_bottom+range_adjustment_->get_page_size());
-       const Real dr((r_top-r_bottom)/h);
-       Real r_max(-100000000);
-       Real r_min(100000000);
-
-       std::list<CurveStruct>::iterator curve_iter;
-
-       vector<Gdk::Point> points[10];
-
-       gc->set_function(Gdk::COPY);
-       gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-
-       // Draw zero mark
-       gc->set_rgb_fg_color(Gdk::Color("#4f4f4f"));
-       get_window()->draw_rectangle(gc, false, 0, round_to_int((0-r_bottom)/dr), w, 0);
-
-       // This try to find a valid vanvas to show the keyframes of those
-       // valuenodes. If not canvas found then no keyframes marks are shown.
-       synfig::Canvas::Handle canvas=0;
-       for(curve_iter=curve_list_.begin();curve_iter!=curve_list_.end();++curve_iter)
-       {
-               canvas=curve_iter->value_desc.get_canvas();
-               if(canvas)
-                       break;
-       }
-
-       if(canvas)
-       {
-       // Draw vertical lines for the keyframes marks.
-               const synfig::KeyframeList& keyframe_list(canvas->keyframe_list());
-               synfig::KeyframeList::const_iterator iter;
-
-               for(iter=keyframe_list.begin();iter!=keyframe_list.end();++iter)
-               {
-                       if(!iter->get_time().is_valid())
-                               continue;
-
-                       const int x((int)((float)w/(t_end-t_begin)*(iter->get_time()-t_begin)));
-                       if(iter->get_time()>=t_begin && iter->get_time()<t_end)
-                       {
-                               gc->set_rgb_fg_color(Gdk::Color("#a07f7f")); // It should be user selectable
-                               get_window()->draw_rectangle(gc, true, x, 0, 1, h);
-                       }
-               }
-       }
-
-       // Draw current time
-       gc->set_rgb_fg_color(Gdk::Color("#0000ff")); // It should be user selectable
-       get_window()->draw_rectangle(gc, false, round_to_int((time_adjustment_->get_value()-t_begin)/dt), 0, 0, h);
-
-       // Draw curves for the valuenodes stored in the curve list
-       for(curve_iter=curve_list_.begin();curve_iter!=curve_list_.end();++curve_iter)
-       {
-               Real t;
-               int i;
-               int channels(curve_iter->channels.size());
-               for(i=0;i<channels;i++)
-                       points[i].clear();
-
-               for(i=0,t=t_begin;i<w;i++,t+=dt)
-               {
-                       for(int chan=0;chan<channels;chan++)
-                       {
-                               Real x(curve_iter->get_value(chan,t,dt));
-                               r_max=max(r_max,x);
-                               r_min=min(r_min,x);
-                               points[chan].push_back(
-                                       Gdk::Point(
-                                               i,
-                                               round_to_int(
-                                                       (
-                                                               x-r_bottom
-                                                       )/dr
-                                               )
-                                       )
-                               );
-                       }
-               }
-
-               for(int chan=0;chan<channels;chan++)
-               {
-                       gc->set_rgb_fg_color(curve_iter->channels[chan].color);
-
-                       // Draw the curve
-                       get_window()->draw_lines(gc, Glib::ArrayHandle<Gdk::Point>(points[chan]));
-
-                       Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_pango_context()));
-
-                       layout->set_text(curve_iter->channels[chan].name);
-                       get_window()->draw_layout(gc, 1, points[chan][0].get_y()+1, layout);
-               }
-       }
-
-       if(!curve_list_.empty())
-       {
-               range_adjustment_->set_upper(r_max+range_adjustment_->get_page_size()/2);
-               range_adjustment_->set_lower(r_min-range_adjustment_->get_page_size()/2);
-       }
-       get_window()->get_update_area();
-
-       return true;
-}
diff --git a/synfig-studio/src/gtkmm/widget_curves.h b/synfig-studio/src/gtkmm/widget_curves.h
deleted file mode 100644 (file)
index 4fcf66f..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_curves.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_WIDGET_CURVES_H
-#define __SYNFIG_STUDIO_WIDGET_CURVES_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/box.h>
-#include <gtkmm/table.h>
-#include <gtkmm/spinbutton.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/drawingarea.h>
-#include <gtkmm/layout.h>
-#include <synfig/color.h>
-#include <synfigapp/value_desc.h>
-#include <list>
-
-/* === 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 Widget_Curves : public Gtk::DrawingArea
-{
-       struct Channel;
-       struct CurveStruct;
-
-       Gtk::Adjustment* time_adjustment_;
-       Gtk::Adjustment* range_adjustment_;
-
-       std::list<CurveStruct> curve_list_;
-
-public:
-
-       Widget_Curves();
-       ~Widget_Curves();
-
-       void set_value_descs(std::list<synfigapp::ValueDesc> value_descs);
-       void clear();
-       void refresh();
-
-       Gtk::Adjustment& get_range_adjustment() { return *range_adjustment_; }
-       Gtk::Adjustment& get_time_adjustment() { return *time_adjustment_; }
-       void set_time_adjustment(Gtk::Adjustment&);
-
-private:
-       bool redraw(GdkEventExpose*bleh);
-       bool on_event(GdkEvent *event);
-
-}; // END of class Widget_Curves
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/widget_defaults.cpp b/synfig-studio/src/gtkmm/widget_defaults.cpp
deleted file mode 100644 (file)
index 20cabfe..0000000
+++ /dev/null
@@ -1,611 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_defaults.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**  Copyright (c) 2008 Chris Moore
-**  Copyright (c) 2008 Carlos López
-**
-**     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 <config.h>
-#endif
-
-#include "widget_defaults.h"
-#include "widget_color.h"
-#include "widget_gradient.h"
-#include "dialog_color.h"
-#include "dialog_gradient.h"
-#include "app.h"
-#include <gtkmm/menu.h>
-#include <gtkmm/scale.h>
-#include <synfig/exception.h>
-#include <synfigapp/main.h>
-#include "canvasview.h"
-#include "widget_distance.h"
-#include "widget_enum.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 ========================================================= */
-
-#define GRADIENT_HEIGHT                16
-#define DEFAULT_INCREMENT      (0.25)
-#define DEFAULT_WIDTH          (synfig::Distance(3,synfig::Distance::SYSTEM_POINTS))
-
-/* === G L O B A L S ======================================================= */
-
-class studio::Widget_Brush : public Gtk::DrawingArea
-{
-public:
-       Widget_Brush()
-       {
-               signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Brush::redraw));
-
-               set_size_request(24,24);
-               add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
-               add_events(Gdk::BUTTON1_MOTION_MASK);
-
-               synfigapp::Main::signal_outline_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Brush::queue_draw));
-               synfigapp::Main::signal_fill_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Brush::queue_draw));
-               synfigapp::Main::signal_bline_width_changed().connect(sigc::mem_fun(*this,&studio::Widget_Brush::queue_draw));
-               studio::App::signal_instance_selected().connect(sigc::hide(sigc::mem_fun(*this,&studio::Widget_Brush::queue_draw)));
-       }
-
-       bool
-       redraw(GdkEventExpose */*bleh*/)
-       {
-               Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
-
-               const int h(get_height());
-               const int w(get_width());
-
-               float pixelsize(0);
-               if(App::get_selected_canvas_view())
-               {
-                       const RendDesc& rend_desc(App::get_selected_canvas_view()->get_canvas()->rend_desc());
-                       pixelsize=synfigapp::Main::get_bline_width().get(Distance::SYSTEM_PIXELS,rend_desc);
-               }
-               else
-               {
-                       RendDesc rend_desc;
-                       pixelsize=synfigapp::Main::get_bline_width().get(Distance::SYSTEM_PIXELS,rend_desc);
-               }
-               // Fill in the fill color
-               render_color_to_window(get_window(),Gdk::Rectangle(0,0,w,h),synfigapp::Main::get_fill_color());
-
-/*
-               gc->set_rgb_fg_color(colorconv_synfig2gdk(synfigapp::Main::get_fill_color()));
-               gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-               get_window()->draw_rectangle(
-                       gc,
-                       true,   // Fill?
-                       0,0,    // x,y
-                       w,h     //w,h
-               );
-*/
-
-               // Draw in the circle
-               gc->set_rgb_fg_color(colorconv_synfig2gdk(synfigapp::Main::get_outline_color()));
-               gc->set_function(Gdk::COPY);
-               gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-               get_window()->draw_arc(
-                       gc,
-                       true,
-                       round_to_int(((float)w/2.0f)-pixelsize/2.0f),
-                       round_to_int(((float)h/2.0f)-pixelsize/2.0f),
-                       round_to_int(pixelsize+0.6),
-                       round_to_int(pixelsize+0.6),
-                       0,
-                       360*64
-               );
-
-               return true;
-       }
-
-       bool
-       on_event(GdkEvent *event)
-       {
-//             const int x(static_cast<int>(event->button.x));
-               const int y(static_cast<int>(event->button.y));
-
-               const int h(get_height());
-//             const int w(get_width());
-
-               switch(event->type)
-               {
-                       case GDK_MOTION_NOTIFY:
-                               break;
-                       case GDK_BUTTON_RELEASE:
-                               if(event->button.button==1) // Left click
-                               {
-                                       Distance dist(synfigapp::Main::get_bline_width());
-
-                                       if(y<h/2) // increase BLine size
-                                       {
-                                               dist+=DEFAULT_INCREMENT;
-                                       }
-                                       else // Decrease BLine size
-                                       {
-                                               dist-=DEFAULT_INCREMENT;
-                                       }
-                                       synfigapp::Main::set_bline_width(dist);
-                                       return true;
-                               }
-                               if(event->button.button==3)
-                               {
-                                       // right click on bline width
-                                       synfigapp::Main::set_bline_width(DEFAULT_WIDTH);
-                                       return true;
-                               }
-                               break;
-                       case GDK_SCROLL:
-                               {
-                                       Distance dist(synfigapp::Main::get_bline_width());
-
-                                       switch(event->scroll.direction){
-                                               case GDK_SCROLL_UP:
-                                               case GDK_SCROLL_RIGHT:
-                                                       dist+=DEFAULT_INCREMENT;
-                                               break;
-                                               case GDK_SCROLL_DOWN:
-                                               case GDK_SCROLL_LEFT:
-                                                       dist-=DEFAULT_INCREMENT;
-                                               break;
-                                       }
-                                       synfigapp::Main::set_bline_width(dist);
-                                       return true;
-                               }
-                       default:
-                               break;
-               }
-
-               return false;
-       }
-
-};
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Widget_Defaults::Widget_Defaults()
-{
-       //set_size_request(48,48+GRADIENT_HEIGHT+16);
-       //set_size_request(48,-1);
-
-       {
-               Gtk::Table* subtable(manage(new Gtk::Table()));
-
-               // Outline Color
-               widget_otln_color=manage(new Widget_Color());
-               widget_otln_color->show();
-               widget_otln_color->set_size_request(16,16);
-               widget_otln_color->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Defaults::on_otln_color_clicked));
-               subtable->attach(*widget_otln_color, 0, 4, 0, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-               tooltips_.set_tip(*widget_otln_color,_("Outline Color"));
-
-               // Fill Color
-               widget_fill_color=manage(new Widget_Color());
-               widget_fill_color->show();
-               widget_fill_color->set_size_request(16,16);
-               widget_fill_color->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Defaults::on_fill_color_clicked));
-               subtable->attach(*widget_fill_color, 3, 7, 3, 7, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-               tooltips_.set_tip(*widget_fill_color,_("Fill Color"));
-
-               Gtk::Image* icon;
-
-               // Swap button
-               Gtk::Button* button_swap(manage(new Gtk::Button()));
-               button_swap->show();
-               button_swap->set_relief(Gtk::RELIEF_NONE);
-               button_swap->set_border_width(0);
-               icon=manage(new Gtk::Image(Gtk::StockID("synfig-swap_colors"),Gtk::IconSize(1)));
-               icon->show();
-               button_swap->add(*icon);
-               //button_swap->get_child()->set_size_request(16/3,16/3);
-               //button_swap->set_size_request(16/3,16/3);
-               dynamic_cast<Gtk::Misc*>(button_swap->get_child())->set_padding(0,0);
-               button_swap->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Defaults::on_swap_color_clicked));
-               subtable->attach(*button_swap, 4, 7, 0, 3, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-               tooltips_.set_tip(*button_swap,_("Swap Fill and\nOutline Colors"));
-
-               // Reset button
-               Gtk::Button* button_reset(manage(new Gtk::Button()));
-               button_reset->show();
-               button_reset->set_relief(Gtk::RELIEF_NONE);
-               button_reset->set_border_width(0);
-               icon=manage(new Gtk::Image(Gtk::StockID("synfig-reset_colors"),Gtk::IconSize(1)));
-               icon->show();
-               button_reset->add(*icon);
-               dynamic_cast<Gtk::Misc*>(button_reset->get_child())->set_padding(0,0);
-               //button_reset->set_size_request(16/3,16/3);
-               button_reset->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Defaults::on_reset_color_clicked));
-               subtable->attach(*button_reset, 0, 3, 4, 7, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-               tooltips_.set_tip(*button_reset,_("Reset Colors to Black and White"));
-
-
-               attach(*subtable, 0, 1, 0, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 1, 1);
-               subtable->set_size_request(36,36);
-               subtable->set_homogeneous(true);
-               subtable->show();
-       }
-       widget_brush=manage(new Widget_Brush());
-       widget_brush->show();
-       widget_brush->set_size_request(36,36);
-       attach(*widget_brush,1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 1, 1);
-       tooltips_.set_tip(*widget_brush,_("Brush Preview"));
-
-       widget_bline_width=manage(new Widget_Distance());
-       widget_bline_width->show();
-       bline_width_refresh();
-       widget_bline_width->set_digits(2);
-       widget_bline_width->set_range(0,10000000);
-       widget_bline_width->set_size_request(24,-1);
-       widget_bline_width->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_bline_width_changed));
-       attach(*widget_bline_width,1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       tooltips_.set_tip(*widget_bline_width,_("Brush Size"));
-
-
-       widget_blend_method=manage(new Widget_Enum());
-       widget_blend_method->show();
-       widget_blend_method->signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_blend_method_changed));
-       widget_blend_method->set_param_desc(ParamDesc(Color::BLEND_COMPOSITE,"blend_method"));
-       attach(*widget_blend_method,0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 1, 1);
-       tooltips_.set_tip(*widget_blend_method,_("Default Blend Method"));
-
-       widget_interpolation=manage(new Widget_Enum());
-       widget_interpolation->show();
-       widget_interpolation->signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_interpolation_changed));
-       widget_interpolation->set_param_desc(
-               ParamDesc("interpolation")
-                       .set_hint("enum")
-                       .add_enum_value(INTERPOLATION_TCB,"auto",_("_TCB"))
-                       .add_enum_value(INTERPOLATION_CONSTANT,"constant",_("_Constant"))
-                       .add_enum_value(INTERPOLATION_HALT,"ease",_("_Ease In/Out"))
-                       .add_enum_value(INTERPOLATION_LINEAR,"linear",_("_Linear"))
-       );
-       attach(*widget_interpolation,0, 2, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 1, 1);
-       tooltips_.set_tip(*widget_interpolation,_("Default Interpolation"));
-
-       widget_opacity=manage(new Gtk::HScale(0.0f,1.01f,0.01f));
-       widget_opacity->show();
-       widget_opacity->set_digits(2);
-       widget_opacity->set_value_pos(Gtk::POS_LEFT);
-       widget_opacity->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_opacity_changed));
-       attach(*widget_opacity,0, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 1, 1);
-       tooltips_.set_tip(*widget_opacity,_("Default Opacity"));
-
-       widget_gradient=manage(new Widget_Gradient());
-       widget_gradient->show();
-       widget_gradient->set_size_request(-1,GRADIENT_HEIGHT);
-       widget_gradient->signal_clicked().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_gradient_clicked));
-       attach(*widget_gradient,0, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 1, 1);
-       tooltips_.set_tip(*widget_gradient,_("Default Gradient"));
-
-
-       // Signals
-       synfigapp::Main::signal_opacity_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::opacity_refresh));
-       synfigapp::Main::signal_bline_width_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::bline_width_refresh));
-       synfigapp::Main::signal_outline_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::otln_color_refresh));
-       synfigapp::Main::signal_fill_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::fill_color_refresh));
-       synfigapp::Main::signal_gradient_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::gradient_refresh));
-       synfigapp::Main::signal_blend_method_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::blend_method_refresh));
-       synfigapp::Main::signal_interpolation_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::interpolation_refresh));
-
-       otln_color_refresh();
-       fill_color_refresh();
-       gradient_refresh();
-       blend_method_refresh();
-       opacity_refresh();
-       interpolation_refresh();
-/*
-       set_size_request(48,48+GRADIENT_HEIGHT);
-       signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Defaults::redraw));
-       add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
-       add_events(Gdk::BUTTON1_MOTION_MASK);
-
-       synfigapp::Main::signal_outline_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::queue_draw));
-       synfigapp::Main::signal_fill_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::queue_draw));
-       synfigapp::Main::signal_gradient_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::queue_draw));
-       synfigapp::Main::signal_bline_width_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::queue_draw));
-
-       if(App::dialog_gradient)
-       {
-               App::dialog_gradient->set_gradient(synfigapp::Main::get_gradient());
-               App::dialog_gradient->reset();
-               App::dialog_gradient->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_gradient));
-       }
-
-       if(App::dialog_color)
-       {
-               App::dialog_color->set_color(synfigapp::Main::get_outline_color());
-               App::dialog_color->reset();
-               App::dialog_color->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_outline_color));
-       }
-*/
-}
-
-Widget_Defaults::~Widget_Defaults()
-{
-}
-
-void
-Widget_Defaults::otln_color_refresh()
-{
-       widget_otln_color->set_value(synfigapp::Main::get_outline_color());
-}
-
-void
-Widget_Defaults::fill_color_refresh()
-{
-       widget_fill_color->set_value(synfigapp::Main::get_fill_color());
-}
-
-void
-Widget_Defaults::gradient_refresh()
-{
-       widget_gradient->set_value(synfigapp::Main::get_gradient());
-}
-
-void
-Widget_Defaults::bline_width_refresh()
-{
-       widget_bline_width->set_value(synfigapp::Main::get_bline_width());
-}
-
-void
-Widget_Defaults::blend_method_refresh()
-{
-       widget_blend_method->set_value(synfigapp::Main::get_blend_method());
-}
-
-void
-Widget_Defaults::interpolation_refresh()
-{
-       widget_interpolation->set_value(synfigapp::Main::get_interpolation());
-}
-
-void
-Widget_Defaults::opacity_refresh()
-{
-       widget_opacity->set_value(synfigapp::Main::get_opacity());
-}
-
-void
-Widget_Defaults::on_opacity_changed()
-{
-       synfigapp::Main::set_opacity(widget_opacity->get_value());
-}
-
-void
-Widget_Defaults::on_blend_method_changed()
-{
-       synfigapp::Main::set_blend_method(Color::BlendMethod(widget_blend_method->get_value()));
-}
-
-void
-Widget_Defaults::on_interpolation_changed()
-{
-       synfigapp::Main::set_interpolation(Waypoint::Interpolation(widget_interpolation->get_value()));
-}
-
-void
-Widget_Defaults::on_bline_width_changed()
-{
-       synfigapp::Main::set_bline_width(widget_bline_width->get_value());
-}
-
-void
-Widget_Defaults::on_otln_color_clicked()
-{
-       // Left click on outline color
-       App::dialog_color->set_color(synfigapp::Main::get_outline_color());
-       App::dialog_color->reset();
-       App::dialog_color->signal_edited().connect(sigc::ptr_fun(synfigapp::Main::set_outline_color));
-       App::dialog_color->present();
-}
-
-void
-Widget_Defaults::on_fill_color_clicked()
-{
-       // Left click on fill color
-       App::dialog_color->set_color(synfigapp::Main::get_fill_color());
-       App::dialog_color->reset();
-       App::dialog_color->signal_edited().connect(sigc::ptr_fun(synfigapp::Main::set_fill_color));
-       App::dialog_color->present();
-}
-
-void
-Widget_Defaults::on_swap_color_clicked()
-{
-       synfigapp::Main::color_swap();
-}
-
-void
-Widget_Defaults::on_reset_color_clicked()
-{
-       synfigapp::Main::set_fill_color(Color::white());
-       synfigapp::Main::set_outline_color(Color::black());
-}
-
-void
-Widget_Defaults::on_gradient_clicked()
-{
-       App::dialog_gradient->set_gradient(synfigapp::Main::get_gradient());
-       App::dialog_gradient->reset();
-       App::dialog_gradient->signal_edited().connect(sigc::ptr_fun(synfigapp::Main::set_gradient));
-       App::dialog_gradient->set_default_button_set_sensitive(false);
-       App::dialog_gradient->present();
-}
-
-/*
-bool
-Widget_Defaults::redraw(GdkEventExpose*bleh)
-{
-       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
-
-       const int h(get_height());
-       const int w(get_width());
-       const int size=std::min(h-GRADIENT_HEIGHT,w);
-
-       render_color_to_window(get_window(),Gdk::Rectangle(size/4,size/4,size/4*3-1,size/4*3-1),synfigapp::Main::get_fill_color());
-       render_color_to_window(get_window(),Gdk::Rectangle(0,0,size/4*3-1,size/4*3-1),synfigapp::Main::get_outline_color());
-       render_gradient_to_window(get_window(),Gdk::Rectangle(0,h-GRADIENT_HEIGHT,w,GRADIENT_HEIGHT-1),synfigapp::Main::get_gradient());
-
-
-
-
-
-       Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_pango_context()));
-
-       gc->set_rgb_fg_color(Gdk::Color("#FF0000"));
-       layout->set_text(synfigapp::Main::get_bline_width().get_string(2));
-       layout->set_alignment(Pango::ALIGN_CENTER);
-       layout->set_width(w/2);
-       get_window()->draw_layout(gc, w*3/4, (h-GRADIENT_HEIGHT)-16, layout);
-
-       return true;
-}
-
-bool
-Widget_Defaults::on_event(GdkEvent *event)
-{
-       const int x(static_cast<int>(event->button.x));
-       const int y(static_cast<int>(event->button.y));
-
-       const int h(get_height());
-       const int w(get_width());
-       const int size=std::min(h-GRADIENT_HEIGHT,w);
-
-       switch(event->type)
-       {
-       case GDK_MOTION_NOTIFY:
-               break;
-       case GDK_BUTTON_PRESS:
-//                     if(event->button.button==1 && y>get_height()-CONTROL_HEIGHT)
-               break;
-       case GDK_BUTTON_RELEASE:
-               if(event->button.button==1)
-               {
-                       if(y>size)
-                       {
-                               // Left click on gradient
-                               App::dialog_gradient->set_gradient(synfigapp::Main::get_gradient());
-                               App::dialog_gradient->reset();
-                               App::dialog_gradient->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_gradient));
-                               App::dialog_gradient->present();
-                               return true;
-                       }
-                       if(x>0 && x<=size)
-                       {
-                               if(x<size*3/4 && y<size*3/4)
-                               {
-                                       // Left click on outline coloe
-                                       App::dialog_color->set_color(synfigapp::Main::get_outline_color());
-                                       App::dialog_color->reset();
-                                       App::dialog_color->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_outline_color));
-                                       App::dialog_color->present();
-                                       return true;
-                               }
-                               if(x>size*3/4 && y>size/4)
-                               {
-                                       // Left click on fill color
-                                       App::dialog_color->set_color(synfigapp::Main::get_fill_color());
-                                       App::dialog_color->reset();
-                                       App::dialog_color->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_fill_color));
-                                       App::dialog_color->present();
-                                       return true;
-                               }
-                       }
-                       if(x>size) // Left click on BLine Width
-                       {
-                               Distance dist(synfigapp::Main::get_bline_width());
-
-                               if(y<size/2) // increase BLine size
-                               {
-                                       dist+=DEFAULT_INCREMENT;
-                               }
-                               else // Decrease BLine size
-                               {
-                                       dist-=DEFAULT_INCREMENT;
-                               }
-                               synfigapp::Main::set_bline_width(dist);
-                       }
-               }
-               if(event->button.button==3)
-               {
-                       if(y>size)
-                       {
-                               // right click on gradient
-                               synfigapp::Main::set_gradient_default_colors();
-                               return true;
-                       }
-                       else
-                       {
-                               if(x<size)
-                               {
-                                       // right click on colors
-                                       synfigapp::Main::color_swap();
-                                       return true;
-                               }
-
-                               if(x>w/2)
-                               {
-                                       // right click on bline width
-                                       synfigapp::Main::set_bline_width(DEFAULT_WIDTH);
-                               }
-
-                       }
-               }
-               break;
-       case GDK_SCROLL:
-               {
-                       Distance dist(synfigapp::Main::get_bline_width());
-
-                       if(event->scroll.direction==GDK_SCROLL_UP)
-                       {
-                               dist+=DEFAULT_INCREMENT;
-                       }
-                       else if(event->scroll.direction==GDK_SCROLL_DOWN)
-                       {
-                               dist-=DEFAULT_INCREMENT;
-                       }
-                       synfigapp::Main::set_bline_width(dist);
-               }
-       default:
-               break;
-       }
-
-       return false;
-}
-*/
diff --git a/synfig-studio/src/gtkmm/widget_defaults.h b/synfig-studio/src/gtkmm/widget_defaults.h
deleted file mode 100644 (file)
index 705e2da..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_defaults.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_WIDGET_DEFAULTS_H
-#define __SYNFIG_STUDIO_WIDGET_DEFAULTS_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/drawingarea.h>
-#include <gtkmm/table.h>
-#include <synfig/gradient.h>
-#include "widget_gradient.h"
-#include <gtkmm/tooltips.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 Gtk { class HScale; }
-
-namespace studio {
-
-class Widget_Brush;
-class Widget_Color;
-class Widget_Distance;
-class Widget_Enum;
-
-class Widget_Defaults : public Gtk::Table
-{
-       Widget_Brush *widget_brush;
-       Widget_Color *widget_otln_color;
-       Widget_Color *widget_fill_color;
-       Widget_Distance *widget_bline_width;
-       Widget_Gradient *widget_gradient;
-       Widget_Enum     *widget_blend_method;
-       Widget_Enum     *widget_interpolation;
-       Gtk::HScale *widget_opacity;
-
-       void otln_color_refresh();
-       void fill_color_refresh();
-       void gradient_refresh();
-       void bline_width_refresh();
-       void interpolation_refresh();
-
-       void on_bline_width_changed();
-       void on_otln_color_clicked();
-       void on_fill_color_clicked();
-       void on_swap_color_clicked();
-       void on_reset_color_clicked();
-       void on_gradient_clicked();
-       void on_interpolation_changed();
-
-       void blend_method_refresh();
-       void on_blend_method_changed();
-
-       void opacity_refresh();
-       void on_opacity_changed();
-
-       Gtk::Tooltips tooltips_;
-
-public:
-
-       Widget_Defaults();
-
-       ~Widget_Defaults();
-
-//     bool redraw(GdkEventExpose*bleh=NULL);
-
-//     bool on_event(GdkEvent *event);
-}; // END of class BlackLevelSelector
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/widget_distance.cpp b/synfig-studio/src/gtkmm/widget_distance.cpp
deleted file mode 100644 (file)
index 050b411..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_distance.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include <gtkmm/entry.h>
-#include <gtkmm/button.h>
-#include "widget_distance.h"
-#include "app.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Widget_Distance::Widget_Distance():
-       Gtk::SpinButton(0.05,5),
-       distance_(1, Distance::SYSTEM_POINTS),
-       adjustment(0,-100000000,100000000,1,1,0)
-{
-       set_adjustment(adjustment);
-       set_numeric(false);
-}
-
-Widget_Distance::~Widget_Distance()
-{
-}
-
-int
-Widget_Distance::on_input(double* new_value)
-{
-       distance_=synfig::String(get_text());
-       *new_value=distance_.get();
-       return 1;
-}
-
-bool
-Widget_Distance::on_output()
-{
-       try{
-       distance_=get_adjustment()->get_value();
-       set_text(distance_.get_string(get_digits()));
-       } catch (...) { /* synfig::error("Widget_Distance::on_output(): Caught something..."); */ }
-       return true;
-}
-
-void
-Widget_Distance::set_value(const synfig::Distance &data)
-{
-       distance_=data;
-       get_adjustment()->set_value(distance_.get());
-}
-
-synfig::Distance
-Widget_Distance::get_value() const
-{
-       distance_=get_adjustment()->get_value();
-       return distance_;
-}
diff --git a/synfig-studio/src/gtkmm/widget_distance.h b/synfig-studio/src/gtkmm/widget_distance.h
deleted file mode 100644 (file)
index 3bf625c..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_distance.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_WIDGET_DISTANCE_H
-#define __SYNFIG_STUDIO_WIDGET_DISTANCE_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <sigc++/signal.h>
-#include <sigc++/slot.h>
-#include <gtkmm/spinbutton.h>
-#include <gtkmm/adjustment.h>
-#include <synfig/distance.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 Gtk { class Entry; class Button; };
-
-namespace studio {
-
-class Widget_Distance : public Gtk::SpinButton
-{
-       //sigc::signal<void> signal_value_changed_;
-
-       mutable synfig::Distance distance_;
-
-       Gtk::Adjustment adjustment;
-
-protected:
-
-       int     on_input(double* new_value);
-       bool on_output();
-
-public:
-       //sigc::signal<void> &signal_value_changed() { return signal_value_changed_; }
-
-       void set_value(const synfig::Distance &data);
-       synfig::Distance get_value()const;
-       Widget_Distance();
-       ~Widget_Distance();
-}; // END of class Widget_Distance
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/widget_enum.cpp b/synfig-studio/src/gtkmm/widget_enum.cpp
deleted file mode 100644 (file)
index 2a58909..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_enum.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include <gtkmm/menu.h>
-#include "widget_enum.h"
-#include <ETL/stringf>
-#include <synfig/valuenode.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Widget_Enum::Widget_Enum()
-{
-}
-
-Widget_Enum::~Widget_Enum()
-{
-}
-
-void
-Widget_Enum::set_param_desc(const synfig::ParamDesc &x)
-{
-       param_desc=x;
-       //refresh();
-}
-
-void
-Widget_Enum::set_value_(int data)
-{
-       set_value(data);
-       activate();
-}
-
-void
-Widget_Enum::refresh()
-{
-       enum_menu = manage(new class Gtk::Menu());
-
-       std::list<synfig::ParamDesc::EnumData> enum_list=param_desc.get_enum_list();
-       std::list<synfig::ParamDesc::EnumData>::iterator iter;
-
-       String name=strprintf("(%d)",value);
-
-       for(iter=enum_list.begin();iter!=enum_list.end();iter++)
-               if(iter->value!=value)
-                       enum_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(iter->local_name,
-                               sigc::bind(sigc::mem_fun(*this,&Widget_Enum::set_value_),iter->value)
-                       ));
-               else
-                       name=iter->local_name;
-
-       enum_menu->items().push_front(Gtk::Menu_Helpers::MenuElem(name));
-
-       set_menu(*enum_menu);
-}
-
-void
-Widget_Enum::set_value(int data)
-{
-       value=data;
-
-       refresh();
-
-       set_history(0);
-}
-
-int
-Widget_Enum::get_value() const
-{
-       return value;
-}
diff --git a/synfig-studio/src/gtkmm/widget_enum.h b/synfig-studio/src/gtkmm/widget_enum.h
deleted file mode 100644 (file)
index 1059d34..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_enum.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_WIDGET_ENUM_H
-#define __SYNFIG_STUDIO_WIDGET_ENUM_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <synfig/layer.h>
-#include <gtkmm/optionmenu.h>
-#include <synfig/paramdesc.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 Gtk { class Menu; };
-
-namespace studio {
-
-class Widget_Enum : public Gtk::OptionMenu
-{
-       Gtk::Menu *enum_menu;
-       synfig::ParamDesc param_desc;
-
-       int value;
-       void set_value_(int data);
-public:
-
-       Widget_Enum();
-       ~Widget_Enum();
-
-       void set_param_desc(const synfig::ParamDesc &x);
-       void refresh();
-
-       void set_value(int data);
-       int get_value() const;
-}; // END of class Widget_Enum
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/widget_filename.cpp b/synfig-studio/src/gtkmm/widget_filename.cpp
deleted file mode 100644 (file)
index 1e94ef7..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_filename.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 <config.h>
-#endif
-
-#include <gtkmm/entry.h>
-#include <gtkmm/button.h>
-#include "widget_filename.h"
-#include "app.h"
-#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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Widget_Filename::Widget_Filename()
-{
-       entry_filename=manage(new Gtk::Entry());
-       label_find= manage(new Gtk::Label(_("Find")));
-       button_choose=manage(new Gtk::Button());
-       Pango::AttrList attr_list;
-       {
-               Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*7));
-               pango_size.set_start_index(0);
-               pango_size.set_end_index(64);
-               attr_list.change(pango_size);
-       }
-       label_find->set_attributes(attr_list);
-       label_find->set_ellipsize(Pango::ELLIPSIZE_END);
-       button_choose->add(*label_find);
-
-       pack_start(*entry_filename);
-       pack_start(*button_choose);
-       entry_filename->show();
-       button_choose->show();
-       label_find->show();
-
-       button_choose->signal_clicked().connect(sigc::mem_fun(*this, &studio::Widget_Filename::on_button_choose_pressed));
-       //entry_filename->signal_value_changed().connect(sigc::mem_fun(*this, &studio::Widget_Filename::on_value_changed));
-       entry_filename->signal_activate().connect(sigc::mem_fun(*this, &studio::Widget_Filename::on_value_changed));
-}
-
-Widget_Filename::~Widget_Filename()
-{
-}
-
-void
-Widget_Filename::set_has_frame(bool x)
-{
-       entry_filename->set_has_frame(x);
-}
-
-
-void
-Widget_Filename::set_value(const std::string &data)
-{
-       entry_filename->set_text(data);
-}
-
-string
-Widget_Filename::get_value() const
-{
-       try
-       {
-               return entry_filename->get_text();
-       }
-       catch(...)
-       {
-               throw string("Caught unknown exception");
-       }
-}
-
-void
-Widget_Filename::on_value_changed()
-{
-       signal_value_changed()();
-}
-
-void
-Widget_Filename::on_button_choose_pressed()
-{
-       string filename=entry_filename->get_text();
-       if(filename.empty())
-               filename=".";
-       else
-               filename = etl::absolute_path(
-                       etl::dirname(App::get_selected_canvas_view()->get_canvas()->get_file_name()) +
-                       ETL_DIRECTORY_SEPARATOR +
-                       filename);
-       if(App::dialog_open_file(_("Choose File"), filename, MISC_DIR_PREFERENCE))
-               entry_filename->set_text(filename);
-}
diff --git a/synfig-studio/src/gtkmm/widget_filename.h b/synfig-studio/src/gtkmm/widget_filename.h
deleted file mode 100644 (file)
index 69cfb48..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_filename.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_WIDGET_FILENAME_H
-#define __SYNFIG_STUDIO_WIDGET_FILENAME_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <sigc++/signal.h>
-#include <sigc++/slot.h>
-#include <gtkmm/box.h>
-#include <gtkmm/entry.h>
-#include <gtkmm/button.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 Gtk { class Entry; class Button; };
-
-namespace studio {
-
-class Widget_Filename : public Gtk::HBox
-{
-       Gtk::Entry *entry_filename;
-       Gtk::Button *button_choose;
-       Gtk::Label *label_find;
-
-       void on_button_choose_pressed();
-
-       sigc::signal<void> signal_value_changed_;
-
-public:
-       sigc::signal<void> &signal_value_changed() { return signal_value_changed_; }
-       Glib::SignalProxy0<void> signal_activate() { return entry_filename->signal_activate(); }
-
-       void on_value_changed();
-
-       void set_value(const  std::string &data);
-       std::string get_value() const;
-       void set_has_frame(bool x);
-       Widget_Filename();
-       ~Widget_Filename();
-}; // END of class Widget_Filename
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/widget_gradient.cpp b/synfig-studio/src/gtkmm/widget_gradient.cpp
deleted file mode 100644 (file)
index c964599..0000000
+++ /dev/null
@@ -1,370 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_gradient.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \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
-**     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 <config.h>
-#endif
-
-#include "widget_gradient.h"
-#include "app.h"
-#include <gtkmm/menu.h>
-#include <synfig/exception.h>
-#include <ETL/misc>
-
-#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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-void
-studio::render_gradient_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::Gradient &gradient)
-{
-       int     height = ca.get_height();
-       int     width = ca.get_width()-4;
-
-       float sample_width(1.0f/(float)width);
-       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(window));
-       const Color bg1(0.25, 0.25, 0.25);
-       const Color bg2(0.5, 0.5, 0.5);
-       Gdk::Color gdk_c;
-       int i;
-       for(i=0;i<width;i++)
-       {
-               const Color c(gradient(float(i)/float(width),sample_width));
-               const Color c1(Color::blend(c,bg1,1.0).clamped());
-               const Color c2(Color::blend(c,bg2,1.0).clamped());
-               gushort r1(256*App::gamma.r_F32_to_U8(c1.get_r()));
-               gushort g1(256*App::gamma.g_F32_to_U8(c1.get_g()));
-               gushort b1(256*App::gamma.b_F32_to_U8(c1.get_b()));
-               gushort r2(256*App::gamma.r_F32_to_U8(c2.get_r()));
-               gushort g2(256*App::gamma.g_F32_to_U8(c2.get_g()));
-               gushort b2(256*App::gamma.b_F32_to_U8(c2.get_b()));
-
-               if((i*2/height)&1)
-               {
-                       gdk_c.set_rgb(r1,g1,b1);
-                       gc->set_rgb_fg_color(gdk_c);
-                       window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y(), 1, height/2);
-
-                       gdk_c.set_rgb(r2,g2,b2);
-                       gc->set_rgb_fg_color(gdk_c);
-                       window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y()+height/2, 1, height/2);
-               }
-               else
-               {
-                       gdk_c.set_rgb(r2,g2,b2);
-                       gc->set_rgb_fg_color(gdk_c);
-                       window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y(), 1, height/2);
-
-                       gdk_c.set_rgb(r1,g1,b1);
-                       gc->set_rgb_fg_color(gdk_c);
-                       window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y()+height/2, 1, height/2);
-               }
-       }
-       gc->set_rgb_fg_color(Gdk::Color("#ffffff"));
-       window->draw_rectangle(gc, false, ca.get_x()+1, ca.get_y()+1, ca.get_width()-3, height-3);
-       gc->set_rgb_fg_color(Gdk::Color("#000000"));
-       window->draw_rectangle(gc, false, ca.get_x(), ca.get_y(), ca.get_width()-1, height-1);
-}
-
-/* === M E T H O D S ======================================================= */
-
-Widget_Gradient::Widget_Gradient():
-       editable_(false)
-{
-       set_size_request(-1,64);
-       signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Gradient::redraw));
-       add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
-       add_events(Gdk::BUTTON1_MOTION_MASK);
-
-}
-
-Widget_Gradient::~Widget_Gradient()
-{
-}
-
-#define CONTROL_HEIGHT         16
-bool
-Widget_Gradient::redraw(GdkEventExpose */*bleh*/)
-{
-       const int h(get_height());
-       const int w(get_width());
-
-       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
-       Gdk::Rectangle area(0,0,w,h);
-       if(!editable_)
-       {
-               render_gradient_to_window(get_window(),area,gradient_);
-               return true;
-       }
-
-       render_gradient_to_window(get_window(),Gdk::Rectangle(0,0,w,h-CONTROL_HEIGHT),gradient_);
-
-       gc->set_rgb_fg_color(Gdk::Color("#7f7f7f"));
-       get_window()->draw_rectangle(gc, false, 0, h-CONTROL_HEIGHT, w, CONTROL_HEIGHT);
-
-       Gradient::iterator iter,selected_iter;
-       bool show_selected(false);
-       for(iter=gradient_.begin();iter!=gradient_.end();iter++)
-       {
-               if(*iter!=selected_cpoint)
-               get_style()->paint_arrow(
-                       get_window(),
-                       (*iter==selected_cpoint)?Gtk::STATE_SELECTED:Gtk::STATE_ACTIVE,
-                       Gtk::SHADOW_OUT,
-                       area,
-                       *this,
-                       " ",
-                       Gtk::ARROW_UP,
-                       1,
-                       int(iter->pos*w)-CONTROL_HEIGHT/2+1,
-                       h-CONTROL_HEIGHT,
-                       CONTROL_HEIGHT,
-                       CONTROL_HEIGHT
-               );
-               else
-               {
-                       selected_iter=iter;
-                       show_selected=true;
-               }
-       }
-
-       // we do this so that we can be sure that
-       // the selected marker is shown on top
-       if(show_selected)
-       {
-               get_style()->paint_arrow(
-                       get_window(),
-                       Gtk::STATE_SELECTED,
-                       Gtk::SHADOW_OUT,
-                       area,
-                       *this,
-                       " ",
-                       Gtk::ARROW_UP,
-                       1,
-                       round_to_int(selected_iter->pos*w)-CONTROL_HEIGHT/2+1,
-                       h-CONTROL_HEIGHT,
-                       CONTROL_HEIGHT,
-                       CONTROL_HEIGHT
-               );
-       }
-
-       return true;
-}
-
-void
-Widget_Gradient::insert_cpoint(float x)
-{
-       Gradient::CPoint new_cpoint;
-       new_cpoint.pos=x;
-       new_cpoint.color=gradient_(x);
-       gradient_.push_back(new_cpoint);
-       gradient_.sort();
-       gradient_.sort();
-       set_selected_cpoint(new_cpoint);
-       queue_draw();
-}
-
-void
-Widget_Gradient::remove_cpoint(float x)
-{
-       gradient_.erase(gradient_.proximity(x));
-       signal_value_changed_();
-       queue_draw();
-}
-
-void
-Widget_Gradient::popup_menu(float x)
-{
-       Gtk::Menu* menu(manage(new Gtk::Menu()));
-       menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), menu));
-
-       menu->items().clear();
-
-       menu->items().push_back(
-               Gtk::Menu_Helpers::MenuElem(
-                       _("Insert CPoint"),
-                       sigc::bind(
-                               sigc::mem_fun(*this,&studio::Widget_Gradient::insert_cpoint),
-                               x
-                       )
-               )
-       );
-
-       if(!gradient_.empty())
-       {
-               menu->items().push_back(
-                       Gtk::Menu_Helpers::MenuElem(
-                               _("Remove CPoint"),
-                               sigc::bind(
-                                       sigc::mem_fun(*this,&studio::Widget_Gradient::remove_cpoint),
-                                       x
-                               )
-                       )
-               );
-       }
-
-       menu->popup(0,0);
-}
-
-void
-Widget_Gradient::set_value(const synfig::Gradient& x)
-{
-       gradient_=x;
-       if(gradient_.size())
-               set_selected_cpoint(*gradient_.proximity(0.0f));
-       queue_draw();
-}
-
-void
-Widget_Gradient::set_selected_cpoint(const synfig::Gradient::CPoint &x)
-{
-       selected_cpoint=x;
-       signal_cpoint_selected_(selected_cpoint);
-       queue_draw();
-}
-
-void
-Widget_Gradient::update_cpoint(const synfig::Gradient::CPoint &x)
-{
-       try
-       {
-               Gradient::iterator iter(gradient_.find(x));
-               iter->pos=x.pos;
-               iter->color=x.color;
-               gradient_.sort();
-               queue_draw();
-       }
-       catch(synfig::Exception::NotFound)
-       {
-               // Yotta...
-       }
-}
-
-bool
-Widget_Gradient::on_event(GdkEvent *event)
-{
-       //if(editable_)
-       {
-               const int x(static_cast<int>(event->button.x));
-               const int y(static_cast<int>(event->button.y));
-
-               float pos((float)x/(float)get_width());
-               if(pos<0.0f)pos=0.0f;
-               if(pos>1.0f)pos=1.0f;
-
-               switch(event->type)
-               {
-               case GDK_MOTION_NOTIFY:
-                       if(editable_ && y>get_height()-CONTROL_HEIGHT)
-                       {
-                               if(!gradient_.size()) return true;
-                               Gradient::iterator iter(gradient_.find(selected_cpoint));
-                               //! Use SHIFT to stack two CPoints together.
-                               if(event->button.state&GDK_SHIFT_MASK)
-                               {
-                                       float begin(-100000000),end(100000000);
-                                       Gradient::iterator before(iter),after(iter);
-                                       after++;
-                                       if(iter!=gradient_.begin())
-                                       {
-                                               before--;
-                                               begin=before->pos;
-                                       }
-                                       if(after!=gradient_.end())
-                                       {
-                                               end=after->pos;
-                                       }
-
-                                       if(pos>end)
-                                               pos=end;
-                                       if(pos<begin)
-                                               pos=begin;
-
-                                       iter->pos=pos;
-                               }
-                               else
-                               {
-                                       iter->pos=pos;
-                                       gradient_.sort();
-                               }
-
-//                             signal_value_changed_();
-                               changed_=true;
-                               queue_draw();
-                               return true;
-                       }
-                       break;
-               case GDK_BUTTON_PRESS:
-                       changed_=false;
-                       if(event->button.button==1)
-                       {
-                               if(editable_ && y>get_height()-CONTROL_HEIGHT)
-                               {
-                                       set_selected_cpoint(*gradient_.proximity(pos));
-                                       queue_draw();
-                                       return true;
-                               }
-                               else
-                               {
-                                       signal_clicked_();
-                                       return true;
-                               }
-                       }
-                       else if(editable_ && event->button.button==3)
-                       {
-                               popup_menu(pos);
-                               return true;
-                       }
-                       break;
-               case GDK_BUTTON_RELEASE:
-                       if(editable_ && event->button.button==1 && y>get_height()-CONTROL_HEIGHT)
-                       {
-                               set_selected_cpoint(*gradient_.proximity(pos));
-                               if(changed_)signal_value_changed_();
-                               return true;
-                       }
-               default:
-                       break;
-               }
-       }
-
-       return false;
-}
diff --git a/synfig-studio/src/gtkmm/widget_gradient.h b/synfig-studio/src/gtkmm/widget_gradient.h
deleted file mode 100644 (file)
index 5f5bc73..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_gradient.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_WIDGET_GRADIENT_H
-#define __SYNFIG_STUDIO_WIDGET_GRADIENT_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/drawingarea.h>
-#include <synfig/gradient.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 {
-
-void render_gradient_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::Gradient &gradient);
-
-class Widget_Gradient : public Gtk::DrawingArea
-{
-       sigc::signal<void> signal_value_changed_;
-       sigc::signal<void> signal_clicked_;
-
-       sigc::signal<void,synfig::Gradient::CPoint> signal_cpoint_selected_;
-
-       synfig::Gradient gradient_;
-
-       bool editable_;
-
-       bool changed_;
-
-       synfig::Gradient::CPoint        selected_cpoint;
-
-       void popup_menu(float x);
-
-       void insert_cpoint(float x);
-
-       void remove_cpoint(float x);
-
-public:
-
-       Widget_Gradient();
-
-       ~Widget_Gradient();
-
-       sigc::signal<void>& signal_value_changed() { return signal_value_changed_; }
-       sigc::signal<void>& signal_clicked() { return signal_clicked_; }
-
-       sigc::signal<void,synfig::Gradient::CPoint>& signal_cpoint_selected() { return signal_cpoint_selected_; }
-
-       void set_value(const synfig::Gradient& x);
-
-       const synfig::Gradient& get_value()const { return gradient_; }
-
-       void set_editable(bool x=true) { editable_=x; }
-
-       bool get_editable()const { return editable_; }
-
-
-
-       void set_selected_cpoint(const synfig::Gradient::CPoint &x);
-
-       const synfig::Gradient::CPoint& get_selected_cpoint() { return selected_cpoint; }
-
-       void update_cpoint(const synfig::Gradient::CPoint &x);
-
-
-
-       bool redraw(GdkEventExpose*bleh=NULL);
-
-       bool on_event(GdkEvent *event);
-}; // END of class BlackLevelSelector
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/widget_keyframe_list.cpp b/synfig-studio/src/gtkmm/widget_keyframe_list.cpp
deleted file mode 100644 (file)
index 9af70bf..0000000
+++ /dev/null
@@ -1,425 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_keyframe_list.cpp
-**     \brief A custom widget to manage keyframes in the timeline.
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007 Chris Moore
-**     Copyright (c) 2009 Carlos López
-**
-**     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 <config.h>
-#endif
-
-#include "widget_keyframe_list.h"
-#include "app.h"
-#include <gtkmm/menu.h>
-#include <synfig/exception.h>
-#include <ETL/misc>
-
-#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 ========================================================= */
-#define WIDGET_KEYFRAME_LIST_DEFAULT_FPS 24.0
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Widget_Keyframe_List::Widget_Keyframe_List():
-       adj_default(0,0,2,1/WIDGET_KEYFRAME_LIST_DEFAULT_FPS,10/WIDGET_KEYFRAME_LIST_DEFAULT_FPS),
-       kf_list_(&default_kf_list_),
-       time_ratio("4f", WIDGET_KEYFRAME_LIST_DEFAULT_FPS)
-{
-       adj_timescale=0;
-       editable_=true;
-       fps=WIDGET_KEYFRAME_LIST_DEFAULT_FPS;
-       set_size_request(-1,64);
-       //!This signal is called when the widget need to be redrawn
-       signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Keyframe_List::redraw));
-       //! The widget respond to mouse button press and release and to
-       //! left button motion
-       add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
-       add_events(Gdk::BUTTON1_MOTION_MASK /*| Gdk::BUTTON3_MOTION_MASK*/);
-       add_events(Gdk::POINTER_MOTION_MASK);
-       set_time_adjustment(&adj_default);
-       queue_draw();
-}
-
-Widget_Keyframe_List::~Widget_Keyframe_List()
-{
-}
-
-bool
-Widget_Keyframe_List::redraw(GdkEventExpose */*bleh*/)
-{
-
-       const int h(get_height());
-       const int w(get_width());
-
-       //!Boundaries of the drawing area in time units.
-       synfig::Time top(adj_timescale->get_upper());
-       synfig::Time bottom(adj_timescale->get_lower());
-
-       //! The graphic context
-       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
-       //! A rectangle that defines the drawing area.
-       Gdk::Rectangle area(0,0,w,h);
-
-       //! draw a background
-       gc->set_rgb_fg_color(Gdk::Color("#9d9d9d"));
-       get_window()->draw_rectangle(gc, true, 0, 0, w, h);
-
-       if(!editable_)
-       {
-               return true; //needs fixing!
-       }
-       //!Returns if there are not keyframes to draw.
-       if (kf_list_->empty()) return false;
-
-       //!Loop all the keyframes
-       synfig::KeyframeList::iterator iter,selected_iter;
-       bool show_selected(false);
-       for(iter=kf_list_->begin();iter!=kf_list_->end();iter++)
-       {
-               //!do not draw keyframes out of the widget boundaries
-               if (iter->get_time()>top || iter->get_time()<bottom)
-                       continue;
-               //! If the keyframe is not the selected one
-               if(*iter!=selected_kf)
-               {
-                       const int x((int)((float)(iter->get_time()-bottom) * (w/(top-bottom)) ) );
-                       get_style()->paint_arrow(get_window(), Gtk::STATE_NORMAL,
-                       Gtk::SHADOW_OUT, area, *this, " ", Gtk::ARROW_DOWN, 1,
-                       x-h/2+1, 0, h, h );
-               }
-               else
-               {
-                       selected_iter=iter;
-                       show_selected=true;
-               }
-       }
-
-       // we do this so that we can be sure that
-       // the selected keyframe is shown on top
-       if(show_selected)
-       {
-               // If not dragging just show the selected keyframe
-               if (!dragging_)
-               {
-                       int x((int)((float)(selected_iter->get_time()-bottom) * (w/(top-bottom)) ) );
-                       get_style()->paint_arrow(get_window(), Gtk::STATE_SELECTED,
-                       Gtk::SHADOW_OUT, area, *this, " ", Gtk::ARROW_DOWN, 1,
-                       x-h/2+1, 0, h, h );
-               }
-               // If dragging then show the selected as insensitive and the
-               // dragged as selected
-               else
-               {
-                       int x((int)((float)(selected_iter->get_time()-bottom) * (w/(top-bottom)) ) );
-                       get_style()->paint_arrow(get_window(), Gtk::STATE_INSENSITIVE,
-                       Gtk::SHADOW_OUT, area, *this, " ", Gtk::ARROW_DOWN, 1,
-                       x-h/2, 0, h, h );
-                       x=(int)((float)(dragging_kf_time-bottom) * (w/(top-bottom)) ) ;
-                       get_style()->paint_arrow(get_window(), Gtk::STATE_SELECTED,
-                       Gtk::SHADOW_OUT, area, *this, " ", Gtk::ARROW_DOWN, 1,
-                       x-h/2+1, 0, h, h );
-               }
-       }
-       return true;
-}
-
-
-void
-Widget_Keyframe_List::set_kf_list(synfig::KeyframeList* x)
-{
-       kf_list_=x;
-       set_selected_keyframe(selected_none);
-       selected_=false;
-       dragging_=false;
-}
-
-void
-Widget_Keyframe_List::set_selected_keyframe(const synfig::Keyframe &x)
-{
-       selected_kf=x;
-       selected_=true;
-       dragging_kf_time=selected_kf.get_time();
-       //signal_keyframe_selected_(selected_kf);
-       dragging_=false;
-       queue_draw();
-}
-
-bool
-Widget_Keyframe_List::perform_move_kf(bool delta=false)
-{
-       if(!selected_)
-               return false;
-       if(dragging_kf_time == selected_kf.get_time())
-               return false; // change this checking if not sticked to integer frames
-       Time selected_kf_time(selected_kf.get_time());
-       Time prev, next;
-       kf_list_->find_prev_next(selected_kf_time, prev, next);
-       // Not possible to set delta to the first keyframe
-       // perform normal movement
-       // As suggested by Zelgadis it is better to not perform anything.
-       if (prev==Time::begin() && delta==true)
-       {
-               synfig::info(_("Not possible to ALT-drag the first keyframe"));
-               return false;
-       }
-       if(!delta)
-               {
-                       synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeSet"));
-                       if(!action)
-                       return false;
-                       selected_kf.set_time(dragging_kf_time);
-                       action->set_param("canvas",canvas_interface_->get_canvas());
-                       action->set_param("canvas_interface",canvas_interface_);
-                       action->set_param("keyframe",selected_kf);
-                       try
-                       {
-                               canvas_interface_->get_instance()->perform_action(action);
-                       }
-                       catch(...)
-                       {
-                               return false;
-                       }
-               }
-       else
-               {
-                       Keyframe prev_kf(*kf_list_->find_prev(selected_kf_time));
-                       Time prev_kf_time(prev_kf.get_time());
-                       if (prev_kf_time >= dragging_kf_time) //Not allowed
-                       {
-                               synfig::warning(_("Delta set not allowed"));
-                               synfig::info("Widget_Keyframe_List::perform_move_kf(%i)::prev_kf_time=%s", delta, prev_kf_time.get_string().c_str());
-                               synfig::info("Widget_Keyframe_List::perform_move_kf(%i)::dragging_kf_time=%s", delta, dragging_kf_time.get_string().c_str());
-                               return false;
-                       }
-                       else
-                       {
-                               Time old_delta_time(selected_kf_time-prev_kf_time);
-                               Time new_delta_time(dragging_kf_time-prev_kf_time);
-                               Time change_delta(new_delta_time-old_delta_time);
-                               synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeSetDelta"));
-                               if(!action)
-                                       return false;
-                               action->set_param("canvas",canvas_interface_->get_canvas());
-                               action->set_param("canvas_interface",canvas_interface_);
-                               action->set_param("keyframe",prev_kf);
-                               action->set_param("delta",change_delta);
-                               canvas_interface_->get_instance()->perform_action(action);
-                       }
-               }
-       queue_draw();
-       return true;
-}
-
-bool
-Widget_Keyframe_List::on_event(GdkEvent *event)
-{
-       const int x(static_cast<int>(event->button.x));
-       //const int y(static_cast<int>(event->button.y));
-       //!Boundaries of the drawing area in time units.
-       synfig::Time top(adj_timescale->get_upper());
-       synfig::Time bottom(adj_timescale->get_lower());
-       //!pos is the [0,1] relative horizontal place on the widget
-       float pos((float)x/(get_width()));
-       if(pos<0.0f)pos=0.0f;
-       if(pos>1.0f)pos=1.0f;
-       //! The time where the event x is
-       synfig::Time t((float)(bottom+pos*(top-bottom)));
-       //Do not respond mouse events if the list is empty
-       if(!kf_list_->size())
-               return true;
-
-       //! here the guts of the event
-       switch(event->type)
-       {
-       case GDK_MOTION_NOTIFY:
-               if(editable_)
-               {
-                       // here is captured mouse motion
-                       // AND left or right mouse button pressed
-                       if (event->motion.state & (GDK_BUTTON1_MASK /*| GDK_BUTTON3_MASK*/))
-                       {
-                               // stick to integer frames. It can be optional in the future
-                               if(fps) t = floor(t*fps + 0.5)/fps;
-                               dragging_kf_time=t;
-                               dragging_=true;
-                               queue_draw();
-                               return true;
-                       }
-                       // here is captured mouse motion
-                       // AND NOT left or right mouse button pressed
-                       else
-                       {
-                               Glib::ustring ttip="";
-                               synfig::Time p_t,n_t;
-                               kf_list_->find_prev_next(t, p_t, n_t);
-                               if( (p_t==Time::begin()         &&      n_t==Time::end())
-                               ||
-                               ((t-p_t)>time_ratio     && (n_t-t)>time_ratio)
-                               )
-                               {
-                                       ttip = _("Click and drag keyframes");
-                               }
-                               else if ((t-p_t)<(n_t-t))
-                               {
-                                       synfig::Keyframe kf(*kf_list_->find_prev(t));
-                                       synfig::String kf_name(kf.get_description().c_str());
-                                       ttip = kf_name.c_str();
-                               }
-                               else
-                               {
-                                       synfig::Keyframe kf(*kf_list_->find_next(t));
-                                       synfig::String kf_name(kf.get_description().c_str());
-                                       ttip = kf_name.c_str();
-                               }
-                               tooltips.set_tip(*this, ttip);
-                               dragging_=false;
-                               queue_draw();
-                               return true;
-                       }
-               }
-               break;
-       case GDK_BUTTON_PRESS:
-               changed_=false;
-               dragging_=false;
-               if(event->button.button==1 /*|| event->button.button==3*/)
-               {
-                       if(editable_)
-                       {
-                               synfig::Time prev_t,next_t;
-                               kf_list_->find_prev_next(t, prev_t, next_t);
-                               if( (prev_t==Time::begin()      &&      next_t==Time::end())
-                               ||
-                               ((t-prev_t)>time_ratio  && (next_t-t)>time_ratio)
-                               )
-                               {
-                                       set_selected_keyframe(selected_none);
-                                       selected_=false;
-                                       queue_draw();
-                               }
-                               else if ((t-prev_t)<(next_t-t))
-                               {
-                                       set_selected_keyframe(*(kf_list_->find_prev(t)));
-                                       queue_draw();
-                                       selected_=true;
-                               }
-                               else
-                               {
-                                       set_selected_keyframe(*(kf_list_->find_next(t)));
-                                       queue_draw();
-                                       selected_=true;
-                               }
-                               return true;
-                       }
-                       else
-                       {
-                               return false;
-                       }
-               }
-
-               break;
-       case GDK_BUTTON_RELEASE:
-               if(editable_ && (event->button.button==1 /*|| event->button.button==3*/))
-               {
-                       // stick to integer frames.
-                       if(fps) t = floor(t*fps + 0.5)/fps;
-                       bool stat=false;
-                       if(dragging_)
-                               {
-                                       //if (event->button.button==3)
-                                       if(event->button.state & GDK_MOD1_MASK)
-                                       {
-                                               stat=perform_move_kf(true);
-                                       }
-                                       else
-                                       {
-                                               stat=perform_move_kf(false);
-                                       }
-                               }
-                       dragging_=false;
-                       return stat;
-               }
-               break;
-       default:
-               break;
-       }
-       return false;
-}
-
-
-void Widget_Keyframe_List::set_time_adjustment(Gtk::Adjustment *x)
-{
-       //disconnect old connections
-       time_value_change.disconnect();
-       time_other_change.disconnect();
-
-       //connect update function to new adjustment
-       adj_timescale = x;
-
-       if(x)
-       {
-               time_value_change = x->signal_value_changed().connect(sigc::mem_fun(*this,&Widget_Keyframe_List::queue_draw));
-               time_other_change = x->signal_changed().connect(sigc::mem_fun(*this,&Widget_Keyframe_List::queue_draw));
-       }
-}
-
-void
-Widget_Keyframe_List::set_fps(float d)
-{
-       if(fps != d)
-       {
-               fps = d;
-               //update everything since we need to redraw already
-               queue_draw();
-       }
-}
-
-void
-Widget_Keyframe_List::set_canvas_interface(etl::loose_handle<synfigapp::CanvasInterface> h)
-{
-       canvas_interface_=h;
-       // Store the values used fomr the canvas interface.
-       if (canvas_interface_)
-       {
-               set_fps(canvas_interface_->get_canvas()->rend_desc().get_frame_rate());
-               set_kf_list(&canvas_interface_->get_canvas()->keyframe_list());
-       }
-}
-
-
diff --git a/synfig-studio/src/gtkmm/widget_keyframe_list.h b/synfig-studio/src/gtkmm/widget_keyframe_list.h
deleted file mode 100644 (file)
index 1e41770..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_keyframe_list.h
-**     \brief A custom widget to manage keyframes in the timeline.
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2009 Carlos López
-**
-**     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_WIDGET_KEYFRAME_LIST_H
-#define __SYNFIG_STUDIO_WIDGET_KEYFRAME_LIST_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/drawingarea.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/tooltips.h>
-#include <synfig/keyframe.h>
-#include <sigc++/connection.h>
-#include <synfigapp/canvasinterface.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 Widget_Keyframe_List : public Gtk::DrawingArea
-{
-       //! Tooltips class. It is deprecated since gtkmm 2.12
-       //! replace with Tooltip class or use the own tooltip widget's members
-       Gtk::Tooltips tooltips;
-
-       //! The canvas interface being watched
-       etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
-
-       //! Time adjustment window
-       Gtk::Adjustment adj_default;
-       Gtk::Adjustment *adj_timescale;
-
-       //!The list of keyframes to be drawn on the widget and moved with mouse
-       synfig::KeyframeList default_kf_list_;
-       mutable synfig::KeyframeList* kf_list_;
-
-       //! The frames per second of the canvas
-       float fps;
-
-       //! Time radius to click a keyframe
-       synfig::Time time_ratio;
-
-       //!True if it is editable. Keyframes can be moved.
-       bool editable_;
-
-       //!True if a keyframe is being dragged.
-       bool dragging_;
-
-       //!True if a keyframe has been moved
-       bool changed_;
-
-       //!Holds the selected keyframe of the keyframe list
-       synfig::Keyframe selected_kf;
-       synfig::Keyframe selected_none;
-       bool selected_;
-
-       //!The time of the selected keyframe
-       synfig::Time selected_kf_time;
-
-       //!The time of the selected keyframe during draging
-       synfig::Time dragging_kf_time;
-
-       //!Connectors for handling the signals of the time adjustment
-       sigc::connection time_value_change;
-       sigc::connection time_other_change;
-
-public:
-
-       //!Default constructor
-       Widget_Keyframe_List();
-
-       //!Destructror
-       ~Widget_Keyframe_List();
-
-       //!Loads a new keyframe list on the widget.
-       void set_kf_list(synfig::KeyframeList* x);
-
-       //!Member for private data.
-       synfig::KeyframeList* get_kf_list()const { return kf_list_; }
-
-       //!Member for private data
-       void set_editable(bool x=true) { editable_=x; }
-
-       //!Member for private data
-       bool get_editable()const { return editable_; }
-
-
-       //!Store the selected keyframe value
-       void set_selected_keyframe(const synfig::Keyframe &x);
-
-       //!Returns the selected keyframe
-       const synfig::Keyframe& get_selected_keyframe() { return selected_kf; }
-
-       //! Set the time adjustment and proper connects its change signals
-       void set_time_adjustment(Gtk::Adjustment *x);
-
-       //! Set the fps
-       void set_fps(float x);
-
-       //! Set the canvas interface
-       void set_canvas_interface(etl::loose_handle<synfigapp::CanvasInterface> h);
-
-       //! Performs the keyframe movement. Returns true if it was sucessful
-       //! @return true: if success otherwise false
-       //! |delta=false: permorm normal move. true: perform delta movement
-       bool perform_move_kf(bool delta);
-
-
-
-/* ======================= EVENTS HANDLERS ===========================*/
-       //!Redraw event. Should draw all the keyframes +  the selected + the dragged
-       bool redraw(GdkEventExpose*bleh=NULL);
-
-       //!Mouse event handler.
-       bool on_event(GdkEvent *event);
-}; // END of class Keyframe_List
-
-}; // END of namespace studio
-
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/widget_sound.cpp b/synfig-studio/src/gtkmm/widget_sound.cpp
deleted file mode 100644 (file)
index 3d43731..0000000
+++ /dev/null
@@ -1,323 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_sound.cpp
-**     \brief Widget Sound Implementation File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include <gtkmm/adjustment.h>
-
-#include <synfig/general.h>
-#include <ETL/clock>
-
-#include "widget_sound.h"
-#include "audiocontainer.h"
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-//using namespace synfig;
-
-using studio::AudioProfile;
-
-/* === M A C R O S ========================================================= */
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-/* === E N T R Y P O I N T ================================================= */
-
-studio::Widget_Sound::Widget_Sound()
-{
-}
-
-studio::Widget_Sound::~Widget_Sound()
-{
-}
-
-void studio::Widget_Sound::set_position(double t)
-{
-       //synfig::info("Setting position to %.2lf s", t);
-       if(adj_timescale && t != adj_timescale->get_value())
-       {
-               float upper = adj_timescale->get_upper();
-               float lower = adj_timescale->get_lower();
-               float framesize =  upper - lower;
-
-               if(t < lower)
-               {
-                       lower -= ceil((lower-t)/framesize)*framesize;
-                       upper = lower + framesize;
-                       adj_timescale->set_lower(lower); adj_timescale->set_upper(upper);
-                       adj_timescale->set_value(t);
-                       adj_timescale->changed(); adj_timescale->value_changed();
-               }else
-               if(t > upper)
-               {
-                       lower += ceil((t-upper)/framesize)*framesize;
-                       upper = lower + framesize;
-                       adj_timescale->set_lower(lower); adj_timescale->set_upper(upper);
-                       adj_timescale->set_value(t);
-                       adj_timescale->changed(); adj_timescale->value_changed();
-               }else
-               {
-                       adj_timescale->set_value(t);
-                       adj_timescale->value_changed();
-               }
-       }
-}
-
-double studio::Widget_Sound::get_position() const
-{
-       if(adj_timescale)
-       {
-               return adj_timescale->get_value();
-       }
-       return 0;
-}
-
-bool studio::Widget_Sound::set_profile(etl::handle<AudioProfile>       p)
-{
-       clear();
-
-       //set the profile
-       audioprof = p;
-
-       if(!audioprof)
-       {
-               clear();
-               return false;
-       }
-
-       return true;
-}
-
-etl::handle<AudioProfile>      studio::Widget_Sound::get_profile() const
-{
-       return audioprof;
-}
-
-void studio::Widget_Sound::clear()
-{
-       audioprof.detach();
-}
-
-void studio::Widget_Sound::draw()
-{
-       on_expose_event();
-}
-
-bool studio::Widget_Sound::on_expose_event(GdkEventExpose */*heh*/)
-{
-       if(!get_window()) return false;
-
-       //clear the background to dark grey
-       Glib::RefPtr<Gdk::GC>   gc = Gdk::GC::create(get_window());
-
-       if(!gc) return false;
-
-       {
-               Gdk::Rectangle r(0,0,get_width(),get_height());
-               get_window()->begin_paint_rect(r);
-       }
-       Gdk::Color      c("#3f3f3f");
-       gc->set_rgb_fg_color(c);
-       gc->set_background(c);
-
-       int w = get_width();
-       int baseline = get_height()/2;
-       get_window()->draw_rectangle(gc,true,0,0,w,get_height());
-
-       //set up the color to be blue
-       c.set_rgb_p(0,0.5,1);
-       gc->set_rgb_fg_color(c);
-
-       //draw the base line
-       get_window()->draw_line(gc,0,baseline,w,baseline);
-
-       //redraw all the samples from begin to end, but only if we have samples to draw (or there is no space to draw)
-
-       //synfig::warning("Ok rendered everything, now must render actual sound wave");
-       if(!audioprof || !adj_timescale || !w)
-       {
-               get_window()->end_paint();
-               return true;
-       }
-
-       //draw you fool!
-       float framesize = adj_timescale->get_upper() - adj_timescale->get_lower();
-       if(framesize)
-       {
-               float delta=0,cum=0;
-
-               //position in sample space
-               int begin=0,end=0;
-               int     cur=0,maxs=0,mins=0;
-
-               int       i=0; //pixel counter
-
-               //etl::clock    check; check.reset();
-
-               float position = adj_timescale->get_value();
-               float samplerate = audioprof->get_samplerate();
-               int             posi = 0;
-               //enforce position inside of frame size
-               {
-                       float offset = audioprof->get_offset();
-
-                       //clamp begin and end to framesize
-                       float beginf = adj_timescale->get_lower();
-                       float endf = adj_timescale->get_upper();
-
-                       posi = round_to_int((position-beginf)*w/framesize);
-                       //posi = (int)((position-beginf)*w/framesize);
-
-                       //calculate in sample space from seconds
-                       begin = round_to_int((beginf - offset)*samplerate);
-                       end = round_to_int((endf - offset)*samplerate);
-                       //begin = (int)((beginf - offset)*samplerate);
-                       //end = (int)((endf - offset)*samplerate);
-               }
-
-               delta = (end - begin)/(float)w; //samples per pixel
-
-               /*synfig::warning("Rendering a framesize of %f secs from [%d,%d) samples to %d samples, took %f sec",
-                                               framesize, begin, end, w, check());*/
-
-               cur = begin;
-               i = 0; cum = 0;
-               for(int i=0;i<w;++i)
-               {
-                       //get the maximum of the collected samples
-                       maxs = 0;
-                       mins = 0;
-                       for(;cum < delta; ++cum, ++cur)
-                       {
-                               maxs = std::max(maxs,(int)(*audioprof)[cur]);
-                               mins = std::min(mins,(int)(*audioprof)[cur]);
-                       }
-                       cum -= delta;
-
-                       //draw spike if not needed be
-                       if(maxs||mins)
-                       {
-                               int top = maxs * baseline / 64;
-                               int bot = mins * baseline / 64;
-
-                               get_window()->draw_line(gc,i,baseline+bot,i,baseline+top);
-                       }
-               }
-
-               //synfig::warning("Drawing audio line");
-               c.set_rgb_p(1,0,0);
-               gc->set_rgb_fg_color(c);
-               get_window()->draw_line(gc,posi,0,posi,get_height());
-       }
-       get_window()->end_paint();
-
-       return true;
-}
-
-//--- Handle the single clicking and dragging for scrubbing
-
-bool studio::Widget_Sound::on_motion_notify_event(GdkEventMotion* event)
-{
-       Gdk::ModifierType       mod = Gdk::ModifierType(event->state);
-
-       //if we are scrubbing
-       if(mod & Gdk::BUTTON1_MASK)
-       {
-               //Can't do this if we don't have a time frame (heheh...)
-               if(!adj_timescale) return false;
-
-               double beg = adj_timescale->get_lower(), end = adj_timescale->get_upper();
-
-               //find event position in time
-               double t = beg + event->x * (end-beg) / get_width();
-
-               //signal that we are scrubbing to this new value...
-               signal_scrub()(t);
-
-
-               // We should be able to just call
-               // Widget_Timeslider::on_motion_notify_event(),
-               // but that seems to cause the program to halt
-               // for some reason. So for now, let's do the job ourselves
-               //adj_timescale->set_value(t);
-               //adj_timescale->changed();
-               //return true;
-       }
-
-       return Widget_Timeslider::on_motion_notify_event(event);
-}
-
-bool studio::Widget_Sound::on_button_press_event(GdkEventButton *event)
-{
-       //Assume button PRESS
-
-       //if we are starting... using left click
-       if(event->button == 1)
-       {
-               if(!adj_timescale) return false;
-
-               double beg = adj_timescale->get_lower(), end = adj_timescale->get_upper();
-
-               //find event position in time
-               double t = beg + event->x * (end-beg) / get_width();
-
-               //signal the attached scrubbing devices...
-               signal_start_scrubbing()(t);
-
-               return true;
-       }
-
-       return Widget_Timeslider::on_button_press_event(event);
-}
-
-bool studio::Widget_Sound::on_button_release_event(GdkEventButton *event)
-{
-       //Assume button RELEASE
-
-       //if we are ending... using left click
-       if(event->button == 1)
-       {
-               //signal the scrubbing device... to stop
-               signal_stop_scrubbing()();
-
-               return true;
-       }
-
-       return Widget_Timeslider::on_button_release_event(event);
-}
diff --git a/synfig-studio/src/gtkmm/widget_sound.h b/synfig-studio/src/gtkmm/widget_sound.h
deleted file mode 100644 (file)
index 0db129d..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_sound.h
-**     \brief Widget Sound 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_WIDGET_SOUND_H
-#define __SYNFIG_WIDGET_SOUND_H
-
-/* === H E A D E R S ======================================================= */
-#include <ETL/handle>
-
-#include <gtkmm/drawingarea.h>
-
-#include "widget_timeslider.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 AudioProfile;
-class AudioContainer;
-
-/*     What can widget sound do?
-       Options:
-       1. Just draw the sound
-       2. Scroll time and draw the sound
-       3. Play, stop, and scrub the sound... (full interaction...)
-       4. Provide hooks for scrubbing to work... (and possibly play and stop in the future)
-
-       Going with 4 for now...
-*/
-class Widget_Sound : public Widget_Timeslider
-{
-       etl::handle<AudioProfile>       audioprof;
-
-       //event override interface
-       virtual bool on_expose_event(GdkEventExpose *heh = 0);
-
-       //for scrubbing... (click is start, drag is scrub, and release is stop...)
-       virtual bool on_motion_notify_event(GdkEventMotion* event);
-       virtual bool on_button_press_event(GdkEventButton *event);
-       virtual bool on_button_release_event(GdkEventButton *event);
-
-       //Might want a signal setup for scrubbing... and here it is
-       sigc::signal1<void,double>      signal_start_scrubbing_;
-       sigc::signal1<void,double>      signal_scrub_;
-       sigc::signal0<void>                     signal_stop_scrubbing_;
-
-public: //structors
-       Widget_Sound();
-       ~Widget_Sound();
-
-public: //accessors
-       bool set_profile(etl::handle<AudioProfile>      p);
-       etl::handle<AudioProfile>       get_profile() const;
-
-       //for signal interface
-       sigc::signal1<void,double>      &       signal_start_scrubbing()        {return signal_start_scrubbing_;}
-       sigc::signal1<void,double>      &       signal_scrub()                          {return signal_scrub_;}
-       sigc::signal0<void>                     &       signal_stop_scrubbing()         {return signal_stop_scrubbing_;}
-
-public: //get set interface
-       void set_position(double t);
-       double get_position() const;
-
-public: //interface
-       void draw();
-
-       void clear();
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/widget_time.cpp b/synfig-studio/src/gtkmm/widget_time.cpp
deleted file mode 100644 (file)
index 2467c70..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_time.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2008 Chris Moore
-**  Copyright (c) 2008 Paul Wise
-**
-**     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 <config.h>
-#endif
-
-#include <gtkmm/entry.h>
-#include <gtkmm/button.h>
-#include "widget_time.h"
-#include "app.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Widget_Time::Widget_Time():
-       fps_(0),
-       time_(0)
-{
-       signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Time::refresh_value));
-       signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Time::refresh_text));
-}
-
-Widget_Time::~Widget_Time()
-{
-}
-
-void
-Widget_Time::refresh_text()
-{
-       set_text(time_.get_string(fps_,App::get_time_format()));
-}
-
-
-void
-Widget_Time::set_value(const synfig::Time &data)
-{
-       time_=data;
-       refresh_text();
-}
-
-synfig::Time
-Widget_Time::get_value() const
-{
-       return time_;
-}
-
-void
-Widget_Time::set_fps(float x)
-{
-       fps_=Time(x);
-       refresh_text();
-}
-
-void
-Widget_Time::refresh_value()
-{
-       try
-       {
-               Time newtime(get_text(),fps_);
-               if(abs(newtime-time_)>=0.001)
-               {
-                       time_=newtime;
-                       refresh_text();
-                       signal_value_changed()();
-               }
-       }
-       catch(...)
-       {
-               throw string("Caught unknown exception");
-       }
-}
-
-bool
-Widget_Time::on_event(GdkEvent* event)
-{
-       const Time scroll_amount(0.25);
-
-       switch(event->type)
-       {
-       case GDK_SCROLL:
-               if(event->scroll.direction==GDK_SCROLL_DOWN || event->scroll.direction==GDK_SCROLL_LEFT)
-               {
-                       time_-=scroll_amount;
-                       refresh_text();
-                       signal_value_changed()();
-               }
-               else if(event->scroll.direction==GDK_SCROLL_UP || event->scroll.direction==GDK_SCROLL_RIGHT)
-               {
-                       time_+=scroll_amount;
-                       refresh_text();
-                       signal_value_changed()();
-               }
-               return true;
-               break;
-       case GDK_BUTTON_PRESS:
-       case GDK_2BUTTON_PRESS:
-       case GDK_3BUTTON_PRESS:
-               if (!has_focus())
-                       grab_focus();
-               break;
-       default:
-               break;
-       }
-
-       return Gtk::Entry::on_event(event);
-}
-
-bool
-Widget_Time::on_focus_out_event(GdkEventFocus* event)
-{
-       refresh_value();
-       refresh_text();
-       return Gtk::Entry::on_focus_out_event(event);
-}
-
-bool
-Widget_Time::on_focus_in_event(GdkEventFocus* event)
-{
-       // if defined, show the full time format "0h 0m 5s 0f" when the time widget gets focus
-       if (getenv("SYNFIG_SHOW_FULL_TIME_ON_FOCUS"))
-               set_text(time_.get_string(fps_,App::get_time_format()|Time::FORMAT_FULL));
-
-       return Gtk::Entry::on_focus_in_event(event);
-}
diff --git a/synfig-studio/src/gtkmm/widget_time.h b/synfig-studio/src/gtkmm/widget_time.h
deleted file mode 100644 (file)
index 7332610..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_time.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_WIDGET_TIME_H
-#define __SYNFIG_STUDIO_WIDGET_TIME_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <sigc++/signal.h>
-#include <sigc++/slot.h>
-#include <gtkmm/entry.h>
-#include <synfig/time.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 Gtk { class Entry; class Button; };
-
-namespace studio {
-
-class Widget_Time : public Gtk::Entry
-{
-
-
-       sigc::signal<void> signal_value_changed_;
-
-       float fps_;
-
-       synfig::Time time_;
-
-protected:
-       bool on_focus_out_event(GdkEventFocus* event);
-
-       bool on_focus_in_event(GdkEventFocus* event);
-
-       //void on_activate();
-
-       void refresh_text();
-
-       void refresh_value();
-
-       bool on_event(GdkEvent* event);
-
-public:
-       sigc::signal<void> &signal_value_changed() { return signal_value_changed_; }
-
-
-
-       void set_value(const synfig::Time &data);
-       synfig::Time get_value()const;
-       void set_fps(float x);
-       Widget_Time();
-       ~Widget_Time();
-}; // END of class Widget_Time
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/widget_timeslider.cpp b/synfig-studio/src/gtkmm/widget_timeslider.cpp
deleted file mode 100644 (file)
index ed5d63c..0000000
+++ /dev/null
@@ -1,966 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_timeslider.cpp
-**     \brief Time Slider Widget Implementation File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2004 Adrian Bentley
-**     Copyright (c) 2007, 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 <config.h>
-#endif
-
-#include "widget_timeslider.h"
-
-#include <ETL/misc>
-
-#include <cmath>
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-using namespace synfig;
-
-using studio::Widget_Timeslider;
-
-/* === M A C R O S ========================================================= */
-
-/* === G L O B A L S ======================================================= */
-const double zoominfactor = 0.75;
-const double zoomoutfactor = 1/zoominfactor;
-
-/* === P R O C E D U R E S ================================================= */
-
-Gdk::Color get_interp_color(synfig::Interpolation x)
-{
-       switch(x)
-       {
-       case INTERPOLATION_TCB:
-               return Gdk::Color("#00B000");
-
-               break;
-
-       case INTERPOLATION_LINEAR:
-               return Gdk::Color("#B0B000");
-               break;
-
-       case INTERPOLATION_CONSTANT:
-               return Gdk::Color("#C70000");
-               break;
-
-       case INTERPOLATION_HALT:
-               return Gdk::Color("#00b0b0");
-               break;
-
-       case INTERPOLATION_MANUAL:
-               return Gdk::Color("#B000B0");
-               break;
-
-       case INTERPOLATION_UNDEFINED: default:
-               return Gdk::Color("#808080");
-               break;
-       }
-}
-
-static Gdk::Color
-color_darken(Gdk::Color x, float amount)
-{
-       double   red = x.get_red_p()   * amount;
-       double green = x.get_green_p() * amount;
-       double  blue = x.get_blue_p()  * amount;
-
-       x.set_rgb_p(  red > 1 ? 1 : red,
-                               green > 1 ? 1 : green,
-                                blue > 1 ? 1 : blue);
-
-       return x;
-}
-
-void
-studio::render_time_point_to_window(
-       const Glib::RefPtr<Gdk::Drawable>& window,
-       const Gdk::Rectangle& area,
-       const synfig::TimePoint &tp,
-       bool selected
-)
-{
-       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(window));
-       const Gdk::Color black("#000000");
-
-       if(selected)
-               gc->set_line_attributes(2,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-       else
-               gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-
-       Gdk::Color color;
-       std::vector<Gdk::Point> points;
-
-/*-    BEFORE ------------------------------------- */
-
-       color=get_interp_color(tp.get_before());
-       color=color_darken(color,1.0f);
-       if(selected)color=color_darken(color,1.3f);
-       gc->set_rgb_fg_color(color);
-
-       switch(tp.get_before())
-       {
-       case INTERPOLATION_TCB:
-               window->draw_arc(
-                       gc,
-                       true,
-                       area.get_x(),
-                       area.get_y(),
-                       area.get_width(),
-                       area.get_height(),
-                       64*90,
-                       64*180
-               );
-               gc->set_rgb_fg_color(black);
-               window->draw_arc(
-                       gc,
-                       false,
-                       area.get_x(),
-                       area.get_y(),
-                       area.get_width(),
-                       area.get_height(),
-                       64*90,
-                       64*180
-               );
-               break;
-
-       case INTERPOLATION_HALT:
-               window->draw_arc(
-                       gc,
-                       true,
-                       area.get_x(),
-                       area.get_y(),
-                       area.get_width(),
-                       area.get_height()*2,
-                       64*90,
-                       64*90
-               );
-               gc->set_rgb_fg_color(black);
-               window->draw_arc(
-                       gc,
-                       false,
-                       area.get_x(),
-                       area.get_y(),
-                       area.get_width(),
-                       area.get_height()*2,
-                       64*90,
-                       64*90
-               );
-               break;
-
-       case INTERPOLATION_LINEAR:
-               points.clear();
-               points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
-               points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()));
-               points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
-               window->draw_polygon(gc,true,points);
-               gc->set_rgb_fg_color(black);
-               window->draw_lines(gc,points);
-               break;
-
-       case INTERPOLATION_CONSTANT:
-               points.clear();
-               points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
-               points.push_back(Gdk::Point(area.get_x()+area.get_width()/4,area.get_y()));
-               points.push_back(Gdk::Point(area.get_x()+area.get_width()/4,area.get_y()+area.get_height()/2));
-               points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()/2));
-               points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()));
-               points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
-               window->draw_polygon(gc,true,points);
-               gc->set_rgb_fg_color(black);
-               window->draw_lines(gc,points);
-               break;
-
-       case INTERPOLATION_UNDEFINED: default:
-               points.clear();
-               points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
-               points.push_back(Gdk::Point(area.get_x()+area.get_width()/3,area.get_y()));
-               points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()/3));
-               points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()-area.get_height()/3));
-               points.push_back(Gdk::Point(area.get_x()+area.get_width()/3,area.get_y()+area.get_height()));
-               points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
-               window->draw_polygon(gc,true,points);
-               gc->set_rgb_fg_color(black);
-               window->draw_lines(gc,points);
-               break;
-       }
-
-/*-    AFTER -------------------------------------- */
-
-       color=get_interp_color(tp.get_after());
-       color=color_darken(color,0.8f);
-       if(selected)color=color_darken(color,1.3f);
-       gc->set_rgb_fg_color(color);
-
-       switch(tp.get_after())
-       {
-       case INTERPOLATION_TCB:
-               window->draw_arc(
-                       gc,
-                       true,
-                       area.get_x(),
-                       area.get_y(),
-                       area.get_width(),
-                       area.get_height(),
-                       64*270,
-                       64*180
-               );
-               gc->set_rgb_fg_color(black);
-               window->draw_arc(
-                       gc,
-                       false,
-                       area.get_x(),
-                       area.get_y(),
-                       area.get_width(),
-                       area.get_height(),
-                       64*270,
-                       64*180
-               );
-               break;
-
-       case INTERPOLATION_HALT:
-               window->draw_arc(
-                       gc,
-                       true,
-                       area.get_x(),
-                       area.get_y()-area.get_height(),
-                       area.get_width(),
-                       area.get_height()*2,
-                       64*270,
-                       64*90
-               );
-               gc->set_rgb_fg_color(black);
-               window->draw_arc(
-                       gc,
-                       false,
-                       area.get_x(),
-                       area.get_y()-area.get_height(),
-                       area.get_width(),
-                       area.get_height()*2,
-                       64*270,
-                       64*90
-               );
-               break;
-
-       case INTERPOLATION_LINEAR:
-               points.clear();
-               points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
-               points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()));
-               points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
-               window->draw_polygon(gc,true,points);
-               gc->set_rgb_fg_color(black);
-               window->draw_lines(gc,points);
-               break;
-
-       case INTERPOLATION_CONSTANT:
-               points.clear();
-               points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
-               points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()));
-               points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()+area.get_height()/2));
-               points.push_back(Gdk::Point(area.get_x()+area.get_width()-area.get_width()/4,area.get_y()+area.get_height()/2));
-               points.push_back(Gdk::Point(area.get_x()+area.get_width()-area.get_width()/4,area.get_y()+area.get_height()));
-               points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
-               window->draw_polygon(gc,true,points);
-               gc->set_rgb_fg_color(black);
-               window->draw_lines(gc,points);
-               break;
-
-       case INTERPOLATION_UNDEFINED: default:
-               points.clear();
-               points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
-               points.push_back(Gdk::Point(area.get_x()+area.get_width()-area.get_width()/3,area.get_y()));
-               points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()+area.get_height()/3));
-               points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()+area.get_height()-area.get_height()/3));
-               points.push_back(Gdk::Point(area.get_x()+area.get_width()-area.get_width()/3,area.get_y()+area.get_height()));
-               points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
-               window->draw_polygon(gc,true,points);
-               gc->set_rgb_fg_color(black);
-               window->draw_lines(gc,points);
-               break;
-       }
-
-}
-
-/* === M E T H O D S ======================================================= */
-
-/* === E N T R Y P O I N T ================================================= */
-double defaultfps = 24;
-const int fullheight = 20;
-
-Widget_Timeslider::Widget_Timeslider()
-:layout(Pango::Layout::create(get_pango_context())),
-adj_default(0,0,2,1/defaultfps,10/defaultfps),
-adj_timescale(0),
-//invalidated(false),
-last_event_time(0),
-fps(defaultfps),
-dragscroll(false)
-{
-       set_size_request(-1,fullheight);
-
-       //                click                    scroll                     zoom
-       add_events( Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK
-                               | Gdk::BUTTON_MOTION_MASK | Gdk::SCROLL_MASK );
-
-       set_time_adjustment(&adj_default);
-       //update_times();
-}
-
-Widget_Timeslider::~Widget_Timeslider()
-{
-}
-
-void Widget_Timeslider::set_time_adjustment(Gtk::Adjustment *x)
-{
-       //disconnect old connections
-       time_value_change.disconnect();
-       time_other_change.disconnect();
-
-       //connect update function to new adjustment
-       adj_timescale = x;
-
-       if(x)
-       {
-               time_value_change = x->signal_value_changed().connect(sigc::mem_fun(*this,&Widget_Timeslider::queue_draw));
-               time_other_change = x->signal_changed().connect(sigc::mem_fun(*this,&Widget_Timeslider::queue_draw));
-               //invalidated = true;
-               //refresh();
-       }
-}
-
-void Widget_Timeslider::set_global_fps(float d)
-{
-       if(fps != d)
-       {
-               fps = d;
-
-               //update everything since we need to redraw already
-               //invalidated = true;
-               //refresh();
-               queue_draw();
-       }
-}
-
-/*void Widget_Timeslider::update_times()
-{
-       if(adj_timescale)
-       {
-               start = adj_timescale->get_lower();
-               end = adj_timescale->get_upper();
-               current = adj_timescale->get_value();
-       }
-}*/
-
-void Widget_Timeslider::refresh()
-{
-}
-/*
-{
-       if(invalidated)
-       {
-               queue_draw();
-       }else if(adj_timescale)
-       {
-               double  l = adj_timescale->get_lower(),
-                               u = adj_timescale->get_upper(),
-                               v = adj_timescale->get_value();
-
-               bool invalid = (l != start) || (u != end) || (v != current);
-
-               start = l;
-               end = u;
-               current = v;
-
-               if(invalid) queue_draw();
-       }
-}*/
-
-bool Widget_Timeslider::redraw(bool /*doublebuffer*/)
-{
-       Glib::RefPtr<Gdk::Window> window = get_window();
-
-       if(!window) return false;
-
-       Glib::RefPtr<Gdk::GC>   gc = Gdk::GC::create(window);
-       if(!gc) return false;
-
-       //synfig::info("Drawing Timeslider");
-       //clear and update to current values
-       //invalidated = false;
-       //update_times();
-
-       //draw grey rectangle
-       Gdk::Color      c("#7f7f7f");
-       gc->set_rgb_fg_color(c);
-       gc->set_background(c);
-
-       //Get the data for the window and the params to draw it...
-       int w = get_width(), h = get_height();
-
-       window->draw_rectangle(gc,true,0,0,w,h);
-
-       const double EPSILON = 1e-6;
-       if(!adj_timescale || w == 0) return true;
-
-       //Get the time information since we now know it's valid
-       double  start = adj_timescale->get_lower(),
-                       end = adj_timescale->get_upper(),
-                       current = adj_timescale->get_value();
-
-       if(end-start < EPSILON) return true;
-
-       //synfig::info("Drawing Lines");
-
-       //draw all the time stuff
-       double dtdp = (end - start)/get_width();
-       double dpdt = 1/dtdp;
-
-       //lines
-
-       //Draw the time line...
-       double tpx = (current-start)*dpdt;
-       gc->set_rgb_fg_color(Gdk::Color("#ffaf00"));
-       window->draw_line(gc,round_to_int(tpx),0,round_to_int(tpx),fullheight);
-
-       //normal line/text color
-       gc->set_rgb_fg_color(Gdk::Color("#333333"));
-
-       int ifps = round_to_int(fps);
-       if (ifps < 1) ifps = 1;
-
-       std::vector<double> ranges;
-
-       unsigned int pos = 0;
-
-       // build a list of all the factors of the frame rate
-       for (int i = 1; i*i <= ifps; i++)
-               if ((ifps%i) == 0)
-               {
-                       ranges.insert(ranges.begin()+pos, i/fps);
-                       if (i*i != ifps)
-                               ranges.insert(ranges.begin()+pos+1, ifps/i/fps);
-                       pos++;
-               }
-
-       // fill in any gaps where one factor is more than 2 times the previous
-       std::vector<double>::iterator iter, next;
-       pos = 0;
-       for (pos = 0; pos < ranges.size()-1; pos++)
-       {
-               iter = ranges.begin()+pos;
-               next = iter+1;
-               if (*iter*2 < *next)
-                       ranges.insert(next, *iter*2);
-       }
-
-       double more_ranges[] = {
-               2, 3, 5, 10, 20, 30, 60, 90, 120, 180,
-               300, 600, 1200, 1800, 2700, 3600, 3600*2,
-               3600*4, 3600*8, 3600*16, 3600*32, 3600*64,
-               3600*128, 3600*256, 3600*512, 3600*1024 };
-
-       ranges.insert(ranges.end(), more_ranges, more_ranges + sizeof(more_ranges)/sizeof(double));
-
-       double lowerrange = dtdp*140, upperrange = dtdp*280;
-       double midrange = (lowerrange + upperrange)/2;
-
-       //find most ideal scale
-       double scale;
-       next = binary_find(ranges.begin(), ranges.end(), midrange);
-       iter = next++;
-
-       if (iter == ranges.end()) iter--;
-       if (next == ranges.end()) next--;
-
-       if (abs(*next - midrange) < abs(*iter - midrange))
-               iter = next;
-
-       scale = *iter;
-
-       // subdivide into this many tick marks (8 or less)
-       int subdiv = round_to_int(scale * ifps);
-
-       if (subdiv > 8)
-       {
-               const int ideal = subdiv;
-
-               // find a number of tick marks that nicely divides the scale
-               // (5 minutes divided by 6 is 50s, but that's not 'nice' -
-               //  5 ticks of 1m each is much simpler than 6 ticks of 50s)
-               for (subdiv = 8; subdiv > 0; subdiv--)
-                       if ((ideal <= ifps*2       && (ideal % (subdiv           )) == 0) ||
-                               (ideal <= ifps*2*60    && (ideal % (subdiv*ifps      )) == 0) ||
-                               (ideal <= ifps*2*60*60 && (ideal % (subdiv*ifps*60   )) == 0) ||
-                               (true                  && (ideal % (subdiv*ifps*60*60)) == 0))
-                               break;
-
-               // if we didn't find anything, use 4 ticks
-               if (!subdiv)
-                       subdiv = 4;
-       }
-
-       time_per_tickmark = scale / subdiv;
-
-       //get first valid line and its position in pixel space
-       double time = 0;
-       double pixel = 0;
-
-       int sdindex = 0;
-
-       double subr = scale / subdiv;
-
-       //get its position inside...
-       time = ceil(start/subr)*subr - start;
-       pixel = time*dpdt;
-
-       //absolute time of the line to be drawn
-       time += start;
-
-       { //inside the big'n
-               double t = (time/scale - floor(time/scale))*subdiv; // the difference from the big mark in 0:1
-               //sdindex = (int)floor(t + 0.5); //get how far through the range it is...
-               sdindex = round_to_int(t); //get how far through the range it is...
-               if (sdindex == subdiv) sdindex = 0;
-
-               //synfig::info("Extracted fr %.2lf -> %d", t, sdindex);
-       }
-
-       //synfig::info("Initial values: %.4lf t, %.1lf pixels, %d i", time,pixel,sdindex);
-
-       //loop to draw
-       const int heightbig = 12;
-       const int heightsmall = 4;
-
-       int width = get_width();
-       while( pixel < width )
-       {
-               int xpx = round_to_int(pixel);
-
-               //draw big
-               if(sdindex == 0)
-               {
-                       window->draw_line(gc,xpx,0,xpx,heightbig);
-                       //round the time to nearest frame and draw the text
-                       Time tm((double)time);
-                       if(get_global_fps()) tm.round(get_global_fps());
-                       Glib::ustring timecode(tm.get_string(get_global_fps(),App::get_time_format()));
-
-                       //gc->set_rgb_fg_color(Gdk::Color("#000000"));
-                       layout->set_text(timecode);
-                       Pango::AttrList attr_list;
-                       // Aproximately a font size of 8 pixels.
-                       // Pango::SCALE = 1024
-                       // create_attr_size waits a number in 1000th of pixels.
-                       // Should be user customizable in the future. Now it is fixed to 10
-                       Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*10));
-                       pango_size.set_start_index(0);
-                       pango_size.set_end_index(64);
-                       attr_list.change(pango_size);
-                       layout->set_attributes(attr_list);
-                       window->draw_layout(gc,xpx+2,0,layout);
-               }else
-               {
-                       window->draw_line(gc,xpx,0,xpx,heightsmall);
-               }
-
-               //increment time and position
-               pixel += subr / dtdp;
-               time += subr;
-
-               //increment index
-               if(++sdindex >= subdiv) sdindex -= subdiv;
-       }
-
-       return true;
-}
-
-bool Widget_Timeslider::on_motion_notify_event(GdkEventMotion* event) //for dragging
-{
-       if(!adj_timescale) return false;
-
-       Gdk::ModifierType mod = Gdk::ModifierType(event->state);
-
-       //scrolling...
-
-       //NOTE: we might want to address the possibility of dragging with both buttons held down
-
-       if(mod & Gdk::BUTTON2_MASK)
-       {
-
-               //we need this for scrolling by dragging
-               double  curx = event->x;
-
-               double  start = adj_timescale->get_lower(),
-                               end = adj_timescale->get_upper();
-
-               if(dragscroll)
-               {
-                       if(event->time-last_event_time<30)
-                               return false;
-                       else
-                               last_event_time=event->time;
-
-                       if(abs(lastx - curx) < 1 && end != start) return true;
-                       //translate the window and correct it
-
-                       //update our stuff so we are operating correctly
-                       //invalidated = true;
-                       //update_times();
-
-                       //Note: Use inverse of mouse movement because of conceptual space relationship
-                       double diff = lastx - curx; //curx - lastx;
-
-                       //NOTE: This might be incorrect...
-                       //fraction to move...
-                       double dpx = (end - start)/get_width();
-                       lastx = curx;
-
-                       diff *= dpx;
-
-                       //Adjust...
-                       start += diff;
-                       end += diff;
-
-                       //But clamp to bounds if they exist...
-                       //HACK - bounds should not be required for this slider
-                       if(adj_bounds)
-                       {
-                               if(start < adj_bounds->get_lower())
-                               {
-                                       diff = adj_bounds->get_lower() - start;
-                                       start += diff;
-                                       end += diff;
-                               }
-
-                               if(end > adj_bounds->get_upper())
-                               {
-                                       diff = adj_bounds->get_upper() - end;
-                                       start += diff;
-                                       end += diff;
-                               }
-                       }
-
-                       //synfig::info("Scrolling timerange to (%.4f,%.4f)",start,end);
-
-                       adj_timescale->set_lower(start);
-                       adj_timescale->set_upper(end);
-
-                       adj_timescale->changed();
-               }else
-               {
-                       dragscroll = true;
-                       lastx = curx;
-                       //lasty = cury;
-               }
-
-               return true;
-       }
-
-       if(mod & Gdk::BUTTON1_MASK)
-       {
-               double curx = event->x;
-
-               //get time from drag...
-               double  start = adj_timescale->get_lower(),
-                               end = adj_timescale->get_upper(),
-                               current = adj_timescale->get_value();
-               double t = start + curx*(end - start)/get_width();
-
-               //snap it to fps - if they exist...
-               if(fps)
-               {
-                       t = floor(t*fps + 0.5)/fps;
-               }
-
-               //set time if needed
-               if(current != t)
-               {
-                       adj_timescale->set_value(t);
-
-                       //Fixed this to actually do what it's supposed to...
-                       if(event->time-last_event_time>50)
-                       {
-                               adj_timescale->value_changed();
-                               last_event_time = event->time;
-                       }
-               }
-
-               return true;
-       }
-
-       return false;
-}
-
-bool Widget_Timeslider::on_scroll_event(GdkEventScroll* event) //for zooming
-{
-       if(!adj_timescale) return false;
-
-       //Update so we are calculating based on current values
-       //update_times();
-
-       //figure out if we should center ourselves on the current time
-       bool center = false;
-
-       //we want to zoom in on the time value if control is held down
-       if(Gdk::ModifierType(event->state) & Gdk::CONTROL_MASK)
-               center = true;
-
-       switch(event->direction)
-       {
-               case GDK_SCROLL_UP: //zoom in
-                       zoom_in(center);
-                       return true;
-
-               case GDK_SCROLL_DOWN: //zoom out
-                       zoom_out(center);
-                       return true;
-
-               case GDK_SCROLL_RIGHT:
-               case GDK_SCROLL_LEFT:
-               {
-                       double t = adj_timescale->get_value();
-                       double orig_t = t;
-                       double start = adj_timescale->get_lower();
-                       double end = adj_timescale->get_upper();
-                       double lower = adj_bounds->get_lower();
-                       double upper = adj_bounds->get_upper();
-                       double adj = time_per_tickmark;
-
-                       if( event->direction == GDK_SCROLL_RIGHT )
-                       {
-                               // step forward one tick
-                               t += adj;
-
-                               // don't go past the end of time
-                               if (t > upper)
-                                       t = upper;
-
-                               // if we are already in the right half of the slider
-                               if ((t-start)*2 > (end-start))
-                               {
-                                       // if we can't scroll the background left one whole tick, scroll it to the end
-                                       if (end > upper - (t-orig_t))
-                                       {
-                                               adj_timescale->set_lower(upper - (end-start));
-                                               adj_timescale->set_upper(upper);
-                                       }
-                                       // else scroll the background left
-                                       else
-                                       {
-                                               adj_timescale->set_lower(start + (t-orig_t));
-                                               adj_timescale->set_upper(start + (t-orig_t) + (end-start));
-                                       }
-                               }
-                       }
-                       else
-                       {
-                               // step backwards one tick
-                               t -= adj;
-
-                               // don't go past the start of time
-                               if (t < lower)
-                                       t = lower;
-
-                               // if we are already in the left half of the slider
-                               if ((t-start)*2 < (end-start))
-                               {
-                                       // if we can't scroll the background right one whole tick, scroll it to the beginning
-                                       if (start < lower + (orig_t-t))
-                                       {
-                                               adj_timescale->set_lower(lower);
-                                               adj_timescale->set_upper(lower + (end-start));
-                                       }
-                                       // else scroll the background right
-                                       else
-                                       {
-                                               adj_timescale->set_lower(start - (orig_t-t));
-                                               adj_timescale->set_upper(start - (orig_t-t) + (end-start));
-                                       }
-                               }
-                       }
-
-                       if(adj_timescale)
-                       {
-                               adj_timescale->set_value(t);
-                               adj_timescale->value_changed();
-                       }
-                       return true;
-               }
-               default:
-                       return false;
-       }
-}
-
-void Widget_Timeslider::zoom_in(bool centerontime)
-{
-       if(!adj_timescale) return;
-
-       double  start = adj_timescale->get_lower(),
-                       end = adj_timescale->get_upper(),
-                       current = adj_timescale->get_value();
-
-       double focuspoint = centerontime ? current : (start + end)/2;
-
-       //calculate new beginning and end
-       end = focuspoint + (end-focuspoint)*zoominfactor;
-       start = focuspoint + (start-focuspoint)*zoominfactor;
-
-       //synfig::info("Zooming in timerange to (%.4f,%.4f)",start,end);
-       if(adj_bounds)
-       {
-               if(start < adj_bounds->get_lower())
-               {
-                       start = adj_bounds->get_lower();
-               }
-
-               if(end > adj_bounds->get_upper())
-               {
-                       end = adj_bounds->get_upper();
-               }
-       }
-
-       //reset values
-       adj_timescale->set_lower(start);
-       adj_timescale->set_upper(end);
-
-       //call changed function
-       adj_timescale->changed();
-}
-
-void Widget_Timeslider::zoom_out(bool centerontime)
-{
-       if(!adj_timescale) return;
-
-       double  start = adj_timescale->get_lower(),
-                       end = adj_timescale->get_upper(),
-                       current = adj_timescale->get_value();
-
-       double focuspoint = centerontime ? current : (start + end)/2;
-
-       //calculate new beginning and end
-       end = focuspoint + (end-focuspoint)*zoomoutfactor;
-       start = focuspoint + (start-focuspoint)*zoomoutfactor;
-
-       //synfig::info("Zooming out timerange to (%.4f,%.4f)",start,end);
-       if(adj_bounds)
-       {
-               if(start < adj_bounds->get_lower())
-               {
-                       start = adj_bounds->get_lower();
-               }
-
-               if(end > adj_bounds->get_upper())
-               {
-                       end = adj_bounds->get_upper();
-               }
-       }
-
-       //reset values
-       adj_timescale->set_lower(start);
-       adj_timescale->set_upper(end);
-
-       //call changed function
-       adj_timescale->changed();
-}
-
-bool Widget_Timeslider::on_button_press_event(GdkEventButton *event) //for clicking
-{
-       switch(event->button)
-       {
-               //time click...
-               case 1:
-               {
-                       double  start = adj_timescale->get_lower(),
-                                       end = adj_timescale->get_upper(),
-                                       current = adj_timescale->get_value();
-
-                       double w = get_width();
-                       double t = start + (end - start) * event->x / w;
-
-                       t = floor(t*fps + 0.5)/fps;
-
-                       /*synfig::info("Clicking time from %.3lf to %.3lf [(%.2lf,%.2lf) %.2lf / %.2lf ... %.2lf",
-                                               current, vt, start, end, event->x, w, fps);*/
-
-                       if(t != current)
-                       {
-                               current = t;
-
-                               if(adj_timescale)
-                               {
-                                       adj_timescale->set_value(current);
-                                       adj_timescale->value_changed();
-                               }
-                       }
-
-                       break;
-               }
-
-               //scroll click
-               case 2:
-               {
-                       //start dragging
-                       dragscroll = true;
-                       lastx = event->x;
-                       //lasty = event->y;
-
-                       return true;
-               }
-
-               default:
-               {
-                       break;
-               }
-       }
-
-       return false;
-}
-
-bool Widget_Timeslider::on_button_release_event(GdkEventButton *event) //end drag
-{
-       switch(event->button)
-       {
-               case 2:
-               {
-                       //start dragging
-                       dragscroll = false;
-                       return true;
-               }
-
-               default:
-               {
-                       break;
-               }
-       }
-
-       return false;
-}
diff --git a/synfig-studio/src/gtkmm/widget_timeslider.h b/synfig-studio/src/gtkmm/widget_timeslider.h
deleted file mode 100644 (file)
index 49cdc13..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_timeslider.h
-**     \brief Time Slider Widget Header
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2004 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_WIDGET_TIMESLIDER_H
-#define __SYNFIG_WIDGET_TIMESLIDER_H
-
-/* === H E A D E R S ======================================================= */
-#include <gtkmm/drawingarea.h>
-#include <gtkmm/adjustment.h>
-
-#include <synfig/time.h>
-#include "canvasview.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 {
-
-void render_time_point_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::TimePoint &tp,bool selected=false);
-
-
-/* Design for the timeslider...
-
-       Concept: Scalable ruler
-               Ticks are done every so often (30 s, 10 frames, 5 frames, etc.)
-               Print out frame numbers next to the big ticks
-               Show blue pills in separate area (above or below)
-*/
-
-class Widget_Timeslider : public Gtk::DrawingArea
-{
-protected: //implementation that other interfaces can see
-       Glib::RefPtr<Pango::Layout> layout; //implementation awesomeness for text drawing
-
-       Gtk::Adjustment adj_default;
-       Gtk::Adjustment *adj_timescale;
-
-       //HACK - I should not have to see this...
-       Gtk::Adjustment *adj_bounds;
-       double time_per_tickmark;
-
-       //Statistics used for drawing stuff (and making sure we don't if we don't need to)
-       /*double start,end;
-       double current;
-
-       bool invalidated;*/
-
-       guint32 last_event_time;
-
-       float fps;
-
-       sigc::connection time_value_change;
-       sigc::connection time_other_change;
-
-       //TODO: fill out blue pill stuff
-
-       //input functions
-
-       virtual bool on_motion_notify_event(GdkEventMotion* event); //for dragging
-       virtual bool on_scroll_event(GdkEventScroll* event); //for zooming
-       virtual bool on_button_press_event(GdkEventButton *event); //for clicking
-       virtual bool on_button_release_event(GdkEventButton *event); //for clicking
-
-       virtual bool on_expose_event(GdkEventExpose */*event*/) {redraw(); return true;}//for drawing
-
-       virtual bool redraw(bool doublebuffer = false);
-
-       //void update_times();
-
-       void zoom_in(bool centerontime = false);
-       void zoom_out(bool centerontime = false);
-
-       //Drag the Frame
-       bool dragscroll;
-
-       /*NOTE: if we can set the mouse position to the original position
-                       this would only have to be set once (and it would be good otherwise too)
-       */
-       double lastx; //last mouse position for dragging
-
-public: //structors
-       Widget_Timeslider();
-       ~Widget_Timeslider();
-
-public: //Normal Interface
-
-       void draw() {redraw();}
-       virtual void refresh(); //reget bluepills, time values and queue_draw if need be
-
-public: //Time Interface
-
-       //Run FPS stuff through it to the MAX
-       double get_global_fps() const {return fps;}
-       void set_global_fps(float d);
-
-       //accessors for the time adjustment
-       Gtk::Adjustment &get_time_adjustment() const {return *adj_timescale;}
-       void set_time_adjustment(Gtk::Adjustment *x);
-
-       //HACK - I should not have to see these bounds (should be boundless)
-       Gtk::Adjustment &get_bounds_adjustment() const {return *adj_bounds;}
-       void set_bounds_adjustment(Gtk::Adjustment *x) {adj_bounds = x;}
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/widget_value.cpp b/synfig-studio/src/gtkmm/widget_value.cpp
deleted file mode 100644 (file)
index c6a8b97..0000000
+++ /dev/null
@@ -1,486 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_value.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include <gtkmm/label.h>
-#include "widget_value.h"
-#include <ETL/stringf>
-#include <gtkmm/celleditable.h>
-#include <gtkmm/editable.h>
-#include <gtkmm/entry.h>
-#include <gtkmm/eventbox.h>
-#include <gtk/gtkentry.h> /* see XXX below */
-#include "app.h"
-
-
-#include "widget_vector.h"
-#include "widget_filename.h"
-#include "widget_enum.h"
-#include "widget_coloredit.h"
-#include "widget_canvaschooser.h"
-#include "widget_time.h"
-#include "app.h"
-#include "widget_distance.h"
-
-#include "general.h"
-
-#endif
-
-using namespace synfig;
-using namespace etl;
-using namespace std;
-using namespace studio;
-
-/* === M A C R O S ========================================================= */
-
-#define DIGITS         15
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Widget_ValueBase::Widget_ValueBase():
-       Glib::ObjectBase        (typeid(Widget_ValueBase)),
-       Gtk::HBox(),
-       real_adjustment(0,-2000000000,2000000000,0.05,0.05,0),
-       integer_adjustment(0,-2000000000,2000000000,1,1,0),
-       angle_adjustment(0,-2000000000,2000000000,1,1,0)
-{
-       set_no_show_all();
-
-       label=manage(new class Gtk::Label("Unknown Datatype"));
-       pack_start(*label);
-       label->show();
-
-       vector_widget=manage(new class Widget_Vector());
-       pack_start(*vector_widget);
-
-       color_widget=manage(new class Widget_ColorEdit());
-       pack_start(*color_widget);
-
-       enum_widget=manage(new class Widget_Enum());
-       pack_start(*enum_widget);
-
-       real_widget=manage(new class Gtk::SpinButton(real_adjustment,0.05,DIGITS));
-       pack_start(*real_widget);
-
-       integer_widget=manage(new class Gtk::SpinButton(integer_adjustment,1,0));
-       pack_start(*integer_widget);
-
-       angle_widget=manage(new class Gtk::SpinButton(angle_adjustment,15,2));
-       pack_start(*angle_widget);
-
-       bool_widget=manage(new class Gtk::CheckButton());
-       pack_start(*bool_widget);
-
-       //color_widget=manage(new class Gtk::ColorSelection());
-       //pack_start(*color_widget);
-
-       string_widget=manage(new class Gtk::Entry());
-       pack_start(*string_widget);
-
-       canvas_widget=manage(new class Widget_CanvasChooser());
-       pack_start(*canvas_widget);
-
-       filename_widget=manage(new class Widget_Filename());
-       pack_start(*filename_widget);
-
-       time_widget=manage(new class Widget_Time());
-       pack_start(*time_widget);
-
-       distance_widget=manage(new class Widget_Distance());
-       pack_start(*distance_widget);
-
-
-       vector_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
-       color_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
-       enum_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
-       real_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
-       integer_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
-       angle_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
-       string_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
-       canvas_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
-       filename_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
-       time_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
-       distance_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
-
-       /*signal_focus_in_event().connect(
-               sigc::bind_return(
-               sigc::hide(
-                       sigc::mem_fun(*this,&Widget_ValueBase::grab_focus)
-               ),false
-               )
-       );*/
-}
-
-Widget_ValueBase::~Widget_ValueBase()
-{
-}
-
-void
-Widget_ValueBase::activate()
-{
-       signal_activate()();
-}
-
-void
-Widget_ValueBase::inside_cellrenderer()
-{
-       string_widget->set_has_frame(false);
-       string_widget->gobj()->is_cell_renderer = true; // XXX
-
-       real_widget->set_has_frame(false);
-       //static_cast<Gtk::Entry*>(real_widget)->gobj()->is_cell_renderer = true; // XXX
-
-       distance_widget->set_has_frame(false);
-       //static_cast<Gtk::Entry*>(distance_widget)->gobj()->is_cell_renderer = true; // XXX
-
-       integer_widget->set_has_frame(false);
-       //static_cast<Gtk::Entry*>(integer_widget)->gobj()->is_cell_renderer = true; // XXX
-       vector_widget->set_has_frame(false);
-    //vector_widget->set_digits(10);
-
-       color_widget->set_has_frame(false);
-    //color_widget->set_digits(10);
-       filename_widget->set_has_frame(false);
-       time_widget->set_has_frame(false);
-}
-
-void
-Widget_ValueBase::set_sensitive(bool x)
-{
-       Gtk::HBox::set_sensitive(x);
-       label->set_sensitive(x);
-       vector_widget->set_sensitive(x);
-       real_widget->set_sensitive(x);
-       integer_widget->set_sensitive(x);
-       bool_widget->set_sensitive(x);
-    color_widget->set_sensitive(x);
-       string_widget->set_sensitive(x);
-       canvas_widget->set_sensitive(x);
-       enum_widget->set_sensitive(x);
-       angle_widget->set_sensitive(x);
-       filename_widget->set_sensitive(x);
-       time_widget->set_sensitive(x);
-       distance_widget->set_sensitive(x);
-}
-
-void
-Widget_ValueBase::set_value(const synfig::ValueBase &data)
-{
-       label->hide();
-       vector_widget->hide();
-       real_widget->hide();
-       integer_widget->hide();
-       bool_widget->hide();
-    color_widget->hide();
-       string_widget->hide();
-       canvas_widget->hide();
-       enum_widget->hide();
-       angle_widget->hide();
-       filename_widget->hide();
-       time_widget->hide();
-       distance_widget->hide();
-
-       value=data;
-       try{
-       switch(value.get_type())
-       {
-       case ValueBase::TYPE_VECTOR:
-               vector_widget->set_canvas(canvas);
-               vector_widget->set_value(value.get(Vector()));
-               vector_widget->show();
-               break;
-       case ValueBase::TYPE_REAL:
-               if(param_desc.get_is_distance() && canvas)
-               {
-                       Distance dist(value.get(Real()),Distance::SYSTEM_UNITS);
-                       dist.convert(App::distance_system,canvas->rend_desc());
-                       distance_widget->set_value(dist);
-                       distance_widget->show();
-               }
-               else
-               {
-                       real_widget->set_value(value.get(Real()));
-                       real_widget->show();
-               }
-               break;
-       case ValueBase::TYPE_TIME:
-               if(canvas)time_widget->set_fps(canvas->rend_desc().get_frame_rate());
-               time_widget->set_value(value.get(Time()));
-               time_widget->show();
-               break;
-       case ValueBase::TYPE_ANGLE:
-               angle_widget->set_value(Angle::deg(value.get(Angle())).get());
-               angle_widget->show();
-               break;
-       case ValueBase::TYPE_INTEGER:
-               if(param_desc.get_hint()!="enum")
-               {
-                       integer_widget->set_value(value.get(int()));
-                       integer_widget->show();
-               }
-               else
-               {
-                       enum_widget->set_param_desc(param_desc);
-                       enum_widget->set_value(value.get(int()));
-                       enum_widget->show();
-               }
-               break;
-       case ValueBase::TYPE_CANVAS:
-               assert(canvas);
-               canvas_widget->set_parent_canvas(canvas);
-               canvas_widget->set_value(value.get(etl::loose_handle<synfig::Canvas>()));
-               canvas_widget->show();
-               break;
-       case ValueBase::TYPE_BOOL:
-               bool_widget->set_active(value.get(bool()));
-               bool_widget->show();
-               break;
-       case ValueBase::TYPE_STRING:
-               if(param_desc.get_hint()!="filename")
-               {
-                       string_widget->set_text(value.get(string()));
-                       string_widget->show();
-               }
-               else
-               {
-                       filename_widget->set_value(value.get(string()));
-                       filename_widget->show();
-               }
-               break;
-       case ValueBase::TYPE_COLOR:
-        {
-               color_widget->set_value(value.get(synfig::Color()));
-               color_widget->show();
-/*
-                       Gdk::Color gdkcolor;
-                       synfig::Color color=value.get(synfig::Color());
-                       gdkcolor.set_rgb_p(color.get_r(),color.get_g(),color.get_b());
-                       color_widget->set_current_color(gdkcolor);
-                       color_widget->set_has_opacity_control(true);
-                       color_widget->set_current_alpha((unsigned short)(color.get_a()*65535.0));
-                       color_widget->show();
-*/
-               }
-               break;
-       default:
-               label->show();
-               break;
-       }
-       }catch(...) { synfig::error(__FILE__":%d: Caught something that was thrown",__LINE__); }
-}
-
-const synfig::ValueBase &
-Widget_ValueBase::get_value()
-{
-       switch(value.get_type())
-       {
-       case ValueBase::TYPE_VECTOR:
-               value=vector_widget->get_value();
-               break;
-       case ValueBase::TYPE_REAL:
-               if(param_desc.get_is_distance() && canvas)
-                       value=distance_widget->get_value().units(canvas->rend_desc());
-               else
-                       value=real_widget->get_value();
-               break;
-       case ValueBase::TYPE_TIME:
-               value=time_widget->get_value();
-               break;
-       case ValueBase::TYPE_ANGLE:
-               value=Angle::deg(angle_widget->get_value());
-               break;
-       case ValueBase::TYPE_CANVAS:
-               value=canvas_widget->get_value();
-               break;
-       case ValueBase::TYPE_INTEGER:
-               if(param_desc.get_hint()!="enum")
-               {
-                       value=integer_widget->get_value_as_int();
-               }
-               else
-               {
-                       value=enum_widget->get_value();
-               }
-
-               break;
-       case ValueBase::TYPE_BOOL:
-               value=bool_widget->get_active();
-               break;
-       case ValueBase::TYPE_STRING:
-               if(param_desc.get_hint()!="filename")
-               {
-                       value=string(string_widget->get_text());
-               }
-               else
-               {
-                       value=string(filename_widget->get_value());
-               }
-               break;
-       case ValueBase::TYPE_COLOR:
-        {
-                       value=color_widget->get_value();
-/*
-                       Gdk::Color gdkcolor;
-                       synfig::Color color;
-                       gdkcolor=color_widget->get_current_color();
-                       color.set_r(gdkcolor.get_red_p());
-            color.set_g(gdkcolor.get_green_p());
-            color.set_b(gdkcolor.get_blue_p());
-                       color.set_a(color_widget->get_current_alpha()/65535.0);
-
-                       value=color;
-*/
-               }
-               break;
-       default:
-               break;
-       }
-
-       return value;
-}
-
-
-void
-Widget_ValueBase::on_grab_focus()
-{
-       switch(value.get_type())
-       {
-       case ValueBase::TYPE_VECTOR:
-               vector_widget->grab_focus();
-               break;
-       case ValueBase::TYPE_REAL:
-               if(param_desc.get_is_distance()&& canvas)
-                       distance_widget->grab_focus();
-               else
-                       real_widget->grab_focus();
-               break;
-       case ValueBase::TYPE_TIME:
-               time_widget->grab_focus();
-               break;
-       case ValueBase::TYPE_ANGLE:
-               angle_widget->grab_focus();
-               break;
-       case ValueBase::TYPE_CANVAS:
-               canvas_widget->grab_focus();
-               break;
-       case ValueBase::TYPE_INTEGER:
-               if(param_desc.get_hint()!="enum")
-               {
-                       integer_widget->grab_focus();
-               }
-               else
-               {
-                       enum_widget->grab_focus();
-               }
-
-               break;
-       case ValueBase::TYPE_BOOL:
-               bool_widget->grab_focus();
-               break;
-       case ValueBase::TYPE_STRING:
-               if(param_desc.get_hint()!="filename")
-               {
-                       string_widget->grab_focus();
-               }
-               else
-               {
-                       filename_widget->grab_focus();
-               }
-               break;
-       case ValueBase::TYPE_COLOR:
-        {
-                       color_widget->grab_focus();
-               }
-               break;
-       default:
-               break;
-       }
-}
-
-/*
-Glib::SignalProxy0<void>
-Widget_ValueBase::signal_activate()
-{
-       switch(value.get_type())
-       {
-       case ValueBase::TYPE_VECTOR:
-               return vector_widget->signal_activate();
-               break;
-       case ValueBase::TYPE_REAL:
-               if(param_desc.get_is_distance()&& canvas)
-                       return distance_widget->signal_activate();
-               else
-                       return real_widget->signal_activate();
-
-               break;
-       case ValueBase::TYPE_TIME:
-               return time_widget->signal_activate();
-               break;
-       case ValueBase::TYPE_ANGLE:
-               return angle_widget->signal_activate();
-               break;
-       case ValueBase::TYPE_CANVAS:
-               return canvas_widget->signal_activate();
-               break;
-       case ValueBase::TYPE_INTEGER:
-               if(param_desc.get_hint()!="enum")
-                       return integer_widget->signal_activate();
-               else
-                       return enum_widget->signal_activate();
-
-               break;
-       case ValueBase::TYPE_BOOL:
-               return string_widget->signal_activate();
-               break;
-       case ValueBase::TYPE_STRING:
-               if(param_desc.get_hint()!="filename")
-               {
-                       return string_widget->signal_activate();
-               }
-               else
-               {
-                       return filename_widget->signal_activate();
-               }
-               break;
-       case ValueBase::TYPE_COLOR:
-        {
-                       return color_widget->signal_activate();
-               }
-               break;
-       default:
-               return string_widget->signal_activate();
-               break;
-       }
-}
-*/
diff --git a/synfig-studio/src/gtkmm/widget_value.h b/synfig-studio/src/gtkmm/widget_value.h
deleted file mode 100644 (file)
index 99bdf5b..0000000
+++ /dev/null
@@ -1,136 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_value.h
-**     \brief Template File
-**
-**     $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_GTKMM_VALUE_H
-#define __SYNFIG_GTKMM_VALUE_H
-
-/* === H E A D E R S ======================================================= */
-
-//#include <gtk/gtk.h>
-//#include <gtkmm/ruler.h>
-//#include <gtkmm/arrow.h>
-//#include <gtkmm/image.h>
-//#include <gdkmm/pixbufloader.h>
-//#include <gtkmm/viewport.h>
-#include <gtkmm/adjustment.h>
-//#include <gtkmm/scrolledwindow.h>
-#include <gtkmm/table.h>
-//#include <gtkmm/statusbar.h>
-#include <gtkmm/button.h>
-#include <gtkmm/label.h>
-//#include <gtkmm/paned.h>
-//#include <gtkmm/treeview.h>
-//#include <gtkmm/treestore.h>
-#include <gtkmm/box.h>
-#include <gtkmm/spinbutton.h>
-//#include <gtkmm/cellrenderer.h>
-#include <gtkmm/checkbutton.h>
-
-//#include <gtkmm/colorselection.h>
-#include <gtkmm/optionmenu.h>
-
-//#include <synfig/synfig.h>
-#include <synfig/paramdesc.h>
-#include <synfig/value.h>
-#include <synfig/canvas.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 Widget_Color;
-class Widget_ColorEdit;
-class Widget_CanvasChooser;
-class Widget_Enum;
-class Widget_Filename;
-class Widget_Vector;
-class Widget_Time;
-class Widget_Distance;
-
-class Widget_ValueBase : public Gtk::HBox
-{
-       Gtk::Label *label;
-       synfig::ValueBase value;
-
-       Widget_Vector *vector_widget;
-       Gtk::SpinButton *real_widget;
-       Gtk::Adjustment real_adjustment;
-       Gtk::SpinButton *integer_widget;
-       Gtk::Adjustment integer_adjustment;
-       Gtk::SpinButton *angle_widget;
-       Gtk::Adjustment angle_adjustment;
-
-       Gtk::CheckButton *bool_widget;
-       //Gtk::ColorSelection *color_widget;
-       Widget_ColorEdit *color_widget;
-       Widget_CanvasChooser *canvas_widget;
-       Widget_Enum *enum_widget;
-       Widget_Filename *filename_widget;
-       Widget_Time *time_widget;
-       Gtk::Entry *string_widget;
-       Widget_Distance *distance_widget;
-
-//     std::string hint;
-
-       synfig::ParamDesc param_desc;
-       etl::handle<synfig::Canvas> canvas;
-       sigc::signal<void> signal_value_changed_;
-       sigc::signal<void> signal_activate_;
-
-public:
-       sigc::signal<void> &signal_value_changed() { return signal_value_changed_; }
-
-       void activate();
-
-       sigc::signal<void>& signal_activate() { return signal_activate_; }
-
-       void set_value(const synfig::ValueBase &data);
-       const synfig::ValueBase &get_value();
-
-       void on_grab_focus();
-
-       void set_param_desc(const synfig::ParamDesc &x) { param_desc=x; }
-       const synfig::ParamDesc &get_param_desc() { return param_desc; }
-
-       void set_sensitive(bool x);
-
-       //void set_hint(std::string x) { hint=x; }
-//     std::string get_hint() { return hint; }
-
-       void set_canvas(etl::handle<synfig::Canvas> x) { canvas=x; assert(canvas); }
-       void inside_cellrenderer();
-       Widget_ValueBase();
-       ~Widget_ValueBase();
-};
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/widget_vector.cpp b/synfig-studio/src/gtkmm/widget_vector.cpp
deleted file mode 100644 (file)
index f905d34..0000000
+++ /dev/null
@@ -1,244 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_vector.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include <gtkmm/spinbutton.h>
-#include "widget_vector.h"
-#include "widget_distance.h"
-#include "app.h"
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace synfig;
-using namespace studio;
-
-/* === M A C R O S ========================================================= */
-
-#define DIGITS         10
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Widget_Vector::Widget_Vector():
-       Gtk::HBox(false, 5),
-       x_adjustment(0,-100000000,100000000,0.05,0.05,0),
-       y_adjustment(0,-100000000,100000000,0.05,0.05,0)
-{
-       Gtk::Label *label;
-
-       label=manage(new class Gtk::Label("X:"));
-       label->set_alignment(0, 0.5);
-       label->show();
-       pack_start(*label, Gtk::PACK_SHRINK);
-
-       spinbutton_x=manage(new class Gtk::SpinButton(x_adjustment,0.05,DIGITS));
-       spinbutton_x->set_alignment(1);
-       spinbutton_x->set_update_policy(Gtk::UPDATE_ALWAYS);
-       spinbutton_x->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Vector::on_value_changed));
-       pack_start(*spinbutton_x, Gtk::PACK_EXPAND_WIDGET);
-
-       distance_x=manage(new Widget_Distance());
-       distance_x->set_digits(4);
-       distance_x->set_update_policy(Gtk::UPDATE_ALWAYS);
-       distance_x->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Vector::on_value_changed));
-       pack_start(*distance_x, Gtk::PACK_EXPAND_WIDGET);
-
-       label=manage(new class Gtk::Label("Y:"));
-       label->set_alignment(0, 0.5);
-       label->show();
-       pack_start(*label, Gtk::PACK_SHRINK);
-
-       spinbutton_y=manage(new class Gtk::SpinButton(y_adjustment,0.05,DIGITS));
-       spinbutton_y->set_alignment(1);
-       spinbutton_y->set_update_policy(Gtk::UPDATE_ALWAYS);
-       spinbutton_y->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Vector::on_value_changed));
-       spinbutton_y->signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Vector::activate));
-       pack_start(*spinbutton_y, Gtk::PACK_EXPAND_WIDGET);
-
-       distance_y=manage(new Widget_Distance());
-       distance_y->set_digits(4);
-       distance_y->set_update_policy(Gtk::UPDATE_ALWAYS);
-       distance_y->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Vector::on_value_changed));
-       distance_y->signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Vector::activate));
-       pack_start(*distance_y, Gtk::PACK_EXPAND_WIDGET);
-
-       spinbutton_x->show();
-       spinbutton_y->show();
-
-       spinbutton_x->signal_activate().connect(sigc::mem_fun(*spinbutton_y,&Gtk::SpinButton::grab_focus));
-       distance_x->signal_activate().connect(sigc::mem_fun(*distance_y,&Gtk::SpinButton::grab_focus));
-}
-
-Widget_Vector::~Widget_Vector()
-{
-}
-
-void
-Widget_Vector::on_grab_focus()
-{
-       if(canvas_)
-               distance_x->grab_focus();
-       else
-               spinbutton_x->grab_focus();
-}
-
-void
-Widget_Vector::set_has_frame(bool x)
-{
-       if(spinbutton_x)
-       {
-               spinbutton_x->set_has_frame(x);
-               spinbutton_y->set_has_frame(x);
-               spinbutton_x->set_size_request(48,-1);
-               spinbutton_y->set_size_request(48,-1);
-       }
-
-       distance_x->set_has_frame(x);
-       distance_y->set_has_frame(x);
-       distance_x->set_size_request(48,-1);
-       distance_y->set_size_request(48,-1);
-}
-
-void
-Widget_Vector::set_digits(int x)
-{
-       if(spinbutton_x)
-       {
-               spinbutton_x->set_digits(x);
-               spinbutton_y->set_digits(x);
-               spinbutton_x->set_size_request(48,-1);
-               spinbutton_y->set_size_request(48,-1);
-       }
-
-       distance_x->set_digits(x);
-       distance_y->set_digits(x);
-       distance_x->set_size_request(48,-1);
-       distance_y->set_size_request(48,-1);
-}
-
-void
-Widget_Vector::set_value(const synfig::Vector &data)
-{
-       vector=data;
-
-       if(canvas_){try
-       {
-               Distance distx(vector[0],Distance::SYSTEM_UNITS),disty(vector[1],Distance::SYSTEM_UNITS);
-               distx.convert(App::distance_system,canvas_->rend_desc());
-               disty.convert(App::distance_system,canvas_->rend_desc());
-               distance_x->set_value(distx);
-               distance_y->set_value(disty);
-               spinbutton_x->hide();
-               spinbutton_y->hide();
-       }catch(...) { synfig::error("Widget_Vector::set_value(): Caught something that was thrown"); }}
-       else
-       {
-               spinbutton_x->set_value(vector[0]);
-               spinbutton_y->set_value(vector[1]);
-               distance_x->hide();
-               distance_y->hide();
-       }
-}
-
-const synfig::Vector &
-Widget_Vector::get_value()
-{
-       if(!canvas_ && spinbutton_x)
-       {
-               vector[0]=spinbutton_x->get_value();
-               vector[1]=spinbutton_y->get_value();
-               distance_x->hide();
-               distance_y->hide();
-       }
-       else try
-       {
-               vector[0]=distance_x->get_value().units(canvas_->rend_desc());
-               vector[1]=distance_y->get_value().units(canvas_->rend_desc());
-               spinbutton_x->hide();
-               spinbutton_y->hide();
-       }catch(...) { synfig::error("Widget_Vector::set_value(): Caught something that was thrown"); }
-       return vector;
-}
-
-void
-Widget_Vector::on_value_changed()
-{
-       signal_value_changed()();
-}
-
-void
-Widget_Vector::set_canvas(synfig::Canvas::LooseHandle x)
-{
-       canvas_=x;
-       if(x)
-       {
-               if(spinbutton_x)
-               {
-                       spinbutton_x->hide();
-                       spinbutton_y->hide();
-               }
-               distance_x->show();
-               distance_y->show();
-       }
-       else
-       {
-               if(spinbutton_x)
-               {
-                       spinbutton_x->show();
-                       spinbutton_y->show();
-               }
-               distance_x->hide();
-               distance_y->hide();
-       }
-}
-
-void
-Widget_Vector::show_all_vfunc()
-{
-       if(canvas_)
-       {
-               distance_x->show();
-               distance_y->show();
-       }
-       else
-       {
-               spinbutton_x->show();
-               spinbutton_y->show();
-       }
-       show();
-}
diff --git a/synfig-studio/src/gtkmm/widget_vector.h b/synfig-studio/src/gtkmm/widget_vector.h
deleted file mode 100644 (file)
index 36ccbbe..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_vector.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_WIDGET_VECTOR_H
-#define __SYNFIG_STUDIO_WIDGET_VECTOR_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/box.h>
-#include <gtkmm/adjustment.h>
-#include <synfig/vector.h>
-#include <synfig/distance.h>
-#include <synfig/canvas.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 Gtk { class SpinButton; };
-
-namespace studio {
-
-class Widget_Distance;
-
-class Widget_Vector : public Gtk::HBox
-{
-       Gtk::SpinButton* spinbutton_x;
-       Gtk::SpinButton* spinbutton_y;
-
-       Widget_Distance* distance_x;
-       Widget_Distance* distance_y;
-
-       Gtk::Adjustment x_adjustment;
-       Gtk::Adjustment y_adjustment;
-
-       synfig::Vector vector;
-
-       sigc::signal<void> signal_value_changed_;
-
-       sigc::signal<void> signal_activate_;
-
-       synfig::Canvas::LooseHandle canvas_;
-
-public:
-
-       void activate() { signal_activate_(); }
-
-       void set_canvas(synfig::Canvas::LooseHandle);
-       synfig::Canvas::LooseHandle get_canvas()const { return canvas_; }
-
-       sigc::signal<void>& signal_value_changed() { return signal_value_changed_; }
-
-       sigc::signal<void>& signal_activate() { return signal_activate_; }
-
-       void on_value_changed();
-       void on_grab_focus();
-
-       void set_value(const synfig::Vector &data);
-       const synfig::Vector &get_value();
-       void set_has_frame(bool x);
-       void set_digits(int x);
-       Widget_Vector();
-       ~Widget_Vector();
-
-protected:
-       void show_all_vfunc();
-}; // END of class Widget_Vector
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/widget_waypoint.cpp b/synfig-studio/src/gtkmm/widget_waypoint.cpp
deleted file mode 100644 (file)
index d456130..0000000
+++ /dev/null
@@ -1,281 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_waypoint.cpp
-**     \brief Template Header
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2008 Chris Moore
-**  Copyright (c) 2008 Paul Wise
-**
-**     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 <config.h>
-#endif
-
-#include <gtkmm/label.h>
-#include <gtkmm/frame.h>
-#include <gtkmm/alignment.h>
-#include "dialog_waypoint.h"
-#include <gtk/gtk.h>
-#include <gtkmm/spinbutton.h>
-#include <gtkmm/combo.h>
-#include <ETL/stringf>
-#include "widget_value.h"
-#include "app.h"
-#include <gtkmm/menu.h>
-#include <gtkmm/optionmenu.h>
-#include "widget_time.h"
-#include "widget_waypoint.h"
-#include "general.h"
-
-#endif
-
-using namespace synfig;
-using namespace std;
-using namespace etl;
-using namespace studio;
-
-/* === M A C R O S ========================================================= */
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Widget_Waypoint::Widget_Waypoint(etl::handle<synfig::Canvas> canvas):
-       Gtk::Alignment(0, 0, 1, 1),
-       waypoint(synfig::ValueBase(),0),
-       adj_tension(0.0,-20,20,0.1,1),
-       adj_continuity(0.0,-20,20,0.1,1),
-       adj_bias(0.0,-20,20,0.1,1),
-       adj_temporal_tension(0.0,-20,20,0.1,1)
-{
-       value_widget=manage(new Widget_ValueBase());
-       value_widget->set_canvas(canvas);
-       value_widget->show();
-
-       value_node_label=manage(new Gtk::Label(_("(Non-static value)")));
-
-
-       time_widget=manage(new Widget_Time());
-       time_widget->set_fps(canvas->rend_desc().get_frame_rate());
-       //spinbutton=manage(new Gtk::SpinButton(time_adjustment,0.05,3));
-       //spinbutton->set_update_policy(Gtk::UPDATE_ALWAYS);
-       //spinbutton->show();
-
-       before_options=manage(new class Gtk::Menu());
-       before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("TCB Smooth")));
-       before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Constant")));
-       before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Linear")));
-       before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Ease In")));
-       // before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Manual")));
-
-       after_options=manage(new class Gtk::Menu());
-       after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("TCB Smooth")));
-       after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Constant")));
-       after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Linear")));
-       after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Ease Out")));
-       // after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Manual")));
-
-       before=manage(new class Gtk::OptionMenu());
-       before->show();
-       before->set_menu(*before_options);
-
-       after=manage(new class Gtk::OptionMenu());
-       after->show();
-       after->set_menu(*after_options);
-
-       spin_tension=manage(new class Gtk::SpinButton(adj_tension,0.1,3));
-       spin_tension->show();
-       spin_continuity=manage(new class Gtk::SpinButton(adj_continuity,0.1,3));
-       spin_continuity->show();
-       spin_bias=manage(new class Gtk::SpinButton(adj_bias,0.1,3));
-       spin_bias->show();
-       spin_temporal_tension=manage(new class Gtk::SpinButton(adj_temporal_tension,0.1,3));
-       spin_temporal_tension->show();
-
-       set_padding(12, 12, 12, 12);
-
-       Gtk::VBox *widgetBox = manage(new Gtk::VBox(false, 12));
-       add(*widgetBox);
-
-       Gtk::Frame *waypointFrame = manage(new Gtk::Frame(_("Waypoint")));
-       waypointFrame->set_shadow_type(Gtk::SHADOW_NONE);
-       ((Gtk::Label *) waypointFrame->get_label_widget())->set_markup(_("<b>Waypoint</b>"));
-       widgetBox->pack_start(*waypointFrame, false, false, 0);
-
-       Gtk::Alignment *waypointPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
-       waypointPadding->set_padding(6, 0, 24, 0);
-       waypointFrame->add(*waypointPadding);
-
-       Gtk::Table *waypointTable = manage(new Gtk::Table(2, 2, false));
-       waypointTable->set_row_spacings(6);
-       waypointTable->set_col_spacings(12);
-       waypointPadding->add(*waypointTable);
-
-       Gtk::Label *waypointValueLabel = manage(new Gtk::Label(_("_Value"), true));
-       waypointValueLabel->set_alignment(0, 0.5);
-       waypointValueLabel->set_mnemonic_widget(*value_widget);
-       waypointTable->attach(*waypointValueLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       waypointTable->attach(*value_widget, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       waypointTable->attach(*value_node_label, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
-       Gtk::Label *waypointTimeLabel = manage(new Gtk::Label(_("_Time"), true));
-       waypointTimeLabel->set_alignment(0, 0.5);
-       waypointTimeLabel->set_mnemonic_widget(*time_widget);
-       waypointTable->attach(*waypointTimeLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       waypointTable->attach(*time_widget, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
-       Gtk::Frame *interpolationFrame = manage(new Gtk::Frame(_("Interpolation")));
-       interpolationFrame->set_shadow_type(Gtk::SHADOW_NONE);
-       ((Gtk::Label *) interpolationFrame->get_label_widget())->set_markup(_("<b>Interpolation</b>"));
-       widgetBox->pack_start(*interpolationFrame, false, false, 0);
-
-       Gtk::Alignment *interpolationPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
-       interpolationPadding->set_padding(6, 0, 24, 0);
-       interpolationFrame->add(*interpolationPadding);
-
-       Gtk::Table *interpolationTable = manage(new Gtk::Table(2, 2, false));
-       interpolationTable->set_row_spacings(6);
-       interpolationTable->set_col_spacings(12);
-       interpolationPadding->add(*interpolationTable);
-
-       Gtk::Label *interpolationInLabel = manage(new Gtk::Label(_("_In Interpolation"), true));
-       interpolationInLabel->set_alignment(0, 0.5);
-       interpolationInLabel->set_mnemonic_widget(*before);
-       interpolationTable->attach(*interpolationInLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       interpolationTable->attach(*before, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
-       Gtk::Label *interpolationOutLabel = manage(new Gtk::Label(_("_Out Interpolation"), true));
-       interpolationOutLabel->set_alignment(0, 0.5);
-       interpolationOutLabel->set_mnemonic_widget(*after);
-       interpolationTable->attach(*interpolationOutLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       interpolationTable->attach(*after, 1, 2, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
-       Gtk::Frame *tcbFrame = manage(new Gtk::Frame(_("TCB Parameters")));
-       tcbFrame->set_shadow_type(Gtk::SHADOW_NONE);
-       ((Gtk::Label *) tcbFrame->get_label_widget())->set_markup(_("<b>TCB Parameter</b>"));
-       widgetBox->pack_start(*tcbFrame, false, false, 0);
-
-       Gtk::Alignment *tcbPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
-       tcbPadding->set_padding(6, 0, 24, 0);
-       tcbFrame->add(*tcbPadding);
-
-       Gtk::Table *tcbTable = manage(new Gtk::Table(4, 2, false));
-       tcbTable->set_row_spacings(6);
-       tcbTable->set_col_spacings(12);
-       tcbPadding->add(*tcbTable);
-
-       Gtk::Label *tensionLabel = manage(new Gtk::Label(_("T_ension"), true));
-       tensionLabel->set_alignment(0, 0.5);
-       tensionLabel->set_mnemonic_widget(*spin_tension);
-       spin_tension->set_alignment(1);
-       tcbTable->attach(*tensionLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       tcbTable->attach(*spin_tension, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
-       Gtk::Label *continuityLabel = manage(new Gtk::Label(_("_Continuity"), true));
-       continuityLabel->set_alignment(0, 0.5);
-       continuityLabel->set_mnemonic_widget(*spin_continuity);
-       spin_continuity->set_alignment(1);
-       tcbTable->attach(*continuityLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       tcbTable->attach(*spin_continuity, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
-       Gtk::Label *biasLabel = manage(new Gtk::Label(_("_Bias"), true));
-       biasLabel->set_alignment(0, 0.5);
-       biasLabel->set_mnemonic_widget(*spin_bias);
-       spin_bias->set_alignment(1);
-       tcbTable->attach(*biasLabel, 0, 1, 2, 3, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       tcbTable->attach(*spin_bias, 1, 2, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
-       Gtk::Label *temporalTensionLabel = manage(new Gtk::Label(_("Te_mporal Tension"), true));
-       temporalTensionLabel->set_alignment(0, 0.5);
-       temporalTensionLabel->set_mnemonic_widget(*spin_temporal_tension);
-       spin_temporal_tension->set_alignment(1);
-       tcbTable->attach(*temporalTensionLabel, 0, 1, 3, 4, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-       tcbTable->attach(*spin_temporal_tension, 1, 2, 3, 4, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
-
-       show_all();
-       hide();
-       //attach(*hbox, 1, 4, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       set_canvas(canvas);
-}
-
-void
-Widget_Waypoint::set_canvas(synfig::Canvas::Handle x)
-{
-       canvas=x;
-       assert(canvas);
-
-       time_widget->set_fps(canvas->rend_desc().get_frame_rate());
-       value_widget->set_canvas(canvas);
-}
-
-void
-Widget_Waypoint::set_waypoint(synfig::Waypoint &x)
-{
-       time_widget->set_fps(canvas->rend_desc().get_frame_rate());
-
-       waypoint=x;
-
-       //! \todo This really needs to be fixed to support value node waypoints!
-       if(waypoint.is_static())
-       {
-               value_widget->set_value(waypoint.get_value());
-               value_widget->show();
-               value_node_label->hide();
-       }
-       else
-       {
-               value_widget->hide();
-               value_node_label->show();
-       }
-
-       time_widget->set_value(waypoint.get_time());
-
-       before->set_history((int)waypoint.get_before());
-       after->set_history((int)waypoint.get_after());
-
-       adj_tension.set_value(waypoint.get_tension());
-       adj_continuity.set_value(waypoint.get_continuity());
-       adj_bias.set_value(waypoint.get_bias());
-       adj_temporal_tension.set_value(waypoint.get_temporal_tension());
-
-}
-const synfig::Waypoint &
-Widget_Waypoint::get_waypoint()const
-{
-       //! \todo This too!
-       waypoint.set_time(time_widget->get_value());
-       if(waypoint.is_static())
-               waypoint.set_value(value_widget->get_value());
-       //int i;
-
-       waypoint.set_before((synfig::Waypoint::Interpolation)before->get_history());
-       waypoint.set_after((synfig::Waypoint::Interpolation)after->get_history());
-
-       waypoint.set_tension(adj_tension.get_value());
-       waypoint.set_continuity(adj_continuity.get_value());
-       waypoint.set_bias(adj_bias.get_value());
-       waypoint.set_temporal_tension(adj_temporal_tension.get_value());
-       return waypoint;
-}
diff --git a/synfig-studio/src/gtkmm/widget_waypoint.h b/synfig-studio/src/gtkmm/widget_waypoint.h
deleted file mode 100644 (file)
index be87119..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_waypoint.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_GTKMM_WIDGET_WAYPOINT_H
-#define __SYNFIG_GTKMM_WIDGET_WAYPOINT_H
-
-/* === H E A D E R S ======================================================= */
-
-//#include <gtk/gtk.h>
-//#include <gtkmm/arrow.h>
-//#include <gtkmm/image.h>
-//#include <gdkmm/pixbufloader.h>
-//#include <gtkmm/viewport.h>
-#include <gtkmm/adjustment.h>
-//#include <gtkmm/scrolledwindow.h>
-#include <gtkmm/table.h>
-#include <gtkmm/button.h>
-//#include <gtkmm/progressbar.h>
-//#include <gtkmm/paned.h>
-#include <gtkmm/box.h>
-//#include <gtkmm/scrollbar.h>
-#include <gtkmm/combo.h>
-#include <gtkmm/optionmenu.h>
-#include <gtkmm/spinbutton.h>
-#include <gtkmm/alignment.h>
-
-#include <synfigapp/value_desc.h>
-#include <synfig/waypoint.h>
-//#include <synfig/valuenode_dynamiclist.h>
-#include <synfig/string.h>
-#include <synfig/time.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 Widget_ValueBase;
-class Widget_Time;
-class Widget_Waypoint;
-
-class Widget_Waypoint : public Gtk::Alignment
-{
-    Widget_ValueBase *value_widget;
-       Gtk::Label *value_node_label;
-       Gtk::Label *label;
-       Widget_Time *time_widget;
-       mutable synfig::Waypoint waypoint;
-       synfig::Canvas::Handle canvas;
-       //Gtk::Adjustment time_adjustment;
-
-       Gtk::Combo *in,*out;
-       Gtk::OptionMenu *before, *after;
-       Gtk::Menu *before_options,*after_options;
-
-       Gtk::SpinButton *spin_tension, *spin_continuity, *spin_bias, *spin_temporal_tension;
-       Gtk::Adjustment adj_tension, adj_continuity, adj_bias, adj_temporal_tension;
-//     Gtk::ComboDropDownItem item;
-
-public:
-       Widget_Waypoint(etl::handle<synfig::Canvas> canvas);
-       void set_canvas(synfig::Canvas::Handle x);
-       void set_waypoint(synfig::Waypoint &x);
-       const synfig::Waypoint &get_waypoint()const;
-}; // END of class Widget_Waypoint
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/widget_waypointmodel.cpp b/synfig-studio/src/gtkmm/widget_waypointmodel.cpp
deleted file mode 100644 (file)
index 28dacd5..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_waypointmodel.cpp
-**     \brief Template Header
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**  Copyright (c) 2008 Paul Wise
-**
-**     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 <config.h>
-#endif
-
-#include <gtkmm/label.h>
-#include <gtkmm/spinbutton.h>
-#include <ETL/stringf>
-#include "widget_value.h"
-#include "app.h"
-#include <gtkmm/menu.h>
-#include <gtkmm/optionmenu.h>
-#include "widget_time.h"
-#include "widget_waypointmodel.h"
-#include "general.h"
-
-#endif
-
-using namespace synfig;
-using namespace std;
-using namespace etl;
-using namespace studio;
-
-/* === M A C R O S ========================================================= */
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-Widget_WaypointModel::Widget_WaypointModel():
-       Gtk::Table(4,3,false),
-       adj_tension(0.0,-20,20,0.1,1),
-       adj_continuity(0.0,-20,20,0.1,1),
-       adj_bias(0.0,-20,20,0.1,1),
-       adj_temporal_tension(0.0,-20,20,0.1,1),
-       checkbutton_after(_("Out:")),
-       checkbutton_before(_("In:")),
-       checkbutton_tension(_("Tension:")),
-       checkbutton_continuity(_("Continuity:")),
-       checkbutton_bias(_("Bias:")),
-       checkbutton_temporal_tension(_("Temporal Tension:"))
-{
-       before_options=manage(new class Gtk::Menu());
-       before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("TCB Smooth")));
-       before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Constant")));
-       before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Linear")));
-       before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Ease In")));
-       // before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Manual")));
-
-       after_options=manage(new class Gtk::Menu());
-       after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("TCB Smooth")));
-       after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Constant")));
-       after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Linear")));
-       after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Ease Out")));
-       // after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Manual")));
-
-       before=manage(new class Gtk::OptionMenu());
-       before->show();
-       before->set_menu(*before_options);
-
-       after=manage(new class Gtk::OptionMenu());
-       after->show();
-       after->set_menu(*after_options);
-
-       spin_tension=manage(new class Gtk::SpinButton(adj_tension,0.1,3));
-       spin_tension->show();
-       spin_continuity=manage(new class Gtk::SpinButton(adj_continuity,0.1,3));
-       spin_continuity->show();
-       spin_bias=manage(new class Gtk::SpinButton(adj_bias,0.1,3));
-       spin_bias->show();
-       spin_temporal_tension=manage(new class Gtk::SpinButton(adj_temporal_tension,0.1,3));
-       spin_temporal_tension->show();
-
-       checkbutton_before.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
-       checkbutton_after.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
-       checkbutton_tension.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
-       checkbutton_continuity.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
-       checkbutton_bias.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
-       checkbutton_temporal_tension.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
-
-       adj_tension.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
-       adj_continuity.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
-       adj_bias.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
-       adj_temporal_tension.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
-
-       before->signal_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
-       after->signal_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
-
-       attach(checkbutton_before, 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       attach(*before, 1, 2, 0,1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       attach(checkbutton_after, 2, 3, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       attach(*after, 3, 4, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       attach(checkbutton_tension, 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       attach(*spin_tension, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       attach(checkbutton_continuity, 2, 3, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       attach(*spin_continuity, 3, 4, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       attach(checkbutton_bias, 0, 1, 2, 3, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       attach(*spin_bias, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       attach(checkbutton_temporal_tension, 2, 3, 2, 3, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       attach(*spin_temporal_tension, 3, 4, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       show_all();
-       hide();
-       updating=false;
-       on_change();
-}
-
-void
-Widget_WaypointModel::on_change()
-{
-       if(updating)
-               return;
-
-       waypoint_model.set_before((Waypoint::Interpolation)before->get_history());
-       waypoint_model.set_after((Waypoint::Interpolation)after->get_history());
-
-       waypoint_model.set_tension(adj_tension.get_value());
-       waypoint_model.set_continuity(adj_continuity.get_value());
-       waypoint_model.set_bias(adj_bias.get_value());
-       waypoint_model.set_temporal_tension(adj_temporal_tension.get_value());
-
-       waypoint_model.set_before_flag(checkbutton_before.get_active());
-       waypoint_model.set_after_flag(checkbutton_after.get_active());
-       waypoint_model.set_tension_flag(checkbutton_tension.get_active());
-       waypoint_model.set_continuity_flag(checkbutton_continuity.get_active());
-       waypoint_model.set_bias_flag(checkbutton_bias.get_active());
-       waypoint_model.set_temporal_tension_flag(checkbutton_temporal_tension.get_active());
-
-       before->set_sensitive(checkbutton_before.get_active());
-       after->set_sensitive(checkbutton_after.get_active());
-       spin_tension->set_sensitive(checkbutton_tension.get_active());
-       spin_continuity->set_sensitive(checkbutton_continuity.get_active());
-       spin_bias->set_sensitive(checkbutton_bias.get_active());
-       spin_temporal_tension->set_sensitive(checkbutton_temporal_tension.get_active());
-}
-
-void
-Widget_WaypointModel::set_waypoint_model(synfig::Waypoint::Model &x)
-{
-       waypoint_model=x;
-       updating=true;
-
-       before->set_history((int)waypoint_model.get_before());
-       after->set_history((int)waypoint_model.get_after());
-
-       adj_tension.set_value(waypoint_model.get_tension());
-       adj_continuity.set_value(waypoint_model.get_continuity());
-       adj_bias.set_value(waypoint_model.get_bias());
-       adj_temporal_tension.set_value(waypoint_model.get_temporal_tension());
-
-       checkbutton_before.set_active(waypoint_model.get_before_flag());
-       checkbutton_after.set_active(waypoint_model.get_after_flag());
-       checkbutton_tension.set_active(waypoint_model.get_tension_flag());
-       checkbutton_continuity.set_active(waypoint_model.get_continuity_flag());
-       checkbutton_bias.set_active(waypoint_model.get_bias_flag());
-       checkbutton_temporal_tension.set_active(waypoint_model.get_temporal_tension_flag());
-
-       updating=false;
-
-       on_change();
-}
diff --git a/synfig-studio/src/gtkmm/widget_waypointmodel.h b/synfig-studio/src/gtkmm/widget_waypointmodel.h
deleted file mode 100644 (file)
index d8628a7..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file widget_waypointmodel.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_GTKMM_WIDGET_WAYPOINTMODEL_H
-#define __SYNFIG_GTKMM_WIDGET_WAYPOINTMODEL_H
-
-/* === H E A D E R S ======================================================= */
-
-//#include <gtk/gtk.h>
-//#include <gtkmm/arrow.h>
-//#include <gtkmm/image.h>
-//#include <gdkmm/pixbufloader.h>
-//#include <gtkmm/viewport.h>
-//#include <gtkmm/scrolledwindow.h>
-#include <gtkmm/table.h>
-#include <gtkmm/button.h>
-//#include <gtkmm/progressbar.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/box.h>
-#include <gtkmm/combo.h>
-#include <gtkmm/optionmenu.h>
-#include <gtkmm/spinbutton.h>
-#include <gtkmm/checkbutton.h>
-
-
-#include <synfig/waypoint.h>
-#include <synfig/string.h>
-#include <synfig/time.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 Widget_Time;
-class Widget_WaypointModel;
-
-class Widget_WaypointModel : public Gtk::Table
-{
-       synfig::Waypoint::Model waypoint_model;
-
-       bool updating;
-
-       Gtk::Combo *in,*out;
-       Gtk::OptionMenu *before, *after;
-       Gtk::Menu *before_options,*after_options;
-
-       Gtk::SpinButton *spin_tension, *spin_continuity, *spin_bias, *spin_temporal_tension;
-       Gtk::Adjustment adj_tension, adj_continuity, adj_bias, adj_temporal_tension;
-
-       Gtk::CheckButton checkbutton_after;
-       Gtk::CheckButton checkbutton_before;
-       Gtk::CheckButton checkbutton_tension;
-       Gtk::CheckButton checkbutton_continuity;
-       Gtk::CheckButton checkbutton_bias;
-       Gtk::CheckButton checkbutton_temporal_tension;
-
-       void on_change();
-
-public:
-       Widget_WaypointModel();
-       void set_waypoint_model(synfig::Waypoint::Model &x);
-       const synfig::Waypoint::Model &get_waypoint_model()const { return waypoint_model; }
-}; // END of class Widget_WaypointModel
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/workarea.cpp b/synfig-studio/src/gtkmm/workarea.cpp
deleted file mode 100644 (file)
index d2a1f3b..0000000
+++ /dev/null
@@ -1,2798 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file workarea.cpp
-**     \brief Template Header
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2006 Yue Shi Lai
-**     Copyright (c) 2007, 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 <config.h>
-#endif
-
-#include <sigc++/adaptors/hide.h>
-
-#include "workarea.h"
-#include "canvasview.h"
-#include "app.h"
-#include <gtkmm/window.h>
-#include <gtkmm/image.h>
-#include <gtkmm/drawingarea.h>
-#include <gtkmm/ruler.h>
-#include <gtkmm/arrow.h>
-#include <gtkmm/image.h>
-#include <gtkmm/scrollbar.h>
-#include <cmath>
-#include <sigc++/retype_return.h>
-#include <sigc++/retype.h>
-#include <sigc++/hide.h>
-#include <ETL/misc>
-
-#include <synfig/target_scanline.h>
-#include <synfig/target_tile.h>
-#include <synfig/surface.h>
-#include <synfig/valuenode_composite.h>
-#include <synfigapp/canvasinterface.h>
-#include "event_mouse.h"
-#include "event_layerclick.h"
-#include "widget_color.h"
-#include <synfig/distance.h>
-#include "workarearenderer.h"
-
-#include "renderer_canvas.h"
-#include "renderer_grid.h"
-#include "renderer_guides.h"
-#include "renderer_timecode.h"
-#include "renderer_ducks.h"
-#include "renderer_dragbox.h"
-#include "renderer_bbox.h"
-#include "asyncrenderer.h"
-#include <gtkmm/frame.h>
-
-#include <synfig/mutex.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 ========================================================= */
-
-#ifndef stratof
-#define stratof(X) (atof((X).c_str()))
-#define stratoi(X) (atoi((X).c_str()))
-#endif
-
-
-/* === G L O B A L S ======================================================= */
-
-/* === C L A S S E S ======================================================= */
-
-class studio::WorkAreaTarget : public synfig::Target_Tile
-{
-public:
-       WorkArea *workarea;
-       bool low_res;
-       int w,h;
-       int real_tile_w,real_tile_h;
-       //std::vector<Glib::RefPtr<Gdk::Pixbuf> >::iterator tile_iter;
-
-       int twindow_start, twindow_width, twindow_height, twindow_pad;
-       int refresh_id;
-
-       bool onionskin;
-       bool onion_first_tile;
-       int onion_layers;
-
-       std::list<synfig::Time> onion_skin_queue;
-
-       synfig::Mutex mutex;
-
-       void set_onion_skin(bool x, int *onions)
-       {
-               onionskin=x;
-
-               Time time(rend_desc().get_time_start());
-
-               if(!onionskin)
-                       return;
-               onion_skin_queue.push_back(time);
-
-               try
-               {
-               Time thistime=time;
-               for(int i=0; i<onions[0]; i++)
-                       {
-                               Time keytime=get_canvas()->keyframe_list().find_prev(thistime)->get_time();
-                               onion_skin_queue.push_back(keytime);
-                               thistime=keytime;
-                       }
-               }
-               catch(...)
-               {  }
-
-               try
-               {
-               Time thistime=time;
-               for(int i=0; i<onions[1]; i++)
-                       {
-                               Time keytime=get_canvas()->keyframe_list().find_next(thistime)->get_time();
-                               onion_skin_queue.push_back(keytime);
-                               thistime=keytime;
-                       }
-               }
-               catch(...)
-               {  }
-
-               onion_layers=onion_skin_queue.size();
-
-               onion_first_tile=false;
-       }
-public:
-
-       WorkAreaTarget(WorkArea *workarea,int w, int h):
-               workarea(workarea),
-               low_res(workarea->get_low_resolution_flag()),
-               w(w),
-               h(h),
-               real_tile_w(workarea->tile_w),
-               real_tile_h(workarea->tile_h),
-               refresh_id(workarea->refreshes),
-               onionskin(false),
-               onion_layers(0)
-       {
-               //set_remove_alpha();
-               //set_avoid_time_sync();
-               set_clipping(true);
-               if(low_res)
-               {
-                       int div = workarea->get_low_res_pixel_size();
-                       set_tile_w(workarea->tile_w/div);
-                       set_tile_h(workarea->tile_h/div);
-               }
-               else
-               {
-                       set_tile_w(workarea->tile_w);
-                       set_tile_h(workarea->tile_h);
-               }
-               set_canvas(workarea->get_canvas());
-               set_quality(workarea->get_quality());
-       }
-
-       ~WorkAreaTarget()
-       {
-               workarea->queue_draw();
-       }
-
-       virtual bool set_rend_desc(synfig::RendDesc *newdesc)
-       {
-               assert(workarea);
-               newdesc->set_flags(RendDesc::PX_ASPECT|RendDesc::IM_SPAN);
-               if(low_res) {
-                       int div = workarea->get_low_res_pixel_size();
-                       newdesc->set_wh(w/div,h/div);
-               }
-               else
-                       newdesc->set_wh(w,h);
-
-               if(
-                               workarea->get_w()!=w
-                       ||      workarea->get_h()!=h
-               ) workarea->set_wh(w,h,4);
-
-               workarea->full_frame=false;
-
-               desc=*newdesc;
-               return true;
-       }
-
-       virtual int total_tiles()const
-       {
-               int tw(rend_desc().get_w()/get_tile_w());
-               int th(rend_desc().get_h()/get_tile_h());
-               if(rend_desc().get_w()%get_tile_w()!=0)tw++;
-               if(rend_desc().get_h()%get_tile_h()!=0)th++;
-               return tw*th;
-       }
-
-       virtual int next_frame(Time& time)
-       {
-               synfig::Mutex::Lock lock(mutex);
-
-               if(!onionskin)
-                       return synfig::Target_Tile::next_frame(time);
-
-               onion_first_tile=(onion_layers==(signed)onion_skin_queue.size());
-
-               if(!onion_skin_queue.empty())
-               {
-                       time=onion_skin_queue.front();
-                       onion_skin_queue.pop_front();
-               }
-               else
-                       return 0;
-
-               return onion_skin_queue.size()+1;
-       }
-
-       virtual int next_tile(int& x, int& y)
-       {
-               synfig::Mutex::Lock lock(mutex);
-               //if(workarea->tile_queue.empty()) return 0;
-
-               //int curr_tile(workarea->tile_queue.front());
-               //workarea->tile_queue.pop_front();
-               int curr_tile(workarea->next_unrendered_tile(refresh_id-onion_skin_queue.size()));
-               if(curr_tile<0)
-                       return 0;
-
-               // Width of the image(in tiles)
-               int tw(rend_desc().get_w()/get_tile_w());
-               if(rend_desc().get_w()%get_tile_w()!=0)tw++;
-
-               y=(curr_tile/tw)*get_tile_w();
-               x=(curr_tile%tw)*get_tile_h();
-
-               // Mark this tile as "up-to-date"
-               if(onionskin)
-                       workarea->tile_book[curr_tile].second=refresh_id-onion_skin_queue.size();
-               else
-                       workarea->tile_book[curr_tile].second=refresh_id;
-
-               return total_tiles()-curr_tile+1;
-       }
-
-
-       virtual bool start_frame(synfig::ProgressCallback */*cb*/)
-       {
-               synfig::Mutex::Lock lock(mutex);
-
-               int tw(rend_desc().get_w()/get_tile_w());
-               if(rend_desc().get_w()%get_tile_w()!=0)tw++;
-               int th(rend_desc().get_h()/get_tile_h());
-               if(rend_desc().get_h()%get_tile_h()!=0)th++;
-
-               twindow_start=0;
-               twindow_width=tw;
-               twindow_height=th;
-               twindow_pad=0;
-
-               workarea->tile_book.resize(total_tiles());
-               //tile_iter=workarea->tile_book.begin()+twindow_start;
-               return true;
-       }
-
-       static void free_buff(const guint8 *x) { free(const_cast<guint8*>(x)); }
-
-       virtual bool add_tile(const synfig::Surface &surface, int x, int y)
-       {
-               synfig::Mutex::Lock lock(mutex);
-               assert(surface);
-
-               PixelFormat pf(PF_RGB);
-
-               const int total_bytes(get_tile_w()*get_tile_h()*synfig::channels(pf));
-
-               unsigned char *buffer((unsigned char*)malloc(total_bytes));
-
-               if(!surface || !buffer)
-                       return false;
-               {
-                       unsigned char *dest(buffer);
-                       const Color *src(surface[0]);
-                       int w(get_tile_w());
-                       int h(get_tile_h());
-                       int x(surface.get_w()*surface.get_h());
-                       //if(low_res) {
-                       //      int div = workarea->get_low_res_pixel_size();
-                       //      w/=div,h/=div;
-                       //}
-                       Color dark(0.6,0.6,0.6);
-                       Color lite(0.8,0.8,0.8);
-                       for(int i=0;i<x;i++)
-                               dest=Color2PixelFormat(
-                                       Color::blend(
-                                               (*(src++)),
-                                               ((i/surface.get_w())*8/h+(i%surface.get_w())*8/w)&1?dark:lite,
-                                               1.0f
-                                       ).clamped(),
-                                       pf,dest,App::gamma
-                               );
-               }
-
-               x/=get_tile_w();
-               y/=get_tile_h();
-               int tw(rend_desc().get_w()/get_tile_w());
-               if(rend_desc().get_w()%get_tile_w()!=0)tw++;
-               unsigned int index=y*tw+x;
-
-               // Sanity check
-               if(index>workarea->tile_book.size())
-                       return false;
-
-               Glib::RefPtr<Gdk::Pixbuf> pixbuf;
-
-               pixbuf=Gdk::Pixbuf::create_from_data(
-                       buffer, // pointer to the data
-                       Gdk::COLORSPACE_RGB, // the colorspace
-                       ((pf&PF_A)==PF_A), // has alpha?
-                       8, // bits per sample
-                       surface.get_w(),        // width
-                       surface.get_h(),        // height
-                       surface.get_w()*synfig::channels(pf), // stride (pitch)
-                       sigc::ptr_fun(&WorkAreaTarget::free_buff)
-               );
-
-               if(low_res)
-               {
-                       // We need to scale up
-                       int div = workarea->get_low_res_pixel_size();
-                       pixbuf=pixbuf->scale_simple(
-                               surface.get_w()*div,
-                               surface.get_h()*div,
-                               Gdk::INTERP_NEAREST
-                       );
-               }
-
-               if(!onionskin || onion_first_tile || !workarea->tile_book[index].first)
-               {
-                       workarea->tile_book[index].first=pixbuf;
-               }
-               else
-               {
-                       pixbuf->composite(
-                               workarea->tile_book[index].first, // Dest
-                               0,//int dest_x
-                               0,//int dest_y
-                               pixbuf->get_width(), // dest width
-                               pixbuf->get_height(), // dest_height,
-                               0, // double offset_x
-                               0, // double offset_y
-                               1, // double scale_x
-                               1, // double scale_y
-                               Gdk::INTERP_NEAREST, // interp
-                               255/(onion_layers-onion_skin_queue.size()+1) //int overall_alpha
-                       );
-               }
-
-               //if(index%2)
-                       workarea->queue_draw();
-               assert(workarea->tile_book[index].first);
-               return true;
-       }
-
-       virtual void end_frame()
-       {
-               //workarea->queue_draw();
-       }
-};
-
-
-class studio::WorkAreaTarget_Full : public synfig::Target_Scanline
-{
-public:
-       WorkArea *workarea;
-       bool low_res;
-       int w,h;
-       int real_tile_w,real_tile_h;
-       //std::vector<Glib::RefPtr<Gdk::Pixbuf> >::iterator tile_iter;
-
-       int twindow_start, twindow_width, twindow_height, twindow_pad;
-       int refresh_id;
-
-       bool onionskin;
-       bool onion_first_tile;
-       int onion_layers;
-
-       Surface surface;
-
-       std::list<synfig::Time> onion_skin_queue;
-
-       void set_onion_skin(bool x, int *onions)
-       {
-               onionskin=x;
-
-               Time time(rend_desc().get_time_start());
-
-               if(!onionskin)
-                       return;
-               onion_skin_queue.push_back(time);
-               //onion_skin_queue.push_back(time-1);
-               //onion_skin_queue.push_back(time+1);
-               try
-               {
-               Time thistime=time;
-               for(int i=0; i<onions[0]; i++)
-                       {
-                               Time keytime=get_canvas()->keyframe_list().find_prev(thistime)->get_time();
-                               onion_skin_queue.push_back(keytime);
-                               thistime=keytime;
-                       }
-               }
-               catch(...)
-               {  }
-
-               try
-               {
-               Time thistime=time;
-               for(int i=0; i<onions[1]; i++)
-                       {
-                               Time keytime=get_canvas()->keyframe_list().find_next(thistime)->get_time();
-                               onion_skin_queue.push_back(keytime);
-                               thistime=keytime;
-                       }
-               }
-               catch(...)
-               {  }
-
-               onion_layers=onion_skin_queue.size();
-
-               onion_first_tile=false;
-       }
-public:
-
-       WorkAreaTarget_Full(WorkArea *workarea,int w, int h):
-               workarea(workarea),
-               low_res(workarea->get_low_resolution_flag()),
-               w(w),
-               h(h),
-               refresh_id(workarea->refreshes),
-               onionskin(false),
-               onion_layers(0)
-       {
-               set_canvas(workarea->get_canvas());
-               set_quality(workarea->get_quality());
-       }
-
-       ~WorkAreaTarget_Full()
-       {
-       }
-
-       virtual bool set_rend_desc(synfig::RendDesc *newdesc)
-       {
-               assert(workarea);
-               newdesc->set_flags(RendDesc::PX_ASPECT|RendDesc::IM_SPAN);
-               if(low_res)
-               {
-                       int div = workarea->get_low_res_pixel_size();
-                       newdesc->set_wh(w/div,h/div);
-               }
-               else
-                       newdesc->set_wh(w,h);
-
-               if(
-                               workarea->get_w()!=w
-                       ||      workarea->get_h()!=h
-               ) workarea->set_wh(w,h,4);
-
-               surface.set_wh(newdesc->get_w(),newdesc->get_h());
-
-               desc=*newdesc;
-               workarea->full_frame=true;
-               workarea->tile_book.resize(1);
-               return true;
-       }
-
-       virtual int next_frame(Time& time)
-       {
-               // Mark this tile as "up-to-date"
-               if(onionskin)
-                       workarea->tile_book[0].second=refresh_id-onion_skin_queue.size();
-               else
-                       workarea->tile_book[0].second=refresh_id;
-
-               if(!onionskin)
-                       return synfig::Target_Scanline::next_frame(time);
-
-               onion_first_tile=(onion_layers==(signed)onion_skin_queue.size());
-
-               if(!onion_skin_queue.empty())
-               {
-                       time=onion_skin_queue.front();
-                       onion_skin_queue.pop_front();
-               }
-               else
-                       return 0;
-               return onion_skin_queue.size()+1;
-       }
-
-
-       virtual bool start_frame(synfig::ProgressCallback */*cb*/)
-       {
-               return true;
-       }
-
-       virtual Color * start_scanline(int scanline)
-       {
-               return surface[scanline];
-       }
-
-       virtual bool end_scanline()
-       {
-               return true;
-       }
-
-       static void free_buff(const guint8 *x) { free(const_cast<guint8*>(x)); }
-
-       virtual void end_frame()
-       {
-               assert(surface);
-
-               PixelFormat pf(PF_RGB);
-
-               const int total_bytes(surface.get_w()*surface.get_h()*synfig::channels(pf));
-
-               unsigned char *buffer((unsigned char*)malloc(total_bytes));
-
-               if(!surface || !buffer)
-                       return;
-               {
-                       unsigned char *dest(buffer);
-                       const Color *src(surface[0]);
-                       int w(surface.get_w());
-                       //int h(surface.get_h());
-                       int x(surface.get_w()*surface.get_h());
-                       //if(low_res) {
-                       //      int div = workarea->get_low_res_pixel_size();
-                       //      w/=div,h/=div;
-                       //}
-                       Color dark(0.6,0.6,0.6);
-                       Color lite(0.8,0.8,0.8);
-                       int tw=workarea->tile_w;
-                       int th=workarea->tile_h;
-                       if(low_res)
-                       {
-                               int div = workarea->get_low_res_pixel_size();
-                               tw/=div;
-                               th/=div;
-                       }
-                       for(int i=0;i<x;i++)
-                               dest=Color2PixelFormat(
-                                       Color::blend(
-                                               (*(src++)),
-                                               ((i/w)*8/th+(i%w)*8/tw)&1?dark:lite,
-                                               1.0f
-                                       ).clamped(),
-                                       pf,
-                                       dest,
-                                       App::gamma
-                               );
-               }
-
-               Glib::RefPtr<Gdk::Pixbuf> pixbuf;
-
-               pixbuf=Gdk::Pixbuf::create_from_data(
-                       buffer, // pointer to the data
-                       Gdk::COLORSPACE_RGB, // the colorspace
-                       ((pf&PF_A)==PF_A), // has alpha?
-                       8, // bits per sample
-                       surface.get_w(),        // width
-                       surface.get_h(),        // height
-                       surface.get_w()*synfig::channels(pf), // stride (pitch)
-                       sigc::ptr_fun(&WorkAreaTarget::free_buff)
-               );
-
-               if(low_res)
-               {
-                       // We need to scale up
-                       int div = workarea->get_low_res_pixel_size();
-                       pixbuf=pixbuf->scale_simple(
-                               surface.get_w()*div,
-                               surface.get_h()*div,
-                               Gdk::INTERP_NEAREST
-                       );
-               }
-
-               int index=0;
-
-               if(!onionskin || onion_first_tile || !workarea->tile_book[index].first)
-               {
-                       workarea->tile_book[index].first=pixbuf;
-               }
-               else
-               {
-                       pixbuf->composite(
-                               workarea->tile_book[index].first, // Dest
-                               0,//int dest_x
-                               0,//int dest_y
-                               pixbuf->get_width(), // dest width
-                               pixbuf->get_height(), // dest_height,
-                               0, // double offset_x
-                               0, // double offset_y
-                               1, // double scale_x
-                               1, // double scale_y
-                               Gdk::INTERP_NEAREST, // interp
-                               255/(onion_layers-onion_skin_queue.size()+1) //int overall_alpha
-                       );
-               }
-
-               workarea->queue_draw();
-               assert(workarea->tile_book[index].first);
-       }
-};
-
-
-
-
-/* === M E T H O D S ======================================================= */
-
-
-WorkArea::WorkArea(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface):
-       Gtk::Table(3, 3, false), /* 3 columns by 3 rows*/
-       canvas_interface(canvas_interface),
-       canvas(canvas_interface->get_canvas()),
-       scrollx_adjustment(0,-4,4,0.01,0.1),
-       scrolly_adjustment(0,-4,4,0.01,0.1),
-       w(TILE_SIZE),
-       h(TILE_SIZE),
-       last_event_time(0),
-       progresscallback(0),
-       dragging(DRAG_NONE),
-       show_grid(false),
-       tile_w(TILE_SIZE),
-       tile_h(TILE_SIZE),
-       timecode_width(0),
-       timecode_height(0)
-{
-       show_guides=true;
-       curr_input_device=0;
-       full_frame=false;
-       allow_duck_clicks=true;
-       allow_layer_clicks=true;
-       render_idle_func_id=0;
-       zoom=prev_zoom=1.0;
-       quality=10;
-       low_res_pixel_size=2;
-       rendering=false;
-       canceled_=false;
-       low_resolution=true;
-       pw=0.001;
-       ph=0.001;
-       last_focus_point=Point(0,0);
-       onion_skin=false;
-       onion_skins[0]=0;
-       onion_skins[1]=0;
-       queued=false;
-       dirty_trap_enabled=false;
-       solid_lines=true;
-
-       dirty_trap_queued=0;
-
-       meta_data_lock=false;
-
-       insert_renderer(new Renderer_Canvas,    000);
-       insert_renderer(new Renderer_Grid,              100);
-       insert_renderer(new Renderer_Guides,    200);
-       insert_renderer(new Renderer_Ducks,             300);
-       insert_renderer(new Renderer_BBox,              399);
-       insert_renderer(new Renderer_Dragbox,   400);
-       insert_renderer(new Renderer_Timecode,  500);
-
-       signal_duck_selection_changed().connect(sigc::mem_fun(*this,&studio::WorkArea::queue_draw));
-       signal_strokes_changed().connect(sigc::mem_fun(*this,&studio::WorkArea::queue_draw));
-       signal_grid_changed().connect(sigc::mem_fun(*this,&studio::WorkArea::queue_draw));
-       signal_grid_changed().connect(sigc::mem_fun(*this,&studio::WorkArea::save_meta_data));
-       signal_sketch_saved().connect(sigc::mem_fun(*this,&studio::WorkArea::save_meta_data));
-
-       // Not that it really makes a difference... (setting this to zero, that is)
-       refreshes=0;
-
-       drawing_area=manage(new class Gtk::DrawingArea());
-       drawing_area->show();
-       drawing_area->set_extension_events(Gdk::EXTENSION_EVENTS_ALL);
-
-       drawing_frame=manage(new Gtk::Frame);
-       drawing_frame->add(*drawing_area);
-       //drawing_frame->set_shadow_type(Gtk::SHADOW_NONE);
-       //drawing_frame->property_border_width()=5;
-       //drawing_frame->modify_fg(Gtk::STATE_NORMAL,Gdk::Color("#00ffff"));
-       //drawing_frame->modify_base(Gtk::STATE_NORMAL,Gdk::Color("#ff00ff"));
-       /*drawing_frame->modify_fg(Gtk::STATE_ACTIVE,Gdk::Color("#00ffff"));
-       drawing_frame->modify_base(Gtk::STATE_ACTIVE,Gdk::Color("#ff00ff"));
-       drawing_frame->modify_bg(Gtk::STATE_ACTIVE,Gdk::Color("#00ff00"));
-       drawing_frame->modify_fg(Gtk::STATE_INSENSITIVE,Gdk::Color("#00ffff"));
-       drawing_frame->modify_base(Gtk::STATE_INSENSITIVE,Gdk::Color("#ff00ff"));
-       drawing_frame->modify_bg(Gtk::STATE_INSENSITIVE,Gdk::Color("#00ff00"));
-       drawing_frame->modify_fg(Gtk::STATE_SELECTED,Gdk::Color("#00ffff"));
-       drawing_frame->modify_base(Gtk::STATE_SELECTED,Gdk::Color("#ff00ff"));
-       drawing_frame->modify_bg(Gtk::STATE_SELECTED,Gdk::Color("#00ff00"));
-       */
-       //drawing_frame->set_state(Gtk::STATE_NORMAL);
-
-       drawing_frame->show();
-
-       attach(*drawing_frame, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       Gtk::IconSize iconsize=Gtk::IconSize::from_name("synfig-small_icon");
-
-
-       // Create the vertical and horizontal rulers
-       vruler = manage(new class Gtk::VRuler());
-       hruler = manage(new class Gtk::HRuler());
-       vruler->set_metric(Gtk::PIXELS);
-       hruler->set_metric(Gtk::PIXELS);
-       Pango::FontDescription fd(hruler->get_style()->get_font());
-       fd.set_size(Pango::SCALE*8);
-       vruler->modify_font(fd);
-       hruler->modify_font(fd);
-       vruler->show();
-       hruler->show();
-       attach(*vruler, 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       attach(*hruler, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       hruler->signal_event().connect(sigc::mem_fun(*this, &WorkArea::on_hruler_event));
-       vruler->signal_event().connect(sigc::mem_fun(*this, &WorkArea::on_vruler_event));
-       hruler->add_events(Gdk::BUTTON1_MOTION_MASK | Gdk::BUTTON2_MOTION_MASK |Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
-       vruler->add_events(Gdk::BUTTON1_MOTION_MASK | Gdk::BUTTON2_MOTION_MASK |Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
-
-       // Create the menu button
-       menubutton=manage(new class Gtk::Button());
-       Gtk::Arrow *arrow1 = manage(new class Gtk::Arrow(Gtk::ARROW_RIGHT, Gtk::SHADOW_OUT));
-       arrow1->set_size_request(10,10);
-       menubutton->add(*arrow1);
-       menubutton->show_all();
-       menubutton->signal_pressed().connect(sigc::mem_fun(*this, &WorkArea::popup_menu));
-       attach(*menubutton, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-
-       Gtk::HBox *hbox = manage(new class Gtk::HBox(false, 0));
-
-       Gtk::VScrollbar *vscrollbar1 = manage(new class Gtk::VScrollbar(*get_scrolly_adjustment()));
-       Gtk::HScrollbar *hscrollbar1 = manage(new class Gtk::HScrollbar(*get_scrollx_adjustment()));
-       vscrollbar1->show();
-       attach(*vscrollbar1, 2, 3, 1, 2, Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
-       ZoomDial *zoomdial=manage(new class ZoomDial(iconsize));
-       zoomdial->signal_zoom_in().connect(sigc::mem_fun(*this, &studio::WorkArea::zoom_in));
-       zoomdial->signal_zoom_out().connect(sigc::mem_fun(*this, &studio::WorkArea::zoom_out));
-       zoomdial->signal_zoom_fit().connect(sigc::mem_fun(*this, &studio::WorkArea::zoom_fit));
-       zoomdial->signal_zoom_norm().connect(sigc::mem_fun(*this, &studio::WorkArea::zoom_norm));
-
-       hbox->pack_end(*hscrollbar1, Gtk::PACK_EXPAND_WIDGET,0);
-       hscrollbar1->show();
-       hbox->pack_start(*zoomdial, Gtk::PACK_SHRINK,0);
-       zoomdial->show();
-
-       attach(*hbox, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-       hbox->show();
-
-       drawing_area->add_events(Gdk::KEY_PRESS_MASK | Gdk::KEY_RELEASE_MASK);
-       add_events(Gdk::KEY_PRESS_MASK);
-       drawing_area->add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
-       drawing_area->add_events(Gdk::BUTTON1_MOTION_MASK | Gdk::BUTTON2_MOTION_MASK |Gdk::POINTER_MOTION_MASK);
-
-       // ----------------- Attach signals
-
-       drawing_area->signal_expose_event().connect(sigc::mem_fun(*this, &WorkArea::refresh));
-       drawing_area->signal_event().connect(sigc::mem_fun(*this, &WorkArea::on_drawing_area_event));
-       drawing_area->signal_size_allocate().connect(sigc::hide(sigc::mem_fun(*this, &WorkArea::refresh_dimension_info)));
-
-
-
-       canvas_interface->signal_rend_desc_changed().connect(sigc::mem_fun(*this, &WorkArea::refresh_dimension_info));
-       // When either of the scrolling adjustments change, then redraw.
-       get_scrollx_adjustment()->signal_value_changed().connect(sigc::mem_fun(*this, &WorkArea::queue_scroll));
-       get_scrolly_adjustment()->signal_value_changed().connect(sigc::mem_fun(*this, &WorkArea::queue_scroll));
-       get_scrollx_adjustment()->signal_value_changed().connect(sigc::mem_fun(*this, &WorkArea::refresh_dimension_info));
-       get_scrolly_adjustment()->signal_value_changed().connect(sigc::mem_fun(*this, &WorkArea::refresh_dimension_info));
-
-       get_canvas()->signal_meta_data_changed("grid_size").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
-       get_canvas()->signal_meta_data_changed("grid_snap").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
-       get_canvas()->signal_meta_data_changed("grid_show").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
-       get_canvas()->signal_meta_data_changed("guide_show").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
-       get_canvas()->signal_meta_data_changed("guide_x").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
-       get_canvas()->signal_meta_data_changed("guide_y").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
-       get_canvas()->signal_meta_data_changed("onion_skin").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
-       get_canvas()->signal_meta_data_changed("guide_snap").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
-       get_canvas()->signal_meta_data_changed("sketch").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
-       get_canvas()->signal_meta_data_changed("solid_lines").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
-
-       queued=false;
-       meta_data_lock=false;
-       set_focus_point(Point(0,0));
-
-
-       load_meta_data();
-       // Load sketch
-       {
-               String data(canvas->get_meta_data("sketch"));
-               if(!data.empty())
-               {
-                       if(!load_sketch(data))
-                               load_sketch(dirname(canvas->get_file_name())+ETL_DIRECTORY_SEPARATOR+basename(data));
-               }
-       }
-
-       hruler->property_max_size()=double(10.0);
-       vruler->property_max_size()=double(10.0);
-
-       drawing_area->set_flags(drawing_area->get_flags()|Gtk::CAN_FOCUS);
-}
-
-WorkArea::~WorkArea()
-{
-//     delete [] buffer;
-
-       // don't leave the render function queued if we are about to vanish;
-       // that causes crashes
-       if(render_idle_func_id)
-               render_idle_func_id=0;
-}
-
-#ifdef SINGLE_THREADED
-bool
-WorkArea::get_updating()const
-{
-       return App::single_threaded && async_renderer && async_renderer->updating;
-}
-#endif
-
-#ifdef SINGLE_THREADED
-void
-WorkArea::stop_updating(bool cancel)
-{
-       async_renderer->stop();
-       if (cancel) canceled_=true;
-}
-#endif
-
-void
-WorkArea::save_meta_data()
-{
-       if(meta_data_lock)
-               return;
-       meta_data_lock=true;
-
-       Vector s(get_grid_size());
-       canvas_interface->set_meta_data("grid_size",strprintf("%f %f",s[0],s[1]));
-       canvas_interface->set_meta_data("grid_snap",get_grid_snap()?"1":"0");
-       canvas_interface->set_meta_data("guide_snap",get_guide_snap()?"1":"0");
-       canvas_interface->set_meta_data("guide_show",get_show_guides()?"1":"0");
-       canvas_interface->set_meta_data("grid_show",show_grid?"1":"0");
-       canvas_interface->set_meta_data("onion_skin",onion_skin?"1":"0");
-       {
-               String data;
-               GuideList::const_iterator iter;
-               for(iter=get_guide_list_x().begin();iter!=get_guide_list_x().end();++iter)
-               {
-                       if(!data.empty())
-                               data+=' ';
-                       data+=strprintf("%f",*iter);
-               }
-               if(!data.empty())
-                       canvas_interface->set_meta_data("guide_x",data);
-
-               data.clear();
-               for(iter=get_guide_list_y().begin();iter!=get_guide_list_y().end();++iter)
-               {
-                       if(!data.empty())
-                               data+=' ';
-                       data+=strprintf("%f",*iter);
-               }
-               if(!data.empty())
-                       canvas_interface->set_meta_data("guide_y",data);
-       }
-
-       if(get_sketch_filename().size())
-       {
-               if(dirname(canvas->get_file_name())==dirname(get_sketch_filename()))
-                       canvas_interface->set_meta_data("sketch",basename(get_sketch_filename()));
-               else
-                       canvas_interface->set_meta_data("sketch",get_sketch_filename());
-       }
-
-       meta_data_lock=false;
-}
-
-void
-WorkArea::load_meta_data()
-{
-       if(meta_data_lock)
-               return;
-       meta_data_lock=true;
-
-       String data;
-
-       data=canvas->get_meta_data("grid_size");
-       if(!data.empty())
-       {
-               float gx(get_grid_size()[0]),gy(get_grid_size()[1]);
-
-               String::iterator iter(find(data.begin(),data.end(),' '));
-               String tmp(data.begin(),iter);
-
-               if(!tmp.empty())
-                       gx=stratof(tmp);
-               else
-                       synfig::error("WorkArea::load_meta_data(): Unable to parse data for \"grid_size\", which was \"%s\"",data.c_str());
-
-               if(iter==data.end())
-                       tmp.clear();
-               else
-                       tmp=String(iter+1,data.end());
-
-               if(!tmp.empty())
-                       gy=stratof(tmp);
-               else
-                       synfig::error("WorkArea::load_meta_data(): Unable to parse data for \"grid_size\", which was \"%s\"",data.c_str());
-
-               set_grid_size(Vector(gx,gy));
-       }
-
-       data=canvas->get_meta_data("grid_show");
-       if(data.size() && (data=="1" || data[0]=='t' || data[0]=='T'))
-               show_grid=true;
-       if(data.size() && (data=="0" || data[0]=='f' || data[0]=='F'))
-               show_grid=false;
-
-       data=canvas->get_meta_data("solid_lines");
-       if(data.size() && (data=="1" || data[0]=='t' || data[0]=='T'))
-               solid_lines=true;
-       if(data.size() && (data=="0" || data[0]=='f' || data[0]=='F'))
-               solid_lines=false;
-
-       data=canvas->get_meta_data("guide_show");
-       if(data.size() && (data=="1" || data[0]=='t' || data[0]=='T'))
-               show_guides=true;
-       if(data.size() && (data=="0" || data[0]=='f' || data[0]=='F'))
-               show_guides=false;
-
-       data=canvas->get_meta_data("grid_snap");
-       if(data.size() && (data=="1" || data[0]=='t' || data[0]=='T'))
-               set_grid_snap(true);
-       if(data.size() && (data=="0" || data[0]=='f' || data[0]=='F'))
-               set_grid_snap(false);
-
-       data=canvas->get_meta_data("guide_snap");
-       if(data.size() && (data=="1" || data[0]=='t' || data[0]=='T'))
-               set_guide_snap(true);
-       if(data.size() && (data=="0" || data[0]=='f' || data[0]=='F'))
-               set_guide_snap(false);
-
-       data=canvas->get_meta_data("onion_skin");
-       if(data.size() && (data=="1" || data[0]=='t' || data[0]=='T'))
-               set_onion_skin(true);
-       if(data.size() && (data=="0" || data[0]=='f' || data[0]=='F'))
-               set_onion_skin(false);
-
-       data=canvas->get_meta_data("guide_x");
-       get_guide_list_x().clear();
-       while(!data.empty())
-       {
-               String::iterator iter(find(data.begin(),data.end(),' '));
-               String guide(data.begin(),iter);
-
-               if(!guide.empty())
-                       get_guide_list_x().push_back(stratof(guide));
-
-               if(iter==data.end())
-                       data.clear();
-               else
-                       data=String(iter+1,data.end());
-       }
-       //sort(get_guide_list_x());
-
-       data=canvas->get_meta_data("guide_y");
-       get_guide_list_y().clear();
-       while(!data.empty())
-       {
-               String::iterator iter(find(data.begin(),data.end(),' '));
-               String guide(data.begin(),iter);
-
-               if(!guide.empty())
-                       get_guide_list_y().push_back(stratof(guide));
-
-               if(iter==data.end())
-                       data.clear();
-               else
-                       data=String(iter+1,data.end());
-       }
-       //sort(get_guide_list_y());
-
-       meta_data_lock=false;
-       queue_draw();
-}
-
-void
-WorkArea::set_onion_skin(bool x)
-{
-       if(onion_skin==x)
-               return;
-       onion_skin=x;
-       save_meta_data();
-       queue_render_preview();
-       signal_onion_skin_changed()();
-}
-
-bool
-WorkArea::get_onion_skin()const
-{
-       return onion_skin;
-}
-
-void WorkArea::set_onion_skins(int *onions)
-{
-       onion_skins[0]=onions[0];
-       onion_skins[1]=onions[1];
-       if(onion_skin)
-               queue_render_preview();
-}
-
-void
-WorkArea::enable_grid()
-{
-       show_grid=true;
-       save_meta_data();
-       queue_draw();
-}
-
-void
-WorkArea::disable_grid()
-{
-       show_grid=false;
-       save_meta_data();
-       queue_draw();
-}
-
-void
-WorkArea::set_show_guides(bool x)
-{
-       show_guides=x;
-       save_meta_data();
-       queue_draw();
-}
-
-void
-WorkArea::toggle_grid()
-{
-       show_grid=!show_grid;
-       save_meta_data();
-       queue_draw();
-}
-
-void
-WorkArea::set_low_resolution_flag(bool x)
-{
-       if(x!=low_resolution)
-       {
-               low_resolution=x;
-               queue_render_preview();
-       }
-}
-
-void
-WorkArea::toggle_low_resolution_flag()
-{
-       set_low_resolution_flag(!get_low_resolution_flag());
-}
-
-void
-WorkArea::popup_menu()
-{
-       signal_popup_menu()();
-}
-
-void
-WorkArea::set_grid_size(const synfig::Vector &s)
-{
-       Duckmatic::set_grid_size(s);
-       save_meta_data();
-       queue_draw();
-}
-
-void
-WorkArea::set_focus_point(const synfig::Point &point)
-{
-       // These next three lines try to ensure that we place the
-       // focus on a pixel boundary
-       /*Point adjusted(point[0]/abs(get_pw()),point[1]/abs(get_ph()));
-       adjusted[0]=(abs(adjusted[0]-floor(adjusted[0]))<0.5)?floor(adjusted[0])*abs(get_pw()):ceil(adjusted[0])*abs(get_ph());
-       adjusted[1]=(abs(adjusted[1]-floor(adjusted[1]))<0.5)?floor(adjusted[1])*abs(get_ph()):ceil(adjusted[1])*abs(get_ph());
-       */
-       const synfig::Point& adjusted(point);
-
-       synfig::RendDesc &rend_desc(get_canvas()->rend_desc());
-       Real x_factor=(rend_desc.get_br()[0]-rend_desc.get_tl()[0]>0)?-1:1;
-       Real y_factor=(rend_desc.get_br()[1]-rend_desc.get_tl()[1]>0)?-1:1;
-
-       get_scrollx_adjustment()->set_value(adjusted[0]*x_factor);
-       get_scrolly_adjustment()->set_value(adjusted[1]*y_factor);
-}
-
-synfig::Point
-WorkArea::get_focus_point()const
-{
-       synfig::RendDesc &rend_desc(get_canvas()->rend_desc());
-       Real x_factor=(rend_desc.get_br()[0]-rend_desc.get_tl()[0]>0)?-1:1;
-       Real y_factor=(rend_desc.get_br()[1]-rend_desc.get_tl()[1]>0)?-1:1;
-
-       return synfig::Point(get_scrollx_adjustment()->get_value()*x_factor, get_scrolly_adjustment()->get_value()*y_factor);
-}
-
-bool
-WorkArea::set_wh(int W, int H,int CHAN)
-{
-       // If our size is already set, don't set it again
-       if(W==w && H==h && CHAN==bpp)
-       {
-               return true;
-       }
-       if(W<=0 || H<=0 || CHAN<=0)
-               return false;
-
-       assert(W>0);
-       assert(H>0);
-       assert(CHAN>0);
-
-       // Set all of the parameters
-       w=W;
-       h=H;
-       bpp=CHAN;
-
-       refresh_dimension_info();
-
-       tile_book.clear();
-
-       return true;
-}
-
-bool
-WorkArea::on_key_press_event(GdkEventKey* event)
-{
-       if(get_selected_ducks().empty())
-               return false;
-
-       Real multiplier(1.0);
-
-       if(Gdk::ModifierType(event->state)&GDK_SHIFT_MASK)
-               multiplier=10.0;
-
-       Vector nudge;
-       switch(event->keyval)
-       {
-               case GDK_Left:
-                       nudge=Vector(-pw,0);
-                       break;
-               case GDK_Right:
-                       nudge=Vector(pw,0);
-                       break;
-               case GDK_Up:
-                       nudge=Vector(0,-ph);
-                       break;
-               case GDK_Down:
-                       nudge=Vector(0,ph);
-                       break;
-               default:
-                       return false;
-                       break;
-       }
-
-       synfigapp::Action::PassiveGrouper grouper(instance.get(),_("Nudge"));
-
-       // Grid snap does not apply to nudging
-       bool grid_snap_holder(get_grid_snap());
-       bool guide_snap_holder(get_guide_snap());
-       set_grid_snap(false);
-
-       try {
-               start_duck_drag(get_selected_duck()->get_trans_point());
-               translate_selected_ducks(get_selected_duck()->get_trans_point()+nudge*multiplier);
-               end_duck_drag();
-       }
-       catch(String)
-       {
-               canvas_view->duck_refresh_flag=true;
-               canvas_view->queue_rebuild_ducks();
-       }
-
-       set_grid_snap(grid_snap_holder);
-       set_guide_snap(guide_snap_holder);
-
-       return true;
-}
-
-bool
-WorkArea::on_drawing_area_event(GdkEvent *event)
-{
-       synfig::Point mouse_pos;
-    float bezier_click_pos;
-       const float radius((abs(pw)+abs(ph))*4);
-       int button_pressed(0);
-       float pressure(0);
-       bool is_mouse(false);
-       Gdk::ModifierType modifier(Gdk::ModifierType(0));
-
-       // Handle input stuff
-       if(
-               event->any.type==GDK_MOTION_NOTIFY ||
-               event->any.type==GDK_BUTTON_PRESS ||
-               event->any.type==GDK_2BUTTON_PRESS ||
-               event->any.type==GDK_3BUTTON_PRESS ||
-               event->any.type==GDK_BUTTON_RELEASE
-       )
-       {
-               GdkDevice *device;
-               if(event->any.type==GDK_MOTION_NOTIFY)
-               {
-                       device=event->motion.device;
-                       modifier=Gdk::ModifierType(event->motion.state);
-               }
-               else
-               {
-                       device=event->button.device;
-                       modifier=Gdk::ModifierType(event->button.state);
-                       drawing_area->grab_focus();
-               }
-
-               // Make sure we recognize the device
-               if(curr_input_device)
-               {
-                       if(curr_input_device!=device)
-                       {
-                               assert(device);
-                               curr_input_device=device;
-                               signal_input_device_changed()(curr_input_device);
-                       }
-               }
-               else if(device)
-               {
-                       curr_input_device=device;
-                       signal_input_device_changed()(curr_input_device);
-               }
-
-               assert(curr_input_device);
-
-               // Calculate the position of the
-               // input device in canvas coordinates
-               // and the buttons
-               if(!event->button.axes)
-               {
-                       mouse_pos=synfig::Point(screen_to_comp_coords(synfig::Point(event->button.x,event->button.y)));
-                       button_pressed=event->button.button;
-                       pressure=1.0f;
-                       is_mouse=true;
-                       if(isnan(event->button.x) || isnan(event->button.y))
-                               return false;
-               }
-               else
-               {
-                       double x(event->button.axes[0]);
-                       double y(event->button.axes[1]);
-                       if(isnan(x) || isnan(y))
-                               return false;
-
-                       pressure=event->button.axes[2];
-                       //synfig::info("pressure=%f",pressure);
-                       pressure-=0.04f;
-                       pressure/=1.0f-0.04f;
-
-
-                       assert(!isnan(pressure));
-
-                       mouse_pos=synfig::Point(screen_to_comp_coords(synfig::Point(x,y)));
-
-                       button_pressed=event->button.button;
-
-                       if(button_pressed==1 && pressure<0 && (event->any.type!=GDK_BUTTON_RELEASE && event->any.type!=GDK_BUTTON_PRESS))
-                               button_pressed=0;
-                       if(pressure<0)
-                               pressure=0;
-
-                       //if(event->any.type==GDK_BUTTON_PRESS && button_pressed)
-                       //      synfig::info("Button pressed on input device = %d",event->button.button);
-
-                       //if(event->button.axes[2]>0.1)
-                       //      button_pressed=1;
-                       //else
-                       //      button_pressed=0;
-               }
-       }
-       // GDK mouse scrolling events
-       else if(event->any.type==GDK_SCROLL)
-       {
-               // GDK information needed to properly interpret mouse
-               // scrolling events are: scroll.state, scroll.x/scroll.y, and
-               // scroll.direction. The value of scroll.direction will be
-               // obtained later.
-
-               modifier=Gdk::ModifierType(event->scroll.state);
-               mouse_pos=synfig::Point(screen_to_comp_coords(synfig::Point(event->scroll.x,event->scroll.y)));
-       }
-
-       // Handle the renderables
-       {
-               std::set<etl::handle<WorkAreaRenderer> >::iterator iter;
-               for(iter=renderer_set_.begin();iter!=renderer_set_.end();++iter)
-               {
-                       if((*iter)->get_enabled())
-                               if((*iter)->event_vfunc(event))
-                               {
-                                       // Event handled. Return true.
-                                       return true;
-                               }
-               }
-       }
-
-       // Event hasn't been handled, pass it down
-       switch(event->type)
-    {
-       case GDK_BUTTON_PRESS:
-               {
-               switch(button_pressed)
-               {
-               case 1: // Attempt to click on a duck
-               {
-                       etl::handle<Duck> duck;
-                       dragging=DRAG_NONE;
-
-                       if(allow_duck_clicks)
-                       {
-                               duck=find_duck(mouse_pos,radius);
-
-                               if(duck)
-                               {
-                                       // make a note of whether the duck we click on was selected or not
-                                       if(duck_is_selected(duck))
-                                               clicked_duck=duck;
-                                       else
-                                       {
-                                               clicked_duck=0;
-                                               // if CTRL isn't pressed, clicking an unselected duck will unselect all other ducks
-                                               if(!(modifier&GDK_CONTROL_MASK))
-                                                       clear_selected_ducks();
-                                               select_duck(duck);
-                                       }
-                               }
-                       }
-                       //else
-                       //      clear_selected_ducks();
-
-
-
-                       selected_bezier=find_bezier(mouse_pos,radius,&bezier_click_pos);
-                       if(duck)
-                       {
-                               if (!duck->get_editable())
-                                       return true;
-
-                               //get_selected_duck()->signal_user_click(0)();
-                               //if(clicked_duck)clicked_duck->signal_user_click(0)();
-
-                               // if the user is holding shift while clicking on a tangent duck, consider splitting the tangent
-                               if (event->motion.state&GDK_SHIFT_MASK && duck->get_type() == Duck::TYPE_TANGENT)
-                               {
-                                       synfigapp::ValueDesc value_desc = duck->get_value_desc();
-
-                                       // we have the tangent, but need the vertex - that's the parent
-                                       if (value_desc.parent_is_value_node()) {
-                                               ValueNode_Composite::Handle parent_value_node = value_desc.get_parent_value_node();
-
-                                               // if the tangent isn't split, then split it
-                                               if (!((*(parent_value_node->get_link("split")))(get_time()).get(bool())))
-                                               {
-                                                       if (get_canvas_view()->canvas_interface()->
-                                                               change_value(synfigapp::ValueDesc(parent_value_node,
-                                                                                                                                 parent_value_node->get_link_index_from_name("split")),
-                                                                                        true))
-                                                       {
-                                                               // rebuild the ducks from scratch, so the tangents ducks aren't connected
-                                                               get_canvas_view()->rebuild_ducks();
-
-                                                               // reprocess the mouse click
-                                                               return on_drawing_area_event(event);
-                                                       }
-                                                       else
-                                                               return true;
-                                               }
-                                       } else {
-                                               // I don't know how to access the vertex from the tangent duck when originally drawing the bline in the bline tool
-
-                                               // synfig::ValueNode::Handle vn = value_desc.get_value_node();
-                                               synfig::info("parent isn't value node?  shift-drag-tangent doesn't work in bline tool yet...");
-                                       }
-                               }
-
-                               dragging=DRAG_DUCK;
-                               drag_point=mouse_pos;
-                               //drawing_area->queue_draw();
-                               start_duck_drag(mouse_pos);
-                               get_canvas_view()->reset_cancel_status();
-                               return true;
-                       }
-// I commented out this section because
-// it was causing issues when rotoscoping.
-// At the moment, we don't need it, so
-// this was the easiest way to fix the problem.
-/*
-                       else
-                       if(selected_bezier)
-                       {
-                               selected_duck=0;
-                               selected_bezier->signal_user_click(0)(bezier_click_pos);
-                       }
-*/
-                       else
-                       {
-                               //clear_selected_ducks();
-                               selected_bezier=0;
-                               if(canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,BUTTON_LEFT,mouse_pos,pressure,modifier))==Smach::RESULT_OK)
-                               {
-                                       // Check for a guide click
-                                       GuideList::iterator iter;
-
-                                       iter=find_guide_x(mouse_pos,radius);
-                                       if(iter==get_guide_list_x().end())
-                                       {
-                                               curr_guide_is_x=false;
-                                               iter=find_guide_y(mouse_pos,radius);
-                                       }
-                                       else
-                                               curr_guide_is_x=true;
-                                       if(iter!=get_guide_list_x().end() && iter!=get_guide_list_y().end())
-                                       {
-                                               dragging=DRAG_GUIDE;
-                                               curr_guide=iter;
-                                               return true;
-                                       }
-
-
-                                       // All else fails, try making a selection box
-                                       dragging=DRAG_BOX;
-                                       curr_point=drag_point=mouse_pos;
-                                       return true;
-                               }
-                       }
-                       break;
-               }
-               case 2: // Attempt to drag and move the window
-               {
-                       etl::handle<Duck> duck=find_duck(mouse_pos,radius);
-                       etl::handle<Bezier> bezier=find_bezier(mouse_pos,radius,&bezier_click_pos);
-                       if(duck)
-                               duck->signal_user_click(1)();
-                       else
-                       if(bezier)
-                               bezier->signal_user_click(1)(bezier_click_pos);
-
-                       if(canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,BUTTON_MIDDLE,mouse_pos,pressure,modifier))==Smach::RESULT_OK)
-                       if(is_mouse)
-                       {
-                               dragging=DRAG_WINDOW;
-                               drag_point=mouse_pos;
-                               signal_user_click(1)(mouse_pos);
-                       }
-                       break;
-               }
-               case 3: // Attempt to either get info on a duck, or open the menu
-               {
-                       etl::handle<Duck> duck=find_duck(mouse_pos,radius);
-                       etl::handle<Bezier> bezier=find_bezier(mouse_pos,radius,&bezier_click_pos);
-
-                       Layer::Handle layer(get_canvas()->find_layer(mouse_pos));
-                       if(duck)
-                       {
-                               if(get_selected_ducks().size()<=1)
-                                       duck->signal_user_click(2)();
-                               else
-                                       canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MULTIPLE_DUCKS_CLICKED,BUTTON_RIGHT,mouse_pos,pressure,modifier));
-                               return true;
-                       }
-                       else if(bezier)
-                       {
-                               bezier->signal_user_click(2)(bezier_click_pos);
-                               return true;
-                       }
-                       else if (layer)
-                       {
-                               if(canvas_view->get_smach().process_event(EventLayerClick(layer,BUTTON_RIGHT,mouse_pos))==Smach::RESULT_OK)
-                                       return false;
-                               return true;
-                       }
-                       else
-                               canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,BUTTON_RIGHT,mouse_pos,pressure,modifier));
-                       /*
-                       if(canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,BUTTON_RIGHT,mouse_pos,pressure,modifier))==Smach::RESULT_OK)
-                       {
-                               //popup_menu();
-                               return true;
-                       }
-                       */
-                       break;
-               }
-               case 4:
-                       signal_user_click(3)(mouse_pos);
-                       break;
-               case 5:
-                       signal_user_click(4)(mouse_pos);
-                       break;
-               default:
-                       break;
-               }
-               }
-               break;
-       case GDK_MOTION_NOTIFY:
-               curr_point=mouse_pos;
-
-               if(event->motion.time-last_event_time<25)
-                       return true;
-               else
-                       last_event_time=event->motion.time;
-
-               signal_cursor_moved_();
-
-               // Guide/Duck highlights on hover
-               if(dragging==DRAG_NONE)
-               {
-                       GuideList::iterator iter;
-
-                       iter=find_guide_x(mouse_pos,radius);
-                       if(iter==get_guide_list_x().end())
-                               iter=find_guide_y(mouse_pos,radius);
-
-                       if(iter!=curr_guide)
-                       {
-                               curr_guide=iter;
-                               drawing_area->queue_draw();
-                       }
-
-                       etl::handle<Duck> duck;
-                       duck=find_duck(mouse_pos,radius);
-                       if(duck!=hover_duck)
-                       {
-                               hover_duck=duck;
-                               drawing_area->queue_draw();
-                       }
-               }
-
-
-               if(dragging==DRAG_DUCK)
-               {
-                       if(canvas_view->get_cancel_status())
-                       {
-                               dragging=DRAG_NONE;
-                               canvas_view->queue_rebuild_ducks();
-                               return true;
-                       }
-                       /*
-                       Point point((mouse_pos-selected_duck->get_origin())/selected_duck->get_scalar());
-                       if(get_grid_snap())
-                       {
-                               point[0]=floor(point[0]/grid_size[0]+0.5)*grid_size[0];
-                               point[1]=floor(point[1]/grid_size[1]+0.5)*grid_size[1];
-                       }
-                       selected_duck->set_point(point);
-                       */
-
-                       //Point p(mouse_pos);
-
-                       set_axis_lock(event->motion.state&GDK_SHIFT_MASK);
-
-                       translate_selected_ducks(mouse_pos);
-
-                       drawing_area->queue_draw();
-               }
-
-               if(dragging==DRAG_BOX)
-               {
-                       curr_point=mouse_pos;
-                       drawing_area->queue_draw();
-               }
-
-               if(dragging==DRAG_GUIDE)
-               {
-                       if(curr_guide_is_x)
-                               *curr_guide=mouse_pos[0];
-                       else
-                               *curr_guide=mouse_pos[1];
-                       drawing_area->queue_draw();
-               }
-
-               if(dragging!=DRAG_WINDOW)
-               {       // Update those triangle things on the rulers
-                       const synfig::Point point(mouse_pos);
-                       hruler->property_position()=Distance(point[0],Distance::SYSTEM_UNITS).get(App::distance_system,get_canvas()->rend_desc());
-                       vruler->property_position()=Distance(point[1],Distance::SYSTEM_UNITS).get(App::distance_system,get_canvas()->rend_desc());
-               }
-
-               if(dragging == DRAG_WINDOW)
-                       set_focus_point(get_focus_point() + mouse_pos-drag_point);
-               else if (event->motion.state & GDK_BUTTON1_MASK &&
-                               canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_BUTTON_DRAG, BUTTON_LEFT,
-                                                                                                                                 mouse_pos,pressure,modifier)) == Smach::RESULT_ACCEPT)
-                       return true;
-               else if (event->motion.state & GDK_BUTTON2_MASK &&
-                                canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_BUTTON_DRAG, BUTTON_MIDDLE,
-                                                                                                                                  mouse_pos, pressure, modifier)) == Smach::RESULT_ACCEPT)
-                       return true;
-               else if (event->motion.state & GDK_BUTTON3_MASK &&
-                                canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_BUTTON_DRAG, BUTTON_RIGHT,
-                                                                                                                                  mouse_pos, pressure, modifier)) == Smach::RESULT_ACCEPT)
-                       return true;
-               else if(canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_MOTION, BUTTON_NONE,
-                                                                                                                                 mouse_pos, pressure,modifier)) == Smach::RESULT_ACCEPT)
-                       return true;
-
-               break;
-
-       case GDK_BUTTON_RELEASE:
-       {
-               bool ret(false);
-
-               if(dragging==DRAG_GUIDE)
-               {
-                       dragging=DRAG_NONE;
-                       save_meta_data();
-                       return true;
-               }
-               else
-               if(dragging==DRAG_DUCK)
-               {
-                       synfigapp::Action::PassiveGrouper grouper(instance.get(),_("Move"));
-                       dragging=DRAG_NONE;
-                       //translate_selected_ducks(mouse_pos);
-                       set_axis_lock(false);
-
-                       try{
-                       get_canvas_view()->duck_refresh_flag=false;
-                       get_canvas_view()->duck_refresh_needed=false;
-                       const bool drag_did_anything(end_duck_drag());
-                       get_canvas_view()->duck_refresh_flag=true;
-                       if(!drag_did_anything)
-                       {
-                               // if we originally clicked on a selected duck ...
-                               if(clicked_duck)
-                               {
-                                       // ... and CTRL is pressed, then just toggle the clicked duck
-                                       //     otherwise make the clicked duck the only selected duck
-                                       if(modifier&GDK_CONTROL_MASK)
-                                               unselect_duck(clicked_duck);
-                                       else
-                                       {
-                                               clear_selected_ducks();
-                                               select_duck(clicked_duck);
-                                       }
-                                       clicked_duck->signal_user_click(0)();
-                               }
-                       }
-                       else
-                       {
-                               if(canvas_view->duck_refresh_needed)
-                                       canvas_view->queue_rebuild_ducks();
-                               return true;
-                       }
-                       }catch(String)
-                       {
-                               canvas_view->duck_refresh_flag=true;
-                               canvas_view->queue_rebuild_ducks();
-                               return true;
-                       }
-                       //queue_draw();
-                       clicked_duck=0;
-
-                       ret=true;
-               }
-
-               if(dragging==DRAG_BOX)
-               {
-                       dragging=DRAG_NONE;
-                       if((drag_point-mouse_pos).mag()>radius/2.0f)
-                       {
-                               if(canvas_view->get_smach().process_event(EventBox(drag_point,mouse_pos,MouseButton(event->button.button),modifier))==Smach::RESULT_ACCEPT)
-                                       return true;
-
-                               // when dragging a box around some ducks:
-                               // SHIFT selects; CTRL toggles; SHIFT+CTRL unselects; <none> clears all then selects
-                               if(modifier&GDK_SHIFT_MASK)
-                                       select_ducks_in_box(drag_point,mouse_pos);
-
-                               if(modifier&GDK_CONTROL_MASK)
-                                       toggle_select_ducks_in_box(drag_point,mouse_pos);
-                               else if(!(modifier&GDK_SHIFT_MASK))
-                               {
-                                       clear_selected_ducks();
-                                       select_ducks_in_box(drag_point,mouse_pos);
-                               }
-                               ret=true;
-                       }
-                       else
-                       {
-                               if(allow_layer_clicks)
-                               {
-                                       Layer::Handle layer(get_canvas()->find_layer(drag_point));
-                                       //if(layer)
-                                       {
-                                               if(canvas_view->get_smach().process_event(EventLayerClick(layer,BUTTON_LEFT,mouse_pos,modifier))==Smach::RESULT_OK)
-                                                       signal_layer_selected_(layer);
-                                               ret=true;
-                                       }
-                               }
-                               else
-                               {
-                                       signal_user_click(0)(mouse_pos);
-                               }
-                       }
-               }
-
-               dragging=DRAG_NONE;
-
-               if(canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_BUTTON_UP,MouseButton(event->button.button),mouse_pos,pressure,modifier))==Smach::RESULT_ACCEPT)
-                       ret=true;
-
-               return ret;
-       }
-               break;
-       case GDK_SCROLL:
-       {
-               // Handle a mouse scrolling event like Xara Xtreme and
-               // Inkscape:
-
-               // Scroll up/down: scroll up/down
-               // Shift + scroll up/down: scroll left/right
-               // Control + scroll up/down: zoom in/out
-
-               if(modifier&GDK_CONTROL_MASK)
-               {
-
-                       // The zoom is performed while preserving the pointer
-                       // position as a fixed point (similarly to Xara Xtreme and
-                       // Inkscape).
-
-                       // The strategy used below is to scroll to the updated
-                       // position, then zoom. This is easy to implement within
-                       // the present architecture, but has the disadvantage of
-                       // triggering multiple visible refreshes. Note: 1.25 is
-                       // the hard wired ratio in zoom_in()/zoom_out(). The
-                       // variable "drift" compensates additional inaccuracies in
-                       // the zoom. There is also an additional minus sign for
-                       // the inverted y coordinates.
-
-                       // FIXME: One might want to figure out where in the code
-                       // this empirical drift is been introduced.
-
-                       const synfig::Point scroll_point(get_scrollx_adjustment()->get_value(),get_scrolly_adjustment()->get_value());
-                       const double drift = 0.052;
-
-                       switch(event->scroll.direction)
-                       {
-                               case GDK_SCROLL_UP:
-                               case GDK_SCROLL_RIGHT:
-                                       get_scrollx_adjustment()->set_value(scroll_point[0]+(mouse_pos[0]-scroll_point[0])*(1.25-(1+drift)));
-                                       get_scrolly_adjustment()->set_value(scroll_point[1]-(mouse_pos[1]+scroll_point[1])*(1.25-(1+drift)));
-                                       zoom_in();
-                                       break;
-                               case GDK_SCROLL_DOWN:
-                               case GDK_SCROLL_LEFT:
-                                       get_scrollx_adjustment()->set_value(scroll_point[0]+(mouse_pos[0]-scroll_point[0])*(1/1.25-(1+drift)));
-                                       get_scrolly_adjustment()->set_value(scroll_point[1]-(mouse_pos[1]+scroll_point[1])*(1/1.25-(1+drift)));
-                                       zoom_out();
-                                       break;
-                               default:
-                                       break;
-                       }
-               }
-               else if(modifier&GDK_SHIFT_MASK)
-               {
-                       // Scroll in either direction by 20 pixels. Ideally, the
-                       // amount of pixels per scrolling event should be
-                       // configurable. Xara Xtreme currently uses an (hard
-                       // wired) amount 20 pixel, Inkscape defaults to 40 pixels.
-
-                       const int scroll_pixel = 20;
-
-                       switch(event->scroll.direction)
-                       {
-                               case GDK_SCROLL_UP:
-                                       get_scrollx_adjustment()->set_value(get_scrollx_adjustment()->get_value()-scroll_pixel*pw);
-                                       break;
-                               case GDK_SCROLL_DOWN:
-                                       get_scrollx_adjustment()->set_value(get_scrollx_adjustment()->get_value()+scroll_pixel*pw);
-                                       break;
-                               case GDK_SCROLL_LEFT:
-                                       get_scrolly_adjustment()->set_value(get_scrolly_adjustment()->get_value()+scroll_pixel*ph);
-                                       break;
-                               case GDK_SCROLL_RIGHT:
-                                       get_scrolly_adjustment()->set_value(get_scrolly_adjustment()->get_value()-scroll_pixel*ph);
-                                       break;
-                               default:
-                                       break;
-                       }
-               }
-               else
-               {
-                       // Scroll in either direction by 20 pixels. Ideally, the
-                       // amount of pixels per scrolling event should be
-                       // configurable. Xara Xtreme currently uses an (hard
-                       // wired) amount 20 pixel, Inkscape defaults to 40 pixels.
-
-                       const int scroll_pixel = 20;
-
-                       switch(event->scroll.direction)
-                       {
-                               case GDK_SCROLL_UP:
-                                       get_scrolly_adjustment()->set_value(get_scrolly_adjustment()->get_value()+scroll_pixel*ph);
-                                       break;
-                               case GDK_SCROLL_DOWN:
-                                       get_scrolly_adjustment()->set_value(get_scrolly_adjustment()->get_value()-scroll_pixel*ph);
-                                       break;
-                               case GDK_SCROLL_LEFT:
-                                       get_scrollx_adjustment()->set_value(get_scrollx_adjustment()->get_value()-scroll_pixel*pw);
-                                       break;
-                               case GDK_SCROLL_RIGHT:
-                                       get_scrollx_adjustment()->set_value(get_scrollx_adjustment()->get_value()+scroll_pixel*pw);
-                                       break;
-                               default:
-                                       break;
-                       }
-               }
-       }
-               break;
-       default:
-               break;
-       }
-               return false;
-}
-
-bool
-WorkArea::on_hruler_event(GdkEvent */*event*/)
-{
-/*
-       switch(event->type)
-    {
-       case GDK_BUTTON_PRESS:
-               if(dragging==DRAG_NONE)
-               {
-                       dragging=DRAG_GUIDE;
-                       curr_guide=get_guide_list_y().insert(get_guide_list_y().begin());
-                       curr_guide_is_x=false;
-               }
-               return true;
-               break;
-
-       case GDK_MOTION_NOTIFY:
-               // Guide movement
-               if(dragging==DRAG_GUIDE && curr_guide_is_x==false)
-               {
-                       double y,x;
-                       if(event->button.axes)
-                       {
-                               x=(event->button.axes[0]);
-                               y=(event->button.axes[1]);
-                       }
-                       else
-                       {
-                               x=event->button.x;
-                               y=event->button.y;
-                       }
-
-                       if(isnan(y) || isnan(x))
-                               return false;
-
-                       *curr_guide=synfig::Point(screen_to_comp_coords(synfig::Point(x,y)))[1];
-
-                       queue_draw();
-               }
-               return true;
-               break;
-
-       case GDK_BUTTON_RELEASE:
-               if(dragging==DRAG_GUIDE && curr_guide_is_x==false)
-               {
-                       dragging=DRAG_NONE;
-                       get_guide_list_y().erase(curr_guide);
-               }
-               break;
-               return true;
-       default:
-               break;
-       }
-*/
-       return false;
-}
-
-bool
-WorkArea::on_vruler_event(GdkEvent */*event*/)
-{
-/*
-       switch(event->type)
-    {
-       case GDK_BUTTON_PRESS:
-               if(dragging==DRAG_NONE)
-               {
-                       dragging=DRAG_GUIDE;
-                       curr_guide=get_guide_list_x().insert(get_guide_list_x().begin());
-                       curr_guide_is_x=true;
-               }
-               return true;
-               break;
-       case GDK_BUTTON_RELEASE:
-               if(dragging==DRAG_GUIDE && curr_guide_is_x==true)
-               {
-                       dragging=DRAG_NONE;
-                       get_guide_list_x().erase(curr_guide);
-               }
-               break;
-               return true;
-       default:
-               break;
-       }
-*/
-       return false;
-}
-
-
-void
-WorkArea::refresh_dimension_info()
-{
-       synfig::RendDesc &rend_desc(get_canvas()->rend_desc());
-
-       canvaswidth=rend_desc.get_br()[0]-rend_desc.get_tl()[0];
-       canvasheight=rend_desc.get_br()[1]-rend_desc.get_tl()[1];
-
-       pw=canvaswidth/w;
-       ph=canvasheight/h;
-
-       scrollx_adjustment.set_page_increment(abs(get_grid_size()[0]));
-       scrollx_adjustment.set_step_increment(abs(pw));
-       scrollx_adjustment.set_lower(-abs(canvaswidth));
-       scrollx_adjustment.set_upper(abs(canvaswidth));
-       scrolly_adjustment.set_lower(-abs(canvasheight));
-       scrolly_adjustment.set_upper(abs(canvasheight));
-       scrolly_adjustment.set_step_increment(abs(ph));
-       scrolly_adjustment.set_page_increment(abs(get_grid_size()[1]));
-
-
-
-       if(drawing_area->get_width()<=0 || drawing_area->get_height()<=0 || w==0 || h==0)
-               return;
-
-       const synfig::Point focus_point(get_focus_point());
-       const synfig::Real x(focus_point[0]/pw+drawing_area->get_width()/2-w/2);
-       const synfig::Real y(focus_point[1]/ph+drawing_area->get_height()/2-h/2);
-
-       window_tl[0]=rend_desc.get_tl()[0]-pw*x;
-       window_br[0]=rend_desc.get_br()[0]+pw*(drawing_area->get_width()-x-w);
-
-       window_tl[1]=rend_desc.get_tl()[1]-ph*y;
-       window_br[1]=rend_desc.get_br()[1]+ph*(drawing_area->get_height()-y-h);
-
-       hruler->property_lower()=Distance(window_tl[0],Distance::SYSTEM_UNITS).get(App::distance_system,rend_desc);
-       hruler->property_upper()=Distance(window_br[0],Distance::SYSTEM_UNITS).get(App::distance_system,rend_desc);
-       vruler->property_lower()=Distance(window_tl[1],Distance::SYSTEM_UNITS).get(App::distance_system,rend_desc);
-       vruler->property_upper()=Distance(window_br[1],Distance::SYSTEM_UNITS).get(App::distance_system,rend_desc);
-
-       view_window_changed();
-}
-
-
-synfig::Point
-WorkArea::screen_to_comp_coords(synfig::Point pos)const
-{
-       synfig::RendDesc &rend_desc(get_canvas()->rend_desc());
-       //synfig::Vector::value_type canvaswidth=rend_desc.get_br()[0]-rend_desc.get_tl()[0];
-       //synfig::Vector::value_type canvasheight=rend_desc.get_br()[1]-rend_desc.get_tl()[1];
-       //synfig::Vector::value_type pw=canvaswidth/w;
-       //synfig::Vector::value_type ph=canvasheight/h;
-       Vector focus_point=get_focus_point();
-       synfig::Vector::value_type x=focus_point[0]/pw+drawing_area->get_width()/2-w/2;
-       synfig::Vector::value_type y=focus_point[1]/ph+drawing_area->get_height()/2-h/2;
-
-       return rend_desc.get_tl()-synfig::Point(pw*x,ph*y)+synfig::Point(pw*pos[0],ph*pos[1]);
-}
-
-synfig::Point
-WorkArea::comp_to_screen_coords(synfig::Point /*pos*/)const
-{
-       synfig::warning("WorkArea::comp_to_screen_coords: Not yet implemented");
-       return synfig::Point();
-}
-
-int
-WorkArea::next_unrendered_tile(int refreshes)const
-{
-       //assert(!tile_book.empty());
-       if(tile_book.empty())
-               return -1;
-
-       //const synfig::RendDesc &rend_desc(get_canvas()->rend_desc());
-
-       const synfig::Vector focus_point(get_focus_point());
-
-       // Calculate the window coordinates of the top-left
-       // corner of the canvas.
-       const synfig::Vector::value_type
-               x(focus_point[0]/pw+drawing_area->get_width()/2-w/2),
-               y(focus_point[1]/ph+drawing_area->get_height()/2-h/2);
-
-       int div = low_res_pixel_size;
-       const int width_in_tiles(w/tile_w+((low_resolution?((w/div)%(tile_w/div)):(w%tile_w))?1:0));
-       const int height_in_tiles(h/tile_h+(h%tile_h?1:0));
-
-       int
-               u(0),v(0),
-               u1(int(-x/tile_w)),
-               v1(int(-y/tile_h)),
-               u2(int((-x+drawing_area->get_width())/tile_w+1)),
-               v2(int((-y+drawing_area->get_height())/tile_h+1));
-
-       if(u2>width_in_tiles)u2=width_in_tiles;
-       if(v2>height_in_tiles)v2=height_in_tiles;
-       if(u1<0)u1=0;
-       if(v1<0)v1=0;
-
-       int last_good_tile(-1);
-
-       for(v=v1;v<v2;v++)
-               for(u=u1;u<u2;u++)
-               {
-                       int index(v*width_in_tiles+u);
-                       if(tile_book[index].second<refreshes)
-                       {
-                               last_good_tile=index;
-                               if(rand()%8==0)
-                                       return index;
-                       }
-               }
-       return last_good_tile;
-}
-
-/*
-template <typename F, typename T=WorkAreaRenderer, typename R=typename F::result_type>
-class handle2ptr_t : public std::unary_function<typename etl::handle<T>,R>
-{
-private:
-       F func;
-public:
-       handle2ptr_t(const F &func):func(func) { };
-
-       R operator()(typename etl::handle<T> x) { return func(*x); }
-};
-
-template <typename F>
-handle2ptr_t<F>
-handle2ptr(F func)
-{
-       return handle2ptr_t<F>(func);
-}
-       for_each(
-               renderer_set_.begin(),
-               renderer_set_.end(),
-               handle2ptr(
-                       sigc::bind(
-                               sigc::bind(
-                                       sigc::mem_fun(
-                                               &WorkAreaRenderer::render_vfunc
-                                       ),
-                                       Gdk::Rectangle(event->area)
-                               ),
-                               drawing_area->get_window()
-                       )
-               )
-       );
-*/
-
-bool
-WorkArea::refresh(GdkEventExpose*event)
-{
-       assert(get_canvas());
-
-       drawing_area->get_window()->clear();
-
-       //const synfig::RendDesc &rend_desc(get_canvas()->rend_desc());
-
-       const synfig::Vector focus_point(get_focus_point());
-
-       // Update the old focus point
-       last_focus_point=focus_point;
-
-       // Draw out the renderables
-       {
-               std::set<etl::handle<WorkAreaRenderer> >::iterator iter;
-               for(iter=renderer_set_.begin();iter!=renderer_set_.end();++iter)
-               {
-                       if((*iter)->get_enabled())
-                               (*iter)->render_vfunc(
-                                       drawing_area->get_window(),
-                                       Gdk::Rectangle(&event->area)
-                               );
-               }
-       }
-
-       // Calculate the window coordinates of the top-left
-       // corner of the canvas.
-       //const synfig::Vector::value_type
-       //      x(focus_point[0]/pw+drawing_area->get_width()/2-w/2),
-       //      y(focus_point[1]/ph+drawing_area->get_height()/2-h/2);
-
-       //const synfig::Vector::value_type window_startx(window_tl[0]);
-       //const synfig::Vector::value_type window_endx(window_br[0]);
-       //const synfig::Vector::value_type window_starty(window_tl[1]);
-       //const synfig::Vector::value_type window_endy(window_br[1]);
-
-       Glib::RefPtr<Gdk::GC> gc=Gdk::GC::create(drawing_area->get_window());
-
-       // If we are in animate mode, draw a red border around the screen
-       if(canvas_interface->get_mode()&synfigapp::MODE_ANIMATE)
-       {
-// #define USE_FRAME_BACKGROUND_TO_SHOW_EDIT_MODE
-#ifdef USE_FRAME_BACKGROUND_TO_SHOW_EDIT_MODE
-               // This method of drawing the red border doesn't work on any
-               // Gtk theme which uses the crux-engine, hcengine, industrial,
-               // mist, or ubuntulooks engine, such as the default ubuntu
-               // 'Human' theme.
-               drawing_frame->modify_bg(Gtk::STATE_NORMAL,Gdk::Color("#FF0000"));
-#else
-               // So let's do it in a more primitive fashion.
-               gc->set_rgb_fg_color(Gdk::Color("#FF0000"));
-               gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-               drawing_area->get_window()->draw_rectangle(
-                       gc,
-                       false,  // Fill?
-                       0,0,    // x,y
-                       drawing_area->get_width()-1,drawing_area->get_height()-1); // w,h
-#endif
-       }
-#ifdef USE_FRAME_BACKGROUND_TO_SHOW_EDIT_MODE
-       else
-               drawing_frame->unset_bg(Gtk::STATE_NORMAL);
-#endif
-
-       return true;
-}
-
-void
-WorkArea::done_rendering()
-{
-/*
-       assert(buffer);
-       assert(w>0);
-       assert(h>0);
-       pix_buf=Gdk::Pixbuf::create_from_data(
-               buffer, // pointer to the data
-               Gdk::COLORSPACE_RGB, // the colorspace
-               true, // has alpha?
-               8, // bits per sample
-               w,      // width
-               h,      // height
-               w*bpp); // stride (pitch)
-       assert(pix_buf);
-*/
-}
-
-
-void
-WorkArea::set_quality(int x)
-{
-       if(x==quality)
-               return;
-       quality=x;
-       queue_render_preview();
-}
-
-void
-WorkArea::set_low_res_pixel_size(int x)
-{
-       if(x==low_res_pixel_size)
-               return;
-       low_res_pixel_size=x;
-       queue_render_preview();
-}
-
-namespace studio
-{
-class WorkAreaProgress : public synfig::ProgressCallback
-{
-       WorkArea *work_area;
-       ProgressCallback *cb;
-
-public:
-
-       WorkAreaProgress(WorkArea *work_area,ProgressCallback *cb):
-               work_area(work_area),cb(cb)
-       {
-               assert(cb);
-       }
-
-       virtual bool
-       task(const std::string &str)
-       {
-               if(work_area->dirty)
-                       return false;
-               return cb->task(str);
-       }
-
-       virtual bool
-       error(const std::string &err)
-       {
-               if(work_area->dirty)
-                       return false;
-               return cb->error(err);
-       }
-
-       virtual bool
-       amount_complete(int current, int total)
-       {
-               if(work_area->dirty)
-                       return false;
-               return cb->amount_complete(current,total);
-       }
-};
-}
-
-bool
-studio::WorkArea::async_update_preview()
-{
-#ifdef SINGLE_THREADED
-       if (get_updating())
-       {
-               stop_updating();
-               queue_render_preview();
-               return false;
-       }
-#endif
-
-       async_renderer=0;
-
-       queued=false;
-       canceled_=false;
-       get_canvas_view()->reset_cancel_status();
-
-       // This object will mark us as busy until
-       // we are done.
-       //studio::App::Busy busy;
-
-       //WorkAreaProgress callback(this,get_canvas_view()->get_ui_interface().get());
-       //synfig::ProgressCallback *cb=&callback;
-
-       if(!is_visible())return false;
-
-       /*
-       // If we are queued to render the scene at the next idle
-       // go ahead and de-queue it.
-       if(render_idle_func_id)
-       {
-               g_source_remove(render_idle_func_id);
-               //queued=false;
-               render_idle_func_id=0;
-       }
-       */
-
-       dirty=false;
-       get_canvas_view()->reset_cancel_status();
-
-       //bool ret=false;
-       RendDesc desc=get_canvas()->rend_desc();
-
-       int w=(int)(desc.get_w()*zoom);
-       int h=(int)(desc.get_h()*zoom);
-
-       // ensure that the size we draw is at least one pixel in each dimension
-       int min_size = low_resolution ? low_res_pixel_size : 1;
-       if (w < min_size) w = min_size;
-       if (h < min_size) h = min_size;
-
-       // Setup the description parameters
-       desc.set_antialias(1);
-       desc.set_time(cur_time);
-
-       set_rend_desc(desc);
-
-       // Create the render target
-       handle<Target> target;
-
-       // if we have lots of pixels to render and the tile renderer isn't disabled, use it
-       int div;
-       div = low_resolution ? low_res_pixel_size : 1;
-       if ((w*h > 240*div*135*div && !getenv("SYNFIG_DISABLE_TILE_RENDER")) || getenv("SYNFIG_FORCE_TILE_RENDER"))
-       {
-               // do a tile render
-               handle<WorkAreaTarget> trgt(new class WorkAreaTarget(this,w,h));
-
-               trgt->set_rend_desc(&desc);
-               trgt->set_onion_skin(get_onion_skin(), onion_skins);
-               target=trgt;
-       }
-       else
-       {
-               // do a scanline render
-               handle<WorkAreaTarget_Full> trgt(new class WorkAreaTarget_Full(this,w,h));
-
-               trgt->set_rend_desc(&desc);
-               trgt->set_onion_skin(get_onion_skin(), onion_skins);
-               target=trgt;
-       }
-
-       // We can rest assured that our time has already
-       // been set, so there is no need to have to
-       // recalculate that over again.
-       // UPDATE: This is kind of needless with
-       // the way that time is handled now in SYNFIG.
-       //target->set_avoid_time_sync(true);
-       async_renderer=new AsyncRenderer(target);
-       async_renderer->signal_finished().connect(
-               sigc::mem_fun(this,&WorkArea::async_update_finished)
-       );
-
-       rendering=true;
-       async_renderer->start();
-
-       synfig::ProgressCallback *cb=get_canvas_view()->get_ui_interface().get();
-
-       rendering=true;
-       cb->task(_("Rendering..."));
-       rendering=true;
-
-       return true;
-}
-
-void
-studio::WorkArea::async_update_finished()
-{
-       synfig::ProgressCallback *cb=get_canvas_view()->get_ui_interface().get();
-
-       rendering=false;
-
-       if(!async_renderer)
-               return;
-
-       // If we completed successfully, then
-       // we aren't dirty anymore
-       if(async_renderer->has_success())
-       {
-               dirty=false;
-               //queued=false;
-               cb->task(_("Idle"));
-       }
-       else
-       {
-               dirty=true;
-               cb->task(_("Render Failed"));
-       }
-       //get_canvas_view()->reset_cancel_status();
-       done_rendering();
-}
-
-bool
-studio::WorkArea::sync_update_preview()
-{
-       //      const Time &time(cur_time);
-
-       canceled_=false;
-       get_canvas_view()->reset_cancel_status();
-
-       async_renderer=0;
-
-again:
-       // This object will mark us as busy until
-       // we are done.
-       studio::App::Busy busy;
-
-       WorkAreaProgress callback(this,get_canvas_view()->get_ui_interface().get());
-       synfig::ProgressCallback *cb=&callback;
-
-       // We don't want to render if we are already rendering
-       if(rendering)
-       {
-               dirty=true;
-               return false;
-       }
-
-       if(!is_visible())return false;
-       get_canvas()->set_time(get_time());
-       get_canvas_view()->get_smach().process_event(EVENT_REFRESH_DUCKS);
-       signal_rendering()();
-
-       // If we are queued to render the scene at the next idle
-       // go ahead and de-queue it.
-       if(render_idle_func_id)
-       {
-               g_source_remove(render_idle_func_id);
-               //queued=false;
-               render_idle_func_id=0;
-       }
-       // Start rendering
-       rendering=true;
-
-       dirty=false;
-       get_canvas_view()->reset_cancel_status();
-
-       RendDesc desc=get_canvas()->rend_desc();
-       //newdesc->set_flags(RendDesc::PX_ASPECT|RendDesc::IM_SPAN);
-
-       int w=(int)(desc.get_w()*zoom);
-       int h=(int)(desc.get_h()*zoom);
-
-       // Setup the description parameters
-       desc.set_antialias(1);
-       desc.set_time(cur_time);
-       //desc.set_wh(w,h);
-
-       set_rend_desc(desc);
-
-       // Create the render target
-       handle<WorkAreaTarget> target(new class WorkAreaTarget(this,w,h));
-
-       target->set_rend_desc(&desc);
-
-       // We can rest assured that our time has already
-       // been set, so there is no need to have to
-       // recalculate that over again.
-       target->set_avoid_time_sync(true);
-
-       if(cb)
-               cb->task(strprintf(_("Rendering canvas %s..."),get_canvas()->get_name().c_str()));
-
-       bool ret = target->render(cb);
-
-       if(!ret && !get_canvas_view()->get_cancel_status() && dirty)
-       {
-               rendering=false;
-               //canceled_=true;
-               goto again;
-       }
-       if(get_canvas_view()->get_cancel_status())
-               canceled_=true;
-
-       if(cb)
-       {
-               if(ret)
-                       cb->task(_("Idle"));
-               else
-                       cb->task(_("Render Failed"));
-               cb->amount_complete(0,1);
-       }
-
-       // Refresh the work area to make sure that
-       // it is being displayed correctly
-       drawing_area->queue_draw();
-
-       // If we completed successfully, then
-       // we aren't dirty anymore
-       if(ret)
-       {
-               dirty=false;
-               //queued=false;
-       }
-       else dirty=true;
-       rendering=false;
-       //get_canvas_view()->reset_cancel_status();
-       done_rendering();
-       return ret;
-}
-
-void
-studio::WorkArea::async_render_preview(synfig::Time time)
-{
-       cur_time=time;
-       //tile_book.clear();
-
-       refreshes+=5;
-       if(!is_visible())return;
-
-       get_canvas()->set_time(get_time());
-       get_canvas_view()->get_smach().process_event(EVENT_REFRESH_DUCKS);
-       signal_rendering()();
-
-       async_update_preview();
-}
-void
-WorkArea::async_render_preview()
-{
-       return async_render_preview(get_canvas_view()->get_time());
-}
-
-bool
-studio::WorkArea::sync_render_preview(synfig::Time time)
-{
-       cur_time=time;
-       //tile_book.clear();
-       refreshes+=5;
-       if(!is_visible())return false;
-       return sync_update_preview();
-}
-
-bool
-WorkArea::sync_render_preview()
-{
-       return sync_render_preview(get_canvas_view()->get_time());
-}
-
-void
-WorkArea::sync_render_preview_hook()
-{
-       sync_render_preview(get_canvas_view()->get_time());
-}
-
-void
-WorkArea::queue_scroll()
-{
-//     const synfig::RendDesc &rend_desc(get_canvas()->rend_desc());
-
-       const synfig::Point focus_point(get_focus_point());
-
-       const synfig::Real
-               new_x(focus_point[0]/pw+drawing_area->get_width()/2-w/2),
-               new_y(focus_point[1]/ph+drawing_area->get_height()/2-h/2);
-
-       const synfig::Real
-               old_x(last_focus_point[0]/pw+drawing_area->get_width()/2-w/2),
-               old_y(last_focus_point[1]/ph+drawing_area->get_height()/2-h/2);
-
-       // If the coordinates didn't change, we shouldn't queue a draw
-       if(old_x==new_x && old_y==new_y)
-               return;
-
-       const int
-               dx(round_to_int(old_x)-round_to_int(new_x)),
-               dy(round_to_int(old_y)-round_to_int(new_y));
-
-       drawing_area->get_window()->scroll(-dx,-dy);
-
-       if (timecode_width && timecode_height)
-       {
-               drawing_area->queue_draw_area(4,       4,    4+timecode_width,    4+timecode_height);
-               drawing_area->queue_draw_area(4-dx, 4-dy, 4-dx+timecode_width, 4-dy+timecode_height);
-       }
-
-#ifndef USE_FRAME_BACKGROUND_TO_SHOW_EDIT_MODE
-       if(canvas_interface->get_mode()&synfigapp::MODE_ANIMATE)
-       {
-               int maxx = drawing_area->get_width()-1;
-               int maxy = drawing_area->get_height()-1;
-
-               if (dx > 0)
-               {
-                       drawing_area->queue_draw_area(      0, 0,       1, maxy);
-                       drawing_area->queue_draw_area(maxx-dx, 0, maxx-dx, maxy);
-               }
-               else if (dx < 0)
-               {
-                       drawing_area->queue_draw_area(   maxx, 0,    maxx, maxy);
-                       drawing_area->queue_draw_area(    -dx, 0,     -dx, maxy);
-               }
-               if (dy > 0)
-               {
-                       drawing_area->queue_draw_area(0,       0, maxx,       1);
-                       drawing_area->queue_draw_area(0, maxy-dy, maxx, maxy-dy);
-               }
-               else if (dy < 0)
-               {
-                       drawing_area->queue_draw_area(0,    maxy, maxx,    maxy);
-                       drawing_area->queue_draw_area(0,     -dy, maxx,     -dy);
-               }
-       }
-#endif // USE_FRAME_BACKGROUND_TO_SHOW_EDIT_MODE
-
-       last_focus_point=focus_point;
-}
-
-void
-studio::WorkArea::zoom_in()
-{
-       set_zoom(zoom*1.25);
-}
-
-void
-studio::WorkArea::zoom_out()
-{
-       set_zoom(zoom/1.25);
-}
-
-void
-studio::WorkArea::zoom_fit()
-{
-       float new_zoom(min(drawing_area->get_width() * zoom / w,
-                                          drawing_area->get_height() * zoom / h) * 0.995);
-       if (zoom / new_zoom > 0.995 && new_zoom / zoom > 0.995)
-       {
-               set_zoom(prev_zoom);
-               return set_focus_point(previous_focus);
-       }
-       previous_focus = get_focus_point();
-       prev_zoom = zoom;
-       set_zoom(new_zoom);
-       set_focus_point(Point(0,0));
-}
-
-void
-studio::WorkArea::zoom_norm()
-{
-       if (zoom == 1.0) return set_zoom(prev_zoom);
-       prev_zoom = zoom;
-       set_zoom(1.0f);
-}
-
-gboolean
-studio::WorkArea::__render_preview(gpointer data)
-{
-       WorkArea *work_area(static_cast<WorkArea*>(data));
-
-       // there's no point anyone trying to cancel the timer now - it's gone off already
-       work_area->render_idle_func_id = 0;
-
-       work_area->queued=false;
-       work_area->async_render_preview(work_area->get_canvas_view()->get_time());
-
-       return 0;
-}
-
-void
-studio::WorkArea::queue_render_preview()
-{
-       //synfig::info("queue_render_preview(): called for %s", get_canvas_view()->get_time().get_string().c_str());
-
-       if(queued==true)
-       {
-               return;
-               //synfig::info("queue_render_preview(): already queued, unqueuing");
-/*             if(render_idle_func_id)
-                       g_source_remove(render_idle_func_id);
-               render_idle_func_id=0;
-               queued=false;
-*/
-               //async_renderer=0;
-       }
-
-       if(dirty_trap_enabled)
-       {
-               dirty_trap_queued++;
-               return;
-       }
-
-       int queue_time=50;
-
-       if(rendering)
-               queue_time+=250;
-
-
-       if(queued==false)
-       {
-               //synfig::info("queue_render_preview(): (re)queuing...");
-               //render_idle_func_id=g_idle_add_full(G_PRIORITY_DEFAULT,__render_preview,this,NULL);
-               render_idle_func_id=g_timeout_add_full(
-                       G_PRIORITY_DEFAULT,     // priority -
-                       queue_time,                     // interval - the time between calls to the function, in milliseconds (1/1000ths of a second)
-                       __render_preview,       // function - function to call
-                       this,                           // data     - data to pass to function
-                       NULL);                          // notify   - function to call when the idle is removed, or NULL
-               queued=true;
-       }
-/*     else if(rendering)
-       {
-               refreshes+=5;
-               dirty=true;
-               queue_draw();
-       }
-*/
-}
-
-DirtyTrap::DirtyTrap(WorkArea *work_area):work_area(work_area)
-{
-       work_area->dirty_trap_enabled=true;
-
-       work_area->dirty_trap_queued=0;
-}
-
-DirtyTrap::~DirtyTrap()
-{
-       work_area->dirty_trap_enabled=false;
-       if(work_area->dirty_trap_queued)
-               work_area->queue_render_preview();
-}
-
-void
-studio::WorkArea::queue_draw_preview()
-{
-       drawing_area->queue_draw();
-}
-
-void
-studio::WorkArea::set_cursor(const Gdk::Cursor& x)
-{
-       drawing_area->get_window()->set_cursor(x);
-}
-void
-studio::WorkArea::set_cursor(Gdk::CursorType x)
-{
-       drawing_area->get_window()->set_cursor(Gdk::Cursor(x));
-}
-
-//#include "iconcontroller.h"
-void
-studio::WorkArea::refresh_cursor()
-{
-//     set_cursor(IconController::get_tool_cursor(canvas_view->get_smach().get_state_name(),drawing_area->get_window()));
-}
-
-void
-studio::WorkArea::reset_cursor()
-{
-       drawing_area->get_window()->set_cursor(Gdk::Cursor(Gdk::TOP_LEFT_ARROW));
-//     set_cursor(Gdk::TOP_LEFT_ARROW);
-}
-
-void
-studio::WorkArea::set_zoom(float z)
-{
-       z=max(1.0f/128.0f,min(128.0f,z));
-       if(z==zoom)
-               return;
-       zoom = z;
-       refresh_dimension_info();
-       /*if(async_renderer)
-       {
-               async_renderer->stop();
-               async_renderer=0;
-       }*/
-       refreshes+=5;
-       async_update_preview();
-       //queue_render_preview();
-}
-
-void
-WorkArea::set_selected_value_node(etl::loose_handle<synfig::ValueNode> x)
-{
-       if(x!=selected_value_node_)
-       {
-               selected_value_node_=x;
-               queue_draw();
-       }
-}
-
-void
-WorkArea::insert_renderer(const etl::handle<WorkAreaRenderer> &x)
-{
-       renderer_set_.insert(x);
-       x->set_work_area(this);
-       queue_draw();
-}
-
-void
-WorkArea::insert_renderer(const etl::handle<WorkAreaRenderer> &x, int priority)
-{
-       x->set_priority(priority);
-       insert_renderer(x);
-}
-
-void
-WorkArea::erase_renderer(const etl::handle<WorkAreaRenderer> &x)
-{
-       x->set_work_area(0);
-       renderer_set_.erase(x);
-       queue_draw();
-}
-
-void
-WorkArea::resort_render_set()
-{
-       std::set<etl::handle<WorkAreaRenderer> > tmp(
-               renderer_set_.begin(),
-               renderer_set_.end()
-       );
-       renderer_set_.swap(tmp);
-       queue_draw();
-}
diff --git a/synfig-studio/src/gtkmm/workarea.h b/synfig-studio/src/gtkmm/workarea.h
deleted file mode 100644 (file)
index 989ac8d..0000000
+++ /dev/null
@@ -1,515 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file workarea.h
-**     \brief Template Header
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 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
-*/
-/* ========================================================================= */
-
-/* === S T A R T =========================================================== */
-
-#ifndef __SYNFIG_GTKMM_WORKAREA_H
-#define __SYNFIG_GTKMM_WORKAREA_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <list>
-#include <map>
-#include <set>
-
-#include <ETL/smart_ptr>
-#include <ETL/handle>
-
-#include <gtkmm/drawingarea.h>
-#include <gtkmm/table.h>
-#include <gtkmm/adjustment.h>
-#include <gtkmm/ruler.h>
-#include <gtkmm/image.h>
-#include <gdkmm/pixbuf.h>
-#include <gdkmm/cursor.h>
-#include <gdkmm/device.h>
-
-#include <synfig/time.h>
-#include <synfig/vector.h>
-#include <synfig/general.h>
-#include <synfig/renddesc.h>
-#include <synfig/canvas.h>
-
-#include "zoomdial.h"
-#include "duckmatic.h"
-#include "instance.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 etl {
-
-template <typename T_, typename C_=std::less<T_,T_> >
-class dereferenced_compare
-{
-public:
-       typedef etl::loose_handle<T_> first_argument_type;
-       typedef etl::loose_handle<T_> second_argument_type;
-       typedef bool result_type;
-
-}
-};
-*/
-
-namespace synfigapp { class CanvasInterface; };
-
-namespace synfig { class Layer; };
-namespace Gtk { class Frame; };
-
-namespace studio
-{
-class WorkAreaTarget;
-class WorkAreaTarget_Full;
-
-class Instance;
-class CanvasView;
-class WorkArea;
-class WorkAreaRenderer;
-class AsyncRenderer;
-class DirtyTrap
-{
-       friend class WorkArea;
-       WorkArea *work_area;
-public:
-       DirtyTrap(WorkArea *work_area);
-       ~DirtyTrap();
-};
-
-
-class WorkArea : public Gtk::Table, public Duckmatic
-{
-       friend class WorkAreaTarget;
-       friend class WorkAreaTarget_Full;
-       friend class DirtyTrap;
-       friend class WorkAreaRenderer;
-       friend class WorkAreaProgress;
-
-       /*
- -- ** -- P U B L I C   T Y P E S ---------------------------------------------
-       */
-
-public:
-
-       void insert_renderer(const etl::handle<WorkAreaRenderer> &x);
-       void insert_renderer(const etl::handle<WorkAreaRenderer> &x,int priority);
-       void erase_renderer(const etl::handle<WorkAreaRenderer> &x);
-       void resort_render_set();
-
-       enum DragMode
-       {
-               DRAG_NONE=0,
-               DRAG_WINDOW,
-               DRAG_DUCK,
-               DRAG_GUIDE,
-               DRAG_BOX
-       };
-
-       /*
- -- ** -- P R I V A T E   D A T A ---------------------------------------------
-       */
-
-private:
-
-       std::set<etl::handle<WorkAreaRenderer> > renderer_set_;
-
-       etl::handle<studio::AsyncRenderer> async_renderer;
-
-
-       etl::loose_handle<synfigapp::CanvasInterface> canvas_interface;
-       etl::handle<synfig::Canvas> canvas;
-       etl::loose_handle<studio::Instance> instance;
-       etl::loose_handle<studio::CanvasView> canvas_view;
-
-       // Widgets
-       Gtk::DrawingArea *drawing_area;
-       Gtk::Adjustment scrollx_adjustment;
-       Gtk::Adjustment scrolly_adjustment;
-       Gtk::VRuler *vruler;
-       Gtk::HRuler *hruler;
-       Gtk::Button *menubutton;
-       Gtk::Frame *drawing_frame;
-
-       GdkDevice* curr_input_device;
-
-       // Bleh!
-       int     w;                                              //!< Width of the image (in pixels)
-       int     h;                                              //!< Height of the image (in pixels)
-       synfig::Real    canvaswidth;    //!< Width of the canvas
-       synfig::Real    canvasheight;   //!< Height of the canvas
-       synfig::Real    pw;                             //!< The width of a pixel
-       synfig::Real    ph;                             //!< The height of a pixel
-       float zoom;                                     //!< Zoom factor
-       float prev_zoom;                        //!< Previous Zoom factor
-       synfig::Point window_tl;                //!< The (theoretical) top-left corner of the view window
-       synfig::Point window_br;                //!< The (theoretical) bottom-right corner of the view window
-
-       guint32 last_event_time;
-
-       int bpp;
-       //unsigned char *buffer;
-
-       //! ???
-       synfig::ProgressCallback *progresscallback;
-
-       //! ???
-       synfig::RendDesc desc;
-
-       //! This flag is set if the user is dragging the video window
-       /*! \see drag_point */
-       DragMode dragging;
-
-       etl::handle<Duckmatic::Duck> clicked_duck;
-       etl::handle<Duckmatic::Duck> hover_duck;
-
-       //! When dragging the viewport, this is set to the origin of the drag
-       synfig::Point drag_point;
-
-       synfig::Point curr_point;
-
-       //! ???
-       synfig::Point previous_focus;
-
-       //! This flag is set if the grid should be drawn
-       bool show_grid;
-
-       //! This flag is set if the guides should be drawn
-       bool show_guides;
-
-       bool low_resolution;
-
-       bool meta_data_lock;
-
-       //! This flag is set if the entire frame is rendered rather than using tiles
-       bool full_frame;
-
-       //Glib::RefPtr<Gdk::Pixbuf> pix_buf;
-
-       //! This vector holds all of the tiles for this image
-       std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> > tile_book;
-
-       //! This integer describes the total times that the work are has been refreshed
-       int refreshes;
-
-       //! This list holds the queue of tiles that need to be rendered
-       //std::list<int> tile_queue;
-
-       int tile_w, tile_h;
-
-       gint render_idle_func_id;
-
-       //! The coordinates of the focus the last time a part of the screen was refreshed
-       synfig::Point last_focus_point;
-
-       bool canceled_;
-
-       int quality;
-       int low_res_pixel_size;
-
-       bool dirty_trap_enabled;
-
-       int dirty_trap_queued;
-
-
-       bool onion_skin;
-       //! stores the future [1] and past [0] onion skins based on keyframes
-       int onion_skins[2];
-
-       etl::loose_handle<synfig::ValueNode> selected_value_node_;
-
-       bool allow_duck_clicks;
-       bool allow_layer_clicks;
-       bool cancel;
-       bool curr_guide_is_x;
-       bool dirty;
-       bool queued;
-       bool rendering;
-
-       /*
- -- ** -- P U B L I C   D A T A -----------------------------------------------
-       */
-
-public:
-
-       const etl::loose_handle<synfig::ValueNode>& get_selected_value_node() { return  selected_value_node_; }
-       const synfig::Point& get_drag_point()const { return drag_point; }
-       std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> >& get_tile_book(){ return tile_book; }
-       int get_refreshes()const { return refreshes; }
-       bool get_canceled()const { return canceled_; }
-       bool get_queued()const { return queued; }
-       bool get_rendering()const { return rendering; }
-#ifdef SINGLE_THREADED
-       bool get_updating()const;
-       void stop_updating(bool cancel = false);
-#endif
-       bool get_full_frame()const { return full_frame; }
-       //int get_w()const { return w; }
-       //int get_h()const { return h; }
-
-       int get_tile_w()const { return tile_w; }
-       int get_tile_h()const { return tile_h; }
-
-       bool get_allow_layer_clicks() { return allow_layer_clicks; }
-       void set_allow_layer_clicks(bool value) { allow_layer_clicks=value; }
-
-       bool get_allow_duck_clicks() { return allow_duck_clicks; }
-       void set_allow_duck_clicks(bool value) { allow_duck_clicks=value; }
-
-       // used in renderer_ducks.cpp
-       bool solid_lines;
-
-       // used in renderer_guides.cpp
-       GuideList::iterator curr_guide;
-
-       // used in renderer_timecode.cpp
-       int timecode_width, timecode_height;
-
-       /*
- -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
-       */
-
-private:
-
-       //unsigned char *get_buffer() { return buffer; }
-       bool set_wh(int w, int h,int chan=3);
-
-       int next_unrendered_tile(int refreshes)const;
-       int next_unrendered_tile()const { return next_unrendered_tile(refreshes); }
-
-       /*
- -- ** -- S I G N A L S -------------------------------------------------------
-       */
-
-private:
-
-       sigc::signal<void,GdkDevice* > signal_input_device_changed_;
-
-       //! One signal per button
-       sigc::signal<void,synfig::Point> signal_user_click_[5];
-
-       sigc::signal<void> signal_popup_menu_;
-
-       sigc::signal<void> signal_cursor_moved_;
-       sigc::signal<void> signal_rendering_;
-
-       sigc::signal<void> signal_onion_skin_changed_;
-
-       //! Signal for when the user clicks on a layer
-       sigc::signal<void, etl::handle<synfig::Layer> > signal_layer_selected_;
-
-       sigc::signal<void> signal_view_window_changed_;
-
-public:
-
-       sigc::signal<void>& signal_onion_skin_changed() { return signal_onion_skin_changed_; }
-
-       sigc::signal<void>& signal_rendering() { return signal_rendering_; }
-
-       sigc::signal<void>& signal_cursor_moved() { return signal_cursor_moved_; }
-
-       sigc::signal<void>& signal_view_window_changed() { return signal_view_window_changed_; }
-       void view_window_changed() { signal_view_window_changed()(); }
-
-       sigc::signal<void,GdkDevice* >& signal_input_device_changed() { return signal_input_device_changed_; }
-
-       sigc::signal<void> &signal_popup_menu() { return signal_popup_menu_; }
-
-       //! One signal per button (5 buttons)
-       sigc::signal<void,synfig::Point> &signal_user_click(int button=0){ return signal_user_click_[button]; }
-
-       sigc::signal<void, etl::handle<synfig::Layer> >& signal_layer_selected() { return signal_layer_selected_; }
-
-       /*
- -- ** -- P U B L I C   M E T H O D S -----------------------------------------
-       */
-
-public:
-       void set_onion_skin(bool x);
-       bool get_onion_skin()const;
-       void toggle_onion_skin() { set_onion_skin(!get_onion_skin()); }
-       void set_onion_skins(int *onions);
-
-       void set_selected_value_node(etl::loose_handle<synfig::ValueNode> x);
-
-       bool is_dragging() { return dragging!=DRAG_NONE; }
-
-       DragMode get_dragging_mode() { return dragging; }
-
-       WorkArea(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface);
-       virtual ~WorkArea();
-
-       void set_cursor(const Gdk::Cursor& x);
-       void set_cursor(Gdk::CursorType x);
-
-       const synfig::Point& get_cursor_pos()const { return curr_point; }
-
-       Gtk::Adjustment *get_scrollx_adjustment() { return &scrollx_adjustment; }
-       Gtk::Adjustment *get_scrolly_adjustment() { return &scrolly_adjustment; }
-       const Gtk::Adjustment *get_scrollx_adjustment()const { return &scrollx_adjustment; }
-       const Gtk::Adjustment *get_scrolly_adjustment()const { return &scrolly_adjustment; }
-
-       void set_instance(etl::loose_handle<studio::Instance> x) { instance=x; }
-       void set_canvas(etl::handle<synfig::Canvas> x) { canvas=x; }
-       void set_canvas_view(etl::loose_handle<studio::CanvasView> x) { canvas_view=x; }
-       etl::handle<synfig::Canvas> get_canvas()const { return canvas; }
-       etl::handle<studio::Instance> get_instance()const { return instance; }
-       etl::loose_handle<studio::CanvasView> get_canvas_view()const { return canvas_view; }
-
-       void refresh_dimension_info();
-
-       //! Enables showing of the grid
-       void enable_grid();
-
-       //! Disables showing of the grid
-       void disable_grid();
-
-       //! Toggles the showing of the grid
-       void toggle_grid();
-
-       //! Returns the state of the show_grid flag
-       bool grid_status()const { return show_grid; }
-
-       void toggle_grid_snap() { Duckmatic::toggle_grid_snap(); }
-
-       bool get_show_guides()const { return show_guides; }
-       void set_show_guides(bool x);
-       void toggle_show_guides() { set_show_guides(!get_show_guides()); }
-
-       bool get_low_resolution_flag()const { return low_resolution; }
-       void set_low_resolution_flag(bool x);
-       void toggle_low_resolution_flag();
-
-       //! ???
-       void queue_scroll();
-
-       //! Sets the size of the grid
-       void set_grid_size(const synfig::Vector &s);
-
-       //! ??
-       void popup_menu();
-
-       int get_quality()const { return quality; }
-       int get_low_res_pixel_size()const { return low_res_pixel_size; }
-
-       void set_quality(int x);
-       void set_low_res_pixel_size(int x);
-
-
-       int get_w()const { return w; }
-       int get_h()const { return h; }
-       int get_bpp()const { return bpp; }
-
-       //! ??
-       const synfig::RendDesc &get_rend_desc()const { return desc; }
-
-       //! ??
-       void set_rend_desc(const synfig::RendDesc &x) { desc=x; }
-
-       //! Converts screen coords (ie: pixels) to composition coordinates
-       synfig::Point screen_to_comp_coords(synfig::Point pos)const;
-
-       //! Converts composition coordinates to screen coords (ie: pixels)
-       synfig::Point comp_to_screen_coords(synfig::Point pos)const;
-
-       float get_pw()const { return pw; }
-       float get_ph()const { return ph; }
-
-       const synfig::Point &get_window_tl()const { return window_tl; }
-       const synfig::Point &get_window_br()const { return window_br; }
-
-
-       bool async_update_preview();
-       void async_update_finished();
-       void async_render_preview(synfig::Time time);
-       void async_render_preview();
-
-       bool sync_update_preview();
-       bool sync_render_preview(synfig::Time time);
-       bool sync_render_preview();
-       void sync_render_preview_hook();
-
-       void queue_render_preview();
-
-
-       void queue_draw_preview();
-
-       void zoom_in();
-       void zoom_out();
-       void zoom_fit();
-       void zoom_norm();
-       float get_zoom()const { return zoom; }
-
-       void set_zoom(float z);
-
-
-       void set_progress_callback(synfig::ProgressCallback *x) { progresscallback=x; }
-       synfig::ProgressCallback *get_progress_callback() { return progresscallback; }
-
-       void set_focus_point(const synfig::Point &x);
-
-       synfig::Point get_focus_point()const;
-
-       void done_rendering();
-
-       bool refresh(GdkEventExpose*bleh=NULL);
-
-       void reset_cursor();
-       void refresh_cursor();
-
-       void save_meta_data();
-       void load_meta_data();
-
-       /*
- -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
-       */
-
-private:
-       bool on_key_press_event(GdkEventKey* event);
-       bool on_drawing_area_event(GdkEvent* event);
-       bool on_hruler_event(GdkEvent* event);
-       bool on_vruler_event(GdkEvent* event);
-
-       /*
- -- ** -- S T A T I C   P U B L I C   M E T H O D S ---------------------------
-       */
-
-public:
-
-       /*
- -- ** -- S T A T I C   P R I V A T E   M E T H O D S -------------------------
-       */
-
-private:
-
-       static gboolean __render_preview(gpointer data);
-
-}; // END of class WorkArea
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/workarearenderer.cpp b/synfig-studio/src/gtkmm/workarearenderer.cpp
deleted file mode 100644 (file)
index 303bc03..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file workarearenderer.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "workarearenderer.h"
-#include "workarea.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 ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-WorkAreaRenderer::WorkAreaRenderer():
-       enabled_(true),
-       priority_(0)
-{
-}
-
-WorkAreaRenderer::~WorkAreaRenderer()
-{
-}
-
-bool
-WorkAreaRenderer::get_enabled_vfunc()const
-{
-       return enabled_;
-}
-
-void
-WorkAreaRenderer::set_enabled(bool x)
-{
-       if(x==enabled_)
-               return;
-       enabled_=x;
-       signal_changed()();
-}
-
-void
-WorkAreaRenderer::set_priority(int x)
-{
-       if(x==priority_)
-               return;
-       priority_=x;
-       signal_changed()();
-}
-
-void
-WorkAreaRenderer::set_work_area(WorkArea* x)
-{
-       work_area_=x;
-}
-
-void
-WorkAreaRenderer::render_vfunc(
-       const Glib::RefPtr<Gdk::Drawable>& /*window*/,
-       const Gdk::Rectangle& /*expose_area*/
-)
-{
-}
-
-bool
-WorkAreaRenderer::event_vfunc(
-       GdkEvent* /*event*/
-)
-{
-       return false;
-}
-
-int
-WorkAreaRenderer::get_w()const
-{ return get_work_area()->get_w(); }
-int
-WorkAreaRenderer::get_h()const
-{ return get_work_area()->get_h(); }
-
-float
-WorkAreaRenderer::get_pw()const
-{ return get_work_area()->get_pw(); }
-float
-WorkAreaRenderer::get_ph()const
-{ return get_work_area()->get_ph(); }
-
-synfig::Point
-WorkAreaRenderer::screen_to_comp_coords(synfig::Point pos)const
-{
-       return get_work_area()->screen_to_comp_coords(pos);
-}
-
-synfig::Point
-WorkAreaRenderer::comp_to_screen_coords(synfig::Point pos)const
-{
-       return get_work_area()->comp_to_screen_coords(pos);
-}
diff --git a/synfig-studio/src/gtkmm/workarearenderer.h b/synfig-studio/src/gtkmm/workarearenderer.h
deleted file mode 100644 (file)
index fd79bb6..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file workarearenderer.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_WORKAREARENDERER_H
-#define __SYNFIG_WORKAREARENDERER_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <ETL/handle>
-#include <sigc++/signal.h>
-#include <sigc++/object.h>
-#include <synfig/vector.h>
-#include <gdkmm/drawable.h>
-#include <gdkmm/rectangle.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 WorkArea;
-
-class WorkAreaRenderer : public etl::shared_object, public sigc::trackable
-{
-public:
-       typedef etl::handle<WorkAreaRenderer> Handle;
-       typedef etl::loose_handle<WorkAreaRenderer> LooseHandle;
-
-private:
-       bool enabled_;
-       int priority_;
-
-       sigc::signal<void> signal_changed_;
-
-       WorkArea* work_area_;
-
-public:
-
-       sigc::signal<void>& signal_changed() { return signal_changed_; }
-
-public:
-       int get_w()const;
-       int get_h()const;
-
-       float get_pw()const;
-       float get_ph()const;
-
-       //! Converts screen coords (ie: pixels) to composition coordinates
-       synfig::Point screen_to_comp_coords(synfig::Point pos)const;
-
-       //! Converts composition coordinates to screen coords (ie: pixels)
-       synfig::Point comp_to_screen_coords(synfig::Point pos)const;
-
-       WorkAreaRenderer();
-       virtual ~WorkAreaRenderer();
-
-       bool get_enabled()const { return get_enabled_vfunc(); }
-       int get_priority()const { return priority_; }
-       WorkArea* get_work_area()const { return work_area_; }
-
-       void set_enabled(bool x);
-       void set_priority(int x);
-       void set_work_area(WorkArea* work_area_);
-
-       virtual void render_vfunc(
-               const Glib::RefPtr<Gdk::Drawable>& window,
-               const Gdk::Rectangle& expose_area
-       );
-
-       virtual bool event_vfunc(
-               GdkEvent* event
-       );
-
-protected:
-
-       virtual bool get_enabled_vfunc()const;
-
-public:
-       bool operator<(const WorkAreaRenderer &rhs)
-               { return priority_<rhs.priority_; }
-};
-
-inline bool operator<(const WorkAreaRenderer::Handle &lhs,const WorkAreaRenderer::Handle &rhs)
-       { return lhs->get_priority() < rhs->get_priority(); }
-
-inline bool operator<(const WorkAreaRenderer::LooseHandle &lhs,const WorkAreaRenderer::LooseHandle &rhs)
-       { return lhs->get_priority() < rhs->get_priority(); }
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gtkmm/zoomdial.cpp b/synfig-studio/src/gtkmm/zoomdial.cpp
deleted file mode 100644 (file)
index ae2f4a4..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file zoomdial.cpp
-**     \brief Template File
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === H E A D E R S ======================================================= */
-
-#ifdef USING_PCH
-#      include "pch.h"
-#else
-#ifdef HAVE_CONFIG_H
-#      include <config.h>
-#endif
-
-#include "zoomdial.h"
-#include <gtkmm/image.h>
-#include <gtkmm/stock.h>
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace studio;
-
-/* === M A C R O S ========================================================= */
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-ZoomDial::ZoomDial(Gtk::IconSize & size): Table(3, 1, false)
-{
-       zoom_in = create_icon(size, Gtk::Stock::ZOOM_IN, _("Zoom In"));
-       zoom_out = create_icon(size, Gtk::Stock::ZOOM_OUT, _("Zoom Out"));
-       zoom_fit = create_icon(size, Gtk::Stock::ZOOM_FIT, _("Zoom to Fit"));
-       zoom_norm = create_icon(size, Gtk::Stock::ZOOM_100, _("Zoom to 100%"));
-
-       attach(*zoom_out, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       attach(*zoom_norm, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       attach(*zoom_fit, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-       attach(*zoom_in, 3, 4, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-}
-
-Gtk::Button *
-ZoomDial::create_icon(Gtk::IconSize size, const Gtk::BuiltinStockID & stockid,
-               const char * tooltip)
-{
-       Gtk::Button *button = manage(new class Gtk::Button());
-       Gtk::Image *icon = manage(new Gtk::Image(stockid, size));
-       button->add(*icon);
-       tooltips.set_tip(*button, tooltip);
-       icon->set_padding(0, 0);
-       icon->show();
-       button->set_relief(Gtk::RELIEF_NONE);
-       button->show();
-
-       return button;
-}
-
diff --git a/synfig-studio/src/gtkmm/zoomdial.h b/synfig-studio/src/gtkmm/zoomdial.h
deleted file mode 100644 (file)
index 1d9d63a..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file zoomdial.h
-**     \brief Template Header
-**
-**     $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
-*/
-/* ========================================================================= */
-
-/* === S T A R T =========================================================== */
-
-#ifndef __SYNFIG_STUDIO_ZOOMDIAL_H
-#define __SYNFIG_STUDIO_ZOOMDIAL_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/tooltips.h>
-#include <gtkmm/table.h>
-#include <gtkmm/button.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 ZoomDial : public Gtk::Table
-{
-       Gtk::Tooltips tooltips;
-
-       Gtk::Button *zoom_in;
-       Gtk::Button *zoom_out;
-       Gtk::Button *zoom_fit;
-       Gtk::Button *zoom_norm;
-
-       Gtk::Button *create_icon(Gtk::IconSize size, const Gtk::BuiltinStockID & stockid,
-                       const char * tooltip);
-
-public:
-       ZoomDial(Gtk::IconSize &size);
-
-       Glib::SignalProxy0<void> signal_zoom_in()   { return zoom_in->signal_clicked(); }
-       Glib::SignalProxy0<void> signal_zoom_out()  { return zoom_out->signal_clicked(); }
-       Glib::SignalProxy0<void> signal_zoom_fit()  { return zoom_fit->signal_clicked(); }
-       Glib::SignalProxy0<void> signal_zoom_norm() { return zoom_norm->signal_clicked(); }
-
-}; // END of class ZoomDial
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gui/Makefile.am b/synfig-studio/src/gui/Makefile.am
new file mode 100644 (file)
index 0000000..384a865
--- /dev/null
@@ -0,0 +1,387 @@
+# $Id$
+
+EXTRA_DIST = \
+       compview.cpp
+
+MAINTAINERCLEANFILES = \
+       Makefile.in
+
+
+CELLRENDERER_HH = \
+       cellrenderer_gradient.h \
+       cellrenderer_time.h \
+       cellrenderer_timetrack.h \
+       cellrenderer_value.h
+
+CELLRENDERER_CC = \
+       cellrenderer_gradient.cpp \
+       cellrenderer_time.cpp \
+       cellrenderer_timetrack.cpp \
+       cellrenderer_value.cpp
+
+
+WORKAREARENDERER_HH = \
+       renderer_bbox.h \
+       renderer_canvas.h \
+       renderer_dragbox.h \
+       renderer_ducks.h \
+       renderer_grid.h \
+       renderer_guides.h \
+       renderer_timecode.h \
+       workarearenderer.h
+
+WORKAREARENDERER_CC = \
+       renderer_bbox.cpp \
+       renderer_canvas.cpp \
+       renderer_dragbox.cpp \
+       renderer_ducks.cpp \
+       renderer_grid.cpp \
+       renderer_guides.cpp \
+       renderer_timecode.cpp \
+       workarearenderer.cpp
+
+
+PALETTE_HH = \
+       mod_palette/dock_palbrowse.h \
+       mod_palette/dock_paledit.h \
+       mod_palette/mod_palette.h
+
+PALETTE_CC = \
+       mod_palette/dock_palbrowse.cpp \
+       mod_palette/dock_paledit.cpp \
+       mod_palette/mod_palette.cpp
+
+
+MOD_MIRROR_HH = \
+       mod_mirror/mod_mirror.h \
+       mod_mirror/state_mirror.h
+
+MOD_MIRROR_CC = \
+       mod_mirror/mod_mirror.cpp \
+       mod_mirror/state_mirror.cpp
+
+
+DIALOG_HH = \
+       dialog_color.h \
+       dialog_gradient.h \
+       dialog_keyframe.h \
+       dialog_preview.h \
+       dialog_setup.h \
+       dialog_soundselect.h \
+       dialog_targetparam.h \
+       dialog_waypoint.h
+
+DIALOG_CC = \
+       dialog_color.cpp \
+       dialog_gradient.cpp \
+       dialog_keyframe.cpp \
+       dialog_preview.cpp \
+       dialog_setup.cpp \
+       dialog_soundselect.cpp \
+       dialog_targetparam.cpp \
+       dialog_waypoint.cpp
+
+
+DOCK_HH = \
+       dialog_tooloptions.h \
+       dock_canvases.h \
+       dock_canvasspecific.h \
+       dock_children.h \
+       dock_curves.h \
+       dock_history.h \
+       dock_info.h \
+       dock_keyframes.h \
+       dock_layergroups.h \
+       dock_layers.h \
+       dock_metadata.h \
+       dock_navigator.h \
+       dock_params.h \
+       dock_timetrack.h \
+       dockable.h \
+       dockbook.h \
+       dockdialog.h \
+       dockmanager.h
+
+DOCK_CC = \
+       dialog_tooloptions.cpp \
+       dock_canvases.cpp \
+       dock_canvasspecific.cpp \
+       dock_children.cpp \
+       dock_curves.cpp \
+       dock_history.cpp \
+       dock_info.cpp \
+       dock_keyframes.cpp \
+       dock_layergroups.cpp \
+       dock_layers.cpp \
+       dock_metadata.cpp \
+       dock_navigator.cpp \
+       dock_params.cpp \
+       dock_timetrack.cpp \
+       dockable.cpp \
+       dockbook.cpp \
+       dockdialog.cpp \
+       dockmanager.cpp
+
+
+WIDGET_HH = \
+       widget_canvaschooser.h \
+       widget_color.h \
+       widget_coloredit.h \
+       widget_compselect.h \
+       widget_curves.h \
+       widget_defaults.h \
+       widget_distance.h \
+       widget_enum.h \
+       widget_filename.h \
+       widget_gradient.h \
+       widget_sound.h \
+       widget_time.h \
+       widget_timeslider.h \
+       widget_value.h \
+       widget_vector.h \
+       widget_waypoint.h \
+       widget_waypointmodel.h \
+       widget_keyframe_list.h
+
+WIDGET_CC = \
+       widget_canvaschooser.cpp \
+       widget_color.cpp \
+       widget_coloredit.cpp \
+       widget_compselect.cpp \
+       widget_curves.cpp \
+       widget_defaults.cpp \
+       widget_distance.cpp \
+       widget_enum.cpp \
+       widget_filename.cpp \
+       widget_gradient.cpp \
+       widget_sound.cpp \
+       widget_time.cpp \
+       widget_timeslider.cpp \
+       widget_value.cpp \
+       widget_vector.cpp \
+       widget_waypoint.cpp \
+       widget_waypointmodel.cpp \
+       widget_keyframe_list.cpp
+
+
+STATE_HH = \
+       state_bline.h \
+       state_circle.h \
+       state_draw.h \
+       state_eyedrop.h \
+       state_fill.h \
+       state_gradient.h \
+       state_normal.h \
+       state_polygon.h \
+       state_rectangle.h \
+       state_rotate.h \
+       state_scale.h \
+       state_sketch.h \
+       state_smoothmove.h \
+       state_star.h \
+       state_stroke.h \
+       state_text.h \
+       state_width.h \
+       state_zoom.h
+
+STATE_CC = \
+       state_bline.cpp \
+       state_circle.cpp \
+       state_draw.cpp \
+       state_eyedrop.cpp \
+       state_fill.cpp \
+       state_gradient.cpp \
+       state_normal.cpp \
+       state_polygon.cpp \
+       state_rectangle.cpp \
+       state_rotate.cpp \
+       state_scale.cpp \
+       state_sketch.cpp \
+       state_smoothmove.cpp \
+       state_star.cpp \
+       state_stroke.cpp \
+       state_text.cpp \
+       state_width.cpp \
+       state_zoom.cpp
+
+
+TREEVIEW_HH = \
+       childrentree.h \
+       keyframetree.h \
+       layergrouptree.h \
+       layertree.h
+
+TREEVIEW_CC = \
+       childrentree.cpp \
+       keyframetree.cpp \
+       layergrouptree.cpp \
+       layertree.cpp
+
+
+TREESTORE_HH = \
+       canvastreestore.h \
+       childrentreestore.h \
+       historytreestore.h \
+       keyframetreestore.h \
+       layergrouptreestore.h \
+       layerparamtreestore.h \
+       layertreestore.h \
+       metadatatreestore.h
+
+TREESTORE_CC = \
+       canvastreestore.cpp \
+       childrentreestore.cpp \
+       historytreestore.cpp \
+       keyframetreestore.cpp \
+       layergrouptreestore.cpp \
+       layerparamtreestore.cpp \
+       layertreestore.cpp \
+       metadatatreestore.cpp
+
+
+DUCKTRANSFORM_HH = \
+       ducktransform_rotate.h \
+       ducktransform_scale.h \
+       ducktransform_translate.h \
+       duck.h
+
+DUCKTRANSFORM_CC = \
+       duck.cpp
+
+
+EVENTS_HH = \
+       event_layerclick.h \
+       event_mouse.h
+
+
+ACTION_MANAGERS_HH = \
+       groupactionmanager.h \
+       keyframeactionmanager.h \
+       layeractionmanager.h
+
+ACTION_MANAGERS_CC = \
+       groupactionmanager.cpp \
+       keyframeactionmanager.cpp \
+       layeractionmanager.cpp
+
+
+OTHER_HH = \
+       compview.h \
+       eventkey.h \
+       smach.h \
+       about.h \
+       adjust_window.h \
+       app.h \
+       asyncrenderer.h \
+       audiocontainer.h \
+       autorecover.h \
+       canvasoptions.h \
+       canvasproperties.h \
+       canvasview.h \
+       devicetracker.h \
+       dialogsettings.h \
+       duckmatic.h \
+       general.h \
+       iconcontroller.h \
+       instance.h \
+       ipc.h \
+       keymapsettings.h \
+       module.h \
+       onemoment.h \
+       preview.h \
+       renddesc.h \
+       render.h \
+       splash.h \
+       statemanager.h \
+       toolbox.h \
+       valuelink.h \
+       workarea.h \
+       zoomdial.h \
+       framedial.h \
+       keyframedial.h \
+       toggleducksdial.h \
+       resolutiondial.h
+
+OTHER_CC = \
+       main.cpp \
+       about.cpp \
+       adjust_window.cpp \
+       app.cpp \
+       asyncrenderer.cpp \
+       audiocontainer.cpp \
+       autorecover.cpp \
+       canvasoptions.cpp \
+       canvasproperties.cpp \
+       canvasview.cpp \
+       devicetracker.cpp \
+       dialogsettings.cpp \
+       duckmatic.cpp \
+       iconcontroller.cpp \
+       instance.cpp \
+       ipc.cpp \
+       keymapsettings.cpp \
+       module.cpp \
+       onemoment.cpp \
+       preview.cpp \
+       renddesc.cpp \
+       render.cpp \
+       splash.cpp \
+       statemanager.cpp \
+       toolbox.cpp \
+       valuelink.cpp \
+       workarea.cpp \
+       zoomdial.cpp \
+       framedial.cpp \
+       keyframedial.cpp \
+       toggleducksdial.cpp \
+       resolutiondial.cpp
+
+INCLUDES = \
+       -I$(top_srcdir)/src
+
+bin_PROGRAMS = synfigstudio
+
+synfigstudio_SOURCES = \
+       $(MOD_MIRROR_CC) \
+       $(MOD_MIRROR_HH) \
+       $(PALETTE_CC) \
+       $(PALETTE_HH) \
+       $(WORKAREARENDERER_CC) \
+       $(WORKAREARENDERER_HH) \
+       $(ACTION_MANAGERS_HH) \
+       $(ACTION_MANAGERS_CC) \
+       $(DOCK_HH) \
+       $(DOCK_CC) \
+       $(OTHER_HH) \
+       $(OTHER_CC) \
+       $(EVENTS_HH) \
+       $(DUCKTRANSFORM_HH) \
+       $(DUCKTRANSFORM_CC) \
+       $(TREEVIEW_HH) \
+       $(TREEVIEW_CC) \
+       $(TREESTORE_HH) \
+       $(TREESTORE_CC) \
+       $(STATE_CC) \
+       $(STATE_HH) \
+       $(WIDGET_CC) \
+       $(WIDGET_HH) \
+       $(CELLRENDERER_HH) \
+       $(CELLRENDERER_CC) \
+       $(DIALOG_HH) \
+       $(DIALOG_CC)
+
+synfigstudio_LDADD = \
+       ../synfigapp/libsynfigapp.la \
+       @SYNFIG_LIBS@ \
+       @GTKMM_LIBS@ \
+       @FMOD_LIBS@
+
+synfigstudio_LDFLAGS = \
+       -dlopen self
+
+synfigstudio_CXXFLAGS = \
+       @SYNFIG_CFLAGS@ \
+       @GTKMM_CFLAGS@ \
+       -DIMAGE_DIR=\"$(imagedir)\" \
+       -DIMAGE_EXT=\"$(imageext)\" \
+       "-DLOCALEDIR=\"$(localedir)\""
diff --git a/synfig-studio/src/gui/about.cpp b/synfig-studio/src/gui/about.cpp
new file mode 100644 (file)
index 0000000..600d135
--- /dev/null
@@ -0,0 +1,248 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file about.cpp
+**     \brief About dialog implementation
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2008 Paul Wise
+**
+**     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 <config.h>
+#endif
+
+#include <vector>
+
+#include <gtk/gtk.h>
+
+#include <gtkmm/aboutdialog.h>
+
+#include <ETL/stringf>
+
+#include <synfig/general.h>
+
+// This is generated at make time from .svn or .git/svn or autorevision.conf
+#include <autorevision.h>
+
+#include "about.h"
+#include "app.h"
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+#ifndef VERSION
+#define VERSION        "unknown"
+#define PACKAGE        "synfigstudio"
+#endif
+
+#ifdef WIN32
+#      ifdef IMAGE_DIR
+#              undef IMAGE_DIR
+#              define IMAGE_DIR "share\\pixmaps"
+#      endif
+#endif
+
+#ifndef IMAGE_DIR
+#      define IMAGE_DIR "/usr/local/share/pixmaps"
+#endif
+
+#ifndef IMAGE_EXT
+#      define IMAGE_EXT        "png"
+#endif
+
+#define stringify_(x) #x
+#define stringify(x) stringify_(x)
+
+/* === G L O B A L S ======================================================= */
+
+extern const guint gtk_major_version;
+extern const guint gtk_minor_version;
+extern const guint gtk_micro_version;
+extern const guint gtk_binary_age;
+extern const guint gtk_interface_age;
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+About::About()
+{
+
+#ifdef HAVE_GTK_ABOUTDIALOG_SET_PROGRAM_NAME
+       set_program_name(PACKAGE_NAME);
+#else
+       set_name(PACKAGE_NAME);
+#endif
+       set_version(VERSION);
+       set_comments(_("2D vector animation studio"));
+
+       set_url_hook(sigc::mem_fun(*this, &About::on_link_clicked));
+       set_website("http://www.synfig.org/");
+       set_website_label(_("Visit the Synfig website"));
+
+       set_copyright(_("Copyright 2001-2008\nRobert B. Quattlebaum Jr.,\nAdrian Bentley and Synfig contributors"));
+       Glib::ustring license =
+               "This program 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.\n\n"
+
+               "This program 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.\n\n"
+
+               "You should have received a copy of the GNU General Public License along "
+               "with this program; if not, write to the Free Software Foundation, Inc., "
+               "51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or visit: http://www.gnu.org/";
+       set_license(license);
+#ifdef HAVE_GTK_ABOUTDIALOG_SET_WRAP_LICENSE
+       set_wrap_license(true);
+#endif
+
+       std::vector<Glib::ustring> authors;
+       authors.push_back(_("Original developers:"));
+       authors.push_back("");
+       authors.push_back("Robert B. Quattlebaum Jr (darco)");
+       authors.push_back("Adrian Bentley");
+       authors.push_back("");
+       authors.push_back(_("Contributors:"));
+       authors.push_back("");
+       authors.push_back("Adrian Winchell (SnapSilverlight)");
+       authors.push_back("Andreas Jochens");
+       authors.push_back("Carlos López González (genete)");
+       authors.push_back("Carlos A. Sosa Navarro");
+       authors.push_back("Chris Moore (dooglus)");
+       authors.push_back("Chris Norman (pixelgeek)");
+       authors.push_back("Cyril Brulebois (KiBi)");
+       authors.push_back("Daniel Fort");
+       authors.push_back("Daniel Hornung (rubikcube)");
+       authors.push_back("David Roden (Bombe)");
+       authors.push_back("Dmitriy Pomerantsev (Atrus)");
+       authors.push_back("Douglas Lau");
+       authors.push_back("Gerald Young (Yoyobuae)");
+       authors.push_back("Gerco Ballintijn");
+       authors.push_back("IL'dar AKHmetgaleev (AkhIL)");
+       authors.push_back("Konstantin Dmitriev (zelgadis)");
+       authors.push_back("Luka Pravica");
+       authors.push_back("Martin Michlmayr (tbm)");
+       authors.push_back("Miguel Gea Milvaques (xerakko)");
+       authors.push_back("Paul Wise (pabs)");
+       authors.push_back("Ralf Corsepius");
+       authors.push_back("Ray Frederikson");
+       authors.push_back("Timo Paulssen (timonator)");
+       authors.push_back("Yue Shi Lai");
+       set_authors(authors);
+
+       std::vector<Glib::ustring> artists;
+       artists.push_back("Aurore D (rore)");
+       artists.push_back("Carlos López González (genete)");
+       artists.push_back("Chris Norman (pixelgeek)");
+       artists.push_back("Daniel Hornung (rubikcube)");
+       artists.push_back("David Rylander (rylleman)");
+       artists.push_back("Franco Iacomella (Yaco)");
+       artists.push_back("Gerald Young (Yoyobuae)");
+       artists.push_back("Henrique Lopes Barone");
+       artists.push_back("Robert B. Quattlebaum Jr. (darco)");
+
+       set_artists(artists);
+
+       // TRANSLATORS: change this to your name, separate multiple names with \n
+       set_translator_credits(_("translator-credits"));
+
+       std::string imagepath;
+#ifdef WIN32
+       imagepath=App::get_base_path()+ETL_DIRECTORY_SEPARATOR+IMAGE_DIR;
+#else
+       imagepath=IMAGE_DIR;
+#endif
+       char* synfig_root=getenv("SYNFIG_ROOT");
+       if(synfig_root) {
+               imagepath=synfig_root;
+               imagepath+=ETL_DIRECTORY_SEPARATOR;
+               imagepath+="share";
+               imagepath+=ETL_DIRECTORY_SEPARATOR;
+               imagepath+="pixmaps";
+       }
+       imagepath+=ETL_DIRECTORY_SEPARATOR;
+
+       Gtk::Image *Logo = manage(new class Gtk::Image());
+       Logo->set(imagepath+"synfig_icon."IMAGE_EXT);
+       set_logo(Logo->get_pixbuf());
+
+#ifdef SHOW_EXTRA_INFO
+
+       string extra_info = get_comments() + "\n";
+
+       #ifdef DEVEL_VERSION
+               extra_info += strprintf(_("\nDevelopment version:\n%s\n"),DEVEL_VERSION);
+       #endif
+
+       extra_info += "\n";
+
+       extra_info += strprintf(_("Built on %s" /* at %s */ "\n"), __DATE__ /* , __TIME__ */ );
+
+       extra_info += "\n";
+
+       extra_info += strprintf(_("Built with:\n"), ETL_VERSION);
+       extra_info += strprintf(_("ETL %s\n"), ETL_VERSION);
+       extra_info += strprintf(_("Synfig API %s\n"), stringify(SYNFIG_VERSION));
+       extra_info += strprintf(_("Synfig library %d\n"), SYNFIG_LIBRARY_VERSION);
+       extra_info += strprintf(_("GTK+ %d.%d.%d\n"), GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
+       #ifdef __GNUC__
+               extra_info += strprintf(_("GNU G++ %d.%d.%d\n"),__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__);
+       #endif
+
+       extra_info += "\n";
+
+       extra_info += strprintf(_("Using:\n"), synfig::get_version());
+       extra_info += strprintf(_("Synfig %s\n"), synfig::get_version());
+       extra_info += strprintf(_("GTK+ %d.%d.%d"),gtk_major_version,gtk_minor_version,gtk_micro_version);
+
+       #ifdef _DEBUG
+               extra_info += "\n\nDEBUG BUILD";
+       #endif
+
+       set_comments(extra_info);
+
+#endif
+
+       // Hide the dialog when you click close
+       signal_response().connect(sigc::mem_fun(*this, &About::close));
+}
+
+void About::close(int){
+       hide();
+}
+
+void About::on_link_clicked(Gtk::AboutDialog&, const Glib::ustring &url)
+{
+       App::open_url(url);
+}
diff --git a/synfig-studio/src/gui/about.h b/synfig-studio/src/gui/about.h
new file mode 100644 (file)
index 0000000..f00a773
--- /dev/null
@@ -0,0 +1,55 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file about.h
+**     \brief About dialog class
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2008 Paul Wise
+**
+**     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_GTKMM_ABOUT_H
+#define __SYNFIG_GTKMM_ABOUT_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/aboutdialog.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 About : public Gtk::AboutDialog
+{
+public:
+
+       About();
+       void close(int);
+       void on_link_clicked(Gtk::AboutDialog&, const Glib::ustring &url);
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/adjust_window.cpp b/synfig-studio/src/gui/adjust_window.cpp
new file mode 100644 (file)
index 0000000..0b62737
--- /dev/null
@@ -0,0 +1,170 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file adjust_window.cpp
+**     \brief Adjustment Window Implementation File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2004 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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "adjust_window.h"
+#include "app.h"
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+//using namespace etl;
+//using namespace synfig;
+
+using studio::Adjust_Window;
+
+/* === M A C R O S ========================================================= */
+const double EPSILON = 1.0e-6;
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+/* === E N T R Y P O I N T ================================================= */
+
+Adjust_Window::Adjust_Window(double value, double lower, double upper,
+                                                       double stepinc, double pageinc, double pagesize,
+                                                       Gtk::Adjustment *adj)
+: Adjustment(value,lower,upper,stepinc,pageinc,pagesize),
+       adj_child(0)
+{
+       if(adj) set_child_adjustment(adj);
+}
+
+Adjust_Window::~Adjust_Window()
+{
+       //connections should automatically be killed etc.
+}
+
+//child interface functions
+Gtk::Adjustment *Adjust_Window::get_child_adjustment()
+{
+       return adj_child;
+}
+
+const Gtk::Adjustment *Adjust_Window::get_child_adjustment() const
+{
+       return adj_child;
+}
+
+void Adjust_Window::set_child_adjustment(Gtk::Adjustment *child)
+{
+       childchanged.disconnect();
+
+       adj_child = child;
+
+       // synfig::info("Adjust: connecting to child signals");
+
+       if(child)
+       {
+               childchanged = child->signal_changed().connect(sigc::mem_fun(*this,&Adjust_Window::update_fromchild));
+
+               update_child();
+       }
+}
+
+void Adjust_Window::on_changed()
+{
+       update_child();
+}
+
+void Adjust_Window::on_value_changed()
+{
+       update_child();
+}
+
+//SUB TIME FUNCTIONS
+double Adjust_Window::get_sub_lower() const
+{
+       return get_value();
+}
+
+double Adjust_Window::get_sub_upper() const
+{
+       return get_value() + get_page_size();
+}
+
+//---- REFRESH FUNCTIONS -----
+void Adjust_Window::update_child()
+{
+       if(adj_child)
+       {
+               bool childchanged = false;
+
+               double v = get_value();
+               double ve = v + get_page_size();
+
+               //reset child's values if they need to be...
+               if(abs(v - adj_child->get_lower()) > EPSILON)
+               {
+                       adj_child->set_lower(v);
+                       childchanged = true;
+               }
+
+               if(abs(ve - adj_child->get_upper()) > EPSILON)
+               {
+                       adj_child->set_upper(ve);
+                       childchanged = true;
+               }
+
+               if(childchanged)
+               {
+                       adj_child->changed();
+               }
+       }
+}
+
+void Adjust_Window::update_fromchild()
+{
+       if(adj_child)
+       {
+               double b = adj_child->get_lower();
+               double dist = adj_child->get_upper() - b;
+
+               //reset our values if they need to be...
+               if(abs(get_value() - b) > EPSILON)
+               {
+                       set_value(b);
+                       value_changed();
+               }
+
+               if(abs(get_page_size() - dist) > EPSILON)
+               {
+                       set_page_size(dist);
+                       changed();
+               }
+       }
+}
diff --git a/synfig-studio/src/gui/adjust_window.h b/synfig-studio/src/gui/adjust_window.h
new file mode 100644 (file)
index 0000000..d1b57c3
--- /dev/null
@@ -0,0 +1,94 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file adjust_window.h
+**     \brief Adjustment Window Header
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2004 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_TEMPLATE_H
+#define __SYNFIG_TEMPLATE_H
+
+/* === H E A D E R S ======================================================= */
+#include <gtkmm/adjustment.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 {
+
+/* Sets up an adjustment that controls/communicates with another adjustment
+       (could be expanded to multiple children)
+
+       The current value and pagesize define the lower and upper bounds of the
+       child adjustment.
+
+       NEED TO REPLACE FUNCTIONALITY IN:
+       refresh_rend_desc
+       refresh_time_window
+       on_time_changed - possibly....
+
+       time_zoom_in - possibly...
+       time_zoom_out - possibly...
+
+       play - possibly...
+
+       THINGS TO CHECK:
+       disp_audio's use of time_adjustment
+       children_tree's use of time_adjustment
+       layer_tree's use of time_adjustment
+*/
+class Adjust_Window : public Gtk::Adjustment
+{
+       Gtk::Adjustment *adj_child;
+
+       sigc::connection childchanged; //we only care about the non-value parts of the child
+
+       virtual void on_changed(); //value+pagesize corresponds to child upper
+       virtual void on_value_changed(); //value corresponds to child lower
+
+protected: //update interface
+       virtual void update_child();
+       virtual void update_fromchild();
+
+public: //structors
+       Adjust_Window(double value, double lower, double upper,
+                                       double step_increment=1, double page_increment=10, double page_size=0,
+                                       Gtk::Adjustment *adj = 0);
+
+       virtual ~Adjust_Window();
+
+public: //child interface
+       Gtk::Adjustment *get_child_adjustment();
+       const Gtk::Adjustment *get_child_adjustment() const;
+       void set_child_adjustment(Gtk::Adjustment *child);
+
+public: //Sub value interface
+       double get_sub_lower() const;
+       double get_sub_upper() const;
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/app.cpp b/synfig-studio/src/gui/app.cpp
new file mode 100644 (file)
index 0000000..01a4f8f
--- /dev/null
@@ -0,0 +1,2515 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file app.cpp
+**     \brief writeme
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 2008 Chris Moore
+**     Copyright (c) 2008 Gerald Young
+**  Copyright (c) 2008 Carlos López
+**     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 <config.h>
+#endif
+
+#ifdef WIN32
+#define WINVER 0x0500
+#include <windows.h>
+#endif
+
+#include <fstream>
+#include <iostream>
+#include <locale>
+#include <cstring>
+
+#ifdef HAVE_SYS_ERRNO_H
+#include <sys/errno.h>
+#endif
+#include <gtkmm/fileselection.h>
+#include <gtkmm/dialog.h>
+#include <gtkmm/messagedialog.h>
+#include <gtkmm/label.h>
+#include <gtkmm/stock.h>
+#include <gtkmm/stockitem.h>
+#include <gtkmm/iconsource.h>
+#include <gtkmm/inputdialog.h>
+#include <gtkmm/accelmap.h>
+#include <gtkmm/uimanager.h>
+#include <gtkmm/textview.h>
+
+#include <gtk/gtk.h>
+
+#include <gdkmm/general.h>
+
+#include <synfig/loadcanvas.h>
+#include <synfig/savecanvas.h>
+
+#include "app.h"
+#include "about.h"
+#include "splash.h"
+#include "instance.h"
+#include "canvasview.h"
+#include "dialog_setup.h"
+#include "dialog_gradient.h"
+#include "dialog_color.h"
+#include "toolbox.h"
+#include "onemoment.h"
+
+#include "dockmanager.h"
+
+#include "state_eyedrop.h"
+#include "state_normal.h"
+#include "state_draw.h"
+#include "state_fill.h"
+#include "state_bline.h"
+#include "state_polygon.h"
+#include "state_sketch.h"
+#include "state_gradient.h"
+#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"
+#include "dialog_tooloptions.h"
+#include "widget_enum.h"
+
+#include "autorecover.h"
+
+#include <synfigapp/settings.h>
+#include "dock_history.h"
+#include "dock_canvases.h"
+#include "dock_keyframes.h"
+#include "dock_layers.h"
+#include "dock_params.h"
+#include "dock_metadata.h"
+#include "dock_children.h"
+#include "dock_info.h"
+#include "dock_navigator.h"
+#include "dock_layergroups.h"
+#include "dock_timetrack.h"
+#include "dock_curves.h"
+
+#include "mod_palette/mod_palette.h"
+#include "mod_mirror/mod_mirror.h"
+
+#include <sys/stat.h>
+
+#include "ipc.h"
+
+#include "module.h"
+
+#include "statemanager.h"
+
+#ifdef WITH_FMOD
+#include <fmod.h>
+#endif
+
+#include <gtkmm/accelmap.h>
+#include <gtkmm/filechooser.h>
+#include <gtkmm/filechooserdialog.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 ========================================================= */
+
+#ifndef SYNFIG_USER_APP_DIR
+#ifdef __APPLE__
+#define SYNFIG_USER_APP_DIR    "Library/Synfig"
+#elif defined(_WIN32)
+#define SYNFIG_USER_APP_DIR    "Synfig"
+#else
+#define SYNFIG_USER_APP_DIR    ".synfig"
+#endif
+#endif
+
+#ifndef DPM2DPI
+#define DPM2DPI(x)     (float(x)/39.3700787402f)
+#define DPI2DPM(x)     (float(x)*39.3700787402f)
+#endif
+
+#ifdef WIN32
+#      ifdef IMAGE_DIR
+#              undef IMAGE_DIR
+#              define IMAGE_DIR "share\\pixmaps"
+#      endif
+#endif
+
+#ifndef IMAGE_DIR
+#      define IMAGE_DIR "/usr/local/share/pixmaps"
+#endif
+
+#ifndef IMAGE_EXT
+#      define IMAGE_EXT        "tif"
+#endif
+
+#include <synfigapp/main.h>
+
+/* === S I G N A L S ======================================================= */
+
+static sigc::signal<void> signal_present_all_;
+sigc::signal<void>&
+App::signal_present_all() { return signal_present_all_; }
+
+static sigc::signal<void> signal_recent_files_changed_;
+sigc::signal<void>&
+App::signal_recent_files_changed() { return signal_recent_files_changed_; }
+
+static sigc::signal<void,etl::loose_handle<CanvasView> > signal_canvas_view_focus_;
+sigc::signal<void,etl::loose_handle<CanvasView> >&
+App::signal_canvas_view_focus() { return signal_canvas_view_focus_; }
+
+static sigc::signal<void,etl::handle<Instance> > signal_instance_selected_;
+sigc::signal<void,etl::handle<Instance> >&
+App::signal_instance_selected() { return signal_instance_selected_; }
+
+static sigc::signal<void,etl::handle<Instance> > signal_instance_created_;
+sigc::signal<void,etl::handle<Instance> >&
+App::signal_instance_created() { return signal_instance_created_; }
+
+static sigc::signal<void,etl::handle<Instance> > signal_instance_deleted_;
+sigc::signal<void,etl::handle<Instance> >&
+App::signal_instance_deleted() { return signal_instance_deleted_; }
+
+/* === G L O B A L S ======================================================= */
+
+static std::list<std::string> recent_files;
+const std::list<std::string>& App::get_recent_files() { return recent_files; }
+
+static std::list<std::string> recent_files_window_size;
+
+int    App::Busy::count;
+bool App::shutdown_in_progress;
+
+synfig::Gamma App::gamma;
+
+Glib::RefPtr<studio::UIManager>        App::ui_manager_;
+
+synfig::Distance::System App::distance_system;
+
+studio::Dialog_Setup* App::dialog_setup;
+
+etl::handle< studio::ModPalette > mod_palette_;
+//studio::Dialog_Palette* App::dialog_palette;
+
+std::list<etl::handle<Instance> > App::instance_list;
+
+static etl::handle<synfigapp::UIInterface> ui_interface_;
+const etl::handle<synfigapp::UIInterface>& App::get_ui_interface() { return ui_interface_; }
+
+etl::handle<Instance> App::selected_instance;
+etl::handle<CanvasView> App::selected_canvas_view;
+
+studio::About *studio::App::about=NULL;
+
+studio::Toolbox *studio::App::toolbox=NULL;
+
+studio::AutoRecover *studio::App::auto_recover=NULL;
+
+studio::IPC *ipc=NULL;
+
+studio::DockManager* studio::App::dock_manager=0;
+
+studio::DeviceTracker* studio::App::device_tracker=0;
+
+studio::Dialog_Gradient* studio::App::dialog_gradient;
+
+studio::Dialog_Color* studio::App::dialog_color;
+
+Gtk::InputDialog* studio::App::dialog_input;
+
+studio::Dialog_ToolOptions* studio::App::dialog_tool_options;
+
+studio::Dock_History* dock_history;
+studio::Dock_Canvases* dock_canvases;
+studio::Dock_Keyframes* dock_keyframes;
+studio::Dock_Layers* dock_layers;
+studio::Dock_Params* dock_params;
+studio::Dock_MetaData* dock_meta_data;
+studio::Dock_Children* dock_children;
+studio::Dock_Info* dock_info;
+studio::Dock_LayerGroups* dock_layer_groups;
+studio::Dock_Navigator* dock_navigator;
+studio::Dock_Timetrack* dock_timetrack;
+studio::Dock_Curves* dock_curves;
+
+std::list< etl::handle< studio::Module > > module_list_;
+
+bool studio::App::use_colorspace_gamma=true;
+#ifdef SINGLE_THREADED
+bool studio::App::single_threaded=false;
+#endif
+bool studio::App::restrict_radius_ducks=false;
+bool studio::App::resize_imported_images=false;
+String studio::App::custom_filename_prefix(DEFAULT_FILENAME_PREFIX);
+int studio::App::preferred_x_size=480;
+int studio::App::preferred_y_size=270;
+String studio::App::predefined_size(DEFAULT_PREDEFINED_SIZE);
+String studio::App::predefined_fps(DEFAULT_PREDEFINED_FPS);
+float studio::App::preferred_fps=24.0;
+#ifdef USE_OPEN_FOR_URLS
+String studio::App::browser_command("open"); // MacOS only
+#else
+String studio::App::browser_command("xdg-open"); // Linux XDG standard
+#endif
+
+static int max_recent_files_=25;
+int studio::App::get_max_recent_files() { return max_recent_files_; }
+void studio::App::set_max_recent_files(int x) { max_recent_files_=x; }
+
+static synfig::String app_base_path_;
+
+namespace studio {
+
+bool
+really_delete_widget(Gtk::Widget *widget)
+{
+       // synfig::info("really delete %p", (void*)widget);
+       delete widget;
+       return false;
+}
+
+// nasty workaround - when we've finished with a popup menu, we want to delete it
+// attaching to the signal_hide() signal gets us here before the action on the menu has run,
+// so schedule the real delete to happen in 50ms, giving the action a chance to run
+void
+delete_widget(Gtk::Widget *widget)
+{
+       // synfig::info("delete %p", (void*)widget);
+       Glib::signal_timeout().connect(sigc::bind(sigc::ptr_fun(&really_delete_widget), widget), 50);
+}
+
+}; // END of namespace studio
+studio::StateManager* state_manager;
+
+
+
+
+class GlobalUIInterface : public synfigapp::UIInterface
+{
+public:
+
+       virtual Response confirmation(const std::string &title,
+                       const std::string &primaryText,
+                       const std::string &secondaryText,
+                       const std::string &confirmPhrase,
+                       const std::string &cancelPhrase,
+                       Response defaultResponse)
+       {
+               Gtk::MessageDialog dialog(
+                       primaryText,            // Message
+                       false,                  // Markup
+                       Gtk::MESSAGE_WARNING,   // Type
+                       Gtk::BUTTONS_NONE,      // Buttons
+                       true                    // Modal
+               );
+
+               if (! title.empty())
+                       dialog.set_title(title);
+               if (! secondaryText.empty())
+                       dialog.set_secondary_text(secondaryText);
+
+               dialog.add_button(cancelPhrase, RESPONSE_CANCEL);
+               dialog.add_button(confirmPhrase, RESPONSE_OK);
+               dialog.set_default_response(defaultResponse);
+
+               dialog.show_all();
+               return (Response) dialog.run();
+       }
+
+       virtual Response yes_no(const std::string &title, const std::string &message,Response dflt=RESPONSE_YES)
+       {
+               Gtk::Dialog dialog(
+                       title,          // Title
+                       true,           // Modal
+                       true            // use_separator
+               );
+               Gtk::Label label(message);
+               label.show();
+
+               dialog.get_vbox()->pack_start(label);
+               dialog.add_button(Gtk::StockID("gtk-yes"),RESPONSE_YES);
+               dialog.add_button(Gtk::StockID("gtk-no"),RESPONSE_NO);
+
+               dialog.set_default_response(dflt);
+               dialog.show();
+               return (Response)dialog.run();
+       }
+       virtual Response yes_no_cancel(const std::string &title, const std::string &message,Response dflt=RESPONSE_YES)
+       {
+               Gtk::Dialog dialog(
+                       title,          // Title
+                       true,           // Modal
+                       true            // use_separator
+               );
+               Gtk::Label label(message);
+               label.show();
+
+               dialog.get_vbox()->pack_start(label);
+               dialog.add_button(Gtk::StockID("gtk-yes"),RESPONSE_YES);
+               dialog.add_button(Gtk::StockID("gtk-no"),RESPONSE_NO);
+               dialog.add_button(Gtk::StockID("gtk-cancel"),RESPONSE_CANCEL);
+
+               dialog.set_default_response(dflt);
+               dialog.show();
+               return (Response)dialog.run();
+       }
+       virtual Response ok_cancel(const std::string &title, const std::string &message,Response dflt=RESPONSE_OK)
+       {
+               Gtk::Dialog dialog(
+                       title,          // Title
+                       true,           // Modal
+                       true            // use_separator
+               );
+               Gtk::Label label(message);
+               label.show();
+
+               dialog.get_vbox()->pack_start(label);
+               dialog.add_button(Gtk::StockID("gtk-ok"),RESPONSE_OK);
+               dialog.add_button(Gtk::StockID("gtk-cancel"),RESPONSE_CANCEL);
+
+               dialog.set_default_response(dflt);
+               dialog.show();
+               return (Response)dialog.run();
+       }
+
+       virtual bool
+       task(const std::string &task)
+       {
+               std::cerr<<task<<std::endl;
+               while(studio::App::events_pending())studio::App::iteration(false);
+               return true;
+       }
+
+       virtual bool
+       error(const std::string &err)
+       {
+               Gtk::MessageDialog dialog(err, false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE, true);
+               dialog.show();
+               dialog.run();
+               return true;
+       }
+
+       virtual bool
+       warning(const std::string &err)
+       {
+               std::cerr<<"warning: "<<err<<std::endl;
+               while(studio::App::events_pending())studio::App::iteration(false);
+               return true;
+       }
+
+       virtual bool
+       amount_complete(int /*current*/, int /*total*/)
+       {
+               while(studio::App::events_pending())studio::App::iteration(false);
+               return true;
+       }
+};
+
+/* === P R O C E D U R E S ================================================= */
+
+/*
+void
+studio::UIManager::insert_action_group (const Glib::RefPtr<Gtk::ActionGroup>& action_group, int pos)
+{
+       action_group_list.push_back(action_group);
+       Gtk::UIManager::insert_action_group(action_group, pos);
+}
+
+void
+studio::UIManager::remove_action_group (const Glib::RefPtr<Gtk::ActionGroup>& action_group)
+{
+       std::list<Glib::RefPtr<Gtk::ActionGroup> >::iterator iter;
+       for(iter=action_group_list.begin();iter!=action_group_list.end();++iter)
+               if(*iter==action_group)
+               {
+                       action_group_list.erase(iter);
+                       Gtk::UIManager::remove_action_group(action_group);
+                       return;
+               }
+       synfig::error("Unable to find action group");
+}
+
+void
+studio::add_action_group_to_top(Glib::RefPtr<studio::UIManager> ui_manager, Glib::RefPtr<Gtk::ActionGroup> group)
+{
+       ui_manager->insert_action_group(group,0);
+       return;
+       std::list<Glib::RefPtr<Gtk::ActionGroup> > prev_groups(ui_manager->get_action_groups());
+       std::list<Glib::RefPtr<Gtk::ActionGroup> >::reverse_iterator iter;
+
+       for(iter=prev_groups.rbegin();iter!=prev_groups.rend();++iter)
+       {
+               if(*iter && (*iter)->get_name()!="menus")
+               {
+                       synfig::info("Removing action group "+(*iter)->get_name());
+                       ui_manager->remove_action_group(*iter);
+               }
+       }
+       ui_manager->insert_action_group(group,0);
+
+       for(;!prev_groups.empty();prev_groups.pop_front())
+       {
+               if(prev_groups.front() && prev_groups.front()!=group && prev_groups.front()->get_name()!="menus")
+                       ui_manager->insert_action_group(prev_groups.front(),1);
+       }
+}
+*/
+class Preferences : public synfigapp::Settings
+{
+public:
+       virtual bool get_value(const synfig::String& key, synfig::String& value)const
+       {
+               if(key=="gamma")
+               {
+                       value=strprintf("%f %f %f %f",
+                               App::gamma.get_gamma_r(),
+                               App::gamma.get_gamma_g(),
+                               App::gamma.get_gamma_b(),
+                               App::gamma.get_black_level()
+                       );
+                       return true;
+               }
+               if(key=="time_format")
+               {
+                       value=strprintf("%i",App::get_time_format());
+                       return true;
+               }
+               if(key=="file_history.size")
+               {
+                       value=strprintf("%i",App::get_max_recent_files());
+                       return true;
+               }
+               if(key=="use_colorspace_gamma")
+               {
+                       value=strprintf("%i",(int)App::use_colorspace_gamma);
+                       return true;
+               }
+               if(key=="distance_system")
+               {
+                       value=strprintf("%s",Distance::system_name(App::distance_system).c_str());
+                       return true;
+               }
+#ifdef SINGLE_THREADED
+               if(key=="single_threaded")
+               {
+                       value=strprintf("%i",(int)App::single_threaded);
+                       return true;
+               }
+#endif
+               if(key=="auto_recover_backup_interval")
+               {
+                       value=strprintf("%i",App::auto_recover->get_timeout());
+                       return true;
+               }
+               if(key=="restrict_radius_ducks")
+               {
+                       value=strprintf("%i",(int)App::restrict_radius_ducks);
+                       return true;
+               }
+               if(key=="resize_imported_images")
+               {
+                       value=strprintf("%i",(int)App::resize_imported_images);
+                       return true;
+               }
+               if(key=="browser_command")
+               {
+                       value=App::browser_command;
+                       return true;
+               }
+               if(key=="custom_filename_prefix")
+               {
+                       value=App::custom_filename_prefix;
+                       return true;
+               }
+               if(key=="preferred_x_size")
+               {
+                       value=strprintf("%i",App::preferred_x_size);
+                       return true;
+               }
+               if(key=="preferred_y_size")
+               {
+                       value=strprintf("%i",App::preferred_y_size);
+                       return true;
+               }
+               if(key=="predefined_size")
+               {
+                       value=strprintf("%s",App::predefined_size.c_str());
+                       return true;
+               }
+               if(key=="preferred_fps")
+               {
+                       value=strprintf("%f",App::preferred_fps);
+                       return true;
+               }
+               if(key=="predefined_fps")
+               {
+                       value=strprintf("%s",App::predefined_fps.c_str());
+                       return true;
+               }
+
+               return synfigapp::Settings::get_value(key,value);
+       }
+
+       virtual bool set_value(const synfig::String& key,const synfig::String& value)
+       {
+               if(key=="gamma")
+               {
+                       float r,g,b,blk;
+
+                       strscanf(value,"%f %f %f %f",
+                               &r,
+                               &g,
+                               &b,
+                               &blk
+                       );
+
+                       App::gamma.set_all(r,g,b,blk);
+
+                       return true;
+               }
+               if(key=="time_format")
+               {
+                       int i(atoi(value.c_str()));
+                       App::set_time_format(static_cast<synfig::Time::Format>(i));
+                       return true;
+               }
+               if(key=="auto_recover_backup_interval")
+               {
+                       int i(atoi(value.c_str()));
+                       App::auto_recover->set_timeout(i);
+                       return true;
+               }
+               if(key=="file_history.size")
+               {
+                       int i(atoi(value.c_str()));
+                       App::set_max_recent_files(i);
+                       return true;
+               }
+               if(key=="use_colorspace_gamma")
+               {
+                       int i(atoi(value.c_str()));
+                       App::use_colorspace_gamma=i;
+                       return true;
+               }
+               if(key=="distance_system")
+               {
+                       App::distance_system=Distance::ident_system(value);;
+                       return true;
+               }
+#ifdef SINGLE_THREADED
+               if(key=="single_threaded")
+               {
+                       int i(atoi(value.c_str()));
+                       App::single_threaded=i;
+                       return true;
+               }
+#endif
+               if(key=="restrict_radius_ducks")
+               {
+                       int i(atoi(value.c_str()));
+                       App::restrict_radius_ducks=i;
+                       return true;
+               }
+               if(key=="resize_imported_images")
+               {
+                       int i(atoi(value.c_str()));
+                       App::resize_imported_images=i;
+                       return true;
+               }
+               if(key=="browser_command")
+               {
+                       App::browser_command=value;
+                       return true;
+               }
+               if(key=="custom_filename_prefix")
+               {
+                       App::custom_filename_prefix=value;
+                       return true;
+               }
+               if(key=="preferred_x_size")
+               {
+                       int i(atoi(value.c_str()));
+                       App::preferred_x_size=i;
+                       return true;
+               }
+               if(key=="preferred_y_size")
+               {
+                       int i(atoi(value.c_str()));
+                       App::preferred_y_size=i;
+                       return true;
+               }
+               if(key=="predefined_size")
+               {
+                       App::predefined_size=value;
+                       return true;
+               }
+               if(key=="preferred_fps")
+               {
+                       float i(atof(value.c_str()));
+                       App::preferred_fps=i;
+                       return true;
+               }
+               if(key=="predefined_fps")
+               {
+                       App::predefined_fps=value;
+                       return true;
+               }
+
+               return synfigapp::Settings::set_value(key,value);
+       }
+
+       virtual KeyList get_key_list()const
+       {
+               KeyList ret(synfigapp::Settings::get_key_list());
+               ret.push_back("gamma");
+               ret.push_back("time_format");
+               ret.push_back("distance_system");
+               ret.push_back("file_history.size");
+               ret.push_back("use_colorspace_gamma");
+#ifdef SINGLE_THREADED
+               ret.push_back("single_threaded");
+#endif
+               ret.push_back("auto_recover_backup_interval");
+               ret.push_back("restrict_radius_ducks");
+               ret.push_back("resize_imported_images");
+               ret.push_back("browser_command");
+               ret.push_back("custom_filename_prefix");
+               ret.push_back("preferred_x_size");
+               ret.push_back("preferred_y_size");
+               ret.push_back("predefined_size");
+               ret.push_back("preferred_fps");
+               ret.push_back("predefined_fps");
+               return ret;
+       }
+};
+
+static ::Preferences _preferences;
+
+void
+init_ui_manager()
+{
+       Glib::RefPtr<Gtk::ActionGroup> menus_action_group = Gtk::ActionGroup::create("menus");
+
+       Glib::RefPtr<Gtk::ActionGroup> toolbox_action_group = Gtk::ActionGroup::create("toolbox");
+
+       Glib::RefPtr<Gtk::ActionGroup> actions_action_group = Gtk::ActionGroup::create("actions");
+
+       menus_action_group->add( Gtk::Action::create("menu-file", _("_File")) );
+       menus_action_group->add( Gtk::Action::create("menu-edit", _("_Edit")) );
+       menus_action_group->add( Gtk::Action::create("menu-view", _("_View")) );
+       menus_action_group->add( Gtk::Action::create("menu-canvas", _("_Canvas")) );
+       menus_action_group->add( Gtk::Action::create("menu-layer", _("_Layer")) );
+       menus_action_group->add( Gtk::Action::create("menu-duck-mask", _("Show/Hide Ducks")) );
+       menus_action_group->add( Gtk::Action::create("menu-preview-quality", _("Preview Quality")) );
+       menus_action_group->add( Gtk::Action::create("menu-lowres-pixel", _("Low-Res Pixel Size")) );
+       menus_action_group->add( Gtk::Action::create("menu-layer-new", _("New Layer")) );
+       menus_action_group->add( Gtk::Action::create("menu-keyframe", _("Keyframe")) );
+       menus_action_group->add( Gtk::Action::create("menu-group", _("Group")) );
+       menus_action_group->add( Gtk::Action::create("menu-state", _("Tool")) );
+       menus_action_group->add( Gtk::Action::create("menu-toolbox", _("Toolbox")) );
+
+       // Add the synfigapp actions...
+       synfigapp::Action::Book::iterator iter;
+       for(iter=synfigapp::Action::book().begin();iter!=synfigapp::Action::book().end();++iter)
+       {
+               actions_action_group->add(Gtk::Action::create(
+                       "action-"+iter->second.name,
+                       get_action_stock_id(iter->second),
+                       iter->second.local_name,iter->second.local_name
+               ));
+       }
+
+#define DEFINE_ACTION(x,stock) { Glib::RefPtr<Gtk::Action> action( Gtk::Action::create(x, stock) ); actions_action_group->add(action); }
+#define DEFINE_ACTION2(x,stock,label) { Glib::RefPtr<Gtk::Action> action( Gtk::Action::create(x, stock,label,label) ); actions_action_group->add(action); }
+#define DEFINE_ACTION_SIG(group,x,stock,sig) { Glib::RefPtr<Gtk::Action> action( Gtk::Action::create(x, stock) ); group->add(action,sig); }
+
+       DEFINE_ACTION2("keyframe-properties", Gtk::StockID("gtk-properties"), _("Keyframe Properties"));
+       DEFINE_ACTION("about", Gtk::StockID("synfig-about"));
+       DEFINE_ACTION("new", Gtk::Stock::NEW);
+       DEFINE_ACTION("open", Gtk::Stock::OPEN);
+       DEFINE_ACTION("save", Gtk::Stock::SAVE);
+       DEFINE_ACTION("save-as", Gtk::Stock::SAVE_AS);
+       DEFINE_ACTION("revert", Gtk::Stock::REVERT_TO_SAVED);
+       DEFINE_ACTION("cvs-add", Gtk::StockID("synfig-cvs_add"));
+       DEFINE_ACTION("cvs-update", Gtk::StockID("synfig-cvs_update"));
+       DEFINE_ACTION("cvs-commit", Gtk::StockID("synfig-cvs_commit"));
+       DEFINE_ACTION("cvs-revert", Gtk::StockID("synfig-cvs_revert"));
+       DEFINE_ACTION("import", _("Import"));
+       DEFINE_ACTION("render", _("Render"));
+       DEFINE_ACTION("preview", _("Preview"));
+       DEFINE_ACTION("dialog-flipbook", _("Preview Dialog"));
+       DEFINE_ACTION("sound", _("Sound File"));
+       DEFINE_ACTION("options", _("Options"));
+       DEFINE_ACTION("close", _("Close View"));
+       DEFINE_ACTION("close-document", _("Close Document"));
+       DEFINE_ACTION("quit", Gtk::Stock::QUIT);
+
+
+       DEFINE_ACTION("undo", Gtk::StockID("gtk-undo"));
+       DEFINE_ACTION("redo", Gtk::StockID("gtk-redo"));
+       DEFINE_ACTION("cut", Gtk::StockID("gtk-cut"));
+       DEFINE_ACTION("copy", Gtk::StockID("gtk-copy"));
+       DEFINE_ACTION("paste", Gtk::StockID("gtk-paste"));
+       DEFINE_ACTION("select-all-ducks", _("Select All Ducks"));
+       DEFINE_ACTION("unselect-all-ducks", _("Unselect All Ducks"));
+       DEFINE_ACTION("select-all-layers", _("Select All Layers"));
+       DEFINE_ACTION("unselect-all-layers", _("Unselect All Layers"));
+       DEFINE_ACTION("properties", _("Properties"));
+
+       DEFINE_ACTION("mask-position-ducks", _("Show Position Ducks"));
+       DEFINE_ACTION("mask-vertex-ducks", _("Show Vertex Ducks"));
+       DEFINE_ACTION("mask-tangent-ducks", _("Show Tangent Ducks"));
+       DEFINE_ACTION("mask-radius-ducks", _("Show Radius Ducks"));
+       DEFINE_ACTION("mask-width-ducks", _("Show Width Ducks"));
+       DEFINE_ACTION("mask-angle-ducks", _("Show Angle Ducks"));
+       DEFINE_ACTION("quality-00", _("Use Parametric Renderer"));
+       DEFINE_ACTION("quality-01", _("Use Quality Level 1"));
+       DEFINE_ACTION("quality-02", _("Use Quality Level 2"));
+       DEFINE_ACTION("quality-03", _("Use Quality Level 3"));
+       DEFINE_ACTION("quality-04", _("Use Quality Level 4"));
+       DEFINE_ACTION("quality-05", _("Use Quality Level 5"));
+       DEFINE_ACTION("quality-06", _("Use Quality Level 6"));
+       DEFINE_ACTION("quality-07", _("Use Quality Level 7"));
+       DEFINE_ACTION("quality-08", _("Use Quality Level 8"));
+       DEFINE_ACTION("quality-09", _("Use Quality Level 9"));
+       DEFINE_ACTION("quality-10", _("Use Quality Level 10"));
+       for(list<int>::iterator iter = CanvasView::get_pixel_sizes().begin(); iter != CanvasView::get_pixel_sizes().end(); iter++)
+               DEFINE_ACTION(strprintf("lowres-pixel-%d", *iter), strprintf(_("Set Low-Res pixel size to %d"), *iter));
+       DEFINE_ACTION("play", _("Play"));
+       // DEFINE_ACTION("pause", _("Pause"));
+       DEFINE_ACTION("stop", _("Stop"));
+       DEFINE_ACTION("toggle-grid-show", _("Toggle Grid Show"));
+       DEFINE_ACTION("toggle-grid-snap", _("Toggle Grid Snap"));
+       DEFINE_ACTION("toggle-guide-show", _("Toggle Guide Show"));
+       DEFINE_ACTION("toggle-low-res", _("Toggle Low-Res"));
+       DEFINE_ACTION("decrease-low-res-pixel-size", _("Decrease Low-Res Pixel Size"));
+       DEFINE_ACTION("increase-low-res-pixel-size", _("Increase Low-Res Pixel Size"));
+       DEFINE_ACTION("toggle-onion-skin", _("Toggle Onion Skin"));
+       DEFINE_ACTION("canvas-zoom-in", Gtk::StockID("gtk-zoom-in"));
+       DEFINE_ACTION("canvas-zoom-out", Gtk::StockID("gtk-zoom-out"));
+       DEFINE_ACTION("canvas-zoom-fit", Gtk::StockID("gtk-zoom-fit"));
+       DEFINE_ACTION("canvas-zoom-100", Gtk::StockID("gtk-zoom-100"));
+       DEFINE_ACTION("time-zoom-in", Gtk::StockID("gtk-zoom-in"));
+       DEFINE_ACTION("time-zoom-out", Gtk::StockID("gtk-zoom-out"));
+       DEFINE_ACTION("jump-next-keyframe", _("Jump to Next Keyframe"));
+       DEFINE_ACTION("jump-prev-keyframe", _("Jump to Prev Keyframe"));
+       DEFINE_ACTION("seek-next-frame", _("Next Frame"));
+       DEFINE_ACTION("seek-prev-frame", _("Prev Frame"));
+       DEFINE_ACTION("seek-next-second", _("Seek Forward"));
+       DEFINE_ACTION("seek-prev-second", _("Seek Backward"));
+       DEFINE_ACTION("seek-begin", _("Seek to Begin"));
+       DEFINE_ACTION("seek-end", _("Seek to End"));
+
+       DEFINE_ACTION("action-group_add", _("Add group"));
+
+       DEFINE_ACTION("canvas-new", _("New Canvas"));
+
+       DEFINE_ACTION("amount-inc", _("Increase Amount"));
+       DEFINE_ACTION("amount-dec", _("Decrease Amount"));
+
+#undef DEFINE_ACTION
+#undef DEFINE_ACTION_2
+#undef DEFINE_ACTION_SIG
+
+    Glib::ustring ui_info =
+"<ui>"
+"      <popup name='menu-toolbox' action='menu-toolbox'>"
+"      <menu action='menu-file'>"
+"      </menu>"
+"      </popup>"
+"      <popup name='menu-main' action='menu-main'>"
+"      <menu action='menu-file'>"
+"              <menuitem action='new' />"
+"              <menuitem action='open' />"
+"              <menuitem action='save' />"
+"              <menuitem action='save-as' />"
+"              <menuitem action='revert' />"
+"              <separator name='bleh01'/>"
+"              <menuitem action='cvs-add' />"
+"              <menuitem action='cvs-update' />"
+"              <menuitem action='cvs-commit' />"
+"              <menuitem action='cvs-revert' />"
+"              <separator name='bleh02'/>"
+"              <menuitem action='import' />"
+"              <separator name='bleh03'/>"
+"              <menuitem action='render' />"
+"              <menuitem action='preview' />"
+"              <menuitem action='sound' />"
+"              <separator name='bleh04'/>"
+"              <menuitem action='options' />"
+"              <menuitem action='close' />"
+"              <menuitem action='close-document' />"
+"              <menuitem action='quit' />"
+"      </menu>"
+"      <menu action='menu-edit'>"
+"              <menuitem action='undo'/>"
+"              <menuitem action='redo'/>"
+"              <separator name='bleh05'/>"
+"              <menuitem action='cut'/>"
+"              <menuitem action='copy'/>"
+"              <menuitem action='paste'/>"
+"              <separator name='bleh06'/>"
+"              <menuitem action='select-all-layers'/>"
+"              <menuitem action='unselect-all-layers'/>"
+"              <menuitem action='select-all-ducks'/>"
+"              <menuitem action='unselect-all-ducks'/>"
+"              <separator name='bleh07'/>"
+"              <menuitem action='properties'/>"
+"      </menu>"
+"      <menu action='menu-view'>"
+"              <menu action='menu-duck-mask'>"
+"                      <menuitem action='mask-position-ducks' />"
+"                      <menuitem action='mask-vertex-ducks' />"
+"                      <menuitem action='mask-tangent-ducks' />"
+"                      <menuitem action='mask-radius-ducks' />"
+"                      <menuitem action='mask-width-ducks' />"
+"                      <menuitem action='mask-angle-ducks' />"
+"              </menu>"
+"              <menu action='menu-preview-quality'>"
+"                      <menuitem action='quality-00' />"
+"                      <menuitem action='quality-01' />"
+"                      <menuitem action='quality-02' />"
+"                      <menuitem action='quality-03' />"
+"                      <menuitem action='quality-04' />"
+"                      <menuitem action='quality-05' />"
+"                      <menuitem action='quality-06' />"
+"                      <menuitem action='quality-07' />"
+"                      <menuitem action='quality-08' />"
+"                      <menuitem action='quality-09' />"
+"                      <menuitem action='quality-10' />"
+"              </menu>"
+"              <menu action='menu-lowres-pixel'>"
+"              <menuitem action='decrease-low-res-pixel-size'/>"
+"              <menuitem action='increase-low-res-pixel-size'/>"
+"              <separator name='pixel-size-separator'/>"
+;
+
+       for(list<int>::iterator iter = CanvasView::get_pixel_sizes().begin(); iter != CanvasView::get_pixel_sizes().end(); iter++)
+               ui_info += strprintf("                  <menuitem action='lowres-pixel-%d' />", *iter);
+
+       ui_info +=
+"              </menu>"
+"              <separator name='bleh08'/>"
+"              <menuitem action='play'/>"
+//"            <menuitem action='pause'/>"
+"              <menuitem action='stop'/>"
+"              <menuitem action='dialog-flipbook'/>"
+"              <separator name='bleh09'/>"
+"              <menuitem action='toggle-grid-show'/>"
+"              <menuitem action='toggle-grid-snap'/>"
+"              <menuitem action='toggle-guide-show'/>"
+"              <menuitem action='toggle-low-res'/>"
+"              <menuitem action='toggle-onion-skin'/>"
+"              <separator name='bleh10'/>"
+"              <menuitem action='canvas-zoom-in'/>"
+"              <menuitem action='canvas-zoom-out'/>"
+"              <menuitem action='canvas-zoom-fit'/>"
+"              <menuitem action='canvas-zoom-100'/>"
+"              <separator name='bleh11'/>"
+"              <menuitem action='time-zoom-in'/>"
+"              <menuitem action='time-zoom-out'/>"
+"              <separator name='bleh12'/>"
+"              <menuitem action='jump-next-keyframe'/>"
+"              <menuitem action='jump-prev-keyframe'/>"
+"              <menuitem action='seek-next-frame'/>"
+"              <menuitem action='seek-prev-frame'/>"
+"              <menuitem action='seek-next-second'/>"
+"              <menuitem action='seek-prev-second'/>"
+"              <menuitem action='seek-begin'/>"
+"              <menuitem action='seek-end'/>"
+"      </menu>"
+"      <menu action='menu-canvas'>"
+"              <menuitem action='canvas-new'/>"
+"      </menu>"
+"      <menu name='menu-state' action='menu-state'>"
+"      </menu>"
+"      <menu action='menu-group'>"
+"              <menuitem action='action-group_add'/>"
+"      </menu>"
+"      <menu action='menu-layer'>"
+//"            <menuitem action='cut'/>"
+//"            <menuitem action='copy'/>"
+//"            <menuitem action='paste'/>"
+//"            <separator name='bleh06'/>"
+"              <menu action='menu-layer-new'></menu>"
+"              <menuitem action='amount-inc'/>"
+"              <menuitem action='amount-dec'/>"
+"      </menu>"
+"      <menu action='menu-keyframe'>"
+"              <menuitem action='keyframe-properties'/>"
+"      </menu>"
+"      </popup>"
+
+"</ui>"
+;
+/*             "<ui>"
+        "  <menubar name='MenuBar'>"
+        "    <menu action='MenuFile'>"
+        "      <menuitem action='New'/>"
+        "      <menuitem action='Open'/>"
+        "      <separator/>"
+        "      <menuitem action='Quit'/>"
+        "    </menu>"
+        "    <menu action='MenuEdit'>"
+        "      <menuitem action='Cut'/>"
+        "      <menuitem action='Copy'/>"
+        "      <menuitem action='Paste'/>"
+        "    </menu>"
+        "  </menubar>"
+        "  <toolbar  name='ToolBar'>"
+        "    <toolitem action='Open'/>"
+        "    <toolitem action='Quit'/>"
+        "  </toolbar>"
+        "</ui>";
+*/
+       try
+       {
+               actions_action_group->set_sensitive(false);
+               App::ui_manager()->set_add_tearoffs(true);
+               App::ui_manager()->insert_action_group(menus_action_group,1);
+               App::ui_manager()->insert_action_group(actions_action_group,1);
+               App::ui_manager()->add_ui_from_string(ui_info);
+
+               //App::ui_manager()->get_accel_group()->unlock();
+       }
+       catch(const Glib::Error& ex)
+       {
+               synfig::error("building menus and toolbars failed: " + ex.what());
+       }
+
+       // Add default keyboard accelerators
+#define ACCEL(accel,path)                                              \
+       {                                                                                       \
+               Gtk::AccelKey accel_key(accel,path);    \
+               Gtk::AccelMap::add_entry(accel_key.get_path(), accel_key.get_key(), accel_key.get_mod());       \
+       }
+
+#define ACCEL2(accel)                                                  \
+       {                                                                                       \
+               Gtk::AccelKey accel_key(accel);                 \
+               Gtk::AccelMap::add_entry(accel_key.get_path(), accel_key.get_key(), accel_key.get_mod());       \
+       }
+
+       // the toolbox
+       ACCEL("<Mod1>a",                                                                                                        "<Actions>/action_group_state_manager/state-normal"                                     );
+       ACCEL("<Mod1>v",                                                                                                        "<Actions>/action_group_state_manager/state-smooth_move"                                );
+       ACCEL("<Mod1>s",                                                                                                        "<Actions>/action_group_state_manager/state-scale"                                      );
+       ACCEL("<Mod1>t",                                                                                                        "<Actions>/action_group_state_manager/state-rotate"                                     );
+       ACCEL("<Mod1>m",                                                                                                        "<Actions>/action_group_state_manager/state-mirror"                                     );
+       ACCEL("<Mod1>c",                                                                                                        "<Actions>/action_group_state_manager/state-circle"                                     );
+       ACCEL("<Mod1>r",                                                                                                        "<Actions>/action_group_state_manager/state-rectangle"                          );
+       ACCEL("<Mod1>q",                                                                                                        "<Actions>/action_group_state_manager/state-star"                                               );
+       ACCEL("<Mod1>g",                                                                                                        "<Actions>/action_group_state_manager/state-gradient"                                   );
+       ACCEL("<Mod1>p",                                                                                                        "<Actions>/action_group_state_manager/state-polygon"                                    );
+       ACCEL("<Mod1>b",                                                                                                        "<Actions>/action_group_state_manager/state-bline"                                      );
+       ACCEL("<Mod1>x",                                                                                                        "<Actions>/action_group_state_manager/state-text"                                               );
+       ACCEL("<Mod1>f",                                                                                                        "<Actions>/action_group_state_manager/state-fill"                                               );
+       ACCEL("<Mod1>e",                                                                                                        "<Actions>/action_group_state_manager/state-eyedrop"                                    );
+       ACCEL("<Mod1>z",                                                                                                        "<Actions>/action_group_state_manager/state-zoom"                                               );
+       ACCEL("<Mod1>d",                                                                                                        "<Actions>/action_group_state_manager/state-draw"                                               );
+       ACCEL("<Mod1>k",                                                                                                        "<Actions>/action_group_state_manager/state-sketch"                                     );
+       ACCEL("<Mod1>w",                                                                                                        "<Actions>/action_group_state_manager/state-width"                                      );
+
+       // everything else
+       ACCEL("<Control>a",                                                                                                     "<Actions>/canvasview/select-all-ducks"                         );
+       ACCEL("<Control>d",                                                                                                     "<Actions>/canvasview/unselect-all-ducks"                               );
+       ACCEL("<Control><Shift>a",                                                                                      "<Actions>/canvasview/select-all-layers"                                );
+       ACCEL("<Control><Shift>d",                                                                                      "<Actions>/canvasview/unselect-all-layers"                      );
+       ACCEL("F9",                                                                                                                     "<Actions>/canvasview/render"                                                   );
+       ACCEL("F11",                                                                                                            "<Actions>/canvasview/preview"                                          );
+       ACCEL("F8",                                                                                                                     "<Actions>/canvasview/properties"                                               );
+       ACCEL("F12",                                                                                                            "<Actions>/canvasview/options"                                          );
+       ACCEL("<control>i",                                                                                                     "<Actions>/canvasview/import"                                                   );
+       ACCEL2(Gtk::AccelKey(GDK_Escape,static_cast<Gdk::ModifierType>(0),      "<Actions>/canvasview/stop"                                                     ));
+       ACCEL("<Control>g",                                                                                                     "<Actions>/canvasview/toggle-grid-show"                         );
+       ACCEL("<Control>l",                                                                                                     "<Actions>/canvasview/toggle-grid-snap"                         );
+       ACCEL2(Gtk::AccelKey('`',Gdk::CONTROL_MASK,                                                     "<Actions>/canvasview/toggle-low-res"                                   ));
+       ACCEL("<Mod1>1",                                                                                                        "<Actions>/canvasview/mask-position-ducks"                      );
+       ACCEL("<Mod1>2",                                                                                                        "<Actions>/canvasview/mask-vertex-ducks"                                );
+       ACCEL("<Mod1>3",                                                                                                        "<Actions>/canvasview/mask-tangent-ducks"                               );
+       ACCEL("<Mod1>4",                                                                                                        "<Actions>/canvasview/mask-radius-ducks"                                );
+       ACCEL("<Mod1>5",                                                                                                        "<Actions>/canvasview/mask-width-ducks"                         );
+       ACCEL("<Mod1>6",                                                                                                        "<Actions>/canvasview/mask-angle-ducks"                         );
+       ACCEL2(Gtk::AccelKey(GDK_Page_Up,Gdk::SHIFT_MASK,                                       "<Actions>/action_group_layer_action_manager/action-LayerRaise"                         ));
+       ACCEL2(Gtk::AccelKey(GDK_Page_Down,Gdk::SHIFT_MASK,                                     "<Actions>/action_group_layer_action_manager/action-LayerLower"                         ));
+       ACCEL("<Control>1",                                                                                                     "<Actions>/canvasview/quality-01"                                               );
+       ACCEL("<Control>2",                                                                                                     "<Actions>/canvasview/quality-02"                                               );
+       ACCEL("<Control>3",                                                                                                     "<Actions>/canvasview/quality-03"                                               );
+       ACCEL("<Control>4",                                                                                                     "<Actions>/canvasview/quality-04"                                               );
+       ACCEL("<Control>5",                                                                                                     "<Actions>/canvasview/quality-05"                                               );
+       ACCEL("<Control>6",                                                                                                     "<Actions>/canvasview/quality-06"                                               );
+       ACCEL("<Control>7",                                                                                                     "<Actions>/canvasview/quality-07"                                               );
+       ACCEL("<Control>8",                                                                                                     "<Actions>/canvasview/quality-08"                                               );
+       ACCEL("<Control>9",                                                                                                     "<Actions>/canvasview/quality-09"                                               );
+       ACCEL("<Control>0",                                                                                                     "<Actions>/canvasview/quality-10"                                               );
+       ACCEL("<Control>z",                                                                                                     "<Actions>/action_group_dock_history/undo"                                                      );
+       ACCEL("<Control>r",                                                                                                     "<Actions>/action_group_dock_history/redo"                                                      );
+       ACCEL2(Gtk::AccelKey(GDK_Delete,Gdk::CONTROL_MASK,                                      "<Actions>/action_group_layer_action_manager/action-LayerRemove"                                ));
+       ACCEL2(Gtk::AccelKey('(',Gdk::CONTROL_MASK,                                                     "<Actions>/canvasview/decrease-low-res-pixel-size"      ));
+       ACCEL2(Gtk::AccelKey(')',Gdk::CONTROL_MASK,                                                     "<Actions>/canvasview/increase-low-res-pixel-size"      ));
+       ACCEL2(Gtk::AccelKey('(',Gdk::MOD1_MASK|Gdk::CONTROL_MASK,                      "<Actions>/action_group_layer_action_manager/amount-dec"                                                ));
+       ACCEL2(Gtk::AccelKey(')',Gdk::MOD1_MASK|Gdk::CONTROL_MASK,                      "<Actions>/action_group_layer_action_manager/amount-inc"                                                ));
+       ACCEL2(Gtk::AccelKey(']',Gdk::CONTROL_MASK,                                                     "<Actions>/canvasview/jump-next-keyframe"                               ));
+       ACCEL2(Gtk::AccelKey('[',Gdk::CONTROL_MASK,                                                     "<Actions>/canvasview/jump-prev-keyframe"                               ));
+       ACCEL2(Gtk::AccelKey('=',Gdk::CONTROL_MASK,                                                     "<Actions>/canvasview/canvas-zoom-in"                                   ));
+       ACCEL2(Gtk::AccelKey('-',Gdk::CONTROL_MASK,                                                     "<Actions>/canvasview/canvas-zoom-out"                          ));
+       ACCEL2(Gtk::AccelKey('+',Gdk::CONTROL_MASK,                                                     "<Actions>/canvasview/time-zoom-in"                                     ));
+       ACCEL2(Gtk::AccelKey('_',Gdk::CONTROL_MASK,                                                     "<Actions>/canvasview/time-zoom-out"                                    ));
+       ACCEL2(Gtk::AccelKey('.',Gdk::CONTROL_MASK,                                                     "<Actions>/canvasview/seek-next-frame"                          ));
+       ACCEL2(Gtk::AccelKey(',',Gdk::CONTROL_MASK,                                                     "<Actions>/canvasview/seek-prev-frame"                          ));
+       ACCEL2(Gtk::AccelKey('>',Gdk::CONTROL_MASK,                                                     "<Actions>/canvasview/seek-next-second"                         ));
+       ACCEL2(Gtk::AccelKey('<',Gdk::CONTROL_MASK,                                                     "<Actions>/canvasview/seek-prev-second"                         ));
+       ACCEL("<Mod1>o",                                                                                                        "<Actions>/canvasview/toggle-onion-skin"                                );
+       ACCEL("<Control><Shift>z",                                                                                      "<Actions>/canvasview/canvas-zoom-fit"                          );
+       ACCEL("<Control>p",                                                                                                     "<Actions>/canvasview/play"                                                     );
+       ACCEL("Home",                                                                                                           "<Actions>/canvasview/seek-begin"                                               );
+       ACCEL("End",                                                                                                            "<Actions>/canvasview/seek-end"                                         );
+
+#undef ACCEL
+#undef ACCEL2
+}
+
+#ifdef _WIN32
+#define mkdir(x,y) mkdir(x)
+#endif
+
+/* === M E T H O D S ======================================================= */
+
+App::App(int *argc, char ***argv):
+       Gtk::Main(argc,argv),
+       IconController(etl::dirname((*argv)[0]))
+{
+       app_base_path_=etl::dirname(etl::dirname((*argv)[0]));
+
+
+       ui_interface_=new GlobalUIInterface();
+
+       gdk_rgb_init();
+
+       // don't call thread_init() if threads are already initialized
+       // on some machines bonobo_init() initialized threads before we get here
+       if (!g_thread_supported())
+               Glib::thread_init();
+
+       distance_system=Distance::SYSTEM_UNITS;
+
+       if(mkdir(get_user_app_directory().c_str(),ACCESSPERMS)<0)
+       {
+               if(errno!=EEXIST)
+                       synfig::error("UNABLE TO CREATE \"%s\"",get_user_app_directory().c_str());
+       }
+       else
+       {
+               synfig::info("Created directory \"%s\"",get_user_app_directory().c_str());
+       }
+
+
+       ipc=new IPC();
+
+       if(!SYNFIG_CHECK_VERSION())
+       {
+               cerr<<"FATAL: Synfig Version Mismatch"<<endl;
+               dialog_error_blocking("Synfig Studio",
+                       "This copy of Synfig Studio was compiled against a\n"
+                       "different version of libsynfig than what is currently\n"
+                       "installed. Synfig Studio will now abort. Try downloading\n"
+                       "the latest version from the Synfig website at\n"
+                       "http://synfig.org/Download"
+               );
+               throw 40;
+       }
+       Glib::set_application_name(_("Synfig Studio"));
+
+       Splash splash_screen;
+       splash_screen.show();
+
+       shutdown_in_progress=false;
+       SuperCallback synfig_init_cb(splash_screen.get_callback(),0,9000,10000);
+       SuperCallback studio_init_cb(splash_screen.get_callback(),9000,10000,10000);
+
+       // Initialize the Synfig library
+       try { synfigapp_main=etl::smart_ptr<synfigapp::Main>(new synfigapp::Main(etl::dirname((*argv)[0]),&synfig_init_cb)); }
+       catch(std::runtime_error x)
+       {
+               get_ui_interface()->error(strprintf("%s\n\n%s", _("Failed to initialize synfig!"), x.what()));
+               throw;
+       }
+       catch(...)
+       {
+               get_ui_interface()->error(_("Failed to initialize synfig!"));
+               throw;
+       }
+
+       // add the preferences to the settings
+       synfigapp::Main::settings().add_domain(&_preferences,"pref");
+
+       try
+       {
+               studio_init_cb.task(_("Init UI Manager..."));
+               App::ui_manager_=studio::UIManager::create();
+               init_ui_manager();
+
+               studio_init_cb.task(_("Init Dock Manager..."));
+               dock_manager=new studio::DockManager();
+
+               studio_init_cb.task(_("Init State Manager..."));
+               state_manager=new StateManager();
+
+               studio_init_cb.task(_("Init Toolbox..."));
+               toolbox=new studio::Toolbox();
+
+               studio_init_cb.task(_("Init About Dialog..."));
+               about=new studio::About();
+
+               studio_init_cb.task(_("Init Tool Options..."));
+               dialog_tool_options=new studio::Dialog_ToolOptions();
+               dock_manager->register_dockable(*dialog_tool_options);
+
+               studio_init_cb.task(_("Init History..."));
+               dock_history=new studio::Dock_History();
+               dock_manager->register_dockable(*dock_history);
+
+               studio_init_cb.task(_("Init Canvases..."));
+               dock_canvases=new studio::Dock_Canvases();
+               dock_manager->register_dockable(*dock_canvases);
+
+               studio_init_cb.task(_("Init Keyframes..."));
+               dock_keyframes=new studio::Dock_Keyframes();
+               dock_manager->register_dockable(*dock_keyframes);
+
+               studio_init_cb.task(_("Init Layers..."));
+               dock_layers=new studio::Dock_Layers();
+               dock_manager->register_dockable(*dock_layers);
+
+               studio_init_cb.task(_("Init Params..."));
+               dock_params=new studio::Dock_Params();
+               dock_manager->register_dockable(*dock_params);
+
+               studio_init_cb.task(_("Init MetaData..."));
+               dock_meta_data=new studio::Dock_MetaData();
+               dock_manager->register_dockable(*dock_meta_data);
+
+               studio_init_cb.task(_("Init Children..."));
+               dock_children=new studio::Dock_Children();
+               dock_manager->register_dockable(*dock_children);
+
+               studio_init_cb.task(_("Init Info..."));
+               dock_info = new studio::Dock_Info();
+               dock_manager->register_dockable(*dock_info);
+
+               studio_init_cb.task(_("Init Navigator..."));
+               dock_navigator = new studio::Dock_Navigator();
+               dock_manager->register_dockable(*dock_navigator);
+
+               studio_init_cb.task(_("Init Timetrack..."));
+               dock_timetrack = new studio::Dock_Timetrack();
+               dock_manager->register_dockable(*dock_timetrack);
+
+               studio_init_cb.task(_("Init Curve Editor..."));
+               dock_curves = new studio::Dock_Curves();
+               dock_manager->register_dockable(*dock_curves);
+
+               studio_init_cb.task(_("Init Layer Groups..."));
+               dock_layer_groups = new studio::Dock_LayerGroups();
+               dock_manager->register_dockable(*dock_layer_groups);
+
+
+               studio_init_cb.task(_("Init Color Dialog..."));
+               dialog_color=new studio::Dialog_Color();
+
+               studio_init_cb.task(_("Init Gradient Dialog..."));
+               dialog_gradient=new studio::Dialog_Gradient();
+
+               studio_init_cb.task(_("Init DeviceTracker..."));
+               device_tracker=new studio::DeviceTracker();
+
+               studio_init_cb.task(_("Init Tools..."));
+
+               /* 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_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);
+               if(!getenv("SYNFIG_DISABLE_SKETCH" )) state_manager->add_state(&state_sketch);
+
+               studio_init_cb.task(_("Init ModPalette..."));
+               module_list_.push_back(new ModPalette()); module_list_.back()->start();
+
+               studio_init_cb.task(_("Init Setup Dialog..."));
+               dialog_setup=new studio::Dialog_Setup();
+
+               studio_init_cb.task(_("Init Input Dialog..."));
+               dialog_input=new Gtk::InputDialog();
+               dialog_input->get_close_button()->signal_clicked().connect( sigc::mem_fun( *dialog_input, &Gtk::InputDialog::hide ) );
+               dialog_input->get_save_button()->signal_clicked().connect( sigc::mem_fun( *device_tracker, &DeviceTracker::save_preferences) );
+
+               studio_init_cb.task(_("Init auto recovery..."));
+               auto_recover=new AutoRecover();
+
+               studio_init_cb.amount_complete(9250,10000);
+               studio_init_cb.task(_("Loading Settings..."));
+               load_settings();
+               device_tracker->load_preferences();
+
+               studio_init_cb.task(_("Checking auto-recover..."));
+
+               studio_init_cb.amount_complete(9900,10000);
+
+               bool opened_any = false;
+               if(auto_recover->recovery_needed())
+               {
+                       splash_screen.hide();
+                       if (get_ui_interface()->confirmation("Crash Recovery",
+                                       _("Auto recovery file found"),
+                                       _("Synfig Studio seems to have crashed\n"
+                                         "before you could save all your files.\n"
+                                         "Recover unsaved changes?"),
+                                       _("Recover"), _("Ignore"))
+                               == synfigapp::UIInterface::RESPONSE_OK)
+                       {
+                               int number_recovered;
+                               if(!auto_recover->recover(number_recovered))
+                                       if (number_recovered)
+                                               get_ui_interface()->error(_("Unable to fully recover from previous crash"));
+                                       else
+                                               get_ui_interface()->error(_("Unable to recover from previous crash"));
+                               else
+                                       get_ui_interface()->error(
+                                               _("Synfig Studio has attempted to recover\n"
+                                                 "from a previous crash. The files that it has\n"
+                                                 "recovered are NOT YET SAVED. It would be a good\n"
+                                                 "idea to review them and save them now."));
+
+                               if (number_recovered)
+                                       opened_any = true;
+                       }
+                       splash_screen.show();
+               }
+
+               // Look for any files given on the command line,
+               // and load them if found.
+               for(;*argc>=1;(*argc)--)
+                       if((*argv)[*argc] && (*argv)[*argc][0]!='-')
+                       {
+                               studio_init_cb.task(_("Loading files..."));
+                               splash_screen.hide();
+                               open((*argv)[*argc]);
+                               opened_any = true;
+                               splash_screen.show();
+                       }
+
+               // if no file was specified to be opened, create a new document to help new users get started more easily
+               if (!opened_any && !getenv("SYNFIG_DISABLE_AUTOMATIC_DOCUMENT_CREATION"))
+                       new_instance();
+
+               studio_init_cb.task(_("Done."));
+               studio_init_cb.amount_complete(10000,10000);
+
+               toolbox->present();
+       }
+       catch(String x)
+       {
+               get_ui_interface()->error(_("Unknown exception caught when constructing App.\nThis software may be unstable.") + String("\n\n") + x);
+       }
+       catch(...)
+       {
+               get_ui_interface()->error(_("Unknown exception caught when constructing App.\nThis software may be unstable."));
+       }
+}
+
+StateManager* App::get_state_manager() { return state_manager; }
+
+App::~App()
+{
+       shutdown_in_progress=true;
+
+       save_settings();
+
+       synfigapp::Main::settings().remove_domain("pref");
+
+       selected_instance=0;
+
+       // Unload all of the modules
+       for(;!module_list_.empty();module_list_.pop_back())
+               ;
+
+       delete state_manager;
+
+       delete ipc;
+
+       delete auto_recover;
+
+       delete about;
+
+       toolbox->hide();
+
+       delete toolbox;
+
+       delete dialog_setup;
+
+       delete dialog_gradient;
+
+       delete dialog_color;
+
+       delete dialog_input;
+
+       delete dock_manager;
+
+       instance_list.clear();
+}
+
+String
+App::get_user_app_directory()
+{
+//! \todo do we need locale_from_utf8() on non-Windows boxes too?  (bug #1837445)
+#ifdef WIN32
+       return Glib::locale_from_utf8(Glib::build_filename(Glib::get_home_dir(),SYNFIG_USER_APP_DIR));
+#else
+       return Glib::build_filename(Glib::get_home_dir(),SYNFIG_USER_APP_DIR);
+#endif
+}
+
+synfig::String
+App::get_config_file(const synfig::String& file)
+{
+       return Glib::build_filename(get_user_app_directory(),file);
+}
+
+#define SCALE_FACTOR   (1280)
+//! set the \a instance's canvas(es) position and size to be those specified in the first entry of recent_files_window_size
+void
+App::set_recent_file_window_size(etl::handle<Instance> instance)
+{
+       int screen_w(Gdk::screen_width());
+       int screen_h(Gdk::screen_height());
+
+       const std::string &canvas_window_size = *recent_files_window_size.begin();
+
+       if(canvas_window_size.empty())
+               return;
+
+       synfig::String::size_type current=0;
+       bool seen_root(false), shown_non_root(false);
+
+       while(current != synfig::String::npos)
+       {
+               // find end of first field (canvas) or return
+               synfig::String::size_type separator = canvas_window_size.find_first_of(' ', current);
+               if(separator == synfig::String::npos) break;
+
+               // find the canvas
+               synfig::Canvas::Handle canvas;
+               try {
+                       String warnings;
+                       canvas = instance->get_canvas()->find_canvas(String(canvas_window_size, current, separator-current), warnings);
+               }
+               catch(Exception::IDNotFound) {
+                       // can't find the canvas; skip to the next canvas or return
+                       separator = canvas_window_size.find_first_of('\t', current);
+                       if(separator == synfig::String::npos) return;
+                       current = separator+1;
+                       continue;
+               }
+
+               if (canvas->is_root())
+                       seen_root = true;
+               else
+                       shown_non_root = true;
+
+               // check that we have the tab character the ends this canvas' data or return
+               current = separator+1;
+               separator = canvas_window_size.find_first_of('\t', current);
+               if(separator == synfig::String::npos) return;
+
+               int x,y,w,h;
+               if(!strscanf(String(canvas_window_size, current, separator-current),"%d %d %d %d",&x, &y, &w, &h))
+               {
+                       current = separator+1;
+                       continue;
+               }
+
+               if (x > SCALE_FACTOR) x = SCALE_FACTOR - 150; if (x < 0) x = 0;
+               if (y > SCALE_FACTOR) y = SCALE_FACTOR - 150; if (y < 0) y = 0;
+               x=x*screen_w/SCALE_FACTOR;
+               y=y*screen_h/SCALE_FACTOR;
+               if(getenv("SYNFIG_WINDOW_POSITION_X_OFFSET"))
+                       x += atoi(getenv("SYNFIG_WINDOW_POSITION_X_OFFSET"));
+               if(getenv("SYNFIG_WINDOW_POSITION_Y_OFFSET"))
+                       y += atoi(getenv("SYNFIG_WINDOW_POSITION_Y_OFFSET"));
+
+               if (w > SCALE_FACTOR) w = 150; if (w < 0) w = 0;
+               if (h > SCALE_FACTOR) h = 150; if (h < 0) h = 0;
+
+               CanvasView::Handle canvasview = instance->find_canvas_view(canvas);
+               canvasview->move(x,y);
+               canvasview->resize(w*screen_w/SCALE_FACTOR,h*screen_h/SCALE_FACTOR);
+               canvasview->present();
+
+               current = separator+1;
+       }
+
+       if (shown_non_root && !seen_root)
+               instance->find_canvas_view(instance->get_canvas())->hide();
+}
+
+void
+App::add_recent_file(const etl::handle<Instance> instance)
+{
+       int screen_w(Gdk::screen_width());
+       int screen_h(Gdk::screen_height());
+
+       std::string canvas_window_size;
+
+       const Instance::CanvasViewList& cview_list = instance->canvas_view_list();
+       Instance::CanvasViewList::const_iterator iter;
+
+       for(iter=cview_list.begin();iter!=cview_list.end();iter++)
+       {
+               if( !((*iter)->is_visible()) )
+                       continue;
+
+               etl::handle<synfig::Canvas> canvas = (*iter)->get_canvas();
+               int x_pos, y_pos, x_size, y_size;
+               (*iter)->get_position(x_pos,y_pos);
+               (*iter)->get_size(x_size,y_size);
+
+               canvas_window_size += strprintf("%s %d %d %d %d\t",
+                                                                               canvas->get_relative_id(canvas->get_root()).c_str(),
+                                                                               x_pos*SCALE_FACTOR/screen_w,  y_pos*SCALE_FACTOR/screen_h,
+                                                                               x_size*SCALE_FACTOR/screen_w, y_size*SCALE_FACTOR/screen_h);
+       }
+
+       add_recent_file(absolute_path(instance->get_file_name()), canvas_window_size);
+}
+#undef SCALE_FACTOR
+
+void
+App::add_recent_file(const std::string &file_name, const std::string &window_size)
+{
+       std::string filename(file_name);
+
+       assert(!filename.empty());
+
+       if(filename.empty())
+               return;
+
+       // Toss out any "hidden" files
+       if(basename(filename)[0]=='.')
+               return;
+
+       // If we aren't an absolute path, turn ourselves into one
+       if(!is_absolute_path(filename))
+               filename=absolute_path(filename);
+
+       std::string old_window_size;
+
+       list<string>::iterator iter;
+       list<string>::iterator iter_wsize;
+       // Check to see if the file is already on the list.
+       // If it is, then remove it from the list
+       for(iter=recent_files.begin(), iter_wsize=recent_files_window_size.begin();iter!=recent_files.end();iter++, iter_wsize++)
+               if(*iter==filename)
+               {
+                       recent_files.erase(iter);
+                       old_window_size = *iter_wsize;
+                       recent_files_window_size.erase(iter_wsize);
+                       break;
+               }
+
+
+       // Push the filename to the front of the list
+       recent_files.push_front(filename);
+       if(window_size.empty())
+               recent_files_window_size.push_front(old_window_size);
+       else
+               recent_files_window_size.push_front(window_size);
+
+       // Clean out the files at the end of the list.
+       while(recent_files.size()>(unsigned)get_max_recent_files())
+       {
+               recent_files.pop_back();
+               recent_files_window_size.pop_back();
+       }
+
+       signal_recent_files_changed_();
+
+       return;
+}
+
+static Time::Format _App_time_format(Time::FORMAT_NORMAL);
+
+Time::Format
+App::get_time_format()
+{
+       return _App_time_format;
+}
+
+void
+App::set_time_format(synfig::Time::Format x)
+{
+       _App_time_format=x;
+}
+
+
+void
+App::save_settings()
+{
+       char * old_locale;
+       try
+       {
+       old_locale=strdup(setlocale(LC_NUMERIC, NULL));
+       setlocale(LC_NUMERIC, "C");
+               {
+                       std::string filename=get_config_file("accelrc");
+                       Gtk::AccelMap::save(filename);
+               }
+               do{
+                       std::string filename=get_config_file("recentfiles");
+
+                       std::ofstream file(filename.c_str());
+
+                       if(!file)
+                       {
+                               synfig::warning("Unable to save %s",filename.c_str());
+                               break;
+                       }
+
+                       list<string>::reverse_iterator iter;
+
+                       for(iter=recent_files.rbegin();iter!=recent_files.rend();iter++)
+                               file<<*iter<<endl;
+               }while(0);
+               do{
+                       std::string filename=get_config_file("recentfiles")+std::string("_window_size");
+
+                       std::ofstream file(filename.c_str());
+
+                       if(!file)
+                       {
+                               synfig::warning("Unable to save %s",filename.c_str());
+                               break;
+                       }
+
+                       list<string>::reverse_iterator iter;
+
+                       for(iter=recent_files_window_size.rbegin();iter!=recent_files_window_size.rend();iter++)
+                               file<<*iter<<endl;
+
+               }while(0);
+               std::string filename=get_config_file("settings");
+               synfigapp::Main::settings().save_to_file(filename);
+       setlocale(LC_NUMERIC,old_locale);
+       }
+       catch(...)
+       {
+               synfig::warning("Caught exception when attempting to save settings.");
+       }
+}
+
+void
+App::load_settings()
+{
+       char  * old_locale;
+       try
+       {
+       old_locale=strdup(setlocale(LC_NUMERIC, NULL));
+       setlocale(LC_NUMERIC, "C");
+               {
+                       std::string filename=get_config_file("accelrc");
+                       Gtk::AccelMap::load(filename);
+               }
+               {
+                       bool window_size_broken = false;
+
+                       std::string filename=get_config_file("recentfiles");
+                       std::string filename_window_size=filename+std::string("_window_size");
+
+                       std::ifstream file(filename.c_str());
+                       std::ifstream file_window_size(filename_window_size.c_str());
+
+                       if(!file_window_size)
+                               window_size_broken = true;
+
+                       while(file)
+                       {
+                               std::string recent_file;
+                               std::string recent_file_window_size;
+                               getline(file,recent_file);
+                               if(!window_size_broken)
+                                       getline(file_window_size,recent_file_window_size);
+                               if(!recent_file.empty())
+                               {
+                                       if(!window_size_broken && !file_window_size)
+                                               window_size_broken = true;
+                                       if (std::ifstream(recent_file.c_str()))
+                                       {
+                                               if(!window_size_broken)
+                                                       add_recent_file(recent_file,recent_file_window_size);
+                                               else
+                                                       add_recent_file(recent_file);
+                                       }
+                               }
+                       }
+                       if(!window_size_broken && file_window_size)
+                               window_size_broken = true;
+
+                       if(window_size_broken)
+                       {
+                               recent_files_window_size.clear();
+                               recent_files_window_size.resize(recent_files.size());
+                       }
+               }
+               std::string filename=get_config_file("settings");
+               if(!synfigapp::Main::settings().load_from_file(filename))
+               {
+                       //std::string filename=Glib::locale_from_utf8(Glib::build_filename(Glib::get_home_dir(),".synfigrc"));
+                       //if(!synfigapp::Main::settings().load_from_file(filename))
+                       {
+                               gamma.set_gamma(1.0/2.2);
+                               reset_initial_window_configuration();
+                       }
+               }
+       setlocale(LC_NUMERIC,old_locale);
+       }
+       catch(...)
+       {
+               synfig::warning("Caught exception when attempting to load settings.");
+       }
+}
+
+void
+App::reset_initial_window_configuration()
+{
+       synfigapp::Main::settings().set_value("dock.dialog.1.comp_selector","1");
+       synfigapp::Main::settings().set_value("dock.dialog.1.contents","navigator - info pal_edit pal_browse - tool_options history canvases - layers groups");
+       synfigapp::Main::settings().set_value("dock.dialog.1.contents_size","225 167 207");
+       synfigapp::Main::settings().set_value("dock.dialog.1.pos","1057 32");
+       synfigapp::Main::settings().set_value("dock.dialog.1.size","208 1174");
+       synfigapp::Main::settings().set_value("dock.dialog.2.comp_selector","0");
+       synfigapp::Main::settings().set_value("dock.dialog.2.contents","params children keyframes | timetrack curves meta_data");
+       synfigapp::Main::settings().set_value("dock.dialog.2.contents_size","263");
+       synfigapp::Main::settings().set_value("dock.dialog.2.pos","0 973");
+       synfigapp::Main::settings().set_value("dock.dialog.2.size","1045 235");
+       synfigapp::Main::settings().set_value("pref.distance_system","pt");
+       synfigapp::Main::settings().set_value("pref.use_colorspace_gamma","1");
+#ifdef SINGLE_THREADED
+       synfigapp::Main::settings().set_value("pref.single_threaded","1");
+#endif
+       synfigapp::Main::settings().set_value("pref.restrict_radius_ducks","0");
+       synfigapp::Main::settings().set_value("pref.resize_imported_images","0");
+       synfigapp::Main::settings().set_value("pref.custom_filename_prefix",DEFAULT_FILENAME_PREFIX);
+       synfigapp::Main::settings().set_value("pref.preferred_x_size","480");
+       synfigapp::Main::settings().set_value("pref.preferred_y_size","270");
+       synfigapp::Main::settings().set_value("pref.predefined_size",DEFAULT_PREDEFINED_SIZE);
+       synfigapp::Main::settings().set_value("pref.preferred_fps","24.0");
+       synfigapp::Main::settings().set_value("pref.predefined_fps",DEFAULT_PREDEFINED_FPS);
+       synfigapp::Main::settings().set_value("window.toolbox.pos","4 4");
+}
+
+bool
+App::shutdown_request(GdkEventAny*)
+{
+       quit();
+       return true;
+       //return !shutdown_in_progress;
+}
+
+void
+App::quit()
+{
+       if(shutdown_in_progress)return;
+
+
+       get_ui_interface()->task(_("Quit Request"));
+       if(Busy::count)
+       {
+               dialog_error_blocking(_("Cannot quit!"),_("Tasks are currently running.\nPlease cancel the current tasks and try again"));
+               return;
+       }
+
+       std::list<etl::handle<Instance> >::iterator iter;
+       for(iter=instance_list.begin();!instance_list.empty();iter=instance_list.begin())
+       {
+               if(!(*iter)->safe_close())
+                       return;
+
+/*
+               if((*iter)->synfigapp::Instance::get_action_count())
+               {
+                       handle<synfigapp::UIInterface> uim;
+                       uim=(*iter)->find_canvas_view((*iter)->get_canvas())->get_ui_interface();
+                       assert(uim);
+                       string str=strprintf(_("Would you like to save your changes to %s?"),(*iter)->get_file_name().c_str() );
+                       switch(uim->yes_no_cancel((*iter)->get_canvas()->get_name(),str,synfigapp::UIInterface::RESPONSE_YES))
+                       {
+                               case synfigapp::UIInterface::RESPONSE_NO:
+                                       break;
+                               case synfigapp::UIInterface::RESPONSE_YES:
+                                       (*iter)->save();
+                                       break;
+                               case synfigapp::UIInterface::RESPONSE_CANCEL:
+                                       return;
+                               default:
+                                       assert(0);
+                                       return;
+                       }
+               }
+
+
+               if((*iter)->synfigapp::Instance::is_modified())
+               {
+                       handle<synfigapp::UIInterface> uim;
+                       uim=(*iter)->find_canvas_view((*iter)->get_canvas())->get_ui_interface();
+                       assert(uim);
+                       string str=strprintf(_("%s has changes not yet on the CVS repository.\nWould you like to commit these changes?"),(*iter)->get_file_name().c_str() );
+                       switch(uim->yes_no_cancel((*iter)->get_canvas()->get_name(),str,synfigapp::UIInterface::RESPONSE_YES))
+                       {
+                               case synfigapp::UIInterface::RESPONSE_NO:
+                                       break;
+                               case synfigapp::UIInterface::RESPONSE_YES:
+                                       (*iter)->dialog_cvs_commit();
+                                       break;
+                               case synfigapp::UIInterface::RESPONSE_CANCEL:
+                                       return;
+                               default:
+                                       assert(0);
+                                       return;
+                       }
+               }
+*/
+
+               // This next line causes things to crash for some reason
+               //(*iter)->close();
+       }
+
+       shutdown_in_progress=true;
+
+       instance_list.clear();
+
+       while(studio::App::events_pending())studio::App::iteration(false);
+
+       Gtk::Main::quit();
+       auto_recover->normal_shutdown();
+
+       get_ui_interface()->task(_("Quit Request sent"));
+}
+
+void
+App::show_setup()
+{
+       dialog_setup->refresh();
+       dialog_setup->show();
+}
+
+gint Signal_Open_Ok(GtkWidget */*widget*/, int *val){*val=1;return 0;}
+gint Signal_Open_Cancel(GtkWidget */*widget*/, int *val){*val=2;return 0;}
+
+//#ifdef WIN32
+//#define USE_WIN32_FILE_DIALOGS 1
+//#endif
+
+#ifdef USE_WIN32_FILE_DIALOGS
+static OPENFILENAME ofn={};
+#endif
+
+#ifdef WIN32
+#include <gdk/gdkwin32.h>
+#endif
+
+bool
+App::dialog_open_file(const std::string &title, std::string &filename, std::string preference)
+{
+       // info("App::dialog_open_file('%s', '%s', '%s')", title.c_str(), filename.c_str(), preference.c_str());
+
+#ifdef USE_WIN32_FILE_DIALOGS
+       static TCHAR szFilter[] = TEXT ("All Files (*.*)\0*.*\0\0") ;
+
+       GdkWindow *gdkWinPtr=toolbox->get_window()->gobj();
+       HINSTANCE hInstance=static_cast<HINSTANCE>(GetModuleHandle(NULL));
+       HWND hWnd=static_cast<HWND>(GDK_WINDOW_HWND(gdkWinPtr));
+
+       ofn.lStructSize=sizeof(OPENFILENAME);
+       ofn.hwndOwner = hWnd;
+       ofn.hInstance = hInstance;
+       ofn.lpstrFilter = szFilter;
+//     ofn.lpstrCustomFilter=NULL;
+//     ofn.nMaxCustFilter=0;
+//     ofn.nFilterIndex=0;
+//     ofn.lpstrFile=NULL;
+       ofn.nMaxFile=MAX_PATH;
+//     ofn.lpstrFileTitle=NULL;
+//     ofn.lpstrInitialDir=NULL;
+//     ofn.lpstrTitle=NULL;
+       ofn.Flags=OFN_HIDEREADONLY;
+//     ofn.nFileOffset=0;
+//     ofn.nFileExtension=0;
+       ofn.lpstrDefExt=TEXT("sif");
+//     ofn.lCustData = 0l;
+       ofn.lpfnHook=NULL;
+//     ofn.lpTemplateName=NULL;
+
+       CHAR szFilename[MAX_PATH];
+       CHAR szTitle[500];
+       strcpy(szFilename,filename.c_str());
+       strcpy(szTitle,title.c_str());
+
+       ofn.lpstrFile=szFilename;
+       ofn.lpstrFileTitle=szTitle;
+
+       if(GetOpenFileName(&ofn))
+       {
+               filename=szFilename;
+               return true;
+       }
+       return false;
+
+#else   // not USE_WIN32_FILE_DIALOGS
+       synfig::String prev_path;
+
+       if(!_preferences.get_value(preference, prev_path))
+               prev_path = ".";
+
+       prev_path = absolute_path(prev_path);
+
+    Gtk::FileChooserDialog *dialog = new Gtk::FileChooserDialog(title, Gtk::FILE_CHOOSER_ACTION_OPEN);
+
+    dialog->set_current_folder(prev_path);
+    dialog->add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
+    dialog->add_button(Gtk::Stock::OPEN,   Gtk::RESPONSE_ACCEPT);
+
+    if (filename.empty())
+               dialog->set_filename(prev_path);
+       else if (is_absolute_path(filename))
+               dialog->set_filename(filename);
+       else
+               dialog->set_filename(prev_path + ETL_DIRECTORY_SEPARATOR + filename);
+
+    if(dialog->run() == GTK_RESPONSE_ACCEPT) {
+        filename = dialog->get_filename();
+               // info("Saving preference %s = '%s' in App::dialog_open_file()", preference.c_str(), dirname(filename).c_str());
+               _preferences.set_value(preference, dirname(filename));
+        delete dialog;
+        return true;
+    }
+
+    delete dialog;
+    return false;
+#endif   // not USE_WIN32_FILE_DIALOGS
+}
+
+bool
+App::dialog_save_file(const std::string &title, std::string &filename, std::string preference)
+{
+       // info("App::dialog_save_file('%s', '%s', '%s')", title.c_str(), filename.c_str(), preference.c_str());
+
+#if USE_WIN32_FILE_DIALOGS
+       static TCHAR szFilter[] = TEXT ("All Files (*.*)\0*.*\0\0") ;
+
+       GdkWindow *gdkWinPtr=toolbox->get_window()->gobj();
+       HINSTANCE hInstance=static_cast<HINSTANCE>(GetModuleHandle(NULL));
+       HWND hWnd=static_cast<HWND>(GDK_WINDOW_HWND(gdkWinPtr));
+
+       ofn.lStructSize=sizeof(OPENFILENAME);
+       ofn.hwndOwner = hWnd;
+       ofn.hInstance = hInstance;
+       ofn.lpstrFilter = szFilter;
+//     ofn.lpstrCustomFilter=NULL;
+//     ofn.nMaxCustFilter=0;
+//     ofn.nFilterIndex=0;
+//     ofn.lpstrFile=NULL;
+       ofn.nMaxFile=MAX_PATH;
+//     ofn.lpstrFileTitle=NULL;
+//     ofn.lpstrInitialDir=NULL;
+//     ofn.lpstrTitle=NULL;
+       ofn.Flags=OFN_OVERWRITEPROMPT;
+//     ofn.nFileOffset=0;
+//     ofn.nFileExtension=0;
+       ofn.lpstrDefExt=TEXT("sif");
+//     ofn.lCustData = 0l;
+       ofn.lpfnHook=NULL;
+//     ofn.lpTemplateName=NULL;
+
+       CHAR szFilename[MAX_PATH];
+       CHAR szTitle[500];
+       strcpy(szFilename,filename.c_str());
+       strcpy(szTitle,title.c_str());
+
+       ofn.lpstrFile=szFilename;
+       ofn.lpstrFileTitle=szTitle;
+
+       if(GetSaveFileName(&ofn))
+       {
+               filename=szFilename;
+               _preferences.set_value(preference,dirname(filename));
+               return true;
+       }
+       return false;
+#else
+       synfig::String prev_path;
+
+       if(!_preferences.get_value(preference, prev_path))
+               prev_path=".";
+
+       prev_path = absolute_path(prev_path);
+
+    Gtk::FileChooserDialog *dialog = new Gtk::FileChooserDialog(title, Gtk::FILE_CHOOSER_ACTION_SAVE);
+
+    dialog->set_current_folder(prev_path);
+    dialog->add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
+    dialog->add_button(Gtk::Stock::SAVE,   Gtk::RESPONSE_ACCEPT);
+
+       Widget_Enum *file_type_enum = 0;
+       if (preference == ANIMATION_DIR_PREFERENCE)
+       {
+               file_type_enum = manage(new Widget_Enum());
+               file_type_enum->set_param_desc(ParamDesc().set_hint("enum")
+                                                                          .add_enum_value(synfig::RELEASE_VERSION_0_62_00, "0.62.00", strprintf("0.62.00 (%s)", _("current")))
+                                                                          .add_enum_value(synfig::RELEASE_VERSION_0_61_09, "0.61.09", "0.61.09")
+                                                                          .add_enum_value(synfig::RELEASE_VERSION_0_61_08, "0.61.08", "0.61.08")
+                                                                          .add_enum_value(synfig::RELEASE_VERSION_0_61_07, "0.61.07", "0.61.07")
+                                                                          .add_enum_value(synfig::RELEASE_VERSION_0_61_06, "0.61.06", strprintf("0.61.06 %s", _("and older"))));
+               file_type_enum->set_value(RELEASE_VERSION_END-1); // default to the most recent version
+
+               Gtk::HBox *hbox = manage(new Gtk::HBox);
+               hbox->pack_start(*manage(new Gtk::Label(_("File Format Version: "))),Gtk::PACK_SHRINK,0);
+               hbox->pack_start(*file_type_enum,Gtk::PACK_EXPAND_WIDGET,0);
+               hbox->show_all();
+
+               dialog->set_extra_widget(*hbox);
+       }
+
+    if (filename.empty())
+               dialog->set_filename(prev_path);
+    else
+       {
+               std::string full_path;
+               if (is_absolute_path(filename))
+                       full_path = filename;
+               else
+                       full_path = prev_path + ETL_DIRECTORY_SEPARATOR + filename;
+
+               // select the file if it exists
+               dialog->set_filename(full_path);
+
+               // if the file doesn't exist, put its name into the filename box
+               struct stat s;
+               if(stat(full_path.c_str(),&s) == -1 && errno == ENOENT)
+                       dialog->set_current_name(basename(filename));
+       }
+
+    if(dialog->run() == GTK_RESPONSE_ACCEPT) {
+               if (preference == ANIMATION_DIR_PREFERENCE)
+                       set_file_version(synfig::ReleaseVersion(file_type_enum->get_value()));
+        filename = dialog->get_filename();
+               // info("Saving preference %s = '%s' in App::dialog_save_file()", preference.c_str(), dirname(filename).c_str());
+               _preferences.set_value(preference, dirname(filename));
+        delete dialog;
+        return true;
+    }
+
+    delete dialog;
+    return false;
+#endif
+}
+
+void
+App::dialog_error_blocking(const std::string &title, const std::string &message)
+{
+       Gtk::MessageDialog dialog(message, false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE, true);
+       dialog.set_title(title);
+       dialog.show();
+       dialog.run();
+}
+
+void
+App::dialog_warning_blocking(const std::string &title, const std::string &message)
+{
+       Gtk::MessageDialog dialog(message, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_CLOSE, true);
+       dialog.set_title(title);
+       dialog.show();
+       dialog.run();
+}
+
+bool
+App::dialog_yes_no(const std::string &title, const std::string &message)
+{
+       Gtk::Dialog dialog(
+               title,          // Title
+               true,           // Modal
+               true            // use_separator
+       );
+       Gtk::Label label(message);
+       label.show();
+
+       dialog.get_vbox()->pack_start(label);
+       dialog.add_button(Gtk::StockID("gtk-yes"),1);
+       dialog.add_button(Gtk::StockID("gtk-no"),0);
+       dialog.show();
+       return dialog.run();
+}
+
+int
+App::dialog_yes_no_cancel(const std::string &title, const std::string &message)
+{
+       Gtk::Dialog dialog(
+               title,          // Title
+               true,           // Modal
+               true            // use_separator
+       );
+       Gtk::Label label(message);
+       label.show();
+
+       dialog.get_vbox()->pack_start(label);
+       dialog.add_button(Gtk::StockID("gtk-yes"),1);
+       dialog.add_button(Gtk::StockID("gtk-no"),0);
+       dialog.add_button(Gtk::StockID("gtk-cancel"),2);
+       dialog.show();
+       return dialog.run();
+}
+
+void
+App::dialog_not_implemented()
+{
+       Gtk::MessageDialog dialog(_("Feature not available"), false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE, true);
+       dialog.set_secondary_text(_("Sorry, this feature has not yet been implemented."));
+       dialog.run();
+}
+
+static bool
+try_open_url(const std::string &url)
+{
+#ifdef WIN32
+       return ShellExecute(GetDesktopWindow(), "open", url.c_str(), NULL, NULL, SW_SHOW);
+#else // !WIN32
+       std::vector<std::string> command_line;
+       std::vector<std::string> browsers;
+       browsers.reserve(23);
+
+       // Browser wrapper scripts
+#ifdef USE_OPEN_FOR_URLS
+       browsers.push_back("open");              // Apple MacOS X wrapper, on Linux it opens a virtual console
+#endif
+       browsers.push_back("xdg-open");          // XDG wrapper
+       browsers.push_back("sensible-browser");  // Debian wrapper
+       browsers.push_back("gnome-open");        // GNOME wrapper
+       browsers.push_back("kfmclient");         // KDE wrapper
+       browsers.push_back("exo-open");          // XFCE wrapper
+
+       // Alternatives system
+       browsers.push_back("gnome-www-browser"); // Debian GNOME alternative
+       browsers.push_back("x-www-browser");     // Debian GUI alternative
+
+       // Individual browsers
+       browsers.push_back("firefox");
+       browsers.push_back("epiphany-browser");
+       browsers.push_back("epiphany");
+       browsers.push_back("konqueror");
+       browsers.push_back("iceweasel");
+       browsers.push_back("mozilla");
+       browsers.push_back("netscape");
+       browsers.push_back("icecat");
+       browsers.push_back("galeon");
+       browsers.push_back("midori");
+       browsers.push_back("safari");
+       browsers.push_back("opera");
+       browsers.push_back("amaya");
+       browsers.push_back("netsurf");
+       browsers.push_back("dillo");
+
+       // Try the user-specified browser first
+       command_line.push_back(App::browser_command);
+       if( command_line[0] == "kfmclient" ) command_line.push_back("openURL");
+       command_line.push_back(url);
+
+       try { Glib::spawn_async(".", command_line, Glib::SPAWN_SEARCH_PATH); return true; }
+       catch( Glib::SpawnError& exception ){
+
+               while ( !browsers.empty() )
+               {
+                       // Skip the browser if we already tried it
+                       if( browsers[0] == App::browser_command )
+                               continue;
+
+                       // Construct the command line
+                       command_line.clear();
+                       command_line.push_back(browsers[0]);
+                       if( command_line[0] == "kfmclient" ) command_line.push_back("openURL");
+                       command_line.push_back(url);
+
+                       // Remove the browser from the list
+                       browsers.erase(browsers.begin());
+
+                       // Try to spawn the browser
+                       try { Glib::spawn_async(".", command_line, Glib::SPAWN_SEARCH_PATH); }
+                       // Failed, move on to the next one
+                       catch(Glib::SpawnError& exception){ continue; }
+                       return true; // No exception means we succeeded!
+               }
+       }
+
+       return false;
+#endif // !WIN32
+}
+
+void
+App::dialog_help()
+{
+       if (!try_open_url("http://synfig.org/Documentation"))
+       {
+               Gtk::MessageDialog dialog(_("Documentation"), false, Gtk::MESSAGE_INFO, Gtk::BUTTONS_CLOSE, true);
+               dialog.set_secondary_text(_("Documentation for Synfig Studio is available on the website:\n\nhttp://www.synfig.org/Documentation"));
+               dialog.set_title(_("Help"));
+               dialog.run();
+       }
+}
+
+void
+App::open_url(const std::string &url)
+{
+       if(!try_open_url(url))
+       {
+               Gtk::MessageDialog dialog(_("No browser was found. Please load this website manually:"), false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE, true);
+               dialog.set_secondary_text(url);
+               dialog.set_title(_("No browser found"));
+               dialog.run();
+       }
+}
+
+bool
+App::dialog_entry(const std::string &title, const std::string &message,std::string &text)
+{
+       Gtk::Dialog dialog(
+               title,          // Title
+               true,           // Modal
+               true);          // use_separator
+
+       Gtk::Label label(message);
+       label.show();
+       dialog.get_vbox()->pack_start(label);
+
+       Gtk::Entry entry;
+       entry.set_text(text);
+       entry.show();
+       entry.set_activates_default(true);
+
+       dialog.get_vbox()->pack_start(entry);
+
+       dialog.add_button(Gtk::StockID("gtk-ok"),Gtk::RESPONSE_OK);
+       dialog.add_button(Gtk::StockID("gtk-cancel"),Gtk::RESPONSE_CANCEL);
+       dialog.set_default_response(Gtk::RESPONSE_OK);
+
+       entry.signal_activate().connect(sigc::bind(sigc::mem_fun(dialog,&Gtk::Dialog::response),Gtk::RESPONSE_OK));
+       dialog.show();
+
+       if(dialog.run()!=Gtk::RESPONSE_OK)
+               return false;
+
+       text=entry.get_text();
+
+       return true;
+}
+
+bool
+App::dialog_paragraph(const std::string &title, const std::string &message,std::string &text)
+{
+       Gtk::Dialog dialog(
+               title,          // Title
+               true,           // Modal
+               true);          // use_separator
+
+       Gtk::Label label(message);
+       label.show();
+       dialog.get_vbox()->pack_start(label);
+
+       Glib::RefPtr<Gtk::TextBuffer> text_buffer(Gtk::TextBuffer::create());
+       text_buffer->set_text(text);
+       Gtk::TextView text_view(text_buffer);
+       text_view.show();
+
+       dialog.get_vbox()->pack_start(text_view);
+
+       dialog.add_button(Gtk::StockID("gtk-ok"),Gtk::RESPONSE_OK);
+       dialog.add_button(Gtk::StockID("gtk-cancel"),Gtk::RESPONSE_CANCEL);
+       dialog.set_default_response(Gtk::RESPONSE_OK);
+
+       //text_entry.signal_activate().connect(sigc::bind(sigc::mem_fun(dialog,&Gtk::Dialog::response),Gtk::RESPONSE_OK));
+       dialog.show();
+
+       if(dialog.run()!=Gtk::RESPONSE_OK)
+               return false;
+
+       text=text_buffer->get_text();
+
+       return true;
+}
+
+bool
+App::open(std::string filename)
+{
+       return open_as(filename,filename);
+}
+
+// this is called from autorecover.cpp:
+//   App::open_as(get_shadow_file_name(filename),filename)
+// other than that, 'filename' and 'as' are the same
+bool
+App::open_as(std::string filename,std::string as)
+{
+#ifdef WIN32
+    char long_name[1024];
+    if(GetLongPathName(as.c_str(),long_name,sizeof(long_name)));
+       // when called from autorecover.cpp, filename doesn't exist, and so long_name is empty
+       // don't use it if that's the case
+       if (long_name[0] != '\0')
+               as=long_name;
+#endif
+
+       try
+       {
+               OneMoment one_moment;
+               String errors, warnings;
+
+               etl::handle<synfig::Canvas> canvas(open_canvas_as(filename,as,errors,warnings));
+               if(canvas && get_instance(canvas))
+               {
+                       get_instance(canvas)->find_canvas_view(canvas)->present();
+                       info("%s is already open", filename.c_str());
+                       // throw (String)strprintf(_("\"%s\" appears to already be open!"),filename.c_str());
+               }
+               else
+               {
+                       if(!canvas)
+                               throw (String)strprintf(_("Unable to load \"%s\":\n\n"),filename.c_str()) + errors;
+
+                       if (warnings != "")
+                               dialog_warning_blocking(_("Warnings"), strprintf("%s:\n\n%s", _("Warnings"), warnings.c_str()));
+
+                       if (as.find(custom_filename_prefix.c_str()) != 0)
+                               add_recent_file(as);
+
+                       handle<Instance> instance(Instance::create(canvas));
+
+                       if(!instance)
+                               throw (String)strprintf(_("Unable to create instance for \"%s\""),filename.c_str());
+
+                       set_recent_file_window_size(instance);
+
+                       one_moment.hide();
+
+                       if(instance->is_updated() && App::dialog_yes_no(_("CVS Update"), _("There appears to be a newer version of this file available on the CVS repository.\nWould you like to update now? (It would probably be a good idea)")))
+                               instance->dialog_cvs_update();
+               }
+       }
+       catch(String x)
+       {
+               dialog_error_blocking(_("Error"), x);
+               return false;
+       }
+       catch(runtime_error x)
+       {
+               dialog_error_blocking(_("Error"), x.what());
+               return false;
+       }
+       catch(...)
+       {
+               dialog_error_blocking(_("Error"), _("Uncaught error on file open (BUG)"));
+               return false;
+       }
+
+       return true;
+}
+
+
+void
+App::new_instance()
+{
+       handle<synfig::Canvas> canvas=synfig::Canvas::create();
+
+       String file_name(strprintf("%s%d", App::custom_filename_prefix.c_str(), Instance::get_count()+1));
+       canvas->set_name(file_name);
+       file_name += ".sifz";
+
+       canvas->rend_desc().set_frame_rate(preferred_fps);
+       canvas->rend_desc().set_time_start(0.0);
+       canvas->rend_desc().set_time_end(5.0);
+       canvas->rend_desc().set_x_res(DPI2DPM(72.0f));
+       canvas->rend_desc().set_y_res(DPI2DPM(72.0f));
+       // The top left and botton right positions are expressed in units
+       // Original convention is that 1 unit = 60 pixels
+       canvas->rend_desc().set_tl(Vector(-(preferred_x_size/60.0)/2.0,(preferred_y_size/60.0)/2.0));
+       canvas->rend_desc().set_br(Vector((preferred_x_size/60.0)/2.0,-(preferred_y_size/60.0)/2.0));
+       canvas->rend_desc().set_w(preferred_x_size);
+       canvas->rend_desc().set_h(preferred_y_size);
+       canvas->rend_desc().set_antialias(1);
+       canvas->rend_desc().set_flags(RendDesc::PX_ASPECT|RendDesc::IM_SPAN);
+       canvas->set_file_name(file_name);
+
+       handle<Instance> instance = Instance::create(canvas);
+
+       if (getenv("SYNFIG_ENABLE_NEW_CANVAS_EDIT_PROPERTIES"))
+               instance->find_canvas_view(canvas)->canvas_properties.present();
+}
+
+void
+App::dialog_open(string filename)
+{
+       if (filename.empty())
+               filename="*.sif";
+
+       while(dialog_open_file("Open", filename, ANIMATION_DIR_PREFERENCE))
+       {
+               // If the filename still has wildcards, then we should
+               // continue looking for the file we want
+               if(find(filename.begin(),filename.end(),'*')!=filename.end())
+                       continue;
+
+               if(open(filename))
+                       break;
+
+               get_ui_interface()->error(_("Unable to open file"));
+       }
+}
+
+void
+App::set_selected_instance(etl::loose_handle<Instance> instance)
+{
+/*     if(get_selected_instance()==instance)
+       {
+               selected_instance=instance;
+               signal_instance_selected()(instance);
+               return;
+       }
+       else
+       {
+*/
+               selected_instance=instance;
+               if(get_selected_canvas_view() && get_selected_canvas_view()->get_instance()!=instance)
+               {
+                       if(instance)
+                       {
+                               instance->focus(instance->get_canvas());
+                       }
+                       else
+                               set_selected_canvas_view(0);
+               }
+               signal_instance_selected()(instance);
+}
+
+void
+App::set_selected_canvas_view(etl::loose_handle<CanvasView> canvas_view)
+{
+       selected_canvas_view=canvas_view;
+       signal_canvas_view_focus()(selected_canvas_view);
+       if(canvas_view)
+       {
+               selected_instance=canvas_view->get_instance();
+               signal_instance_selected()(canvas_view->get_instance());
+       }
+/*
+       if(get_selected_canvas_view()==canvas_view)
+       {
+               signal_canvas_view_focus()(selected_canvas_view);
+               signal_instance_selected()(canvas_view->get_instance());
+               return;
+       }
+       selected_canvas_view=canvas_view;
+       if(canvas_view && canvas_view->get_instance() != get_selected_instance())
+               set_selected_instance(canvas_view->get_instance());
+       signal_canvas_view_focus()(selected_canvas_view);
+*/
+}
+
+etl::loose_handle<Instance>
+App::get_instance(etl::handle<synfig::Canvas> canvas)
+{
+       if(!canvas) return 0;
+       canvas=canvas->get_root();
+
+       std::list<etl::handle<Instance> >::iterator iter;
+       for(iter=instance_list.begin();iter!=instance_list.end();++iter)
+       {
+               if((*iter)->get_canvas()==canvas)
+                       return *iter;
+       }
+       return 0;
+}
+
+void
+App::dialog_about()
+{
+       if(about)
+               about->show();
+}
+
+void
+studio::App::undo()
+{
+       if(selected_instance)
+               selected_instance->undo();
+}
+
+void
+studio::App::redo()
+{
+       if(selected_instance)
+               selected_instance->redo();
+}
+
+synfig::String
+studio::App::get_base_path()
+{
+       return app_base_path_;
+}
diff --git a/synfig-studio/src/gui/app.h b/synfig-studio/src/gui/app.h
new file mode 100644 (file)
index 0000000..f9960d3
--- /dev/null
@@ -0,0 +1,363 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file app.h
+**     \brief writeme
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 2008 Chris Moore
+**  Copyright (c) 2008 Carlos López
+**
+**     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_APP_H
+#define __SYNFIG_STUDIO_APP_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <sigc++/bind.h>
+
+#include <gtkmm/main.h>
+#include <string>
+#include <list>
+
+#include <ETL/smart_ptr>
+
+#include <synfig/distance.h>
+#include <synfig/string.h>
+#include <synfig/time.h>
+
+#include <gtkmm/uimanager.h>
+
+#include <synfigapp/instance.h>
+#include "iconcontroller.h"
+
+/* === M A C R O S ========================================================= */
+
+#define MISC_DIR_PREFERENCE                    "misc_dir"
+#define ANIMATION_DIR_PREFERENCE       "animation_dir"
+#define IMAGE_DIR_PREFERENCE           "image_dir"
+#define SKETCH_DIR_PREFERENCE          "sketch_dir"
+#define RENDER_DIR_PREFERENCE          "render_dir"
+
+/* === T Y P E D E F S ===================================================== */
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+namespace Gtk
+{
+       class InputDialog;
+       class UIManager;
+       class ActionGroup;
+};
+
+namespace synfigapp
+{
+       class UIInterface;
+       class Main;
+};
+
+class Preferences;
+
+namespace studio {
+
+typedef Gtk::UIManager UIManager;
+
+class About;
+class Toolbox;
+class Instance;
+class CanvasView;
+class Dialog_Setup;
+class Dialog_Gradient;
+class Dialog_Color;
+class Dialog_ToolOptions;
+class DeviceTracker;
+class AutoRecover;
+
+class DockManager;
+
+class Dock_History;
+class Dock_Canvases;
+
+class Dock_Keyframes;
+class Dock_Params;
+class Dock_Layers;
+class Dock_MetaData;
+class Dock_Children;
+class Dock_Info;
+class Dock_Navigator;
+class Dock_LayerGroups;
+class IPC;
+
+class Module;
+
+class StateManager;
+class IconController;
+
+class App : public Gtk::Main, private IconController
+{
+       friend class Preferences;
+       friend class Dialog_Setup;
+
+       /*
+ -- ** -- P U B L I C   T Y P E S ---------------------------------------------
+       */
+
+public:
+
+       struct Busy
+       {
+               static int count;
+               Busy(){count++;}
+               ~Busy(){count--;}
+       };
+
+
+       /*
+ -- ** -- P R I V A T E   D A T A ---------------------------------------------
+       */
+
+private:
+       //static etl::handle<synfigapp::UIInterface> ui_interface_;
+       //static int max_recent_files;
+
+/*      //declated as globals in app.cpp
+       static Dock_Keyframes *dock_keyframes;
+       static Dock_Layers *dock_layers;
+       static Dock_Params *dock_params;
+       static Dock_MetaData *dock_meta_data;
+       static Dock_Children *dock_children;
+       static Dock_Info *dock_info;
+       static Dock_Navigator *dock_navigator;
+       static Dock_History *dock_history;
+       static Dock_Canvases *dock_canvases;
+       static Dock_LayerGroups *dock_layer_groups;
+
+       static IPC *ipc;
+*/
+
+       etl::smart_ptr<synfigapp::Main> synfigapp_main;
+
+
+       static etl::handle<Instance> selected_instance;
+       static etl::handle<CanvasView> selected_canvas_view;
+
+       static Glib::RefPtr<UIManager>  ui_manager_;
+
+//     static std::list< etl::handle< Module > > module_list_;
+
+       /*
+ -- ** -- P U B L I C   D A T A -----------------------------------------------
+       */
+
+public:
+       static Gtk::InputDialog* dialog_input;
+
+       static DeviceTracker*   device_tracker;
+       static AutoRecover*     auto_recover;
+       static DockManager* dock_manager;
+
+       static DockManager* get_dock_manager() { return dock_manager; }
+
+       static Dialog_Setup* dialog_setup;
+       static Dialog_Gradient* dialog_gradient;
+       static Dialog_Color* dialog_color;
+//     static Dialog_Palette* dialog_palette;
+       static Dialog_ToolOptions *dialog_tool_options;
+
+       static synfig::Distance::System distance_system;
+
+       static synfig::Gamma gamma;
+
+       static About *about;
+       static Toolbox *toolbox;
+
+       static std::list<etl::handle<Instance> > instance_list;
+
+       static bool shutdown_in_progress;
+
+       static bool use_colorspace_gamma;
+
+#ifdef SINGLE_THREADED
+       static bool single_threaded;
+#endif
+
+       static bool restrict_radius_ducks;
+       static bool resize_imported_images;
+
+       static synfig::String browser_command;
+       static synfig::String custom_filename_prefix;
+       static int preferred_x_size;
+       static int preferred_y_size;
+       static synfig::String predefined_size;
+       static synfig::String predefined_fps;
+       static float preferred_fps;
+       /*
+ -- ** -- S I G N A L S -------------------------------------------------------
+       */
+/*      //declated as globals in app.cpp
+       static sigc::signal<
+               void,
+               etl::loose_handle<CanvasView>
+       > signal_canvas_view_focus_;
+       static sigc::signal<
+               void,
+               etl::handle<Instance>
+       > signal_instance_selected_;
+       static sigc::signal<
+               void,
+               etl::handle<Instance>
+       > signal_instance_created_;
+       static sigc::signal<
+               void,
+               etl::handle<Instance>
+       > signal_instance_deleted_;
+       static sigc::signal<void> signal_recent_files_changed_;
+       static sigc::signal<void> signal_present_all_;
+*/
+public:
+
+       static sigc::signal<void> &signal_present_all();
+
+       static sigc::signal<void> &signal_recent_files_changed();
+
+       static sigc::signal<
+               void,
+               etl::loose_handle<CanvasView>
+       >& signal_canvas_view_focus();
+
+       static sigc::signal<
+               void,
+               etl::handle<Instance>
+       > &signal_instance_selected();
+
+       static sigc::signal<
+               void,
+               etl::handle<Instance>
+       > &signal_instance_created();
+
+       static sigc::signal<
+               void,
+               etl::handle<Instance>
+       > &signal_instance_deleted();
+
+       /*
+ -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
+       */
+
+private:
+       static void add_recent_file(const std::string &filename, const std::string &window_size = std::string());
+
+       /*
+ -- ** -- P U B L I C   M E T H O D S -----------------------------------------
+       */
+
+public:
+
+       App(int *argc, char ***argv);
+       virtual ~App();
+
+       /*
+ -- ** -- S T A T I C   P U B L I C   M E T H O D S ---------------------------
+       */
+
+public:
+
+       static StateManager* get_state_manager();
+
+       static Glib::RefPtr<UIManager>& ui_manager() { return ui_manager_; }
+
+       static void set_recent_file_window_size(etl::handle<Instance> instance);
+       static void add_recent_file(const etl::handle<Instance> instance);
+
+       static synfig::String get_base_path();
+       static void save_settings();
+       static void load_settings();
+       static void reset_initial_window_configuration();
+
+       static const std::list<std::string>& get_recent_files();
+
+       static const etl::handle<synfigapp::UIInterface>& get_ui_interface();
+
+
+       static void set_selected_instance(etl::loose_handle<Instance> instance);
+       static void set_selected_canvas_view(etl::loose_handle<CanvasView>);
+
+       static etl::loose_handle<Instance> get_instance(etl::handle<synfig::Canvas> canvas);
+
+       static etl::loose_handle<Instance> get_selected_instance() { return selected_instance; }
+       static etl::loose_handle<CanvasView> get_selected_canvas_view() { return selected_canvas_view; }
+
+       static bool open(std::string filename);
+
+       static bool open_as(std::string filename,std::string as);
+
+       static void new_instance();
+
+       static void dialog_open(std::string filename = "");
+
+       static void dialog_about();
+
+       static void quit();
+
+       static void show_setup();
+
+       static void undo();
+       static void redo();
+
+       static int get_max_recent_files();
+       static void set_max_recent_files(int x);
+
+
+       static synfig::Time::Format get_time_format();
+       static void set_time_format(synfig::Time::Format x);
+
+       static bool shutdown_request(GdkEventAny*bleh=NULL);
+
+//     static bool dialog_file(const std::string &title, std::string &filename);
+
+       static bool dialog_open_file(const std::string &title, std::string &filename, std::string preference);
+       static bool dialog_save_file(const std::string &title, std::string &filename, std::string preference);
+
+       static void dialog_error_blocking(const std::string &title, const std::string &message);
+
+       static void dialog_warning_blocking(const std::string &title, const std::string &message);
+
+       static bool dialog_entry(const std::string &title, const std::string &message,std::string &text);
+       static bool dialog_paragraph(const std::string &title, const std::string &message,std::string &text);
+
+       static bool dialog_yes_no(const std::string &title, const std::string &message);
+
+       static int dialog_yes_no_cancel(const std::string &title, const std::string &message);
+
+       static void dialog_not_implemented();
+
+       static void dialog_help();
+
+       static void open_url(const std::string &url);
+
+       static synfig::String get_user_app_directory();
+       static synfig::String get_config_file(const synfig::String& file);
+}; // END of class App
+
+       void delete_widget(Gtk::Widget *widget);
+
+}; // END namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/asyncrenderer.cpp b/synfig-studio/src/gui/asyncrenderer.cpp
new file mode 100644 (file)
index 0000000..72a286c
--- /dev/null
@@ -0,0 +1,541 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file asyncrenderer.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \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
+**     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 <config.h>
+#endif
+
+#include "asyncrenderer.h"
+#include "app.h"
+#include <glibmm/thread.h>
+#include <glibmm/dispatcher.h>
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
+
+#ifdef HAVE_SIGNAL_H
+#include <signal.h>
+#endif
+
+#include <synfig/general.h>
+#include <ETL/clock>
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+using namespace studio;
+
+#define BOREDOM_TIMEOUT                50
+
+#define REJOIN_ON_STOP 1
+
+// The Glib::Dispatcher class is broken as of Glibmm 2.4.5.
+// Defining this macro enables the workaround.
+#define GLIB_DISPATCHER_BROKEN 1
+
+/* === C L A S S E S ======================================================= */
+
+class AsyncTarget_Tile : public synfig::Target_Tile
+{
+public:
+       etl::handle<synfig::Target_Tile> warm_target;
+
+       struct tile_t
+       {
+               Surface surface;
+               int x,y;
+               tile_t(const Surface& surface,int x, int y):
+                       surface(surface),
+                       x(x),y(y)
+               {
+               }
+       };
+       std::list<tile_t> tile_queue;
+       Glib::Mutex mutex;
+
+#ifndef GLIB_DISPATCHER_BROKEN
+       Glib::Dispatcher tile_ready_signal;
+#endif
+       Glib::Cond cond_tile_queue_empty;
+       bool alive_flag;
+
+       sigc::connection ready_connection;
+
+public:
+       AsyncTarget_Tile(etl::handle<synfig::Target_Tile> warm_target):
+               warm_target(warm_target)
+       {
+               set_avoid_time_sync(warm_target->get_avoid_time_sync());
+               set_tile_w(warm_target->get_tile_w());
+               set_tile_h(warm_target->get_tile_h());
+               set_canvas(warm_target->get_canvas());
+               set_quality(warm_target->get_quality());
+               set_remove_alpha(warm_target->get_remove_alpha());
+               set_threads(warm_target->get_threads());
+               set_clipping(warm_target->get_clipping());
+               set_rend_desc(&warm_target->rend_desc());
+               alive_flag=true;
+#ifndef GLIB_DISPATCHER_BROKEN
+               ready_connection=tile_ready_signal.connect(sigc::mem_fun(*this,&AsyncTarget_Tile::tile_ready));
+#endif
+       }
+
+       ~AsyncTarget_Tile()
+       {
+               ready_connection.disconnect();
+       }
+       void set_dead()
+       {
+               Glib::Mutex::Lock lock(mutex);
+               alive_flag=false;
+       }
+
+       virtual int total_tiles()const
+       {
+               return warm_target->total_tiles();
+       }
+
+       virtual int next_tile(int& x, int& y)
+       {
+               if(!alive_flag)
+                       return 0;
+
+               return warm_target->next_tile(x,y);
+       }
+
+       virtual int next_frame(Time& time)
+       {
+               if(!alive_flag)
+                       return 0;
+               return warm_target->next_frame(time);
+       }
+
+       virtual bool start_frame(synfig::ProgressCallback *cb=0)
+       {
+               if(!alive_flag)
+                       return false;
+               return warm_target->start_frame(cb);
+       }
+
+       virtual bool add_tile(const synfig::Surface &surface, int gx, int gy)
+       {
+               assert(surface);
+               if(!alive_flag)
+                       return false;
+               Glib::Mutex::Lock lock(mutex);
+               tile_queue.push_back(tile_t(surface,gx,gy));
+               if(tile_queue.size()==1)
+               {
+#ifdef GLIB_DISPATCHER_BROKEN
+               ready_connection=Glib::signal_timeout().connect(
+                       sigc::bind_return(
+                               sigc::mem_fun(*this,&AsyncTarget_Tile::tile_ready),
+                               false
+                       )
+                       ,0
+               );
+#else
+               tile_ready_signal();
+#endif
+               }
+
+               return alive_flag;
+       }
+
+       void tile_ready()
+       {
+               Glib::Mutex::Lock lock(mutex);
+               if(!alive_flag)
+               {
+                       tile_queue.clear();
+                       cond_tile_queue_empty.signal();
+                       return;
+               }
+               while(!tile_queue.empty() && alive_flag)
+               {
+                       tile_t& tile(tile_queue.front());
+
+                       if (getenv("SYNFIG_SHOW_TILE_OUTLINES"))
+                       {
+                               Color red(1,0,0);
+                               tile.surface.fill(red, 0, 0, 1, tile.surface.get_h());
+                               tile.surface.fill(red, 0, 0, tile.surface.get_w(), 1);
+                       }
+
+                       alive_flag=warm_target->add_tile(tile.surface,tile.x,tile.y);
+
+                       tile_queue.pop_front();
+               }
+               cond_tile_queue_empty.signal();
+       }
+
+       virtual void end_frame()
+       {
+#ifdef SINGLE_THREADED
+               if (!single_threaded())
+               {
+#endif
+                       while(alive_flag)
+                       {
+                               Glib::Mutex::Lock lock(mutex);
+                               if(!tile_queue.empty() && alive_flag)
+                               {
+                                       if(cond_tile_queue_empty.timed_wait(mutex,Glib::TimeVal(0,BOREDOM_TIMEOUT)))
+                                               break;
+                               }
+                               else
+                                       break;
+                       }
+#ifdef SINGLE_THREADED
+               }
+#endif
+               Glib::Mutex::Lock lock(mutex);
+               if(!alive_flag)
+                       return;
+               return warm_target->end_frame();
+       }
+};
+
+
+
+class AsyncTarget_Scanline : public synfig::Target_Scanline
+{
+public:
+       etl::handle<synfig::Target_Scanline> warm_target;
+
+       int scanline_;
+       Surface surface;
+
+       Glib::Mutex mutex;
+
+#ifndef GLIB_DISPATCHER_BROKEN
+       Glib::Dispatcher frame_ready_signal;
+#endif
+       Glib::Cond cond_frame_queue_empty;
+       bool alive_flag;
+       bool ready_next;
+       sigc::connection ready_connection;
+
+
+public:
+       AsyncTarget_Scanline(etl::handle<synfig::Target_Scanline> warm_target):
+               warm_target(warm_target)
+       {
+               set_avoid_time_sync(warm_target->get_avoid_time_sync());
+               set_canvas(warm_target->get_canvas());
+               set_quality(warm_target->get_quality());
+               set_remove_alpha(warm_target->get_remove_alpha());
+               set_threads(warm_target->get_threads());
+               set_rend_desc(&warm_target->rend_desc());
+               alive_flag=true;
+#ifndef GLIB_DISPATCHER_BROKEN
+               ready_connection=frame_ready_signal.connect(sigc::mem_fun(*this,&AsyncTarget_Scanline::frame_ready));
+#endif
+               surface.set_wh(warm_target->rend_desc().get_w(),warm_target->rend_desc().get_h());
+       }
+
+       ~AsyncTarget_Scanline()
+       {
+               ready_connection.disconnect();
+       }
+
+       virtual int next_frame(Time& time)
+       {
+               if(!alive_flag)
+                       return 0;
+               return warm_target->next_frame(time);
+
+       }
+
+       void set_dead()
+       {
+               Glib::Mutex::Lock lock(mutex);
+               alive_flag=false;
+       }
+
+       virtual bool start_frame(synfig::ProgressCallback */*cb*/=0)
+       {
+               return alive_flag;
+       }
+
+       virtual void end_frame()
+       {
+               {
+                       Glib::Mutex::Lock lock(mutex);
+
+                       if(!alive_flag)
+                               return;
+                       ready_next=false;
+
+#ifdef GLIB_DISPATCHER_BROKEN
+               ready_connection=Glib::signal_timeout().connect(
+                       sigc::bind_return(
+                               sigc::mem_fun(*this,&AsyncTarget_Scanline::frame_ready),
+                               false
+                       )
+                       ,0
+               );
+#else
+                       frame_ready_signal();
+#endif
+               }
+
+#ifdef SINGLE_THREADED
+               if (single_threaded())
+                       signal_progress()();
+               else
+#endif
+                       while(alive_flag && !ready_next)
+                       {
+                               Glib::Mutex::Lock lock(mutex);
+                               if(cond_frame_queue_empty.timed_wait(mutex,Glib::TimeVal(0,BOREDOM_TIMEOUT)))
+                                       break;
+                       }
+       }
+
+
+       virtual Color * start_scanline(int scanline)
+       {
+               Glib::Mutex::Lock lock(mutex);
+
+               return surface[scanline];
+       }
+
+       virtual bool end_scanline()
+       {
+               return alive_flag;
+       }
+
+       void frame_ready()
+       {
+               Glib::Mutex::Lock lock(mutex);
+               if(alive_flag)
+                       alive_flag=warm_target->add_frame(&surface);
+#ifdef SINGLE_THREADED
+               if (!single_threaded())
+#endif
+                       cond_frame_queue_empty.signal();
+               ready_next=true;
+       }
+};
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+AsyncRenderer::AsyncRenderer(etl::handle<synfig::Target> target_,synfig::ProgressCallback *cb):
+       error(false),
+       success(false),
+       cb(cb)
+#ifdef SINGLE_THREADED
+       , updating(false)
+#endif
+{
+       render_thread=0;
+       if(etl::handle<synfig::Target_Tile>::cast_dynamic(target_))
+       {
+               etl::handle<AsyncTarget_Tile> wrap_target(
+                       new AsyncTarget_Tile(etl::handle<synfig::Target_Tile>::cast_dynamic(target_))
+               );
+
+               signal_stop_.connect(sigc::mem_fun(*wrap_target,&AsyncTarget_Tile::set_dead));
+
+               target=wrap_target;
+       }
+       else if(etl::handle<synfig::Target_Scanline>::cast_dynamic(target_))
+       {
+               etl::handle<AsyncTarget_Scanline> wrap_target(
+                       new AsyncTarget_Scanline(
+                               etl::handle<synfig::Target_Scanline>::cast_dynamic(target_)
+                       )
+               );
+
+               signal_stop_.connect(sigc::mem_fun(*wrap_target,&AsyncTarget_Scanline::set_dead));
+
+               target=wrap_target;
+       }
+}
+
+AsyncRenderer::~AsyncRenderer()
+{
+       stop();
+}
+
+void
+AsyncRenderer::stop()
+{
+       if(target)
+       {
+               Glib::Mutex::Lock lock(mutex);
+               done_connection.disconnect();
+
+               if(render_thread)
+               {
+                       signal_stop_();
+
+#if REJOIN_ON_STOP
+#ifdef SINGLE_THREADED
+                       if (!single_threaded())
+#endif
+                               render_thread->join();
+#endif
+
+                       // Make sure all the dispatch crap is cleared out
+                       //Glib::MainContext::get_default()->iteration(false);
+
+                       if(success)
+                               signal_success_();
+
+                       signal_finished_();
+
+                       target=0;
+                       render_thread=0;
+               }
+       }
+}
+
+void
+AsyncRenderer::pause()
+{
+}
+
+void
+AsyncRenderer::resume()
+{
+}
+
+void
+AsyncRenderer::start()
+{
+       done_connection=Glib::signal_timeout().connect(
+               sigc::bind_return(
+                       mem_fun(*this,&AsyncRenderer::start_),
+                       false
+               )
+               ,50
+       );
+}
+
+#ifdef SINGLE_THREADED
+void
+AsyncRenderer::rendering_progress()
+{
+       updating = true;
+       while(studio::App::events_pending()) studio::App::iteration(false);
+       updating = false;
+}
+#endif
+
+void
+AsyncRenderer::start_()
+{
+       error=false;success=false;
+       if(target)
+       {
+#ifndef GLIB_DISPATCHER_BROKEN
+               done_connection=signal_done_.connect(mem_fun(*this,&AsyncRenderer::stop));
+#endif
+
+#ifdef SINGLE_THREADED
+               if (single_threaded())
+               {
+                       synfig::info("%s:%d rendering in the same thread", __FILE__, __LINE__);
+                       target->signal_progress().connect(sigc::mem_fun(this,&AsyncRenderer::rendering_progress));
+                       render_thread = (Glib::Thread*)1;
+                       render_target();
+               }
+               else
+#endif
+               {
+                       render_thread=Glib::Thread::create(
+                               sigc::mem_fun(*this,&AsyncRenderer::render_target),
+#if REJOIN_ON_STOP
+                               true
+#else
+                               false
+#endif
+                               );
+                       assert(render_thread);
+               }
+       }
+       else
+       {
+               stop();
+       }
+}
+
+void
+AsyncRenderer::render_target()
+{
+       etl::handle<Target> target(AsyncRenderer::target);
+
+       if(target && target->render())
+       {
+               success=true;
+       }
+       else
+       {
+               error=true;
+#ifndef REJOIN_ON_STOP
+               return;
+#endif
+       }
+
+       if(mutex.trylock())
+       {
+#ifdef GLIB_DISPATCHER_BROKEN
+               done_connection=Glib::signal_timeout().connect(
+                       sigc::bind_return(
+                               mem_fun(*this,&AsyncRenderer::stop),
+                               false
+                       )
+                       ,0
+               );
+#else
+               signal_done_.emit();
+#endif
+               mutex.unlock();
+       }
+}
diff --git a/synfig-studio/src/gui/asyncrenderer.h b/synfig-studio/src/gui/asyncrenderer.h
new file mode 100644 (file)
index 0000000..7d865fd
--- /dev/null
@@ -0,0 +1,123 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file asyncrenderer.h
+**     \brief Template Header
+**
+**     $Id$
+**
+**     \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
+**     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_ASYNCRENDERER_H
+#define __SYNFIG_ASYNCRENDERER_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <ETL/handle>
+#include <sigc++/signal.h>
+#include <sigc++/trackable.h>
+#include <sigc++/connection.h>
+
+#include <synfig/target_scanline.h>
+#include <synfig/target_tile.h>
+#include <synfig/surface.h>
+#include <glibmm/main.h>
+#include <ETL/ref_count>
+#include <glibmm/thread.h>
+#include <glibmm/dispatcher.h>
+
+/* === M A C R O S ========================================================= */
+
+// uncomment define SINGLE_THREADED to use a single thread, and hopefully get more stability (dooglus) - changed to be default if using windows (Nov 2009 pixelgeek)
+#ifdef WIN32
+#define SINGLE_THREADED
+#endif
+#ifdef SINGLE_THREADED
+#  define single_threaded()    App::single_threaded
+#endif
+
+/* === 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 AsyncRenderer : public etl::shared_object, public sigc::trackable
+{
+       sigc::signal<void> signal_finished_;
+       sigc::signal<void> signal_success_;
+
+       std::list<sigc::connection> activity_connection_list;
+
+       //etl::handle<synfig::Target_Scanline> target_scanline;
+       //etl::handle<synfig::Target_Tile> target_tile;
+       etl::handle<synfig::Target> target;
+
+       bool error;
+       bool success;
+
+       synfig::ProgressCallback *cb;
+
+       sigc::signal<void> signal_stop_;
+
+       Glib::Thread* render_thread;
+       Glib::Dispatcher signal_done_;
+       Glib::Mutex mutex;
+       sigc::connection done_connection;
+
+       /*
+ --    ** -- P A R E N T   M E M B E R S -----------------------------------------
+       */
+public:
+
+       AsyncRenderer(etl::handle<synfig::Target> target,synfig::ProgressCallback *cb=0);
+       virtual ~AsyncRenderer();
+
+       void start();
+       void stop();
+       void pause();
+       void resume();
+#ifdef SINGLE_THREADED
+       void rendering_progress();
+       bool updating;
+#endif
+
+       bool has_error()const { return error; }
+       bool has_success()const { return success; }
+
+       sigc::signal<void>& signal_finished() { return signal_finished_; }
+       sigc::signal<void>& signal_success() { return signal_success_; }
+
+private:
+
+       void render_target();
+       void start_();
+
+       /*
+ --    ** -- C H I L D   M E M B E R S -------------------------------------------
+       */
+
+protected:
+
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/audiocontainer.cpp b/synfig-studio/src/gui/audiocontainer.cpp
new file mode 100644 (file)
index 0000000..70d5dd9
--- /dev/null
@@ -0,0 +1,1429 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file audiocontainer.cpp
+**     \brief Audio Container implementation File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include <algorithm>
+#include <sigc++/signal.h>
+
+#include <ETL/stringf>
+#include <ETL/clock>
+//#include <ETL/thread>
+#include <glibmm/thread.h>
+
+#include <synfig/general.h>
+
+#include <glibmm/main.h>
+
+#include "audiocontainer.h"
+
+#include <cstdio>
+#include <sys/stat.h>
+#include <errno.h>
+
+#include <set>
+#include <vector>
+
+#ifdef WITH_FMOD
+#include <fmod.h>
+#endif
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+
+/* === M A C R O S ========================================================= */
+#ifdef __WIN32
+#else //linux...
+#define AUDIO_OUTPUT   FSOUND_OUTPUT_OSS
+#endif
+
+/* === G L O B A L S ======================================================= */
+const double delay_factor = 3;
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+/* === E N T R Y P O I N T ================================================= */
+
+//Help constructing stuff
+struct FSOUND_SAMPLE;
+using studio::AudioContainer;
+
+#ifdef WITH_FMOD
+bool build_profile(FSOUND_SAMPLE *sample, double &samplerate, std::vector<char> &samples)
+#else
+bool build_profile(FSOUND_SAMPLE */*sample*/, double &/*samplerate*/, std::vector<char> &/*samples*/)
+#endif
+{
+#ifdef WITH_FMOD
+
+       float sps = samplerate;
+
+       //trivial rejection...
+       if(!sample || sps < 1)
+       {
+               synfig::warning("build_profile: Sample rate was too low or sample was invalid");
+               return false;
+       }
+
+       //lock for all samples and process them into a subset
+       unsigned int mode = FSOUND_Sample_GetMode(sample);
+
+       //make sure that it's 8 bit... I hope this works...
+
+       //sample rate of the actual song...
+       int allsamplerate = 0;
+       FSOUND_Sample_GetDefaults(sample,&allsamplerate,0,0,0);
+
+       //get the size of the sample defaults from the mode
+       int channels = 1;
+       int channelsize = 1; //number of bytes
+
+       if(mode & FSOUND_16BITS) channelsize = 2; //this shouldn't happen
+       if(mode & FSOUND_STEREO) channels = 2;
+
+       //Get the sample information
+       int samplesize = channels*channelsize; //the only two things that increase samplesize
+       int numsamples = FSOUND_Sample_GetLength(sample); //number of samples in the sound
+       int sizeall = samplesize*numsamples; //should be the size of the entire song...
+
+       if(sizeall <= 0)
+       {
+               synfig::warning("ProfileAudio: Sample buffer cannot be size smaller than 1 (%X)",FSOUND_GetError());
+               return false;
+       }
+
+       //be sure that the new sample rate is less than or equal to the original
+       if(sps > allsamplerate) sps = allsamplerate;
+
+       float stride = allsamplerate/(float)sps;
+
+       //down sampling to 8 bit min/max values
+       synfig::warning("About to downsample from %d Hz to %.1f Hz, sample stride: %f", allsamplerate, sps, stride);
+
+       char *sampledata=0,*useless = 0;
+       unsigned int len1,len2;
+       // vector<char> samples;
+       {
+               if(!FSOUND_Sample_Lock(sample,0,sizeall,(void**)&sampledata,(void**)&useless,&len1,&len2))
+               {
+                       synfig::warning("ProfileAudio: Unable to lock the sound buffer... (%X)",FSOUND_GetError());
+                       return false;
+               }
+               synfig::warning("Locked: %X: %d bytes, %X: %d bytes",sampledata,len1,useless,len2);
+
+               if(channelsize == 1)
+               {
+                       //process the data
+                       char *iter = sampledata;
+                       char *end = iter + sizeall;
+
+                       float curaccum = 0;
+                       float numinc = sps/(float)allsamplerate;
+
+                       /* Loop per sample DDA alg.
+                       */
+
+                       int i = 0;
+
+                       //HACK - to prevent if statement inside inner loop
+                       //synfig::warning("wo baby wo baby, inc: %d, stride: %f, size: %d", inc, stride, sizeall);
+                       while(iter < end)
+                       {
+                               int maxs = 0, mins = 0;
+
+                               for(;curaccum < 1; curaccum += numinc)
+                               {
+                                       for(i = 0; iter < end && i < channels; ++i, iter += channelsize)
+                                       {
+                                               maxs = std::max(maxs,(int)*iter);
+                                               mins = std::min(mins,(int)*iter);
+                                       }
+                               }
+                               //insert onto new list
+                               samples.push_back(maxs);
+                               samples.push_back(mins);
+
+                               //and flush all the used samples for curaccum
+                               curaccum -= 1;
+                       }
+               }else if(channelsize == 2)
+               {
+                       //process the data
+                       char *iter = sampledata;
+                       char *end = iter + sizeall;
+
+                       float curaccum = 0;
+                       float numinc = sps/(float)allsamplerate;
+
+                       /* Loop per sample DDA alg.
+                       */
+
+                       int i = 0;
+
+                       //HACK - to prevent if statement inside inner loop
+                       //synfig::warning("wo baby wo baby, inc: %d, stride: %f, size: %d", inc, stride, sizeall);
+                       while(iter < end)
+                       {
+                               int maxs = 0, mins = 0;
+
+                               for(;curaccum < 1; curaccum += numinc)
+                               {
+                                       for(i = 0; iter < end && i < channels; ++i, iter += channelsize)
+                                       {
+                                               maxs = std::max(maxs,(int)*(short*)iter);
+                                               mins = std::min(mins,(int)*(short*)iter);
+                                       }
+                               }
+                               //insert onto new list
+                               samples.push_back(maxs / 256);
+                               samples.push_back(mins / 256);
+
+                               //and flush all the used samples for curaccum
+                               curaccum -= 1;
+                       }
+               }
+       }
+
+       synfig::warning("Stats: %f seconds with %d bytes now %d bytes", (samples.size()/2)/sps, sizeall, samples.size());
+       synfig::warning("               %f seconds before", numsamples/(float)allsamplerate);
+
+       //we're done yay!, unlock
+       FSOUND_Sample_Unlock(sample,sampledata,useless,len1,len2);
+       synfig::info("Unlocked");
+
+       //FSOUND_PlaySound(FSOUND_FREE,sound); //test
+
+       //we're done
+       samplerate = sps*2; //it must be x2 because we are sampling max and min
+
+       return true;
+
+       #else
+
+       return false;
+
+       #endif
+}
+
+
+//FMOD Systemwide Specific data mostly here...
+
+struct scrubinfo;
+
+#ifdef WITH_FMOD
+static double  buffer_length_sec = 0;
+
+//------- Scrubbing --------------
+/* Scrubbing works as follows:
+
+       The sound is played using PlaySoundEx
+               we specify a user created DSP for scrubbing
+               set it initially to inactive
+
+       When the program initiates it
+               we set the initial data in the shared structure and activate the dsp unit
+               then for each cursor update we get we set the value in the shared structure
+*/
+
+/* Things to check:
+       If IsPlaying just governs the channel play/stop value or if it also concerns the pause state
+
+*/
+
+//so we can know where to create all this stuff
+struct scrubinfo
+{
+       /*      Linearly fit the frequency to hit the desired zero point...
+       */
+       /*struct scrubelement
+       {
+               double  pos;
+               double  dt;
+               //the amount of time left til the cursor hits this one
+               //      it's incremental so that the cursor must pass previous
+               //      ones before decrementing this value
+       };
+       */
+
+       //the time it should take to get to the next position...
+
+       //to prevent from writing to the same location at once... (pos, deltatime, delaystart)
+       //Glib::Mutex   lock;
+
+       //the queue system would provide a more accurate representation...
+       volatile double pos;
+       volatile double deltatime;
+
+       volatile double delaystart; //the amount of time we need to go before we start interpolating...
+
+       volatile int    channel;
+
+       /*std::list<scrubelement>       queue;
+
+       volatile int    channel;
+
+       //current position is FSOUND_GetCurrentPosition and current time is always 0...
+
+       void add(const scrubelement &elem)
+       {
+               lock.LockWrite();
+
+               queue.push_back(elem);
+
+               lock.UnlockWrite();
+       }
+
+       //Function to safely get rid of all the old samples (dt < 0)
+       void flush()
+       {
+               lock.LockWrite();
+
+               while(queue.size() && queue.front().dt < 0)
+               {
+                       queue.pop_front();
+               }
+
+               lock.UnlockWrite();
+       }*/
+
+       void Lock()
+       {
+               //lock.lock();
+       }
+
+       void Unlock()
+       {
+               //lock.unlock();
+       }
+
+       //All parameters and state should be set by the time we get here...
+       void scrub_dsp_process()
+       {
+               const double epsilon = 1e-5;
+
+               //Trivial reject... we go nowhere if we aren't playing (hit boundary...)
+               if(!FSOUND_IsPlaying(channel)) return;
+
+               //Get rid of all the old samples
+               //flush();
+
+               //Trivial reject #2 - We also go nowhere with no future samples (pause)
+               /*if(queue.size() <= 0)
+               {
+                       FSOUND_SetPaused(channel,true);
+                       return;
+               }*/
+
+               double dt = buffer_length_sec;
+
+               //Lock ourselves so we don't die
+               Lock();
+
+               //printf("DSP data: delay = %.3f s, pos = %d, dt = %.3f\n", delaystart, (int)pos, deltatime);
+
+               //Check delay
+               if(delaystart > 0)
+               {
+                       delaystart -= dt;
+
+                       if(delaystart < 0)
+                       {
+                               dt = -delaystart; //add time back...
+                               delaystart = 0;
+                       }
+               }
+
+               //Trivial reject for if we're past current sample...
+               if(delaystart > 0 || deltatime <= 0)
+               {
+                       FSOUND_SetPaused(channel,true);
+                       Unlock();
+                       return;
+               }
+
+               //Calculate stretched frequency based on delayed future sample...
+
+               //NOTE: BY NOT TRACKING POSITION AS A FLOAT AND JUST USING THE SOUNDS VALUE
+               //              WE ARE LOSING A TINY AMOUNT OF PRECISION ACCURACY EVERY UPDATE
+               //              (THIS SHOULDN'T BE A PROBLEM)
+               const double p0 = FSOUND_GetCurrentPosition(channel);
+               double curdp = 0;
+
+               if(!FSOUND_GetPaused(channel))
+               {
+                       curdp = FSOUND_GetFrequency(channel) * deltatime;
+               }
+
+               //need to rescale derivative...
+
+               //Extrapolate from difference in position and deltatime vs dt...
+               const double pa = p0 + curdp/2;
+
+               const double p1 = pos;
+
+               //const double pb = p0/3 + p1*2/3;
+
+               //will extrapolate if needed... (could be funky on a curve)
+               double t = 0;
+               if(deltatime > epsilon)
+               {
+                       t = dt / deltatime;
+               }
+
+               //Decrement deltatime (we may have gone past but that's what happens when we don't get input...)
+               deltatime -= dt;
+
+               //we don't need to look at the current variables anymore...
+               Unlock();
+
+               const double invt = 1-t;
+               //double deltapos = (p1-p0)*t; //linear version
+               double deltapos = invt*invt*p0 + 2*t*invt*pa + t*t*p1 - p0; //quadratic smoothing version
+
+               //Attempted cubic smoothing
+               //const double invt2 = invt*invt;
+               //const double t2 = t*t;
+               //double deltapos = invt2*invt*p0 + 3*t*invt2*pa + 3*t2*invt*pb + t2*t*p1;
+               //double deltapos = p0 + t*(3*(pa-p0) + t*(3*(p0+2*pa+pb) + t*((p1-3*pb+3*ba-p0)))); //unwound cubic
+
+               //printf("\ttime = %.2f; p(%d,%d,%d) dp:%d - delta = %d\n",t,(int)p0,(int)p1,(int)p2,(int)curdp,(int)deltapos);
+
+               //Based on the delta info calculate the stretched frequency
+               const int dest_samplesize = FSOUND_DSP_GetBufferLength();
+
+               //rounded to nearest frequency... (hopefully...)
+               int freq = (int)(deltapos * FSOUND_GetOutputRate() / (double)dest_samplesize);
+
+               //NOTE: WE MIGHT WANT TO DO THIS TO BE MORE ACCURATE BUT YEAH... ISSUES WITH SMALL NUMBERS
+               //double newdp = deltapos / t;
+
+               //printf("\tfreq = %d Hz\n", freq);
+
+               // !If I failed... um assume we have to pause it... ?
+               if(abs(freq) < 100)
+               {
+                       FSOUND_SetPaused(channel,true);
+               }else
+               {
+                       //synfig::info("DSP f = %d Hz", freq);
+                       FSOUND_SetPaused(channel,false);
+                       if(!FSOUND_SetFrequency(channel,freq))
+                       {
+                               //ERROR WILL ROBINSON!!!...
+                               printf("Error in Freq... what do I do?\n");
+                       }
+               }
+       }
+};
+
+struct scrubuserdata
+{
+       /* //for use with multiple
+       //each one is a 'handle' to a pointer that will be effected by something else
+       typedef scrubinfo**     value_type;
+       typedef std::set< value_type > scrubslist;
+       scrubslist              scrubs;
+
+       //so we can lock access to the list...
+       ReadWriteLock   lock;
+
+       void AddScrub(scrubinfo **i)
+       {
+               lock.LockWrite();
+               scrubs.insert(i);
+               lock.UnLockWrite();
+       }
+
+       void RemoveScrub(scrubinfo **i)
+       {
+               lock.LockWrite();
+               scrubs.erase(i);
+               lock.UnLockWrite();
+       }*/
+
+       scrubinfo * volatile *  scrub;
+};
+
+//Scrubbing data structures
+static const int               default_scrub_priority = 5; //between clear and sfx/music mix
+static scrubuserdata   g_scrubdata = {0};
+static FSOUND_DSPUNIT  *scrubdspunit = 0;
+
+void * scrubdspwrap(void *originalbuffer, void *newbuffer, int length, void *userdata)
+{
+       //std::string   dsp = "DSP";
+       if(userdata)
+       {
+               scrubuserdata &sd = *(scrubuserdata*)userdata;
+
+               /* //For use with multiple scrubs...
+               //Lock so no one can write to it while we're reading from it...
+               sd.lock.LockRead();
+
+               //make a copy of it...
+               std::vector<scrubinfo**>        v(sd.scrubs.begin(),sd.scrubs.end());
+
+               //other things can do stuff with it again...
+               sd.lock.UnLockRead();
+
+               //loop through the list and process all the active scrub units
+               std::vector<scrubinfo**>::iterator      i = v.begin(),
+                                                                                       end = v.end();
+               for(;i != end; ++i)
+               {
+                       //check to make sure this object is active...
+                       if(*i && **i)
+                       {
+                               (**i)->scrub_dsp_process();
+                       }
+               }
+               */
+
+               if(sd.scrub && *sd.scrub)
+               {
+                       //dsp += " processing...";
+                       scrubinfo * info = (*sd.scrub);
+                       info->scrub_dsp_process();
+               }
+       }
+
+       //synfig::info(dsp);
+
+       return newbuffer;
+}
+
+//------- Class for loading fmod on demand -------
+
+class FMODInitializer
+{
+       bool loaded;
+       int     refcount;
+
+public:
+       FMODInitializer():loaded(false),refcount(0) {}
+       ~FMODInitializer()
+       {
+               clear();
+       }
+
+       void addref()
+       {
+               if(!loaded)
+               {
+                       #ifdef WITH_FMOD
+                       synfig::info("Initializing FMOD on demand...");
+
+                       {
+                               FSOUND_SetOutput(AUDIO_OUTPUT);
+
+                               /*int numdrivers = FSOUND_GetNumDrivers();
+                               synfig::info("Num FMOD drivers = %d",numdrivers);
+                               synfig::info("Current Driver is #%d", FSOUND_GetDriver());
+
+                               for(int i = 0; i < numdrivers; ++i)
+                               {
+                                       unsigned int caps = 0;
+                                       FSOUND_GetDriverCaps(i,&caps);
+
+                                       synfig::info("   Caps for driver %d (%s) = %x",i,FSOUND_GetDriverName(i),caps);
+                               }
+
+                               FSOUND_SetDriver(0);*/
+
+                               //Modify buffer size...
+                               //FSOUND_SetBufferSize(100);
+
+                               if(!FSOUND_Init(44100, 32, 0))
+                               {
+                                       synfig::warning("Unable to load FMOD");
+                               }else
+                               {
+                                       loaded = true;
+
+                                       //Create the DSP for processing scrubbing...
+                                       scrubdspunit = FSOUND_DSP_Create(&scrubdspwrap,default_scrub_priority,&g_scrubdata);
+
+                                       //Load the number of sec per buffer into the global variable...
+                                       buffer_length_sec = FSOUND_DSP_GetBufferLength() / (double)FSOUND_GetOutputRate();
+                               }
+                       }
+                       #endif
+               }
+
+               //add to the refcount
+               ++refcount;
+               //synfig::info("Audio: increment fmod refcount %d", refcount);
+       }
+
+       void decref()
+       {
+               if(refcount <= 0)
+               {
+                       synfig::warning("FMOD refcount is already 0...");
+               }else
+               {
+                       --refcount;
+                       //synfig::info("Audio: decrement fmod refcount %d", refcount);
+
+                       //NOTE: UNCOMMENT THIS IF YOU WANT FMOD TO UNLOAD ITSELF WHEN IT ISN'T NEEDED ANYMORE...
+                       flush();
+               }
+       }
+
+       bool is_loaded() const { return loaded; }
+
+       void clear()
+       {
+               refcount = 0;
+               flush();
+       }
+
+       void flush()
+       {
+               if(loaded && refcount <= 0)
+               {
+                       #ifdef WITH_FMOD
+                       synfig::info("Unloading FMOD");
+                       if(scrubdspunit) FSOUND_DSP_Free(scrubdspunit);
+                       FSOUND_Close();
+                       #endif
+                       loaded = false;
+               }
+       }
+};
+
+//The global counter for FMOD....
+FMODInitializer                fmodinit;
+
+#endif
+
+//----- AudioProfile Implementation -----------
+void studio::AudioProfile::clear()
+{
+       samplerate = 0;
+       samples.clear();
+}
+
+handle<AudioContainer> studio::AudioProfile::get_parent() const
+{
+       return parent;
+}
+
+void studio::AudioProfile::set_parent(etl::handle<AudioContainer> i)
+{
+       parent = i;
+}
+
+double studio::AudioProfile::get_offset() const
+{
+       if(parent)
+               return parent->get_offset();
+       return 0;
+}
+
+//---------- AudioContainer definitions ---------------------
+
+struct studio::AudioContainer::AudioImp
+{
+       //Sample load time information
+       FSOUND_SAMPLE *         sample;
+       int                                     channel;
+       int                                     sfreq;
+       int                                     length;
+
+       //Time information
+       double                          offset; //time offset for playing...
+
+       //We don't need it now that we've adopted the play(t) time schedule...
+       //current time... and playing info....
+       //float                         seekpost;
+       //bool                          useseekval;
+
+       //Make sure to sever our delayed start if we are stopped prematurely
+       sigc::connection        delaycon;
+
+       //Action information
+       bool                            playing;
+       double                          curscrubpos;
+       etl::clock                      timer;  //for getting the time diff between scrub input points
+
+       //Scrubbing information...
+       //the current position of the sound will be sufficient for normal stuff...
+       #ifdef WITH_FMOD
+       scrubinfo                       scrinfo;
+       #endif
+
+       scrubinfo                       *scrptr;
+
+       bool is_scrubbing() const {return scrptr != 0;}
+#ifdef WITH_FMOD
+       void set_scrubbing(bool s)
+#else
+       void set_scrubbing(bool /*s*/)
+#endif
+       {
+               #ifdef WITH_FMOD
+               if(s)
+                       scrptr = &scrinfo;
+               else
+               #endif
+               scrptr = 0;
+       }
+
+       //helper to make sure we are actually playing (and to get a new channel...)
+       bool init_play()
+       {
+               #ifdef WITH_FMOD
+               if(!FSOUND_IsPlaying(channel))
+               {
+                       if(sample)
+                       {
+                               //play sound paused etc.
+                               channel = FSOUND_PlaySoundEx(FSOUND_FREE,sample,0,true);
+                               if(channel < 0 || FSOUND_GetError() != FMOD_ERR_NONE)
+                               {
+                                       synfig::warning("Could not play the sample...");
+                                       return false;
+                               }
+                       }
+               }else
+               {
+                       FSOUND_SetPaused(channel,true);
+                       FSOUND_SetFrequency(channel,sfreq);
+               }
+               return true;
+
+               #else
+
+               return false;
+
+               #endif
+       }
+
+public: //structors
+       AudioImp()
+       :sample(0),
+       channel(0),
+       sfreq(0),
+       length(0),
+       offset(0),
+       playing(false),
+       scrptr(0)
+       {
+               //reuse the channel...
+               #ifdef WITH_FMOD
+               channel = FSOUND_FREE;
+               #endif
+       }
+
+       ~AudioImp()
+       {
+               clear();
+       }
+
+public: //helper/accessor funcs
+       bool start_playing_now() //callback for timer...
+       {
+               #ifdef WITH_FMOD
+               if(playing)
+               {
+                       //Make sure the sound is playing and if it is un pause it...
+                       if(init_play())
+                               FSOUND_SetPaused(channel,false);
+               }
+               #endif
+
+               return false; //so the timer doesn't repeat itself
+       }
+
+       bool isRunning()
+       {
+               #ifdef WITH_FMOD
+               return FSOUND_IsPlaying(channel);
+               #else
+               return false;
+               #endif
+       }
+
+       bool isPaused()
+       {
+#ifdef WITH_FMOD
+               return FSOUND_GetPaused(channel);
+#else
+               return false;
+#endif
+       }
+
+
+public: //forward interface
+
+       //Accessors for the offset - in seconds
+       const double &get_offset() const {return offset;}
+       void set_offset(const double &d)
+       {
+               offset = d;
+       }
+
+       //Will override the parameter timevalue if the sound is running, and not if it's not...
+#ifdef WITH_FMOD
+       bool get_current_time(double &out)
+#else
+       bool get_current_time(double &/*out*/)
+#endif
+       {
+               if(isRunning())
+               {
+                       #ifdef WITH_FMOD
+                       unsigned int pos = FSOUND_GetCurrentPosition(channel);
+
+                       //adjust back by 1 frame... HACK....
+                       //pos -= FSOUND_DSP_GetBufferLength();
+
+                       //set the position
+                       out = pos/(double)sfreq + offset;
+                       #endif
+
+                       return true;
+               }
+               return false;
+       }
+
+       //Big implementation functions...
+       bool load(const std::string &filename, const std::string &filedirectory);
+       void clear();
+
+       //playing functions
+       void play(double t);
+       void stop();
+
+       //scrubbing functions
+       void start_scrubbing(double t);
+       void scrub(double t);
+       void stop_scrubbing();
+
+       double scrub_time()
+       {
+               return curscrubpos;
+       }
+};
+
+//--------------- Audio Container definitions --------------------------
+studio::AudioContainer::AudioContainer()
+{
+       imp = 0;
+}
+
+studio::AudioContainer::~AudioContainer()
+{
+       if(imp) delete (imp);
+}
+
+bool studio::AudioContainer::load(const std::string &filename,const std::string &filedirectory)
+{
+       if(!imp)
+       {
+               imp = new AudioImp;
+       }
+
+       profilevalid = false;
+       return imp->load(filename,filedirectory);
+}
+
+#ifdef WITH_FMOD
+handle<studio::AudioProfile> studio::AudioContainer::get_profile(float samplerate)
+#else
+handle<studio::AudioProfile> studio::AudioContainer::get_profile(float /*samplerate*/)
+#endif
+{
+       #ifdef WITH_FMOD
+
+       //if we already have done our work, then we're good
+       if(profilevalid && prof)
+       {
+               //synfig::info("Using already built profile");
+               return prof;
+       }
+
+       //synfig::info("Before profile");
+       //make a new profile at current sample rate
+
+       //NOTE: We might want to reuse the structure already there...
+       prof = new AudioProfile;
+       prof->set_parent(this); //Our parent is THIS!!!
+
+       if(!prof)
+       {
+               synfig::warning("Couldn't allocate audioprofile...");
+               return handle<studio::AudioProfile>();
+       }
+
+       //setting the info for the sample rate
+       //synfig::info("Setting info...");
+
+       synfig::info("Building Profile...");
+       prof->samplerate = samplerate;
+       if(build_profile(imp->sample,prof->samplerate,prof->samples))
+       {
+               synfig::info("  Success!");
+               profilevalid = true;
+               return prof;
+       }else
+       {
+               return handle<studio::AudioProfile>();
+       }
+
+       #else
+
+       return handle<studio::AudioProfile>();
+
+       #endif
+}
+
+void studio::AudioContainer::clear()
+{
+       if(imp)
+       {
+               delete imp;
+               imp = 0;
+       }
+
+       profilevalid = false;
+}
+
+void studio::AudioContainer::play(double t)
+{
+       if(imp) imp->play(t);
+}
+
+void studio::AudioContainer::stop()
+{
+       if(imp) imp->stop();
+}
+
+bool studio::AudioContainer::get_current_time(double &out)
+{
+       if(imp) return imp->get_current_time(out);
+       else return false;
+}
+
+void AudioContainer::set_offset(const double &s)
+{
+       if(imp) imp->set_offset(s);
+}
+
+double AudioContainer::get_offset() const
+{
+       static double zero = 0;
+       if(imp)
+               return imp->get_offset();
+       return zero;
+}
+
+bool AudioContainer::is_playing() const
+{
+       if(imp)
+               return imp->playing;
+       return false;
+}
+
+bool AudioContainer::is_scrubbing() const
+{
+       if(imp)
+               return imp->is_scrubbing();
+       return false;
+}
+
+void AudioContainer::start_scrubbing(double t)
+{
+       if(imp) imp->start_scrubbing(t);
+}
+
+void AudioContainer::stop_scrubbing()
+{
+       if(imp) imp->stop_scrubbing();
+}
+
+void AudioContainer::scrub(double t)
+{
+       if(imp) imp->scrub(t);
+}
+
+double AudioContainer::scrub_time() const
+{
+       if(imp) return imp->scrub_time();
+       else return 0;
+}
+
+bool AudioContainer::isRunning() const
+{
+       if(imp) return imp->isRunning();
+       else return false;
+}
+
+bool AudioContainer::isPaused() const
+{
+       if(imp) return imp->isPaused();
+       else return false;
+}
+
+//----------- Audio imp information -------------------
+
+#ifdef WITH_FMOD
+bool studio::AudioContainer::AudioImp::load(const std::string &filename,
+                                                                                       const std::string &filedirectory)
+#else
+bool studio::AudioContainer::AudioImp::load(const std::string &/*filename*/,
+                                                                                       const std::string &/*filedirectory*/)
+#endif
+{
+       clear();
+
+       #ifdef WITH_FMOD
+
+       //And continue with the sound loading...
+       string  file = filename;
+
+       //Trivial reject... (fixes stat call problem... where it just looks at directory and not file...)
+       if(file.length() == 0) return false;
+
+       //we don't need the file directory?
+       if(!is_absolute_path(file))
+       {
+               file=filedirectory+filename;
+               synfig::warning("Not absolute hoooray");
+       }
+       synfig::info("Loading Audio file: %s", file.c_str());
+
+       //check to see if file exists
+       {
+               struct stat     s;
+               if(stat(file.c_str(),&s) == -1 && errno == ENOENT)
+               {
+                       synfig::info("There was no audio file...");
+                       return false;
+               }
+       }
+
+       //load fmod if we can...
+       //synfig::warning("I'm compiled with FMOD!");
+       fmodinit.addref();
+
+       //load the stream
+       int ch = FSOUND_FREE;
+       FSOUND_SAMPLE *sm = FSOUND_Sample_Load(FSOUND_FREE,file.c_str(),FSOUND_LOOP_OFF|FSOUND_MPEGACCURATE,0,0);
+
+       if(!sm)
+       {
+               synfig::warning("Could not open the audio file as a sample: %s",file.c_str());
+               goto error;
+       }
+
+       //synfig::warning("Opened a file as a sample! :)");
+
+       /*{
+               int bufferlen = FSOUND_DSP_GetBufferLength();
+               synfig::info("Buffer length = %d samples, %.3lf s",bufferlen, bufferlen / (double)FSOUND_GetOutputRate());
+       }*/
+
+       //set all the variables since everything has worked out...
+       //get the length of the stream
+       {
+               length = FSOUND_Sample_GetLength(sm);
+
+               int volume = 0;
+               FSOUND_Sample_GetDefaults(sm,&sfreq,&volume,0,0);
+
+               //double len = length / (double)sfreq;
+               //synfig::info("Sound info: %.2lf s long, %d Hz, %d Vol",(double)length,sfreq,volume);
+       }
+
+       //synfig::warning("Got all info, and setting up everything, %.2f sec.", length);
+       //synfig::warning("     BigSample: composed of %d samples", FSOUND_Sample_GetLength(sm));
+       synfig::info("Successfully opened %s as a sample and initialized it.",file.c_str());
+
+       //set up the playable info
+       sample = sm;
+       channel = ch;
+
+       //the length and sfreq params have already been initialized
+
+       return true;
+
+error:
+       if(sm) FSOUND_Sample_Free(sm);
+       file = "";
+
+       fmodinit.decref();
+
+       return false;
+
+       #else
+       return false;
+       #endif
+}
+
+#ifdef WITH_FMOD
+void studio::AudioContainer::AudioImp::play(double t)
+#else
+void studio::AudioContainer::AudioImp::play(double /*t*/)
+#endif
+{
+       #ifdef WITH_FMOD
+       if(!sample) return;
+
+       //stop scrubbing if we are...
+       if(is_scrubbing()) stop_scrubbing();
+
+       //t -= offset;
+       t -= get_offset();
+       playing = true;
+
+       if(t < 0)
+       {
+               unsigned int timeout = (int)floor(-t * 1000 + 0.5);
+               //synfig::info("Playing audio delayed by %d ms",timeout);
+               //delay for t seconds...
+               delaycon = Glib::signal_timeout().connect(
+                                               sigc::mem_fun(*this,&studio::AudioContainer::AudioImp::start_playing_now),timeout);
+
+               init_play();
+               FSOUND_SetFrequency(channel,sfreq);
+               FSOUND_SetCurrentPosition(channel,0);
+               return;
+       }
+
+       unsigned int position = (int)floor(t*sfreq + 0.5);
+
+       if(position >= FSOUND_Sample_GetLength(sample))
+       {
+               synfig::warning("Can't play audio when past length...");
+               return;
+       }
+
+       init_play();
+       FSOUND_SetFrequency(channel,sfreq);
+       FSOUND_SetCurrentPosition(channel,position);
+       FSOUND_SetPaused(channel,false);
+
+       //synfig::info("Playing audio with position %d samples",position);
+
+       #endif
+}
+
+void studio::AudioContainer::AudioImp::stop()
+{
+       delaycon.disconnect();
+
+       #ifdef WITH_FMOD
+       if(fmodinit.is_loaded() && playing && isRunning())
+       {
+               FSOUND_SetPaused(channel,true);
+       }
+       #endif
+
+       playing = false;
+}
+
+void studio::AudioContainer::AudioImp::clear()
+{
+       #ifdef WITH_FMOD
+       delaycon.disconnect();
+
+       stop();
+       stop_scrubbing();
+
+       if(sample)
+       {
+               if(FSOUND_IsPlaying(channel))
+               {
+                       FSOUND_StopSound(channel);
+               }
+               channel = FSOUND_FREE;
+               FSOUND_Sample_Free(sample);
+               fmodinit.decref();
+       }
+
+       playing = false;
+
+       #else
+       channel = 0;
+       #endif
+
+       sample = 0;
+       playing = false;
+}
+
+#ifdef WITH_FMOD
+void studio::AudioContainer::AudioImp::start_scrubbing(double t)
+#else
+void studio::AudioContainer::AudioImp::start_scrubbing(double /*t*/)
+#endif
+{
+       //synfig::info("Start scrubbing: %lf", t);
+       if(playing) stop();
+
+       set_scrubbing(true);
+
+       #ifdef WITH_FMOD
+       //make sure the other one is not scrubbing...
+       if(g_scrubdata.scrub)
+       {
+               *g_scrubdata.scrub = 0; //nullify the pointer...
+       }
+
+       //Set up the initial state for the delayed audio position
+       scrinfo.delaystart = 0;
+       scrinfo.pos = 0;
+       scrinfo.deltatime = 0;
+
+       //set it to point to our pointer (dizzy...)
+       g_scrubdata.scrub = &scrptr;
+
+       //setup position info so we can know what to do on boundary conditions...
+       curscrubpos = (t - get_offset()) * sfreq;
+
+       //So we can get an accurate difference...
+       timer.reset();
+
+       //reposition the sound if it won't be when scrubbed (if it's already in the range...)
+       int curi = (int)curscrubpos;
+       if(curi >= 0 && curi < length)
+       {
+               init_play();
+               FSOUND_SetCurrentPosition(channel,curi);
+
+               //Set the values...
+               scrinfo.pos = curscrubpos;
+               scrinfo.delaystart = delay_factor*buffer_length_sec;
+
+               //synfig::info("\tStarting at %d samps, with %d p %.3f delay",
+               //                              FSOUND_GetCurrentPosition(channel), (int)scrinfo.pos, scrinfo.delaystart);
+       }
+
+
+
+       //enable the dsp...
+       //synfig::info("\tActivating DSP");
+       FSOUND_DSP_SetActive(scrubdspunit,true);
+       #endif
+}
+
+void studio::AudioContainer::AudioImp::stop_scrubbing()
+{
+       //synfig::info("Stop scrubbing");
+
+       if(is_scrubbing())
+       {
+               set_scrubbing(false);
+
+               #ifdef WITH_FMOD
+               g_scrubdata.scrub = 0;
+
+               //stop the dsp...
+               //synfig::info("\tDeactivating DSP");
+               FSOUND_DSP_SetActive(scrubdspunit,false);
+               if(FSOUND_IsPlaying(channel)) FSOUND_SetPaused(channel,true);
+               #endif
+       }
+
+       curscrubpos = 0;
+}
+
+#ifdef WITH_FMOD
+void studio::AudioContainer::AudioImp::scrub(double t)
+#else
+void studio::AudioContainer::AudioImp::scrub(double /*t*/)
+#endif
+{
+       #ifdef WITH_FMOD
+       //synfig::info("Scrub to %lf",t);
+       if(is_scrubbing())
+       {
+               //What should we do?
+
+               /* Different special cases
+                       All outside, all inside,
+                       coming in (left or right),
+                       going out (left or right)
+               */
+               double oldpos = curscrubpos;
+               double newpos = (t - get_offset()) * sfreq;
+
+               curscrubpos = newpos;
+
+               //Ok the sound is running, now we need to tweak it
+               if(newpos > oldpos)
+               {
+                       //Outside so completely stopped...
+                       if(newpos < 0 || oldpos >= length)
+                       {
+                               //synfig::info("\tOut +");
+                               if(FSOUND_IsPlaying(channel))
+                               {
+                                       FSOUND_SetPaused(channel,true);
+                               }
+
+                               //Zero out the data!
+                               scrinfo.Lock();
+                               scrinfo.delaystart = 0;
+                               scrinfo.deltatime = 0;
+                               scrinfo.Unlock();
+
+                               return;
+                       }
+
+                       //going in? - start the sound at the beginning...
+                       /*else if(oldpos < 0)
+                       {
+                               //Set up the sound to be playing paused at the start...
+                               init_play();
+                               FSOUND_SetCurrentPosition(channel,0);
+
+                               synfig::info("\tIn + %d", FSOUND_GetCurrentPosition(channel));
+
+                               scrinfo.Lock();
+                               scrinfo.pos = 0;
+                               scrinfo.delaystart = delay_factor*buffer_length_sec;
+                               scrinfo.deltatime = 0;
+                               scrinfo.Unlock();
+                       }*/
+                       //don't need to deal with leaving... automatically dealt with...
+
+                       else //We're all inside...
+                       {
+                               //Set new position and decide what to do with time...
+                               scrinfo.Lock();
+                               scrinfo.pos = newpos;
+
+                               //should we restart the delay cycle... (is it done?)
+                               if(!isRunning() || (scrinfo.delaystart <= 0 && scrinfo.deltatime <= 0 && isPaused()))
+                               {
+                                       //synfig::info("Starting + at %d",(int)newpos);
+                                       scrinfo.deltatime = 0;
+                                       scrinfo.delaystart = delay_factor*buffer_length_sec;
+                                       scrinfo.Unlock();
+
+                                       //Set up the sound paused at the current position
+                                       init_play();
+                                       int setpos = min(max((int)newpos,0),length);
+                                       FSOUND_SetCurrentPosition(channel,setpos);
+                                       timer.reset();
+                                       return;
+                               }
+
+                               //No! just increment the time delta...
+                               scrinfo.deltatime += timer.pop_time();
+
+                               //Nope... continue and just increment the deltatime and reset position...
+                               scrinfo.Unlock();
+
+                               //set channel and unpause
+                               FSOUND_SetPaused(channel,false);
+                               scrinfo.channel = channel;
+
+                       }
+               }else if(newpos < oldpos)
+               {
+                       //completely stopped...
+                       if(newpos >= length || oldpos < 0)
+                       {
+                               //synfig::info("Out -");
+                               if(FSOUND_IsPlaying(channel))
+                               {
+                                       FSOUND_SetPaused(channel,true);
+                               }
+
+                               //Zero out the data!
+                               scrinfo.Lock();
+                               scrinfo.delaystart = 0;
+                               scrinfo.deltatime = 0;
+                               scrinfo.Unlock();
+                       }
+
+                       //going in? - start going backwards at the end...
+                       /*else if(oldpos >= length)
+                       {
+                               synfig::info("In -");
+                               //Set up the sound to be playing paused at the start...
+                               init_play();
+                               FSOUND_SetCurrentPosition(channel,length-1);
+
+                               scrinfo.Lock();
+                               scrinfo.pos = length-1;
+                               scrinfo.delaystart = delay_factor*buffer_length_sec;
+                               scrinfo.deltatime = 0;
+                               scrinfo.Unlock();
+                       }*/
+                       //we don't have to worry about the leaving case...
+
+                       else //We're all inside...
+                       {
+                               //Set new position and decide what to do with time...
+                               scrinfo.Lock();
+                               scrinfo.pos = newpos;
+
+                               //should we restart the delay cycle... (is it done?)
+                               if(!isRunning() ||(scrinfo.delaystart <= 0 && scrinfo.deltatime <= 0 && isPaused()))
+                               {
+                                       //synfig::info("Starting - at %d",(int)newpos);
+                                       scrinfo.deltatime = 0;
+                                       scrinfo.delaystart = delay_factor*buffer_length_sec;
+                                       scrinfo.Unlock();
+
+                                       //reset timing so next update will be a valid diff...
+                                       init_play();
+                                       int setpos = min(max((int)newpos,0),length);
+                                       FSOUND_SetCurrentPosition(channel,setpos);
+                                       timer.reset();
+                                       return;
+                               }
+
+                               //No! just increment the time delta...
+                               scrinfo.deltatime += timer.pop_time();
+
+                               //Nope... continue and just increment the deltatime and reset position...
+                               scrinfo.Unlock();
+
+                               //set channel and unpause
+                               FSOUND_SetPaused(channel,false);
+                               scrinfo.channel = channel;
+                       }
+               }
+       }
+       #endif
+}
diff --git a/synfig-studio/src/gui/audiocontainer.h b/synfig-studio/src/gui/audiocontainer.h
new file mode 100644 (file)
index 0000000..21d5f51
--- /dev/null
@@ -0,0 +1,139 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file audiocontainer.h
+**     \brief Sound info 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_AUDIOCONTAINER_H
+#define __SYNFIG_AUDIOCONTAINER_H
+
+/* === H E A D E R S ======================================================= */
+#include <sigc++/signal.h>
+
+#include <ETL/handle>
+
+#include <vector>
+#include <string>
+
+#include <synfig/time.h>
+
+/* === M A C R O S ========================================================= */
+const float DEF_DISPLAYSAMPLERATE = 400;
+/* === 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 AudioContainer;
+
+//Note: Might want to abstract something to share data between profile and parent
+class AudioProfile : public etl::shared_object
+{
+public:
+       typedef std::vector<char>       SampleProfile;
+
+private:
+       SampleProfile   samples;
+       double                  samplerate; //samples / second of the profile
+
+       //reference our parent for any native sound info
+       etl::loose_handle<AudioContainer>       parent;
+
+public:        //samples interface
+
+       SampleProfile::const_iterator   begin() const   {return samples.begin();}
+       SampleProfile::const_iterator   end() const     {return samples.end();}
+
+       void clear();
+       unsigned int size() const {return samples.size();}
+
+       char operator[](int i) const
+       {
+               if(i >= 0 && i < (int)samples.size()) return samples[i];
+               else return 0;
+       }
+
+public: //
+
+       double get_samplerate() const {return samplerate;}
+       void set_samplerate(double f) {samplerate = f;}
+
+       double get_offset() const;
+
+       etl::handle<AudioContainer>     get_parent() const;
+       void set_parent(etl::handle<AudioContainer> i);
+       friend class AudioContainer;
+};
+
+/*     Audio container actually implements all the cool stuff
+       Note: May be a bit too monolithic...
+*/
+class AudioContainer : public sigc::trackable, public etl::shared_object
+{
+       etl::handle<AudioProfile>       prof;
+
+       struct  AudioImp;
+       AudioImp *imp;
+
+       bool    profilevalid; //this is only half useful
+               //it makes it so we don't always have to realloc memory when the file switches...
+
+public: //structors
+
+       AudioContainer();
+       ~AudioContainer();
+
+public: //accessor interface
+       void set_offset(const double &s);
+       double get_offset() const;
+
+public: //info gather interface
+       etl::handle<AudioProfile>       get_profile(float samplerate = DEF_DISPLAYSAMPLERATE);
+       bool get_current_time(double &out);
+
+public: //operational interface
+       bool load(const std::string &filename, const std::string &filedirectory = "");
+       void clear();
+
+       //play functions...
+       void play(double t);
+       void stop();
+       //Note: this refers to the wrapper concept of the audio, the actual sound may or may not be playing...
+       bool is_playing() const;
+
+       //scrubbing functions...
+       void start_scrubbing(double t);
+       void stop_scrubbing();
+       void scrub(double t); //!< if we are not currently scrubbing this will not work
+       bool is_scrubbing() const;
+
+       double scrub_time() const;
+
+       bool isRunning() const;
+       bool isPaused() const;
+};
+
+} // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/autorecover.cpp b/synfig-studio/src/gui/autorecover.cpp
new file mode 100644 (file)
index 0000000..4e9eeb8
--- /dev/null
@@ -0,0 +1,329 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file autorecover.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 <config.h>
+#endif
+
+#include "autorecover.h"
+
+#ifdef HAVE_SYS_ERRNO_H
+#include <sys/errno.h>
+#endif
+//#include <unistd.h>
+#include "app.h"
+#include <synfig/savecanvas.h>
+#include <synfig/loadcanvas.h>
+#include <fstream>
+#include <iostream>
+#include "instance.h"
+
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
+
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#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 ========================================================= */
+
+#ifdef _WIN32
+#define mkdir(x,y) mkdir(x)
+#endif
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+AutoRecover::AutoRecover()
+{
+       // Three Minutes
+       set_timeout(3*60*1000);
+
+       if(mkdir(get_shadow_directory().c_str(),ACCESSPERMS)<0)
+       {
+               if(errno!=EEXIST)
+                       synfig::error("UNABLE TO CREATE \"%s\"",get_shadow_directory().c_str());
+       }
+       else
+       {
+               synfig::info("Created directory \"%s\"",get_shadow_directory().c_str());
+       }
+}
+
+AutoRecover::~AutoRecover()
+{
+}
+
+synfig::String
+AutoRecover::get_shadow_directory()
+{
+       return Glib::build_filename(App::get_user_app_directory(),"tmp");
+}
+
+int
+AutoRecover::pid()
+{
+//     return getpid();
+       return 0;
+}
+
+void
+AutoRecover::set_timeout(int milliseconds)
+{
+       timeout=milliseconds;
+       auto_backup_connect.disconnect();
+       if(timeout)
+               auto_backup_connect=Glib::signal_timeout().connect(sigc::ptr_fun(&AutoRecover::auto_backup),timeout);
+}
+
+synfig::String
+AutoRecover::get_shadow_file_name(const synfig::String& filename)
+{
+       unsigned int hash1(0xdeadbeef);
+       unsigned int hash2(0x83502529);
+       char* str_hash1(reinterpret_cast<char*>(&hash1));
+       char* str_hash2(reinterpret_cast<char*>(&hash2));
+
+       // First we need to hash up the directory
+       {
+               String pool(dirname(filename));
+
+               while(pool.size()>4)
+               {
+                       str_hash1[0]^=pool[1];str_hash1[1]^=pool[2];str_hash1[2]^=pool[3];str_hash1[3]^=pool[0];
+                       str_hash2[3]+=pool[0];str_hash2[2]+=pool[1];str_hash2[1]+=pool[2];str_hash2[0]+=pool[3];
+                       swap(hash1,hash2);
+                       pool=String(pool,4,pool.size());
+               }
+               while(pool.size())
+               {
+                       str_hash1[0]^=pool[0];
+                       str_hash1[2]^=pool[0];
+                       str_hash2[1]^=pool[0];
+                       str_hash2[3]^=pool[0];
+                       swap(hash1,hash2);
+                       pool=String(pool,1,pool.size());
+               }
+       }
+       hash1^=hash2;
+
+       return Glib::build_filename(get_shadow_directory(),strprintf("%08X-%s",hash1,basename(filename).c_str()));
+
+//     return dirname(filename) + ETL_DIRECTORY_SEPARATOR + ".shadow_" + basename(filename);
+}
+
+bool
+AutoRecover::cleanup_pid(int pid)
+{
+#ifdef HAVE_FORK
+       int status=0;
+       if(waitpid(pid,&status,WNOHANG)==-1)
+       {
+               synfig::info("PID %d isn't a zombie yet",pid);
+               return true;
+       }
+       if(WEXITSTATUS(status)!=0)
+       {
+               synfig::error("Autobackup seems to have failed! (PID=%d)",pid);
+       }
+//     else
+//             synfig::info("PID=%d has been cleaned up",pid);
+#endif
+       return false;
+}
+
+bool
+AutoRecover::auto_backup()
+{
+       int pid(0);
+
+#ifdef HAVE_FORK
+       pid=fork();
+#endif
+
+       if(pid<=0)
+       {
+#ifdef HAVE_SETPRIORITY
+               // make us low priority so that we don't
+               // cause the machine to slow down too much
+               setpriority(PRIO_PROCESS,0,15);
+#endif
+
+               try
+               {
+                       std::list<etl::handle<Instance> >::iterator iter;
+
+                       std::string filename=App::get_config_file("autorecovery");
+                       std::ofstream file(filename.c_str());
+
+                       int savecount(0);
+
+                       for(iter=App::instance_list.begin();iter!=App::instance_list.end();++iter)
+                       {
+                               // If this file hasn't even been changed
+                               // since it was last saved, then don't bother
+                               // backing it up.
+                               if((*iter)->get_action_count()==0)
+                                       continue;
+
+                               Canvas::Handle canvas((*iter)->get_canvas());
+                               file<<canvas->get_file_name()<<endl;
+                               save_canvas(get_shadow_file_name(canvas->get_file_name()),canvas);
+                               savecount++;
+                       }
+
+//                     if(savecount)
+//                             synfig::info("AutoRecover::auto_backup(): %d Files backed up.",savecount);
+               }
+               catch(...)
+               {
+                       synfig::error("AutoRecover::auto_backup(): UNKNOWN EXCEPTION THROWN.");
+                       synfig::error("AutoRecover::auto_backup(): FILES NOT BACKED UP.");
+               }
+
+#ifdef HAVE_FORK
+               if(pid==0)
+               {
+                       _exit(0);
+               }
+#endif
+       }
+
+#ifdef HAVE_FORK
+       Glib::signal_timeout().connect(
+               sigc::bind(
+                       sigc::ptr_fun(&AutoRecover::cleanup_pid),
+                       pid
+               ),
+               60*1000
+       );
+#endif
+
+       // Also go ahead and save the settings
+       App::save_settings();
+
+       return true;
+}
+
+bool
+AutoRecover::recovery_needed()const
+{
+       std::string filename=App::get_config_file("autorecovery");
+       std::ifstream file(filename.c_str());
+       if(!file)
+               return false;
+
+       while(file)
+       {
+               std::string filename;
+               getline(file,filename);
+               if(!filename.empty())
+                       return true;
+       }
+
+       return false;
+}
+
+bool
+AutoRecover::recover(int& number_recovered)
+{
+       std::string filename=App::get_config_file("autorecovery");
+       std::ifstream file(filename.c_str());
+       number_recovered = 0;
+       if(!file)
+               return false;
+       bool success=true;
+
+       while(file)
+       {
+               std::string filename;
+               getline(file,filename);
+               if(filename.empty())
+                       continue;
+
+               // Open the file
+               if(App::open_as(get_shadow_file_name(filename),filename))
+               {
+                       // Correct the file name
+                       App::instance_list.back()->set_file_name(filename);
+
+                       // This file isn't saved! mark it as such
+                       App::instance_list.back()->inc_action_count();
+
+                       number_recovered++;
+               }
+               else
+                       success=false;
+       }
+
+       return success;
+}
+
+void
+AutoRecover::normal_shutdown()
+{
+       // Turn off the timer
+       auto_backup_connect.disconnect();
+
+       std::string filename=App::get_config_file("autorecovery");
+       remove(filename.c_str());
+}
+
+void
+AutoRecover::clear_backup(synfig::Canvas::Handle canvas)
+{
+       if(canvas)
+               remove(get_shadow_file_name(canvas->get_file_name()).c_str());
+}
diff --git a/synfig-studio/src/gui/autorecover.h b/synfig-studio/src/gui/autorecover.h
new file mode 100644 (file)
index 0000000..9bdedac
--- /dev/null
@@ -0,0 +1,75 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file autorecover.h
+**     \brief Template Header
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_AUTORECOVER_H
+#define __SYNFIG_AUTORECOVER_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <synfig/string.h>
+#include <synfig/canvas.h>
+#include <sigc++/connection.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 AutoRecover
+{
+       int timeout;
+       sigc::connection auto_backup_connect;
+public:
+       AutoRecover();
+       ~AutoRecover();
+
+       static int pid();
+       static synfig::String get_shadow_file_name(const synfig::String& filename);
+
+       static bool auto_backup();
+
+       static bool cleanup_pid(int pid);
+
+       void set_timeout(int milliseconds);
+       int get_timeout()const { return timeout; }
+
+       static synfig::String get_shadow_directory();
+
+       bool recovery_needed()const;
+       bool recover(int& number_recovered);
+
+       void normal_shutdown();
+
+       void clear_backup(synfig::Canvas::Handle canvas);
+}; // END of class AutoRecover
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/canvasoptions.cpp b/synfig-studio/src/gui/canvasoptions.cpp
new file mode 100644 (file)
index 0000000..dfc15ed
--- /dev/null
@@ -0,0 +1,215 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file canvasoptions.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "canvasoptions.h"
+#include <gtkmm/frame.h>
+#include <gtkmm/table.h>
+#include <gtkmm/label.h>
+#include <gtkmm/notebook.h>
+#include <gtkmm/alignment.h>
+#include "canvasview.h"
+#include "workarea.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+CanvasOptions::CanvasOptions(etl::loose_handle<CanvasView> canvas_view):
+       Gtk::Dialog(_("Canvas Options"),*canvas_view,false,true),
+       canvas_view_(canvas_view),
+       toggle_grid_snap(_("_Snap to grid"), true),
+       toggle_grid_show(_("S_how grid"), true),
+       toggle_time_snap(_("Snap to _frame"), true)
+{
+       vector_grid_size.set_canvas(canvas_view->get_canvas());
+
+       Gtk::Alignment *dialogPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
+       dialogPadding->set_padding(12, 12, 12, 12);
+
+       Gtk::Notebook *notebook=manage(new class Gtk::Notebook());
+       dialogPadding->add(*notebook);
+
+       toggle_grid_snap.signal_toggled().connect(sigc::mem_fun(*this, &studio::CanvasOptions::on_grid_snap_toggle));
+       toggle_grid_show.signal_toggled().connect(sigc::mem_fun(*this, &studio::CanvasOptions::on_grid_show_toggle));
+
+       Gtk::Alignment *gridPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
+       gridPadding->set_padding(12, 12, 12, 12);
+       notebook->append_page(*gridPadding, _("Grid"));
+
+       Gtk::VBox *gridBox = manage(new Gtk::VBox(false, 12));
+       gridPadding->add(*gridBox);
+
+       Gtk::Table *gridTable = manage(new Gtk::Table(3, 2, false));
+       gridTable->set_row_spacings(6);
+       gridTable->set_col_spacings(12);
+       gridBox->pack_start(*gridTable, false, false, 0);
+
+       Gtk::Label *gridSizeLabel = manage(new Gtk::Label(_("_Grid size"), true));
+       gridSizeLabel->set_alignment(0, 0.5);
+       gridSizeLabel->set_mnemonic_widget(vector_grid_size);
+
+       toggle_grid_show.set_alignment(0, 0.5);
+       toggle_grid_snap.set_alignment(0, 0.5);
+
+       gridTable->attach(*gridSizeLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       gridTable->attach(vector_grid_size, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       gridTable->attach(toggle_grid_show, 0, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       gridTable->attach(toggle_grid_snap, 0, 2, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+       Gtk::Alignment *timePadding = manage(new Gtk::Alignment(0, 0, 1, 1));
+       timePadding->set_padding(12, 12, 12, 12);
+       notebook->append_page(*timePadding, _("Time"));
+
+       Gtk::VBox *timeBox = manage(new Gtk::VBox(false, 12));
+       timePadding->add(*timeBox);
+
+       timeBox->pack_start(toggle_time_snap, false, false, 0);
+
+       Gtk::Alignment *unitPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
+       unitPadding->set_padding(12, 12, 12, 12);
+       notebook->append_page(*unitPadding, _("Units"));
+       unitPadding->add(*manage(new Gtk::Label(_("Not yet implemented!"))));
+
+       Gtk::Button *ok_button(manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))));
+       ok_button->show();
+       add_action_widget(*ok_button,2);
+       ok_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasOptions::on_ok_pressed));
+
+       Gtk::Button *apply_button(manage(new class Gtk::Button(Gtk::StockID("gtk-apply"))));
+       apply_button->show();
+       add_action_widget(*apply_button,1);
+       apply_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasOptions::on_apply_pressed));
+
+       Gtk::Button *cancel_button(manage(new class Gtk::Button(Gtk::StockID("gtk-close"))));
+       cancel_button->show();
+       add_action_widget(*cancel_button,0);
+       cancel_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasOptions::on_cancel_pressed));
+
+       //set_default_response(1);
+
+
+       get_vbox()->pack_start(*dialogPadding);
+       get_vbox()->show_all();
+
+       signal_show().connect(sigc::mem_fun(*this, &studio::CanvasOptions::refresh));
+
+       vector_grid_size.set_digits(5);
+
+       update_title();
+}
+
+CanvasOptions::~CanvasOptions()
+{
+}
+
+void
+CanvasOptions::update_title()
+{
+       set_title(_("Options")+String(" - ")+canvas_view_->get_canvas()->get_name());
+}
+
+void
+CanvasOptions::refresh()
+{
+       if(canvas_view_->work_area->grid_status())
+               toggle_grid_show.set_active(true);
+       else
+               toggle_grid_show.set_active(false);
+
+       if(canvas_view_->work_area->get_grid_snap())
+               toggle_grid_snap.set_active(true);
+       else
+               toggle_grid_snap.set_active(false);
+
+       vector_grid_size.set_value(canvas_view_->work_area->get_grid_size());
+
+       tooltips.set_tip(toggle_time_snap,_("Not yet implemented"));
+       toggle_time_snap.set_sensitive(false);
+
+       update_title();
+}
+
+void
+CanvasOptions::on_grid_snap_toggle()
+{
+}
+
+void
+CanvasOptions::on_grid_show_toggle()
+{
+}
+
+void
+CanvasOptions::on_apply_pressed()
+{
+       canvas_view_->set_grid_snap_toggle(toggle_grid_snap.get_active());
+       if(toggle_grid_snap.get_active())
+               canvas_view_->work_area->enable_grid_snap();
+       else
+               canvas_view_->work_area->disable_grid_snap();
+
+       canvas_view_->set_grid_show_toggle(toggle_grid_show.get_active());
+       if(toggle_grid_show.get_active())
+               canvas_view_->work_area->enable_grid();
+       else
+               canvas_view_->work_area->disable_grid();
+
+       canvas_view_->work_area->set_grid_size(vector_grid_size.get_value());
+}
+
+void
+CanvasOptions::on_ok_pressed()
+{
+       on_apply_pressed();
+       hide();
+}
+
+void
+CanvasOptions::on_cancel_pressed()
+{
+       refresh();
+       hide();
+}
diff --git a/synfig-studio/src/gui/canvasoptions.h b/synfig-studio/src/gui/canvasoptions.h
new file mode 100644 (file)
index 0000000..452ab3f
--- /dev/null
@@ -0,0 +1,82 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file canvasoptions.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_GTKMM_CANVASOPTIONS_H
+#define __SYNFIG_GTKMM_CANVASOPTIONS_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/tooltips.h>
+#include <gtkmm/table.h>
+#include <gtkmm/entry.h>
+#include <gtkmm/tooltips.h>
+#include "widget_value.h"
+#include "widget_vector.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 CanvasView;
+
+class CanvasOptions  :  public Gtk::Dialog
+{
+       Gtk::Tooltips tooltips;
+
+       etl::loose_handle<CanvasView> canvas_view_;
+
+       Gtk::CheckButton toggle_grid_snap;
+       Gtk::CheckButton toggle_grid_show;
+
+       Widget_Vector vector_grid_size;
+
+       Gtk::CheckButton toggle_time_snap;
+
+public:
+       CanvasOptions(etl::loose_handle<CanvasView> canvas_view);
+       ~CanvasOptions();
+
+       void refresh();
+       void update_title();
+private:
+
+       void on_grid_snap_toggle();
+       void on_grid_show_toggle();
+
+       void on_ok_pressed();
+       void on_apply_pressed();
+       void on_cancel_pressed();
+}; // END of class CanvasOptions
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/canvasproperties.cpp b/synfig-studio/src/gui/canvasproperties.cpp
new file mode 100644 (file)
index 0000000..d095331
--- /dev/null
@@ -0,0 +1,255 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file canvasproperties.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 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 <config.h>
+#endif
+
+#include "canvasproperties.h"
+#include <gtkmm/frame.h>
+#include <gtkmm/table.h>
+#include <gtkmm/label.h>
+#include <gtkmm/alignment.h>
+#include <synfigapp/canvasinterface.h>
+#include "metadatatreestore.h"
+#include <gtkmm/treeview.h>
+#include <gtkmm/scrolledwindow.h>
+#include "app.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+CanvasProperties::CanvasProperties(Gtk::Window& parent,etl::handle<synfigapp::CanvasInterface> canvas_interface):
+       Gtk::Dialog(_("Canvas Properties"),parent,false,true),
+       canvas_interface_(canvas_interface)
+{
+       widget_rend_desc.show();
+       widget_rend_desc.signal_changed().connect(sigc::mem_fun(*this,&studio::CanvasProperties::on_rend_desc_changed));
+
+       Gtk::Alignment *dialogPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
+       dialogPadding->set_padding(12, 12, 12, 12);
+       get_vbox()->pack_start(*dialogPadding, false, false, 0);
+
+       Gtk::VBox *dialogBox = manage(new Gtk::VBox(false, 12));
+       dialogPadding->add(*dialogBox);
+
+       Gtk::Frame *info_frame=manage(new Gtk::Frame(_("Canvas Info")));
+       info_frame->set_shadow_type(Gtk::SHADOW_NONE);
+       ((Gtk::Label *) info_frame->get_label_widget())->set_markup(_("<b>Canvas Info</b>"));
+       dialogBox->pack_start(*info_frame, false, false, 0);
+
+       Gtk::Alignment *infoPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
+       infoPadding->set_padding(6, 0, 24, 0);
+       info_frame->add(*infoPadding);
+
+       Gtk::Table *info_table=manage(new Gtk::Table(2,2,false));
+       info_table->set_row_spacings(6);
+       info_table->set_col_spacings(12);
+       infoPadding->add(*info_table);
+
+       // The root canvas doesn't have an ID, so don't
+       // display it if this is a root canvas.
+       if(!canvas_interface_->get_canvas()->is_root())
+       {
+               Gtk::Label *idLabel = manage(new Gtk::Label(_("_ID"), true));
+               idLabel->set_alignment(0, 0.5);
+               idLabel->set_mnemonic_widget(entry_id);
+               info_table->attach(*idLabel, 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+               info_table->attach(entry_id, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       }
+       Gtk::Label *nameLabel = manage(new Gtk::Label(_("_Name"), true));
+       nameLabel->set_alignment(0, 0.5);
+       nameLabel->set_mnemonic_widget(entry_name);
+       Gtk::Label *descriptionLabel = manage(new Gtk::Label(_("_Description"), true));
+       descriptionLabel->set_alignment(0, 0.5);
+       descriptionLabel->set_mnemonic_widget(entry_description);
+       info_table->attach(*nameLabel, 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       info_table->attach(*descriptionLabel, 0, 1, 2, 3, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       info_table->attach(entry_name, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       info_table->attach(entry_description, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+
+       dialogBox->pack_start(widget_rend_desc, false, false, 0);
+
+       canvas_interface_->signal_rend_desc_changed().connect(sigc::mem_fun(*this,&studio::CanvasProperties::refresh));
+       canvas_interface_->signal_id_changed().connect(sigc::mem_fun(*this,&studio::CanvasProperties::refresh));
+
+       Gtk::Button *ok_button(manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))));
+       ok_button->show();
+       add_action_widget(*ok_button,2);
+       ok_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasProperties::on_ok_pressed));
+
+       Gtk::Button *apply_button(manage(new class Gtk::Button(Gtk::StockID("gtk-apply"))));
+       apply_button->show();
+       add_action_widget(*apply_button,1);
+       apply_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasProperties::on_apply_pressed));
+
+       Gtk::Button *cancel_button(manage(new class Gtk::Button(Gtk::StockID("gtk-close"))));
+       cancel_button->show();
+       add_action_widget(*cancel_button,0);
+       cancel_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasProperties::on_cancel_pressed));
+
+       //set_default_response(1);
+
+       get_vbox()->show_all();
+       refresh();
+
+       update_title();
+}
+
+Gtk::Widget&
+CanvasProperties::create_meta_data_view()
+{
+       MetaDataTreeStore::Model model;
+       meta_data_tree_view=(manage(new class Gtk::TreeView()));
+
+       meta_data_tree_view->append_column(_("Key"),model.key);
+       meta_data_tree_view->append_column_editable(_("Data"),model.data);
+       meta_data_tree_view->set_model(MetaDataTreeStore::create(canvas_interface_));
+       meta_data_tree_view->set_rules_hint();
+       meta_data_tree_view->show();
+
+       Gtk::ScrolledWindow *scrolledwindow = manage(new class Gtk::ScrolledWindow());
+       scrolledwindow->set_flags(Gtk::CAN_FOCUS);
+       scrolledwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+       scrolledwindow->add(*meta_data_tree_view);
+       scrolledwindow->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
+       scrolledwindow->show();
+
+
+
+       Gtk::Table *table=manage(new Gtk::Table());
+       table->attach(*scrolledwindow, 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       Gtk::Button* button_add(manage(new Gtk::Button(Gtk::StockID("gtk-add"))));
+       button_add->show();
+       button_add->signal_clicked().connect(sigc::mem_fun(*this,&CanvasProperties::on_button_meta_data_add));
+       table->attach(*button_add, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+
+       Gtk::Button* button_delete(manage(new Gtk::Button(Gtk::StockID("gtk-delete"))));
+       button_delete->show();
+       button_delete->signal_clicked().connect(sigc::mem_fun(*this,&CanvasProperties::on_button_meta_data_delete));
+       table->attach(*button_delete, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+
+       table->show();
+       return *table;
+}
+
+void
+CanvasProperties::on_button_meta_data_add()
+{
+       synfig::String key;
+       if(App::dialog_entry(_("New MetaData Entry"), _("Please enter the name of the key"),key) && !key.empty())
+       {
+               canvas_interface_->set_meta_data(key," ");
+       }
+
+}
+
+void
+CanvasProperties::on_button_meta_data_delete()
+{
+}
+
+void
+CanvasProperties::update_title()
+{
+       set_title(_("Properties")+String(" - ")+canvas_interface_->get_canvas()->get_name());
+}
+
+void
+CanvasProperties::refresh()
+{
+       widget_rend_desc.set_rend_desc(canvas_interface_->get_canvas()->rend_desc());
+       entry_id.set_text(canvas_interface_->get_canvas()->get_id());
+       entry_name.set_text(canvas_interface_->get_canvas()->get_name());
+       entry_description.set_text(canvas_interface_->get_canvas()->get_description());
+
+       dirty_rend_desc=false;
+
+       update_title();
+}
+
+CanvasProperties::~CanvasProperties()
+{
+}
+
+void
+CanvasProperties::on_rend_desc_changed()
+{
+       dirty_rend_desc=true;
+}
+
+void
+CanvasProperties::on_apply_pressed()
+{
+       synfigapp::Action::PassiveGrouper group(canvas_interface_->get_instance().get(),_("Edit Canvas Properties"));
+
+       // fetch these three values first, because each set_() method refreshes the dialog with currently set values
+       String id = entry_id.get_text();
+       String name = entry_name.get_text();
+       String description = entry_description.get_text();
+
+       // do this first, because the other three cause the dialog to be refreshed with currently set values
+       if (dirty_rend_desc) canvas_interface_->set_rend_desc(widget_rend_desc.get_rend_desc());
+
+       if (id != canvas_interface_->get_canvas()->get_id() && !id.empty())             canvas_interface_->set_id(id);
+       if (name != canvas_interface_->get_canvas()->get_name())                                canvas_interface_->set_name(name);
+       if (description != canvas_interface_->get_canvas()->get_description())  canvas_interface_->set_description(description);
+
+       dirty_rend_desc=false;
+}
+
+void
+CanvasProperties::on_ok_pressed()
+{
+       on_apply_pressed();
+       hide();
+}
+
+void
+CanvasProperties::on_cancel_pressed()
+{
+       refresh();
+       hide();
+}
diff --git a/synfig-studio/src/gui/canvasproperties.h b/synfig-studio/src/gui/canvasproperties.h
new file mode 100644 (file)
index 0000000..3a32d40
--- /dev/null
@@ -0,0 +1,87 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file canvasproperties.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_GTKMM_CANVASPROPERTIES_H
+#define __SYNFIG_GTKMM_CANVASPROPERTIES_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <ETL/handle>
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/tooltips.h>
+#include <gtkmm/table.h>
+#include <gtkmm/entry.h>
+#include <gtkmm/tooltips.h>
+
+#include "renddesc.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 Gtk { class TreeView; };
+namespace synfigapp { class CanvasInterface; };
+
+namespace studio
+{
+class CanvasProperties  :  public Gtk::Dialog
+{
+       Gtk::Tooltips tooltips;
+
+       etl::handle<synfigapp::CanvasInterface> canvas_interface_;
+       Widget_RendDesc widget_rend_desc;
+       Gtk::Entry entry_id;
+       Gtk::Entry entry_name;
+       Gtk::Entry entry_description;
+
+       bool dirty_rend_desc;
+
+       Gtk::TreeView* meta_data_tree_view;
+       void on_button_meta_data_add();
+       void on_button_meta_data_delete();
+
+public:
+       CanvasProperties(Gtk::Window& parent,etl::handle<synfigapp::CanvasInterface> canvas_interface);
+       ~CanvasProperties();
+
+       void refresh();
+       void update_title();
+private:
+       void on_rend_desc_changed();
+
+       Gtk::Widget& create_meta_data_view();
+
+       void on_ok_pressed();
+       void on_apply_pressed();
+       void on_cancel_pressed();
+}; // END of class CanvasProperties
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/canvastreestore.cpp b/synfig-studio/src/gui/canvastreestore.cpp
new file mode 100644 (file)
index 0000000..f49d7a3
--- /dev/null
@@ -0,0 +1,622 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file canvastreestore.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 <config.h>
+#endif
+
+#include "canvastreestore.h"
+#include <synfig/valuenode.h>
+#include "iconcontroller.h"
+#include <synfig/valuenode_timedswap.h>
+#include <synfig/valuenode_animated.h>
+#include <gtkmm/button.h>
+#include <synfigapp/instance.h>
+#include "cellrenderer_value.h"
+#include "cellrenderer_timetrack.h"
+#include <ETL/clock>
+
+#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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+static CanvasTreeStore::Model& ModelHack()
+{
+       static CanvasTreeStore::Model* model(0);
+       if(!model)model=new CanvasTreeStore::Model;
+       return *model;
+}
+
+CanvasTreeStore::CanvasTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_):
+       Gtk::TreeStore(ModelHack()),
+       canvas_interface_               (canvas_interface_)
+{
+}
+
+CanvasTreeStore::~CanvasTreeStore()
+{
+}
+
+void
+CanvasTreeStore::get_value_vfunc(const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const
+{
+       if(column==model.value.index())
+       {
+               synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
+
+               Glib::Value<synfig::ValueBase> x;
+               g_value_init(x.gobj(),x.value_type());
+
+               if(!value_desc)
+               {
+                       x.set(ValueBase());
+               }
+               else
+               if(value_desc.is_const())
+                       x.set(value_desc.get_value());
+               else
+               if(value_desc.is_value_node())
+                       x.set((*value_desc.get_value_node())(canvas_interface()->get_time()));
+               else
+               {
+                       synfig::error(__FILE__":%d: Unable to figure out value",__LINE__);
+                       return;
+               }
+
+               g_value_init(value.gobj(),x.value_type());
+               g_value_copy(x.gobj(),value.gobj());
+       }
+       else
+       if(column==model.is_value_node.index())
+       {
+               synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
+
+               Glib::Value<bool> x;
+               g_value_init(x.gobj(),x.value_type());
+
+               x.set(value_desc && value_desc.is_value_node());
+
+               g_value_init(value.gobj(),x.value_type());
+               g_value_copy(x.gobj(),value.gobj());
+       }
+       else
+       if(column==model.is_shared.index())
+       {
+               synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
+
+               Glib::Value<bool> x;
+               g_value_init(x.gobj(),x.value_type());
+
+               x.set(value_desc.is_value_node() && value_desc.get_value_node()->rcount()>1);
+
+               g_value_init(value.gobj(),x.value_type());
+               g_value_copy(x.gobj(),value.gobj());
+       }
+       else
+       if(column==model.is_exported.index())
+       {
+               synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
+
+               Glib::Value<bool> x;
+               g_value_init(x.gobj(),x.value_type());
+
+               x.set(value_desc.is_value_node() && value_desc.get_value_node()->is_exported());
+
+               g_value_init(value.gobj(),x.value_type());
+               g_value_copy(x.gobj(),value.gobj());
+       }
+       else
+       if(column==model.is_canvas.index())
+       {
+               synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
+
+               Glib::Value<bool> x;
+               g_value_init(x.gobj(),x.value_type());
+
+               x.set(!value_desc && (Canvas::Handle)(*iter)[model.canvas]);
+
+               g_value_init(value.gobj(),x.value_type());
+               g_value_copy(x.gobj(),value.gobj());
+       }
+       else
+       if(column==model.id.index())
+       {
+               synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
+
+               Glib::Value<Glib::ustring> x;
+               g_value_init(x.gobj(),x.value_type());
+
+               if(value_desc && value_desc.is_value_node())
+                       x.set(value_desc.get_value_node()->get_id());
+               else if(!value_desc && Canvas::Handle((*iter)[model.canvas]))
+                       x.set(Canvas::Handle((*iter)[model.canvas])->get_id());
+               else
+                       return Gtk::TreeStore::get_value_vfunc(iter,column,value);
+
+               g_value_init(value.gobj(),x.value_type());
+               g_value_copy(x.gobj(),value.gobj());
+       }
+       else
+       if(column==model.is_editable.index())
+       {
+               synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
+
+               Glib::Value<bool> x;
+               g_value_init(x.gobj(),x.value_type());
+
+               x.set(!value_desc.is_value_node() || synfigapp::is_editable(value_desc.get_value_node()));
+
+               g_value_init(value.gobj(),x.value_type());
+               g_value_copy(x.gobj(),value.gobj());
+       }
+       else
+       if(column==model.type.index())
+       {
+               synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
+
+               Glib::Value<Glib::ustring> x;
+               g_value_init(x.gobj(),x.value_type());
+
+               // Set the type
+               if(!value_desc)
+               {
+                       if((*iter)[model.is_canvas])
+                               x.set(_("Canvas"));
+               }
+               else
+               {
+                       if(!value_desc.is_value_node() || value_desc.get_value_node()->get_name()=="constant")
+                       {
+                               x.set(ValueBase::type_local_name(value_desc.get_value_type()));
+                       }
+                       else
+                       {
+                               x.set(value_desc.get_value_node()->get_local_name());
+                       }
+               }
+
+               g_value_init(value.gobj(),x.value_type());
+               g_value_copy(x.gobj(),value.gobj());
+       }
+       else
+       if(column==model.label.index())
+       {
+               synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
+
+               Glib::Value<Glib::ustring> x;
+               g_value_init(x.gobj(),x.value_type());
+
+               // Set the type
+               if(!value_desc)
+               {
+                       Canvas::Handle canvas((*iter)[model.canvas]);
+                       if(canvas)
+                       {
+                               if(!canvas->get_id().empty())
+                                       x.set(canvas->get_id());
+                               else
+                               if(!canvas->get_name().empty())
+                                       x.set(canvas->get_name());
+                               else
+                                       x.set(_("[Unnamed]"));
+                               x.set(_("Canvas"));
+                       }
+                       return Gtk::TreeStore::get_value_vfunc(iter,column,value);
+               }
+               else
+               {
+                       ValueNode::Handle value_node=value_desc.get_value_node();
+
+                       // Setup the row's label
+                       if(value_node->get_id().empty())
+                               x.set(Glib::ustring((*iter)[model.name]));
+                       else if(Glib::ustring((*iter)[model.name]).empty())
+                               x.set(value_node->get_id());
+                       else
+                               x.set(Glib::ustring((*iter)[model.name])+" ("+value_node->get_id()+')');
+               }
+
+               g_value_init(value.gobj(),x.value_type());
+               g_value_copy(x.gobj(),value.gobj());
+       }
+       else
+       if(column==model.icon.index())
+       {
+               synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
+               if(!value_desc)
+                       return Gtk::TreeStore::get_value_vfunc(iter,column,value);
+
+               Glib::Value<Glib::RefPtr<Gdk::Pixbuf> > x;
+               g_value_init(x.gobj(),x.value_type());
+
+               x.set(get_tree_pixbuf(value_desc.get_value_type()));
+
+               g_value_init(value.gobj(),x.value_type());
+               g_value_copy(x.gobj(),value.gobj());
+       }
+       else
+               Gtk::TreeStore::get_value_vfunc(iter,column,value);
+}
+
+bool
+CanvasTreeStore::find_first_value_desc(const synfigapp::ValueDesc& value_desc, Gtk::TreeIter& iter)
+{
+       iter=children().begin();
+       while(iter && value_desc!=(*iter)[model.value_desc])
+       {
+               if(!iter->children().empty())
+               {
+                       Gtk::TreeIter iter2(iter->children().begin());
+                       //! \todo confirm that the && should be done before the ||
+                       if((iter2 && value_desc==(*iter2)[model.value_desc]) || find_next_value_desc(value_desc, iter2))
+                       {
+                               iter=iter2;
+                               return true;
+                       }
+               }
+               Gtk::TreeIter iter2(++iter);
+               if(!iter2)
+                       iter==iter->parent();
+               else
+                       iter=iter2;
+       }
+       return (bool)iter && value_desc==(*iter)[model.value_desc];
+}
+
+bool
+CanvasTreeStore::find_next_value_desc(const synfigapp::ValueDesc& value_desc, Gtk::TreeIter& iter)
+{
+       if(!iter) return find_first_value_desc(value_desc,iter);
+
+       if(iter) do {
+               if(!iter->children().empty())
+               {
+                       Gtk::TreeIter iter2(iter->children().begin());
+                       //! \todo confirm that the && should be done before the ||
+                       if((iter2 && value_desc==(*iter2)[model.value_desc]) || find_next_value_desc(value_desc, iter2))
+                       {
+                               iter=iter2;
+                               return true;
+                       }
+               }
+               Gtk::TreeIter iter2(++iter);
+               if(!iter2)
+               {
+                       iter==iter->parent();
+                       if(iter)++iter;
+               }
+               else
+                       iter=iter2;
+       } while(iter && value_desc!=(*iter)[model.value_desc]);
+       return (bool)iter && value_desc==(*iter)[model.value_desc];
+}
+
+bool
+CanvasTreeStore::find_first_value_node(const synfig::ValueNode::Handle& value_node, Gtk::TreeIter& iter)
+{
+       iter=children().begin();
+       while(iter && value_node!=(ValueNode::Handle)(*iter)[model.value_node])
+       {
+               if(!iter->children().empty())
+               {
+                       Gtk::TreeIter iter2(iter->children().begin());
+                       //! \todo confirm that the && should be done before the ||
+                       if((iter2 && value_node==(ValueNode::Handle)(*iter2)[model.value_node]) || find_next_value_node(value_node, iter2))
+                       {
+                               iter=iter2;
+                               return true;
+                       }
+               }
+               Gtk::TreeIter iter2(++iter);
+               if(!iter2)
+                       iter==iter->parent();
+               else
+                       iter=iter2;
+       }
+       return (bool)iter && value_node==(ValueNode::Handle)(*iter)[model.value_node];
+}
+
+bool
+CanvasTreeStore::find_next_value_node(const synfig::ValueNode::Handle& value_node, Gtk::TreeIter& iter)
+{
+       if(!iter) return find_first_value_node(value_node,iter);
+
+       if(iter) do {
+               if(!iter->children().empty())
+               {
+                       Gtk::TreeIter iter2(iter->children().begin());
+                       //! \todo confirm that the && should be done before the ||
+                       if((iter2 && value_node==(ValueNode::Handle)(*iter2)[model.value_node]) || find_next_value_node(value_node, iter2))
+                       {
+                               iter=iter2;
+                               return true;
+                       }
+               }
+               Gtk::TreeIter iter2(++iter);
+               if(!iter2)
+               {
+                       iter==iter->parent();
+                       if(iter)++iter;
+               }
+               else
+                       iter=iter2;
+       } while(iter && value_node!=(ValueNode::Handle)(*iter)[model.value_node]);
+       return (bool)iter && value_node==(ValueNode::Handle)(*iter)[model.value_node];
+}
+
+void
+CanvasTreeStore::set_row(Gtk::TreeRow row,synfigapp::ValueDesc value_desc, bool do_children)
+{
+       Gtk::TreeModel::Children children = row.children();
+       while(!children.empty() && erase(children.begin()))
+               ;
+
+       row[model.value_desc]=value_desc;
+       try
+       {
+               //row[model.icon] = get_tree_pixbuf(value_desc.get_value_type());
+
+               if(value_desc.is_value_node())
+               {
+                       ValueNode::Handle value_node=value_desc.get_value_node();
+
+                       assert(value_node);
+
+                       row[model.value_node] = value_node;
+                       //row[model.is_canvas] = false;
+                       //row[model.is_value_node] = true;
+                       //row[model.is_editable] = synfigapp::is_editable(value_node);
+                       //row[model.id]=value_node->get_id();
+
+                       // Set the canvas
+                       if(value_desc.parent_is_canvas())
+                               row[model.canvas]=value_desc.get_canvas();
+                       else
+                               row[model.canvas]=canvas_interface()->get_canvas();
+
+                       LinkableValueNode::Handle linkable;
+                       linkable=LinkableValueNode::Handle::cast_dynamic(value_node);
+
+                       if(linkable && do_children)
+                       {
+                               row[model.link_count] = linkable->link_count();
+                               for(int i=0;i<linkable->link_count();i++)
+                               {
+                                       Gtk::TreeRow child_row=*(append(row.children()));
+                                       child_row[model.link_id] = i;
+                                       child_row[model.canvas] = static_cast<Canvas::Handle>(row[model.canvas]);
+                                       child_row[model.name] = linkable->link_local_name(i);
+                                       set_row(child_row,synfigapp::ValueDesc(linkable,i));
+                               }
+                       }
+                       return;
+               }
+               else
+               {
+                       //row[model.is_value_node] = false;
+                       //row[model.is_editable] = true;
+                       //row[model.label] = Glib::ustring(row[model.name]);
+                       return;
+               }
+       }
+       catch(synfig::Exception::IDNotFound x)
+       {
+               synfig::error(__FILE__":%d: IDNotFound thrown",__LINE__);
+               erase(row);
+               return;
+       }
+
+       // We should never get to this point
+       assert(0);
+}
+
+void
+CanvasTreeStore::refresh_row(Gtk::TreeModel::Row &row, bool do_children)
+{
+       synfigapp::ValueDesc value_desc=row[model.value_desc];
+
+       if(value_desc)
+       {
+               if((bool)row[model.is_value_node] != value_desc.is_value_node() ||
+                       (!bool(row[model.is_value_node]) && row[model.link_count]!=0))
+               {
+                       set_row(row,value_desc,do_children);
+                       return;
+               }
+
+               if(row[model.is_value_node])
+               {
+                       ValueNode::Handle value_node(value_desc.get_value_node());
+
+                       if(ValueNode::Handle(row[model.value_node])!=value_node)
+                       {
+                               rebuild_row(row,do_children);
+                               return;
+                       }
+
+                       //row[model.id]=value_node->get_id();
+
+                       // Setup the row's label
+                       /*
+                       if(value_node->get_id().empty())
+                               row[model.label] = Glib::ustring(row[model.name]);
+                       else if(Glib::ustring(row[model.name]).empty())
+                               row[model.label] = value_node->get_id();
+                       else
+                               row[model.label] = Glib::ustring(row[model.name])+" ("+value_node->get_id()+')';
+                       */
+
+                       LinkableValueNode::Handle linkable;
+                       linkable=LinkableValueNode::Handle::cast_dynamic(value_node);
+                       if(do_children && linkable && ((int)row[model.link_count] != linkable->link_count()))
+                       {
+       //                      Gtk::TreeModel::Children children = row.children();
+       //                      while(!children.empty() && erase(children.begin()));
+
+                               set_row(row,value_desc);
+                               return;
+                       }
+               }
+               else
+               {
+                       //row[model.label] = Glib::ustring(row[model.name]);
+                       //row[model.is_value_node] = false;
+                       //row[model.is_editable] = true;
+               }
+       }
+       if(!do_children)
+               return;
+
+       Gtk::TreeModel::Children children = row.children();
+       Gtk::TreeModel::Children::iterator iter;
+
+       if(!children.empty())
+       for(iter = children.begin(); iter != children.end(); ++iter)
+       {
+               Gtk::TreeRow row=*iter;
+               refresh_row(row);
+       }
+}
+
+void
+CanvasTreeStore::rebuild_row(Gtk::TreeModel::Row &row, bool do_children)
+{
+       synfigapp::ValueDesc value_desc=(synfigapp::ValueDesc)row[model.value_desc];
+
+       if(value_desc && value_desc.get_value_node())
+       {
+               ValueNode::Handle value_node;
+               value_node=value_desc.get_value_node();
+
+               assert(value_node);if(!value_node)return;
+
+               if(value_node && value_node!=(ValueNode::Handle)row[model.value_node])
+               {
+//                     Gtk::TreeModel::Children children = row.children();
+//                     while(!children.empty() && erase(children.begin()));
+
+                       set_row(row,value_desc,do_children);
+                       return;
+               }
+
+               LinkableValueNode::Handle linkable;
+               linkable=LinkableValueNode::Handle::cast_dynamic(value_node);
+
+               if( do_children && linkable && (int)row[model.link_count] != linkable->link_count())
+               {
+//                     Gtk::TreeModel::Children children = row.children();
+//                     while(!children.empty() && erase(children.begin()));
+
+                       set_row(row,value_desc);
+                       return;
+               }
+
+               //if(!value_node)
+               //      value_node=row[model.value_node];
+
+               row[model.id]=value_node->get_id();
+
+               // Setup the row's label
+               if(value_node->get_id().empty())
+                       row[model.label] = Glib::ustring(row[model.name]);
+               else if(Glib::ustring(row[model.name]).empty())
+                       row[model.label] = value_node->get_id();
+               else
+                       row[model.label] = Glib::ustring(row[model.name])+" ("+value_node->get_id()+')';
+       }
+       else
+       {
+               row[model.label] = Glib::ustring(row[model.name]);
+               row[model.is_value_node] = false;
+               row[model.is_editable] = true;
+               Gtk::TreeModel::Children children = row.children();
+               while(!children.empty() && erase(children.begin()))
+                       ;
+       }
+       if(!do_children)
+               return;
+
+       Gtk::TreeModel::Children children = row.children();
+       Gtk::TreeModel::Children::iterator iter;
+       if(!children.empty())
+       for(iter = children.begin(); iter != children.end(); ++iter)
+       {
+               Gtk::TreeRow row=*iter;
+               rebuild_row(row);
+       }
+}
+
+CellRenderer_ValueBase*
+CanvasTreeStore::add_cell_renderer_value(Gtk::TreeView::Column* column)
+{
+       const CanvasTreeStore::Model model;
+
+       CellRenderer_ValueBase* ret;
+
+       ret=Gtk::manage( new CellRenderer_ValueBase() );
+
+       column->pack_start(*ret,true);
+       column->add_attribute(ret->property_value(), model.value);
+       column->add_attribute(ret->property_editable(), model.is_editable);
+       column->add_attribute(ret->property_canvas(), model.canvas);
+
+       return ret;
+}
+
+CellRenderer_TimeTrack*
+CanvasTreeStore::add_cell_renderer_value_node(Gtk::TreeView::Column* column)
+{
+       const CanvasTreeStore::Model model;
+
+       CellRenderer_TimeTrack* ret;
+
+       ret = Gtk::manage( new CellRenderer_TimeTrack() );
+
+       column->pack_start(*ret,true);
+       //column->add_attribute(ret->property_visible(), model.is_value_node);
+       column->add_attribute(ret->property_value_desc(), model.value_desc);
+       column->add_attribute(ret->property_canvas(), model.canvas);
+
+
+       return ret;
+}
diff --git a/synfig-studio/src/gui/canvastreestore.h b/synfig-studio/src/gui/canvastreestore.h
new file mode 100644 (file)
index 0000000..faed8b6
--- /dev/null
@@ -0,0 +1,195 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file canvastreestore.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_CANVASTREESTORE_H
+#define __SYNFIG_STUDIO_CANVASTREESTORE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/treestore.h>
+#include <synfigapp/canvasinterface.h>
+#include <gdkmm/pixbuf.h>
+#include <synfigapp/value_desc.h>
+#include <gtkmm/treeview.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 CellRenderer_TimeTrack;
+class CellRenderer_ValueBase;
+
+       enum ColumnID
+       {
+               COLUMNID_ID,
+               COLUMNID_VALUE,
+               COLUMNID_TIME_TRACK,
+               COLUMNID_TYPE,
+
+               COLUMNID_END                    //!< \internal
+       };
+#define        COLUMNID_NAME COLUMNID_ID
+
+class CanvasTreeStore : virtual public Gtk::TreeStore
+{
+       /*
+ -- ** -- P U B L I C   T Y P E S ---------------------------------------------
+       */
+
+public:
+
+       class Model : public Gtk::TreeModel::ColumnRecord
+       {
+       public:
+               Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
+               Gtk::TreeModelColumn<Glib::ustring> label;
+               Gtk::TreeModelColumn<Glib::ustring> name;
+               Gtk::TreeModelColumn<Glib::ustring> id;
+
+               Gtk::TreeModelColumn<synfig::Canvas::Handle> canvas;
+               Gtk::TreeModelColumn<bool> is_canvas;
+
+               Gtk::TreeModelColumn<synfig::ValueNode::Handle> value_node;
+               Gtk::TreeModelColumn<bool> is_value_node;
+               Gtk::TreeModelColumn<synfig::ValueBase> value;
+               Gtk::TreeModelColumn<Glib::ustring> type;
+               Gtk::TreeModelColumn<int> link_id;
+               Gtk::TreeModelColumn<int> link_count;
+
+               Gtk::TreeModelColumn<bool> is_editable;
+
+               Gtk::TreeModelColumn<bool> is_shared;
+               Gtk::TreeModelColumn<bool> is_exported;
+
+               Gtk::TreeModelColumn<synfigapp::ValueDesc> value_desc;
+
+               Gtk::TreeModelColumn<Glib::ustring> tooltip;
+
+               Model()
+               {
+                       add(value);
+                       add(name);
+                       add(label);
+                       add(icon);
+                       add(type);
+                       add(id);
+                       add(canvas);
+                       add(value_node);
+                       add(is_canvas);
+                       add(is_value_node);
+
+                       add(is_shared);
+                       add(is_exported);
+                       add(is_editable);
+                       add(value_desc);
+                       add(link_count);
+                       add(link_id);
+
+                       add(tooltip);
+               }
+       };
+
+       /*
+ -- ** -- P U B L I C  D A T A ------------------------------------------------
+       */
+
+public:
+
+       const Model model;
+
+       //std::multimap<etl::handle<ValueNode>, sigc::connection> connection_map;
+
+       /*
+ -- ** -- P R I V A T E   D A T A ---------------------------------------------
+       */
+
+private:
+
+       etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
+
+       /*
+ -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
+       */
+
+private:
+
+protected:
+       virtual void  get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const;
+
+       /*
+ -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
+       */
+
+private:
+
+       /*
+ -- ** -- P U B L I C   M E T H O D S -----------------------------------------
+       */
+
+public:
+
+       CanvasTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
+       ~CanvasTreeStore();
+
+       etl::loose_handle<synfigapp::CanvasInterface> canvas_interface() { return canvas_interface_; }
+       etl::loose_handle<const synfigapp::CanvasInterface> canvas_interface()const { return canvas_interface_; }
+
+       virtual void rebuild_row(Gtk::TreeModel::Row &row, bool do_children=true);
+
+       virtual void refresh_row(Gtk::TreeModel::Row &row, bool do_children=true);
+
+       virtual void set_row(Gtk::TreeRow row,synfigapp::ValueDesc value_desc, bool do_children=true);
+
+       bool find_first_value_desc(const synfigapp::ValueDesc& value_desc, Gtk::TreeIter& iter);
+       bool find_next_value_desc(const synfigapp::ValueDesc& value_desc, Gtk::TreeIter& iter);
+
+       bool find_first_value_node(const synfig::ValueNode::Handle& value_node, Gtk::TreeIter& iter);
+       bool find_next_value_node(const synfig::ValueNode::Handle& value_node, Gtk::TreeIter& iter);
+
+
+       static CellRenderer_ValueBase* add_cell_renderer_value(Gtk::TreeView::Column* column);
+
+       static CellRenderer_TimeTrack* add_cell_renderer_value_node(Gtk::TreeView::Column* column);
+
+       etl::loose_handle<synfigapp::CanvasInterface> get_canvas_interface()const { return canvas_interface_; }
+
+       virtual void on_value_node_changed(synfig::ValueNode::Handle value_node)=0;
+
+       /*
+ -- ** -- P R O T E C T E D   M E T H O D S -----------------------------------
+       */
+
+public:
+
+}; // END of class CanvasTreeStore
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/canvasview.cpp b/synfig-studio/src/gui/canvasview.cpp
new file mode 100644 (file)
index 0000000..f520ced
--- /dev/null
@@ -0,0 +1,4338 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file canvasview.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 2008 Chris Moore
+**     Copyright (c) 2009 Carlos López
+**     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 <config.h>
+#endif
+
+#include <sigc++/adaptors/hide.h>
+
+#include <ETL/clock>
+#include <sstream>
+#include <math.h>
+
+#include <gtkmm/paned.h>
+#include <gtkmm/scale.h>
+#include <gtkmm/dialog.h>
+#include <gtkmm/messagedialog.h>
+#include <gtkmm/treemodelsort.h>
+#include <gtkmm/buttonbox.h>
+#include <gtkmm/separator.h>
+
+#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_range.h>
+#include <synfig/valuenode_dynamiclist.h>
+#include <synfig/valuenode_twotone.h>
+#include <synfig/valuenode_stripes.h>
+#include <synfig/valuenode_blinecalctangent.h>
+#include <synfig/valuenode_blinecalcvertex.h>
+#include <synfig/valuenode_blinecalcwidth.h>
+#include <synfig/valuenode_bline.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 "keyframedial.h"
+
+#include <synfigapp/main.h>
+#include <synfigapp/inputdevice.h>
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+using namespace studio;
+using namespace sigc;
+
+/* === M A C R O S ========================================================= */
+
+#define GRAB_HINT_DATA(y)      { \
+               String x; \
+               if(synfigapp::Main::settings().get_value(String("pref.")+y+"_hints",x)) \
+               { \
+                       set_type_hint((Gdk::WindowTypeHint)atoi(x.c_str()));    \
+               } \
+       }
+
+#define DEFAULT_TIME_WINDOW_SIZE               (10.0)
+
+#ifndef SMALL_BUTTON
+#define SMALL_BUTTON(button,stockid,tooltip)   \
+       button = manage(new class Gtk::Button());       \
+       icon=manage(new Gtk::Image(Gtk::StockID(stockid),iconsize));    \
+       button->add(*icon);     \
+       tooltips.set_tip(*button,tooltip);      \
+       icon->set_padding(0,0);\
+       icon->show();   \
+       button->set_relief(Gtk::RELIEF_NONE); \
+       button->show()
+#endif
+
+#ifndef NORMAL_BUTTON
+#define NORMAL_BUTTON(button,stockid,tooltip)  \
+       button = manage(new class Gtk::Button());       \
+       icon=manage(new Gtk::Image(Gtk::StockID(stockid),Gtk::ICON_SIZE_BUTTON));       \
+       button->add(*icon);     \
+       tooltips.set_tip(*button,tooltip);      \
+       icon->set_padding(0,0);\
+       icon->show();   \
+       /*button->set_relief(Gtk::RELIEF_NONE);*/ \
+       button->show()
+#endif
+
+#define NEW_SMALL_BUTTON(x,y,z)        Gtk::Button *SMALL_BUTTON(x,y,z)
+
+#define NOT_IMPLEMENTED_SLOT sigc::mem_fun(*reinterpret_cast<studio::CanvasViewUIInterface*>(get_ui_interface().get()),&studio::CanvasViewUIInterface::not_implemented)
+
+#define SLOT_EVENT(x)  sigc::hide_return(sigc::bind(sigc::mem_fun(*this,&studio::CanvasView::process_event_key),x))
+
+/* === C L A S S E S ======================================================= */
+
+class studio::UniversalScrubber
+{
+       CanvasView *canvas_view;
+
+       bool            scrubbing;
+       etl::clock      scrub_timer;
+
+       sigc::connection end_scrub_connection;
+public:
+       UniversalScrubber(CanvasView *canvas_view):
+               canvas_view(canvas_view),
+               scrubbing(false)
+       {
+               canvas_view->canvas_interface()->signal_time_changed().connect(
+                       sigc::mem_fun(*this,&studio::UniversalScrubber::on_time_changed)
+               );
+       }
+
+       ~UniversalScrubber()
+       {
+               end_scrub_connection.disconnect();
+       }
+
+       void on_time_changed()
+       {
+               // Make sure we are changing the time quickly
+               // before we enable scrubbing
+               if(!scrubbing && scrub_timer()>1)
+               {
+                       scrub_timer.reset();
+                       return;
+               }
+
+               // If we aren't scrubbing already, enable it
+               if(!scrubbing)
+               {
+                       scrubbing=true;
+                       audio_container()->start_scrubbing(canvas_view->get_time());
+               }
+
+               // Reset the scrubber ender
+               end_scrub_connection.disconnect();
+               end_scrub_connection=Glib::signal_timeout().connect(
+                       sigc::bind_return(
+                               sigc::mem_fun(*this,&UniversalScrubber::end_of_scrubbing),
+                               false
+                       ),
+                       1000
+               );
+
+               // Scrub!
+               audio_container()->scrub(canvas_view->get_time());
+
+               scrub_timer.reset();
+       }
+
+       void end_of_scrubbing()
+       {
+               scrubbing=false;
+               audio_container()->stop_scrubbing();
+               scrub_timer.reset();
+       }
+
+       handle<AudioContainer> audio_container()
+       {
+               assert(canvas_view->audio);
+               return canvas_view->audio;
+       }
+};
+
+class studio::CanvasViewUIInterface : public synfigapp::UIInterface
+{
+       CanvasView *view;
+
+public:
+
+       CanvasViewUIInterface(CanvasView *view):
+               view(view)
+       {
+               view->statusbar->push(_("Idle"));
+       }
+
+       ~CanvasViewUIInterface()
+       {
+               //view->statusbar->pop();
+               //view->progressbar->set_fraction(0);
+       }
+
+       virtual Response confirmation(const std::string &title,
+                       const std::string &primaryText,
+                       const std::string &secondaryText,
+                       const std::string &confirmPhrase,
+                       const std::string &cancelPhrase,
+                       Response defaultResponse=RESPONSE_OK)
+       {
+               view->present();
+               //while(studio::App::events_pending())studio::App::iteration(false);
+               Gtk::MessageDialog dialog(
+                       *view,                  // Parent
+                       primaryText,            // Message
+                       false,                  // Markup
+                       Gtk::MESSAGE_WARNING,   // Type
+                       Gtk::BUTTONS_NONE,      // Buttons
+                       true                    // Modal
+               );
+
+               if (! title.empty())
+                       dialog.set_title(title);
+               if (! secondaryText.empty())
+                       dialog.set_secondary_text(secondaryText);
+
+               dialog.add_button(cancelPhrase, RESPONSE_CANCEL);
+               dialog.add_button(confirmPhrase, RESPONSE_OK);
+               dialog.set_default_response(defaultResponse);
+
+               dialog.show_all();
+               return (Response) dialog.run();
+       }
+
+       virtual Response yes_no(const std::string &title, const std::string &message,Response dflt=RESPONSE_YES)
+       {
+               view->present();
+               //while(studio::App::events_pending())studio::App::iteration(false);
+               Gtk::Dialog dialog(
+                       title,          // Title
+                       *view,          // Parent
+                       true,           // Modal
+                       true            // use_separator
+               );
+               Gtk::Label label(message);
+               label.show();
+
+               dialog.get_vbox()->pack_start(label);
+               dialog.add_button(Gtk::StockID("gtk-yes"),RESPONSE_YES);
+               dialog.add_button(Gtk::StockID("gtk-no"),RESPONSE_NO);
+
+               dialog.set_default_response(dflt);
+               dialog.show();
+               return (Response)dialog.run();
+       }
+       virtual Response yes_no_cancel(const std::string &title, const std::string &message,Response dflt=RESPONSE_YES)
+       {
+               view->present();
+               //while(studio::App::events_pending())studio::App::iteration(false);
+               Gtk::Dialog dialog(
+                       title,          // Title
+                       *view,          // Parent
+                       true,           // Modal
+                       true            // use_separator
+               );
+               Gtk::Label label(message);
+               label.show();
+
+               dialog.get_vbox()->pack_start(label);
+               dialog.add_button(Gtk::StockID("gtk-yes"),RESPONSE_YES);
+               dialog.add_button(Gtk::StockID("gtk-no"),RESPONSE_NO);
+               dialog.add_button(Gtk::StockID("gtk-cancel"),RESPONSE_CANCEL);
+
+               dialog.set_default_response(dflt);
+               dialog.show();
+               return (Response)dialog.run();
+       }
+       virtual Response ok_cancel(const std::string &title, const std::string &message,Response dflt=RESPONSE_OK)
+       {
+               view->present();
+               //while(studio::App::events_pending())studio::App::iteration(false);
+               Gtk::Dialog dialog(
+                       title,          // Title
+                       *view,          // Parent
+                       true,           // Modal
+                       true            // use_separator
+               );
+               Gtk::Label label(message);
+               label.show();
+
+               dialog.get_vbox()->pack_start(label);
+               dialog.add_button(Gtk::StockID("gtk-ok"),RESPONSE_OK);
+               dialog.add_button(Gtk::StockID("gtk-cancel"),RESPONSE_CANCEL);
+
+               dialog.set_default_response(dflt);
+               dialog.show();
+               return (Response)dialog.run();
+       }
+
+       virtual bool
+       task(const std::string &task)
+       {
+               if(!view->is_playing_)
+               {
+                       view->statusbar->pop();
+                       view->statusbar->push(task);
+               }
+               //while(studio::App::events_pending())studio::App::iteration(false);
+               if(view->cancel){return false;}
+               return true;
+       }
+
+       virtual bool
+       error(const std::string &err)
+       {
+               view->statusbar->push(_("ERROR"));
+
+               // If we are in the process of canceling,
+               // then just go ahead and return false --
+               // don't bother displaying a dialog
+               if(view->cancel)return false;
+               Gtk::MessageDialog dialog(*view, err, false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE, true);
+               dialog.show();
+               dialog.run();
+               view->statusbar->pop();
+               return true;
+       }
+
+       virtual bool
+       warning(const std::string &err)
+       {
+               view->statusbar->pop();
+               view->statusbar->push(err);
+
+               //while(studio::App::events_pending())studio::App::iteration(false);
+               if(view->cancel)return false;
+               return true;
+       }
+
+       virtual bool
+       amount_complete(int current, int total)
+       {
+               if(!view->is_playing_)
+               {
+                       if(!view->working_depth)
+                       {
+                               if(current)
+                                       view->stopbutton->set_sensitive(true);
+                               else
+                                       view->stopbutton->set_sensitive(false);
+                       }
+                       float x((float)current/(float)total);
+                       if(x<0)x=0;
+                       else if(x>1)x=1;
+                       view->progressbar->set_fraction(x);
+               }
+               //while(studio::App::events_pending())studio::App::iteration(false);
+               if(view->cancel){/*view->cancel=false;*/return false;}
+               return true;
+       }
+
+       void
+       not_implemented()
+       {
+               error(_("Feature not yet implemented"));
+       }
+};
+
+class studio::CanvasViewSelectionManager : public synfigapp::SelectionManager
+{
+       CanvasView *view;
+       CanvasView::LayerTreeModel layer_tree_model;
+       CanvasView::ChildrenTreeModel children_tree_model;
+
+public:
+       CanvasViewSelectionManager(CanvasView *view): view(view) { }
+
+private:
+       void _set_selected_layer(const synfig::Layer::Handle &layer)
+       {
+               view->layer_tree->select_layer(layer);
+/*
+               // Don't change the selection while we are busy
+               // I cannot remember exactly why I put this here...
+               // It musta been for some reason, but I cannot recall.
+               //if(App::Busy::count)
+               //      return;
+
+               if(view->layer_tree->get_selection()->get_selected())
+               {
+                       const Gtk::TreeRow row = *(view->layer_tree->get_selection()->get_selected());
+
+                       // Don't do anything if that layer is already selected
+                       if(layer == static_cast<synfig::Layer::Handle>(row[layer_tree_model.layer]))
+                               return;
+               }
+               Gtk::TreeModel::Children::iterator iter;
+               if(view->layer_tree_store()->find_layer_row(layer,iter))
+               {
+                       Gtk::TreePath path(iter);
+                       for(int i=path.get_depth();i;i--)
+                       {
+                               int j;
+                               path=Gtk::TreePath(iter);
+                               for(j=i;j;j--)
+                                       path.up();
+                               view->layer_tree->get_tree_view().expand_row(path,false);
+                       }
+                       view->layer_tree->get_tree_view().scroll_to_row(Gtk::TreePath(iter));
+                       view->layer_tree->get_selection()->select(iter);
+               }
+*/
+       }
+public:
+
+       //! Returns the number of layers selected.
+       virtual int get_selected_layer_count()const
+       {
+               return get_selected_layers().size();
+       }
+
+       //! Returns a list of the currently selected layers.
+       virtual LayerList get_selected_layers()const
+       {
+//             assert(view->layer_tree);
+
+               if(!view->layer_tree) { synfig::error("%s:%d canvas_view.layer_tree not defined!?", __FILE__, __LINE__); return LayerList(); }
+               return view->layer_tree->get_selected_layers();
+       }
+
+       //! Returns the first layer selected or an empty handle if none are selected.
+       virtual synfig::Layer::Handle get_selected_layer()const
+       {
+//             assert(view->layer_tree);
+
+               if(!view->layer_tree) { synfig::error("%s:%d canvas_view.layer_tree not defined!?", __FILE__, __LINE__); return 0; }
+               return view->layer_tree->get_selected_layer();
+       }
+
+       //! Sets which layers should be selected
+       virtual void set_selected_layers(const LayerList &layer_list)
+       {
+//             assert(view->layer_tree);
+
+               if(!view->layer_tree) { 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);
+
+               //view->queue_rebuild_ducks();
+       }
+
+       //! Sets which layer should be selected.
+       virtual void set_selected_layer(const synfig::Layer::Handle &layer)
+       {
+//             assert(view->layer_tree);
+
+               if(!view->layer_tree) { synfig::error("canvas_view.layer_tree not defined!?"); return; }
+               view->layer_tree->select_layer(layer);
+               //view->queue_rebuild_ducks();
+       }
+
+       //! Clears the layer selection list
+       virtual void clear_selected_layers()
+       {
+               if(!view->layer_tree) return;
+               view->layer_tree->clear_selected_layers();
+       }
+
+       //! Returns the number of value_nodes selected.
+       virtual int get_selected_children_count()const
+       {
+               return get_selected_children().size();
+       }
+
+       static inline void __child_grabber(const Gtk::TreeModel::iterator& iter, ChildrenList* ret)
+       {
+               const CanvasView::ChildrenTreeModel children_tree_model;
+               synfigapp::ValueDesc value_desc((*iter)[children_tree_model.value_desc]);
+               if(value_desc)
+                       ret->push_back(value_desc);
+       }
+
+       //! Returns a list of the currently selected value_nodes.
+       virtual ChildrenList get_selected_children()const
+       {
+               if(!view->children_tree) return ChildrenList();
+
+               Glib::RefPtr<Gtk::TreeSelection> selection=view->children_tree->get_selection();
+
+               if(!selection)
+                       return ChildrenList();
+
+               ChildrenList ret;
+
+               selection->selected_foreach_iter(
+                       sigc::bind(
+                               sigc::ptr_fun(
+                                       &studio::CanvasViewSelectionManager::__child_grabber
+                               ),
+                               &ret
+                       )
+               );
+
+               /*
+               Gtk::TreeModel::Children::iterator iter(view->children_tree_store()->children().begin());
+               iter++;
+               Gtk::TreeModel::Children children = iter->children();
+               for(iter = children.begin(); iter != children.end(); ++iter)
+               {
+                       Gtk::TreeModel::Row row = *iter;
+                       if(selection->is_selected(row))
+                               ret.push_back((synfigapp::ValueDesc)row[children_tree_model.value_desc]);
+               }
+               */
+               return ret;
+       }
+
+       //! Returns the first value_node selected or an empty handle if none are selected.
+       virtual ChildrenList::value_type get_selected_child()const
+       {
+               if(!view->children_tree) return ChildrenList::value_type();
+
+               ChildrenList children(get_selected_children());
+
+               if(children.empty())
+                       return ChildrenList::value_type();
+
+               return children.front();
+       }
+
+       //! Sets which value_nodes should be selected
+       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*/)
+       {
+               return;
+       }
+
+       //! Clears the value_node selection list
+       virtual void clear_selected_children()
+       {
+               return;
+       }
+
+       int get_selected_layer_parameter_count()const
+       {
+               return get_selected_layer_parameters().size();
+       }
+
+       LayerParamList get_selected_layer_parameters()const
+       {
+               if(!view->layer_tree) return LayerParamList();
+
+               Glib::RefPtr<Gtk::TreeSelection> selection=view->layer_tree->get_selection();
+
+               if(!selection)
+                       return LayerParamList();
+
+               LayerParamList ret;
+
+               Gtk::TreeModel::Children children = const_cast<CanvasView*>(view)->layer_tree_store()->children();
+               Gtk::TreeModel::Children::iterator iter;
+               for(iter = children.begin(); iter != children.end(); ++iter)
+               {
+                       Gtk::TreeModel::Row row = *iter;
+                       Gtk::TreeModel::Children::iterator iter;
+                       for(iter=row.children().begin();iter!=row.children().end();iter++)
+                       {
+                               Gtk::TreeModel::Row row = *iter;
+                               if(selection->is_selected(row))
+                                       ret.push_back(LayerParam(row[layer_tree_model.layer],(Glib::ustring)row[layer_tree_model.id]));
+                       }
+               }
+               return ret;
+       }
+
+       LayerParam get_selected_layer_parameter() const
+       {
+               if(!view->layer_tree) return LayerParam();
+               return get_selected_layer_parameters().front();
+       }
+
+       void set_selected_layer_parameters(const LayerParamList &/*layer_param_list*/)
+       {
+               return;
+       }
+
+       void set_selected_layer_param(const LayerParam &/*layer_param*/)
+       {
+               return;
+       }
+
+       void clear_selected_layer_parameters()
+       {
+               return;
+       }
+
+}; // END of class SelectionManager
+
+CanvasView::IsWorking::IsWorking(CanvasView &canvas_view_):
+       canvas_view_(canvas_view_)
+{
+       if(!canvas_view_.working_depth)
+               canvas_view_.stopbutton->set_sensitive(true);
+       canvas_view_.working_depth++;
+       canvas_view_.cancel=false;
+}
+
+CanvasView::IsWorking::~IsWorking()
+{
+       canvas_view_.working_depth--;
+       if(!canvas_view_.working_depth)
+               canvas_view_.stopbutton->set_sensitive(false);
+}
+
+CanvasView::IsWorking::operator bool()const
+{
+       if(canvas_view_.cancel)
+               return false;
+       return true;
+}
+
+/* === M E T H O D S ======================================================= */
+
+CanvasView::CanvasView(etl::loose_handle<Instance> instance,etl::handle<synfigapp::CanvasInterface> canvas_interface_):
+       smach_                                  (this),
+       instance_                               (instance),
+       canvas_interface_               (canvas_interface_),
+       //layer_tree_store_             (LayerTreeStore::create(canvas_interface_)),
+       //children_tree_store_  (ChildrenTreeStore::create(canvas_interface_)),
+       //keyframe_tree_store_  (KeyframeTreeStore::create(canvas_interface_)),
+       time_adjustment_                (0,0,25,0,0,0),
+       time_window_adjustment_ (0,0,25,0,0,0),
+       statusbar                               (manage(new class Gtk::Statusbar())),
+       quality_adjustment_             (8,1,10,1,1,0),
+       future_onion_adjustment_ (0,0,2,1,1,0),
+       past_onion_adjustment_  (0,0,2,1,1,0),
+
+       timeslider                              (new Widget_Timeslider),
+       widget_kf_list                  (new Widget_Keyframe_List),
+
+       ui_interface_                   (new CanvasViewUIInterface(this)),
+       selection_manager_              (new CanvasViewSelectionManager(this)),
+       is_playing_                             (false),
+
+       working_depth                   (0),
+       cancel                                  (false),
+
+       canvas_properties               (*this,canvas_interface_),
+       canvas_options                  (this),
+       render_settings                 (*this,canvas_interface_),
+       waypoint_dialog                 (*this,canvas_interface_->get_canvas()),
+       keyframe_dialog                 (*this,canvas_interface_),
+       preview_dialog                  (new Dialog_Preview),
+       sound_dialog                    (new Dialog_SoundSelect(*this,canvas_interface_))
+{
+       layer_tree=0;
+       children_tree=0;
+       duck_refresh_flag=true;
+       toggling_ducks_=false;
+       changing_resolution_=false;
+       updating_quality_=false;
+       toggling_show_grid=false;
+       toggling_snap_grid=false;
+       toggling_onion_skin=false;
+
+       disp_audio = new Widget_Sound();
+
+       //synfig::info("Canvasview: Entered constructor");
+       // Minor hack
+       get_canvas()->set_time(0);
+       //layer_tree_store_->rebuild();
+
+       // Set up the UI and Selection managers
+       canvas_interface()->set_ui_interface(get_ui_interface());
+       canvas_interface()->set_selection_manager(get_selection_manager());
+       rebuild_ducks_queued=false;
+
+       //notebook=manage(new class Gtk::Notebook());
+       //Gtk::VPaned *vpaned = manage(new class Gtk::VPaned());
+       //vpaned->pack1(*create_work_area(), Gtk::EXPAND|Gtk::SHRINK);
+       //vpaned->pack2(*notebook, Gtk::SHRINK);
+       //vpaned->show_all();
+
+       //notebook->show();
+
+       //notebook->append_page(*create_layer_tree(),_("Layers"));
+       //notebook->append_page(*create_children_tree(),_("Children"));
+       //notebook->append_page(*create_keyframe_tree(),_("Keyframes"));
+
+       //synfig::info("Canvasview: Before big chunk of allocation and tabling stuff");
+       //create all allocated stuff for this canvas
+       audio = new AudioContainer();
+
+       Gtk::Table *layout_table= manage(new class Gtk::Table(1, 4, false));
+       //layout_table->attach(*vpaned, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       layout_table->attach(*create_work_area(), 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       layout_table->attach(*create_display_bar(), 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       init_menus();
+       //layout_table->attach(*App::ui_manager()->get_widget("/menu-main"), 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+
+       layout_table->attach(*create_time_bar(), 0, 1, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       layout_table->attach(*create_status_bar(), 0, 1, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+
+       update_title();
+
+       layout_table->show();
+       add(*layout_table);
+
+       //set_transient_for(*App::toolbox);
+
+       smach_.set_default_state(&state_normal);
+
+       //synfig::info("Canvasview: Before Signals");
+       /*
+ --    ** -- Signals -------------------------------------------------------------
+       */
+
+       canvas_interface()->signal_dirty_preview().connect(sigc::mem_fun(*this,&studio::CanvasView::on_dirty_preview));
+       canvas_interface()->signal_mode_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::on_mode_changed));
+
+       canvas_interface()->signal_time_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::on_time_changed));
+
+       //canvas_interface()->signal_time_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::refresh_tables));
+       canvas_interface()->signal_id_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::on_id_changed));
+       canvas_interface()->signal_rend_desc_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::refresh_rend_desc));
+       waypoint_dialog.signal_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::on_waypoint_changed));
+       waypoint_dialog.signal_delete().connect(sigc::mem_fun(*this,&studio::CanvasView::on_waypoint_delete));
+
+       //MODIFIED TIME ADJUSTMENT STUFF....
+       time_window_adjustment().set_child_adjustment(&time_adjustment());
+       time_window_adjustment().signal_value_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::refresh_time_window));
+       time_adjustment().signal_value_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::time_was_changed));
+
+       work_area->signal_layer_selected().connect(sigc::mem_fun(*this,&studio::CanvasView::workarea_layer_selected));
+       work_area->signal_input_device_changed().connect(sigc::mem_fun(*this,&studio::CanvasView::on_input_device_changed));
+
+       canvas_interface()->signal_canvas_added().connect(
+               sigc::hide(
+                       sigc::mem_fun(*instance,&studio::Instance::refresh_canvas_tree)
+               )
+       );
+       canvas_interface()->signal_canvas_removed().connect(
+               sigc::hide(
+                       sigc::mem_fun(*instance,&studio::Instance::refresh_canvas_tree)
+               )
+       );
+
+       canvas_interface()->signal_layer_param_changed().connect(
+               sigc::hide(
+                       sigc::hide(
+                               SLOT_EVENT(EVENT_REFRESH_DUCKS)
+                       )
+               )
+       );
+
+       //MUCH TIME STUFF TAKES PLACE IN HERE
+       refresh_rend_desc();
+       refresh_time_window();
+
+       /*! \todo We shouldn't need to do this at construction --
+       **      This should be performed at the first time the window
+       **      becomes visible.
+       */
+       work_area->queue_render_preview();
+
+       // If the canvas is really big, zoom out so that we can fit it all in the window
+       /*! \todo In other words, this is a zoom-to-fit, and should be
+       ** in its own function.
+       */
+       int w=get_canvas()->rend_desc().get_w()+70;
+       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 initialized
+               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);
+       }
+       if(w>700)w=700;
+       if(h>600)h=600;
+       set_default_size(w,h);
+       property_window_position().set_value(Gtk::WIN_POS_NONE);
+
+       std::list<Gtk::TargetEntry> listTargets;
+       listTargets.push_back( Gtk::TargetEntry("STRING") );
+       listTargets.push_back( Gtk::TargetEntry("text/plain") );
+       listTargets.push_back( Gtk::TargetEntry("image") );
+
+       drag_dest_set(listTargets);
+       signal_drag_data_received().connect( sigc::mem_fun(*this, &studio::CanvasView::on_drop_drag_data_received) );
+
+       /*
+       Time length(get_canvas()->rend_desc().get_time_end()-get_canvas()->rend_desc().get_time_start());
+       if(length<10.0)
+       {
+               time_window_adjustment().set_page_increment(length);
+               time_window_adjustment().set_page_size(length);
+       }
+       else
+       {
+               time_window_adjustment().set_page_increment(10.0);
+               time_window_adjustment().set_page_size(10.0);
+       }
+       */
+
+       //synfig::info("Canvasview: Before Sound Hookup");
+       //load sound info from meta data
+       {
+               //synfig::warning("Should load Audio: %s with %s offset",apath.c_str(),aoffset.c_str());
+
+               on_audio_file_notify(); //redundant setting of the metadata, but oh well, it's no big deal :)
+               on_audio_offset_notify();
+
+               //signal connection - since they are all associated with the canvas view
+
+               //hook in signals for sound options box
+               sound_dialog->signal_file_changed().connect(sigc::mem_fun(*this,&CanvasView::on_audio_file_change));
+               sound_dialog->signal_offset_changed().connect(sigc::mem_fun(*this,&CanvasView::on_audio_offset_change));
+
+               //attach to the preview when it's visible
+               //preview_dialog->get_widget().signal_play().connect(sigc::mem_fun(*this,&CanvasView::play_audio));
+               //preview_dialog->get_widget().signal_stop().connect(sigc::mem_fun(*this,&CanvasView::stop_audio));
+
+               //hook to metadata signals
+               get_canvas()->signal_meta_data_changed("audiofile").connect(sigc::mem_fun(*this,&CanvasView::on_audio_file_notify));
+               get_canvas()->signal_meta_data_changed("audiooffset").connect(sigc::mem_fun(*this,&CanvasView::on_audio_offset_notify));
+
+               //universal_scrubber=std::auto_ptr<UniversalScrubber>(new UniversalScrubber(this));
+       }
+
+       //synfig::info("Canvasview: Before Final time set up");
+       //MORE TIME STUFF
+       time_window_adjustment().set_value(get_canvas()->rend_desc().get_time_start());
+       time_window_adjustment().value_changed();
+
+       GRAB_HINT_DATA("canvas_view");
+       /*
+       {
+       set_skip_taskbar_hint(true);
+       set_skip_pager_hint(true);
+       set_type_hint(Gdk::WINDOW_TYPE_HINT_UTILITY);
+       }
+       */
+
+       refresh_rend_desc();
+       hide_tables();
+
+       on_time_changed();
+       //synfig::info("Canvasview: Constructor Done");
+}
+
+CanvasView::~CanvasView()
+{
+       signal_deleted()();
+
+       App::ui_manager()->remove_action_group(action_group);
+
+       // Shut down the smach
+       smach_.egress();
+       smach_.set_default_state(0);
+
+       // We want to ensure that the UI_Manager and
+       // the selection manager get destructed right now.
+       ui_interface_.reset();
+       selection_manager_.reset();
+
+       // Delete any external widgets
+       for(;!ext_widget_book_.empty();ext_widget_book_.erase(ext_widget_book_.begin()))
+       {
+               if(ext_widget_book_.begin()->second)
+                       delete ext_widget_book_.begin()->second;
+       }
+
+       //delete preview
+       audio.reset();
+
+       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();
+
+       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
+               synfig::info("CanvasView::~CanvasView(): Deleted");
+}
+
+std::list<int>&
+CanvasView::get_pixel_sizes()
+{
+       // prime factors of 120 are 2, 2, 2, 3, 5 - see TILE_SIZE in synfig-core/trunk/src/synfig/target_tile.h
+       static int pixel_size_array[] = {2,3,4,5,6,8,10,12,15,20,24,30,40,60,120};
+       static list<int> pixel_sizes = list<int>(pixel_size_array, pixel_size_array + sizeof(pixel_size_array) / sizeof(int));
+
+       return pixel_sizes;
+}
+
+Gtk::Widget *
+CanvasView::create_time_bar()
+{
+       Gtk::Image *icon;
+
+       //Setup the Time Slider and the Time window scroll
+       Gtk::HScrollbar *time_window_scroll = manage(new class Gtk::HScrollbar(time_window_adjustment()));
+       //Gtk::HScrollbar *time_scroll = manage(new class Gtk::HScrollbar(time_adjustment()));
+       //TIME BAR TEMPORARY POSITION
+       //Widget_Timeslider *time_scroll = manage(new Widget_Timeslider);
+       timeslider->set_time_adjustment(&time_adjustment());
+       timeslider->set_bounds_adjustment(&time_window_adjustment());
+       //layout_table->attach(*timeslider, 0, 1, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL);
+       //Setup the keyframe list widget
+       widget_kf_list->set_time_adjustment(&time_adjustment());
+       widget_kf_list->set_canvas_interface(canvas_interface());
+       widget_kf_list->show();
+
+       tooltips.set_tip(*time_window_scroll,_("Moves the time window"));
+       tooltips.set_tip(*timeslider,_("Changes the current time"));
+       time_window_scroll->show();
+       timeslider->show();
+       //time_window_scroll->set_flags(Gtk::CAN_FOCUS); // Uncomment this produce bad render of the HScroll
+       timeslider->set_flags(Gtk::CAN_FOCUS);
+
+       //time_scroll->signal_value_changed().connect(sigc::mem_fun(*work_area, &studio::WorkArea::render_preview_hook));
+       //time_scroll->set_update_policy(Gtk::UPDATE_DISCONTINUOUS);
+
+       //Setup the Animation Mode Button and the Keyframe Lock button
+       Gtk::IconSize iconsize=Gtk::IconSize::from_name("synfig-small_icon");
+       SMALL_BUTTON(animatebutton,"gtk-yes",_("Animate"));
+       animatebutton->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::on_animate_button_pressed));
+       animatebutton->show();
+
+       //Setup the audio display
+       disp_audio->set_size_request(-1,32); //disp_audio->show();
+       disp_audio->set_time_adjustment(&time_adjustment());
+       disp_audio->signal_start_scrubbing().connect(
+               sigc::mem_fun(*audio,&AudioContainer::start_scrubbing)
+       );
+       disp_audio->signal_scrub().connect(
+               sigc::mem_fun(*audio,&AudioContainer::scrub)
+       );
+       disp_audio->signal_stop_scrubbing().connect(
+               sigc::mem_fun(*audio,&AudioContainer::stop_scrubbing)
+       );
+       //Setup the current time widget
+       current_time_widget=manage(new Widget_Time);
+       current_time_widget->set_value(get_time());
+       current_time_widget->set_fps(get_canvas()->rend_desc().get_frame_rate());
+       current_time_widget->signal_value_changed().connect(
+               sigc::mem_fun(*this,&CanvasView::on_current_time_widget_changed)
+       );
+       current_time_widget->set_size_request(0,-1); // request horizontal shrink
+       tooltips.set_tip(*current_time_widget,_("Current time"));
+       current_time_widget->show();
+
+       //Setup the FrameDial widget
+       framedial = manage(new class FrameDial());
+       framedial->signal_seek_begin().connect(
+                       sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_time), Time::begin())
+       );
+       framedial->signal_seek_prev_frame().connect(
+                       sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_frame), -1)
+       );
+       framedial->signal_play_stop().connect(
+                       sigc::mem_fun(*this, &studio::CanvasView::on_play_stop_pressed)
+       );
+       framedial->signal_seek_next_frame().connect(
+                       sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_frame), 1)
+       );
+       framedial->signal_seek_end().connect(
+                       sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_time), Time::end())
+       );
+       framedial->show();
+
+       //Setup the KeyFrameDial widget
+       KeyFrameDial *keyframedial = Gtk::manage(new class KeyFrameDial());
+       keyframedial->signal_seek_prev_keyframe().connect(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::jump_to_prev_keyframe));
+       keyframedial->signal_seek_next_keyframe().connect(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::jump_to_next_keyframe));
+       keyframedial->signal_lock_keyframe().connect(sigc::mem_fun(*this, &studio::CanvasView::on_keyframe_button_pressed));
+       keyframedial->show();
+       keyframebutton=keyframedial->get_lock_button();
+
+       timebar = Gtk::manage(new class Gtk::Table(5, 4, false));
+
+       //Adjust both widgets to be the same as the
+       int header_height = 0;
+       if(getenv("SYNFIG_TIMETRACK_HEADER_HEIGHT"))
+               header_height = atoi(getenv("SYNFIG_TIMETRACK_HEADER_HEIGHT"));
+       if (header_height < 3)
+               header_height = 24;
+       timeslider->set_size_request(-1,header_height-header_height/3+1);
+       widget_kf_list->set_size_request(-1,header_height/3+1);
+
+       //Attach widgets to the timebar
+       //timebar->attach(*manage(disp_audio), 1, 5, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
+       timebar->attach(*current_time_widget, 0, 1, 0, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       timebar->attach(*framedial, 0, 1, 2, 3, Gtk::SHRINK, Gtk::SHRINK);
+       timebar->attach(*timeslider, 1, 3, 1, 2, Gtk::FILL|Gtk::SHRINK, Gtk::FILL|Gtk::SHRINK);
+       timebar->attach(*widget_kf_list, 1, 3, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::SHRINK);
+       timebar->attach(*time_window_scroll, 1, 3, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
+       timebar->attach(*keyframedial, 3, 4, 0, 2, Gtk::SHRINK, Gtk::SHRINK);
+       timebar->attach(*animatebutton, 4, 5, 0, 2, Gtk::SHRINK, Gtk::SHRINK);
+       //timebar->attach(*keyframebutton, 1, 2, 3, 4, Gtk::SHRINK, Gtk::SHRINK);
+
+       timebar->show();
+
+       return timebar;
+}
+
+Gtk::Widget *
+CanvasView::create_work_area()
+{
+       work_area=std::auto_ptr<WorkArea>(new class studio::WorkArea(canvas_interface_));
+       work_area->set_instance(get_instance());
+       work_area->set_canvas(get_canvas());
+       work_area->set_canvas_view(this);
+       work_area->set_progress_callback(get_ui_interface().get());
+       work_area->signal_popup_menu().connect(sigc::mem_fun(*this, &studio::CanvasView::popup_main_menu));
+       work_area->show();
+       return work_area.get();
+}
+
+Gtk::Widget*
+CanvasView::create_status_bar()
+{
+       Gtk::Image *icon;
+       Gtk::IconSize iconsize=Gtk::IconSize::from_name("synfig-small_icon");
+       cancel=false;
+
+       // Create the status bar at the bottom of the window
+       Gtk::Table *statusbartable= manage(new class Gtk::Table(5, 1, false));
+//     statusbar = manage(new class Gtk::Statusbar()); // This is already done at construction
+       progressbar =manage(new class Gtk::ProgressBar());
+       SMALL_BUTTON(stopbutton,"gtk-stop",_("Stop"));
+       SMALL_BUTTON(refreshbutton,"gtk-refresh",_("Refresh"));
+       //SMALL_BUTTON(treetogglebutton,"gtk-go-down",_("Toggle Layer Tree"));
+//     NEW_SMALL_BUTTON(raisebutton,"gtk-go-up",_("Raise Layer"));
+//     NEW_SMALL_BUTTON(lowerbutton,"gtk-go-down",_("Lower Layer"));
+       //statusbartable->attach(*treetogglebutton, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+//     statusbartable->attach(*lowerbutton, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+//     statusbartable->attach(*raisebutton, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+
+       statusbartable->attach(*statusbar, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       statusbartable->attach(*progressbar, 2, 3, 0, 1, Gtk::SHRINK, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       statusbartable->attach(*refreshbutton, 3, 4, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       statusbartable->attach(*stopbutton, 4, 5, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       statusbar->set_has_resize_grip(false);
+       statusbar->show();
+       stopbutton->show();
+       refreshbutton->show();
+       progressbar->show();
+       stopbutton->set_sensitive(false);
+
+       //refreshbutton->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::on_refresh_pressed));
+       //stopbutton->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::stop));
+       //treetogglebutton->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::toggle_tables));
+
+       refreshbutton->signal_clicked().connect(SLOT_EVENT(EVENT_REFRESH));
+       stopbutton->signal_clicked().connect(SLOT_EVENT(EVENT_STOP));
+
+       statusbartable->show_all();
+       return statusbartable;
+}
+
+Gtk::Widget*
+CanvasView::create_display_bar()
+{
+       displaybar = manage(new class Gtk::Table(16, 1, false));
+       Gtk::IconSize iconsize=Gtk::IconSize::from_name("synfig-small_icon_16x16");
+       // Setup the ToggleDuckDial widget
+       toggleducksdial = Gtk::manage(new class ToggleDucksDial(iconsize));
+
+       Duck::Type m = work_area->get_type_mask();
+       toggleducksdial->update_toggles(m);
+
+       toggleducksdial->signal_ducks_position().connect(
+                       sigc::bind(sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),Duck::TYPE_POSITION)
+                       );
+       toggleducksdial->signal_ducks_vertex().connect(
+                       sigc::bind(sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),Duck::TYPE_VERTEX)
+                       );
+       toggleducksdial->signal_ducks_tangent().connect(
+                       sigc::bind(sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),Duck::TYPE_TANGENT)
+                       );
+       toggleducksdial->signal_ducks_radius().connect(
+                       sigc::bind(sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),Duck::TYPE_RADIUS)
+                       );
+       toggleducksdial->signal_ducks_width().connect(
+                       sigc::bind(sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),Duck::TYPE_WIDTH)
+                       );
+       toggleducksdial->signal_ducks_angle().connect(
+                       sigc::bind(sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),Duck::TYPE_ANGLE)
+                       );
+       toggleducksdial->show();
+
+       // Set up the ResolutionDial widget
+       resolutiondial=Gtk::manage(new class ResolutionDial(iconsize));
+
+       resolutiondial->update_lowres(work_area->get_low_resolution_flag());
+       resolutiondial->signal_increase_resolution().connect(
+                       sigc::mem_fun(*this, &studio::CanvasView::decrease_low_res_pixel_size));
+       resolutiondial->signal_decrease_resolution().connect(
+                       sigc::mem_fun(*this, &studio::CanvasView::increase_low_res_pixel_size));
+       resolutiondial->signal_use_low_resolution().connect(
+                       sigc::mem_fun(*this, &studio::CanvasView::toggle_low_res_pixel_flag));
+       resolutiondial->show();
+
+       // Set up some separators
+       Gtk::VSeparator *separator1 = Gtk::manage(new class Gtk::VSeparator());
+       separator1->show();
+       Gtk::VSeparator *separator2 = Gtk::manage(new class Gtk::VSeparator());
+       separator2->show();
+       Gtk::VSeparator *separator3 = Gtk::manage(new class Gtk::VSeparator());
+       separator3->show();
+       Gtk::VSeparator *separator4 = Gtk::manage(new class Gtk::VSeparator());
+       separator4->show();
+       Gtk::VSeparator *separator5 = Gtk::manage(new class Gtk::VSeparator());
+       separator5->show();
+
+       // Set up quality spin button
+       quality_spin=Gtk::manage(new class Gtk::SpinButton(quality_adjustment_));
+       quality_spin->signal_value_changed().connect(
+                       sigc::mem_fun(*this, &studio::CanvasView::update_quality));
+       tooltips.set_tip(*quality_spin, _("Quality (lower is better)"));
+       quality_spin->show();
+
+       // Set up the show grid toggle button
+       show_grid = Gtk::manage(new class Gtk::ToggleButton());
+       show_grid->set_active(work_area->grid_status());
+       Gtk::Image *icon = manage(new Gtk::Image(Gtk::StockID("synfig-toggle_show_grid"), iconsize));
+       icon->set_padding(0, 0);
+       icon->show();
+       show_grid->add(*icon);
+       show_grid->signal_toggled().connect(
+                       sigc::mem_fun(*this, &studio::CanvasView::toggle_show_grid));
+       tooltips.set_tip(*show_grid, _("Show grid when enabled"));
+       show_grid->set_relief(Gtk::RELIEF_NONE);
+       show_grid->show();
+
+       // Set up the snap to grid toggle button
+       snap_grid = Gtk::manage(new class Gtk::ToggleButton());
+       snap_grid->set_active(work_area->grid_status());
+       Gtk::Image *icon2 = manage(new Gtk::Image(Gtk::StockID("synfig-toggle_snap_grid"), iconsize));
+       icon2->set_padding(0, 0);
+       icon2->show();
+       snap_grid->add(*icon2);
+       snap_grid->signal_toggled().connect(
+                       sigc::mem_fun(*this, &studio::CanvasView::toggle_snap_grid));
+       tooltips.set_tip(*snap_grid, _("Snap grid when enabled"));
+       snap_grid->set_relief(Gtk::RELIEF_NONE);
+       snap_grid->show();
+
+       // Set up the onion skin toggle button
+       onion_skin = Gtk::manage(new class Gtk::ToggleButton());
+       onion_skin->set_active(work_area->get_onion_skin());
+       Gtk::Image *icon3 = manage(new Gtk::Image(Gtk::StockID("synfig-toggle_onion_skin"), iconsize));
+       icon3->set_padding(0, 0);
+       icon3->show();
+       onion_skin->add(*icon3);
+       onion_skin->signal_toggled().connect(
+                       sigc::mem_fun(*this, &studio::CanvasView::toggle_onion_skin));
+       tooltips.set_tip(*onion_skin, _("Shows onion skin when enabled"));
+       onion_skin->set_relief(Gtk::RELIEF_NONE);
+       onion_skin->show();
+
+       // Set up past onion skin spin button
+       past_onion_spin=Gtk::manage(new class Gtk::SpinButton(past_onion_adjustment_));
+       past_onion_spin->signal_value_changed().connect(
+                       sigc::mem_fun(*this, &studio::CanvasView::set_onion_skins));
+       tooltips.set_tip(*past_onion_spin, _("Past onion skins"));
+       past_onion_spin->show();
+
+       // Set up future onion skin spin button
+       future_onion_spin=Gtk::manage(new class Gtk::SpinButton(future_onion_adjustment_));
+       future_onion_spin->signal_value_changed().connect(
+                       sigc::mem_fun(*this, &studio::CanvasView::set_onion_skins));
+       tooltips.set_tip(*future_onion_spin, _("Future onion skins"));
+       future_onion_spin->show();
+
+       // Setup render options dialog button
+       render_options_button = Gtk::manage(new class Gtk::Button());
+       Gtk::Image *icon4 = manage(new Gtk::Image(Gtk::StockID("synfig-render_options"), iconsize));
+       icon4->set_padding(0, 0);
+       icon4->show();
+       render_options_button->add(*icon4);
+       render_options_button->signal_clicked().connect(
+                       sigc::mem_fun0(render_settings,&studio::RenderSettings::present));
+       tooltips.set_tip(*render_options_button, _("Shows the Render Settings Dialog"));
+       render_options_button->set_relief(Gtk::RELIEF_NONE);
+       render_options_button->show();
+
+       // Setup preview options dialog button
+       preview_options_button = Gtk::manage(new class Gtk::Button());
+       Gtk::Image *icon5 = manage(new Gtk::Image(Gtk::StockID("synfig-preview_options"), iconsize));
+       icon5->set_padding(0, 0);
+       icon5->show();
+       preview_options_button->add(*icon5);
+       preview_options_button->signal_clicked().connect(
+                       sigc::mem_fun(*this,&CanvasView::on_preview_option));
+       tooltips.set_tip(*preview_options_button, _("Shows the Preview Settings Dialog"));
+       preview_options_button->set_relief(Gtk::RELIEF_NONE);
+       preview_options_button->show();
+
+
+       displaybar->attach(*toggleducksdial, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
+       displaybar->attach(*separator1, 1, 2, 0, 1, Gtk::FILL, Gtk::FILL);
+       displaybar->attach(*resolutiondial, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
+       displaybar->attach(*separator2, 3, 4, 0, 1, Gtk::FILL, Gtk::FILL);
+       displaybar->attach(*quality_spin, 4, 5, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
+       displaybar->attach(*separator3, 5, 6, 0, 1, Gtk::FILL, Gtk::FILL);
+       displaybar->attach(*show_grid, 6, 7, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
+       displaybar->attach(*snap_grid, 7, 8, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
+       displaybar->attach(*separator4, 8, 9, 0, 1, Gtk::FILL, Gtk::FILL);
+       displaybar->attach(*past_onion_spin, 9, 10, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
+       displaybar->attach(*onion_skin, 10, 11, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
+       displaybar->attach(*future_onion_spin, 11, 12, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
+       displaybar->attach(*separator5, 12, 13, 0, 1, Gtk::FILL, Gtk::FILL);
+       displaybar->attach(*render_options_button, 13, 14, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
+       displaybar->attach(*preview_options_button, 14, 15, 0, 1, Gtk::SHRINK, Gtk::SHRINK);
+
+       displaybar->show();
+
+       return displaybar;
+
+}
+
+void
+CanvasView::on_current_time_widget_changed()
+{
+       set_time(current_time_widget->get_value());
+
+       // show the value being used - it will have been rounded to nearest frame
+       // this was already being done elsewhere, but only if the time was really changed;
+       // if the current time was 6f and the user edited it to 6.1f, then the 6.1f would
+       // be left in the display without the following line to fix it
+       current_time_widget->set_value(get_time());
+       current_time_widget->set_position(-1); // leave the cursor at the end
+}
+
+//     Gtk::Widget*
+//     CanvasView::create_children_tree()
+//     {
+//             // Create the layer tree
+//             children_tree=manage(new class ChildrenTree());
+//
+//             // Set up the layer tree
+//             //children_tree->set_model(children_tree_store());
+//             if(children_tree)children_tree->set_time_adjustment(time_adjustment());
+//             if(children_tree)children_tree->show();
+//
+//             // Connect Signals
+//             if(children_tree)children_tree->signal_edited_value().connect(sigc::mem_fun(*this, &studio::CanvasView::on_edited_value));
+//             if(children_tree)children_tree->signal_user_click().connect(sigc::mem_fun(*this, &studio::CanvasView::on_children_user_click));
+//             if(children_tree)children_tree->signal_waypoint_clicked_childrentree().connect(sigc::mem_fun(*this, &studio::CanvasView::on_waypoint_clicked_canvasview));
+//             if(children_tree)children_tree->get_selection()->signal_changed().connect(SLOT_EVENT(EVENT_REFRESH_DUCKS));
+//
+//             return children_tree;
+//     }
+
+//     Gtk::Widget*
+//     CanvasView::create_keyframe_tree()
+//     {
+//             keyframe_tree=manage(new KeyframeTree());
+//
+//             //keyframe_tree->get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
+//             //keyframe_tree->show();
+//             //keyframe_tree->set_model(keyframe_tree_store());
+//             keyframe_tree->set_editable(true);
+//             //keyframe_tree->signal_edited().connect(sigc::hide_return(sigc::mem_fun(*canvas_interface(), &synfigapp::CanvasInterface::update_keyframe)));
+//
+//             keyframe_tree->signal_event().connect(sigc::mem_fun(*this, &studio::CanvasView::on_keyframe_tree_event));
+//
+//             Gtk::ScrolledWindow *scroll_layer_tree = manage(new class Gtk::ScrolledWindow());
+//             scroll_layer_tree->set_flags(Gtk::CAN_FOCUS);
+//             scroll_layer_tree->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+//             scroll_layer_tree->add(*keyframe_tree);
+//             scroll_layer_tree->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
+//             //scroll_layer_tree->show();
+//
+//
+//             Gtk::Table *layout_table= manage(new Gtk::Table(1, 2, false));
+//             layout_table->attach(*scroll_layer_tree, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+//
+//             Gtk::Image *icon;
+//             Gtk::IconSize iconsize(Gtk::IconSize::from_name("synfig-small_icon"));
+//
+//             NEW_SMALL_BUTTON(button_add,"gtk-add",_("New Keyframe"));
+//             NEW_SMALL_BUTTON(button_duplicate,"synfig-duplicate",_("Duplicate Keyframe"));
+//             NEW_SMALL_BUTTON(button_delete,"gtk-delete",_("Delete Keyframe"));
+//
+//             Gtk::HBox *hbox(manage(new Gtk::HBox()));
+//             layout_table->attach(*hbox, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK, 0, 0);
+//
+//             hbox->pack_start(*button_add,Gtk::PACK_SHRINK);
+//             hbox->pack_start(*button_duplicate,Gtk::PACK_SHRINK);
+//             hbox->pack_start(*button_delete,Gtk::PACK_SHRINK);
+//
+//             /*
+//             button_raise->set_relief(Gtk::RELIEF_HALF);
+//             button_lower->set_relief(Gtk::RELIEF_HALF);
+//             button_duplicate->set_relief(Gtk::RELIEF_HALF);
+//             button_delete->set_relief(Gtk::RELIEF_HALF);
+//             */
+//
+//             button_add->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::on_keyframe_add_pressed));
+//             button_duplicate->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::on_keyframe_duplicate_pressed));
+//             button_delete->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::on_keyframe_remove_pressed));
+//
+//             //layout_table->show_all();
+//
+//             keyframe_tab_child=layout_table;
+//
+//
+//             layout_table->hide();
+//
+//             return layout_table;
+//     }
+
+//     Gtk::Widget*
+//     CanvasView::create_layer_tree()
+//     {
+//             // Create the layer tree
+//             printf("CanvasView::create_layer_tree()\n");
+//             layer_tree=manage(new class LayerTree());
+//
+//             // Set up the layer tree
+//             //layer_tree->set_model(layer_tree_store());
+//             layer_tree->set_time_adjustment(time_adjustment());
+//             layer_tree->show();
+//
+//             // Connect Signals
+//             layer_tree->signal_layer_toggle().connect(sigc::mem_fun(*this, &studio::CanvasView::on_layer_toggle));
+//             layer_tree->signal_edited_value().connect(sigc::mem_fun(*this, &studio::CanvasView::on_edited_value));
+//             layer_tree->signal_layer_user_click().connect(sigc::mem_fun(*this, &studio::CanvasView::on_layer_user_click));
+//             layer_tree->signal_param_user_click().connect(sigc::mem_fun(*this, &studio::CanvasView::on_children_user_click));
+//             layer_tree->signal_waypoint_clicked_layertree().connect(sigc::mem_fun(*this, &studio::CanvasView::on_waypoint_clicked_canvasview));
+//             layer_tree->get_selection()->signal_changed().connect(SLOT_EVENT(EVENT_REFRESH_DUCKS));
+//
+//             layer_tree->hide();
+//             return layer_tree;
+//     }
+
+void
+CanvasView::init_menus()
+{
+/*
+       mainmenu.set_accel_group(get_accel_group());
+       mainmenu.set_accel_path("<Canvas-view>");
+
+       filemenu.set_accel_group(get_accel_group());
+       filemenu.set_accel_path("<Canvas-view>/File");
+
+       editmenu.set_accel_group(get_accel_group());
+       editmenu.set_accel_path("<Canvas-view>/Edit");
+
+       layermenu.set_accel_group(get_accel_group());
+       layermenu.set_accel_path("<Canvas-view>/Layer");
+*/
+       //cache the position of desired widgets
+
+       /*Menus to worry about:
+       - filemenu
+       - editmenu
+       - layermenu
+       - duckmaskmenu
+       - mainmenu
+       - canvasmenu
+       - viewmenu
+       */
+       action_group = Gtk::ActionGroup::create("canvasview");
+
+       //action_group->add( Gtk::Action::create("MenuFile", _("_File")) );
+       action_group->add( Gtk::Action::create("new", Gtk::Stock::NEW),
+               sigc::hide_return(sigc::ptr_fun(&studio::App::new_instance))
+       );
+       action_group->add( Gtk::Action::create("open", Gtk::Stock::OPEN),
+               sigc::hide_return(sigc::mem_fun(*get_instance().get(), &studio::Instance::open))
+       );
+       action_group->add( Gtk::Action::create("save", Gtk::Stock::SAVE),
+               hide_return(sigc::mem_fun(*get_instance().get(), &studio::Instance::save))
+       );
+       action_group->add( Gtk::Action::create("save-as", Gtk::Stock::SAVE_AS),
+               sigc::hide_return(sigc::mem_fun(*get_instance().get(), &studio::Instance::dialog_save_as))
+       );
+       action_group->add( Gtk::Action::create("revert", Gtk::Stock::REVERT_TO_SAVED),
+               sigc::hide_return(sigc::mem_fun(*get_instance().get(), &studio::Instance::safe_revert))
+       );
+       action_group->add( Gtk::Action::create("cvs-add", Gtk::StockID("synfig-cvs_add")),
+               sigc::hide_return(sigc::mem_fun(*get_instance(), &studio::Instance::dialog_cvs_add))
+       );
+       action_group->add( Gtk::Action::create("cvs-update", Gtk::StockID("synfig-cvs_update")),
+               sigc::hide_return(sigc::mem_fun(*get_instance(), &studio::Instance::dialog_cvs_update))
+       );
+       action_group->add( Gtk::Action::create("cvs-revert", Gtk::StockID("synfig-cvs_revert")),
+               sigc::hide_return(sigc::mem_fun(*get_instance(), &studio::Instance::dialog_cvs_revert))
+       );
+       action_group->add( Gtk::Action::create("cvs-commit", Gtk::StockID("synfig-cvs_commit")),
+               sigc::hide_return(sigc::mem_fun(*get_instance(), &studio::Instance::dialog_cvs_commit))
+       );
+       action_group->add( Gtk::Action::create("import", _("Import")),
+               sigc::hide_return(sigc::mem_fun(*this, &studio::CanvasView::image_import))
+       );
+       action_group->add( Gtk::Action::create("render", _("Render")),
+               sigc::mem_fun0(render_settings,&studio::RenderSettings::present)
+       );
+       action_group->add( Gtk::Action::create("preview", _("Preview")),
+               sigc::mem_fun(*this,&CanvasView::on_preview_option)
+       );
+       action_group->add( Gtk::Action::create("sound", _("Sound File")),
+               sigc::mem_fun(*this,&CanvasView::on_audio_option)
+       );
+       action_group->add( Gtk::Action::create("options", _("Options")),
+               sigc::mem_fun0(canvas_options,&studio::CanvasOptions::present)
+       );
+       action_group->add( Gtk::Action::create("close", Gtk::StockID("gtk-close"), _("Close Window")),
+               sigc::hide_return(sigc::mem_fun(*this,&studio::CanvasView::close_view))
+       );
+       action_group->add( Gtk::Action::create("close-document", Gtk::StockID("gtk-close"), _("Close Document")),
+               sigc::hide_return(sigc::mem_fun(*this,&studio::CanvasView::close_instance))
+       );
+       action_group->add( Gtk::Action::create("quit", Gtk::StockID("gtk-quit"), _("Quit")),
+               sigc::hide_return(sigc::ptr_fun(&studio::App::quit))
+       );
+
+       //action_group->add( Gtk::Action::create("undo", Gtk::StockID("gtk-undo")),
+       //      SLOT_EVENT(EVENT_UNDO)
+       //);
+
+       //action_group->add( Gtk::Action::create("redo", Gtk::StockID("gtk-redo")),
+       //      SLOT_EVENT(EVENT_REDO)
+       //);
+
+       action_group->add( Gtk::Action::create("select-all-ducks", _("Select All Ducks")),
+               sigc::mem_fun(*work_area,&studio::WorkArea::select_all_ducks)
+       );
+
+       action_group->add( Gtk::Action::create("unselect-all-ducks", _("Unselect All Ducks")),
+               sigc::mem_fun(*work_area,&studio::WorkArea::unselect_all_ducks)
+       );
+
+       action_group->add( Gtk::Action::create("select-all-layers", _("Select All Layers")),
+               sigc::mem_fun(*this,&CanvasView::on_select_layers)
+       );
+
+       action_group->add( Gtk::Action::create("unselect-all-layers", _("Unselect All Layers")),
+               sigc::mem_fun(*this,&CanvasView::on_unselect_layers)
+       );
+
+       action_group->add( Gtk::Action::create("stop", Gtk::StockID("gtk-stop")),
+               SLOT_EVENT(EVENT_STOP)
+       );
+
+       action_group->add( Gtk::Action::create("refresh", Gtk::StockID("gtk-refresh")),
+               SLOT_EVENT(EVENT_REFRESH)
+       );
+
+       action_group->add( Gtk::Action::create("properties", Gtk::StockID("gtk-properties")),
+               sigc::mem_fun0(canvas_properties,&studio::CanvasProperties::present)
+       );
+
+       // Preview Quality Menu
+       {
+               int i;
+               action_group->add( Gtk::RadioAction::create(quality_group,"quality-00", _("Use Parametric Renderer")),
+                       sigc::bind(
+                               sigc::mem_fun(*work_area, &studio::WorkArea::set_quality),
+                               0
+                       )
+               );
+               for(i=1;i<=10;i++)
+               {
+                       String note;
+                       if (i == 1) note = _(" (best)");
+                       if (i == 10) note = _(" (fastest)");
+                       Glib::RefPtr<Gtk::RadioAction> action(Gtk::RadioAction::create(quality_group,strprintf("quality-%02d",i),
+                                                                                                                                                  strprintf(_("Set Quality to %d"),i) + note));
+                       if (i==8)                       // default quality
+                       {
+                               action->set_active();
+                               work_area->set_quality(i);
+                       }
+                       action_group->add( action,
+                               sigc::bind(
+                                       sigc::mem_fun(*this, &studio::CanvasView::set_quality),
+                                       i
+                               )
+                       );
+               }
+       }
+
+       // Low-Res Quality Menu
+       {
+               int i;
+               for(list<int>::iterator iter = CanvasView::get_pixel_sizes().begin(); iter != CanvasView::get_pixel_sizes().end(); iter++)
+               {
+                       i = *iter;
+                       Glib::RefPtr<Gtk::RadioAction> action(Gtk::RadioAction::create(low_res_pixel_size_group,strprintf("lowres-pixel-%d",i),
+                                                                                                                                                  strprintf(_("Set Low-Res pixel size to %d"),i)));
+                       if(i==2)                        // default pixel size
+                       {
+                               action->set_active();
+                               work_area->set_low_res_pixel_size(i);
+                       }
+                       action_group->add( action,
+                               sigc::bind(
+                                       sigc::mem_fun(*work_area, &studio::WorkArea::set_low_res_pixel_size),
+                                       i
+                               )
+                       );
+               }
+
+               Glib::RefPtr<Gtk::Action> action;
+
+               action=Gtk::Action::create("decrease-low-res-pixel-size", _("Decrease Low-Res Pixel Size"));
+               action_group->add( action,sigc::mem_fun(this, &studio::CanvasView::decrease_low_res_pixel_size));
+
+               action=Gtk::Action::create("increase-low-res-pixel-size",  _("Increase Low-Res Pixel Size"));
+               action_group->add( action, sigc::mem_fun(this, &studio::CanvasView::increase_low_res_pixel_size));
+
+       }
+
+       action_group->add( Gtk::Action::create("play", Gtk::Stock::MEDIA_PLAY),
+               sigc::mem_fun(*this, &studio::CanvasView::play)
+       );
+
+       action_group->add( Gtk::Action::create("dialog-flipbook", _("Preview Window")),
+               sigc::mem_fun0(*preview_dialog, &studio::Dialog_Preview::present)
+       );
+
+       {
+               Glib::RefPtr<Gtk::ToggleAction> action;
+
+               grid_show_toggle = Gtk::ToggleAction::create("toggle-grid-show", _("Show Grid"));
+               grid_show_toggle->set_active(work_area->grid_status());
+               action_group->add(grid_show_toggle, sigc::mem_fun(*this, &studio::CanvasView::toggle_show_grid));
+
+               grid_snap_toggle = Gtk::ToggleAction::create("toggle-grid-snap", _("Snap to Grid"));
+               grid_snap_toggle->set_active(work_area->get_grid_snap());
+               action_group->add(grid_snap_toggle, sigc::mem_fun(*this, &studio::CanvasView::toggle_snap_grid));
+
+               action = Gtk::ToggleAction::create("toggle-guide-show", _("Show Guides"));
+               action->set_active(work_area->get_show_guides());
+               action_group->add(action, sigc::mem_fun(*work_area, &studio::WorkArea::toggle_guide_snap));
+
+               action = Gtk::ToggleAction::create("toggle-low-res", _("Use Low-Res"));
+               action->set_active(work_area->get_low_resolution_flag());
+               action_group->add(action, sigc::mem_fun(*this, &studio::CanvasView::toggle_low_res_pixel_flag));
+
+               action = Gtk::ToggleAction::create("toggle-onion-skin", _("Show Onion Skin"));
+               action->set_active(work_area->get_onion_skin());
+               action_group->add(action, sigc::mem_fun(*this, &studio::CanvasView::toggle_onion_skin));
+       }
+
+       action_group->add( Gtk::Action::create("canvas-zoom-fit", Gtk::StockID("gtk-zoom-fit")),
+               sigc::mem_fun(*work_area, &studio::WorkArea::zoom_fit)
+       );
+       action_group->add( Gtk::Action::create("canvas-zoom-100", Gtk::StockID("gtk-zoom-100")),
+               sigc::mem_fun(*work_area, &studio::WorkArea::zoom_norm)
+       );
+
+       {
+               Glib::RefPtr<Gtk::Action> action;
+
+               action=Gtk::Action::create("seek-next-frame", Gtk::Stock::GO_FORWARD,_("Next Frame"),_("Next Frame"));
+               action_group->add(action,sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_frame),1));
+               action=Gtk::Action::create("seek-prev-frame", Gtk::Stock::GO_BACK,_("Prev Frame"),_("Prev Frame"));
+               action_group->add( action, sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_frame),-1));
+
+               action=Gtk::Action::create("seek-next-second", Gtk::Stock::GO_FORWARD,_("Seek Forward"),_("Seek Forward"));
+               action_group->add(action,sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_time),Time(1)));
+               action=Gtk::Action::create("seek-prev-second", Gtk::Stock::GO_BACK,_("Seek Backward"),_("Seek Backward"));
+               action_group->add( action, sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_time),Time(-1)));
+
+               action=Gtk::Action::create("seek-end", Gtk::Stock::GOTO_LAST,_("Seek to End"),_("Seek to End"));
+               action_group->add(action,sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_time),Time::end()));
+
+               action=Gtk::Action::create("seek-begin", Gtk::Stock::GOTO_FIRST,_("Seek to Begin"),_("Seek to Begin"));
+               action_group->add( action, sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek_time),Time::begin()));
+
+               action=Gtk::Action::create("jump-next-keyframe", Gtk::Stock::GO_FORWARD,_("Jump to Next Keyframe"),_("Jump to Next Keyframe"));
+               action_group->add( action,sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::jump_to_next_keyframe));
+
+               action=Gtk::Action::create("jump-prev-keyframe", Gtk::Stock::GO_BACK,_("Jump to Prev Keyframe"),_("Jump to Prev Keyframe"));
+               action_group->add( action,sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::jump_to_prev_keyframe));
+
+               action=Gtk::Action::create("canvas-zoom-in", Gtk::Stock::ZOOM_IN);
+               action_group->add( action,sigc::mem_fun(*work_area, &studio::WorkArea::zoom_in));
+
+               action=Gtk::Action::create("canvas-zoom-out", Gtk::Stock::ZOOM_OUT);
+               action_group->add( action, sigc::mem_fun(*work_area, &studio::WorkArea::zoom_out) );
+
+               action=Gtk::Action::create("time-zoom-in", Gtk::Stock::ZOOM_IN, _("Zoom In on Timeline"));
+               action_group->add( action, sigc::mem_fun(*this, &studio::CanvasView::time_zoom_in) );
+
+               action=Gtk::Action::create("time-zoom-out", Gtk::Stock::ZOOM_OUT, _("Zoom Out on Timeline"));
+               action_group->add( action, sigc::mem_fun(*this, &studio::CanvasView::time_zoom_out) );
+
+       }
+
+       {
+               Glib::RefPtr<Gtk::ToggleAction> action;
+
+#define DUCK_MASK(lower,upper,string)                                                                                          \
+               action=Gtk::ToggleAction::create("mask-" #lower "-ducks", string);                      \
+               action->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_##upper));      \
+               action_group->add(action,                                                                                                       \
+                       sigc::bind(                                                                                                                             \
+                               sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),            \
+                               Duck::TYPE_##upper))
+
+               DUCK_MASK(position,POSITION,_("Show Position Ducks"));
+               DUCK_MASK(tangent,TANGENT,_("Show Tangent Ducks"));
+               DUCK_MASK(vertex,VERTEX,_("Show Vertex Ducks"));
+               DUCK_MASK(radius,RADIUS,_("Show Radius Ducks"));
+               DUCK_MASK(width,WIDTH,_("Show Width Ducks"));
+               DUCK_MASK(angle,ANGLE,_("Show Angle Ducks"));
+
+#undef DUCK_MASK
+       }
+
+       add_accel_group(App::ui_manager()->get_accel_group());
+
+/*     // Here is where we add the actions that may have conflicting
+       // keyboard accelerators.
+       {
+               Glib::RefPtr<Gtk::ActionGroup> accel_action_group(Gtk::ActionGroup::create("canvas_view"));
+               Glib::RefPtr<Gtk::Action> action;
+
+               action=Gtk::Action::create("seek-next-frame", Gtk::StockID("gtk-forward"),_("Next Frame"),_("Next Frame"));
+               accel_action_group->add(action,sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek),1));
+
+               action=Gtk::Action::create("seek-prev-frame", Gtk::StockID("gtk-forward"),_("Prev Frame"),_("Prev Frame"));
+               accel_action_group->add( action, sigc::bind(sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::seek),-1));
+
+               action=Gtk::Action::create("jump-next-keyframe", Gtk::StockID("gtk-forward"),_("Jump to Next Keyframe"),_("Jump to Next Keyframe"));
+               accel_action_group->add( action,sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::jump_to_next_keyframe));
+
+               action=Gtk::Action::create("jump-prev-keyframe", Gtk::StockID("gtk-back"),_("Jump to Prev Keyframe"),_("Jump to Prev Keyframe"));
+               accel_action_group->add( action,sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::jump_to_prev_keyframe));
+
+               action=Gtk::Action::create("canvas-zoom-in", Gtk::StockID("gtk-zoom-in"));
+               accel_action_group->add( action,sigc::mem_fun(*work_area, &studio::WorkArea::zoom_in));
+
+               action=Gtk::Action::create("canvas-zoom-out", Gtk::StockID("gtk-zoom-out"));
+               accel_action_group->add( action, sigc::mem_fun(*work_area, &studio::WorkArea::zoom_out) );
+
+               action=Gtk::Action::create("time-zoom-in", Gtk::StockID("gtk-zoom-in"), _("Zoom In on Timeline"));
+               accel_action_group->add( action, sigc::mem_fun(*this, &studio::CanvasView::time_zoom_in) );
+
+               action=Gtk::Action::create("time-zoom-out", Gtk::StockID("gtk-zoom-out"), _("Zoom Out on Timeline"));
+               accel_action_group->add( action, sigc::mem_fun(*this, &studio::CanvasView::time_zoom_out) );
+
+               Glib::RefPtr<Gtk::UIManager> accel_ui_manager(Gtk::UIManager::create());
+
+               Glib::ustring ui_info =
+               "
+               <ui>
+                       <accelerator action='seek-next-frame' />
+                       <accelerator action='seek-prev-frame' />
+                       <accelerator action='jump-next-keyframe' />
+                       <accelerator action='jump-prev-keyframe' />
+                       <accelerator action='canvas-zoom-in' />
+                       <accelerator action='canvas-zoom-out' />
+                       <accelerator action='time-zoom-in' />
+                       <accelerator action='time-zoom-out' />
+               </ui>
+               ";
+
+               accel_ui_manager->add_ui_from_string(ui_info);
+               add_accel_group(accel_ui_manager->get_accel_group());
+
+               accel_ui_manager->insert_action_group(accel_action_group);
+               set_ref_obj("accel_ui_manager",accel_ui_manager);
+               set_ref_obj("accel_action_group",accel_action_group);
+       }
+*/
+
+#if 0
+//
+//     //Test some key stuff
+//
+//     filemenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-save"),
+//             hide_return(sigc::mem_fun(*get_instance().get(), &studio::Instance::save))));
+//     filemenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-save-as"),sigc::hide_return(sigc::mem_fun(*get_instance(), &studio::Instance::dialog_save_as))));
+//     filemenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-revert-to-saved"),hide_return(sigc::mem_fun(*get_instance().get(), &studio::Instance::safe_revert))));
+//     filemenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
+//
+//     filemenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-cvs_add"),sigc::hide_return(sigc::mem_fun(*get_instance(), &studio::Instance::dialog_cvs_add))));
+//     filemenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-cvs_update"),sigc::hide_return(sigc::mem_fun(*get_instance(), &studio::Instance::dialog_cvs_update))));
+//     filemenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-cvs_commit"),sigc::hide_return(sigc::mem_fun(*get_instance(), &studio::Instance::dialog_cvs_commit))));
+//
+//     filemenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
+//     filemenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Import..."),Gtk::AccelKey('I',Gdk::CONTROL_MASK),sigc::hide_return(sigc::mem_fun(*this, &studio::CanvasView::image_import))));
+//     filemenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
+//     filemenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Render"),Gtk::AccelKey("F9"),
+//             sigc::mem_fun(render_settings,&studio::RenderSettings::present)
+//     ));
+//     filemenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Preview"),Gtk::AccelKey("F11"),
+//             sigc::mem_fun(*this,&CanvasView::on_preview_option)
+//     ));
+//     filemenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Sound File"),
+//             sigc::mem_fun(*this,&CanvasView::on_audio_option)
+//     ));
+//
+//     filemenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
+//     filemenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Options"),Gtk::AccelKey("F12"),
+//             sigc::mem_fun(canvas_options,&studio::CanvasOptions::present)
+//     ));
+//     filemenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
+//     filemenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Close View"),
+//             sigc::hide_return(sigc::mem_fun(*this,&studio::CanvasView::close_view))
+//     ));
+//     filemenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Close Document"),
+//             sigc::hide_return(sigc::mem_fun(*this,&studio::CanvasView::close_document))
+//     ));
+//
+//     editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-undo"),Gtk::AccelKey('Z',Gdk::CONTROL_MASK),SLOT_EVENT(EVENT_UNDO)));
+//     editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-redo"),Gtk::AccelKey('R',Gdk::CONTROL_MASK),SLOT_EVENT(EVENT_REDO)));
+//     editmenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
+//     editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-cut"),NOT_IMPLEMENTED_SLOT));
+//     editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-copy"),NOT_IMPLEMENTED_SLOT));
+//     editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-paste"),NOT_IMPLEMENTED_SLOT));
+//     editmenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
+//     editmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Select All Ducks"),Gtk::AccelKey('E',Gdk::CONTROL_MASK),sigc::mem_fun(*work_area,&studio::WorkArea::select_all_ducks)));
+//     editmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Unselect All Ducks"),Gtk::AccelKey('E',Gdk::CONTROL_MASK),sigc::mem_fun(*work_area,&studio::WorkArea::unselect_all_ducks)));
+//     editmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Select All Layers"),Gtk::AccelKey('A',Gdk::CONTROL_MASK),sigc::mem_fun(*this,&CanvasView::on_select_layers)));
+//     editmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Unselect All Layers"),Gtk::AccelKey('D',Gdk::CONTROL_MASK),sigc::mem_fun(*this,&CanvasView::on_unselect_layers)));
+//     editmenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
+//
+//     //editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-stop"),Gtk::AccelKey(GDK_Escape,static_cast<Gdk::ModifierType>(0)),sigc::hide_return(sigc::mem_fun(*this, &studio::CanvasView::stop))));
+//     //editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-refresh"),Gtk::AccelKey('k',Gdk::CONTROL_MASK),sigc::hide_return(sigc::mem_fun(*this, &studio::CanvasView::on_refresh_pressed))));
+//     editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-stop"),Gtk::AccelKey(GDK_Escape,static_cast<Gdk::ModifierType>(0)),SLOT_EVENT(EVENT_STOP)));
+//     editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-refresh"),Gtk::AccelKey('k',Gdk::CONTROL_MASK),SLOT_EVENT(EVENT_REFRESH)));
+//     editmenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
+//     editmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-properties"),Gtk::AccelKey("F8"),
+//             sigc::mem_fun(canvas_properties,&studio::CanvasProperties::present)
+//     ));
+//
+//     build_new_layer_menu(newlayermenu);
+//     layermenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("New"),newlayermenu));
+//
+//
+//     {
+//             synfigapp::Action::ParamList param_list;
+//             param_list.add("canvas",Canvas::Handle(get_canvas()));
+//             param_list.add("canvas_interface",canvas_interface());
+//             add_actions_to_menu(&canvasmenu, param_list,synfigapp::Action::CATEGORY_CANVAS);
+//     }
+//
+//
+//     //canvasmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Keyframe Dialog"),sigc::mem_fun(keyframe_dialog,&studio::Dialog_Keyframe::present)));
+//
+//     // Duck Mask Menu
+//     if(1)
+//             {
+//             duckmaskmenu.items().push_back(Gtk::Menu_Helpers::TearoffMenuElem());
+//
+//             duckmaskmenu.items().push_back(Gtk::Menu_Helpers::CheckMenuElem(_("Position Ducks"),Gtk::AccelKey('1',Gdk::MOD1_MASK)));
+//             duck_mask_position=static_cast<Gtk::CheckMenuItem*>(&duckmaskmenu.items().back());
+//             duck_mask_position->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_POSITION));
+//             duck_mask_position->signal_toggled().connect(
+//                     sigc::bind(
+//                             sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),
+//                             Duck::TYPE_POSITION
+//                     )
+//             );
+//
+//             duckmaskmenu.items().push_back(Gtk::Menu_Helpers::CheckMenuElem(_("Vertex Ducks"),Gtk::AccelKey('2',Gdk::MOD1_MASK)));
+//             duck_mask_vertex=static_cast<Gtk::CheckMenuItem*>(&duckmaskmenu.items().back());
+//             duck_mask_vertex->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_VERTEX));
+//             duck_mask_vertex->signal_toggled().connect(
+//                     sigc::bind(
+//                             sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),
+//                             Duck::TYPE_VERTEX
+//                     )
+//             );
+//
+//             duckmaskmenu.items().push_back(Gtk::Menu_Helpers::CheckMenuElem(_("Tangent Ducks"),Gtk::AccelKey('3',Gdk::MOD1_MASK)));
+//             duck_mask_tangent=static_cast<Gtk::CheckMenuItem*>(&duckmaskmenu.items().back());
+//             duck_mask_tangent->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_TANGENT));
+//             duck_mask_tangent->signal_toggled().connect(
+//                     sigc::bind(
+//                             sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),
+//                             Duck::TYPE_TANGENT
+//                     )
+//             );
+//
+//             duckmaskmenu.items().push_back(Gtk::Menu_Helpers::CheckMenuElem(_("Radius Ducks"),Gtk::AccelKey('4',Gdk::MOD1_MASK)));
+//             duck_mask_radius=static_cast<Gtk::CheckMenuItem*>(&duckmaskmenu.items().back());
+//             duck_mask_radius->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_RADIUS));
+//             duck_mask_radius->signal_toggled().connect(
+//                     sigc::bind(
+//                             sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),
+//                             Duck::TYPE_RADIUS
+//                     )
+//             );
+//
+//             duckmaskmenu.items().push_back(Gtk::Menu_Helpers::CheckMenuElem(_("Width Ducks"),Gtk::AccelKey('5',Gdk::MOD1_MASK)));
+//             duck_mask_width=static_cast<Gtk::CheckMenuItem*>(&duckmaskmenu.items().back());
+//             duck_mask_width->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_WIDTH));
+//             duck_mask_width->signal_toggled().connect(
+//                     sigc::bind(
+//                             sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),
+//                             Duck::TYPE_WIDTH
+//                     )
+//             );
+//
+//             duckmaskmenu.items().push_back(Gtk::Menu_Helpers::CheckMenuElem(_("Angle Ducks"),Gtk::AccelKey('6',Gdk::MOD1_MASK)));
+//             duck_mask_angle=static_cast<Gtk::CheckMenuItem*>(&duckmaskmenu.items().back());
+//             duck_mask_angle->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_ANGLE));
+//             duck_mask_angle->signal_toggled().connect(
+//                     sigc::bind(
+//                             sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask),
+//                             Duck::TYPE_ANGLE
+//                     )
+//             );
+//
+//             viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Mask Ducks"),duckmaskmenu));
+//     }
+//
+//     // Preview Quality Menu
+//     if(1)
+//     {
+//             qualitymenu.items().push_back(Gtk::Menu_Helpers::TearoffMenuElem());
+//             int i;
+//             qualitymenu.items().push_back(Gtk::Menu_Helpers::MenuElem(strprintf(_("Use Parametric Renderer"),0),
+//                     sigc::bind(
+//                             sigc::mem_fun(*work_area, &studio::WorkArea::set_quality),
+//                             0
+//                     )
+//             ));
+//             for(i=1;i<=10;i++)
+//             {
+//                     qualitymenu.items().push_back(Gtk::Menu_Helpers::MenuElem(strprintf(_("Set Quality to %d"),i),Gtk::AccelKey('0'+(i%10),Gdk::CONTROL_MASK),
+//                             sigc::bind(
+//                                     sigc::mem_fun(*work_area, &studio::WorkArea::set_quality),
+//                                     i
+//                             )
+//                     ));
+//             }
+//             viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Preview Quality"),qualitymenu));
+//     }
+//
+//     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)));
+//
+//     viewmenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
+//
+//     viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Toggle Grid Show"),Gtk::AccelKey('g',Gdk::CONTROL_MASK),
+//             sigc::mem_fun(*work_area, &studio::WorkArea::toggle_grid)));
+//     viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Toggle Grid Snap"),Gtk::AccelKey('l',Gdk::CONTROL_MASK),
+//             sigc::mem_fun(*work_area, &studio::WorkArea::toggle_grid_snap)));
+//     viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Toggle Guide Snap"),Gtk::AccelKey('k',Gdk::CONTROL_MASK),
+//             sigc::mem_fun(*work_area, &studio::WorkArea::toggle_guide_snap)));
+//     viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Toggle Low-Res"),Gtk::AccelKey('`',Gdk::CONTROL_MASK),
+//             sigc::mem_fun(*work_area, &studio::WorkArea::toggle_low_resolution_flag)));
+//
+//     viewmenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
+//
+//     viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-zoom-in"),Gtk::AccelKey('=',static_cast<Gdk::ModifierType>(0)),
+//             sigc::mem_fun(*work_area, &studio::WorkArea::zoom_in)));
+//     viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-zoom-out"),Gtk::AccelKey('-',static_cast<Gdk::ModifierType>(0)),
+//             sigc::mem_fun(*work_area, &studio::WorkArea::zoom_out)));
+//     viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-zoom-fit"),
+//             sigc::mem_fun(*work_area, &studio::WorkArea::zoom_fit)));
+//     viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-zoom-100"),Gtk::AccelKey('`',static_cast<Gdk::ModifierType>(0)),
+//             sigc::mem_fun(*work_area, &studio::WorkArea::zoom_norm)));
+//     viewmenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
+//
+//     viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-zoom-in"),Gtk::AccelKey('+',static_cast<Gdk::ModifierType>(0)),
+//             sigc::mem_fun(*this, &studio::CanvasView::time_zoom_in)));
+//     viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-zoom-out"),Gtk::AccelKey('_',static_cast<Gdk::ModifierType>(0)),
+//             sigc::mem_fun(*this, &studio::CanvasView::time_zoom_out)));
+//
+//     viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Jump to Next Keyframe"),Gtk::AccelKey(']',static_cast<Gdk::ModifierType>(0)),
+//             sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::jump_to_next_keyframe)));
+//     viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Jump to Prev Keyframe"),Gtk::AccelKey('[',static_cast<Gdk::ModifierType>(0)),
+//             sigc::mem_fun(*canvas_interface().get(), &synfigapp::CanvasInterface::jump_to_prev_keyframe)));
+//
+//     mainmenu.items().push_back(Gtk::Menu_Helpers::TearoffMenuElem());
+//     mainmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("_File"),filemenu));
+//     mainmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Edit"),editmenu));
+//     mainmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("_View"),viewmenu));
+//     mainmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Canvas"),canvasmenu));
+//     mainmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Layer"),layermenu));
+//
+//     mainmenu.accelerate(*this);
+//
+///*
+//     {
+//
+//             trackmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("New Waypoint"),NOT_IMPLEMENTED_SLOT));
+//             trackmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Delete Waypoint"),NOT_IMPLEMENTED_SLOT));
+//             trackmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Export"),NOT_IMPLEMENTED_SLOT));
+//             trackmenu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
+//             trackmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Properties"),NOT_IMPLEMENTED_SLOT));
+//     }
+//*/
+//     mainmenu.show();
+//     filemenu.show();
+//     editmenu.show();
+//     canvasmenu.show();
+//     layermenu.show();
+//
+//     keyframemenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-properties"),
+//             sigc::mem_fun(*this,&studio::CanvasView::show_keyframe_dialog)
+//     ));
+//
+//
+//     get_accel_group()->unlock();
+//
+//     //Set the accelerator paths for all the menus
+//     filemenu.set_accel_path("<synfig>/File");
+//     editmenu.set_accel_path("<synfig>/Edit");
+//     layermenu.set_accel_path("<synfig>/Layer");
+//     //mainmenu.set_accel_path("<synfig-main>");
+//     canvasmenu.set_accel_path("<synfig>/Canvas");
+//     viewmenu.set_accel_path("<synfig>/View");
+//     duckmaskmenu.set_accel_path("<synfig>/DuckMask");
+#endif
+}
+
+void
+CanvasView::on_select_layers()
+{
+       Canvas::Handle canvas(get_canvas());
+       for (CanvasBase::iterator iter = canvas->begin(); iter != canvas->end(); iter++)
+               layer_tree->select_all_children_layers(*iter);
+}
+
+void
+CanvasView::on_unselect_layers()
+{
+       layer_tree->clear_selected_layers();
+}
+
+void
+CanvasView::show_keyframe_dialog()
+{
+       Glib::RefPtr<Gtk::TreeSelection> selection(keyframe_tree->get_selection());
+       if(selection->get_selected())
+       {
+               Gtk::TreeRow row(*selection->get_selected());
+
+               Keyframe keyframe(row[keyframe_tree->model.keyframe]);
+
+               keyframe_dialog.set_keyframe(keyframe);
+               keyframe_dialog.present();
+       }
+}
+
+void
+CanvasView::add_layer(synfig::String x)
+{
+       Canvas::Handle canvas;
+
+       synfigapp::SelectionManager::LayerList layer_list(get_selection_manager()->get_selected_layers());
+
+       int target_depth(0);
+
+       if(layer_list.empty())
+       {
+               canvas=get_canvas();
+       }
+       else
+       {
+               canvas=(*layer_list.begin())->get_canvas();
+               target_depth=canvas->get_depth(*layer_list.begin());
+       }
+
+       Layer::Handle layer(canvas_interface()->add_layer_to(x,canvas,target_depth));
+       if(layer)
+       {
+               get_selection_manager()->clear_selected_layers();
+               get_selection_manager()->set_selected_layer(layer);
+       }
+}
+
+void
+CanvasView::popup_layer_menu(synfig::Layer::Handle layer)
+{
+       //Gtk::Menu* menu(manage(new Gtk::Menu));
+       Gtk::Menu* menu(&parammenu);
+       menu->items().clear();
+
+       synfigapp::Action::ParamList param_list;
+       param_list.add("time",canvas_interface()->get_time());
+       param_list.add("canvas",Canvas::Handle(layer->get_canvas()));
+       param_list.add("canvas_interface",canvas_interface());
+       param_list.add("layer",layer);
+
+       //Gtk::Menu *newlayers(manage(new Gtk::Menu()));
+       //build_new_layer_menu(*newlayers);
+
+       //parammenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("New Layer"),*newlayers));
+
+       if(layer->get_name()=="PasteCanvas")
+       {
+               menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Select All Children"),
+                       sigc::bind(
+                               sigc::mem_fun(
+                                       *layer_tree,
+                                       &studio::LayerTree::select_all_children_layers
+                               ),
+                               layer
+                       )
+               ));
+       }
+
+       add_actions_to_menu(menu, param_list,synfigapp::Action::CATEGORY_LAYER);
+
+       menu->popup(3,gtk_get_current_event_time());
+}
+
+void
+CanvasView::register_layer_type(synfig::Layer::Book::value_type &/*lyr*/,std::map<synfig::String,Gtk::Menu*>* /*category_map*/)
+{
+/*     if(lyr.second.category==CATEGORY_DO_NOT_USE)
+               return;
+
+       if(category_map->count(lyr.second.category)==0)
+               (*category_map)[lyr.second.category]=manage(new Gtk::Menu());
+
+       (*category_map)[lyr.second.category]->items().push_back(Gtk::Menu_Helpers::MenuElem(lyr.second.local_name,
+               sigc::hide_return(
+                       sigc::bind(
+                               sigc::mem_fun(*this,&studio::CanvasView::add_layer),
+                               lyr.first
+                       )
+               )
+       ));
+*/
+}
+
+void
+CanvasView::build_new_layer_menu(Gtk::Menu &/*menu*/)
+{
+/*
+       std::map<synfig::String,Gtk::Menu*> category_map;
+
+       std::for_each(
+               synfig::Layer::book().begin(),
+               synfig::Layer::book().end(),
+               sigc::bind(
+                       sigc::mem_fun(
+                               *this,
+                               &studio::CanvasView::register_layer_type
+                       ),
+                       &category_map
+               )
+       );
+
+       menu.items().clear();
+       menu.items().push_back(Gtk::Menu_Helpers::TearoffMenuElem());
+
+       std::map<synfig::String,Gtk::Menu*>::iterator iter;
+       for(iter=category_map.begin();iter!=category_map.end();++iter)
+               menu.items().push_back(Gtk::Menu_Helpers::MenuElem(iter->first,*iter->second));
+
+       menu.show();
+*/
+}
+
+void
+CanvasView::popup_main_menu()
+{
+       //mainmenu.popup(0,gtk_get_current_event_time());
+       Gtk::Menu* menu = dynamic_cast<Gtk::Menu*>(App::ui_manager()->get_widget("/menu-main"));
+       if(menu)
+       {
+               //menu->set_accel_group(App::ui_manager()->get_accel_group());
+               //menu->accelerate(*this);
+               menu->popup(0,gtk_get_current_event_time());
+       }
+}
+
+void
+CanvasView::on_refresh_pressed()
+{
+       rebuild_tables();
+       rebuild_ducks();
+       work_area->queue_render_preview();
+}
+
+void
+CanvasView::workarea_layer_selected(synfig::Layer::Handle layer)
+{
+       get_selection_manager()->clear_selected_layers();
+       if(layer)
+               get_selection_manager()->set_selected_layer(layer);
+}
+
+void
+CanvasView::refresh_rend_desc()
+{
+       current_time_widget->set_fps(get_canvas()->rend_desc().get_frame_rate());
+
+       //????
+       //synfig::info("Canvasview: Refreshing render desc info");
+       if(!get_time().is_equal(time_adjustment().get_value()))
+       {
+               time_adjustment().set_value(get_time());
+               time_adjustment().value_changed();
+       }
+
+       Time length(get_canvas()->rend_desc().get_time_end()-get_canvas()->rend_desc().get_time_start());
+       if(length<DEFAULT_TIME_WINDOW_SIZE)
+       {
+               time_window_adjustment().set_page_increment(length);
+               time_window_adjustment().set_page_size(length);
+       }
+       else
+       {
+               time_window_adjustment().set_page_increment(DEFAULT_TIME_WINDOW_SIZE);
+               time_window_adjustment().set_page_size(DEFAULT_TIME_WINDOW_SIZE);
+       }
+
+       //set the FPS of the timeslider
+       timeslider->set_global_fps(get_canvas()->rend_desc().get_frame_rate());
+
+       //set the beginning and ending time of the time slider
+       Time begin_time=get_canvas()->rend_desc().get_time_start();
+       Time end_time=get_canvas()->rend_desc().get_time_end();
+
+       // Setup the time_window adjustment
+       time_window_adjustment().set_lower(begin_time);
+       time_window_adjustment().set_upper(end_time);
+       time_window_adjustment().set_step_increment(synfig::Time(1.0/get_canvas()->rend_desc().get_frame_rate()));
+
+       //Time length(get_canvas()->rend_desc().get_time_end()-get_canvas()->rend_desc().get_time_start());
+       if(length < time_window_adjustment().get_page_size())
+       {
+               time_window_adjustment().set_page_increment(length);
+               time_window_adjustment().set_page_size(length);
+       }
+
+       /*synfig::info("w: %p - [%.3f,%.3f] (%.3f,%.3f) child: %p\n",
+                               &time_window_adjustment_, time_window_adjustment_.get_lower(),
+                               time_window_adjustment_.get_upper(),time_window_adjustment_.get_value(),
+                               time_window_adjustment_.get_page_size(),time_window_adjustment_.get_child_adjustment()
+       );*/
+
+       time_window_adjustment().changed(); //only non-value stuff was changed
+
+       // Setup the time adjustment
+
+       //NOTE THESE TWO SHOULD BE CHANGED BY THE changed() CALL ABOVE
+       //time_adjustment().set_lower(time_window_adjustment().get_value());
+       //time_adjustment().set_upper(time_window_adjustment().get_value()+time_window_adjustment().get_page_size());
+
+//     time_adjustment().set_lower(get_canvas()->rend_desc().get_time_start());
+//     time_adjustment().set_upper(get_canvas()->rend_desc().get_time_end());
+       time_adjustment().set_step_increment(synfig::Time(1.0/get_canvas()->rend_desc().get_frame_rate()));
+       time_adjustment().set_page_increment(synfig::Time(1.0));
+       time_adjustment().set_page_size(0);
+
+       time_adjustment().changed();
+
+       /*synfig::info("w: %p - [%.3f,%.3f] (%.3f,%.3f) child: %p\n",
+                               &time_window_adjustment_, time_window_adjustment_.get_lower(),
+                               time_window_adjustment_.get_upper(),time_window_adjustment_.get_value(),
+                               time_window_adjustment_.get_page_size(),time_window_adjustment_.get_child_adjustment()
+       );      */
+
+       if(begin_time==end_time)
+       {
+               hide_timebar();
+       }
+       else
+       {
+               show_timebar();
+       }
+
+       //clamp time to big bounds...
+       if(time_window_adjustment().get_value() < begin_time)
+       {
+               time_window_adjustment().set_value(begin_time);
+               time_window_adjustment().value_changed();
+       }
+
+       if(time_window_adjustment().get_value() + time_window_adjustment().get_page_size() > end_time)
+       {
+               time_window_adjustment().set_value(end_time - time_window_adjustment().get_page_size());
+               time_window_adjustment().value_changed();
+       }
+
+       if(time_adjustment().get_value() < begin_time)
+       {
+               time_adjustment().set_value(begin_time);
+               time_adjustment().value_changed();
+       }
+
+       if(time_adjustment().get_value() > end_time)
+       {
+               time_adjustment().set_value(end_time);
+               time_adjustment().value_changed();
+       }
+
+       /*synfig::info("Time stats: \n"
+                               "w: %p - [%.3f,%.3f] (%.3f,%.3f) child: %p\n"
+                               "t: %p - [%.3f,%.3f] %.3f",
+                               &time_window_adjustment_, time_window_adjustment_.get_lower(),
+                               time_window_adjustment_.get_upper(),time_window_adjustment_.get_value(),
+                               time_window_adjustment_.get_page_size(),time_window_adjustment_.get_child_adjustment(),
+                               &time_adjustment_,time_adjustment_.get_lower(),time_adjustment_.get_upper(),
+                               time_adjustment_.get_value()
+       );*/
+
+       work_area->queue_render_preview();
+}
+
+bool
+CanvasView::close_view()
+{
+       if(get_instance()->get_visible_canvases()==1)
+               close_instance();
+       else
+               hide();
+       return false;
+}
+
+static bool _close_instance(etl::handle<Instance> instance)
+{
+       etl::handle<Instance> argh(instance);
+       instance->safe_close();
+       synfig::info("closed");
+       return false;
+}
+
+bool
+CanvasView::close_instance()
+{
+#ifdef SINGLE_THREADED
+       if (get_work_area()->get_updating())
+       {
+               get_work_area()->stop_updating(true); // stop and mark as cancelled
+
+               // give the workarea chances to stop updating
+               Glib::signal_timeout().connect(
+                       sigc::mem_fun(*this, &CanvasView::close_instance),
+                       250);
+       }
+       else
+#endif
+               Glib::signal_timeout().connect(
+                       sigc::bind(sigc::ptr_fun(_close_instance),
+                                          (etl::handle<Instance>)get_instance()),
+                       250);
+       return false;
+}
+
+handle<CanvasView>
+CanvasView::create(etl::loose_handle<Instance> instance, etl::handle<synfig::Canvas> canvas)
+{
+       etl::handle<studio::CanvasView> view(new CanvasView(instance,instance->synfigapp::Instance::find_canvas_interface(canvas)));
+       instance->canvas_view_list().push_front(view);
+       instance->signal_canvas_view_created()(view.get());
+       return view;
+}
+
+void
+CanvasView::update_title()
+{
+       string title;
+
+       title = strprintf("%s%s\"%s\"",
+                                         (
+                                                 get_instance()->get_action_count()
+                                                 ? "*"
+                                                 : ""
+                                         ), (
+                                                 get_instance()->has_real_filename()
+                                                 ? (etl::basename(get_instance()->get_file_name()) + " : ").c_str()
+                                                 : ""
+                                         ), (
+                                                 get_canvas()->get_name().empty()
+                                                 ? get_canvas()->get_id().c_str()
+                                                 : get_canvas()->get_name().c_str()
+                                         ));
+
+       if(get_instance()->synfigapp::Instance::in_repository())
+       {
+               title+=" (CVS";
+               if(get_instance()->synfigapp::Instance::is_modified())
+                       title+=_("-MODIFIED");
+               if(get_instance()->synfigapp::Instance::is_updated())
+                       title+=_("-UPDATED");
+               title+=')';
+       }
+
+       if(get_canvas()->is_root())
+               title+=_(" (Root)");
+
+       set_title(title);
+}
+
+void
+CanvasView::on_hide()
+{
+       smach_.egress();
+       Gtk::Window::on_hide();
+}
+
+void
+CanvasView::present()
+{
+       grab_focus();//on_focus_in_event(0);
+       Gtk::Window::present();
+}
+
+bool
+CanvasView::on_focus_in_event(GdkEventFocus*x)
+{
+       if(studio::App::get_selected_canvas_view()!=this)
+       {
+               if(studio::App::get_selected_canvas_view())
+               {
+                       studio::App::get_selected_canvas_view()->get_smach().process_event(EVENT_YIELD_TOOL_OPTIONS);
+                       App::ui_manager()->remove_action_group(App::get_selected_canvas_view()->action_group);
+               }
+
+               get_smach().process_event(EVENT_REFRESH_TOOL_OPTIONS);
+
+               studio::App::set_selected_canvas_view(this);
+
+               App::ui_manager()->insert_action_group(action_group);
+       }
+
+       // HACK ... Questionable...?
+       if(x)
+               return Gtk::Window::on_focus_in_event(x);
+
+       return true;
+}
+
+bool
+CanvasView::on_focus_out_event(GdkEventFocus*x)
+{
+       //App::ui_manager()->remove_action_group(action_group);
+       //App::ui_manager()->ensure_update();
+       return Gtk::Window::on_focus_out_event(x);
+}
+
+void
+CanvasView::refresh_tables()
+{
+//     if(layer_tree_store_)layer_tree_store_->refresh();
+//     if(children_tree_store_)children_tree_store_->refresh();
+}
+
+void
+CanvasView::rebuild_tables()
+{
+//     layer_tree_store_->rebuild();
+//     children_tree_store_->rebuild();
+}
+
+void
+CanvasView::build_tables()
+{
+//     layer_tree_store_->rebuild();
+//     children_tree_store_->rebuild();
+}
+
+void
+CanvasView::on_layer_toggle(synfig::Layer::Handle layer)
+{
+       synfigapp::Action::Handle action(synfigapp::Action::create("LayerActivate"));
+       assert(action);
+
+       if(!action)
+               return;
+
+       action->set_param("canvas",Canvas::Handle(layer->get_canvas()));
+       if(!action->set_param("canvas_interface",canvas_interface()))
+//     if(!action->set_param("canvas_interface",get_instance()->find_canvas_interface(layer->get_canvas())))
+               synfig::error("LayerActivate didn't like CanvasInterface...?");
+       action->set_param("time",get_time());
+       action->set_param("layer",layer);
+       action->set_param("new_status",!layer->active());
+
+       assert(action->is_ready());
+
+       canvas_interface()->get_instance()->perform_action(action);
+}
+
+void
+CanvasView::popup_param_menu(synfigapp::ValueDesc value_desc, float location, bool bezier)
+{
+       parammenu.items().clear();
+       get_instance()->make_param_menu(&parammenu,get_canvas(),value_desc,location,bezier);
+
+       parammenu.popup(3,gtk_get_current_event_time());
+}
+
+void
+CanvasView::add_actions_to_menu(Gtk::Menu *menu, const synfigapp::Action::ParamList &param_list,synfigapp::Action::Category category)const
+{
+       get_instance()->add_actions_to_menu(menu, param_list, category);
+}
+
+bool
+CanvasView::on_layer_user_click(int button, Gtk::TreeRow /*row*/, LayerTree::ColumnID /*column_id*/)
+{
+       switch(button)
+       {
+       case 3:
+               {
+                       Gtk::MenuItem* menu = dynamic_cast<Gtk::MenuItem*>(App::ui_manager()->get_widget("/menu-main/menu-layer"));
+                       if(menu && menu->get_submenu())
+                       {
+                               //menu->set_accel_group(App::ui_manager()->get_accel_group());
+                               //menu->accelerate(*this);
+                               menu->get_submenu()->popup(button,gtk_get_current_event_time());
+                       }
+
+                       #if 0
+                       bool multiple_selected=true;
+
+                       if(layer_tree->get_selection()->count_selected_rows()<=1)
+                               multiple_selected=false;
+
+                       // If the clicked row is not selected, then unselect
+                       // everything that isn't selected and select this row
+                       if(multiple_selected && !layer_tree->get_selection()->is_selected(row))
+                       {
+                               layer_tree->get_selection()->unselect_all();
+                               layer_tree->get_selection()->select(row);
+                               multiple_selected=false;
+                       }
+
+                       if(column_id==COLUMNID_TIME_TRACK)
+                               return false;
+
+                       //synfigapp::ValueDesc value_desc(row[layer_param_tree_model.value_desc]);
+                       //ValueNode::Handle value_node(row[layer_param_tree_model.value_node]);
+                       //ValueNode::Handle parent_value_node;
+                       //ValueBase value=row[layer_param_tree_model.value];
+
+                       //if(row.parent())
+                       //{
+                       //      parent_value_node=(*row.parent())[layer_tree_model.value_node];
+                       //}
+
+                       {
+                               Layer::Handle layer(row[layer_tree_model.layer]);
+                               synfigapp::Action::ParamList param_list;
+                               param_list.add("time",canvas_interface()->get_time());
+                               param_list.add("canvas",Canvas::Handle(row[layer_tree_model.canvas]));
+                               param_list.add("canvas_interface",canvas_interface());
+                               if(!multiple_selected)
+                                       param_list.add("layer",layer);
+                               else
+                               {
+                                       synfigapp::SelectionManager::LayerList layer_list(get_selection_manager()->get_selected_layers());
+                                       synfigapp::SelectionManager::LayerList::iterator iter;
+
+                                       for(iter=layer_list.begin();iter!=layer_list.end();++iter)
+                                               param_list.add("layer",Layer::Handle(*iter));
+                               }
+
+                               parammenu.items().clear();
+
+                               Gtk::Menu *newlayers(manage(new Gtk::Menu()));
+                               // do we need this?  the code is all #ifdef'ed out anyway
+                               // newlayers->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), newlayers));
+                               build_new_layer_menu(*newlayers);
+
+                               parammenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("New Layer"),*newlayers));
+                               if(!multiple_selected && layer->get_name()=="PasteCanvas")
+                               {
+                                       parammenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Select All Children"),
+                                               sigc::bind(
+                                                       sigc::mem_fun(
+                                                               *layer_tree,
+                                                               &studio::LayerTree::select_all_children_layers
+                                                       ),
+                                                       layer
+                                               )
+                                       ));
+                               }
+
+                               add_actions_to_menu(&parammenu, param_list,synfigapp::Action::CATEGORY_LAYER);
+                               parammenu.popup(button,gtk_get_current_event_time());
+                               return true;
+                       }
+/*
+                       else if(column_id==LayerTree::COLUMNID_TIME_TRACK && value_node && handle<synfig::ValueNode_Animated>::cast_dynamic(value_node))
+                       {
+                               // Right-click on time track with animated
+//                             trackmenu.popup(0,0);
+                               return true;
+                       }
+                       else
+                       {
+                               if(!multiple_selected)
+                               {
+                                       popup_param_menu(value_desc);
+                                       return true;
+                               }
+                               else
+                               {
+#warning update me!
+#if 0
+                                       parammenu.items().clear();
+                                       parammenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Connect"),
+                                               hide_return(sigc::mem_fun(*canvas_interface().get(),&synfigapp::CanvasInterface::connect_selected_layer_params))
+                                       ));
+                                       parammenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Disconnect"),
+                                               hide_return(sigc::mem_fun(*canvas_interface().get(),&synfigapp::CanvasInterface::disconnect_selected_layer_params))
+                                       ));
+                                       parammenu.popup(0,0);
+#endif
+                               }
+                               return true;
+                       }
+               */
+#endif
+}
+               return true;
+               break;
+
+       default:
+               return false;
+               break;
+       }
+}
+
+bool
+CanvasView::on_children_user_click(int button, Gtk::TreeRow row, ChildrenTree::ColumnID column_id)
+{
+       switch(button)
+       {
+       case 3:
+               {
+                       if(column_id==COLUMNID_TIME_TRACK)
+                               return false;
+                       if(!(bool)row[children_tree_model.is_canvas])
+                       {
+                               synfigapp::ValueDesc value_desc=row[children_tree_model.value_desc];
+                               if (!value_desc)
+                               {
+                                       //! \todo fix properly -- what is the child dialog for?
+                                       synfig::info("preventing child dialog right-click crash");
+                                       return true;
+                               }
+                               assert(value_desc);
+                               popup_param_menu(value_desc);
+                               return true;
+                       }
+               }
+               return true;
+               break;
+
+       default:
+               return false;
+               break;
+       }
+}
+
+bool
+CanvasView::on_keyframe_tree_event(GdkEvent *event)
+{
+    switch(event->type)
+    {
+       case GDK_BUTTON_PRESS:
+               switch(event->button.button)
+               {
+                       case 3:
+                       {
+                               //keyframemenu.popup(event->button.button,gtk_get_current_event_time());
+                               return true;
+                       }
+                       break;
+               }
+               break;
+       case GDK_MOTION_NOTIFY:
+               break;
+       case GDK_BUTTON_RELEASE:
+               break;
+       default:
+               break;
+       }
+       return false;
+}
+
+void
+CanvasView::refresh_time_window()
+{
+       //THESE SHOULD AUTOMATICALLY BE TAKEN CARE OF
+       //time_adjustment().set_lower(time_window_adjustment().get_value());
+       //time_adjustment().set_upper(time_window_adjustment().get_value()+time_window_adjustment().get_page_size());
+
+       time_adjustment().set_page_increment(1.0); // One second
+       time_adjustment().set_page_size(0);
+
+       if(get_canvas())
+               time_adjustment().set_step_increment(1.0/get_canvas()->rend_desc().get_frame_rate());
+       time_adjustment().changed();
+
+       //NOTE THIS SHOULD HOOK INTO THE CORRECT SIGNALS...
+       if(children_tree)
+               children_tree->queue_draw();
+}
+
+void
+CanvasView::on_time_changed()
+{
+       Time time(get_time());
+
+       current_time_widget->set_value(time);
+       try {
+               get_canvas()->keyframe_list().find(time);
+               current_time_widget->modify_text(Gtk::STATE_NORMAL,Gdk::Color("#FF0000"));
+       }catch(...){
+               current_time_widget->modify_text(Gtk::STATE_NORMAL,Gdk::Color("#000000"));
+       }
+
+       if(get_time() != time_adjustment().get_value())
+       {
+               //Recenters the window, causing it to jump (possibly undesirably... but whatever)
+               if(time < time_window_adjustment().get_value() ||
+                       time > time_window_adjustment().get_value()+time_window_adjustment().get_page_size())
+               {
+                       time_window_adjustment().set_value(
+                               time-time_window_adjustment().get_page_size()/2
+                       );
+               }
+               time_adjustment().set_value(time);
+               time_adjustment().value_changed();
+
+               // Shouldn't these trees just hook into
+               // the time changed signal...?
+               //YES THEY SHOULD...
+               if(layer_tree)layer_tree->queue_draw();
+               if(children_tree)children_tree->queue_draw();
+       }
+}
+
+void
+CanvasView::time_zoom_in()
+{
+       float frame_rate = get_canvas()->rend_desc().get_frame_rate();
+       Time min_page_size = 2/frame_rate;
+
+       time_window_adjustment().set_page_size(time_window_adjustment().get_page_size()*0.75);
+       if (time_window_adjustment().get_page_size() < min_page_size)
+               time_window_adjustment().set_page_size(min_page_size);
+       time_window_adjustment().set_page_increment(time_window_adjustment().get_page_size());
+       time_window_adjustment().changed();
+
+       refresh_time_window();
+}
+
+void
+CanvasView::time_zoom_out()
+{
+       Time length = (get_canvas()->rend_desc().get_time_end() -
+                                  get_canvas()->rend_desc().get_time_start());
+
+       time_window_adjustment().set_page_size(time_window_adjustment().get_page_size()/0.75);
+       if (time_window_adjustment().get_page_size() > length)
+               time_window_adjustment().set_page_size(length);
+       time_window_adjustment().set_page_increment(time_window_adjustment().get_page_size());
+       time_window_adjustment().changed();
+
+       refresh_time_window();
+}
+
+void
+CanvasView::time_was_changed()
+{
+       synfig::Time time((synfig::Time)(double)time_adjustment().get_value());
+       set_time(time);
+}
+
+void
+CanvasView::on_edited_value(synfigapp::ValueDesc value_desc,synfig::ValueBase new_value)
+{
+       canvas_interface()->change_value(value_desc,new_value);
+}
+
+/*
+void
+CanvasView::on_children_edited_value(const Glib::ustring&path_string,synfig::ValueBase value)
+{
+       Gtk::TreePath path(path_string);
+
+       const Gtk::TreeRow row = *(children_tree->get_model()->get_iter(path));
+
+       assert((bool)row[children_tree_model.is_value_node]);
+
+       synfigapp::ValueDesc value_desc=row[children_tree_model.value_desc];
+       assert(value_desc);
+
+       on_edited_value(value_desc,value);
+}
+*/
+
+void
+CanvasView::on_id_changed()
+{
+       update_title();
+}
+
+void
+CanvasView::on_mode_changed(synfigapp::CanvasInterface::Mode mode)
+{
+       // If the animate flag was set in mode...
+       Gtk::IconSize iconsize=Gtk::IconSize::from_name("synfig-small_icon");
+       if(mode&synfigapp::MODE_ANIMATE)
+       {
+               Gtk::Image *icon;
+               icon=manage(new Gtk::Image(Gtk::StockID("gtk-no"),iconsize));
+               animatebutton->remove();
+               animatebutton->add(*icon);
+               tooltips.set_tip(*animatebutton,_("In Animate Editing Mode"));
+               icon->set_padding(0,0);
+               icon->show();
+       }
+       else
+       {
+               Gtk::Image *icon;
+               icon=manage(new Gtk::Image(Gtk::StockID("gtk-yes"),iconsize));
+               animatebutton->remove();
+               animatebutton->add(*icon);
+               tooltips.set_tip(*animatebutton,_("Not in Animate Editing Mode"));
+               icon->set_padding(0,0);
+               icon->show();
+       }
+
+       if((mode&synfigapp::MODE_ANIMATE_FUTURE) && (mode&synfigapp::MODE_ANIMATE_PAST))
+       {
+               Gtk::Image *icon;
+               icon=manage(new Gtk::Image(Gtk::StockID("synfig-keyframe_lock_all"),Gtk::ICON_SIZE_BUTTON));
+               keyframebutton->remove();
+               keyframebutton->add(*icon);
+               tooltips.set_tip(*keyframebutton,_("All Keyframes Locked"));
+               icon->set_padding(0,0);
+               icon->show();
+       }
+       else if((mode&synfigapp::MODE_ANIMATE_FUTURE) && !(mode&synfigapp::MODE_ANIMATE_PAST))
+       {
+               Gtk::Image *icon;
+               icon=manage(new Gtk::Image(Gtk::StockID("synfig-keyframe_lock_future"),Gtk::ICON_SIZE_BUTTON));
+               keyframebutton->remove();
+               keyframebutton->add(*icon);
+               tooltips.set_tip(*keyframebutton,_("Future Keyframes Locked"));
+               icon->set_padding(0,0);
+               icon->show();
+       }
+       else if(!(mode&synfigapp::MODE_ANIMATE_FUTURE) && (mode&synfigapp::MODE_ANIMATE_PAST))
+       {
+               Gtk::Image *icon;
+               icon=manage(new Gtk::Image(Gtk::StockID("synfig-keyframe_lock_past"),Gtk::ICON_SIZE_BUTTON));
+               keyframebutton->remove();
+               keyframebutton->add(*icon);
+               tooltips.set_tip(*keyframebutton,_("Past Keyframes Locked"));
+               icon->set_padding(0,0);
+               icon->show();
+       }
+       else if(!(mode&synfigapp::MODE_ANIMATE_FUTURE) && !(mode&synfigapp::MODE_ANIMATE_PAST))
+       {
+               Gtk::Image *icon;
+               icon=manage(new Gtk::Image(Gtk::StockID("synfig-keyframe_lock_none"),Gtk::ICON_SIZE_BUTTON));
+               keyframebutton->remove();
+               keyframebutton->add(*icon);
+               tooltips.set_tip(*keyframebutton,_("No Keyframes Locked"));
+               icon->set_padding(0,0);
+               icon->show();
+       }
+
+       work_area->queue_draw();
+}
+
+void
+CanvasView::on_animate_button_pressed()
+{
+       if(get_mode()&synfigapp::MODE_ANIMATE)
+               set_mode(get_mode()-synfigapp::MODE_ANIMATE);
+       else
+               set_mode(get_mode()|synfigapp::MODE_ANIMATE);
+}
+
+void
+CanvasView::on_keyframe_button_pressed()
+{
+       synfigapp::CanvasInterface::Mode mode(get_mode());
+
+       //   future && past   -->             past
+       if((mode&synfigapp::MODE_ANIMATE_FUTURE) && (mode&synfigapp::MODE_ANIMATE_PAST))
+               set_mode(get_mode()-synfigapp::MODE_ANIMATE_FUTURE);
+       //             past   -->   future
+       else if(!(mode&synfigapp::MODE_ANIMATE_FUTURE) && (mode&synfigapp::MODE_ANIMATE_PAST))
+               set_mode((get_mode()-synfigapp::MODE_ANIMATE_PAST)|synfigapp::MODE_ANIMATE_FUTURE);
+       //   future           -->       (nothing)
+       else if((mode&synfigapp::MODE_ANIMATE_FUTURE) && !(mode&synfigapp::MODE_ANIMATE_PAST))
+               set_mode(get_mode()-synfigapp::MODE_ANIMATE_FUTURE);
+       //      (nothing)     -->   future && past
+       else if(!(mode&synfigapp::MODE_ANIMATE_FUTURE) && !(mode&synfigapp::MODE_ANIMATE_PAST))
+               set_mode(get_mode()|synfigapp::MODE_ANIMATE_FUTURE|synfigapp::MODE_ANIMATE_PAST);
+}
+
+bool
+CanvasView::duck_change_param(const synfig::Point &value,synfig::Layer::Handle layer, synfig::String param_name)
+{
+       return canvas_interface()->change_value(synfigapp::ValueDesc(layer,param_name),value);
+}
+
+bool
+CanvasView::on_duck_changed(const synfig::Point &value,const synfigapp::ValueDesc& value_desc)
+{
+       if (ValueNode_BLineCalcWidth::Handle bline_width = ValueNode_BLineCalcWidth::Handle::cast_dynamic(value_desc.get_value_node()))
+       {
+               Real old_width((*bline_width)(get_time()).get(Real()));
+               Real new_width(value.mag());
+               int scale_index(bline_width->get_link_index_from_name("scale"));
+               Real scale((*(bline_width->get_link(scale_index)))(get_time()).get(Real()));
+               return canvas_interface()->change_value(synfigapp::ValueDesc(bline_width,scale_index), new_width * scale / old_width);
+       }
+
+       if (ValueNode_BLineCalcVertex::Handle bline_vertex = ValueNode_BLineCalcVertex::Handle::cast_dynamic(value_desc.get_value_node()))
+       {
+               ValueNode_BLine::Handle bline = ValueNode_BLine::Handle::cast_dynamic(bline_vertex->get_link("bline"));
+               Real radius = 0.0;
+               if (((*(bline_vertex->get_link("loop")))(get_time()).get(bool()))){
+                       Real amount_old((*(bline_vertex->get_link("amount")))(get_time()).get(Real()));
+                       Real amount_new = synfig::find_closest_point((*bline)(get_time()), value, radius, bline->get_loop());
+                       Real difference = fmod( fmod(amount_new - amount_old, 1.0) + 1.0 , 1.0);
+                                                       //fmod is called twice to avoid negative values
+                       if (difference > 0.5) difference=difference-1.0;
+                       return canvas_interface()->change_value(synfigapp::ValueDesc(bline_vertex,bline_vertex->get_link_index_from_name("amount")), amount_old+difference);
+
+               } else {
+                       Real amount = synfig::find_closest_point((*bline)(get_time()), value, radius, bline->get_loop());
+                       return canvas_interface()->change_value(synfigapp::ValueDesc(bline_vertex,bline_vertex->get_link_index_from_name("amount")), amount);
+               }
+       }
+
+       if (ValueNode_BLineCalcTangent::Handle bline_tangent = ValueNode_BLineCalcTangent::Handle::cast_dynamic(value_desc.get_value_node()))
+       {
+               switch(value_desc.get_value_type())
+               {
+               case ValueBase::TYPE_REAL:
+               {
+                       Real old_length = (*bline_tangent)(get_time()).get(Real());
+                       Real new_length = value.mag();
+                       int scale_index(bline_tangent->get_link_index_from_name("scale"));
+                       int fixed_length_index(bline_tangent->get_link_index_from_name("fixed_length"));
+                       Real scale((*(bline_tangent->get_link(scale_index)))(get_time()).get(Real()));
+                       bool fixed_length((*(bline_tangent->get_link(fixed_length_index)))(get_time()).get(bool()));
+                       if (fixed_length)
+                               return canvas_interface()->change_value(synfigapp::ValueDesc(bline_tangent,scale_index), new_length);
+                       if (old_length == 0)
+                               return true;
+                       return canvas_interface()->change_value(synfigapp::ValueDesc(bline_tangent,scale_index), new_length * scale / old_length);
+               }
+
+               case ValueBase::TYPE_ANGLE:
+                       assert(0);                      // doesn't happen?
+                       break;
+
+               case ValueBase::TYPE_VECTOR:
+               {
+                       Vector old_tangent = (*bline_tangent)(get_time()).get(Vector());
+                       Angle old_angle = old_tangent.angle();
+                       Real old_length = old_tangent.mag();
+                       Angle new_angle = value.angle();
+                       Real new_length = value.mag();
+                       int offset_index(bline_tangent->get_link_index_from_name("offset"));
+                       int scale_index(bline_tangent->get_link_index_from_name("scale"));
+                       int fixed_length_index(bline_tangent->get_link_index_from_name("fixed_length"));
+                       Angle old_offset((*(bline_tangent->get_link(offset_index)))(get_time()).get(Angle()));
+                       Real scale((*(bline_tangent->get_link(scale_index)))(get_time()).get(Real()));
+                       bool fixed_length((*(bline_tangent->get_link(fixed_length_index)))(get_time()).get(bool()));
+                       if (fixed_length)
+                       {
+                               if (!(canvas_interface()->change_value(synfigapp::ValueDesc(bline_tangent,scale_index), new_length)))
+                                       return false;
+                       }
+                       else if (old_length != 0 && !(canvas_interface()->change_value(synfigapp::ValueDesc(bline_tangent,scale_index), new_length * scale / old_length)))
+                               return false;
+                       return canvas_interface()->change_value(synfigapp::ValueDesc(bline_tangent,offset_index), old_offset + new_angle - old_angle);
+               }
+               default:
+                       break;
+               }
+       }
+
+       if (ValueNode_Scale::Handle scale_value_node = ValueNode_Scale::Handle::cast_dynamic(value_desc.get_value_node()))
+       {
+               int link_index(scale_value_node->get_link_index_from_name("link"));
+               if(scale_value_node->is_invertible(get_time()))
+                       return canvas_interface()->change_value(
+                               synfigapp::ValueDesc(scale_value_node,link_index),
+                                       scale_value_node->get_inverse(get_time(), value)
+                                       );
+               else
+                       return false;
+       }
+
+       if (ValueNode_Range::Handle range_value_node = ValueNode_Range::Handle::cast_dynamic(value_desc.get_value_node()))
+       {
+               int link_index(range_value_node->get_link_index_from_name("link"));
+               return canvas_interface()->change_value(
+                       synfigapp::ValueDesc(range_value_node,link_index),
+                               range_value_node->get_inverse(get_time(), value)
+                               );
+       }
+
+       switch(value_desc.get_value_type())
+       {
+       case ValueBase::TYPE_REAL:
+               return canvas_interface()->change_value(value_desc,value.mag());
+       case ValueBase::TYPE_ANGLE:
+               return canvas_interface()->change_value(value_desc,Angle::tan(value[1],value[0]));
+       default:
+               return canvas_interface()->change_value(value_desc,value);
+       }
+}
+
+bool
+CanvasView::on_duck_angle_changed(const synfig::Angle &rotation,const synfigapp::ValueDesc& value_desc)
+{
+       if (ValueNode_BLineCalcTangent::Handle bline_tangent = ValueNode_BLineCalcTangent::Handle::cast_dynamic(value_desc.get_value_node()))
+       {
+               int offset_index(bline_tangent->get_link_index_from_name("offset"));
+               Angle old_offset((*(bline_tangent->get_link(offset_index)))(get_time()).get(Angle()));
+               return canvas_interface()->change_value(synfigapp::ValueDesc(bline_tangent,offset_index), old_offset + rotation);
+       }
+
+       if (ValueNode_Scale::Handle scale_value_node = ValueNode_Scale::Handle::cast_dynamic(value_desc.get_value_node()))
+       {
+               int link_index(scale_value_node->get_link_index_from_name("link"));
+               if(scale_value_node->is_invertible(get_time()))
+                       return canvas_interface()->change_value(
+                               synfigapp::ValueDesc(scale_value_node,link_index),
+                                       scale_value_node->get_inverse(get_time(), rotation)
+                                       );
+               else
+                       return false;
+
+       }
+       if (ValueNode_Range::Handle range_value_node = ValueNode_Range::Handle::cast_dynamic(value_desc.get_value_node()))
+       {
+               int link_index(range_value_node->get_link_index_from_name("link"));
+               return canvas_interface()->change_value(
+                       synfigapp::ValueDesc(range_value_node,link_index),
+                               range_value_node->get_inverse(get_time(), rotation)
+                               );
+       }
+       // \todo will this really always be the case?
+       assert(value_desc.get_value_type() == ValueBase::TYPE_ANGLE);
+       return canvas_interface()->change_value(value_desc, value_desc.get_value(get_time()).get(Angle()) + rotation);
+}
+
+void
+CanvasView::selected_layer_color_set(synfig::Color color)
+{
+       synfigapp::SelectionManager::LayerList selected_list(get_selection_manager()->get_selected_layers());
+       synfigapp::SelectionManager::LayerList::iterator iter;
+
+       // Create the action group
+       //synfigapp::PassiveGrouper group(canvas_interface()->get_instance(),_("Set Colors"));
+
+       Layer::Handle layer;
+       for(iter=selected_list.begin();iter!=selected_list.end();++iter)
+       {
+               if(*iter==layer)
+                       continue;
+               layer=*iter;
+               on_edited_value(synfigapp::ValueDesc(layer,"color"),color);
+       }
+}
+
+void
+CanvasView::rebuild_ducks_layer_(synfig::TransformStack& transform_stack, synfig::Canvas::Handle canvas, std::set<synfig::Layer::Handle>& selected_list)
+{
+       int transforms(0);
+       String layer_name;
+
+#define QUEUE_REBUILD_DUCKS            sigc::mem_fun(*this,&CanvasView::queue_rebuild_ducks)
+
+       if(!canvas)
+       {
+               synfig::warning("CanvasView::rebuild_ducks_layer_(): Layer doesn't have canvas set");
+               return;
+       }
+       for(Canvas::iterator iter(canvas->begin());iter!=canvas->end();++iter)
+       {
+               Layer::Handle layer(*iter);
+
+               if(selected_list.count(layer))
+               {
+                       if(!curr_transform_stack_set)
+                       {
+                               curr_transform_stack_set=true;
+                               curr_transform_stack=transform_stack;
+                       }
+
+                       // This layer is currently selected.
+                       duck_changed_connections.push_back(layer->signal_changed().connect(QUEUE_REBUILD_DUCKS));
+
+                       // do the bounding box thing
+                       bbox|=transform_stack.perform(layer->get_bounding_rect());
+
+                       // Grab the layer's list of parameters
+                       Layer::ParamList paramlist(layer->get_param_list());
+
+                       // Grab the layer vocabulary
+                       Layer::Vocab vocab=layer->get_param_vocab();
+                       Layer::Vocab::iterator iter;
+
+                       for(iter=vocab.begin();iter!=vocab.end();iter++)
+                       {
+                               if(!iter->get_hidden() && !iter->get_invisible_duck())
+                               {
+                                       synfigapp::ValueDesc value_desc(layer,iter->get_name());
+                                       work_area->add_to_ducks(value_desc,this,transform_stack,&*iter);
+                                       if(value_desc.is_value_node())
+                                               duck_changed_connections.push_back(value_desc.get_value_node()->signal_changed().connect(QUEUE_REBUILD_DUCKS));
+                               }
+                               if(iter->get_name()=="color")
+                               {
+                                       /*
+                                       if(!App::dialog_color->busy())
+                                       {
+                                               App::dialog_color->reset();
+                                               App::dialog_color->set_color(layer->get_param("color").get(Color()));
+                                               App::dialog_color->signal_edited().connect(
+                                                       sigc::mem_fun(
+                                                               *this,
+                                                               &studio::CanvasView::selected_layer_color_set
+                                                       )
+                                               );
+                                       }
+                                       */
+                               }
+                       }
+               }
+
+               layer_name=layer->get_name();
+
+               if(layer->active())
+               {
+                       Transform::Handle trans(layer->get_transform());
+                       if(trans)
+                       {
+                               transform_stack.push(trans);
+                               transforms++;
+                       }
+
+/*                     // Add transforms onto the stack
+                       if(layer_name=="Translate")
+                       {
+                               transform_stack.push(synfig::Transform_Translate(layer->get_param("origin").get(Vector())));
+                               transforms++;
+                       }else
+                       if(layer_name=="Zoom")
+                       {
+                               Vector scale;
+                               scale[0]=scale[1]=exp(layer->get_param("amount").get(Real()));
+                               transform_stack.push(synfig::Transform_Scale(scale,layer->get_param("center").get(Vector())));
+                               transforms++;
+                       }else
+                       if(layer_name=="stretch")
+                       {
+                               Vector scale(layer->get_param("amount").get(Vector()));
+                               transform_stack.push(synfig::Transform_Scale(scale,layer->get_param("center").get(Vector())));
+                               transforms++;
+                       }else
+                       if(layer_name=="Rotate")
+                       {
+                               transform_stack.push(synfig::Transform_Rotate(layer->get_param("amount").get(Angle()),layer->get_param("origin").get(Vector())));
+                               transforms++;
+                       }
+*/
+               }
+
+               // If this is a paste canvas layer, then we need to
+               // descend into it
+               if(layer_name=="PasteCanvas")
+               {
+                       Vector scale;
+                       scale[0]=scale[1]=exp(layer->get_param("zoom").get(Real()));
+                       Vector origin(layer->get_param("origin").get(Vector()));
+
+                       Canvas::Handle child_canvas(layer->get_param("canvas").get(Canvas::Handle()));
+                       Vector focus(layer->get_param("focus").get(Vector()));
+
+                       if(!scale.is_equal_to(Vector(1,1)))
+                               transform_stack.push(new Transform_Scale(layer->get_guid(), scale,origin+focus));
+                       if(!origin.is_equal_to(Vector(0,0)))
+                               transform_stack.push(new Transform_Translate(layer->get_guid(), origin));
+
+                       rebuild_ducks_layer_(transform_stack,child_canvas,selected_list);
+
+                       if(!origin.is_equal_to(Vector(0,0)))
+                               transform_stack.pop();
+                       if(!scale.is_equal_to(Vector(1,1)))
+                               transform_stack.pop();
+               }
+       }
+       // Remove all of the transforms we have added
+       while(transforms--) { transform_stack.pop(); }
+
+#undef QUEUE_REBUILD_DUCKS
+}
+
+void
+CanvasView::queue_rebuild_ducks()
+{
+#if 0
+       if(rebuild_ducks_queued)
+               return;
+#else
+       if(rebuild_ducks_queued)
+               queue_rebuild_ducks_connection.disconnect();
+#endif
+
+       queue_rebuild_ducks_connection=Glib::signal_timeout().connect(
+               sigc::bind_return(
+                       sigc::mem_fun(*this,&CanvasView::rebuild_ducks),
+                       false
+               ),
+               50
+       );
+
+       rebuild_ducks_queued=true;
+}
+
+void
+CanvasView::rebuild_ducks()
+{
+       /*static int i=0;
+       i++;
+       if(i>30)
+               synfig::info("%d",i/(i-i));
+       */
+
+       rebuild_ducks_queued=false;
+       //queue_rebuild_ducks_connection.disconnect();
+
+       if(work_area->is_dragging())
+       {
+               queue_rebuild_ducks();
+               return;
+       }
+
+       if(!duck_refresh_flag)
+       {
+               duck_refresh_needed=true;
+               return;
+       }
+
+       bbox=Rect::zero();
+
+       work_area->clear_ducks();
+       work_area->set_time(get_time());
+       get_canvas()->set_time(get_time());
+       curr_transform_stack.clear();
+       //curr_transform_stack.push(new Transform_Translate(Point(0,0)));
+       curr_transform_stack_set=false;
+
+       for(;!duck_changed_connections.empty();duck_changed_connections.pop_back())duck_changed_connections.back().disconnect();
+
+       //get_canvas()->set_time(get_time());
+       bool not_empty(false);
+
+       // First do the layers...
+       do{
+               synfigapp::SelectionManager::LayerList selected_list(get_selection_manager()->get_selected_layers());
+               std::set<synfig::Layer::Handle> layer_set(selected_list.begin(),selected_list.end());
+
+               if(!layer_set.empty())
+                       not_empty=true;
+
+               synfig::TransformStack transform_stack;
+
+               rebuild_ducks_layer_(transform_stack, get_canvas(), layer_set);
+
+       }while(0);
+
+       // Now do the children
+       do{
+               synfigapp::SelectionManager::ChildrenList selected_list(get_selection_manager()->get_selected_children());
+               synfigapp::SelectionManager::ChildrenList::iterator iter;
+               synfig::TransformStack transform_stack;
+
+               if(selected_list.empty())
+               {
+                       break;
+               }
+               else
+               {
+                       not_empty=true;
+                       for(iter=selected_list.begin();iter!=selected_list.end();++iter)
+                       {
+                               work_area->add_to_ducks(*iter,this,transform_stack);
+                       }
+               }
+       }while(0);
+       work_area->refresh_selected_ducks();
+       work_area->queue_draw_preview();
+}
+
+void
+CanvasView::decrease_low_res_pixel_size()
+{
+       if(changing_resolution_)
+               return;
+       changing_resolution_=true;
+       list<int> sizes = CanvasView::get_pixel_sizes();
+       int pixel_size = work_area->get_low_res_pixel_size();
+       for (list<int>::iterator iter = sizes.begin(); iter != sizes.end(); iter++)
+               if (*iter == pixel_size)
+               {
+                       if (iter == sizes.begin())
+                               // we already have the smallest low-res pixels possible - turn off low-res instead
+                               work_area->set_low_resolution_flag(false);
+                       else
+                       {
+                               iter--;
+                               Glib::RefPtr<Gtk::Action> action = action_group->get_action(strprintf("lowres-pixel-%d", *iter));
+                               action->activate(); // to make sure the radiobutton in the menu is updated too
+                               work_area->set_low_resolution_flag(true);
+                       }
+                       break;
+               }
+       // Update the "toggle-low-res" action
+       Glib::RefPtr<Gtk::ToggleAction> action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("toggle-low-res"));
+       action->set_active(work_area->get_low_resolution_flag());
+       // Update toggle low res button
+       resolutiondial->update_lowres(work_area->get_low_resolution_flag());
+       changing_resolution_=false;
+}
+
+void
+CanvasView::increase_low_res_pixel_size()
+{
+       if(changing_resolution_)
+               return;
+       changing_resolution_=true;
+       list<int> sizes = CanvasView::get_pixel_sizes();
+       int pixel_size = work_area->get_low_res_pixel_size();
+       if (!work_area->get_low_resolution_flag())
+       {
+               // We were using "hi res" so change it to low res.
+               work_area->set_low_resolution_flag(true);
+               // Update the "toggle-low-res" action
+               Glib::RefPtr<Gtk::ToggleAction> action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("toggle-low-res"));
+               action->set_active(true);
+               // Update the toggle low res button
+               resolutiondial->update_lowres(true);
+               changing_resolution_=false;
+               return;
+       }
+
+       for (list<int>::iterator iter = sizes.begin(); iter != sizes.end(); iter++)
+               if (*iter == pixel_size)
+               {
+                       iter++;
+                       if (iter != sizes.end())
+                       {
+                               Glib::RefPtr<Gtk::Action> action = action_group->get_action(strprintf("lowres-pixel-%d", *iter));
+                               action->activate(); // to make sure the radiobutton in the menu is updated too
+                               work_area->set_low_resolution_flag(true);
+                       }
+                       break;
+               }
+       // Update the "toggle-low-res" action
+       Glib::RefPtr<Gtk::ToggleAction> action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("toggle-low-res"));
+       action->set_active(work_area->get_low_resolution_flag());
+       // Update toggle low res button
+       resolutiondial->update_lowres(work_area->get_low_resolution_flag());
+       changing_resolution_=false;
+}
+
+void
+CanvasView::toggle_low_res_pixel_flag()
+{
+       if(changing_resolution_)
+               return;
+       changing_resolution_=true;
+       work_area->toggle_low_resolution_flag();
+       // Update the toggle low res button
+       resolutiondial->update_lowres(work_area->get_low_resolution_flag());
+       // Update the "toggle-low-res" action
+       Glib::RefPtr<Gtk::ToggleAction> action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("toggle-low-res"));
+       action->set_active(work_area->get_low_resolution_flag());
+       changing_resolution_=false;
+}
+
+void
+CanvasView::update_quality()
+{
+       //if(working_depth)
+       //              return;
+       if(updating_quality_)
+               return;
+       updating_quality_=true;
+       work_area->set_quality((int) quality_spin->get_value());
+       // Update Quality Radio actions
+       Glib::RefPtr<Gtk::RadioAction> action=Glib::RefPtr<Gtk::RadioAction>::cast_dynamic(
+               action_group->get_action(strprintf("quality-%02d",(int) quality_spin->get_value()))
+               );
+       action->set_active();
+
+       updating_quality_=false;
+}
+
+void
+CanvasView::set_quality(int x)
+{
+       if(updating_quality_)
+               return;
+       work_area->set_quality(x);
+       // Update the quality spin button
+       quality_spin->set_value(x);
+}
+
+void
+CanvasView::set_onion_skins()
+{
+       if(toggling_onion_skin)
+               return;
+       int onion_skins[2];
+       onion_skins[0]=past_onion_spin->get_value();
+       onion_skins[1]=future_onion_spin->get_value();
+       work_area->set_onion_skins(onion_skins);
+}
+
+void
+CanvasView::toggle_show_grid()
+{
+       if(toggling_show_grid)
+               return;
+       toggling_show_grid=true;
+       work_area->toggle_grid();
+       // Update the toggle grid show action
+       set_grid_show_toggle(work_area->grid_status());
+       // Update the toggle grid show check button
+       show_grid->set_active(work_area->grid_status());
+       toggling_show_grid=false;
+}
+
+void
+CanvasView::toggle_snap_grid()
+{
+       if(toggling_snap_grid)
+               return;
+       toggling_snap_grid=true;
+       work_area->toggle_grid_snap();
+       // Update the toggle grid snap action
+       set_grid_snap_toggle(work_area->get_grid_snap());
+       // Update the toggle grid snap check button
+       snap_grid->set_active(work_area->get_grid_snap());
+       toggling_snap_grid=false;
+}
+
+void
+CanvasView::toggle_onion_skin()
+{
+       if(toggling_onion_skin)
+               return;
+       toggling_onion_skin=true;
+       work_area->toggle_onion_skin();
+       // Update the toggle onion skin action
+       Glib::RefPtr<Gtk::ToggleAction> action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("toggle-onion-skin"));
+       action->set_active(work_area->get_onion_skin());
+       // Update the toggle grid snap check button
+       onion_skin->set_active(work_area->get_onion_skin());
+       toggling_onion_skin=false;
+}
+
+void
+CanvasView::on_dirty_preview()
+{
+       if(!is_playing_)
+       {
+               IsWorking is_working(*this);
+
+               work_area->queue_render_preview();
+       }
+}
+
+void
+CanvasView::play()
+{
+       assert(get_canvas());
+
+       // If we are already busy, don't play!
+       if(working_depth)return;
+
+       // Set us up as working
+       IsWorking is_working(*this);
+
+       etl::clock timer;
+       Time
+               time=work_area->get_time(),
+               endtime=get_canvas()->rend_desc().get_time_end();
+
+       // If we are already at the end of time, start over
+       if(time==endtime)
+               time=get_canvas()->rend_desc().get_time_start();
+
+       is_playing_=true;
+
+       work_area->clear_ducks();
+
+       for(timer.reset(); time + timer() < endtime;)
+       {
+               //Clamp the time window so we can see the time value as it races across the horizon
+               bool timewindreset = false;
+
+               while( time + timer() > Time(time_window_adjustment().get_sub_upper()) )
+               {
+                       time_window_adjustment().set_value(
+                                       min(
+                                               time_window_adjustment().get_value()+time_window_adjustment().get_page_size()/2,
+                                               time_window_adjustment().get_upper()-time_window_adjustment().get_page_size() )
+                               );
+                       timewindreset = true;
+               }
+
+               while( time + timer() < Time(time_window_adjustment().get_sub_lower()) )
+               {
+                       time_window_adjustment().set_value(
+                               max(
+                                       time_window_adjustment().get_value()-time_window_adjustment().get_page_size()/2,
+                                       time_window_adjustment().get_lower())
+                       );
+
+                       timewindreset = true;
+               }
+
+               //we need to tell people that the value changed
+               if(timewindreset) time_window_adjustment().value_changed();
+
+               //update actual time to next step
+               time_adjustment().set_value(time+timer());
+               time_adjustment().value_changed();
+
+               if(!work_area->sync_render_preview())
+                       break;
+
+               // wait for the workarea to refresh itself
+               while (studio::App::events_pending())
+                       studio::App::iteration(false);
+
+               if(get_cancel_status())
+               {
+                       is_playing_=false;
+                       return;
+               }
+       }
+       on_play_stop_pressed();
+       is_playing_=false;
+       time_adjustment().set_value(endtime);
+       time_adjustment().value_changed();
+}
+
+void
+CanvasView::show_tables()
+{
+/*
+       Smach::event_result x(process_event_key(EVENT_TABLES_SHOW));
+       if(x==Smach::RESULT_OK || x==Smach::RESULT_ACCEPT)
+       {
+               Gtk::IconSize iconsize=Gtk::IconSize::from_name("synfig-small_icon");
+               treetogglebutton->remove();
+               treetogglebutton->add(*manage(new Gtk::Image(Gtk::StockID("gtk-go-down"),iconsize)));
+               treetogglebutton->show_all();
+               notebook->show();
+       }
+*/
+}
+
+void
+CanvasView::hide_tables()
+{
+/*
+       Smach::event_result x(process_event_key(EVENT_TABLES_HIDE));
+       if(x==Smach::RESULT_OK || x==Smach::RESULT_ACCEPT)
+       {
+               Gtk::IconSize iconsize=Gtk::IconSize::from_name("synfig-small_icon");
+               treetogglebutton->remove();
+               treetogglebutton->add(*manage(new Gtk::Image(Gtk::StockID("gtk-go-up"),iconsize)));
+               treetogglebutton->show_all();
+               notebook->hide();
+       }
+*/
+}
+
+bool
+CanvasView::tables_are_visible()
+{
+//     return notebook->is_visible();
+       return false;
+}
+
+void
+CanvasView::toggle_tables()
+{
+//     if(tables_are_visible())
+//             hide_tables();
+//     else
+//             show_tables();
+}
+
+void
+CanvasView::show_timebar()
+{
+       timebar->show();
+       //current_time_widget->show(); // not needed now that belongs to the timebar
+
+       //keyframe_tab_child->show();
+       if(layer_tree)
+               layer_tree->set_show_timetrack(true);
+       if(children_tree)
+               children_tree->set_show_timetrack(true);
+}
+
+void
+CanvasView::hide_timebar()
+{
+       timebar->hide();
+       //current_time_widget->hide(); // not needed now that belongs to the timebar
+       //keyframe_tab_child->hide();
+       if(layer_tree)
+               layer_tree->set_show_timetrack(false);
+       if(children_tree)
+               children_tree->set_show_timetrack(false);
+}
+
+void
+CanvasView::set_sensitive_timebar(bool sensitive)
+{
+       timebar->set_sensitive(sensitive);
+       //current_time_widget->set_sensitive(sensitive); //not needed now that belongs to timebar
+       //keyframe_tab_child->set_sensitive(sensitive);
+       if(layer_tree)
+               layer_tree->set_sensitive(sensitive);
+       if(children_tree)
+               children_tree->set_sensitive(sensitive);
+}
+
+static void
+set_waypoint_model(std::set<synfig::Waypoint, std::less<UniqueID> > waypoints,
+                                  Waypoint::Model model,
+                                  etl::loose_handle<synfigapp::CanvasInterface> canvas_interface)
+{
+       // Create the action group
+       synfigapp::Action::PassiveGrouper group(canvas_interface->get_instance().get(),_("Change Waypoint Group"));
+
+       std::set<synfig::Waypoint, std::less<UniqueID> >::const_iterator iter;
+       for(iter=waypoints.begin();iter!=waypoints.end();++iter)
+       {
+               Waypoint waypoint(*iter);
+               waypoint.apply_model(model);
+
+               synfigapp::Action::Handle action(synfigapp::Action::create("WaypointSet"));
+
+               assert(action);
+
+               action->set_param("canvas",canvas_interface->get_canvas());
+               action->set_param("canvas_interface",canvas_interface);
+
+               action->set_param("waypoint",waypoint);
+               action->set_param("value_node",waypoint.get_parent_value_node());
+
+               if(!canvas_interface->get_instance()->perform_action(action))
+               {
+                       group.cancel();
+                       return;
+               }
+       }
+}
+
+static void
+duplicate_waypoints(std::set<synfig::Waypoint, std::less<UniqueID> > waypoints,
+                                       etl::loose_handle<synfigapp::CanvasInterface> canvas_interface)
+{
+       // Create the action group
+       synfigapp::Action::PassiveGrouper group(canvas_interface->get_instance().get(),_("Duplicate Waypoints"));
+
+       std::set<synfig::Waypoint, std::less<UniqueID> >::const_iterator iter;
+       for (iter = waypoints.begin(); iter != waypoints.end(); iter++)
+       {
+               Waypoint waypoint(*iter);
+               ValueNode::Handle value_node(iter->get_parent_value_node());
+               canvas_interface->waypoint_duplicate(value_node, waypoint);
+       }
+}
+
+static void
+remove_waypoints(std::set<synfig::Waypoint, std::less<UniqueID> > waypoints,
+                                etl::loose_handle<synfigapp::CanvasInterface> canvas_interface)
+{
+       // Create the action group
+       synfigapp::Action::PassiveGrouper group(canvas_interface->get_instance().get(),_("Remove Waypoints"));
+
+       std::set<synfig::Waypoint, std::less<UniqueID> >::const_iterator iter;
+       for (iter = waypoints.begin(); iter != waypoints.end(); iter++)
+       {
+               Waypoint waypoint(*iter);
+               ValueNode::Handle value_node(iter->get_parent_value_node());
+               canvas_interface->waypoint_remove(value_node, waypoint);
+       }
+}
+
+void
+CanvasView::on_waypoint_clicked_canvasview(synfigapp::ValueDesc value_desc,
+                                                                                  std::set<synfig::Waypoint, std::less<UniqueID> > waypoint_set,
+                                                                                  int button)
+{
+       int size = waypoint_set.size();
+       Waypoint waypoint(*(waypoint_set.begin()));
+       Time time(waypoint.get_time());
+
+       if (size == 1)
+       {
+               waypoint_dialog.set_value_desc(value_desc);
+               waypoint_dialog.set_waypoint(waypoint);
+       }
+
+       switch(button)
+       {
+       case -1:
+               if (size == 1)
+                       waypoint_dialog.show();
+               break;
+       case 2:
+       {
+               Gtk::Menu* waypoint_menu(manage(new Gtk::Menu()));
+               waypoint_menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), waypoint_menu));
+
+               Gtk::Menu* interp_menu_in(manage(new Gtk::Menu()));
+               Gtk::Menu* interp_menu_out(manage(new Gtk::Menu()));
+               Gtk::Menu* interp_menu_both(manage(new Gtk::Menu()));
+
+               {
+                       Waypoint::Model model;
+
+                       model.reset(); model.set_before(INTERPOLATION_TCB);
+                       interp_menu_in->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_TCB"),
+                               sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
+                       model.reset(); model.set_after(INTERPOLATION_TCB);
+                       interp_menu_out->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_TCB"),
+                               sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
+                       model.set_before(INTERPOLATION_TCB);
+                       interp_menu_both->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_TCB"),
+                               sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
+
+                       model.reset(); model.set_before(INTERPOLATION_LINEAR);
+                       interp_menu_in->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Linear"),
+                               sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
+                       model.reset(); model.set_after(INTERPOLATION_LINEAR);
+                       interp_menu_out->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Linear"),
+                               sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
+                       model.set_before(INTERPOLATION_LINEAR);
+                       interp_menu_both->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Linear"),
+                               sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
+
+                       model.reset(); model.set_before(INTERPOLATION_HALT);
+                       interp_menu_in->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Ease In"),
+                               sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
+                       model.reset(); model.set_after(INTERPOLATION_HALT);
+                       interp_menu_out->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Ease Out"),
+                               sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
+                       model.set_before(INTERPOLATION_HALT);
+                       interp_menu_both->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Ease In/Out"),
+                               sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
+
+                       model.reset(); model.set_before(INTERPOLATION_CONSTANT);
+                       interp_menu_in->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Constant"),
+                               sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
+                       model.reset(); model.set_after(INTERPOLATION_CONSTANT);
+                       interp_menu_out->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Constant"),
+                               sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
+                       model.set_before(INTERPOLATION_CONSTANT);
+                       interp_menu_both->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Constant"),
+                               sigc::bind(sigc::ptr_fun(set_waypoint_model), waypoint_set, model, canvas_interface())));
+               }
+
+               // ------------------------------------------------------------------------
+               if (size == 1)
+               {
+                       const synfigapp::ValueDesc value_desc(synfig::ValueNode_Animated::Handle::cast_reinterpret(waypoint.get_parent_value_node()), time);
+                       get_instance()->make_param_menu(waypoint_menu,canvas_interface()->get_canvas(),value_desc,0.5f);
+
+                       // ------------------------------------------------------------------------
+                       waypoint_menu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
+               }
+
+               // ------------------------------------------------------------------------
+               waypoint_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Jump To"),
+                       sigc::bind(sigc::mem_fun(*canvas_interface(), &synfigapp::CanvasInterface::set_time), time)));
+
+               waypoint_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Duplicate"),
+                        sigc::bind(sigc::ptr_fun(duplicate_waypoints), waypoint_set, canvas_interface())));
+
+               waypoint_menu->items().push_back(Gtk::Menu_Helpers::MenuElem((size == 1) ? _("_Remove") : strprintf(_("_Remove %d Waypoints"), size),
+                        sigc::bind(sigc::ptr_fun(remove_waypoints), waypoint_set, canvas_interface())));
+
+               if (size == 1 && value_desc.is_valid())
+                       waypoint_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Edit"),
+                               sigc::mem_fun(waypoint_dialog,&Gtk::Widget::show)));
+
+               // ------------------------------------------------------------------------
+               waypoint_menu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
+
+               // ------------------------------------------------------------------------
+               waypoint_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Both"), *interp_menu_both));
+               waypoint_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_In"),   *interp_menu_in));
+               waypoint_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Out"),  *interp_menu_out));
+
+               // ------------------------------------------------------------------------
+               waypoint_menu->popup(button+1,gtk_get_current_event_time());
+       }
+       break;
+
+       default:
+               break;
+       }
+}
+
+void
+CanvasView::on_waypoint_changed()
+{
+       synfigapp::Action::ParamList param_list;
+       param_list.add("canvas",get_canvas());
+       param_list.add("canvas_interface",canvas_interface());
+       param_list.add("value_node",waypoint_dialog.get_value_desc().get_value_node());
+       param_list.add("waypoint",waypoint_dialog.get_waypoint());
+//     param_list.add("time",canvas_interface()->get_time());
+
+       get_instance()->process_action("WaypointSetSmart", param_list);
+}
+
+void
+CanvasView::on_waypoint_delete()
+{
+       synfigapp::Action::ParamList param_list;
+       param_list.add("canvas",get_canvas());
+       param_list.add("canvas_interface",canvas_interface());
+       param_list.add("value_node",waypoint_dialog.get_value_desc().get_value_node());
+       param_list.add("waypoint",waypoint_dialog.get_waypoint());
+//     param_list.add("time",canvas_interface()->get_time());
+
+       get_instance()->process_action("WaypointRemove", param_list);
+}
+
+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)
+{
+       // We will make this true once we have a solid drop
+       bool success(false);
+       //synfig::info("Dropped data of type \"%s\"",selection_data.get_data_type());
+       //synfig::info("Dropped data of target \"%s\"",gdk_atom_name(selection_data->target));
+       //synfig::info("selection=\"%s\"",gdk_atom_name(selection_data->selection));
+
+       if ((selection_data_.get_length() >= 0) && (selection_data_.get_format() == 8))
+       {
+               if(synfig::String(selection_data_.get_data_type())=="STRING")do
+               {
+                       synfig::String selection_data((gchar *)(selection_data_.get_data()));
+
+                       Layer::Handle layer(synfig::Layer::create("Text"));
+                       if(!layer)
+                               break;
+                       if(!layer->set_param("text",ValueBase(selection_data)))
+                               break;
+
+                       synfigapp::Action::Handle       action(synfigapp::Action::create("LayerAdd"));
+
+                       assert(action);
+                       if(!action)
+                               break;
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",canvas_interface());
+                       action->set_param("new",layer);
+
+                       if(!get_instance()->perform_action(action))
+                               break;
+
+                       // Ok, we have successfully imported at least one item.
+                       success=true;
+               } while(0); // END of "STRING"
+
+               if(synfig::String(selection_data_.get_data_type())=="text/plain")
+               {
+                       synfig::String selection_data((gchar *)(selection_data_.get_data()));
+
+                       // For some reason, GTK hands us a list of URLs separated
+                       // by not only Carriage-Returns, but also Line-Feeds.
+                       // Line-Feeds will mess us up. Remove all the line-feeds.
+                       while(selection_data.find_first_of('\r')!=synfig::String::npos)
+                               selection_data.erase(selection_data.begin()+selection_data.find_first_of('\r'));
+
+                       std::stringstream stream(selection_data);
+
+                       //synfigapp::PassiveGrouper group(canvas_interface()->get_instance(),_("Insert Image"));
+                       while(stream)
+                       {
+                               synfig::String filename,URI;
+                               getline(stream,filename);
+
+                               // If we don't have a filename, move on.
+                               if(filename.empty())
+                                       continue;
+
+                               // Make sure this URL is of the "file://" type.
+                               URI=String(filename.begin(),filename.begin()+sizeof("file://")-1);
+                               if(URI!="file://")
+                               {
+                                       synfig::warning("Unknown URI (%s) in \"%s\"",URI.c_str(),filename.c_str());
+                                       continue;
+                               }
+
+                               // Strip the "file://" part from the filename
+                               filename=synfig::String(filename.begin()+sizeof("file://")-1,filename.end());
+
+                               String ext(filename_extension(filename));
+                               if (ext.size()) ext = ext.substr(1); // skip initial '.'
+
+                               // If this is a SIF file, then we need to do things slightly differently
+                               if(ext=="sketch")
+                               {
+                                       if(work_area->load_sketch(filename))
+                                       {
+                                               success=true;
+                                               work_area->queue_draw();
+                                       }
+                               }
+                               else
+                               {
+                                       String errors, warnings;
+                                       if(canvas_interface()->import(filename, errors, warnings, App::resize_imported_images))
+                                               success=true;
+                                       if (warnings != "")
+                                               App::dialog_warning_blocking(_("Warnings"), strprintf("%s:\n\n%s", _("Warnings"), warnings.c_str()));
+                               }
+
+                               continue;
+                       }
+               } // END of "text/plain"
+       }
+       else
+               ui_interface_->error("Drop failed: bad selection data");
+
+       // Finish the drag
+       context->drag_finish(success, false, time);
+}
+
+void
+CanvasView::on_keyframe_add_pressed()
+{
+       synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeAdd"));
+
+       if(!action)
+       {
+               ui_interface_->error("I am unable to find the appropriate action");
+               return;
+       }
+
+       action->set_param("canvas",get_canvas());
+       action->set_param("canvas_interface",canvas_interface());
+       action->set_param("keyframe",Keyframe(get_time()));
+
+       canvas_interface()->get_instance()->perform_action(action);
+}
+
+void
+CanvasView::on_keyframe_duplicate_pressed()
+{
+       const KeyframeTreeStore::Model model;
+       const Gtk::TreeRow row(*keyframe_tree->get_selection()->get_selected());
+       Keyframe keyframe;
+       if(!row)
+       {
+               ui_interface_->error("I am unable to duplicate the keyframe");
+               return;
+       }
+       keyframe=row[model.keyframe];
+
+       synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeDuplicate"));
+
+       if(!action)
+       {
+               ui_interface_->error("I am unable to find the appropriate action");
+               return;
+       }
+
+       action->set_param("canvas",get_canvas());
+       action->set_param("canvas_interface",canvas_interface());
+       action->set_param("keyframe",keyframe);
+       action->set_param("time",get_time());
+
+       canvas_interface()->get_instance()->perform_action(action);
+}
+
+void
+CanvasView::on_keyframe_remove_pressed()
+{
+       const KeyframeTreeStore::Model model;
+       const Gtk::TreeRow row(*keyframe_tree->get_selection()->get_selected());
+       Keyframe keyframe;
+       if(!row)
+       {
+               ui_interface_->error("I am unable to remove the keyframe");
+               return;
+       }
+       keyframe=row[model.keyframe];
+
+       synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeRemove"));
+
+       if(!action)
+       {
+               ui_interface_->error("I am unable to find the appropriate action");
+               return;
+       }
+
+       action->set_param("canvas",get_canvas());
+       action->set_param("canvas_interface",canvas_interface());
+       action->set_param("keyframe",keyframe);
+
+       canvas_interface()->get_instance()->perform_action(action);
+}
+
+void
+CanvasView::toggle_duck_mask(Duckmatic::Type type)
+{
+       if(toggling_ducks_)
+               return;
+       toggling_ducks_=true;
+       bool is_currently_on(work_area->get_type_mask()&type);
+
+       if(is_currently_on)
+               work_area->set_type_mask(work_area->get_type_mask()-type);
+       else
+               work_area->set_type_mask(work_area->get_type_mask()|type);
+
+       work_area->queue_draw();
+       try
+       {
+               // Update the toggle ducks actions
+               Glib::RefPtr<Gtk::ToggleAction> action;
+               action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("mask-position-ducks"));
+               action->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_POSITION));
+               action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("mask-tangent-ducks"));
+               action->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_TANGENT));
+               action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("mask-vertex-ducks"));
+               action->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_VERTEX));
+               action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("mask-radius-ducks"));
+               action->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_RADIUS));
+               action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("mask-width-ducks"));
+               action->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_WIDTH));
+               action = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(action_group->get_action("mask-angle-ducks"));
+               action->set_active((bool)(work_area->get_type_mask()&Duck::TYPE_ANGLE));
+               // Update toggle ducks buttons
+               toggleducksdial->update_toggles(work_area->get_type_mask());
+       }
+       catch(...)
+       {
+               toggling_ducks_=false;
+       }
+       toggling_ducks_=false;
+}
+
+void
+CanvasView::image_import()
+{
+       // String filename(dirname(get_canvas()->get_file_name()));
+       String filename("*.*");
+       String errors, warnings;
+       if(App::dialog_open_file(_("Import Image"), filename, IMAGE_DIR_PREFERENCE))
+       {
+               canvas_interface()->import(filename, errors, warnings, App::resize_imported_images);
+               if (warnings != "")
+                       App::dialog_warning_blocking(_("Warnings"), strprintf("%s:\n\n%s", _("Warnings"), warnings.c_str()));
+       }
+}
+
+Smach::event_result
+CanvasView::process_event_key(EventKey x)
+{
+       return smach_.process_event(x);
+}
+
+void
+CanvasView::on_input_device_changed(GdkDevice* device)
+{
+       if(!device)
+       {
+               get_smach().egress();
+       }
+       assert(device);
+
+       synfigapp::InputDevice::Handle input_device;
+       input_device=synfigapp::Main::select_input_device(device->name);
+       App::toolbox->change_state(input_device->get_state());
+       process_event_key(EVENT_INPUT_DEVICE_CHANGED);
+}
+
+void
+CanvasView::on_preview_option()
+{
+       Dialog_PreviewOptions *po = dynamic_cast<Dialog_PreviewOptions *>(get_ext_widget("prevoptions"));
+
+       Canvas::Handle  canv = get_canvas();
+
+       if(canv)
+       {
+               RendDesc &r = canv->rend_desc();
+               if(r.get_frame_rate())
+               {
+                       float rate = 1/r.get_frame_rate();
+                       float beg = r.get_time_start() + r.get_frame_start()*rate;
+                       float end = r.get_time_start() + r.get_frame_end()*rate;
+
+                       if(!po)
+                       {
+                               po = new Dialog_PreviewOptions;
+                               po->set_zoom(work_area->get_zoom()/2);
+                               po->set_fps(r.get_frame_rate()/2);
+                               po->set_begintime(beg);
+                               po->set_begin_override(false);
+                               po->set_endtime(end);
+                               po->set_end_override(false);
+
+                               set_ext_widget("prevoptions",po);
+                       }
+                       /*po->set_zoom(work_area->get_zoom()/2);
+                       po->set_fps(r.get_frame_rate()/2);
+                       po->set_begintime(beg);
+                       po->set_begin_override(false);
+                       po->set_endtime(end);
+                       po->set_end_override(false);*/
+
+                       po->set_global_fps(r.get_frame_rate());
+                       po->signal_finish().connect(sigc::mem_fun(*this,&CanvasView::on_preview_create));
+                       po->present();
+               }
+       }
+}
+
+void
+CanvasView::on_preview_create(const PreviewInfo &info)
+{
+       //set all the options
+       etl::handle<Preview>    prev = new Preview;
+
+       prev->set_canvasview(this);
+       prev->set_zoom(info.zoom);
+       prev->set_fps(info.fps);
+       prev->set_overbegin(info.overbegin);
+       prev->set_begintime(info.begintime);
+       prev->set_overend(info.overend);
+       prev->set_endtime(info.endtime);
+       prev->set_quality(work_area->get_quality());
+
+       //render it out...
+       prev->render();
+
+       Dialog_Preview *pd = preview_dialog.get();
+       assert(pd);
+
+       pd->set_default_size(700,510);
+       pd->set_preview(prev.get());
+       pd->present();
+}
+
+void
+CanvasView::on_audio_option()
+{
+       synfig::warning("Launching Audio Options");
+       sound_dialog->set_global_fps(get_canvas()->rend_desc().get_frame_rate());
+       sound_dialog->present();
+}
+
+void
+CanvasView::on_audio_file_change(const std::string &f)
+{
+       //save in meta data - always even when not valid...
+       canvas_interface()->set_meta_data("audiofile",f);
+}
+
+void
+CanvasView::on_audio_offset_change(const synfig::Time &t)
+{
+       canvas_interface()->set_meta_data("audiooffset",t.get_string());
+}
+
+void
+CanvasView::on_audio_file_notify()
+{
+       std::string file(get_canvas()->get_meta_data("audiofile"));
+       if(!file.c_str()) return;
+
+       if(!audio->load(file,dirname(get_canvas()->get_file_name())+string("/")))
+       {
+               if(file != "") synfig::warning("Could not load the file: %s", file.c_str());
+               get_canvas()->erase_meta_data("audiofile");
+               disp_audio->hide();
+               disp_audio->set_profile(etl::handle<AudioProfile>());
+       }else
+       {
+               //save in canvasview
+               synfig::warning("Getting the profile of the music stuff");
+
+               //profile specific stuff for the preview widget
+               //similar for other attachments
+               Dialog_Preview *pd = preview_dialog.get();
+               pd->get_widget().set_audio(audio);
+
+               handle<AudioProfile>    prof = audio->get_profile();
+
+               if(!prof)
+               {
+                       synfig::warning("Agh, I couldn't build the profile captain!");
+               }
+               pd->get_widget().set_audioprofile(prof);
+
+               disp_audio->set_profile(audio->get_profile());
+               disp_audio->show();
+
+               synfig::warning("successfully set the profiles and stuff");
+       }
+       disp_audio->queue_draw();
+}
+
+void
+CanvasView::on_audio_offset_notify()
+{
+       Time t(get_canvas()->get_meta_data("audiooffset"),get_canvas()->rend_desc().get_frame_rate());
+       audio->set_offset(t);
+       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());
+}
+
+void
+CanvasView::play_audio(float t)
+{
+       if(audio.get())
+       {
+               synfig::info("Playing audio at %f s",t);
+               audio->play(t);
+       }
+}
+
+void
+CanvasView::stop_audio()
+{
+       if(audio.get())
+       {
+               audio->stop();
+       }
+}
+
+bool
+CanvasView::on_audio_scrub()
+{
+       disp_audio->draw();
+       return true;
+}
+
+Glib::RefPtr<Glib::ObjectBase>
+CanvasView::get_ref_obj(const synfig::String& x)
+{
+       return ref_obj_book_[x];
+}
+
+Glib::RefPtr<const Glib::ObjectBase>
+CanvasView::get_ref_obj(const synfig::String& x)const
+{
+       return ref_obj_book_.find(x)->second;
+}
+
+void
+CanvasView::set_ref_obj(const synfig::String& x, Glib::RefPtr<Glib::ObjectBase> y)
+{
+       ref_obj_book_[x]=y;
+}
+
+Glib::RefPtr<Gtk::TreeModel>
+CanvasView::get_tree_model(const synfig::String& x)
+{
+       return Glib::RefPtr<Gtk::TreeModel>::cast_dynamic(ref_obj_book_["_tree_model_"+x]);
+}
+
+Glib::RefPtr<const Gtk::TreeModel>
+CanvasView::get_tree_model(const synfig::String& x)const
+{
+       return Glib::RefPtr<Gtk::TreeModel>::cast_dynamic(ref_obj_book_.find("_tree_model_"+x)->second);
+}
+
+void
+CanvasView::set_tree_model(const synfig::String& x, Glib::RefPtr<Gtk::TreeModel> y)
+{
+       ref_obj_book_["_tree_model_"+x]=Glib::RefPtr<Glib::ObjectBase>::cast_static(y);
+}
+
+Gtk::Widget*
+CanvasView::get_ext_widget(const synfig::String& x)
+{
+       return ext_widget_book_[x];
+}
+
+void
+CanvasView::set_ext_widget(const synfig::String& x, Gtk::Widget* y)
+{
+       ext_widget_book_[x]=y;
+       if(x=="layers_cmp")
+       {
+               layer_tree=dynamic_cast<LayerTree*>(y);
+
+               layer_tree->get_selection()->signal_changed().connect(SLOT_EVENT(EVENT_LAYER_SELECTION_CHANGED));
+               layer_tree->get_selection()->signal_changed().connect(SLOT_EVENT(EVENT_REFRESH_DUCKS));
+               layer_tree->signal_layer_user_click().connect(sigc::mem_fun(*this, &studio::CanvasView::on_layer_user_click));
+               layer_tree->signal_param_user_click().connect(sigc::mem_fun(*this, &studio::CanvasView::on_children_user_click));
+               layer_tree->signal_waypoint_clicked_layertree().connect(sigc::mem_fun(*this, &studio::CanvasView::on_waypoint_clicked_canvasview));
+       }
+       if(x=="children")
+       {
+               children_tree=dynamic_cast<ChildrenTree*>(y);
+               if(children_tree)children_tree->signal_user_click().connect(sigc::mem_fun(*this, &studio::CanvasView::on_children_user_click));
+               if(children_tree)children_tree->signal_waypoint_clicked_childrentree().connect(sigc::mem_fun(*this, &studio::CanvasView::on_waypoint_clicked_canvasview));
+               if(children_tree)children_tree->get_selection()->signal_changed().connect(SLOT_EVENT(EVENT_REFRESH_DUCKS));
+       }
+       if(x=="keyframes")
+               keyframe_tree=dynamic_cast<KeyframeTree*>(y);
+}
+
+bool
+CanvasView::on_delete_event(GdkEventAny* event __attribute__ ((unused)))
+{
+       close_view();
+
+       //! \todo This causes the window to be deleted straight away - but what if we prompt 'save?' and the user cancels?
+       //                Is there ever any need to pass on the delete event to the window here?
+       // if(event) return Gtk::Window::on_delete_event(event);
+
+       return true;
+}
+
+//! Modify the play stop button apearence and play stop the animation
+void
+CanvasView::on_play_stop_pressed()
+{
+       Gtk::Image *icon;
+       Gtk::Button *stop_button;
+       stop_button=framedial->get_play_button();
+       bool play_flag;
+       if(!is_playing())
+       {
+               icon = manage(new Gtk::Image(Gtk::Stock::MEDIA_STOP, Gtk::IconSize::from_name("synfig-small_icon")));
+               stop_button->set_relief(Gtk::RELIEF_NORMAL);
+               play_flag=true;
+       }
+       else
+       {
+               icon = manage(new Gtk::Image(Gtk::Stock::MEDIA_PLAY, Gtk::IconSize::from_name("synfig-small_icon")));
+               stop_button->set_relief(Gtk::RELIEF_NONE);
+               play_flag=false;
+       }
+       stop_button->remove();
+       stop_button->add(*icon);
+       icon->set_padding(0, 0);
+       icon->show();
+       if(play_flag) play(); else stop();
+}
diff --git a/synfig-studio/src/gui/canvasview.h b/synfig-studio/src/gui/canvasview.h
new file mode 100644 (file)
index 0000000..11005d3
--- /dev/null
@@ -0,0 +1,743 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file canvasview.h
+**     \brief Template Header
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 2008 Chris Moore
+**     Copyright (c) 2009 Carlos López
+**
+**     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_GTKMM_CANVASVIEW_H
+#define __SYNFIG_STUDIO_GTKMM_CANVASVIEW_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/window.h>
+#include <gtkmm/image.h>
+#include <gtkmm/tooltips.h>
+#include <gtkmm/table.h>
+#include <gtkmm/statusbar.h>
+#include <gtkmm/progressbar.h>
+#include <gtkmm/button.h>
+#include <gtkmm/menu.h>
+#include <gtkmm/treeview.h>
+#include <gtkmm/treestore.h>
+#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/notebook.h>
+#include <gdkmm/device.h>
+#include <gtkmm/spinbutton.h>
+
+#include <synfigapp/canvasinterface.h>
+#include <synfigapp/selectionmanager.h>
+
+#include <synfig/canvas.h>
+#include <synfig/string.h>
+#include <synfig/time.h>
+
+#include "instance.h"
+#include "canvasproperties.h"
+#include "canvasoptions.h"
+#include "render.h"
+#include "cellrenderer_timetrack.h"
+#include "app.h"
+
+#include "layertreestore.h"
+#include "layertree.h"
+#include "childrentreestore.h"
+#include "childrentree.h"
+#include "keyframetreestore.h"
+#include "keyframetree.h"
+
+#include "dialog_waypoint.h"
+#include "dialog_keyframe.h"
+#include "framedial.h"
+#include "toggleducksdial.h"
+#include "resolutiondial.h"
+#include "widget_keyframe_list.h"
+
+#include "duckmatic.h"
+#include <gtkmm/scale.h>
+
+#include <gtkmm/uimanager.h>
+
+#include "smach.h"
+
+#include <memory>
+#include <set>
+#include <map>
+#include <gtkmm/toggleaction.h>
+#include <gtkmm/radioaction.h>
+#include <synfig/rect.h>
+
+#include "adjust_window.h"
+
+#include <synfig/transform.h>
+
+/* === M A C R O S ========================================================= */
+
+#ifndef DEBUGPOINT_CLASS
+#if    _DEBUG
+#define DEBUGPOINT_CLASS(x)            struct debugpointclass_ ## x { debugpointclass_ ## x () { DEBUGPOINT(); } ~debugpointclass_ ## x () { DEBUGPOINT(); } } badfthguae_ ## x ;
+#else
+#define DEBUGPOINT_CLASS(x)
+#endif
+#endif
+
+/* === T Y P E D E F S ===================================================== */
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+namespace synfig {
+       class TransformStack;
+}
+
+namespace studio {
+
+class CanvasViewUIInterface;
+class CanvasViewSelectionManager;
+
+class CellRenderer_TimeTrack;
+class CellRenderer_ValueBase;
+class UniversalScrubber;
+class WorkArea;
+
+class Duckmatic;
+
+class Preview;
+struct PreviewInfo;
+class AudioContainer;
+
+class Widget_Sound;
+class Widget_Timeslider;
+class Widget_Time;
+
+class Dialog_SoundSelect;
+class Dialog_Preview;
+
+class Dock_Layers;
+class Dock_Children;
+class Dock_Keyframes;
+
+class CanvasView : public Gtk::Window, public etl::shared_object
+{
+       friend class UniversalScrubber;
+       friend class Dock_Layers;
+       friend class Dock_Children;
+       friend class Dock_Keyframes;
+
+       friend class CanvasViewUIInterface;
+       friend class CanvasViewSelectionManager;
+
+       friend class Duckmatic;
+
+       /*
+ -- ** -- P U B L I C   T Y P E S ---------------------------------------------
+       */
+
+public:
+
+       typedef etl::handle<CanvasView> Handle;
+
+       typedef etl::handle<const CanvasView> ConstHandle;
+
+       typedef etl::loose_handle<CanvasView> LooseHandle;
+
+       typedef LayerTreeStore::Model LayerTreeModel;
+
+       typedef ChildrenTreeStore::Model ChildrenTreeModel;
+
+       //! Create an instance of this class whenever doing a longer task.
+       /*! Make sure that you check the bool value of this class occasionally
+       **      to make sure the action has not been canceled. */
+       class IsWorking
+       {
+               CanvasView &canvas_view_;
+
+       public:
+               IsWorking(CanvasView &canvas_view_);
+               ~IsWorking();
+               operator bool()const;
+       };
+       friend class IsWorking;
+
+       typedef synfigapp::CanvasInterface::Mode Mode;
+
+       void set_grid_snap_toggle(bool flag) { grid_snap_toggle->set_active(flag); }
+       void set_grid_show_toggle(bool flag) { grid_show_toggle->set_active(flag); }
+
+       /*
+ -- ** -- P R I V A T E   D A T A ---------------------------------------------
+       */
+
+public:
+       std::auto_ptr<WorkArea> work_area;
+
+       WorkArea* get_work_area() { return work_area.get(); }
+private:
+
+       synfig::TransformStack curr_transform_stack;
+       bool curr_transform_stack_set;
+
+       synfig::Rect bbox;
+
+       // DEBUGPOINT_CLASS(1);
+
+       //! State Machine
+       Smach smach_;
+
+       // DEBUGPOINT_CLASS(2);
+
+       etl::loose_handle<Instance> instance_;
+       etl::handle<synfigapp::CanvasInterface> canvas_interface_;
+
+       // DEBUGPOINT_CLASS(3);
+
+       //! Sound and information to play it
+       etl::handle<AudioContainer>             audio;
+       studio::Widget_Sound                    *disp_audio; //should this be put into thing too?
+
+       sigc::connection                                playcon;
+       sigc::connection                                stopcon;
+
+       std::auto_ptr<UniversalScrubber> universal_scrubber;
+
+       //! Tooltip controller
+       Gtk::Tooltips tooltips;
+
+       // DEBUGPOINT_CLASS(4);
+
+       //! TreeModel for the layers
+       LayerTreeModel layer_tree_model;
+
+       //! TreeModel for the the children
+       ChildrenTreeModel children_tree_model;
+
+       //Glib::RefPtr<LayerTreeStore> layer_tree_store_;
+
+       //Glib::RefPtr<ChildrenTreeStore> children_tree_store_;
+
+       //Glib::RefPtr<KeyframeTreeStore> keyframe_tree_store_;
+
+       // DEBUGPOINT_CLASS(5);
+
+       //std::map<synfig::String,Glib::RefPtr<Gtk::TreeModel> > tree_model_book_;
+       std::map<synfig::String,Glib::RefPtr<Glib::ObjectBase> > ref_obj_book_;
+       std::map<synfig::String,Gtk::Widget*> ext_widget_book_;
+
+       //! The time adjustment's scope is defined by the time_window adjustment
+       Gtk::Adjustment time_adjustment_;
+
+       //! The time_window adjustment governs the position of the time window on the whole time line
+       //Gtk::Adjustment time_window_adjustment_;
+       studio::Adjust_Window time_window_adjustment_;
+
+       LayerTree *layer_tree;
+
+       ChildrenTree *children_tree;
+
+       KeyframeTree *keyframe_tree;
+
+       Gtk::Widget *keyframe_tab_child;
+
+       Gtk::ProgressBar *progressbar;
+       Gtk::Statusbar *statusbar;
+
+       Gtk::TreeRow children_canvas_row;
+       Gtk::TreeRow children_valuenode_row;
+
+       Gtk::Button *stopbutton;
+       Gtk::Button *refreshbutton;
+       Gtk::Button *treetogglebutton;  // not used
+       Gtk::Notebook *notebook; // not used
+       Gtk::Table *timebar;
+       Gtk::Table *displaybar;
+       Gtk::Button *animatebutton;
+       Gtk::Button *keyframebutton;
+       FrameDial *framedial;
+       ToggleDucksDial *toggleducksdial;
+       bool toggling_ducks_;
+       ResolutionDial *resolutiondial;
+       bool changing_resolution_;
+       Gtk::Adjustment quality_adjustment_;
+       Gtk::SpinButton *quality_spin;
+       Gtk::Adjustment future_onion_adjustment_;
+       Gtk::Adjustment past_onion_adjustment_;
+       Gtk::SpinButton *past_onion_spin;
+       Gtk::SpinButton *future_onion_spin;
+       bool updating_quality_;
+       Gtk::ToggleButton *show_grid;
+       Gtk::ToggleButton *snap_grid;
+       Gtk::ToggleButton *onion_skin;
+       Gtk::Button *render_options_button;
+       Gtk::Button *preview_options_button;
+       bool toggling_show_grid;
+       bool toggling_snap_grid;
+       bool toggling_onion_skin;
+       //! Shows current time and allows edition
+       Widget_Time *current_time_widget;
+       void on_current_time_widget_changed();
+
+       //! Time slider class. Same than the Time track panel
+       std::auto_ptr<Widget_Timeslider> timeslider;
+
+       //!Keyframe list slider
+       std::auto_ptr<Widget_Keyframe_List> widget_kf_list;
+
+       std::list<sigc::connection> duck_changed_connections;
+
+/*     DEBUGPOINT_CLASS(8);
+
+       Gtk::Menu duckmaskmenu;
+       DEBUGPOINT_CLASS(77);
+       Gtk::Menu qualitymenu;
+       DEBUGPOINT_CLASS(6);
+
+       Gtk::Menu filemenu;
+       DEBUGPOINT_CLASS(777);
+       Gtk::Menu editmenu;
+       DEBUGPOINT_CLASS(71);
+       Gtk::Menu canvasmenu;
+       DEBUGPOINT_CLASS(73);
+public:
+       Gtk::Menu layermenu;
+private:
+       DEBUGPOINT_CLASS(74);
+       Gtk::Menu newlayermenu;
+       DEBUGPOINT_CLASS(76);
+       Gtk::Menu viewmenu;
+
+       DEBUGPOINT_CLASS(99);
+       Gtk::Menu keyframemenu;
+
+       Gtk::Menu parammenu;
+       DEBUGPOINT_CLASS(9);
+       Gtk::Menu trackmenu;
+       DEBUGPOINT_CLASS(7);
+
+       Gtk::CheckMenuItem* duck_mask_position;
+       Gtk::CheckMenuItem* duck_mask_vertex;
+       Gtk::CheckMenuItem* duck_mask_tangent;
+       Gtk::CheckMenuItem* duck_mask_radius;
+       Gtk::CheckMenuItem* duck_mask_width;
+       Gtk::CheckMenuItem* duck_mask_angle;
+*/
+       //! Menu members
+       Gtk::Menu parammenu;
+
+       Glib::RefPtr<Gtk::ToggleAction> grid_snap_toggle;
+       Glib::RefPtr<Gtk::ToggleAction> grid_show_toggle;
+
+       Gtk::RadioButtonGroup quality_group;
+       Gtk::RadioButtonGroup low_res_pixel_size_group;
+
+       Glib::RefPtr<Gtk::ActionGroup> action_group;
+
+       etl::handle<synfigapp::UIInterface> ui_interface_;
+       etl::handle<synfigapp::SelectionManager> selection_manager_;
+
+       bool is_playing_;
+
+       sigc::signal<void> signal_deleted_;
+
+       bool rebuild_ducks_queued;
+       sigc::connection queue_rebuild_ducks_connection;
+
+       /*
+ -- ** -- P U B L I C   D A T A -----------------------------------------------
+       */
+
+public:
+       void queue_rebuild_ducks();
+       sigc::signal<void>& signal_deleted() { return signal_deleted_; }
+
+       Gtk::Menu mainmenu;
+
+       bool duck_refresh_flag;
+       bool duck_refresh_needed;
+
+       //! This is for the IsWorking class.
+       int working_depth;
+
+       bool cancel;
+
+       /*
+ -- ** -- D I A L O G S -------------------------------------------------------
+       */
+
+public:
+
+       CanvasProperties canvas_properties;
+       CanvasOptions canvas_options;
+       RenderSettings render_settings;
+       Dialog_Waypoint waypoint_dialog;
+       Dialog_Keyframe keyframe_dialog;
+
+       std::auto_ptr<Dialog_Preview>                   preview_dialog;
+       //std::auto_ptr<Dialog_PreviewOptions>  previewoption_dialog;
+       std::auto_ptr<Dialog_SoundSelect>               sound_dialog;
+
+       /*
+ -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
+       */
+
+private:
+
+       // Constructor is private to force the use of the "create()" constructor
+       CanvasView(etl::loose_handle<Instance> instance,etl::handle<synfigapp::CanvasInterface> canvas_interface);
+
+       //! Constructor Helper
+       // Gtk::Widget* create_layer_tree();
+
+       //! Constructor Helper
+       // Gtk::Widget* create_children_tree();
+
+       //! Constructor Helper
+       // Gtk::Widget* create_keyframe_tree();
+
+       //! Constructor Helper
+       Gtk::Widget* create_status_bar();
+
+       //! Constructor Helper - Initializes all of the menus
+       void init_menus();
+
+       bool duck_change_param(const synfig::Point &value,synfig::Layer::Handle layer, synfig::String param_name);
+
+       void refresh_time_window();
+
+       void time_was_changed();
+
+       void refresh_rend_desc();
+
+       void toggle_duck_mask(Duckmatic::Type type);
+
+       Gtk::Widget *create_work_area();
+
+       Gtk::Widget *create_time_bar();
+
+       Gtk::Widget *create_display_bar();
+
+       //! Pop up menu for the bezier (bline, draw) tool (?)
+       void popup_param_menu_bezier(float location, synfigapp::ValueDesc value_desc)
+       { popup_param_menu(value_desc,location,true); }
+
+       //! Pop up menu for the tools but not the bezier ones.
+       void popup_param_menu(synfigapp::ValueDesc value_desc, float location=0, bool bezier=false);
+
+       void workarea_layer_selected(synfig::Layer::Handle layer);
+
+       void selected_layer_color_set(synfig::Color color);
+
+       void register_layer_type(synfig::Layer::Book::value_type &lyr,std::map<synfig::String,Gtk::Menu*>*);
+
+       //! Rebuilds the "new layer" menu
+       void build_new_layer_menu(Gtk::Menu &menu);
+
+       void rebuild_ducks_layer_(synfig::TransformStack& transform_stack, synfig::Canvas::Handle canvas, std::set<synfig::Layer::Handle>& selected_list);
+
+       void decrease_low_res_pixel_size();
+       void increase_low_res_pixel_size();
+       void toggle_low_res_pixel_flag();
+       void set_quality(int x);
+       void set_onion_skins();
+       void toggle_show_grid();
+       void toggle_snap_grid();
+       void toggle_onion_skin();
+
+       /*
+ -- ** -- P U B L I C   M E T H O D S -----------------------------------------
+       */
+
+public:
+       const synfig::TransformStack& get_curr_transform_stack()const { return curr_transform_stack; }
+
+       const synfig::Rect& get_bbox()const { return bbox; }
+
+       Glib::RefPtr<Glib::ObjectBase> get_ref_obj(const synfig::String& x);
+       Glib::RefPtr<const Glib::ObjectBase> get_ref_obj(const synfig::String& x)const;
+       void set_ref_obj(const synfig::String& x, Glib::RefPtr<Glib::ObjectBase> y);
+
+       Glib::RefPtr<Gtk::TreeModel> get_tree_model(const synfig::String& x);
+       Glib::RefPtr<const Gtk::TreeModel> get_tree_model(const synfig::String& x)const;
+       void set_tree_model(const synfig::String& x, Glib::RefPtr<Gtk::TreeModel> y);
+
+       Gtk::Widget* get_ext_widget(const synfig::String& x);
+       void set_ext_widget(const synfig::String& x, Gtk::Widget* y);
+
+       //std::map<synfig::String,Gtk::Widget*>& tree_view_book() { return tree_view_book_; }
+       //std::map<synfig::String,Gtk::Widget*>& ext_widget_book() { return tree_view_book_; }
+
+       void popup_main_menu();
+
+       Smach& get_smach() { return smach_; }
+
+       const Smach& get_smach()const { return smach_; }
+
+       Smach::event_result process_event_key(EventKey x);
+
+       void popup_layer_menu(synfig::Layer::Handle layer);
+
+       virtual ~CanvasView();
+
+       void set_mode(Mode x) { canvas_interface()->set_mode(x); }
+
+       Mode get_mode()const { return canvas_interface()->get_mode(); }
+
+       Gtk::Adjustment &time_adjustment() { return time_adjustment_; }
+
+       const Gtk::Adjustment &time_adjustment()const { return time_adjustment_; }
+
+       studio::Adjust_Window &time_window_adjustment() { return time_window_adjustment_; }
+
+       const studio::Adjust_Window &time_window_adjustment()const { return time_window_adjustment_; }
+
+       etl::handle<synfigapp::UIInterface> get_ui_interface() { return ui_interface_;}
+
+       etl::handle<synfigapp::SelectionManager> get_selection_manager() { return selection_manager_; }
+
+       Glib::RefPtr<Gtk::TreeModel> layer_tree_store() { return get_tree_model("layers"); }
+
+       Glib::RefPtr<const Gtk::TreeModel> layer_tree_store()const { return get_tree_model("layers"); }
+
+       Glib::RefPtr<Gtk::TreeModel> children_tree_store() { return get_tree_model("children"); }
+
+       Glib::RefPtr<const Gtk::TreeModel> children_tree_store()const { return get_tree_model("children"); }
+
+       Glib::RefPtr<Gtk::TreeModel> keyframe_tree_store() { return get_tree_model("keyframes"); }
+
+       Glib::RefPtr<const Gtk::TreeModel> keyframe_tree_store()const { return get_tree_model("keyframes"); }
+
+       void set_time(synfig::Time t) { canvas_interface_->set_time(t); }
+
+       synfig::Time get_time() { return canvas_interface_->get_time(); }
+
+       etl::handle<synfig::Canvas> get_canvas()const { return canvas_interface_->get_canvas(); }
+
+       etl::handle<Instance> get_instance()const { return instance_; }
+
+       etl::handle<synfigapp::CanvasInterface> canvas_interface() { return canvas_interface_; }
+
+       etl::handle<const synfigapp::CanvasInterface> canvas_interface()const { return canvas_interface_; }
+
+       void add_actions_to_menu(Gtk::Menu *menu,   const synfigapp::Action::ParamList &param_list, synfigapp::Action::Category category=synfigapp::Action::CATEGORY_ALL)const;
+
+       //! Updates the title of the window
+       void update_title();
+
+       //! Closes this document
+       bool close_instance();
+
+       //! Closes this canvas view
+       bool close_view();
+
+       //!     Stops the currently executing action
+       /*! \see get_cancel_status(), reset_cancel_status(), IsWorking */
+       void stop() { cancel=true; }
+
+       //! Returns the cancel status
+       /*! \see stop(), reset_cancel_status(), IsWorking */
+       bool get_cancel_status()const { return cancel; }
+
+       //! Resets the cancel status
+       /*! \see stop(), get_cancel_status(), IsWorking */
+       void reset_cancel_status() { cancel=false; }
+
+       void new_child_canvas();
+
+       //! Rebuilds layer_tree_store_ from the Canvas. Maintains selected items.
+       void rebuild_tables();
+
+       //! Builds layer_tree_store_ from the Canvas. Does not maintain selected items.
+       void build_tables();
+
+       //! Refreshes the data for the tables
+       void refresh_tables();
+
+       //void rebuild_layer_table();
+       //void build_layer_table();
+       //void refresh_layer_table();
+
+//     void rebuild_canvas_table();
+//     void build_canvas_table();
+//     void refresh_canvas_table();
+
+//     void rebuild_valuenode_table();
+//     void build_valuenode_table();
+//     void refresh_valuenode_table();
+
+       //! \writeme
+       void rebuild_ducks();
+
+       //bool add_to_ducks(synfigapp::ValueDesc value_desc, synfig::ParamDesc *param_desc=NULL);
+
+       //! Starts "playing" the animation in real-time
+       void play();
+
+       //! Shows the tables (Layer/Children)
+       void show_tables();
+
+       //! Hides the tables (Layer/Children)
+       void hide_tables();
+
+       //! Toggles the tables
+       void toggle_tables();
+
+       //! Gets the table status
+       bool tables_are_visible();
+
+       //! Shows the time bar
+       void show_timebar();
+
+       //! Hides the time bar
+       void hide_timebar();
+
+       //t Enables or disables interaction with the timebar
+       void set_sensitive_timebar(bool sensitive);
+
+       void time_zoom_in();
+       void time_zoom_out();
+
+       void add_layer(synfig::String x);
+
+       void show_keyframe_dialog();
+
+       void play_audio(float t);
+       void stop_audio();
+
+       void image_import();
+
+       void on_waypoint_clicked_canvasview(synfigapp::ValueDesc,std::set<synfig::Waypoint,std::less<synfig::UniqueID> >, int button);
+
+       void preview_option() {on_preview_option();}
+
+       void present();
+
+       bool is_playing() { return is_playing_; }
+
+       void update_quality();
+
+
+
+       /*
+ -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
+       */
+
+private:
+
+       void on_select_layers();
+       void on_unselect_layers();
+
+       void on_input_device_changed(GdkDevice*);
+
+       virtual void on_hide();
+
+       virtual bool on_focus_in_event(GdkEventFocus*);
+       virtual bool on_focus_out_event(GdkEventFocus*);
+
+       //bool on_children_tree_event(GdkEvent *event);
+
+       bool on_keyframe_tree_event(GdkEvent *event);
+
+       //void on_children_edited_value(const Glib::ustring&path_string,synfig::ValueBase value);
+
+       void on_dirty_preview();
+
+       bool on_children_user_click(int, Gtk::TreeRow, ChildrenTree::ColumnID);
+
+       bool on_layer_user_click(int, Gtk::TreeRow, LayerTree::ColumnID);
+
+//     void on_layer_toggle(const Glib::ustring& path_string, Gtk::TreeModelColumn<bool> column);
+
+       void on_mode_changed(synfigapp::CanvasInterface::Mode mode);
+
+//     void on_layer_waypoint_clicked(const Glib::ustring &, synfig::ValueNode_Animated::WaypointList::iterator);
+
+       //void on_children_waypoint_clicked(const Glib::ustring &, synfig::ValueNode_Animated::WaypointList::iterator);
+
+       void on_waypoint_changed();
+
+       void on_waypoint_delete();
+
+       void on_refresh_pressed();
+
+       void on_id_changed();
+
+       void on_time_changed();
+
+       /*
+       void on_layer_raise_pressed();
+       void on_layer_lower_pressed();
+       void on_layer_duplicate_pressed();
+       void on_layer_delete_pressed();
+       */
+
+       void on_keyframe_add_pressed();
+
+       void on_keyframe_duplicate_pressed();
+
+       void on_keyframe_remove_pressed();
+
+       void on_animate_button_pressed();
+
+       void on_keyframe_button_pressed();
+
+       void on_preview_option();
+       void on_preview_create(const PreviewInfo &);
+
+       void on_audio_option();
+       void on_audio_file_change(const std::string &f);
+       void on_audio_offset_change(const synfig::Time &t);
+
+       void on_audio_file_notify();
+       void on_audio_offset_notify();
+
+       bool on_duck_changed(const synfig::Point &value,const synfigapp::ValueDesc& value_desc);
+       bool on_duck_angle_changed(const synfig::Angle &rotation,const synfigapp::ValueDesc& value_desc);
+
+       void on_layer_toggle(synfig::Layer::Handle);
+
+       void on_edited_value(synfigapp::ValueDesc,synfig::ValueBase);
+
+       void on_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& selection_data, guint info, guint time);
+
+       //void on_audio_play();
+       bool on_audio_scrub();
+
+       void on_play_stop_pressed();
+
+protected:
+       bool close_instance_when_safe();
+       bool on_delete_event(GdkEventAny* event);
+
+       /*
+ -- ** -- S T A T I C   P U B L I C   M E T H O D S ---------------------------
+       */
+
+public:
+
+       static etl::handle<studio::CanvasView> create(etl::loose_handle<Instance> instance,etl::handle<synfig::Canvas> canvas);
+       static std::list<int>& get_pixel_sizes();
+
+}; // END of class CanvasView
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/cellrenderer_gradient.cpp b/synfig-studio/src/gui/cellrenderer_gradient.cpp
new file mode 100644 (file)
index 0000000..708c362
--- /dev/null
@@ -0,0 +1,96 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file cellrenderer_gradient.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include <gtkmm/entry.h>
+#include <gtkmm/button.h>
+#include "cellrenderer_gradient.h"
+#include "widget_gradient.h"
+#include "app.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+CellRenderer_Gradient::CellRenderer_Gradient():
+       Glib::ObjectBase        (typeid(CellRenderer_Gradient)),
+       Gtk::CellRendererText   (),
+       property_gradient_(*this,"gradient",synfig::Gradient())
+{
+       assert(0); //CHECK: This class does not appear to be used.
+       //CellRendererText::signal_edited().connect(sigc::mem_fun(*this,&studio::CellRenderer_Gradient::string_edited_));
+}
+
+CellRenderer_Gradient::~CellRenderer_Gradient()
+{
+}
+
+
+void
+CellRenderer_Gradient::render_vfunc(
+               const Glib::RefPtr<Gdk::Drawable>& window,
+               Gtk::Widget& /*widget*/,
+               const Gdk::Rectangle& /*background_area*/,
+               const Gdk::Rectangle& ca,
+               const Gdk::Rectangle& /*expose_area*/,
+               Gtk::CellRendererState /*flags*/)
+{
+       if(!window)
+               return;
+       render_gradient_to_window(window,ca,property_gradient_.get_value());
+}
+
+
+Gtk::CellEditable*
+CellRenderer_Gradient::start_editing_vfunc(
+       GdkEvent* /*event*/,
+       Gtk::Widget& /*widget*/,
+       const Glib::ustring& /*path*/,
+       const Gdk::Rectangle& /*background_area*/,
+       const Gdk::Rectangle& /*cell_area*/,
+       Gtk::CellRendererState /*flags*/)
+{
+       return 0;
+}
diff --git a/synfig-studio/src/gui/cellrenderer_gradient.h b/synfig-studio/src/gui/cellrenderer_gradient.h
new file mode 100644 (file)
index 0000000..10b54c5
--- /dev/null
@@ -0,0 +1,88 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file cellrenderer_gradient.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_CELLRENDERER_GRADIENT_H
+#define __SYNFIG_STUDIO_CELLRENDERER_GRADIENT_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/entry.h>
+#include <gtkmm/cellrenderertext.h>
+
+#include <sigc++/signal.h>
+#include <sigc++/slot.h>
+
+#include <synfig/gradient.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 Gtk { class Entry; class Button; };
+
+namespace studio {
+
+class CellRenderer_Gradient : public Gtk::CellRendererText
+{
+       sigc::signal<void, const Glib::ustring&> signal_secondary_click_;
+       sigc::signal<void, const Glib::ustring&, synfig::Gradient> signal_edited_;
+
+       Glib::Property<synfig::Gradient> property_gradient_;
+
+public:
+       sigc::signal<void, const Glib::ustring&, synfig::Gradient> &signal_edited()
+       {return signal_edited_; }
+
+       Glib::PropertyProxy<synfig::Gradient> property_gradient() { return property_gradient_.get_proxy();}
+
+       CellRenderer_Gradient();
+       ~CellRenderer_Gradient();
+
+protected:
+
+       virtual void
+       render_vfunc(
+               const Glib::RefPtr<Gdk::Drawable>& window,
+               Gtk::Widget& widget,
+               const Gdk::Rectangle& background_area,
+               const Gdk::Rectangle& ca,
+               const Gdk::Rectangle& expose_area,
+               Gtk::CellRendererState flags);
+
+       virtual Gtk::CellEditable* start_editing_vfunc(GdkEvent* event,
+                                                 Gtk::Widget& widget,
+                                                 const Glib::ustring& path,
+                                                 const Gdk::Rectangle& background_area,
+                                                 const Gdk::Rectangle& cell_area,
+                                                 Gtk::CellRendererState flags);
+
+}; // END of class CellRenderer_Gradient
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/cellrenderer_time.cpp b/synfig-studio/src/gui/cellrenderer_time.cpp
new file mode 100644 (file)
index 0000000..5567a35
--- /dev/null
@@ -0,0 +1,133 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file cellrenderer_time.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 <config.h>
+#endif
+
+#include <gtkmm/entry.h>
+#include <gtkmm/button.h>
+#include "cellrenderer_time.h"
+#include "app.h"
+#include "widget_time.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+CellRenderer_Time::CellRenderer_Time():
+       Glib::ObjectBase        (typeid(CellRenderer_Time)),
+       Gtk::CellRendererText   (),
+       property_time_(*this,"time",synfig::Time(0)),
+       property_fps_(*this,"fps", float(0))
+{
+       CellRendererText::signal_edited().connect(sigc::mem_fun(*this,&studio::CellRenderer_Time::string_edited_));
+}
+
+CellRenderer_Time::~CellRenderer_Time()
+{
+       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
+               synfig::info("CellRenderer_Time::~CellRenderer_Time(): Deleted");
+}
+
+void
+CellRenderer_Time::string_edited_(const Glib::ustring&path,const Glib::ustring&str)
+{
+       signal_edited_(path,Time((String)str,(Real)Time(property_fps_)));
+}
+
+void
+CellRenderer_Time::render_vfunc(
+               const Glib::RefPtr<Gdk::Drawable>& window,
+               Gtk::Widget& widget,
+               const Gdk::Rectangle& background_area,
+               const Gdk::Rectangle& ca,
+               const Gdk::Rectangle& expose_area,
+               Gtk::CellRendererState flags)
+{
+       if(!window)
+               return;
+       //int   height = ca.get_height();
+
+       Gtk::StateType state = Gtk::STATE_INSENSITIVE;
+       if(property_editable())
+               state = Gtk::STATE_NORMAL;
+       if((flags & Gtk::CELL_RENDERER_SELECTED) != 0)
+               state = (widget.has_focus()) ? Gtk::STATE_SELECTED : Gtk::STATE_ACTIVE;
+
+       const Time time(property_time_);
+       const float fps((Real)Time(property_fps_));
+
+       property_text()=(Glib::ustring)time.get_string(fps,App::get_time_format());
+
+       CellRendererText::render_vfunc(window,widget,background_area,ca,expose_area,flags);
+}
+
+
+Gtk::CellEditable*
+CellRenderer_Time::start_editing_vfunc(
+       GdkEvent* event,
+       Gtk::Widget& widget,
+       const Glib::ustring& path,
+       const Gdk::Rectangle& background_area,
+       const Gdk::Rectangle& cell_area,
+       Gtk::CellRendererState flags)
+{
+       // If we aren't editable, then there is nothing to do
+       if(!property_editable())
+               return 0;
+
+       const Time time(property_time_);
+       const float fps((Real)Time(property_fps_));
+
+       property_text()=(Glib::ustring)time.get_string(fps,App::get_time_format()|Time::FORMAT_FULL);
+#if 0
+       Widget_Time* widget_time(manage(new Widget_Time));
+       widget_time->set_fps(fps);
+       widget_time->set_value(time);
+       widget_time->signal_editing_done().connect(sigc::mem_fun(*this, &CellRenderer_Time::on_value_editing_done));
+       return widget_time;
+#else
+       return CellRendererText::start_editing_vfunc(event,widget,path,background_area,cell_area,flags);
+#endif
+}
diff --git a/synfig-studio/src/gui/cellrenderer_time.h b/synfig-studio/src/gui/cellrenderer_time.h
new file mode 100644 (file)
index 0000000..149f7d8
--- /dev/null
@@ -0,0 +1,94 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file cellrenderer_time.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_CELLRENDERER_TIME_H
+#define __SYNFIG_STUDIO_CELLRENDERER_TIME_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/entry.h>
+#include <gtkmm/cellrenderertext.h>
+
+#include <sigc++/signal.h>
+#include <sigc++/slot.h>
+
+#include <synfig/time.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 Gtk { class Entry; class Button; };
+
+namespace studio {
+
+class CellRenderer_Time : public Gtk::CellRendererText
+{
+       sigc::signal<void, const Glib::ustring&> signal_secondary_click_;
+       sigc::signal<void, const Glib::ustring&, synfig::Time> signal_edited_;
+
+       Glib::Property<synfig::Time> property_time_;
+       Glib::Property<synfig::Time> property_fps_;
+
+       void string_edited_(const Glib::ustring&,const Glib::ustring&);
+
+       void on_value_editing_done();
+
+public:
+       sigc::signal<void, const Glib::ustring&, synfig::Time> &signal_edited()
+       {return signal_edited_; }
+
+       Glib::PropertyProxy<synfig::Time> property_time() { return property_time_.get_proxy();}
+       Glib::PropertyProxy<synfig::Time> property_fps() { return property_fps_.get_proxy();}
+
+       CellRenderer_Time();
+       ~CellRenderer_Time();
+
+protected:
+
+       virtual void
+       render_vfunc(
+               const Glib::RefPtr<Gdk::Drawable>& window,
+               Gtk::Widget& widget,
+               const Gdk::Rectangle& background_area,
+               const Gdk::Rectangle& ca,
+               const Gdk::Rectangle& expose_area,
+               Gtk::CellRendererState flags);
+
+       virtual Gtk::CellEditable* start_editing_vfunc(GdkEvent* event,
+                                                 Gtk::Widget& widget,
+                                                 const Glib::ustring& path,
+                                                 const Gdk::Rectangle& background_area,
+                                                 const Gdk::Rectangle& cell_area,
+                                                 Gtk::CellRendererState flags);
+
+}; // END of class CellRenderer_Time
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/cellrenderer_timetrack.cpp b/synfig-studio/src/gui/cellrenderer_timetrack.cpp
new file mode 100644 (file)
index 0000000..8382465
--- /dev/null
@@ -0,0 +1,906 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file cellrenderer_timetrack.cpp
+**     \brief Template Header
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 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 <config.h>
+#endif
+
+#include <gtkmm/label.h>
+#include "cellrenderer_timetrack.h"
+#include <gtk/gtk.h>
+#include <gtkmm/spinbutton.h>
+#include <gtkmm/combo.h>
+#include <ETL/stringf>
+#include "widget_value.h"
+#include "app.h"
+#include <gtkmm/menu.h>
+#include <gtkmm/optionmenu.h>
+#include "widget_time.h"
+#include "widget_timeslider.h"
+
+#include <synfigapp/canvasinterface.h>
+#include "instance.h"
+
+#include "general.h"
+
+#endif
+
+using namespace synfig;
+using namespace std;
+using namespace etl;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+
+static char stipple_xpm[] = { 2, 0 };
+
+//mode for modifier keys
+enum MODMODE
+{
+       NONE = 0,
+       SELECT_MASK = Gdk::CONTROL_MASK,
+       COPY_MASK = Gdk::SHIFT_MASK,
+       DELETE_MASK = Gdk::MOD1_MASK
+};
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+CellRenderer_TimeTrack::CellRenderer_TimeTrack():
+       Glib::ObjectBase        (typeid(CellRenderer_TimeTrack)),
+       Gtk::CellRenderer       (),
+       adjustment_                     (10,10,20,0,0,0),
+
+       property_valuedesc_     (*this,"value_desc",synfigapp::ValueDesc()),
+       property_canvas_        (*this,"canvas",synfig::Canvas::Handle()),
+       property_adjustment_(*this,"adjustment",&adjustment_),
+       property_enable_timing_info_(*this,"enable-timing-info", false)
+{
+       dragging=false;
+       selection=false;
+}
+
+CellRenderer_TimeTrack::~CellRenderer_TimeTrack()
+{
+       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
+               synfig::info("CellRenderer_TimeTrack::~CellRenderer_TimeTrack(): Deleted");
+}
+
+void
+CellRenderer_TimeTrack::set_adjustment(Gtk::Adjustment &x)
+{
+       property_adjustment_=&x;
+//     x.signal_value_changed().connect(sigc::mem_fun(*this,&Gtk::Widget::queue_draw));
+}
+
+synfig::Canvas::Handle
+CellRenderer_TimeTrack::get_canvas()const
+{
+       return const_cast<CellRenderer_TimeTrack*>(this)->property_canvas().get_value();
+}
+
+Gtk::Adjustment *
+CellRenderer_TimeTrack::get_adjustment()
+{
+       return (Gtk::Adjustment*)property_adjustment_;
+}
+
+const Gtk::Adjustment *
+CellRenderer_TimeTrack::get_adjustment()const
+{
+       return (const Gtk::Adjustment*)property_adjustment_;
+}
+
+bool
+CellRenderer_TimeTrack::is_selected(const Waypoint& waypoint)const
+{
+       return selected==waypoint;
+}
+
+const synfig::Time get_time_offset_from_vdesc(const synfigapp::ValueDesc &v)
+{
+#ifdef ADJUST_WAYPOINTS_FOR_TIME_OFFSET
+       if(getenv("SYNFIG_SHOW_CANVAS_PARAM_WAYPOINTS") ||
+          v.get_value_type() != synfig::ValueBase::TYPE_CANVAS)
+               return synfig::Time::zero();
+
+       synfig::Canvas::Handle canvasparam = v.get_value().get(Canvas::Handle());
+       if(!canvasparam)
+               return synfig::Time::zero();
+
+       if (!v.parent_is_layer_param())
+               return synfig::Time::zero();
+
+       synfig::Layer::Handle layer = v.get_layer();
+
+       if (layer->get_name()!="PasteCanvas")
+               return synfig::Time::zero();
+
+       return layer->get_param("time_offset").get(Time());
+#else // ADJUST_WAYPOINTS_FOR_TIME_OFFSET
+       return synfig::Time::zero();
+#endif
+}
+
+//kind of a hack... pointer is ugly
+const synfig::Node::time_set *get_times_from_vdesc(const synfigapp::ValueDesc &v)
+{
+       if(!getenv("SYNFIG_SHOW_CANVAS_PARAM_WAYPOINTS") &&
+          v.get_value_type() == synfig::ValueBase::TYPE_CANVAS)
+       {
+               synfig::Canvas::Handle canvasparam = v.get_value().get(Canvas::Handle());
+
+               if(canvasparam)
+                       return &canvasparam->get_times();
+       }
+
+       ValueNode *base_value = v.get_value_node().get();
+
+       ValueNode_DynamicList *parent_value_node =
+                       v.parent_is_value_node() ?
+                               dynamic_cast<ValueNode_DynamicList *>(v.get_parent_value_node().get()) :
+                               0;
+
+       //we want a dynamic list entry to override the normal...
+       if(parent_value_node)
+       {
+               return &parent_value_node->list[v.get_index()].get_times();
+       }else if(base_value) //don't render stuff if it's just animated...
+       {
+               return &base_value->get_times();
+       }
+       return 0;
+}
+
+bool get_closest_time(const synfig::Node::time_set &tset, const Time &t, const Time &range, Time &out)
+{
+       Node::time_set::const_iterator  i,j,end = tset.end();
+
+       // stop the crash mentioned in bug #1689282
+       // doesn't solve the underlying problem though, I don't think
+       if (tset.size() == 0)
+       {
+               synfig::error(__FILE__":%d: tset.size() == 0",__LINE__);
+               return false;
+       }
+
+       //TODO add in RangeGet so it's not so damn hard to click on points
+
+       i = tset.upper_bound(t); //where t is the lower bound, t < [first,i)
+       j = i; --j;
+
+       double dist = Time::end();
+       double closest = 0;
+
+       if(i != end)
+       {
+               closest = i->get_time();
+               dist = abs(i->get_time() - t);
+       }
+
+       if(j != end && (abs(j->get_time() - t) < dist) )
+       {
+               closest = j->get_time();
+               dist = abs(j->get_time() - t);
+       }
+
+       if( dist <= range/2 )
+       {
+               out = closest;
+               return true;
+       }
+
+       return false;
+}
+
+void
+CellRenderer_TimeTrack::render_vfunc(
+               const Glib::RefPtr<Gdk::Drawable>& window,
+               Gtk::Widget& widget,
+               const Gdk::Rectangle& /*background_area*/,
+               const Gdk::Rectangle& area_,
+               const Gdk::Rectangle& /*expose_area*/,
+               Gtk::CellRendererState /*flags*/)
+{
+       if(!window)
+               return;
+
+       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(window));
+       Glib::RefPtr<Gdk::GC> inactive_gc(Gdk::GC::create(window));
+       Gtk::Adjustment *adjustment=get_adjustment();
+       // Gtk::StateType state = Gtk::STATE_ACTIVE;
+       // Gtk::ShadowType shadow;
+
+       Gdk::Color
+               curr_time_color("#0000ff"),
+               inactive_color("#000000"),
+               keyframe_color("#a07f7f");
+       Gdk::Color activepoint_color[2];
+
+       activepoint_color[0]=Gdk::Color("#ff0000");
+       activepoint_color[1]=Gdk::Color("#00ff00");
+
+       inactive_gc->set_rgb_fg_color(inactive_color);
+       inactive_gc->set_stipple(Gdk::Bitmap::create(stipple_xpm,2,2));
+       inactive_gc->set_fill(Gdk::STIPPLED);
+
+       synfig::Canvas::Handle canvas(property_canvas().get_value());
+
+       synfigapp::ValueDesc value_desc = property_value_desc().get_value();
+       synfig::ValueNode *base_value = value_desc.get_value_node().get();
+       // synfig::ValueNode_Animated *value_node=dynamic_cast<synfig::ValueNode_Animated*>(base_value);
+
+       synfig::ValueNode_DynamicList *parent_value_node(0);
+       if(property_value_desc().get_value().parent_is_value_node())
+               parent_value_node=dynamic_cast<synfig::ValueNode_DynamicList*>(property_value_desc().get_value().get_parent_value_node().get());
+
+       // If the canvas is defined, then load up the keyframes
+       if(canvas)
+       {
+               const synfig::KeyframeList& keyframe_list(canvas->keyframe_list());
+               synfig::KeyframeList::const_iterator iter;
+
+               for(iter=keyframe_list.begin();iter!=keyframe_list.end();++iter)
+               {
+                       if(!iter->get_time().is_valid())
+                               continue;
+
+                       const int x((int)((float)area_.get_width()/(adjustment->get_upper()-adjustment->get_lower())*(iter->get_time()-adjustment->get_lower())));
+                       if(iter->get_time()>=adjustment->get_lower() && iter->get_time()<adjustment->get_upper())
+                       {
+                               gc->set_rgb_fg_color(keyframe_color);
+                               window->draw_rectangle(gc, true, area_.get_x()+x, area_.get_y(), 1, area_.get_height()+1);
+                       }
+               }
+       }
+
+       //render all the time points that exist
+       {
+               const synfig::Node::time_set *tset = get_times_from_vdesc(value_desc);
+
+               if(tset)
+               {
+                       const synfig::Time time_offset = get_time_offset_from_vdesc(value_desc);
+                       synfig::Node::time_set::const_iterator  i = tset->begin(), end = tset->end();
+
+                       float   lower = adjustment->get_lower(),
+                                       upper = adjustment->get_upper();
+
+                       Glib::RefPtr<Gdk::GC>   gc = Gdk::GC::create(widget.get_window());
+
+                       Gdk::Rectangle area(area_);
+                       gc->set_clip_rectangle(area);
+                       gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+
+                       bool valselected = sel_value.get_value_node() == base_value && !sel_times.empty();
+
+                       float cfps = get_canvas()->rend_desc().get_frame_rate();
+
+                       vector<Time>    drawredafter;
+
+                       Time diff = actual_time - actual_dragtime;//selected_time-drag_time;
+                       for(; i != end; ++i)
+                       {
+                               //find the coordinate in the drawable space...
+                               Time t_orig = i->get_time();
+                               if(!t_orig.is_valid()) continue;
+                               Time t = t_orig - time_offset;
+                               if(t<adjustment->get_lower() || t>adjustment->get_upper()) continue;
+
+                               //if it found it... (might want to change comparison, and optimize
+                               //                                       sel_times.find to not produce an overall nlogn solution)
+
+                               bool selected=false;
+                               //not dragging... just draw as per normal
+                               //if move dragging draw offset
+                               //if copy dragging draw both...
+
+                               if(valselected && sel_times.find(t_orig) != sel_times.end())
+                               {
+                                       if(dragging) //skip if we're dragging because we'll render it later
+                                       {
+                                               if(mode & COPY_MASK) // draw both blue and red moved
+                                               {
+                                                       drawredafter.push_back(t + diff.round(cfps));
+                                                       gc->set_rgb_fg_color(Gdk::Color("#00EEEE"));
+                                               }else if(mode & DELETE_MASK) //it's just red...
+                                               {
+                                                       gc->set_rgb_fg_color(Gdk::Color("#EE0000"));
+                                                       selected=true;
+                                               }else //move - draw the red on top of the others...
+                                               {
+                                                       drawredafter.push_back(t + diff.round(cfps));
+                                                       continue;
+                                               }
+                                       }else
+                                       {
+                                               gc->set_rgb_fg_color(Gdk::Color("#EE0000"));
+                                               selected=true;
+                                       }
+                               }else
+                               {
+                                       gc->set_rgb_fg_color(Gdk::Color("#00EEEE"));
+                               }
+
+                               //synfig::info("Displaying time: %.3f s",(float)t);
+                               const int x = (int)((t-lower)*area.get_width()/(upper-lower));
+
+                               //should draw me a grey filled circle...
+                               Gdk::Rectangle area2(
+                                       area.get_x() - area.get_height()/2 + x + 1,
+                                       area.get_y() + 1,
+                                       area.get_height()-2,
+                                       area.get_height()-2
+                               );
+                               render_time_point_to_window(window,area2,*i - time_offset,selected);
+
+                               /*window->draw_arc(gc,true,
+                               area.get_x() + x - area.get_height()/4, area.get_y() + area.get_height()/8,
+                               area.get_height()/2, area.get_height()*3/4,
+                               0, 64*360);
+
+                               gc->set_rgb_fg_color(Gdk::Color("#000000"));
+                               window->draw_arc(gc,false,
+                               area.get_x() + x - area.get_height()/4, area.get_y() + area.get_height()/8,
+                               area.get_height()/2, area.get_height()*3/4,
+                               0, 64*360);
+                               */
+                       }
+
+                       {
+                               vector<Time>::iterator i = drawredafter.begin(), end = drawredafter.end();
+                               for(; i != end; ++i)
+                               {
+                                       //find the coordinate in the drawable space...
+                                       Time t = *i;
+
+                                       if(!t.is_valid())
+                                               continue;
+
+                                       //synfig::info("Displaying time: %.3f s",(float)t);
+                                       const int x = (int)((t-lower)*area.get_width()/(upper-lower));
+
+                                       //should draw me a grey filled circle...
+
+                                       Gdk::Rectangle area2(
+                                               area.get_x() - area.get_height()/2 + x + 1,
+                                               area.get_y() + 1,
+                                               area.get_height()-2,
+                                               area.get_height()-2
+                                       );
+                                       render_time_point_to_window(window,area2,*i,true);
+/*                                     gc->set_rgb_fg_color(Gdk::Color("#EE0000"));
+                                       window->draw_arc(gc,true,
+                                       area.get_x() + x - area.get_height()/4, area.get_y() + area.get_height()/8,
+                                       area.get_height()/2, area.get_height()*3/4,
+                                       0, 64*360);
+
+                                       gc->set_rgb_fg_color(Gdk::Color("#000000"));
+                                       window->draw_arc(gc,false,
+                                       area.get_x() + x - area.get_height()/4, area.get_y() + area.get_height()/8,
+                                       area.get_height()/2, area.get_height()*3/4,
+                                       0, 64*360);
+*/
+                               }
+                       }
+               }
+       }
+
+       /* THIS IS NOW HANDLED ENTIRELY BY THE TIMEPOINT SYSTEM
+       // This this is an animated value node, then render the waypoints
+       if(value_node)
+       {
+               //now render the actual waypoints
+               synfig::ValueNode_Animated::WaypointList::iterator iter;
+               for(
+                       iter=value_node->waypoint_list().begin();
+                       iter!=value_node->waypoint_list().end();
+                       iter++
+               )
+               {
+                       if(!iter->get_time().is_valid())
+                               continue;
+                       int x;
+                       bool selected=false;
+                       if(is_selected(*iter))
+                       {
+                               Time t(iter->get_time());
+
+
+                               if(dragging)
+                                       t=(t+selected_time-drag_time).round(get_canvas()->rend_desc().get_frame_rate());
+
+                               x=(int)((float)area.get_width()/(adjustment->get_upper()-adjustment->get_lower())*(t-adjustment->get_lower()));
+                               shadow=Gtk::SHADOW_IN;
+                               selected=true;
+                       }
+                       else
+                       {
+                               x=(int)((float)area.get_width()/(adjustment->get_upper()-adjustment->get_lower())*(iter->get_time()-adjustment->get_lower()));
+                               shadow=Gtk::SHADOW_OUT;
+                               selected=false;
+                       }
+
+
+                       widget.get_style()->paint_diamond(
+                               Glib::RefPtr<Gdk::Window>::cast_static(window),
+                               state,
+                               shadow,
+                               area,
+                               widget,
+                               "solid",
+                               area.get_x()+x-area.get_height()/4,
+                               area.get_y()+area.get_height()/4,
+                               area.get_height()/2,
+                               area.get_height()/2
+                       );
+               }
+       }
+       */
+               Gdk::Rectangle area(area_);
+       // If the parent of this value node is a dynamic list, then
+       // render the on and off times
+       if(parent_value_node)
+       {
+               const int index(property_value_desc().get_value().get_index());
+               const synfig::ValueNode_DynamicList::ListEntry& list_entry(parent_value_node->list[index]);
+               const synfig::ValueNode_DynamicList::ListEntry::ActivepointList& activepoint_list(list_entry.timing_info);
+               synfig::ValueNode_DynamicList::ListEntry::ActivepointList::const_iterator iter,next;
+
+               bool is_off(false);
+               if(!activepoint_list.empty())
+                       is_off=!activepoint_list.front().state;
+
+               int xstart(0);
+
+               int x=0,prevx=0;
+               for(next=activepoint_list.begin(),iter=next++;iter!=activepoint_list.end();iter=next++)
+               {
+                       x=((int)((float)area.get_width()/(adjustment->get_upper()-adjustment->get_lower())*(iter->time-adjustment->get_lower())));
+                       if(x<0)x=0;
+                       if(x>area.get_width())x=area.get_width();
+
+                       bool status_at_time=0;
+                       if(next!=activepoint_list.end())
+                       {
+                               status_at_time=!list_entry.status_at_time((iter->time+next->time)/2.0);
+                       }
+                       else
+                               status_at_time=!list_entry.status_at_time(Time::end());
+
+                       if(!is_off && status_at_time)
+                       {
+                               xstart=x;
+                               is_off=true;
+                       }
+                       else
+                       if(is_off && !status_at_time)
+                       {
+                               window->draw_rectangle(inactive_gc, true, area.get_x()+xstart, area.get_y(), x-xstart, area.get_height());
+                               is_off=false;
+                       }
+
+                       /*
+                       if(!is_off && iter!=activepoint_list.end() && next->state==false && iter->state==false)
+                       {
+                               xstart=x;
+                               is_off=true;
+                       }
+                       else if(is_off && next!=activepoint_list.end() && iter->state==false && next->state==true)
+                       {
+                               window->draw_rectangle(inactive_gc, true, area.get_x()+xstart, area.get_y(), x-xstart, area.get_height());
+                               is_off=false;
+                       }
+                       else if(is_off && iter!=activepoint_list.end() && iter->state==true)
+                       {
+                               window->draw_rectangle(inactive_gc, true, area.get_x()+xstart, area.get_y(), prevx-xstart, area.get_height());
+                               is_off=false;
+                       }
+                       */
+
+
+
+                       if(iter->time>=adjustment->get_lower() && iter->time<adjustment->get_upper())
+                       {
+                               int w(1);
+                               if(selected==*iter)
+                                       w=3;
+                               gc->set_rgb_fg_color(activepoint_color[iter->state]);
+                               window->draw_rectangle(gc, true, area.get_x()+x-w/2, area.get_y(), w, area.get_height());
+                       }
+                       prevx=x;
+               }
+               if(is_off)
+               {
+                       window->draw_rectangle(inactive_gc, true, area.get_x()+xstart, area.get_y(), area.get_width()-xstart, area.get_height());
+               }
+       }
+
+       // Render a line that defines the current tick in time
+       {
+               gc->set_rgb_fg_color(curr_time_color);
+
+               const int x((int)((float)area.get_width()/(adjustment->get_upper()-adjustment->get_lower())*(adjustment->get_value()-adjustment->get_lower())));
+
+               if(adjustment->get_value()>=adjustment->get_lower() && adjustment->get_value()<adjustment->get_upper())
+                       window->draw_rectangle(gc, true, area.get_x()+x, area.get_y(), 1, area.get_height());
+       }
+}
+
+synfig::ValueNode_Animated::WaypointList::iterator
+CellRenderer_TimeTrack::find_waypoint(const synfig::Time& /*t*/,const synfig::Time& scope)
+{
+       synfig::ValueNode_Animated *value_node=dynamic_cast<synfig::ValueNode_Animated*>(property_value_desc().get_value().get_value_node().get());
+
+    Time nearest(Time::end());
+
+       synfig::ValueNode_Animated::WaypointList::iterator iter,ret;
+
+       if(value_node)
+       {
+               for(
+                       iter=value_node->waypoint_list().begin();
+                       iter!=value_node->waypoint_list().end();
+                       iter++
+                       )
+               {
+                       Time val=abs(iter->get_time()-selected_time);
+                       if(val<nearest)
+                       {
+                               nearest=val;
+                               ret=iter;
+                       }
+               }
+
+               if(nearest!=Time::end() && nearest<scope)
+               {
+                       return ret;
+               }
+       }
+       throw int();
+}
+
+bool
+CellRenderer_TimeTrack::activate_vfunc(
+       GdkEvent* event,
+       Gtk::Widget& /*widget*/,
+       const Glib::ustring& treepath,
+       const Gdk::Rectangle& /*background_area*/,
+       const Gdk::Rectangle& cell_area,
+       Gtk::CellRendererState /*flags*/)
+{
+       path=treepath;
+       synfig::ValueNode_Animated::WaypointList::iterator iter;
+    Time nearest=1000000000;
+       Gtk::Adjustment *adjustment=get_adjustment();
+
+       // synfig::ValueNode_Animated *value_node=dynamic_cast<synfig::ValueNode_Animated*>(property_value_desc().get_value().get_value_node().get());
+
+       synfig::Canvas::Handle canvas(get_canvas());
+
+       synfig::ValueNode_DynamicList *parent_value_node(0);
+       if(property_value_desc().get_value().parent_is_value_node())
+               parent_value_node=dynamic_cast<synfig::ValueNode_DynamicList*>(property_value_desc().get_value().get_parent_value_node().get());
+
+       Time deltatime = 0;
+       Time curr_time;
+       switch(event->type)
+       {
+       case GDK_MOTION_NOTIFY:
+               curr_time=((float)event->motion.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();
+
+               mode = NONE;
+               {
+                       Gdk::ModifierType mod;
+                       Gdk::Event(event).get_state(mod);
+                       mode = mod;
+               }
+               break;
+       case GDK_BUTTON_PRESS:
+       case GDK_BUTTON_RELEASE:
+       default:
+               curr_time=((float)event->button.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();
+               {
+                       Gdk::ModifierType mod;
+                       Gdk::Event(event).get_state(mod);
+                       mode = mod;
+               }
+               break;
+       }
+       actual_time = curr_time;
+       if(canvas)
+               curr_time=curr_time.round(canvas->rend_desc().get_frame_rate());
+       selected_time=curr_time;
+
+    Time pixel_width((adjustment->get_upper()-adjustment->get_lower())/cell_area.get_width());
+
+    switch(event->type)
+    {
+       case GDK_BUTTON_PRESS:
+               //selected_time=((float)event->button.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();
+
+               //Deal with time point selection, but only if they aren't involved in the insanity...
+               if(/*!value_node && */event->button.button == 1)
+               {
+                       Time stime;
+
+                       /*!     UI specification:
+
+                               When nothing is selected, clicking on a point in either normal mode or
+                                       additive mode will select the time point closest to the click.
+                                       Subtractive click will do nothing
+
+                               When things are already selected, clicking on a selected point does
+                                       nothing (in both normal and add mode).  Add mode clicking on an unselected
+                                       point adds it to the set.  Normal clicking on an unselected point will
+                                       select only that one time point.  Subtractive clicking on any point
+                                       will remove it from the the set if it is included.
+                       */
+
+                       synfigapp::ValueDesc valdesc = property_value_desc().get_value();
+                       const Node::time_set *tset = get_times_from_vdesc(valdesc);
+                       const synfig::Time time_offset = get_time_offset_from_vdesc(valdesc);
+
+                       bool clickfound = tset && get_closest_time(*tset,actual_time+time_offset,pixel_width*cell_area.get_height(),stime);
+                       bool selectmode = mode & SELECT_MASK;
+
+                       //NOTE LATER ON WE SHOULD MAKE IT SO MULTIPLE VALUENODES CAN BE SELECTED AT ONCE
+                       //we want to jump to the value desc if we're not currently on it
+                       //      but only if we want to add the point
+                       if(clickfound && !(sel_value == valdesc))
+                       {
+                               sel_value = valdesc;
+                               sel_times.clear();
+                       }
+
+                       //now that we've made sure we're selecting the correct value, deal with the already selected points
+                       set<Time>::iterator foundi = clickfound ? sel_times.find(stime) : sel_times.end();
+                       bool found = foundi != sel_times.end();
+
+                       //remove all other points from our list... (only select the one we need)
+                       if(!selectmode && !found)
+                       {
+                               sel_times.clear();
+                       }
+
+                       if(found && selectmode) //remove a single already selected point
+                       {
+                               sel_times.erase(foundi);
+                       }else if(clickfound) //otherwise look at adding it
+                       {
+                               //for replace the list was cleared earlier, and for add it wasn't so it works
+                               sel_times.insert(stime);
+                       }
+               }
+
+               selection=false;
+               try
+               {
+                       iter=find_waypoint(selected_time,pixel_width*cell_area.get_height()/2);
+                       selected_waypoint=iter;
+                       selected=*iter;
+
+                       selection=true;
+               }
+               catch(int)
+               {
+                       selection=false;
+                       selected=synfig::UniqueID::nil();
+               }
+
+               if((!sel_times.empty() || selection) && event->button.button==1)
+               {
+                       dragging=true;
+                       drag_time=selected_time;
+                       actual_dragtime=actual_time;
+               }
+               //selected_time=iter->time;
+
+               /*
+               // Activepoint Selection
+               if(parent_value_node)
+               {
+                       const int index(property_value_desc().get_value().get_index());
+                       const synfig::ValueNode_DynamicList::ListEntry::ActivepointList& activepoint_list(parent_value_node->list[index].timing_info);
+                       synfig::ValueNode_DynamicList::ListEntry::ActivepointList::const_iterator iter;
+
+                       for(iter=activepoint_list.begin();iter!=activepoint_list.end();++iter)
+                       {
+                               Time val=abs(iter->time-selected_time);
+                               if(val<nearest)
+                               {
+                                       nearest=val;
+                                       selected=*iter;
+                                       selection=true;
+                               }
+                       }
+                       // Perhaps I should signal if we selected this activepoint?
+               }*/
+
+                       if(event->button.button==3)
+                       {
+                               Time stime;
+                               synfigapp::ValueDesc valdesc = property_value_desc().get_value();
+                               const Node::time_set *tset = get_times_from_vdesc(valdesc);
+                               synfig::Time time_offset = get_time_offset_from_vdesc(valdesc);
+
+                               bool clickfound = tset && get_closest_time(*tset,actual_time+time_offset,pixel_width*cell_area.get_height(),stime);
+
+                               etl::handle<synfig::Node> node;
+                               if(!getenv("SYNFIG_SHOW_CANVAS_PARAM_WAYPOINTS") &&
+                                  valdesc.get_value(stime).get_type()==ValueBase::TYPE_CANVAS)
+                               {
+                                       node=Canvas::Handle(valdesc.get_value(stime).get(Canvas::Handle()));
+                               }
+                               else //if(valdesc.is_value_node())
+                               {
+                                       node=valdesc.get_value_node();
+                               }
+
+                               if(clickfound && node)
+                                       signal_waypoint_clicked_cellrenderer()(node, stime, time_offset, 2);
+                       }
+
+               break;
+       case GDK_MOTION_NOTIFY:
+               //if(selection && dragging)
+               //      selected_time=((float)event->motion.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();
+               return true;
+
+               break;
+       case GDK_BUTTON_RELEASE:
+               {
+                       //selected_time=((float)event->button.x-(float)cell_area.get_x())/(float)cell_area.get_width()*(adjustment->get_upper()-adjustment->get_lower())+adjustment->get_lower();
+                       dragging=false;
+
+                       /*if(event->button.button==3 && selection)
+                       {
+                               signal_waypoint_clicked_cellrenderer()(path,*selected_waypoint,event->button.button-1);
+                               return true;
+                       }
+                       */
+
+                       //Time point stuff...
+                       if(event->button.button == 1)
+                       {
+                               bool delmode = (mode & DELETE_MASK) && !(mode & COPY_MASK);
+                               deltatime = actual_time - actual_dragtime;
+                               if(sel_times.size() != 0 && (delmode || !deltatime.is_equal(Time(0))))
+                               {
+                                       synfigapp::Action::ParamList param_list;
+                                       param_list.add("canvas",canvas_interface()->get_canvas());
+                                       param_list.add("canvas_interface",canvas_interface());
+
+                                       if(!getenv("SYNFIG_SHOW_CANVAS_PARAM_WAYPOINTS") &&
+                                          sel_value.get_value_type() == synfig::ValueBase::TYPE_CANVAS)
+                                       {
+                                               param_list.add("addcanvas",sel_value.get_value().get(Canvas::Handle()));
+                                       }else
+                                       {
+                                               param_list.add("addvaluedesc",sel_value);
+                                       }
+
+                                       set<Time>       newset;
+                                       std::set<synfig::Time>::iterator i = sel_times.begin(), end = sel_times.end();
+                                       for(; i != end; ++i)
+                                       {
+                                               param_list.add("addtime",*i);
+
+                                               newset.insert((*i + deltatime).round(get_canvas()->rend_desc().get_frame_rate()));
+                                       }
+
+                                       if(!delmode)
+                                               param_list.add("deltatime",deltatime);
+                               //      param_list.add("time",canvas_interface()->get_time());
+
+                                       if(mode & COPY_MASK) //copy
+                                       {
+                                               etl::handle<studio::Instance>::cast_static(canvas_interface()->get_instance())
+                                                       ->process_action("TimepointsCopy", param_list);
+                                       }else if(delmode) //DELETE
+                                       {
+                                               etl::handle<studio::Instance>::cast_static(canvas_interface()->get_instance())
+                                                       ->process_action("TimepointsDelete", param_list);
+                                       }else //MOVE
+                                       {
+                                               etl::handle<studio::Instance>::cast_static(canvas_interface()->get_instance())
+                                                       ->process_action("TimepointsMove", param_list);
+                                       }
+
+                                       //now replace all the selected with the new selected
+                                       sel_times = newset;
+                               }
+                       }
+
+
+
+                       /*if(value_node && selection)
+                       {
+                               if(selected_time==drag_time && event->button.button!=3)
+                                       signal_waypoint_clicked_cellrenderer()(path,*selected_waypoint,event->button.button-1);
+                               else
+                               if(event->button.button==1)
+                               {
+                                       synfig::Waypoint waypoint(*selected_waypoint);
+                                       Time newtime((waypoint.get_time()+(selected_time-drag_time)).round(canvas->rend_desc().get_frame_rate()));
+                                       if(waypoint.get_time()!=newtime)
+                                       {
+                                               waypoint.set_time(newtime);
+                                               signal_waypoint_changed_(waypoint,value_node);
+                                       }
+                               }
+                       }*/
+
+                       //if(selection)
+                       //      selected_time=iter->time;
+                       //selected_time=iter->get_time();
+                       return true;
+               }
+       default:
+               //std::cerr<<"unknown event type "<<event->type<<std::endl;
+               return false;
+               break;
+       }
+
+
+
+       return false;
+}
+
+
+
+// The following three functions don't get documented correctly by
+// doxygen 1.5.[23] because of a bug with any function whose name
+// begins with 'property'.  Fixed in doxygen 1.5.4 apparently.  See
+// http://bugzilla.gnome.org/show_bug.cgi?id=471185 .
+Glib::PropertyProxy<synfigapp::ValueDesc>
+CellRenderer_TimeTrack::property_value_desc()
+{
+       return Glib::PropertyProxy<synfigapp::ValueDesc>(this,"value_desc");
+}
+
+Glib::PropertyProxy<synfig::Canvas::Handle>
+CellRenderer_TimeTrack::property_canvas()
+{
+       return Glib::PropertyProxy<synfig::Canvas::Handle>(this,"canvas");
+}
+
+Glib::PropertyProxy<Gtk::Adjustment* >
+CellRenderer_TimeTrack::property_adjustment()
+{
+       return Glib::PropertyProxy<Gtk::Adjustment* >(this,"adjustment");
+}
+
+void
+CellRenderer_TimeTrack::set_canvas_interface(etl::loose_handle<synfigapp::CanvasInterface>     h)
+{
+       canvas_interface_ = h;
+}
diff --git a/synfig-studio/src/gui/cellrenderer_timetrack.h b/synfig-studio/src/gui/cellrenderer_timetrack.h
new file mode 100644 (file)
index 0000000..519ac8d
--- /dev/null
@@ -0,0 +1,207 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file cellrenderer_timetrack.h
+**     \brief Template Header
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 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
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_GTKMM_CELLRENDERER_TIMETRACK_H
+#define __SYNFIG_GTKMM_CELLRENDERER_TIMETRACK_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtk/gtk.h>
+#include <gtkmm/ruler.h>
+#include <gtkmm/arrow.h>
+#include <gtkmm/image.h>
+#include <gdkmm/pixbufloader.h>
+#include <gtkmm/viewport.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/table.h>
+#include <gtkmm/statusbar.h>
+#include <gtkmm/button.h>
+#include <gtkmm/progressbar.h>
+#include <gtkmm/paned.h>
+#include <gtkmm/treeview.h>
+#include <gtkmm/treestore.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/box.h>
+#include <gtkmm/scrollbar.h>
+#include <gtkmm/cellrenderer.h>
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/menu.h>
+
+
+#include <synfigapp/canvasinterface.h>
+#include <synfigapp/value_desc.h>
+#include <synfig/valuenode_animated.h>
+#include <synfig/valuenode_dynamiclist.h>
+#include <synfig/string.h>
+#include <synfig/time.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 Widget_ValueBase;
+
+/*! \class CellRenderer_TimeTrack
+**     \brief A cell renderer that displays the waypoints for Animated ValueNodes.
+*/
+class CellRenderer_TimeTrack :
+       public Gtk::CellRenderer
+{
+
+       /*
+ --    ** -- P R I V A T E   D A T A ---------------------------------------------
+       */
+
+private:
+       //! Time adjustment window
+       Gtk::Adjustment adjustment_;
+
+       //! Signal for when the user clicks on a waypoint
+       sigc::signal<void, const etl::handle<synfig::Node>&, const synfig::Time&, const synfig::Time&, int> signal_waypoint_clicked_cellrenderer_;
+
+       sigc::signal<void, synfig::Waypoint, synfig::ValueNode::Handle> signal_waypoint_changed_;
+
+       //! Iterator for selected waypoint. (Should this be an UniqueID instead?)
+       synfig::ValueNode_Animated::WaypointList::iterator selected_waypoint;
+
+       synfig::UniqueID selected;
+
+       //! selected information for time... (will work for way points etc...)
+       //TODO: make multiple... on both time and value select...
+       std::set<synfig::Time>  sel_times;
+       synfigapp::ValueDesc            sel_value;
+       synfig::Time                            actual_time;
+       synfig::Time                            actual_dragtime;
+       int                                             mode;
+
+       //! ???
+       synfig::Time selected_time;
+
+       //! The path to the current item in the tree model
+       Glib::ustring path;
+
+       //! ???
+       bool selection;
+
+       bool dragging;
+
+       synfig::Time drag_time;
+
+       etl::loose_handle<synfigapp::CanvasInterface>   canvas_interface_;
+
+       /*
+ --    ** -- P R O P E R T I E S -------------------------------------------------
+       */
+
+private:
+
+       //! ValueBase Desc
+       Glib::Property<synfigapp::ValueDesc> property_valuedesc_;
+
+       //! Canvas
+       Glib::Property<synfig::Canvas::Handle> property_canvas_;
+
+       //! ??? \see adjustment_
+       Glib::Property<Gtk::Adjustment* > property_adjustment_;
+
+       //! \writeme
+       Glib::Property<bool> property_enable_timing_info_;
+
+       /*
+ --    ** -- P R O P E R T Y   I N T E R F A C E S -------------------------------
+       */
+
+public:
+
+       Glib::PropertyProxy<synfigapp::ValueDesc> property_value_desc();
+
+       Glib::PropertyProxy<synfig::Canvas::Handle> property_canvas();
+
+       Glib::PropertyProxy<Gtk::Adjustment* > property_adjustment();
+
+       /*
+ --    ** -- S I G N A L   I N T E R F A C E S -----------------------------------
+       */
+
+public:
+
+       sigc::signal<void, const etl::handle<synfig::Node>&, const synfig::Time&, const synfig::Time&, int> &signal_waypoint_clicked_cellrenderer()
+       {return signal_waypoint_clicked_cellrenderer_; }
+
+       sigc::signal<void, synfig::Waypoint, synfig::ValueNode::Handle> &signal_waypoint_changed()
+       {return signal_waypoint_changed_; }
+
+       /*
+ --    ** -- P U B L I C   M E T H O D S -----------------------------------------
+       */
+
+public:
+
+       CellRenderer_TimeTrack();
+    ~CellRenderer_TimeTrack();
+
+       void set_adjustment(Gtk::Adjustment &x);
+       Gtk::Adjustment *get_adjustment();
+       const Gtk::Adjustment *get_adjustment()const;
+
+       etl::loose_handle<synfigapp::CanvasInterface>   canvas_interface()const {return canvas_interface_;}
+       void set_canvas_interface(etl::loose_handle<synfigapp::CanvasInterface> h); //this should only be called by smart people
+
+       synfig::Canvas::Handle get_canvas()const;
+
+       bool is_selected(const synfig::Waypoint& waypoint)const;
+
+       synfig::ValueNode_Animated::WaypointList::iterator find_waypoint(const synfig::Time& t, const synfig::Time& scope=synfig::Time::end());
+
+       virtual void
+       render_vfunc(
+               const Glib::RefPtr<Gdk::Drawable>& window,
+               Gtk::Widget& widget,
+               const Gdk::Rectangle& background_area,
+               const Gdk::Rectangle& ca,
+               const Gdk::Rectangle& expose_area,
+               Gtk::CellRendererState flags);
+
+       virtual bool
+       activate_vfunc( GdkEvent* event,
+                                       Gtk::Widget& widget,
+                                       const Glib::ustring& path,
+                                       const Gdk::Rectangle& background_area,
+                                       const Gdk::Rectangle& cell_area,
+                                       Gtk::CellRendererState flags);
+
+}; // END of class CellRenderer_TimeTrack
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/cellrenderer_value.cpp b/synfig-studio/src/gui/cellrenderer_value.cpp
new file mode 100644 (file)
index 0000000..f0403fd
--- /dev/null
@@ -0,0 +1,604 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file cellrenderer_value.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 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 <config.h>
+#endif
+
+#include <gtkmm/label.h>
+#include <ETL/stringf>
+#include <gtkmm/celleditable.h>
+#include <gtkmm/editable.h>
+#include <gtkmm/entry.h>
+#include <gtkmm/eventbox.h>
+#include <gtk/gtkentry.h> /* see XXX below */
+
+#include "app.h"
+#include "widget_value.h"
+#include "widget_vector.h"
+#include "widget_filename.h"
+#include "widget_enum.h"
+#include "widget_color.h"
+#include "widget_canvaschooser.h"
+#include "widget_time.h"
+
+#include "cellrenderer_gradient.h"
+#include "cellrenderer_value.h"
+
+#include "widget_gradient.h"
+#include "dialog_gradient.h"
+#include "dialog_color.h"
+#include <gtkmm/textview.h>
+
+#include "general.h"
+
+#endif
+
+using namespace synfig;
+using namespace etl;
+using namespace std;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+#define DIGITS         15
+
+/* === G L O B A L S ======================================================= */
+
+class studio::ValueBase_Entry : public Gtk::EventBox, public Gtk::CellEditable
+{
+       Glib::ustring path;
+       Widget_ValueBase *valuewidget;
+       bool edit_done_called;
+       Gtk::Widget *parent;
+public:
+       ValueBase_Entry():
+               Glib::ObjectBase  (typeid(ValueBase_Entry)),
+               Gtk::EventBox     (),
+               Gtk::CellEditable ()
+       {
+               parent=0;
+               edit_done_called=false;
+/*
+                 Gtk::HBox *const hbox = new Gtk::HBox(false, 0);
+                 add(*Gtk::manage(hbox));
+
+                 Gtk::Entry *entry_ = new Gtk::Entry();
+                       entry_->set_text("bleh");
+                 hbox->pack_start(*Gtk::manage(entry_), Gtk::PACK_EXPAND_WIDGET);
+                 entry_->set_has_frame(false);
+                 entry_->gobj()->is_cell_renderer = true; // XXX
+
+*/
+               valuewidget=manage(new class Widget_ValueBase());
+               valuewidget->inside_cellrenderer();
+               add(*valuewidget);
+               valuewidget->show();
+
+               //set_flags(Gtk::CAN_FOCUS);
+               //set_events(Gdk::KEY_PRESS_MASK | Gdk::KEY_RELEASE_MASK);
+
+               /*
+               set_events(//(Gdk::ALL_EVENTS_MASK)
+               ~(      Gdk::EXPOSURE_MASK
+                       | Gdk::ENTER_NOTIFY_MASK
+                       | Gdk::LEAVE_NOTIFY_MASK
+                       | Gdk::FOCUS_CHANGE_MASK
+                       | Gdk::STRUCTURE_MASK
+                       | Gdk::PROPERTY_CHANGE_MASK
+                       | Gdk::VISIBILITY_NOTIFY_MASK
+                       | Gdk::PROXIMITY_IN_MASK
+                       | Gdk::PROXIMITY_OUT_MASK
+                       | Gdk::SUBSTRUCTURE_MASK
+               )
+               );
+               */
+               //signal_editing_done().connect(sigc::mem_fun(*this, &studio::ValueBase_Entry::hide));
+               //signal_remove_widget().connect(sigc::mem_fun(*this, &studio::ValueBase_Entry::hide));
+
+               show_all_children();
+
+               //signal_show().connect(sigc::mem_fun(*this, &ValueBase_Entry::grab_focus));
+       }
+       ~ValueBase_Entry()
+       {
+       }
+
+       void on_editing_done()
+       {
+               hide();
+               if(parent)parent->grab_focus();
+               if(!edit_done_called)
+               {
+                       edit_done_called=true;
+                       Gtk::CellEditable::on_editing_done();
+               }
+               else
+               {
+                       synfig::error("on_editing_done(): Called twice!");
+               }
+       }
+       void set_parent(Gtk::Widget*x) { parent=x; }
+       void on_remove_widget()
+       {
+               hide();
+               edit_done_called=true;
+               if(parent)parent->grab_focus();
+               Gtk::CellEditable::on_remove_widget();
+       }
+       void start_editing_vfunc(GdkEvent */*event*/)
+       {
+               valuewidget->signal_activate().connect(sigc::mem_fun(*this, &studio::ValueBase_Entry::editing_done));
+               show();
+               //valuewidget->grab_focus();
+               //get_window()->set_focus(*valuewidget);
+       }
+       bool on_event(GdkEvent *event)
+       {
+               if(event->any.type==GDK_BUTTON_PRESS ||
+                       event->any.type==GDK_2BUTTON_PRESS ||
+                       event->any.type==GDK_KEY_PRESS ||
+                       event->any.type==GDK_KEY_RELEASE ||
+                       event->any.type==GDK_SCROLL ||
+                       event->any.type==GDK_3BUTTON_PRESS)
+                       return true;
+               return Gtk::EventBox::on_event(event);
+       }
+       void on_grab_focus()
+       {
+               Gtk::EventBox::on_grab_focus();
+               if(valuewidget)
+                       valuewidget->grab_focus();
+       }
+       void set_path(const Glib::ustring &p)
+       {
+               path=p;
+       }
+       void set_value(const synfig::ValueBase &data)
+       {
+               if(valuewidget)
+                       valuewidget->set_value(data);
+               //valuewidget->grab_focus();
+       }
+       void set_canvas(const etl::handle<synfig::Canvas> &data)
+       {
+               assert(data);
+               if(valuewidget)
+                       valuewidget->set_canvas(data);
+       }
+       void set_param_desc(const synfig::ParamDesc &data)
+       {
+               if(valuewidget)
+                       valuewidget->set_param_desc(data);
+       }
+
+       const synfig::ValueBase &get_value()
+       {
+               if(valuewidget)
+                       return valuewidget->get_value();
+
+               warning("%s:%d this code shouldn't be reached", __FILE__, __LINE__);
+               return *(new synfig::ValueBase());
+       }
+
+       const Glib::ustring &get_path()
+       {
+               return path;
+       }
+
+};
+
+/* === P R O C E D U R E S ================================================= */
+
+bool get_paragraph(synfig::String& text)
+{
+       Gtk::Dialog dialog(
+               _("Paragraph"),         // Title
+               true,           // Modal
+               true            // use_separator
+       );
+       Gtk::Label label(_("Enter Paragraph Text Here:"));
+       label.show();
+       dialog.get_vbox()->pack_start(label);
+
+
+       Glib::RefPtr<Gtk::TextBuffer> text_buffer(Gtk::TextBuffer::create());
+       text_buffer->set_text(text);
+
+       Gtk::TextView text_view(text_buffer);
+       text_view.show();
+       dialog.get_vbox()->pack_start(text_view);
+
+/*
+       Gtk::Entry entry;
+       entry.set_text(text);
+       entry.show();
+       entry.set_activates_default(true);
+       dialog.get_vbox()->pack_start(entry);
+*/
+
+       dialog.add_button(Gtk::StockID("gtk-ok"),Gtk::RESPONSE_OK);
+       dialog.add_button(Gtk::StockID("gtk-cancel"),Gtk::RESPONSE_CANCEL);
+       dialog.set_default_response(Gtk::RESPONSE_OK);
+
+       //text_entry.signal_activate().connect(sigc::bind(sigc::mem_fun(dialog,&Gtk::Dialog::response),Gtk::RESPONSE_OK));
+
+       dialog.show();
+
+       if(dialog.run()!=Gtk::RESPONSE_OK)
+               return false;
+
+       text=text_buffer->get_text();
+
+       return true;
+}
+
+/* === M E T H O D S ======================================================= */
+
+CellRenderer_ValueBase::CellRenderer_ValueBase():
+       Glib::ObjectBase        (typeid(CellRenderer_ValueBase)),
+       Gtk::CellRendererText   (),
+       property_value_ (*this,"value",synfig::ValueBase()),
+       property_canvas_(*this,"canvas",etl::handle<synfig::Canvas>()),
+       property_param_desc_(*this,"param_desc",synfig::ParamDesc())
+{
+       CellRendererText::signal_edited().connect(sigc::mem_fun(*this,&CellRenderer_ValueBase::string_edited_));
+       value_entry=new ValueBase_Entry();
+       value_entry->hide();
+
+       Pango::AttrList attr_list;
+       {
+               Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*8));
+               pango_size.set_start_index(0);
+               pango_size.set_end_index(64);
+               attr_list.change(pango_size);
+       }
+       property_attributes()=attr_list;
+
+       property_foreground()=Glib::ustring("#7f7f7f");
+       property_inconsistent()=false;
+}
+
+CellRenderer_ValueBase::~CellRenderer_ValueBase()
+{
+       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
+               synfig::info("CellRenderer_ValueBase::~CellRenderer_ValueBase(): Deleted");
+}
+
+void
+CellRenderer_ValueBase::string_edited_(const Glib::ustring&path,const Glib::ustring&str)
+{
+       ValueBase old_value=property_value_.get_value();
+       ValueBase value;
+
+       if(old_value.get_type()==ValueBase::TYPE_TIME)
+       {
+               value=ValueBase(Time((String)str,get_canvas()->rend_desc().get_frame_rate()));
+       }
+       else
+               value=ValueBase((String)str);
+
+       if(old_value!=value)
+               signal_edited_(path,value);
+}
+
+void
+CellRenderer_ValueBase::render_vfunc(
+               const Glib::RefPtr<Gdk::Drawable>& window,
+               Gtk::Widget& widget,
+               const Gdk::Rectangle& background_area,
+               const Gdk::Rectangle& ca,
+               const Gdk::Rectangle& expose_area,
+               Gtk::CellRendererState flags)
+{
+       if(!window)
+               return;
+//     const unsigned int cell_xpad = property_xpad();
+//     const unsigned int cell_ypad = property_ypad();
+
+       //int x_offset = 0, y_offset = 0;
+//     int     width = ca.get_width();
+       int     height = ca.get_height();
+//     get_size(widget, ca, x_offset, y_offset, width, height);
+
+//     width  -= cell_xpad * 2;
+//     height -= cell_ypad * 2;
+
+//     if(width <= 0 || height <= 0)
+//             return;
+
+       Gtk::StateType state = Gtk::STATE_INSENSITIVE;
+       if(property_editable())
+               state = Gtk::STATE_NORMAL;
+       if((flags & Gtk::CELL_RENDERER_SELECTED) != 0)
+               state = (widget.has_focus()) ? Gtk::STATE_SELECTED : Gtk::STATE_ACTIVE;
+
+       ValueBase data=property_value_.get_value();
+
+       switch(data.get_type())
+       {
+       case ValueBase::TYPE_REAL:
+               if(((synfig::ParamDesc)property_param_desc_).get_is_distance())
+               {
+                       Distance x(data.get(Real()),Distance::SYSTEM_UNITS);
+                       x.convert(App::distance_system,get_canvas()->rend_desc());
+                       property_text()=(Glib::ustring)x.get_string(6).c_str();
+               }
+               else
+                       property_text()=(Glib::ustring)strprintf("%.6f",data.get(Real()));
+               break;
+       case ValueBase::TYPE_TIME:
+               property_text()=(Glib::ustring)data.get(Time()).get_string(get_canvas()->rend_desc().get_frame_rate(),App::get_time_format());
+               break;
+       case ValueBase::TYPE_ANGLE:
+               property_text()=(Glib::ustring)strprintf("%.2f DEG",(Real)Angle::deg(data.get(Angle())).get());
+               break;
+       case ValueBase::TYPE_INTEGER:
+               if(((synfig::ParamDesc)property_param_desc_).get_hint()!="enum")
+               {
+                       property_text()=(Glib::ustring)strprintf("%i",data.get(int()));
+               }
+               else
+               {
+                       property_text()=(Glib::ustring)strprintf("(%i)",data.get(int()));
+                       std::list<synfig::ParamDesc::EnumData> enum_list=((synfig::ParamDesc)property_param_desc_).get_enum_list();
+                       std::list<synfig::ParamDesc::EnumData>::iterator iter;
+
+                       for(iter=enum_list.begin();iter!=enum_list.end();iter++)
+                               if(iter->value==data.get(int()))
+                               {
+                                       // don't show the key_board s_hortcut under_scores
+                                       String local_name = iter->local_name;
+                                       String::size_type pos = local_name.find_first_of('_');
+                                       if (pos != String::npos)
+                                               property_text() = local_name.substr(0,pos) + local_name.substr(pos+1);
+                                       else
+                                               property_text() = local_name;
+                                       break;
+                               }
+               }
+
+               break;
+       case ValueBase::TYPE_VECTOR:
+               {
+                       Vector vector=data.get(Vector());
+                       Distance x(vector[0],Distance::SYSTEM_UNITS),y(vector[1],Distance::SYSTEM_UNITS);
+                       x.convert(App::distance_system,get_canvas()->rend_desc());
+                       y.convert(App::distance_system,get_canvas()->rend_desc());
+                       property_text()=static_cast<Glib::ustring>(strprintf("%s,%s",x.get_string(6).c_str(),y.get_string(6).c_str()));
+               }
+               break;
+
+       case ValueBase::TYPE_STRING:
+
+               if(data.get_type()==ValueBase::TYPE_STRING)
+               {
+                       if(!data.get(synfig::String()).empty())
+                               property_text()=static_cast<Glib::ustring>(data.get(synfig::String()));
+                       else
+                               property_text()=Glib::ustring("<empty>");
+               }
+               break;
+       case ValueBase::TYPE_CANVAS:
+               if(data.get(etl::handle<synfig::Canvas>()))
+               {
+                       if(data.get(etl::handle<synfig::Canvas>())->is_inline())
+                               property_text()=_("<Inline Canvas>");
+                       else
+                               property_text()=(Glib::ustring)data.get(etl::handle<synfig::Canvas>())->get_id();
+               }
+               else
+                       property_text()="<No Image Selected>";
+               break;
+       case ValueBase::TYPE_COLOR:
+               {
+                       render_color_to_window(window,ca,data.get(Color()));
+                       return;
+               }
+               break;
+       case ValueBase::TYPE_BOOL:
+               {
+                       widget.get_style()->paint_check(
+                               Glib::RefPtr<Gdk::Window>::cast_static(window), state,
+                               data.get(bool())?Gtk::SHADOW_IN:Gtk::SHADOW_OUT,
+                               ca, widget, "cellcheck",
+                               ca.get_x()/* + x_offset + cell_xpad*/,
+                               ca.get_y()/* + y_offset + cell_ypad*/,
+                               height-1,height-1);
+                       return;
+               }
+               break;
+       case ValueBase::TYPE_NIL:
+               //property_text()=(Glib::ustring)" ";
+               return;
+               break;
+       case ValueBase::TYPE_SEGMENT:
+               property_text()=(Glib::ustring)_("Segment");
+               break;
+       case ValueBase::TYPE_GRADIENT:
+               render_gradient_to_window(window,ca,data.get(Gradient()));
+               return;
+               break;
+       case ValueBase::TYPE_LIST:
+               property_text()=(Glib::ustring)_("List");
+               break;
+       case ValueBase::TYPE_BLINEPOINT:
+               property_text()=(Glib::ustring)_("BLine Point");
+               break;
+       default:
+               property_text()=static_cast<Glib::ustring>(_("UNKNOWN"));
+               break;
+       }
+       CellRendererText::render_vfunc(window,widget,background_area,ca,expose_area,flags);
+}
+
+
+/*
+bool
+CellRenderer_ValueBase::activate_vfunc(        GdkEvent* event,
+       Gtk::Widget& widget,
+       const Glib::ustring& path,
+       const Gdk::Rectangle& background_area,
+       const Gdk::Rectangle& cell_area,
+       Gtk::CellRendererState flags)
+{
+       ValueBase data=(ValueBase)property_value_.get_value();
+
+       switch(data.type)
+       {
+       case ValueBase::TYPE_BOOL:
+               if(property_editable())
+                       signal_edited_(path,ValueBase(!data.get(bool())));
+       return true;
+       case ValueBase::TYPE_STRING:
+               return CellRendererText::activate_vfunc(event,widget,path,background_area,cell_area,flags);
+       }
+       return false;
+}
+*/
+
+void
+CellRenderer_ValueBase::gradient_edited(synfig::Gradient gradient, Glib::ustring path)
+{
+       ValueBase old_value(property_value_.get_value());
+       ValueBase value(gradient);
+       if(old_value!=value)
+               signal_edited_(path,value);
+}
+
+void
+CellRenderer_ValueBase::color_edited(synfig::Color color, Glib::ustring path)
+{
+       ValueBase old_value(property_value_.get_value());
+       ValueBase value(color);
+       if(old_value!=value)
+               signal_edited_(path,value);
+}
+
+Gtk::CellEditable*
+CellRenderer_ValueBase::start_editing_vfunc(
+       GdkEvent* event __attribute__ ((unused)),
+       Gtk::Widget& widget,
+       const Glib::ustring& path,
+       const Gdk::Rectangle& background_area __attribute__ ((unused)),
+       const Gdk::Rectangle& cell_area __attribute__ ((unused)),
+       Gtk::CellRendererState flags __attribute__ ((unused)))
+{
+       edit_value_done_called = false;
+       // If we aren't editable, then there is nothing to do
+       if(!property_editable())
+               return 0;
+
+       ValueBase data=property_value_.get_value();
+
+       switch(data.get_type())
+       {
+       case ValueBase::TYPE_BOOL:
+               signal_edited_(path,ValueBase(!data.get(bool())));
+       return NULL;
+       //case ValueBase::TYPE_TIME:
+       //      property_text()=(Glib::ustring)data.get(Time()).get_string(get_canvas()->rend_desc().get_frame_rate(),App::get_time_format()|Time::FORMAT_FULL);
+       //      return CellRendererText::start_editing_vfunc(event,widget,path,background_area,cell_area,flags);
+
+       case ValueBase::TYPE_GRADIENT:
+               App::dialog_gradient->reset();
+               App::dialog_gradient->set_gradient(data.get(Gradient()));
+               App::dialog_gradient->signal_edited().connect(
+                       sigc::bind(
+                               sigc::mem_fun(*this,&studio::CellRenderer_ValueBase::gradient_edited),
+                               path
+                       )
+               );
+               App::dialog_gradient->set_default_button_set_sensitive(true);
+               App::dialog_gradient->present();
+
+               return NULL;
+
+       case ValueBase::TYPE_COLOR:
+               App::dialog_color->reset();
+               App::dialog_color->set_color(data.get(Color()));
+               App::dialog_color->signal_edited().connect(
+                       sigc::bind(
+                               sigc::mem_fun(*this,&studio::CellRenderer_ValueBase::color_edited),
+                               path
+                       )
+               );
+               App::dialog_color->present();
+
+               return NULL;
+       case ValueBase::TYPE_STRING:
+               if(get_param_desc().get_hint()=="paragraph")
+               {
+                       synfig::String string;
+                       string=data.get(string);
+                       if(get_paragraph(string))
+                               signal_edited_(path,ValueBase(string));
+                       return NULL;
+               }
+               // if(get_param_desc().get_hint()!="filename")
+                       // return CellRendererText::start_editing_vfunc(event,widget,path,background_area,cell_area,flags);
+       default:
+               {
+                       assert(get_canvas());
+                       //delete value_entry;
+                       value_entry=manage(new ValueBase_Entry());
+                       value_entry->set_path(path);
+                       value_entry->set_canvas(get_canvas());
+                       value_entry->set_param_desc(get_param_desc());
+                       value_entry->set_value(data);
+                       value_entry->set_parent(&widget);
+                       value_entry->signal_editing_done().connect(sigc::mem_fun(*this, &CellRenderer_ValueBase::on_value_editing_done));
+                       return value_entry;
+               }
+       }
+       return NULL;
+}
+
+void
+CellRenderer_ValueBase::on_value_editing_done()
+{
+       if (edit_value_done_called)
+       {
+               synfig::error("on_value_editing_done(): Called twice!");
+               return;
+       }
+
+       edit_value_done_called = true;
+
+       if(value_entry)
+       {
+               ValueBase old_value(property_value_.get_value());
+               ValueBase value(value_entry->get_value());
+
+               if(old_value!=value)
+                       signal_edited_(value_entry->get_path(),value);
+
+               //delete value_entry;
+               //value_entry=0;
+       }
+}
diff --git a/synfig-studio/src/gui/cellrenderer_value.h b/synfig-studio/src/gui/cellrenderer_value.h
new file mode 100644 (file)
index 0000000..14a425d
--- /dev/null
@@ -0,0 +1,135 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file cellrenderer_value.h
+**     \brief Template File
+**
+**     $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_GTKMM_CELLRENDERER_VALUE_H
+#define __SYNFIG_GTKMM_CELLRENDERER_VALUE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtk/gtk.h>
+#include <gtkmm/ruler.h>
+#include <gtkmm/arrow.h>
+#include <gtkmm/image.h>
+#include <gdkmm/pixbufloader.h>
+#include <gtkmm/viewport.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/table.h>
+#include <gtkmm/statusbar.h>
+#include <gtkmm/button.h>
+#include <gtkmm/label.h>
+#include <gtkmm/paned.h>
+#include <gtkmm/treeview.h>
+#include <gtkmm/treestore.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/box.h>
+#include <gtkmm/spinbutton.h>
+#include <gtkmm/cellrenderer.h>
+#include <gtkmm/checkbutton.h>
+
+#include <gtkmm/colorselection.h>
+#include <gtkmm/optionmenu.h>
+
+//#include <synfig/synfig.h>
+#include <synfig/paramdesc.h>
+#include <synfig/value.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 Widget_Color;
+class Widget_CanvasChooser;
+class Widget_Enum;
+class Widget_Filename;
+class Widget_Vector;
+class Widget_Time;
+
+class ValueBase_Entry;
+
+class CellRenderer_ValueBase : public Gtk::CellRendererText
+{
+       sigc::signal<void, const Glib::ustring&> signal_secondary_click_;
+       sigc::signal<void, const Glib::ustring&, synfig::ValueBase> signal_edited_;
+
+       Glib::Property<synfig::ValueBase> property_value_;
+       Glib::Property<etl::handle<synfig::Canvas> > property_canvas_;
+       Glib::Property<synfig::ParamDesc> property_param_desc_;
+
+       void string_edited_(const Glib::ustring&,const Glib::ustring&);
+
+       void gradient_edited(synfig::Gradient gradient, Glib::ustring path);
+       void color_edited(synfig::Color color, Glib::ustring path);
+
+       bool edit_value_done_called;
+public:
+       sigc::signal<void, const Glib::ustring&> &signal_secondary_click()
+       {return signal_secondary_click_; }
+
+       sigc::signal<void, const Glib::ustring&, synfig::ValueBase> &signal_edited()
+       {return signal_edited_; }
+
+       Glib::PropertyProxy<synfig::ValueBase> property_value() { return property_value_.get_proxy();}
+       Glib::PropertyProxy<etl::handle<synfig::Canvas> > property_canvas() { return property_canvas_.get_proxy();}
+       Glib::PropertyProxy<synfig::ParamDesc> property_param_desc() { return property_param_desc_.get_proxy(); }
+       Glib::PropertyProxy<bool> property_inconsistent() { return property_foreground_set(); }
+
+       etl::handle<synfig::Canvas> get_canvas()const { return property_canvas_; }
+       synfig::ParamDesc get_param_desc()const { return property_param_desc_; }
+
+       CellRenderer_ValueBase();
+       ~CellRenderer_ValueBase();
+
+       ValueBase_Entry *value_entry;
+
+       void on_value_editing_done();
+
+       virtual void
+       render_vfunc(
+               const Glib::RefPtr<Gdk::Drawable>& window,
+               Gtk::Widget& widget,
+               const Gdk::Rectangle& background_area,
+               const Gdk::Rectangle& ca,
+               const Gdk::Rectangle& expose_area,
+               Gtk::CellRendererState flags);
+
+       virtual Gtk::CellEditable* start_editing_vfunc(GdkEvent* event,
+                                                 Gtk::Widget& widget,
+                                                 const Glib::ustring& path,
+                                                 const Gdk::Rectangle& background_area,
+                                                 const Gdk::Rectangle& cell_area,
+                                                 Gtk::CellRendererState flags);
+
+}; // END of class CellRenderer_ValueBase
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/childrentree.cpp b/synfig-studio/src/gui/childrentree.cpp
new file mode 100644 (file)
index 0000000..01ef95e
--- /dev/null
@@ -0,0 +1,439 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file childrentree.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 <config.h>
+#endif
+
+#include "childrentree.h"
+#include "cellrenderer_value.h"
+#include "cellrenderer_timetrack.h"
+#include <synfigapp/action.h>
+#include <synfigapp/instance.h>
+#include <gtkmm/scrolledwindow.h>
+#include <synfig/timepointcollect.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 ========================================================= */
+
+#ifndef SMALL_BUTTON
+#define SMALL_BUTTON(button,stockid,tooltip)   \
+       button = manage(new class Gtk::Button());       \
+       icon=manage(new Gtk::Image(Gtk::StockID(stockid),iconsize));    \
+       button->add(*icon);     \
+       tooltips_.set_tip(*button,tooltip);     \
+       icon->set_padding(0,0);\
+       icon->show();   \
+       button->set_relief(Gtk::RELIEF_NONE); \
+       button->show()
+#endif
+
+#ifndef NORMAL_BUTTON
+#define NORMAL_BUTTON(button,stockid,tooltip)  \
+       button = manage(new class Gtk::Button());       \
+       icon=manage(new Gtk::Image(Gtk::StockID(stockid),Gtk::ICON_SIZE_BUTTON));       \
+       button->add(*icon);     \
+       tooltips_.set_tip(*button,tooltip);     \
+       icon->set_padding(0,0);\
+       icon->show();   \
+       /*button->set_relief(Gtk::RELIEF_NONE);*/ \
+       button->show()
+#endif
+
+#define NEW_SMALL_BUTTON(x,y,z)        Gtk::Button *SMALL_BUTTON(x,y,z)
+
+#define NOT_IMPLEMENTED_SLOT sigc::mem_fun(*reinterpret_cast<studio::CanvasViewUIInterface*>(get_ui_interface().get()),&studio::CanvasViewUIInterface::not_implemented)
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+ChildrenTree::ChildrenTree()
+{
+       const ChildrenTreeStore::Model model;
+
+       {       // --- N A M E --------------------------------------------------------
+               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("ID")) );
+
+               // Set up the icon cell-renderer
+               Gtk::CellRendererPixbuf* icon_cellrenderer = Gtk::manage( new Gtk::CellRendererPixbuf() );
+               column->pack_start(*icon_cellrenderer,false);
+               column->add_attribute(icon_cellrenderer->property_pixbuf(), model.icon);
+
+               // Pack the label into the column
+               column->pack_start(model.label,true);
+
+               // Finish setting up the column
+               column->set_reorderable();
+               column->set_resizable();
+               column->set_clickable();
+               column->set_min_width(150);
+               column->set_sort_column(model.label);
+               tree_view.append_column(*column);
+
+       }
+       {       // --- T Y P E --------------------------------------------------------
+               int cols_count = tree_view.append_column(_("Type"),model.type);
+               Gtk::TreeViewColumn* column = tree_view.get_column(cols_count-1);
+               if(column)
+               {
+                       column->set_reorderable();
+                       column->set_resizable();
+                       column->set_clickable();
+                       column->set_sort_column(model.type);
+               }
+       }
+       {       // --- V A L U E  -----------------------------------------------------
+               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("ValueBase")) );
+
+               // Set up the value cell-renderer
+               cellrenderer_value=ChildrenTreeStore::add_cell_renderer_value(column);
+               cellrenderer_value->signal_edited().connect(sigc::mem_fun(*this, &studio::ChildrenTree::on_edited_value));
+               cellrenderer_value->property_value()=synfig::ValueBase();
+
+               // Finish setting up the column
+               tree_view.append_column(*column);
+               column->set_sizing(Gtk::TREE_VIEW_COLUMN_AUTOSIZE);
+               column->set_min_width(150);
+               column->set_reorderable();
+               column->set_resizable();
+               column->set_clickable(false);
+       }
+       {       // --- T I M E   T R A C K --------------------------------------------
+               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Time Track")) );
+               column_time_track=column;
+
+               // Set up the value-node cell-renderer
+               cellrenderer_time_track=ChildrenTreeStore::add_cell_renderer_value_node(column);
+               cellrenderer_time_track->property_mode()=Gtk::CELL_RENDERER_MODE_ACTIVATABLE;
+               cellrenderer_time_track->signal_waypoint_clicked_cellrenderer().connect(sigc::mem_fun(*this, &studio::ChildrenTree::on_waypoint_clicked_childrentree) );
+               column->add_attribute(cellrenderer_time_track->property_value_desc(), model.value_desc);
+               column->add_attribute(cellrenderer_time_track->property_canvas(), model.canvas);
+
+               //column->pack_start(*cellrenderer_time_track);
+
+               // Finish setting up the column
+               column->set_reorderable();
+               column->set_resizable();
+               tree_view.append_column(*column);
+       }
+
+       // This makes things easier to read.
+       tree_view.set_rules_hint();
+
+       // Make us more sensitive to several events
+       tree_view.add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::BUTTON1_MOTION_MASK | Gdk::BUTTON2_MOTION_MASK|Gdk::POINTER_MOTION_MASK);
+
+       tree_view.signal_event().connect(sigc::mem_fun(*this, &studio::ChildrenTree::on_tree_event));
+
+       // Create a scrolled window for that tree
+       Gtk::ScrolledWindow *scroll_children_tree = manage(new class Gtk::ScrolledWindow());
+       scroll_children_tree->set_flags(Gtk::CAN_FOCUS);
+       scroll_children_tree->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+       scroll_children_tree->add(tree_view);
+       scroll_children_tree->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
+       scroll_children_tree->show();
+
+       attach(*scroll_children_tree, 0, 3, 0, 1, Gtk::EXPAND|Gtk::FILL,Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       hbox=manage(new Gtk::HBox());
+
+       attach(*hbox, 0, 1, 1, 2, Gtk::FILL|Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+
+       tree_view.set_enable_search(true);
+       tree_view.set_search_column(model.label);
+
+/*  // Buttons to raise/lower/duplicate/delete children valuenodes
+       //   Commented out because these functions are not implemented
+    //   and children sort themselves alphabetically
+
+       Gtk::Image *icon;
+       //Gtk::IconSize iconsize(Gtk::IconSize::from_name("synfig-small_icon"));
+       Gtk::IconSize iconsize(Gtk::ICON_SIZE_SMALL_TOOLBAR);
+
+       SMALL_BUTTON(button_raise,"gtk-go-up",_("Raise"));
+       SMALL_BUTTON(button_lower,"gtk-go-down",_("Lower"));
+       SMALL_BUTTON(button_duplicate,"synfig-duplicate",_("Duplicate"));
+       SMALL_BUTTON(button_delete,"gtk-delete",_("Delete"));
+
+       hbox->pack_start(*button_raise,Gtk::PACK_SHRINK);
+       hbox->pack_start(*button_lower,Gtk::PACK_SHRINK);
+       hbox->pack_start(*button_duplicate,Gtk::PACK_SHRINK);
+       hbox->pack_start(*button_delete,Gtk::PACK_SHRINK);
+
+       button_raise->signal_clicked().connect(sigc::mem_fun(*this, &studio::ChildrenTree::on_raise_pressed));
+       button_lower->signal_clicked().connect(sigc::mem_fun(*this, &studio::ChildrenTree::on_lower_pressed));
+       button_duplicate->signal_clicked().connect(sigc::mem_fun(*this, &studio::ChildrenTree::on_duplicate_pressed));
+       button_delete->signal_clicked().connect(sigc::mem_fun(*this, &studio::ChildrenTree::on_delete_pressed));
+
+       button_raise->set_sensitive(false);
+       button_lower->set_sensitive(false);
+       button_duplicate->set_sensitive(false);
+       button_delete->set_sensitive(false);
+*/
+
+       get_selection()->signal_changed().connect(sigc::mem_fun(*this, &studio::ChildrenTree::on_selection_changed));
+
+       tree_view.set_reorderable(true);
+
+       hbox->show();
+       tree_view.show();
+
+       tooltips_.enable();
+
+       //get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
+}
+
+ChildrenTree::~ChildrenTree()
+{
+}
+
+void
+ChildrenTree::set_show_timetrack(bool x)
+{
+       column_time_track->set_visible(x);
+}
+
+void
+ChildrenTree::set_model(Glib::RefPtr<ChildrenTreeStore> children_tree_store)
+{
+       children_tree_store_=children_tree_store;
+       tree_view.set_model(children_tree_store_);
+       cellrenderer_time_track->set_canvas_interface(children_tree_store_->canvas_interface()); // am I smart people?  (cellrenderer_timetrack.h:176)
+       children_tree_store_->canvas_interface()->signal_dirty_preview().connect(sigc::mem_fun(*this,&studio::ChildrenTree::on_dirty_preview));
+}
+
+void
+ChildrenTree::set_time_adjustment(Gtk::Adjustment &adjustment)
+{
+       cellrenderer_time_track->set_adjustment(adjustment);
+}
+
+void
+ChildrenTree::on_dirty_preview()
+{
+}
+
+void
+ChildrenTree::on_selection_changed()
+{
+       if(0)
+               {
+               button_raise->set_sensitive(false);
+               button_lower->set_sensitive(false);
+               button_duplicate->set_sensitive(false);
+               button_delete->set_sensitive(false);
+               return;
+       }
+}
+
+void
+ChildrenTree::on_edited_value(const Glib::ustring&path_string,synfig::ValueBase value)
+{
+       Gtk::TreePath path(path_string);
+
+       const Gtk::TreeRow row = *(tree_view.get_model()->get_iter(path));
+
+       row[model.value]=value;
+//     signal_edited_value()(row[model.value_desc],value);
+}
+
+void
+ChildrenTree::on_waypoint_clicked_childrentree(const etl::handle<synfig::Node>& node __attribute__ ((unused)),
+                                                                                          const synfig::Time& time __attribute__ ((unused)),
+                                                                                          const synfig::Time& time_offset __attribute__ ((unused)),
+                                                                                          int button __attribute__ ((unused)))
+{
+       std::set<synfig::Waypoint, std::less<UniqueID> > waypoint_set;
+       synfig::waypoint_collect(waypoint_set,time,node);
+
+       synfigapp::ValueDesc value_desc;
+
+       if (waypoint_set.size() == 1)
+       {
+               ValueNode::Handle value_node(waypoint_set.begin()->get_parent_value_node());
+               assert(value_node);
+
+               Gtk::TreeRow row;
+               if (children_tree_store_->find_first_value_node(value_node, row) && row)
+                       value_desc = static_cast<synfigapp::ValueDesc>(row[model.value_desc]);
+       }
+
+       if (!waypoint_set.empty())
+               signal_waypoint_clicked_childrentree()(value_desc,waypoint_set,button);
+}
+
+bool
+ChildrenTree::on_tree_event(GdkEvent *event)
+{
+    switch(event->type)
+    {
+       case GDK_BUTTON_PRESS:
+               {
+                       Gtk::TreeModel::Path path;
+                       Gtk::TreeViewColumn *column;
+                       int cell_x, cell_y;
+                       if(!tree_view.get_path_at_pos(
+                               int(event->button.x),int(event->button.y),      // x, y
+                               path, // TreeModel::Path&
+                               column, //TreeViewColumn*&
+                               cell_x,cell_y //int&cell_x,int&cell_y
+                               )
+                       ) break;
+                       const Gtk::TreeRow row = *(tree_view.get_model()->get_iter(path));
+
+                       if(column->get_first_cell_renderer()==cellrenderer_time_track)
+                       {
+                               Gdk::Rectangle rect;
+                               tree_view.get_cell_area(path,*column,rect);
+                               cellrenderer_time_track->property_value_desc()=row[model.value_desc];
+                               cellrenderer_time_track->property_canvas()=row[model.canvas];
+                               cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
+                               queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
+                               return true;
+                       }
+                       else if(column->get_first_cell_renderer()==cellrenderer_value)
+                               return signal_user_click()(event->button.button,row,COLUMNID_VALUE);
+                       else
+                               return signal_user_click()(event->button.button,row,COLUMNID_ID);
+
+               }
+               break;
+
+       case GDK_MOTION_NOTIFY:
+               {
+                       Gtk::TreeModel::Path path;
+                       Gtk::TreeViewColumn *column;
+                       int cell_x, cell_y;
+                       if(!tree_view.get_path_at_pos(
+                               (int)event->button.x,(int)event->button.y,      // x, y
+                               path, // TreeModel::Path&
+                               column, //TreeViewColumn*&
+                               cell_x,cell_y //int&cell_x,int&cell_y
+                               )
+                       ) break;
+
+                       if(!tree_view.get_model()->get_iter(path))
+                               break;
+
+                       Gtk::TreeRow row = *(tree_view.get_model()->get_iter(path));
+
+                       if(cellrenderer_time_track==column->get_first_cell_renderer())
+                       {
+                               // Movement on TimeLine
+                               Gdk::Rectangle rect;
+                               tree_view.get_cell_area(path,*column,rect);
+                               cellrenderer_time_track->property_value_desc()=row[model.value_desc];
+                               cellrenderer_time_track->property_canvas()=row[model.canvas];
+                               cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
+                               queue_draw();
+                               //queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
+                               return true;
+                       }
+                       else
+                       if(last_tooltip_path.get_depth()<=0 || path!=last_tooltip_path)
+                       {
+                               tooltips_.unset_tip(*this);
+                               Glib::ustring tooltips_string(row[model.tooltip]);
+                               last_tooltip_path=path;
+                               if(!tooltips_string.empty())
+                               {
+                                       tooltips_.set_tip(*this,tooltips_string);
+                                       tooltips_.force_window();
+                               }
+                       }
+               }
+               break;
+       case GDK_BUTTON_RELEASE:
+               {
+                       Gtk::TreeModel::Path path;
+                       Gtk::TreeViewColumn *column;
+                       int cell_x, cell_y;
+                       if(!tree_view.get_path_at_pos(
+                                  (int)event->button.x,(int)event->button.y,   // x, y
+                                  path, // TreeModel::Path&
+                                  column, //TreeViewColumn*&
+                                  cell_x,cell_y //int&cell_x,int&cell_y
+                                  )
+                               ) break;
+
+                       if(!tree_view.get_model()->get_iter(path))
+                               break;
+
+                       Gtk::TreeRow row = *(tree_view.get_model()->get_iter(path));
+
+                       if(column && cellrenderer_time_track == column->get_first_cell_renderer())
+                       {
+                               Gdk::Rectangle rect;
+                               tree_view.get_cell_area(path,*column,rect);
+                               cellrenderer_time_track->property_value_desc()=row[model.value_desc];
+                               cellrenderer_time_track->property_canvas()=row[model.canvas];
+                               cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
+                               queue_draw();
+                               queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
+                               return true;
+                       }
+               }
+               break;
+       default:
+               break;
+       }
+       return false;
+}
+
+void
+ChildrenTree::on_raise_pressed()
+{
+}
+
+void
+ChildrenTree::on_lower_pressed()
+{
+}
+
+void
+ChildrenTree::on_duplicate_pressed()
+{
+}
+
+void
+ChildrenTree::on_delete_pressed()
+{
+}
diff --git a/synfig-studio/src/gui/childrentree.h b/synfig-studio/src/gui/childrentree.h
new file mode 100644 (file)
index 0000000..d307fd0
--- /dev/null
@@ -0,0 +1,179 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file childrentree.h
+**     \brief Template Header
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_STUDIO_CHILDRENTREE_H
+#define __SYNFIG_STUDIO_CHILDRENTREE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/treeview.h>
+#include <gtkmm/treestore.h>
+#include <gtkmm/tooltips.h>
+#include <gtkmm/table.h>
+#include <gtkmm/box.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/scale.h>
+#include <gtkmm/button.h>
+
+#include <synfigapp/canvasinterface.h>
+#include <synfigapp/value_desc.h>
+#include "childrentreestore.h"
+#include <synfig/valuenode_animated.h>
+
+#include "widget_value.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 CellRenderer_TimeTrack;
+class CellRenderer_ValueBase;
+
+class ChildrenTree : public Gtk::Table
+{
+       /*
+ -- ** -- P U B L I C   T Y P E S ---------------------------------------------
+       */
+
+public:
+
+       typedef studio::ColumnID ColumnID;
+
+       /*
+ -- ** -- P U B L I C  D A T A ------------------------------------------------
+       */
+
+public:
+
+       ChildrenTreeStore::Model model;
+
+       /*
+ -- ** -- P R I V A T E   D A T A ---------------------------------------------
+       */
+
+private:
+
+       Gtk::Tooltips tooltips_;
+
+       Gtk::TreePath last_tooltip_path;
+
+       Gtk::TreeView tree_view;
+
+       Gtk::HBox *hbox;
+
+       Glib::RefPtr<ChildrenTreeStore> children_tree_store_;
+
+       CellRenderer_TimeTrack *cellrenderer_time_track;
+
+       Gtk::TreeView::Column* column_time_track;
+
+       CellRenderer_ValueBase *cellrenderer_value;
+
+       sigc::signal<void,synfigapp::ValueDesc,synfig::ValueBase> signal_edited_value_;
+
+       sigc::signal<bool, int, Gtk::TreeRow, ColumnID> signal_user_click_;
+
+       sigc::signal<void,synfigapp::ValueDesc,std::set<synfig::Waypoint,std::less<synfig::UniqueID> >,int> signal_waypoint_clicked_childrentree_;
+
+       Gtk::Button *button_raise;
+       Gtk::Button *button_lower;
+       Gtk::Button *button_duplicate;
+       Gtk::Button *button_delete;
+
+       Widget_ValueBase blend_method_widget;
+
+       /*
+ -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
+       */
+
+private:
+
+       /*
+ -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
+       */
+
+private:
+
+       void on_edited_value(const Glib::ustring&path_string,synfig::ValueBase value);
+
+       void on_waypoint_clicked_childrentree(const etl::handle<synfig::Node>& node,const synfig::Time&,const synfig::Time&,int button);
+
+       bool on_tree_event(GdkEvent *event);
+
+       void on_selection_changed();
+
+       void on_dirty_preview();
+
+       //! \todo Implement raise/lower/duplicate/delete functions
+       void on_raise_pressed();
+
+       void on_lower_pressed();
+
+       void on_duplicate_pressed();
+
+       void on_delete_pressed();
+
+       /*
+ -- ** -- P U B L I C   M E T H O D S -----------------------------------------
+       */
+
+public:
+
+       Gtk::HBox& get_hbox() { return *hbox; }
+
+       Gtk::TreeView& get_tree_view() { return tree_view; }
+
+       Glib::RefPtr<Gtk::TreeSelection> get_selection() { return tree_view.get_selection(); }
+       Glib::SignalProxy1< bool,GdkEvent* >  signal_event () { return tree_view.signal_event(); }
+
+       ChildrenTree();
+       ~ChildrenTree();
+
+       void set_model(Glib::RefPtr<ChildrenTreeStore> children_tree_store_);
+
+       void set_time_adjustment(Gtk::Adjustment &adjustment);
+
+       void set_show_timetrack(bool x=true);
+
+       //! Signal called with a value has been edited.
+       sigc::signal<void,synfigapp::ValueDesc,synfig::ValueBase>& signal_edited_value() { return signal_edited_value_; }
+
+       sigc::signal<bool,int, Gtk::TreeRow, ColumnID>& signal_user_click() { return signal_user_click_; }
+
+       sigc::signal<void,synfigapp::ValueDesc,std::set<synfig::Waypoint,std::less<synfig::UniqueID> >,int>& signal_waypoint_clicked_childrentree() { return signal_waypoint_clicked_childrentree_; }
+
+       etl::handle<synfigapp::SelectionManager> get_selection_manager() { return children_tree_store_->canvas_interface()->get_selection_manager(); }
+
+}; // END of ChildrenTree
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/childrentreestore.cpp b/synfig-studio/src/gui/childrentreestore.cpp
new file mode 100644 (file)
index 0000000..cf8798f
--- /dev/null
@@ -0,0 +1,389 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file childrentreestore.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \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
+**     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 <config.h>
+#endif
+
+#include "childrentreestore.h"
+#include "iconcontroller.h"
+#include <gtkmm/button.h>
+#include <synfig/paramdesc.h>
+#include <ETL/clock>
+
+#include "general.h"
+
+class Profiler : private etl::clock
+{
+       const std::string name;
+public:
+       Profiler(const std::string& name):name(name) { reset(); }
+       ~Profiler() { float time(operator()()); synfig::info("%s: took %f msec",name.c_str(),time*1000); }
+};
+
+#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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+static ChildrenTreeStore::Model& ModelHack()
+{
+       static ChildrenTreeStore::Model* model(0);
+       if(!model)model=new ChildrenTreeStore::Model;
+       return *model;
+}
+
+ChildrenTreeStore::ChildrenTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_):
+       Gtk::TreeStore                  (ModelHack()),
+       CanvasTreeStore                 (canvas_interface_)
+{
+       canvas_row=*append();
+       canvas_row[model.label]=_("Canvases");
+       canvas_row[model.is_canvas] = false;
+       canvas_row[model.is_value_node] = false;
+
+       value_node_row=*append();
+       value_node_row[model.label]=_("ValueBase Nodes");
+       value_node_row[model.is_canvas] = false;
+       value_node_row[model.is_value_node] = false;
+
+       // Connect all the signals
+       canvas_interface()->signal_value_node_changed().connect(sigc::mem_fun(*this,&studio::ChildrenTreeStore::on_value_node_changed));
+       canvas_interface()->signal_value_node_renamed().connect(sigc::mem_fun(*this,&studio::ChildrenTreeStore::on_value_node_renamed));
+       canvas_interface()->signal_value_node_added().connect(sigc::mem_fun(*this,&studio::ChildrenTreeStore::on_value_node_added));
+       canvas_interface()->signal_value_node_deleted().connect(sigc::mem_fun(*this,&studio::ChildrenTreeStore::on_value_node_deleted));
+       canvas_interface()->signal_value_node_replaced().connect(sigc::mem_fun(*this,&studio::ChildrenTreeStore::on_value_node_replaced));
+       canvas_interface()->signal_canvas_added().connect(sigc::mem_fun(*this,&studio::ChildrenTreeStore::on_canvas_added));
+       canvas_interface()->signal_canvas_removed().connect(sigc::mem_fun(*this,&studio::ChildrenTreeStore::on_canvas_removed));
+
+       rebuild();
+}
+
+ChildrenTreeStore::~ChildrenTreeStore()
+{
+}
+
+Glib::RefPtr<ChildrenTreeStore>
+ChildrenTreeStore::create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_)
+{
+       return Glib::RefPtr<ChildrenTreeStore>(new ChildrenTreeStore(canvas_interface_));
+}
+
+void
+ChildrenTreeStore::rebuild()
+{
+       // Profiler profiler("ChildrenTreeStore::rebuild()");
+       rebuild_value_nodes();
+       rebuild_canvases();
+}
+
+void
+ChildrenTreeStore::refresh()
+{
+       // Profiler profiler("ChildrenTreeStore::refresh()");
+       refresh_value_nodes();
+       refresh_canvases();
+}
+
+void
+ChildrenTreeStore::rebuild_value_nodes()
+{
+       Gtk::TreeModel::Children children(value_node_row.children());
+
+       while(!children.empty())erase(children.begin());
+
+       clear_changed_queue();
+
+       std::for_each(
+               canvas_interface()->get_canvas()->value_node_list().rbegin(), canvas_interface()->get_canvas()->value_node_list().rend(),
+               sigc::mem_fun(*this, &studio::ChildrenTreeStore::on_value_node_added)
+       );
+}
+
+void
+ChildrenTreeStore::refresh_value_nodes()
+{
+       Gtk::TreeModel::Children children(value_node_row.children());
+
+       Gtk::TreeModel::Children::iterator iter;
+
+       if(!children.empty())
+               for(iter = children.begin(); iter != children.end(); ++iter)
+               {
+                       Gtk::TreeRow row=*iter;
+                       refresh_row(row);
+               }
+}
+
+void
+ChildrenTreeStore::rebuild_canvases()
+{
+       Gtk::TreeModel::Children children(canvas_row.children());
+
+       while(!children.empty())erase(children.begin());
+
+       std::for_each(
+               canvas_interface()->get_canvas()->children().rbegin(), canvas_interface()->get_canvas()->children().rend(),
+               sigc::mem_fun(*this, &studio::ChildrenTreeStore::on_canvas_added)
+       );
+}
+
+void
+ChildrenTreeStore::refresh_canvases()
+{
+       rebuild_canvases();
+}
+
+void
+ChildrenTreeStore::refresh_row(Gtk::TreeModel::Row &row, bool /*do_children*/)
+{
+       CanvasTreeStore::refresh_row(row,false);
+
+       if((bool)row[model.is_value_node])
+       {
+               changed_set_.erase(row[model.value_node]);
+       }
+
+}
+
+void
+ChildrenTreeStore::on_canvas_added(synfig::Canvas::Handle canvas)
+{
+       Gtk::TreeRow row = *(prepend(canvas_row.children()));
+
+       row[model.icon] = Gtk::Button().render_icon(Gtk::StockID("synfig-canvas"),Gtk::ICON_SIZE_SMALL_TOOLBAR);
+       row[model.id] = canvas->get_id();
+       row[model.name] = canvas->get_name();
+
+       if(!canvas->get_id().empty())
+               row[model.label] = canvas->get_id();
+       else
+       if(!canvas->get_name().empty())
+               row[model.label] = canvas->get_name();
+       else
+               row[model.label] = _("[Unnamed]");
+
+       row[model.canvas] = canvas;
+       row[model.type] = _("Canvas");
+       //row[model.is_canvas] = true;
+       //row[model.is_value_node] = false;
+}
+
+void
+ChildrenTreeStore::on_canvas_removed(synfig::Canvas::Handle /*canvas*/)
+{
+       rebuild_canvases();
+}
+
+void
+ChildrenTreeStore::on_value_node_added(synfig::ValueNode::Handle value_node)
+{
+//     if(value_node->get_id().find("Unnamed")!=String::npos)
+//             return;
+
+       Gtk::TreeRow row = *prepend(value_node_row.children());
+
+       set_row(row,synfigapp::ValueDesc(canvas_interface()->get_canvas(),value_node->get_id()),false);
+}
+
+void
+ChildrenTreeStore::on_value_node_deleted(synfig::ValueNode::Handle value_node)
+{
+       Gtk::TreeIter iter;
+       //int i(0);
+
+       if(find_first_value_node(value_node,iter))
+       {
+               erase(iter);
+       }
+       //rebuild_value_nodes();
+}
+
+bool
+ChildrenTreeStore::execute_changed_value_nodes()
+{
+       // Profiler profiler("ChildrenTreeStore::execute_changed_value_nodes()");
+       if(!replaced_set_.empty())
+               rebuild_value_nodes();
+
+       etl::clock timer;
+       timer.reset();
+
+       while(!changed_set_.empty())
+       {
+               ValueNode::Handle value_node(*changed_set_.begin());
+               changed_set_.erase(value_node);
+
+               Gtk::TreeIter iter;
+
+               try
+               {
+                       Gtk::TreeIter iter;
+                       int i(0);
+
+                       if(!value_node->is_exported() && find_first_value_node(value_node,iter))
+                       {
+                               rebuild_value_nodes();
+                               continue;
+                       }
+
+                       if(value_node->is_exported() && find_first_value_node(value_node,iter)) do
+                       {
+                               Gtk::TreeRow row(*iter);
+                               i++;
+                               refresh_row(row);
+                       }while(find_next_value_node(value_node,iter));
+
+                       if(!i)
+                       {
+                               refresh_value_nodes();
+                               return false;
+                       }
+
+               }
+               catch(...)
+               {
+                       rebuild_value_nodes();
+                       return false;
+               }
+
+               // If we are taking too long...
+               if(timer()>4)
+               {
+                       refresh_value_nodes();
+                       return false;
+               }
+       }
+
+       return false;
+}
+
+void
+ChildrenTreeStore::on_value_node_changed(synfig::ValueNode::Handle value_node)
+{
+
+       if(!value_node->is_exported())
+               return;
+       changed_connection.disconnect();
+//     if(!execute_changed_queued())
+//             changed_connection=Glib::signal_idle().connect(sigc::mem_fun(*this,&ChildrenTreeStore::execute_changed_value_nodes));
+       changed_connection=Glib::signal_timeout().connect(sigc::mem_fun(*this,&ChildrenTreeStore::execute_changed_value_nodes),150);
+
+       changed_set_.insert(value_node);
+       /*
+       try
+       {
+               Gtk::TreeIter iter;
+               int i(0);
+               while(find_next_value_node(value_node,iter))
+               {
+                       Gtk::TreeRow row(*iter);
+                       i++;
+                       refresh_row(row);
+               }
+               if(!i)
+               {
+                       refresh_value_nodes();
+               }
+       }
+       catch(...)
+       {
+               rebuild_value_nodes();
+       }
+       */
+}
+
+void
+ChildrenTreeStore::on_value_node_renamed(synfig::ValueNode::Handle value_node __attribute__ ((unused)))
+{
+       rebuild_value_nodes();
+}
+
+void
+ChildrenTreeStore::on_value_node_replaced(synfig::ValueNode::Handle replaced_value_node,synfig::ValueNode::Handle /*new_value_node*/)
+{
+       changed_connection.disconnect();
+       //if(!execute_changed_queued())
+//             changed_connection=Glib::signal_idle().connect(sigc::mem_fun(*this,&ChildrenTreeStore::execute_changed_value_nodes));
+               changed_connection=Glib::signal_timeout().connect(sigc::mem_fun(*this,&ChildrenTreeStore::execute_changed_value_nodes),150);
+
+       replaced_set_.insert(replaced_value_node);
+}
+
+void
+ChildrenTreeStore::set_value_impl(const Gtk::TreeModel::iterator& iter, int column, const Glib::ValueBase& value)
+{
+       if(column>=get_n_columns_vfunc())
+       {
+               g_warning("LayerTreeStore::set_value_impl: Bad column (%d)",column);
+               return;
+       }
+
+       if(!g_value_type_compatible(G_VALUE_TYPE(value.gobj()),get_column_type_vfunc(column)))
+       {
+               g_warning("LayerTreeStore::set_value_impl: Bad value type");
+               return;
+       }
+
+       try
+       {
+               if(column==model.value.index())
+               {
+                       Glib::Value<synfig::ValueBase> x;
+                       g_value_init(x.gobj(),model.value.type());
+                       g_value_copy(value.gobj(),x.gobj());
+
+                       synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
+                       if(value_desc)
+                       {
+                               canvas_interface()->change_value(value_desc,x.get());
+                               row_changed(get_path(*iter),*iter);
+                       }
+
+                       return;
+               }
+               else
+                       CanvasTreeStore::set_value_impl(iter,column, value);
+       }
+       catch(std::exception x)
+       {
+               g_warning("%s", x.what());
+       }
+}
diff --git a/synfig-studio/src/gui/childrentreestore.h b/synfig-studio/src/gui/childrentreestore.h
new file mode 100644 (file)
index 0000000..5d0412a
--- /dev/null
@@ -0,0 +1,143 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file childrentreestore.h
+**     \brief Template Header
+**
+**     $Id$
+**
+**     \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
+**     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_CHILDRENTREESTORE_H
+#define __SYNFIG_STUDIO_CHILDRENTREESTORE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/treestore.h>
+#include <synfigapp/canvasinterface.h>
+#include "canvastreestore.h"
+#include <synfig/value.h>
+#include <synfig/valuenode.h>
+#include <set>
+
+/* === 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 ChildrenTreeStore : public CanvasTreeStore
+{
+       /*
+ -- ** -- P U B L I C   T Y P E S ---------------------------------------------
+       */
+
+public:
+
+       /*
+ -- ** -- P U B L I C  D A T A ------------------------------------------------
+       */
+
+public:
+
+       //! TreeModel for the layers
+       const Model model;
+
+       /*
+ -- ** -- P R I V A T E   D A T A ---------------------------------------------
+       */
+
+private:
+
+       Gtk::TreeModel::Row value_node_row;
+       Gtk::TreeModel::Row canvas_row;
+
+       std::set<synfig::ValueNode::Handle> changed_set_;
+
+       std::set<synfig::ValueNode::Handle> replaced_set_;
+
+       /*
+ -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
+       */
+
+private:
+
+       sigc::connection changed_connection;
+       bool execute_changed_queued()const { return !changed_set_.empty() || !replaced_set_.empty(); }
+       bool execute_changed_value_nodes();
+       void clear_changed_queue() { changed_set_.clear(); replaced_set_.clear(); }
+
+       /*
+ -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
+       */
+
+private:
+
+       void on_value_node_added(synfig::ValueNode::Handle value_node);
+       void on_value_node_deleted(synfig::ValueNode::Handle value_node);
+       void on_value_node_changed(synfig::ValueNode::Handle value_node);
+       void on_value_node_renamed(synfig::ValueNode::Handle value_node);
+       void on_value_node_replaced(synfig::ValueNode::Handle replaced_value_node,synfig::ValueNode::Handle new_value_node);
+       void on_canvas_added(synfig::Canvas::Handle canvas);
+       void on_canvas_removed(synfig::Canvas::Handle canvas);
+
+       void set_value_impl(const Gtk::TreeModel::iterator& iter, int column, const Glib::ValueBase& value);
+
+       /*
+ -- ** -- P U B L I C   M E T H O D S -----------------------------------------
+       */
+
+public:
+
+       ChildrenTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
+       ~ChildrenTreeStore();
+
+       void rebuild();
+
+       void refresh();
+
+       void rebuild_value_nodes();
+
+       void refresh_value_nodes();
+
+       void rebuild_canvases();
+
+       void refresh_canvases();
+
+       void refresh_row(Gtk::TreeModel::Row &row, bool do_children=false);
+
+       Gtk::TreeModel::Row get_canvas_row()const { return canvas_row; }
+
+       Gtk::TreeModel::Row get_value_node_row()const { return value_node_row; }
+
+       /*
+ -- ** -- S T A T I C   P U B L I C   M E T H O D S ---------------------------
+       */
+
+public:
+
+       static Glib::RefPtr<ChildrenTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
+}; // END of class ChildrenTreeStore
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/compview.cpp b/synfig-studio/src/gui/compview.cpp
new file mode 100644 (file)
index 0000000..6605944
--- /dev/null
@@ -0,0 +1,616 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file compview.cpp
+**     \brief writeme
+**
+**     $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
+**
+** === N O T E S ===========================================================
+**
+** ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "compview.h"
+#include "app.h"
+#include <gtkmm/scrolledwindow.h>
+#include <cassert>
+#include <iostream>
+#include "instance.h"
+#include <sigc++/signal.h>
+#include <sigc++/hide.h>
+#include <sigc++/slot.h>
+#include "canvasview.h"
+#include <synfigapp/action.h>
+
+#include "general.h"
+
+#endif
+
+/* === M A C R O S ========================================================= */
+
+#define ADD_TOOLBOX_BUTTON(button,stockid,tooltip)     \
+       Gtk::Button *button = manage(new class Gtk::Button());  \
+       button->add(*manage(new Gtk::Image(Gtk::StockID(stockid),Gtk::IconSize(4))));   \
+       tooltips.set_tip(*button,tooltip);      \
+       button->show_all()
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+using namespace studio;
+
+#define COLUMNID_JUMP          (787584)
+#define ColumnID       int
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+CompView::CompView():
+       Gtk::Window(Gtk::WINDOW_TOPLEVEL),
+       dialog_settings(this,"compview")
+{
+       assert(0); //CHECK: This class does not appear to be used.
+       init_menu();
+       set_type_hint(Gdk::WINDOW_TYPE_HINT_UTILITY);
+
+       Gtk::Table *table = manage(new class Gtk::Table(2, 1, false));
+
+
+       table->attach(*create_instance_selector(), 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK, 0, 0);
+
+       notebook=manage(new class Gtk::Notebook());
+
+       table->attach(*notebook, 0, 1, 1,2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       notebook->append_page(*create_canvas_tree(),_("Canvases"));
+       notebook->append_page(*create_action_tree(),_("History"));
+
+
+
+/*
+
+       studio::Instance::ImageColumnModel image_column_model;
+       image_list=manage(new class Gtk::TreeView());
+       image_list->append_column(_("Name"),image_column_model.name);
+       image_list->signal_row_activated().connect(sigc::mem_fun(*this,&CompView::on_image_activate));
+       image_list->set_rules_hint();
+
+       Gtk::Table *image_page = manage(new class Gtk::Table(2, 1, false));
+       Gtk::ScrolledWindow *image_list_scroll = manage(new class Gtk::ScrolledWindow());
+       image_list_scroll->set_flags(Gtk::CAN_FOCUS);
+       image_list_scroll->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+       image_list_scroll->add(*image_list);
+       image_page->attach(*image_list_scroll, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       Gtk::HBox *image_buttons=manage(new class Gtk::HBox());
+       image_page->attach(*image_buttons, 0, 1, 1,2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK, 0, 0);
+       ADD_TOOLBOX_BUTTON(button_image_new,"gtk-new",_("Create a new image"));
+       ADD_TOOLBOX_BUTTON(button_image_delete,"gtk-delete",_("Delete image"));
+       ADD_TOOLBOX_BUTTON(button_image_rename,"gtk-rename",_("Rename image"));
+       ADD_TOOLBOX_BUTTON(button_image_copy,"gtk-copy",_("Duplicate image"));
+       button_image_new->signal_clicked().connect(sigc::mem_fun(*this,&CompView::new_image));
+       button_image_delete->signal_clicked().connect(sigc::mem_fun(*this,&CompView::delete_image));
+       button_image_rename->signal_clicked().connect(sigc::mem_fun(*this,&CompView::rename_image));
+       button_image_copy->signal_clicked().connect(sigc::mem_fun(*this,&CompView::copy_image));
+       image_buttons->pack_start(*button_image_new);
+       image_buttons->pack_start(*button_image_delete);
+       image_buttons->pack_start(*button_image_rename);
+       image_buttons->pack_start(*button_image_copy);
+
+       studio::Instance::ValueNodeColumnModel valuenode_column_model;
+       valuenode_list=manage(new class Gtk::TreeView());
+       valuenode_list->append_column(_("Name"),valuenode_column_model.name);
+       valuenode_list->signal_row_activated().connect(sigc::mem_fun(*this,&CompView::on_valuenode_activate));
+       valuenode_list->set_rules_hint();
+
+       Gtk::Table *valuenode_page = manage(new class Gtk::Table(2, 1, false));
+       Gtk::ScrolledWindow *valuenode_list_scroll = manage(new class Gtk::ScrolledWindow());
+       valuenode_list_scroll->set_flags(Gtk::CAN_FOCUS);
+       valuenode_list_scroll->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+       valuenode_list_scroll->add(*valuenode_list);
+       valuenode_page->attach(*valuenode_list_scroll, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       Gtk::HBox *valuenode_buttons=manage(new class Gtk::HBox());
+       valuenode_page->attach(*valuenode_buttons, 0, 1, 1,2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK, 0, 0);
+       ADD_TOOLBOX_BUTTON(button_valuenode_new,"gtk-new",_("Create a new value_node"));
+       ADD_TOOLBOX_BUTTON(button_valuenode_delete,"gtk-delete",_("Delete value_node"));
+       ADD_TOOLBOX_BUTTON(button_valuenode_rename,"gtk-rename",_("Rename value_node"));
+       ADD_TOOLBOX_BUTTON(button_valuenode_copy,"gtk-copy",_("Duplicate value_node"));
+       button_valuenode_new->signal_clicked().connect(sigc::mem_fun(*this,&CompView::new_value_node));
+       button_valuenode_delete->signal_clicked().connect(sigc::mem_fun(*this,&CompView::delete_value_node));
+       button_valuenode_rename->signal_clicked().connect(sigc::mem_fun(*this,&CompView::rename_value_node));
+       button_valuenode_copy->signal_clicked().connect(sigc::mem_fun(*this,&CompView::copy_value_node));
+       valuenode_buttons->pack_start(*button_valuenode_new);
+       valuenode_buttons->pack_start(*button_valuenode_delete);
+       valuenode_buttons->pack_start(*button_valuenode_rename);
+       valuenode_buttons->pack_start(*button_valuenode_copy);
+
+
+       notebook->append_page(*image_page,_("Images"));
+       notebook->append_page(*valuenode_page,_("ValueNodes"));
+
+       image_page->show_all();
+       valuenode_page->show_all();
+*/
+//     notebook->set_current_page(0);
+       signal_delete_event().connect(sigc::hide(sigc::mem_fun(*this, &CompView::close)));
+       App::signal_instance_created().connect(sigc::mem_fun(*this,&studio::CompView::new_instance));
+       App::signal_instance_deleted().connect(sigc::mem_fun(*this,&studio::CompView::delete_instance));
+       App::signal_instance_selected().connect(sigc::mem_fun(*this,&studio::CompView::set_selected_instance_signal));
+
+       table->show_all();
+       add(*table);
+
+
+       set_title(_("Canvas Browser"));
+       set_modal(false);
+       set_resizable(true);
+       property_window_position().set_value(Gtk::WIN_POS_NONE);
+       set_default_size(200,300);
+}
+
+CompView::~CompView()
+{
+}
+
+etl::loose_handle<studio::CanvasView>
+CompView::get_selected_canvas_view()
+{
+       return get_selected_instance()->find_canvas_view(get_selected_canvas());
+}
+
+Gtk::Widget*
+CompView::create_canvas_tree()
+{
+       studio::Instance::CanvasTreeModel canvas_tree_model;
+       canvas_tree=manage(new class Gtk::TreeView());
+       {
+               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("ID")) );
+//             Gtk::CellRendererPixbuf* icon_cellrenderer = Gtk::manage( new Gtk::CellRendererPixbuf() );
+
+               //column->pack_start(*icon_cellrenderer,false);
+               column->pack_start(canvas_tree_model.icon, false); //false = don't expand.
+               column->pack_start(canvas_tree_model.label);
+
+//#ifdef NDEBUG
+//             column->add_attribute(icon_cellrenderer->property_pixbuf(), canvas_tree_model.icon);
+//#endif
+
+               canvas_tree->append_column(*column);
+       }
+       canvas_tree->set_rules_hint();
+       canvas_tree->signal_row_activated().connect(sigc::mem_fun(*this,&CompView::on_row_activate));
+       canvas_tree->signal_event().connect(sigc::mem_fun(*this,&CompView::on_tree_event));
+       canvas_tree->add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
+       canvas_tree->add_events(Gdk::BUTTON1_MOTION_MASK);
+       canvas_tree->show();
+
+       Gtk::ScrolledWindow *scrolledwindow = manage(new class Gtk::ScrolledWindow());
+       scrolledwindow->set_flags(Gtk::CAN_FOCUS);
+       scrolledwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+       scrolledwindow->add(*canvas_tree);
+       scrolledwindow->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
+       scrolledwindow->show();
+
+       return scrolledwindow;
+}
+
+Gtk::Widget*
+CompView::create_action_tree()
+{
+       studio::HistoryTreeStore::Model history_tree_model;
+       action_tree=manage(new class Gtk::TreeView());
+       {
+               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column("") );
+
+               Gtk::CellRendererToggle* toggle_cr = Gtk::manage( new Gtk::CellRendererToggle() );
+               toggle_cr->signal_toggled().connect(sigc::mem_fun(*this, &studio::CompView::on_action_toggle) );
+
+               column->pack_start(*toggle_cr); //false = don't expand.
+               column->add_attribute(toggle_cr->property_active(),history_tree_model.is_active);
+               column->set_resizable();
+               column->set_clickable();
+
+               action_tree->append_column(*column);
+       }
+       /*{
+               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Canvas")) );
+               Gtk::CellRendererText *text_cr=Gtk::manage(new Gtk::CellRendererText());
+               text_cr->property_foreground()=Glib::ustring("#7f7f7f");
+
+               column->pack_start(*text_cr);
+               column->add_attribute(text_cr->property_text(),history_tree_model.canvas_id);
+               column->add_attribute(text_cr->property_foreground_set(),history_tree_model.is_redo);
+
+               action_tree->append_column(*column);
+       }*/
+       {
+               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Jump")) );
+
+               Gtk::CellRendererText* cell_renderer_jump=Gtk::manage(new Gtk::CellRendererText());
+               column->pack_start(*cell_renderer_jump,true);
+
+               cell_renderer_jump->property_text()=_("(JMP)");
+               cell_renderer_jump->property_foreground()="#003a7f";
+
+               column->set_resizable();
+               column->set_clickable();
+
+               column->set_sort_column(COLUMNID_JUMP);
+
+               action_tree->append_column(*column);
+               //column->clicked();
+       }
+       {
+               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Action")) );
+
+               Gtk::CellRendererText *text_cr=Gtk::manage(new Gtk::CellRendererText());
+               text_cr->property_foreground()=Glib::ustring("#7f7f7f");
+
+
+
+               //column->pack_start(history_tree_model.icon, false); //false = don't expand.
+               column->pack_start(*text_cr);
+               column->add_attribute(text_cr->property_text(),history_tree_model.name);
+               column->add_attribute(text_cr->property_foreground_set(),history_tree_model.is_redo);
+
+               action_tree->append_column(*column);
+       }
+
+
+       action_tree->set_rules_hint();
+//     action_tree->signal_row_activated().connect(sigc::mem_fun(*this,&CompView::on_row_activate));
+       action_tree->signal_event().connect(sigc::mem_fun(*this,&CompView::on_action_event));
+//     action_tree->add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
+//     action_tree->add_events(Gdk::BUTTON1_MOTION_MASK);
+       action_tree->show();
+
+       Gtk::ScrolledWindow *scrolledwindow = manage(new class Gtk::ScrolledWindow());
+       scrolledwindow->set_flags(Gtk::CAN_FOCUS);
+       scrolledwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+       scrolledwindow->add(*action_tree);
+       scrolledwindow->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
+       scrolledwindow->show();
+
+       Gtk::Button* clear_button(manage(new Gtk::Button(_("Clear Undo"))));
+       clear_button->signal_pressed().connect(sigc::mem_fun(*this,&studio::CompView::clear_history));
+
+       Gtk::Button* clear_redo_button(manage(new Gtk::Button(_("Clear Redo"))));
+       clear_redo_button->signal_pressed().connect(sigc::mem_fun(*this,&studio::CompView::clear_redo));
+
+       Gtk::Table* table(manage(new Gtk::Table()));
+       table->attach(*scrolledwindow, 0, 2, 0,1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       table->attach(*clear_button, 0, 1, 1,2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK, 0, 0);
+       table->attach(*clear_redo_button, 1, 2, 1,2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK, 0, 0);
+
+       table->show_all();
+
+       return table;
+}
+
+Gtk::Widget*
+CompView::create_instance_selector()
+{
+       instance_selector=manage(new class Gtk::OptionMenu());
+       instance_selector->show();
+       instance_selector->set_menu(instance_list_menu);
+       return instance_selector;
+}
+
+bool
+CompView::close()
+{
+       hide();
+       return true;
+}
+
+void
+CompView::clear_history()
+{
+       if(selected_instance && App::dialog_yes_no(_("Clear History"), _("You will not be able to undo any changes that you have made!\nAre you sure you want to clear the undo stack?")))
+       {
+               selected_instance->clear_undo_stack();
+       }
+}
+
+void
+CompView::clear_redo()
+{
+       if(selected_instance && App::dialog_yes_no(_("Clear History"), _("You will not be able to redo any changes that you have made!\nAre you sure you want to clear the redo stack?")))
+       {
+               selected_instance->clear_redo_stack();
+       }
+}
+
+void
+CompView::init_menu()
+{
+       menu.items().push_back(Gtk::Menu_Helpers::SeparatorElem());
+       menu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-canvas_new"),
+               sigc::mem_fun(*this,&CompView::menu_new_canvas)));
+       menu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-delete"),
+               sigc::mem_fun(*this,&CompView::menu_delete)));
+       menu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-rename"),
+               sigc::mem_fun(*this,&CompView::menu_rename)));
+}
+
+etl::loose_handle<synfig::Canvas>
+CompView::get_selected_canvas()
+{
+       Glib::RefPtr<Gtk::TreeSelection> selection=canvas_tree->get_selection();
+
+       if(!selection || !selection->get_selected())
+               return 0;
+
+       studio::Instance::CanvasTreeModel canvas_tree_model;
+
+       return static_cast<etl::handle<synfig::Canvas> >((*selection->get_selected())[canvas_tree_model.canvas]);
+}
+
+void
+CompView::menu_new_canvas()
+{
+#warning Update Me!
+#if 0
+       get_selected_canvas_view()->new_child_canvas();
+#endif
+}
+
+void
+CompView::menu_delete()
+{
+       studio::App::dialog_not_implemented();
+}
+
+void
+CompView::menu_rename()
+{
+       studio::App::dialog_not_implemented();
+}
+
+void
+CompView::set_selected_instance_signal(etl::handle<studio::Instance> x)
+{
+       set_selected_instance(x);
+}
+
+void
+CompView::set_selected_instance_(etl::handle<studio::Instance> instance)
+{
+       if(studio::App::shutdown_in_progress)
+               return;
+
+       selected_instance=instance;
+       if(instance)
+       {
+               canvas_tree->set_model(instance->canvas_tree_store());
+               action_tree->set_model(instance->history_tree_store());
+               canvas_tree->show();
+               action_tree->show();
+       }
+       else
+       {
+               canvas_tree->set_model(Glib::RefPtr< Gtk::TreeModel >());
+               action_tree->set_model(Glib::RefPtr< Gtk::TreeModel >());
+               canvas_tree->hide();
+               action_tree->hide();
+       }
+}
+
+void
+CompView::set_selected_instance(etl::loose_handle<studio::Instance> x)
+{
+       if(studio::App::shutdown_in_progress)
+               return;
+
+       // if it's already selected, don't select it again
+       if (x==selected_instance)
+               return;
+
+       std::list<etl::handle<studio::Instance> >::iterator iter;
+
+       if(x)
+       {
+               int i;
+               for(i=0,iter=studio::App::instance_list.begin();iter!=studio::App::instance_list.end() && ((*iter)!=x);iter++,i++);
+
+               assert(*iter==x);
+
+               instance_selector->set_history(i);
+       }
+       else
+               instance_selector->set_history(0);
+
+       set_selected_instance_(x);
+}
+
+void
+CompView::new_instance(etl::handle<studio::Instance> instance)
+{
+       if(studio::App::shutdown_in_progress)
+               return;
+
+       assert(instance);
+
+       etl::loose_handle<studio::Instance> loose_instance(instance);
+
+       instance->synfigapp::Instance::signal_filename_changed().connect(sigc::mem_fun(*this,&CompView::refresh_instances));
+       instance->synfigapp::Instance::signal_filename_changed().connect(
+               sigc::bind<etl::loose_handle<studio::Instance> >(
+                       sigc::mem_fun(*this,&CompView::set_selected_instance),
+                       loose_instance
+               )
+       );
+
+       {
+               std::string name=basename(instance->get_file_name());
+
+               instance_list_menu.items().push_back(Gtk::Menu_Helpers::MenuElem(name,
+                       sigc::bind<etl::loose_handle<studio::Instance> >(sigc::mem_fun(&studio::App::set_selected_instance),loose_instance)     ));
+       }
+}
+
+void
+CompView::delete_instance(etl::handle<studio::Instance> instance)
+{
+       if(studio::App::shutdown_in_progress)
+               return;
+
+       refresh_instances();
+
+       if(selected_instance==instance)
+       {
+               set_selected_instance(0);
+               instance_selector->set_history(0);
+       }
+}
+
+void
+CompView::refresh_instances()
+{
+       if(studio::App::shutdown_in_progress)
+               return;
+
+       if(!instance_list_menu.items().empty())
+               instance_list_menu.items().clear();
+
+       std::list<etl::handle<studio::Instance> >::iterator iter;
+       for(iter=studio::App::instance_list.begin();iter!=studio::App::instance_list.end();iter++)
+       {
+               std::string name=basename((*iter)->get_file_name());
+
+               instance_list_menu.items().push_back(Gtk::Menu_Helpers::MenuElem(name,
+                       sigc::bind<etl::loose_handle<studio::Instance> >(sigc::mem_fun(&studio::App::set_selected_instance),*iter)      ));
+       }
+       instance_selector->set_menu(instance_list_menu);
+}
+
+void
+CompView::on_row_activate(const Gtk::TreeModel::Path &path, Gtk::TreeViewColumn *)
+{
+       assert(get_selected_instance());
+       studio::Instance::CanvasTreeModel canvas_tree_model;
+       const Gtk::TreeRow row = *(get_selected_instance()->canvas_tree_store()->get_iter(path));
+       if(row[canvas_tree_model.is_canvas])
+               get_selected_instance()->focus(row[canvas_tree_model.canvas]);
+       else
+               studio::App::dialog_not_implemented();
+}
+
+bool
+CompView::on_action_event(GdkEvent *event)
+{
+       studio::HistoryTreeStore::Model model;
+    switch(event->type)
+    {
+       case GDK_BUTTON_PRESS:
+       case GDK_2BUTTON_PRESS:
+               {
+                       Gtk::TreeModel::Path path;
+                       Gtk::TreeViewColumn *column;
+                       int cell_x, cell_y;
+                       if(!action_tree->get_path_at_pos(
+                               int(event->button.x),int(event->button.y),      // x, y
+                               path, // TreeModel::Path&
+                               column, //TreeViewColumn*&
+                               cell_x,cell_y //int&cell_x,int&cell_y
+                               )
+                       ) break;
+                       const Gtk::TreeRow row = *(action_tree->get_model()->get_iter(path));
+
+                       //signal_user_click()(event->button.button,row,(ColumnID)column->get_sort_column_id());
+                       if((ColumnID)column->get_sort_column_id()==COLUMNID_JUMP)
+                       {
+                               etl::handle<synfigapp::Action::Undoable> action(row[model.action]);
+                               if((bool)row[model.is_undo])
+                               {
+                                       while(get_selected_instance()->undo_action_stack().size() && get_selected_instance()->undo_action_stack().front()!=action)
+                                               get_selected_instance()->undo();
+                               }
+                               else if((bool)row[model.is_redo])
+                               {
+                                       while(get_selected_instance()->redo_action_stack().size() && get_selected_instance()->undo_action_stack().front()!=action)
+                                               get_selected_instance()->redo();
+                               }
+                       }
+               }
+
+       case GDK_BUTTON_RELEASE:
+               break;
+       default:
+               break;
+       }
+       return false;
+}
+
+bool
+CompView::on_tree_event(GdkEvent *event)
+{
+    switch(event->type)
+    {
+       case GDK_BUTTON_PRESS:
+               switch(event->button.button)
+               {
+               case 3:
+               if(get_selected_canvas())
+               {
+                       menu.items().clear();
+
+                       synfigapp::Action::ParamList param_list;
+                       param_list.add("canvas",synfig::Canvas::Handle(get_selected_canvas()));
+                       param_list.add("canvas_interface",get_selected_instance()->find_canvas_interface(get_selected_canvas()));
+                       get_selected_instance()->find_canvas_view(get_selected_canvas())->add_actions_to_menu(&menu, param_list,synfigapp::Action::CATEGORY_CANVAS);
+                       menu.popup(0,0);
+                       menu.show();
+                       break;
+               }
+               default:
+                       break;
+               }
+               break;
+       case GDK_MOTION_NOTIFY:
+               break;
+       case GDK_BUTTON_RELEASE:
+               break;
+       default:
+               break;
+       }
+       return false;
+}
+
+void
+CompView::on_action_toggle(const Glib::ustring& path_string)
+{
+       studio::HistoryTreeStore::Model history_tree_model;
+
+       Gtk::TreePath path(path_string);
+
+       const Gtk::TreeRow row = *(selected_instance->history_tree_store()->get_iter(path));
+
+       handle<synfigapp::Action::Undoable> action=row[history_tree_model.action];
+
+       selected_instance->synfigapp::Instance::set_action_status(action,!action->is_active());
+}
diff --git a/synfig-studio/src/gui/compview.h b/synfig-studio/src/gui/compview.h
new file mode 100644 (file)
index 0000000..fbfdb1d
--- /dev/null
@@ -0,0 +1,128 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file compview.h
+**     \brief Header File
+**
+**     $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
+**
+** === N O T E S ===========================================================
+**
+** ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_COMPVIEW_H
+#define __SYNFIG_COMPVIEW_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/window.h>
+#include <gtkmm/image.h>
+#include <gtkmm/tooltips.h>
+#include <gtkmm/table.h>
+#include <gtkmm/button.h>
+#include <gtkmm/menu.h>
+#include <gtkmm/optionmenu.h>
+#include <gtkmm/notebook.h>
+#include <gtkmm/treeview.h>
+#include <gtkmm/box.h>
+
+#include <ETL/handle>
+
+#include "dialogsettings.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 synfig { class Canvas; };
+
+namespace studio {
+
+class Instance;
+class CanvasView;
+
+class CompView : public Gtk::Window
+{
+       DialogSettings dialog_settings;
+
+       Gtk::Tooltips tooltips;
+
+       Gtk::OptionMenu *instance_selector;
+       Gtk::Notebook *notebook;
+
+       Gtk::TreeView *canvas_tree;
+       Gtk::TreeView *action_tree;
+
+       Gtk::Menu       instance_list_menu;
+       Gtk::Menu       menu;
+
+       etl::loose_handle<studio::Instance>     selected_instance;
+
+       void set_selected_instance_(etl::handle<studio::Instance> x);
+
+       void clear_history();
+       void clear_redo();
+
+public:
+       CompView();
+       ~CompView();
+
+       etl::loose_handle<studio::Instance> get_selected_instance() { return selected_instance; }
+
+       etl::loose_handle<synfig::Canvas> get_selected_canvas();
+
+       etl::loose_handle<studio::CanvasView> get_selected_canvas_view();
+
+       void set_selected_instance(etl::loose_handle<studio::Instance> x);
+
+       void set_selected_instance_signal(etl::handle<studio::Instance> x);
+
+       void new_instance(etl::handle<studio::Instance> x);
+
+       void delete_instance(etl::handle<studio::Instance> x);
+
+       void refresh_instances();
+
+       bool close();
+
+private:
+
+       Gtk::Widget* create_canvas_tree();
+       Gtk::Widget* create_action_tree();
+       Gtk::Widget* create_instance_selector();
+
+       void on_row_activate(const Gtk::TreeModel::Path &path, Gtk::TreeViewColumn *);
+       bool on_tree_event(GdkEvent *event);
+
+       bool on_action_event(GdkEvent *event);
+
+       void init_menu();
+
+       void menu_new_canvas();
+       void menu_delete();
+       void menu_rename();
+
+       void on_action_toggle(const Glib::ustring& path);
+};
+
+};
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/devicetracker.cpp b/synfig-studio/src/gui/devicetracker.cpp
new file mode 100644 (file)
index 0000000..48bfa13
--- /dev/null
@@ -0,0 +1,150 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file devicetracker.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**  Copyright (c) 2009 Gerco Ballintijn
+**
+**     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
+*/
+/* ========================================================================= */
+
+// FIXME: The code here doesn't use the GTKmm layer but uses GTK+ directly
+// since the GTKmm wrapper for Gdk::Device is incomplete. When the wrapper
+// gets fixed, this code should be updated accoordingly.
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "devicetracker.h"
+#include <gdk/gdk.h>
+#include <gtk/gtk.h>
+#include <synfigapp/main.h>
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+using namespace synfigapp;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+DeviceTracker::DeviceTracker()
+{
+       GList*  device_list;
+       GList*  iter;
+       device_list=gdk_devices_list();
+
+       for(iter=device_list;iter;iter=g_list_next(iter))
+       {
+               GdkDevice* device=reinterpret_cast<GdkDevice*>(iter->data);
+
+               synfigapp::InputDevice::Handle input_device;
+               input_device=synfigapp::Main::add_input_device(device->name,synfigapp::InputDevice::Type(device->source));
+               //Disable all extended devices by default. This tries to fix several
+               // bugs reported in track and forums
+               if(     input_device->get_type()==synfigapp::InputDevice::TYPE_MOUSE  ||
+                       input_device->get_type()==synfigapp::InputDevice::TYPE_PEN    ||
+                       input_device->get_type()==synfigapp::InputDevice::TYPE_ERASER ||
+                       input_device->get_type()==synfigapp::InputDevice::TYPE_CURSOR  ) {
+                       input_device->set_mode(synfigapp::InputDevice::MODE_DISABLED);
+                       //synfigapp::Main::select_input_device(input_device);
+               }
+       }
+       // Once all devices are disabled be sure that the core pointer is the
+       // one selected. The user should decide later whether enable and save the
+       // rest of input devices found.
+       synfigapp::Main::select_input_device(gdk_device_get_core_pointer()->name);
+}
+
+DeviceTracker::~DeviceTracker()
+{
+}
+
+void
+DeviceTracker::save_preferences()
+{
+       GList * device_list = gdk_devices_list();
+       for (GList * itr = device_list; itr; itr = g_list_next(itr))
+       {
+               GdkDevice * gdk_device = reinterpret_cast<GdkDevice*>(itr->data);
+
+               InputDevice::Handle synfig_device = synfigapp::Main::find_input_device(gdk_device->name);
+               if (synfig_device == NULL)
+                       continue;
+
+               synfig_device->set_mode(InputDevice::Mode(gdk_device->mode));
+               if (gdk_device->num_axes > 0) {
+                       vector<synfigapp::InputDevice::AxisUse> axes;
+                       axes.resize(gdk_device->num_axes);
+                       for (int i = 0; i < gdk_device->num_axes; i++)
+                               axes[i] = InputDevice::AxisUse(gdk_device->axes[i].use);
+                       synfig_device->set_axes(axes);
+               }
+
+               if (gdk_device->num_keys > 0) {
+                       vector<synfigapp::InputDevice::DeviceKey> keys;
+                       keys.resize(gdk_device->num_keys);
+                       for (int i = 0; i < gdk_device->num_keys; i++) {
+                               keys[i].keyval = gdk_device->keys[i].keyval;
+                               keys[i].modifiers = gdk_device->keys[i].modifiers;
+                       }
+                       synfig_device->set_keys(keys);
+               }
+       }
+}
+
+void
+DeviceTracker::load_preferences()
+{
+       GList * device_list = gdk_devices_list();
+       for (GList * itr = device_list; itr; itr = g_list_next(itr))
+       {
+               GdkDevice * gdk_device = reinterpret_cast<GdkDevice*>(itr->data);
+
+               InputDevice::Handle synfig_device = synfigapp::Main::find_input_device(gdk_device->name);
+               if (synfig_device == NULL)
+                       continue;
+
+               gdk_device_set_mode(gdk_device, GdkInputMode(synfig_device->get_mode()));
+
+               const std::vector<synfigapp::InputDevice::AxisUse> axes = synfig_device->get_axes();
+               for (int axis = 0; axis < (int) axes.size(); axis++)
+                       gdk_device_set_axis_use(gdk_device, axis, GdkAxisUse(axes[axis]));
+
+               const std::vector<synfigapp::InputDevice::DeviceKey> keys = synfig_device->get_keys();
+               for (int key = 0; key < (int) keys.size(); key++)
+                       gdk_device_set_key(gdk_device, key, keys[key].keyval,
+                                       GdkModifierType(keys[key].modifiers));
+       }
+}
diff --git a/synfig-studio/src/gui/devicetracker.h b/synfig-studio/src/gui/devicetracker.h
new file mode 100644 (file)
index 0000000..14c0272
--- /dev/null
@@ -0,0 +1,56 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file devicetracker.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_DEVICETRACKER_H
+#define __SYNFIG_DEVICETRACKER_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <synfig/string.h>
+#include <synfigapp/inputdevice.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 DeviceTracker
+{
+public:
+       DeviceTracker();
+       ~DeviceTracker();
+
+       void save_preferences();
+       void load_preferences();
+
+}; // END of class DeviceTracker
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/dialog_color.cpp b/synfig-studio/src/gui/dialog_color.cpp
new file mode 100644 (file)
index 0000000..6953a75
--- /dev/null
@@ -0,0 +1,155 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dialog_color.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "dialog_color.h"
+#include "widget_color.h"
+#include <synfig/general.h>
+#include <synfigapp/main.h>
+#include <gtkmm/button.h>
+#include "app.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Dialog_Color::Dialog_Color():
+       Dialog(_("Colors"), false, true),
+       dialog_settings(this, "color"),
+       busy_(false)
+{
+       set_type_hint(Gdk::WINDOW_TYPE_HINT_UTILITY);
+
+       create_color_edit_widget();
+       create_set_color_button("synfig-set_outline_color", _("Set as Outline"), 0,
+                       sigc::mem_fun(*this, &Dialog_Color::on_set_oc_pressed));
+       create_set_color_button("synfig-set_fill_color", _("Set as Fill"), 1,
+                       sigc::mem_fun(*this, &Dialog_Color::on_set_fc_pressed));
+       create_close_button();
+
+       add_accel_group(App::ui_manager()->get_accel_group());
+       show_all_children();
+}
+
+Dialog_Color::~Dialog_Color()
+{
+}
+
+void
+Dialog_Color::create_color_edit_widget()
+{
+       color_edit_widget = manage(new Widget_ColorEdit());
+       color_edit_widget->signal_value_changed().connect(sigc::mem_fun(*this,
+                       &studio::Dialog_Color::on_color_changed));
+       get_vbox()->pack_start(*color_edit_widget);
+}
+
+void
+Dialog_Color::create_set_color_button(const char *stock_id,
+               const Glib::ustring& tip_text, int index,
+               const sigc::slot0<void>& callback)
+{
+       Gtk::Button *set_color_button = manage(new Gtk::Button());
+       Gtk::Image *set_color_icon = manage(new Gtk::Image(Gtk::StockID(stock_id),
+                       Gtk::IconSize::IconSize(Gtk::ICON_SIZE_BUTTON)));
+       set_color_button->add(*set_color_icon);
+       set_color_icon->show();
+       tooltips.set_tip(*set_color_button, tip_text);
+       set_color_button->show();
+       add_action_widget(*set_color_button, index);
+       set_color_button->signal_clicked().connect(callback);
+}
+
+void
+Dialog_Color::create_close_button()
+{
+       Gtk::Button *close_button(manage(new Gtk::Button(Gtk::StockID("gtk-close"))));
+       close_button->show();
+       add_action_widget(*close_button, 2);
+       close_button->signal_clicked().connect(sigc::hide_return(sigc::mem_fun(*this,
+                       &Dialog_Color::on_close_pressed)));
+       signal_delete_event().connect(sigc::hide(sigc::mem_fun(*this,
+                       &Dialog_Color::on_close_pressed)));
+}
+
+void
+Dialog_Color::on_color_changed()
+{
+       busy_ = true;
+       signal_edited_(get_color());
+       busy_ = false;
+}
+
+void
+Dialog_Color::on_set_oc_pressed()
+{
+       busy_ = true;
+       synfigapp::Main::set_outline_color(get_color());
+       busy_ = false;
+}
+
+void
+Dialog_Color::on_set_fc_pressed()
+{
+       busy_ = true;
+       synfigapp::Main::set_fill_color(get_color());
+       busy_ = false;
+}
+
+bool
+Dialog_Color::on_close_pressed()
+{
+       busy_ = false;
+       grab_focus();
+       reset();
+       hide();
+       return true;
+}
+
+void
+Dialog_Color::reset()
+{
+       signal_edited_.clear();
+}
diff --git a/synfig-studio/src/gui/dialog_color.h b/synfig-studio/src/gui/dialog_color.h
new file mode 100644 (file)
index 0000000..ee350cf
--- /dev/null
@@ -0,0 +1,88 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dialog_color.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_DIALOG_COLOR_H
+#define __SYNFIG_STUDIO_DIALOG_COLOR_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtk/gtk.h>
+#include <gtkmm/dialog.h>
+#include <gtkmm/tooltips.h>
+#include <sigc++/functors/slot.h>
+
+#include "widget_coloredit.h"
+#include "dialogsettings.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 Widget_Color;
+
+class Dialog_Color : public Gtk::Dialog
+{
+       DialogSettings dialog_settings;
+       Gtk::Tooltips tooltips;
+
+       Widget_ColorEdit* color_edit_widget;
+
+       sigc::signal<void,synfig::Color> signal_edited_;
+
+       bool busy_;
+
+       void create_color_edit_widget();
+       void create_set_color_button(const char *stock_id,
+                       const Glib::ustring& tip_text, int index,
+                       const sigc::slot0<void>& callback);
+       void create_close_button();
+
+       void on_color_changed();
+       void on_set_oc_pressed();
+       void on_set_fc_pressed();
+       bool on_close_pressed();
+
+public:
+       Dialog_Color();
+       ~Dialog_Color();
+
+       sigc::signal<void,synfig::Color>& signal_edited() { return signal_edited_; }
+
+       void set_color(const synfig::Color& x) { color_edit_widget->set_value(x); }
+       synfig::Color get_color() const { return color_edit_widget->get_value(); }
+       void reset();
+
+       bool busy() const { return busy_; }
+
+}; // END of Dialog_Color
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/dialog_gradient.cpp b/synfig-studio/src/gui/dialog_gradient.cpp
new file mode 100644 (file)
index 0000000..fe060b9
--- /dev/null
@@ -0,0 +1,185 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dialog_gradient.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "dialog_gradient.h"
+#include "widget_gradient.h"
+#include <gtkmm/frame.h>
+#include <gtkmm/table.h>
+#include <gtkmm/label.h>
+#include <synfig/general.h>
+#include <synfigapp/canvasinterface.h>
+#include <synfigapp/value_desc.h>
+#include <synfigapp/main.h>
+#include "widget_color.h"
+#include <gtkmm/spinbutton.h>
+#include "app.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Dialog_Gradient::Dialog_Gradient():
+       Dialog(_("Gradient Editor"),false,true),
+       dialog_settings(this,"gradient"),
+       adjustment_pos(0,0.0,1.0,0.001,0.001,0)
+{
+       set_type_hint(Gdk::WINDOW_TYPE_HINT_DIALOG);
+       set_keep_above(false);
+
+       set_role("gradient_editor");
+
+       // Setup the buttons
+       set_default_button = manage(new class Gtk::Button(Gtk::StockID(_("Set as Default"))));
+       set_default_button->show();
+       add_action_widget(*set_default_button,2);
+       set_default_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Gradient::on_set_default_pressed));
+
+       Gtk::Button *cancel_button(manage(new class Gtk::Button(Gtk::StockID("gtk-close"))));
+       cancel_button->show();
+       add_action_widget(*cancel_button,0);
+       cancel_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Gradient::hide));
+
+       Gtk::Table* table(manage(new Gtk::Table(2,2,false)));
+       get_vbox()->pack_start(*table);
+
+       widget_gradient=manage(new Widget_Gradient());
+       widget_gradient->set_editable();
+       widget_gradient->signal_cpoint_selected().connect(sigc::mem_fun(*this,&studio::Dialog_Gradient::on_cpoint_selected));
+       widget_gradient->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Gradient::on_changed));
+       //table->attach(*manage(new Gtk::Label(_("Not yet fully implemented"))), 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       table->attach(*widget_gradient, 0, 1, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       widget_color=manage(new Widget_ColorEdit());
+       widget_color->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Gradient::on_values_adjusted));
+       widget_color->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Gradient::on_changed));
+       widget_color->signal_activated().connect(sigc::mem_fun(*this,&studio::Dialog_Gradient::on_values_adjusted));
+       table->attach(*widget_color, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+
+       spinbutton_pos=manage(new class Gtk::SpinButton(adjustment_pos,0.0001,4));
+       spinbutton_pos->set_update_policy(Gtk::UPDATE_ALWAYS);
+       adjustment_pos.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Gradient::on_values_adjusted));
+       adjustment_pos.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Gradient::on_changed));
+       table->attach(*spinbutton_pos, 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+
+
+       add_accel_group(App::ui_manager()->get_accel_group());
+
+       show_all_children();
+}
+
+Dialog_Gradient::~Dialog_Gradient()
+{
+}
+
+void
+Dialog_Gradient::set_gradient(const synfig::Gradient& x)
+{
+       widget_gradient->set_value(x);
+}
+
+void
+Dialog_Gradient::reset()
+{
+       value_changed_connection.disconnect();
+       signal_edited_.clear();
+}
+
+void
+Dialog_Gradient::on_set_default_pressed()
+{
+       synfigapp::Main::set_gradient(get_gradient());
+}
+
+void
+Dialog_Gradient::on_changed()
+{
+       signal_edited_(get_gradient());
+}
+
+void
+Dialog_Gradient::on_cpoint_selected(synfig::Gradient::CPoint x)
+{
+       widget_color->set_value(x.color);
+       adjustment_pos.set_value(x.pos);
+}
+
+void
+Dialog_Gradient::on_values_adjusted()
+{
+       synfig::Gradient::CPoint x(widget_gradient->get_selected_cpoint());
+       x.color=widget_color->get_value();
+       x.pos=adjustment_pos.get_value();
+       widget_gradient->update_cpoint(x);
+}
+
+static void
+dialog_gradient_value_desc_edit(synfig::Gradient /*g*/,synfigapp::ValueDesc /*x*/,handle<synfigapp::CanvasInterface> /*canvas_interface*/)
+{
+//     canvas_interface->connect_value(x,ValueBase(g));
+}
+
+void
+Dialog_Gradient::edit(const synfigapp::ValueDesc &x, etl::handle<synfigapp::CanvasInterface> canvas_interface, synfig::Time time)
+{
+       reset();
+       if(x.is_const())
+               set_gradient(x.get_value().get(Gradient()));
+       else if(x.is_value_node())
+               set_gradient((*x.get_value_node())(time).get(Gradient()));
+
+       signal_edited().connect(
+               sigc::bind(
+                       sigc::bind(
+                               sigc::ptr_fun(dialog_gradient_value_desc_edit),
+                               canvas_interface
+                       ),
+                       x
+               )
+       );
+
+       present();
+}
diff --git a/synfig-studio/src/gui/dialog_gradient.h b/synfig-studio/src/gui/dialog_gradient.h
new file mode 100644 (file)
index 0000000..698ba3c
--- /dev/null
@@ -0,0 +1,115 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dialog_gradient.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_DIALOG_GRADIENT_H
+#define __SYNFIG_STUDIO_DIALOG_GRADIENT_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtk/gtk.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/table.h>
+#include <gtkmm/button.h>
+#include <gtkmm/dialog.h>
+#include <gtkmm/drawingarea.h>
+#include <gtkmm/optionmenu.h>
+#include <gtkmm/checkbutton.h>
+
+#include <synfig/gamma.h>
+#include <synfig/time.h>
+
+#include "widget_gradient.h"
+#include "widget_coloredit.h"
+
+#include <synfigapp/value_desc.h>
+#include <synfig/time.h>
+
+#include "dialogsettings.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 Gtk { class Menu; class SpinButton; class Adjustment; };
+
+namespace synfigapp {
+class CanvasInterface;
+};
+
+namespace studio {
+
+class Widget_Gradient;
+class Widget_ColorEdit;
+
+class Dialog_Gradient : public Gtk::Dialog
+{
+       DialogSettings dialog_settings;
+
+       Gtk::SpinButton *spinbutton_pos;
+
+       Gtk::Adjustment adjustment_pos;
+
+
+       sigc::signal<void,synfig::Gradient> signal_edited_;
+
+       sigc::connection value_changed_connection;
+
+       void on_set_default_pressed();
+
+       void on_cpoint_selected(synfig::Gradient::CPoint x);
+       void on_values_adjusted();
+
+       Widget_Gradient* widget_gradient;
+       Widget_ColorEdit* widget_color;
+       Gtk::Button *set_default_button;
+
+       void on_changed();
+
+public:
+
+       sigc::signal<void,synfig::Gradient>& signal_edited() { return signal_edited_; }
+
+       void set_gradient(const synfig::Gradient& x);
+
+       const synfig::Gradient& get_gradient()const { return widget_gradient->get_value(); }
+
+       void set_default_button_set_sensitive(bool sensitive) { set_default_button->set_sensitive(sensitive); }
+
+       void reset();
+
+
+       Dialog_Gradient();
+       ~Dialog_Gradient();
+       //! Interface to external calls to fill in the Gradient Editor Dialog
+       //! when a Constant ValueNode or a Animated ValueNode is double cliked.
+       void edit(const synfigapp::ValueDesc &x, etl::handle<synfigapp::CanvasInterface> canvas_interface, synfig::Time time=0);
+}; // END of Dialog_Gradient
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/dialog_keyframe.cpp b/synfig-studio/src/gui/dialog_keyframe.cpp
new file mode 100644 (file)
index 0000000..b746490
--- /dev/null
@@ -0,0 +1,166 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dialog_keyframe.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "dialog_keyframe.h"
+#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/button.h>
+#include "widget_waypointmodel.h"
+#include <synfigapp/action.h>
+#include <synfigapp/instance.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Dialog_Keyframe::Dialog_Keyframe(Gtk::Window& parent, etl::handle<synfigapp::CanvasInterface> canvas_interface):
+       Gtk::Dialog(_("Keyframe Dialog"),parent,false,true),
+       canvas_interface(canvas_interface)
+{
+       // Set up the buttons
+       {
+               Gtk::Button *ok_button(manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))));
+               ok_button->show();
+               add_action_widget(*ok_button,2);
+               ok_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Keyframe::on_ok_pressed));
+
+               Gtk::Button *apply_button(manage(new class Gtk::Button(Gtk::StockID("gtk-apply"))));
+               apply_button->show();
+               add_action_widget(*apply_button,1);
+               apply_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Keyframe::on_apply_pressed));
+
+               Gtk::Button *delete_button(manage(new class Gtk::Button(Gtk::StockID("gtk-delete"))));
+               delete_button->show();
+               add_action_widget(*delete_button,3);
+               delete_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Keyframe::on_delete_pressed));
+
+               Gtk::Button *cancel_button(manage(new class Gtk::Button(Gtk::StockID("gtk-close"))));
+               cancel_button->show();
+               add_action_widget(*cancel_button,0);
+               cancel_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Keyframe::hide));
+       }
+
+       Gtk::Table *table=manage(new Gtk::Table(2,2,false));
+
+       get_vbox()->pack_start(*table);
+
+/*  // \todo Allow setting descriptions for keyframes
+
+       entry_description.set_text(_("Not yet implemented"));
+
+       table->attach(*manage(new Gtk::Label(_("Description"))), 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       table->attach(entry_description, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+*/
+
+       table->show_all();
+
+       widget_waypoint_model=Gtk::manage(new Widget_WaypointModel());
+       widget_waypoint_model->show();
+       table->attach(*widget_waypoint_model, 0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+
+}
+
+Dialog_Keyframe::~Dialog_Keyframe()
+{
+}
+
+const synfig::Keyframe&
+Dialog_Keyframe::get_keyframe()const
+{
+       return keyframe_;
+}
+
+void
+Dialog_Keyframe::set_keyframe(const synfig::Keyframe& x)
+{
+       keyframe_=x;
+}
+
+void
+Dialog_Keyframe::on_ok_pressed()
+{
+       on_apply_pressed();
+       hide();
+}
+
+
+void
+Dialog_Keyframe::on_delete_pressed()
+{
+       synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeRemove"));
+
+       assert(action);
+
+       action->set_param("canvas",canvas_interface->get_canvas());
+       action->set_param("canvas_interface",canvas_interface);
+       action->set_param("keyframe",keyframe_);
+       action->set_param("model",widget_waypoint_model->get_waypoint_model());
+
+       if(canvas_interface->get_instance()->perform_action(action))
+       {
+               hide();
+       }
+}
+
+
+void
+Dialog_Keyframe::on_apply_pressed()
+{
+       if(widget_waypoint_model->get_waypoint_model().is_trivial())
+               return;
+
+       synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeWaypointSet"));
+
+       assert(action);
+
+       action->set_param("canvas",canvas_interface->get_canvas());
+       action->set_param("canvas_interface",canvas_interface);
+       action->set_param("keyframe",keyframe_);
+       action->set_param("model",widget_waypoint_model->get_waypoint_model());
+
+       if(!canvas_interface->get_instance()->perform_action(action))
+       {
+       }
+}
diff --git a/synfig-studio/src/gui/dialog_keyframe.h b/synfig-studio/src/gui/dialog_keyframe.h
new file mode 100644 (file)
index 0000000..1222fd6
--- /dev/null
@@ -0,0 +1,79 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dialog_keyframe.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_DIALOG_KEYFRAME_H
+#define __SYNFIG_STUDIO_DIALOG_KEYFRAME_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/window.h>
+#include <gtkmm/tooltips.h>
+#include <gtkmm/table.h>
+#include <gtkmm/entry.h>
+
+#include <synfigapp/canvasinterface.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 Widget_WaypointModel;
+
+class Dialog_Keyframe : public Gtk::Dialog
+{
+       Gtk::Tooltips tooltips_;
+       etl::handle<synfigapp::CanvasInterface> canvas_interface;
+
+       synfig::Keyframe keyframe_;
+
+       Gtk::Entry entry_description;
+
+       Widget_WaypointModel* widget_waypoint_model;
+
+       void on_ok_pressed();
+       void on_apply_pressed();
+       void on_delete_pressed();
+
+public:
+       Dialog_Keyframe(Gtk::Window& parent,etl::handle<synfigapp::CanvasInterface> canvas_interface);
+       ~Dialog_Keyframe();
+
+       const synfig::Keyframe& get_keyframe()const;
+       void set_keyframe(const synfig::Keyframe& x);
+
+private:
+
+}; // END of class Dialog_Keyframe
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/dialog_preview.cpp b/synfig-studio/src/gui/dialog_preview.cpp
new file mode 100644 (file)
index 0000000..0782869
--- /dev/null
@@ -0,0 +1,220 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dialog_preview.cpp
+**     \brief Preview dialog File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "dialog_preview.h"
+#include "preview.h"
+#include <gtkmm/spinbutton.h>
+#include <gtkmm/alignment.h>
+#include <gtkmm/frame.h>
+#include <gtkmm/box.h>
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+using namespace studio;
+using namespace Gtk;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+/* === E N T R Y P O I N T ================================================= */
+
+//dialog_preview stuff...
+Dialog_Preview::Dialog_Preview()
+:Dialog(_("Preview Window"),false,true),
+settings(this,"preview")
+{
+       get_vbox()->pack_start(preview);
+}
+
+Dialog_Preview::~Dialog_Preview()
+{
+}
+
+void Dialog_Preview::set_preview(etl::handle<Preview> prev)
+{
+       get_window().clear();
+       preview.set_preview(prev);
+       //preview.update();
+}
+
+void Dialog_Preview::on_hide()
+{
+       Dialog::on_hide();
+       preview.stop();
+       preview.stoprender();
+}
+
+//dialog_previewoptions stuff
+Dialog_PreviewOptions::Dialog_PreviewOptions()
+:Dialog(_("Preview Options"),false,true),
+adj_zoom(0.5,0.1,5.0,0.1,0.2),
+adj_fps(15,1,120,1,5),
+check_overbegin(_("_Begin Time"),false),
+check_overend(_("_End Time"),false),
+settings(this,"prevoptions")
+{
+       //framerate = 15.0f;
+       //zoom = 0.2f;
+
+       //set the fps of the time widgets
+       Gtk::Alignment *dialogPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
+       dialogPadding->set_padding(12, 12, 12, 12);
+       get_vbox()->add(*dialogPadding);
+
+       Gtk::VBox *dialogBox = manage(new Gtk::VBox(false, 12));
+       dialogPadding->add(*dialogBox);
+
+       Gtk::Frame *generalFrame = manage(new Gtk::Frame(_("General Settings")));
+       generalFrame->set_shadow_type(Gtk::SHADOW_NONE);
+       ((Gtk::Label *) generalFrame->get_label_widget())->set_markup(_("<b>General Settings</b>"));
+       dialogBox->pack_start(*generalFrame, false, false, 0);
+
+       Gtk::Alignment *generalPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
+       generalPadding->set_padding(6, 0, 24, 0);
+       generalFrame->add(*generalPadding);
+
+       Gtk::Table *generalTable = manage(new Gtk::Table(2, 2, false));
+       generalTable->set_row_spacings(6);
+       generalTable->set_col_spacings(12);
+       generalPadding->add(*generalTable);
+
+       Gtk::Label *zoomLabel = manage(new Gtk::Label(_("_Zoom")));
+       zoomLabel->set_alignment(0, 0.5);
+       zoomLabel->set_use_underline(TRUE);
+       Gtk::SpinButton *zoomSpinner = manage(new Gtk::SpinButton(adj_zoom, 0.1, 2));
+       zoomLabel->set_mnemonic_widget(*zoomSpinner);
+       zoomSpinner->set_alignment(1);
+       generalTable->attach(*zoomLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       generalTable->attach(*zoomSpinner, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+       Gtk::Label *fpsLabel = manage(new Gtk::Label(_("_Frames per second")));
+       fpsLabel->set_alignment(0, 0.5);
+       fpsLabel->set_use_underline(TRUE);
+       Gtk::SpinButton *fpsSpinner = manage(new Gtk::SpinButton(adj_fps, 1, 1));
+       fpsLabel->set_mnemonic_widget(*fpsSpinner);
+       fpsSpinner->set_alignment(1);
+       generalTable->attach(*fpsLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       generalTable->attach(*fpsSpinner, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+       Gtk::Frame *timeFrame = manage(new Gtk::Frame(_("Time Settings")));
+       timeFrame->set_shadow_type(Gtk::SHADOW_NONE);
+       ((Gtk::Label *) timeFrame->get_label_widget())->set_markup(_("<b>Time Settings</b>"));
+       dialogBox->pack_start(*timeFrame, false, false, 0);
+
+       Gtk::Alignment *timePadding = manage(new Gtk::Alignment(0, 0, 1, 1));
+       timePadding->set_padding(6, 0, 24, 0);
+       timeFrame->add(*timePadding);
+
+       Gtk::Table *timeTable = manage(new Gtk::Table(2, 2, false));
+       timeTable->set_row_spacings(6);
+       timeTable->set_col_spacings(12);
+       timePadding->add(*timeTable);
+
+       check_overbegin.set_alignment(0, 0.5);
+       check_overbegin.set_use_underline(TRUE);
+       check_overend.set_alignment(0, 0.5);
+       check_overend.set_use_underline(TRUE);
+       time_begin.set_alignment(1);
+       time_end.set_alignment(1);
+       timeTable->attach(check_overbegin, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       timeTable->attach(time_begin, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       timeTable->attach(check_overend, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       timeTable->attach(time_end, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+       check_overbegin.signal_toggled().connect(sigc::mem_fun(*this,&Dialog_PreviewOptions::on_overbegin_toggle));
+       check_overend.signal_toggled().connect(sigc::mem_fun(*this,&Dialog_PreviewOptions::on_overend_toggle));
+
+       Gtk::Button *cancelButton = manage(new Gtk::Button(Gtk::StockID("gtk-cancel")));
+       cancelButton->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_PreviewOptions::on_cancel_pressed));
+       add_action_widget(*cancelButton, 1);
+
+       Gtk::Button *okbutton = manage(new Gtk::Button(Gtk::StockID("gtk-go-forward")));
+       okbutton->set_label(_("Preview"));
+       okbutton->signal_clicked().connect(sigc::mem_fun(*this,&Dialog_PreviewOptions::on_ok_pressed));
+       add_action_widget(*okbutton, 0);
+
+       time_begin.set_sensitive(false);
+       time_end.set_sensitive(false);
+       show_all();
+}
+
+Dialog_PreviewOptions::~Dialog_PreviewOptions()
+{
+}
+
+void Dialog_PreviewOptions::on_ok_pressed()
+{
+       PreviewInfo     i;
+       i.zoom = get_zoom();
+       i.fps = get_fps();
+       i.overbegin = get_begin_override();
+       i.overend = get_end_override();
+       if(i.overbegin) i.begintime = (float)get_begintime();
+       if(i.overend)   i.endtime = (float)get_endtime();
+
+       hide();
+       signal_finish_(i);
+       signal_finish_.clear();
+}
+
+void
+Dialog_PreviewOptions::on_cancel_pressed()
+{
+       hide();
+}
+
+void Dialog_PreviewOptions::on_overbegin_toggle()
+{
+       time_begin.set_sensitive(get_begin_override());
+}
+
+void Dialog_PreviewOptions::on_overend_toggle()
+{
+       time_end.set_sensitive(get_end_override());
+}
+
+void studio::Dialog_PreviewOptions::set_global_fps(float f)
+{
+       globalfps = f;
+       time_begin.set_fps(f);
+       time_end.set_fps(f);
+}
diff --git a/synfig-studio/src/gui/dialog_preview.h b/synfig-studio/src/gui/dialog_preview.h
new file mode 100644 (file)
index 0000000..9286552
--- /dev/null
@@ -0,0 +1,132 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dialog_preview.h
+**     \brief Preview dialog 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_GTKMM_DIALOG_PREVIEW_H
+#define __SYNFIG_GTKMM_DIALOG_PREVIEW_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/adjustment.h>
+#include <gtkmm/dialog.h>
+#include <gtkmm/menu.h>
+#include <gtkmm/spinbutton.h>
+#include <gui/dialogsettings.h>
+
+#include "preview.h"
+#include <gui/widget_time.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 {
+
+struct PreviewInfo
+{
+       float zoom,fps,begintime,endtime;
+       bool overbegin,overend;
+};
+
+class Dialog_Preview : public Gtk::Dialog
+{
+       Widget_Preview  preview;
+       DialogSettings  settings;
+
+       //etl::handle<synfig::Canvas> canvas;
+
+public:
+       Dialog_Preview();
+       ~Dialog_Preview();
+
+    void set_preview(etl::handle<Preview> prev);
+
+       Widget_Preview &get_widget() {return preview;}
+       const Widget_Preview &get_widget() const {return preview;}
+
+       virtual void on_hide();
+       //other forwarding functions...
+}; // END of Dialog_Preview
+
+class Dialog_PreviewOptions : public Gtk::Dialog
+{
+       //all the info needed to construct a render description...
+       Gtk::Adjustment adj_zoom;       // factor at which to resize the window...
+
+       Gtk::Adjustment adj_fps;        // how often to take samples of the animation
+
+       studio::Widget_Time time_begin;
+       studio::Widget_Time time_end;
+
+       Gtk::CheckButton check_overbegin;
+       Gtk::CheckButton check_overend;
+
+       DialogSettings  settings;
+
+       float   globalfps;
+
+       // for finishing
+       void on_ok_pressed();
+       void on_cancel_pressed();
+
+       //for ui stuff
+       void on_overbegin_toggle();
+       void on_overend_toggle();
+
+       sigc::signal<void,const PreviewInfo &>  signal_finish_;
+public:
+       Dialog_PreviewOptions();
+       ~Dialog_PreviewOptions();
+
+       float get_zoom() const { return adj_zoom.get_value(); }
+       void set_zoom(float z) { adj_zoom.set_value(z); }
+
+       float get_fps() const { return adj_fps.get_value(); }
+       void set_fps(float z) { adj_fps.set_value(z); }
+
+       float get_global_fps() const { return globalfps; }
+       void set_global_fps(float f);
+
+       synfig::Time get_begintime() const { return time_begin.get_value(); }
+       void set_begintime(const synfig::Time &t) { time_begin.set_value(t); }
+
+       synfig::Time get_endtime() const { return time_end.get_value(); }
+       void set_endtime(const synfig::Time &t) { time_end.set_value(t); }
+
+       bool get_begin_override() const { return check_overbegin.get_active(); }
+       void set_begin_override(bool o) { check_overbegin.set_active(o); }
+
+       bool get_end_override() const { return check_overend.get_active(); }
+       void set_end_override(bool o) { check_overend.set_active(o); }
+
+       sigc::signal<void,const PreviewInfo &>  &signal_finish() {return signal_finish_;}
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/dialog_setup.cpp b/synfig-studio/src/gui/dialog_setup.cpp
new file mode 100644 (file)
index 0000000..6272cb3
--- /dev/null
@@ -0,0 +1,839 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dialog_setup.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 2008 Chris Moore
+**     Copyright (c) 2008, 2009 Carlos López
+**
+**     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 <config.h>
+#endif
+
+#include "dialog_setup.h"
+#include "app.h"
+#include <gtkmm/scale.h>
+#include <gtkmm/table.h>
+#include <gtkmm/frame.h>
+#include <gtkmm/notebook.h>
+#include "widget_enum.h"
+#include "autorecover.h"
+
+#include <ETL/stringf>
+#include <ETL/misc>
+#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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+static void
+attach_label(Gtk::Table *table, String str, guint col, guint xpadding, guint ypadding)
+{
+       Gtk::Label* label(manage(new Gtk::Label((str + ":").c_str())));
+       label->set_alignment(Gtk::ALIGN_RIGHT, Gtk::ALIGN_CENTER);
+       table->attach(*label, 0, 1, col, col+1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+}
+
+Dialog_Setup::Dialog_Setup():
+       Dialog(_("Synfig Studio Setup"),false,true),
+       adj_gamma_r(2.2,0.1,3.0,0.025,0.025,0.025),
+       adj_gamma_g(2.2,0.1,3.0,0.025,0.025,0.025),
+       adj_gamma_b(2.2,0.1,3.0,0.025,0.025,0.025),
+       adj_recent_files(15,1,50,1,1,0),
+       adj_undo_depth(100,10,5000,1,1,1),
+       toggle_use_colorspace_gamma(_("Visually Linear Color Selection")),
+#ifdef SINGLE_THREADED
+       toggle_single_threaded(_("Use Only a Single Thread")),
+#endif
+       toggle_restrict_radius_ducks(_("Restrict Real-Valued Ducks to Top Right Quadrant")),
+       toggle_resize_imported_images(_("Scale New Imported Images to Fit Canvas")),
+       adj_pref_x_size(480,1,10000,1,10,0),
+       adj_pref_y_size(270,1,10000,1,10,0),
+       adj_pref_fps(24.0,1.0,100,0.1,1,0)
+
+       {
+       // Setup the buttons
+
+       Gtk::Button *ok_button(manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))));
+       ok_button->show();
+       add_action_widget(*ok_button,2);
+       ok_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Setup::on_ok_pressed));
+
+       Gtk::Button *apply_button(manage(new class Gtk::Button(Gtk::StockID("gtk-apply"))));
+       apply_button->show();
+       add_action_widget(*apply_button,1);
+       apply_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Setup::on_apply_pressed));
+
+       Gtk::Button *cancel_button(manage(new class Gtk::Button(Gtk::StockID("gtk-close"))));
+       cancel_button->show();
+       add_action_widget(*cancel_button,0);
+       cancel_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Setup::hide));
+
+
+       // Notebook
+       Gtk::Notebook *notebook=manage(new class Gtk::Notebook());
+       get_vbox()->pack_start(*notebook);
+
+
+       // Gamma
+       Gtk::Table *gamma_table=manage(new Gtk::Table(2,2,false));
+       notebook->append_page(*gamma_table,_("Gamma"));
+
+       gamma_table->attach(gamma_pattern, 0, 2, 0, 1, Gtk::EXPAND, Gtk::SHRINK|Gtk::FILL, 0, 0);
+
+       Gtk::HScale* scale_gamma_r(manage(new Gtk::HScale(adj_gamma_r)));
+       gamma_table->attach(*manage(new Gtk::Label(_("Red"))), 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       gamma_table->attach(*scale_gamma_r, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       adj_gamma_r.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Setup::on_gamma_r_change));
+
+       Gtk::HScale* scale_gamma_g(manage(new Gtk::HScale(adj_gamma_g)));
+       gamma_table->attach(*manage(new Gtk::Label(_("Green"))), 0, 1, 2, 3, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       gamma_table->attach(*scale_gamma_g, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       adj_gamma_g.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Setup::on_gamma_g_change));
+
+       Gtk::HScale* scale_gamma_b(manage(new Gtk::HScale(adj_gamma_b)));
+       gamma_table->attach(*manage(new Gtk::Label(_("Blue"))), 0, 1, 3, 4, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       gamma_table->attach(*scale_gamma_b, 1, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       adj_gamma_b.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Setup::on_gamma_b_change));
+
+       gamma_table->attach(*manage(new Gtk::Label(_("Black Level"))), 0, 1, 4, 5, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       gamma_table->attach(black_level_selector, 1, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       black_level_selector.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Setup::on_black_level_change));
+
+       //gamma_table->attach(*manage(new Gtk::Label(_("Red-Blue Level"))), 0, 1, 5, 6, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       //gamma_table->attach(red_blue_level_selector, 1, 2, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       //red_blue_level_selector.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Setup::on_red_blue_level_change));
+
+
+       // Misc
+       Gtk::Table *misc_table=manage(new Gtk::Table(2,2,false));
+       notebook->append_page(*misc_table,_("Misc."));
+
+       int xpadding(8), ypadding(8);
+
+       // Misc - Timestamp
+       timestamp_menu=manage(new class Gtk::Menu());
+       attach_label(misc_table, _("Timestamp"), 0, xpadding, ypadding);
+       misc_table->attach(timestamp_optionmenu, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+
+#define ADD_TIMESTAMP(desc,x)                                                                  \
+       timestamp_menu->items().push_back(                                                      \
+               Gtk::Menu_Helpers::MenuElem(                                                    \
+                       desc,                                                                                           \
+                       sigc::bind(                                                                                     \
+                               sigc::mem_fun(                                                                  \
+                                       *this,                                                                          \
+                                       &studio::Dialog_Setup::set_time_format),        \
+                               x)));
+       ADD_TIMESTAMP("HH:MM:SS.FF",            Time::FORMAT_VIDEO      );
+       ADD_TIMESTAMP("(HHh MMm SSs) FFf",      Time::FORMAT_NORMAL     );
+       ADD_TIMESTAMP("(HHhMMmSSs)FFf",         Time::FORMAT_NORMAL     | Time::FORMAT_NOSPACES );
+       ADD_TIMESTAMP("HHh MMm SSs FFf",        Time::FORMAT_NORMAL     | Time::FORMAT_FULL             );
+       ADD_TIMESTAMP("HHhMMmSSsFFf",           Time::FORMAT_NORMAL     | Time::FORMAT_NOSPACES | Time::FORMAT_FULL);
+       ADD_TIMESTAMP("FFf",                            Time::FORMAT_FRAMES );
+
+       timestamp_optionmenu.set_menu(*timestamp_menu);
+
+#undef ADD_TIMESTAMP
+
+       {
+               ParamDesc param_desc;
+               param_desc
+                       .set_hint("enum")
+                       .add_enum_value(Distance::SYSTEM_UNITS,"u",_("Units"))
+                       .add_enum_value(Distance::SYSTEM_PIXELS,"px",_("Pixels"))
+                       .add_enum_value(Distance::SYSTEM_POINTS,"pt",_("Points"))
+                       .add_enum_value(Distance::SYSTEM_INCHES,"in",_("Inches"))
+                       .add_enum_value(Distance::SYSTEM_METERS,"m",_("Meters"))
+                       .add_enum_value(Distance::SYSTEM_CENTIMETERS,"cm",_("Centimeters"))
+                       .add_enum_value(Distance::SYSTEM_MILLIMETERS,"mm",_("Millimeters"));
+
+               widget_enum=manage(new Widget_Enum());
+               widget_enum->set_param_desc(param_desc);
+
+               attach_label(misc_table, _("Unit System"), 1, xpadding, ypadding);
+               misc_table->attach(*widget_enum, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+       }
+
+       // Misc - recent files
+       Gtk::SpinButton* recent_files_spinbutton(manage(new Gtk::SpinButton(adj_recent_files,1,0)));
+       attach_label(misc_table, _("Recent Files"), 2, xpadding, ypadding);
+       misc_table->attach(*recent_files_spinbutton, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+
+       // Misc - use_colorspace_gamma
+       misc_table->attach(toggle_use_colorspace_gamma, 0, 2, 7, 8, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+
+#ifdef SINGLE_THREADED
+       // Misc - single_threaded
+       misc_table->attach(toggle_single_threaded, 0, 2, 10, 11, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+#endif
+
+       // Misc - auto backup interval
+       attach_label(misc_table, _("Auto Backup Interval (0 to disable)"), 3, xpadding, ypadding);
+       misc_table->attach(auto_backup_interval, 1, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+
+       // Misc - restrict_radius_ducks
+       misc_table->attach(toggle_restrict_radius_ducks, 0, 2, 8, 9, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+
+       // Misc - resize_imported_images
+       misc_table->attach(toggle_resize_imported_images, 0, 2, 9, 10, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+
+       // Misc - browser_command
+       attach_label(misc_table, _("Browser Command"), 4, xpadding, ypadding);
+       misc_table->attach(textbox_browser_command, 1, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+
+       // Document
+       Gtk::Table *document_table = manage(new Gtk::Table(2, 4, false));
+       notebook->append_page(*document_table, _("Document"));
+
+       // Document - Preferred file name prefix
+       attach_label(document_table, _("New Document filename prefix"), 0, xpadding, ypadding);
+       document_table->attach(textbox_custom_filename_prefix, 1, 4, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+       tooltips_.set_tip(textbox_custom_filename_prefix, _("File name prefix for the new created document"));
+
+       // Document - New Document X size
+       pref_x_size_spinbutton = Gtk::manage(new Gtk::SpinButton(adj_pref_x_size, 1, 0));
+       attach_label(document_table, _("New Document X size"),1, xpadding, ypadding);
+       document_table->attach(*pref_x_size_spinbutton, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+       tooltips_.set_tip(*pref_x_size_spinbutton, _("Width in pixels of the new created document"));
+
+       // Document - New Document Y size
+       pref_y_size_spinbutton = Gtk::manage(new Gtk::SpinButton(adj_pref_y_size, 1, 0));
+       attach_label(document_table,_("New Document Y size"), 2, xpadding, ypadding);
+       document_table->attach(*pref_y_size_spinbutton, 1, 2, 2, 3,Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+       tooltips_.set_tip(*pref_y_size_spinbutton, _("High in pixels of the new created document"));
+
+       //Document - Template for predefined sizes of canvases.
+       size_template_combo = Gtk::manage(new Gtk::ComboBoxText());
+       Gtk::Label* label(manage(new Gtk::Label(_("Predefined Resolutions:"))));
+       label->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
+       document_table->attach(*label, 2, 3, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+       document_table->attach(*size_template_combo, 2, 3, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+       size_template_combo->signal_changed().connect(sigc::mem_fun(*this, &studio::Dialog_Setup::on_size_template_combo_change));
+       size_template_combo->prepend_text(_("4096x3112 Full Aperture 4K"));
+       size_template_combo->prepend_text(_("2048x1556 Full Aperture Native 2K"));
+       size_template_combo->prepend_text(_("1920x1080 HDTV 1080p/i"));
+       size_template_combo->prepend_text(_("1280x720  HDTV 720p"));
+       size_template_combo->prepend_text(_("720x576   DVD PAL"));
+       size_template_combo->prepend_text(_("720x480   DVD NTSC"));
+       size_template_combo->prepend_text(_("720x540   Web 720x"));
+       size_template_combo->prepend_text(_("720x405   Web 720x HD"));
+       size_template_combo->prepend_text(_("640x480   Web 640x"));
+       size_template_combo->prepend_text(_("640x360   Web 640x HD"));
+       size_template_combo->prepend_text(_("480x360   Web 480x"));
+       size_template_combo->prepend_text(_("480x270   Web 480x HD"));
+       size_template_combo->prepend_text(_("360x270   Web 360x"));
+       size_template_combo->prepend_text(_("360x203   Web 360x HD"));
+       size_template_combo->prepend_text(DEFAULT_PREDEFINED_SIZE);
+
+       //Document - Template for predefined fps
+       fps_template_combo = Gtk::manage(new Gtk::ComboBoxText());
+       Gtk::Label* label1(manage(new Gtk::Label(_("Predefined FPS:"))));
+       label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
+       document_table->attach(*label1, 2, 3, 3, 4, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+       document_table->attach(*fps_template_combo,2, 3, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+       fps_template_combo->signal_changed().connect(sigc::mem_fun(*this, &studio::Dialog_Setup::on_fps_template_combo_change));
+       //Document - Fill the FPS combo box with proper strings (not localised)
+       float f[8];
+       f[0] = 60;
+       f[1] = 50;
+       f[2] = 30;
+       f[3] = 25;
+       f[4] = 24.967;
+       f[5] = 24;
+       f[6] = 15;
+       f[7] = 12;
+       for (int i=0; i<8; i++)
+               fps_template_combo->prepend_text(strprintf("%5.3f", f[i]));
+
+       fps_template_combo->prepend_text(DEFAULT_PREDEFINED_FPS);
+
+       // Document - New Document FPS
+       pref_fps_spinbutton = Gtk::manage(new Gtk::SpinButton(adj_pref_fps, 1, 3));
+       attach_label(document_table,_("New Document FPS"), 4, xpadding, ypadding);
+       document_table->attach(*pref_fps_spinbutton, 1, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+       tooltips_.set_tip(*pref_fps_spinbutton, _("Frames per second of the new created document"));
+
+       show_all_children();
+}
+
+Dialog_Setup::~Dialog_Setup()
+{
+}
+
+void
+Dialog_Setup::on_ok_pressed()
+{
+    on_apply_pressed();
+       hide();
+}
+
+void
+Dialog_Setup::on_apply_pressed()
+{
+       App::gamma.set_all(1.0/adj_gamma_r.get_value(),1.0/adj_gamma_g.get_value(),1.0/adj_gamma_b.get_value(),black_level_selector.get_value(),red_blue_level_selector.get_value());
+
+       App::set_max_recent_files((int)adj_recent_files.get_value());
+
+       // Set the time format
+       App::set_time_format(get_time_format());
+
+       // Set the use_colorspace_gamma flag
+       App::use_colorspace_gamma=toggle_use_colorspace_gamma.get_active();
+
+#ifdef SINGLE_THREADED
+       // Set the single_threaded flag
+       App::single_threaded=toggle_single_threaded.get_active();
+#endif
+
+       // Set the auto backup interval
+       App::auto_recover->set_timeout(auto_backup_interval.get_value() * 1000);
+
+       App::distance_system=Distance::System(widget_enum->get_value());
+
+       // Set the restrict_radius_ducks flag
+       App::restrict_radius_ducks=toggle_restrict_radius_ducks.get_active();
+
+       // Set the resize_imported_images flag
+       App::resize_imported_images=toggle_resize_imported_images.get_active();
+
+       // Set the browser_command textbox
+       App::browser_command=textbox_browser_command.get_text();
+
+       // Set the preferred file name prefix
+       App::custom_filename_prefix=textbox_custom_filename_prefix.get_text();
+
+       // Set the preferred new Document X dimension
+       App::preferred_x_size=int(adj_pref_x_size.get_value());
+
+       // Set the preferred new Document Y dimension
+       App::preferred_y_size=int(adj_pref_y_size.get_value());
+
+       // Set the preferred Predefined size
+       App::predefined_size=size_template_combo->get_active_text();
+
+       // Set the preferred Predefined fps
+       App::predefined_fps=fps_template_combo->get_active_text();
+
+       // Set the preferred FPS
+       App::preferred_fps=Real(adj_pref_fps.get_value());
+
+       App::save_settings();
+}
+
+void
+Dialog_Setup::on_gamma_r_change()
+{
+       gamma_pattern.set_gamma_r(1.0/adj_gamma_r.get_value());
+       gamma_pattern.refresh();
+       gamma_pattern.queue_draw();
+}
+
+void
+Dialog_Setup::on_gamma_g_change()
+{
+       gamma_pattern.set_gamma_g(1.0/adj_gamma_g.get_value());
+       gamma_pattern.refresh();
+       gamma_pattern.queue_draw();
+}
+
+void
+Dialog_Setup::on_gamma_b_change()
+{
+       gamma_pattern.set_gamma_b(1.0/adj_gamma_b.get_value());
+       gamma_pattern.refresh();
+       gamma_pattern.queue_draw();
+}
+
+void
+Dialog_Setup::on_black_level_change()
+{
+       gamma_pattern.set_black_level(black_level_selector.get_value());
+       gamma_pattern.refresh();
+       gamma_pattern.queue_draw();
+}
+
+void
+Dialog_Setup::on_red_blue_level_change()
+{
+       gamma_pattern.set_red_blue_level(red_blue_level_selector.get_value());
+       gamma_pattern.refresh();
+       gamma_pattern.queue_draw();
+}
+
+void
+Dialog_Setup::on_size_template_combo_change()
+{
+       String selection(size_template_combo->get_active_text());
+       if(selection==DEFAULT_PREDEFINED_SIZE)
+       {
+               pref_y_size_spinbutton->set_sensitive(true);
+               pref_x_size_spinbutton->set_sensitive(true);
+               return;
+       }
+       String::size_type locx=selection.find_first_of("x"); // here should be some comparison with string::npos
+       String::size_type locspace=selection.find_first_of(" ");
+       String x_size(selection.substr(0,locx));
+       String y_size(selection.substr(locx+1,locspace));
+       int x=atoi(x_size.c_str());
+       int y=atoi(y_size.c_str());
+       adj_pref_x_size.set_value(x);
+       adj_pref_y_size.set_value(y);
+       pref_y_size_spinbutton->set_sensitive(false);
+       pref_x_size_spinbutton->set_sensitive(false);
+
+       return;
+}
+
+void
+Dialog_Setup::on_fps_template_combo_change()
+{
+       String selection(fps_template_combo->get_active_text());
+       if(selection==DEFAULT_PREDEFINED_FPS)
+       {
+               pref_fps_spinbutton->set_sensitive(true);
+               return;
+       }
+       adj_pref_fps.set_value(atof(selection.c_str()));
+       pref_fps_spinbutton->set_sensitive(false);
+       return;
+}
+
+void
+Dialog_Setup::refresh()
+{
+       // Refresh the temporary gamma; do this before adjusting the sliders,
+       // or variables will be used before their initialization.
+       gamma_pattern.set_gamma_r(App::gamma.get_gamma_r());
+       gamma_pattern.set_gamma_g(App::gamma.get_gamma_g());
+       gamma_pattern.set_gamma_b(App::gamma.get_gamma_b());
+       gamma_pattern.set_black_level(App::gamma.get_black_level());
+       gamma_pattern.set_red_blue_level(App::gamma.get_red_blue_level());
+
+       adj_gamma_r.set_value(1.0/App::gamma.get_gamma_r());
+       adj_gamma_g.set_value(1.0/App::gamma.get_gamma_g());
+       adj_gamma_b.set_value(1.0/App::gamma.get_gamma_b());
+       black_level_selector.set_value(App::gamma.get_black_level());
+       red_blue_level_selector.set_value(App::gamma.get_red_blue_level());
+
+       gamma_pattern.refresh();
+
+       adj_recent_files.set_value(App::get_max_recent_files());
+
+       // Refresh the time format
+       set_time_format(App::get_time_format());
+
+       widget_enum->set_value(App::distance_system);
+
+       // Refresh the status of the use_colorspace_gamma flag
+       toggle_use_colorspace_gamma.set_active(App::use_colorspace_gamma);
+
+#ifdef SINGLE_THREADED
+       // Refresh the status of the single_threaded flag
+       toggle_single_threaded.set_active(App::single_threaded);
+#endif
+
+       // Refresh the value of the auto backup interval
+       auto_backup_interval.set_value(App::auto_recover->get_timeout() / 1000);
+
+       // Refresh the status of the restrict_radius_ducks flag
+       toggle_restrict_radius_ducks.set_active(App::restrict_radius_ducks);
+
+       // Refresh the status of the resize_imported_images flag
+       toggle_resize_imported_images.set_active(App::resize_imported_images);
+
+       // Refresh the browser_command textbox
+       textbox_browser_command.set_text(App::browser_command);
+
+       // Refresh the preferred filename prefix
+       textbox_custom_filename_prefix.set_text(App::custom_filename_prefix);
+
+       // Refresh the preferred new Document X dimension
+       adj_pref_x_size.set_value(App::preferred_x_size);
+
+       // Refresh the preferred new Document Y dimension
+       adj_pref_y_size.set_value(App::preferred_y_size);
+
+       // Refresh the preferred Predefined size
+       size_template_combo->set_active_text(App::predefined_size);
+
+       //Refresh the preferred FPS
+       adj_pref_fps.set_value(App::preferred_fps);
+
+       //Refresh the predefined FPS
+       fps_template_combo->set_active_text(App::predefined_fps);
+}
+
+GammaPattern::GammaPattern():
+       tile_w(80),
+       tile_h(80)
+{
+       set_size_request(tile_w*4,tile_h*3);
+       signal_expose_event().connect(sigc::mem_fun(*this, &studio::GammaPattern::redraw));
+}
+
+GammaPattern::~GammaPattern()
+{
+}
+
+void
+GammaPattern::refresh()
+{
+       black[0].set_rgb_p(
+               r_F32_to_F32(0.0),
+               g_F32_to_F32(0.0),
+               b_F32_to_F32(0.0)
+       );
+       white[0].set_rgb_p(
+               r_F32_to_F32(1.0),
+               g_F32_to_F32(1.0),
+               b_F32_to_F32(1.0)
+       );
+       gray50[0].set_rgb_p(
+               r_F32_to_F32(0.5),
+               g_F32_to_F32(0.5),
+               b_F32_to_F32(0.5)
+       );
+       gray25[0].set_rgb_p(
+               r_F32_to_F32(0.25),
+               g_F32_to_F32(0.25),
+               b_F32_to_F32(0.25)
+       );
+
+       // Reds
+       black[1].set_rgb(black[0].get_red(),0,0);
+       gray25[1].set_rgb(gray25[0].get_red(),0,0);
+       gray50[1].set_rgb(gray50[0].get_red(),0,0);
+       white[1].set_rgb(white[0].get_red(),0,0);
+
+       // Greens
+       black[2].set_rgb(0,black[0].get_green(),0);
+       gray25[2].set_rgb(0,gray25[0].get_green(),0);
+       gray50[2].set_rgb(0,gray50[0].get_green(),0);
+       white[2].set_rgb(0,white[0].get_green(),0);
+
+       // blues
+       black[3].set_rgb(0,0,black[0].get_blue());
+       gray25[3].set_rgb(0,0,gray25[0].get_blue());
+       gray50[3].set_rgb(0,0,gray50[0].get_blue());
+       white[3].set_rgb(0,0,white[0].get_blue());
+}
+
+bool
+GammaPattern::redraw(GdkEventExpose */*bleh*/)
+{
+       static const char hlines[] = { 3, 0 };
+
+       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
+
+       int i;
+       Gdk::Color trueblack("#000000");
+
+       // 50% Pattern
+       for(i=0;i<4;i++)
+       {
+               gc->set_rgb_fg_color(black[i]);
+               get_window()->draw_rectangle(gc, true, i*tile_w, 0, tile_w, tile_h);
+
+               gc->set_stipple(Gdk::Bitmap::create(hlines,2,2));
+               gc->set_fill(Gdk::STIPPLED);
+               gc->set_rgb_fg_color(white[i]);
+               get_window()->draw_rectangle(gc, true, i*tile_w, 0, tile_w, tile_h);
+
+               gc->set_fill(Gdk::SOLID);
+               gc->set_rgb_fg_color(gray50[i]);
+
+               get_window()->draw_rectangle(gc, true, i*tile_w+tile_w/4, tile_h/4, tile_w-tile_w/2, tile_h-tile_h/2);
+       }
+
+       // 25% Pattern
+       for(i=0;i<4;i++)
+       {
+               gc->set_rgb_fg_color(black[i]);
+               get_window()->draw_rectangle(gc, true, i*tile_w, tile_h, tile_w, tile_h);
+
+               gc->set_stipple(Gdk::Bitmap::create(hlines,2,2));
+               gc->set_fill(Gdk::STIPPLED);
+               gc->set_rgb_fg_color(gray50[i]);
+               get_window()->draw_rectangle(gc, true, i*tile_w, tile_h, tile_w, tile_h);
+
+               gc->set_fill(Gdk::SOLID);
+               gc->set_rgb_fg_color(gray25[i]);
+
+               get_window()->draw_rectangle(gc, true, i*tile_w+tile_w/4, tile_h+tile_h/4, tile_w-tile_w/2, tile_h-tile_h/2);
+       }
+
+       // Black-level Pattern
+       gc->set_rgb_fg_color(trueblack);
+       get_window()->draw_rectangle(gc, true, 0, tile_h*2, tile_w*4, tile_h);
+       gc->set_fill(Gdk::SOLID);
+       for(i=0;i<4;i++)
+       {
+               gc->set_rgb_fg_color(black[i]);
+
+               get_window()->draw_rectangle(gc, true, i*tile_w+tile_w/4, tile_h*2+tile_h/4, tile_w-tile_w/2, tile_h-tile_h/2);
+       }
+
+       return true;
+}
+
+
+BlackLevelSelector::BlackLevelSelector()
+{
+       set_size_request(-1,24);
+       signal_expose_event().connect(sigc::mem_fun(*this, &studio::BlackLevelSelector::redraw));
+
+       add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
+       add_events(Gdk::BUTTON1_MOTION_MASK);
+       add_events(Gdk::BUTTON1_MOTION_MASK);
+}
+
+BlackLevelSelector::~BlackLevelSelector()
+{
+}
+
+bool
+BlackLevelSelector::redraw(GdkEventExpose */*bleh*/)
+{
+       const int w(get_width()),h(get_height());
+
+       Gdk::Color color;
+
+       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
+
+       int i;
+
+       // Draw the gradient
+       for(i=0;i<w;i++)
+       {
+               color.set_rgb(i*65536/w,i*65536/w,i*65536/w);
+
+               gc->set_rgb_fg_color(color);
+               get_window()->draw_rectangle(gc, true, i, 0, 1, h);
+       }
+
+       // Draw a frame
+       gc->set_rgb_fg_color(Gdk::Color("#000000"));
+       get_window()->draw_rectangle(gc, false, 0, 0, w-1, h-1);
+
+       // Draw the position of the current value
+       i=(int)(level*w+0.5);
+       gc->set_rgb_fg_color(Gdk::Color("#ff0000"));
+       get_window()->draw_rectangle(gc, true, i, 1, 1, h-1);
+
+       // Print out the value
+       Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_pango_context()));
+       layout->set_text(etl::strprintf("%0.01f%%",level*100.0f));
+       layout->set_alignment(Pango::ALIGN_CENTER);
+       gc->set_rgb_fg_color(Gdk::Color("#a00000"));
+       get_window()->draw_layout(gc, w/2, 4, layout);
+
+       return true;
+}
+
+
+
+bool
+BlackLevelSelector::on_event(GdkEvent *event)
+{
+       int x(round_to_int(event->button.x));
+       //int y(round_to_int(event->button.y));
+
+    switch(event->type)
+    {
+       case GDK_MOTION_NOTIFY:
+               level=(float)x/(float)get_width();
+               if(level<0.0f)level=0.0f;
+               if(level>1.0f)level=1.0f;
+               signal_value_changed_();
+               queue_draw();
+               return true;
+               break;
+       case GDK_BUTTON_PRESS:
+       case GDK_BUTTON_RELEASE:
+               if(event->button.button==1)
+               {
+                       level=(float)x/(float)get_width();
+                       if(level<0.0f)level=0.0f;
+                       if(level>1.0f)level=1.0f;
+                       signal_value_changed_();
+                       queue_draw();
+                       return true;
+               }
+               break;
+       default:
+               break;
+       }
+
+       return false;
+}
+
+
+void
+Dialog_Setup::set_time_format(synfig::Time::Format x)
+{
+       time_format=x;
+       if (x <= Time::FORMAT_VIDEO)
+               timestamp_optionmenu.set_history(0);
+       else if (x == (Time::FORMAT_NORMAL))
+               timestamp_optionmenu.set_history(1);
+       else if (x == (Time::FORMAT_NORMAL | Time::FORMAT_NOSPACES))
+               timestamp_optionmenu.set_history(2);
+       else if (x == (Time::FORMAT_NORMAL | Time::FORMAT_FULL))
+               timestamp_optionmenu.set_history(3);
+       else if (x == (Time::FORMAT_NORMAL | Time::FORMAT_NOSPACES | Time::FORMAT_FULL))
+               timestamp_optionmenu.set_history(4);
+       else if (x == (Time::FORMAT_FRAMES))
+               timestamp_optionmenu.set_history(5);
+       else
+               timestamp_optionmenu.set_history(1);
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+RedBlueLevelSelector::RedBlueLevelSelector()
+{
+       set_size_request(-1,24);
+       signal_expose_event().connect(sigc::mem_fun(*this, &studio::RedBlueLevelSelector::redraw));
+
+       add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
+       add_events(Gdk::BUTTON1_MOTION_MASK);
+       add_events(Gdk::BUTTON1_MOTION_MASK);
+}
+
+RedBlueLevelSelector::~RedBlueLevelSelector()
+{
+}
+
+bool
+RedBlueLevelSelector::redraw(GdkEventExpose */*bleh*/)
+{
+       const int w(get_width()),h(get_height());
+
+       Gdk::Color color;
+
+       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
+
+       int i;
+
+       // Draw the gradient
+       for(i=0;i<w;i++)
+       {
+               float red_blue(((float(i)/float(w)+0.5f)-1.0f)/2.0f+1.0f);
+               float blue_red(2.0f-(red_blue));
+               if(red_blue>1.0f)red_blue=1.0f;
+               if(blue_red>1.0f)blue_red=1.0f;
+
+               color.set_rgb(
+                       round_to_int(min(red_blue,1.0f)*65535),
+                       round_to_int(sqrt(min(red_blue,blue_red))*65535),
+                       round_to_int(min(blue_red,1.0f)*65535)
+               );
+
+               gc->set_rgb_fg_color(color);
+               get_window()->draw_rectangle(gc, true, i, 0, 1, h);
+       }
+
+       // Draw a frame
+       gc->set_rgb_fg_color(Gdk::Color("#000000"));
+       get_window()->draw_rectangle(gc, false, 0, 0, w-1, h-1);
+
+       // Draw the position of the current value
+       i=(int)(((level-1.0f)*2.0f+1.0f-0.5f)*w+0.5);
+       gc->set_rgb_fg_color(Gdk::Color("#00ff00"));
+       get_window()->draw_rectangle(gc, true, i, 1, 1, h-1);
+
+       // Print out the value
+       Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_pango_context()));
+       layout->set_text(etl::strprintf("%0.02f",level));
+       layout->set_alignment(Pango::ALIGN_CENTER);
+       gc->set_rgb_fg_color(Gdk::Color("#a00000"));
+       get_window()->draw_layout(gc, w/2, 4, layout);
+
+       return true;
+}
+
+
+
+bool
+RedBlueLevelSelector::on_event(GdkEvent *event)
+{
+       int x(round_to_int(event->button.x));
+       //int y(round_to_int(event->button.y));
+
+    switch(event->type)
+    {
+       case GDK_MOTION_NOTIFY:
+               level=(((float)(x)/(float)get_width()+0.5)-1.0f)/2.0f+1.0f;
+               if(level<0.5f)level=0.5f;
+               if(level>1.5f)level=1.5f;
+               signal_value_changed_();
+               queue_draw();
+               return true;
+               break;
+       case GDK_BUTTON_PRESS:
+       case GDK_BUTTON_RELEASE:
+               if(event->button.button==1)
+               {
+                       level=(((float)(x)/(float)get_width()+0.5)-1.0f)/2.0f+1.0f;
+                       if(level<0.5f)level=0.5f;
+                       if(level>1.5f)level=1.5f;
+                       signal_value_changed_();
+                       queue_draw();
+                       return true;
+               }
+               break;
+       default:
+               break;
+       }
+
+       return false;
+}
diff --git a/synfig-studio/src/gui/dialog_setup.h b/synfig-studio/src/gui/dialog_setup.h
new file mode 100644 (file)
index 0000000..3d94956
--- /dev/null
@@ -0,0 +1,222 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dialog_setup.h
+**     \brief Template Header
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 2008 Chris Moore
+**     Copyright (c) 2008, 2009 Carlos López
+**
+**     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_DIALOG_SETUP_H
+#define __SYNFIG_STUDIO_DIALOG_SETUP_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtk/gtk.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/table.h>
+#include <gtkmm/button.h>
+#include <gtkmm/dialog.h>
+#include <gtkmm/drawingarea.h>
+#include <gtkmm/optionmenu.h>
+#include <gtkmm/checkbutton.h>
+#include <gui/widget_time.h>
+#include <gtkmm/tooltips.h>
+#include <gtkmm/comboboxtext.h>
+#include <gtkmm/spinbutton.h>
+
+#include <synfig/gamma.h>
+#include <synfig/time.h>
+#include <algorithm>
+
+/* === M A C R O S ========================================================= */
+#ifndef DEFAULT_PREDEFINED_SIZE
+#define DEFAULT_PREDEFINED_SIZE _("Custom Size")
+#endif
+#ifndef DEFAULT_PREDEFINED_FPS
+#define DEFAULT_PREDEFINED_FPS _("Custom fps")
+#endif
+
+/* === T Y P E D E F S ===================================================== */
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+namespace Gtk { class Menu; };
+
+namespace studio {
+
+class GammaPattern : public Gtk::DrawingArea
+{
+       float gamma_r;
+       float gamma_g;
+       float gamma_b;
+       float black_level;
+       float red_blue_level;
+
+       int tile_w, tile_h;
+
+       Gdk::Color black[4],white[4],gray50[4],gray25[4];
+
+       float r_F32_to_F32(float x)const { float f((pow(x,gamma_r)*std::min(red_blue_level,1.0f)*(1.0f-black_level)+black_level)); if(f<0)f=0; if(f>1)f=1; return f; }
+       float g_F32_to_F32(float x)const { float f((pow(x,gamma_g)*sqrt(std::min(2.0f-red_blue_level,red_blue_level))*(1.0f-black_level)+black_level)); if(f<0)f=0; if(f>1)f=1; return f; }
+       float b_F32_to_F32(float x)const { float f((pow(x,gamma_b)*std::min(2.0f-red_blue_level,1.0f)*(1.0f-black_level)+black_level)); if(f<0)f=0; if(f>1)f=1; return f; }
+
+public:
+
+       void refresh();
+
+       void set_gamma_r(float x) { gamma_r=x; }
+       void set_gamma_g(float x) { gamma_g=x; };
+       void set_gamma_b(float x) { gamma_b=x; };
+       void set_black_level(float x) { black_level=x; };
+       void set_red_blue_level(float x) { red_blue_level=x; };
+
+       float get_gamma_r()const { return gamma_r; }
+       float get_gamma_g()const { return gamma_g; }
+       float get_gamma_b()const { return gamma_b; }
+       float get_black_level()const { return black_level; }
+       float get_red_blue_level()const { return red_blue_level; }
+
+       GammaPattern();
+
+       ~GammaPattern();
+
+       bool redraw(GdkEventExpose*bleh=NULL);
+}; // END of class GammaPattern
+
+class BlackLevelSelector : public Gtk::DrawingArea
+{
+       float level;
+
+       sigc::signal<void> signal_value_changed_;
+
+public:
+
+       BlackLevelSelector();
+
+       ~BlackLevelSelector();
+
+       sigc::signal<void>& signal_value_changed() { return signal_value_changed_; }
+
+       void set_value(float x) { level=x; queue_draw(); }
+
+       const float &get_value()const { return level; }
+
+       bool redraw(GdkEventExpose*bleh=NULL);
+
+       bool on_event(GdkEvent *event);
+}; // END of class BlackLevelSelector
+
+class RedBlueLevelSelector : public Gtk::DrawingArea
+{
+       float level;
+
+       sigc::signal<void> signal_value_changed_;
+
+public:
+
+       RedBlueLevelSelector();
+
+       ~RedBlueLevelSelector();
+
+       sigc::signal<void>& signal_value_changed() { return signal_value_changed_; }
+
+       void set_value(float x) { level=x; queue_draw(); }
+
+       const float &get_value()const { return level; }
+
+       bool redraw(GdkEventExpose*bleh=NULL);
+
+       bool on_event(GdkEvent *event);
+}; // END of class RedBlueSelector
+
+class Widget_Enum;
+
+class Dialog_Setup : public Gtk::Dialog
+{
+
+       void on_ok_pressed();
+       void on_apply_pressed();
+
+       void on_gamma_r_change();
+       void on_gamma_g_change();
+       void on_gamma_b_change();
+       void on_black_level_change();
+       void on_red_blue_level_change();
+       void on_size_template_combo_change();
+       void on_fps_template_combo_change();
+
+       GammaPattern gamma_pattern;
+       BlackLevelSelector black_level_selector;
+       RedBlueLevelSelector red_blue_level_selector;
+       Gtk::OptionMenu timestamp_optionmenu;
+
+       Gtk::Adjustment adj_gamma_r;
+       Gtk::Adjustment adj_gamma_g;
+       Gtk::Adjustment adj_gamma_b;
+
+       Gtk::Adjustment adj_recent_files;
+       Gtk::Adjustment adj_undo_depth;
+
+       Gtk::CheckButton toggle_use_colorspace_gamma;
+#ifdef SINGLE_THREADED
+       Gtk::CheckButton toggle_single_threaded;
+#endif
+
+       synfig::Time::Format time_format;
+
+       Gtk::Menu *timestamp_menu;
+       Widget_Enum *widget_enum;
+
+       Widget_Time auto_backup_interval;
+
+       Gtk::CheckButton toggle_restrict_radius_ducks;
+       Gtk::CheckButton toggle_resize_imported_images;
+
+       Gtk::Entry textbox_browser_command;
+
+       Gtk::ComboBoxText* size_template_combo;
+       Gtk::ComboBoxText* fps_template_combo;
+       Gtk::Entry textbox_custom_filename_prefix;
+       Gtk::Adjustment adj_pref_x_size;
+       Gtk::Adjustment adj_pref_y_size;
+       Gtk::Adjustment adj_pref_fps;
+       Gtk::SpinButton* pref_fps_spinbutton;
+       Gtk::SpinButton* pref_y_size_spinbutton;
+       Gtk::SpinButton* pref_x_size_spinbutton;
+       Gtk::Tooltips tooltips_;
+public:
+
+       void set_time_format(synfig::Time::Format time_format);
+
+       const synfig::Time::Format& get_time_format()const { return time_format; }
+
+       Dialog_Setup();
+       ~Dialog_Setup();
+
+    void refresh();
+
+}; // END of Dialog_Waypoint
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/dialog_soundselect.cpp b/synfig-studio/src/gui/dialog_soundselect.cpp
new file mode 100644 (file)
index 0000000..0892616
--- /dev/null
@@ -0,0 +1,129 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dialog_soundselect.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2008 David Roden
+**
+**     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 <config.h>
+#endif
+
+#include "dialog_soundselect.h"
+#include <gtkmm/alignment.h>
+#include <gtkmm/frame.h>
+#include <gtkmm/label.h>
+#include <gtkmm/table.h>
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+/* === E N T R Y P O I N T ================================================= */
+
+studio::Dialog_SoundSelect::Dialog_SoundSelect(Gtk::Window &parent, etl::handle<synfigapp::CanvasInterface> ci)
+:Dialog(_("Sound Select"), parent, false, true),
+canvas_interface(ci)
+{
+       Gtk::Alignment *dialogPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
+       dialogPadding->set_padding(12, 12, 12, 12);
+       get_vbox()->pack_start(*dialogPadding, false, false, 0);
+
+       Gtk::Frame *soundFrame = manage(new Gtk::Frame(_("Sound Parameters")));
+       ((Gtk::Label *) soundFrame->get_label_widget())->set_markup(_("<b>Sound Parameters</b>"));
+       soundFrame->set_shadow_type(Gtk::SHADOW_NONE);
+       dialogPadding->add(*soundFrame);
+
+       Gtk::Alignment *framePadding = manage(new Gtk::Alignment(0, 0, 1, 1));
+       framePadding->set_padding(6, 0, 24, 0);
+       soundFrame->add(*framePadding);
+
+       Gtk::Label *fileLabel = manage(new Gtk::Label(_("_Sound File"), true));
+       fileLabel->set_alignment(0, 0.5);
+       fileLabel->set_mnemonic_widget(soundfile);
+       Gtk::Label *offsetLabel = manage(new Gtk::Label(_("Time _Offset"), true));
+       offsetLabel->set_alignment(0, 0.5);
+       offsetLabel->set_mnemonic_widget(offset);
+
+       Gtk::Table *table = manage(new Gtk::Table(2, 2, false));
+       table->set_row_spacings(6);
+       table->set_col_spacings(12);
+       framePadding->add(*table);
+
+       table->attach(*fileLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::SHRINK | Gtk::FILL, 0, 0);
+       table->attach(soundfile, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK | Gtk::FILL, 0, 0);
+       table->attach(*offsetLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::SHRINK | Gtk::FILL, 0, 0);
+       table->attach(offset, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK | Gtk::FILL, 0, 0);
+
+       okbutton = manage(new Gtk::Button(Gtk::StockID("gtk-ok")));
+       add_action_widget(*okbutton, 0);
+
+       get_vbox()->show_all();
+
+       offset.set_value(0);
+
+       okbutton->signal_clicked().connect(sigc::mem_fun(*this,&Dialog_SoundSelect::on_ok));
+}
+
+studio::Dialog_SoundSelect::~Dialog_SoundSelect()
+{
+}
+
+void studio::Dialog_SoundSelect::on_file()
+{
+       signal_file_changed_(soundfile.get_value());
+}
+
+void studio::Dialog_SoundSelect::on_offset()
+{
+       signal_offset_changed_(offset.get_value());
+}
+
+void studio::Dialog_SoundSelect::on_ok()
+{
+       hide();
+
+       //signal_finish_(a);
+       signal_file_changed_(soundfile.get_value());
+       signal_offset_changed_(offset.get_value());
+}
+
+void studio::Dialog_SoundSelect::set_global_fps(float f)
+{
+       offset.set_fps(f);
+}
diff --git a/synfig-studio/src/gui/dialog_soundselect.h b/synfig-studio/src/gui/dialog_soundselect.h
new file mode 100644 (file)
index 0000000..d23ce93
--- /dev/null
@@ -0,0 +1,86 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dialog_soundselect.h
+**     \brief Sound Select Header
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2008 David Roden
+**
+**     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_DIALOG_SOUNDSELECT_H
+#define __SYNFIG_DIALOG_SOUNDSELECT_H
+
+/* === H E A D E R S ======================================================= */
+#include "dockdialog.h"
+#include "widget_filename.h"
+#include "widget_time.h"
+
+#include <synfigapp/canvasinterface.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 {
+
+struct AudioBaseInfo
+{
+       std::string             file;
+       synfig::Time            offset;
+};
+
+class Dialog_SoundSelect : public Gtk::Dialog
+{
+       Widget_Filename         soundfile;
+       Widget_Time                     offset;
+       Gtk::Button                     *okbutton;
+
+       etl::handle<synfigapp::CanvasInterface> canvas_interface;
+
+       sigc::signal<void,const std::string &>  signal_file_changed_;
+       sigc::signal<void,const synfig::Time &> signal_offset_changed_;
+
+       void on_file();
+       void on_offset();
+       void on_ok();
+
+public:
+       Dialog_SoundSelect(Gtk::Window &parent,etl::handle<synfigapp::CanvasInterface> ci );
+       ~Dialog_SoundSelect();
+
+       //float get_global_fps() const { return globalfps; }
+       void set_global_fps(float f);
+
+       synfig::Time get_offset() const { return offset.get_value(); }
+       void set_offset(const synfig::Time &t) {offset.set_value(t); }
+
+       std::string get_file() const { return soundfile.get_value(); }
+       void set_file(const std::string &f) {soundfile.set_value(f); }
+
+       sigc::signal<void,const std::string &> &signal_file_changed() { return signal_file_changed_; }
+       sigc::signal<void,const synfig::Time &> &signal_offset_changed() { return signal_offset_changed_; }
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/dialog_targetparam.cpp b/synfig-studio/src/gui/dialog_targetparam.cpp
new file mode 100644 (file)
index 0000000..29cce71
--- /dev/null
@@ -0,0 +1,150 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dialog_targetparam.cpp
+**     \brief Implementation for the TargetParam Dialog
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2010 Carlos López González
+**
+**     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 <config.h>
+#endif
+
+#include "dialog_targetparam.h"
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+//! Allowed video codecs
+/*! \warning This variable is linked to allowed_video_codecs_description,
+ *  if you change this you must change the other acordingly.
+ *  \warning These codecs are linked to the filename extensions for
+ *  mod_ffmpeg. If you change this you must change the others acordingly.
+ */
+const char* allowed_video_codecs[] =
+{
+       "flv", "h263p", "huffyuv", "libtheora", "libx264", "libxvid",
+       "mjpeg", "mpeg1video", "mpeg2video", "mpeg4", "msmpeg4",
+       "msmpeg4v1", "msmpeg4v2", "wmv1", "wmv2", NULL
+};
+
+//! Allowed video codecs description.
+/*! \warning This variable is linked to allowed_video_codecs,
+ *  if you change this you must change the other acordingly.
+ */
+const char* allowed_video_codecs_description[] =
+{
+       "Flash Video (FLV) / Sorenson Spark / Sorenson H.263.",
+       "H.263+ / H.263-1998 / H.263 version 2.",
+       "Huffyuv / HuffYUV.",
+       "libtheora Theora.",
+       "libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10.",
+       "libxvidcore MPEG-4 part 2.",
+       "MJPEG (Motion JPEG).",
+       "raw MPEG-1 video.",
+       "raw MPEG-2 video.",
+       "MPEG-4 part 2.",
+       "MPEG-4 part 2 Microsoft variant version 3.",
+       "MPEG-4 part 2 Microsoft variant version 1.",
+       "MPEG-4 part 2 Microsoft variant version 2.",
+       "Windows Media Video 7.",
+       "Windows Media Video 8.",
+       NULL
+};
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+/* === E N T R Y P O I N T ================================================= */
+
+Dialog_TargetParam::Dialog_TargetParam(synfig::TargetParam &tparam)
+{
+       set_title("TargetParam Dialog");
+       set_tparam(tparam);
+       // Available Video Codecs Combo Box Text.
+       vcodec = Gtk::manage(new Gtk::ComboBoxText());
+       Gtk::Label* label(manage(new Gtk::Label(_("Available Video Codecs:"))));
+       label->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
+       get_vbox()->pack_start(*label, true, true, 0);
+       for (int i = 0; allowed_video_codecs[i] != NULL &&
+                                       allowed_video_codecs_description[i] != NULL; i++)
+               vcodec->append_text(allowed_video_codecs_description[i]);
+       for (int i = 0; allowed_video_codecs[i] != NULL &&
+                                       allowed_video_codecs_description[i] != NULL; i++)
+               if(!get_tparam().video_codec.compare(allowed_video_codecs[i]))
+                       vcodec->set_active_text(allowed_video_codecs_description[i]);
+
+       get_vbox()->pack_start(*vcodec, true, true, 0);
+
+       //Bitrate Spin Button
+       Gtk::Adjustment* bradj(manage(new class Gtk::Adjustment(double(tparam.bitrate), 10.0,1000.0)));
+       bitrate = Gtk::manage(new class Gtk::SpinButton(*bradj));
+       Gtk::Label* label2(manage(new Gtk::Label(_("Video Bit Rate:"))));
+       label2->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
+       get_vbox()->pack_start(*label2, true, true, 0);
+       get_vbox()->pack_start(*bitrate,true, true, 0);
+
+       get_vbox()->show_all();
+
+       ok_button = manage(new class Gtk::Button(Gtk::StockID("gtk-ok")));
+       ok_button->show();
+       add_action_widget(*ok_button,Gtk::RESPONSE_OK);
+       ok_button->signal_clicked().connect(sigc::mem_fun(*this,&Dialog_TargetParam::on_ok));
+
+       cancel_button = manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
+       cancel_button->show();
+       add_action_widget(*cancel_button,Gtk::RESPONSE_CANCEL);
+       cancel_button->signal_clicked().connect(sigc::mem_fun(*this,&Dialog_TargetParam::on_cancel));
+
+}
+
+void
+Dialog_TargetParam::on_ok()
+{
+       std::string codecnamed = vcodec->get_active_text();
+       for (int i = 0; allowed_video_codecs[i] != NULL &&
+                                       allowed_video_codecs_description[i] != NULL; i++)
+               if(!codecnamed.compare(allowed_video_codecs_description[i]))
+                       tparam_.video_codec=allowed_video_codecs[i];
+       tparam_.bitrate=bitrate->get_value();
+       hide();
+}
+
+void
+Dialog_TargetParam::on_cancel()
+{
+       hide();
+}
+
+Dialog_TargetParam::~Dialog_TargetParam()
+{
+}
+
diff --git a/synfig-studio/src/gui/dialog_targetparam.h b/synfig-studio/src/gui/dialog_targetparam.h
new file mode 100644 (file)
index 0000000..8fa8cfb
--- /dev/null
@@ -0,0 +1,71 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dialog_targetparam.h
+**     \brief Targetparam Dialog Header
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2010 Carlos López González
+**
+**     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_DIALOG_TARGETPARAM_H
+#define __SYNFIG_STUDIO_DIALOG_TARGETPARAM_H
+
+/* === H E A D E R S ======================================================= */
+#include <gtkmm/dialog.h>
+#include <gtkmm/button.h>
+#include <gtkmm/comboboxtext.h>
+#include <gtkmm/spinbutton.h>
+
+#include <synfig/targetparam.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 Dialog_TargetParam : public Gtk::Dialog
+{
+       synfig::TargetParam tparam_;
+       Gtk::Button *ok_button;
+       Gtk::Button *cancel_button;
+       Gtk::SpinButton *bitrate;
+       Gtk::ComboBoxText *vcodec;
+
+       void on_ok();
+       void on_cancel();
+
+public:
+       Dialog_TargetParam(synfig::TargetParam &tparam);
+       ~Dialog_TargetParam();
+
+       synfig::TargetParam get_tparam() const { return tparam_; }
+       void set_tparam(const synfig::TargetParam &tp) {tparam_=tp; }
+
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
+
+
+
diff --git a/synfig-studio/src/gui/dialog_tooloptions.cpp b/synfig-studio/src/gui/dialog_tooloptions.cpp
new file mode 100644 (file)
index 0000000..da759c8
--- /dev/null
@@ -0,0 +1,97 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dialog_tooloptions.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include <gtkmm/label.h>
+#include <gtkmm/scrolledwindow.h>
+#include <synfig/general.h>
+#include "dialog_tooloptions.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Dialog_ToolOptions::Dialog_ToolOptions():
+       Dockable("tool_options",_("Tool Options"),Gtk::StockID("synfig-about")),
+       empty_label(_("This tool has no options"))
+{
+       add(sub_vbox_);
+
+       set_widget(empty_label);
+       empty_label.show();
+}
+
+Dialog_ToolOptions::~Dialog_ToolOptions()
+{
+}
+
+void
+Dialog_ToolOptions::clear()
+{
+       Dockable::clear();
+       set_local_name(_("Tool Options"));
+       add(sub_vbox_);
+       set_widget(empty_label);
+       empty_label.show();
+
+       set_stock_id(Gtk::StockID("synfig-about"));
+}
+
+void
+Dialog_ToolOptions::set_widget(Gtk::Widget&x)
+{
+       if(!sub_vbox_.children().empty())
+               sub_vbox_.children().clear();
+
+       sub_vbox_.show();
+       sub_vbox_.pack_start(x,false,false);
+       x.show();
+}
+
+void
+Dialog_ToolOptions::set_name(const synfig::String& name)
+{
+       set_stock_id(Gtk::StockID("synfig-"+name));
+}
diff --git a/synfig-studio/src/gui/dialog_tooloptions.h b/synfig-studio/src/gui/dialog_tooloptions.h
new file mode 100644 (file)
index 0000000..69680e0
--- /dev/null
@@ -0,0 +1,62 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dialog_tooloptions.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_DIALOG_TOOLOPTIONS_H
+#define __SYNFIG_STUDIO_DIALOG_TOOLOPTIONS_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/label.h>
+#include <gtkmm/scrolledwindow.h>
+#include "dockable.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 Dialog_ToolOptions : public Dockable
+{
+       Gtk::Label empty_label;
+       Gtk::VBox sub_vbox_;
+
+public:
+
+       void clear();
+       void set_widget(Gtk::Widget&);
+       void set_name(const synfig::String& name);
+
+       Dialog_ToolOptions();
+       ~Dialog_ToolOptions();
+}; // END of Dialog_ToolOptions
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/dialog_waypoint.cpp b/synfig-studio/src/gui/dialog_waypoint.cpp
new file mode 100644 (file)
index 0000000..5fbf61c
--- /dev/null
@@ -0,0 +1,141 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dialog_waypoint.cpp
+**     \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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include <gtkmm/label.h>
+#include "dialog_waypoint.h"
+#include <gtk/gtk.h>
+#include <gtkmm/spinbutton.h>
+#include <gtkmm/combo.h>
+#include <ETL/stringf>
+#include "widget_value.h"
+#include "app.h"
+#include <gtkmm/menu.h>
+#include <gtkmm/optionmenu.h>
+#include "widget_time.h"
+#include "widget_waypoint.h"
+
+#include "general.h"
+
+#endif
+
+using namespace synfig;
+using namespace std;
+using namespace etl;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Dialog_Waypoint::Dialog_Waypoint(Gtk::Window& parent,etl::handle<synfig::Canvas> canvas):
+       Dialog(_("Waypoint Editor"),parent,false,true),
+       canvas(canvas)
+{
+       assert(canvas);
+    waypointwidget=manage(new class Widget_Waypoint(canvas));
+       get_vbox()->pack_start(*waypointwidget);
+
+       Gtk::Button *ok_button(manage(new class Gtk::Button(Gtk::StockID("gtk-ok"))));
+       ok_button->show();
+       add_action_widget(*ok_button,2);
+       ok_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Waypoint::on_ok_pressed));
+
+       Gtk::Button *apply_button(manage(new class Gtk::Button(Gtk::StockID("gtk-apply"))));
+       apply_button->show();
+       add_action_widget(*apply_button,1);
+       apply_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Waypoint::on_apply_pressed));
+
+       Gtk::Button *delete_button(manage(new class Gtk::Button(Gtk::StockID("gtk-delete"))));
+       delete_button->show();
+       add_action_widget(*delete_button,3);
+       delete_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Waypoint::on_delete_pressed));
+
+       Gtk::Button *cancel_button(manage(new class Gtk::Button(Gtk::StockID("gtk-close"))));
+       cancel_button->show();
+       add_action_widget(*cancel_button,0);
+       cancel_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Waypoint::hide));
+
+
+       waypointwidget->show_all();
+}
+
+Dialog_Waypoint::~Dialog_Waypoint()
+{
+}
+
+void
+Dialog_Waypoint::on_ok_pressed()
+{
+       hide();
+    signal_changed_();
+}
+
+void
+Dialog_Waypoint::on_apply_pressed()
+{
+    signal_changed_();
+}
+
+void
+Dialog_Waypoint::on_delete_pressed()
+{
+       hide();
+    signal_delete_();
+}
+
+void
+Dialog_Waypoint::set_waypoint(synfig::ValueNode_Animated::Waypoint x)
+{
+       waypointwidget->set_waypoint(x);
+}
+
+const synfig::ValueNode_Animated::Waypoint &
+Dialog_Waypoint::get_waypoint()const
+{
+       return waypointwidget->get_waypoint();
+}
+
+void
+Dialog_Waypoint::set_value_desc(synfigapp::ValueDesc value_desc)
+{
+       value_desc_=value_desc;
+       if(value_desc.get_value_node() && value_desc.get_value_node()->get_parent_canvas())
+               waypointwidget->set_canvas(value_desc.get_value_node()->get_parent_canvas());
+}
+
+void
+Dialog_Waypoint::reset()
+{
+}
diff --git a/synfig-studio/src/gui/dialog_waypoint.h b/synfig-studio/src/gui/dialog_waypoint.h
new file mode 100644 (file)
index 0000000..bbeab02
--- /dev/null
@@ -0,0 +1,109 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dialog_waypoint.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_GTKMM_DIALOG_WAYPOINT_H
+#define __SYNFIG_GTKMM_DIALOG_WAYPOINT_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtk/gtk.h>
+#include <gtkmm/ruler.h>
+#include <gtkmm/arrow.h>
+#include <gtkmm/image.h>
+#include <gdkmm/pixbufloader.h>
+#include <gtkmm/viewport.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/table.h>
+#include <gtkmm/statusbar.h>
+#include <gtkmm/button.h>
+#include <gtkmm/progressbar.h>
+#include <gtkmm/paned.h>
+#include <gtkmm/treeview.h>
+#include <gtkmm/treestore.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/box.h>
+#include <gtkmm/scrollbar.h>
+#include <gtkmm/cellrenderer.h>
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/menu.h>
+
+
+#include <synfigapp/value_desc.h>
+#include <synfig/valuenode_animated.h>
+#include <synfig/valuenode_dynamiclist.h>
+#include <synfig/string.h>
+#include <synfig/time.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 Widget_ValueBase;
+class Widget_Waypoint;
+
+class Dialog_Waypoint : public Gtk::Dialog
+{
+       Widget_Waypoint *waypointwidget;
+       etl::handle<synfig::Canvas> canvas;
+       synfig::ValueNode_Animated::WaypointList::iterator waypoint;
+       synfigapp::ValueDesc value_desc_;
+
+       sigc::signal<void> signal_changed_;
+
+       sigc::signal<void> signal_delete_;
+       void on_ok_pressed();
+       void on_apply_pressed();
+       void on_delete_pressed();
+
+public:
+       Dialog_Waypoint(Gtk::Window& parent,etl::handle<synfig::Canvas> canvas);
+       ~Dialog_Waypoint();
+
+    void reset();
+
+       void set_value_desc(synfigapp::ValueDesc value_desc);
+       synfigapp::ValueDesc get_value_desc()const { return value_desc_; }
+
+       void set_waypoint(synfig::ValueNode_Animated::Waypoint x);
+       const synfig::ValueNode_Animated::Waypoint &get_waypoint()const;
+
+       sigc::signal<void> &signal_changed()
+       {return signal_changed_; }
+
+       sigc::signal<void> &signal_delete()
+       {return signal_delete_; }
+}; // END of Dialog_Waypoint
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/dialogsettings.cpp b/synfig-studio/src/gui/dialogsettings.cpp
new file mode 100644 (file)
index 0000000..7f38a83
--- /dev/null
@@ -0,0 +1,201 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dialogsettings.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 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 <config.h>
+#endif
+
+#include "dialogsettings.h"
+#include <synfigapp/main.h>
+#include <gdkmm/general.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+DialogSettings::DialogSettings(Gtk::Window* window,const synfig::String& name):
+       window(window),
+       name(name)
+{
+       synfigapp::Main::settings().add_domain(this,"window."+name);
+}
+
+DialogSettings::~DialogSettings()
+{
+       synfigapp::Main::settings().remove_domain("window."+name);
+}
+
+bool
+DialogSettings::get_value(const synfig::String& key, synfig::String& value)const
+{
+       if(key=="pos")
+       {
+               // if(!window->is_visible())return false;
+               int x,y; window->get_position(x,y);
+               value=strprintf("%d %d",x,y);
+               return true;
+       }
+       if(key=="size")
+       {
+               // if(!window->is_visible())return false;
+               int x,y; window->get_size(x,y);
+               value=strprintf("%d %d",x,y);
+               return true;
+       }
+       if(key=="x")
+       {
+               int x,y; window->get_position(x,y);
+               value=strprintf("%d",x);
+               return true;
+       }
+       if(key=="y")
+       {
+               int x,y; window->get_position(x,y);
+               value=strprintf("%d",y);
+               return true;
+       }
+       if(key=="w")
+       {
+               int x,y; window->get_size(x,y);
+               value=strprintf("%d",x);
+               return true;
+       }
+       if(key=="h")
+       {
+               int x,y; window->get_size(x,y);
+               value=strprintf("%d",y);
+               return true;
+       }
+       if(key=="visible")
+       {
+               value=window->is_visible()?"1":"0";
+               return true;
+       }
+
+       return synfigapp::Settings::get_value(key,value);
+}
+
+bool
+DialogSettings::set_value(const synfig::String& key,const synfig::String& value)
+{
+       int screen_w(Gdk::screen_width());
+       int screen_h(Gdk::screen_height());
+
+       if(value.empty())
+               return false;
+
+       if(key=="pos")
+       {
+               int x,y;
+               if(!strscanf(value,"%d %d",&x, &y))
+                       return false;
+
+               if (x > screen_w) x = screen_w - 150; if (x < 0) x = 0;
+               if (y > screen_h) y = screen_h - 150; if (y < 0) y = 0;
+
+               window->move(x,y);
+               return true;
+       }
+       if(key=="size")
+       {
+               int x,y;
+               if(!strscanf(value,"%d %d",&x, &y))
+                       return false;
+
+               if (x > screen_w) x = 150; if (x < 0) x = 0;
+               if (y > screen_h) y = 150; if (y < 0) y = 0;
+
+               window->set_default_size(x,y);
+               return true;
+       }
+       if(key=="x")
+       {
+               int x,y; window->get_position(x,y);
+               x=atoi(value.c_str());
+               window->move(x,y);
+               return true;
+       }
+       if(key=="y")
+       {
+               int x,y; window->get_position(x,y);
+               y=atoi(value.c_str());
+               window->move(x,y);
+               return true;
+       }
+       if(key=="w")
+       {
+               int x,y; window->get_size(x,y);
+               x=atoi(value.c_str());
+               window->set_default_size(x,y);
+               return true;
+       }
+       if(key=="h")
+       {
+               int x,y; window->get_size(x,y);
+               y=atoi(value.c_str());
+               window->set_default_size(x,y);
+               return true;
+       }
+       if(key=="visible")
+       {
+               if(value=="0")
+                       window->hide();
+               else
+                       window->present();
+               return true;
+       }
+
+       return synfigapp::Settings::set_value(key,value);
+}
+
+synfigapp::Settings::KeyList
+DialogSettings::get_key_list()const
+{
+       synfigapp::Settings::KeyList ret(synfigapp::Settings::get_key_list());
+
+       ret.push_back("size");
+       ret.push_back("pos");
+       ret.push_back("visible");
+
+       return ret;
+}
diff --git a/synfig-studio/src/gui/dialogsettings.h b/synfig-studio/src/gui/dialogsettings.h
new file mode 100644 (file)
index 0000000..3a32ed4
--- /dev/null
@@ -0,0 +1,58 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dialogsettings.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_DIALOGSETTINGS_H
+#define __SYNFIG_DIALOGSETTINGS_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <synfigapp/settings.h>
+#include <gtkmm/window.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 DialogSettings : public synfigapp::Settings
+{
+       Gtk::Window* window;
+       synfig::String name;
+public:
+       DialogSettings(Gtk::Window* window,const synfig::String& name);
+       virtual ~DialogSettings();
+
+       virtual bool get_value(const synfig::String& key, synfig::String& value)const;
+       virtual bool set_value(const synfig::String& key,const synfig::String& value);
+       virtual KeyList get_key_list()const;
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/dock_canvases.cpp b/synfig-studio/src/gui/dock_canvases.cpp
new file mode 100644 (file)
index 0000000..f230820
--- /dev/null
@@ -0,0 +1,251 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_canvases.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "dock_canvases.h"
+#include "app.h"
+#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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Dock_Canvases::Dock_Canvases():
+       Dockable("canvases",_("Canvas Browser"),Gtk::StockID("synfig-canvas"))
+{
+
+       App::signal_instance_created().connect(sigc::mem_fun(*this,&studio::Dock_Canvases::new_instance));
+       App::signal_instance_deleted().connect(sigc::mem_fun(*this,&studio::Dock_Canvases::delete_instance));
+       App::signal_instance_selected().connect(sigc::mem_fun(*this,&studio::Dock_Canvases::set_selected_instance_signal));
+
+
+       add(*create_canvas_tree());
+
+/*  // \todo Implement canvas management in canvas browser
+       add_button(
+               Gtk::StockID("synfig-canvas_new"),
+               _("Insert a new canvas")
+       )->signal_clicked().connect(
+               sigc::mem_fun(
+                       *this,
+                       &Dock_Canvases::menu_new_canvas
+               )
+       );
+
+       add_button(
+               Gtk::StockID("gtk-delete"),
+               _("Remove selected canvas")
+       )->signal_clicked().connect(
+               sigc::mem_fun(
+                       *this,
+                       &Dock_Canvases::menu_delete
+               )
+       );
+
+       add_button(
+               Gtk::StockID("synfig-rename"),
+               _("Rename selected canvas")
+       )->signal_clicked().connect(
+               sigc::mem_fun(
+                       *this,
+                       &Dock_Canvases::menu_rename
+               )
+       );
+*/
+}
+
+Dock_Canvases::~Dock_Canvases()
+{
+}
+
+Gtk::Widget*
+Dock_Canvases::create_canvas_tree()
+{
+       studio::Instance::CanvasTreeModel canvas_tree_model;
+       canvas_tree=manage(new class Gtk::TreeView());
+       {
+               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("ID")) );
+//             Gtk::CellRendererPixbuf* icon_cellrenderer = Gtk::manage( new Gtk::CellRendererPixbuf() );
+
+               //column->pack_start(*icon_cellrenderer,false);
+               column->pack_start(canvas_tree_model.icon, false); //false = don't expand.
+               column->pack_start(canvas_tree_model.label);
+
+//#ifdef NDEBUG
+//             column->add_attribute(icon_cellrenderer->property_pixbuf(), canvas_tree_model.icon);
+//#endif
+
+               canvas_tree->append_column(*column);
+       }
+       canvas_tree->set_rules_hint();
+       canvas_tree->signal_row_activated().connect(sigc::mem_fun(*this,&Dock_Canvases::on_row_activate));
+       //canvas_tree->signal_event().connect(sigc::mem_fun(*this,&Dock_Canvases::on_tree_event));
+       canvas_tree->add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
+       canvas_tree->add_events(Gdk::BUTTON1_MOTION_MASK);
+       canvas_tree->show();
+       canvas_tree->set_headers_visible(false);
+
+       Gtk::ScrolledWindow *scrolledwindow = manage(new class Gtk::ScrolledWindow());
+       scrolledwindow->set_flags(Gtk::CAN_FOCUS);
+       scrolledwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+       scrolledwindow->add(*canvas_tree);
+       scrolledwindow->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
+       scrolledwindow->show_all();
+
+       return scrolledwindow;
+}
+
+etl::loose_handle<studio::CanvasView>
+Dock_Canvases::get_selected_canvas_view()
+{
+       return get_selected_instance()->find_canvas_view(get_selected_canvas());
+}
+
+etl::loose_handle<synfig::Canvas>
+Dock_Canvases::get_selected_canvas()
+{
+       Glib::RefPtr<Gtk::TreeSelection> selection=canvas_tree->get_selection();
+
+       if(!selection || !selection->get_selected())
+               return 0;
+
+       studio::Instance::CanvasTreeModel canvas_tree_model;
+
+       return static_cast<etl::handle<synfig::Canvas> >((*selection->get_selected())[canvas_tree_model.canvas]);
+}
+
+
+
+void
+Dock_Canvases::set_selected_instance_signal(etl::handle<studio::Instance> x)
+{
+       set_selected_instance(x);
+}
+
+void
+Dock_Canvases::set_selected_instance_(etl::handle<studio::Instance> instance)
+{
+       if(studio::App::shutdown_in_progress)
+               return;
+
+       selected_instance=instance;
+       if(instance)
+       {
+               canvas_tree->set_model(instance->canvas_tree_store());
+               canvas_tree->show();
+       }
+       else
+       {
+               canvas_tree->set_model(Glib::RefPtr< Gtk::TreeModel >());
+               canvas_tree->hide();
+       }
+}
+
+void
+Dock_Canvases::set_selected_instance(etl::loose_handle<studio::Instance> x)
+{
+       if(studio::App::shutdown_in_progress)
+               return;
+
+       // if it's already selected, don't select it again
+       if (x==selected_instance)
+               return;
+
+       set_selected_instance_(x);
+}
+
+void
+Dock_Canvases::new_instance(etl::handle<studio::Instance> instance)
+{
+       if(studio::App::shutdown_in_progress)
+               return;
+
+       assert(instance);
+
+       etl::loose_handle<studio::Instance> loose_instance(instance);
+
+       instance->synfigapp::Instance::signal_filename_changed().connect(sigc::mem_fun(*this,&Dock_Canvases::refresh_instances));
+       instance->synfigapp::Instance::signal_filename_changed().connect(
+               sigc::bind<etl::loose_handle<studio::Instance> >(
+                       sigc::mem_fun(*this,&Dock_Canvases::set_selected_instance),
+                       loose_instance
+               )
+       );
+
+       present();
+
+}
+
+void
+Dock_Canvases::delete_instance(etl::handle<studio::Instance> instance)
+{
+       if(studio::App::shutdown_in_progress)
+               return;
+
+       refresh_instances();
+
+       if(selected_instance==instance)
+       {
+               set_selected_instance(0);
+       }
+}
+
+void
+Dock_Canvases::refresh_instances()
+{
+       if(studio::App::shutdown_in_progress)
+               return;
+}
+
+void
+Dock_Canvases::on_row_activate(const Gtk::TreeModel::Path &path, Gtk::TreeViewColumn *)
+{
+       assert(get_selected_instance());
+       studio::Instance::CanvasTreeModel canvas_tree_model;
+       const Gtk::TreeRow row = *(get_selected_instance()->canvas_tree_store()->get_iter(path));
+       if(row[canvas_tree_model.is_canvas])
+               get_selected_instance()->focus(row[canvas_tree_model.canvas]);
+       else
+               studio::App::dialog_not_implemented();
+}
diff --git a/synfig-studio/src/gui/dock_canvases.h b/synfig-studio/src/gui/dock_canvases.h
new file mode 100644 (file)
index 0000000..34bdbaa
--- /dev/null
@@ -0,0 +1,88 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_canvases.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_DIALOG_CANVASES_H
+#define __SYNFIG_STUDIO_DIALOG_CANVASES_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "dockable.h"
+#include <gtkmm/treeview.h>
+#include "instance.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 Dock_Canvases : public Dockable
+{
+       Gtk::TreeView *canvas_tree;
+       //Gtk::Menu     menu;
+       etl::loose_handle<studio::Instance>     selected_instance;
+
+private:
+
+       void set_selected_instance_(etl::handle<studio::Instance> x);
+
+       etl::loose_handle<studio::Instance> get_selected_instance() { return selected_instance; }
+
+       etl::loose_handle<synfig::Canvas> get_selected_canvas();
+
+       etl::loose_handle<studio::CanvasView> get_selected_canvas_view();
+
+       void set_selected_instance(etl::loose_handle<studio::Instance> x);
+
+       void set_selected_instance_signal(etl::handle<studio::Instance> x);
+
+       void new_instance(etl::handle<studio::Instance> x);
+
+       void delete_instance(etl::handle<studio::Instance> x);
+
+       void refresh_instances();
+
+       bool close();
+
+       void on_row_activate(const Gtk::TreeModel::Path &path, Gtk::TreeViewColumn *);
+       //bool on_tree_event(GdkEvent *event);
+
+
+
+       void on_action_toggle(const Glib::ustring& path);
+       Gtk::Widget* create_canvas_tree();
+
+public:
+
+       Dock_Canvases();
+       ~Dock_Canvases();
+}; // END of Dock_Canvases
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/dock_canvasspecific.cpp b/synfig-studio/src/gui/dock_canvasspecific.cpp
new file mode 100644 (file)
index 0000000..dc655ef
--- /dev/null
@@ -0,0 +1,175 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_canvasspecific.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "app.h"
+#include "dock_canvasspecific.h"
+
+#include <gtkmm/scrolledwindow.h>
+#include <cassert>
+#include "instance.h"
+#include <sigc++/signal.h>
+#include <sigc++/adaptors/hide.h>
+//#include <sigc++/hide.h>
+#include <sigc++/slot.h>
+#include "metadatatreestore.h"
+#include "canvasview.h"
+#include <ETL/clock>
+
+#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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Dock_CanvasSpecific::Dock_CanvasSpecific(const synfig::String& name,const synfig::String& local_name,Gtk::StockID stock_id_):
+       Dockable(name,local_name,stock_id_)
+{
+       App::signal_instance_created().connect(sigc::mem_fun(*this,&Dock_CanvasSpecific::init_instance));
+}
+
+Dock_CanvasSpecific::~Dock_CanvasSpecific()
+{
+}
+
+etl::loose_handle<studio::CanvasView>
+Dock_CanvasSpecific::get_canvas_view()
+{
+       return App::get_selected_canvas_view();
+}
+
+etl::loose_handle<synfigapp::CanvasInterface>
+Dock_CanvasSpecific::get_canvas_interface()
+{
+       if(get_canvas_view())
+               return get_canvas_view()->canvas_interface();
+       return 0;
+}
+
+void
+Dock_CanvasSpecific::init_canvas_view_vfunc(etl::loose_handle<CanvasView> /*canvas_view*/)
+{
+}
+
+void
+Dock_CanvasSpecific::init_instance_vfunc(etl::loose_handle<Instance> /*instance*/)
+{
+}
+
+void
+Dock_CanvasSpecific::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> /*canvas_view*/)
+{
+}
+
+void
+Dock_CanvasSpecific::init_instance(etl::handle<Instance> instance)
+{
+       etl::clock timer;timer.reset();
+       instance->signal_canvas_view_created().connect(sigc::mem_fun(*this,&Dock_CanvasSpecific::init_canvas_view));
+       init_instance_vfunc(instance);
+       // synfig::info("%s init_instance() took %f seconds",get_local_name().c_str(),float(timer()));
+}
+
+void
+Dock_CanvasSpecific::delete_instance(etl::handle<Instance> /*instance*/)
+{
+       changed_canvas_view_vfunc(0);
+}
+
+void
+Dock_CanvasSpecific::init_canvas_view(CanvasView* canvas_view)
+{
+       /*
+       canvas_view->signal_focus_in_event().connect(
+               sigc::hide(
+                       sigc::bind_return(
+                               sigc::mem_fun(
+                                       *this,
+                                       &Dock_CanvasSpecific::canvas_view_changed
+                               ),
+                               false
+                       )
+               )
+       );
+       */
+       // synfig::info("%s init_canvas_view() Starting init...",get_local_name().c_str());
+       etl::clock timer;timer.reset();
+       App::signal_canvas_view_focus().connect(
+               sigc::hide(
+                       sigc::mem_fun(
+                               *this,
+                               &Dock_CanvasSpecific::canvas_view_changed
+                       )
+               )
+       );
+       init_canvas_view_vfunc(canvas_view);
+       // synfig::info("%s init_canvas_view() took %f seconds",get_local_name().c_str(),float(timer()));
+}
+
+void
+Dock_CanvasSpecific::canvas_view_changed()
+{
+       etl::loose_handle<CanvasView> canvas_view(App::get_selected_canvas_view());
+/*     if(canvas_view)
+       {
+               canvas_delete_connection.disconnect();
+               canvas_delete_connection=canvas_view->signal_deleted().connect(
+                       sigc::bind(
+                               sigc::mem_fun(
+                                       *this,
+                                       &Dock_CanvasSpecific::changed_canvas_view
+                               ),
+                               etl::loose_handle<CanvasView>(0)
+                       )
+               );
+       }
+*/
+
+// #ifdef _DEBUG
+//     synfig::info("%s canvas_view_changed: start",get_local_name().c_str());
+// #endif
+       changed_canvas_view_vfunc(canvas_view);
+// #ifdef _DEBUG
+//     synfig::info("%s canvas_view_changed: end",get_local_name().c_str());
+// #endif
+}
diff --git a/synfig-studio/src/gui/dock_canvasspecific.h b/synfig-studio/src/gui/dock_canvasspecific.h
new file mode 100644 (file)
index 0000000..24efc78
--- /dev/null
@@ -0,0 +1,73 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_canvasspecific.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_DOCK_CANVASSPECIFIC_H
+#define __SYNFIG_STUDIO_DOCK_CANVASSPECIFIC_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "dockable.h"
+#include <gtkmm/treeview.h>
+#include "instance.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 CanvasView;
+class Instance;
+
+class Dock_CanvasSpecific : public Dockable
+{
+       sigc::connection canvas_delete_connection;
+protected:
+       virtual void init_instance_vfunc(etl::loose_handle<Instance> instance);
+
+       virtual void init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
+       virtual void changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
+
+private:
+       void init_canvas_view(CanvasView* canvas_view);
+       void init_instance(etl::handle<Instance> instance);
+       void delete_instance(etl::handle<Instance> instance);
+       void canvas_view_changed();
+       void changed_canvas_view(etl::loose_handle<CanvasView> canvas_view) { return changed_canvas_view_vfunc(canvas_view); }
+public:
+
+       etl::loose_handle<studio::CanvasView> get_canvas_view();
+       etl::loose_handle<synfigapp::CanvasInterface> get_canvas_interface();
+
+       Dock_CanvasSpecific(const synfig::String& name,const synfig::String& local_name,Gtk::StockID stock_id_=Gtk::StockID(" "));
+       virtual ~Dock_CanvasSpecific();
+}; // END of Dock_CanvasSpecific
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/dock_children.cpp b/synfig-studio/src/gui/dock_children.cpp
new file mode 100644 (file)
index 0000000..0b65306
--- /dev/null
@@ -0,0 +1,107 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_children.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \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
+**     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 <config.h>
+#endif
+
+#include "dock_children.h"
+#include "app.h"
+
+#include <gtkmm/scrolledwindow.h>
+#include <cassert>
+#include "instance.h"
+#include <sigc++/signal.h>
+#include <sigc++/hide.h>
+#include <sigc++/retype_return.h>
+#include <sigc++/slot.h>
+#include "childrentreestore.h"
+#include "childrentree.h"
+#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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Dock_Children::Dock_Children():
+       Dock_CanvasSpecific("children",_("Children"),Gtk::StockID("synfig-children"))
+{
+    //! \todo the combination of set_use_scrolled(false) and
+       //!       add(*tree_view) causes crashes when
+       //!       Dockable::prev_widget_ is left referencing a
+       //!       ChildrenTree that has already been destroyed.
+       // set_use_scrolled(false);
+}
+
+Dock_Children::~Dock_Children()
+{
+}
+
+void
+Dock_Children::init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
+{
+       Glib::RefPtr<ChildrenTreeStore> children_tree_store;
+       children_tree_store=ChildrenTreeStore::create(canvas_view->canvas_interface());
+
+       ChildrenTree* children_tree(new ChildrenTree());
+       children_tree->set_model(children_tree_store);
+       children_tree->set_time_adjustment(canvas_view->time_adjustment());
+
+
+       canvas_view->set_tree_model(get_name(),children_tree_store);
+       canvas_view->set_ext_widget(get_name(),children_tree);
+}
+
+void
+Dock_Children::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
+{
+       if(canvas_view)
+       {
+               Gtk::Widget* tree_view(canvas_view->get_ext_widget(get_name()));
+
+               add(*tree_view);
+               tree_view->show();
+       }
+       else clear_previous();
+
+}
diff --git a/synfig-studio/src/gui/dock_children.h b/synfig-studio/src/gui/dock_children.h
new file mode 100644 (file)
index 0000000..a65d3da
--- /dev/null
@@ -0,0 +1,60 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_children.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_DOCK_CHILDREN_H
+#define __SYNFIG_STUDIO_DOCK_CHILDREN_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "dockable.h"
+#include <gtkmm/treeview.h>
+#include "instance.h"
+#include "dock_canvasspecific.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 Dock_Children : public Dock_CanvasSpecific
+{
+protected:
+       virtual void init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
+       virtual void changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
+
+public:
+
+
+       Dock_Children();
+       ~Dock_Children();
+}; // END of Dock_Children
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/dock_curves.cpp b/synfig-studio/src/gui/dock_curves.cpp
new file mode 100644 (file)
index 0000000..142b842
--- /dev/null
@@ -0,0 +1,194 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_curves.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "dock_curves.h"
+#include "app.h"
+
+#include <gtkmm/scrolledwindow.h>
+#include <cassert>
+#include "instance.h"
+#include <sigc++/signal.h>
+#include <sigc++/hide.h>
+#include <sigc++/slot.h>
+#include "canvasview.h"
+#include "layerparamtreestore.h"
+#include "workarea.h"
+#include "widget_curves.h"
+#include "layerparamtreestore.h"
+#include <gtkmm/table.h>
+#include <gtkmm/scrollbar.h>
+#include "widget_timeslider.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Dock_Curves::Dock_Curves():
+       Dock_CanvasSpecific("curves",_("Curves"),Gtk::StockID("synfig-curves"))
+{
+       last_widget_curves_=0;
+       table_=0;
+
+       hscrollbar_=new Gtk::HScrollbar();
+       vscrollbar_=new Gtk::VScrollbar();
+       widget_timeslider_= new Widget_Timeslider();
+}
+
+Dock_Curves::~Dock_Curves()
+{
+       if(table_)delete table_;
+       delete hscrollbar_;
+       delete vscrollbar_;
+       delete widget_timeslider_;
+}
+
+static void
+_curve_selection_changed(Gtk::TreeView* param_tree_view,Widget_Curves* curves)
+{
+       LayerParamTreeStore::Model model;
+       Gtk::TreeIter iter;
+       if(!param_tree_view->get_selection()->count_selected_rows())
+       {
+               curves->clear();
+               curves->refresh();
+               return;
+       }
+
+       std::list<synfigapp::ValueDesc> value_descs;
+
+       iter=param_tree_view->get_selection()->get_selected();
+       value_descs.push_back((*iter)[model.value_desc]);
+       curves->set_value_descs(value_descs);
+}
+
+void
+Dock_Curves::init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
+{
+       Widget_Curves* curves(new Widget_Curves());
+       curves->set_time_adjustment(canvas_view->time_adjustment());
+
+       Gtk::TreeView* param_tree_view(
+               static_cast<Gtk::TreeView*>(canvas_view->get_ext_widget("params"))
+       );
+
+       param_tree_view->get_selection()->signal_changed().connect(
+               sigc::bind(
+                       sigc::bind(
+                               sigc::ptr_fun(
+                                       _curve_selection_changed
+                               ),curves
+                       ),param_tree_view
+               )
+       );
+
+       canvas_view->set_ext_widget(get_name(),curves);
+}
+
+void
+Dock_Curves::refresh_selected_param()
+{
+/*     Gtk::TreeView* tree_view(
+               static_cast<Gtk::TreeView*>(get_canvas_view()->get_ext_widget(get_name()))
+       );
+       Gtk::TreeModel::iterator iter(tree_view->get_selection()->get_selected());
+
+       if(iter)
+       {
+               LayerParamTreeStore::Model model;
+               get_canvas_view()->work_area->set_selected_value_node(
+                       (synfig::ValueNode::Handle)(*iter)[model.value_node]
+               );
+       }
+       else
+       {
+               get_canvas_view()->work_area->set_selected_value_node(0);
+       }
+*/
+}
+
+void
+Dock_Curves::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
+{
+       if(table_)
+       {
+               table_->hide();
+               delete table_;
+               hscrollbar_->unset_adjustment();
+               vscrollbar_->unset_adjustment();
+               //widget_timeslider_->unset_adjustment();
+               table_=0;
+       }
+
+
+       if(canvas_view)
+       {
+               last_widget_curves_=dynamic_cast<Widget_Curves*>(
+                       canvas_view->get_ext_widget(get_name())
+               );
+
+               vscrollbar_->set_adjustment(last_widget_curves_->get_range_adjustment());
+               hscrollbar_->set_adjustment(canvas_view->time_window_adjustment());
+               widget_timeslider_->set_time_adjustment(&canvas_view->time_adjustment());
+               widget_timeslider_->set_bounds_adjustment(&canvas_view->time_window_adjustment());
+               widget_timeslider_->set_global_fps(canvas_view->get_canvas()->rend_desc().get_frame_rate());
+
+               table_=new Gtk::Table(2,2);
+               table_->attach(*widget_timeslider_, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::SHRINK);
+               table_->attach(*last_widget_curves_, 0, 1, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
+               table_->attach(*hscrollbar_, 0, 1, 2, 3, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::SHRINK);
+               table_->attach(*vscrollbar_, 1, 2, 0, 2, Gtk::FILL|Gtk::SHRINK, Gtk::FILL|Gtk::EXPAND);
+               add(*table_);
+
+               //add(*last_widget_curves_);
+               last_widget_curves_->show();
+               table_->show_all();
+               show_all();
+       }
+       else
+       {
+               //clear_previous();
+       }
+}
diff --git a/synfig-studio/src/gui/dock_curves.h b/synfig-studio/src/gui/dock_curves.h
new file mode 100644 (file)
index 0000000..dbe913f
--- /dev/null
@@ -0,0 +1,74 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_curves.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_DOCK_CURVES_H
+#define __SYNFIG_STUDIO_DOCK_CURVES_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "dockable.h"
+#include <gtkmm/treeview.h>
+#include "instance.h"
+#include "dock_canvasspecific.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 Gtk { class Table; class HScrollbar; class VScrollbar; };
+
+namespace studio {
+
+class Widget_Curves;
+class Widget_Timeslider;
+
+class Dock_Curves : public Dock_CanvasSpecific
+{
+       Gtk::Table* table_;
+       Gtk::HScrollbar* hscrollbar_;
+       Gtk::VScrollbar* vscrollbar_;
+
+       Widget_Timeslider* widget_timeslider_;
+       Widget_Curves* last_widget_curves_;
+
+protected:
+       virtual void init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
+       virtual void changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
+
+       void refresh_selected_param();
+
+public:
+
+
+       Dock_Curves();
+       ~Dock_Curves();
+}; // END of Dock_Keyframes
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/dock_history.cpp b/synfig-studio/src/gui/dock_history.cpp
new file mode 100644 (file)
index 0000000..cddf07b
--- /dev/null
@@ -0,0 +1,447 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_history.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 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 <config.h>
+#endif
+
+#include "dock_history.h"
+#include "app.h"
+
+
+
+#include <gtkmm/scrolledwindow.h>
+#include <cassert>
+#include "instance.h"
+#include <sigc++/signal.h>
+#include <sigc++/hide.h>
+#include <sigc++/slot.h>
+#include <synfigapp/action.h>
+#include "historytreestore.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 ========================================================= */
+#define COLUMNID_JUMP          (787584)
+#define ColumnID       int
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Dock_History::Dock_History():
+       Dock_CanvasSpecific("history",_("History"),Gtk::StockID("gtk-undo")),
+       action_group(Gtk::ActionGroup::create("action_group_dock_history"))
+{
+       App::signal_instance_deleted().connect(sigc::mem_fun(*this,&studio::Dock_History::delete_instance));
+       App::signal_instance_selected().connect(sigc::mem_fun(*this,&studio::Dock_History::set_selected_instance_signal));
+
+       action_group->add(Gtk::Action::create(
+               "clear-undo",
+               Gtk::StockID("synfig-clear_undo"),
+               _("Clear Undo Stack"),
+               _("Clear the undo stack")
+       ),
+               sigc::mem_fun(
+                       *this,
+                       &Dock_History::clear_undo
+               )
+       );
+       action_group->add(Gtk::Action::create(
+               "clear-redo",
+               Gtk::StockID("synfig-clear_redo"),
+               _("Clear Redo Stack"),
+               _("Clear the redo stack")
+       ),
+               sigc::mem_fun(
+                       *this,
+                       &Dock_History::clear_redo
+               )
+       );
+       action_group->add(Gtk::Action::create(
+               "clear-undo-and-redo",
+               Gtk::Stock::CLEAR,
+               _("Clear Undo and Redo Stacks"),
+               _("Clear the undo and redo stacks")
+       ),
+               sigc::mem_fun(
+                       *this,
+                       &Dock_History::clear_undo_and_redo
+               )
+       );
+       action_group->add(Gtk::Action::create(
+               "undo",
+               Gtk::StockID("gtk-undo"),
+               _("Undo"),
+               _("Undo the previous action")
+       ),
+               sigc::ptr_fun(studio::App::undo)
+       );
+       action_group->add(Gtk::Action::create(
+               "redo",
+               Gtk::StockID("gtk-redo"),
+               _("Redo"),
+               _("Redo the previously undone action")
+       ),
+               sigc::ptr_fun(studio::App::redo)
+       );
+
+       action_group->add( Gtk::Action::create("toolbar-history", _("History")) );
+       App::ui_manager()->insert_action_group(action_group);
+
+       Glib::ustring ui_info =
+       "<ui>"
+       "       <toolbar action='toolbar-history'>"
+       "       <toolitem action='undo' />"
+       "       <toolitem action='redo' />"
+       "       <toolitem action='clear-undo' />"
+       "       <toolitem action='clear-redo' />"
+       "       <toolitem action='clear-undo-and-redo' />"
+       "       </toolbar>"
+       "</ui>"
+       ;
+
+       App::ui_manager()->add_ui_from_string(ui_info);
+
+       action_group->set_sensitive(false);
+
+       set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-history")));
+       add(*create_action_tree());
+}
+
+Dock_History::~Dock_History()
+{
+}
+
+void
+Dock_History::init_instance_vfunc(etl::loose_handle<Instance> instance)
+{
+       instance->signal_undo_redo_status_changed().connect(
+               sigc::mem_fun(*this,&Dock_History::update_undo_redo)
+       );
+}
+
+Gtk::Widget*
+Dock_History::create_action_tree()
+{
+       studio::HistoryTreeStore::Model history_tree_model;
+       action_tree=manage(new class Gtk::TreeView());
+       {
+               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column("") );
+
+               Gtk::CellRendererToggle* toggle_cr = Gtk::manage( new Gtk::CellRendererToggle() );
+               toggle_cr->signal_toggled().connect(sigc::mem_fun(*this, &studio::Dock_History::on_action_toggle) );
+
+               column->pack_start(*toggle_cr); //false = don't expand.
+               column->add_attribute(toggle_cr->property_active(),history_tree_model.is_active);
+               column->set_resizable();
+               column->set_clickable();
+
+               action_tree->append_column(*column);
+       }
+       /*{
+               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Canvas")) );
+               Gtk::CellRendererText *text_cr=Gtk::manage(new Gtk::CellRendererText());
+               text_cr->property_foreground()=Glib::ustring("#7f7f7f");
+
+               column->pack_start(*text_cr);
+               column->add_attribute(text_cr->property_text(),history_tree_model.canvas_id);
+               column->add_attribute(text_cr->property_foreground_set(),history_tree_model.is_redo);
+
+               action_tree->append_column(*column);
+       }*/
+       {
+               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Jump")) );
+
+               Gtk::CellRendererText* cell_renderer_jump=Gtk::manage(new Gtk::CellRendererText());
+               column->pack_start(*cell_renderer_jump,true);
+
+               cell_renderer_jump->property_text()=_("(JMP)");
+               cell_renderer_jump->property_foreground()="#003a7f";
+
+               column->set_resizable();
+               column->set_clickable();
+
+               column->set_sort_column(COLUMNID_JUMP);
+
+               action_tree->append_column(*column);
+               //column->clicked();
+       }
+       {
+               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Action")) );
+
+               Gtk::CellRendererText *text_cr=Gtk::manage(new Gtk::CellRendererText());
+               text_cr->property_foreground()=Glib::ustring("#7f7f7f");
+
+
+
+               //column->pack_start(history_tree_model.icon, false); //false = don't expand.
+               column->pack_start(*text_cr);
+               column->add_attribute(text_cr->property_text(),history_tree_model.name);
+               column->add_attribute(text_cr->property_foreground_set(),history_tree_model.is_redo);
+
+               action_tree->append_column(*column);
+       }
+
+       action_tree->set_enable_search(true);
+       action_tree->set_search_column(history_tree_model.name);
+       action_tree->set_search_equal_func(sigc::ptr_fun(&studio::HistoryTreeStore::search_func));
+
+       action_tree->set_rules_hint();
+//     action_tree->signal_row_activated().connect(sigc::mem_fun(*this,&Dock_History::on_row_activate));
+       action_tree->signal_event().connect(sigc::mem_fun(*this,&Dock_History::on_action_event));
+//     action_tree->add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
+//     action_tree->add_events(Gdk::BUTTON1_MOTION_MASK);
+       action_tree->show();
+
+       Gtk::ScrolledWindow *scrolledwindow = manage(new class Gtk::ScrolledWindow());
+       scrolledwindow->set_flags(Gtk::CAN_FOCUS);
+       scrolledwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+       scrolledwindow->add(*action_tree);
+       scrolledwindow->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
+       scrolledwindow->show_all();
+
+/*     {
+               Gtk::Widget& widget(*action_tree);
+               Pango::FontDescription font(widget.get_modifier_style()->get_font());
+               font.set_size(Pango::SCALE*5);
+               widget.get_modifier_style()->set_font(font);
+               widget.modify_font(font);
+       }
+*/
+       return scrolledwindow;
+}
+
+void
+Dock_History::clear_undo()
+{
+       if(selected_instance && App::dialog_yes_no(_("Clear History"),
+                       _("You will not be able to undo any changes that you have made!\nAre you sure you want to clear the undo stack?")))
+               selected_instance->clear_undo_stack();
+}
+
+void
+Dock_History::clear_redo()
+{
+       if(selected_instance && App::dialog_yes_no(_("Clear History"),
+                       _("You will not be able to redo any changes that you have made!\nAre you sure you want to clear the redo stack?")))
+               selected_instance->clear_redo_stack();
+}
+
+void
+Dock_History::clear_undo_and_redo()
+{
+       if(selected_instance && App::dialog_yes_no(_("Clear History"),
+                       _("You will not be able to undo or redo any changes that you have made!\nAre you sure you want to clear the undo and redo stacks?")))
+       {
+               selected_instance->clear_undo_stack();
+               selected_instance->clear_redo_stack();
+       }
+}
+
+void
+Dock_History::update_undo_redo()
+{
+       etl::handle<Instance> instance=App::get_selected_instance();
+       if(instance)
+       {
+               action_group->get_action("undo")->set_sensitive(instance->get_undo_status());
+               action_group->get_action("clear-undo")->set_sensitive(instance->get_undo_status());
+               action_group->get_action("redo")->set_sensitive(instance->get_redo_status());
+               action_group->get_action("clear-redo")->set_sensitive(instance->get_redo_status());
+               action_group->get_action("clear-undo-and-redo")->set_sensitive(instance->get_undo_status() || instance->get_redo_status());
+       }
+}
+
+void
+Dock_History::on_undo_tree_changed()
+{
+       Gtk::TreeModel::Children children(selected_instance->history_tree_store()->children());
+
+       if (!children.size())
+               return;
+
+       studio::HistoryTreeStore::Model model;
+
+       Gtk::TreeModel::Children::iterator iter, prev = children.end();
+       for (iter = children.begin(); iter != children.end(); prev = iter++)
+               if ((*iter)[model.is_redo])
+               {
+                       if (prev == children.end())
+                               action_tree->get_selection()->unselect_all();
+                       else
+                       {
+                               action_tree->scroll_to_row(Gtk::TreePath(prev), 0.5);
+                               action_tree->get_selection()->select(prev);
+                       }
+                       return;
+               }
+
+       action_tree->scroll_to_row(Gtk::TreePath(prev), 0.5);
+       action_tree->get_selection()->select(prev);
+}
+
+void
+Dock_History::set_selected_instance_(etl::handle<studio::Instance> instance)
+{
+       if(studio::App::shutdown_in_progress)
+               return;
+
+       if (on_undo_tree_changed_connection)
+               on_undo_tree_changed_connection.disconnect();
+
+       selected_instance=instance;
+       if(instance)
+       {
+               on_undo_tree_changed_connection = selected_instance->history_tree_store()->signal_undo_tree_changed().connect(
+                       sigc::mem_fun(*this,&Dock_History::on_undo_tree_changed));
+
+               action_tree->set_model(instance->history_tree_store());
+               action_tree->show();
+               update_undo_redo();
+               action_group->set_sensitive(true);
+       }
+       else
+       {
+               action_tree->set_model(Glib::RefPtr< Gtk::TreeModel >());
+               action_tree->hide();
+               action_group->set_sensitive(false);
+       }
+}
+
+void
+Dock_History::set_selected_instance_signal(etl::handle<studio::Instance> x)
+{
+       set_selected_instance(x);
+}
+
+void
+Dock_History::set_selected_instance(etl::loose_handle<studio::Instance> x)
+{
+       if(studio::App::shutdown_in_progress)
+               return;
+
+       // if it's already selected, don't select it again
+       if (x==selected_instance)
+               return;
+
+       std::list<etl::handle<studio::Instance> >::iterator iter;
+
+       set_selected_instance_(x);
+}
+
+void
+Dock_History::delete_instance(etl::handle<studio::Instance> instance)
+{
+       if(studio::App::shutdown_in_progress)
+               return;
+
+       if(selected_instance==instance)
+       {
+               set_selected_instance(0);
+       }
+}
+
+bool
+Dock_History::on_action_event(GdkEvent *event)
+{
+       studio::HistoryTreeStore::Model model;
+    switch(event->type)
+    {
+       case GDK_BUTTON_PRESS:
+       case GDK_2BUTTON_PRESS:
+               {
+                       Gtk::TreeModel::Path path;
+                       Gtk::TreeViewColumn *column;
+                       int cell_x, cell_y;
+                       if(!action_tree->get_path_at_pos(
+                               int(event->button.x),int(event->button.y),      // x, y
+                               path, // TreeModel::Path&
+                               column, //TreeViewColumn*&
+                               cell_x,cell_y //int&cell_x,int&cell_y
+                               )
+                       ) break;
+                       const Gtk::TreeRow row = *(action_tree->get_model()->get_iter(path));
+
+                       //signal_user_click()(event->button.button,row,(ColumnID)column->get_sort_column_id());
+                       if((ColumnID)column->get_sort_column_id()==COLUMNID_JUMP)
+                       {
+                               etl::handle<synfigapp::Action::Undoable> action(row[model.action]);
+                               try{
+                               if((bool)row[model.is_undo])
+                               {
+                                       while(get_selected_instance()->undo_action_stack().size() && get_selected_instance()->undo_action_stack().front()!=action)
+                                               if(get_selected_instance()->undo()==false)
+                                                       throw int();
+                               }
+                               else if((bool)row[model.is_redo])
+                               {
+                                       while(get_selected_instance()->redo_action_stack().size() && get_selected_instance()->undo_action_stack().front()!=action)
+                                               if(get_selected_instance()->redo()==false)
+                                                       throw int();
+                               }
+                               }
+                               catch(int)
+                               {
+                                       return true;
+                               }
+                       }
+               }
+
+       case GDK_BUTTON_RELEASE:
+               break;
+       default:
+               break;
+       }
+       return false;
+}
+
+void
+Dock_History::on_action_toggle(const Glib::ustring& path_string)
+{
+       studio::HistoryTreeStore::Model history_tree_model;
+
+       Gtk::TreePath path(path_string);
+
+       const Gtk::TreeRow row = *(selected_instance->history_tree_store()->get_iter(path));
+
+       handle<synfigapp::Action::Undoable> action=row[history_tree_model.action];
+
+       selected_instance->synfigapp::Instance::set_action_status(action,!action->is_active());
+}
diff --git a/synfig-studio/src/gui/dock_history.h b/synfig-studio/src/gui/dock_history.h
new file mode 100644 (file)
index 0000000..00154b2
--- /dev/null
@@ -0,0 +1,90 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_history.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_DIALOG_HISTORY_H
+#define __SYNFIG_STUDIO_DIALOG_HISTORY_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "dockable.h"
+#include <gtkmm/treeview.h>
+#include "instance.h"
+#include <gtkmm/actiongroup.h>
+#include "dock_canvasspecific.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 Dock_History : public Dock_CanvasSpecific
+{
+       Glib::RefPtr<Gtk::ActionGroup> action_group;
+       Gtk::TreeView *action_tree;
+
+       etl::loose_handle<studio::Instance>     selected_instance;
+
+       sigc::connection on_undo_tree_changed_connection;
+
+       void on_undo_tree_changed();
+
+       void set_selected_instance_(etl::handle<studio::Instance> x);
+
+
+       void set_selected_instance(etl::loose_handle<studio::Instance> x);
+
+       void set_selected_instance_signal(etl::handle<studio::Instance> x);
+
+       void delete_instance(etl::handle<studio::Instance> x);
+
+       Gtk::Widget* create_action_tree();
+
+public:
+
+       etl::loose_handle<studio::Instance> get_selected_instance() { return selected_instance; }
+
+       void clear_undo();
+       void clear_redo();
+       void clear_undo_and_redo();
+
+       bool on_action_event(GdkEvent *event);
+       void on_action_toggle(const Glib::ustring& path);
+
+       void update_undo_redo();
+
+       Dock_History();
+       ~Dock_History();
+protected:
+       virtual void init_instance_vfunc(etl::loose_handle<Instance> instance);
+
+}; // END of Dock_History
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/dock_info.cpp b/synfig-studio/src/gui/dock_info.cpp
new file mode 100644 (file)
index 0000000..42c8a82
--- /dev/null
@@ -0,0 +1,144 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_info.cpp
+**     \brief Dock Info File
+**
+**     $Id$
+**
+**     \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
+**     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 <config.h>
+#endif
+
+#include "dock_info.h"
+#include "canvasview.h"
+#include "workarea.h"
+
+#include <synfig/canvas.h>
+#include <synfig/color.h>              // for gamma_in()
+#include <synfig/context.h>
+
+#include <gtkmm/separator.h>
+#include <gtkmm/invisible.h>
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+/* === E N T R Y P O I N T ================================================= */
+
+void studio::Dock_Info::on_mouse_move()
+{
+       Point pos = get_canvas_view()->work_area->get_cursor_pos();
+
+       Distance xv(pos[0],Distance::SYSTEM_UNITS);
+       xv.convert(App::distance_system, get_canvas_view()->get_canvas()->rend_desc());
+
+       Distance yv(pos[1],Distance::SYSTEM_UNITS);
+       yv.convert(App::distance_system, get_canvas_view()->get_canvas()->rend_desc());
+
+       //get the color and set the labels
+
+       x.set_text(xv.get_string(3));
+       y.set_text(yv.get_string(3));
+
+       Color c = get_canvas_view()->get_canvas()->get_context().get_color(pos);
+       float cr = c.get_r(),cg = c.get_g(), cb = c.get_b();
+
+       if(use_colorspace_gamma())
+       {
+               cr = gamma_in(cr);
+               cg = gamma_in(cg);
+               cb = gamma_in(cb);
+       }
+
+       r.set_text(strprintf("%.1f%%",cr*100));
+       g.set_text(strprintf("%.1f%%",cg*100));
+       b.set_text(strprintf("%.1f%%",cb*100));
+       a.set_text(strprintf("%.1f%%",c.get_a()*100));
+}
+
+studio::Dock_Info::Dock_Info()
+:Dock_CanvasSpecific("info",_("Info"),Gtk::StockID("synfig-info"))
+{
+       set_use_scrolled(false);
+
+       Gtk::Table *table = manage(new Gtk::Table);
+
+       //pos labels
+       table->attach(*manage(new Gtk::Label(_("X: "))),0,1,0,2,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
+       table->attach(*manage(new Gtk::Label(_("Y: "))),0,1,2,4,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
+
+       //pos
+       table->attach(x,1,2,0,2,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
+       table->attach(y,1,2,2,4,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
+
+       //separator
+       table->attach(*manage(new Gtk::VSeparator),2,3,0,4,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
+
+       //color label
+       table->attach(*manage(new Gtk::Label(_("R: "))),3,4,0,1,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
+       table->attach(*manage(new Gtk::Label(_("G: "))),3,4,1,2,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
+       table->attach(*manage(new Gtk::Label(_("B: "))),3,4,2,3,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
+       table->attach(*manage(new Gtk::Label(_("A: "))),3,4,3,4,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
+
+       //color
+       table->attach(r,4,5,0,1,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
+       table->attach(g,4,5,1,2,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
+       table->attach(b,4,5,2,3,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
+       table->attach(a,4,5,3,4,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
+
+       table->attach(*manage(new Gtk::Label),0,5,4,5);
+
+       table->show_all();
+
+       add(*table);
+}
+
+studio::Dock_Info::~Dock_Info()
+{
+}
+
+void studio::Dock_Info::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
+{
+       mousecon.disconnect();
+
+       if(canvas_view && canvas_view->get_work_area())
+       {
+               mousecon = get_canvas_view()->work_area->signal_cursor_moved().connect(sigc::mem_fun(*this,&Dock_Info::on_mouse_move));
+       }
+}
diff --git a/synfig-studio/src/gui/dock_info.h b/synfig-studio/src/gui/dock_info.h
new file mode 100644 (file)
index 0000000..4ecd337
--- /dev/null
@@ -0,0 +1,62 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_info.h
+**     \brief Info Dock 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_DOCK_INFO_H
+#define __SYNFIG_DOCK_INFO_H
+
+/* === H E A D E R S ======================================================= */
+#include "dock_canvasspecific.h"
+#include "sigc++/signal.h"
+
+#include "widget_distance.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 Dock_Info : public Dock_CanvasSpecific
+{
+       Gtk::Label  r,g,b,a;
+       Gtk::Label      x,y;
+
+       sigc::connection mousecon;
+
+       void on_mouse_move();
+
+public:
+       Dock_Info();
+       ~Dock_Info();
+
+       virtual void changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/dock_keyframes.cpp b/synfig-studio/src/gui/dock_keyframes.cpp
new file mode 100644 (file)
index 0000000..44e9893
--- /dev/null
@@ -0,0 +1,138 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_keyframes.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "dock_keyframes.h"
+#include "app.h"
+
+#include <gtkmm/scrolledwindow.h>
+#include <cassert>
+#include "instance.h"
+#include <sigc++/signal.h>
+#include <sigc++/hide.h>
+#include <sigc++/slot.h>
+#include "keyframetreestore.h"
+#include "keyframetree.h"
+#include "canvasview.h"
+#include "keyframeactionmanager.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Dock_Keyframes::Dock_Keyframes():
+       Dock_CanvasSpecific("keyframes",_("Keyframes"),Gtk::StockID("synfig-keyframes")),
+       action_group(Gtk::ActionGroup::create("action_group_dock_keyframes")),
+       keyframe_action_manager(new KeyframeActionManager)
+{
+       keyframe_action_manager->set_ui_manager(App::ui_manager());
+       keyframe_action_manager->signal_show_keyframe_properties().connect(
+               sigc::mem_fun(*this,&Dock_Keyframes::show_keyframe_properties)
+       );
+
+    Glib::ustring ui_info =
+       "<ui>"
+       "       <toolbar action='toolbar-keyframe'>"
+       "       <toolitem action='action-KeyframeAdd' />"
+       "       <toolitem action='action-KeyframeDuplicate' />"
+       "       <toolitem action='action-KeyframeRemove' />"
+       "       <toolitem action='keyframe-properties' />"
+       "       </toolbar>"
+       "</ui>"
+       ;
+
+       App::ui_manager()->add_ui_from_string(ui_info);
+
+       set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-keyframe")));
+}
+
+Dock_Keyframes::~Dock_Keyframes()
+{
+}
+
+void
+Dock_Keyframes::show_keyframe_properties()
+{
+       if(get_canvas_view())
+               get_canvas_view()->show_keyframe_dialog();
+}
+
+void
+Dock_Keyframes::init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
+{
+       Glib::RefPtr<KeyframeTreeStore> keyframe_tree_store;
+       keyframe_tree_store=KeyframeTreeStore::create(canvas_view->canvas_interface());
+
+       KeyframeTree* keyframe_tree(new KeyframeTree());
+       keyframe_tree->set_model(keyframe_tree_store);
+       keyframe_tree->set_editable(true);
+
+       canvas_view->set_tree_model(get_name(),keyframe_tree_store);
+       canvas_view->set_ext_widget(get_name(),keyframe_tree);
+}
+
+void
+Dock_Keyframes::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
+{
+       if(canvas_view)
+       {
+               Gtk::Widget* tree_view(canvas_view->get_ext_widget(get_name()));
+
+               add(*tree_view);
+               tree_view->show();
+
+               keyframe_action_manager->set_keyframe_tree(dynamic_cast<KeyframeTree*>(canvas_view->get_ext_widget(get_name())));
+               keyframe_action_manager->set_canvas_interface(canvas_view->canvas_interface());
+               keyframe_action_manager->refresh();
+       }
+       else
+       {
+               clear_previous();
+
+               keyframe_action_manager->set_keyframe_tree(0);
+               keyframe_action_manager->set_canvas_interface(0);
+               keyframe_action_manager->refresh();
+       }
+}
diff --git a/synfig-studio/src/gui/dock_keyframes.h b/synfig-studio/src/gui/dock_keyframes.h
new file mode 100644 (file)
index 0000000..37c99c4
--- /dev/null
@@ -0,0 +1,79 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_keyframes.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_DOCK_KEYFRAMES_H
+#define __SYNFIG_STUDIO_DOCK_KEYFRAMES_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "dockable.h"
+#include "dock_canvasspecific.h"
+#include <gtkmm/treeview.h>
+#include "instance.h"
+#include <gtkmm/actiongroup.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 KeyframeTreeStore;
+class KeyframeTree;
+
+class KeyframeActionManager;
+
+class Dock_Keyframes : public Dock_CanvasSpecific
+{
+       Glib::RefPtr<Gtk::ActionGroup> action_group;
+
+       /*
+       void add_keyframe_pressed();
+       void duplicate_keyframe_pressed();
+       void delete_keyframe_pressed();
+       */
+
+       void show_keyframe_properties();
+
+       KeyframeActionManager* keyframe_action_manager;
+
+protected:
+       virtual void init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
+       virtual void changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
+
+
+public:
+
+
+       Dock_Keyframes();
+       ~Dock_Keyframes();
+}; // END of Dock_Keyframes
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/dock_layergroups.cpp b/synfig-studio/src/gui/dock_layergroups.cpp
new file mode 100644 (file)
index 0000000..d847ff7
--- /dev/null
@@ -0,0 +1,136 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_layergroups.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "dock_layergroups.h"
+#include "app.h"
+
+#include <gtkmm/scrolledwindow.h>
+#include <cassert>
+#include "instance.h"
+#include <sigc++/signal.h>
+#include <sigc++/hide.h>
+#include <sigc++/retype_return.h>
+#include <sigc++/slot.h>
+#include "canvasview.h"
+
+#include "layergrouptreestore.h"
+#include "layergrouptree.h"
+#include "groupactionmanager.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Dock_LayerGroups::Dock_LayerGroups():
+       Dock_CanvasSpecific("groups",_("Groups"),Gtk::StockID("synfig-group")),
+       action_group_group_ops(Gtk::ActionGroup::create("action_group_dock_layergroups")),
+       group_action_manager(new GroupActionManager)
+{
+       group_action_manager->set_ui_manager(App::ui_manager());
+
+       action_group_group_ops->add( Gtk::Action::create("toolbar-groups", _("Group Ops")) );
+
+       action_group_add=Gtk::Action::create("action-group_add", Gtk::Stock::ADD,_("Add a New Group"),_("Add a New Group"));
+       action_group_group_ops->add(action_group_add);
+       action_group_add->set_sensitive(false);
+
+       App::ui_manager()->insert_action_group(action_group_group_ops);
+
+    Glib::ustring ui_info =
+       "<ui>"
+       "       <toolbar action='toolbar-groups'>"
+       "       <toolitem action='action-GroupRemove' />"
+       "       <toolitem action='action-group_add' />"
+       "       </toolbar>"
+       "</ui>"
+       ;
+
+       App::ui_manager()->add_ui_from_string(ui_info);
+
+       set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-groups")));
+}
+
+Dock_LayerGroups::~Dock_LayerGroups()
+{
+       delete group_action_manager;
+}
+
+void
+Dock_LayerGroups::init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
+{
+       Glib::RefPtr<LayerGroupTreeStore> layer_group_tree_store;
+       layer_group_tree_store=LayerGroupTreeStore::create(canvas_view->canvas_interface());
+
+       LayerGroupTree* layer_group_tree(new LayerGroupTree());
+       layer_group_tree->set_model(layer_group_tree_store);
+       layer_group_tree->signal_popup_layer_menu().connect(sigc::mem_fun(*canvas_view,&CanvasView::popup_layer_menu));
+
+       canvas_view->set_tree_model(get_name(),layer_group_tree_store);
+       canvas_view->set_ext_widget(get_name(),layer_group_tree);
+}
+
+void
+Dock_LayerGroups::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
+{
+       if(canvas_view)
+       {
+               Gtk::Widget* tree_view(canvas_view->get_ext_widget(get_name()));
+
+               add(*tree_view);
+               tree_view->show();
+
+               group_action_manager->set_group_tree(dynamic_cast<LayerGroupTree*>(tree_view));
+               group_action_manager->set_canvas_interface(canvas_view->canvas_interface());
+               group_action_manager->refresh();
+       }
+       else
+       {
+               clear_previous();
+               group_action_manager->clear();
+               group_action_manager->set_canvas_interface(0);
+               group_action_manager->set_group_tree(0);
+       }
+}
diff --git a/synfig-studio/src/gui/dock_layergroups.h b/synfig-studio/src/gui/dock_layergroups.h
new file mode 100644 (file)
index 0000000..bdb4f22
--- /dev/null
@@ -0,0 +1,71 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_layergroups.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_DOCK_LAYERGROUPS_H
+#define __SYNFIG_STUDIO_DOCK_LAYERGROUPS_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "dockable.h"
+#include <gtkmm/treeview.h>
+#include "instance.h"
+#include "dock_canvasspecific.h"
+#include <gtkmm/actiongroup.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 Gtk { class HScale; }
+
+namespace studio {
+
+class GroupActionManager ;
+
+class Dock_LayerGroups : public Dock_CanvasSpecific
+{
+       Glib::RefPtr<Gtk::ActionGroup> action_group_group_ops;
+       Glib::RefPtr<Gtk::Action> action_group_add;
+
+       GroupActionManager *group_action_manager;
+protected:
+       virtual void init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
+       virtual void changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
+
+private:
+
+public:
+
+
+       Dock_LayerGroups();
+       ~Dock_LayerGroups();
+}; // END of Dock_LayerGroups
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/dock_layers.cpp b/synfig-studio/src/gui/dock_layers.cpp
new file mode 100644 (file)
index 0000000..2c75e83
--- /dev/null
@@ -0,0 +1,295 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_layers.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 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 <config.h>
+#endif
+
+#include "dock_layers.h"
+#include "app.h"
+
+#include <gtkmm/scrolledwindow.h>
+#include <cassert>
+#include "instance.h"
+#include <sigc++/signal.h>
+#include <sigc++/hide.h>
+#include <sigc++/retype_return.h>
+#include <sigc++/slot.h>
+#include "layertreestore.h"
+#include "layertree.h"
+#include "canvasview.h"
+#include "layeractionmanager.h"
+//#include <ETL/ref_count>
+
+#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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/*static void do_nothing(reference_counter x)
+{
+       synfig::info(__FILE__":%d:ref_count.count()=%d",__LINE__,x.count());
+}*/
+
+/* === M E T H O D S ======================================================= */
+
+Dock_Layers::Dock_Layers():
+       Dock_CanvasSpecific("layers",_("Layers"),Gtk::StockID("synfig-layer")),
+       layer_action_manager(new LayerActionManager)
+{
+       if(layer_action_manager)layer_action_manager->set_ui_manager(App::ui_manager());
+
+       action_group_new_layers=Gtk::ActionGroup::create("action_group_new_layers");
+       action_group_layer_ops=Gtk::ActionGroup::create("action_group_layer_ops");
+
+       std::map<synfig::String,synfig::String> category_map;
+
+       // Build layer creation actions
+       synfig::Layer::Book::iterator iter;
+       for(iter=synfig::Layer::book().begin();iter!=synfig::Layer::book().end();++iter)
+       {
+               synfig::Layer::Book::value_type lyr(*iter);
+
+               if(lyr.second.category==CATEGORY_DO_NOT_USE)
+                       continue;
+
+               action_group_new_layers->add(Gtk::Action::create(
+                       strprintf("layer-new-%s",lyr.first.c_str()),
+                       layer_icon(lyr.first.c_str()),
+                       lyr.second.local_name,lyr.second.local_name
+               ),
+                       sigc::hide_return(
+                               sigc::bind(
+                                       sigc::mem_fun(*this,&studio::Dock_Layers::add_layer),
+                                       lyr.first
+                               )
+                       )
+               );
+
+               category_map[lyr.second.category]+=strprintf("<menuitem action='layer-new-%s' />",lyr.first.c_str());
+
+               //(*category_map)[lyr.second.category]->items().push_back(Gtk::Menu_Helpers::MenuElem(lyr.second.local_name,
+               //));
+       }
+
+       {
+               Glib::RefPtr<Gtk::ActionGroup> action_group_categories(Gtk::ActionGroup::create("layer-category"));
+               synfig::String layer_ui_info;
+
+               layer_ui_info+="<ui><popup action='menu-main'><menu action='menu-layer'><menu action='menu-layer-new'>";
+
+               std::map<synfig::String,synfig::String>::iterator iter;
+               for(iter=category_map.begin();iter!=category_map.end();++iter)
+               {
+                       layer_ui_info+=strprintf("<menu action='%s'>%s</menu>",iter->first.c_str(),iter->second.c_str());
+                       action_group_categories->add(Gtk::Action::create(iter->first.c_str(),dgettext("synfig", iter->first.c_str())));
+               }
+
+               layer_ui_info+="</menu></menu></popup></ui>";
+
+               App::ui_manager()->insert_action_group(action_group_categories);
+               App::ui_manager()->insert_action_group(action_group_new_layers);
+
+               try
+               {
+                       App::ui_manager()->add_ui_from_string(layer_ui_info);
+               }
+               catch(Glib::MarkupError x)
+               {
+                       error("%s:%d caught MarkupError code %d: %s", __FILE__, __LINE__, x.code(), x.what().c_str());
+                       error("%s:%d with markup: \"%s\"", __FILE__, __LINE__, layer_ui_info.c_str());
+                       exit(1);
+               }
+       }
+
+       if(layer_action_manager)
+               action_group_layer_ops->add(layer_action_manager->get_action_select_all_child_layers());
+
+       action_group_layer_ops->add( Gtk::Action::create("toolbar-layer", _("Layer Ops")) );
+       App::ui_manager()->insert_action_group(action_group_layer_ops);
+
+    Glib::ustring ui_info =
+       "<ui>"
+       "       <toolbar action='toolbar-layer'>"
+       "       <toolitem action='action-LayerRaise' />"
+       "       <toolitem action='action-LayerLower' />"
+       "       <separator />"
+       "       <toolitem action='action-LayerDuplicate' />"
+       "       <toolitem action='action-LayerEncapsulate' />"
+       "       <toolitem action='select-all-child-layers' />"
+       "       <toolitem action='action-LayerRemove' />"
+       "       <separator />"
+       "       <toolitem action='cut' />"
+       "       <toolitem action='copy' />"
+       "       <toolitem action='paste' />"
+       "       </toolbar>"
+       "</ui>"
+       ;
+
+       App::ui_manager()->add_ui_from_string(ui_info);
+
+       action_group_new_layers->set_sensitive(false);
+
+       set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-layer")));
+
+
+
+
+
+       /*
+       reference_counter ref_count;
+       synfig::info(__FILE__":%d:ref_count.count()=%d",__LINE__,ref_count.count());
+
+       {
+               sigc::signal<void> tmp_signal;
+
+               tmp_signal.connect(
+                       sigc::bind(
+                               sigc::ptr_fun(do_nothing),
+                               ref_count
+                       )
+               );
+
+       synfig::info(__FILE__":%d:ref_count.count()=%d",__LINE__,ref_count.count());
+               tmp_signal();
+       synfig::info(__FILE__":%d:ref_count.count()=%d",__LINE__,ref_count.count());
+
+               tmp_signal.clear();
+       synfig::info(__FILE__":%d:ref_count.count()=%d",__LINE__,ref_count.count());
+
+               tmp_signal();
+       synfig::info(__FILE__":%d:ref_count.count()=%d",__LINE__,ref_count.count());
+               tmp_signal.connect(
+                       sigc::bind(
+                               sigc::ptr_fun(do_nothing),
+                               ref_count
+                       )
+               );
+       synfig::info(__FILE__":%d:ref_count.count()=%d",__LINE__,ref_count.count());
+       }
+       synfig::info(__FILE__":%d:ref_count.count()=%d",__LINE__,ref_count.count());
+       assert(ref_count.count()==1);
+       */
+}
+
+
+Dock_Layers::~Dock_Layers()
+{
+       delete layer_action_manager;
+}
+
+
+void
+Dock_Layers::init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
+{
+       Glib::RefPtr<LayerTreeStore> layer_tree_store;
+       layer_tree_store=LayerTreeStore::create(canvas_view->canvas_interface());
+
+       canvas_view->set_tree_model(get_name(),layer_tree_store);
+       LayerTree* layer_tree(new LayerTree());
+       layer_tree->set_time_adjustment(canvas_view->time_adjustment());
+
+       layer_tree->signal_edited_value().connect(
+               sigc::hide_return(
+                       sigc::mem_fun(*canvas_view->canvas_interface(), &synfigapp::CanvasInterface::change_value)
+               )
+       );
+
+       // (a) should be before (b), (b) should be before (c)
+       canvas_view->set_ext_widget(get_name()+"_cmp",layer_tree); // (a)
+       canvas_view->set_ext_widget(get_name(),&layer_tree->get_layer_tree_view());
+       canvas_view->set_ext_widget("params",&layer_tree->get_param_tree_view());
+
+       layer_tree->set_model(layer_tree_store); // (b)
+       canvas_view->set_tree_model("params",layer_tree->get_param_tree_view().get_model()); // (c)
+
+       /*
+       canvas_view->layermenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-delete"),Gtk::AccelKey("Delete"),
+               sigc::mem_fun(*layer_tree, &LayerTree::on_delete_pressed))
+       );
+       */
+
+       // Hide the time bar
+       if(canvas_view->get_canvas()->rend_desc().get_time_start()==canvas_view->get_canvas()->rend_desc().get_time_end())
+               canvas_view->hide_timebar();
+       layer_tree_store->rebuild();
+       present();
+}
+
+void
+Dock_Layers::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
+{
+       if(canvas_view)
+       {
+               Gtk::Widget* tree_view(canvas_view->get_ext_widget(get_name()));
+
+               add(*tree_view);
+               tree_view->show();
+               action_group_new_layers->set_sensitive(true);
+               if(layer_action_manager)
+               {
+                       layer_action_manager->set_layer_tree(dynamic_cast<LayerTree*>(canvas_view->get_ext_widget(get_name()+"_cmp")));
+                       layer_action_manager->set_canvas_interface(canvas_view->canvas_interface());
+                       layer_action_manager->refresh();
+               }
+       }
+       else
+       {
+               action_group_new_layers->set_sensitive(false);
+               if(layer_action_manager)
+               {
+                       layer_action_manager->clear();
+                       layer_action_manager->set_canvas_interface(0);
+                       layer_action_manager->set_layer_tree(0);
+               }
+
+               clear_previous();
+       }
+}
+
+void
+Dock_Layers::add_layer(synfig::String id)
+{
+       etl::loose_handle<CanvasView> canvas_view(get_canvas_view());
+       if(canvas_view)
+       {
+               canvas_view->add_layer(id);
+       }
+}
diff --git a/synfig-studio/src/gui/dock_layers.h b/synfig-studio/src/gui/dock_layers.h
new file mode 100644 (file)
index 0000000..b5eda42
--- /dev/null
@@ -0,0 +1,79 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_layers.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_DOCK_LAYERS_H
+#define __SYNFIG_STUDIO_DOCK_LAYERS_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "dockable.h"
+#include <gtkmm/treeview.h>
+#include "instance.h"
+#include "dock_canvasspecific.h"
+#include <gtkmm/actiongroup.h>
+#include <list>
+
+/* === 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 Gtk { class HScale; }
+
+namespace studio {
+
+class LayerActionManager;
+
+class Dock_Layers : public Dock_CanvasSpecific
+{
+       Glib::RefPtr<Gtk::ActionGroup> action_group_new_layers;
+       Glib::RefPtr<Gtk::ActionGroup> action_group_layer_ops;
+
+       Gtk::HScale *layer_amount_hscale;
+
+       LayerActionManager* layer_action_manager;
+
+protected:
+       virtual void init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
+       virtual void changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
+
+private:
+
+       void add_layer(synfig::String id);
+       void increase_amount();
+       void decrease_amount();
+
+public:
+
+
+       Dock_Layers();
+       ~Dock_Layers();
+}; // END of Dock_Layers
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/dock_metadata.cpp b/synfig-studio/src/gui/dock_metadata.cpp
new file mode 100644 (file)
index 0000000..3dce59a
--- /dev/null
@@ -0,0 +1,144 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_metadata.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "dock_metadata.h"
+#include "app.h"
+
+#include <gtkmm/scrolledwindow.h>
+#include <cassert>
+#include "instance.h"
+#include <sigc++/signal.h>
+#include <sigc++/hide.h>
+#include <sigc++/slot.h>
+#include "metadatatreestore.h"
+#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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Dock_MetaData::Dock_MetaData():
+       Dock_CanvasSpecific("meta_data",_("Canvas MetaData"),Gtk::StockID("synfig-meta_data")),
+       tree_view(manage(new Gtk::TreeView()))
+{
+       MetaDataTreeStore::Model model;
+
+       tree_view->append_column(_("Key"),model.key);
+       tree_view->append_column_editable(_("Data"),model.data);
+       tree_view->set_rules_hint();
+
+       Gtk::ScrolledWindow *scrolledwindow = manage(new class Gtk::ScrolledWindow());
+       scrolledwindow->set_flags(Gtk::CAN_FOCUS);
+       scrolledwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+       scrolledwindow->add(*tree_view);
+       scrolledwindow->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
+       scrolledwindow->show();
+
+       add(*scrolledwindow);
+
+       add_button(
+               Gtk::StockID("gtk-add"),
+               _("Add new MetaData entry")
+       )->signal_clicked().connect(
+               sigc::mem_fun(
+                       *this,
+                       &Dock_MetaData::on_add_pressed
+               )
+       );
+
+       add_button(
+               Gtk::StockID("gtk-delete"),
+               _("Remove selected MetaData entry")
+       )->signal_clicked().connect(
+               sigc::mem_fun(
+                       *this,
+                       &Dock_MetaData::on_delete_pressed
+               )
+       );
+}
+
+Dock_MetaData::~Dock_MetaData()
+{
+}
+
+void
+Dock_MetaData::init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
+{
+       canvas_view->set_tree_model(get_name(),MetaDataTreeStore::create(canvas_view->canvas_interface()));
+}
+
+void
+Dock_MetaData::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
+{
+       if(canvas_view)
+       {
+               tree_view->set_model(canvas_view->get_tree_model(get_name()));
+               tree_view->show();
+       }
+       else
+       {
+               tree_view->set_model(Glib::RefPtr<Gtk::TreeModel>());
+               tree_view->hide();
+       }
+}
+
+void
+Dock_MetaData::on_add_pressed()
+{
+       if(get_canvas_interface())
+       {
+               synfig::String key;
+               if(App::dialog_entry(_("New MetaData Entry"), _("Please enter the name of the key"),key) && !key.empty())
+               {
+                       get_canvas_interface()->set_meta_data(key," ");
+               }
+       }
+}
+
+void
+Dock_MetaData::on_delete_pressed()
+{
+}
diff --git a/synfig-studio/src/gui/dock_metadata.h b/synfig-studio/src/gui/dock_metadata.h
new file mode 100644 (file)
index 0000000..285b845
--- /dev/null
@@ -0,0 +1,71 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_metadata.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_DOCK_METADATA_H
+#define __SYNFIG_STUDIO_DOCK_METADATA_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "dockable.h"
+#include <gtkmm/treeview.h>
+#include "instance.h"
+#include "dock_canvasspecific.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 CanvasView;
+class Instance;
+
+class Dock_MetaData : public Dock_CanvasSpecific
+{
+
+       Gtk::TreeView *tree_view;
+
+
+       void on_add_pressed();
+       void on_delete_pressed();
+
+protected:
+
+       virtual void init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
+       virtual void changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
+
+public:
+
+
+       Dock_MetaData();
+       ~Dock_MetaData();
+}; // END of Dock_MetaData
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/dock_navigator.cpp b/synfig-studio/src/gui/dock_navigator.cpp
new file mode 100644 (file)
index 0000000..ad5061e
--- /dev/null
@@ -0,0 +1,522 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_navigator.cpp
+**     \brief Dock Nagivator File
+**
+**     $Id$
+**
+**     \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
+**     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 <config.h>
+#endif
+
+#include "dock_navigator.h"
+#include "canvasview.h"
+#include "workarea.h"
+
+#include <cassert>
+#include <synfig/canvas.h>
+#include <synfig/context.h>
+#include <synfig/target_scanline.h>
+#include <synfig/surface.h>
+
+#include <gtkmm/separator.h>
+
+#include "asyncrenderer.h"
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+
+/* === M A C R O S ========================================================= */
+
+const double log_10_2 = log(2.0);
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+/* === E N T R Y P O I N T ================================================= */
+studio::Widget_NavView::Widget_NavView(CanvasView::LooseHandle cv)
+:canvview(cv),
+adj_zoom(0,-4,4,1,2),
+scrolling(false),
+surface(new synfig::Surface)
+{
+       attach(drawto,0,4,0,1);
+
+       attach(*manage(new Gtk::HSeparator),0,4,1,2,Gtk::SHRINK|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
+
+       //zooming stuff
+       attach(zoom_print,0,1,2,3,Gtk::SHRINK|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
+       zoom_print.set_size_request(40,-1);
+
+       Gtk::HScale *s = manage(new Gtk::HScale(adj_zoom));
+       s->set_draw_value(false);
+       //s->set_update_policy(Gtk::UPDATE_DELAYED);
+       //s->signal_event().connect(sigc::mem_fun(*this,&Dock_Navigator::on_scroll_event));
+       attach(*s,1,4,2,3,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
+
+       show_all();
+
+       adj_zoom.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_NavView::on_number_modify));
+
+       if(cv)
+       {
+               drawto.signal_expose_event().connect(sigc::mem_fun(*this,&Widget_NavView::on_expose_draw));
+               drawto.signal_event().connect(sigc::mem_fun(*this,&Widget_NavView::on_mouse_event));
+
+               drawto.add_events(Gdk::BUTTON_MOTION_MASK|Gdk::BUTTON_PRESS_MASK);
+
+               //get_canvas_view()->canvas_interface()->signal_dirty_preview()
+               //                              .connect(sigc::mem_fun(*this,&Widget_NavView::on_dirty_preview));
+               get_canvas_view()->work_area->signal_rendering()
+                                               .connect(sigc::mem_fun(*this,&Widget_NavView::on_dirty_preview));
+
+               get_canvas_view()->work_area->signal_view_window_changed()
+                                               .connect(sigc::mem_fun(*this,&Widget_NavView::on_workarea_view_change));
+
+               //update with this canvas' view
+               on_workarea_view_change();
+
+               dirty = true;
+               queue_draw();
+       }
+
+       adj_zoom.set_value(0);
+}
+
+studio::Widget_NavView::~Widget_NavView()
+{
+}
+
+
+static void freegu8(const guint8 *p)
+{
+       delete [] p;
+}
+
+void studio::Widget_NavView::on_start_render()
+{
+       if(dirty)
+       {
+               //synfig::warning("Nav: Starting render");
+               //synfig::warning("Nav: Rendering canvas");
+               etl::handle<Target_Scanline>    targ = surface_target(surface.get());
+
+               targ->set_canvas(get_canvas_view()->get_canvas());
+               targ->set_remove_alpha();
+               targ->set_avoid_time_sync();
+               targ->set_quality(get_canvas_view()->get_work_area()->get_quality());
+               //synfig::info("Set the quality level to: %d", get_canvas_view()->get_work_area()->get_quality());
+
+               //this should set it to render a single frame
+               RendDesc        r = get_canvas_view()->get_canvas()->rend_desc();
+               r.set_time(get_canvas_view()->canvas_interface()->get_time());
+
+               //this changes the size of the canvas to the closest thing we can find
+               int sw = r.get_w(), sh = r.get_h();
+
+               //synfig::warning("Nav: source image is %d x %d", sw,sh);
+
+               //resize so largest dimension is 128
+               int dw = sw > sh ? 128 : sw*128/sh,
+                       dh = sh > sw ? 128 : sh*128/sw;
+
+               //synfig::warning("Nav: dest image is %d x %d", dw,dh);
+
+               r.set_w(dw);
+               r.set_h(dh);
+
+               //get the pw and ph
+               //float pw = r.get_pw();
+               //float ph = r.get_ph();
+               //synfig::warning("Nav: pixel size is %f x %f", pw,ph);
+
+               //this renders that single frame
+               targ->set_rend_desc(&r);
+
+               //synfig::warning("Nav: Building async renderer and starting it...");
+
+               renderer = new AsyncRenderer(targ);
+               renderer->signal_success().connect(sigc::mem_fun(*this,&Widget_NavView::on_finish_render));
+               dirty = false;
+               renderer->start();
+       }
+}
+
+void studio::Widget_NavView::on_finish_render()
+{
+       //convert it into our pixmap
+       PixelFormat pf(PF_RGB);
+
+       //synfig::warning("Nav: It hath succeeded!!!");
+
+       //assert(renderer && renderer->has_success());
+       //synfig::warning("Nav: now we know it really succeeded");
+       if(!*surface)
+       {
+               synfig::warning("dock_navigator: Bad surface");
+               return;
+       }
+
+       int w = 0, h = 0;
+       int dw = surface->get_w();
+       int dh = surface->get_h();
+
+       if(prev)
+       {
+               w = prev->get_width();
+               h = prev->get_height();
+       }
+
+       if(w != dw || h != dh || !prev)
+       {
+               const int total_bytes(dw*dh*synfig::channels(pf));
+
+               //synfig::warning("Nav: Updating the pixbuf to be the right size, etc. (%d bytes)", total_bytes);
+
+               prev.clear();
+               guint8 *bytes = new guint8[total_bytes]; //24 bits per pixel
+
+               //convert into our buffered dataS
+               //synfig::warning("Nav: converting color format into buffer");
+               convert_color_format((unsigned char *)bytes, (*surface)[0], dw*dh, pf, App::gamma);
+
+               prev =
+               Gdk::Pixbuf::create_from_data(
+                       bytes,  // pointer to the data
+                       Gdk::COLORSPACE_RGB, // the colorspace
+                       ((pf&PF_A)==PF_A), // has alpha?
+                       8, // bits per sample
+                       dw,     // width
+                       dh,     // height
+                       dw*synfig::channels(pf), // stride (pitch)
+                       sigc::ptr_fun(freegu8)
+               );
+       }
+       else
+       {
+               //synfig::warning("Nav: Don't need to resize");
+               //convert into our buffered dataS
+               //synfig::warning("Nav: converting color format into buffer");
+               if(prev) //just in case we're stupid
+               {
+                       convert_color_format((unsigned char *)prev->get_pixels(), (*surface)[0], dw*dh, pf, App::gamma);
+               }
+       }
+       queue_draw();
+}
+
+/*     zoom slider is on exponential scale
+
+       map: -4,4 -> small number,1600 with 100 at 0
+
+       f(x) = 100*2^x
+*/
+
+static double unit_to_zoom(double f)
+{
+       return pow(2.0,f);
+}
+
+static double zoom_to_unit(double f)
+{
+       if(f > 0)
+       {
+               return log(f) / log_10_2;
+       }else return -999999.0;
+}
+
+bool studio::Widget_NavView::on_expose_draw(GdkEventExpose */*exp*/)
+{
+#ifdef SINGLE_THREADED
+       // don't redraw if the previous redraw is still running single-threaded
+       // or we end up destroying the renderer that's rendering it
+       if (App::single_threaded && renderer && renderer->updating)
+               return false;
+#endif
+
+       //print out the zoom
+       //HACK kind of...
+       //zoom_print.set_text(strprintf("%.1f%%",100*unit_to_zoom(adj_zoom.get_value())));
+
+       //draw the good stuff
+       on_start_render();
+
+       //if we've got a preview etc. display it...
+       if(get_canvas_view() && prev)
+       {
+               //axis transform from units to pixel coords
+               float xaxis = 0, yaxis = 0;
+
+               int canvw = get_canvas_view()->get_canvas()->rend_desc().get_w();
+               //int canvh = get_canvas_view()->get_canvas()->rend_desc().get_h();
+
+               float pw = get_canvas_view()->get_canvas()->rend_desc().get_pw();
+               float ph = get_canvas_view()->get_canvas()->rend_desc().get_ph();
+
+               int w = prev->get_width();
+               int h = prev->get_height();
+
+               //scale up/down to the nearest pixel ratio...
+               //and center in center
+               int offx=0, offy=0;
+
+               float sx, sy;
+               int nw,nh;
+
+               sx = drawto.get_width() / (float)w;
+               sy = drawto.get_height() / (float)h;
+
+               //synfig::warning("Nav redraw: now to scale the bitmap: %.3f x %.3f",sx,sy);
+
+               //round to smallest scale (fit entire thing in window without distortion)
+               if(sx > sy) sx = sy;
+               //else sy = sx;
+
+               //scaling and stuff
+               // the point to navpixel space conversion should be:
+               //              (navpixels / canvpixels) * (canvpixels / canvsize)
+               //      or (navpixels / prevpixels) * (prevpixels / navpixels)
+               xaxis = sx * w / (float)canvw;
+               yaxis = xaxis/ph;
+               xaxis /= pw;
+
+               //scale to a new pixmap and then copy over to the window
+               nw = (int)(w*sx);
+               nh = (int)(h*sx);
+
+               //must now center to be cool
+               offx = (drawto.get_width() - nw)/2;
+               offy = (drawto.get_height() - nh)/2;
+
+               //trivial escape
+               if(nw == 0 || nh == 0)return true;
+
+               //draw to drawing area
+               Glib::RefPtr<Gdk::GC>   gc = Gdk::GC::create(drawto.get_window());
+
+               //synfig::warning("Nav: Scaling pixmap to off (%d,%d) with size (%d,%d)", offx,offy,nw, nh);
+               Glib::RefPtr<Gdk::Pixbuf> scalepx = prev->scale_simple(nw,nh,Gdk::INTERP_NEAREST);
+
+               //synfig::warning("Nav: Drawing scaled bitmap");
+               drawto.get_window()->draw_pixbuf(
+                       gc, //GC
+                       scalepx, //pixbuf
+                       0, 0,   // Source X and Y
+                       offx, offy,     // Dest X and Y
+                       -1,-1,  // Width and Height
+                       Gdk::RGB_DITHER_MAX, // RgbDither
+                       2, 2 // Dither offset X and Y
+               );
+
+               //draw fancy red rectangle around focus point
+               const Point &wtl = get_canvas_view()->work_area->get_window_tl(),
+                                       &wbr = get_canvas_view()->work_area->get_window_br();
+
+               gc->set_rgb_fg_color(Gdk::Color("#ff0000"));
+               gc->set_line_attributes(2,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+
+               //it must be clamped to the drawing area though
+               int l=0,rw=0,t=0,rh=0;
+               const Point fp = -get_canvas_view()->work_area->get_focus_point();
+
+               //get focus point in normal space
+               rw = (int)(abs((wtl[0]-wbr[0])*xaxis));
+               rh = (int)(abs((wtl[1]-wbr[1])*yaxis));
+
+               //transform into pixel space
+               l = (int)(drawto.get_width()/2 + fp[0]*xaxis - rw/2);
+               t = (int)(drawto.get_height()/2 + fp[1]*yaxis - rh/2);
+
+               //coord system:
+               // tl : (offx,offy)
+               // axis multipliers = xaxis,yaxis
+               //synfig::warning("Nav: tl (%f,%f), br (%f,%f)", wtl[0],wtl[1],wbr[0],wbr[1]);
+               //synfig::warning("Nav: tl (%f,%f), br (%f,%f)", wtl[0],wtl[1],wbr[0],wbr[1]);
+               //synfig::warning("Nav: Drawing Rectangle (%d,%d) with dim (%d,%d)", l,t,rw,rh);
+               drawto.get_window()->draw_rectangle(gc,false,l,t,rw,rh);
+       }
+
+       return false; //draw everything else too
+}
+
+void studio::Widget_NavView::on_dirty_preview()
+{
+       dirty = true;
+       queue_draw();
+}
+
+bool studio::Widget_NavView::on_scroll_event(GdkEvent *event)
+{
+       if(get_canvas_view() && get_canvas_view()->get_work_area())
+       {
+               double z = unit_to_zoom(adj_zoom.get_value());
+
+               switch(event->type)
+               {
+                       case GDK_BUTTON_PRESS:
+                       {
+                               if(event->button.button == 1)
+                               {
+                                       scrolling = true;
+                                       get_canvas_view()->get_work_area()->set_zoom(z);
+                                       scrolling = false;
+                               }
+                               break;
+                       }
+
+                       case GDK_MOTION_NOTIFY:
+                       {
+                               if(Gdk::ModifierType(event->motion.state) & Gdk::BUTTON1_MASK)
+                               {
+                                       scrolling = true;
+                                       get_canvas_view()->get_work_area()->set_zoom(z);
+                                       scrolling = false;
+                               }
+                               break;
+                       }
+
+                       default:
+                               break;
+               }
+       }
+
+       return false;
+}
+
+void studio::Widget_NavView::on_number_modify()
+{
+       double z = unit_to_zoom(adj_zoom.get_value());
+       zoom_print.set_text(strprintf("%.1f%%",z*100.0));
+       //synfig::warning("Updating zoom to %f",adj_zoom.get_value());
+
+       if(get_canvas_view() && z != get_canvas_view()->get_work_area()->get_zoom())
+       {
+               scrolling = true;
+               get_canvas_view()->get_work_area()->set_zoom(z);
+               scrolling = false;
+       }
+}
+
+void studio::Widget_NavView::on_workarea_view_change()
+{
+       double wz = get_canvas_view()->get_work_area()->get_zoom();
+       double z = zoom_to_unit(wz);
+
+       //synfig::warning("Updating zoom to %f -> %f",wz,z);
+       if(!scrolling && z != adj_zoom.get_value())
+       {
+               adj_zoom.set_value(z);
+               //adj_zoom.value_changed();
+       }
+       queue_draw();
+}
+
+bool studio::Widget_NavView::on_mouse_event(GdkEvent * e)
+{
+       Point p;
+       bool    setpos = false;
+
+       if(e->type == GDK_BUTTON_PRESS && e->button.button == 1)
+       {
+               p[0] = e->button.x - drawto.get_width()/2;
+               p[1] = e->button.y - drawto.get_height()/2;
+
+               setpos = true;
+       }
+
+       if(e->type == GDK_MOTION_NOTIFY && (Gdk::ModifierType(e->motion.state) & Gdk::BUTTON1_MASK))
+       {
+               p[0] = e->motion.x - drawto.get_width()/2;
+               p[1] = e->motion.y - drawto.get_height()/2;
+
+               setpos = true;
+       }
+
+       if(setpos && prev && get_canvas_view())
+       {
+               const Point &tl = get_canvas_view()->get_canvas()->rend_desc().get_tl();
+               const Point &br = get_canvas_view()->get_canvas()->rend_desc().get_br();
+
+               float max = abs((br[0]-tl[0]) / drawto.get_width());
+
+               if((float(prev->get_width()) / drawto.get_width()) < (float(prev->get_height()) / drawto.get_height()))
+                       max = abs((br[1]-tl[1]) / drawto.get_height());
+
+               float signx = (br[0]-tl[0]) < 0 ? -1 : 1;
+               float signy = (br[1]-tl[1]) < 0 ? -1 : 1;
+
+               Point pos;
+
+               pos[0] = p[0] * max * signx;
+               pos[1] = p[1] * max * signy;
+
+               get_canvas_view()->get_work_area()->set_focus_point(-pos);
+
+               return true;
+       }
+
+       return false;
+}
+
+//Navigator Dock Definitions
+
+studio::Dock_Navigator::Dock_Navigator()
+:Dock_CanvasSpecific("navigator",_("Navigator"),Gtk::StockID("synfig-navigator"))
+{
+       add(dummy);
+}
+
+studio::Dock_Navigator::~Dock_Navigator()
+{
+}
+
+void studio::Dock_Navigator::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
+{
+       if(canvas_view)
+       {
+               Widget *v = canvas_view->get_ext_widget("navview");
+
+               if(!v)
+               {
+                       v = new Widget_NavView(canvas_view);
+                       canvas_view->set_ext_widget("navview",v);
+               }
+
+               add(*v);
+       }else
+       {
+               clear_previous();
+               //add(dummy);
+       }
+}
diff --git a/synfig-studio/src/gui/dock_navigator.h b/synfig-studio/src/gui/dock_navigator.h
new file mode 100644 (file)
index 0000000..95e3fa1
--- /dev/null
@@ -0,0 +1,121 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_navigator.h
+**     \brief Navigator Dock 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_DOCK_NAVIGATOR_H
+#define __SYNFIG_DOCK_NAVIGATOR_H
+
+/* === H E A D E R S ======================================================= */
+#include "sigc++/signal.h"
+
+#include <gtkmm/drawingarea.h>
+#include <gdkmm/pixbuf.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/label.h>
+
+#include <synfig/renddesc.h>
+
+#include "canvasview.h"
+#include "dock_canvasspecific.h"
+#include "widget_distance.h"
+
+#include <ETL/smart_ptr>
+
+/* === 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 AsyncRenderer;
+
+class Widget_NavView : public Gtk::Table
+{
+       //handle to out parent canvas
+       CanvasView::LooseHandle         canvview;
+
+       Glib::RefPtr<Gdk::Pixbuf>       prev;
+       bool dirty;
+
+       //The drawing stuff
+       Gtk::DrawingArea        drawto;
+
+       //The input stuff
+       Gtk::Adjustment         adj_zoom;
+       Gtk::Label                      zoom_print;
+
+       //zoom window stuff
+       bool                            scrolling;
+
+       //asynchronous rendering stuff
+       etl::handle<AsyncRenderer>      renderer;
+       etl::smart_ptr<synfig::Surface> surface;
+       bool                                            rendering;
+
+       //drawing functionality
+       void on_start_render(); //breaks out into asynchronous rendering
+       void on_finish_render();
+       void on_draw(); //renders the small thing we have
+       void on_dirty_preview(); //dirties the preview for rerender
+
+       //for the zoom buttons
+       void on_zoom_in();
+       void on_zoom_out();
+
+       //handles the zoom scroller
+       bool on_scroll_event(GdkEvent *event);
+       void on_number_modify();
+
+       //
+       bool on_mouse_event(GdkEvent * e);
+
+       //draws the gotten bitmap on the draw area
+       bool on_expose_draw(GdkEventExpose *exp=0);
+
+       //for when the canvasview view changes (boolean value scrolling solves cyclic problems)
+       void on_workarea_view_change();
+
+public:
+       Widget_NavView(CanvasView::LooseHandle cv = CanvasView::LooseHandle());
+       ~Widget_NavView();
+
+       etl::loose_handle<studio::CanvasView> get_canvas_view() {return canvview;}
+};
+
+class Dock_Navigator : public Dock_CanvasSpecific
+{
+       Widget_NavView  dummy;
+
+public:
+       Dock_Navigator();
+       ~Dock_Navigator();
+
+       virtual void changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/dock_params.cpp b/synfig-studio/src/gui/dock_params.cpp
new file mode 100644 (file)
index 0000000..7b3d360
--- /dev/null
@@ -0,0 +1,126 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_params.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "dock_params.h"
+#include "app.h"
+
+#include <gtkmm/scrolledwindow.h>
+#include <cassert>
+#include "instance.h"
+#include <sigc++/signal.h>
+#include <sigc++/hide.h>
+#include <sigc++/slot.h>
+#include "canvasview.h"
+#include "layerparamtreestore.h"
+#include "workarea.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Dock_Params::Dock_Params():
+       Dock_CanvasSpecific("params",_("Params"),Gtk::Stock::INDEX/*Gtk::StockID("synfig-params")*/),
+       action_group(Gtk::ActionGroup::create("action_group_dock_params"))
+{
+}
+
+Dock_Params::~Dock_Params()
+{
+}
+
+
+void
+Dock_Params::init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
+{
+       Gtk::TreeView* tree_view(
+               static_cast<Gtk::TreeView*>(canvas_view->get_ext_widget(get_name()))
+       );
+
+       if(tree_view)
+       {
+               tree_view->get_selection()->signal_changed().connect(
+                       sigc::mem_fun(
+                               *this,
+                               &Dock_Params::refresh_selected_param
+                       )
+               );
+       }
+}
+
+void
+Dock_Params::refresh_selected_param()
+{
+       Gtk::TreeView* tree_view(
+               static_cast<Gtk::TreeView*>(get_canvas_view()->get_ext_widget(get_name()))
+       );
+       Gtk::TreeModel::iterator iter(tree_view->get_selection()->get_selected());
+
+       if(iter)
+       {
+               LayerParamTreeStore::Model model;
+               get_canvas_view()->work_area->set_selected_value_node(
+                       (synfig::ValueNode::Handle)(*iter)[model.value_node]
+               );
+       }
+       else
+       {
+               get_canvas_view()->work_area->set_selected_value_node(0);
+       }
+}
+
+void
+Dock_Params::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
+{
+       if(canvas_view)
+       {
+               Gtk::Widget* tree_view(canvas_view->get_ext_widget(get_name()));
+
+               add(*tree_view);
+               tree_view->show();
+               show_all();
+       }
+       else clear_previous();
+}
diff --git a/synfig-studio/src/gui/dock_params.h b/synfig-studio/src/gui/dock_params.h
new file mode 100644 (file)
index 0000000..7ad9f61
--- /dev/null
@@ -0,0 +1,64 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_params.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_DOCK_PARAMS_H
+#define __SYNFIG_STUDIO_DOCK_PARAMS_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "dockable.h"
+#include <gtkmm/treeview.h>
+#include "instance.h"
+#include "dock_canvasspecific.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 Dock_Params : public Dock_CanvasSpecific
+{
+       Glib::RefPtr<Gtk::ActionGroup> action_group;
+
+protected:
+       virtual void init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
+       virtual void changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
+
+       void refresh_selected_param();
+
+public:
+
+
+       Dock_Params();
+       ~Dock_Params();
+}; // END of Dock_Keyframes
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/dock_timetrack.cpp b/synfig-studio/src/gui/dock_timetrack.cpp
new file mode 100644 (file)
index 0000000..29105e4
--- /dev/null
@@ -0,0 +1,494 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_timetrack.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 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 <config.h>
+#endif
+
+#include "dock_timetrack.h"
+#include "app.h"
+
+#include <gtkmm/scrolledwindow.h>
+#include <cassert>
+#include "instance.h"
+#include <sigc++/signal.h>
+#include <sigc++/hide.h>
+#include <sigc++/slot.h>
+#include "canvasview.h"
+#include "layerparamtreestore.h"
+#include "workarea.h"
+#include "widget_timeslider.h"
+#include "widget_keyframe_list.h"
+#include "layerparamtreestore.h"
+#include "general.h"
+#include <synfig/timepointcollect.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 ========================================================= */
+
+/* === C L A S S E S ======================================================= */
+
+class TimeTrackView : public Gtk::TreeView
+{
+       CellRenderer_TimeTrack *cellrenderer_time_track;
+
+       Glib::RefPtr<LayerParamTreeStore> param_tree_store_;
+
+       Gtk::TreeView *mimic_tree_view;
+public:
+
+       sigc::signal<void,synfigapp::ValueDesc,std::set<synfig::Waypoint, std::less<UniqueID> >,int> signal_waypoint_clicked_timetrackview;
+
+       LayerParamTreeStore::Model model;
+
+       void set_canvas_view(handle<CanvasView> canvas_view)
+       {
+               cellrenderer_time_track->set_adjustment(canvas_view->time_adjustment());
+       }
+
+       TimeTrackView()
+       {
+               int label_index(append_column_editable(_("Name"),model.label));
+               Gtk::TreeView::Column* label_column = get_column(label_index-1);
+
+               {       // --- T I M E   T R A C K --------------------------------------------
+                       Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Time Track")) );
+
+                       // Set up the value-node cell-renderer
+                       cellrenderer_time_track=LayerParamTreeStore::add_cell_renderer_value_node(column);
+                       cellrenderer_time_track->property_mode()=Gtk::CELL_RENDERER_MODE_ACTIVATABLE;
+                       cellrenderer_time_track->signal_waypoint_clicked_cellrenderer().connect(sigc::mem_fun(*this, &TimeTrackView::on_waypoint_clicked_timetrackview));
+                       cellrenderer_time_track->signal_waypoint_changed().connect(sigc::mem_fun(*this, &TimeTrackView::on_waypoint_changed) );
+                       column->add_attribute(cellrenderer_time_track->property_value_desc(), model.value_desc);
+                       column->add_attribute(cellrenderer_time_track->property_canvas(), model.canvas);
+                       //column->add_attribute(cellrenderer_time_track->property_visible(), model.is_value_node);
+
+                       //column->pack_start(*cellrenderer_time_track);
+
+                       // Finish setting up the column
+                       column->set_reorderable();
+                       column->set_resizable();
+                       column->set_min_width(200);
+
+                       append_column(*column);
+               }
+               set_rules_hint();
+
+               set_expander_column(*label_column);
+               label_column->set_visible(false);
+               set_headers_visible(false);
+               set_size_request(-1,64);
+       }
+
+       bool
+       on_event(GdkEvent *event)
+       {
+               switch(event->type)
+               {
+               case GDK_SCROLL:
+                       if(mimic_tree_view)
+                       {
+                               if(event->scroll.direction==GDK_SCROLL_DOWN)
+                               {
+                                       mimic_tree_view->get_vadjustment()->set_value(
+                                               std::min(
+                                                       mimic_tree_view->get_vadjustment()->get_value()+
+                                                       mimic_tree_view->get_vadjustment()->get_step_increment(),
+                                                       mimic_tree_view->get_vadjustment()->get_upper()-
+                                                       mimic_tree_view->get_vadjustment()->get_page_size()
+                                               )
+                                       );
+                                       mimic_tree_view->get_vadjustment()->value_changed();
+                               }
+                               else if(event->scroll.direction==GDK_SCROLL_UP)
+                               {
+                                       mimic_tree_view->get_vadjustment()->set_value(
+                                               std::max(
+                                                       mimic_tree_view->get_vadjustment()->get_value()-
+                                                       mimic_tree_view->get_vadjustment()->get_step_increment(),
+                                                       mimic_tree_view->get_vadjustment()->get_lower()
+                                               )
+                                       );
+                                       mimic_tree_view->get_vadjustment()->value_changed();
+                               }
+                       }
+                       break;
+               case GDK_BUTTON_PRESS:
+                       {
+                               Gtk::TreeModel::Path path;
+                               Gtk::TreeViewColumn *column;
+                               int cell_x, cell_y;
+                               if(!get_path_at_pos(
+                                       int(event->button.x),int(event->button.y),      // x, y
+                                       path, // TreeModel::Path&
+                                       column, //TreeViewColumn*&
+                                       cell_x,cell_y //int&cell_x,int&cell_y
+                                       )
+                               ) break;
+                               const Gtk::TreeRow row = *(get_model()->get_iter(path));
+
+                               if(column && column->get_first_cell_renderer()==cellrenderer_time_track)
+                               {
+                                       Gdk::Rectangle rect;
+                                       get_cell_area(path,*column,rect);
+                                       cellrenderer_time_track->property_value_desc()=row[model.value_desc];
+                                       cellrenderer_time_track->property_canvas()=row[model.canvas];
+                                       cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
+                                       queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
+                                       return true;
+                                       //return signal_param_user_click()(event->button.button,row,COLUMNID_TIME_TRACK);
+                               }
+                       }
+                       break;
+
+               case GDK_MOTION_NOTIFY:
+                       {
+                               Gtk::TreeModel::Path path;
+                               Gtk::TreeViewColumn *column;
+                               int cell_x, cell_y;
+                               if(!get_path_at_pos(
+                                       (int)event->motion.x,(int)event->motion.y,      // x, y
+                                       path, // TreeModel::Path&
+                                       column, //TreeViewColumn*&
+                                       cell_x,cell_y //int&cell_x,int&cell_y
+                                       )
+                               ) break;
+
+                               if(!get_model()->get_iter(path))
+                                       break;
+
+                               Gtk::TreeRow row = *(get_model()->get_iter(path));
+
+                               if ((event->motion.state&GDK_BUTTON1_MASK || event->motion.state&GDK_BUTTON3_MASK) &&
+                                       column &&
+                                       cellrenderer_time_track == column->get_first_cell_renderer())
+                               {
+                                       Gdk::Rectangle rect;
+                                       get_cell_area(path,*column,rect);
+                                       cellrenderer_time_track->property_value_desc()=row[model.value_desc];
+                                       cellrenderer_time_track->property_canvas()=row[model.canvas];
+                                       cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
+                                       queue_draw();
+                                       //queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
+                                       return true;
+                               }
+/*                             else
+                               if(last_tooltip_path.get_depth()<=0 || path!=last_tooltip_path)
+                               {
+                                       tooltips_.unset_tip(*this);
+                                       Glib::ustring tooltips_string(row[layer_model.tooltip]);
+                                       last_tooltip_path=path;
+                                       if(!tooltips_string.empty())
+                                       {
+                                               tooltips_.set_tip(*this,tooltips_string);
+                                               tooltips_.force_window();
+                                       }
+                               }
+*/
+                               return true;
+                       }
+                       break;
+               case GDK_BUTTON_RELEASE:
+                       {
+                               Gtk::TreeModel::Path path;
+                               Gtk::TreeViewColumn *column;
+                               int cell_x, cell_y;
+                               if(!get_path_at_pos(
+                                       (int)event->button.x,(int)event->button.y,      // x, y
+                                       path, // TreeModel::Path&
+                                       column, //TreeViewColumn*&
+                                       cell_x,cell_y //int&cell_x,int&cell_y
+                                       )
+                               ) break;
+
+                               if(!get_model()->get_iter(path))
+                                       break;
+
+                               Gtk::TreeRow row = *(get_model()->get_iter(path));
+
+                               if(column && cellrenderer_time_track==column->get_first_cell_renderer())
+                               {
+                                       Gdk::Rectangle rect;
+                                       get_cell_area(path,*column,rect);
+                                       cellrenderer_time_track->property_value_desc()=row[model.value_desc];
+                                       cellrenderer_time_track->property_canvas()=row[model.canvas];
+                                       cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
+                                       queue_draw();
+                                       queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
+                                       return true;
+                               }
+                       }
+                       break;
+               default:
+                       break;
+               }
+               mimic_resync();
+               return Gtk::TreeView::on_event(event);
+       }
+
+       void
+       queue_draw_msg()
+       {
+               synfig::info("*************QUEUE_DRAW***************** (time track view)");
+               Widget::queue_draw();
+       }
+       void set_model(Glib::RefPtr<LayerParamTreeStore> store)
+       {
+               Gtk::TreeView::set_model(store);
+               param_tree_store_=store;
+               cellrenderer_time_track->set_canvas_interface(param_tree_store_->canvas_interface());
+               store->signal_changed().connect(sigc::mem_fun(*this, &TimeTrackView::queue_draw));
+       }
+
+       void
+       on_waypoint_changed( synfig::Waypoint waypoint , synfig::ValueNode::Handle value_node)
+       {
+               // \todo is this code used?
+               assert(0);
+
+               synfigapp::Action::ParamList param_list;
+               param_list.add("canvas",param_tree_store_->canvas_interface()->get_canvas());
+               param_list.add("canvas_interface",param_tree_store_->canvas_interface());
+               param_list.add("value_node",value_node);
+               param_list.add("waypoint",waypoint);
+       //      param_list.add("time",canvas_interface()->get_time());
+
+               etl::handle<studio::Instance>::cast_static(param_tree_store_->canvas_interface()->get_instance())->process_action("WaypointSetSmart", param_list);
+       }
+
+       void mimic(Gtk::TreeView *param_tree_view)
+       {
+               mimic_tree_view=param_tree_view;
+               param_tree_view->signal_row_expanded().connect(
+                       sigc::hide<0>(
+                       sigc::hide_return(
+                               sigc::bind<-1>(
+                                       sigc::mem_fun(
+                                               *this,
+                                               &Gtk::TreeView::expand_row
+                                       ),
+                                       false
+                               )
+                       ))
+               );
+               param_tree_view->signal_row_collapsed().connect(
+                       sigc::hide<0>(
+                       sigc::hide_return(
+                                       sigc::mem_fun(
+                                               *this,
+                                               &Gtk::TreeView::collapse_row
+                                       )
+                       ))
+               );
+               mimic_resync();
+       }
+
+       void mimic_resync()
+       {
+               if(mimic_tree_view)
+               {
+                       Gtk::Adjustment &adjustment(*mimic_tree_view->get_vadjustment());
+                       set_vadjustment(adjustment);
+
+                       if(adjustment.get_page_size()>get_height())
+                               adjustment.set_page_size(get_height());
+
+                       int row_height = 0;
+                       if(getenv("SYNFIG_TIMETRACK_ROW_HEIGHT"))
+                               row_height = atoi(getenv("SYNFIG_TIMETRACK_ROW_HEIGHT"));
+                       if (row_height < 3)
+                               row_height = 18;
+
+                       cellrenderer_time_track->set_fixed_size(-1,row_height);
+               }
+       }
+
+       void
+       on_waypoint_clicked_timetrackview(const etl::handle<synfig::Node>& node,
+                                                                         const synfig::Time& time,
+                                                                         const synfig::Time& time_offset __attribute__ ((unused)),
+                                                                         int button)
+       {
+               std::set<synfig::Waypoint, std::less<UniqueID> > waypoint_set;
+               synfig::waypoint_collect(waypoint_set,time,node);
+
+               synfigapp::ValueDesc value_desc;
+
+               if (waypoint_set.size() == 1)
+               {
+                       ValueNode::Handle value_node(waypoint_set.begin()->get_parent_value_node());
+                       assert(value_node);
+
+                       Gtk::TreeRow row;
+                       if (param_tree_store_->find_first_value_node(value_node, row) && row)
+                               value_desc = static_cast<synfigapp::ValueDesc>(row[model.value_desc]);
+               }
+
+               if (!waypoint_set.empty())
+                       signal_waypoint_clicked_timetrackview(value_desc,waypoint_set,button);
+       }
+};
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Dock_Timetrack::Dock_Timetrack():
+       Dock_CanvasSpecific("timetrack",_("Timetrack"),Gtk::StockID("synfig-timetrack"))
+{
+       table_=0;
+       widget_timeslider_= new Widget_Timeslider();
+       widget_kf_list_= new Widget_Keyframe_List();
+
+       int header_height = 0;
+       if(getenv("SYNFIG_TIMETRACK_HEADER_HEIGHT"))
+               header_height = atoi(getenv("SYNFIG_TIMETRACK_HEADER_HEIGHT"));
+       if (header_height < 3)
+               header_height = 24;
+
+       widget_timeslider_->set_size_request(-1,header_height-header_height/3+1);
+       widget_kf_list_->set_size_request(-1,header_height/3+1);
+
+       hscrollbar_=new Gtk::HScrollbar();
+       vscrollbar_=new Gtk::VScrollbar();
+}
+
+Dock_Timetrack::~Dock_Timetrack()
+{
+       if(table_)delete table_;
+       delete hscrollbar_;
+       delete vscrollbar_;
+       delete widget_timeslider_;
+       delete widget_kf_list_;
+}
+
+void
+Dock_Timetrack::init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
+{
+       LayerParamTreeStore::Model model;
+
+       Glib::RefPtr<LayerParamTreeStore> tree_store(
+               Glib::RefPtr<LayerParamTreeStore>::cast_dynamic(
+                       canvas_view->get_tree_model("params")
+               )
+       );
+
+       TimeTrackView* tree_view(new TimeTrackView());
+       tree_view->set_canvas_view(canvas_view);
+       tree_view->set_model(tree_store);
+       Gtk::TreeView* param_tree_view(dynamic_cast<Gtk::TreeView*>(canvas_view->get_ext_widget("params")));
+       tree_view->mimic(param_tree_view);
+
+       tree_view->signal_waypoint_clicked_timetrackview.connect(sigc::mem_fun(*canvas_view, &studio::CanvasView::on_waypoint_clicked_canvasview));
+
+       canvas_view->time_adjustment().signal_value_changed().connect(sigc::mem_fun(*tree_view,&Gtk::TreeView::queue_draw));
+       canvas_view->time_adjustment().signal_changed().connect(sigc::mem_fun(*tree_view,&Gtk::TreeView::queue_draw));
+
+       canvas_view->set_ext_widget(get_name(),tree_view);
+}
+
+void
+Dock_Timetrack::refresh_selected_param()
+{
+/*     Gtk::TreeView* tree_view(
+               static_cast<Gtk::TreeView*>(get_canvas_view()->get_ext_widget(get_name()))
+       );
+       Gtk::TreeModel::iterator iter(tree_view->get_selection()->get_selected());
+
+       if(iter)
+       {
+               LayerParamTreeStore::Model model;
+               get_canvas_view()->work_area->set_selected_value_node(
+                       (synfig::ValueNode::Handle)(*iter)[model.value_node]
+               );
+       }
+       else
+       {
+               get_canvas_view()->work_area->set_selected_value_node(0);
+       }
+*/
+}
+
+void
+Dock_Timetrack::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
+{
+       if(table_)
+       {
+               table_->hide();
+               delete table_;
+               hscrollbar_->unset_adjustment();
+               vscrollbar_->unset_adjustment();
+               //widget_timeslider_->unset_adjustment();
+               table_=0;
+       }
+
+       if(canvas_view)
+       {
+               TimeTrackView* tree_view(dynamic_cast<TimeTrackView*>(canvas_view->get_ext_widget(get_name())));
+       Gtk::TreeView* param_tree_view(dynamic_cast<Gtk::TreeView*>(canvas_view->get_ext_widget("params")));
+       tree_view->set_vadjustment(*param_tree_view->get_vadjustment());
+
+               assert(tree_view);
+
+
+               widget_timeslider_->set_time_adjustment(&canvas_view->time_adjustment());
+               widget_timeslider_->set_bounds_adjustment(&canvas_view->time_window_adjustment());
+               widget_timeslider_->set_global_fps(canvas_view->get_canvas()->rend_desc().get_frame_rate());
+
+               widget_kf_list_->set_time_adjustment(&canvas_view->time_adjustment());
+               widget_kf_list_->set_canvas_interface(canvas_view->canvas_interface());
+
+               vscrollbar_->set_adjustment(*tree_view->get_vadjustment());
+               hscrollbar_->set_adjustment(canvas_view->time_window_adjustment());
+               table_=new Gtk::Table(2,3);
+               table_->attach(*widget_timeslider_, 0, 1, 1, 2, Gtk::FILL|Gtk::SHRINK, Gtk::FILL|Gtk::SHRINK);
+               table_->attach(*widget_kf_list_, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::SHRINK);
+               table_->attach(*tree_view, 0, 1, 2, 3, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND);
+               table_->attach(*hscrollbar_, 0, 1, 3, 4, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::SHRINK);
+               table_->attach(*vscrollbar_, 1, 2, 0, 3, Gtk::FILL|Gtk::SHRINK, Gtk::FILL|Gtk::EXPAND);
+               add(*table_);
+
+               //add(*last_widget_curves_);
+               table_->show_all();
+               show_all();
+       }
+       else
+       {
+               //clear_previous();
+       }
+}
diff --git a/synfig-studio/src/gui/dock_timetrack.h b/synfig-studio/src/gui/dock_timetrack.h
new file mode 100644 (file)
index 0000000..9da19fd
--- /dev/null
@@ -0,0 +1,71 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_timetrack.h
+**     \brief Template Header
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**  Copyright (c) 2009 Carlos López
+**
+**     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_DOCK_TIMETRACK_H
+#define __SYNFIG_STUDIO_DOCK_TIMETRACK_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "dockable.h"
+#include <gtkmm/treeview.h>
+#include "instance.h"
+#include "dock_canvasspecific.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 Widget_Timeslider;
+class Widget_Keyframe_List;
+
+class Dock_Timetrack : public Dock_CanvasSpecific
+{
+       Gtk::HScrollbar* hscrollbar_;
+       Gtk::VScrollbar* vscrollbar_;
+       Widget_Timeslider* widget_timeslider_;
+       Widget_Keyframe_List* widget_kf_list_;
+       Gtk::Table* table_;
+
+protected:
+       virtual void init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
+       virtual void changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view);
+
+       void refresh_selected_param();
+
+public:
+
+
+       Dock_Timetrack();
+       ~Dock_Timetrack();
+}; // END of Dock_Timetrack
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/dockable.cpp b/synfig-studio/src/gui/dockable.cpp
new file mode 100644 (file)
index 0000000..f0a3dce
--- /dev/null
@@ -0,0 +1,380 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dockable.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "app.h"
+#include <sigc++/hide.h>
+
+#include "dockable.h"
+#include "dockmanager.h"
+#include "dockbook.h"
+#include "dockdialog.h"
+#include <synfig/general.h>
+#include <gtkmm/table.h>
+#include <gtk/gtk.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 ========================================================= */
+
+#ifdef WIN32
+#      ifdef IMAGE_DIR
+#              undef IMAGE_DIR
+#              define IMAGE_DIR "share\\pixmaps"
+#      endif
+#endif
+
+#ifndef IMAGE_DIR
+#      define IMAGE_DIR "/usr/local/share/pixmaps"
+#endif
+
+#ifndef IMAGE_EXT
+#      define IMAGE_EXT        "png"
+#endif
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Dockable::Dockable(const synfig::String& name,const synfig::String& local_name,Gtk::StockID stock_id_):
+//     Gtk::Window(Gtk::WINDOW_TOPLEVEL),
+       name_(name),
+       local_name_(local_name),
+//     dialog_settings(this,name),
+       title_label_(local_name,Gtk::ALIGN_LEFT),
+       stock_id_(stock_id_)
+{
+       parent_=0;
+       scrolled_=0;
+
+       use_scrolled_=true;
+
+       attach_dnd_to(title_label_);
+
+       toolbar_=0;
+       //button_box_.show();
+
+       Gtk::Table* table(this);
+
+       {
+               title_label_.set_padding(0,0);
+               //title_label_.show();
+               Gtk::EventBox* event_box(manage(new Gtk::EventBox()));
+               event_box->set_border_width(0);
+               event_box->add(title_label_);
+               //table->attach(*event_box, 0, 1, 0,1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+
+               header_box_.pack_start(*event_box);
+
+               attach_dnd_to(*event_box);
+               event_box->show();
+       //      event_box->set_events(Gdk::ALL_EVENTS_MASK); //!< \todo change this to only allow what is necessary for DnD
+
+
+               Gtk::Button* bttn_close(manage(new Gtk::Button(_("X"))));
+               //table->attach(*bttn_close, 1, 2, 0,1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+               header_box_.pack_end(*bttn_close,false,false);
+               bttn_close->show();
+               bttn_close->set_relief(Gtk::RELIEF_NONE);
+               bttn_close->signal_clicked().connect(sigc::mem_fun(*this,&Dockable::detach));
+               bttn_close->set_border_width(0);
+               dynamic_cast<Gtk::Misc*>(bttn_close->get_child())->set_padding(0,0);
+       }
+
+       prev_widget_=manage(new Gtk::Label(" "));
+
+       //table->attach(header_box_, 0, 1, 0,1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       table->attach(*prev_widget_, 0, 1, 1,2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       //table->attach(*toolbar_, 0, 1, 2,3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       set_toolbar(*manage(new Gtk::Toolbar));
+       table->show();
+
+       prev_widget_->show();
+
+       set_size_request(175,120);
+
+}
+
+Dockable::~Dockable()
+{
+       if(scrolled_)
+       {
+               delete scrolled_;
+               scrolled_=0;
+       }
+}
+
+void
+Dockable::attach_dnd_to(Gtk::Widget& widget)
+{
+       std::list<Gtk::TargetEntry> listTargets;
+       listTargets.push_back( Gtk::TargetEntry("DOCK") );
+
+       widget.drag_source_set(listTargets);
+       widget.drag_source_set_icon(get_stock_id());
+       widget.drag_dest_set(listTargets);
+
+
+       widget.signal_drag_data_get().connect(sigc::mem_fun(*this,&Dockable::on_drag_data_get));
+       widget.signal_drag_end().connect(sigc::mem_fun(*this,&Dockable::on_drag_end));
+       widget.signal_drag_begin().connect(sigc::mem_fun(*this,&Dockable::on_drag_begin));
+       widget.signal_drag_data_received().connect(sigc::mem_fun(*this,&Dockable::on_drag_data_received));
+}
+
+void
+Dockable::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time)
+{
+       if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
+       {
+               Dockable& dockable(**reinterpret_cast<Dockable**>(const_cast<guint8*>(selection_data.get_data())));
+
+               if(dockable.parent_ != parent_)
+                       parent_->add(dockable,parent_->page_num(*this));
+               else
+                       parent_->reorder_child(dockable,parent_->page_num(*this));
+               dockable.present();
+               context->drag_finish(true, false, time);
+               return;
+       }
+
+       context->drag_finish(false, false, time);
+}
+
+void
+Dockable::on_drag_end(const Glib::RefPtr<Gdk::DragContext>&/*context*/)
+{
+       if(!dnd_success_)
+       {
+               detach();
+               present();
+       }
+}
+
+void
+Dockable::on_drag_begin(const Glib::RefPtr<Gdk::DragContext>&/*context*/)
+{
+       dnd_success_=false;
+}
+
+void
+Dockable::on_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, Gtk::SelectionData& selection_data, guint /*info*/, guint /*time*/)
+{
+       Dockable* tmp(this);
+       dnd_success_=true;
+
+       selection_data.set(8, reinterpret_cast<const guchar*>(&tmp), 4);
+}
+
+void
+Dockable::set_local_name(const synfig::String& local_name)
+{
+       //set_title(local_name);
+       title_label_.set_text(local_name);
+}
+
+void
+Dockable::clear()
+{
+       //if(!toolbar_->children().empty())
+       //      toolbar_->children().clear();
+       set_toolbar(*manage(new Gtk::Toolbar));
+
+}
+
+void
+Dockable::set_toolbar(Gtk::Toolbar& toolbar)
+{
+       if(toolbar_)remove(*toolbar_);
+       toolbar_=0;
+       toolbar_=&toolbar;
+       if(toolbar_)
+       {
+               attach(*toolbar_, 0, 1, 2,3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+               gtk_toolbar_set_icon_size(toolbar_->gobj(),GtkIconSize(1)/*GTK_ICON_SIZE_MENU*/);
+               toolbar_->show();
+       }
+}
+
+bool
+Dockable::clear_previous()
+{
+       prev_widget_=0;
+       prev_widget_delete_connection.disconnect();
+       return false;
+}
+
+void
+Dockable::add(Gtk::Widget& x)
+{
+       if(prev_widget_)
+       {
+               remove(*prev_widget_);
+               clear_previous();
+       }
+
+       if(scrolled_)
+       {
+               delete scrolled_;
+               scrolled_=0;
+       }
+
+       if(use_scrolled_)
+       {
+               scrolled_=new Gtk::ScrolledWindow;
+
+               scrolled_->add(x);
+
+               attach(*scrolled_, 0, 1, 1,2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+               x.show();
+
+               scrolled_->show();
+
+               scrolled_->set_shadow_type(Gtk::SHADOW_NONE);
+               scrolled_->set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC);
+               prev_widget_=scrolled_;
+       }
+       else
+       {
+               attach(x, 0, 1, 1,2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+               x.show();
+               prev_widget_=&x;
+       }
+       prev_widget_delete_connection=prev_widget_->signal_delete_event().connect(
+               sigc::hide(
+                       sigc::mem_fun(
+                               *this,
+                               &Dockable::clear_previous
+                       )
+               )
+       );
+}
+
+Gtk::ToolButton*
+Dockable::add_button(const Gtk::StockID& stock_id, const synfig::String& tooltip)
+{
+       if(!toolbar_)
+               set_toolbar(*manage(new Gtk::Toolbar));
+
+       //Gtk::IconSize iconsize(4);
+       //Gtk::IconSize iconsize(Gtk::IconSize::from_name("synfig-small_icon"));
+
+       Gtk::ToolButton* ret(manage(new Gtk::ToolButton(stock_id)));
+       //Gtk::Image* icon(manage(new Gtk::Image(stock_id,iconsize)));
+       //ret->add(*icon);
+       //ret->set_relief(Gtk::RELIEF_HALF);
+       //ret->set_relief(Gtk::RELIEF_NONE);
+       ret->set_label(tooltip);
+       if (toolbar_->get_tooltips_object())
+               toolbar_->get_tooltips_object()->set_tip(*ret,tooltip);
+
+       ret->show();
+       //icon->show();
+       toolbar_->set_tooltips(true);
+
+       toolbar_->append(*ret);
+       //button_box_.pack_start(*ret,false,false);
+       //get_action_area()->pack_start(*ret,false,false);
+       //add_action_widget(*ret,1);
+       return ret;
+}
+
+
+void
+Dockable::detach()
+{
+       if(parent_)
+               parent_->remove(*this);
+}
+
+void
+Dockable::present()
+{
+       if(parent_)
+       {
+               parent_->set_current_page(parent_->page_num(*this));
+               parent_->present();
+       }
+       else
+       {
+               DockDialog* dock_dialog(new DockDialog());
+               dock_dialog->get_dock_book().add(*this);
+/*             //hack: always display composition selector on top of canvas browser
+               if(get_name()=="canvases")
+                       dock_dialog->set_composition_selector(true);
+*/
+               dock_dialog->present();
+       }
+}
+
+Gtk::Widget*
+Dockable::create_tab_label()
+{
+       Gtk::EventBox* event_box(manage(new Gtk::EventBox()));
+
+       attach_dnd_to(*event_box);
+
+       {
+               Gtk::StockID stock_id(get_stock_id());
+               Gtk::StockItem item;
+
+               // Check to make sure the icon is valid
+               if(Gtk::Stock::lookup(stock_id,item))
+               {
+                       Gtk::Image* icon(manage(new Gtk::Image(stock_id,Gtk::IconSize(4))));
+                       event_box->add(*icon);
+                       tooltips_.set_tip(*event_box,get_local_name());
+                       icon->show();
+               }
+               else
+               {
+                       // Bad icon, try to make a label
+
+                       Glib::ustring text(get_local_name());
+
+                       Gtk::Label* label(manage(new Gtk::Label(text)));
+                       event_box->add(*label);
+                       label->show();
+               }
+       }
+
+       return event_box;
+}
diff --git a/synfig-studio/src/gui/dockable.h b/synfig-studio/src/gui/dockable.h
new file mode 100644 (file)
index 0000000..e1a2ad1
--- /dev/null
@@ -0,0 +1,144 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dockable.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_DOCKABLE_H
+#define __SYNFIG_STUDIO_DOCKABLE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/stockid.h>
+#include <gtkmm/button.h>
+#include "dialogsettings.h"
+#include <synfig/string.h>
+#include <gtkmm/table.h>
+#include <gtkmm/tooltips.h>
+#include <gtkmm/label.h>
+#include <gtkmm/frame.h>
+#include <gtkmm/handlebox.h>
+#include <gtkmm/box.h>
+#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/toolbar.h>
+#include <gtkmm/toolbutton.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 DockManager;
+class DockBook;
+
+class Dockable : public Gtk::Table
+{
+       friend class DockManager;
+       friend class DockBook;
+
+
+       sigc::signal<void> signal_stock_id_changed_;
+       sigc::connection prev_widget_delete_connection;
+protected:
+
+//     DialogSettings dialog_settings;
+
+
+private:
+
+       Gtk::Toolbar *toolbar_;
+
+       synfig::String name_;
+       synfig::String local_name_;
+       Gtk::Tooltips tooltips_;
+       Gtk::Frame frame_;
+       Gtk::Label title_label_;
+       //Gtk::HBox button_box_;
+       Gtk::HBox header_box_;
+
+       //Gtk::HandleBox handle_box_;
+       Gtk::ScrolledWindow *scrolled_;
+       Gtk::Widget *prev_widget_;
+
+       bool use_scrolled_;
+
+       Gtk::StockID stock_id_;
+
+       DockBook* parent_;
+
+       bool dnd_success_;
+
+public:
+
+       void set_toolbar(Gtk::Toolbar& toolbar);
+
+       void set_use_scrolled(bool x) { use_scrolled_=x; }
+
+       Dockable(const synfig::String& name,const synfig::String& local_name,Gtk::StockID stock_id_=Gtk::StockID(" "));
+       ~Dockable();
+
+       sigc::signal<void>& signal_stock_id_changed() { return signal_stock_id_changed_; }
+
+       const synfig::String& get_name()const { return name_; }
+       const synfig::String& get_local_name()const { return local_name_; }
+
+       const Gtk::StockID& get_stock_id()const { return stock_id_; }
+       void set_stock_id(Gtk::StockID x) { stock_id_=x; signal_stock_id_changed()(); }
+
+       void set_local_name(const synfig::String&);
+
+       void clear();
+
+       Gtk::Tooltips& get_tooltips() { return tooltips_; }
+
+       //DialogSettings& settings() { return dialog_settings; }
+       //const DialogSettings& settings()const { return dialog_settings; }
+
+       void add(Gtk::Widget& x);
+
+       Gtk::ToolButton* add_button(const Gtk::StockID& stock_id, const synfig::String& tooltip=synfig::String());
+
+       void detach();
+
+       void present();
+
+       void attach_dnd_to(Gtk::Widget& widget);
+
+       bool clear_previous();
+       virtual Gtk::Widget* create_tab_label();
+
+private:
+
+       void on_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, Gtk::SelectionData& selection_data, guint info, guint time);
+       void on_drag_end(const Glib::RefPtr<Gdk::DragContext>&context);
+       void on_drag_begin(const Glib::RefPtr<Gdk::DragContext>&context);
+       void on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time);
+
+}; // END of studio::Dockable
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/dockbook.cpp b/synfig-studio/src/gui/dockbook.cpp
new file mode 100644 (file)
index 0000000..707352e
--- /dev/null
@@ -0,0 +1,253 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dockbook.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \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
+**     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 <config.h>
+#endif
+
+#include "dockbook.h"
+#include "dockable.h"
+#include "app.h"
+#include "dockmanager.h"
+
+#include <gtkmm/image.h>
+#include <gtkmm/eventbox.h>
+#include <gtkmm/menu.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+DockBook::DockBook()
+{
+       std::list<Gtk::TargetEntry> listTargets;
+       listTargets.push_back( Gtk::TargetEntry("DOCK") );
+
+       drag_dest_set(listTargets);
+       //set_sensitive(true);
+       set_flags(get_flags()|Gtk::RECEIVES_DEFAULT|Gtk::HAS_GRAB);
+       //add_events(Gdk::ALL_EVENTS_MASK);
+       //set_extension_events(Gdk::EXTENSION_EVENTS_ALL);
+       set_show_tabs(true);
+       deleting_=false;
+}
+
+DockBook::~DockBook()
+{
+       deleting_=true;
+       clear();
+}
+
+void
+DockBook::clear()
+{
+       while(get_n_pages())
+               remove(static_cast<Dockable&>(*get_nth_page(get_n_pages()-1)));
+}
+
+void
+DockBook::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time)
+{
+       if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
+       {
+               Dockable& dockable(**reinterpret_cast<Dockable**>(const_cast<guint8*>(selection_data.get_data())));
+               if(dockable.parent_!=this)
+                       add(dockable);
+               dockable.present();
+               context->drag_finish(true, false, time);
+               return;
+       }
+
+       context->drag_finish(false, false, time);
+}
+
+void
+DockBook::add(Dockable& dockable, int position)
+{
+       dockable.detach();
+
+       if(position==-1)
+               append_page(dockable, " ");
+       else
+               insert_page(dockable, " ", position);
+
+       refresh_tab(&dockable);
+
+       dockable.signal_stock_id_changed().connect(
+               sigc::bind(
+                       sigc::mem_fun(
+                               *this,
+                               &DockBook::refresh_tab
+                       ),
+                       &dockable
+               )
+       );
+
+       dockable.parent_=this;
+
+       dockable.show();
+
+       signal_changed_();
+}
+
+void
+DockBook::refresh_tab(Dockable* dockable)
+{
+       Gtk::Widget* label(dockable->create_tab_label());
+
+       label->signal_button_press_event().connect(
+               sigc::bind(
+                       sigc::mem_fun(
+                               *this,
+                               &DockBook::tab_button_pressed
+                       ),
+                       dockable
+               )
+       );
+
+       set_tab_label(*dockable, *label);
+       label->show();
+}
+
+
+void
+DockBook::remove(Dockable& dockable)
+{
+       dockable.hide();
+       remove_page(dockable);
+       dockable.parent_=0;
+
+       if(!deleting_)
+       {
+               signal_changed_();
+
+               if(get_n_pages()==0)
+                       signal_empty()();
+       }
+}
+
+void
+DockBook::present()
+{
+       show();
+}
+
+synfig::String
+DockBook::get_local_contents()const
+{
+       synfig::String ret;
+
+       for(int i(0);i!=const_cast<DockBook*>(this)->get_n_pages();i++)
+       {
+               Dockable& dockable(static_cast<Dockable&>(*const_cast<DockBook*>(this)->get_nth_page(i)));
+
+               if(i)
+                       ret+=", ";
+               ret+=dockable.get_local_name();
+       }
+
+       return ret;
+}
+
+synfig::String
+DockBook::get_contents()const
+{
+       synfig::String ret;
+
+       for(int i(0);i!=const_cast<DockBook*>(this)->get_n_pages();i++)
+       {
+               Dockable& dockable(static_cast<Dockable&>(*const_cast<DockBook*>(this)->get_nth_page(i)));
+
+               if(i)
+                       ret+=' ';
+               ret+=dockable.get_name();
+       }
+
+       return ret;
+}
+
+void
+DockBook::set_contents(const synfig::String& x)
+{
+       synfig::String str(x);
+       while(!str.empty())
+       {
+               synfig::String::size_type separator=str.find_first_of(' ');
+               synfig::String dock;
+               if(separator==synfig::String::npos)
+               {
+                       dock=str;
+                       str.clear();
+               }
+               else
+               {
+                       dock=String(str.begin(),str.begin()+separator);
+                       str=String(str.begin()+separator+1,str.end());
+               }
+
+               try
+               {
+                       add(App::dock_manager->find_dockable(dock));
+               }catch(...) { }
+       }
+}
+
+bool
+DockBook::tab_button_pressed(GdkEventButton* event, Dockable* dockable)
+{
+       if(event->button!=3)
+               return false;
+
+       Gtk::Menu *tabmenu=manage(new class Gtk::Menu());
+       tabmenu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), tabmenu));
+
+       tabmenu->items().push_back(
+               Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-close"),
+                       sigc::mem_fun(*dockable,&Dockable::detach)
+               )
+       );
+
+       tabmenu->popup(event->button,gtk_get_current_event_time());
+
+       return true;
+}
diff --git a/synfig-studio/src/gui/dockbook.h b/synfig-studio/src/gui/dockbook.h
new file mode 100644 (file)
index 0000000..c8b76a8
--- /dev/null
@@ -0,0 +1,89 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dockbook.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_DOCKBOOK_H
+#define __SYNFIG_STUDIO_DOCKBOOK_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/notebook.h>
+#include <synfig/string.h>
+#include <gtkmm/tooltips.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 DockManager;
+class Dockable;
+
+class DockBook : public Gtk::Notebook
+{
+       friend class DockManager;
+       friend class Dockable;
+
+       sigc::signal<void> signal_empty_;
+       sigc::signal<void> signal_changed_;
+
+       Gtk::Tooltips tooltips_;
+
+       bool deleting_;
+
+protected:
+public:
+       DockBook();
+       ~DockBook();
+
+       sigc::signal<void>& signal_empty() { return signal_empty_; }
+       sigc::signal<void>& signal_changed() { return signal_changed_; }
+
+       void add(Dockable& dockable, int position=-1);
+       void remove(Dockable& dockable);
+
+       void present();
+
+       void clear();
+
+       synfig::String get_local_contents()const;
+
+       synfig::String get_contents()const;
+       void set_contents(const synfig::String& x);
+
+       void refresh_tabs_headers();
+
+       void refresh_tab(Dockable*);
+
+       bool tab_button_pressed(GdkEventButton* event, Dockable* dockable);
+       void on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time);
+}; // END of studio::DockBook
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/dockdialog.cpp b/synfig-studio/src/gui/dockdialog.cpp
new file mode 100644 (file)
index 0000000..614e8db
--- /dev/null
@@ -0,0 +1,564 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dockdialog.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 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 <config.h>
+#endif
+
+#include "app.h"
+#include <sigc++/adaptors/hide.h>
+
+#include "dockdialog.h"
+#include "dockbook.h"
+#include "dockmanager.h"
+#include "toolbox.h"
+#include "widget_compselect.h"
+#include <synfig/general.h>
+#include <synfig/uniqueid.h>
+#include <gtkmm/table.h>
+#include <sigc++/hide.h>
+#include <sigc++/slot.h>
+#include <sigc++/retype_return.h>
+#include <sigc++/retype.h>
+#include "canvasview.h"
+#include <gtkmm/paned.h>
+#include <gtkmm/box.h>
+#include <synfigapp/main.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 ========================================================= */
+
+#define GRAB_HINT_DATA(y,default)      { \
+               String x; \
+               if(synfigapp::Main::settings().get_value(String("pref.")+y+"_hints",x)) \
+               { \
+                       set_type_hint((Gdk::WindowTypeHint)atoi(x.c_str()));    \
+               } else {\
+                       set_type_hint(default); \
+               } \
+       }
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+DockDialog::DockDialog():
+       Gtk::Window(Gtk::WINDOW_TOPLEVEL)
+{
+       composition_selector_=false;
+       is_deleting=false;
+       is_horizontal=false;
+       last_dock_book=0;
+       box=0;
+
+       widget_comp_select=new Widget_CompSelect();
+
+       // Give ourselves an ID that is most likely unique
+       set_id(synfig::UniqueID().get_uid()^reinterpret_cast<long>(this));
+
+       set_role(strprintf("dock_dialog_%d",get_id()));
+       GRAB_HINT_DATA(
+               "dock_dialog",
+#ifdef __APPLE__
+               Gdk::WINDOW_TYPE_HINT_NORMAL
+#else
+               Gdk::WINDOW_TYPE_HINT_UTILITY
+#endif
+       );
+       set_keep_above(false);
+
+       //! \todo can we set dialog windows transient for all normal windows, not just the toolbox?
+       //! paragraph 3 of http://standards.freedesktop.org/wm-spec/1.3/ar01s07.html suggests we can
+       // this seems to have bad effects on KDE, so leave it disabled by default
+       if(getenv("SYNFIG_TRANSIENT_DIALOGS"))
+               set_transient_for(*App::toolbox);
+
+       // Set up the window
+       //set_type_hint(Gdk::WINDOW_TYPE_HINT_UTILITY);
+       set_title(_("Dock Panel"));
+
+       // Register with the dock manager
+       App::dock_manager->dock_dialog_list_.push_back(this);
+
+
+       // connect our signals
+       signal_delete_event().connect(
+               sigc::hide(
+                       sigc::mem_fun(*this,&DockDialog::close)
+               )
+       );
+
+/*
+       App::signal_canvas_view_focus().connect(
+               sigc::hide(
+                       sigc::mem_fun(
+                               *this,
+                               &DockDialog::refresh_accel_group
+                       )
+               )
+       );
+*/
+
+       add_accel_group(App::ui_manager()->get_accel_group());
+       App::signal_present_all().connect(sigc::mem_fun0(*this,&DockDialog::present));
+
+}
+
+DockDialog::~DockDialog()
+{
+       empty_sig.disconnect();
+
+       is_deleting=true;
+
+       // Remove all of the dock books
+       for(;!dock_book_list.empty();dock_book_list.pop_front())
+       {
+               dock_book_list.front()->clear();
+
+               //! \todo Fix this UGLY HACK
+               // The following line really should be uncommented,
+               // but it causes crashes. Without it, a small
+               // memory hole is created--but at least it doesn't crash
+               // delete dock_book_list.front();
+
+               // Oddly enough, the following line should
+               // theoretically do the same thing after this
+               // class is destroyed, but it doesn't seem to
+               // cause a crash.  It does, however, trigger this warning:
+               //
+               //   A floating object was finalized. This means that someone
+               //   called g_object_unref() on an object that had only a
+               //   floating reference; the initial floating reference is not
+               //   owned by anyone and must be removed with g_object_ref_sink().
+               //
+               // manage(dock_book_list.front());
+       }
+
+       // Remove us from the dock manager
+       if(App::dock_manager)try{
+               std::list<DockDialog*>::iterator iter;
+               for(iter=App::dock_manager->dock_dialog_list_.begin();iter!=App::dock_manager->dock_dialog_list_.end();++iter)
+                       if(*iter==this)
+                       {
+                               App::dock_manager->dock_dialog_list_.erase(iter);
+                               break;
+                       }
+       }
+       catch(...)
+       {
+               synfig::warning("DockDialog::~DockDialog(): Exception thrown when trying to remove from dock manager...?");
+       }
+
+       delete widget_comp_select;
+}
+
+void
+DockDialog::drop_on_prepend(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time)
+{
+       if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
+       {
+               Dockable& dockable(**reinterpret_cast<Dockable**>(const_cast<guint8*>(selection_data.get_data())));
+               prepend_dock_book()->add(dockable);
+               context->drag_finish(true, false, time);
+               return;
+       }
+
+       context->drag_finish(false, false, time);
+}
+
+void
+DockDialog::drop_on_append(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time)
+{
+       if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
+       {
+               Dockable& dockable(**reinterpret_cast<Dockable**>(const_cast<guint8*>(selection_data.get_data())));
+               append_dock_book()->add(dockable);
+               context->drag_finish(true, false, time);
+               return;
+       }
+
+       context->drag_finish(false, false, time);
+}
+
+
+void
+DockDialog::on_hide()
+{
+       Gtk::Window::on_hide();
+       close();
+}
+
+DockBook*
+DockDialog::prepend_dock_book()
+{
+       if(is_deleting)return 0;
+
+       dock_book_list.push_front(new DockBook);
+       last_dock_book=dock_book_list.front();
+
+
+       last_dock_book->signal_empty().connect(
+               sigc::bind(
+                       sigc::mem_fun(*this,&DockDialog::erase_dock_book),
+                       last_dock_book
+               )
+       );
+
+       dock_book_sizes_.insert(dock_book_sizes_.begin(),225);
+       refresh();
+       return last_dock_book;
+}
+
+DockBook*
+DockDialog::append_dock_book()
+{
+       if(is_deleting)return 0;
+
+       dock_book_list.push_back(new DockBook);
+       last_dock_book=dock_book_list.back();
+       last_dock_book->signal_empty().connect(
+               sigc::bind(
+                       sigc::mem_fun(*this,&DockDialog::erase_dock_book),
+                       last_dock_book
+               )
+       );
+       last_dock_book->signal_changed().connect(
+               sigc::mem_fun(*this,&DockDialog::refresh_title)
+       );
+       last_dock_book->signal_changed().connect(
+               sigc::mem_fun(*this,&DockDialog::refresh_title)
+       );
+       dock_book_sizes_.push_back(225);
+
+       //last_dock_book->show();
+       refresh();
+       return last_dock_book;
+}
+
+void
+DockDialog::erase_dock_book(DockBook* dock_book)
+{
+       if(is_deleting)return;
+
+       std::list<DockBook*>::iterator iter;
+       for(iter=dock_book_list.begin();iter!=dock_book_list.end();++iter)
+               if(*iter==dock_book)
+               {
+                       dock_book_list.erase(iter);
+
+                       if(dock_book_list.empty())
+                       {
+                               last_dock_book=0;
+                               close();
+                               return;
+                       }
+                       else
+                       {
+                               if(last_dock_book==dock_book)
+                                       last_dock_book=dock_book_list.front();
+                       }
+
+                       refresh();
+
+                       return;
+               }
+}
+
+void
+DockDialog::refresh()
+{
+       // synfig::info("dock_book_list.size()=%d",dock_book_list.size());
+       //remove();
+
+       if(dock_book_list.empty())
+               return;
+
+       if(box)delete box;
+       box=(manage(is_horizontal?(Gtk::Box*)new Gtk::HBox:(Gtk::Box*)new Gtk::VBox));
+       add(*box);
+
+       box->pack_start(*widget_comp_select,false,true);
+
+       Gtk::Button* append_button(manage(new Gtk::Button));
+       Gtk::Button* prepend_button(manage(new Gtk::Button));
+
+       std::list<Gtk::TargetEntry> listTargets;
+       listTargets.push_back( Gtk::TargetEntry("DOCK") );
+
+       append_button->drag_dest_set(listTargets);
+       prepend_button->drag_dest_set(listTargets);
+
+       append_button->signal_drag_data_received().connect(
+               sigc::mem_fun(*this,&DockDialog::drop_on_append)
+       );
+
+       prepend_button->signal_drag_data_received().connect(
+               sigc::mem_fun(*this,&DockDialog::drop_on_prepend)
+       );
+
+       box->pack_start(*prepend_button,false,true);
+       box->pack_end(*append_button,false,true);
+
+       //prepend_button->show();
+       //append_button->show();
+       panels_.clear();
+
+       if(dock_book_list.size()==1)
+       {
+               box->pack_start(get_dock_book(),true,true);
+       }
+       else
+       {
+               Gtk::Paned* parent(manage(is_horizontal?(Gtk::Paned*)new Gtk::HPaned:(Gtk::Paned*)new Gtk::VPaned));
+
+               panels_.push_back(parent);
+
+               if(panels_.size()<=dock_book_sizes_.size())
+                       panels_.back()->set_position(dock_book_sizes_[panels_.size()-1]);
+               panels_.back()->property_position().signal_changed().connect(
+                       sigc::mem_fun(*this,&DockDialog::rebuild_sizes)
+               );
+               //parent->show();
+               parent->add1(*dock_book_list.front());
+               //dock_book_list.front()->show();
+
+               box->pack_start(*parent,true,true);
+
+               std::list<DockBook*>::iterator iter,next;
+               for(next=dock_book_list.begin(),next++,iter=next++;next!=dock_book_list.end();iter=next++)
+               {
+                       Gtk::Paned* current(manage(is_horizontal?(Gtk::Paned*)new Gtk::HPaned:(Gtk::Paned*)new Gtk::VPaned));
+                       panels_.push_back(current);
+
+                       if(panels_.size()<=dock_book_sizes_.size())
+                               panels_.back()->set_position(dock_book_sizes_[panels_.size()-1]);
+                       panels_.back()->property_position().signal_changed().connect(
+                               sigc::mem_fun(*this,&DockDialog::rebuild_sizes)
+                       );
+
+
+                       parent->add2(*current);
+
+                       current->add1(**iter);
+                       //(*iter)->show();
+                       //current->show();
+
+                       parent=current;
+               }
+               parent->add2(**iter);
+               //(*iter)->show();
+       }
+
+       box->show_all();
+       if(!composition_selector_)
+               widget_comp_select->hide();
+       rebuild_sizes();
+}
+
+void
+DockDialog::rebuild_sizes()
+{
+       unsigned int i=0;
+       dock_book_sizes_.clear();
+       for(i=0;i<panels_.size();i++)
+       {
+               dock_book_sizes_.push_back(panels_[i]->get_position());
+       }
+}
+
+void
+DockDialog::set_dock_book_sizes(const std::vector<int>& new_sizes)
+{
+       unsigned int i=0;
+       for(i=0;i<panels_.size() && i<new_sizes.size();i++)
+       {
+               panels_[i]->set_position(new_sizes[i]);
+       }
+       dock_book_sizes_=new_sizes;
+       //rebuild_sizes();
+}
+
+void
+DockDialog::refresh_accel_group()
+{
+/*
+       if(last_accel_group_)
+       {
+               last_accel_group_->unlock();
+               remove_accel_group(last_accel_group_);
+               last_accel_group_=Glib::RefPtr<Gtk::AccelGroup>();
+       }
+
+       etl::loose_handle<CanvasView> canvas_view(App::get_selected_canvas_view());
+       if(canvas_view)
+       {
+               last_accel_group_=canvas_view->get_accel_group();
+               last_accel_group_->lock();
+               add_accel_group(last_accel_group_);
+       }
+*/
+       etl::loose_handle<CanvasView> canvas_view(App::get_selected_canvas_view());
+       if(canvas_view)
+       {
+               canvas_view->mainmenu.accelerate(*this);
+       }
+}
+
+bool
+DockDialog::close()
+{
+       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
+               synfig::info("DockDialog::close(): Deleted");
+
+       empty_sig.disconnect();
+       //get_dock_book().clear();
+       delete this;
+       return true;
+}
+
+DockBook&
+DockDialog::get_dock_book()
+{
+       if(!last_dock_book)
+               return *append_dock_book();
+       return *last_dock_book;
+}
+
+const DockBook&
+DockDialog::get_dock_book()const
+{
+       return *last_dock_book;
+}
+
+
+synfig::String
+DockDialog::get_contents()const
+{
+       synfig::String ret;
+
+       std::list<DockBook*>::const_iterator iter;
+       for(iter=dock_book_list.begin();iter!=dock_book_list.end();++iter)
+       {
+               if(!ret.empty())
+                       ret+=is_horizontal?" | ":" - ";
+               ret+=(*iter)->get_contents();
+       }
+
+
+       return ret;
+}
+
+void
+DockDialog::set_contents(const synfig::String& z)
+{
+       int x,y;
+       get_size(x,y);
+
+       synfig::String str(z);
+       while(!str.empty())
+       {
+               synfig::String::size_type separator=str.find_first_of('-');
+               {
+                       synfig::String::size_type sep2=str.find_first_of('|');
+                       if(separator!=synfig::String::npos || sep2!=synfig::String::npos)
+                       {
+                               if((separator==synfig::String::npos || sep2<separator) && sep2!=synfig::String::npos)
+                               {
+                                       separator=sep2;
+                                       is_horizontal=true;
+                               }
+                               else
+                                       is_horizontal=false;
+                       }
+               }
+
+               synfig::String book_contents;
+               if(separator==synfig::String::npos)
+               {
+                       book_contents=str;
+                       str.clear();
+               }
+               else
+               {
+                       book_contents=String(str.begin(),str.begin()+separator);
+                       str=String(str.begin()+separator+1,str.end());
+               }
+
+               try
+               {
+                       append_dock_book()->set_contents(book_contents);
+               }catch(...) { }
+       }
+
+       resize(x,y);
+}
+
+void
+DockDialog::set_composition_selector(bool x)
+{
+       if(x==get_composition_selector())
+               return;
+       composition_selector_=x;
+       if(x)
+               widget_comp_select->show();
+       else
+               widget_comp_select->hide();
+}
+
+void
+DockDialog::refresh_title()
+{
+       if(is_deleting)return;
+       if(dock_book_list.size())
+       {
+               synfig::String title;
+
+               std::list<DockBook*>::const_iterator iter;
+               for(iter=dock_book_list.begin();iter!=dock_book_list.end();++iter)
+               {
+                       if(!title.empty())
+                               title+=", ";
+                       title+=(*iter)->get_local_contents();
+               }
+               set_title(title);
+       }
+       else
+               set_title(_("Empty Dock Panel"));
+}
diff --git a/synfig-studio/src/gui/dockdialog.h b/synfig-studio/src/gui/dockdialog.h
new file mode 100644 (file)
index 0000000..551ecba
--- /dev/null
@@ -0,0 +1,128 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dockdialog.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_DOCK_DIALOG_H
+#define __SYNFIG_STUDIO_DOCK_DIALOG_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/stockid.h>
+#include <gtkmm/button.h>
+#include "dialogsettings.h"
+#include <synfig/string.h>
+#include <gtkmm/dialog.h>
+#include <gtkmm/tooltips.h>
+#include <gtkmm/label.h>
+#include <gtkmm/frame.h>
+#include <gtkmm/handlebox.h>
+#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/accelgroup.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 Gtk { class Box; class Paned;  };
+namespace studio {
+
+class DockManager;
+class DockBook;
+class Dockable;
+class Widget_CompSelect;
+class CanvasView;
+
+class DockDialog : public Gtk::Window
+{
+       friend class DockManager;
+       friend class DockBook;
+       friend class Dockable;
+       sigc::connection empty_sig;
+
+       bool composition_selector_;
+
+       bool is_deleting;
+
+       bool is_horizontal;
+
+private:
+       std::list<DockBook*> dock_book_list;
+
+       std::vector<Gtk::Paned*>        panels_;
+       std::vector<int>                        dock_book_sizes_;
+
+
+       DockBook* last_dock_book;
+
+       Widget_CompSelect* widget_comp_select;
+       Gtk::Box *box;
+
+       int id_;
+
+       void on_hide();
+
+       void refresh();
+
+       void refresh_title();
+
+       void set_id(int x) { id_=x; }
+
+       void refresh_accel_group();
+
+       void drop_on_append(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time);
+       void drop_on_prepend(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time);
+
+public:
+
+       const std::vector<int>& get_dock_book_sizes()const { return dock_book_sizes_;}
+       void set_dock_book_sizes(const std::vector<int>&);
+       void rebuild_sizes();
+
+       bool close();
+
+       int get_id()const { return id_; }
+
+       DockBook* append_dock_book();
+       DockBook* prepend_dock_book();
+       void erase_dock_book(DockBook*);
+
+       void set_composition_selector(bool x);
+       bool get_composition_selector()const { return composition_selector_; }
+
+       DockDialog();
+       ~DockDialog();
+
+       DockBook& get_dock_book();
+       const DockBook& get_dock_book()const;
+
+       synfig::String get_contents()const;
+       void set_contents(const synfig::String& x);
+}; // END of studio::DockDialog
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/dockmanager.cpp b/synfig-studio/src/gui/dockmanager.cpp
new file mode 100644 (file)
index 0000000..8a5198c
--- /dev/null
@@ -0,0 +1,328 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dockmanager.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 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 <config.h>
+#endif
+
+#include "dockmanager.h"
+#include <stdexcept>
+#include "dockable.h"
+#include "dockdialog.h"
+#include <synfigapp/settings.h>
+#include <synfigapp/main.h>
+#include <gdkmm/general.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 ========================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+class studio::DockSettings : public synfigapp::Settings
+{
+       DockManager* dock_manager;
+
+public:
+       DockSettings(DockManager* dock_manager):dock_manager(dock_manager)
+       {
+               synfigapp::Main::settings().add_domain(this,"dock");
+       }
+
+       virtual ~DockSettings()
+       {
+               synfigapp::Main::settings().remove_domain("dock");
+       }
+#define SCALE_FACTOR   (1280)
+       virtual bool get_value(const synfig::String& key_, synfig::String& value)const
+       {
+               int screen_w(Gdk::screen_width());
+               int screen_h(Gdk::screen_height());
+
+               if(key_.size()>6 && String(key_.begin(),key_.begin()+6)=="dialog")try
+               {
+                       synfig::String key(key_.begin()+7,key_.end());
+                       synfig::String::size_type separator=key.find_first_of('.');
+                       int id(atoi(synfig::String(key.begin(),key.begin()+separator).c_str()));
+                       key=synfig::String(key.begin()+separator+1,key.end());
+
+                       DockDialog& dock_dialog(dock_manager->find_dock_dialog(id));
+
+                       if(key=="contents_size")
+                       {
+                               dock_dialog.rebuild_sizes();
+                               vector<int>::const_iterator iter(dock_dialog.get_dock_book_sizes().begin());
+                               vector<int>::const_iterator end(dock_dialog.get_dock_book_sizes().end());
+                               value.clear();
+                               for(;iter!=end;++iter)
+                                       value+=strprintf("%d ",(*iter)*SCALE_FACTOR/screen_h);
+                               return true;
+                       }
+                       if(key=="pos")
+                       {
+                               int x,y; dock_dialog.get_position(x,y);
+                               value=strprintf("%d %d",x*SCALE_FACTOR/screen_w,y*SCALE_FACTOR/screen_h);
+                               return true;
+                       }
+                       if(key=="size")
+                       {
+                               int x,y; dock_dialog.get_size(x,y);
+                               value=strprintf("%d %d",x*SCALE_FACTOR/screen_w,y*SCALE_FACTOR/screen_h);
+                               return true;
+                       }
+                       if(key=="contents")
+                       {
+                               value=dock_dialog.get_contents();
+                               return true;
+                       }
+                       if(key=="comp_selector")
+                       {
+                               value=dock_dialog.get_composition_selector()?"1":"0";
+                               return true;
+                       }
+               }catch (...) { return false; }
+               return synfigapp::Settings::get_value(key_,value);
+       }
+
+       virtual bool set_value(const synfig::String& key_,const synfig::String& value)
+       {
+               int screen_w(Gdk::screen_width());
+               int screen_h(Gdk::screen_height());
+
+               if(key_.size()>6 && String(key_.begin(),key_.begin()+6)=="dialog")
+               {
+                       synfig::String key(key_.begin()+7,key_.end());
+                       synfig::String::size_type separator=key.find_first_of('.');
+                       int id(atoi(synfig::String(key.begin(),key.begin()+separator).c_str()));
+                       key=synfig::String(key.begin()+separator+1,key.end());
+
+                       DockDialog& dock_dialog(dock_manager->find_dock_dialog(id));
+
+                       if(key=="contents_size")
+                       {
+                               try {
+                               int width, height;
+                               Gtk::IconSize::lookup(Gtk::IconSize(4),width,height);
+                               vector<int> data;
+                               String::size_type n=0;
+                               String value_(value);
+                               while(value_.size() && value_.size()>n){
+                                       value_=String(value_.begin()+n,value_.end());
+                                       int size;
+                                       if(!strscanf(value_,"%d",&size))
+                                               break;
+                                       if (size > SCALE_FACTOR) size = SCALE_FACTOR - 150;
+                                       if (size < 0) size = 0;
+                                       size=size*screen_h/SCALE_FACTOR;
+
+                                       // prevent errors like this, by allowing space for at least the dockable's icon:
+                                       // ** CRITICAL **: clearlooks_style_draw_box_gap: assertion `height >= -1' failed
+                                       if (size < height + 9) size = height + 9;
+
+                                       data.push_back(size);
+
+                                       n=value_.find(" ");
+                                       if(n==String::npos)
+                                               break;
+                                       n++;
+                               }
+                               dock_dialog.set_dock_book_sizes(data);
+                               }
+                               catch(...)
+                               {
+                                       synfig::error("Exception caught!!!");
+                                       return false;
+                               }
+                               return true;
+                       }
+                       if(key=="pos")
+                       {
+                               int x,y;
+                               if(!strscanf(value,"%d %d",&x, &y))
+                                       return false;
+                               if (x > SCALE_FACTOR) x = SCALE_FACTOR - 150; if (x < 0) x = 0;
+                               if (y > SCALE_FACTOR) y = SCALE_FACTOR - 150; if (y < 0) y = 0;
+                               x=x*screen_w/SCALE_FACTOR;
+                               y=y*screen_h/SCALE_FACTOR;
+                               if(getenv("SYNFIG_WINDOW_POSITION_X_OFFSET"))
+                                       x += atoi(getenv("SYNFIG_WINDOW_POSITION_X_OFFSET"));
+                               if(getenv("SYNFIG_WINDOW_POSITION_Y_OFFSET"))
+                                       y += atoi(getenv("SYNFIG_WINDOW_POSITION_Y_OFFSET"));
+                               dock_dialog.move(x,y);
+                               return true;
+                       }
+                       if(key=="size")
+                       {
+                               int x,y;
+                               if(!strscanf(value,"%d %d",&x, &y))
+                                       return false;
+                               if (x > SCALE_FACTOR) x = 150; if (x < 0) x = 0;
+                               if (y > SCALE_FACTOR) y = 150; if (y < 0) y = 0;
+                               x=x*screen_w/SCALE_FACTOR;
+                               y=y*screen_h/SCALE_FACTOR;
+                               dock_dialog.set_default_size(x,y);
+                               dock_dialog.resize(x,y);
+                               return true;
+                       }
+                       if(key=="contents")
+                       {
+                               dock_dialog.set_contents(value);
+                               return true;
+                       }
+                       if(key=="comp_selector")
+                       {
+                               if(value.empty() || value[0]=='0')
+                                       dock_dialog.set_composition_selector(false);
+                               else
+                                       dock_dialog.set_composition_selector(true);
+                               return true;
+                       }
+               }
+               return synfigapp::Settings::set_value(key_,value);
+       }
+
+       virtual KeyList get_key_list()const
+       {
+               synfigapp::Settings::KeyList ret(synfigapp::Settings::get_key_list());
+
+               std::list<DockDialog*>::const_iterator iter;
+               for(iter=dock_manager->dock_dialog_list_.begin();iter!=dock_manager->dock_dialog_list_.end();++iter)
+               {
+                       ret.push_back(strprintf("dialog.%d.contents",(*iter)->get_id()));
+                       ret.push_back(strprintf("dialog.%d.comp_selector",(*iter)->get_id()));
+                       ret.push_back(strprintf("dialog.%d.pos",(*iter)->get_id()));
+                       ret.push_back(strprintf("dialog.%d.size",(*iter)->get_id()));
+                       ret.push_back(strprintf("dialog.%d.contents_size",(*iter)->get_id()));
+               }
+               return ret;
+       }
+};
+
+/* === M E T H O D S ======================================================= */
+
+DockManager::DockManager():
+       dock_settings(new DockSettings(this))
+{
+}
+
+DockManager::~DockManager()
+{
+       while(!dock_dialog_list_.empty())
+       {
+               dock_dialog_list_.back()->close();
+       }
+       while(!dockable_list_.empty())
+       {
+               Dockable* dockable(dockable_list_.back());
+               // synfig::info("DockManager::~DockManager(): Deleting dockable \"%s\"",dockable->get_name().c_str());
+               dockable_list_.pop_back();
+               delete dockable;
+       }
+}
+
+void
+DockManager::register_dockable(Dockable& x)
+{
+       dockable_list_.push_back(&x);
+       // synfig::info("DockManager::register_dockable(): Registered dockable \"%s\"",dockable_list_.back()->get_name().c_str());
+       signal_dockable_registered()(&x);
+}
+
+bool
+DockManager::unregister_dockable(Dockable& x)
+{
+       std::list<Dockable*>::iterator iter;
+       for(iter=dockable_list_.begin();iter!=dockable_list_.end();++iter)
+       {
+               if(&x==*iter)
+               {
+                       x.detach();
+                       dockable_list_.erase(iter);
+                       synfig::info("DockManager::unregister_dockable(): \"%s\" has been Unregistered",x.get_name().c_str());
+                       return true;
+               }
+       }
+       return false;
+}
+
+Dockable&
+DockManager::find_dockable(const synfig::String& x)
+{
+       std::list<Dockable*>::iterator iter;
+       for(iter=dockable_list_.begin();iter!=dockable_list_.end();++iter)
+               if((*iter)->get_name()==x)
+                       return **iter;
+
+       throw std::runtime_error("DockManager::find_dockable(): not found");
+}
+
+void
+DockManager::present(synfig::String x)
+{
+       try
+       {
+               find_dockable(x).present();
+       }
+       catch(...)
+       {
+       }
+}
+
+DockDialog&
+DockManager::find_dock_dialog(int id)
+{
+       std::list<DockDialog*>::iterator iter;
+       for(iter=dock_dialog_list_.begin();iter!=dock_dialog_list_.end();++iter)
+               if((*iter)->get_id()==id)
+                       return **iter;
+
+       DockDialog* dock_dialog(new DockDialog());
+       dock_dialog->set_id(id);
+       dock_dialog->show();
+       return *dock_dialog;
+}
+
+const DockDialog&
+DockManager::find_dock_dialog(int id)const
+{
+       std::list<DockDialog*>::const_iterator iter;
+       for(iter=dock_dialog_list_.begin();iter!=dock_dialog_list_.end();++iter)
+               if((*iter)->get_id()==id)
+                       return **iter;
+
+       throw std::runtime_error("DockManager::find_dock_dialog(int id)const: not found");
+}
diff --git a/synfig-studio/src/gui/dockmanager.h b/synfig-studio/src/gui/dockmanager.h
new file mode 100644 (file)
index 0000000..98df376
--- /dev/null
@@ -0,0 +1,82 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dockmanager.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_DOCKMANAGER_H
+#define __SYNFIG_DOCKMANAGER_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <vector>
+#include <list>
+#include <synfig/string.h>
+#include <sigc++/signal.h>
+#include <sigc++/object.h>
+#include <ETL/smart_ptr>
+
+/* === 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 Dockable;
+class DockDialog;
+class DockSettings;
+
+class DockManager : public sigc::trackable
+{
+       friend class Dockable;
+       friend class DockDialog;
+       friend class DockSettings;
+
+       std::list<Dockable*> dockable_list_;
+       std::list<DockDialog*> dock_dialog_list_;
+
+       sigc::signal<void,Dockable*> signal_dockable_registered_;
+
+       etl::smart_ptr<DockSettings> dock_settings;
+
+public:
+       DockManager();
+       ~DockManager();
+
+       DockDialog& find_dock_dialog(int id);
+       const DockDialog& find_dock_dialog(int id)const;
+
+       sigc::signal<void,Dockable*>& signal_dockable_registered() { return signal_dockable_registered_; }
+
+       void register_dockable(Dockable& x);
+       bool unregister_dockable(Dockable& x);
+       Dockable& find_dockable(const synfig::String& x);
+       void present(synfig::String x);
+
+}; // END of class DockManager
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/duck.cpp b/synfig-studio/src/gui/duck.cpp
new file mode 100644 (file)
index 0000000..14ea8d0
--- /dev/null
@@ -0,0 +1,300 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file duck.cpp
+**     \brief Template 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 <config.h>
+#endif
+
+#include "duck.h"
+#include <ETL/misc>
+
+#include <synfig/valuenode_bline.h>
+#include <synfig/valuenode_blinecalctangent.h>
+#include <synfig/valuenode_blinecalcvertex.h>
+#include <synfig/valuenode_blinecalcwidth.h>
+#include <synfig/valuenode_composite.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 ======================================================= */
+
+int studio::Duck::duck_count(0);
+
+struct _DuckCounter
+{
+       static int counter;
+       ~_DuckCounter()
+       {
+               if(counter)
+                       synfig::error("%d ducks not yet deleted!",counter);
+       }
+} _duck_counter;
+
+int _DuckCounter::counter(0);
+
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Duck::Duck():
+       rotations(synfig::Angle::deg(0)),
+       origin(0,0),
+       scalar(1),
+       editable(false),
+       radius_(false),
+       tangent_(false),
+       hover_(false),
+       ignore_(false)
+{ duck_count++; _DuckCounter::counter++; }
+
+Duck::Duck(const synfig::Point &point):
+       type_(TYPE_NONE),
+       point(point),
+       rotations(synfig::Angle::deg(0)),
+       origin(0,0),
+       scalar(1),
+       guid_(0),
+       editable(false),
+       radius_(false),
+       tangent_(false),
+       hover_(false),
+       ignore_(false)
+{ duck_count++; _DuckCounter::counter++;}
+
+Duck::Duck(const synfig::Point &point,const synfig::Point &origin):
+       point(point),
+       rotations(synfig::Angle::deg(0)),
+       origin(origin),
+       scalar(1),
+       guid_(0),
+       editable(false),
+       radius_(true),
+       tangent_(false),
+       hover_(false),
+       ignore_(false)
+{ duck_count++; _DuckCounter::counter++;}
+
+Duck::~Duck() { duck_count--; _DuckCounter::counter--;}
+
+synfig::GUID
+Duck::get_data_guid()const
+{
+       if(value_desc_.is_value_node())
+               return value_desc_.get_value_node()->get_guid();
+       return synfig::GUID::hasher(get_name());
+}
+
+void
+Duck::set_name(const synfig::String &x)
+{
+       name=x;
+       if(guid_==synfig::GUID::zero())
+       {
+               guid_=synfig::GUID::hasher(name);
+       }
+}
+
+
+bool
+Duck::operator==(const Duck &rhs)const
+{
+       if(this==&rhs)
+               return true;
+       return
+               name==rhs.name &&
+               scalar==rhs.scalar &&
+               type_==rhs.type_ &&
+               transform_stack_.size()==rhs.transform_stack_.size();
+               //true;
+               //(origin_duck?*origin_duck==*rhs.origin_duck:origin==rhs.origin) &&
+               //(shared_point?*shared_point==*rhs.shared_point:point==rhs.point) ;
+}
+
+synfig::Point
+Duck::get_trans_point()const
+{
+       return transform_stack_.perform(get_sub_trans_point());
+}
+
+void
+Duck::set_trans_point(const synfig::Point &x)
+{
+       set_sub_trans_point(transform_stack_.unperform(x));
+}
+
+void
+Duck::set_trans_point(const synfig::Point &x, const synfig::Time &time)
+{
+       set_sub_trans_point(transform_stack_.unperform(x), time);
+}
+
+//! Sets the origin point.
+void
+Duck::set_origin(const synfig::Point &x)
+{
+       origin=x; origin_duck=0;
+}
+
+//! Sets the origin point as another duck
+void
+Duck::set_origin(const etl::handle<Duck> &x)
+{
+       origin_duck=x;
+}
+
+//! Retrieves the origin location
+synfig::Point
+Duck::get_origin()const
+{
+       return origin_duck?origin_duck->get_point():origin;
+}
+
+//! Retrieves the origin duck
+const etl::handle<Duck> &
+Duck::get_origin_duck() const
+{
+       return origin_duck;
+}
+
+//! Retrieves the origin location
+synfig::Point
+Duck::get_trans_origin()const
+{
+       return transform_stack_.perform(get_sub_trans_origin());
+}
+
+synfig::Point
+Duck::get_sub_trans_point()const
+{
+       return get_point()*get_scalar()+get_sub_trans_origin();
+}
+
+void
+Duck::set_sub_trans_point(const synfig::Point &x, const synfig::Time &time)
+{
+       if (get_type() == Duck::TYPE_TANGENT ||
+               get_type() == Duck::TYPE_ANGLE)
+       {
+               Angle old_angle = get_point().angle();
+               set_point((x-get_sub_trans_origin())/get_scalar());
+               Angle change = get_point().angle() - old_angle;
+               while (change < Angle::deg(-180)) change += Angle::deg(360);
+               while (change > Angle::deg(180)) change -= Angle::deg(360);
+               int old_halves = round_to_int(Angle::deg(rotations).get()/180);
+               rotations += change;
+               int new_halves = round_to_int(Angle::deg(rotations).get()/180);
+               if (old_halves != new_halves &&
+                       (new_halves > 1 || new_halves < -1 ||
+                        old_halves > 1 || old_halves < -1))
+                       synfig::info("rotation: %.2f turns", new_halves/2.0);
+       } else if(get_type() == Duck::TYPE_VERTEX || get_type() == Duck::TYPE_POSITION)
+       {
+               set_point((x-get_sub_trans_origin())/get_scalar());
+
+               ValueNode_BLineCalcVertex::Handle bline_vertex;
+               ValueNode_Composite::Handle composite;
+
+               if ((bline_vertex = ValueNode_BLineCalcVertex::Handle::cast_dynamic(get_value_desc().get_value_node())) ||
+                       ((composite = ValueNode_Composite::Handle::cast_dynamic(get_value_desc().get_value_node())) &&
+                        composite->get_type() == ValueBase::TYPE_BLINEPOINT &&
+                        (bline_vertex = ValueNode_BLineCalcVertex::Handle::cast_dynamic(composite->get_link("point")))))
+               {
+                       synfig::Point closest_point = get_point();
+                       synfig::Real radius = 0.0;
+                       ValueNode_BLine::Handle bline = ValueNode_BLine::Handle::cast_dynamic(bline_vertex->get_link(bline_vertex->get_link_index_from_name("bline")));
+                       synfig::find_closest_point(
+                               (*bline)(time),
+                               get_point(),
+                               radius,
+                               bline->get_loop(),
+                               &closest_point);
+                       set_point(closest_point);
+               }
+       }
+       else set_point((x-get_sub_trans_origin())/get_scalar());
+}
+
+void
+Duck::set_sub_trans_point(const synfig::Point &x)
+{
+       if (get_type() == Duck::TYPE_TANGENT ||
+               get_type() == Duck::TYPE_ANGLE)
+       {
+               Angle old_angle = get_point().angle();
+               set_point((x-get_sub_trans_origin())/get_scalar());
+               Angle change = get_point().angle() - old_angle;
+               while (change < Angle::deg(-180)) change += Angle::deg(360);
+               while (change > Angle::deg(180)) change -= Angle::deg(360);
+               int old_halves = round_to_int(Angle::deg(rotations).get()/180);
+               rotations += change;
+               int new_halves = round_to_int(Angle::deg(rotations).get()/180);
+               if (old_halves != new_halves &&
+                       (new_halves > 1 || new_halves < -1 ||
+                        old_halves > 1 || old_halves < -1))
+                       synfig::info("rotation: %.2f turns", new_halves/2.0);
+       }
+       else set_point((x-get_sub_trans_origin())/get_scalar());
+}
+
+synfig::Point
+Duck::get_sub_trans_origin()const
+{
+       return origin_duck?origin_duck->get_sub_trans_point():origin;
+}
+
+#ifdef _DEBUG
+synfig::String
+Duck::type_name(Type id)
+{
+       String ret;
+
+       if (id & TYPE_POSITION) { if (!ret.empty()) ret += ", "; ret += "position"; }
+       if (id & TYPE_TANGENT ) { if (!ret.empty()) ret += ", "; ret += "tangent" ; }
+       if (id & TYPE_RADIUS  ) { if (!ret.empty()) ret += ", "; ret += "radius"  ; }
+       if (id & TYPE_WIDTH       ) { if (!ret.empty()) ret += ", "; ret += "width"   ; }
+       if (id & TYPE_ANGLE       ) { if (!ret.empty()) ret += ", "; ret += "angle"   ; }
+       if (id & TYPE_VERTEX  ) { if (!ret.empty()) ret += ", "; ret += "vertex"  ; }
+
+       if (ret.empty())
+               ret = "none";
+
+       return ret;
+}
+#endif // _DEBUG
diff --git a/synfig-studio/src/gui/duck.h b/synfig-studio/src/gui/duck.h
new file mode 100644 (file)
index 0000000..9a054f3
--- /dev/null
@@ -0,0 +1,307 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file duck.h
+**     \brief Template Header
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_DUCKMATIC_DUCK_H
+#define __SYNFIG_DUCKMATIC_DUCK_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <list>
+
+#include <ETL/smart_ptr>
+#include <ETL/handle>
+
+#include <synfig/vector.h>
+#include <synfig/string.h>
+#include <synfig/real.h>
+#include <sigc++/signal.h>
+#include <sigc++/object.h>
+#include <synfig/time.h>
+#include <ETL/smart_ptr>
+#include <synfigapp/value_desc.h>
+#include <synfig/transform.h>
+
+/* === M A C R O S ========================================================= */
+
+#ifdef HASH_MAP_H
+#include HASH_MAP_H
+#include FUNCTIONAL_H
+
+#ifndef __STRING_HASH__
+#define __STRING_HASH__
+class StringHash
+{
+# ifdef FUNCTIONAL_HASH_ON_STRING
+       HASH_MAP_NAMESPACE::hash<synfig::String> hasher_;
+# else  // FUNCTIONAL_HASH_ON_STRING
+       HASH_MAP_NAMESPACE::hash<const char*> hasher_;
+# endif  // FUNCTIONAL_HASH_ON_STRING
+public:
+       size_t operator()(const synfig::String& x)const
+       {
+# ifdef FUNCTIONAL_HASH_ON_STRING
+               return hasher_(x);
+# else  // FUNCTIONAL_HASH_ON_STRING
+               return hasher_(x.c_str());
+# endif  // FUNCTIONAL_HASH_ON_STRING
+       }
+};
+#endif
+#else
+#include <map>
+#endif
+
+#include <set>
+
+/* === 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 Duckmatic;
+
+/*! \class Duck
+**     \writeme */
+class Duck : public etl::shared_object
+{
+       friend class Duckmatic;
+
+public:
+       enum Type
+       {
+               TYPE_NONE               =       (0),    //  0
+               TYPE_POSITION   =       (1<<0), //  1
+               TYPE_TANGENT    =       (1<<1), //  2
+               TYPE_RADIUS             =       (1<<2), //  4
+               TYPE_WIDTH              =       (1<<3), //  8
+               TYPE_ANGLE              =       (1<<4), // 16
+               TYPE_VERTEX             =       (1<<5), // 32
+
+               TYPE_ALL                =       (~0),
+
+               TYPE_DEFAULT    =       0xdefadefa
+       };
+
+       typedef etl::handle<Duck> Handle;
+       typedef etl::loose_handle<Duck> LooseHandle;
+
+private:
+
+       sigc::signal<bool,const synfig::Point &> signal_edited_;
+       sigc::signal<bool,const synfig::Angle &> signal_edited_angle_;
+       sigc::signal<void> signal_user_click_[5];
+
+       Type type_;
+
+       synfig::Point point;
+       synfig::Angle rotations;
+
+       etl::smart_ptr<synfig::Point> shared_point;
+
+       synfig::Point origin;
+       synfig::String name;
+       synfig::Real scalar;
+
+       etl::handle<Duck> origin_duck;
+
+       etl::handle<Duck> connect_duck;
+       etl::handle<Duck> box_duck;
+
+       synfig::GUID guid_;
+
+       // Flags
+       bool editable;
+       bool radius_;
+       bool tangent_;
+       bool hover_;
+       bool ignore_;
+
+       synfig::TransformStack transform_stack_;
+
+       synfigapp::ValueDesc value_desc_;
+
+       static int duck_count;
+public:
+       Duck();
+       Duck(const synfig::Point &point);
+       Duck(const synfig::Point &point,const synfig::Point &origin);
+       ~Duck();
+
+       sigc::signal<bool,const synfig::Point &> &signal_edited() { return signal_edited_; }
+       sigc::signal<bool,const synfig::Angle &> &signal_edited_angle() { return signal_edited_angle_; }
+       sigc::signal<void> &signal_user_click(int i=0) { assert(i>=0); assert(i<5); return signal_user_click_[i]; }
+
+       void set_guid(const synfig::GUID& x) { guid_=x; }
+       const synfig::GUID& get_guid()const { return guid_; }
+
+       synfig::GUID get_data_guid()const;
+
+       //! Changes the editable flag. If set, the duck will not be able to be moved.
+       void set_editable(bool x) { editable=x; }
+
+       //! Retrieves the status of the editable flag
+       bool get_editable()const { return editable; }
+
+       //! \writeme
+       void set_tangent(bool x) { tangent_=x; type_=TYPE_TANGENT; }
+
+       //! \writeme
+       bool get_tangent()const { return tangent_; }
+
+       //! Sets whether to show the duck as if it is being hovered over
+       void set_hover(bool h) { hover_=h; }
+
+       //! Retrieves whether to show the duck as if it is being hovered over
+       bool get_hover()const { return hover_; }
+
+       //! Sets whether to ignore the duck when checking for user interaction
+       void set_ignore(bool i) { ignore_=i; }
+
+       //! Retrieves whether to ignore the duck when checking for user interaction
+       bool get_ignore()const { return ignore_; }
+
+       void set_connect_duck(const etl::handle<Duck>& x) { connect_duck=x; }
+       void set_box_duck(const etl::handle<Duck>& x) { box_duck=x; }
+
+       const etl::handle<Duck>& get_connect_duck()const { return connect_duck; }
+       const etl::handle<Duck>& get_box_duck()const { return box_duck; }
+
+       void set_value_desc(synfigapp::ValueDesc x) { value_desc_=x; }
+
+       synfigapp::ValueDesc& get_value_desc() { return value_desc_; }
+
+       void set_transform_stack(const synfig::TransformStack& x) { transform_stack_=x; }
+
+       const synfig::TransformStack& get_transform_stack()const { return transform_stack_; }
+
+       //! \writeme
+       void set_type(Type x) { type_=x; }
+
+       //! \writeme
+       Type get_type()const { return type_; }
+
+       //! Sets the scalar multiplier for the duck with respect to the origin
+       void set_scalar(synfig::Vector::value_type n) { scalar=n; }
+
+       //! Retrieves the scalar value
+       synfig::Vector::value_type get_scalar()const { return scalar; }
+
+       void set_shared_point(const etl::smart_ptr<synfig::Point>&x) { shared_point=x; }
+
+       //! Sets the location of the duck with respect to the origin
+       void set_point(const synfig::Point &x) { (shared_point?*shared_point:point)=x; }
+
+       //! Returns the location of the duck
+       synfig::Point get_point()const { return shared_point?*shared_point:point; }
+
+       synfig::Angle get_rotations()const { return rotations; };
+       void set_rotations(const synfig::Angle &x) { rotations=x; };
+
+       synfig::Point get_trans_point()const;
+
+       void set_trans_point(const synfig::Point &x);
+       void set_trans_point(const synfig::Point &x, const synfig::Time &time);
+
+       synfig::Point get_sub_trans_point()const;
+       void set_sub_trans_point(const synfig::Point &x);
+       void set_sub_trans_point(const synfig::Point &x, const synfig::Time &time);
+       synfig::Point get_sub_trans_origin()const;
+
+       //! Sets the origin point.
+       void set_origin(const synfig::Point &x);
+
+       //! Sets the origin point as another duck
+       void set_origin(const etl::handle<Duck> &x);
+
+       //! Retrieves the origin location
+       synfig::Point get_origin()const;
+
+       //! Retrieves the origin duck
+       const etl::handle<Duck> & get_origin_duck() const;
+
+       //! Retrieves the origin location
+       synfig::Point get_trans_origin()const;
+
+       void set_radius(bool r) { radius_=r; }
+       bool is_radius()const { return radius_; }
+
+       //! Sets the name of the duck
+       void set_name(const synfig::String &x);
+
+       //! Retrieves the name of the duck
+       synfig::String get_name()const { return name; }
+
+       bool operator==(const Duck &rhs)const;
+
+#ifdef _DEBUG
+       //!     Returns a string containing the name of the given Type
+       static synfig::String type_name(Type id);
+
+       //!     Returns a string containing the name of the type
+       synfig::String type_name()const { return type_name(get_type()); }
+#endif // _DEBUG
+
+}; // END of class Duck
+
+//! Combine Flags
+inline Duck::Type
+operator|(Duck::Type lhs, const Duck::Type rhs)
+{ return static_cast<Duck::Type>(int(lhs)|int(rhs)); }
+
+//! Exclude Flags
+inline Duck::Type
+operator-(Duck::Type lhs, const Duck::Type rhs)
+{ return static_cast<Duck::Type>(int(lhs)&~int(rhs)); }
+
+inline Duck::Type&
+operator|=(Duck::Type& lhs, const Duck::Type rhs)
+{ *reinterpret_cast<int*>(&lhs)|=int(rhs); return lhs; }
+
+inline Duck::Type
+operator&(const Duck::Type lhs, const Duck::Type rhs)
+{ return static_cast<Duck::Type>(int(lhs)&int(rhs)); }
+
+class DuckMap : public
+#ifdef HASH_MAP_H
+HASH_MAP_CLASS<synfig::GUID,etl::handle<studio::Duck>,synfig::GUIDHash>
+{
+       typedef HASH_MAP_CLASS<synfig::GUID,etl::handle<studio::Duck>,synfig::GUIDHash> PARENT_TYPE;
+#else
+std::map<synfig::GUID,etl::handle<studio::Duck> >
+{
+       typedef std::map<synfig::GUID,etl::handle<studio::Duck> > PARENT_TYPE;
+#endif
+public:
+       void insert(const Duck::Handle& x) { operator[](x->get_guid())=x;  }
+}; // END of class DuckMap
+
+typedef std::list<Duck::Handle> DuckList;
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/duckmatic.cpp b/synfig-studio/src/gui/duckmatic.cpp
new file mode 100644 (file)
index 0000000..786aa11
--- /dev/null
@@ -0,0 +1,1923 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file duckmatic.cpp
+**     \brief Template 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 <config.h>
+#endif
+#include <fstream>
+#include <iostream>
+#include <algorithm>
+
+#include <ETL/hermite>
+
+#include "duckmatic.h"
+#include <synfigapp/value_desc.h>
+#include <synfig/general.h>
+#include <synfig/paramdesc.h>
+#include <synfig/valuenode_timedswap.h>
+#include <synfig/valuenode_animated.h>
+#include <synfig/valuenode_composite.h>
+#include <synfig/valuenode_scale.h>
+#include <synfig/valuenode_bline.h>
+#include <synfig/valuenode_blinecalctangent.h>
+#include <synfig/valuenode_blinecalcvertex.h>
+#include <synfig/valuenode_blinecalcwidth.h>
+
+#include <synfig/curve_helper.h>
+
+#include <sigc++/retype_return.h>
+#include <sigc++/retype.h>
+#include <sigc++/hide.h>
+#include <sigc++/bind.h>
+
+#include "canvasview.h"
+
+#include "onemoment.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 ========================================================= */
+
+/* 0.33333333333333333 makes for nice short tangent handles,
+   1.0 makes them draw as their real length */
+#define TANGENT_HANDLE_SCALE 0.33333333333333333
+
+/* leave this alone or the bezier won't lie on top of the bline */
+#define TANGENT_BEZIER_SCALE 0.33333333333333333
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+/* === E N T R Y P O I N T ================================================= */
+
+Duckmatic::Duckmatic():
+       type_mask(Duck::TYPE_ALL-Duck::TYPE_WIDTH),
+       grid_snap(false),
+       guide_snap(false),
+       grid_size(1.0/4.0,1.0/4.0),
+       show_persistent_strokes(true)
+{
+       axis_lock=false;
+       drag_offset_=Point(0,0);
+       clear_duck_dragger();
+}
+
+Duckmatic::~Duckmatic()
+{
+       clear_ducks();
+
+       if (Duck::duck_count)
+               synfig::error("%d ducks not yet deleted!", Duck::duck_count);
+
+       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
+               synfig::info("Duckmatic::~Duckmatic(): Deleted");
+}
+
+void
+Duckmatic::clear_ducks()
+{
+       duck_data_share_map.clear();
+       duck_map.clear();
+
+       //duck_list_.clear();
+       bezier_list_.clear();
+       stroke_list_.clear();
+
+       if(show_persistent_strokes)
+               stroke_list_=persistent_stroke_list_;
+}
+
+//! Returns \a true if the given duck is currently selected
+bool
+Duckmatic::duck_is_selected(const etl::handle<Duck> &duck)const
+{
+       return duck && selected_ducks.count(duck->get_guid());
+}
+
+void
+Duckmatic::set_grid_size(const synfig::Vector &s)
+{
+       if(grid_size!=s)
+       {
+               grid_size=s;
+               signal_grid_changed();
+       }
+}
+
+void
+Duckmatic::set_grid_snap(bool x)
+{
+       if(grid_snap!=x)
+       {
+               grid_snap=x;
+               signal_grid_changed();
+       }
+}
+
+void
+Duckmatic::set_guide_snap(bool x)
+{
+       if(guide_snap!=x)
+       {
+               guide_snap=x;
+               signal_grid_changed();
+       }
+}
+
+Duckmatic::GuideList::iterator
+Duckmatic::find_guide_x(synfig::Point pos, float radius)
+{
+       GuideList::iterator iter,best(guide_list_x_.end());
+       float dist(radius);
+       for(iter=guide_list_x_.begin();iter!=guide_list_x_.end();++iter)
+       {
+               float amount(abs(*iter-pos[0]));
+               if(amount<dist)
+               {
+                       dist=amount;
+                       best=iter;
+               }
+       }
+       return best;
+}
+
+Duckmatic::GuideList::iterator
+Duckmatic::find_guide_y(synfig::Point pos, float radius)
+{
+       GuideList::iterator iter,best(guide_list_y_.end());
+       float dist(radius);
+       for(iter=guide_list_y_.begin();iter!=guide_list_y_.end();++iter)
+       {
+               float amount(abs(*iter-pos[1]));
+               if(amount<=dist)
+               {
+                       dist=amount;
+                       best=iter;
+               }
+       }
+       return best;
+}
+
+void
+Duckmatic::clear_selected_ducks()
+{
+       selected_ducks.clear();
+       signal_duck_selection_changed_();
+}
+
+etl::handle<Duckmatic::Duck>
+Duckmatic::get_selected_duck()const
+{
+       if(selected_ducks.empty() || duck_map.empty())
+               return 0;
+       return duck_map.find(*selected_ducks.begin())->second;
+}
+
+void
+Duckmatic::refresh_selected_ducks()
+{
+/*
+       std::set<etl::handle<Duck> >::iterator iter;
+       std::set<etl::handle<Duck> > new_set;
+       if(duck_list().empty())
+       {
+               selected_duck_list.clear();
+               signal_duck_selection_changed_();
+               return;
+       }
+
+       for(iter=selected_duck_list.begin();iter!=selected_duck_list.end();++iter)
+       {
+               etl::handle<Duck> similar(find_similar_duck(*iter));
+               if(similar)
+               {
+                       new_set.insert(similar);
+               }
+       }
+       selected_duck_list=new_set;
+*/
+       GUIDSet old_set(selected_ducks);
+       GUIDSet::const_iterator iter;
+
+       for(iter=old_set.begin();iter!=old_set.end();++iter)
+       {
+               if(duck_map.count(*iter)==0)
+                       selected_ducks.erase(*iter);
+       }
+
+       signal_duck_selection_changed_();
+}
+
+bool
+Duckmatic::is_duck_group_selectable(const etl::handle<Duck>& x)const
+{
+       const Type type(get_type_mask());
+
+       if (((x->get_type() && (!(type & x->get_type()))) ||
+                !x->get_editable()))
+               return false;
+
+       synfigapp::ValueDesc value_desc(x->get_value_desc());
+       if(value_desc.parent_is_layer_param() && type & Duck::TYPE_POSITION)
+       {
+               Layer::Handle layer(value_desc.get_layer());
+               String layer_name(layer->get_name());
+
+               if (layer_name == "outline" || layer_name == "region" || layer_name == "plant" ||
+                       layer_name == "polygon" || layer_name == "curve_gradient")
+                       return false;
+
+               if((layer_name=="PasteCanvas"|| layer_name=="paste_canvas") &&
+                  !layer->get_param("children_lock").get(bool()))
+                       return false;
+       }
+       else if (value_desc.parent_is_value_node())
+       {
+               if (ValueNode_BLineCalcVertex::Handle::cast_dynamic(value_desc.get_value_node()))
+                       return false;
+               if (value_desc.parent_is_linkable_value_node())
+               {
+                       LinkableValueNode::Handle parent_value_node(value_desc.get_parent_value_node());
+                       if (ValueNode_Composite::Handle::cast_dynamic(parent_value_node))
+                       {
+                               if (parent_value_node->get_type() == ValueBase::TYPE_BLINEPOINT &&
+                                       ValueNode_BLineCalcVertex::Handle::cast_dynamic(
+                                               parent_value_node->get_link("point")))
+                                       return false;
+                       }
+                       else if (ValueNode_BLine::Handle::cast_dynamic(parent_value_node))
+                       {
+                               ValueNode_Composite::Handle composite(ValueNode_Composite::Handle::cast_dynamic(
+                                                                                                                 value_desc.get_value_node()));
+                               if (composite &&
+                                       ValueNode_BLineCalcVertex::Handle::cast_dynamic(composite->get_link("point")))
+                                       return false;
+                       }
+               }
+       }
+       return true;
+}
+
+void
+Duckmatic::select_all_ducks()
+{
+       DuckMap::const_iterator iter;
+       for(iter=duck_map.begin();iter!=duck_map.end();++iter)
+               if(is_duck_group_selectable(iter->second))
+                       select_duck(iter->second);
+               else
+                       unselect_duck(iter->second);
+}
+
+void
+Duckmatic::unselect_all_ducks()
+{
+       DuckMap::const_iterator iter;
+       for(iter=duck_map.begin();iter!=duck_map.end();++iter)
+               unselect_duck(iter->second);
+}
+
+void
+Duckmatic::toggle_select_ducks_in_box(const synfig::Vector& tl,const synfig::Vector& br)
+{
+       Vector vmin, vmax;
+       vmin[0]=std::min(tl[0],br[0]);
+       vmin[1]=std::min(tl[1],br[1]);
+       vmax[0]=std::max(tl[0],br[0]);
+       vmax[1]=std::max(tl[1],br[1]);
+
+       DuckMap::const_iterator iter;
+       for(iter=duck_map.begin();iter!=duck_map.end();++iter)
+       {
+               Point p(iter->second->get_trans_point());
+               if(p[0]<=vmax[0] && p[0]>=vmin[0] && p[1]<=vmax[1] && p[1]>=vmin[1] &&
+                  is_duck_group_selectable(iter->second))
+                       toggle_select_duck(iter->second);
+       }
+}
+
+void
+Duckmatic::select_ducks_in_box(const synfig::Vector& tl,const synfig::Vector& br)
+{
+       Vector vmin, vmax;
+       vmin[0]=std::min(tl[0],br[0]);
+       vmin[1]=std::min(tl[1],br[1]);
+       vmax[0]=std::max(tl[0],br[0]);
+       vmax[1]=std::max(tl[1],br[1]);
+
+//     Type type(get_type_mask());
+
+       DuckMap::const_iterator iter;
+       for(iter=duck_map.begin();iter!=duck_map.end();++iter)
+       {
+               Point p(iter->second->get_trans_point());
+               if(p[0]<=vmax[0] && p[0]>=vmin[0] && p[1]<=vmax[1] && p[1]>=vmin[1])
+               {
+                       if(is_duck_group_selectable(iter->second))
+                               select_duck(iter->second);
+               }
+       }
+}
+
+int
+Duckmatic::count_selected_ducks()const
+{
+       return selected_ducks.size();
+}
+
+void
+Duckmatic::select_duck(const etl::handle<Duck> &duck)
+{
+       if(duck)
+       {
+               selected_ducks.insert(duck->get_guid());
+               signal_duck_selection_changed_();
+       }
+}
+
+DuckList
+Duckmatic::get_selected_ducks()const
+{
+       DuckList ret;
+       GUIDSet::const_iterator iter;
+       const Type type(get_type_mask());
+
+       for(iter=selected_ducks.begin();iter!=selected_ducks.end();++iter)
+       {
+               const DuckMap::const_iterator d_iter(duck_map.find(*iter));
+
+               if(d_iter==duck_map.end())
+                       continue;
+
+               if(( d_iter->second->get_type() && (!(type & d_iter->second->get_type())) ) )
+                       continue;
+
+               ret.push_back(d_iter->second);
+       }
+       return ret;
+}
+
+DuckList
+Duckmatic::get_duck_list()const
+{
+       DuckList ret;
+       DuckMap::const_iterator iter;
+       for(iter=duck_map.begin();iter!=duck_map.end();++iter) if (iter->second->get_type()&Duck::TYPE_POSITION) ret.push_back(iter->second);
+       for(iter=duck_map.begin();iter!=duck_map.end();++iter) if (iter->second->get_type()&Duck::TYPE_VERTEX  ) ret.push_back(iter->second);
+       for(iter=duck_map.begin();iter!=duck_map.end();++iter) if (iter->second->get_type()&Duck::TYPE_TANGENT ) ret.push_back(iter->second);
+       for(iter=duck_map.begin();iter!=duck_map.end();++iter)
+               if (!(iter->second->get_type()&Duck::TYPE_POSITION) &&
+                       !(iter->second->get_type()&Duck::TYPE_VERTEX) &&
+                       !(iter->second->get_type()&Duck::TYPE_TANGENT))
+                       ret.push_back(iter->second);
+       return ret;
+}
+
+void
+Duckmatic::unselect_duck(const etl::handle<Duck> &duck)
+{
+       if(duck && selected_ducks.count(duck->get_guid()))
+       {
+               selected_ducks.erase(duck->get_guid());
+               signal_duck_selection_changed_();
+       }
+}
+
+void
+Duckmatic::toggle_select_duck(const etl::handle<Duck> &duck)
+{
+       if(duck_is_selected(duck))
+               unselect_duck(duck);
+       else
+               select_duck(duck);
+}
+
+void
+Duckmatic::translate_selected_ducks(const synfig::Vector& vector)
+{
+       if(duck_dragger_)
+               duck_dragger_->duck_drag(this,vector);
+}
+
+void
+Duckmatic::start_duck_drag(const synfig::Vector& offset)
+{
+       if(duck_dragger_)
+               duck_dragger_->begin_duck_drag(this,offset);
+
+       //drag_offset_=offset;
+       drag_offset_=find_duck(offset)->get_trans_point();
+}
+
+void
+Duckmatic::update_ducks()
+{
+       Time time(get_time());
+       DuckList duck_list(get_duck_list());
+       const DuckList selected_ducks(get_selected_ducks());
+       DuckList::const_iterator iter;
+       for (iter=selected_ducks.begin(); iter!=selected_ducks.end(); ++iter)
+       {
+               etl::handle<Duck> duck(*iter);
+               if (duck->get_type() == Duck::TYPE_VERTEX || duck->get_type() == Duck::TYPE_POSITION)
+               {
+                       ValueNode_BLineCalcVertex::Handle bline_vertex;
+                       ValueNode_Composite::Handle composite;
+
+                       if ((bline_vertex = ValueNode_BLineCalcVertex::Handle::cast_dynamic(duck->get_value_desc().get_value_node())) ||
+                               ((composite = ValueNode_Composite::Handle::cast_dynamic(duck->get_value_desc().get_value_node())) &&
+                                composite->get_type() == ValueBase::TYPE_BLINEPOINT &&
+                                (bline_vertex = ValueNode_BLineCalcVertex::Handle::cast_dynamic(composite->get_link("point")))))
+                       {
+                               DuckList::iterator iter;
+                               for (iter=duck_list.begin(); iter!=duck_list.end(); iter++)
+                                       if ( (*iter)->get_origin_duck()==duck  /*&& !duck_is_selected(*iter)*/ )
+                                       {
+                                               synfig::Real radius = 0.0;
+                                               ValueNode_BLine::Handle bline(ValueNode_BLine::Handle::cast_dynamic(bline_vertex->get_link(bline_vertex->get_link_index_from_name("bline"))));
+                                               Real amount = synfig::find_closest_point((*bline)(time), duck->get_point(), radius, bline->get_loop());
+
+                                               int vertex_amount_index(bline_vertex->get_link_index_from_name("amount"));
+                                               ValueNode::Handle vertex_amount_value_node(bline_vertex->get_link(vertex_amount_index));
+
+
+                                               ValueNode::Handle duck_value_node((*iter)->get_value_desc().get_value_node());
+                                               if (ValueNode_BLineCalcTangent::Handle bline_tangent = ValueNode_BLineCalcTangent::Handle::cast_dynamic(duck_value_node))
+                                               {
+                                                       if (bline_tangent->get_link(bline_tangent->get_link_index_from_name("amount")) == vertex_amount_value_node)
+                                                       {
+                                                               switch (bline_tangent->get_type())
+                                                               {
+                                                               case ValueBase::TYPE_ANGLE:
+                                                               {
+                                                                       Angle angle((*bline_tangent)(time, amount).get(Angle()));
+                                                                       (*iter)->set_point(Point(Angle::cos(angle).get(), Angle::sin(angle).get()));
+                                                                       (*iter)->set_rotations(Angle::deg(0)); //hack: rotations are a relative value
+                                                                       break;
+                                                               }
+                                                               case ValueBase::TYPE_REAL:
+                                                                       (*iter)->set_point(Point((*bline_tangent)(time, amount).get(Real()), 0));
+                                                                       break;
+                                                               case ValueBase::TYPE_VECTOR:
+                                                                       (*iter)->set_point((*bline_tangent)(time, amount).get(Vector()));
+                                                                       break;
+                                                               default:
+                                                                       break;
+                                                               }
+                                                       }
+                                               }
+                                               else if (ValueNode_BLineCalcWidth::Handle bline_width = ValueNode_BLineCalcWidth::Handle::cast_dynamic(duck_value_node))
+                                               {
+                                                       if (bline_width->get_link(bline_width->get_link_index_from_name("amount")) == vertex_amount_value_node)
+                                                               (*iter)->set_point(Point((*bline_width)(time, amount).get(Real()), 0));
+                                               }
+                                       }
+                       }
+               }
+       }
+}
+
+
+bool
+Duckmatic::end_duck_drag()
+{
+       if(duck_dragger_)
+               return duck_dragger_->end_duck_drag(this);
+       return false;
+}
+
+Point
+Duckmatic::snap_point_to_grid(const synfig::Point& x, float radius)const
+{
+       Point ret(x);
+
+       GuideList::const_iterator guide_x,guide_y;
+       bool has_guide_x(false), has_guide_y(false);
+
+       guide_x=find_guide_x(ret,radius);
+       if(guide_x!=guide_list_x_.end())
+               has_guide_x=true;
+
+       guide_y=find_guide_y(ret,radius);
+       if(guide_y!=guide_list_y_.end())
+               has_guide_y=true;
+
+       if(get_grid_snap())
+       {
+               Point snap(
+                       floor(ret[0]/get_grid_size()[0]+0.5)*get_grid_size()[0],
+                       floor(ret[1]/get_grid_size()[1]+0.5)*get_grid_size()[1]);
+
+               if(abs(snap[0]-ret[0])<=radius && (!has_guide_x || abs(snap[0]-ret[0])<=abs(*guide_x-ret[0])))
+                       ret[0]=snap[0],has_guide_x=false;
+               if(abs(snap[1]-ret[1])<=radius && (!has_guide_y || abs(snap[1]-ret[1])<=abs(*guide_y-ret[1])))
+                       ret[1]=snap[1],has_guide_y=false;
+       }
+
+       if(guide_snap)
+       {
+               if(has_guide_x)
+                       ret[0]=*guide_x;
+               if(has_guide_y)
+                       ret[1]=*guide_y;
+       }
+
+       if(axis_lock)
+       {
+               ret-=drag_offset_;
+               if(abs(ret[0])<abs(ret[1]))
+                       ret[0]=0;
+               else
+                       ret[1]=0;
+               ret+=drag_offset_;
+       }
+
+       return ret;
+}
+
+void
+DuckDrag_Translate::begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& offset)
+{
+       last_translate_=Vector(0,0);
+       {
+               drag_offset_=duckmatic->find_duck(offset)->get_trans_point();
+
+               snap=Vector(0,0);
+       }
+
+       const DuckList selected_ducks(duckmatic->get_selected_ducks());
+       DuckList::const_iterator iter;
+
+       positions.clear();
+       for(iter=selected_ducks.begin();iter!=selected_ducks.end();++iter)
+       {
+               Point p((*iter)->get_trans_point());
+               positions.push_back(p);
+       }
+}
+
+bool
+DuckDrag_Translate::end_duck_drag(Duckmatic* duckmatic)
+{
+       if(last_translate_.mag()>0.0001)
+       {
+               duckmatic->signal_edited_selected_ducks();
+               return true;
+       }
+       else
+       {
+               duckmatic->signal_user_click_selected_ducks(0);
+               return false;
+       }
+}
+
+void
+DuckDrag_Translate::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector)
+{
+       const DuckList selected_ducks(duckmatic->get_selected_ducks());
+       DuckList::const_iterator iter;
+
+       synfig::Vector vect(duckmatic->snap_point_to_grid(vector)-drag_offset_);
+       int i;
+       Time time(duckmatic->get_time());
+
+       // drag the vertex and position ducks first
+       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)
+                       (*iter)->set_trans_point(positions[i]+vect, time);
+
+       // then drag the others
+       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)
+                       (*iter)->set_trans_point(positions[i]+vect, time);
+
+       // then patch up the tangents for the vertices we've moved
+       duckmatic->update_ducks();
+
+       last_translate_=vect;
+}
+
+void
+Duckmatic::signal_edited_selected_ducks()
+{
+       const DuckList ducks(get_selected_ducks());
+       DuckList::const_iterator iter;
+
+       synfig::GUIDSet old_set(selected_ducks);
+
+       // If we have more than 20 things to move, then display
+       // something to explain that it may take a moment
+       smart_ptr<OneMoment> wait; if(ducks.size()>20)wait.spawn();
+
+       // Go ahead and call everyone's signals
+       for(iter=ducks.begin();iter!=ducks.end();++iter)
+       {
+               if ((*iter)->get_type() == Duck::TYPE_ANGLE)
+               {
+                       if(!(*iter)->signal_edited_angle()((*iter)->get_rotations()))
+                       {
+                               selected_ducks=old_set;
+                               throw String("Bad edit");
+                       }
+               }
+               else if (App::restrict_radius_ducks &&
+                                (*iter)->is_radius())
+               {
+                       Point point((*iter)->get_point());
+                       bool changed = false;
+
+                       if (point[0] < 0)
+                       {
+                               point[0] = 0;
+                               changed = true;
+                       }
+                       if (point[1] < 0)
+                       {
+                               point[1] = 0;
+                               changed = true;
+                       }
+
+                       if (changed) (*iter)->set_point(point);
+
+                       if(!(*iter)->signal_edited()(point))
+                       {
+                               selected_ducks=old_set;
+                               throw String("Bad edit");
+                       }
+               }
+               else
+               {
+                       if(!(*iter)->signal_edited()((*iter)->get_point()))
+                       {
+                               selected_ducks=old_set;
+                               throw String("Bad edit");
+                       }
+               }
+       }
+       selected_ducks=old_set;
+}
+
+void
+Duckmatic::signal_user_click_selected_ducks(int button)
+{
+       const DuckList ducks(get_selected_ducks());
+       DuckList::const_iterator iter;
+
+       for(iter=ducks.begin();iter!=ducks.end();++iter)
+       {
+               (*iter)->signal_user_click(button)();
+       }
+}
+
+void
+Duckmatic::add_duck(const etl::handle<Duck> &duck)
+{
+       //if(!duck_map.count(duck->get_guid()))
+       {
+               if(duck_data_share_map.count(duck->get_data_guid()))
+               {
+                       duck->set_shared_point(duck_data_share_map[duck->get_data_guid()]);
+               }
+               else
+               {
+                       etl::smart_ptr<synfig::Point> point(new Point(duck->get_point()));
+                       duck->set_shared_point(point);
+                       duck_data_share_map[duck->get_data_guid()]=point;
+               }
+
+               duck_map.insert(duck);
+       }
+
+       last_duck_guid=duck->get_guid();
+}
+
+void
+Duckmatic::add_bezier(const etl::handle<Bezier> &bezier)
+{
+       bezier_list_.push_back(bezier);
+}
+
+void
+Duckmatic::add_stroke(etl::smart_ptr<std::list<synfig::Point> > stroke_point_list, const synfig::Color& color)
+{
+       assert(stroke_point_list);
+
+       std::list<etl::handle<Stroke> >::iterator iter;
+
+       for(iter=stroke_list_.begin();iter!=stroke_list_.end();++iter)
+       {
+               if((*iter)->stroke_data==stroke_point_list)
+                       return;
+       }
+
+       etl::handle<Stroke> stroke(new Stroke());
+
+       stroke->stroke_data=stroke_point_list;
+       stroke->color=color;
+
+       stroke_list_.push_back(stroke);
+}
+
+void
+Duckmatic::add_persistent_stroke(etl::smart_ptr<std::list<synfig::Point> > stroke_point_list, const synfig::Color& color)
+{
+       add_stroke(stroke_point_list,color);
+       persistent_stroke_list_.push_back(stroke_list_.back());
+}
+
+void
+Duckmatic::clear_persistent_strokes()
+{
+       persistent_stroke_list_.clear();
+}
+
+void
+Duckmatic::set_show_persistent_strokes(bool x)
+{
+       if(x!=show_persistent_strokes)
+       {
+               show_persistent_strokes=x;
+               if(x)
+                       stroke_list_=persistent_stroke_list_;
+               else
+                       stroke_list_.clear();
+       }
+}
+
+void
+Duckmatic::erase_duck(const etl::handle<Duck> &duck)
+{
+       duck_map.erase(duck->get_guid());
+}
+
+etl::handle<Duckmatic::Duck>
+Duckmatic::find_similar_duck(etl::handle<Duck> duck)
+{
+       DuckMap::const_iterator iter(duck_map.find(duck->get_guid()));
+       if(iter!=duck_map.end())
+               return iter->second;
+       return 0;
+
+/*     std::list<handle<Duck> >::reverse_iterator iter;
+
+       for(iter=duck_list_.rbegin();iter!=duck_list_.rend();++iter)
+       {
+               if(*iter!=duck && **iter==*duck)
+               {
+                       //synfig::info("Found similar duck! (iter:%08x vs. duck:%08x)",iter->get(), duck.get());
+                       return *iter;
+               }
+       }
+       return 0;
+*/
+}
+
+etl::handle<Duckmatic::Duck>
+Duckmatic::add_similar_duck(etl::handle<Duck> duck)
+{
+       etl::handle<Duck> similar(find_similar_duck(duck));
+       if(!similar)
+       {
+               add_duck(duck);
+               return duck;
+       }
+       return similar;
+}
+
+void
+Duckmatic::erase_bezier(const etl::handle<Bezier> &bezier)
+{
+       std::list<handle<Bezier> >::iterator iter;
+
+       for(iter=bezier_list_.begin();iter!=bezier_list_.end();++iter)
+       {
+               if(*iter==bezier)
+               {
+                       bezier_list_.erase(iter);
+                       return;
+               }
+       }
+       synfig::warning("Unable to find bezier to erase!");
+}
+
+etl::handle<Duckmatic::Duck>
+Duckmatic::last_duck()const
+{
+       DuckMap::const_iterator iter(duck_map.find(last_duck_guid));
+       if(iter!=duck_map.end())
+               return iter->second;
+       return 0;
+}
+
+etl::handle<Duckmatic::Bezier>
+Duckmatic::last_bezier()const
+{
+       return bezier_list_.back();
+}
+
+etl::handle<Duckmatic::Duck>
+Duckmatic::find_duck(synfig::Point point, synfig::Real radius, Duck::Type type)
+{
+       if(radius==0)radius=10000000;
+
+       if(type==Duck::TYPE_DEFAULT)
+               type=get_type_mask();
+
+       Real closest(10000000);
+       etl::handle<Duck> ret;
+
+       DuckMap::const_iterator iter;
+
+       for(iter=duck_map.begin();iter!=duck_map.end();++iter)
+       {
+               const Duck::Handle& duck(iter->second);
+
+               if(duck->get_ignore() ||
+                  (duck->get_type() && !(type & duck->get_type())))
+                       continue;
+
+               Real dist((duck->get_trans_point()-point).mag_squared());
+
+               if(duck->get_type()&Duck::TYPE_VERTEX)
+                       dist*=1.0001;
+               else if(duck->get_type()&Duck::TYPE_TANGENT && duck->get_scalar()>0)
+                       dist*=1.00005;
+               else if(duck->get_type()&Duck::TYPE_RADIUS)
+                       dist*=0.9999;
+
+               if(dist<=closest)
+               {
+                       closest=dist;
+                       ret=duck;
+               }
+       }
+
+       if(radius==0 || closest<radius*radius)
+               return ret;
+
+       return 0;
+}
+
+etl::handle<Duckmatic::Bezier>
+Duckmatic::find_bezier(synfig::Point point, synfig::Real radius,float* location)
+{
+       return find_bezier(point,radius,radius,location);
+}
+
+etl::handle<Duckmatic::Bezier>
+Duckmatic::find_bezier(synfig::Point pos, synfig::Real scale, synfig::Real radius, float* location)
+{
+       if(radius==0)radius=10000000;
+       Real closest(10000000);
+       etl::handle<Bezier> ret;
+
+       bezier<Point>   curve;
+
+       Real    d,step;
+       float   time = 0;
+       float   best_time = 0;
+
+       for(std::list<handle<Bezier> >::const_iterator iter=bezier_list().begin();iter!=bezier_list().end();++iter)
+       {
+               curve[0] = (*iter)->p1->get_trans_point();
+               curve[1] = (*iter)->c1->get_trans_point();
+               curve[2] = (*iter)->c2->get_trans_point();
+               curve[3] = (*iter)->p2->get_trans_point();
+               curve.sync();
+
+#if 0
+               // I don't know why this doesn't work
+               time=curve.find_closest(pos,6);
+               d=((curve(time)-pos).mag_squared());
+
+#else
+               //set the step size based on the size of the picture
+               d = (curve[1] - curve[0]).mag() + (curve[2]-curve[1]).mag()     + (curve[3]-curve[2]).mag();
+
+               step = d/(2*scale); //want to make the distance between lines happy
+
+               step = max(step,0.01); //100 samples should be plenty
+               step = min(step,0.1); //10 is minimum
+
+               d = find_closest(curve,pos,step,&closest,&time);
+#endif
+
+               if(d < closest)
+               {
+                       closest = d;
+                       ret = *iter;
+                       best_time=time;
+               }
+       }
+
+       if(closest < radius*radius)
+       {
+               if(location)
+                       *location = best_time;  // We need to square-root this because we were dealing with squared distances
+
+               return ret;
+       }
+
+       return 0;
+}
+
+bool
+Duckmatic::save_sketch(const synfig::String& filename)const
+{
+       ChangeLocale change_locale(LC_NUMERIC, "C");
+       std::ofstream file(filename.c_str());
+
+       if(!file)return false;
+
+       file<<"SKETCH"<<endl;
+
+       std::list<etl::handle<Stroke> >::const_iterator iter;
+
+       for(iter=persistent_stroke_list_.begin();iter!=persistent_stroke_list_.end();++iter)
+       {
+               file<<"C "
+                       <<(*iter)->color.get_r()<<' '
+                       <<(*iter)->color.get_g()<<' '
+                       <<(*iter)->color.get_b()
+               <<endl;
+               std::list<synfig::Point>::const_iterator viter;
+               for(viter=(*iter)->stroke_data->begin();viter!=(*iter)->stroke_data->end();++viter)
+               {
+                       file<<"V "
+                               <<(*viter)[0]<<' '
+                               <<(*viter)[1]
+                       <<endl;
+               }
+       }
+       if(!file)return false;
+       sketch_filename_=filename;
+       signal_sketch_saved_();
+       return true;
+}
+
+bool
+Duckmatic::load_sketch(const synfig::String& filename)
+{
+       ChangeLocale change_locale(LC_NUMERIC, "C");
+       std::ifstream file(filename.c_str());
+
+       if(!file)
+               return false;
+
+       std::string line;
+       getline(file,line);
+
+       if(line!="SKETCH")
+       {
+               synfig::error("Not a sketch");
+               return false;
+       }
+
+       etl::smart_ptr<std::list<synfig::Point> > stroke_data;
+
+       while(file)
+       {
+               getline(file,line);
+
+               if(line.empty())
+                       continue;
+
+               switch(line[0])
+               {
+               case 'C':
+               case 'c':
+                       {
+                               stroke_data.spawn();
+                               float r,g,b;
+                               if(!strscanf(line,"C %f %f %f",&r, &g, &b))
+                               {
+                                       synfig::warning("Bad color line \"%s\"",line.c_str());
+                                       r=0;g=0;b=0;
+                               }
+                               add_persistent_stroke(stroke_data, synfig::Color(r,g,b));
+                       }
+                       break;
+               case 'V':
+               case 'v':
+                       if(!stroke_data)
+                       {
+                               stroke_data.spawn();
+                               add_persistent_stroke(stroke_data, synfig::Color(0,0,0));
+                       }
+                       float x,y;
+                       if(!strscanf(line,"V %f %f",&x, &y))
+                               synfig::warning("Bad vertex \"%s\"",line.c_str());
+                       else
+                               stroke_data->push_back(synfig::Vector(x,y));
+                       break;
+               default:
+                       synfig::warning("Unexpected sketch token '%c'",line[0]);
+                       break;
+               }
+       }
+
+       sketch_filename_=filename;
+       return true;
+}
+
+Duckmatic::Push::Push(Duckmatic *duckmatic_):
+       duckmatic_(duckmatic_)
+{
+       duck_map=duckmatic_->duck_map;
+       bezier_list_=duckmatic_->bezier_list_;
+       duck_data_share_map=duckmatic_->duck_data_share_map;
+       stroke_list_=duckmatic_->stroke_list_;
+       duck_dragger_=duckmatic_->duck_dragger_;
+       needs_restore=true;
+}
+
+Duckmatic::Push::~Push()
+{
+       if(needs_restore)
+               restore();
+}
+
+void
+Duckmatic::Push::restore()
+{
+       duckmatic_->duck_map=duck_map;
+       duckmatic_->bezier_list_=bezier_list_;
+       duckmatic_->duck_data_share_map=duck_data_share_map;
+       duckmatic_->stroke_list_=stroke_list_;
+       duckmatic_->duck_dragger_=duck_dragger_;
+       needs_restore=false;
+}
+
+inline String guid_string(const synfigapp::ValueDesc& x)
+{
+       if(x.parent_is_layer_param())
+               return strprintf("%s",x.get_layer()->get_guid().get_string().c_str())+x.get_param_name();
+       //if(x.is_value_node())
+               return strprintf("%s",x.get_value_node()->get_guid().get_string().c_str());
+}
+
+inline synfig::GUID calc_duck_guid(const synfigapp::ValueDesc& x,const synfig::TransformStack& transform_stack)
+{
+       synfig::GUID ret(0);
+
+       if(x.parent_is_layer_param())
+       {
+               ret=x.get_layer()->get_guid()^synfig::GUID::hasher(x.get_param_name());
+       }
+       else
+       {
+               ret=x.get_value_node()->get_guid();
+       }
+
+       ret^=transform_stack.get_guid();
+       return ret;
+}
+
+/*
+Duck::Handle
+Duckmatic::create_duck_from(const synfigapp::ValueDesc& value_desc,etl::handle<CanvasView> canvas_view, const synfig::TransformStack& transform_stack, int modifier, synfig::ParamDesc *param_desc)
+{
+       synfig::GUID duck_guid(calc_duck_guid(value_desc,transform_stack)^synfig::GUID::hasher(modifier));
+       etl::handle<Duck> duck=new Duck();
+
+       return duck;
+}
+*/
+
+bool
+Duckmatic::add_to_ducks(const synfigapp::ValueDesc& value_desc,etl::handle<CanvasView> canvas_view, const synfig::TransformStack& transform_stack, synfig::ParamDesc *param_desc, int multiple)
+{
+       ValueBase::Type type=value_desc.get_value_type();
+#define REAL_COOKIE            reinterpret_cast<synfig::ParamDesc*>(28)
+       switch(type)
+       {
+       case ValueBase::TYPE_REAL:
+
+               if(!param_desc || param_desc==REAL_COOKIE || !param_desc->get_origin().empty())
+               {
+                       etl::handle<Duck> duck=new Duck();
+                       duck->set_transform_stack(transform_stack);
+                       duck->set_radius(true);
+                       duck->set_type(Duck::TYPE_RADIUS);
+
+                       // put the duck on the right hand side of the center
+                       duck->set_point(Point(value_desc.get_value(get_time()).get(Real()), 0));
+                       duck->set_name(guid_string(value_desc));
+                       if(value_desc.is_value_node())
+                       {
+                               // If the ValueNode can be directly manipulated,
+                               // then set it as so.
+                               duck->set_editable(synfigapp::is_editable(value_desc.get_value_node()));
+                       }
+                       else
+                       {
+                               duck->set_editable(true);
+                       }
+
+                       if(param_desc && param_desc!=REAL_COOKIE)
+                       {
+                               if(!param_desc->get_origin().empty())
+                               {
+                                       synfigapp::ValueDesc value_desc_origin(value_desc.get_layer(),param_desc->get_origin());
+                                       /*
+                                       duck->set_origin(value_desc_origin.get_value(get_time()).get(synfig::Point()));
+                                       */
+                                       add_to_ducks(value_desc_origin,canvas_view, transform_stack);
+                                       duck->set_origin(last_duck());
+                               }
+                               duck->set_scalar(param_desc->get_scalar());
+                       }
+
+                       duck->signal_edited().clear(); // value_desc.get_value_type() == ValueBase::TYPE_REAL:
+                       duck->signal_edited().connect(
+                               sigc::bind(
+                                       sigc::mem_fun(
+                                               *canvas_view,
+                                               &studio::CanvasView::on_duck_changed),
+                                       value_desc));
+                       duck->set_value_desc(value_desc);
+
+                       duck->signal_user_click(2).connect(
+                               sigc::bind(
+                                       sigc::bind(
+                                               sigc::bind(
+                                                       sigc::mem_fun(
+                                                               *canvas_view,
+                                                               &studio::CanvasView::popup_param_menu),
+                                                       false),
+                                               0.0f),
+                                       value_desc));
+
+                       duck->set_guid(calc_duck_guid(value_desc,transform_stack)^synfig::GUID::hasher(multiple));
+
+                       add_duck(duck);
+
+                       return true;
+               }
+               break;
+
+       case ValueBase::TYPE_ANGLE:
+
+               if(!param_desc || param_desc==REAL_COOKIE || !param_desc->get_origin().empty())
+               {
+                       etl::handle<Duck> duck=new Duck();
+                       duck->set_type(Duck::TYPE_ANGLE);
+                       duck->set_transform_stack(transform_stack);
+                       synfig::Angle angle;
+
+                       angle=value_desc.get_value(get_time()).get(Angle());
+                       duck->set_point(Point(Angle::cos(angle).get(),Angle::sin(angle).get()));
+                       duck->set_name(guid_string(value_desc));
+                       if(value_desc.is_value_node())
+                       {
+                               ValueNode::Handle value_node=value_desc.get_value_node();
+                               //duck->set_name(strprintf("%x",value_node.get()));
+
+                               // If the ValueNode can be directly manipulated,
+                               // then set it as so.
+                               duck->set_editable(synfigapp::is_editable(value_desc.get_value_node()));
+                       }
+                       else
+                       {
+                               //angle=(value_desc.get_value().get(Angle()));
+                               //duck->set_point(Point(Angle::cos(angle).get(),Angle::sin(angle).get()));
+                               //duck->set_name(strprintf("%x",value_desc.get_layer().get())+value_desc.get_param_name());
+                               duck->set_editable(true);
+                       }
+
+                       if(param_desc && param_desc!=REAL_COOKIE)
+                       {
+                               if(!param_desc->get_origin().empty())
+                               {
+                                       synfigapp::ValueDesc value_desc_origin(value_desc.get_layer(),param_desc->get_origin());
+                                       /*
+                                       duck->set_origin(value_desc_origin.get_value(get_time()).get(synfig::Point()));
+                                       */
+                                       add_to_ducks(value_desc_origin,canvas_view, transform_stack);
+                                       duck->set_origin(last_duck());
+                               }
+                               duck->set_scalar(param_desc->get_scalar());
+                       }
+
+                       duck->signal_edited().clear(); // value_desc.get_value_type() == ValueBase::TYPE_ANGLE:
+                       duck->signal_edited_angle().clear();
+                       duck->signal_edited_angle().connect(
+                               sigc::bind(
+                                       sigc::mem_fun(
+                                               *canvas_view,
+                                               &studio::CanvasView::on_duck_angle_changed),
+                                       value_desc));
+                       duck->set_value_desc(value_desc);
+
+                       duck->signal_user_click(2).connect(
+                               sigc::bind(
+                                       sigc::bind(
+                                               sigc::bind(
+                                                       sigc::mem_fun(
+                                                               *canvas_view,
+                                                               &studio::CanvasView::popup_param_menu),
+                                                       false),
+                                               0.0f),
+                                       value_desc));
+                       duck->set_guid(calc_duck_guid(value_desc,transform_stack)^synfig::GUID::hasher(multiple));
+
+                       add_duck(duck);
+
+                       return true;
+               }
+               break;
+
+       case ValueBase::TYPE_VECTOR:
+               {
+                       etl::handle<Duck> duck=new Duck();
+                       duck->set_transform_stack(transform_stack);
+
+                       duck->set_point(value_desc.get_value(get_time()).get(Point()));
+                       duck->set_name(guid_string(value_desc));
+                       if(value_desc.is_value_node())
+                       {
+                               //duck->set_name(strprintf("%x",value_desc.get_value_node().get()));
+
+                               // If the ValueNode can be directly manipulated,
+                               // then set it as so.
+                               duck->set_editable(synfigapp::is_editable(value_desc.get_value_node()));
+                       }
+                       else
+                       {
+                               //duck->set_point(value_desc.get_value().get(Point()));
+                               //duck->set_name(strprintf("%x",value_desc.get_layer().get())+value_desc.get_param_name());
+                               duck->set_editable(true);
+                       }
+
+                       // If we were passed a parameter description
+                       if(param_desc)
+                       {
+                               if(!param_desc->get_connect().empty())
+                               {
+                                       synfigapp::ValueDesc value_desc_origin(value_desc.get_layer(),param_desc->get_connect());
+                                       Duck::Handle connect_duck;
+                                       if(duck_map.find(calc_duck_guid(value_desc_origin,transform_stack)^synfig::GUID::hasher(0))!=duck_map.end())
+                                       {
+                                               connect_duck=duck_map[calc_duck_guid(value_desc_origin,transform_stack)^synfig::GUID::hasher(0)];
+                                       }
+                                       else
+                                       {
+                                               add_to_ducks(value_desc_origin,canvas_view, transform_stack);
+                                               connect_duck=last_duck();
+                                       }
+                                       duck->set_connect_duck(connect_duck);
+                               }
+                               if(!param_desc->get_box().empty())
+                               {
+                                       synfigapp::ValueDesc value_desc_origin(value_desc.get_layer(),param_desc->get_box());
+                                       add_to_ducks(value_desc_origin,canvas_view, transform_stack);
+                                       duck->set_box_duck(last_duck());
+                               }
+
+                               // If we have an origin
+                               if(!param_desc->get_origin().empty())
+                               {
+                                       synfigapp::ValueDesc value_desc_origin(value_desc.get_layer(),param_desc->get_origin());
+                                       /*
+                                       duck->set_origin(value_desc_origin.get_value(get_time()).get(synfig::Point()));
+                                       */
+                                       add_to_ducks(value_desc_origin,canvas_view, transform_stack);
+                                       duck->set_origin(last_duck());
+                                       duck->set_type(Duck::TYPE_VERTEX);
+                               }
+                               else
+                                       duck->set_type(Duck::TYPE_POSITION);
+
+                               duck->set_scalar(param_desc->get_scalar());
+                       }
+                       else
+                               duck->set_type(Duck::TYPE_POSITION);
+
+                       duck->signal_edited().clear(); // value_desc.get_value_type() == ValueBase::TYPE_VECTOR:
+                       duck->signal_edited().connect(
+                               sigc::bind(
+                                       sigc::mem_fun(
+                                               *canvas_view,
+                                               &studio::CanvasView::on_duck_changed),
+                                       value_desc));
+                       duck->set_value_desc(value_desc);
+
+                       duck->signal_user_click(2).connect(
+                               sigc::bind(
+                                       sigc::bind(
+                                               sigc::bind(
+                                                       sigc::mem_fun(
+                                                               *canvas_view,
+                                                               &studio::CanvasView::popup_param_menu),
+                                                       false),
+                                               1.0f),
+                                       value_desc));
+                       duck->set_guid(calc_duck_guid(value_desc,transform_stack)^synfig::GUID::hasher(multiple));
+                       add_duck(duck);
+
+                       return true;
+               }
+               break;
+       case ValueBase::TYPE_SEGMENT:
+               {
+                       etl::handle<Bezier> bezier(new Bezier());
+                       ValueNode_Composite::Handle value_node;
+
+                       if(value_desc.is_value_node() &&
+                               (value_node=ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node())))
+                       {
+                               if(!add_to_ducks(synfigapp::ValueDesc(value_node,0),canvas_view,transform_stack))
+                                       return false;
+                               bezier->p1=last_duck();
+                               bezier->p1->set_type(Duck::TYPE_VERTEX);
+                               if(!add_to_ducks(synfigapp::ValueDesc(value_node,1),canvas_view,transform_stack))
+                                       return false;
+                               bezier->c1=last_duck();
+                               bezier->c1->set_type(Duck::TYPE_TANGENT);
+                               bezier->c1->set_origin(bezier->p1);
+                               bezier->c1->set_scalar(TANGENT_BEZIER_SCALE);
+                               bezier->c1->set_tangent(true);
+
+                               if(!add_to_ducks(synfigapp::ValueDesc(value_node,2),canvas_view,transform_stack))
+                                       return false;
+                               bezier->p2=last_duck();
+                               bezier->p2->set_type(Duck::TYPE_VERTEX);
+                               if(!add_to_ducks(synfigapp::ValueDesc(value_node,3),canvas_view,transform_stack))
+                                       return false;
+                               bezier->c2=last_duck();
+                               bezier->c2->set_type(Duck::TYPE_TANGENT);
+                               bezier->c2->set_origin(bezier->p2);
+                               bezier->c2->set_scalar(-TANGENT_BEZIER_SCALE);
+                               bezier->c2->set_tangent(true);
+
+                               bezier->signal_user_click(2).connect(
+                                       sigc::bind(
+                                               sigc::mem_fun(
+                                                       *canvas_view,
+                                                       &studio::CanvasView::popup_param_menu_bezier),
+                                               value_desc));
+
+                               add_bezier(bezier);
+                       }
+                       else if(value_desc.get_value().is_valid())
+                       {
+                               Segment segment=value_desc.get_value();
+                               etl::handle<Duck> duck_p,duck_c;
+                               synfig::String name;
+                               if(param_desc)
+                               {
+                                       name=param_desc->get_local_name();
+                               }
+                               else
+                               {
+                                       name=guid_string(value_desc);
+                               }
+
+                               duck_p=new Duck(segment.p1);
+                               duck_p->set_name(name+".P1");
+                               duck_p->set_type(Duck::TYPE_VERTEX);
+                               add_duck(duck_p);
+
+                               duck_c=new Duck(segment.t1);
+                               duck_c->set_name(name+".T1");
+                               duck_c->set_type(Duck::TYPE_TANGENT);
+                               add_duck(duck_c);
+                               duck_c->set_origin(duck_p);
+                               duck_c->set_scalar(TANGENT_HANDLE_SCALE);
+                               duck_c->set_tangent(true);
+
+                               bezier->p1=duck_p;
+                               bezier->c1=duck_c;
+
+                               duck_p=new Duck(segment.p2);
+                               duck_p->set_name(name+".P2");
+                               duck_p->set_type(Duck::TYPE_VERTEX);
+                               add_duck(duck_p);
+
+                               duck_c=new Duck(segment.t2);
+                               duck_c->set_type(Duck::TYPE_TANGENT);
+                               duck_c->set_name(name+".T2");
+                               add_duck(duck_c);
+                               duck_c->set_origin(duck_p);
+                               duck_c->set_scalar(-TANGENT_HANDLE_SCALE);
+                               duck_c->set_tangent(true);
+
+                               bezier->p2=duck_p;
+                               bezier->c2=duck_c;
+                               add_bezier(bezier);
+                       }
+
+                       return true;
+               }
+               break;
+       case ValueBase::TYPE_BLINEPOINT:
+       {
+
+               if(value_desc.is_value_node() &&
+                       ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node()))
+               {
+                       ValueNode_Composite::Handle value_node;
+                       value_node=ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node());
+
+                       if(!add_to_ducks(synfigapp::ValueDesc(value_node,0),canvas_view,transform_stack))
+                               return false;
+                       etl::handle<Duck> vertex_duck(last_duck());
+                       vertex_duck->set_type(Duck::TYPE_VERTEX);
+                       if(!add_to_ducks(synfigapp::ValueDesc(value_node,4),canvas_view,transform_stack))
+                               return false;
+                       etl::handle<Duck> t1_duck(last_duck());
+
+                       t1_duck->set_origin(vertex_duck);
+                       t1_duck->set_scalar(-TANGENT_HANDLE_SCALE);
+                       t1_duck->set_tangent(true);
+
+                       etl::handle<Duck> t2_duck;
+
+                       // If the tangents are split
+                       if((*value_node->get_link("split"))(get_time()).get(bool()))
+                       {
+                               if(!add_to_ducks(synfigapp::ValueDesc(value_node,5),canvas_view,transform_stack))
+                                       return false;
+                               t2_duck=last_duck();
+                               t2_duck->set_origin(vertex_duck);
+                               t2_duck->set_scalar(TANGENT_HANDLE_SCALE);
+                               t2_duck->set_tangent(true);
+                       }
+                       else
+                       {
+                               if(!add_to_ducks(synfigapp::ValueDesc(value_node,4),canvas_view,transform_stack))
+                                       return false;
+                               t2_duck=last_duck();
+                               t2_duck->set_origin(vertex_duck);
+                               t2_duck->set_scalar(TANGENT_HANDLE_SCALE);
+                               t2_duck->set_tangent(true);
+                       }
+                       return true;
+               }
+
+       }
+       break;
+       case ValueBase::TYPE_LIST:
+       {
+               // Check for BLine
+               if (value_desc.is_value_node() &&
+                       ValueNode_BLine::Handle::cast_dynamic(value_desc.get_value_node()))
+               {
+                       ValueNode_BLine::Handle value_node;
+                       value_node=ValueNode_BLine::Handle::cast_dynamic(value_desc.get_value_node());
+
+                       int i,first=-1;
+
+                       etl::handle<Bezier> bezier;
+                       etl::handle<Duck> first_duck;
+                       etl::handle<Duck> duck, tduck;
+
+                       for (i = 0; i < value_node->link_count(); i++)
+                       {
+                               float amount(value_node->list[i].amount_at_time(get_time()));
+
+                               // skip vertices that aren't fully on
+                               if (amount < 0.9999f)
+                                       continue;
+
+                               // remember the index of the first vertex we didn't skip
+                               if (first == -1)
+                                       first = i;
+
+                               BLinePoint bline_point((*value_node->get_link(i))(get_time()));
+
+                               // try casting the vertex to Composite - this tells us whether it is composite or not
+                               ValueNode_Composite::Handle composite_vertex_value_node(
+                                       ValueNode_Composite::Handle::cast_dynamic(value_node->get_link(i)));
+
+                               // add the vertex duck - it's a composite
+                               if(composite_vertex_value_node)
+                               {
+                                       if (add_to_ducks(synfigapp::ValueDesc(composite_vertex_value_node,0),canvas_view,transform_stack))
+                                       {
+                                               duck=last_duck();
+                                               if(i==first)
+                                                       first_duck=duck;
+                                               duck->set_type(Duck::TYPE_VERTEX);
+
+                                               duck->signal_user_click(2).clear();
+                                               duck->signal_user_click(2).connect(
+                                                       sigc::bind(
+                                                               sigc::bind(
+                                                                       sigc::bind(
+                                                                               sigc::mem_fun(
+                                                                                       *canvas_view,
+                                                                                       &studio::CanvasView::popup_param_menu),
+                                                                               false),
+                                                                       1.0f),
+                                                               synfigapp::ValueDesc(value_node,i)));
+                                               duck->set_value_desc(synfigapp::ValueDesc(value_node,i));
+
+                                               if(param_desc)
+                                               {
+                                                       if(!param_desc->get_origin().empty())
+                                                       {
+                                                               synfigapp::ValueDesc value_desc_origin(value_desc.get_layer(),param_desc->get_origin());
+                                                               add_to_ducks(value_desc_origin,canvas_view, transform_stack);
+                                                               duck->set_origin(last_duck());
+/*
+                                                               ValueBase value(synfigapp::ValueDesc(value_desc.get_layer(),param_desc->get_origin()).get_value(get_time()));
+                                                               if(value.same_type_as(synfig::Point()))
+                                                                       duck->set_origin(value.get(synfig::Point()));
+*/
+                                                       }
+                                               }
+                                       }
+                                       else
+                                               return false;
+                               }
+                               // else it's not a composite
+                               else
+                               {
+                                       duck=new Duck(bline_point.get_vertex());
+                                       if(i==first)
+                                               first_duck=duck;
+                                       duck->set_transform_stack(transform_stack);
+                                       duck->set_editable(false);
+                                       //duck->set_name(strprintf("%x-vertex",value_node->get_link(i).get()));
+                                       duck->set_name(guid_string(synfigapp::ValueDesc(value_node,i))+".v");
+
+                                       duck->set_type(Duck::TYPE_VERTEX);
+                                       if(param_desc)
+                                       {
+                                               if(!param_desc->get_origin().empty())
+                                               {
+                                                       synfigapp::ValueDesc value_desc_origin(value_desc.get_layer(),param_desc->get_origin());
+                                                       add_to_ducks(value_desc_origin,canvas_view, transform_stack);
+                                                       duck->set_origin(last_duck());
+/*
+                                                       ValueBase value(synfigapp::ValueDesc(value_desc.get_layer(),param_desc->get_origin()).get_value(get_time()));
+                                                       if(value.same_type_as(synfig::Point()))
+                                                               duck->set_origin(value.get(synfig::Point()));
+*/
+                                               }
+                                       }
+                                       duck->set_guid(calc_duck_guid(synfigapp::ValueDesc(value_node,i),transform_stack)^synfig::GUID::hasher(".v"));
+                                       duck=add_similar_duck(duck);
+//                                     add_duck(duck);
+                               }
+
+                               // Add the width duck if it is a parameter with a hint (ie. "width") or if it isn't a parameter
+                               if ((param_desc && !param_desc->get_hint().empty()) ||
+                                       !param_desc)
+                               {
+                                       etl::handle<Duck> width;
+                                       if (add_to_ducks(synfigapp::ValueDesc(composite_vertex_value_node,1),canvas_view,transform_stack,REAL_COOKIE))
+                                       {
+                                               width=last_duck();
+                                               width->set_origin(duck);
+                                               width->set_type(Duck::TYPE_WIDTH);
+                                               width->set_name(guid_string(synfigapp::ValueDesc(value_node,i))+".w");
+
+                                               // if the bline is a layer's parameter, scale the width duck by the layer's "width" parameter
+                                               if (param_desc)
+                                               {
+                                                       ValueBase value(synfigapp::ValueDesc(value_desc.get_layer(),param_desc->get_hint()).get_value(get_time()));
+                                                       if(value.same_type_as(synfig::Real()))
+                                                               width->set_scalar(value.get(synfig::Real())*0.5f);
+                                                       // if it doesn't have a "width" parameter, scale by 0.5f instead
+                                                       else
+                                                               width->set_scalar(0.5f);
+                                               }
+                                               // otherwise just present the raw unscaled width
+                                               else
+                                                       width->set_scalar(0.5f);
+                                       }
+                                       else
+                                               synfig::error("Unable to add width duck!");
+                               }
+
+                               // each bezier uses t2 of one point and t1 of the next
+                               // the first time through this loop we won't have the t2 duck from the previous vertex
+                               // and so we don't make a bezier.  instead we skip on to t2 for this point
+                               if(bezier)
+                               {
+                                       // Add the tangent1 duck
+                                       if(composite_vertex_value_node)
+                                       {
+                                               if(!add_to_ducks(synfigapp::ValueDesc(composite_vertex_value_node,4),canvas_view,transform_stack))
+                                                       return false;
+                                               tduck=last_duck();
+                                       }
+                                       else
+                                       {
+                                               tduck=new Duck(bline_point.get_tangent1());
+                                               tduck->set_transform_stack(transform_stack);
+                                               tduck->set_editable(false);
+                                               tduck->set_name(guid_string(synfigapp::ValueDesc(value_node,i))+".t1");
+//                                             tduck->set_name(strprintf("%x-tangent1",value_node->get_link(i).get()));
+                                               tduck->set_guid(calc_duck_guid(synfigapp::ValueDesc(value_node,i),transform_stack)^synfig::GUID::hasher(".t1"));
+                                               tduck=add_similar_duck(tduck);
+//                                             add_duck(duck);
+                                       }
+
+                                       tduck->set_origin(duck);
+                                       tduck->set_scalar(-TANGENT_BEZIER_SCALE);
+                                       tduck->set_tangent(true);
+
+                                       bezier->p2=duck;
+                                       bezier->c2=tduck;
+
+                                       bezier->signal_user_click(2).connect(
+                                               sigc::bind(
+                                                       sigc::mem_fun(
+                                                               *canvas_view,
+                                                               &studio::CanvasView::popup_param_menu_bezier),
+                                                       synfigapp::ValueDesc(value_node,i)));
+
+                                       duck->signal_user_click(2).clear();
+                                       duck->signal_user_click(2).connect(
+                                               sigc::bind(
+                                                       sigc::bind(
+                                                               sigc::bind(
+                                                                       sigc::mem_fun(
+                                                                               *canvas_view,
+                                                                               &studio::CanvasView::popup_param_menu),
+                                                                       false),
+                                                               1.0f),
+                                                       synfigapp::ValueDesc(value_node,i)));
+                                       duck->set_value_desc(synfigapp::ValueDesc(value_node,i));
+
+                                       add_bezier(bezier);
+                                       bezier=0;
+                               }
+
+                               // don't start a new bezier for the last point in the line if we're not looped
+                               if(i+1>=value_node->link_count() && !value_node->get_loop())
+                                       continue;
+
+                               bezier=new Bezier();
+
+                               // Add the tangent2 duck
+                               if(composite_vertex_value_node)
+                               {
+                                       int i=bline_point.get_split_tangent_flag()?5:4;
+                                       if(!add_to_ducks(synfigapp::ValueDesc(composite_vertex_value_node,i),canvas_view,transform_stack,0,2))
+                                               return false;
+                                       tduck=last_duck();
+                               }
+                               else
+                               {
+                                       if(bline_point.get_split_tangent_flag())
+                                               tduck=new Duck(bline_point.get_tangent2());
+                                       else
+                                               tduck=new Duck(bline_point.get_tangent1());
+
+                                       tduck->set_transform_stack(transform_stack);
+                                       tduck->set_name(guid_string(synfigapp::ValueDesc(value_node,i))+".t2");
+                                       tduck->set_guid(calc_duck_guid(synfigapp::ValueDesc(value_node,i),transform_stack)^synfig::GUID::hasher(".t2"));
+                                       tduck->set_editable(false);
+                                       tduck=add_similar_duck(tduck);
+//                                     add_duck(duck);
+                                       if(param_desc)
+                                       {
+                                               synfigapp::ValueDesc value_desc_origin(value_desc.get_layer(),param_desc->get_origin());
+                                               add_to_ducks(value_desc_origin,canvas_view, transform_stack);
+                                               duck->set_origin(last_duck());
+/*
+                                               ValueBase value(synfigapp::ValueDesc(value_desc.get_layer(),param_desc->get_origin()).get_value(get_time()));
+                                               if(value.same_type_as(synfig::Point()))
+                                                       duck->set_origin(value.get(synfig::Point()));
+*/
+//                                             if(!param_desc->get_origin().empty())
+//                                                     duck->set_origin(synfigapp::ValueDesc(value_desc.get_layer(),param_desc->get_origin()).get_value(get_time()).get(synfig::Point()));
+                                       }
+                                       duck->signal_user_click(2).clear();
+                                       duck->signal_user_click(2).connect(
+                                               sigc::bind(
+                                                       sigc::bind(
+                                                               sigc::bind(
+                                                                       sigc::mem_fun(
+                                                                               *canvas_view,
+                                                                               &studio::CanvasView::popup_param_menu),
+                                                                       false),
+                                                               1.0f),
+                                                       synfigapp::ValueDesc(value_node,i)));
+                                       duck->set_value_desc(synfigapp::ValueDesc(value_node,i));
+
+                               }
+
+                               tduck->set_origin(duck);
+                               tduck->set_scalar(TANGENT_BEZIER_SCALE);
+                               tduck->set_tangent(true);
+
+                               bezier->p1=duck;
+                               bezier->c1=tduck;
+                       }
+
+                       // Loop if necessary
+                       if(bezier && value_node->get_loop())
+                       {
+                               BLinePoint bline_point((*value_node->get_link(first))(get_time()));
+
+                               ValueNode_Composite::Handle composite_vertex_value_node(
+                                       ValueNode_Composite::Handle::cast_dynamic(
+                                               value_node->get_link(first)));
+
+                               // Add the vertex duck
+                               duck=first_duck;
+
+                               // Add the tangent1 duck
+                               if(composite_vertex_value_node)
+                               {
+                                       if(!add_to_ducks(synfigapp::ValueDesc(composite_vertex_value_node,4),canvas_view,transform_stack))
+                                               return false;
+                                       tduck=last_duck();
+                               }
+                               else
+                               {
+                                       tduck=new Duck(bline_point.get_tangent1());
+                                       tduck->set_transform_stack(transform_stack);
+                                       tduck->set_editable(false);
+                                       tduck->set_name(guid_string(synfigapp::ValueDesc(value_node,first))+".t1");
+                                       //tduck->set_name(strprintf("%x-tangent1",value_node->get_link(first).get()));
+                                       tduck=add_similar_duck(tduck);
+                                       tduck->set_guid(calc_duck_guid(synfigapp::ValueDesc(value_node,first),transform_stack)^synfig::GUID::hasher(".t1"));
+                                       //add_duck(duck);
+                               }
+
+                               tduck->set_origin(duck);
+                               tduck->set_scalar(-TANGENT_BEZIER_SCALE);
+                               tduck->set_tangent(true);
+
+                               bezier->p2=duck;
+                               bezier->c2=tduck;
+
+                               bezier->signal_user_click(2).connect(
+                                       sigc::bind(
+                                               sigc::mem_fun(
+                                                       *canvas_view,
+                                                       &studio::CanvasView::popup_param_menu_bezier),
+                                               synfigapp::ValueDesc(value_node,first)));
+
+                               duck->signal_user_click(2).clear();
+                               duck->signal_user_click(2).connect(
+                                       sigc::bind(
+                                               sigc::bind(
+                                                       sigc::bind(
+                                                               sigc::mem_fun(
+                                                                       *canvas_view,
+                                                                       &studio::CanvasView::popup_param_menu),
+                                                               false),
+                                                       1.0f),
+                                               synfigapp::ValueDesc(value_node,first)));
+                               duck->set_value_desc(synfigapp::ValueDesc(value_node,first));
+
+                               add_bezier(bezier);
+                               bezier=0;
+                       }
+                       return true;
+               }
+               else // Check for DynamicList
+               if(value_desc.is_value_node() &&
+                       ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_value_node()))
+               {
+                       ValueNode_DynamicList::Handle value_node;
+                       value_node=ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_value_node());
+                       int i;
+
+                       if(value_node->get_contained_type()==ValueBase::TYPE_VECTOR)
+                       {
+                               Bezier bezier;
+                               etl::handle<Duck> first_duck, duck;
+                               int first = -1;
+                               for(i=0;i<value_node->link_count();i++)
+                               {
+                                       if(!value_node->list[i].status_at_time(get_time()))
+                                               continue;
+                                       if(!add_to_ducks(synfigapp::ValueDesc(value_node,i),canvas_view,transform_stack))
+                                               return false;
+                                       duck = last_duck();
+
+                                       // remember the index of the first vertex we didn't skip
+                                       if (first == -1)
+                                       {
+                                               first = i;
+                                               first_duck = duck;
+                                       }
+
+                                       if(param_desc && !param_desc->get_origin().empty())
+                                       {
+                                               synfigapp::ValueDesc value_desc_origin(value_desc.get_layer(),param_desc->get_origin());
+                                               add_to_ducks(value_desc_origin,canvas_view, transform_stack);
+                                               duck->set_origin(last_duck());
+/*
+                                               ValueBase value(synfigapp::ValueDesc(value_desc.get_layer(),param_desc->get_origin()).get_value(get_time()));
+                                               if(value.same_type_as(synfig::Point()))
+                                                       duck->set_origin(value.get(synfig::Point()));
+*/
+//                                             if(!param_desc->get_origin().empty())
+//                                                     last_duck()->set_origin(synfigapp::ValueDesc(value_desc.get_layer(),param_desc->get_origin()).get_value(get_time()).get(synfig::Point()));
+                                       }
+                                       duck->set_type(Duck::TYPE_VERTEX);
+                                       bezier.p1=bezier.p2;bezier.c1=bezier.c2;
+                                       bezier.p2=bezier.c2=duck;
+
+                                       if (first != i)
+                                       {
+                                               handle<Bezier> bezier_(new Bezier());
+                                               bezier_->p1=bezier.p1;
+                                               bezier_->c1=bezier.c1;
+                                               bezier_->p2=bezier.p2;
+                                               bezier_->c2=bezier.c2;
+                                               add_bezier(bezier_);
+                                               last_bezier()->signal_user_click(2).connect(
+                                                       sigc::bind(
+                                                               sigc::mem_fun(
+                                                                       *canvas_view,
+                                                                       &studio::CanvasView::popup_param_menu_bezier),
+                                                               synfigapp::ValueDesc(value_node,i)));
+                                       }
+                               }
+
+                               if (value_node->get_loop() && first != -1 && first_duck != duck)
+                               {
+                                       duck = first_duck;
+
+                                       bezier.p1=bezier.p2;bezier.c1=bezier.c2;
+                                       bezier.p2=bezier.c2=duck;
+
+                                       handle<Bezier> bezier_(new Bezier());
+                                       bezier_->p1=bezier.p1;
+                                       bezier_->c1=bezier.c1;
+                                       bezier_->p2=bezier.p2;
+                                       bezier_->c2=bezier.c2;
+                                       add_bezier(bezier_);
+                                       last_bezier()->signal_user_click(2).connect(
+                                               sigc::bind(
+                                                       sigc::mem_fun(
+                                                               *canvas_view,
+                                                               &studio::CanvasView::popup_param_menu_bezier),
+                                                       synfigapp::ValueDesc(value_node,first)));
+                               }
+                       }
+                       else if(value_node->get_contained_type()==ValueBase::TYPE_SEGMENT)
+                       {
+                               for(i=0;i<value_node->link_count();i++)
+                               {
+                                       if(!value_node->list[i].status_at_time(get_time()))
+                                               continue;
+                                       if(!add_to_ducks(synfigapp::ValueDesc(value_node,i),canvas_view,transform_stack))
+                                               return false;
+                               }
+                       }
+                       else
+                               return false;
+               }
+               else
+               {
+                       // WRITEME
+               }
+
+               return true;
+       }
+
+       break;
+       default:
+               break;
+       }
+       return false;
+}
diff --git a/synfig-studio/src/gui/duckmatic.h b/synfig-studio/src/gui/duckmatic.h
new file mode 100644 (file)
index 0000000..e10db0c
--- /dev/null
@@ -0,0 +1,453 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file duckmatic.h
+**     \brief Template Header
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 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
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_STUDIO_DUCKMATIC_H
+#define __SYNFIG_STUDIO_DUCKMATIC_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <list>
+#include <map>
+#include <set>
+
+#include <ETL/smart_ptr>
+#include <ETL/handle>
+
+#include <synfig/vector.h>
+#include <synfig/string.h>
+#include <synfig/real.h>
+#include <sigc++/signal.h>
+#include <sigc++/object.h>
+#include <synfig/time.h>
+#include <synfig/color.h>
+#include <ETL/smart_ptr>
+
+#include "duck.h"
+#include <synfig/color.h>
+#include <synfig/guidset.h>
+
+/* === M A C R O S ========================================================= */
+
+#ifdef HASH_MAP_H
+#include HASH_MAP_H
+#include FUNCTIONAL_H
+
+#ifndef __STRING_HASH__
+#define __STRING_HASH__
+class StringHash
+{
+# ifdef FUNCTIONAL_HASH_ON_STRING
+       HASH_MAP_NAMESPACE::hash<synfig::String> hasher_;
+# else  // FUNCTIONAL_HASH_ON_STRING
+       HASH_MAP_NAMESPACE::hash<const char*> hasher_;
+# endif  // FUNCTIONAL_HASH_ON_STRING
+public:
+       size_t operator()(const synfig::String& x)const
+       {
+# ifdef FUNCTIONAL_HASH_ON_STRING
+               return hasher_(x);
+# else  // FUNCTIONAL_HASH_ON_STRING
+               return hasher_(x.c_str());
+# endif  // FUNCTIONAL_HASH_ON_STRING
+       }
+};
+#endif
+#else
+#include <map>
+#endif
+
+/* === T Y P E D E F S ===================================================== */
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+namespace synfigapp { class ValueDesc; }
+namespace synfig { class ParamDesc; }
+
+namespace studio
+{
+
+class CanvasView;
+class Duckmatic;
+
+class DuckDrag_Base : public etl::shared_object
+{
+public:
+       virtual void begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& begin)=0;
+       virtual bool end_duck_drag(Duckmatic* duckmatic)=0;
+       virtual void duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector)=0;
+};
+
+class DuckDrag_Translate : public DuckDrag_Base
+{
+       synfig::Vector last_translate_;
+       synfig::Vector drag_offset_;
+       synfig::Vector snap;
+       std::vector<synfig::Vector> positions;
+
+public:
+       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 Duckmatic
+**
+**     This class helps organize any of the devices displayed in
+**     the work area that the user may want to interact with.
+**     This includes ducks, beziers, and strokes
+**
+**     \note At some point I'll probably rename this class to "DuckOMatic".
+*/
+class Duckmatic
+{
+       friend class DuckDrag_Base;
+       friend class DuckDrag_Translate;
+
+       /*
+ -- ** -- P U B L I C   T Y P E S ---------------------------------------------
+       */
+
+public:
+
+#ifdef HASH_MAP_H
+typedef HASH_MAP_CLASS<synfig::GUID,etl::smart_ptr<synfig::Point>,synfig::GUIDHash> DuckDataMap;
+#else
+typedef std::map<synfig::GUID,etl::smart_ptr<synfig::Point> > DuckDataMap;
+#endif
+
+       typedef studio::DuckMap DuckMap;
+
+       typedef studio::Duck Duck;
+
+       struct Stroke;
+
+       struct Bezier;
+
+       class Push;
+
+       friend class Push;
+
+       typedef Duck::Type Type;
+
+       typedef std::list<float> GuideList;
+
+       /*
+ -- ** -- P R I V A T E   D A T A ---------------------------------------------
+       */
+
+private:
+
+       Type type_mask;
+
+       DuckMap duck_map;
+
+       DuckDataMap duck_data_share_map;
+
+       std::list<etl::handle<Stroke> > stroke_list_;
+
+       std::list<etl::handle<Stroke> > persistent_stroke_list_;
+
+       synfig::GUIDSet selected_ducks;
+
+       synfig::GUID last_duck_guid;
+
+       std::list<etl::handle<Bezier> > bezier_list_;
+
+       //! I cannot recall what this is for
+       //synfig::Vector snap;
+
+       etl::handle<DuckDrag_Base> duck_dragger_;
+
+       sigc::signal<void> signal_duck_selection_changed_;
+
+       sigc::signal<void> signal_strokes_changed_;
+
+       sigc::signal<void> signal_grid_changed_;
+
+       mutable sigc::signal<void> signal_sketch_saved_;
+
+       GuideList guide_list_x_;
+       GuideList guide_list_y_;
+
+       mutable synfig::String sketch_filename_;
+
+       /*
+ -- ** -- P R O T E C T E D   D A T A -----------------------------------------
+       */
+
+protected:
+
+       etl::handle<Bezier> selected_bezier;
+
+       synfig::Time cur_time;
+
+       //! This flag is set if operations should snap to the grid
+       /*! \todo perhaps there should be two of these flags, one for each axis?
+       **      \see show_grid, grid_size */
+       bool grid_snap;
+
+       bool guide_snap;
+
+       //! This vector describes the grid size.
+       /*! \see grid_snap, show_grid */
+       synfig::Vector grid_size;
+
+       bool show_persistent_strokes;
+
+       bool axis_lock;
+
+       /*
+ -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
+       */
+
+private:
+
+       synfig::Vector last_translate_;
+       synfig::Vector drag_offset_;
+
+       //etl::handle<Duck> selected_duck;
+
+
+       /*
+ -- ** -- P U B L I C   M E T H O D S -----------------------------------------
+       */
+
+public:
+
+       Duckmatic();
+       virtual ~Duckmatic();
+
+       sigc::signal<void>& signal_duck_selection_changed() { return signal_duck_selection_changed_; }
+       sigc::signal<void>& signal_strokes_changed() { return signal_strokes_changed_; }
+       sigc::signal<void>& signal_grid_changed() { return signal_grid_changed_; }
+       sigc::signal<void>& signal_sketch_saved() { return signal_sketch_saved_; }
+
+       GuideList& get_guide_list_x() { return guide_list_x_; }
+       GuideList& get_guide_list_y() { return guide_list_y_; }
+       const GuideList& get_guide_list_x()const { return guide_list_x_; }
+       const GuideList& get_guide_list_y()const { return guide_list_y_; }
+
+       void set_guide_snap(bool x=true);
+       bool get_guide_snap()const { return guide_snap; }
+       void toggle_guide_snap() { set_guide_snap(!get_guide_snap()); }
+
+       //! Sets the state of the grid snap flag
+       void set_grid_snap(bool x=true);
+
+       //! Gets the state of the grid snap flag
+       bool get_grid_snap()const { return grid_snap; }
+
+       void enable_grid_snap() { set_grid_snap(true); }
+
+       void disable_grid_snap() { set_grid_snap(false); }
+
+       void toggle_grid_snap() { set_grid_snap(!grid_snap); }
+
+       synfig::Point snap_point_to_grid(const synfig::Point& x, float radius=0.1)const;
+
+       bool get_show_persistent_strokes()const { return show_persistent_strokes; }
+       void set_show_persistent_strokes(bool x);
+
+       //! Sets the size of the grid
+       void set_grid_size(const synfig::Vector &s);
+
+       //! Returns the size of the grid
+       const synfig::Vector &get_grid_size()const { return grid_size; }
+
+
+       const synfig::Time &get_time()const { return cur_time; }
+
+       bool get_axis_lock()const { return axis_lock; }
+       void set_axis_lock(bool x) { axis_lock=x; }
+
+       void set_time(synfig::Time x) { cur_time=x; }
+
+       bool is_duck_group_selectable(const etl::handle<Duck>& x)const;
+
+       //const DuckMap& duck_map()const { return duck_map; }
+       DuckList get_duck_list()const;
+
+       const std::list<etl::handle<Bezier> >& bezier_list()const { return bezier_list_; }
+
+       const std::list<etl::handle<Stroke> >& stroke_list()const { return stroke_list_; }
+
+       const std::list<etl::handle<Stroke> >& persistent_stroke_list()const { return persistent_stroke_list_; }
+
+       std::list<etl::handle<Stroke> >& persistent_stroke_list() { return persistent_stroke_list_; }
+
+       //! \todo We should modify this to support multiple selections
+       etl::handle<Duck> get_selected_duck()const;
+
+       DuckList get_selected_ducks()const;
+
+       //! Returns \a true if the given duck is currently selected
+       bool duck_is_selected(const etl::handle<Duck> &duck)const;
+
+
+       void refresh_selected_ducks();
+
+       void clear_selected_ducks();
+
+       int count_selected_ducks()const;
+
+       void toggle_select_duck(const etl::handle<Duck> &duck);
+
+       void select_duck(const etl::handle<Duck> &duck);
+
+       void toggle_select_ducks_in_box(const synfig::Vector& tl,const synfig::Vector& br);
+
+       void select_ducks_in_box(const synfig::Vector& tl,const synfig::Vector& br);
+
+       void unselect_duck(const etl::handle<Duck> &duck);
+
+       void start_duck_drag(const synfig::Vector& offset);
+       void translate_selected_ducks(const synfig::Vector& vector);
+       void update_ducks();
+       bool end_duck_drag();
+
+       void signal_edited_selected_ducks();
+
+       void signal_user_click_selected_ducks(int button);
+
+
+       etl::handle<Duck> find_similar_duck(etl::handle<Duck> duck);
+       etl::handle<Duck> add_similar_duck(etl::handle<Duck> duck);
+
+       void add_stroke(etl::smart_ptr<std::list<synfig::Point> > stroke_point_list, const synfig::Color& color=synfig::Color(0,0,0));
+
+       void add_persistent_stroke(etl::smart_ptr<std::list<synfig::Point> > stroke_point_list, const synfig::Color& color=synfig::Color(0,0,0));
+
+       void clear_persistent_strokes();
+
+       void add_duck(const etl::handle<Duck> &duck);
+
+       void add_bezier(const etl::handle<Bezier> &bezier);
+
+       void erase_duck(const etl::handle<Duck> &duck);
+
+       void erase_bezier(const etl::handle<Bezier> &bezier);
+
+       //! Returns the last duck added
+       etl::handle<Duck> last_duck()const;
+
+       etl::handle<Bezier> last_bezier()const;
+
+       //! \note parameter is in canvas coordinates
+       /*!     A radius of "zero" will have an unlimited radius */
+       etl::handle<Duck> find_duck(synfig::Point pos, synfig::Real radius=0, Duck::Type type=Duck::TYPE_DEFAULT);
+
+       GuideList::iterator find_guide_x(synfig::Point pos, float radius=0.1);
+       GuideList::iterator find_guide_y(synfig::Point pos, float radius=0.1);
+       GuideList::const_iterator find_guide_x(synfig::Point pos, float radius=0.1)const { return const_cast<Duckmatic*>(this)->find_guide_x(pos,radius); }
+       GuideList::const_iterator find_guide_y(synfig::Point pos, float radius=0.1)const { return const_cast<Duckmatic*>(this)->find_guide_y(pos,radius); }
+
+       //! \note parameter is in canvas coordinates
+       /*!     A radius of "zero" will have an unlimited radius */
+       //etl::handle<Bezier> find_bezier(synfig::Point pos, synfig::Real radius=0);
+
+       //! \note parameter is in canvas coordinates
+       /*!     A radius of "zero" will have an unlimited radius */
+       etl::handle<Bezier> find_bezier(synfig::Point pos, synfig::Real radius=0, float* location=0);
+
+       etl::handle<Bezier> find_bezier(synfig::Point pos, synfig::Real scale, synfig::Real radius, float* location=0);
+
+       bool add_to_ducks(const synfigapp::ValueDesc& value_desc,etl::handle<CanvasView> canvas_view, const synfig::TransformStack& transform_stack_, synfig::ParamDesc *param_desc=0, int multiple=0);
+
+       //! \writeme
+       void set_type_mask(Type x) { type_mask=x; }
+
+       //! \writeme
+       Type get_type_mask()const { return type_mask; }
+
+       void select_all_ducks();
+       void unselect_all_ducks();
+
+       void clear_ducks();
+
+       bool save_sketch(const synfig::String& filename)const;
+       bool load_sketch(const synfig::String& filename);
+       const synfig::String& get_sketch_filename()const { return sketch_filename_; }
+
+       void set_duck_dragger(etl::handle<DuckDrag_Base> x) { duck_dragger_=x; }
+       etl::handle<DuckDrag_Base> get_duck_dragger()const { return duck_dragger_; }
+       void clear_duck_dragger() { duck_dragger_=new DuckDrag_Translate(); }
+}; // END of class Duckmatic
+
+
+/*! \class Duckmatic::Push
+**     \writeme */
+class Duckmatic::Push
+{
+       Duckmatic *duckmatic_;
+       DuckMap duck_map;
+       std::list<etl::handle<Bezier> > bezier_list_;
+       std::list<etl::handle<Stroke> > stroke_list_;
+       DuckDataMap duck_data_share_map;
+       etl::handle<DuckDrag_Base> duck_dragger_;
+
+       bool needs_restore;
+
+public:
+       Push(Duckmatic *duckmatic_);
+       ~Push();
+       void restore();
+}; // END of class Duckmatic::Push
+
+/*! \struct Duckmatic::Bezier
+**     \writeme */
+struct Duckmatic::Bezier : public etl::shared_object
+{
+private:
+       sigc::signal<void,float> signal_user_click_[5];
+public:
+
+       etl::handle<Duck> p1,p2,c1,c2;
+       bool is_valid()const { return p1 && p2 && c1 && c2; }
+
+       sigc::signal<void,float> &signal_user_click(int i=0) { assert(i>=0); assert(i<5); return signal_user_click_[i]; }
+}; // END of struct Duckmatic::Bezier
+
+/*! \struct Duckmatic::Stroke
+**     \writeme */
+struct Duckmatic::Stroke : public etl::shared_object
+{
+private:
+       sigc::signal<void,float> signal_user_click_[5];
+public:
+
+       etl::smart_ptr<std::list<synfig::Point> > stroke_data;
+
+       synfig::Color color;
+
+       bool is_valid()const { return (bool)stroke_data; }
+
+       sigc::signal<void,float> &signal_user_click(int i=0) { assert(i>=0); assert(i<5); return signal_user_click_[i]; }
+}; // END of struct Duckmatic::Stroke
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/ducktransform_rotate.h b/synfig-studio/src/gui/ducktransform_rotate.h
new file mode 100644 (file)
index 0000000..5a4a338
--- /dev/null
@@ -0,0 +1,75 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file ducktransform_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_DUCK_TRANSFORM_ROTATE_H
+#define __SYNFIG_STUDIO_DUCK_TRANSFORM_ROTATE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "duckmatic.h"
+#include <synfig/angle.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 Transform_Rotate : public synfig::Transform
+{
+private:
+       synfig::Angle angle;
+       synfig::Vector origin;
+       synfig::Real sin_val;
+       synfig::Real cos_val;
+
+public:
+       Transform_Rotate(const synfig::GUID& guid, const synfig::Angle& angle,const synfig::Vector& origin=synfig::Vector(0,0)):
+               Transform(guid),
+               angle(angle),
+               origin(origin),
+               sin_val(synfig::Angle::sin(angle).get()),
+               cos_val(synfig::Angle::cos(angle).get())
+       {
+       }
+
+       synfig::Vector perform(const synfig::Vector& x)const
+       {
+               synfig::Point pos(x-origin);
+               return synfig::Point(cos_val*pos[0]-sin_val*pos[1],sin_val*pos[0]+cos_val*pos[1])+origin;
+       }
+       synfig::Vector unperform(const synfig::Vector& x)const
+       {
+               synfig::Point pos(x-origin);
+               return synfig::Point(cos_val*pos[0]+sin_val*pos[1],-sin_val*pos[0]+cos_val*pos[1])+origin;
+       }
+};
+
+};
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/ducktransform_scale.h b/synfig-studio/src/gui/ducktransform_scale.h
new file mode 100644 (file)
index 0000000..348a580
--- /dev/null
@@ -0,0 +1,56 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file ducktransform_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_DUCK_TRANSFORM_SCALE_H
+#define __SYNFIG_STUDIO_DUCK_TRANSFORM_SCALE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "duckmatic.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 Transform_Scale : public synfig::Transform
+{
+private:
+       synfig::Vector scale;
+       synfig::Vector origin;
+public:
+       Transform_Scale(const synfig::GUID& guid, const synfig::Vector& scale,const synfig::Vector& origin=synfig::Vector(0,0)):
+               Transform(guid), scale(scale), origin(origin) { }
+       synfig::Vector perform(const synfig::Vector& x)const { return synfig::Vector((x[0]-origin[0])*scale[0]+origin[0],(x[1]-origin[1])*scale[1]+origin[1]); }
+       synfig::Vector unperform(const synfig::Vector& x)const { return synfig::Vector((x[0]-origin[0])/scale[0]+origin[0],(x[1]-origin[1])/scale[1]+origin[1]); }
+};
+
+};
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/ducktransform_translate.h b/synfig-studio/src/gui/ducktransform_translate.h
new file mode 100644 (file)
index 0000000..fffd910
--- /dev/null
@@ -0,0 +1,55 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file ducktransform_translate.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_DUCK_TRANSFORM_TRANSLATE_H
+#define __SYNFIG_STUDIO_DUCK_TRANSFORM_TRANSLATE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "duckmatic.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 Transform_Translate : public synfig::Transform
+{
+private:
+       synfig::Vector origin;
+       std::vector<synfig::Vector> positions;
+
+public:
+       Transform_Translate(const synfig::GUID& guid, const synfig::Vector& origin):Transform(guid), origin(origin) { }
+       synfig::Vector perform(const synfig::Vector& x)const { return x+origin; }
+       synfig::Vector unperform(const synfig::Vector& x)const { return x-origin; }
+}; // END of class synfig::Transform_Translate
+
+}; // END of namespace studio
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/event_layerclick.h b/synfig-studio/src/gui/event_layerclick.h
new file mode 100644 (file)
index 0000000..e32c4cc
--- /dev/null
@@ -0,0 +1,64 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file event_layerclick.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_EVENT_LAYERCLICK_H
+#define __SYNFIG_EVENT_LAYERCLICK_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <synfig/vector.h>
+#include "event_mouse.h"
+#include <synfig/layer.h>
+#include "smach.h"
+#include <gdkmm/types.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 {
+
+struct EventLayerClick : public Smach::event
+{
+       synfig::Point pos;
+       MouseButton button;
+       etl::loose_handle<synfig::Layer> layer;
+       Gdk::ModifierType modifier;
+
+       EventLayerClick(etl::loose_handle<synfig::Layer> layer, MouseButton button, const synfig::Point& pos, Gdk::ModifierType modifier=Gdk::ModifierType(0)):
+               Smach::event(EVENT_WORKAREA_LAYER_CLICKED),
+               pos(pos),
+               button(button),
+               layer(layer),
+               modifier(modifier)
+       { }
+}; // END of EventLayerClick
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/event_mouse.h b/synfig-studio/src/gui/event_mouse.h
new file mode 100644 (file)
index 0000000..106f8aa
--- /dev/null
@@ -0,0 +1,106 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file event_mouse.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_EVENT_MOUSE_H
+#define __SYNFIG_EVENT_MOUSE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <synfig/vector.h>
+#include "smach.h"
+#include <gdkmm/types.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 {
+
+enum MouseButton
+{
+       BUTTON_NONE,
+       BUTTON_LEFT,
+       BUTTON_MIDDLE,
+       BUTTON_RIGHT,
+       BUTTON_UP,
+       BUTTON_DOWN,
+
+       BUTTON_END
+};
+
+struct EventMouse : public Smach::event
+{
+       synfig::Point pos;
+       MouseButton button;
+       float pressure;
+       Gdk::ModifierType modifier;
+
+       EventMouse(EventKey id, MouseButton button, const synfig::Point& pos, Gdk::ModifierType modifier=Gdk::ModifierType(0)):
+               Smach::event(id),
+               pos(pos),
+               button(button),
+               pressure(button==BUTTON_NONE?0.0f:1.0f),
+               modifier(modifier)
+       { }
+
+       EventMouse(EventKey id, MouseButton button, const synfig::Point& pos, float pressure, Gdk::ModifierType modifier=Gdk::ModifierType(0)):
+               Smach::event(id),
+               pos(pos),
+               button(button),
+               pressure(pressure),
+               modifier(modifier)
+       { }
+}; // END of EventMouse
+
+struct EventBox : public Smach::event
+{
+       synfig::Point p1,p2;
+       MouseButton button;
+       Gdk::ModifierType modifier;
+
+       EventBox(EventKey id, const synfig::Point& p1,const synfig::Point& p2,MouseButton button=BUTTON_NONE, Gdk::ModifierType modifier=Gdk::ModifierType(0)):
+               Smach::event(id),
+               p1(p1),
+               p2(p2),
+               button(button),
+               modifier(modifier)
+       { }
+
+       EventBox(const synfig::Point& p1,const synfig::Point& p2,MouseButton button=BUTTON_NONE, Gdk::ModifierType modifier=Gdk::ModifierType(0)):
+               Smach::event(EVENT_WORKAREA_BOX),
+               p1(p1),
+               p2(p2),
+               button(button),
+               modifier(modifier)
+       { }
+}; // END of EventBox
+
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/eventkey.h b/synfig-studio/src/gui/eventkey.h
new file mode 100644 (file)
index 0000000..639f6d1
--- /dev/null
@@ -0,0 +1,74 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file eventkey.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_EVENTKEY_H
+#define __SYNFIG_STUDIO_EVENTKEY_H
+
+/* === H E A D E R S ======================================================= */
+
+/* === 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 {
+
+enum EventKey
+{
+       EVENT_NIL,
+       EVENT_REFRESH,
+       EVENT_DIRTY,
+       EVENT_STOP,
+       EVENT_UNDO,
+       EVENT_REDO,
+       EVENT_REFRESH_DUCKS,
+       EVENT_REFRESH_TOOL_OPTIONS,
+       EVENT_YIELD_TOOL_OPTIONS,
+       EVENT_INPUT_DEVICE_CHANGED,
+       EVENT_TABLES_HIDE,
+       EVENT_LAYER_SELECTION_CHANGED,
+       EVENT_TABLES_SHOW,
+
+
+       EVENT_WORKAREA_START=1000,              //!< Not a valid event
+       EVENT_WORKAREA_LAYER_CLICKED,
+       EVENT_WORKAREA_MULTIPLE_DUCKS_CLICKED,
+       EVENT_WORKAREA_MOUSE_MOTION,
+       EVENT_WORKAREA_MOUSE_BUTTON_DOWN,
+       EVENT_WORKAREA_MOUSE_BUTTON_DRAG,
+       EVENT_WORKAREA_MOUSE_BUTTON_UP,
+       EVENT_WORKAREA_BOX,
+       EVENT_WORKAREA_END,             //!< Not a valid event
+
+       EVENT_WORKAREA_STROKE,
+
+       EVENT_END               //!< Not a valid event
+};
+
+};
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/framedial.cpp b/synfig-studio/src/gui/framedial.cpp
new file mode 100644 (file)
index 0000000..6437930
--- /dev/null
@@ -0,0 +1,91 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file framedial.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**  Copyright (c) 2008 Chris Moore
+**  Copyright (c) 2009 Gerco Ballintijn
+**     Copyright (c) 2009 Carlos López
+**
+**     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 <config.h>
+#endif
+
+#include "framedial.h"
+#include <gtkmm/image.h>
+#include <gtkmm/stock.h>
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+FrameDial::FrameDial(): Gtk::Table(5, 1, false)
+{
+       Gtk::IconSize iconsize = Gtk::IconSize::from_name("synfig-small_icon");
+
+       seek_begin = create_icon(iconsize, Gtk::Stock::MEDIA_PREVIOUS,
+                                       _("Seek to Begin"));
+       seek_prev_frame = create_icon(iconsize, Gtk::Stock::MEDIA_REWIND,
+                                       _("Previous Frame"));
+       play_stop = create_icon(iconsize, Gtk::Stock::MEDIA_PLAY,
+                                       _("Play"));
+       seek_next_frame = create_icon(iconsize, Gtk::Stock::MEDIA_FORWARD,
+                                       _("Next Frame"));
+       seek_end = create_icon(iconsize, Gtk::Stock::MEDIA_NEXT,
+                                       _("Seek to End"));
+
+       attach(*seek_begin, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       attach(*seek_prev_frame, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       attach(*play_stop, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       attach(*seek_next_frame, 3, 4, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       attach(*seek_end, 4, 5, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+}
+
+Gtk::Button *
+FrameDial::create_icon(Gtk::IconSize size, const Gtk::BuiltinStockID & stockid,
+               const char * tooltip)
+{
+       Gtk::Button *button = manage(new class Gtk::Button());
+       Gtk::Image *icon = manage(new Gtk::Image(stockid, size));
+       button->add(*icon);
+       tooltips.set_tip(*button, tooltip);
+       icon->set_padding(0, 0);
+       icon->show();
+       button->set_relief(Gtk::RELIEF_NONE);
+       button->show();
+
+       return button;
+}
+
diff --git a/synfig-studio/src/gui/framedial.h b/synfig-studio/src/gui/framedial.h
new file mode 100644 (file)
index 0000000..4fc51ca
--- /dev/null
@@ -0,0 +1,79 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file zoomdial.h
+**     \brief Template Header
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**  Copyright (c) 2008 Chris Moore
+**  Copyright (c) 2009 Gerco Ballintijn
+**     Copyright (c) 2009 Carlos López
+**
+**     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_FRAMEDIAL_H
+#define __SYNFIG_STUDIO_FRAMEDIAL_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/tooltips.h>
+#include <gtkmm/table.h>
+#include <gtkmm/button.h>
+
+#include "general.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 FrameDial : public Gtk::Table
+{
+       Gtk::Tooltips tooltips;
+
+       Gtk::Button *seek_begin;
+       Gtk::Button *seek_prev_frame;
+       Gtk::Button *play_stop;
+       Gtk::Button *seek_next_frame;
+       Gtk::Button *seek_end;
+
+       Gtk::Button *create_icon(Gtk::IconSize size, const Gtk::BuiltinStockID & stockid,
+                       const char * tooltip);
+
+public:
+       FrameDial();
+
+       Glib::SignalProxy0<void> signal_seek_begin()            { return seek_begin->signal_clicked(); }
+       Glib::SignalProxy0<void> signal_seek_prev_frame()       { return seek_prev_frame->signal_clicked(); }
+       Glib::SignalProxy0<void> signal_play_stop()                     { return play_stop->signal_clicked(); }
+       Glib::SignalProxy0<void> signal_seek_next_frame()       { return seek_next_frame->signal_clicked(); }
+       Glib::SignalProxy0<void> signal_seek_end()                      { return seek_end->signal_clicked(); }
+
+       Gtk::Button *get_play_button() { return play_stop; }
+
+}; // END of class FrameDial
+
+}; // END of namespace studio
+
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/general.h b/synfig-studio/src/gui/general.h
new file mode 100644 (file)
index 0000000..154a614
--- /dev/null
@@ -0,0 +1,54 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file gtkmm/general.h
+**     \brief General header file for synfigstudio
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2007 Paul Wise
+**
+**     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 __SYNFIGSTUDIO_GENERAL_H
+#define __SYNFIGSTUDIO_GENERAL_H
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef ENABLE_NLS
+#include <libintl.h>
+#endif
+
+/* === M A C R O S ========================================================= */
+
+#undef _
+#undef gettext_noop
+#undef N_
+#ifdef ENABLE_NLS
+#define _(x) gettext(x)
+#define gettext_noop(x) x
+#define N_(x) gettext_noop(x)
+#else
+#define _(x) (x)
+#define N_(x) (x)
+#endif
+
+/* === T Y P E D E F S ===================================================== */
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/groupactionmanager.cpp b/synfig-studio/src/gui/groupactionmanager.cpp
new file mode 100644 (file)
index 0000000..54eab18
--- /dev/null
@@ -0,0 +1,275 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file groupactionmanager.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \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
+**     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 <config.h>
+#endif
+
+#include "groupactionmanager.h"
+#include "layergrouptree.h"
+#include <synfigapp/action_param.h>
+#include "instance.h"
+#include <gtkmm/stock.h>
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+using namespace studio;
+
+static const guint no_prev_popup((guint)-1);
+
+/* === M A C R O S ========================================================= */
+
+//#define ONE_ACTION_GROUP 1
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+GroupActionManager::GroupActionManager():
+       action_group_(Gtk::ActionGroup::create("action_group_group_action_manager")),
+       popup_id_(no_prev_popup),
+       queued(false)
+{
+}
+
+GroupActionManager::~GroupActionManager()
+{
+}
+
+void
+GroupActionManager::set_ui_manager(const Glib::RefPtr<Gtk::UIManager> &x)
+{
+       clear();
+
+#ifdef ONE_ACTION_GROUP
+       if(ui_manager_) get_ui_manager()->remove_action_group(action_group_);
+       ui_manager_=x;
+       if(ui_manager_) get_ui_manager()->insert_action_group(action_group_);
+#else
+       ui_manager_=x;
+#endif
+}
+
+void
+GroupActionManager::set_group_tree(LayerGroupTree* x)
+{
+       selection_changed_connection.disconnect();
+       group_tree_=x;
+       if(group_tree_)
+       {
+               selection_changed_connection=group_tree_->get_selection()->signal_changed().connect(
+                       sigc::mem_fun(*this,&GroupActionManager::queue_refresh)
+               );
+       }
+}
+
+void
+GroupActionManager::set_canvas_interface(const etl::handle<synfigapp::CanvasInterface> &x)
+{
+       canvas_interface_=x;
+}
+
+void
+GroupActionManager::clear()
+{
+       if(ui_manager_)
+       {
+               // Clear out old stuff
+               if(popup_id_!=no_prev_popup)
+               {
+                       get_ui_manager()->remove_ui(popup_id_);
+                       popup_id_=no_prev_popup;
+                       action_group_->set_sensitive(false);
+#ifdef ONE_ACTION_GROUP
+                       while(!action_group_->get_actions().empty())action_group_->remove(*action_group_->get_actions().begin());
+                       action_group_->set_sensitive(true);
+#else
+                       get_ui_manager()->remove_action_group(action_group_);
+                       action_group_=Gtk::ActionGroup::create("action_group_group_action_manager");
+#endif
+               }
+       }
+}
+
+void
+GroupActionManager::queue_refresh()
+{
+       if(queued)
+               return;
+
+       //queue_refresh_connection.disconnect();
+       queue_refresh_connection=Glib::signal_idle().connect(
+               sigc::bind_return(
+                       sigc::mem_fun(*this,&GroupActionManager::refresh),
+                       false
+               )
+       );
+
+       queued=true;
+}
+
+void
+GroupActionManager::refresh()
+{
+       if(queued)
+       {
+               queued=false;
+               //queue_refresh_connection.disconnect();
+       }
+
+
+       clear();
+
+       // Make sure we are ready
+       if(!ui_manager_ || !group_tree_ || !canvas_interface_)
+       {
+               synfig::error("GroupActionManager::refresh(): Not ready!");
+               return;
+       }
+
+       if(group_tree_->get_selection()->count_selected_rows()==0)
+               return;
+
+       String ui_info;
+
+       {
+               {
+                       action_group_->add(
+                               Gtk::Action::create(
+                                       "action-group_add",
+                                       Gtk::Stock::ADD,
+                                       _("Add a New Group"),
+                                       _("Add a New Group")
+                               ),
+                               sigc::mem_fun(
+                                       *this,
+                                       &GroupActionManager::on_action_add
+                               )
+                       );
+               }
+
+
+//             bool multiple_selected(group_tree_->get_selection()->count_selected_rows()>1);
+               LayerGroupTree::LayerList selected_layers(group_tree_->get_selected_layers());
+               std::list<synfig::String> selected_groups(group_tree_->get_selected_groups());
+
+               synfig::info("selected_layers.size()=%d",selected_layers.size());
+               synfig::info("selected_groups.size()=%d",selected_groups.size());
+
+               {
+                       bool canvas_set(false);
+                       synfigapp::Action::ParamList param_list;
+                       param_list.add("time",get_canvas_interface()->get_time());
+                       param_list.add("canvas_interface",get_canvas_interface());
+
+                       {
+                               LayerGroupTree::LayerList::iterator iter;
+
+                               for(iter=selected_layers.begin();iter!=selected_layers.end();++iter)
+                               {
+                                       if(!canvas_set)
+                                       {
+                                               param_list.add("canvas",Canvas::Handle(Layer::Handle(*iter)->get_canvas()));
+                                               canvas_set=true;
+                                       }
+                                       param_list.add("layer",Layer::Handle(*iter));
+                               }
+                       }
+
+                       {
+                               std::list<synfig::String>::iterator iter;
+
+                               for(iter=selected_groups.begin();iter!=selected_groups.end();++iter)
+                               {
+                                       param_list.add("group",(synfig::String)*iter);
+                               }
+                       }
+
+                       if(!canvas_set)
+                       {
+                               param_list.add("canvas",Canvas::Handle(get_canvas_interface()->get_canvas()));
+                               canvas_set=true;
+                       }
+
+                       handle<studio::Instance>::cast_static(get_canvas_interface()->get_instance())->
+                               add_actions_to_group(action_group_, ui_info,   param_list, synfigapp::Action::CATEGORY_GROUP);
+                       }
+       }
+
+       if(true)
+       {
+               ui_info="<ui><popup action='menu-main'><menu action='menu-group'>"+ui_info+"</menu></popup></ui>";
+               popup_id_=get_ui_manager()->add_ui_from_string(ui_info);
+       }
+       else
+       {
+               get_ui_manager()->ensure_update();
+       }
+
+#ifdef ONE_ACTION_GROUP
+#else
+       get_ui_manager()->insert_action_group(action_group_);
+#endif
+}
+
+void
+GroupActionManager::on_action_add()
+{
+       LayerGroupTreeStore::Model model;
+
+       String group_name;
+
+       Gtk::TreeIter selected_iter;
+
+       if(group_tree_->get_selection()->count_selected_rows())
+       {
+               selected_iter=(
+                       group_tree_->get_model()->get_iter(
+                               (*group_tree_->get_selection()->get_selected_rows().begin())
+                       )
+               );
+               if(selected_iter && selected_iter->parent())
+                       group_name=(Glib::ustring)(*selected_iter->parent())[model.group_name]+'.';
+       }
+
+       group_name+=_("UnnamedGroup");
+
+       Gtk::TreePath path(group_tree_->get_model()->on_group_added(group_name));
+
+       group_tree_->expand_to_path(path);
+       group_tree_->set_cursor(path,true);
+}
diff --git a/synfig-studio/src/gui/groupactionmanager.h b/synfig-studio/src/gui/groupactionmanager.h
new file mode 100644 (file)
index 0000000..0e232f9
--- /dev/null
@@ -0,0 +1,85 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file groupactionmanager.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_GROUP_ACTION_MANAGER_H
+#define __SYNFIG_GROUP_ACTION_MANAGER_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/uimanager.h>
+#include <gtkmm/treeview.h>
+#include <synfigapp/canvasinterface.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 LayerGroupTree;
+
+class GroupActionManager
+{
+       Glib::RefPtr<Gtk::UIManager> ui_manager_;
+       LayerGroupTree* group_tree_;
+       etl::handle<synfigapp::CanvasInterface> canvas_interface_;
+
+       Glib::RefPtr<Gtk::ActionGroup>  action_group_;
+       Gtk::UIManager::ui_merge_id     popup_id_;
+
+       sigc::connection selection_changed_connection;
+
+       bool queued;
+       sigc::connection queue_refresh_connection;
+
+private:
+
+       void on_action_add();
+
+public:
+       void queue_refresh();
+
+       GroupActionManager();
+       ~GroupActionManager();
+
+       void set_ui_manager(const Glib::RefPtr<Gtk::UIManager> &x);
+       Glib::RefPtr<Gtk::UIManager> get_ui_manager()const { return ui_manager_; }
+
+       void set_group_tree(LayerGroupTree* x);
+       LayerGroupTree* get_group_tree()const { return group_tree_; }
+
+       void set_canvas_interface(const etl::handle<synfigapp::CanvasInterface> &x);
+       etl::handle<synfigapp::CanvasInterface> get_canvas_interface()const { return canvas_interface_; }
+
+       void refresh();
+       void clear();
+}; // END of GroupActionManager
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/historytreestore.cpp b/synfig-studio/src/gui/historytreestore.cpp
new file mode 100644 (file)
index 0000000..1f0eb9c
--- /dev/null
@@ -0,0 +1,235 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file historytreestore.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 <config.h>
+#endif
+
+#include "historytreestore.h"
+#include <synfig/valuenode.h>
+#include "iconcontroller.h"
+#include <synfig/valuenode_timedswap.h>
+#include <gtkmm/button.h>
+#include <synfigapp/action.h>
+#include "instance.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+static HistoryTreeStore::Model& ModelHack()
+{
+       static HistoryTreeStore::Model* model(0);
+       if(!model)model=new HistoryTreeStore::Model;
+       return *model;
+}
+
+HistoryTreeStore::HistoryTreeStore(etl::loose_handle<studio::Instance> instance_):
+       Gtk::TreeStore  (ModelHack()),
+       instance_               (instance_)
+{
+       instance_->signal_undo().connect(sigc::mem_fun(*this,&studio::HistoryTreeStore::on_undo));
+       instance_->signal_redo().connect(sigc::mem_fun(*this,&studio::HistoryTreeStore::on_redo));
+       instance_->signal_undo_stack_cleared().connect(sigc::mem_fun(*this,&studio::HistoryTreeStore::on_undo_stack_cleared));
+       instance_->signal_redo_stack_cleared().connect(sigc::mem_fun(*this,&studio::HistoryTreeStore::on_redo_stack_cleared));
+       instance_->signal_new_action().connect(sigc::mem_fun(*this,&studio::HistoryTreeStore::on_new_action));
+       instance_->signal_action_status_changed().connect(sigc::mem_fun(*this,&studio::HistoryTreeStore::on_action_status_changed));
+}
+
+HistoryTreeStore::~HistoryTreeStore()
+{
+       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
+               synfig::info("HistoryTreeStore::~HistoryTreeStore(): Deleted");
+}
+
+Glib::RefPtr<HistoryTreeStore>
+HistoryTreeStore::create(etl::loose_handle<studio::Instance> instance_)
+{
+       return Glib::RefPtr<HistoryTreeStore>(new HistoryTreeStore(instance_));
+}
+
+void
+HistoryTreeStore::rebuild()
+{
+       synfigapp::Action::Stack::const_iterator iter;
+
+       clear();
+
+       for(iter=instance()->undo_action_stack().begin();iter!=instance()->undo_action_stack().end();++iter)
+       {
+               insert_action(*(prepend()),*iter,true,true,false);
+       }
+       curr_row=*children().end();
+       for(iter=instance()->redo_action_stack().begin();iter!=instance()->redo_action_stack().end();++iter)
+       {
+               insert_action(*(append()),*iter,true,false,true);
+       }
+
+       signal_undo_tree_changed()();
+}
+
+void
+HistoryTreeStore::insert_action(Gtk::TreeRow row,etl::handle<synfigapp::Action::Undoable> action, bool /*is_active*/, bool is_undo, bool is_redo)
+{
+       assert(action);
+
+       row[model.action] = action;
+       row[model.name] = static_cast<Glib::ustring>(action->get_local_name());
+       row[model.is_active] = action->is_active();
+       row[model.is_undo] = is_undo;
+       row[model.is_redo] = is_redo;
+
+       synfigapp::Action::CanvasSpecific *specific_action;
+       specific_action=dynamic_cast<synfigapp::Action::CanvasSpecific*>(action.get());
+       if(specific_action)
+       {
+               row[model.canvas] = specific_action->get_canvas();
+               row[model.canvas_id] = specific_action->get_canvas()->get_id();
+       }
+
+       etl::handle<synfigapp::Action::Group> group;
+       group=etl::handle<synfigapp::Action::Group>::cast_dynamic(action);
+       if(group)
+       {
+               synfigapp::Action::ActionList::const_iterator iter;
+               for(iter=group->action_list().begin();iter!=group->action_list().end();++iter)
+               {
+                       Gtk::TreeRow child_row = *(append(row.children()));
+                       insert_action(child_row,*iter,true,is_undo,is_redo);
+               }
+       }
+
+       //row[model.icon] = Gtk::Button().render_icon(Gtk::StockID("synfig-canvas"),Gtk::ICON_SIZE_SMALL_TOOLBAR);
+}
+
+
+void
+HistoryTreeStore::on_undo()
+{
+       refresh();
+}
+
+void
+HistoryTreeStore::on_redo()
+{
+       refresh();
+}
+
+void
+HistoryTreeStore::on_undo_stack_cleared()
+{
+       Gtk::TreeModel::Children::iterator iter,next;
+       Gtk::TreeModel::Children children_(children());
+
+       for(next=children_.begin(),iter=next++; iter != children_.end(); iter=(next!=children_.end())?next++:next)
+       {
+               Gtk::TreeModel::Row row = *iter;
+               if(row[model.is_undo])
+                       erase(iter);
+       }
+}
+
+void
+HistoryTreeStore::on_redo_stack_cleared()
+{
+       Gtk::TreeModel::Children::iterator iter,next;
+       Gtk::TreeModel::Children children_(children());
+
+       for(next=children_.begin(),iter=next++; iter != children_.end(); iter=(next!=children_.end())?next++:next)
+       {
+               Gtk::TreeModel::Row row = *iter;
+               if(row[model.is_redo])
+                       erase(iter);
+       }
+}
+
+void
+HistoryTreeStore::on_new_action(etl::handle<synfigapp::Action::Undoable> action)
+{
+//     Gtk::TreeRow row = *(append());
+       Gtk::TreeRow row;
+       Gtk::TreeModel::Children::iterator iter;
+       for(iter=children().begin(); iter != children().end(); ++iter)
+       {
+               Gtk::TreeModel::Row row = *iter;
+               if(row[model.is_redo])
+               {
+                       break;
+               }
+       }
+
+       row=*insert(iter);
+
+       insert_action(row,action);
+
+       signal_undo_tree_changed()();
+}
+
+void
+HistoryTreeStore::on_action_status_changed(etl::handle<synfigapp::Action::Undoable> action)
+{
+       Gtk::TreeModel::Children::iterator iter;
+       Gtk::TreeModel::Children children_(children());
+
+       for(iter=children_.begin(); iter != children_.end(); ++iter)
+       {
+               Gtk::TreeModel::Row row = *iter;
+               if(action == (etl::handle<synfigapp::Action::Undoable>)row[model.action])
+               {
+                       row[model.is_active]=action->is_active();
+                       return;
+               }
+       }
+}
+
+bool
+HistoryTreeStore::search_func(const Glib::RefPtr<Gtk::TreeModel>&,int,const Glib::ustring& x,const Gtk::TreeModel::iterator& iter)
+{
+       const Model model;
+
+       Glib::ustring substr(x.uppercase());
+       Glib::ustring name((*iter)[model.name]);
+       name=name.uppercase();
+
+       return name.find(substr)==Glib::ustring::npos;
+}
diff --git a/synfig-studio/src/gui/historytreestore.h b/synfig-studio/src/gui/historytreestore.h
new file mode 100644 (file)
index 0000000..31a4b13
--- /dev/null
@@ -0,0 +1,172 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file historytreestore.h
+**     \brief Template Header
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_STUDIO_HISTORYTREESTORE_H
+#define __SYNFIG_STUDIO_HISTORYTREESTORE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/treestore.h>
+#include <synfigapp/canvasinterface.h>
+#include <gdkmm/pixbuf.h>
+#include <synfigapp/action.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 Instance;
+
+class HistoryTreeStore : virtual public Gtk::TreeStore
+{
+       /*
+ -- ** -- P U B L I C   T Y P E S ---------------------------------------------
+       */
+
+public:
+
+       class Model : public Gtk::TreeModel::ColumnRecord
+       {
+       public:
+       public:
+               Gtk::TreeModelColumn<etl::handle<synfigapp::Action::Undoable> > action;
+               Gtk::TreeModelColumn<Glib::ustring> name;
+               Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
+               Gtk::TreeModelColumn<bool> is_active;
+               Gtk::TreeModelColumn<bool> is_undo;
+               Gtk::TreeModelColumn<bool> is_redo;
+
+               Gtk::TreeModelColumn<Glib::ustring> canvas_id;
+               Gtk::TreeModelColumn<synfig::Canvas::Handle> canvas;
+
+               Model()
+               {
+                       add(action);
+                       add(name);
+                       add(icon);
+                       add(is_active);
+                       add(is_undo);
+                       add(is_redo);
+                       add(canvas_id);
+                       add(canvas);
+               }
+       };
+
+       /*
+ -- ** -- P U B L I C  D A T A ------------------------------------------------
+       */
+
+public:
+
+       const Model model;
+
+       /*
+ -- ** -- P R I V A T E   D A T A ---------------------------------------------
+       */
+
+private:
+
+       etl::loose_handle<studio::Instance> instance_;
+       Gtk::TreeIter curr_row;
+
+       /*
+ -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
+       */
+
+private:
+
+       /*
+ -- ** -- P R I V A T E   D A T A ---------------------------------------------
+       */
+
+private:
+
+       sigc::signal<void> signal_undo_tree_changed_;
+
+       /*
+ -- ** -- S I G N A L   I N T E R F A C E S -----------------------------------
+       */
+
+public:
+
+       sigc::signal<void>& signal_undo_tree_changed() { return signal_undo_tree_changed_; }
+
+       /*
+ -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
+       */
+
+private:
+
+       void on_undo();
+
+       void on_redo();
+
+       void on_undo_stack_cleared();
+
+       void on_redo_stack_cleared();
+
+       void on_new_action(etl::handle<synfigapp::Action::Undoable> action);
+
+       void on_action_status_changed(etl::handle<synfigapp::Action::Undoable> action);
+
+       /*
+ -- ** -- P U B L I C   M E T H O D S -----------------------------------------
+       */
+
+public:
+
+       HistoryTreeStore(etl::loose_handle<studio::Instance> instance_);
+       ~HistoryTreeStore();
+
+       etl::loose_handle<studio::Instance> instance() { return instance_; }
+       etl::loose_handle<const studio::Instance> instance()const { return instance_; }
+
+       void rebuild();
+
+       void refresh() { rebuild(); }
+
+       void insert_action(Gtk::TreeRow row,etl::handle<synfigapp::Action::Undoable> action, bool is_active=true, bool is_undo=true, bool is_redo=false);
+
+       static bool search_func(const Glib::RefPtr<TreeModel>&,int,const Glib::ustring&,const TreeModel::iterator&);
+
+       /*
+ -- ** -- P R O T E C T E D   M E T H O D S -----------------------------------
+       */
+
+public:
+
+       static Glib::RefPtr<HistoryTreeStore> create(etl::loose_handle<studio::Instance> instance);
+
+}; // END of class HistoryTreeStore
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/iconcontroller.cpp b/synfig-studio/src/gui/iconcontroller.cpp
new file mode 100644 (file)
index 0000000..de86bbb
--- /dev/null
@@ -0,0 +1,442 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file iconcontroller.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 2008 Chris Moore
+**  Copyright (c) 2008 Paul Wise
+**  Copyright (c) 2009 Gerco Ballintijn
+**     Copyright (c) 2009 Carlos López
+**     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 <config.h>
+#endif
+
+#include "iconcontroller.h"
+#include <synfig/valuenode_const.h>
+#include <gtkmm/button.h>
+#include <gtkmm/window.h>
+#include <synfigapp/action.h>
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace etl;
+using namespace std;
+using namespace studio;
+using namespace synfig;
+
+/* === M A C R O S ========================================================= */
+
+#ifdef WIN32
+#      ifdef IMAGE_DIR
+#              undef IMAGE_DIR
+#              define IMAGE_DIR "share\\pixmaps"
+#      endif
+#endif
+
+#ifndef IMAGE_DIR
+#      define IMAGE_DIR "/usr/local/share/pixmaps"
+#endif
+
+
+#ifndef IMAGE_EXT
+#      define IMAGE_EXT        "png"
+#endif
+
+/* === M E T H O D S ======================================================= */
+
+static Glib::RefPtr<Gdk::Pixbuf> _tree_pixbuf_table_value_type[(int)synfig::ValueBase::TYPE_END];
+
+#ifdef WIN32
+IconController::IconController(const synfig::String& basepath)
+#else
+IconController::IconController(const synfig::String& /*basepath*/)
+#endif
+{
+       Gtk::IconSource icon_source;
+       icon_source.set_direction_wildcarded();
+       icon_source.set_state_wildcarded();
+       icon_source.set_size_wildcarded();
+       icon_factory=Gtk::IconFactory::create();
+
+       std::string path_to_icons;
+#ifdef WIN32
+       path_to_icons=basepath+ETL_DIRECTORY_SEPARATOR+".."+ETL_DIRECTORY_SEPARATOR+IMAGE_DIR;
+#else
+       path_to_icons=IMAGE_DIR;
+#endif
+
+       char* synfig_root=getenv("SYNFIG_ROOT");
+       if(synfig_root) {
+               path_to_icons=synfig_root;
+               path_to_icons+=ETL_DIRECTORY_SEPARATOR;
+               path_to_icons+="share";
+               path_to_icons+=ETL_DIRECTORY_SEPARATOR;
+               path_to_icons+="pixmaps";
+               path_to_icons+=ETL_DIRECTORY_SEPARATOR;
+               path_to_icons+="synfigstudio";
+       }
+       path_to_icons+=ETL_DIRECTORY_SEPARATOR;
+
+       try{
+       Gtk::Window::set_default_icon_from_file(path_to_icons+"synfig_icon."+IMAGE_EXT);
+       } catch(...)
+       {
+               synfig::warning("Unable to open "+path_to_icons+"synfig_icon."+IMAGE_EXT);
+       }
+
+#define INIT_STOCK_ICON(name,iconfile,desc){                                                   \
+       Gtk::StockItem stockitem(Gtk::StockID("synfig-" #name),desc); \
+       Gtk::Stock::add(stockitem);                                                             \
+       Gtk::IconSet icon_set;                                                                  \
+       icon_source.set_filename(path_to_icons+iconfile);                                                       \
+       icon_set.add_source(icon_source);                                               \
+       icon_factory->add(stockitem.get_stock_id(),icon_set); \
+       }
+
+#define INIT_STOCK_ICON_CLONE(name,stockid,desc){                                                      \
+       Gtk::StockItem stockitem(Gtk::StockID("synfig-" #name),desc); \
+       Gtk::Stock::add(stockitem);                                                             \
+       Gtk::IconSet icon_set;                                                                  \
+       if(Gtk::Stock::lookup(stockitem.get_stock_id(),icon_set))       \
+       icon_factory->add(stockitem.get_stock_id(),icon_set); \
+       }
+
+#define INIT_STOCK_ITEM(name,desc)                                                     \
+       stock_##name=Gtk::StockItem(Gtk::StockID("synfig-" #name),desc);                        \
+       Gtk::Stock::add(stock_##name);
+
+       INIT_STOCK_ICON(bool,"bool_icon."IMAGE_EXT,_("Bool"));
+       INIT_STOCK_ICON(integer,"integer_icon."IMAGE_EXT,_("Integer"));
+       INIT_STOCK_ICON(angle,"angle_icon."IMAGE_EXT,_("Angle"));
+       INIT_STOCK_ICON(time,"time_icon."IMAGE_EXT,_("Time"));
+       INIT_STOCK_ICON(real,"real_icon."IMAGE_EXT,_("Real"));
+       INIT_STOCK_ICON(vector,"vector_icon."IMAGE_EXT,_("Vector"));
+       INIT_STOCK_ICON(color,"color_icon."IMAGE_EXT,_("Color"));
+       INIT_STOCK_ICON(segment,"segment_icon."IMAGE_EXT,_("Segment"));
+       INIT_STOCK_ICON(blinepoint,"blinepoint_icon."IMAGE_EXT,_("BLine Point"));
+       INIT_STOCK_ICON(list,"list_icon."IMAGE_EXT,_("Rename"));
+       INIT_STOCK_ICON(canvas,"canvas_icon."IMAGE_EXT,_("Canvas"));
+       INIT_STOCK_ICON(string,"string_icon."IMAGE_EXT,_("Rename"));
+
+       INIT_STOCK_ICON(reset_colors,"reset_colors_icon."IMAGE_EXT,_("Reset Colors"));
+       INIT_STOCK_ICON(swap_colors,"swap_colors_icon."IMAGE_EXT,_("Swap Colors"));
+       INIT_STOCK_ICON(value_node,"valuenode_icon."IMAGE_EXT,_("ValueNode"));
+       INIT_STOCK_ICON(about,"about_icon."IMAGE_EXT,_("About"));
+       INIT_STOCK_ICON(rename,"rename_icon."IMAGE_EXT,_("Rename"));
+       INIT_STOCK_ICON(canvas_pointer,"canvas_pointer_icon."IMAGE_EXT,_("Rename"));
+       INIT_STOCK_ICON(canvas_new,"canvas_icon."IMAGE_EXT,_("New Canvas"));
+       INIT_STOCK_ICON(saveall,"saveall_icon."IMAGE_EXT,_("Save All"));
+       INIT_STOCK_ICON(layer,"layer_icon."IMAGE_EXT,_("Layer"));
+       INIT_STOCK_ICON(layer_pastecanvas,"pastecanvas_icon."IMAGE_EXT,_("Paste Canvas"));
+       INIT_STOCK_ICON(plant,"plant_icon."IMAGE_EXT,"");
+       INIT_STOCK_ICON(group,"group_icon."IMAGE_EXT,_("Group"));
+       INIT_STOCK_ICON(grid_enable,"grid_enable_icon."IMAGE_EXT,_("Show Grid"));
+       INIT_STOCK_ICON(grid_disable,"grid_disable_icon."IMAGE_EXT,_("Hide Grid"));
+       INIT_STOCK_ICON(grid_snap_enable,"grid_snap_enable_icon."IMAGE_EXT,_("Enable Grid Snap"));
+       INIT_STOCK_ICON(grid_snap_disable,"grid_snap_disable_icon."IMAGE_EXT,_("Disable Grid Snap"));
+       INIT_STOCK_ICON(duplicate,"duplicate_icon."IMAGE_EXT,_("Duplicate"));
+       INIT_STOCK_ICON(encapsulate,"encapsulate_icon."IMAGE_EXT,_("Encapsulate"));
+       INIT_STOCK_ICON(select_all_child_layers,"select_all_child_layers_icon."IMAGE_EXT,_("Select All Child Layers"));
+
+       INIT_STOCK_ICON(clear_undo,"clear_undo_icon."IMAGE_EXT,_("Clear Undo Stack"));
+       INIT_STOCK_ICON(clear_redo,"clear_redo_icon."IMAGE_EXT,_("Clear Redo Stack"));
+
+       INIT_STOCK_ICON(children,"children_icon."IMAGE_EXT,_("Children"));
+       INIT_STOCK_ICON(curves,"curves_icon."IMAGE_EXT,_("Curves"));
+       INIT_STOCK_ICON(keyframes,"keyframe_icon."IMAGE_EXT,_("Keyframes"));
+       INIT_STOCK_ICON(meta_data,"meta_data_icon."IMAGE_EXT,_("MetaData"));
+       INIT_STOCK_ICON(navigator,"navigator_icon."IMAGE_EXT,_("Navigator"));
+       INIT_STOCK_ICON(timetrack,"time_track_icon."IMAGE_EXT,_("Time Track"));
+
+       INIT_STOCK_ICON(keyframe_lock_all,"keyframe_lock_all."IMAGE_EXT,_("All Keyframes Locked"));
+       INIT_STOCK_ICON(keyframe_lock_past,"keyframe_lock_past."IMAGE_EXT,_("Past Keyframes Locked"));
+       INIT_STOCK_ICON(keyframe_lock_future,"keyframe_lock_future."IMAGE_EXT,_("Future Keyframes Locked"));
+       INIT_STOCK_ICON(keyframe_lock_none,"keyframe_lock_none."IMAGE_EXT,_("No Keyframes Locked"));
+
+       INIT_STOCK_ICON(set_outline_color,"set_outline_color."IMAGE_EXT,_("Set as Outline"));
+       INIT_STOCK_ICON(set_fill_color,"set_fill_color."IMAGE_EXT,_("Set as Fill"));
+
+       INIT_STOCK_ICON(seek_begin,"seek_begin."IMAGE_EXT,_("Seek to Begin"));
+       INIT_STOCK_ICON(seek_prev_frame,"seek_prev_frame."IMAGE_EXT,_("Previous Frame"));
+       INIT_STOCK_ICON(seek_next_frame,"seek_next_frame."IMAGE_EXT,_("Next Frame"));
+       INIT_STOCK_ICON(seek_end,"seek_end."IMAGE_EXT,_("Seek to End"));
+
+       INIT_STOCK_ICON(toggle_duck_position,"duck_position_icon."IMAGE_EXT,_("Toggle position ducks"));
+       INIT_STOCK_ICON(toggle_duck_vertex,"duck_vertex_icon."IMAGE_EXT,_("Toggle vertex ducks"));
+       INIT_STOCK_ICON(toggle_duck_tangent,"duck_tangent_icon."IMAGE_EXT,_("Toggle tangent ducks"));
+       INIT_STOCK_ICON(toggle_duck_radius,"duck_radius_icon."IMAGE_EXT,_("Toggle radius ducks"));
+       INIT_STOCK_ICON(toggle_duck_width,"duck_width_icon."IMAGE_EXT,_("Toggle width ducks"));
+       INIT_STOCK_ICON(toggle_duck_angle,"duck_angle_icon."IMAGE_EXT,_("Toggle angle ducks"));
+
+       INIT_STOCK_ICON(toggle_show_grid,"show_grid_icon."IMAGE_EXT,_("Toggle show grid"));
+       INIT_STOCK_ICON(toggle_snap_grid,"snap_grid_icon."IMAGE_EXT,_("Toggle snap grid"));
+
+       INIT_STOCK_ICON(toggle_onion_skin,"onion_skin_icon."IMAGE_EXT,_("Toggle onion skin"));
+
+       INIT_STOCK_ICON(increase_resolution,"incr_resolution_icon."IMAGE_EXT,_("Increase resolution"));
+       INIT_STOCK_ICON(decrease_resolution,"decr_resolution_icon."IMAGE_EXT,_("Decrease resolution"));
+
+       INIT_STOCK_ICON(preview_options,"preview_options_icon."IMAGE_EXT,_("Preview Options Dialog"));
+       INIT_STOCK_ICON(render_options,"render_options_icon."IMAGE_EXT,_("Render Options Dialog"));
+
+       INIT_STOCK_ICON_CLONE(cvs_add,"gtk-add",_("CVS Add"));
+       INIT_STOCK_ICON_CLONE(cvs_update,"gtk-open",_("CVS Update"));
+       INIT_STOCK_ICON_CLONE(cvs_commit,"gtk-save",_("CVS Commit"));
+       INIT_STOCK_ICON_CLONE(cvs_revert,"gtk-revert",_("CVS Revert"));
+
+       // Tools
+       INIT_STOCK_ICON(normal,"normal_icon."IMAGE_EXT,_("Normal Tool"));
+       INIT_STOCK_ICON(transform,"transform_icon."IMAGE_EXT,_("Transform Tool"));
+       INIT_STOCK_ICON(polygon,"polyline_icon."IMAGE_EXT,_("Polygon Tool"));
+       INIT_STOCK_ICON(bline,"bline_icon."IMAGE_EXT,_("BLine Tool"));
+       INIT_STOCK_ICON(eyedrop,"eyedrop_icon."IMAGE_EXT,_("Eyedrop Tool"));
+       INIT_STOCK_ICON(fill,"fill_icon."IMAGE_EXT,_("Fill Tool"));
+       INIT_STOCK_ICON(draw,"draw_icon."IMAGE_EXT,_("Draw Tool"));
+       INIT_STOCK_ICON(sketch,"sketch_icon."IMAGE_EXT,_("Sketch Tool"));
+       INIT_STOCK_ICON(circle,"circle_icon."IMAGE_EXT,_("Circle Tool"));
+       INIT_STOCK_ICON(rectangle,"rectangle_icon."IMAGE_EXT,_("Rectangle Tool"));
+       INIT_STOCK_ICON(smooth_move,"smooth_move_icon."IMAGE_EXT,_("SmoothMove Tool"));
+       INIT_STOCK_ICON(rotate,"rotate_icon."IMAGE_EXT,"Rotate Tool");
+       INIT_STOCK_ICON(width,"width_icon."IMAGE_EXT,_("Width Tool"));
+       INIT_STOCK_ICON(scale,"scale_icon."IMAGE_EXT,"Scale Tool");
+       INIT_STOCK_ICON(zoom,"zoom_icon."IMAGE_EXT,_("Zoom Tool"));
+       INIT_STOCK_ICON(info,"info_icon."IMAGE_EXT,_("Info Tool"));
+       INIT_STOCK_ICON(mirror,"mirror_icon."IMAGE_EXT,_("Mirror Tool"));
+       INIT_STOCK_ICON(text,"text_icon."IMAGE_EXT,"Text Tool");
+       INIT_STOCK_ICON(gradient,"gradient_icon."IMAGE_EXT,_("Gradient Tool"));
+       INIT_STOCK_ICON(star,"star_icon."IMAGE_EXT,_("Star Tool"));
+
+#undef INIT_STOCK_ICON
+#undef INIT_STOCK_ICON
+
+       icon_factory->add_default();
+
+       Gtk::IconSize::register_new("synfig-small_icon",12,12);
+       Gtk::IconSize::register_new("synfig-small_icon_16x16",16,16);
+
+       for(int i(0);i<(int)ValueBase::TYPE_END;i++)
+               _tree_pixbuf_table_value_type[i]=Gtk::Button().render_icon(value_icon(ValueBase::Type(i)),Gtk::ICON_SIZE_SMALL_TOOLBAR);
+
+}
+
+IconController::~IconController()
+{
+       for(int i(0);i<(int)ValueBase::TYPE_END;i++)
+               _tree_pixbuf_table_value_type[i]=Glib::RefPtr<Gdk::Pixbuf>();
+
+       icon_factory->remove_default();
+}
+
+Gdk::Cursor
+IconController::get_normal_cursor()
+{
+       return Gdk::Cursor(Gdk::TOP_LEFT_ARROW);
+}
+
+Gdk::Cursor
+IconController::get_tool_cursor(const Glib::ustring& name,const Glib::RefPtr<Gdk::Window>& window)
+{
+       //this function is never called
+       //it is commented out in WorkArea::refresh_cursor()
+       assert(0);
+       // \todo Do we still need it?
+
+       Glib::RefPtr<Gdk::Pixmap> pixmap;
+       pixmap=Gdk::Pixmap::create(window, 64, 64, 8);
+       pixmap->set_colormap(window->get_colormap());
+       //pixmap->set_colormap(Gdk::Colormap::create(pixmap->get_visual(),false));
+       Glib::RefPtr<Gdk::Pixbuf> pixbuf;
+       pixbuf=Gtk::Button().render_icon(Gtk::StockID("synfig-"+name),Gtk::ICON_SIZE_SMALL_TOOLBAR);
+
+       pixbuf->render_to_drawable_alpha(
+               pixmap,
+               0,0,    // SOURCE X,Y
+               0,0,    // DEST X Y
+               -1,-1,  // WIDTH HEIGHT
+               Gdk::PIXBUF_ALPHA_FULL, // (ignored)
+               64,             //int alpha_threshold,
+               Gdk::RGB_DITHER_MAX,            //RgbDither dither,
+               2,2     //int x_dither, int y_dither
+       );
+/*
+       pixmap->draw_pixbuf(
+               Glib::RefPtr<const Gdk::GC>(0), // GC
+               pixbuf,
+               0, 0, // Source X,Y
+               0, 0, // Dest X,Y
+               -1, -1, // Width, Height
+               Gdk::RGB_DITHER_MAX, // Dither
+               0,0 // Dither X,Y
+       );
+*/
+
+       Gdk::Color FG("#000000");
+       Gdk::Color BG("#FF00FF");
+
+       return Gdk::Cursor(pixmap, pixmap, FG, BG, 0, 0);
+}
+
+Gtk::StockID
+studio::value_icon(synfig::ValueBase::Type type)
+{
+               switch(type)
+               {
+               case ValueBase::TYPE_BOOL:
+                       return Gtk::StockID("synfig-bool");
+                       break;
+               case ValueBase::TYPE_INTEGER:
+                       return Gtk::StockID("synfig-integer");
+                       break;
+               case ValueBase::TYPE_ANGLE:
+                       return Gtk::StockID("synfig-angle");
+                       break;
+               case ValueBase::TYPE_TIME:
+                       return Gtk::StockID("synfig-time");
+                       break;
+               case ValueBase::TYPE_REAL:
+                       return Gtk::StockID("synfig-real");
+                       break;
+               case ValueBase::TYPE_VECTOR:
+                       return Gtk::StockID("synfig-vector");
+                       break;
+               case ValueBase::TYPE_COLOR:
+                       return Gtk::StockID("synfig-color");
+                       break;
+               case ValueBase::TYPE_SEGMENT:
+                       return Gtk::StockID("synfig-segment");
+                       break;
+               case ValueBase::TYPE_BLINEPOINT:
+                       return Gtk::StockID("synfig-blinepoint");
+                       break;
+               case ValueBase::TYPE_LIST:
+                       return Gtk::StockID("synfig-list");
+                       break;
+               case ValueBase::TYPE_CANVAS:
+                       return Gtk::StockID("synfig-canvas_pointer");
+                       break;
+               case ValueBase::TYPE_STRING:
+                       return Gtk::StockID("synfig-string");
+                       break;
+               case ValueBase::TYPE_GRADIENT:
+                       return Gtk::StockID("synfig-gradient");
+                       break;
+               case ValueBase::TYPE_NIL:
+               default:
+                       return Gtk::StockID("synfig-unknown");
+                       break;
+               }
+}
+
+Gtk::StockID
+studio::valuenode_icon(etl::handle<synfig::ValueNode> value_node)
+{
+       if(handle<ValueNode_Const>::cast_dynamic(value_node))
+       {
+               return value_icon(value_node->get_type());
+       }
+       else
+       {
+               return Gtk::StockID("synfig-value_node");
+       }
+}
+
+Glib::RefPtr<Gdk::Pixbuf>
+studio::get_tree_pixbuf(synfig::ValueBase::Type type)
+{
+       //return Gtk::Button().render_icon(value_icon(type),Gtk::ICON_SIZE_SMALL_TOOLBAR);
+       return _tree_pixbuf_table_value_type[int(type)];
+}
+
+#ifdef WIN32
+#define TEMPORARY_DELETE_MACRO DELETE
+#undef DELETE
+#endif
+
+Gtk::StockID
+studio::get_action_stock_id(const synfigapp::Action::BookEntry& action)
+{
+       Gtk::StockID stock_id;
+       if(action.task=="add")                          stock_id=Gtk::Stock::ADD;
+       else if(action.task=="connect")         stock_id=Gtk::Stock::CONNECT;
+       else if(action.task=="disconnect")      stock_id=Gtk::Stock::DISCONNECT;
+       else if(action.task=="insert")          stock_id=Gtk::Stock::ADD;
+       else if(action.task=="lower")           stock_id=Gtk::Stock::GO_DOWN;
+       else if(action.task=="move_bottom")     stock_id=Gtk::Stock::GOTO_BOTTOM;
+       else if(action.task=="move_top")        stock_id=Gtk::Stock::GOTO_TOP;
+       else if(action.task=="raise")           stock_id=Gtk::Stock::GO_UP;
+       else if(action.task=="remove")          stock_id=Gtk::Stock::DELETE;
+       else if(action.task=="set_off")         stock_id=Gtk::Stock::NO;
+       else if(action.task=="set_on")          stock_id=Gtk::Stock::YES;
+       else                                                            stock_id=Gtk::StockID("synfig-"+
+                                                                                                                         action.task);
+       return stock_id;
+}
+
+#ifdef WIN32
+#define DELETE TEMPORARY_DELETE_MACRO
+#undef TEMPORARY_DELETE_MACRO
+#endif
+
+Gtk::StockID
+studio::layer_icon(const synfig::String &layer)
+{
+       if(layer=="PasteCanvas" || layer=="pastecanvas" || layer=="paste_canvas")
+               return Gtk::StockID("synfig-layer_pastecanvas");
+       else if(layer=="rotate")
+               return Gtk::StockID("synfig-rotate");
+       else if(layer=="zoom")
+               return Gtk::StockID("synfig-zoom");
+       else if(layer=="region")
+               return Gtk::StockID("synfig-bline");
+       else if(layer=="polygon")
+               return Gtk::StockID("synfig-polygon");
+       else if(layer=="outline")
+               return Gtk::StockID("synfig-width");
+       else if(layer=="circle")
+               return Gtk::StockID("synfig-circle");
+       else if(layer=="rectangle")
+               return Gtk::StockID("synfig-rectangle");
+       else if(layer=="star")
+               return Gtk::StockID("synfig-star");
+       else if(layer=="plant")
+               return Gtk::StockID("synfig-plant");
+       else if(layer=="text")
+               return Gtk::StockID("synfig-text");
+       else if(layer.find("gradient")!=String::npos)
+               return Gtk::StockID("synfig-gradient");
+       else
+               return Gtk::StockID("synfig-layer");
+}
+
+Glib::RefPtr<Gdk::Pixbuf>
+studio::get_tree_pixbuf_layer(const synfig::String &layer)
+{
+       return Gtk::Button().render_icon(layer_icon(layer),Gtk::ICON_SIZE_SMALL_TOOLBAR);
+}
diff --git a/synfig-studio/src/gui/iconcontroller.h b/synfig-studio/src/gui/iconcontroller.h
new file mode 100644 (file)
index 0000000..fa48cf1
--- /dev/null
@@ -0,0 +1,73 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file iconcontroller.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_ICONCONTROLLER_H
+#define __SYNFIG_STUDIO_ICONCONTROLLER_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/stock.h>
+#include <gtkmm/iconfactory.h>
+#include <gtkmm/iconset.h>
+#include <gdkmm/cursor.h>
+
+#include <synfig/value.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 synfig { class ValueNode; class Layer; }
+
+namespace synfigapp { namespace Action { class BookEntry; };};
+
+namespace studio {
+
+
+class IconController
+{
+       Glib::RefPtr<Gtk::IconFactory> icon_factory;
+public:
+       IconController(const synfig::String& basepath);
+       ~IconController();
+
+       static Gdk::Cursor get_normal_cursor();
+       static Gdk::Cursor get_tool_cursor(const Glib::ustring& name,const Glib::RefPtr<Gdk::Window>& window);
+};
+
+Gtk::StockID layer_icon(const synfig::String &layer);
+Glib::RefPtr<Gdk::Pixbuf> get_tree_pixbuf_layer(const synfig::String &layer);
+
+Gtk::StockID value_icon(synfig::ValueBase::Type type);
+Gtk::StockID valuenode_icon(etl::handle<synfig::ValueNode> value_node);
+Glib::RefPtr<Gdk::Pixbuf> get_tree_pixbuf(synfig::ValueBase::Type type);
+Gtk::StockID get_action_stock_id(const synfigapp::Action::BookEntry& action);
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/instance.cpp b/synfig-studio/src/gui/instance.cpp
new file mode 100644 (file)
index 0000000..62d63a0
--- /dev/null
@@ -0,0 +1,1150 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file gtkmm/instance.cpp
+**     \brief writeme
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 2008 Chris Moore
+**     Copyright (c) 2008 Carlos López
+**     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 <config.h>
+#endif
+
+#include "instance.h"
+#include <cassert>
+#include <gtkmm/stock.h>
+#include <gtkmm/image.h>
+#include <iostream>
+#include <gtkmm/button.h>
+#include "canvasview.h"
+#include "app.h"
+#include <sigc++/signal.h>
+#include <sigc++/adaptors/hide.h>
+#include "toolbox.h"
+#include "onemoment.h"
+#include <synfig/savecanvas.h>
+
+#include "autorecover.h"
+#include <sigc++/retype_return.h>
+#include <sigc++/retype.h>
+//#include <sigc++/hide.h>
+#include <synfig/valuenode_composite.h>
+#include <synfig/valuenode_duplicate.h>
+#include "widget_waypointmodel.h"
+#include <gtkmm/actiongroup.h>
+#include "iconcontroller.h"
+#include "workarea.h"
+#include <sys/stat.h>
+#include <errno.h>
+#include <ETL/stringf>
+
+#include "general.h"
+
+#endif
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+using namespace studio;
+using namespace sigc;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+
+int studio::Instance::instance_count_=0;
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Instance::Instance(synfig::Canvas::Handle canvas):
+       synfigapp::Instance             (canvas),
+       canvas_tree_store_              (Gtk::TreeStore::create(canvas_tree_model)),
+       history_tree_store_             (HistoryTreeStore::create(this)),
+       undo_status_(false),
+       redo_status_(false)
+{
+       id_=instance_count_++;
+
+       // Connect up all the signals
+       signal_filename_changed().connect(sigc::mem_fun(*this,&studio::Instance::update_all_titles));
+       signal_unsaved_status_changed().connect(sigc::hide(sigc::mem_fun(*this,&studio::Instance::update_all_titles)));
+       signal_undo_status().connect(sigc::mem_fun(*this,&studio::Instance::set_undo_status));
+       signal_redo_status().connect(sigc::mem_fun(*this,&studio::Instance::set_redo_status));
+
+       signal_saved().connect(
+               sigc::hide_return(
+                       sigc::ptr_fun(
+                               studio::AutoRecover::auto_backup
+                       )
+               )
+       );
+
+       refresh_canvas_tree();
+}
+
+Instance::~Instance()
+{
+}
+
+int
+Instance::get_visible_canvases()const
+{
+       int count(0);
+       CanvasViewList::const_iterator iter;
+       for(iter=canvas_view_list_.begin();iter!=canvas_view_list_.end();++iter)
+               if((*iter)->is_visible())
+                       count++;
+       return count;
+}
+
+handle<Instance>
+Instance::create(synfig::Canvas::Handle canvas)
+{
+       // Construct a new instance
+       handle<Instance> instance(new Instance(canvas));
+
+       // Add the new instance to the application's instance list
+       App::instance_list.push_back(instance);
+
+       // Set up the instance with the default UI manager
+       instance->synfigapp::Instance::set_ui_interface(App::get_ui_interface());
+
+       // Signal the new instance
+       App::signal_instance_created()(instance);
+
+       // And then make sure that is has been selected
+       App::set_selected_instance(instance);
+
+       // Create the initial window for the root canvas
+       instance->focus(canvas);
+
+       return instance;
+}
+
+handle<CanvasView>
+Instance::find_canvas_view(etl::handle<synfig::Canvas> canvas)
+{
+       if(!canvas)
+               return 0;
+
+       while(canvas->is_inline())
+               canvas=canvas->parent();
+
+       CanvasViewList::iterator iter;
+
+       for(iter=canvas_view_list().begin();iter!=canvas_view_list().end();iter++)
+               if((*iter)->get_canvas()==canvas)
+                       return *iter;
+
+       return CanvasView::create(this,canvas);
+}
+
+void
+Instance::focus(etl::handle<synfig::Canvas> canvas)
+{
+       handle<CanvasView> canvas_view=find_canvas_view(canvas);
+       assert(canvas_view);
+       canvas_view->present();
+}
+
+void
+Instance::set_undo_status(bool x)
+{
+       undo_status_=x;
+       App::toolbox->update_undo_redo();
+       signal_undo_redo_status_changed()();
+}
+
+void
+Instance::set_redo_status(bool x)
+{
+       redo_status_=x;
+       App::toolbox->update_undo_redo();
+       signal_undo_redo_status_changed()();
+}
+
+bool
+studio::Instance::save_as(const synfig::String &file_name)
+{
+       if(synfigapp::Instance::save_as(file_name))
+       {
+               // after changing the filename, update the render settings with the new filename
+               list<handle<CanvasView> >::iterator iter;
+               for(iter=canvas_view_list().begin();iter!=canvas_view_list().end();iter++)
+                       (*iter)->render_settings.set_entry_filename();
+               App::add_recent_file(etl::handle<Instance>(this));
+               return true;
+       }
+       return false;
+}
+
+void
+studio::Instance::open()
+{
+       App::dialog_open(get_file_name());
+}
+
+Instance::Status
+studio::Instance::save()
+{
+       // if we don't have a real filename yet then we need to ask where to save it
+       if (!has_real_filename())
+       {
+               if (dialog_save_as())
+                       return STATUS_OK;
+               else
+                       return STATUS_CANCEL;
+       }
+
+       if (synfigapp::Instance::save())
+       {
+               App::add_recent_file(etl::handle<Instance>(this));
+               return STATUS_OK;
+       }
+       string msg(strprintf(_("Unable to save to '%s'"), get_file_name().c_str()));
+       App::dialog_error_blocking(_("Save - Error"), msg.c_str());
+       return STATUS_ERROR;
+}
+
+// the filename will be set to "Synfig Animation 1" or some such when first created
+// and will be changed to an absolute path once it has been saved
+// so if it still begins with "Synfig Animation " then we don't have a real filename yet
+bool
+studio::Instance::has_real_filename()
+{
+       return get_file_name().find(App::custom_filename_prefix.c_str()) != 0;
+}
+
+bool
+studio::Instance::dialog_save_as()
+{
+       string filename = get_file_name();
+       Canvas::Handle canvas(get_canvas());
+
+       {
+               OneMoment one_moment;
+               std::set<Node*>::iterator iter;
+               for(iter=canvas->parent_set.begin();iter!=canvas->parent_set.end();++iter)
+               {
+                       synfig::Node* node(*iter);
+                       for(;!node->parent_set.empty();node=*node->parent_set.begin())
+                       {
+                               Layer::Handle parent_layer(dynamic_cast<Layer*>(node));
+                               if(parent_layer && parent_layer->get_canvas()->get_root()!=get_canvas())
+                               {
+                                       //! \todo Fix big involving "Save As" with referenced compositions
+                                       string msg(strprintf(_("There is currently a bug when using \"SaveAs\"\n"
+                                               "on a composition that is being referenced by other\n"
+                                               "files that are currently open. Close these\n"
+                                               "other files first before trying to use \"SaveAs\".")));
+                                       App::dialog_error_blocking(_("SaveAs - Error"), msg.c_str());
+
+                                       return false;
+                               }
+                               if(parent_layer)
+                                       break;
+                       }
+               }
+       }
+
+       if (has_real_filename())
+               filename = absolute_path(filename);
+
+       // show the canvas' name if it has one, else its ID
+       while (App::dialog_save_file((_("Choose a Filename to Save As") +
+                                                                 String(" (") +
+                                                                 (canvas->get_name().empty() ? canvas->get_id() : canvas->get_name()) +
+                                                                 ") ..."),
+                                                                filename, ANIMATION_DIR_PREFERENCE))
+       {
+               // If the filename still has wildcards, then we should
+               // continue looking for the file we want
+               string base_filename = basename(filename);
+               if (find(base_filename.begin(),base_filename.end(),'*')!=base_filename.end())
+                       continue;
+
+               if (filename_extension(filename) == "")
+                       filename+=".sifz";
+
+               try
+               {
+                       String ext(filename_extension(filename));
+                       if(ext!=".sif" && ext!=".sifz" && !App::dialog_yes_no(_("Unknown extension"),
+                               _("You have given the file name an extension\nwhich I do not recognize. Are you sure this is what you want?")))
+                               continue;
+               }
+               catch(...)
+               {
+                       continue;
+               }
+
+               {
+                       struct stat     s;
+                       int stat_return = stat(filename.c_str(), &s);
+
+                       // if stat() fails with something other than 'file doesn't exist', there's been a real
+                       // error of some kind.  let's give up now and ask for a new path.
+                       if (stat_return == -1 && errno != ENOENT)
+                       {
+                               perror(filename.c_str());
+                               string msg(strprintf(_("Unable to check whether '%s' exists."), filename.c_str()));
+                               App::dialog_error_blocking(_("SaveAs - Error"),msg.c_str());
+                               continue;
+                       }
+
+                       // if the file exists and the user doesn't want to overwrite it, keep prompting for a filename
+                       string msg(strprintf(_("A file named '%s' already exists.\n\n"
+                                                                       "Do you want to replace it with the file you are saving?"), filename.c_str()));
+                       if ((stat_return == 0) &&
+                               !App::dialog_yes_no(_("File exists"),msg.c_str()))
+                               continue;
+               }
+
+               if(save_as(filename))
+               {
+                       synfig::set_file_version(ReleaseVersion(RELEASE_VERSION_END-1));
+                       return true;
+               }
+               string msg(strprintf(_("Unable to save to '%s'"), filename.c_str()));
+               App::dialog_error_blocking(_("SaveAs - Error"),msg.c_str());
+       }
+
+       return false;
+}
+
+void
+Instance::update_all_titles()
+{
+       list<handle<CanvasView> >::iterator iter;
+       for(iter=canvas_view_list().begin();iter!=canvas_view_list().end();iter++)
+               (*iter)->update_title();
+}
+
+void
+Instance::close()
+{
+       // This will increase the reference count so we don't get DELETED
+       // until we are ready
+       handle<Instance> me(this);
+
+       // Make sure we aren't selected as the current instance
+       if(studio::App::get_selected_instance()==this)
+               studio::App::set_selected_instance(0);
+
+       // Turn-off/clean-up auto recovery
+       studio::App::auto_recover->clear_backup(get_canvas());
+
+       // Remove us from the active instance list
+       std::list<etl::handle<studio::Instance> >::iterator iter;
+       for(iter=studio::App::instance_list.begin();iter!=studio::App::instance_list.end();iter++)
+               if(*iter==this)
+                       break;
+       assert(iter!=studio::App::instance_list.end());
+       if(iter!=studio::App::instance_list.end())
+               studio::App::instance_list.erase(iter);
+
+       // Send out a signal that we are being deleted
+       studio::App::signal_instance_deleted()(this);
+
+       // Hide all of the canvas views
+       for(std::list<etl::handle<CanvasView> >::iterator iter=canvas_view_list().begin();iter!=canvas_view_list().end();iter++)
+               (*iter)->hide();
+
+       // Consume pending events before deleting the canvas views
+       while(studio::App::events_pending())studio::App::iteration(false);
+
+       // Delete all of the canvas views
+       canvas_view_list().clear();
+
+       // If there is another open instance to select,
+       // go ahead and do so. If not, never mind.
+       if(studio::App::instance_list.empty())
+       {
+               studio::App::set_selected_canvas_view(0);
+               studio::App::set_selected_instance(0);
+       }
+       else
+               studio::App::instance_list.front()->canvas_view_list().front()->present();
+}
+
+void
+Instance::insert_canvas(Gtk::TreeRow row, synfig::Canvas::Handle canvas)
+{
+       CanvasTreeModel canvas_tree_model;
+       assert(canvas);
+
+       row[canvas_tree_model.icon] = Gtk::Button().render_icon(Gtk::StockID("synfig-canvas"),Gtk::ICON_SIZE_SMALL_TOOLBAR);
+       row[canvas_tree_model.id] = canvas->get_id();
+       row[canvas_tree_model.name] = canvas->get_name();
+       if(canvas->is_root())
+               row[canvas_tree_model.label] = basename(canvas->get_file_name());
+       else
+       if(!canvas->get_id().empty())
+               row[canvas_tree_model.label] = canvas->get_id();
+       else
+       if(!canvas->get_name().empty())
+               row[canvas_tree_model.label] = canvas->get_name();
+       else
+               row[canvas_tree_model.label] = _("[Unnamed]");
+
+       row[canvas_tree_model.canvas] = canvas;
+       row[canvas_tree_model.is_canvas] = true;
+       row[canvas_tree_model.is_value_node] = false;
+
+       {
+               synfig::Canvas::Children::iterator iter;
+               synfig::Canvas::Children &children(canvas->children());
+
+               for(iter=children.begin();iter!=children.end();iter++)
+                       insert_canvas(*(canvas_tree_store()->append(row.children())),*iter);
+       }       
+}
+
+void
+Instance::refresh_canvas_tree()
+{
+       canvas_tree_store()->clear();
+       Gtk::TreeRow row = *(canvas_tree_store()->prepend());
+       insert_canvas(row,get_canvas());
+}
+
+void
+Instance::dialog_cvs_commit()
+{
+       calc_repository_info();
+       if(!in_repository())
+       {
+               App::dialog_error_blocking(_("Error"),_("You must first add this composition to the repository"));
+               return;
+       }
+       try
+       {
+               string message;
+
+               if(synfigapp::Instance::get_action_count())
+               {
+                       if(!App::dialog_yes_no(_("CVS Commit"), _("This will save any changes you have made. Are you sure?")))
+                               return;
+                       save();
+               }
+
+               if(!is_modified())
+               {
+                       App::dialog_error_blocking(_("Error"),_("The local copy of the file hasn't been changed since the last update.\nNothing to commit!"));
+                       return;
+               }
+
+               if(!App::dialog_entry(_("CVS Commit"),_("Enter a log message describing the changes you have made"), message))
+                       return;
+
+               OneMoment one_moment;
+               cvs_commit(message);
+       }
+       catch(...)
+       {
+               App::dialog_error_blocking(_("Error"),_("An error has occurred when trying to COMMIT"));
+       }
+       update_all_titles();
+}
+
+void
+Instance::dialog_cvs_add()
+{
+       calc_repository_info();
+       if(in_repository())
+       {
+               App::dialog_error_blocking(_("Error"),_("This composition has already been added to the repository"));
+               return;
+       }
+       try
+       {
+               string message;
+
+               //if(!App::dialog_entry(_("CVS Add"),_("Enter a log message describing the file"), message))
+               //      return;
+               OneMoment one_moment;
+               cvs_add();
+       }
+       catch(...)
+       {
+               App::dialog_error_blocking(_("Error"),_("An error has occurred when trying to ADD"));
+       }
+       update_all_titles();
+}
+
+void
+Instance::dialog_cvs_update()
+{
+       calc_repository_info();
+       if(!in_repository())
+       {
+               App::dialog_error_blocking(_("Error"),_("This file is not under version control, so there is nothing to update from!"));
+               return;
+       }
+       if(!is_updated())
+       {
+               App::dialog_error_blocking(_("Info"),_("This file is up-to-date"));
+               return;
+       }
+
+       try
+       {
+               String filename(get_file_name());
+               if(synfigapp::Instance::get_action_count())
+               {
+                       if(!App::dialog_yes_no(_("CVS Update"), _("This will save any changes you have made. Are you sure?")))
+                               return;
+                       save();
+               }
+               OneMoment one_moment;
+               time_t oldtime=get_original_timestamp();
+               cvs_update();
+               calc_repository_info();
+               // If something has been updated...
+               if(oldtime!=get_original_timestamp())
+               {
+                       revert();
+               }
+       }
+       catch(...)
+       {
+               App::dialog_error_blocking(_("Error"),_("An error has occurred when trying to UPDATE"));
+       }
+       //update_all_titles();
+}
+
+void
+Instance::dialog_cvs_revert()
+{
+       calc_repository_info();
+       if(!in_repository())
+       {
+               App::dialog_error_blocking(_("Error"),_("This file is not under version control, so there is nothing to revert to!"));
+               return;
+       }
+       try
+       {
+               String filename(get_file_name());
+               if(!App::dialog_yes_no(_("CVS Revert"),
+                       _("This will abandon all changes you have made\nsince the last time you performed a commit\noperation. This cannot be undone! Are you sure\nyou want to do this?")
+               ))
+                       return;
+
+               OneMoment one_moment;
+
+               // Remove the old file
+               if(remove(get_file_name().c_str())!=0)
+               {
+                       App::dialog_error_blocking(_("Error"),_("Unable to remove previous version"));
+                       return;
+               }
+
+               cvs_update();
+               revert();
+       }
+       catch(...)
+       {
+               App::dialog_error_blocking(_("Error"),_("An error has occurred when trying to UPDATE"));
+       }
+       //update_all_titles();
+}
+
+void
+Instance::_revert(Instance *instance)
+{
+       OneMoment one_moment;
+
+       String filename(instance->get_file_name());
+
+       Canvas::Handle canvas(instance->get_canvas());
+
+       instance->close();
+
+       if(canvas->count()!=1)
+       {
+               one_moment.hide();
+               App::dialog_error_blocking(_("Error: Revert Failed"),_("The revert operation has failed. This can be due to it being\nreferenced by another composition that is already open, or\nbecause of an internal error in Synfig Studio. Try closing any\ncompositions that might reference this composition and try\nagain, or restart Synfig Studio."));
+               one_moment.show();
+       }
+       canvas=0;
+
+       App::open(filename);
+}
+
+void
+Instance::revert()
+{
+       // Schedule a revert to occur in a few moments
+       Glib::signal_timeout().connect(
+               sigc::bind_return(
+                       sigc::bind(
+                               sigc::ptr_fun(&Instance::_revert),
+                               this
+                       ),
+                       false
+               )
+               ,500
+       );
+}
+
+bool
+Instance::safe_revert()
+{
+       if(synfigapp::Instance::get_action_count())
+               if(!App::dialog_yes_no(_("Revert to saved"), _("You will lose any changes you have made since your last save.\nAre you sure?")))
+                       return false;
+       revert();
+       return true;
+}
+
+bool
+Instance::safe_close()
+{
+       handle<CanvasView> canvas_view = find_canvas_view(get_canvas());
+       handle<synfigapp::UIInterface> uim=canvas_view->get_ui_interface();
+
+       // if the animation is currently playing, closing the window will cause a crash,
+       // so don't allow it
+       if (canvas_view->is_playing())
+       {
+               canvas_view->present();
+               App::dialog_error_blocking("Close Error", "The animation is currently playing so the window cannot be closed.");
+               return false;
+       }
+       if(get_action_count())
+               do
+               {
+                       string str=strprintf(_("Would you like to save your changes to %s?"),basename(get_file_name()).c_str() );
+                       int answer=uim->yes_no_cancel(get_canvas()->get_name(),str,synfigapp::UIInterface::RESPONSE_YES);
+                       if(answer==synfigapp::UIInterface::RESPONSE_YES)
+                       {
+                               enum Status status = save();
+                               if (status == STATUS_OK) break;
+                               else if (status == STATUS_CANCEL) return false;
+                       }
+                       if(answer==synfigapp::UIInterface::RESPONSE_NO)
+                               break;
+                       if(answer==synfigapp::UIInterface::RESPONSE_CANCEL)
+                               return false;
+               } while (true);
+
+       if(is_modified())
+       {
+               string str=strprintf(_("%s has changes not yet on the CVS repository.\nWould you like to commit these changes?"),basename(get_file_name()).c_str());
+               int answer=uim->yes_no_cancel(get_canvas()->get_name(),str,synfigapp::UIInterface::RESPONSE_YES);
+
+               if(answer==synfigapp::UIInterface::RESPONSE_YES)
+                       dialog_cvs_commit();
+               if(answer==synfigapp::UIInterface::RESPONSE_CANCEL)
+                       return false;
+       }
+
+       close();
+
+       return true;
+}
+
+void
+Instance::add_actions_to_group(const Glib::RefPtr<Gtk::ActionGroup>& action_group, synfig::String& ui_info,   const synfigapp::Action::ParamList &param_list, synfigapp::Action::Category category)const
+{
+       synfigapp::Action::CandidateList candidate_list;
+       synfigapp::Action::CandidateList::iterator iter;
+
+       candidate_list=compile_candidate_list(param_list,category);
+
+       candidate_list.sort();
+
+       // if(candidate_list.empty())
+       //      synfig::warning("%s:%d Action CandidateList is empty!", __FILE__, __LINE__);
+
+       for(iter=candidate_list.begin();iter!=candidate_list.end();++iter)
+       {
+               Gtk::StockID stock_id(get_action_stock_id(*iter));
+
+               if(!(iter->category&synfigapp::Action::CATEGORY_HIDDEN))
+               {
+                       action_group->add(Gtk::Action::create(
+                               "action-"+iter->name,
+                               stock_id,
+                               iter->local_name,iter->local_name
+                       ),
+                               sigc::bind(
+                                       sigc::bind(
+                                               sigc::mem_fun(
+                                                       *const_cast<studio::Instance*>(this),
+                                                       &studio::Instance::process_action
+                                               ),
+                                               param_list
+                                       ),
+                                       iter->name
+                               )
+                       );
+                       ui_info+=strprintf("<menuitem action='action-%s' />",iter->name.c_str());
+               }
+       }
+}
+
+void
+Instance::add_actions_to_menu(Gtk::Menu *menu, const synfigapp::Action::ParamList &param_list,synfigapp::Action::Category category)const
+{
+       synfigapp::Action::CandidateList candidate_list;
+       synfigapp::Action::CandidateList::iterator iter;
+
+       candidate_list=compile_candidate_list(param_list,category);
+
+       candidate_list.sort();
+
+       if(candidate_list.empty())
+               synfig::warning("%s:%d Action CandidateList is empty!", __FILE__, __LINE__);
+
+       for(iter=candidate_list.begin();iter!=candidate_list.end();++iter)
+       {
+               if(!(iter->category&synfigapp::Action::CATEGORY_HIDDEN))
+               {
+                       Gtk::Image* image(manage(new Gtk::Image()));
+                       Gtk::Stock::lookup(get_action_stock_id(*iter),Gtk::ICON_SIZE_MENU,*image);
+
+                       menu->items().push_back(
+                               Gtk::Menu_Helpers::ImageMenuElem(
+                                       iter->local_name,
+                                       *image,
+                                       sigc::bind(
+                                               sigc::bind(
+                                                       sigc::mem_fun(
+                                                               *const_cast<studio::Instance*>(this),
+                                                               &studio::Instance::process_action
+                                                       ),
+                                                       param_list
+                                               ),
+                                               iter->name
+                                       )
+                               )
+                       );
+               }
+       }
+}
+
+void
+Instance::add_actions_to_menu(Gtk::Menu *menu, const synfigapp::Action::ParamList &param_list,const synfigapp::Action::ParamList &param_list2,synfigapp::Action::Category category)const
+{
+       synfigapp::Action::CandidateList candidate_list;
+       synfigapp::Action::CandidateList candidate_list2;
+
+       synfigapp::Action::CandidateList::iterator iter;
+
+       candidate_list=compile_candidate_list(param_list,category);
+       candidate_list2=compile_candidate_list(param_list2,category);
+
+       candidate_list.sort();
+
+       if(candidate_list.empty())
+               synfig::warning("%s:%d Action CandidateList is empty!", __FILE__, __LINE__);
+       if(candidate_list2.empty())
+               synfig::warning("%s:%d Action CandidateList2 is empty!", __FILE__, __LINE__);
+
+       // Separate out the candidate lists so that there are no conflicts
+       for(iter=candidate_list.begin();iter!=candidate_list.end();++iter)
+       {
+               synfigapp::Action::CandidateList::iterator iter2(candidate_list2.find(iter->name));
+               if(iter2!=candidate_list2.end())
+                       candidate_list2.erase(iter2);
+       }
+
+       for(iter=candidate_list2.begin();iter!=candidate_list2.end();++iter)
+       {
+               if(!(iter->category&synfigapp::Action::CATEGORY_HIDDEN))
+               {
+                       Gtk::Image* image(manage(new Gtk::Image()));
+                       Gtk::Stock::lookup(get_action_stock_id(*iter),Gtk::ICON_SIZE_MENU,*image);
+
+                       menu->items().push_back(
+                               Gtk::Menu_Helpers::ImageMenuElem(
+                                       iter->local_name,
+                                       *image,
+                                       sigc::bind(
+                                               sigc::bind(
+                                                       sigc::mem_fun(
+                                                               *const_cast<studio::Instance*>(this),
+                                                               &studio::Instance::process_action
+                                                       ),
+                                                       param_list2
+                                               ),
+                                               iter->name
+                                       )
+                               )
+                       );
+               }
+       }
+
+       for(iter=candidate_list.begin();iter!=candidate_list.end();++iter)
+       {
+               if(!(iter->category&synfigapp::Action::CATEGORY_HIDDEN))
+               {
+                       Gtk::Image* image(manage(new Gtk::Image()));
+                       Gtk::Stock::lookup(get_action_stock_id(*iter),Gtk::ICON_SIZE_MENU,*image);
+
+                       menu->items().push_back(
+                               Gtk::Menu_Helpers::ImageMenuElem(
+                                       iter->local_name,
+                                       *image,
+                                       sigc::bind(
+                                               sigc::bind(
+                                                       sigc::mem_fun(
+                                                               *const_cast<studio::Instance*>(this),
+                                                               &studio::Instance::process_action
+                                                       ),
+                                                       param_list
+                                               ),
+                                               iter->name
+                                       )
+                               )
+                       );
+               }
+       }
+}
+
+void
+Instance::process_action(synfig::String name, synfigapp::Action::ParamList param_list)
+{
+       //// debug actions
+       // synfig::info("%s:%d process_action: '%s'", __FILE__, __LINE__, name.c_str());
+
+       assert(synfigapp::Action::book().count(name));
+
+       synfigapp::Action::BookEntry entry(synfigapp::Action::book().find(name)->second);
+
+       synfigapp::Action::Handle action(entry.factory());
+
+       if(!action)
+       {
+               synfig::error("Bad Action");
+               return;
+       }
+
+       action->set_param_list(param_list);
+
+       synfigapp::Action::ParamVocab param_vocab(entry.get_param_vocab());
+       synfigapp::Action::ParamVocab::const_iterator iter;
+
+       for(iter=param_vocab.begin();iter!=param_vocab.end();++iter)
+       {
+               if(!iter->get_mutual_exclusion().empty() && param_list.count(iter->get_mutual_exclusion()))
+                       continue;
+
+               // If the parameter is optionally user-supplied,
+               // and has not been already provided in the param_list,
+               // then we should go ahead and see if we can
+               // provide that data.
+               if(iter->get_user_supplied() && param_list.count(iter->get_name())==0)
+               {
+                       switch(iter->get_type())
+                       {
+                       case synfigapp::Action::Param::TYPE_STRING:
+                       {
+                               String str;
+                               if(!studio::App::dialog_entry(entry.local_name, iter->get_local_name()+": "+iter->get_desc(),str))
+                                       return;
+                               action->set_param(iter->get_name(),str);
+                               break;
+                       }
+                       default:
+                               synfig::error("Unsupported user-supplied action parameter");
+                               return;
+                               break;
+                       }
+               }
+       }
+
+       if(!action->is_ready())
+       {
+               synfig::error("Action not ready");
+               return;
+       }
+
+       perform_action(action);
+}
+
+void
+Instance::make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas, synfigapp::ValueDesc value_desc, float location, bool bezier)
+{
+       Gtk::Menu& parammenu(*menu);
+
+       etl::handle<synfigapp::CanvasInterface> canvas_interface(find_canvas_interface(canvas));
+
+       if(!canvas_interface)
+               return;
+
+       synfigapp::Action::ParamList param_list,param_list2;
+       param_list=canvas_interface->generate_param_list(value_desc);
+       param_list.add("origin",location);
+
+#ifdef BLINEPOINT_MENU_IS_VERTEX_MENU
+       if(value_desc.get_value_type()==ValueBase::TYPE_BLINEPOINT && value_desc.is_value_node() && ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node()))
+       {
+               param_list2=canvas_interface->generate_param_list(
+                       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")
+                       )
+               );
+               param_list2.add("origin",location);
+       }
+#endif // BLINEPOINT_MENU_IS_VERTEX_MENU
+
+       // Populate the convert menu by looping through
+       // the ValueNode book and find the ones that are
+       // relevant.
+
+       // show the 'Convert' sub-menu if this valuedesc is anything other than either:
+       //   the 'Index' parameter of a Duplicate layer
+       // or
+       //   a Duplicate ValueNode whose parent is not a (layer or ValueNode)
+       if (!((value_desc.parent_is_layer_param() &&
+                  value_desc.get_layer()->get_name() == "duplicate" &&
+                  value_desc.get_param_name() == "index") ||
+                 (value_desc.is_value_node() &&
+                  ValueNode_Duplicate::Handle::cast_dynamic(value_desc.get_value_node()) &&
+                  !(value_desc.parent_is_layer_param() ||
+                        value_desc.parent_is_value_node()))))
+       {
+               Gtk::Menu *convert_menu=manage(new Gtk::Menu());
+               LinkableValueNode::Book::const_iterator iter;
+               for(iter=LinkableValueNode::book().begin();iter!=LinkableValueNode::book().end();++iter)
+               {
+                       if(iter->second.check_type(value_desc.get_value_type()))
+                       {
+                               convert_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(iter->second.local_name,
+                                       sigc::hide_return(
+                                               sigc::bind(
+                                                       sigc::bind(
+                                                               sigc::mem_fun(*canvas_interface.get(),&synfigapp::CanvasInterface::convert),
+                                                               iter->first
+                                                       ),
+                                                       value_desc
+                                               )
+                                       )
+                               ));
+                       }
+               }
+
+               parammenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::CONVERT,*convert_menu));
+       }
+
+       synfigapp::Action::Category categories = synfigapp::Action::CATEGORY_VALUEDESC|synfigapp::Action::CATEGORY_VALUENODE;
+       if (bezier)
+       {
+               categories = categories|synfigapp::Action::CATEGORY_BEZIER;
+
+               const DuckList selected_ducks(find_canvas_view(canvas)->get_work_area()->get_selected_ducks());
+               for(DuckList::const_iterator iter=selected_ducks.begin();iter!=selected_ducks.end();++iter)
+               {
+                       synfigapp::ValueDesc value_desc((*iter)->get_value_desc());
+                       if(value_desc.is_valid())
+                               param_list.add("selected_value_desc",value_desc);
+               }
+       }
+
+       if(param_list2.empty())
+               add_actions_to_menu(&parammenu, param_list,categories);
+       else
+               add_actions_to_menu(&parammenu, param_list2,param_list,categories);
+
+       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=synfigapp::ValueDesc(ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node()),0);
+       }
+
+       if(value_desc.is_value_node() && ValueNode_Animated::Handle::cast_dynamic(value_desc.get_value_node()))
+       {
+               ValueNode_Animated::Handle value_node(ValueNode_Animated::Handle::cast_dynamic(value_desc.get_value_node()));
+
+               try
+               {
+                       // try to find a waypoint at the current time - if we
+                       // can't, we don't want the menu entry - an exception is thrown
+                       WaypointList::iterator iter(value_node->find(canvas->get_time()));
+                       std::set<synfig::Waypoint, std::less<UniqueID> > waypoint_set;
+                       waypoint_set.insert(*iter);
+
+                       parammenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Edit Waypoint"),
+                               sigc::bind(
+                                       sigc::bind(
+                                               sigc::bind(
+                                                       sigc::mem_fun(*find_canvas_view(canvas),&studio::CanvasView::on_waypoint_clicked_canvasview),
+                                                       -1
+                                               ),
+                                               waypoint_set
+                                       ),
+                                       value_desc
+                               )
+                       ));
+               }
+               catch(...)
+               {
+               }
+       }
+}
+
+void
+edit_several_waypoints(etl::handle<CanvasView> canvas_view, std::list<synfigapp::ValueDesc> value_desc_list)
+{
+       etl::handle<synfigapp::CanvasInterface> canvas_interface(canvas_view->canvas_interface());
+
+       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 || widget_waypoint_model.get_waypoint_model().is_trivial())
+               return;
+       synfigapp::Action::PassiveGrouper group(canvas_interface->get_instance().get(),_("Set Waypoints"));
+
+       std::list<synfigapp::ValueDesc>::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,canvas_interface->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",canvas_view->get_canvas());
+                       action->set_param("canvas_interface",canvas_interface);
+
+                       if(!canvas_interface->get_instance()->perform_action(action))
+                       {
+                               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)
+                       {
+                               canvas_view->get_ui_interface()->error(_("Unable to find WaypointSetSmart action"));
+                               group.cancel();
+                               return;
+                       }
+
+                       action->set_param("canvas",canvas_view->get_canvas());
+                       action->set_param("canvas_interface",canvas_interface);
+                       action->set_param("value_node",ValueNode::Handle(value_node));
+                       action->set_param("time",canvas_interface->get_time());
+                       action->set_param("model",widget_waypoint_model.get_waypoint_model());
+
+                       if(!canvas_interface->get_instance()->perform_action(action))
+                       {
+                               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;
+               }
+
+       }
+}
+
+void
+Instance::make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas,const std::list<synfigapp::ValueDesc>& value_desc_list)
+{
+       etl::handle<synfigapp::CanvasInterface> canvas_interface(find_canvas_interface(canvas));
+
+       synfigapp::Action::ParamList param_list;
+       param_list=canvas_interface->generate_param_list(value_desc_list);
+
+       add_actions_to_menu(menu, param_list,synfigapp::Action::CATEGORY_VALUEDESC|synfigapp::Action::CATEGORY_VALUENODE);
+
+       // Add the edit waypoints option if that might be useful
+       if(canvas->rend_desc().get_time_end()-Time::epsilon()>canvas->rend_desc().get_time_start())
+       {
+               menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Edit Waypoints"),
+                       sigc::bind(
+                               sigc::bind(
+                                       sigc::ptr_fun(
+                                               &edit_several_waypoints
+                                       ),
+                                       value_desc_list
+                               ),
+                               find_canvas_view(canvas)
+                       )
+               ));
+       }
+}
diff --git a/synfig-studio/src/gui/instance.h b/synfig-studio/src/gui/instance.h
new file mode 100644 (file)
index 0000000..16842c1
--- /dev/null
@@ -0,0 +1,237 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file gtkmm/instance.h
+**     \brief writeme
+**
+**     $Id$
+**
+**     \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
+**     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_INSTANCE_H
+#define __SYNFIG_STUDIO_INSTANCE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <ETL/handle>
+#include <gtkmm/treeview.h>
+#include <gtkmm/treestore.h>
+#include <synfigapp/instance.h>
+#include <sigc++/object.h>
+#include <synfigapp/value_desc.h>
+#include "historytreestore.h"
+#include <synfig/canvas.h>
+
+/* === M A C R O S ========================================================= */
+#define DEFAULT_FILENAME_PREFIX _("Synfig Animation ") // will be followed by a different number for each document
+
+/* === T Y P E D E F S ===================================================== */
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+namespace Gtk { class Menu; class ActionGroup; };
+
+namespace studio {
+
+class CanvasView;
+
+
+class Instance : public synfigapp::Instance
+{
+public:
+       typedef std::list< etl::handle<CanvasView> > CanvasViewList;
+
+       enum Status
+       {
+               STATUS_OK,
+               STATUS_ERROR,
+               STATUS_CANCEL
+       };
+
+       class CanvasTreeModel : public Gtk::TreeModel::ColumnRecord
+       {
+       public:
+               Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
+               Gtk::TreeModelColumn<Glib::ustring> label;
+               Gtk::TreeModelColumn<Glib::ustring> name;
+               Gtk::TreeModelColumn<Glib::ustring> id;
+
+               Gtk::TreeModelColumn<synfig::Canvas::Handle> canvas;
+               Gtk::TreeModelColumn<bool> is_canvas;
+
+               Gtk::TreeModelColumn<synfig::ValueNode::Handle> value_node;
+               Gtk::TreeModelColumn<bool> is_value_node;
+               Gtk::TreeModelColumn<synfig::ValueBase> value;
+               Gtk::TreeModelColumn<Glib::ustring> type;
+               Gtk::TreeModelColumn<int> link_id;
+               Gtk::TreeModelColumn<int> link_count;
+
+               Gtk::TreeModelColumn<bool> is_editable;
+
+               Gtk::TreeModelColumn<synfigapp::ValueDesc> value_desc;
+
+               CanvasTreeModel()
+               {
+                       add(value);
+                       add(name);
+                       add(label);
+                       add(icon);
+                       add(type);
+                       add(id);
+                       add(canvas);
+                       add(value_node);
+                       add(is_canvas);
+                       add(is_value_node);
+
+                       add(is_editable);
+                       add(value_desc);
+                       add(link_count);
+                       add(link_id);
+               }
+       } canvas_tree_model;
+
+private:
+
+       sigc::signal<void,CanvasView*> signal_canvas_view_created_;
+       sigc::signal<void,CanvasView*> signal_canvas_view_deleted_;
+
+       sigc::signal<void> signal_undo_redo_status_changed_;
+
+       //! Tree containing the canvases -- used for the "canvas browser"
+       Glib::RefPtr<Gtk::TreeStore> canvas_tree_store_;
+
+       //! Tree containing the actions -- used for the "canvas browser"
+       Glib::RefPtr<HistoryTreeStore> history_tree_store_;
+
+       //! Instance number
+       int     id_;
+
+       //! Used to calculate instance ID
+       static int instance_count_;
+
+       //! List of canvas view windows
+       CanvasViewList canvas_view_list_;
+
+       bool undo_status_;
+       bool redo_status_;
+
+       void set_undo_status(bool x);
+       void set_redo_status(bool x);
+
+       static void _revert(Instance *);
+
+protected:
+
+       Instance(synfig::Canvas::Handle);
+
+public:
+
+       sigc::signal<void>& signal_undo_redo_status_changed() { return signal_undo_redo_status_changed_; }
+
+       ~Instance();
+
+       sigc::signal<void,CanvasView*>& signal_canvas_view_created() { return signal_canvas_view_created_; }
+       sigc::signal<void,CanvasView*>& signal_canvas_view_deleted() { return signal_canvas_view_deleted_; }
+
+       bool get_undo_status()const { return undo_status_; }
+
+       bool get_redo_status()const { return redo_status_; }
+
+       int get_visible_canvases()const;
+
+       Glib::RefPtr<Gtk::TreeStore> canvas_tree_store() { return canvas_tree_store_; }
+
+       Glib::RefPtr<const Gtk::TreeStore> canvas_tree_store()const { return canvas_tree_store_; }
+
+       Glib::RefPtr<HistoryTreeStore> history_tree_store() { return history_tree_store_; }
+
+       Glib::RefPtr<const HistoryTreeStore> history_tree_store()const { return history_tree_store_; }
+
+       //! Returns the number of instances that are currently open in the program
+       static int get_count() { return instance_count_; }
+
+       //etl::handle<synfig::Canvas> get_canvas()const { return synfigapp::Instance::get_canvas(); }
+
+       etl::handle<CanvasView> find_canvas_view(etl::handle<synfig::Canvas> canvas);
+
+       //! Sets the focus to a specific canvas
+       void focus(etl::handle<synfig::Canvas> canvas);
+
+       CanvasViewList & canvas_view_list() { return canvas_view_list_; }
+
+       const CanvasViewList & canvas_view_list()const { return canvas_view_list_; }
+
+       bool save_as(const synfig::String &filename);
+
+       //! returns true if the instance has a real filename associated with it, rather than the made up "synfig animation 1" or some such
+       bool has_real_filename();
+
+       //! Opens a "Save As" dialog, and then saves the composition to that file
+       //! returns true if the save was successful
+       bool dialog_save_as();
+
+       void open();
+
+       Status save();
+
+       void dialog_cvs_commit();
+
+       void dialog_cvs_add();
+
+       void dialog_cvs_update();
+
+       void dialog_cvs_revert();
+
+       //! Closes the instance of this composition
+       void close();
+
+       void revert();
+
+       void update_all_titles();
+
+       void refresh_canvas_tree();
+
+       bool safe_revert();
+       bool safe_close();
+
+       void add_actions_to_menu(Gtk::Menu *menu,   const synfigapp::Action::ParamList &param_list, synfigapp::Action::Category category=synfigapp::Action::CATEGORY_ALL)const;
+       void add_actions_to_menu(Gtk::Menu *menu, const synfigapp::Action::ParamList &param_list1,const synfigapp::Action::ParamList &param_list2, synfigapp::Action::Category category=synfigapp::Action::CATEGORY_ALL)const;
+
+       void add_actions_to_group(const Glib::RefPtr<Gtk::ActionGroup>& action_group, synfig::String& ui_info,   const synfigapp::Action::ParamList &param_list, synfigapp::Action::Category category=synfigapp::Action::CATEGORY_ALL)const;
+
+       void process_action(synfig::String name, synfigapp::Action::ParamList param_list);
+
+       void make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas, synfigapp::ValueDesc value_desc, float location=0.5f, bool bezier=false);
+
+       void make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas,const std::list<synfigapp::ValueDesc>& value_desc_list);
+
+
+       static void edit_waypoint(synfigapp::ValueDesc value_desc,synfig::Waypoint waypoint);
+
+private:
+       void insert_canvas(Gtk::TreeRow row,synfig::Canvas::Handle canvas);
+
+public:
+       static etl::handle<Instance> create(synfig::Canvas::Handle canvas);
+}; // END class Instance
+
+}; // END namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/ipc.cpp b/synfig-studio/src/gui/ipc.cpp
new file mode 100644 (file)
index 0000000..4d1db56
--- /dev/null
@@ -0,0 +1,343 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file ipc.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \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
+**     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 <config.h>
+#endif
+
+#include "ipc.h"
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+#ifdef HAVE_SYS_ERRNO_H
+#include <sys/errno.h>
+#endif
+
+#include <synfig/main.h>
+#include "app.h"
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+
+#ifdef _WIN32
+#include <windows.h>
+#define BUFSIZE   128
+#define read   _read
+#endif
+
+#include "toolbox.h"
+#include <glibmm/dispatcher.h>
+#include <synfig/mutex.h>
+#include <synfig/string.h>
+#include <glibmm/thread.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 ======================================================= */
+
+#ifdef _WIN32
+#define WIN32_PIPE_PATH "\\\\.\\pipe\\SynfigStudio.Cmd"
+static synfig::Mutex cmd_mutex;
+static std::list<synfig::String> cmd_queue;
+static Glib::Dispatcher* cmd_dispatcher;
+static void
+pipe_listen_thread()
+{
+       for(;;)
+       {
+               HANDLE pipe_handle;
+               pipe_handle=CreateNamedPipe(
+                       WIN32_PIPE_PATH, // pipe name
+                       PIPE_ACCESS_INBOUND, // Access type
+                       PIPE_READMODE_BYTE /*|PIPE_NOWAIT*/,
+                       PIPE_UNLIMITED_INSTANCES,
+                       BUFSIZE,
+                       BUFSIZE,
+                       NMPWAIT_USE_DEFAULT_WAIT,
+                       NULL
+               );
+               if(pipe_handle==INVALID_HANDLE_VALUE)
+               {
+                       synfig::error("IPC(): Call to CreateNamedPipe failed. Ignore next error. GetLastError=%d",GetLastError());
+                       return;
+               }
+
+               bool connected;
+               connected=ConnectNamedPipe(pipe_handle,NULL)?true:(GetLastError()==ERROR_PIPE_CONNECTED);
+               DWORD read_bytes;
+               bool success;
+
+               Glib::Thread::yield();
+
+               if(connected)
+               do {
+                       String data;
+                       char c;
+                       do
+                       {
+                               success= ReadFile(
+                                       pipe_handle,
+                                       &c,             // buffer pointer
+                                       1,              // buffer size
+                                       &read_bytes,
+                                       NULL
+                               );
+                               if(success && read_bytes==1 && c!='\n')
+                                       data+=c;
+                       }while(c!='\n');
+                       synfig::Mutex::Lock lock(cmd_mutex);
+                       cmd_queue.push_back(data);
+                       cmd_dispatcher->emit();
+               } while(success && read_bytes);
+
+               CloseHandle(pipe_handle);
+       }
+}
+
+static void
+empty_cmd_queue()
+{
+       synfig::Mutex::Lock lock(cmd_mutex);
+       while(!cmd_queue.empty())
+       {
+               IPC::process_command(cmd_queue.front());
+               cmd_queue.pop_front();
+       }
+}
+
+#endif
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+IPC::IPC()
+{
+#ifdef _WIN32
+
+       cmd_dispatcher=new Glib::Dispatcher;
+       cmd_dispatcher->connect(sigc::ptr_fun(empty_cmd_queue));
+
+       Glib::Thread::create(
+               sigc::ptr_fun(pipe_listen_thread),
+               false
+       );
+
+#else
+
+       remove(fifo_path().c_str());
+       fd=-1;
+
+       if(mkfifo(fifo_path().c_str(), S_IRWXU)!=0)
+       {
+               synfig::error("IPC(): mkfifo failed for "+fifo_path());
+       }
+
+       {
+               fd=open(fifo_path().c_str(),O_RDWR);
+
+
+               if(fd<0)
+               {
+                       synfig::error("IPC(): Failed to open fifo \"%s\". (errno=?)",fifo_path().c_str());
+                       //synfig::error("IPC(): Failed to open fifo \"%s\". (errno=%d)",fifo_path().c_str(),::errno);
+               }
+               else
+               {
+                       file=SmartFILE(fdopen(fd,"r"));
+
+                       Glib::signal_io().connect(
+                               sigc::mem_fun(this,&IPC::fifo_activity),
+                               fd,
+                               Glib::IO_IN|Glib::IO_PRI|Glib::IO_ERR|Glib::IO_HUP|Glib::IO_NVAL
+                       );
+               }
+       }
+#endif
+}
+
+IPC::~IPC()
+{
+       //if(file)
+       //      fclose(file.get());
+
+       remove(fifo_path().c_str());
+
+       //if(fd>=0)
+       //      close(fd);
+}
+
+synfig::String
+IPC::fifo_path()
+{
+#ifdef _WIN32
+       return WIN32_PIPE_PATH;
+#else
+       return Glib::build_filename(App::get_user_app_directory(),"fifo");
+#endif
+}
+
+bool
+IPC::fifo_activity(Glib::IOCondition cond)
+{
+       if(cond&(Glib::IO_ERR|Glib::IO_HUP|Glib::IO_NVAL))
+       {
+               if(cond&(Glib::IO_ERR))
+                       synfig::error("IPC::fifo_activity(): IO_ERR");
+               if(cond&(Glib::IO_HUP))
+                       synfig::error("IPC::fifo_activity(): IO_HUP");
+               if(cond&(Glib::IO_NVAL))
+                       synfig::error("IPC::fifo_activity(): IO_NVAL");
+               return false;
+       }
+
+       String command;
+       {
+               char tmp;
+               do {
+                       if(read(fd,&tmp,sizeof(tmp))<=0)
+                               break;
+                       if(tmp!='\n')
+                               command+=tmp;
+               } while(tmp!='\n');
+       }
+
+       synfig::info("%s:%d: fifo activity: '%s'", __FILE__, __LINE__, command.c_str());
+       process_command(command);
+       return true;
+}
+
+bool
+IPC::process_command(const synfig::String& command_line)
+{
+       if(command_line.empty())
+               return false;
+
+       char cmd = command_line[0];
+
+       String args(command_line.begin()+1,command_line.end());
+
+       // erase leading spaces
+       while (!args.empty() && args[0] == ' ')
+               args.erase(args.begin());
+
+       // erase trailing newlines and spaces
+       while (!args.empty() && (args[args.size()-1] == '\n' || args[args.size()-1] == ' '))
+               args.erase(args.end()-1);
+
+       switch(toupper(cmd))
+       {
+               case 'F': // Focus/Foreground
+                       App::signal_present_all()();
+                       break;
+               case 'N': // New file
+                       App::signal_present_all()();
+                       App::new_instance();
+                       break;
+               case 'O': // Open <arg>
+                       App::signal_present_all()();
+                       App::open(args);
+                       break;
+               case 'X': // Quit
+               case 'Q': // Quit
+                       App::quit();
+                       break;
+               default:
+                       synfig::warning("Received unknown command '%c' with arg '%s'",cmd,args.c_str());
+                       break;
+       }
+
+       return true;
+}
+
+synfig::SmartFILE
+IPC::make_connection()
+{
+       SmartFILE ret;
+#ifdef _WIN32
+       HANDLE pipe_handle;
+       pipe_handle=CreateFile(
+               fifo_path().c_str(),
+               GENERIC_WRITE, // desired access
+               0, // share mode
+               NULL, // security attributes
+               OPEN_EXISTING, // creation disposition
+               FILE_ATTRIBUTE_NORMAL, // flags and attributes
+               NULL  // template file
+       );
+       if(pipe_handle==INVALID_HANDLE_VALUE)
+       {
+               DWORD error = GetLastError();
+#ifndef _DEBUG
+               if( error != ERROR_FILE_NOT_FOUND )
+#endif
+                       synfig::warning("IPC::make_connection(): Unable to connect to previous instance. GetLastError=%d",error);
+       }
+       int fd=_open_osfhandle(reinterpret_cast<long int>(pipe_handle),_O_APPEND|O_WRONLY);
+#else
+       struct stat file_stat;
+       if(stat(fifo_path().c_str(),&file_stat)!=0)
+               return ret;
+
+       if(!S_ISFIFO(file_stat.st_mode))
+               return ret;
+
+       int fd=open(fifo_path().c_str(),O_WRONLY|O_NONBLOCK);
+#endif
+
+       if(fd>=0)
+               ret=SmartFILE(fdopen(fd,"w"));
+
+#ifdef _DEBUG
+       // synfig::info("uplink fd=%d",fd);
+#endif
+
+       return ret;
+}
diff --git a/synfig-studio/src/gui/ipc.h b/synfig-studio/src/gui/ipc.h
new file mode 100644 (file)
index 0000000..59c401e
--- /dev/null
@@ -0,0 +1,65 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file ipc.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_IPC_H
+#define __SYNFIG_IPC_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <synfig/smartfile.h>
+#include <glibmm/main.h>
+#include <synfig/string.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 IPC
+{
+private:
+
+       int fd;
+       synfig::SmartFILE file;
+
+       bool fifo_activity(Glib::IOCondition cond);
+
+public:
+       IPC();
+       ~IPC();
+
+       static synfig::String fifo_path();
+       static synfig::SmartFILE make_connection();
+
+       static bool process_command(const synfig::String& cmd);
+}; // END of class IPC
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/keyframeactionmanager.cpp b/synfig-studio/src/gui/keyframeactionmanager.cpp
new file mode 100644 (file)
index 0000000..aaddf1f
--- /dev/null
@@ -0,0 +1,251 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file keyframeactionmanager.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \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
+**     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 <config.h>
+#endif
+
+#include "keyframeactionmanager.h"
+#include "keyframetree.h"
+#include <synfigapp/action_param.h>
+#include "instance.h"
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+using namespace studio;
+
+static const guint no_prev_popup((guint)-1);
+
+/* === M A C R O S ========================================================= */
+
+//#define ONE_ACTION_GROUP 1
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+KeyframeActionManager::KeyframeActionManager():
+       action_group_(Gtk::ActionGroup::create("action_group_keyframe_action_manager")),
+       popup_id_(no_prev_popup),
+       queued(false)
+{
+}
+
+KeyframeActionManager::~KeyframeActionManager()
+{
+}
+
+void
+KeyframeActionManager::set_ui_manager(const Glib::RefPtr<Gtk::UIManager> &x)
+{
+       clear();
+
+#ifdef ONE_ACTION_GROUP
+       if(ui_manager_) get_ui_manager()->remove_action_group(action_group_);
+       ui_manager_=x;
+       if(ui_manager_) get_ui_manager()->insert_action_group(action_group_);
+#else
+       ui_manager_=x;
+#endif
+}
+
+void
+KeyframeActionManager::set_keyframe_tree(KeyframeTree* x)
+{
+       selection_changed_connection.disconnect();
+       keyframe_tree_=x;
+       if(keyframe_tree_)
+       {
+               selection_changed_connection=keyframe_tree_->get_selection()->signal_changed().connect(
+                       sigc::mem_fun(*this,&KeyframeActionManager::queue_refresh)
+               );
+       }
+}
+
+void
+KeyframeActionManager::set_canvas_interface(const etl::handle<synfigapp::CanvasInterface> &x)
+{
+       time_changed_connection.disconnect();
+       canvas_interface_=x;
+       if(canvas_interface_)
+       {
+               canvas_interface_->signal_time_changed().connect(
+                       sigc::mem_fun(*this,&KeyframeActionManager::queue_refresh)
+               );
+       }
+}
+
+void
+KeyframeActionManager::clear()
+{
+       if(ui_manager_)
+       {
+               // Clear out old stuff
+               if(popup_id_!=no_prev_popup)
+               {
+                       get_ui_manager()->remove_ui(popup_id_);
+                       popup_id_=no_prev_popup;
+#ifdef ONE_ACTION_GROUP
+                       while(!action_group_->get_actions().empty())action_group_->remove(*action_group_->get_actions().begin());
+#else
+                       get_ui_manager()->remove_action_group(action_group_);
+                       action_group_=Gtk::ActionGroup::create("action_group_keyframe_action_manager");
+#endif
+               }
+       }
+}
+
+void
+KeyframeActionManager::queue_refresh()
+{
+       if(queued)
+               return;
+
+       //queue_refresh_connection.disconnect();
+       queue_refresh_connection=Glib::signal_idle().connect(
+               sigc::bind_return(
+                       sigc::mem_fun(*this,&KeyframeActionManager::refresh),
+                       false
+               )
+       );
+
+       queued=true;
+}
+
+void
+KeyframeActionManager::on_keyframe_properties()
+{
+       signal_show_keyframe_properties_();
+}
+
+void
+KeyframeActionManager::on_add_keyframe()
+{
+       synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeAdd"));
+
+       if(!action)
+               return;
+
+       action->set_param("canvas",canvas_interface_->get_canvas());
+       action->set_param("canvas_interface",canvas_interface_);
+       action->set_param("keyframe",Keyframe(canvas_interface_->get_time()));
+
+       canvas_interface_->get_instance()->perform_action(action);
+}
+
+void
+KeyframeActionManager::refresh()
+{
+       KeyframeTreeStore::Model model;
+
+       if(queued)
+       {
+               queued=false;
+               //queue_refresh_connection.disconnect();
+       }
+
+
+       clear();
+
+       // Make sure we are ready
+       if(!ui_manager_ || !keyframe_tree_ || !canvas_interface_)
+       {
+               synfig::error("KeyframeActionManager::refresh(): Not ready!");
+               return;
+       }
+
+       String ui_info;
+
+       {
+               synfigapp::Action::ParamList param_list;
+               param_list.add("time",get_canvas_interface()->get_time());
+               param_list.add("canvas",get_canvas_interface()->get_canvas());
+               param_list.add("canvas_interface",get_canvas_interface());
+               if(keyframe_tree_->get_selection()->count_selected_rows()==1)
+               {
+                       Keyframe keyframe((*keyframe_tree_->get_selection()->get_selected())[model.keyframe]);
+                       param_list.add("keyframe",keyframe);
+               }
+
+               handle<studio::Instance>::cast_static(
+                       get_canvas_interface()->get_instance()
+               )->add_actions_to_group(
+                       action_group_,
+                       ui_info,
+                       param_list,
+                       synfigapp::Action::CATEGORY_KEYFRAME
+               );
+       }
+       if(action_group_->get_action("action-KeyframeAdd"))
+       {
+               action_group_->remove(action_group_->get_action("action-KeyframeAdd"));
+       }
+
+               action_group_->add(Gtk::Action::create(
+                       "action-KeyframeAdd",
+                       Gtk::StockID("gtk-add"),
+                       _("Add New Keyframe"),_("Add New Keyframe")
+               ),
+                       sigc::mem_fun(*this,&KeyframeActionManager::on_add_keyframe)
+               );
+
+       try
+       {
+               canvas_interface_->get_canvas()->keyframe_list().find(canvas_interface_->get_time());
+               action_group_->get_action("action-KeyframeAdd")->set_sensitive(false);
+               if(action_group_->get_action("action-KeyframeDuplicate"))
+                       action_group_->get_action("action-KeyframeDuplicate")->set_sensitive(false);
+       }
+       catch(...)
+       {
+       }
+
+       {
+               Glib::RefPtr<Gtk::Action> action(Gtk::Action::create("keyframe-properties", Gtk::StockID("gtk-properties"),
+                                                                                                                        _("Keyframe Properties"), _("Keyframe Properties")));
+               action_group_->add(action,sigc::mem_fun(*this,&KeyframeActionManager::on_keyframe_properties));
+               if(keyframe_tree_->get_selection()->count_selected_rows()==0)
+                       action->set_sensitive(false);
+       }
+
+       ui_info="<ui><popup action='menu-main'><menu action='menu-keyframe'>"+ui_info+"</menu></popup></ui>";
+       popup_id_=get_ui_manager()->add_ui_from_string(ui_info);
+#ifdef ONE_ACTION_GROUP
+#else
+       get_ui_manager()->insert_action_group(action_group_);
+#endif
+}
diff --git a/synfig-studio/src/gui/keyframeactionmanager.h b/synfig-studio/src/gui/keyframeactionmanager.h
new file mode 100644 (file)
index 0000000..9048a42
--- /dev/null
@@ -0,0 +1,91 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file keyframeactionmanager.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_KEYFRAME_ACTION_MANAGER_H
+#define __SYNFIG_KEYFRAME_ACTION_MANAGER_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/uimanager.h>
+#include <gtkmm/treeview.h>
+#include <synfigapp/canvasinterface.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 KeyframeTree;
+
+class KeyframeActionManager
+{
+       sigc::signal<void> signal_show_keyframe_properties_;
+
+       Glib::RefPtr<Gtk::UIManager> ui_manager_;
+       //Glib::RefPtr<Gtk::TreeSelection> tree_selection_;
+       KeyframeTree* keyframe_tree_;
+       etl::handle<synfigapp::CanvasInterface> canvas_interface_;
+
+       Glib::RefPtr<Gtk::ActionGroup>  action_group_;
+       Gtk::UIManager::ui_merge_id     popup_id_;
+
+
+       sigc::connection selection_changed_connection;
+
+       bool queued;
+       sigc::connection queue_refresh_connection;
+       sigc::connection time_changed_connection;
+
+       void on_add_keyframe();
+       void on_keyframe_properties();
+
+public:
+       sigc::signal<void>& signal_show_keyframe_properties() { return signal_show_keyframe_properties_; }
+
+       void queue_refresh();
+
+       KeyframeActionManager();
+       ~KeyframeActionManager();
+
+       void set_ui_manager(const Glib::RefPtr<Gtk::UIManager> &x);
+       Glib::RefPtr<Gtk::UIManager> get_ui_manager()const { return ui_manager_; }
+
+       void set_keyframe_tree(KeyframeTree* x);
+       KeyframeTree* get_keyframe_tree()const { return keyframe_tree_; }
+
+       void set_canvas_interface(const etl::handle<synfigapp::CanvasInterface> &x);
+       etl::handle<synfigapp::CanvasInterface> get_canvas_interface()const { return canvas_interface_; }
+
+       void refresh();
+       void clear();
+}; // END of KeyframeActionManager
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/keyframedial.cpp b/synfig-studio/src/gui/keyframedial.cpp
new file mode 100644 (file)
index 0000000..c7b5c56
--- /dev/null
@@ -0,0 +1,96 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file keyframedial.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2009 Gerco Ballintijn
+**     Copyright (c) 2009 Carlos Lopez
+**
+**     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 <config.h>
+#endif
+
+#include "keyframedial.h"
+#include <gtkmm/image.h>
+#include <gtkmm/stock.h>
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+KeyFrameDial::KeyFrameDial(): Gtk::Table(1, 3, false)
+{
+       Gtk::IconSize iconsize = Gtk::IconSize::from_name("synfig-small_icon");
+
+       seek_prev_keyframe = create_icon(iconsize, Gtk::Stock::GO_BACK, _("Previous KeyFrame"));
+       seek_next_keyframe = create_icon(iconsize, Gtk::Stock::GO_FORWARD, _("Next KeyFrame"));
+       lock_keyframe = create_icon(Gtk::ICON_SIZE_BUTTON, "synfig-keyframe_lock_all",_("All Keyframes Locked"));
+
+       attach(*seek_prev_keyframe, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       attach(*seek_next_keyframe, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       attach(*lock_keyframe, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+}
+
+Gtk::Button *
+KeyFrameDial::create_icon(Gtk::IconSize iconsize, const char * stockid,
+               const char * tooltip)
+{
+       Gtk::Button *button = manage(new class Gtk::Button());
+       Gtk::Image *icon = manage(new Gtk::Image(Gtk::StockID(stockid), iconsize));
+       button->add(*icon);
+       tooltips.set_tip(*button, tooltip);
+       icon->set_padding(0, 0);
+       icon->show();
+       button->set_relief(Gtk::RELIEF_NONE);
+       button->show();
+
+       return button;
+}
+
+Gtk::Button *
+KeyFrameDial::create_icon(Gtk::IconSize iconsize, const Gtk::BuiltinStockID & stockid,
+               const char * tooltip)
+{
+       Gtk::Button *button = manage(new class Gtk::Button());
+       Gtk::Image *icon = manage(new Gtk::Image(stockid, iconsize));
+       button->add(*icon);
+       tooltips.set_tip(*button, tooltip);
+       icon->set_padding(0, 0);
+       icon->show();
+       button->set_relief(Gtk::RELIEF_NONE);
+       button->show();
+
+       return button;
+}
diff --git a/synfig-studio/src/gui/keyframedial.h b/synfig-studio/src/gui/keyframedial.h
new file mode 100644 (file)
index 0000000..a6491c9
--- /dev/null
@@ -0,0 +1,74 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file keyframedial.h
+**     \brief Template Header
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2008 Chris Moore
+**     Copyright (c) 2009 Gerco Ballintijn
+**     Copyright (c) 2009 Carlos Lopez
+**
+**     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_KEYFRAMEDIAL_H
+#define __SYNFIG_STUDIO_KEYFRAMEDIAL_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/tooltips.h>
+#include <gtkmm/table.h>
+#include <gtkmm/button.h>
+
+#include "general.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 KeyFrameDial : public Gtk::Table
+{
+       Gtk::Tooltips tooltips;
+
+       Gtk::Button *seek_prev_keyframe;
+       Gtk::Button *seek_next_keyframe;
+       Gtk::Button *lock_keyframe;
+
+       Gtk::Button *create_icon(Gtk::IconSize iconsize, const char * stockid, const char * tooltip);
+       Gtk::Button *create_icon(Gtk::IconSize iconsize, const Gtk::BuiltinStockID & stockid, const char * tooltip);
+
+public:
+
+       KeyFrameDial();
+       Glib::SignalProxy0<void> signal_seek_prev_keyframe()  { return seek_prev_keyframe->signal_clicked(); }
+       Glib::SignalProxy0<void> signal_seek_next_keyframe()  { return seek_next_keyframe->signal_clicked(); }
+       Glib::SignalProxy0<void> signal_lock_keyframe()  { return lock_keyframe->signal_clicked(); }
+       Gtk::Button *get_lock_button() { return lock_keyframe; }
+
+}; // END of class KeyFrameDial
+
+}; // END of namespace studio
+
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/keyframetree.cpp b/synfig-studio/src/gui/keyframetree.cpp
new file mode 100644 (file)
index 0000000..e480292
--- /dev/null
@@ -0,0 +1,291 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file keyframetree.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 <config.h>
+#endif
+
+#include "keyframetree.h"
+#include "cellrenderer_time.h"
+#include <gtkmm/treemodelsort.h>
+#include <ETL/misc>
+
+#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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+KeyframeTree::KeyframeTree()
+{
+       const KeyframeTreeStore::Model model;
+
+       {
+               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Time")) );
+
+               cell_renderer_time = Gtk::manage( new CellRenderer_Time() );
+               column->pack_start(*cell_renderer_time,true);
+               column->add_attribute(cell_renderer_time->property_time(), model.time);
+               cell_renderer_time->signal_edited().connect(sigc::mem_fun(*this,&studio::KeyframeTree::on_edited_time));
+
+               column->set_reorderable();
+               column->set_resizable();
+               column->set_clickable();
+               column->set_sort_column(model.time);
+
+               append_column(*column);
+       }
+       {
+               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Length")) );
+
+               cell_renderer_time_delta = Gtk::manage( new CellRenderer_Time() );
+               column->pack_start(*cell_renderer_time_delta,true);
+               column->add_attribute(cell_renderer_time_delta->property_time(), model.time_delta);
+               cell_renderer_time_delta->signal_edited().connect(sigc::mem_fun(*this,&studio::KeyframeTree::on_edited_time_delta));
+
+               column->set_reorderable();
+               column->set_resizable();
+               column->set_clickable(false);
+               // column->set_sort_column(model.time_delta);
+
+               append_column(*column);
+       }
+       {
+               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Jump")) );
+
+               Gtk::CellRendererText* cell_renderer_jump=Gtk::manage(new Gtk::CellRendererText());
+               column->pack_start(*cell_renderer_jump,true);
+               cell_renderer_jump->property_text()=_("(JMP)");
+               cell_renderer_jump->property_foreground()="#003a7f";
+
+               column->set_reorderable();
+               column->set_resizable();
+               column->set_clickable(false);
+               column->set_sort_column(COLUMNID_JUMP); // without this, (JMP) needs a double click?!
+
+               append_column(*column);
+       }
+       {
+               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Description")) );
+
+               cell_renderer_description=Gtk::manage(new Gtk::CellRendererText());
+               column->pack_start(*cell_renderer_description,true);
+               column->add_attribute(cell_renderer_description->property_text(), model.description);
+               cell_renderer_description->signal_edited().connect(sigc::mem_fun(*this,&studio::KeyframeTree::on_edited_description));
+
+               column->set_reorderable();
+               column->set_resizable();
+               column->set_clickable();
+               column->set_sort_column(model.description);
+
+               append_column(*column);
+       }
+
+       set_enable_search(true);
+       set_search_column(model.description);
+
+       // This makes things easier to read.
+       set_rules_hint();
+
+       // Make us more sensitive to several events
+       add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
+}
+
+KeyframeTree::~KeyframeTree()
+{
+       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
+               synfig::info("KeyframeTree::~KeyframeTree(): Deleted");
+}
+
+void
+KeyframeTree::on_rend_desc_changed()
+{
+       cell_renderer_time->property_fps().set_value(keyframe_tree_store_->canvas_interface()->get_canvas()->rend_desc().get_frame_rate());
+       queue_draw();
+}
+
+void
+KeyframeTree::set_model(Glib::RefPtr<KeyframeTreeStore> keyframe_tree_store)
+{
+       keyframe_tree_store_=keyframe_tree_store;
+       KeyframeTreeStore::Model model;
+
+       if(true)
+       {
+               Glib::RefPtr<Gtk::TreeModelSort> sorted_store(Gtk::TreeModelSort::create(keyframe_tree_store_));
+               sorted_store->set_default_sort_func(sigc::ptr_fun(&studio::KeyframeTreeStore::time_sorter));
+               sorted_store->set_sort_func(model.time,                 sigc::ptr_fun(&studio::KeyframeTreeStore::time_sorter));
+               sorted_store->set_sort_func(model.description,  sigc::ptr_fun(&studio::KeyframeTreeStore::description_sorter));
+               Gtk::TreeView::set_model(sorted_store);
+       }
+       else
+               Gtk::TreeView::set_model(keyframe_tree_store);
+
+       keyframe_tree_store_->canvas_interface()->signal_rend_desc_changed().connect(
+               sigc::mem_fun(
+                       *this,
+                       &studio::KeyframeTree::on_rend_desc_changed
+               )
+       );
+       cell_renderer_time->property_fps().set_value(keyframe_tree_store_->canvas_interface()->get_canvas()->rend_desc().get_frame_rate());
+       cell_renderer_time_delta->property_fps().set_value(keyframe_tree_store_->canvas_interface()->get_canvas()->rend_desc().get_frame_rate());
+}
+
+void
+KeyframeTree::set_editable(bool x)
+{
+       editable_=x;
+
+       if(editable_)
+       {
+               cell_renderer_time->property_editable()=true;
+               cell_renderer_time_delta->property_editable()=true;
+               cell_renderer_description->property_editable()=true;
+       }
+       else
+       {
+               cell_renderer_time->property_editable()=false;
+               cell_renderer_time_delta->property_editable()=false;
+               cell_renderer_description->property_editable()=false;
+       }
+}
+
+void
+KeyframeTree::on_edited_time(const Glib::ustring&path_string,synfig::Time time)
+{
+       Gtk::TreePath path(path_string);
+
+       const Gtk::TreeRow row(*(get_model()->get_iter(path)));
+
+       synfig::Keyframe keyframe(row[model.keyframe]);
+       if(time!=keyframe.get_time())
+       {
+               row[model.time]=time;
+               //keyframe.set_time(time);
+               //signal_edited_time()(keyframe,time);
+               //signal_edited()(keyframe);
+       }
+}
+
+void
+KeyframeTree::on_edited_time_delta(const Glib::ustring&path_string,synfig::Time time)
+{
+       Gtk::TreePath path(path_string);
+
+       const Gtk::TreeRow row(*(get_model()->get_iter(path)));
+
+       if(row)row[model.time_delta]=time;
+}
+
+void
+KeyframeTree::on_edited_description(const Glib::ustring&path_string,const Glib::ustring &desc)
+{
+       Gtk::TreePath path(path_string);
+
+       const Gtk::TreeRow row = *(get_model()->get_iter(path));
+
+       const synfig::String description(desc);
+       synfig::Keyframe keyframe(row[model.keyframe]);
+       if(description!=keyframe.get_description())
+       {
+               row[model.description]=desc;
+               keyframe.set_description(description);
+               signal_edited_description()(keyframe,description);
+               signal_edited()(keyframe);
+       }
+}
+
+bool
+KeyframeTree::on_event(GdkEvent *event)
+{
+    switch(event->type)
+    {
+       case GDK_BUTTON_PRESS:
+               {
+                       Gtk::TreeModel::Path path;
+                       Gtk::TreeViewColumn *column;
+                       int cell_x, cell_y;
+                       int wx(round_to_int(event->button.x)),wy(round_to_int(event->button.y));
+                       //tree_to_widget_coords (,, wx, wy);
+                       if(!get_path_at_pos(
+                               wx,wy,  // x, y
+                               path, // TreeModel::Path&
+                               column, //TreeViewColumn*&
+                               cell_x,cell_y //int&cell_x,int&cell_y
+                               )
+                       ) break;
+                       const Gtk::TreeRow row = *(get_model()->get_iter(path));
+
+                       signal_user_click()(event->button.button,row,(ColumnID)column->get_sort_column_id());
+                       if((ColumnID)column->get_sort_column_id()==COLUMNID_JUMP)
+                       {
+                               keyframe_tree_store_->canvas_interface()->set_time(row[model.time]);
+                       }
+               }
+               break;
+       case GDK_2BUTTON_PRESS:
+               {
+                       Gtk::TreeModel::Path path;
+                       Gtk::TreeViewColumn *column;
+                       int cell_x, cell_y;
+                       if(!get_path_at_pos(
+                               int(event->button.x),int(event->button.y),      // x, y
+                               path, // TreeModel::Path&
+                               column, //TreeViewColumn*&
+                               cell_x,cell_y //int&cell_x,int&cell_y
+                               )
+                       ) break;
+                       const Gtk::TreeRow row = *(get_model()->get_iter(path));
+
+                       {
+                               keyframe_tree_store_->canvas_interface()->set_time(row[model.time]);
+                               return true;
+                       }
+               }
+               break;
+
+       case GDK_BUTTON_RELEASE:
+               break;
+       default:
+               break;
+       }
+       return false;
+}
diff --git a/synfig-studio/src/gui/keyframetree.h b/synfig-studio/src/gui/keyframetree.h
new file mode 100644 (file)
index 0000000..31d820e
--- /dev/null
@@ -0,0 +1,149 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file keyframetree.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_KEYFRAMETREE_H
+#define __SYNFIG_STUDIO_KEYFRAMETREE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/treeview.h>
+#include <gtkmm/treestore.h>
+#include <synfigapp/canvasinterface.h>
+#include <synfigapp/value_desc.h>
+#include "keyframetreestore.h"
+#include <synfig/keyframe.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 CellRenderer_Time;
+
+class KeyframeTree : public Gtk::TreeView
+{
+       /*
+ -- ** -- P U B L I C   T Y P E S ---------------------------------------------
+       */
+
+public:
+
+       enum ColumnID
+       {
+               COLUMNID_TIME,
+               COLUMNID_DESCRIPTION,
+               COLUMNID_JUMP,
+
+               COLUMNID_END                    //!< \internal
+       };
+
+       /*
+ -- ** -- P U B L I C  D A T A ------------------------------------------------
+       */
+
+public:
+
+       KeyframeTreeStore::Model model;
+
+       /*
+ -- ** -- P R I V A T E   D A T A ---------------------------------------------
+       */
+
+private:
+
+       Glib::RefPtr<KeyframeTreeStore> keyframe_tree_store_;
+
+       CellRenderer_Time *cell_renderer_time;
+
+       CellRenderer_Time *cell_renderer_time_delta;
+
+       Gtk::CellRendererText *cell_renderer_description;
+
+       sigc::signal<void,synfig::Keyframe> signal_edited_;
+
+       sigc::signal<void,synfig::Keyframe,synfig::Time> signal_edited_time_;
+
+       sigc::signal<void,synfig::Keyframe,synfig::String> signal_edited_description_;
+
+       sigc::signal<void, int, Gtk::TreeRow, ColumnID> signal_user_click_;
+
+       bool editable_;
+
+       /*
+ -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
+       */
+
+private:
+
+       /*
+ -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
+       */
+
+private:
+
+       void on_edited_time(const Glib::ustring&path_string,synfig::Time time);
+
+       void on_edited_time_delta(const Glib::ustring&path_string,synfig::Time time);
+
+       void on_edited_description(const Glib::ustring&path_string,const Glib::ustring &description);
+
+       bool on_event(GdkEvent *event);
+
+       void on_rend_desc_changed();
+
+       /*
+ -- ** -- P U B L I C   M E T H O D S -----------------------------------------
+       */
+
+public:
+
+       KeyframeTree();
+       ~KeyframeTree();
+
+       void set_model(Glib::RefPtr<KeyframeTreeStore> keyframe_tree_store_);
+
+       void set_editable(bool x=true);
+
+       bool get_editable()const { return editable_; }
+
+       //! Signal called when a keyframe has been edited in any way
+       sigc::signal<void,synfig::Keyframe>& signal_edited() { return signal_edited_; }
+
+       //! Signal called when a time has been edited.
+       sigc::signal<void,synfig::Keyframe,synfig::Time>& signal_edited_time() { return signal_edited_time_; }
+
+       //! Signal called when a description has been edited.
+       sigc::signal<void,synfig::Keyframe,synfig::String>& signal_edited_description() { return signal_edited_description_; }
+
+       sigc::signal<void,int, Gtk::TreeRow, ColumnID>& signal_user_click() { return signal_user_click_; }
+}; // END of KeyframeTree
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/keyframetreestore.cpp b/synfig-studio/src/gui/keyframetreestore.cpp
new file mode 100644 (file)
index 0000000..4e84001
--- /dev/null
@@ -0,0 +1,901 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file keyframetreestore.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 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 <config.h>
+#endif
+
+#include "keyframetreestore.h"
+#include <synfig/valuenode.h>
+#include "iconcontroller.h"
+#include <synfig/valuenode_timedswap.h>
+#include <gtkmm/button.h>
+#include <gtkmm/treerowreference.h>
+#include <synfig/canvas.h>
+#include <synfig/keyframe.h>
+#include <time.h>
+#include <cstdlib>
+#include <ETL/smart_ptr>
+#include <synfigapp/action.h>
+#include <synfigapp/instance.h>
+#include "onemoment.h"
+#include <synfig/exception.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 ======================================================= */
+
+// KeyframeTreeStore_Class KeyframeTreeStore::keyframe_tree_store_class_;
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+struct _keyframe_iterator
+{
+       synfig::KeyframeList::iterator iter;
+       int ref_count;
+       int index;
+};
+
+/*
+Gtk::TreeModel::iterator keyframe_iter_2_model_iter(synfig::KeyframeList::iterator iter,int index)
+{
+       Gtk::TreeModel::iterator ret;
+
+       _keyframe_iterator*& data(static_cast<_keyframe_iterator*&>(ret->gobj()->user_data));
+       data=new _keyframe_iterator();
+       data->ref_count=1;
+       data->iter=iter;
+       data->index=index;
+
+       return ret;
+}
+*/
+
+synfig::KeyframeList::iterator model_iter_2_keyframe_iter(Gtk::TreeModel::iterator iter)
+{
+       _keyframe_iterator* data(static_cast<_keyframe_iterator*>(iter->gobj()->user_data));
+       if(!data)
+               throw std::runtime_error("bad data");
+       return data->iter;
+}
+
+int get_index_from_model_iter(Gtk::TreeModel::iterator iter)
+{
+       _keyframe_iterator* data(static_cast<_keyframe_iterator*>(iter->gobj()->user_data));
+       if(!data)
+               throw std::runtime_error("bad data");
+       return data->index;
+}
+
+
+/*
+#ifndef TreeRowReferenceHack
+class TreeRowReferenceHack
+{
+       GtkTreeRowReference *gobject_;
+public:
+       TreeRowReferenceHack():
+               gobject_(0)
+       {
+       }
+
+       TreeRowReferenceHack(const Glib::RefPtr<Gtk::TreeModel>& model, const Gtk::TreeModel::Path& path):
+               gobject_ ( gtk_tree_row_reference_new(model->gobj(), const_cast<GtkTreePath*>(path.gobj())) )
+       {
+       }
+
+       TreeRowReferenceHack(const TreeRowReferenceHack &x):
+               gobject_ ( x.gobject_?gtk_tree_row_reference_copy(x.gobject_):0 )
+       {
+
+       }
+
+       void swap(TreeRowReferenceHack & other)
+       {
+               GtkTreeRowReference *const temp = gobject_;
+               gobject_ = other.gobject_;
+               other.gobject_ = temp;
+       }
+
+       const TreeRowReferenceHack &
+       operator=(const TreeRowReferenceHack &rhs)
+       {
+               TreeRowReferenceHack temp (rhs);
+               swap(temp);
+               return *this;
+       }
+
+       ~TreeRowReferenceHack()
+       {
+               if(gobject_)
+                       gtk_tree_row_reference_free(gobject_);
+       }
+
+       Gtk::TreeModel::Path get_path() { return Gtk::TreeModel::Path(gtk_tree_row_reference_get_path(gobject_),false); }
+       GtkTreeRowReference *gobj() { return gobject_; }
+};
+#endif
+*/
+
+/* === P R O C E D U R E S ================================================= */
+
+void clear_iterator(GtkTreeIter* iter)
+{
+       iter->stamp=0;
+       iter->user_data=iter->user_data2=iter->user_data3=0;
+}
+
+/* === M E T H O D S ======================================================= */
+
+const Glib::Class&
+KeyframeTreeStore_Class::init()
+{
+       if(!gtype_)
+       {
+               class_init_func_ = &KeyframeTreeStore_Class::class_init_function;
+
+               const GTypeInfo derived_info =
+               {
+                       sizeof(GObjectClass),
+                       NULL,
+                       NULL,
+                       class_init_func_,
+                       NULL,
+                       NULL,
+                       sizeof(GObject),
+                       0,
+                       0,
+                       NULL
+               };
+
+               gtype_ = g_type_register_static(G_TYPE_OBJECT, "KeyframeTreeStore", &derived_info, GTypeFlags(0));
+               Gtk::TreeModel::add_interface(get_type());
+       }
+       return *this;
+}
+
+void
+KeyframeTreeStore_Class::class_init_function(gpointer /*g_class*/, gpointer /*class_data*/)
+{
+       // ???
+}
+
+KeyframeTreeStore::KeyframeTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_):
+       Glib::ObjectBase        ("KeyframeTreeStore"),
+       //! \todo what is going on here?  why the need for this KeyframeTreeStore_Class at all?
+       // Glib::Object         (Glib::ConstructParams(keyframe_tree_store_class_.init(), (char*) 0, (char*) 0)),
+       canvas_interface_       (canvas_interface_)
+{
+       reset_stamp();
+       //reset_path_table();
+
+       canvas_interface()->signal_keyframe_added().connect(sigc::mem_fun(*this,&studio::KeyframeTreeStore::add_keyframe));
+       canvas_interface()->signal_keyframe_removed().connect(sigc::mem_fun(*this,&studio::KeyframeTreeStore::remove_keyframe));
+       canvas_interface()->signal_keyframe_changed().connect(sigc::mem_fun(*this,&studio::KeyframeTreeStore::change_keyframe));
+}
+
+KeyframeTreeStore::~KeyframeTreeStore()
+{
+       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
+               synfig::info("KeyframeTreeStore::~KeyframeTreeStore(): Deleted");
+}
+
+Glib::RefPtr<KeyframeTreeStore>
+KeyframeTreeStore::create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_)
+{
+       KeyframeTreeStore *store(new KeyframeTreeStore(canvas_interface_));
+       Glib::RefPtr<KeyframeTreeStore> ret(store);
+       assert(ret);
+       return ret;
+}
+
+void
+KeyframeTreeStore::reset_stamp()
+{
+       stamp_=time(0)+reinterpret_cast<long>(this);
+}
+
+/*
+void
+KeyframeTreeStore::reset_path_table()
+{
+       Gtk::TreeModel::Children::iterator iter;
+       const Gtk::TreeModel::Children children(children());
+       path_table_.clear();
+       for(iter = children.begin(); iter != children.end(); ++iter)
+       {
+               Gtk::TreeModel::Row row(*iter);
+               path_table_[(Keyframe)row[model.keyframe]]=TreeRowReferenceHack(Glib::RefPtr<KeyframeTreeStore>(this),Gtk::TreePath(row));
+       }
+}
+*/
+
+
+inline bool
+KeyframeTreeStore::iterator_sane(const GtkTreeIter* iter)const
+{
+       if(iter && iter->stamp==stamp_)
+               return true;
+       g_warning("KeyframeTreeStore::iterator_sane(): Bad iterator stamp");
+       return false;
+}
+
+inline bool
+KeyframeTreeStore::iterator_sane(const Gtk::TreeModel::iterator& iter)const
+{
+       return iterator_sane(iter->gobj());
+}
+
+inline void
+KeyframeTreeStore::dump_iterator(const GtkTreeIter* /*gtk_iter*/, const Glib::ustring &/*name*/)const
+{
+#if 0
+       if(!gtk_iter)
+       {
+               g_warning("KeyframeTreeStore::dump_iterator: \"%s\" is NULL (Root?)",name.c_str());
+               return;
+       }
+
+       _keyframe_iterator *iter(static_cast<_keyframe_iterator*>(gtk_iter->user_data));
+
+       if(gtk_iter->stamp!=stamp_ || !iter)
+       {
+               g_warning("KeyframeTreeStore::dump_iterator: \"%s\" is INVALID",name.c_str());
+               return;
+       }
+
+       if((unsigned)iter->index>=canvas_interface()->get_canvas()->keyframe_list().size())
+               g_warning("KeyframeTreeStore::dump_iterator: \"%s\"(%p) has bad index(index:%d)",name.c_str(),gtk_iter,iter->index);
+
+       g_warning("KeyframeTreeStore::dump_iterator: \"%s\"(%p) ref:%d, index:%d, time:%s",name.c_str(),gtk_iter,iter->ref_count,iter->index,iter->iter->get_time().get_string().c_str());
+#endif
+}
+
+inline void
+KeyframeTreeStore::dump_iterator(const Gtk::TreeModel::iterator& iter, const Glib::ustring &name)const
+{
+       dump_iterator(iter->gobj(),name);
+}
+
+int
+KeyframeTreeStore::time_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs)
+{
+       const Model model;
+
+       _keyframe_iterator *rhs_iter(static_cast<_keyframe_iterator*>(rhs->gobj()->user_data));
+       _keyframe_iterator *lhs_iter(static_cast<_keyframe_iterator*>(lhs->gobj()->user_data));
+
+       Time diff(rhs_iter->iter->get_time()-lhs_iter->iter->get_time());
+       if(diff<0)
+               return -1;
+       if(diff>0)
+               return 1;
+       return 0;
+}
+
+int
+KeyframeTreeStore::description_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs)
+{
+       const Model model;
+
+       _keyframe_iterator *rhs_iter(static_cast<_keyframe_iterator*>(rhs->gobj()->user_data));
+       _keyframe_iterator *lhs_iter(static_cast<_keyframe_iterator*>(lhs->gobj()->user_data));
+
+       int comp = rhs_iter->iter->get_description().compare(lhs_iter->iter->get_description());
+       if (comp > 0) return 1;
+       if (comp < 0) return -1;
+       return 0;
+}
+
+void
+KeyframeTreeStore::set_value_impl(const Gtk::TreeModel::iterator& row, int column, const Glib::ValueBase& value)
+{
+       if(!iterator_sane(row))
+               return;
+
+       if(column>=get_n_columns_vfunc())
+       {
+               g_warning("KeyframeTreeStore::set_value_impl: Bad column (%d)",column);
+               return;
+       }
+
+       if(!g_value_type_compatible(G_VALUE_TYPE(value.gobj()),get_column_type_vfunc(column)))
+       {
+               g_warning("KeyframeTreeStore::set_value_impl: Bad value type");
+               return;
+       }
+
+       _keyframe_iterator *iter(static_cast<_keyframe_iterator*>(row.gobj()->user_data));
+
+       try
+       {
+               if(column==model.time_delta.index())
+               {
+                       Glib::Value<synfig::Time> x;
+                       g_value_init(x.gobj(),model.time.type());
+                       g_value_copy(value.gobj(),x.gobj());
+
+                       Time new_delta(x.get());
+                       if(new_delta<=Time::zero()+Time::epsilon())
+                       {
+                               // Bad value
+                               return;
+                       }
+
+                       Time old_delta((*row)[model.time_delta]);
+                       if(old_delta<=Time::zero()+Time::epsilon())
+                       {
+                               // Bad old delta
+                               return;
+                       }
+                       // row(row) on the next line is bad - don't use it, because it leaves 'row' uninitialized
+                       //Gtk::TreeModel::iterator row(row);
+                       //row++;
+                       //if(!row)return;
+
+                       Time change_delta(new_delta-old_delta);
+
+                       if(change_delta<=Time::zero()+Time::epsilon() &&change_delta>=Time::zero()-Time::epsilon())
+                       {
+                               // Not an error, just no change
+                               return;
+                       }
+
+                       {
+                               Keyframe keyframe((*row)[model.keyframe]);
+                               synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeSetDelta"));
+
+                               if(!action)return;
+
+                               action->set_param("canvas",canvas_interface()->get_canvas());
+                               action->set_param("canvas_interface",canvas_interface());
+                               action->set_param("keyframe",keyframe);
+                               action->set_param("delta",change_delta);
+
+                               canvas_interface()->get_instance()->perform_action(action);
+                       }
+
+                       return;
+               }
+               else
+               if(column==model.time.index())
+               {
+                       OneMoment one_moment;
+
+                       Glib::Value<synfig::Time> x;
+                       g_value_init(x.gobj(),model.time.type());
+                       g_value_copy(value.gobj(),x.gobj());
+                       synfig::Keyframe keyframe(*iter->iter);
+
+                       synfig::info("KeyframeTreeStore::set_value_impl():old_time=%s",keyframe.get_time().get_string().c_str());
+                       keyframe.set_time(x.get());
+                       synfig::info("KeyframeTreeStore::set_value_impl():new_time=%s",keyframe.get_time().get_string().c_str());
+
+                       synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeSet"));
+
+                       if(!action)
+                               return;
+
+                       action->set_param("canvas",canvas_interface()->get_canvas());
+                       action->set_param("canvas_interface",canvas_interface());
+                       action->set_param("keyframe",keyframe);
+
+                       canvas_interface()->get_instance()->perform_action(action);
+               }
+               else if(column==model.description.index())
+               {
+                       Glib::Value<Glib::ustring> x;
+                       g_value_init(x.gobj(),model.description.type());
+                       g_value_copy(value.gobj(),x.gobj());
+                       synfig::Keyframe keyframe(*iter->iter);
+                       keyframe.set_description(x.get());
+
+                       synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeSet"));
+
+                       if(!action)
+                               return;
+
+                       action->set_param("canvas",canvas_interface()->get_canvas());
+                       action->set_param("canvas_interface",canvas_interface());
+                       action->set_param("keyframe",keyframe);
+
+                       canvas_interface()->get_instance()->perform_action(action);
+               }
+               else if(column==model.keyframe.index())
+               {
+                       g_warning("KeyframeTreeStore::set_value_impl: This column is read-only");
+               }
+               else
+               {
+                       assert(0);
+               }
+       }
+       catch(std::exception x)
+       {
+               g_warning("%s", x.what());
+       }
+}
+
+Gtk::TreeModelFlags
+KeyframeTreeStore::get_flags_vfunc ()
+{
+       return Gtk::TREE_MODEL_LIST_ONLY;
+}
+
+int
+KeyframeTreeStore::get_n_columns_vfunc ()
+{
+       return model.size();
+}
+
+GType
+KeyframeTreeStore::get_column_type_vfunc (int index)
+{
+       return model.types()[index];
+}
+
+bool
+KeyframeTreeStore::iter_next_vfunc (const iterator& xiter, iterator& iter_next) const
+{
+       if(!iterator_sane(xiter)) return false;
+
+       _keyframe_iterator *iter(static_cast<_keyframe_iterator*>(xiter.gobj()->user_data));
+
+       if(iter->iter==canvas_interface()->get_canvas()->keyframe_list().end())
+               return false;
+
+       _keyframe_iterator *next(new _keyframe_iterator());
+       iter_next.gobj()->user_data=static_cast<gpointer>(next);
+       next->ref_count=1;
+       next->index=iter->index+1;
+       next->iter=iter->iter;
+       ++next->iter;
+
+       if(next->iter==canvas_interface()->get_canvas()->keyframe_list().end())
+               return false;
+
+       iter_next.gobj()->stamp=stamp_;
+
+       return true;
+}
+
+/*
+bool
+KeyframeTreeStore::iter_next_vfunc (GtkTreeIter* gtk_iter)
+{
+       if(!iterator_sane(gtk_iter)) return false;
+
+       _keyframe_iterator *iter(static_cast<_keyframe_iterator*>(gtk_iter->user_data));
+
+       // If we are already at the end, then we are very invalid
+       if(iter->iter==canvas_interface()->get_canvas()->keyframe_list().end())
+               return false;
+
+       ++(iter->iter);
+
+       if(iter->iter==canvas_interface()->get_canvas()->keyframe_list().end())
+       {
+               --(iter->iter);
+               return false;
+       }
+       (iter->index)++;
+       return true;
+}
+
+bool
+KeyframeTreeStore::iter_children_vfunc (GtkTreeIter* gtk_iter, const GtkTreeIter* parent)
+{
+       dump_iterator(gtk_iter,"gtk_iter");
+       dump_iterator(parent,"parent");
+
+       if(!parent || !iterator_sane(parent))
+       {
+               clear_iterator(gtk_iter);
+               return false;
+       }
+
+       _keyframe_iterator *iter(new _keyframe_iterator());
+       iter->ref_count=1;
+       iter->index=0;
+       iter->iter=canvas_interface()->get_canvas()->keyframe_list().begin();
+
+       gtk_iter->user_data=static_cast<gpointer>(iter);
+       gtk_iter->stamp=stamp_;
+
+       return true;
+}
+
+bool
+KeyframeTreeStore::iter_has_child_vfunc (const GtkTreeIter*parent)
+{
+       dump_iterator(parent,"parent");
+
+       if(parent)
+               return false;
+
+       return true;
+}
+
+int
+KeyframeTreeStore::iter_n_children_vfunc (const GtkTreeIter* parent)
+{
+       dump_iterator(parent,"parent");
+
+       if(parent)
+               return 0;
+
+       return canvas_interface()->get_canvas()->keyframe_list().size();
+}
+*/
+
+int
+KeyframeTreeStore::iter_n_root_children_vfunc () const
+{
+       return canvas_interface()->get_canvas()->keyframe_list().size();
+}
+
+bool
+KeyframeTreeStore::iter_nth_root_child_vfunc (int n, iterator& xiter)const
+{
+       if(canvas_interface()->get_canvas()->keyframe_list().size()==0)
+       {
+               return false;
+       }
+
+       if(n<0)
+       {
+               g_warning("KeyframeTreeStore::iter_nth_root_child_vfunc: Out of range (negative index)");
+               return false;
+       }
+       if(n && (unsigned)n>=canvas_interface()->get_canvas()->keyframe_list().size())
+       {
+               g_warning("KeyframeTreeStore::iter_nth_child_vfunc: Out of range (large index)");
+               return false;
+       }
+
+       _keyframe_iterator *iter(new _keyframe_iterator());
+       iter->ref_count=1;
+       iter->index=n;
+       iter->iter=canvas_interface()->get_canvas()->keyframe_list().begin();
+       while(n--)
+       {
+               if(iter->iter==canvas_interface()->get_canvas()->keyframe_list().end())
+               {
+                       g_warning("KeyframeTreeStore::iter_nth_child_vfunc: >>>BUG<<< in %s on line %d",__FILE__,__LINE__);
+                       delete iter;
+                       return false;
+               }
+               ++iter->iter;
+       }
+       xiter.gobj()->user_data=static_cast<gpointer>(iter);
+       xiter.gobj()->stamp=stamp_;
+       return true;
+}
+
+/*
+bool
+KeyframeTreeStore::iter_nth_child_vfunc (GtkTreeIter* gtk_iter, const GtkTreeIter* parent, int n)
+{
+       dump_iterator(parent,"parent");
+
+       if(parent)
+       {
+               g_warning("KeyframeTreeStore::iter_nth_child_vfunc: I am a list");
+               clear_iterator(gtk_iter);
+               return false;
+       }
+
+
+
+       _keyframe_iterator *iter(new _keyframe_iterator());
+       iter->ref_count=1;
+       iter->index=n;
+       iter->iter=canvas_interface()->get_canvas()->keyframe_list().begin();
+       while(n--)
+       {
+               if(iter->iter==canvas_interface()->get_canvas()->keyframe_list().end())
+               {
+                       g_warning("KeyframeTreeStore::iter_nth_child_vfunc: >>>BUG<<< in %s on line %d",__FILE__,__LINE__);
+                       delete iter;
+                       clear_iterator(gtk_iter);
+                       return false;
+               }
+               ++iter->iter;
+       }
+
+       gtk_iter->user_data=static_cast<gpointer>(iter);
+       gtk_iter->stamp=stamp_;
+       return true;
+}
+
+bool
+KeyframeTreeStore::iter_parent_vfunc (GtkTreeIter* gtk_iter, const GtkTreeIter* child)
+{
+       dump_iterator(child,"child");
+       iterator_sane(child);
+       clear_iterator(gtk_iter);
+       return false;
+}
+*/
+
+void
+KeyframeTreeStore::ref_node_vfunc (iterator& xiter)const
+{
+       GtkTreeIter* gtk_iter(xiter.gobj());
+       if(!gtk_iter || !iterator_sane(gtk_iter)) return;
+
+       _keyframe_iterator *iter(static_cast<_keyframe_iterator*>(gtk_iter->user_data));
+       iter->ref_count++;
+}
+
+void
+KeyframeTreeStore::unref_node_vfunc (iterator& xiter)const
+{
+       GtkTreeIter* gtk_iter(xiter.gobj());
+       if(!gtk_iter || !iterator_sane(gtk_iter)) return;
+
+       _keyframe_iterator *iter(static_cast<_keyframe_iterator*>(gtk_iter->user_data));
+       iter->ref_count--;
+       if(!iter->ref_count)
+       {
+               delete iter;
+
+               // Make this iterator invalid
+               gtk_iter->stamp=0;
+       }
+}
+
+Gtk::TreeModel::Path
+KeyframeTreeStore::get_path_vfunc (const iterator& gtk_iter)const
+{
+       Gtk::TreeModel::Path path;
+
+       // If this is the root node, then return
+       // a root path
+       if(!iterator_sane(gtk_iter))
+               return path;
+
+       _keyframe_iterator *iter(static_cast<_keyframe_iterator*>(gtk_iter->gobj()->user_data));
+
+       path.append_index(iter->index);
+
+       return path;
+}
+
+bool
+KeyframeTreeStore::get_iter_vfunc (const Gtk::TreeModel::Path& path, iterator& iter)const
+{
+       if(path.get_depth()>=1)
+               return iter_nth_root_child_vfunc(path.front(),iter);
+
+       // Error case
+       g_warning("KeyframeTreeStore::get_iter_vfunc(): Bad path \"%s\"",path.to_string().c_str());
+       //clear_iterator(iter);
+       return false;
+}
+
+bool
+KeyframeTreeStore::iter_is_valid (const iterator& iter) const
+{
+       return iterator_sane(iter);
+}
+
+void
+KeyframeTreeStore::get_value_vfunc (const Gtk::TreeModel::iterator& gtk_iter, int column, Glib::ValueBase& value)const
+{
+       dump_iterator(gtk_iter,"gtk_iter");
+       if(!iterator_sane(gtk_iter))
+               return;
+
+       _keyframe_iterator *iter(static_cast<_keyframe_iterator*>(gtk_iter->gobj()->user_data));
+
+       switch(column)
+       {
+       case 0:         // Time
+       {
+               Glib::Value<synfig::Time> x;
+               g_value_init(x.gobj(),x.value_type());
+               x.set(iter->iter->get_time());
+               g_value_init(value.gobj(),x.value_type());
+               g_value_copy(x.gobj(),value.gobj());
+               return;
+       }
+       case 3:         // Time Delta
+       {
+               Glib::Value<synfig::Time> x;
+               g_value_init(x.gobj(),x.value_type());
+
+               synfig::Keyframe prev_keyframe(*iter->iter);
+               synfig::Keyframe keyframe;
+               {
+                       KeyframeList::iterator tmp(iter->iter);
+                       tmp++;
+                       if(tmp==get_canvas()->keyframe_list().end())
+                       {
+                               x.set(Time(0));
+                               g_value_init(value.gobj(),x.value_type());
+                               g_value_copy(x.gobj(),value.gobj());
+                               return;
+                       }
+                       keyframe=*tmp;
+               }
+
+               Time delta(0);
+               try {
+                       delta=keyframe.get_time()-prev_keyframe.get_time();
+               }catch(...) { }
+               x.set(delta);
+               g_value_init(value.gobj(),x.value_type());
+               g_value_copy(x.gobj(),value.gobj());
+               return;
+       }
+       case 1:         // Description
+       {
+               g_value_init(value.gobj(),G_TYPE_STRING);
+               g_value_set_string(value.gobj(),iter->iter->get_description().c_str());
+               return;
+       }
+       case 2:         // Keyframe
+       {
+               Glib::Value<synfig::Keyframe> x;
+               g_value_init(x.gobj(),x.value_type());
+               x.set(*iter->iter);
+               g_value_init(value.gobj(),x.value_type());
+               g_value_copy(x.gobj(),value.gobj());
+               return;
+       }
+       default:
+               break;
+       }
+}
+
+Gtk::TreeModel::Row
+KeyframeTreeStore::find_row(const synfig::Keyframe &keyframe)
+{
+       Gtk::TreeModel::Row row(*(children().begin()));
+       dump_iterator(row,"find_row,begin");
+       const GtkTreeIter *gtk_iter(row.gobj());
+       if(!iterator_sane(gtk_iter))
+               throw std::runtime_error(_("Unable to find Keyframe in table"));
+
+       _keyframe_iterator *iter(static_cast<_keyframe_iterator*>(gtk_iter->user_data));
+
+       synfig::KeyframeList &keyframe_list(canvas_interface()->get_canvas()->keyframe_list());
+       if(keyframe_list.empty())
+               throw std::runtime_error(_("There are no keyframes n this canvas"));
+
+       iter->index=0;
+
+       for(iter->iter=keyframe_list.begin();iter->iter!=keyframe_list.end() && *iter->iter!=keyframe;++iter->iter)
+       {
+               iter->index++;
+       }
+       if(iter->iter==keyframe_list.end())
+               throw std::runtime_error(_("Unable to find Keyframe in table"));
+       return row;
+}
+
+void
+KeyframeTreeStore::add_keyframe(synfig::Keyframe keyframe)
+{
+       try
+       {
+               Gtk::TreeRow row(find_row(keyframe));
+               dump_iterator(row.gobj(),"add_keyframe,row");
+               Gtk::TreePath path(get_path(row));
+
+               row_inserted(path,row);
+
+               old_keyframe_list=get_canvas()->keyframe_list();
+               //old_keyframe_list.add(keyframe);
+               //old_keyframe_list.sort();
+       }
+       catch(std::exception x)
+       {
+               g_warning("%s", x.what());
+       }
+}
+
+void
+KeyframeTreeStore::remove_keyframe(synfig::Keyframe keyframe)
+{
+       try
+       {
+               if(1)
+               {
+                       Gtk::TreeRow row(find_row(keyframe));
+                       dump_iterator(row,"remove_keyframe,row");
+                       Gtk::TreePath path(get_path(row));
+                       row_deleted(path);
+
+                       old_keyframe_list.erase(keyframe);
+               }
+               else
+               {
+                       g_warning("KeyframeTreeStore::remove_keyframe: Keyframe not in table");
+               }
+       }
+       catch(std::exception x)
+       {
+               g_warning("%s", x.what());
+       }
+}
+
+void
+KeyframeTreeStore::change_keyframe(synfig::Keyframe keyframe)
+{
+       try
+       {
+               Gtk::TreeRow row(find_row(keyframe));
+
+               unsigned int new_index(get_index_from_model_iter(row));
+               unsigned int old_index(0);
+               synfig::KeyframeList::iterator iter;
+               for(old_index=0,iter=old_keyframe_list.begin();iter!=old_keyframe_list.end() && (UniqueID)*iter!=(UniqueID)keyframe;++iter,old_index++)
+                       ;
+
+               if(iter!=old_keyframe_list.end() && new_index!=old_index)
+               {
+                       std::vector<int> new_order;
+                       for(unsigned int i=0;i<old_keyframe_list.size();i++)
+                       {
+                               new_order.push_back(i);
+                       }
+                       if(new_order.size()>new_index)
+                       {
+                               new_order.erase(new_order.begin()+new_index);
+                               new_order.insert(new_order.begin()+old_index,new_index);
+
+                               //new_order[old_index]=
+
+                               rows_reordered (Path(), iterator(), &new_order[0]);
+                       }
+                       old_keyframe_list=get_canvas()->keyframe_list();
+
+                       row=find_row(keyframe);
+               }
+
+               dump_iterator(row,"change_keyframe,row");
+               row_changed(get_path(row),row);
+       }
+       catch(std::exception x)
+       {
+               g_warning("%s", x.what());
+       }
+}
diff --git a/synfig-studio/src/gui/keyframetreestore.h b/synfig-studio/src/gui/keyframetreestore.h
new file mode 100644 (file)
index 0000000..c3efccf
--- /dev/null
@@ -0,0 +1,224 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file keyframetreestore.h
+**     \brief Template Header
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_STUDIO_KEYFRAMETREESTORE_H
+#define __SYNFIG_STUDIO_KEYFRAMETREESTORE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/liststore.h>
+#include <synfigapp/canvasinterface.h>
+#include <gdkmm/pixbuf.h>
+#include <synfig/keyframe.h>
+#include <map>
+
+/* === 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 ======================================= */
+
+//class TreeRowReferenceHack;
+//#define TreeRowReferenceHack Gtk::TreeRowReference
+
+namespace studio {
+
+class KeyframeTreeStore_Class;
+
+class KeyframeTreeStore :
+       public Glib::Object,
+       public Gtk::TreeModel,
+       public Gtk::TreeDragSource,
+       public Gtk::TreeDragDest
+{
+       /*
+ -- ** -- P U B L I C   T Y P E S ---------------------------------------------
+       */
+
+public:
+
+       class Model : public Gtk::TreeModel::ColumnRecord
+       {
+       public:
+               Gtk::TreeModelColumn<synfig::Time> time;
+               Gtk::TreeModelColumn<Glib::ustring> description;
+               Gtk::TreeModelColumn<synfig::Keyframe> keyframe;
+               Gtk::TreeModelColumn<synfig::Time> time_delta;
+
+               Model()
+               {
+                       add(time);
+                       add(description);
+                       add(keyframe);
+                       add(time_delta);
+               }
+       };
+
+       /*
+ -- ** -- P U B L I C  D A T A ------------------------------------------------
+       */
+
+public:
+
+       const Model model;
+
+       /*
+ -- ** -- P R I V A T E   D A T A ---------------------------------------------
+       */
+
+private:
+
+       etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
+
+       //! Unique stamp for this TreeModel.
+       int stamp_;
+
+       static KeyframeTreeStore_Class keyframe_tree_store_class_;
+
+       //std::map<synfig::Keyframe,TreeRowReferenceHack> path_table_;
+
+       synfig::KeyframeList old_keyframe_list;
+
+       /*
+ -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
+       */
+
+private:
+
+       void add_keyframe(synfig::Keyframe);
+
+       void remove_keyframe(synfig::Keyframe);
+
+       void change_keyframe(synfig::Keyframe);
+
+       static int sorter(const Gtk::TreeModel::iterator &,const Gtk::TreeModel::iterator &);
+
+       bool iterator_sane(const GtkTreeIter* iter)const;
+
+       bool iterator_sane(const Gtk::TreeModel::iterator& iter)const;
+
+       void dump_iterator(const GtkTreeIter* iter, const Glib::ustring &name)const;
+
+       void dump_iterator(const Gtk::TreeModel::iterator& iter, const Glib::ustring &name)const;
+
+       //! Resets the iterator stamp for this model.
+       /*!     This should be called whenever the class is
+       **      constructed     or when large numbers of
+       **      iterators become invalid. */
+       void reset_stamp();
+
+       //void reset_path_table();
+
+       /*
+ -- ** -- V I R T U A L   F U N C T I O N S -----------------------------------
+       */
+
+protected:
+
+       virtual void set_value_impl (const Gtk::TreeModel::iterator& row, int column, const Glib::ValueBase& value);
+       virtual Gtk::TreeModelFlags  get_flags_vfunc ();
+       virtual int  get_n_columns_vfunc ();
+       virtual GType  get_column_type_vfunc (int index);
+       virtual bool iter_next_vfunc (const iterator& iter, iterator& iter_next) const;
+       virtual bool  get_iter_vfunc (const Gtk::TreeModel::Path& path, iterator& iter_next)const;
+       virtual bool  iter_nth_root_child_vfunc (int n, iterator& iter)const;
+       virtual Gtk::TreeModel::Path  get_path_vfunc (const iterator& iter)const;
+       virtual void  ref_node_vfunc (iterator& iter)const;
+       virtual void  unref_node_vfunc (iterator& iter)const;
+       virtual void  get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const;
+       virtual bool    iter_is_valid (const iterator& iter) const;
+       virtual int     iter_n_root_children_vfunc () const;
+
+       //virtual bool  iter_nth_child_vfunc (GtkTreeIter* iter, const GtkTreeIter* parent, int n);
+       //virtual bool  iter_children_vfunc (GtkTreeIter* iter, const GtkTreeIter* parent);
+       //virtual bool  iter_has_child_vfunc (const GtkTreeIter* iter);
+       //virtual int  iter_n_children_vfunc (const GtkTreeIter* iter);
+       //virtual bool  iter_parent_vfunc (GtkTreeIter* iter, const GtkTreeIter* child);
+
+       /*
+       virtual bool  get_sort_column_id_vfunc (int* sort_column_id, Gtk::SortType* order);
+       virtual void  set_sort_column_id_vfunc (int sort_column_id, Gtk::SortType order);
+       virtual void  set_sort_func_vfunc (int sort_column_id, GtkTreeIterCompareFunc func, void* data, GtkDestroyNotify destroy);
+       virtual void  set_default_sort_func_vfunc (GtkTreeIterCompareFunc func, void* data, GtkDestroyNotify destroy);
+       virtual bool  has_default_sort_func_vfunc ();
+       */
+
+       /*
+ -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
+       */
+
+private:
+
+       /*
+ -- ** -- P U B L I C   M E T H O D S -----------------------------------------
+       */
+
+public:
+
+       KeyframeTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
+       ~KeyframeTreeStore();
+
+       etl::loose_handle<synfigapp::CanvasInterface> canvas_interface() { return canvas_interface_; }
+       etl::loose_handle<const synfigapp::CanvasInterface> canvas_interface()const { return canvas_interface_; }
+
+       synfig::Canvas::Handle get_canvas() { return canvas_interface()->get_canvas(); }
+       synfig::Canvas::Handle get_canvas()const { return canvas_interface()->get_canvas(); }
+
+       Gtk::TreeModel::Row find_row(const synfig::Keyframe &keyframe);
+
+       /*
+ -- ** -- S T A T I C  M E T H O D S ------------------------------------------
+       */
+
+public:
+
+       static Glib::RefPtr<KeyframeTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
+
+       static int time_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs);
+       static int description_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs);
+
+}; // END of class KeyframeTreeStore
+
+//! \internal
+class KeyframeTreeStore_Class : public Glib::Class
+{
+public:
+       struct KeyframeTreeStoreClass
+       {
+               GObjectClass parent_class;
+       };
+
+       friend class KeyframeTreeStore;
+
+       const Glib::Class& init();
+
+       static void class_init_function(gpointer g_blass, gpointer class_data);
+}; // END of CustomTreeStore_Class
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/keymapsettings.cpp b/synfig-studio/src/gui/keymapsettings.cpp
new file mode 100644 (file)
index 0000000..787b054
--- /dev/null
@@ -0,0 +1,113 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file keymapsettings.cpp
+**     \brief Contains Info for Key Map settings
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "keymapsettings.h"
+
+#include <gtkmm/accelkey.h>
+#include <gtkmm/accelmap.h>
+#include <gtk/gtkaccelmap.h>
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+//using namespace etl;
+//using namespace synfig;
+using namespace studio;
+
+using namespace Gtk;
+//using namespace Gtk::Menu_Helpers;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+/* === E N T R Y P O I N T ================================================= */
+
+// KeyMapSettings Definitions
+KeyMapSettings::KeyMapSettings()
+{
+}
+
+KeyMapSettings::~KeyMapSettings()
+{
+}
+
+bool KeyMapSettings::set_key(const char *path, guint key, Gdk::ModifierType mod, bool replace)
+{
+       if(gtk_accel_map_lookup_entry(path,NULL))
+       {
+               return AccelMap::change_entry(path,key,mod,replace);
+       }else
+       {
+               AccelMap::add_entry(path,key,mod);
+               return true;
+       }
+}
+
+bool KeyMapSettings::get_key(const char *path, Gtk::AccelKey *key)
+{
+       GtkAccelKey     ac;
+       if(gtk_accel_map_lookup_entry(path,&ac))
+       {
+               *key = AccelKey(ac.accel_key,(Gdk::ModifierType)ac.accel_mods,string(path));
+               return true;
+       }
+
+       return false;
+}
+
+bool KeyMapSettings::load(const char *filename)
+{
+       string n(filename);
+       n += ".skm";
+
+       AccelMap::load(filename);
+
+       return true;
+}
+
+bool KeyMapSettings::save(const char *filename)
+{
+       string n(filename);
+       n += ".skm";
+
+       AccelMap::save(filename);
+
+       return true;
+}
diff --git a/synfig-studio/src/gui/keymapsettings.h b/synfig-studio/src/gui/keymapsettings.h
new file mode 100644 (file)
index 0000000..f216095
--- /dev/null
@@ -0,0 +1,83 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file keymapsettings.h
+**     \brief Defines the structures for managing key map settings
+**
+**     $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_KEYMAPSETTINGS_H
+#define __SYNFIG_KEYMAPSETTINGS_H
+
+/* === H E A D E R S ======================================================= */
+#include <gtkmm/dialog.h>
+
+#include <set>
+#include <map>
+#include <string>
+
+#include <gtkmm/accelkey.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 {
+
+//a dialog for viewing and setting options, though it can also be used just as is
+class KeyMapSettings : public Gtk::Dialog
+{
+       struct AcKeyInfo
+       {
+               guint                           key;
+               Gdk::ModifierType       mod;
+
+               bool                            on;
+
+               AcKeyInfo(guint k = 0, Gdk::ModifierType m = Gdk::ModifierType())
+               :key(k),mod(m) {}
+       };
+
+       //std::map<const char *,AcKeyInfo>      pathmap; //uses string info from paths set
+       //std::set<std::string>                         accelpaths;
+
+       bool unsaved; //Assume as such...
+
+public:
+
+       KeyMapSettings();
+       ~KeyMapSettings();
+
+       //void add_path(const char *path);
+
+       bool set_key(const char *path, guint key, Gdk::ModifierType mod, bool replace = true);
+       bool get_key(const char *path, Gtk::AccelKey *key);
+
+       // These files must be sent a filename without extension (so the key map can be obtained)
+       bool load(const char *filename);
+       bool save(const char *filename);
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/layeractionmanager.cpp b/synfig-studio/src/gui/layeractionmanager.cpp
new file mode 100644 (file)
index 0000000..c3a3be4
--- /dev/null
@@ -0,0 +1,524 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file layeractionmanager.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 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 <config.h>
+#endif
+
+#include "layeractionmanager.h"
+#include "layertree.h"
+#include <synfig/context.h>
+#include <synfig/layer_pastecanvas.h>
+#include <synfigapp/action_param.h>
+#include "instance.h"
+#include <synfigapp/selectionmanager.h>
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+using namespace studio;
+
+static const guint no_prev_popup((guint)-1);
+
+/* === M A C R O S ========================================================= */
+
+//#define ONE_ACTION_GROUP 1
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+LayerActionManager::LayerActionManager():
+       action_group_(Gtk::ActionGroup::create("action_group_layer_action_manager")),
+       popup_id_(no_prev_popup),
+       action_group_copy_paste(Gtk::ActionGroup::create("action_group_copy_paste")),
+       queued(false)
+{
+       action_cut_=Gtk::Action::create(
+               "cut",
+               Gtk::StockID("gtk-cut")
+       );
+       action_cut_->signal_activate().connect(
+               sigc::mem_fun(
+                       *this,
+                       &LayerActionManager::cut
+               )
+       );
+       action_copy_=Gtk::Action::create(
+               "copy",
+               Gtk::StockID("gtk-copy")
+       );
+       action_copy_->signal_activate().connect(
+               sigc::mem_fun(
+                       *this,
+                       &LayerActionManager::copy
+               )
+       );
+       action_paste_=Gtk::Action::create(
+               "paste",
+               Gtk::StockID("gtk-paste")
+       );
+       action_paste_->signal_activate().connect(
+               sigc::mem_fun(
+                       *this,
+                       &LayerActionManager::paste
+               )
+       );
+
+
+       action_amount_inc_=Gtk::Action::create(
+               "amount-inc",
+               Gtk::StockID("gtk-add"),
+               _("Increase Amount"),_("Increase Amount")
+       );
+       action_amount_inc_->signal_activate().connect(
+               sigc::mem_fun(
+                       *this,
+                       &LayerActionManager::amount_inc
+               )
+       );
+
+       action_amount_dec_=Gtk::Action::create(
+               "amount-dec",
+               Gtk::StockID("gtk-remove"),
+               _("Decrease Amount"),_("Decrease Amount")
+       );
+       action_amount_dec_->signal_activate().connect(
+               sigc::mem_fun(
+                       *this,
+                       &LayerActionManager::amount_dec
+               )
+       );
+
+       action_amount_=Gtk::Action::create(
+               "amount",
+               Gtk::StockID("gtk-index"),
+               _("Amount"),_("Amount")
+       );
+
+       action_select_all_child_layers_=Gtk::Action::create(
+               "select-all-child-layers",
+               Gtk::StockID("synfig-select_all_child_layers"),
+               _("Select All Child Layers"),_("Select All Child Layers")
+       );
+       action_select_all_child_layers_->set_sensitive(false);
+}
+
+LayerActionManager::~LayerActionManager()
+{
+}
+
+void
+LayerActionManager::set_ui_manager(const Glib::RefPtr<Gtk::UIManager> &x)
+{
+       clear();
+
+#ifdef ONE_ACTION_GROUP
+       if(ui_manager_) get_ui_manager()->remove_action_group(action_group_);
+       ui_manager_=x;
+       if(ui_manager_) get_ui_manager()->insert_action_group(action_group_);
+#else
+       ui_manager_=x;
+#endif
+}
+
+void
+LayerActionManager::set_layer_tree(LayerTree* x)
+{
+       selection_changed_connection.disconnect();
+       layer_tree_=x;
+       if(layer_tree_)
+       {
+               selection_changed_connection=layer_tree_->get_selection()->signal_changed().connect(
+                       sigc::mem_fun(*this,&LayerActionManager::queue_refresh)
+               );
+       }
+}
+
+void
+LayerActionManager::set_canvas_interface(const etl::handle<synfigapp::CanvasInterface> &x)
+{
+       canvas_interface_=x;
+}
+
+void
+LayerActionManager::clear()
+{
+       if(ui_manager_)
+       {
+               // Clear out old stuff
+               if(popup_id_!=no_prev_popup)
+               {
+                       get_ui_manager()->remove_ui(popup_id_);
+                       if(action_group_)get_ui_manager()->ensure_update();
+                       popup_id_=no_prev_popup;
+                       if(action_group_)while(!action_group_->get_actions().empty())action_group_->remove(*action_group_->get_actions().begin());
+#ifdef ONE_ACTION_GROUP
+#else
+                       if(action_group_)get_ui_manager()->remove_action_group(action_group_);
+                       action_group_=Gtk::ActionGroup::create("action_group_layer_action_manager");
+#endif
+               }
+       }
+
+       while(!update_connection_list.empty())
+       {
+               update_connection_list.front().disconnect();
+               update_connection_list.pop_front();
+       }
+}
+
+void
+LayerActionManager::queue_refresh()
+{
+       if(queued)
+               return;
+
+       //queue_refresh_connection.disconnect();
+       queue_refresh_connection=Glib::signal_idle().connect(
+               sigc::bind_return(
+                       sigc::mem_fun(*this,&LayerActionManager::refresh),
+                       false
+               )
+       );
+
+       queued=true;
+}
+
+void
+LayerActionManager::refresh()
+{
+       if(queued)
+       {
+               queued=false;
+               //queue_refresh_connection.disconnect();
+       }
+
+
+       clear();
+
+       // Make sure we are ready
+       if(!ui_manager_ || !layer_tree_ || !canvas_interface_)
+       {
+               synfig::error("LayerActionManager::refresh(): Not ready!");
+               return;
+       }
+
+       String ui_info;
+
+       action_paste_->set_sensitive(!clipboard_.empty());
+       action_group_->add(action_paste_);
+
+       if(layer_tree_->get_selection()->count_selected_rows()!=0)
+       {
+               bool multiple_selected(layer_tree_->get_selection()->count_selected_rows()>1);
+               Layer::Handle layer(layer_tree_->get_selected_layer());
+
+               {
+                       bool canvas_set(false);
+                       synfigapp::Action::ParamList param_list;
+                       param_list.add("time",get_canvas_interface()->get_time());
+                       param_list.add("canvas_interface",get_canvas_interface());
+                       {
+                               synfigapp::SelectionManager::LayerList layer_list(layer_tree_->get_selected_layers());
+                               synfigapp::SelectionManager::LayerList::iterator iter;
+                               action_copy_->set_sensitive(!layer_list.empty());
+                               action_cut_->set_sensitive(!layer_list.empty());
+                               action_group_->add(action_copy_);
+                               action_group_->add(action_cut_);
+
+                               action_amount_inc_->set_sensitive(!layer_list.empty());
+                               action_amount_dec_->set_sensitive(!layer_list.empty());
+                               action_amount_->set_sensitive(!layer_list.empty());
+                               action_group_->add(action_amount_inc_);
+                               action_group_->add(action_amount_dec_);
+                               action_group_->add(action_amount_);
+
+                               for(iter=layer_list.begin();iter!=layer_list.end();++iter)
+                               {
+                                       update_connection_list.push_back(
+                                               (*iter)->signal_changed().connect(
+                                                       sigc::mem_fun(*this, &LayerActionManager::queue_refresh)
+                                               )
+                                       );
+
+                                       if(!canvas_set)
+                                       {
+                                               param_list.add("canvas",Canvas::Handle((*iter)->get_canvas()));
+                                               canvas_set=true;
+                                               update_connection_list.push_back(
+                                                       (*iter)->get_canvas()->signal_changed().connect(
+                                                               sigc::mem_fun(*this, &LayerActionManager::queue_refresh)
+                                                       )
+                                               );
+                                       }
+                                       param_list.add("layer",Layer::Handle(*iter));
+                               }
+                       }
+
+                       if(!multiple_selected && layer->get_name()=="PasteCanvas")
+                       {
+                               if (select_all_child_layers_connection)
+                                       select_all_child_layers_connection.disconnect();
+
+                               select_all_child_layers_connection = action_select_all_child_layers_->signal_activate().connect(
+                                       sigc::bind(sigc::mem_fun(*layer_tree_,
+                                                                                        &studio::LayerTree::select_all_children_layers),
+                                                          Layer::LooseHandle(layer)));
+
+                               action_select_all_child_layers_->set_sensitive(true);
+
+                               ui_info+="<menuitem action='select-all-child-layers'/>";
+                       }
+                       else
+                               action_select_all_child_layers_->set_sensitive(false);
+
+                       handle<studio::Instance>::cast_static(get_canvas_interface()->get_instance())->
+                               add_actions_to_group(action_group_, ui_info,   param_list, synfigapp::Action::CATEGORY_LAYER);
+               }
+       }
+
+       ui_info=("<ui>"
+                          "<popup action='menu-main'>"
+                            "<menu action='menu-layer'>" +
+                                  ui_info +
+                                  "<separator/>"
+                              "<menuitem action='cut' />"
+                                  "<menuitem action='copy' />"
+                                  "<menuitem action='paste' />"
+                                  "<separator/>"
+                            "</menu>"
+                          "</popup>" +
+                        "</ui>");
+       popup_id_=get_ui_manager()->add_ui_from_string(ui_info);
+#ifdef ONE_ACTION_GROUP
+#else
+       get_ui_manager()->insert_action_group(action_group_);
+#endif
+}
+
+void
+LayerActionManager::cut()
+{
+       copy();
+       if(action_group_->get_action("action-LayerRemove"))
+               action_group_->get_action("action-LayerRemove")->activate();
+}
+
+void
+LayerActionManager::copy()
+{
+       synfigapp::SelectionManager::LayerList layer_list(layer_tree_->get_selected_layers());
+       clipboard_.clear();
+       synfig::GUID guid;
+
+       while(!layer_list.empty())
+       {
+               clipboard_.push_back(layer_list.front()->clone(guid));
+               layer_list.pop_front();
+       }
+
+       action_paste_->set_sensitive(!clipboard_.empty());
+
+       //queue_refresh();
+}
+
+void
+LayerActionManager::paste()
+{
+       synfig::GUID guid;
+
+       // Create the action group
+       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Paste"));
+
+       Canvas::Handle canvas(get_canvas_interface()->get_canvas());
+       int depth(0);
+
+       // we are temporarily using the layer to hold something
+       Layer::Handle layer(layer_tree_->get_selected_layer());
+       if(layer)
+       {
+               depth=layer->get_depth();
+               canvas=layer->get_canvas();
+       }
+
+       synfigapp::SelectionManager::LayerList layer_selection;
+
+       for(std::list<synfig::Layer::Handle>::iterator iter=clipboard_.begin();iter!=clipboard_.end();++iter)
+       {
+               layer=(*iter)->clone(guid);
+               layer_selection.push_back(layer);
+               synfigapp::Action::Handle       action(synfigapp::Action::create("LayerAdd"));
+
+               assert(action);
+               if(!action)
+                       return;
+
+               action->set_param("canvas",canvas);
+               action->set_param("canvas_interface",etl::loose_handle<synfigapp::CanvasInterface>(get_canvas_interface()));
+               action->set_param("new",layer);
+
+               if(!action->is_ready())
+               {
+                       return;
+               }
+
+               if(!get_instance()->perform_action(action))
+               {
+                       return;
+               }
+
+               etl::handle<Layer_PasteCanvas> paste = etl::handle<Layer_PasteCanvas>::cast_dynamic(layer);
+               if (paste) paste->update_renddesc();
+
+               // synfig::info("DEPTH=%d",depth);
+
+               // Action to move the layer (if necessary)
+               if(depth>0)
+               {
+                       synfigapp::Action::Handle       action(synfigapp::Action::create("LayerMove"));
+
+                       assert(action);
+                       if(!action)
+                               return;
+
+                       action->set_param("canvas",canvas);
+                       action->set_param("canvas_interface",etl::loose_handle<synfigapp::CanvasInterface>(get_canvas_interface()));
+                       action->set_param("layer",layer);
+                       action->set_param("new_index",depth);
+
+                       if(!action->is_ready())
+                       {
+                               //get_ui_interface()->error(_("Move Action Not Ready"));
+                               //return 0;
+                               return;
+                       }
+
+                       if(!get_instance()->perform_action(action))
+                       {
+                               //get_ui_interface()->error(_("Move Action Not Ready"));
+                               //return 0;
+                               return;
+                       }
+               }
+               depth++;
+
+               // automatically export the Index parameter of Duplicate layers when pasting
+               int index = 1;
+               export_dup_nodes(layer, canvas, index);
+       }
+       get_canvas_interface()->get_selection_manager()->clear_selected_layers();
+       get_canvas_interface()->get_selection_manager()->set_selected_layers(layer_selection);
+}
+
+void
+LayerActionManager::export_dup_nodes(synfig::Layer::Handle layer, Canvas::Handle canvas, int &index)
+{
+       // automatically export the Index parameter of Duplicate layers when pasting
+       if (layer->get_name() == "duplicate")
+               while (true)
+               {
+                       String name = strprintf(_("Index %d"), index++);
+                       try
+                       {
+                               canvas->find_value_node(name);
+                       }
+                       catch (Exception::IDNotFound x)
+                       {
+                               get_canvas_interface()->add_value_node(layer->dynamic_param_list().find("index")->second, name);
+                               break;
+                       }
+               }
+       else
+       {
+               Layer::ParamList param_list(layer->get_param_list());
+               for (Layer::ParamList::const_iterator iter(param_list.begin())
+                                ; iter != param_list.end()
+                                ; iter++)
+                       if (layer->dynamic_param_list().count(iter->first)==0 && iter->second.get_type()==ValueBase::TYPE_CANVAS)
+                       {
+                               Canvas::Handle subcanvas(iter->second.get(Canvas::Handle()));
+                               if (subcanvas && subcanvas->is_inline())
+                                       for (Context iter = subcanvas->get_context(); iter != subcanvas->end(); iter++)
+                                               export_dup_nodes(*iter, canvas, index);
+                       }
+
+               for (Layer::DynamicParamList::const_iterator iter(layer->dynamic_param_list().begin())
+                                ; iter != layer->dynamic_param_list().end()
+                                ; iter++)
+                       if (iter->second->get_type()==ValueBase::TYPE_CANVAS)
+                       {
+                               Canvas::Handle canvas((*iter->second)(0).get(Canvas::Handle()));
+                               if (canvas->is_inline())
+                                       //! \todo do we need to implement this?  and if so, shouldn't we check all canvases, not just the one at t=0s?
+                                       warning("%s:%d not yet implemented - do we need to export duplicate valuenodes in dynamic canvas parameters?", __FILE__, __LINE__);
+                       }
+       }
+}
+
+void
+LayerActionManager::amount_inc()
+{
+       float adjust(0.1);
+
+       // Create the action group
+       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Increase Amount"));
+       synfigapp::SelectionManager::LayerList layer_list(layer_tree_->get_selected_layers());
+
+       for (; !layer_list.empty(); layer_list.pop_front())
+       {
+               ValueBase value(layer_list.front()->get_param("amount"));
+               if(value.same_type_as(Real()))
+                       get_canvas_interface()->change_value(synfigapp::ValueDesc(layer_list.front(),"amount"),value.get(Real())+adjust);
+       }
+}
+
+void
+LayerActionManager::amount_dec()
+{
+       float adjust(-0.1);
+
+       // Create the action group
+       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Decrease Amount"));
+       synfigapp::SelectionManager::LayerList layer_list(layer_tree_->get_selected_layers());
+
+       for (; !layer_list.empty(); layer_list.pop_front())
+       {
+               ValueBase value(layer_list.front()->get_param("amount"));
+               if(value.same_type_as(Real()))
+                       get_canvas_interface()->change_value(synfigapp::ValueDesc(layer_list.front(),"amount"),value.get(Real())+adjust);
+       }
+}
diff --git a/synfig-studio/src/gui/layeractionmanager.h b/synfig-studio/src/gui/layeractionmanager.h
new file mode 100644 (file)
index 0000000..91c400f
--- /dev/null
@@ -0,0 +1,112 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file layeractionmanager.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_LAYER_ACTION_MANAGER_H
+#define __SYNFIG_LAYER_ACTION_MANAGER_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/uimanager.h>
+#include <gtkmm/treeview.h>
+#include <synfigapp/canvasinterface.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 LayerTree;
+
+class LayerActionManager
+{
+       Glib::RefPtr<Gtk::UIManager> ui_manager_;
+       //Glib::RefPtr<Gtk::TreeSelection> tree_selection_;
+       LayerTree* layer_tree_;
+       etl::handle<synfigapp::CanvasInterface> canvas_interface_;
+
+       Glib::RefPtr<Gtk::ActionGroup>  action_group_;
+       Gtk::UIManager::ui_merge_id     popup_id_;
+
+
+       Glib::RefPtr<Gtk::ActionGroup> action_group_copy_paste;
+
+       Glib::RefPtr<Gtk::Action>       action_cut_;
+       Glib::RefPtr<Gtk::Action>       action_copy_;
+       Glib::RefPtr<Gtk::Action>       action_paste_;
+
+       Glib::RefPtr<Gtk::Action>       action_amount_inc_;
+       Glib::RefPtr<Gtk::Action>       action_amount_dec_;
+       Glib::RefPtr<Gtk::Action>       action_amount_;
+
+       Glib::RefPtr<Gtk::Action>       action_select_all_child_layers_;
+       sigc::connection                        select_all_child_layers_connection;
+
+       std::list<synfig::Layer::Handle> clipboard_;
+
+       sigc::connection selection_changed_connection;
+
+       bool queued;
+       sigc::connection queue_refresh_connection;
+
+       std::list<sigc::connection> update_connection_list;
+
+       void cut();
+       void copy();
+       void paste();
+       void export_dup_nodes(synfig::Layer::Handle, synfig::Canvas::Handle, int &);
+
+       void amount_inc();
+       void amount_dec();
+
+public:
+       void queue_refresh();
+
+       LayerActionManager();
+       ~LayerActionManager();
+
+       void set_ui_manager(const Glib::RefPtr<Gtk::UIManager> &x);
+       Glib::RefPtr<Gtk::UIManager> get_ui_manager()const { return ui_manager_; }
+
+       void set_layer_tree(LayerTree* x);
+       LayerTree* get_layer_tree()const { return layer_tree_; }
+
+       void set_canvas_interface(const etl::handle<synfigapp::CanvasInterface> &x);
+       etl::handle<synfigapp::CanvasInterface> get_canvas_interface()const { return canvas_interface_; }
+
+       etl::loose_handle<synfigapp::Instance> get_instance()const { return canvas_interface_->get_instance(); }
+
+       void refresh();
+       void clear();
+
+       Glib::RefPtr<Gtk::Action> get_action_select_all_child_layers() { return action_select_all_child_layers_; }
+}; // END of LayerActionManager
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/layergrouptree.cpp b/synfig-studio/src/gui/layergrouptree.cpp
new file mode 100644 (file)
index 0000000..3dd323e
--- /dev/null
@@ -0,0 +1,334 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file layergrouptree.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 <config.h>
+#endif
+
+#include <synfig/layer.h>
+#include "layergrouptree.h"
+#include <gtkmm/treemodelsort.h>
+#include <ETL/misc>
+
+#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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+LayerGroupTree::LayerGroupTree()
+{
+       const LayerGroupTreeStore::Model model;
+
+
+       {       // --- O N / O F F ----------------------------------------------------
+               int index;
+               index=append_column_editable(_(" "),model.active);
+               //Gtk::TreeView::Column* column = get_column(index-1);
+       }
+       {       // --- I C O N --------------------------------------------------------
+               int index;
+               index=append_column(_(" "),model.icon);
+               Gtk::TreeView::Column* column = get_column(index-1);
+               set_expander_column(*column);
+       }
+       {       // --- N A M E --------------------------------------------------------
+               int index;
+               index=append_column_editable(_("Name"),model.label);
+               label_column = get_column(index-1);
+
+               //column->set_sort_column(layer_model.index);
+
+               //set_expander_column(*column);
+               //column->set_reorderable();
+               //column->set_resizable();
+               //column->set_clickable(false);
+
+               //Gtk::CellRendererPixbuf* icon_cellrenderer = Gtk::manage( new Gtk::CellRendererPixbuf() );
+               //column->pack_start(*icon_cellrenderer,false);
+               //column->add_attribute(icon_cellrenderer->property_pixbuf(), layer_model.icon);
+       }
+
+       set_enable_search(true);
+       set_search_column(model.label);
+       set_search_equal_func(sigc::ptr_fun(&studio::LayerGroupTreeStore::search_func));
+
+       // This makes things easier to read.
+       set_rules_hint();
+
+       // Make us more sensitive to several events
+       add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::BUTTON1_MOTION_MASK | Gdk::BUTTON2_MOTION_MASK|Gdk::POINTER_MOTION_MASK);
+
+       set_reorderable(true);
+
+       get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
+
+       //set_flags(get_flags()|Gtk::RECEIVES_DEFAULT|Gtk::HAS_GRAB);
+
+       //std::list<Gtk::TargetEntry> listTargets;
+       //listTargets.push_back( Gtk::TargetEntry("LAYER") );
+       //listTargets.push_back( Gtk::TargetEntry("GROUP") );
+       //drag_dest_set(listTargets);
+}
+
+LayerGroupTree::~LayerGroupTree()
+{
+       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
+               synfig::info("LayerGroupTree::~LayerGroupTree(): Deleted");
+}
+
+void
+LayerGroupTree::set_model(Glib::RefPtr<LayerGroupTreeStore> layer_group_tree_store)
+{
+       layer_group_tree_store_=layer_group_tree_store;
+       LayerGroupTreeStore::Model model;
+
+#if 0
+       {
+               Glib::RefPtr<Gtk::TreeModelSort> sorted_store(Gtk::TreeModelSort::create(layer_group_tree_store_));
+               sorted_store->set_default_sort_func(sigc::ptr_fun(&studio::LayerGroupTreeStore::time_sorter));
+               sorted_store->set_sort_func(model.time.index(),sigc::ptr_fun(&studio::LayerGroupTreeStore::time_sorter));
+               sorted_store->set_sort_column(model.time.index(), Gtk::SORT_ASCENDING);
+               Gtk::TreeView::set_model(sorted_store);
+       }
+#else
+               Gtk::TreeView::set_model(layer_group_tree_store);
+#endif
+}
+
+void
+LayerGroupTree::set_editable(bool x)
+{
+       editable_=x;
+/*
+       if(editable_)
+       {
+               cell_renderer_time->property_editable()=true;
+               cell_renderer_time_delta->property_editable()=true;
+               cell_renderer_description->property_editable()=true;
+       }
+       else
+       {
+               cell_renderer_time->property_editable()=false;
+               cell_renderer_time_delta->property_editable()=false;
+               cell_renderer_description->property_editable()=false;
+       }
+*/
+}
+/*
+void
+LayerGroupTree::on_edited_time(const Glib::ustring&path_string,synfig::Time time)
+{
+       Gtk::TreePath path(path_string);
+
+       const Gtk::TreeRow row(*(get_model()->get_iter(path)));
+
+       synfig::Keyframe keyframe(row[model.keyframe]);
+       if(time!=keyframe.get_time())
+       {
+               row[model.time]=time;
+               //keyframe.set_time(time);
+               //signal_edited_time()(keyframe,time);
+               //signal_edited()(keyframe);
+       }
+}
+
+void
+LayerGroupTree::on_edited_time_delta(const Glib::ustring&path_string,synfig::Time time)
+{
+       Gtk::TreePath path(path_string);
+
+       const Gtk::TreeRow row(*(get_model()->get_iter(path)));
+
+       if(row)row[model.time_delta]=time;
+}
+
+void
+LayerGroupTree::on_edited_description(const Glib::ustring&path_string,const Glib::ustring &desc)
+{
+       Gtk::TreePath path(path_string);
+
+       const Gtk::TreeRow row = *(get_model()->get_iter(path));
+
+       const synfig::String description(desc);
+       synfig::Keyframe keyframe(row[model.keyframe]);
+       if(description!=keyframe.get_description())
+       {
+               row[model.description]=desc;
+               keyframe.set_description(description);
+               signal_edited_description()(keyframe,description);
+               signal_edited()(keyframe);
+       }
+}
+*/
+
+bool
+LayerGroupTree::on_event(GdkEvent *event)
+{
+    switch(event->type)
+    {
+       case GDK_BUTTON_PRESS:
+               {
+                       Gtk::TreeModel::Path path;
+                       Gtk::TreeViewColumn *column;
+                       int cell_x, cell_y;
+                       int wx(round_to_int(event->button.x)),wy(round_to_int(event->button.y));
+                       //tree_to_widget_coords (,, wx, wy);
+                       if(!get_path_at_pos(
+                               wx,wy,  // x, y
+                               path, // TreeModel::Path&
+                               column, //TreeViewColumn*&
+                               cell_x,cell_y //int&cell_x,int&cell_y
+                               )
+                       ) break;
+                       const Gtk::TreeRow row = *(get_model()->get_iter(path));
+
+                       if(row[model.is_layer] && event->button.button==3)
+                       {
+                               signal_popup_layer_menu()((Layer::Handle)row[model.layer]);
+                               return true;
+                       }
+
+                       /*signal_user_click()(event->button.button,row,(ColumnID)column->get_sort_column_id());
+                       if((ColumnID)column->get_sort_column_id()==COLUMNID_JUMP)
+                       {
+                               layer_group_tree_store_->canvas_interface()->set_time(row[model.time]);
+                       }*/
+               }
+               break;
+       case GDK_2BUTTON_PRESS:
+               {
+                       Gtk::TreeModel::Path path;
+                       Gtk::TreeViewColumn *column;
+                       int cell_x, cell_y;
+                       if(!get_path_at_pos(
+                               int(event->button.x),int(event->button.y),      // x, y
+                               path, // TreeModel::Path&
+                               column, //TreeViewColumn*&
+                               cell_x,cell_y //int&cell_x,int&cell_y
+                               )
+                       ) break;
+                       const Gtk::TreeRow row = *(get_model()->get_iter(path));
+
+                       LayerList layer_list(row[model.all_layers]);
+                       if(!layer_list.empty())
+                       {
+                               if(!(event->button.state&GDK_CONTROL_MASK))
+                               {
+                                       layer_group_tree_store_->canvas_interface()->get_selection_manager()->clear_selected_layers();
+                               }
+                               layer_group_tree_store_->canvas_interface()->get_selection_manager()->set_selected_layers(layer_list);
+                               return true;
+                       }
+               }
+               break;
+       case GDK_BUTTON_RELEASE:
+               break;
+       default:
+               break;
+       }
+       return Gtk::TreeView::on_event(event);
+       //return false;
+}
+
+static inline void __group_grabber(const Gtk::TreeModel::iterator& iter, std::list<synfig::String>* ret)
+{
+       const LayerGroupTreeStore::Model model;
+       if((bool)(*iter)[model.is_group])
+               ret->push_back((Glib::ustring)(*iter)[model.group_name]);
+}
+
+std::list<synfig::String>
+LayerGroupTree::get_selected_groups()const
+{
+       Glib::RefPtr<Gtk::TreeSelection> selection=const_cast<LayerGroupTree&>(*this).get_selection();
+
+       if(!selection)
+               return std::list<synfig::String>();
+
+       std::list<synfig::String> ret;
+
+       selection->selected_foreach_iter(
+               sigc::bind(
+                       sigc::ptr_fun(
+                               &__group_grabber
+                       ),
+                       &ret
+               )
+       );
+
+       return ret;
+}
+
+static inline void __layer_grabber(const Gtk::TreeModel::iterator& iter, LayerGroupTree::LayerList* ret)
+{
+       const LayerGroupTreeStore::Model model;
+       if((bool)(*iter)[model.is_layer])
+               ret->push_back((Layer::Handle)(*iter)[model.layer]);
+}
+
+LayerGroupTree::LayerList
+LayerGroupTree::get_selected_layers()const
+{
+       Glib::RefPtr<Gtk::TreeSelection> selection=const_cast<LayerGroupTree&>(*this).get_selection();
+
+       if(!selection)
+               return LayerList();
+
+       LayerList ret;
+
+       selection->selected_foreach_iter(
+               sigc::bind(
+                       sigc::ptr_fun(
+                               &__layer_grabber
+                       ),
+                       &ret
+               )
+       );
+
+       return ret;
+}
+
+void
+LayerGroupTree::set_cursor(const Gtk::TreeModel::Path& path, bool start_editing)
+{
+       Gtk::TreeView::set_cursor(path, *label_column, start_editing);
+}
diff --git a/synfig-studio/src/gui/layergrouptree.h b/synfig-studio/src/gui/layergrouptree.h
new file mode 100644 (file)
index 0000000..a17c470
--- /dev/null
@@ -0,0 +1,127 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file layergrouptree.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_LAYERGROUPTREE_H
+#define __SYNFIG_STUDIO_LAYERGROUPTREE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/treeview.h>
+#include <gtkmm/treestore.h>
+#include <synfigapp/canvasinterface.h>
+#include <synfigapp/value_desc.h>
+#include "layergrouptreestore.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 synfig { class Layer; }
+
+namespace studio {
+
+class LayerGroupTree : public Gtk::TreeView
+{
+       /*
+ -- ** -- P U B L I C   T Y P E S ---------------------------------------------
+       */
+
+public:
+
+       typedef std::list<synfig::Layer::Handle> LayerList;
+
+       /*
+ -- ** -- P U B L I C  D A T A ------------------------------------------------
+       */
+
+public:
+
+       LayerGroupTreeStore::Model model;
+
+       /*
+ -- ** -- P R I V A T E   D A T A ---------------------------------------------
+       */
+
+private:
+
+       Glib::RefPtr<LayerGroupTreeStore> layer_group_tree_store_;
+
+       Gtk::CellRendererText *cell_renderer_description;
+
+       bool editable_;
+
+
+       sigc::signal<void,etl::handle<synfig::Layer> > signal_popup_layer_menu_;
+
+//     sigc::signal<void,LayerList> signal_select_layers_;
+       Gtk::TreeView::Column* label_column;
+
+       /*
+ -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
+       */
+
+private:
+
+       /*
+ -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
+       */
+
+private:
+
+       bool on_event(GdkEvent *event);
+
+       /*
+ -- ** -- P U B L I C   M E T H O D S -----------------------------------------
+       */
+
+public:
+
+       LayerGroupTree();
+       ~LayerGroupTree();
+       void set_cursor(const Gtk::TreeModel::Path& path, bool start_editing=false);
+
+       Glib::RefPtr<LayerGroupTreeStore> get_model() { return layer_group_tree_store_; }
+
+       sigc::signal<void,etl::handle<synfig::Layer> >& signal_popup_layer_menu() { return signal_popup_layer_menu_; }
+
+//     sigc::signal<void,LayerList>& signal_select_layers() { return signal_select_layers_; }
+
+       void set_model(Glib::RefPtr<LayerGroupTreeStore> layer_group_tree_store_);
+
+       void set_editable(bool x=true);
+
+       bool get_editable()const { return editable_; }
+
+       std::list<synfig::String> get_selected_groups()const;
+
+       LayerList get_selected_layers()const;
+}; // END of LayerGroupTree
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/layergrouptreestore.cpp b/synfig-studio/src/gui/layergrouptreestore.cpp
new file mode 100644 (file)
index 0000000..9c947c6
--- /dev/null
@@ -0,0 +1,1031 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file layergrouptreestore.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 <config.h>
+#endif
+
+#include "layergrouptreestore.h"
+#include "iconcontroller.h"
+#include <gtkmm/button.h>
+#include <synfig/paramdesc.h>
+#include <synfigapp/action.h>
+#include <synfigapp/instance.h>
+#include "app.h"
+#include "instance.h"
+#include <synfigapp/action_system.h>
+#include "dockmanager.h"
+#include "dockable.h"
+
+#include <gtk/gtkversion.h>
+#include <ETL/clock>
+#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 ========================================================= */
+
+#define GROUP_NEST_CHAR        '.'
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+static LayerGroupTreeStore::Model& ModelHack()
+{
+       static LayerGroupTreeStore::Model* model(0);
+       if(!model)model=new LayerGroupTreeStore::Model;
+       return *model;
+}
+
+LayerGroupTreeStore::LayerGroupTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_):
+       Gtk::TreeStore                  (ModelHack()),
+       canvas_interface_               (canvas_interface_)
+{
+       layer_icon=Gtk::Button().render_icon(Gtk::StockID("synfig-layer"),Gtk::ICON_SIZE_SMALL_TOOLBAR);
+       group_icon=Gtk::Button().render_icon(Gtk::StockID("synfig-group"),Gtk::ICON_SIZE_SMALL_TOOLBAR);
+
+       // Connect Signals to Terminals
+       canvas_interface()->signal_layer_status_changed().connect(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_layer_status_changed));
+       canvas_interface()->signal_layer_new_description().connect(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_layer_new_description));
+
+       canvas_interface()->get_canvas()->signal_group_added().connect(sigc::hide_return(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_group_added)));
+       canvas_interface()->get_canvas()->signal_group_removed().connect(sigc::hide_return(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_group_removed)));
+       canvas_interface()->get_canvas()->signal_group_changed().connect(sigc::hide_return(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_group_changed)));
+
+       canvas_interface()->get_canvas()->signal_group_pair_added().connect(sigc::hide_return(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_group_pair_added)));
+       canvas_interface()->get_canvas()->signal_group_pair_removed().connect(sigc::hide_return(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_group_pair_removed)));
+
+       rebuild();
+}
+
+LayerGroupTreeStore::~LayerGroupTreeStore()
+{
+       //clear();
+
+       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
+               synfig::info("LayerGroupTreeStore::~LayerGroupTreeStore(): Deleted");
+}
+
+bool
+LayerGroupTreeStore::search_func(const Glib::RefPtr<TreeModel>&,int,const Glib::ustring& x,const TreeModel::iterator& iter)
+{
+       const Model model;
+
+       Glib::ustring substr(x.uppercase());
+       Glib::ustring label((*iter)[model.label]);
+       label=label.uppercase();
+
+       return label.find(substr)==Glib::ustring::npos;
+}
+
+
+Glib::RefPtr<LayerGroupTreeStore>
+LayerGroupTreeStore::create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_)
+{
+       return Glib::RefPtr<LayerGroupTreeStore>(new LayerGroupTreeStore(canvas_interface_));
+}
+
+void
+LayerGroupTreeStore::get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const
+{
+       if(column==model.child_layers.index())
+       {
+               Glib::Value<LayerList> x;
+               g_value_init(x.gobj(),x.value_type());
+
+               if((bool)(*iter)[model.is_group])
+               {
+                       set<Layer::Handle> layer_set(canvas_interface()->get_canvas()->get_layers_in_group((Glib::ustring)(*iter)[model.group_name]));
+
+                       x.set(LayerList(layer_set.begin(),layer_set.end()));
+               }
+               else if((bool)(*iter)[model.is_layer])
+               {
+                       LayerList layer_list;
+                       layer_list.push_back((Layer::Handle)(*iter)[model.layer]);
+                       x.set(layer_list);
+               }
+
+               g_value_init(value.gobj(),x.value_type());
+               value=x;
+       }
+       else if(column==model.all_layers.index())
+       {
+               Glib::Value<LayerList> x;
+               g_value_init(x.gobj(),x.value_type());
+
+               if((bool)(*iter)[model.is_group])
+               {
+                       LayerList layer_list;
+                       Gtk::TreeModel::iterator child_iter(iter->children().begin());
+                       for(;child_iter;++child_iter)
+                       {
+                               LayerList layer_list2((LayerList)(*child_iter)[model.all_layers]);
+                               for(;layer_list2.size();layer_list2.pop_front())
+                                       layer_list.push_back(layer_list2.front());
+                       }
+                       x.set(layer_list);
+               }
+               else if((bool)(*iter)[model.is_layer])
+               {
+                       LayerList layer_list;
+                       layer_list.push_back((Layer::Handle)(*iter)[model.layer]);
+                       x.set(layer_list);
+               }
+
+               g_value_init(value.gobj(),x.value_type());
+               value=x;
+       }
+       else if(column==model.group_name.index())
+       {
+               if((bool)(*iter)[model.is_group])
+                       return Gtk::TreeStore::get_value_vfunc(iter,column,value);
+               return get_value_vfunc(iter->parent(),column,value);
+       }
+       else if(column==model.parent_group_name.index())
+       {
+               if(iter->parent())
+                       return get_value_vfunc(iter->parent(),model.group_name.index(),value);
+               Glib::Value<Glib::ustring> x;
+               g_value_init(x.gobj(),x.value_type());
+               x.set(Glib::ustring());
+               g_value_init(value.gobj(),x.value_type());
+               value=x;
+       }
+       else if(column==model.label.index())
+       {
+               if((bool)(*iter)[model.is_group])
+               {
+                       Glib::Value<Glib::ustring> x;
+                       g_value_init(x.gobj(),x.value_type());
+
+                       Glib::ustring group_name((*iter)[model.group_name]);
+
+                       // Get rid of any parent group crap
+                       while(group_name.find(GROUP_NEST_CHAR)!=Glib::ustring::npos)
+                               group_name=Glib::ustring(group_name,group_name.find(GROUP_NEST_CHAR)+1,Glib::ustring::npos);
+
+                       x.set(group_name);
+
+                       g_value_init(value.gobj(),x.value_type());
+
+                       value=x;
+               }
+               else if((bool)(*iter)[model.is_layer])
+               {
+                       synfig::Layer::Handle layer((*iter)[model.layer]);
+
+                       if(!layer)return;
+
+                       Glib::Value<Glib::ustring> x;
+                       g_value_init(x.gobj(),x.value_type());
+
+                       x.set(layer->get_non_empty_description());
+
+                       g_value_init(value.gobj(),x.value_type());
+                       //g_value_copy(x.gobj(),value.gobj());
+                       value=x;
+               }
+       }
+       else
+       if(column==model.tooltip.index())
+       {
+               synfig::Layer::Handle layer((*iter)[model.layer]);
+
+               if(!layer)return;
+
+               Glib::Value<Glib::ustring> x;
+               g_value_init(x.gobj(),x.value_type());
+
+
+               x.set(layer->get_local_name());
+
+               g_value_init(value.gobj(),x.value_type());
+               //g_value_copy(x.gobj(),value.gobj());
+               value=x;
+       }
+       else
+       if(column==model.canvas.index())
+       {
+               synfig::Layer::Handle layer((*iter)[model.layer]);
+
+               if(!layer)return;
+
+               Glib::Value<Canvas::Handle> x;
+               g_value_init(x.gobj(),x.value_type());
+
+
+               x.set(layer->get_canvas());
+
+               g_value_init(value.gobj(),x.value_type());
+               //g_value_copy(x.gobj(),value.gobj());
+               value=x;
+       }
+       else
+       if(column==model.active.index())
+       {
+               Glib::Value<bool> x;
+               g_value_init(x.gobj(),x.value_type());
+
+               if((bool)(*iter)[model.is_layer])
+               {
+                       synfig::Layer::Handle layer((*iter)[model.layer]);
+                       x.set(layer->active());
+               }
+               else if((bool)(*iter)[model.is_group])
+               {
+                       int activecount(0),total(0);
+                       Gtk::TreeModel::iterator child_iter(iter->children().begin());
+                       for(;child_iter;++child_iter)
+                       {
+                               total++;
+                               if((*child_iter)[model.active])
+                                       activecount++;
+                       }
+                       x.set(activecount>total/2);
+               }
+               else
+                       x.set(false);
+
+               g_value_init(value.gobj(),x.value_type());
+               g_value_copy(x.gobj(),value.gobj());
+       }
+       else
+       if(column==model.icon.index())
+       {
+               Glib::Value<Glib::RefPtr<Gdk::Pixbuf> > x;
+               g_value_init(x.gobj(),x.value_type());
+
+               if((bool)(*iter)[model.is_layer])
+               {
+                       synfig::Layer::Handle layer((*iter)[model.layer]);
+                       if(!layer)return;
+                       //x.set(layer_icon);
+                       x.set(get_tree_pixbuf_layer(layer->get_name()));
+               }
+               if((bool)(*iter)[model.is_group])
+                       x.set(group_icon);
+
+               g_value_init(value.gobj(),x.value_type());
+               g_value_copy(x.gobj(),value.gobj());
+       }
+       else
+               Gtk::TreeStore::get_value_vfunc(iter,column,value);
+}
+
+void
+LayerGroupTreeStore::set_value_impl(const Gtk::TreeModel::iterator& iter, int column, const Glib::ValueBase& value)
+{
+       //if(!iterator_sane(row))
+       //      return;
+
+       if(column>=get_n_columns_vfunc())
+       {
+               g_warning("LayerGroupTreeStore::set_value_impl: Bad column (%d)",column);
+               return;
+       }
+
+       if(!g_value_type_compatible(G_VALUE_TYPE(value.gobj()),get_column_type_vfunc(column)))
+       {
+               g_warning("LayerGroupTreeStore::set_value_impl: Bad value type");
+               return;
+       }
+
+       try
+       {
+               if(column==model.label.index())
+               {
+                       Glib::Value<Glib::ustring> x;
+                       g_value_init(x.gobj(),model.label.type());
+                       g_value_copy(value.gobj(),x.gobj());
+
+                       if((bool)(*iter)[model.is_layer])
+                       {
+                               synfig::Layer::Handle layer((*iter)[model.layer]);
+                               if(!layer)
+                                       return;
+                               synfig::String new_desc(x.get());
+
+                               if(new_desc==layer->get_local_name())
+                                       new_desc=synfig::String();
+
+                               if(new_desc==layer->get_description())
+                                       return;
+
+                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerSetDesc"));
+
+                               if(!action)
+                                       return;
+
+                               action->set_param("canvas",canvas_interface()->get_canvas());
+                               action->set_param("canvas_interface",canvas_interface());
+                               action->set_param("layer",layer);
+                               action->set_param("new_description",synfig::String(x.get()));
+
+                               canvas_interface()->get_instance()->perform_action(action);
+                               return;
+                       }
+                       else if((bool)(*iter)[model.is_group])
+                       {
+                               synfig::String group((Glib::ustring)(*iter)[model.label]);
+                               synfig::String new_group(x.get());
+
+                               if(x.get()==group)
+                                       return;
+
+                               Glib::ustring group_name((*iter)[model.group_name]);
+                               group=group_name;
+                               new_group.clear();
+
+                               // Get rid of any parent group crap
+                               while(group_name.find(GROUP_NEST_CHAR)!=Glib::ustring::npos)
+                               {
+                                       new_group+=Glib::ustring(group_name,0,group_name.find(GROUP_NEST_CHAR)+1);
+                                       group_name=Glib::ustring(group_name,group_name.find(GROUP_NEST_CHAR)+1,Glib::ustring::npos);
+                               }
+                               new_group+=x.get();
+
+                               synfig::info("Renaming group \"%s\" to \"%s\"...",group.c_str(),new_group.c_str());
+
+                               // Check to see if this group is real or not.
+                               // If it isn't real, then renaming it is a cinch.
+                               // We know it isn't real if it doesn't have any
+                               // children yet.
+                               if(iter->children().empty())
+                               {
+                                       (*iter)[model.group_name]=new_group;
+                               }
+                               else
+                               {
+                                       synfigapp::Action::Handle action(synfigapp::Action::create("GroupRename"));
+
+                                       if(!action)
+                                               return;
+
+                                       action->set_param("canvas",canvas_interface()->get_canvas());
+                                       action->set_param("canvas_interface",canvas_interface());
+                                       action->set_param("group",group);
+                                       action->set_param("new_group",new_group);
+
+                                       canvas_interface()->get_instance()->perform_action(action);
+                               }
+                               return;
+                       }
+                       return;
+               }
+               else
+               if(column==model.active.index())
+               {
+                       Glib::Value<bool> x;
+                       g_value_init(x.gobj(),model.active.type());
+                       g_value_copy(value.gobj(),x.gobj());
+
+                       if((bool)(*iter)[model.is_layer])
+                       {
+                               synfig::Layer::Handle layer((*iter)[model.layer]);
+                               if(!layer)return;
+
+                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerActivate"));
+
+                               if(!action)
+                                       return;
+
+                               action->set_param("canvas",canvas_interface()->get_canvas());
+                               action->set_param("canvas_interface",canvas_interface());
+                               action->set_param("layer",layer);
+                               action->set_param("new_status",bool(x.get()));
+
+
+                               canvas_interface()->get_instance()->perform_action(action);
+                               return;
+                       }
+                       else if(!iter->children().empty())
+                       {
+                               synfigapp::Action::PassiveGrouper group(
+                                       get_canvas_interface()->get_instance().get(),
+                                       String(
+                                               x.get()?_("Activate "):_("Deactivate ")
+                                       )+(Glib::ustring)(*iter)[model.label]
+                               );
+
+                               Gtk::TreeModel::iterator child_iter(iter->children().begin());
+
+                               for(;child_iter;++child_iter)
+                                       (*child_iter)[model.active]=x.get();
+
+                               Gtk::TreeStore::set_value_impl(iter,column, value);
+                       }
+               }
+               else
+                       Gtk::TreeStore::set_value_impl(iter,column, value);
+
+       }
+       catch(std::exception x)
+       {
+               g_warning("%s", x.what());
+       }
+}
+
+
+
+
+bool
+LayerGroupTreeStore::row_draggable_vfunc (const TreeModel::Path& /*path*/)const
+{
+       //if(!get_iter(path)) return false;
+//     Gtk::TreeModel::Row row(*get_iter(path));
+
+       return true;
+}
+
+bool
+LayerGroupTreeStore::drag_data_get_vfunc (const TreeModel::Path& path, Gtk::SelectionData& selection_data)const
+{
+       if(!const_cast<LayerGroupTreeStore*>(this)->get_iter(path)) return false;
+       //synfig::info("Dragged data of type \"%s\"",selection_data.get_data_type());
+       //synfig::info("Dragged data of target \"%s\"",gdk_atom_name(selection_data->target));
+       //synfig::info("Dragged selection=\"%s\"",gdk_atom_name(selection_data->selection));
+
+       Gtk::TreeModel::Row row(*const_cast<LayerGroupTreeStore*>(this)->get_iter(path));
+
+       if((bool)row[model.is_layer])
+       {
+               Layer* layer(((Layer::Handle)row[model.layer]).get());
+               assert(layer);
+
+               std::vector<Layer*> layers;
+
+               layers.push_back(layer);
+
+               selection_data.set("LAYER", 8, reinterpret_cast<const guchar*>(&layers.front()), sizeof(void*)*layers.size());
+
+               return true;
+       }
+       else if((bool)row[model.is_group])
+       {
+               synfig::String group((Glib::ustring)row[model.group_name]);
+               if(group.empty())
+                       return false;
+
+               selection_data.set("GROUP", 8, reinterpret_cast<const guchar*>(&*group.begin()), sizeof(void*)*group.size());
+
+               return true;
+       }
+
+       return false;
+}
+
+bool
+LayerGroupTreeStore::drag_data_delete_vfunc (const TreeModel::Path& /*path*/)
+{
+       return true;
+}
+
+bool
+LayerGroupTreeStore::row_drop_possible_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)const
+{
+       Gtk::TreeIter iter(const_cast<LayerGroupTreeStore*>(this)->get_iter(dest));
+       if(!iter) return false;
+
+       if(synfig::String(selection_data.get_data_type())=="LAYER")
+               return true;
+
+       if(synfig::String(selection_data.get_data_type())=="GROUP")
+       {
+               synfig::String dest_group((Glib::ustring)(*iter)[model.group_name]);
+               synfig::String src_group(reinterpret_cast<const gchar*>(selection_data.get_data()));
+               //synfig::String src_group(const_cast<gchar*>(selection_data.get_data()));
+
+               // Avoid putting a group inside of itself
+               if(dest_group.size()>src_group.size() && src_group==String(dest_group,0,src_group.size()))
+                       return false;
+               return true;
+       }
+
+       return false;
+       //synfig::info("possible_drop -- data of type \"%s\"",selection_data.get_data_type());
+       //synfig::info("possible_drop -- data of target \"%s\"",gdk_atom_name(selection_data->target));
+       //synfig::info("possible_drop -- selection=\"%s\"",gdk_atom_name(selection_data->selection));
+
+       //Gtk::TreeModel::Row row(*get_iter(dest));
+
+/*     if(synfig::String(selection_data.get_data_type())=="LAYER" && (bool)true)
+               return true;
+*/
+       return false;
+}
+
+bool
+LayerGroupTreeStore::drag_data_received_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)
+{
+       if(!get_iter(dest)) return false;
+//     bool ret=false;
+       //int i(0);
+
+       Gtk::TreeModel::Row row(*get_iter(dest));
+
+       //synfig::info("Dropped data of type \"%s\"",selection_data.get_data_type());
+       //synfig::info("Dropped data of target \"%s\"",gdk_atom_name(selection_data->target));
+       //synfig::info("Dropped selection=\"%s\"",gdk_atom_name(selection_data->selection));
+       synfigapp::Action::PassiveGrouper passive_grouper(canvas_interface()->get_instance().get(),_("Regroup"));
+
+       if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
+       {
+               synfig::String dest_group;
+
+               dest_group=(Glib::ustring)row[model.group_name];
+
+               if(dest_group.empty())
+                       return false;
+
+               if(synfig::String(selection_data.get_data_type())=="LAYER")
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("GroupAddLayers"));
+
+                       if(!action)
+                               return false;
+
+                       action->set_param("canvas",canvas_interface()->get_canvas());
+                       action->set_param("canvas_interface",canvas_interface());
+                       action->set_param("group",dest_group);
+
+                       for(unsigned int i=0;i<selection_data.get_length()/sizeof(void*);i++)
+                       {
+                               Layer::Handle layer(reinterpret_cast<Layer**>(const_cast<guint8*>(selection_data.get_data()))[i]);
+                               assert(layer);
+
+                               action->set_param("layer",layer);
+                       }
+                       if(!canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               passive_grouper.cancel();
+                               return false;
+                       }
+                       return true;
+               }
+               if(synfig::String(selection_data.get_data_type())=="GROUP")
+               {
+                       synfig::String src_group(reinterpret_cast<const gchar*>(selection_data.get_data()));
+                       synfig::String group(src_group);
+
+                       // Get rid of any parent group crap
+                       while(group.find(GROUP_NEST_CHAR)!=Glib::ustring::npos)
+                               group=Glib::ustring(group,group.find(GROUP_NEST_CHAR)+1,Glib::ustring::npos);
+
+                       group=dest_group+GROUP_NEST_CHAR+group;
+
+                       synfigapp::Action::Handle action(synfigapp::Action::create("GroupRename"));
+
+                       if(!action)
+                               return false;
+
+                       action->set_param("canvas",canvas_interface()->get_canvas());
+                       action->set_param("canvas_interface",canvas_interface());
+                       action->set_param("group",src_group);
+                       action->set_param("new_group",group);
+
+                       if(!canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               passive_grouper.cancel();
+                               return false;
+                       }
+                       return true;
+               }
+       }
+/*     // Save the selection data
+       synfigapp::SelectionManager::LayerList selected_layer_list=canvas_interface()->get_selection_manager()->get_selected_layers();
+
+       if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
+       {
+               Canvas::Handle dest_canvas;
+               Layer::Handle dest_layer;
+
+               dest_canvas=(Canvas::Handle)(row[model.canvas]);
+               dest_layer=(Layer::Handle)(row[model.layer]);
+               assert(dest_canvas);
+
+               if(!dest_layer)
+                       return false;
+
+               int dest_layer_depth=dest_layer->get_depth();
+
+               if(synfig::String(selection_data.get_data_type())=="LAYER")for(i=0;i<selection_data.get_length()/sizeof(void*);i++)
+               {
+                       //synfig::info("dest_layer_depth=%d",dest_layer_depth);
+
+                       Layer::Handle src(reinterpret_cast<Layer**>(const_cast<guint8*>(selection_data.get_data()))[i]);
+                       assert(src);
+                       if(dest_layer==src)
+                               continue;
+
+                       // In this case, we are just moving.
+//                     if(dest_canvas==src->get_canvas())
+                       {
+                               if(dest_canvas==src->get_canvas() && dest_layer_depth && dest_layer_depth>src->get_depth())
+                                       dest_layer_depth--;
+                               if(dest_canvas==src->get_canvas() && dest_layer_depth==src->get_depth())
+                                       continue;
+
+                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerMove"));
+                               action->set_param("canvas",dest_canvas);
+                               action->set_param("canvas_interface",canvas_interface());
+                               action->set_param("layer",src);
+                               action->set_param("new_index",dest_layer_depth);
+                               action->set_param("dest_canvas",dest_canvas);
+                               if(canvas_interface()->get_instance()->perform_action(action))
+                               {
+                                       ret=true;
+                               }
+                               else
+                               {
+                                       passive_grouper.cancel();
+                                       return false;
+                               }
+                               continue;
+                       }
+               }
+       }
+       synfig::info("I supposedly moved %d layers",i);
+
+       // Reselect the previously selected layers
+       canvas_interface()->get_selection_manager()->set_selected_layers(selected_layer_list);
+
+       return ret;
+       */
+       return false;
+}
+
+
+
+
+
+
+
+void
+LayerGroupTreeStore::rebuild()
+{
+       rebuilding=true;
+       // etl::clock timer;timer.reset();
+       try {
+
+               // Clear out the current list
+               clear();
+               Canvas::Handle canvas(canvas_interface()->get_canvas());
+               std::set<String> groups(canvas->get_groups());
+               for(;groups.size();groups.erase(groups.begin()))
+               {
+                       String group(*groups.begin());
+                       Gtk::TreeRow row(on_group_added(group));
+                       std::set<Layer::Handle> layers(canvas->get_layers_in_group(group));
+
+                       for(;layers.size();layers.erase(layers.begin()))
+                       {
+                               Gtk::TreeRow layer_row(*(prepend(row.children())));
+                               Layer::Handle layer(*layers.begin());
+                               set_row_layer(layer_row,layer);
+                       }
+               }
+
+               // Go ahead and add all the layers
+               /*std::for_each(
+                       canvas_interface()->get_canvas()->rbegin(), canvas_interface()->get_canvas()->rend(),
+                       sigc::mem_fun(*this, &studio::LayerGroupTreeStore::on_layer_added)
+               );*/
+       }
+       catch(...)
+       {
+               rebuilding=false;
+               throw;
+       }
+       rebuilding=false;
+       // synfig::info("LayerGroupTreeStore::rebuild() took %f seconds",float(timer()));
+}
+
+void
+LayerGroupTreeStore::refresh()
+{
+       rebuild();
+}
+
+void
+LayerGroupTreeStore::refresh_row(Gtk::TreeModel::Row &row)
+{
+       if((bool)row[model.is_layer])
+       {
+               Layer::Handle layer=row[model.layer];
+
+
+               //if(layer->dynamic_param_list().count("z_depth"))
+               //      row[model.z_depth]=Time::begin();
+       }
+
+       Gtk::TreeModel::Children children = row.children();
+       Gtk::TreeModel::Children::iterator iter;
+
+       if(!children.empty())
+               for(iter = children.begin(); iter && iter != children.end(); ++iter)
+               {
+                       Gtk::TreeRow row=*iter;
+                       refresh_row(row);
+               }
+}
+
+
+void
+LayerGroupTreeStore::set_row_layer(Gtk::TreeRow &row,synfig::Layer::Handle &handle)
+{
+       row[model.is_layer] = true;
+       row[model.is_group] = false;
+       row[model.layer] = handle;
+}
+
+Gtk::TreeRow
+LayerGroupTreeStore::on_group_added(synfig::String group)
+{
+       // Check to see if this group perhaps already
+       // exists
+       {
+               Gtk::TreeModel::Children::iterator iter;
+               if(find_group_row(group,  iter))
+                       return *iter;
+       }
+
+       if(group.find(GROUP_NEST_CHAR)!=String::npos)
+       {
+               Gtk::TreeModel::Children::iterator iter;
+               String parent_name;
+               do
+               {
+                       if(parent_name.size())
+                               parent_name+=GROUP_NEST_CHAR;
+                       parent_name+=string(group,0,group.find(GROUP_NEST_CHAR));
+
+                       if(!find_group_row(parent_name, iter))
+                               iter=on_group_added(parent_name);
+
+                       group=String(group,group.find(GROUP_NEST_CHAR)+1,String::npos);
+               }while(group.find(GROUP_NEST_CHAR)!=String::npos);
+
+               if(parent_name.size())
+                       parent_name+=GROUP_NEST_CHAR;
+               parent_name+=group;
+
+               if(iter)
+               {
+                       Gtk::TreeRow row(*(prepend(iter->children())));
+                       row[model.group_name]=parent_name;
+                       row[model.is_layer]=false;
+                       row[model.is_group]=true;
+                       on_activity();
+                       return row;
+               }
+       }
+
+       Gtk::TreeRow row(*(append()));
+       row[model.group_name]=group;
+       row[model.is_layer]=false;
+       row[model.is_group]=true;
+       on_activity();
+       return row;
+}
+
+bool
+LayerGroupTreeStore::on_group_removed(synfig::String group)
+{
+       Gtk::TreeModel::Children::iterator iter;
+       if(find_group_row(group,iter) && iter->children().size()==0)
+               erase(iter);
+       else
+               return false;
+
+       return true;
+}
+
+bool
+LayerGroupTreeStore::on_group_changed(synfig::String /*group*/)
+{
+       return true;
+}
+
+void
+LayerGroupTreeStore::on_group_pair_added(synfig::String group, etl::handle<synfig::Layer> layer)
+{
+       if(!layer->get_canvas())
+               return;
+       Gtk::TreeModel::Children::iterator iter;
+       if(!find_group_row(group, iter))
+               iter=on_group_added(group);
+
+       Gtk::TreeRow layer_row(*(append(iter->children())));
+       set_row_layer(layer_row,layer);
+       on_activity();
+}
+
+void
+LayerGroupTreeStore::on_group_pair_removed(synfig::String group, etl::handle<synfig::Layer> layer)
+{
+       if(!layer->get_canvas())
+               return;
+       Gtk::TreeModel::Children::iterator iter;
+       if(!find_group_row(group, iter))
+               return;
+
+       Gtk::TreeModel::Children::iterator prev,layer_iter;
+
+       if(!find_layer_row_(layer, layer->get_canvas(), iter->children(), layer_iter, prev))
+               return;
+
+       erase(layer_iter);
+
+       on_activity();
+}
+
+void
+LayerGroupTreeStore::on_activity()
+{
+       // If we aren't rebuilding and the last action
+       // had something to do with groups, then go
+       // a head and present the groups dialog.
+       if(!rebuilding && canvas_interface()->get_instance()->get_most_recent_action() && canvas_interface()->get_instance()->get_most_recent_action()->get_name().find("Group")!=String::npos)
+       try
+       {
+               App::dock_manager->find_dockable("groups").present();
+       }
+       catch(...) { }
+}
+
+void
+LayerGroupTreeStore::on_layer_status_changed(synfig::Layer::Handle handle,bool /*x*/)
+{
+       Gtk::TreeModel::Children::iterator iter;
+       if(find_layer_row(handle,iter))
+               (*iter)[model.layer]=handle;
+       else
+       {
+               // Not need to send a warning when a layer changes its status and
+               // it is not found in any group.
+               //synfig::warning("Couldn't find layer to be activated in layer list. Rebuilding index...");
+               rebuild();
+       }
+}
+
+
+void
+LayerGroupTreeStore::on_layer_new_description(synfig::Layer::Handle handle,synfig::String desc)
+{
+       Gtk::TreeModel::Children::iterator iter;
+       if(find_layer_row(handle,iter))
+       {
+               Gtk::TreeRow row(*iter);
+
+               Layer::Handle layer(row[model.layer]);
+
+               if(desc.empty())
+               {
+                       //row[model.label]=layer->get_local_name();
+                       row[model.tooltip]=Glib::ustring(_("Layer"));
+               }
+               else
+                       //row[model.label]=layer->get_description();
+                       row[model.tooltip]=layer->get_local_name();
+       }
+       else
+       {
+               rebuild();
+       }
+}
+
+bool
+LayerGroupTreeStore::find_layer_row_(const synfig::Layer::Handle &layer, synfig::Canvas::Handle canvas, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter, Gtk::TreeModel::Children::iterator &prev)
+{
+       assert(layer);
+
+       //if(layer->get_canvas()==canvas)
+       {
+               for(iter=prev=layers.begin(); iter && iter != layers.end(); prev=iter++)
+               {
+                       Gtk::TreeModel::Row row = *iter;
+                       if((bool)row[model.is_layer] && layer==(synfig::Layer::Handle)row[model.layer])
+                               return true;
+               }
+
+               iter=children().end();
+               //return false;
+       }
+
+       Gtk::TreeModel::Children::iterator iter2;
+
+       for(iter2 = layers.begin(); iter2 && iter2 != layers.end(); ++iter2)
+       {
+               Gtk::TreeModel::Row row = *iter2;
+               assert((bool)true);
+
+               if(row.children().empty())
+                       continue;
+
+               /*Canvas::Handle canvas((*row.children().begin())[model.canvas]);
+               if(!canvas)
+                       continue;
+               */
+
+               if(find_layer_row_(layer,canvas,iter2->children(),iter,prev))
+                       return true;
+       }
+
+       iter=children().end();
+       return false;
+}
+
+bool
+LayerGroupTreeStore::find_layer_row(const synfig::Layer::Handle &layer, Gtk::TreeModel::Children::iterator &iter)
+{
+       Gtk::TreeModel::Children::iterator prev;
+       return find_layer_row_(layer,canvas_interface()->get_canvas(),children(),iter,prev);
+}
+
+bool
+LayerGroupTreeStore::find_group_row(const synfig::String &group, Gtk::TreeModel::Children::iterator &iter)
+{
+       Gtk::TreeModel::Children::iterator prev;
+       return find_group_row_(group,children(),iter,prev);
+}
+
+bool
+LayerGroupTreeStore::find_group_row_(const synfig::String &group, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter, Gtk::TreeModel::Children::iterator &prev)
+{
+       //if(layer->get_canvas()==canvas)
+       {
+               for(iter=prev=layers.begin(); iter && iter != layers.end(); prev=iter++)
+               {
+                       Gtk::TreeModel::Row row = *iter;
+                       if((bool)row[model.is_group] && group==(Glib::ustring)row[model.group_name])
+                               return true;
+               }
+
+               iter=children().end();
+               //return false;
+       }
+
+       Gtk::TreeModel::Children::iterator iter2;
+
+       for(iter2 = layers.begin(); iter2 && iter2 != layers.end(); ++iter2)
+       {
+               Gtk::TreeModel::Row row = *iter2;
+               assert((bool)true);
+
+               if(row.children().empty())
+                       continue;
+
+               if(find_group_row_(group,iter2->children(),iter,prev))
+                       return true;
+       }
+
+       iter=children().end();
+       return false;
+}
+
+bool
+LayerGroupTreeStore::find_prev_layer_row(const synfig::Layer::Handle &layer, Gtk::TreeModel::Children::iterator &prev)
+{
+       Gtk::TreeModel::Children::iterator iter;
+       if(!find_layer_row_(layer,canvas_interface()->get_canvas(),children(),iter,prev))
+               return false;
+       if(iter==children().begin())
+               return false;
+       return true;
+}
diff --git a/synfig-studio/src/gui/layergrouptreestore.h b/synfig-studio/src/gui/layergrouptreestore.h
new file mode 100644 (file)
index 0000000..cd0c196
--- /dev/null
@@ -0,0 +1,202 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file layergrouptreestore.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_LAYERGROUPTREESTORE_H
+#define __SYNFIG_STUDIO_LAYERGROUPTREESTORE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/treestore.h>
+#include <synfigapp/canvasinterface.h>
+#include <synfig/value.h>
+#include <synfig/valuenode.h>
+#include <gtkmm/treeview.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 LayerGroupTreeStore :  public Gtk::TreeStore
+{
+       /*
+ -- ** -- P U B L I C   T Y P E S ---------------------------------------------
+       */
+
+public:
+       typedef std::list<synfig::Layer::Handle> LayerList;
+
+       class Model : public Gtk::TreeModel::ColumnRecord
+       {
+       public:
+               Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
+               Gtk::TreeModelColumn<Glib::ustring> label;
+               Gtk::TreeModelColumn<Glib::ustring> tooltip;
+
+               Gtk::TreeModelColumn<Glib::ustring> group_name;
+               Gtk::TreeModelColumn<Glib::ustring> parent_group_name;
+
+               Gtk::TreeModelColumn<synfig::Canvas::Handle> canvas;
+
+               Gtk::TreeModelColumn<bool>                                              active;
+               Gtk::TreeModelColumn<bool>                                              is_layer;
+               Gtk::TreeModelColumn<bool>                                              is_group;
+               Gtk::TreeModelColumn<synfig::Layer::Handle>             layer;
+
+               Gtk::TreeModelColumn<LayerList>         all_layers;
+               Gtk::TreeModelColumn<LayerList>         child_layers;
+
+               Model()
+               {
+                       add(icon);
+                       add(label);
+                       add(group_name);
+                       add(parent_group_name);
+                       add(canvas);
+                       add(tooltip);
+                       add(active);
+                       add(layer);
+                       add(is_layer);
+                       add(is_group);
+                       add(all_layers);
+                       add(child_layers);
+               }
+       };
+
+       /*
+ -- ** -- P U B L I C  D A T A ------------------------------------------------
+       */
+
+public:
+
+       //! TreeModel for the layers
+       const Model model;
+
+       bool rebuilding;
+
+       /*
+ -- ** -- P R I V A T E   D A T A ---------------------------------------------
+       */
+
+private:
+
+       etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
+
+       Glib::RefPtr<Gdk::Pixbuf> layer_icon;
+       Glib::RefPtr<Gdk::Pixbuf> group_icon;
+
+       /*
+ -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
+       */
+
+private:
+
+       /*
+ -- ** -- P R O T E C T E D   M E T H O D S -----------------------------------
+       */
+
+private:
+
+       virtual void set_value_impl (const Gtk::TreeModel::iterator& row, int column, const Glib::ValueBase& value);
+       virtual void  get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const;
+
+       virtual bool  row_draggable_vfunc (const TreeModel::Path& path)const;
+       virtual bool  drag_data_get_vfunc (const TreeModel::Path& path, Gtk::SelectionData& selection_data)const;
+       virtual bool  drag_data_delete_vfunc (const TreeModel::Path& path);
+       virtual bool  drag_data_received_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data);
+       virtual bool  row_drop_possible_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)const;
+
+
+       void on_group_pair_added(synfig::String group, etl::handle<synfig::Layer> layer);
+       void on_group_pair_removed(synfig::String group, etl::handle<synfig::Layer> layer);
+
+       void on_activity();
+
+       /*
+ -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
+       */
+
+private:
+
+       bool on_layer_tree_event(GdkEvent *event);
+
+       void on_layer_new_description(synfig::Layer::Handle handle,synfig::String desc);
+
+       void on_layer_status_changed(synfig::Layer::Handle handle,bool);
+
+       bool find_layer_row_(const synfig::Layer::Handle &handle, synfig::Canvas::Handle canvas, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter, Gtk::TreeModel::Children::iterator &prev);
+
+       bool find_group_row_(const synfig::String &group, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter, Gtk::TreeModel::Children::iterator &prev);
+
+       bool on_group_removed(synfig::String group);
+       bool on_group_changed(synfig::String group);
+
+       /*
+ -- ** -- P U B L I C   M E T H O D S -----------------------------------------
+       */
+
+public:
+
+       LayerGroupTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
+       ~LayerGroupTreeStore();
+
+       Gtk::TreeRow on_group_added(synfig::String group);
+       etl::loose_handle<synfigapp::CanvasInterface> canvas_interface() { return canvas_interface_; }
+       etl::loose_handle<const synfigapp::CanvasInterface> canvas_interface()const { return canvas_interface_; }
+       etl::loose_handle<synfigapp::CanvasInterface> get_canvas_interface()const { return canvas_interface_; }
+
+       bool find_layer_row(const synfig::Layer::Handle &handle, Gtk::TreeModel::Children::iterator &iter);
+
+       bool find_group_row(const synfig::String &group, Gtk::TreeModel::Children::iterator &iter);
+
+       bool find_prev_layer_row(const synfig::Layer::Handle &handle, Gtk::TreeModel::Children::iterator &iter);
+
+       void rebuild();
+
+       void refresh();
+
+       void refresh_row(Gtk::TreeModel::Row &row);
+
+       void set_row_layer(Gtk::TreeRow &row,synfig::Layer::Handle &handle);
+
+       static bool search_func(const Glib::RefPtr<TreeModel>&,int,const Glib::ustring&,const TreeModel::iterator&);
+
+       /*
+ -- ** -- S T A T I C   P U B L I C   M E T H O D S ---------------------------
+       */
+
+public:
+
+       static Glib::RefPtr<LayerGroupTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
+
+}; // END of class LayerGroupTreeStore
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/layerparamtreestore.cpp b/synfig-studio/src/gui/layerparamtreestore.cpp
new file mode 100644 (file)
index 0000000..8fe850a
--- /dev/null
@@ -0,0 +1,577 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file layerparamtreestore.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 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 <config.h>
+#endif
+
+#include "layerparamtreestore.h"
+#include "iconcontroller.h"
+#include <gtkmm/button.h>
+#include <synfig/paramdesc.h>
+#include "layertree.h"
+#include <synfigapp/action_system.h>
+#include <synfigapp/instance.h>
+#include "app.h"
+#include <ETL/clock>
+
+#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 ========================================================= */
+
+class Profiler : private etl::clock
+{
+       const std::string name;
+public:
+       Profiler(const std::string& name):name(name) { reset(); }
+       ~Profiler() { float time(operator()()); synfig::info("%s: took %f msec",name.c_str(),time*1000); }
+};
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+static LayerParamTreeStore::Model& ModelHack()
+{
+       static LayerParamTreeStore::Model* model(0);
+       if(!model)model=new LayerParamTreeStore::Model;
+       return *model;
+}
+
+LayerParamTreeStore::LayerParamTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_,LayerTree* layer_tree):
+       Gtk::TreeStore                  (ModelHack()),
+       CanvasTreeStore                 (canvas_interface_),
+       layer_tree                              (layer_tree)
+{
+       queued=0;
+       // Connect all the signals
+       canvas_interface()->signal_value_node_changed().connect(sigc::mem_fun(*this,&studio::LayerParamTreeStore::on_value_node_changed));
+       canvas_interface()->signal_value_node_renamed().connect(sigc::mem_fun(*this,&studio::LayerParamTreeStore::on_value_node_renamed));
+       canvas_interface()->signal_value_node_added().connect(sigc::mem_fun(*this,&studio::LayerParamTreeStore::on_value_node_added));
+       canvas_interface()->signal_value_node_deleted().connect(sigc::mem_fun(*this,&studio::LayerParamTreeStore::on_value_node_deleted));
+       canvas_interface()->signal_value_node_replaced().connect(sigc::mem_fun(*this,&studio::LayerParamTreeStore::on_value_node_replaced));
+       canvas_interface()->signal_layer_param_changed().connect(sigc::mem_fun(*this,&studio::LayerParamTreeStore::on_layer_param_changed));
+
+       canvas_interface()->signal_value_node_child_added().connect(sigc::mem_fun(*this,&studio::LayerParamTreeStore::on_value_node_child_added));
+       canvas_interface()->signal_value_node_child_removed().connect(sigc::mem_fun(*this,&studio::LayerParamTreeStore::on_value_node_child_removed));
+
+
+       layer_tree->get_selection()->signal_changed().connect(sigc::mem_fun(*this,&LayerParamTreeStore::queue_rebuild));
+
+       signal_changed().connect(sigc::mem_fun(*this,&LayerParamTreeStore::queue_refresh));
+       rebuild();
+}
+
+LayerParamTreeStore::~LayerParamTreeStore()
+{
+       while(!changed_connection_list.empty())
+       {
+               changed_connection_list.back().disconnect();
+               changed_connection_list.pop_back();
+       }
+
+       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
+               synfig::info("LayerParamTreeStore::~LayerParamTreeStore(): Deleted");
+}
+
+Glib::RefPtr<LayerParamTreeStore>
+LayerParamTreeStore::create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_, LayerTree*layer_tree)
+{
+       return Glib::RefPtr<LayerParamTreeStore>(new LayerParamTreeStore(canvas_interface_,layer_tree));
+}
+
+
+
+void
+LayerParamTreeStore::get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const
+{
+       if(column<0)
+       {
+               synfig::error("LayerParamTreeStore::get_value_vfunc(): Bad column!");
+               return;
+       }
+
+/*     if(column==model.label.index())
+       {
+               synfig::Layer::Handle layer((*iter)[model.layer]);
+
+               if(!layer)return;
+
+               Glib::Value<Glib::ustring> x;
+               g_value_init(x.gobj(),x.value_type());
+
+               x.set(layer->get_non_empty_description());
+
+               g_value_init(value.gobj(),x.value_type());
+               g_value_copy(x.gobj(),value.gobj());
+       }
+       else
+*/
+       if(column==model.label.index())
+       {
+               synfigapp::ValueDesc value_desc((*iter)[model.value_desc]);
+               Glib::ustring label;
+
+               if(!(*iter)[model.is_toplevel])
+                       return CanvasTreeStore::get_value_vfunc(iter,column,value);
+               synfig::ParamDesc param_desc((*iter)[model.param_desc]);
+               label=param_desc.get_local_name();
+
+               if(!(*iter)[model.is_inconsistent])
+               if(value_desc.is_value_node() && value_desc.get_value_node()->is_exported())
+               {
+                       label+=strprintf(" (%s)",value_desc.get_value_node()->get_id().c_str());
+               }
+
+               Glib::Value<Glib::ustring> x;
+               g_value_init(x.gobj(),x.value_type());
+
+               x.set(label);
+
+               g_value_init(value.gobj(),x.value_type());
+               g_value_copy(x.gobj(),value.gobj());
+       }
+       else
+       if(column==model.is_toplevel.index())
+       {
+               Glib::Value<bool> x;
+               g_value_init(x.gobj(),x.value_type());
+
+               TreeModel::Path path(get_path(iter));
+
+               x.set(path.get_depth()<=1);
+
+               g_value_init(value.gobj(),x.value_type());
+               g_value_copy(x.gobj(),value.gobj());
+       }
+       else
+       if(column==model.is_inconsistent.index())
+       {
+               if((*iter)[model.is_toplevel])
+               {
+                       CanvasTreeStore::get_value_vfunc(iter,column,value);
+                       return;
+               }
+
+               Glib::Value<bool> x;
+               g_value_init(x.gobj(),x.value_type());
+
+               x.set(false);
+
+               g_value_init(value.gobj(),x.value_type());
+               g_value_copy(x.gobj(),value.gobj());
+       }
+       else
+       CanvasTreeStore::get_value_vfunc(iter,column,value);
+}
+
+
+
+void
+LayerParamTreeStore::set_value_impl(const Gtk::TreeModel::iterator& iter, int column, const Glib::ValueBase& value)
+{
+       //if(!iterator_sane(row))
+       //      return;
+
+       if(column>=get_n_columns_vfunc())
+       {
+               g_warning("LayerTreeStore::set_value_impl: Bad column (%d)",column);
+               return;
+       }
+
+       if(!g_value_type_compatible(G_VALUE_TYPE(value.gobj()),get_column_type_vfunc(column)))
+       {
+               g_warning("LayerTreeStore::set_value_impl: Bad value type");
+               return;
+       }
+
+       try
+       {
+               if(column==model.value.index())
+               {
+                       Glib::Value<synfig::ValueBase> x;
+                       g_value_init(x.gobj(),model.value.type());
+                       g_value_copy(value.gobj(),x.gobj());
+
+                       if((bool)(*iter)[model.is_toplevel])
+                       {
+                               synfigapp::Action::PassiveGrouper group(canvas_interface()->get_instance().get(),_("Set Layer Params"));
+
+                               synfig::ParamDesc param_desc((*iter)[model.param_desc]);
+
+                               LayerList::iterator iter2(layer_list.begin());
+
+                               for(;iter2!=layer_list.end();++iter2)
+                               {
+                                       if(!canvas_interface()->change_value(synfigapp::ValueDesc(*iter2,param_desc.get_name()),x.get()))
+                                       {
+                                               // ERROR!
+                                               group.cancel();
+                                               App::dialog_error_blocking(_("Error"),_("Unable to set all layer parameters."));
+
+                                               return;
+                                       }
+                               }
+                       }
+                       else
+                       {
+                               canvas_interface()->change_value((*iter)[model.value_desc],x.get());
+                       }
+                       return;
+               }
+               else
+/*
+               if(column==model.active.index())
+               {
+                       synfig::Layer::Handle layer((*iter)[model.layer]);
+
+                       if(!layer)return;
+
+                       Glib::Value<bool> x;
+                       g_value_init(x.gobj(),model.active.type());
+                       g_value_copy(value.gobj(),x.gobj());
+
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerActivate"));
+
+                       if(!action)
+                               return;
+
+                       action->set_param("canvas",canvas_interface()->get_canvas());
+                       action->set_param("canvas_interface",canvas_interface());
+                       action->set_param("layer",layer);
+                       action->set_param("new_status",bool(x.get()));
+
+                       canvas_interface()->get_instance()->perform_action(action);
+                       return;
+               }
+               else
+*/
+               CanvasTreeStore::set_value_impl(iter,column, value);
+       }
+       catch(std::exception x)
+       {
+               g_warning("%s", x.what());
+       }
+}
+
+
+
+
+
+
+
+
+
+
+void
+LayerParamTreeStore::rebuild()
+{
+       // Profiler profiler("LayerParamTreeStore::rebuild()");
+       if(queued)queued=0;
+       clear();
+       layer_list=layer_tree->get_selected_layers();
+
+       if(layer_list.size()<=0)
+               return;
+
+       // Get rid of all the connections,
+       // and clear the connection map.
+       //while(!connection_map.empty())connection_map.begin()->second.disconnect(),connection_map.erase(connection_map.begin());
+       while(!changed_connection_list.empty())
+       {
+               changed_connection_list.back().disconnect();
+               changed_connection_list.pop_back();
+       }
+
+       struct REBUILD_HELPER
+       {
+               ParamVocab vocab;
+               Layer::Handle layer_0;
+
+               static ParamVocab::iterator find_param_desc(ParamVocab& vocab, const synfig::String& x)
+               {
+                       ParamVocab::iterator iter;
+
+                       for(iter=vocab.begin();iter!=vocab.end();++iter)
+                               if(iter->get_name()==x)
+                                       break;
+                       return iter;
+               }
+
+               void process_vocab(synfig::Layer::Handle layer_n)
+               {
+                       ParamVocab x = layer_n->get_param_vocab();
+                       ParamVocab::iterator iter;
+
+                       for(iter=vocab.begin();iter!=vocab.end();++iter)
+                       {
+                               String name(iter->get_name());
+                               ParamVocab::iterator iter2(find_param_desc(x,name));
+                               if(iter2==x.end() ||
+                                  layer_0->get_param(name).get_type() != layer_n->get_param(name).get_type())
+                               {
+                                       // remove it and start over
+                                       vocab.erase(iter);
+                                       iter=vocab.begin();
+                                       iter--;
+                                       continue;
+                               }
+                       }
+               }
+
+       } rebuild_helper;
+
+
+       {
+               LayerList::iterator iter(layer_list.begin());
+               rebuild_helper.vocab=(*iter)->get_param_vocab();
+               rebuild_helper.layer_0=*iter;
+
+               for(++iter;iter!=layer_list.end();++iter)
+               {
+                       rebuild_helper.process_vocab(*iter);
+                       changed_connection_list.push_back(
+                               (*iter)->signal_changed().connect(
+                                       sigc::mem_fun(
+                                               *this,
+                                               &LayerParamTreeStore::changed
+                                       )
+                               )
+                       );
+               }
+       }
+
+       ParamVocab::iterator iter;
+       for(iter=rebuild_helper.vocab.begin();iter!=rebuild_helper.vocab.end();++iter)
+       {
+               if(iter->get_hidden())
+                       continue;
+
+               /*
+               if(iter->get_animation_only())
+               {
+                       int length(layer_list.front()->get_canvas()->rend_desc().get_frame_end()-layer_list.front()->get_canvas()->rend_desc().get_frame_start());
+                       if(!length)
+                               continue;
+               }
+               */
+               Gtk::TreeRow row(*(append()));
+               synfigapp::ValueDesc value_desc(layer_list.front(),iter->get_name());
+               CanvasTreeStore::set_row(row,value_desc);
+               if(value_desc.is_value_node())
+               {
+                       changed_connection_list.push_back(
+                               value_desc.get_value_node()->signal_changed().connect(
+                                       sigc::mem_fun(
+                                               this,
+                                               &LayerParamTreeStore::changed
+                                       )
+                               )
+                       );
+               }
+               if(value_desc.get_value_type()==ValueBase::TYPE_CANVAS)
+               {
+                       Canvas::Handle canvas_handle = value_desc.get_value().get(Canvas::Handle());
+                       if(canvas_handle) changed_connection_list.push_back(
+                               canvas_handle->signal_changed().connect(
+                                       sigc::mem_fun(
+                                               this,
+                                               &LayerParamTreeStore::changed
+                                       )
+                               )
+                       );
+               }
+               //row[model.label] = iter->get_local_name();
+               row[model.param_desc] = *iter;
+               row[model.canvas] = layer_list.front()->get_canvas();
+               row[model.is_inconsistent] = false;
+               //row[model.is_toplevel] = true;
+
+
+               LayerList::iterator iter2(layer_list.begin());
+               ValueBase value((*iter2)->get_param(iter->get_name()));
+               for(++iter2;iter2!=layer_list.end();++iter2)
+               {
+                       if(value!=((*iter2)->get_param(iter->get_name())))
+                       {
+                               row[model.is_inconsistent] = true;
+                               while(!row.children().empty() && erase(row.children().begin()))
+                                       ;
+                               break;
+                       }
+               }
+       }
+}
+
+void
+LayerParamTreeStore::queue_refresh()
+{
+       if(queued)
+               return;
+       queued=1;
+       queue_connection.disconnect();
+       queue_connection=Glib::signal_timeout().connect(
+               sigc::bind_return(
+                       sigc::mem_fun(*this,&LayerParamTreeStore::refresh),
+                       false
+               )
+       ,150);
+
+}
+
+void
+LayerParamTreeStore::queue_rebuild()
+{
+       if(queued==2)
+               return;
+       queued=2;
+       queue_connection.disconnect();
+       queue_connection=Glib::signal_timeout().connect(
+               sigc::bind_return(
+                       sigc::mem_fun(*this,&LayerParamTreeStore::rebuild),
+                       false
+               )
+       ,150);
+
+}
+
+void
+LayerParamTreeStore::refresh()
+{
+       if(queued)queued=0;
+
+       Gtk::TreeModel::Children children_(children());
+
+       Gtk::TreeModel::Children::iterator iter;
+
+       if(!children_.empty())
+               for(iter = children_.begin(); iter && iter != children_.end(); ++iter)
+               {
+                       Gtk::TreeRow row=*iter;
+                       refresh_row(row);
+               }
+}
+
+void
+LayerParamTreeStore::refresh_row(Gtk::TreeModel::Row &row)
+{
+       if(row[model.is_toplevel])
+       {
+               row[model.is_inconsistent] = false;
+               ParamDesc param_desc(row[model.param_desc]);
+
+               LayerList::iterator iter2(layer_list.begin());
+               ValueBase value((*iter2)->get_param(param_desc.get_name()));
+               for(++iter2;iter2!=layer_list.end();++iter2)
+               {
+                       if(value!=((*iter2)->get_param(param_desc.get_name())))
+                       {
+                               row[model.is_inconsistent] = true;
+                               while(!row.children().empty() && erase(row.children().begin()))
+                                       ;
+                               return;
+                       }
+               }
+       }
+
+       //handle<ValueNode> value_node=row[model.value_node];
+       //if(value_node)
+       {
+               CanvasTreeStore::refresh_row(row);
+               return;
+       }
+}
+
+void
+LayerParamTreeStore::set_row(Gtk::TreeRow row,synfigapp::ValueDesc value_desc)
+{
+       Gtk::TreeModel::Children children = row.children();
+       while(!children.empty() && erase(children.begin()))
+               ;
+
+       CanvasTreeStore::set_row(row,value_desc);
+}
+
+void
+LayerParamTreeStore::on_value_node_added(synfig::ValueNode::Handle /*value_node*/)
+{
+//     queue_refresh();
+}
+
+void
+LayerParamTreeStore::on_value_node_deleted(synfig::ValueNode::Handle /*value_node*/)
+{
+//     queue_refresh();
+}
+
+void
+LayerParamTreeStore::on_value_node_child_added(synfig::ValueNode::Handle /*value_node*/,synfig::ValueNode::Handle /*child*/)
+{
+       queue_rebuild();
+}
+
+void
+LayerParamTreeStore::on_value_node_child_removed(synfig::ValueNode::Handle /*value_node*/,synfig::ValueNode::Handle /*child*/)
+{
+       rebuild();
+}
+
+void
+LayerParamTreeStore::on_value_node_changed(synfig::ValueNode::Handle /*value_node*/)
+{
+       queue_refresh();
+}
+
+void
+LayerParamTreeStore::on_value_node_renamed(synfig::ValueNode::Handle /*value_node*/)
+{
+       rebuild();
+}
+
+void
+LayerParamTreeStore::on_value_node_replaced(synfig::ValueNode::Handle /*replaced_value_node*/,synfig::ValueNode::Handle /*new_value_node*/)
+{
+       queue_rebuild();
+}
+
+void
+LayerParamTreeStore::on_layer_param_changed(synfig::Layer::Handle /*handle*/,synfig::String /*param_name*/)
+{
+       queue_refresh();
+}
diff --git a/synfig-studio/src/gui/layerparamtreestore.h b/synfig-studio/src/gui/layerparamtreestore.h
new file mode 100644 (file)
index 0000000..ce96cbe
--- /dev/null
@@ -0,0 +1,166 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file layerparamtreestore.h
+**     \brief Template Header
+**
+**     $Id$
+**
+**     \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
+**     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_LAYERPARAMTREESTORE_H
+#define __SYNFIG_STUDIO_LAYERPARAMTREESTORE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/treestore.h>
+#include <synfigapp/canvasinterface.h>
+#include "canvastreestore.h"
+#include <synfig/value.h>
+#include <synfig/valuenode.h>
+#include <synfig/paramdesc.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 LayerTree;
+
+class LayerParamTreeStore : public CanvasTreeStore
+{
+       /*
+ -- ** -- P U B L I C   T Y P E S ---------------------------------------------
+       */
+
+public:
+       typedef std::list<synfig::Layer::Handle> LayerList;
+
+       /*
+ -- ** -- P U B L I C  D A T A ------------------------------------------------
+       */
+
+public:
+
+       //! TreeModel for the layer parameters
+       class Model : public CanvasTreeStore::Model
+       {
+       public:
+
+               Gtk::TreeModelColumn<synfig::ParamDesc> param_desc;
+
+               Gtk::TreeModelColumn<bool>      is_inconsistent;
+               Gtk::TreeModelColumn<bool>      is_toplevel;
+
+               Model()
+               {
+                       add(param_desc);
+                       add(is_inconsistent);
+                       add(is_toplevel);
+               }
+       };
+
+       Model model;
+
+
+       /*
+ -- ** -- P R I V A T E   D A T A ---------------------------------------------
+       */
+
+private:
+
+       int queued;
+
+       LayerTree* layer_tree;
+
+       LayerList layer_list;
+
+       sigc::connection queue_connection;
+
+       std::list<sigc::connection> changed_connection_list;
+
+       sigc::signal<void> signal_changed_;
+
+       /*
+ -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
+       */
+
+private:
+
+protected:
+       virtual void  get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const;
+       virtual void set_value_impl (const Gtk::TreeModel::iterator& row, int column, const Glib::ValueBase& value);
+       virtual void set_row(Gtk::TreeRow row,synfigapp::ValueDesc value_desc);
+
+       /*
+ -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
+       */
+
+private:
+
+       void on_value_node_child_added(synfig::ValueNode::Handle value_node,synfig::ValueNode::Handle child);
+       void on_value_node_child_removed(synfig::ValueNode::Handle value_node,synfig::ValueNode::Handle child);
+
+       void on_value_node_added(synfig::ValueNode::Handle value_node);
+       void on_value_node_deleted(synfig::ValueNode::Handle value_node);
+       virtual void on_value_node_changed(synfig::ValueNode::Handle value_node);
+       virtual void on_value_node_renamed(synfig::ValueNode::Handle value_node);
+       void on_value_node_replaced(synfig::ValueNode::Handle replaced_value_node,synfig::ValueNode::Handle new_value_node);
+       void on_layer_param_changed(synfig::Layer::Handle handle,synfig::String param_name);
+
+       /*
+ -- ** -- P U B L I C   M E T H O D S -----------------------------------------
+       */
+
+public:
+
+       LayerParamTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_,
+               LayerTree* layer_tree);
+       ~LayerParamTreeStore();
+
+       void rebuild();
+
+       void refresh();
+
+       void queue_refresh();
+
+       void queue_rebuild();
+
+       void refresh_row(Gtk::TreeModel::Row &row);
+
+       sigc::signal<void>& signal_changed() { return signal_changed_; }
+
+       void changed() { signal_changed_(); }
+
+       /*
+ -- ** -- S T A T I C   P U B L I C   M E T H O D S ---------------------------
+       */
+
+public:
+
+       static Glib::RefPtr<LayerParamTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_, LayerTree*layer_tree);
+}; // END of class LayerParamTreeStore
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/layertree.cpp b/synfig-studio/src/gui/layertree.cpp
new file mode 100644 (file)
index 0000000..a69f234
--- /dev/null
@@ -0,0 +1,1232 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file layertree.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 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 <config.h>
+#endif
+
+#include "layertree.h"
+#include "layerparamtreestore.h"
+#include "cellrenderer_value.h"
+#include "cellrenderer_timetrack.h"
+#include <synfigapp/action.h>
+#include <synfigapp/instance.h>
+#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/paned.h>
+#include "app.h"
+#include "instance.h"
+#include <gtkmm/treemodelsort.h>
+
+#ifdef TIMETRACK_IN_PARAMS_PANEL
+#  include <synfig/timepointcollect.h>
+#endif // TIMETRACK_IN_PARAMS_PANEL
+
+#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 SMALL_BUTTON
+#define SMALL_BUTTON(button,stockid,tooltip)   \
+       button = manage(new class Gtk::Button());       \
+       icon=manage(new Gtk::Image(Gtk::StockID(stockid),iconsize));    \
+       button->add(*icon);     \
+       tooltips_.set_tip(*button,tooltip);     \
+       icon->set_padding(0,0);\
+       icon->show();   \
+       button->set_relief(Gtk::RELIEF_NONE); \
+       button->show()
+#endif
+
+#ifndef NORMAL_BUTTON
+#define NORMAL_BUTTON(button,stockid,tooltip)  \
+       button = manage(new class Gtk::Button());       \
+       icon=manage(new Gtk::Image(Gtk::StockID(stockid),Gtk::ICON_SIZE_BUTTON));       \
+       button->add(*icon);     \
+       tooltips_.set_tip(*button,tooltip);     \
+       icon->set_padding(0,0);\
+       icon->show();   \
+       /*button->set_relief(Gtk::RELIEF_NONE);*/ \
+       button->show()
+#endif
+
+#define NEW_SMALL_BUTTON(x,y,z)        Gtk::Button *SMALL_BUTTON(x,y,z)
+
+#define NOT_IMPLEMENTED_SLOT sigc::mem_fun(*reinterpret_cast<studio::CanvasViewUIInterface*>(get_ui_interface().get()),&studio::CanvasViewUIInterface::not_implemented)
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+LayerTree::LayerTree():
+       layer_amount_adjustment_(1,0,1,0.01,0.01,0)
+{
+       param_tree_view_=new Gtk::TreeView;
+       layer_tree_view_=new Gtk::TreeView;
+
+       //Gtk::HPaned* hpaned(manage(new Gtk::HPaned()));
+       //hpaned->show();
+       //attach(*hpaned, 0, 3, 0, 1, Gtk::EXPAND|Gtk::FILL,Gtk::EXPAND|Gtk::FILL, 0, 0);
+       //attach(*create_layer_tree(), 0, 3, 0, 1, Gtk::EXPAND|Gtk::FILL,Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       create_layer_tree();
+       create_param_tree();
+
+       //hpaned->pack1(*create_layer_tree(),false,false);
+       //hpaned->pack2(*create_param_tree(),true,false);
+       //hpaned->set_position(200);
+       hbox=manage(new Gtk::HBox());
+
+       attach(*hbox, 0, 1, 1, 2, Gtk::FILL|Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       attach(blend_method_widget, 2, 3, 1, 2,Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+
+       layer_amount_hscale=manage(new Gtk::HScale(layer_amount_adjustment_));
+       layer_amount_hscale->set_digits(2);
+       layer_amount_hscale->set_value_pos(Gtk::POS_LEFT);
+       layer_amount_hscale->set_sensitive(false);
+       layer_amount_hscale->set_update_policy( Gtk::UPDATE_DISCONTINUOUS);
+       attach(*layer_amount_hscale, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK, 1, 1);
+       layer_amount_adjustment_.signal_value_changed().connect(sigc::mem_fun(*this, &studio::LayerTree::on_amount_value_changed));
+
+       Gtk::Image *icon;
+       //Gtk::IconSize iconsize(Gtk::IconSize::from_name("synfig-small_icon"));
+       Gtk::IconSize iconsize(Gtk::ICON_SIZE_SMALL_TOOLBAR);
+
+       SMALL_BUTTON(button_raise,"gtk-go-up","Raise");
+       SMALL_BUTTON(button_lower,"gtk-go-down","Lower");
+       SMALL_BUTTON(button_duplicate,"synfig-duplicate","Duplicate");
+       SMALL_BUTTON(button_encapsulate,"synfig-encapsulate","Encapsulate");
+       SMALL_BUTTON(button_delete,"gtk-delete","Delete");
+
+       hbox->pack_start(*button_raise,Gtk::PACK_SHRINK);
+       hbox->pack_start(*button_lower,Gtk::PACK_SHRINK);
+       hbox->pack_start(*button_duplicate,Gtk::PACK_SHRINK);
+       hbox->pack_start(*button_encapsulate,Gtk::PACK_SHRINK);
+       hbox->pack_start(*button_delete,Gtk::PACK_SHRINK);
+
+       // button_raise->signal_clicked().connect(sigc::mem_fun(*this, &studio::LayerTree::on_raise_pressed));
+       // button_lower->signal_clicked().connect(sigc::mem_fun(*this, &studio::LayerTree::on_lower_pressed));
+       // button_duplicate->signal_clicked().connect(sigc::mem_fun(*this, &studio::LayerTree::on_duplicate_pressed));
+       // button_encapsulate->signal_clicked().connect(sigc::mem_fun(*this, &studio::LayerTree::on_encapsulate_pressed));
+       // button_delete->signal_clicked().connect(sigc::mem_fun(*this, &studio::LayerTree::on_delete_pressed));
+
+       button_raise->set_sensitive(false);
+       button_lower->set_sensitive(false);
+       button_duplicate->set_sensitive(false);
+       button_encapsulate->set_sensitive(false);
+       button_delete->set_sensitive(false);
+
+       get_selection()->signal_changed().connect(sigc::mem_fun(*this, &studio::LayerTree::on_selection_changed));
+
+       get_layer_tree_view().set_reorderable(true);
+       get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
+       //get_param_tree_view().get_selection()->set_mode(Gtk::SELECTION_MULTIPLE);
+       get_layer_tree_view().show();
+       get_param_tree_view().show();
+
+       hbox->show();
+       layer_amount_hscale->show();
+       blend_method_widget.show();
+
+       tooltips_.enable();
+       disable_amount_changed_signal=false;
+
+       blend_method_widget.set_param_desc(ParamDesc(Color::BlendMethod(),"blend_method"));
+
+       blend_method_widget.set_value((int)Color::BLEND_COMPOSITE);
+       blend_method_widget.set_size_request(150,-1);
+       blend_method_widget.set_sensitive(false);
+       blend_method_widget.signal_activate().connect(sigc::mem_fun(*this, &studio::LayerTree::on_blend_method_changed));
+}
+
+LayerTree::~LayerTree()
+{
+       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
+               synfig::info("LayerTree::~LayerTree(): Deleted");
+}
+
+Gtk::Widget*
+LayerTree::create_layer_tree()
+{
+       const LayerTreeStore::Model model;
+
+       {       // --- O N / O F F ----------------------------------------------------
+               //int index;
+               //index=get_layer_tree_view().append_column_editable(_(" "),layer_model.active);
+               //Gtk::TreeView::Column* column = get_layer_tree_view().get_column(index-1);
+
+               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_(" ")) );
+
+               // Set up the icon cell-renderer
+               Gtk::CellRendererToggle* cellrenderer = Gtk::manage( new Gtk::CellRendererToggle() );
+               cellrenderer->signal_toggled().connect(sigc::mem_fun(*this, &studio::LayerTree::on_layer_toggle));
+
+               column->pack_start(*cellrenderer,false);
+               column->add_attribute(cellrenderer->property_active(), layer_model.active);
+               get_layer_tree_view().append_column(*column);
+       }
+
+       {       // --- I C O N --------------------------------------------------------
+               int index;
+               index=get_layer_tree_view().append_column(_("Z"),layer_model.icon);
+               Gtk::TreeView::Column* column = get_layer_tree_view().get_column(index-1);
+               get_layer_tree_view().set_expander_column(*column);
+
+               column->set_sort_column(layer_model.z_depth);
+               //column->set_reorderable();
+               //column->set_resizable();
+               //column->set_clickable();
+
+               //Gtk::CellRendererPixbuf* icon_cellrenderer = Gtk::manage( new Gtk::CellRendererPixbuf() );
+               //column->pack_start(*icon_cellrenderer,false);
+               //column->add_attribute(icon_cellrenderer->property_pixbuf(), layer_model.icon);
+       }
+       //get_layer_tree_view().append_column(_("Z"),layer_model.z_depth);
+       {       // --- N A M E --------------------------------------------------------
+               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Name")) );
+
+               // Set up the icon cell-renderer
+               Gtk::CellRendererText* cellrenderer = Gtk::manage( new Gtk::CellRendererText() );
+               column->pack_start(*cellrenderer,false);
+               column->add_attribute(cellrenderer->property_text(), layer_model.label);
+               cellrenderer->signal_edited().connect(sigc::mem_fun(*this, &studio::LayerTree::on_layer_renamed));
+               cellrenderer->property_editable()=true;
+
+               column->set_reorderable();
+               // column->set_resizable();
+               column->set_clickable(true);
+               column->set_sort_column(layer_model.label);
+
+               get_layer_tree_view().append_column(*column);
+
+               //              int index;
+//             index=get_layer_tree_view().append_column_editable(_("Layer"),layer_model.label);
+               //Gtk::TreeView::Column* column = get_layer_tree_view().get_column(index-1);
+
+               //get_layer_tree_view().set_expander_column(*column);
+
+               //Gtk::CellRendererPixbuf* icon_cellrenderer = Gtk::manage( new Gtk::CellRendererPixbuf() );
+               //column->pack_start(*icon_cellrenderer,false);
+               //column->add_attribute(icon_cellrenderer->property_pixbuf(), layer_model.icon);
+       }
+       {       // --- Z D E P T H ----------------------------------------------------
+               int index;
+               index=get_layer_tree_view().append_column(_("Z"),layer_model.z_depth);
+               column_z_depth=get_layer_tree_view().get_column(index-1);
+
+               column_z_depth->set_reorderable();
+               column_z_depth->set_resizable();
+               column_z_depth->set_clickable();
+
+               column_z_depth->set_sort_column(layer_model.z_depth);
+       }
+
+       get_layer_tree_view().set_enable_search(true);
+       get_layer_tree_view().set_search_column(layer_model.label);
+       get_layer_tree_view().set_search_equal_func(sigc::ptr_fun(&studio::LayerTreeStore::search_func));
+
+       std::list<Gtk::TargetEntry> listTargets;
+       listTargets.push_back( Gtk::TargetEntry("LAYER") );
+       get_layer_tree_view().drag_dest_set(listTargets);
+
+       // This makes things easier to read.
+       get_layer_tree_view().set_rules_hint();
+
+       // Make us more sensitive to several events
+       //get_layer_tree_view().add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::BUTTON1_MOTION_MASK | Gdk::BUTTON2_MOTION_MASK|Gdk::POINTER_MOTION_MASK);
+
+       get_layer_tree_view().signal_event().connect(sigc::mem_fun(*this, &studio::LayerTree::on_layer_tree_event));
+       get_layer_tree_view().show();
+
+       Gtk::ScrolledWindow *scroll = manage(new class Gtk::ScrolledWindow());
+       scroll->set_flags(Gtk::CAN_FOCUS);
+       scroll->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+       //scroll->add(get_layer_tree_view());
+       scroll->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
+       scroll->show();
+
+       return scroll;
+}
+
+Gtk::Widget*
+LayerTree::create_param_tree()
+{
+       Pango::AttrList attr_list;
+       {
+               Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*8));
+               pango_size.set_start_index(0);
+               pango_size.set_end_index(64);
+               attr_list.change(pango_size);
+       }
+
+       Gtk::IconSize icon_size(Gtk::ICON_SIZE_SMALL_TOOLBAR);
+
+       {       // --- N A M E --------------------------------------------------------
+               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Name")) );
+
+               // Set up the icon cell-renderer
+               Gtk::CellRendererPixbuf* icon_cellrenderer = Gtk::manage( new Gtk::CellRendererPixbuf() );
+               column->pack_start(*icon_cellrenderer,false);
+               column->add_attribute(icon_cellrenderer->property_pixbuf(), param_model.icon);
+
+               // Pack the label into the column
+               //column->pack_start(layer_model.label,true);
+               Gtk::CellRendererText* text_cellrenderer = Gtk::manage( new Gtk::CellRendererText() );
+               column->pack_start(*text_cellrenderer,false);
+               column->add_attribute(text_cellrenderer->property_text(), param_model.label);
+               text_cellrenderer->property_attributes()=attr_list;
+
+               text_cellrenderer->property_foreground()=Glib::ustring("#7f7f7f");
+               column->add_attribute(text_cellrenderer->property_foreground_set(),param_model.is_inconsistent);
+
+               // Pack the label into the column
+               //column->pack_start(param_model.label,true);
+
+               // Set up the value-node icon cell-renderer to be on the far right
+               Gtk::CellRendererPixbuf* valuenode_icon_cellrenderer = Gtk::manage( new Gtk::CellRendererPixbuf() );
+               column->pack_end(*valuenode_icon_cellrenderer,false);
+               valuenode_icon_cellrenderer->property_pixbuf()=Gtk::Button().render_icon(Gtk::StockID("synfig-value_node"),icon_size);
+               column->add_attribute(valuenode_icon_cellrenderer->property_visible(), param_model.is_shared);
+
+               // Finish setting up the column
+               column->set_reorderable();
+               column->set_resizable();
+               column->set_clickable();
+
+               get_param_tree_view().append_column(*column);
+       }
+       {       // --- V A L U E  -----------------------------------------------------
+               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Value")) );
+
+               // Set up the value cell-renderer
+               cellrenderer_value=LayerParamTreeStore::add_cell_renderer_value(column);
+               cellrenderer_value->signal_edited().connect(sigc::mem_fun(*this, &studio::LayerTree::on_edited_value));
+               cellrenderer_value->property_value()=synfig::ValueBase();
+               column->add_attribute(cellrenderer_value->property_param_desc(), param_model.param_desc);
+               column->add_attribute(cellrenderer_value->property_inconsistent(),param_model.is_inconsistent);
+               //cellrenderer_value->property_canvas()=canvas_interface->get_canvas(); // Is this line necessary?
+               cellrenderer_value->property_attributes()=attr_list;
+
+               // Finish setting up the column
+               get_param_tree_view().append_column(*column);
+               column->set_sizing(Gtk::TREE_VIEW_COLUMN_AUTOSIZE);
+               column->set_clickable();
+               column->set_min_width(120);
+               column->set_reorderable();
+               column->set_resizable();
+       }
+       {       // --- T Y P E --------------------------------------------------------
+               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Type")) );
+               Gtk::CellRendererText* text_cellrenderer = Gtk::manage( new Gtk::CellRendererText() );
+               column->pack_start(*text_cellrenderer,false);
+               column->add_attribute(text_cellrenderer->property_text(), param_model.type);
+               text_cellrenderer->property_attributes()=attr_list;
+               get_param_tree_view().append_column(*column);
+               column->set_reorderable();
+               column->set_resizable();
+               column->set_clickable();
+               column->set_sort_column(param_model.type);
+       }
+#ifdef TIMETRACK_IN_PARAMS_PANEL
+       {       // --- T I M E   T R A C K --------------------------------------------
+               Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Time Track")) );
+               column_time_track=column;
+
+               // Set up the value-node cell-renderer
+               cellrenderer_time_track=LayerParamTreeStore::add_cell_renderer_value_node(column);
+               cellrenderer_time_track->property_mode()=Gtk::CELL_RENDERER_MODE_ACTIVATABLE;
+               cellrenderer_time_track->signal_waypoint_clicked_cellrenderer().connect(sigc::mem_fun(*this, &studio::LayerTree::on_waypoint_clicked_layertree) );
+               cellrenderer_time_track->signal_waypoint_changed().connect(sigc::mem_fun(*this, &studio::LayerTree::on_waypoint_changed) );
+               column->add_attribute(cellrenderer_time_track->property_value_desc(), param_model.value_desc);
+               column->add_attribute(cellrenderer_time_track->property_canvas(), param_model.canvas);
+               column->add_attribute(cellrenderer_time_track->property_visible(), param_model.is_value_node);
+
+               // Finish setting up the column
+               column->set_reorderable();
+               column->set_resizable();
+               column->set_min_width(200);
+
+               if (!getenv("SYNFIG_DISABLE_PARAMS_PANEL_TIMETRACK"))
+                       get_param_tree_view().append_column(*column);
+       }
+#endif // TIMETRACK_IN_PARAMS_PANEL
+
+       // This makes things easier to read.
+       get_param_tree_view().set_rules_hint();
+
+       // Make us more sensitive to several events
+       get_param_tree_view().add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::BUTTON1_MOTION_MASK | Gdk::BUTTON2_MOTION_MASK|Gdk::POINTER_MOTION_MASK);
+
+       get_param_tree_view().signal_event().connect(sigc::mem_fun(*this, &studio::LayerTree::on_param_tree_event));
+       get_param_tree_view().show();
+
+       Gtk::ScrolledWindow *scroll = manage(new class Gtk::ScrolledWindow());
+       scroll->set_flags(Gtk::CAN_FOCUS);
+       scroll->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
+       //scroll->add(get_param_tree_view());
+       scroll->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
+       scroll->show();
+
+       //column_time_track->set_visible(false);
+
+       return scroll;
+}
+
+void
+LayerTree::on_waypoint_changed( synfig::Waypoint waypoint , synfig::ValueNode::Handle value_node)
+{
+       synfigapp::Action::ParamList param_list;
+       param_list.add("canvas",layer_tree_store_->canvas_interface()->get_canvas());
+       param_list.add("canvas_interface",layer_tree_store_->canvas_interface());
+       param_list.add("value_node",value_node);
+       param_list.add("waypoint",waypoint);
+//     param_list.add("time",canvas_interface()->get_time());
+
+       etl::handle<studio::Instance>::cast_static(layer_tree_store_->canvas_interface()->get_instance())->process_action("WaypointSetSmart", param_list);
+}
+
+void
+LayerTree::select_layer(synfig::Layer::Handle layer)
+{
+       Gtk::TreeModel::Children::iterator iter;
+       if(layer_tree_store_->find_layer_row(layer,iter))
+       {
+               if(sorted_layer_tree_store_)
+                       iter=sorted_layer_tree_store_->convert_child_iter_to_iter(iter);
+
+               Gtk::TreePath path(iter);
+               for(int i=path.get_depth();i;i--)
+               {
+                       int j;
+                       path=Gtk::TreePath(iter);
+                       for(j=i;j;j--)
+                               path.up();
+                       get_layer_tree_view().expand_row(path,false);
+               }
+               get_layer_tree_view().scroll_to_row(Gtk::TreePath(iter));
+               get_layer_tree_view().get_selection()->select(iter);
+       }
+}
+
+void
+LayerTree::select_all_children(Gtk::TreeModel::Children::iterator iter)
+{
+       get_layer_tree_view().get_selection()->select(iter);
+       if((bool)(*iter)[layer_model.children_lock])
+               return;
+       get_layer_tree_view().expand_row(layer_tree_store_->get_path(iter),false);
+       Gtk::TreeModel::Children children(iter->children());
+       for(iter=children.begin();iter!=children.end();++iter)
+               select_all_children(iter);
+}
+
+void
+LayerTree::select_all_children_layers(synfig::Layer::Handle layer)
+{
+       Gtk::TreeModel::Children::iterator iter;
+       if(layer_tree_store_->find_layer_row(layer,iter))
+               select_all_children(iter);
+}
+
+void
+LayerTree::select_layers(const LayerList &layer_list)
+{
+       LayerList::const_iterator iter;
+       for(iter = layer_list.begin(); iter != layer_list.end(); ++iter)
+               select_layer(*iter);
+}
+
+static inline void __layer_grabber(const Gtk::TreeModel::iterator& iter, LayerTree::LayerList* ret)
+{
+       const LayerTreeStore::Model layer_tree_model;
+       ret->push_back((Layer::Handle)(*iter)[layer_tree_model.layer]);
+}
+
+LayerTree::LayerList
+LayerTree::get_selected_layers()const
+{
+       Glib::RefPtr<Gtk::TreeSelection> selection=const_cast<Gtk::TreeView&>(get_layer_tree_view()).get_selection();
+
+       if(!selection)
+               return LayerList();
+
+       LayerList ret;
+
+       selection->selected_foreach_iter(
+               sigc::bind(
+                       sigc::ptr_fun(
+                               &__layer_grabber
+                       ),
+                       &ret
+               )
+       );
+
+       return ret;
+}
+
+synfig::Layer::Handle
+LayerTree::get_selected_layer()const
+{
+       LayerList layers(get_selected_layers());
+
+       if(layers.empty())
+               return 0;
+
+       return *layers.begin();
+}
+
+void
+LayerTree::clear_selected_layers()
+{
+       get_layer_tree_view().get_selection()->unselect_all();
+}
+
+void
+LayerTree::set_show_timetrack(bool x)
+{
+       //column_time_track->set_visible(x);
+//     column_time_track->set_visible(false);
+       column_z_depth->set_visible(x);
+}
+
+void
+LayerTree::set_model(Glib::RefPtr<LayerTreeStore> layer_tree_store)
+{
+       layer_tree_store_=layer_tree_store;
+
+       if(false)
+       {
+               sorted_layer_tree_store_=Gtk::TreeModelSort::create(layer_tree_store);
+
+               sorted_layer_tree_store_->set_default_sort_func(sigc::ptr_fun(&studio::LayerTreeStore::z_sorter));
+
+               //sorted_store->set_sort_func(model.time.index(),sigc::mem_fun(&studio::KeyframeTreeStore::time_sorter));
+               //sorted_store->set_sort_column(model.time.index(), Gtk::SORT_ASCENDING);
+
+               get_layer_tree_view().set_model(sorted_layer_tree_store_);
+       }
+       else
+               get_layer_tree_view().set_model(layer_tree_store_);
+
+       layer_tree_store_->canvas_interface()->signal_dirty_preview().connect(sigc::mem_fun(*this,&studio::LayerTree::on_dirty_preview));
+
+       //layer_tree_store_->canvas_interface()->signal_dirty_preview().connect(sigc::mem_fun(*this,&studio::LayerTree::on_dirty_preview));
+
+       layer_tree_store_->canvas_interface()->signal_time_changed().connect(
+               sigc::mem_fun(
+                       &get_param_tree_view(),
+                       &Gtk::Widget::queue_draw
+               )
+       );
+       if(!param_tree_store_)
+       {
+               param_tree_store_=LayerParamTreeStore::create(layer_tree_store_->canvas_interface(), this);
+               get_param_tree_view().set_model(param_tree_store_);
+       }
+
+#ifdef TIMETRACK_IN_PARAMS_PANEL
+       if(cellrenderer_time_track && layer_tree_store_ && layer_tree_store_->canvas_interface())
+               cellrenderer_time_track->set_canvas_interface(layer_tree_store_->canvas_interface());
+#endif // TIMETRACK_IN_PARAMS_PANEL
+}
+
+void
+LayerTree::set_time_adjustment(Gtk::Adjustment &adjustment)
+{
+#ifdef TIMETRACK_IN_PARAMS_PANEL
+       cellrenderer_time_track->set_adjustment(adjustment);
+#endif // TIMETRACK_IN_PARAMS_PANEL
+       adjustment.signal_value_changed().connect(sigc::mem_fun(get_param_tree_view(),&Gtk::TreeView::queue_draw));
+       adjustment.signal_changed().connect(sigc::mem_fun(get_param_tree_view(),&Gtk::TreeView::queue_draw));
+}
+
+void
+LayerTree::on_dirty_preview()
+{
+/*
+       if(quick_layer && !disable_amount_changed_signal)
+       {
+               layer_amount_hscale->set_sensitive(true);
+               disable_amount_changed_signal=true;
+               layer_amount_adjustment_.set_value(quick_layer->get_param("amount").get(Real()));
+               disable_amount_changed_signal=false;
+               if(quick_layer->get_param("blend_method").is_valid())
+               {
+                       blend_method_widget.set_sensitive(true);
+                       disable_amount_changed_signal=true;
+                       blend_method_widget.set_value(quick_layer->get_param("blend_method"));
+                       disable_amount_changed_signal=false;
+               }
+       }
+*/
+}
+
+void
+LayerTree::on_selection_changed()
+{
+       synfigapp::SelectionManager::LayerList layer_list(get_selection_manager()->get_selected_layers());
+
+       Gtk::TreeIter iter;
+       if(last_top_selected_layer && !layer_tree_store_->find_layer_row(last_top_selected_layer,iter))
+       {
+               if(layer_list.empty())
+               {
+                       last_top_selected_layer=0;
+                       layer_tree_view_->get_selection()->select(last_top_selected_path);
+                       return;
+               }
+       }
+
+       {
+               if(!layer_list.empty())
+               {
+                       last_top_selected_layer=layer_list.front();
+                       last_top_selected_path=*layer_tree_view_->get_selection()->get_selected_rows().begin();
+               }
+               else
+               {
+                       last_top_selected_layer=0;
+               }
+       }
+
+       if(layer_list.empty())
+       {
+               button_raise->set_sensitive(false);
+               button_lower->set_sensitive(false);
+               button_duplicate->set_sensitive(false);
+               button_encapsulate->set_sensitive(false);
+               button_delete->set_sensitive(false);
+               layer_amount_hscale->set_sensitive(false);
+               blend_method_widget.set_sensitive(false);
+               return;
+       }
+
+       button_raise->set_sensitive(true);
+       button_lower->set_sensitive(true);
+       button_duplicate->set_sensitive(true);
+       button_encapsulate->set_sensitive(true);
+       button_delete->set_sensitive(true);
+
+       if(layer_list.size()==1 && (*layer_list.begin())->get_param("amount").is_valid()&& (*layer_list.begin())->get_param("amount").same_type_as(Real()))
+       {
+               quick_layer=*layer_list.begin();
+       }
+       else
+               quick_layer=0;
+
+       if(quick_layer)
+       {
+               layer_amount_hscale->set_sensitive(true);
+               disable_amount_changed_signal=true;
+               layer_amount_adjustment_.set_value(quick_layer->get_param("amount").get(Real()));
+               disable_amount_changed_signal=false;
+               if(quick_layer->get_param("blend_method").is_valid())
+               {
+                       blend_method_widget.set_sensitive(true);
+                       disable_amount_changed_signal=true;
+                       blend_method_widget.set_value(quick_layer->get_param("blend_method"));
+                       disable_amount_changed_signal=false;
+               }
+               else
+                       blend_method_widget.set_sensitive(false);
+       }
+       else
+       {
+               layer_amount_hscale->set_sensitive(false);
+               blend_method_widget.set_sensitive(false);
+       }
+}
+
+void
+LayerTree::on_blend_method_changed()
+{
+       if(disable_amount_changed_signal)
+               return;
+       if(!quick_layer)
+               return;
+
+       if(quick_layer->get_param("blend_method").is_valid())
+       {
+               disable_amount_changed_signal=true;
+               signal_edited_value()(synfigapp::ValueDesc(quick_layer,"blend_method"),blend_method_widget.get_value());
+               disable_amount_changed_signal=false;
+       }
+}
+
+void
+LayerTree::on_amount_value_changed()
+{
+       if(disable_amount_changed_signal)
+               return;
+       if(!quick_layer)
+               return;
+
+       disable_amount_changed_signal=true;
+       signal_edited_value()(synfigapp::ValueDesc(quick_layer,"amount"),synfig::ValueBase(layer_amount_adjustment_.get_value()));
+       disable_amount_changed_signal=false;
+}
+
+void
+LayerTree::on_edited_value(const Glib::ustring&path_string,synfig::ValueBase value)
+{
+       Gtk::TreePath path(path_string);
+
+       const Gtk::TreeRow row = *(get_param_tree_view().get_model()->get_iter(path));
+       if(!row)
+               return;
+       row[param_model.value]=value;
+       //signal_edited_value()(row[param_model.value_desc],value);
+}
+
+void
+LayerTree::on_layer_renamed(const Glib::ustring&path_string,const Glib::ustring& value)
+{
+       Gtk::TreePath path(path_string);
+
+       const Gtk::TreeRow row = *(get_layer_tree_view().get_model()->get_iter(path));
+       if(!row)
+               return;
+       row[layer_model.label]=value;
+       get_layer_tree_view().columns_autosize();
+}
+
+void
+LayerTree::on_layer_toggle(const Glib::ustring& path_string)
+{
+       Gtk::TreePath path(path_string);
+
+       const Gtk::TreeRow row = *(get_layer_tree_view().get_model()->get_iter(path));
+       bool active=static_cast<bool>(row[layer_model.active]);
+       row[layer_model.active]=!active;
+}
+
+#ifdef TIMETRACK_IN_PARAMS_PANEL
+void
+LayerTree::on_waypoint_clicked_layertree(const etl::handle<synfig::Node>& node __attribute__ ((unused)),
+                                                                                const synfig::Time& time __attribute__ ((unused)),
+                                                                                const synfig::Time& time_offset __attribute__ ((unused)),
+                                                                                int button __attribute__ ((unused)))
+{
+       std::set<synfig::Waypoint, std::less<UniqueID> > waypoint_set;
+       synfig::waypoint_collect(waypoint_set,time,node);
+
+       synfigapp::ValueDesc value_desc;
+
+       if (waypoint_set.size() == 1)
+       {
+               ValueNode::Handle value_node(waypoint_set.begin()->get_parent_value_node());
+               assert(value_node);
+
+               Gtk::TreeRow row;
+               if (param_tree_store_->find_first_value_node(value_node, row) && row)
+                       value_desc = static_cast<synfigapp::ValueDesc>(row[param_tree_store_->model.value_desc]);
+       }
+
+       if (!waypoint_set.empty())
+               signal_waypoint_clicked_layertree()(value_desc,waypoint_set,button);
+}
+#endif // TIMETRACK_IN_PARAMS_PANEL
+
+bool
+LayerTree::on_layer_tree_event(GdkEvent *event)
+{
+    switch(event->type)
+    {
+       case GDK_BUTTON_PRESS:
+               {
+                       Gtk::TreeModel::Path path;
+                       Gtk::TreeViewColumn *column;
+                       int cell_x, cell_y;
+                       if(!get_layer_tree_view().get_path_at_pos(
+                               int(event->button.x),int(event->button.y),      // x, y
+                               path, // TreeModel::Path&
+                               column, //TreeViewColumn*&
+                               cell_x,cell_y //int&cell_x,int&cell_y
+                               )
+                       ) break;
+                       const Gtk::TreeRow row = *(get_layer_tree_view().get_model()->get_iter(path));
+
+#ifdef TIMETRACK_IN_PARAMS_PANEL
+                       if(column->get_first_cell_renderer()==cellrenderer_time_track)
+                               return signal_layer_user_click()(event->button.button,row,COLUMNID_TIME_TRACK);
+                       else
+#endif // TIMETRACK_IN_PARAMS_PANEL
+                       if(column->get_first_cell_renderer()==cellrenderer_value)
+                               return signal_layer_user_click()(event->button.button,row,COLUMNID_VALUE);
+                       else
+                               return signal_layer_user_click()(event->button.button,row,COLUMNID_NAME);
+
+               }
+               break;
+
+       case GDK_MOTION_NOTIFY:
+               {
+                       Gtk::TreeModel::Path path;
+                       Gtk::TreeViewColumn *column;
+                       int cell_x, cell_y;
+                       if(!get_layer_tree_view().get_path_at_pos(
+                               (int)event->button.x,(int)event->button.y,      // x, y
+                               path, // TreeModel::Path&
+                               column, //TreeViewColumn*&
+                               cell_x,cell_y //int&cell_x,int&cell_y
+                               )
+                       ) break;
+
+                       if(!get_layer_tree_view().get_model()->get_iter(path))
+                               break;
+
+                       Gtk::TreeRow row = *(get_layer_tree_view().get_model()->get_iter(path));
+
+#ifdef TIMETRACK_IN_PARAMS_PANEL
+                       if(cellrenderer_time_track==column->get_first_cell_renderer())
+                               // Movement on TimeLine
+                               return true;
+                       else
+#endif // TIMETRACK_IN_PARAMS_PANEL
+                       if(last_tooltip_path.get_depth()<=0 || path!=last_tooltip_path)
+                       {
+                               tooltips_.unset_tip(*this);
+                               Glib::ustring tooltips_string(row[layer_model.tooltip]);
+                               last_tooltip_path=path;
+                               if(!tooltips_string.empty())
+                               {
+                                       tooltips_.set_tip(*this,tooltips_string);
+                                       tooltips_.force_window();
+                               }
+                       }
+               }
+               break;
+       case GDK_BUTTON_RELEASE:
+               break;
+       default:
+               break;
+       }
+       return false;
+}
+
+bool
+LayerTree::on_param_tree_event(GdkEvent *event)
+{
+    switch(event->type)
+    {
+       case GDK_BUTTON_PRESS:
+               {
+                       Gtk::TreeModel::Path path;
+                       Gtk::TreeViewColumn *column;
+                       int cell_x, cell_y;
+                       if(!get_param_tree_view().get_path_at_pos(
+                               int(event->button.x),int(event->button.y),      // x, y
+                               path, // TreeModel::Path&
+                               column, //TreeViewColumn*&
+                               cell_x,cell_y //int&cell_x,int&cell_y
+                               )
+                       ) break;
+                       const Gtk::TreeRow row = *(get_param_tree_view().get_model()->get_iter(path));
+
+#ifdef TIMETRACK_IN_PARAMS_PANEL
+                       if(column && column->get_first_cell_renderer()==cellrenderer_time_track)
+                       {
+                               Gdk::Rectangle rect;
+                               get_param_tree_view().get_cell_area(path,*column,rect);
+                               cellrenderer_time_track->property_value_desc()=row[param_model.value_desc];
+                               cellrenderer_time_track->property_canvas()=row[param_model.canvas];
+                               cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
+                               get_param_tree_view().queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
+                               return true;
+                               //return signal_param_user_click()(event->button.button,row,COLUMNID_TIME_TRACK);
+                       }
+                       else
+#endif // TIMETRACK_IN_PARAMS_PANEL
+                       {
+                               if(event->button.button==3)
+                               {
+                                       LayerList layer_list(get_selected_layers());
+                                       if(layer_list.size()<=1)
+                                       {
+                                               synfigapp::ValueDesc value_desc(row[param_model.value_desc]);
+                                               Gtk::Menu* menu(manage(new Gtk::Menu()));
+                                               menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), menu));
+                                               App::get_instance(param_tree_store_->canvas_interface()->get_canvas())->make_param_menu(menu,param_tree_store_->canvas_interface()->get_canvas(),value_desc,0.5f);
+                                               menu->popup(event->button.button,gtk_get_current_event_time());
+                                               return true;
+                                       }
+                                       Gtk::Menu* menu(manage(new Gtk::Menu()));
+                                       menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), menu));
+                                       std::list<synfigapp::ValueDesc> value_desc_list;
+                                       ParamDesc param_desc(row[param_model.param_desc]);
+                                       for(;!layer_list.empty();layer_list.pop_back())
+                                               value_desc_list.push_back(synfigapp::ValueDesc(layer_list.back(),param_desc.get_name()));
+                                       App::get_instance(param_tree_store_->canvas_interface()->get_canvas())->make_param_menu(menu,param_tree_store_->canvas_interface()->get_canvas(),value_desc_list);
+                                       menu->popup(event->button.button,gtk_get_current_event_time());
+                                       return true;
+                               }
+                               else
+                               {
+                                       if(column->get_first_cell_renderer()==cellrenderer_value)
+                                               return signal_param_user_click()(event->button.button,row,COLUMNID_VALUE);
+                                       else
+                                               return signal_param_user_click()(event->button.button,row,COLUMNID_NAME);
+                               }
+                       }
+               }
+               break;
+
+       case GDK_MOTION_NOTIFY:
+               {
+                       Gtk::TreeModel::Path path;
+                       Gtk::TreeViewColumn *column;
+                       int cell_x, cell_y;
+                       if(!get_param_tree_view().get_path_at_pos(
+                               (int)event->motion.x,(int)event->motion.y,      // x, y
+                               path, // TreeModel::Path&
+                               column, //TreeViewColumn*&
+                               cell_x,cell_y //int&cell_x,int&cell_y
+                               )
+                       ) break;
+
+                       if(!get_param_tree_view().get_model()->get_iter(path))
+                               break;
+
+                       Gtk::TreeRow row = *(get_param_tree_view().get_model()->get_iter(path));
+
+#ifdef TIMETRACK_IN_PARAMS_PANEL
+                       if((event->motion.state&GDK_BUTTON1_MASK ||event->motion.state&GDK_BUTTON3_MASK) && column && cellrenderer_time_track==column->get_first_cell_renderer())
+                       {
+                               Gdk::Rectangle rect;
+                               get_param_tree_view().get_cell_area(path,*column,rect);
+                               cellrenderer_time_track->property_value_desc()=row[param_model.value_desc];
+                               cellrenderer_time_track->property_canvas()=row[param_model.canvas];
+                               cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
+                               get_param_tree_view().queue_draw();
+                               //get_param_tree_view().queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
+                               return true;
+                       }
+                       else
+#endif // TIMETRACK_IN_PARAMS_PANEL
+                       if(last_tooltip_path.get_depth()<=0 || path!=last_tooltip_path)
+                       {
+                               tooltips_.unset_tip(*this);
+                               Glib::ustring tooltips_string(row[layer_model.tooltip]);
+                               last_tooltip_path=path;
+                               if(!tooltips_string.empty())
+                               {
+                                       tooltips_.set_tip(*this,tooltips_string);
+                                       tooltips_.force_window();
+                               }
+                       }
+               }
+               break;
+       case GDK_BUTTON_RELEASE:
+               {
+                       Gtk::TreeModel::Path path;
+                       Gtk::TreeViewColumn *column;
+                       int cell_x, cell_y;
+                       if(!get_param_tree_view().get_path_at_pos(
+                               (int)event->button.x,(int)event->button.y,      // x, y
+                               path, // TreeModel::Path&
+                               column, //TreeViewColumn*&
+                               cell_x,cell_y //int&cell_x,int&cell_y
+                               )
+                       ) break;
+
+                       if(!get_param_tree_view().get_model()->get_iter(path))
+                               break;
+
+                       Gtk::TreeRow row = *(get_param_tree_view().get_model()->get_iter(path));
+
+#ifdef TIMETRACK_IN_PARAMS_PANEL
+                       if(column && cellrenderer_time_track==column->get_first_cell_renderer())
+                       {
+                               Gdk::Rectangle rect;
+                               get_param_tree_view().get_cell_area(path,*column,rect);
+                               cellrenderer_time_track->property_value_desc()=row[param_model.value_desc];
+                               cellrenderer_time_track->property_canvas()=row[param_model.canvas];
+                               cellrenderer_time_track->activate(event,*this,path.to_string(),rect,rect,Gtk::CellRendererState());
+                               get_param_tree_view().queue_draw();
+                               get_param_tree_view().queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
+                               return true;
+
+                       }
+#endif // TIMETRACK_IN_PARAMS_PANEL
+               }
+               break;
+       default:
+               break;
+       }
+       return false;
+}
+
+// void
+// LayerTree::on_raise_pressed()
+// {
+//     synfigapp::Action::ParamList param_list;
+//     param_list.add("time",layer_tree_store_->canvas_interface()->get_time());
+//     param_list.add("canvas",layer_tree_store_->canvas_interface()->get_canvas());
+//     param_list.add("canvas_interface",layer_tree_store_->canvas_interface());
+//
+//     {
+//             synfigapp::SelectionManager::LayerList layer_list(get_selection_manager()->get_selected_layers());
+//             synfigapp::SelectionManager::LayerList::iterator iter;
+//
+//             for(iter=layer_list.begin();iter!=layer_list.end();++iter)
+//                     param_list.add("layer",Layer::Handle(*iter));
+//     }
+//     synfigapp::Action::Handle action(synfigapp::Action::create("LayerRaise"));
+//     action->set_param_list(param_list);
+//     layer_tree_store_->canvas_interface()->get_instance()->perform_action(action);
+// }
+
+// void
+// LayerTree::on_lower_pressed()
+// {
+//     synfigapp::Action::ParamList param_list;
+//     param_list.add("time",layer_tree_store_->canvas_interface()->get_time());
+//     param_list.add("canvas",layer_tree_store_->canvas_interface()->get_canvas());
+//     param_list.add("canvas_interface",layer_tree_store_->canvas_interface());
+//
+//     {
+//             synfigapp::SelectionManager::LayerList layer_list(get_selection_manager()->get_selected_layers());
+//             synfigapp::SelectionManager::LayerList::iterator iter;
+//
+//             for(iter=layer_list.begin();iter!=layer_list.end();++iter)
+//                     param_list.add("layer",Layer::Handle(*iter));
+//     }
+//
+//     synfigapp::Action::Handle action(synfigapp::Action::create("LayerLower"));
+//     action->set_param_list(param_list);
+//     layer_tree_store_->canvas_interface()->get_instance()->perform_action(action);
+// }
+
+// void
+// LayerTree::on_duplicate_pressed()
+// {
+//     synfigapp::Action::ParamList param_list;
+//     param_list.add("time",layer_tree_store_->canvas_interface()->get_time());
+//     param_list.add("canvas",layer_tree_store_->canvas_interface()->get_canvas());
+//     param_list.add("canvas_interface",layer_tree_store_->canvas_interface());
+//
+//     {
+//             synfigapp::SelectionManager::LayerList layer_list(get_selection_manager()->get_selected_layers());
+//             synfigapp::SelectionManager::LayerList::iterator iter;
+//
+//             for(iter=layer_list.begin();iter!=layer_list.end();++iter)
+//                     param_list.add("layer",Layer::Handle(*iter));
+//     }
+//
+//     synfigapp::Action::Handle action(synfigapp::Action::create("LayerDuplicate"));
+//     action->set_param_list(param_list);
+//     layer_tree_store_->canvas_interface()->get_instance()->perform_action(action);
+// }
+
+// void
+// LayerTree::on_encapsulate_pressed()
+// {
+//     synfigapp::Action::ParamList param_list;
+//     param_list.add("time",layer_tree_store_->canvas_interface()->get_time());
+//     param_list.add("canvas",layer_tree_store_->canvas_interface()->get_canvas());
+//     param_list.add("canvas_interface",layer_tree_store_->canvas_interface());
+//
+//     {
+//             synfigapp::SelectionManager::LayerList layer_list(get_selection_manager()->get_selected_layers());
+//             synfigapp::SelectionManager::LayerList::iterator iter;
+//
+//             for(iter=layer_list.begin();iter!=layer_list.end();++iter)
+//                     param_list.add("layer",Layer::Handle(*iter));
+//     }
+//
+//     synfigapp::Action::Handle action(synfigapp::Action::create("LayerEncapsulate"));
+//     action->set_param_list(param_list);
+//     layer_tree_store_->canvas_interface()->get_instance()->perform_action(action);
+// }
+
+// void
+// LayerTree::on_delete_pressed()
+// {
+//     synfigapp::Action::ParamList param_list;
+//     param_list.add("time",layer_tree_store_->canvas_interface()->get_time());
+//     param_list.add("canvas",layer_tree_store_->canvas_interface()->get_canvas());
+//     param_list.add("canvas_interface",layer_tree_store_->canvas_interface());
+//
+//     {
+//             synfigapp::SelectionManager::LayerList layer_list(get_selection_manager()->get_selected_layers());
+//             synfigapp::SelectionManager::LayerList::iterator iter;
+//
+//             for(iter=layer_list.begin();iter!=layer_list.end();++iter)
+//                     param_list.add("layer",Layer::Handle(*iter));
+//     }
+//
+//     synfigapp::Action::Handle action(synfigapp::Action::create("LayerRemove"));
+//     action->set_param_list(param_list);
+//     layer_tree_store_->canvas_interface()->get_instance()->perform_action(action);
+// }
+
+/*
+void
+LayerTree::on_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&context, Gtk::SelectionData& selection_data, guint info, guint time)
+{
+       synfig::info("Dragged data of type \"%s\"",selection_data.get_data_type());
+       synfig::info("Dragged data of target \"%s\"",gdk_atom_name(selection_data->target));
+       synfig::info("Dragged selection=\"%s\"",gdk_atom_name(selection_data->selection));
+
+       Gtk::TreeModel::Path path;
+       Gtk::TreeViewColumn *column;
+       int cell_x, cell_y;
+       if(get_selection()
+       Gtk::TreeRow row = *(get_selection()->get_selected());
+
+       if(synfig::String(gdk_atom_name(selection_data->target))=="LAYER" && (bool)row[model.is_layer])
+       {
+               Layer* layer(((Layer::Handle)row[model.layer]).get());
+               assert(layer);
+               selection_data.set(8, reinterpret_cast<const guchar*>(&layer), sizeof(layer));
+               return;
+       }
+}
+
+void
+LayerTree::on_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, Gtk::SelectionData& selection_data, guint info, guint time)
+{
+       synfig::info("Dropped data of type \"%s\"",selection_data.get_data_type());
+       synfig::info("Dropped data of target \"%s\"",gdk_atom_name(selection_data->target));
+       synfig::info("Dropped selection=\"%s\"",gdk_atom_name(selection_data->selection));
+       synfig::info("Dropped x=%d, y=%d",x,y);
+       bool success=false;
+       bool dropped_on_specific_row=false;
+
+       Gtk::TreeModel::Path path;
+       Gtk::TreeViewColumn *column;
+       int cell_x, cell_y;
+       if(!get_path_at_pos(
+               x,y,    // x, y
+               path, // TreeModel::Path&
+               column, //TreeViewColumn*&
+               cell_x,cell_y //int&cell_x,int&cell_y
+               )
+       )
+       {
+               dropped_on_specific_row=false;
+       }
+       else
+               dropped_on_specific_row=true;
+
+       Gtk::TreeRow row = *(get_model()->get_iter(path));
+
+       if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
+       {
+               if(synfig::String(selection_data.get_data_type())=="LAYER")do
+               {
+                       Layer::Handle src(*reinterpret_cast<Layer**>(selection_data.get_data()));
+                       assert(src);
+
+                       Canvas::Handle dest_canvas;
+                       Layer::Handle dest_layer;
+
+                       if(dropped_on_specific_row)
+                       {
+                               dest_canvas=(Canvas::Handle)(row[model.canvas]);
+                               dest_layer=(Layer::Handle)(row[model.layer]);
+                               assert(dest_canvas);
+                       }
+                       else
+                               dest_canvas=layer_tree_store_->canvas_interface()->get_canvas();
+
+                       // In this case, we are just moving.
+                       if(dest_canvas==src->get_canvas())
+                       {
+                               if(!dest_layer || dest_layer==src)
+                                       break;
+
+                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerMove"));
+                               action->set_param("canvas",dest_canvas);
+                               action->set_param("canvas_interface",layer_tree_store_->canvas_interface());
+                               action->set_param("layer",src);
+                               action->set_param("new_index",dest_canvas->get_depth(dest_layer));
+                               if(layer_tree_store_->canvas_interface()->get_instance()->perform_action(action))
+                                       success=true;
+                               else
+                                       success=false;
+                               break;
+                       }
+               }while(0);
+       }
+
+       // Finish the drag
+       context->drag_finish(success, false, time);
+}
+*/
+
+/*bool
+LayerTree::on_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context,int x, int    y, guint    time)
+{
+       return get_layer_tree_view().on_drag_motion(context,x,y,time);
+}
+
+void
+LayerTree::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, Gtk::SelectionData& selection_data, guint info, guint time)
+{
+       get_layer_tree_view().on_drag_data_received(context,x,y,selection_data,info,time);
+*/
+/*
+       if(context->gobj()->source_window==context->gobj()->dest_window)
+       {
+               Gtk::TreeView::on_drag_data_received(context,x,y,selection_data,info,time);
+               return;
+       }
+
+       Gtk::TreeModel::Path path;
+       Gtk::TreeViewColumn *column;
+       int cell_x, cell_y;
+       if(!get_path_at_pos(
+               x,y,    // x, y
+               path, // TreeModel::Path&
+               column, //TreeViewColumn*&
+               cell_x,cell_y //int&cell_x,int&cell_y
+               )
+       )
+       {
+               context->drag_finish(false, false, time);
+       }
+
+       if(layer_tree_store_->row_drop_possible(path,selection_data))
+       {
+               if(layer_tree_store_->drag_data_received(path,selection_data))
+                       context->drag_finish(true, false, time);
+       }
+       context->drag_finish(false, false, time);
+}
+*/
diff --git a/synfig-studio/src/gui/layertree.h b/synfig-studio/src/gui/layertree.h
new file mode 100644 (file)
index 0000000..97b2d27
--- /dev/null
@@ -0,0 +1,261 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file layertree.h
+**     \brief Template Header
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_STUDIO_LAYERTREE_H
+#define __SYNFIG_STUDIO_LAYERTREE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/treeview.h>
+#include <gtkmm/treestore.h>
+#include <gtkmm/tooltips.h>
+#include <gtkmm/table.h>
+#include <gtkmm/box.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/scale.h>
+#include <gtkmm/button.h>
+
+#include <synfigapp/canvasinterface.h>
+#include <synfigapp/value_desc.h>
+#include "layertreestore.h"
+#include "layerparamtreestore.h"
+#include <synfig/valuenode_animated.h>
+
+#include "widget_value.h"
+
+/* === M A C R O S ========================================================= */
+
+// comment this out if you don't want the params dialog to have a 'timetrack' column
+// (alternatively, export SYNFIG_DISABLE_PARAMS_PANEL_TIMETRACK=1 in environment at runtime)
+#define TIMETRACK_IN_PARAMS_PANEL
+
+/* === T Y P E D E F S ===================================================== */
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+namespace Gtk { class TreeModelSort; };
+
+namespace studio {
+
+class CellRenderer_TimeTrack;
+class CellRenderer_ValueBase;
+
+class LayerTree : public Gtk::Table
+{
+       /*
+ -- ** -- P U B L I C   T Y P E S ---------------------------------------------
+       */
+
+public:
+
+       typedef studio::ColumnID ColumnID;
+/*     enum ColumnID
+       {
+               COLUMNID_NAME,
+               COLUMNID_VALUE,
+               COLUMNID_TIME_TRACK,
+
+               COLUMNID_END                    //!< \internal
+       };
+*/
+       typedef std::list<synfig::Layer::Handle> LayerList;
+
+       /*
+ -- ** -- P U B L I C  D A T A ------------------------------------------------
+       */
+
+public:
+
+       //LayerTreeStore::Model model;
+
+       LayerTreeStore::Model layer_model;
+       LayerParamTreeStore::Model param_model;
+
+       synfig::Layer::Handle last_top_selected_layer;
+       Gtk::TreePath last_top_selected_path;
+
+       /*
+ -- ** -- P R I V A T E   D A T A ---------------------------------------------
+       */
+
+private:
+
+       Gtk::Tooltips tooltips_;
+       Gtk::TreePath last_tooltip_path;
+
+       Gtk::TreeView* layer_tree_view_;
+
+       Gtk::TreeView* param_tree_view_;
+
+       Gtk::HBox *hbox;
+
+       Gtk::Adjustment layer_amount_adjustment_;
+
+       Gtk::HScale *layer_amount_hscale;
+
+       synfig::Layer::Handle quick_layer;
+
+       Glib::RefPtr<LayerTreeStore> layer_tree_store_;
+
+       Glib::RefPtr<LayerParamTreeStore> param_tree_store_;
+
+       Glib::RefPtr<Gtk::TreeModelSort> sorted_layer_tree_store_;
+
+#ifdef TIMETRACK_IN_PARAMS_PANEL
+       CellRenderer_TimeTrack *cellrenderer_time_track;
+#endif // TIMETRACK_IN_PARAMS_PANEL
+
+       Gtk::TreeView::Column* column_time_track;
+
+       Gtk::TreeView::Column* column_z_depth;
+
+       CellRenderer_ValueBase *cellrenderer_value;
+
+       sigc::signal<void,synfig::Layer::Handle> signal_layer_toggle_;
+
+       sigc::signal<void,synfigapp::ValueDesc,synfig::ValueBase> signal_edited_value_;
+
+       sigc::signal<bool, int, Gtk::TreeRow, ColumnID> signal_layer_user_click_;
+
+       sigc::signal<bool, int, Gtk::TreeRow, ColumnID> signal_param_user_click_;
+
+       sigc::signal<void,synfigapp::ValueDesc,std::set<synfig::Waypoint,std::less<synfig::UniqueID> >,int> signal_waypoint_clicked_layertree_;
+
+       bool disable_amount_changed_signal;
+
+       Gtk::Button *button_raise;
+       Gtk::Button *button_lower;
+       Gtk::Button *button_duplicate;
+       Gtk::Button *button_encapsulate;
+       Gtk::Button *button_delete;
+
+       Widget_ValueBase blend_method_widget;
+
+       /*
+ -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
+       */
+
+private:
+
+       Gtk::Widget* create_layer_tree();
+       Gtk::Widget* create_param_tree();
+
+       /*
+ -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
+       */
+
+private:
+
+       void on_edited_value(const Glib::ustring&path_string,synfig::ValueBase value);
+
+       void on_layer_renamed(const Glib::ustring&path_string,const Glib::ustring& value);
+
+       void on_layer_toggle(const Glib::ustring& path_string);
+
+       void on_waypoint_clicked_layertree(const etl::handle<synfig::Node>& node, const synfig::Time&, const synfig::Time&, int button);
+
+       void on_waypoint_changed( synfig::Waypoint waypoint , synfig::ValueNode::Handle value_node);
+
+       bool on_layer_tree_event(GdkEvent *event);
+
+       bool on_param_tree_event(GdkEvent *event);
+
+       void on_selection_changed();
+
+       void on_dirty_preview();
+
+       void on_amount_value_changed();
+
+       void on_blend_method_changed();
+
+public:
+
+       // void on_raise_pressed();
+
+       // void on_lower_pressed();
+
+       // void on_duplicate_pressed();
+
+       // void on_encapsulate_pressed();
+
+       // void on_delete_pressed();
+
+       /*
+ -- ** -- P U B L I C   M E T H O D S -----------------------------------------
+       */
+
+public:
+
+       //Gtk::TreeView* get_param_tree_view() { return param_tree_view_; }
+       //Gtk::TreeView& param_tree_view() { return *param_tree_view_; }
+       Gtk::HBox& get_hbox() { return *hbox; }
+
+       Gtk::TreeView& get_layer_tree_view() { return *layer_tree_view_; }
+       Gtk::TreeView& get_param_tree_view() { return *param_tree_view_; }
+
+       const Gtk::TreeView& get_layer_tree_view()const { return *layer_tree_view_; }
+       const Gtk::TreeView& get_param_tree_view()const { return *param_tree_view_; }
+
+       Glib::RefPtr<Gtk::TreeSelection> get_selection() { return get_layer_tree_view().get_selection(); }
+       Glib::SignalProxy1< bool,GdkEvent* >  signal_event () { return get_layer_tree_view().signal_event(); }
+
+       LayerTree();
+       ~LayerTree();
+
+       void set_model(Glib::RefPtr<LayerTreeStore> layer_tree_store_);
+
+       void set_time_adjustment(Gtk::Adjustment &adjustment);
+
+       void set_show_timetrack(bool x=true);
+
+       //! Signal called when layer is toggled.
+       sigc::signal<void,synfig::Layer::Handle>& signal_layer_toggle() { return signal_layer_toggle_; }
+
+       //! Signal called with a value has been edited.
+       sigc::signal<void,synfigapp::ValueDesc,synfig::ValueBase>& signal_edited_value() { return signal_edited_value_; }
+
+       sigc::signal<bool,int, Gtk::TreeRow, ColumnID>& signal_layer_user_click() { return signal_layer_user_click_; }
+
+       sigc::signal<bool,int, Gtk::TreeRow, ColumnID>& signal_param_user_click() { return signal_param_user_click_; }
+
+       sigc::signal<void,synfigapp::ValueDesc,std::set<synfig::Waypoint,std::less<synfig::UniqueID> >,int>& signal_waypoint_clicked_layertree() { return signal_waypoint_clicked_layertree_; }
+
+       etl::handle<synfigapp::SelectionManager> get_selection_manager() { return layer_tree_store_->canvas_interface()->get_selection_manager(); }
+
+       void select_layer(synfig::Layer::Handle layer);
+       void select_layers(const LayerList& layer_list);
+       void select_all_children_layers(synfig::Layer::Handle layer);
+       void select_all_children(Gtk::TreeModel::Children::iterator iter);
+       LayerList get_selected_layers()const;
+       synfig::Layer::Handle get_selected_layer()const;
+       void clear_selected_layers();
+
+}; // END of LayerTree
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/layertreestore.cpp b/synfig-studio/src/gui/layertreestore.cpp
new file mode 100644 (file)
index 0000000..16b7fc8
--- /dev/null
@@ -0,0 +1,1081 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file layertreestore.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 <config.h>
+#endif
+
+#include "layertreestore.h"
+#include "iconcontroller.h"
+#include <gtkmm/button.h>
+#include <synfig/paramdesc.h>
+#include <synfigapp/action.h>
+#include <synfigapp/instance.h>
+#include "app.h"
+#include "instance.h"
+#include <synfig/layer_pastecanvas.h>
+#include <synfigapp/action_system.h>
+
+#include <gtk/gtkversion.h>
+#include <ETL/clock>
+#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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+static LayerTreeStore::Model& ModelHack()
+{
+       static LayerTreeStore::Model* model(0);
+       if(!model)model=new LayerTreeStore::Model;
+       return *model;
+}
+
+LayerTreeStore::LayerTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_):
+       Gtk::TreeStore                  (ModelHack()),
+       queued                                  (false),
+       canvas_interface_               (canvas_interface_)
+{
+       layer_icon=Gtk::Button().render_icon(Gtk::StockID("synfig-layer"),Gtk::ICON_SIZE_SMALL_TOOLBAR);
+
+       // Connect Signals to Terminals
+       canvas_interface()->signal_layer_status_changed().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_status_changed));
+       canvas_interface()->signal_layer_lowered().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_lowered));
+       canvas_interface()->signal_layer_raised().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_raised));
+       canvas_interface()->signal_layer_removed().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_removed));
+       canvas_interface()->signal_layer_inserted().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_inserted));
+       canvas_interface()->signal_layer_moved().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_moved));
+       //canvas_interface()->signal_layer_param_changed().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_param_changed));
+       canvas_interface()->signal_layer_new_description().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_layer_new_description));
+
+       canvas_interface()->signal_time_changed().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::refresh));
+
+       //canvas_interface()->signal_value_node_changed().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_value_node_changed));
+       //canvas_interface()->signal_value_node_added().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_value_node_added));
+       //canvas_interface()->signal_value_node_deleted().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_value_node_deleted));
+       //canvas_interface()->signal_value_node_replaced().connect(sigc::mem_fun(*this,&studio::LayerTreeStore::on_value_node_replaced));
+
+       set_default_sort_func(sigc::ptr_fun(index_sorter));
+
+//     rebuild();
+}
+
+LayerTreeStore::~LayerTreeStore()
+{
+       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
+               synfig::info("LayerTreeStore::~LayerTreeStore(): Deleted");
+}
+
+int
+LayerTreeStore::z_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs)
+{
+       const Model model;
+
+       float diff((float)(*rhs)[model.z_depth]-(float)(*lhs)[model.z_depth]);
+
+       if(diff<0)
+               return -1;
+       if(diff>0)
+               return 1;
+       return 0;
+}
+
+int
+LayerTreeStore::index_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs)
+{
+       const Model model;
+
+       return ((int)(*rhs)[model.index]-(int)(*lhs)[model.index]);
+}
+
+bool
+LayerTreeStore::search_func(const Glib::RefPtr<TreeModel>&,int,const Glib::ustring& x,const TreeModel::iterator& iter)
+{
+       const Model model;
+
+       Glib::ustring substr(x.uppercase());
+       Glib::ustring label((*iter)[model.label]);
+       label=label.uppercase();
+
+       return label.find(substr)==Glib::ustring::npos;
+}
+
+
+Glib::RefPtr<LayerTreeStore>
+LayerTreeStore::create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_)
+{
+       return Glib::RefPtr<LayerTreeStore>(new LayerTreeStore(canvas_interface_));
+}
+
+void
+LayerTreeStore::get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const
+{
+       if(column==model.index.index())
+       {
+               synfig::Layer::Handle layer((*iter)[model.layer]);
+
+               if(!layer)return;
+
+               Glib::Value<int> x;
+               g_value_init(x.gobj(),x.value_type());
+
+               x.set(layer->get_depth());
+
+               g_value_init(value.gobj(),x.value_type());
+               g_value_copy(x.gobj(),value.gobj());
+       }
+       else if(column==model.z_depth.index())
+       {
+               synfig::Layer::Handle layer((*iter)[model.layer]);
+
+               if(!layer)return;
+
+               Glib::Value<float> x;
+               g_value_init(x.gobj(),x.value_type());
+
+               x.set(layer->get_z_depth(canvas_interface()->get_time())*1.0001+layer->get_depth());
+
+               g_value_init(value.gobj(),x.value_type());
+               g_value_copy(x.gobj(),value.gobj());
+       }
+       else if(column==model.children_lock.index())
+       {
+               synfig::Layer::Handle layer((*iter)[model.layer]);
+
+               if(!layer)return;
+
+               Glib::Value<bool> x;
+               g_value_init(x.gobj(),x.value_type());
+               x.set(false);
+
+               ValueBase v(layer->get_param("children_lock"));
+               if(v.same_type_as(bool()))
+                       x.set(v.get(bool()));
+
+               g_value_init(value.gobj(),x.value_type());
+               g_value_copy(x.gobj(),value.gobj());
+       }
+       else if(column==model.label.index())
+       {
+               synfig::Layer::Handle layer((*iter)[model.layer]);
+
+               if(!layer)return;
+
+               Glib::Value<Glib::ustring> x;
+               g_value_init(x.gobj(),x.value_type());
+
+               x.set(layer->get_non_empty_description());
+
+               g_value_init(value.gobj(),x.value_type());
+               //g_value_copy(x.gobj(),value.gobj());
+               value=x;
+       }
+       else if(column==model.tooltip.index())
+       {
+               synfig::Layer::Handle layer((*iter)[model.layer]);
+
+               if(!layer)return;
+
+               Glib::Value<Glib::ustring> x;
+               g_value_init(x.gobj(),x.value_type());
+
+
+               x.set(layer->get_local_name());
+
+               g_value_init(value.gobj(),x.value_type());
+               //g_value_copy(x.gobj(),value.gobj());
+               value=x;
+       }
+       else if(column==model.canvas.index())
+       {
+               synfig::Layer::Handle layer((*iter)[model.layer]);
+
+               if(!layer)return;
+
+               Glib::Value<Canvas::Handle> x;
+               g_value_init(x.gobj(),x.value_type());
+
+
+               x.set(layer->get_canvas());
+
+               g_value_init(value.gobj(),x.value_type());
+               //g_value_copy(x.gobj(),value.gobj());
+               value=x;
+       }
+       else if(column==model.active.index())
+       {
+               synfig::Layer::Handle layer((*iter)[model.layer]);
+
+               if(!layer)return;
+
+               Glib::Value<bool> x;
+               g_value_init(x.gobj(),x.value_type());
+
+               x.set(layer->active());
+
+               g_value_init(value.gobj(),x.value_type());
+               g_value_copy(x.gobj(),value.gobj());
+       }
+       else if(column==model.icon.index())
+       {
+               synfig::Layer::Handle layer((*iter)[model.layer]);
+               if(!layer)return;
+
+               Glib::Value<Glib::RefPtr<Gdk::Pixbuf> > x;
+               g_value_init(x.gobj(),x.value_type());
+
+               //x.set(layer_icon);
+               x.set(get_tree_pixbuf_layer(layer->get_name()));
+
+               g_value_init(value.gobj(),x.value_type());
+               g_value_copy(x.gobj(),value.gobj());
+       }
+       else
+               Gtk::TreeStore::get_value_vfunc(iter,column,value);
+}
+
+void
+LayerTreeStore::set_value_impl(const Gtk::TreeModel::iterator& iter, int column, const Glib::ValueBase& value)
+{
+       //if(!iterator_sane(row))
+       //      return;
+
+       if(column>=get_n_columns_vfunc())
+       {
+               g_warning("LayerTreeStore::set_value_impl: Bad column (%d)",column);
+               return;
+       }
+
+       if(!g_value_type_compatible(G_VALUE_TYPE(value.gobj()),get_column_type_vfunc(column)))
+       {
+               g_warning("LayerTreeStore::set_value_impl: Bad value type");
+               return;
+       }
+
+       try
+       {
+               if(column==model.label.index())
+               {
+                       Glib::Value<Glib::ustring> x;
+                       g_value_init(x.gobj(),model.label.type());
+                       g_value_copy(value.gobj(),x.gobj());
+
+                       synfig::Layer::Handle layer((*iter)[model.layer]);
+                       if(!layer)
+                               return;
+                       synfig::String new_desc(x.get());
+
+                       if(new_desc==layer->get_local_name())
+                               new_desc=synfig::String();
+
+                       if(new_desc==layer->get_description())
+                               return;
+
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerSetDesc"));
+
+                       if(!action)
+                               return;
+
+                       action->set_param("canvas",canvas_interface()->get_canvas());
+                       action->set_param("canvas_interface",canvas_interface());
+                       action->set_param("layer",layer);
+                       action->set_param("new_description",synfig::String(x.get()));
+
+                       canvas_interface()->get_instance()->perform_action(action);
+                       return;
+               }
+               else if(column==model.active.index())
+               {
+                       synfig::Layer::Handle layer((*iter)[model.layer]);
+
+                       if(!layer)return;
+
+                       Glib::Value<bool> x;
+                       g_value_init(x.gobj(),model.active.type());
+                       g_value_copy(value.gobj(),x.gobj());
+
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerActivate"));
+
+                       if(!action)
+                               return;
+
+                       action->set_param("canvas",canvas_interface()->get_canvas());
+                       action->set_param("canvas_interface",canvas_interface());
+                       action->set_param("layer",layer);
+                       action->set_param("new_status",bool(x.get()));
+
+                       canvas_interface()->get_instance()->perform_action(action);
+                       return;
+               }
+               else
+                       Gtk::TreeStore::set_value_impl(iter,column, value);
+
+       }
+       catch(std::exception x)
+       {
+               g_warning("%s", x.what());
+       }
+}
+
+
+
+
+bool
+LayerTreeStore::row_draggable_vfunc (const TreeModel::Path& /*path*/)const
+{
+       //if(!get_iter(path)) return false;
+//     Gtk::TreeModel::Row row(*get_iter(path));
+
+       return true;
+//     return (bool)true;
+}
+
+bool
+LayerTreeStore::drag_data_get_vfunc (const TreeModel::Path& path, Gtk::SelectionData& selection_data)const
+{
+       if(!const_cast<LayerTreeStore*>(this)->get_iter(path)) return false;
+       //synfig::info("Dragged data of type \"%s\"",selection_data.get_data_type());
+       //synfig::info("Dragged data of target \"%s\"",gdk_atom_name(selection_data->target));
+       //synfig::info("Dragged selection=\"%s\"",gdk_atom_name(selection_data->selection));
+
+       Gtk::TreeModel::Row row(*const_cast<LayerTreeStore*>(this)->get_iter(path));
+
+       if((bool)true)
+       {
+               Layer* layer(((Layer::Handle)row[model.layer]).get());
+               assert(layer);
+               bool included(false);
+
+               //gtk_selection_data_set (selection_data, gdk_atom_intern("LAYER",false), 8, reinterpret_cast<const guchar*>(&layer), sizeof(layer));
+
+               std::vector<Layer*> layers;
+               // The following is a hack for multiple row DND
+               {
+                       synfigapp::SelectionManager::LayerList bleh(get_canvas_interface()->get_selection_manager()->get_selected_layers());
+                       if(bleh.empty())
+                       {
+                               selection_data.set("LAYER", 8, reinterpret_cast<const guchar*>(&layer), sizeof(layer));
+                               return true;
+                       }
+                       while(!bleh.empty())
+                       {
+                               if(bleh.back().get()==layer)
+                                       included=true;
+                               layers.push_back(bleh.back().get());
+                               bleh.pop_back();
+                       }
+               }
+               if(!included)
+                       layers.push_back(layer);
+               selection_data.set("LAYER", 8, reinterpret_cast<const guchar*>(&layers.front()), sizeof(void*)*layers.size());
+
+               return true;
+       }
+       return false;
+}
+
+bool
+LayerTreeStore::drag_data_delete_vfunc (const TreeModel::Path& /*path*/)
+{
+       return true;
+}
+
+bool
+LayerTreeStore::row_drop_possible_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)const
+{
+       //if(!const_cast<LayerTreeStore*>(this)->get_iter(dest)) return false;
+
+       //synfig::info("possible_drop -- data of type \"%s\"",selection_data.get_data_type());
+       //synfig::info("possible_drop -- data of target \"%s\"",gdk_atom_name(selection_data->target));
+       //synfig::info("possible_drop -- selection=\"%s\"",gdk_atom_name(selection_data->selection));
+
+       //Gtk::TreeModel::Row row(*get_iter(dest));
+
+       if(synfig::String(selection_data.get_data_type())=="LAYER" && (bool)true)
+       {
+               //Layer::Handle src(reinterpret_cast<Layer**>(const_cast<guint8*>(selection_data.get_data()))[i]);
+               //assert(src);
+
+               //return true;
+               TreeModel::Path dest_parent(dest);
+               if(!dest_parent.up() || dest.get_depth()==1)
+               {
+                       //row=(*get_iter(dest));
+                       //dest_canvas=(Canvas::Handle)(row[model.canvas]);
+                       return true;
+               }
+               else if((bool)const_cast<LayerTreeStore*>(this)->get_iter(dest_parent))
+                       return (bool)(Canvas::Handle)(*const_cast<LayerTreeStore*>(this)->get_iter(dest_parent))[model.contained_canvas];
+       }
+       return false;
+}
+
+bool
+LayerTreeStore::drag_data_received_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)
+{
+
+       //if(!dest_parent.up() || !get_iter(dest)) return false;
+
+       bool ret=false;
+       int i(0);
+
+
+       //synfig::info("Dropped data of type \"%s\"",selection_data.get_data_type());
+       //synfig::info("Dropped data of target \"%s\"",gdk_atom_name(selection_data->target));
+       //synfig::info("Dropped selection=\"%s\"",gdk_atom_name(selection_data->selection));
+       synfigapp::Action::PassiveGrouper passive_grouper(canvas_interface()->get_instance().get(),_("Move Layers"));
+
+       // Save the selection data
+       synfigapp::SelectionManager::LayerList selected_layer_list=canvas_interface()->get_selection_manager()->get_selected_layers();
+
+       if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
+       {
+               Gtk::TreeModel::Row row;
+               Canvas::Handle dest_canvas;
+
+               int dest_layer_depth=dest.back();
+
+               TreeModel::Path dest_parent(dest);
+               if(!dest_parent.up() || !get_iter(dest_parent))
+               {
+                       TreeModel::Path dest_(dest);
+                       if(!get_iter(dest_))
+                               dest_.prev();
+
+                       if(!get_iter(dest_))
+                               return false;
+
+                       {
+                               row=(*get_iter(dest_));
+                               dest_canvas=(Canvas::Handle)(row[model.canvas]);
+                       }
+               }
+               else
+               {
+                       row=(*get_iter(dest_parent));
+                       dest_canvas=row[model.contained_canvas];
+               }
+
+               assert(dest_canvas);
+
+               Layer::Handle dest_layer(row[model.layer]);
+
+               if(synfig::String(selection_data.get_data_type())=="LAYER")for(unsigned int i=0;i<selection_data.get_length()/sizeof(void*);i++)
+               {
+                       //synfig::info("dest_layer_depth=%d",dest_layer_depth);
+
+                       Layer::Handle src(reinterpret_cast<Layer**>(const_cast<guint8*>(selection_data.get_data()))[i]);
+                       assert(src);
+                       if(dest_layer==src)
+                               continue;
+
+                       if(dest_canvas==src->get_canvas() && src->get_depth()<dest_layer_depth)
+                               dest_layer_depth--;
+
+                       // In this case, we are just moving.
+//                     if(dest_canvas==src->get_canvas())
+                       {
+                               //if(dest_canvas==src->get_canvas() && dest_layer_depth && dest_layer_depth>src->get_depth())
+                               //      dest_layer_depth--;
+                               if(dest_canvas==src->get_canvas() && dest_layer_depth==src->get_depth())
+                                       continue;
+
+                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerMove"));
+                               action->set_param("canvas",dest_canvas);
+                               action->set_param("canvas_interface",canvas_interface());
+                               action->set_param("layer",src);
+                               action->set_param("new_index",dest_layer_depth);
+                               action->set_param("dest_canvas",dest_canvas);
+                               if(canvas_interface()->get_instance()->perform_action(action))
+                                       ret=true;
+                               else
+                               {
+                                       passive_grouper.cancel();
+                                       return false;
+                               }
+                               continue;
+                       }
+                       /*else // In this case we need to remove and then add
+                       {
+
+                               synfigapp::Action::Handle action;
+                               action=synfigapp::Action::create("LayerRemove");
+                               action->set_param("canvas",Canvas::Handle(src->get_canvas()));
+                               if(!action->set_param("canvas_interface",App::get_instance(src->get_canvas())->find_canvas_interface(src->get_canvas())))
+                                       action->set_param("canvas_interface",canvas_interface());
+                               action->set_param("layer",src);
+                               if(!canvas_interface()->get_instance()->perform_action(action))
+                               {
+                                       passive_grouper.cancel();
+                                       ret=false;
+                                       return false;
+                               }
+
+                               action=synfigapp::Action::create("LayerAdd");
+                               action->set_param("canvas",dest_canvas);
+                               action->set_param("canvas_interface",canvas_interface());
+                               action->set_param("new",src);
+                               if(!canvas_interface()->get_instance()->perform_action(action))
+                               {
+                                       passive_grouper.cancel();
+                                       ret=false;
+                                       return false;
+                               }
+
+                               if(dest_layer_depth!=0)
+                               {
+                                       action=synfigapp::Action::create("LayerMove");
+                                       action->set_param("canvas",dest_canvas);
+                                       action->set_param("canvas_interface",canvas_interface());
+                                       action->set_param("layer",src);
+                                       action->set_param("new_index",dest_layer_depth);
+                                       if(!canvas_interface()->get_instance()->perform_action(action))
+                                       {
+                                               passive_grouper.cancel();
+                                               ret=false;
+                                               return false;
+                                       }
+                               }
+                               ret=true;
+                       }
+                       */
+               }
+       }
+       synfig::info("I supposedly moved %d layers",i);
+
+       // Reselect the previously selected layers
+       canvas_interface()->get_selection_manager()->set_selected_layers(selected_layer_list);
+
+       return ret;
+}
+
+void
+LayerTreeStore::queue_rebuild()
+{
+       if (queued) return;
+       queued = false;
+       queue_connection.disconnect();
+       queue_connection=Glib::signal_timeout().connect(
+               sigc::bind_return(
+                       sigc::mem_fun(*this,&LayerTreeStore::rebuild),
+                       false
+               )
+       ,150);
+}
+
+void
+LayerTreeStore::rebuild()
+{
+       if (queued) queued = false;
+
+       // disconnect any subcanvas_changed connections
+       std::map<synfig::Layer::Handle, sigc::connection>::iterator iter;
+       for (iter = subcanvas_changed_connections.begin(); iter != subcanvas_changed_connections.end(); iter++)
+               iter->second.disconnect();
+       subcanvas_changed_connections.clear();
+
+       //etl::clock timer;timer.reset();
+
+       //synfig::warning("---------rebuilding layer table---------");
+       // Save the selection data
+       synfigapp::SelectionManager::LayerList layer_list=canvas_interface()->get_selection_manager()->get_selected_layers();
+
+       // Clear out the current list
+       clear();
+
+       // Go ahead and add all the layers
+       std::for_each(
+               canvas_interface()->get_canvas()->rbegin(), canvas_interface()->get_canvas()->rend(),
+               sigc::mem_fun(*this, &studio::LayerTreeStore::on_layer_added)
+       );
+
+       // Reselect the previously selected layers
+       if(!layer_list.empty())
+               canvas_interface()->get_selection_manager()->set_selected_layers(layer_list);
+
+       //synfig::info("LayerTreeStore::rebuild() took %f seconds",float(timer()));
+}
+
+void
+LayerTreeStore::refresh()
+{
+       etl::clock timer;timer.reset();
+
+       Gtk::TreeModel::Children children_(children());
+
+       Gtk::TreeModel::Children::iterator iter;
+
+       if(!children_.empty())
+               for(iter = children_.begin(); iter && iter != children_.end(); ++iter)
+               {
+                       Gtk::TreeRow row=*iter;
+                       refresh_row(row);
+               }
+       //synfig::info("LayerTreeStore::refresh() took %f seconds",float(timer()));
+}
+
+void
+LayerTreeStore::refresh_row(Gtk::TreeModel::Row &row)
+{
+       Layer::Handle layer=row[model.layer];
+       /*
+       {
+               row[model.name] = layer->get_local_name();
+               if(layer->get_description().empty())
+               {
+                       row[model.label] = layer->get_local_name();
+                       row[model.tooltip] = Glib::ustring("Layer");
+               }
+               else
+               {
+                       row[model.label] = layer->get_description();
+                       row[model.tooltip] = layer->get_local_name();
+               }
+       }
+       */
+
+       if(layer->dynamic_param_list().count("z_depth"))
+               row[model.z_depth]=Time::begin();
+       //      row_changed(get_path(row),row);
+
+       Gtk::TreeModel::Children children = row.children();
+       Gtk::TreeModel::Children::iterator iter;
+
+       if(!children.empty())
+               for(iter = children.begin(); iter && iter != children.end(); ++iter)
+               {
+                       Gtk::TreeRow row=*iter;
+                       refresh_row(row);
+               }
+}
+
+
+void
+LayerTreeStore::set_row_layer(Gtk::TreeRow &row,synfig::Layer::Handle &handle)
+{
+       //row[model.id] = handle->get_name();
+       //row[model.name] = handle->get_local_name();
+       /*if(handle->get_description().empty())
+       {
+               //row[model.label] = handle->get_local_name();
+               row[model.tooltip] = Glib::ustring("Layer");
+       }
+       else
+       {
+               //row[model.label] = handle->get_description();
+               row[model.tooltip] = handle->get_local_name();
+       }*/
+
+       //row[model.active] = handle->active();
+       row[model.layer] = handle;
+       //row[model.canvas] = handle->get_canvas();
+       //row[model.icon] = layer_icon;
+
+       synfig::Layer::ParamList paramlist=handle->get_param_list();
+
+       synfig::Layer::Vocab vocab=handle->get_param_vocab();
+       synfig::Layer::Vocab::iterator iter;
+
+       for(iter=vocab.begin();iter!=vocab.end();++iter)
+       {
+               if(iter->get_hidden())
+                       continue;
+               if(handle->get_param(iter->get_name()).get_type()!=ValueBase::TYPE_CANVAS)
+                       continue;
+
+               {
+                       Canvas::Handle canvas;
+                       canvas=handle->get_param(iter->get_name()).get(canvas);
+                       if(!canvas)
+                               continue;
+
+                       Canvas::reverse_iterator iter;
+                       row[model.contained_canvas]=canvas;
+
+                       for(iter=canvas->rbegin();iter!=canvas->rend();++iter)
+                       {
+                               Gtk::TreeRow row_(*(prepend(row.children())));
+                               set_row_layer(row_,*iter);
+                       }
+                       continue;
+               }
+
+               /*
+               etl::handle<ValueNode> value_node;
+               if(handle.constant()->dynamic_param_list().count(iter->get_name()))
+                       value_node=handle->dynamic_param_list()[iter->get_name()];
+
+               Gtk::TreeRow child_row = *(append(row.children()));
+               set_row_param(
+                       child_row,
+                       handle,
+                       iter->get_name(),
+                       iter->get_local_name(),
+                       paramlist[iter->get_name()],
+                       value_node,
+                       &*iter
+               );
+               */
+       }
+}
+
+void
+LayerTreeStore::on_layer_added(synfig::Layer::Handle layer)
+{
+       if (etl::handle<Layer_PasteCanvas>::cast_dynamic(layer))
+               subcanvas_changed_connections[layer] =
+                       (etl::handle<Layer_PasteCanvas>::cast_dynamic(layer))->signal_subcanvas_changed().connect(
+                               sigc::mem_fun(*this,&studio::LayerTreeStore::queue_rebuild)
+                       );
+
+       assert(layer);
+       Gtk::TreeRow row;
+       if(canvas_interface()->get_canvas()==layer->get_canvas())
+       {
+               row=*(prepend());
+       }
+       else
+       {
+               Gtk::TreeModel::Children::iterator iter;
+               if(!find_canvas_row(layer->get_canvas(),iter))
+               {
+                       rebuild();
+                       return;
+               }
+               row=*(prepend(iter->children()));
+       }
+       set_row_layer(row,layer);
+}
+
+void
+LayerTreeStore::on_layer_removed(synfig::Layer::Handle handle)
+{
+       if (etl::handle<Layer_PasteCanvas>::cast_dynamic(handle))
+       {
+               subcanvas_changed_connections[handle].disconnect();
+               subcanvas_changed_connections.erase(handle);
+       }
+       Gtk::TreeModel::Children::iterator iter;
+       if(find_layer_row(handle,iter))
+               erase(iter);
+       else
+       {
+               synfig::error("LayerTreeStore::on_layer_removed():Unable to find layer to be removed, forced to rebuild...");
+               rebuild();
+       }
+}
+
+void
+LayerTreeStore::on_layer_inserted(synfig::Layer::Handle handle,int depth)
+{
+       if(depth==0)
+       {
+               on_layer_added(handle);
+               return;
+       }
+
+       Gtk::TreeModel::Children children_(children());
+       if(canvas_interface()->get_canvas()!=handle->get_canvas())
+       {
+               Gtk::TreeModel::Children::iterator iter;
+               if(!find_canvas_row(handle->get_canvas(),iter))
+               {
+                       synfig::error("LayerTreeStore::on_layer_inserted():Unable to find canvas row, forced to rebuild...");
+                       rebuild();
+                       return;
+               }
+               children_=iter->children();
+       }
+
+       Gtk::TreeModel::Children::iterator iter(children_.begin());
+       while(depth-- && iter)
+       {
+               ++iter;
+               if(!iter || iter==children_.end())
+               {
+                       synfig::error("LayerTreeStore::on_layer_inserted():Unable to achieve desired depth, forced to rebuild...");
+                       rebuild();
+                       return;
+               }
+       }
+
+       Gtk::TreeModel::Row row(*insert(iter));
+       set_row_layer(row,handle);
+}
+
+void
+LayerTreeStore::on_layer_status_changed(synfig::Layer::Handle handle,bool /*x*/)
+{
+       Gtk::TreeModel::Children::iterator iter;
+       if(find_layer_row(handle,iter))
+               (*iter)[model.layer]=handle;
+       else
+       {
+               synfig::warning("Couldn't find layer to be activated in layer list. Rebuilding index...");
+               rebuild();
+       }
+}
+
+void
+LayerTreeStore::on_layer_lowered(synfig::Layer::Handle layer)
+{
+       Gtk::TreeModel::Children::iterator iter, iter2;
+       if(find_layer_row(layer,iter))
+       {
+               // Save the selection data
+               //synfigapp::SelectionManager::LayerList layer_list=canvas_interface()->get_selection_manager()->get_selected_layers();
+               iter2=iter;
+               iter2++;
+               if(!iter2)
+               {
+                       rebuild();
+                       return;
+               }
+
+               //Gtk::TreeModel::Row row(*iter);
+               Gtk::TreeModel::Row row2 = *iter2;
+               synfig::Layer::Handle layer2=row2[model.layer];
+
+               erase(iter2);
+               row2=*insert(iter);
+               set_row_layer(row2,layer2);
+
+       }
+       else
+               rebuild();
+}
+
+void
+LayerTreeStore::on_layer_raised(synfig::Layer::Handle layer)
+{
+       Gtk::TreeModel::Children::iterator iter, iter2;
+
+       Gtk::TreeModel::Children children_(children());
+
+       if(find_layer_row_(layer, canvas_interface()->get_canvas(), children_, iter,iter2))
+       {
+               if(iter!=iter2)
+               {
+                       //Gtk::TreeModel::Row row = *iter;
+                       Gtk::TreeModel::Row row2 = *iter2;
+                       synfig::Layer::Handle layer2=row2[model.layer];
+
+                       erase(iter2);
+                       iter++;
+                       row2=*insert(iter);
+                       set_row_layer(row2,layer2);
+
+                       return;
+               }
+       }
+
+       rebuild();
+}
+
+void
+LayerTreeStore::on_layer_moved(synfig::Layer::Handle layer,int depth, synfig::Canvas::Handle /*canvas*/)
+{
+       on_layer_removed(layer);
+       on_layer_inserted(layer,depth);
+}
+
+void
+LayerTreeStore::on_layer_param_changed(synfig::Layer::Handle handle,synfig::String param_name)
+{
+       if(param_name=="z_depth")
+       {
+               Gtk::TreeModel::Children::iterator iter;
+               if(find_layer_row(handle,iter))
+               {
+                       (*iter)[model.z_depth]=Time::begin();
+               }
+       }
+
+       /*
+       Gtk::TreeModel::Children::iterator iter;
+       if(find_layer_row(handle,iter))
+       {
+               Gtk::TreeModel::Children children(iter->children());
+
+               for(iter = children.begin(); iter && iter != children.end(); ++iter)
+               {
+                       if((Glib::ustring)(*iter)[model.param_name]==param_name)
+                       {
+                               Gtk::TreeRow row=*iter;
+                               refresh_row(row);
+                               return;
+                       }
+               }
+       }
+       rebuild();
+       */
+}
+
+void
+LayerTreeStore::on_layer_new_description(synfig::Layer::Handle handle,synfig::String desc)
+{
+       Gtk::TreeModel::Children::iterator iter;
+       if(find_layer_row(handle,iter))
+       {
+               Gtk::TreeRow row(*iter);
+
+               Layer::Handle layer(row[model.layer]);
+
+               if(desc.empty())
+               {
+                       //row[model.label]=layer->get_local_name();
+                       row[model.tooltip]=Glib::ustring(_("Layer"));
+               }
+               else
+                       //row[model.label]=layer->get_description();
+                       row[model.tooltip]=layer->get_local_name();
+       }
+       else
+       {
+               rebuild();
+       }
+}
+
+bool
+LayerTreeStore::find_canvas_row_(synfig::Canvas::Handle canvas, synfig::Canvas::Handle parent, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter)
+{
+       if(canvas==parent)
+               return false;
+
+       {
+               for(iter=layers.begin(); iter && iter != layers.end(); ++iter)
+               {
+                       Gtk::TreeModel::Row row = *iter;
+                       if(canvas==(synfig::Canvas::Handle)row[model.contained_canvas])
+                               return true;
+               }
+
+               iter=children().end();
+               //return false;
+       }
+
+       Gtk::TreeModel::Children::iterator iter2;
+       //Gtk::TreeModel::Children::iterator iter3;
+
+       for(iter2 = layers.begin(); iter2 && iter2 != layers.end(); ++iter2)
+       {
+               Gtk::TreeModel::Row row = *iter2;
+               assert((bool)true);
+
+               if(row.children().empty())
+                       continue;
+
+               Canvas::Handle sub_canvas((*row.children().begin())[model.canvas]);
+               if(!sub_canvas)
+                       continue;
+
+               if(find_canvas_row_(canvas,sub_canvas,iter2->children(),iter))
+                       return true;
+       }
+
+       iter=children().end();
+       return false;
+}
+
+bool
+LayerTreeStore::find_canvas_row(synfig::Canvas::Handle canvas, Gtk::TreeModel::Children::iterator &iter)
+{
+       return find_canvas_row_(canvas,canvas_interface()->get_canvas(),children(),iter);
+}
+
+
+bool
+LayerTreeStore::find_layer_row_(const synfig::Layer::Handle &layer, synfig::Canvas::Handle /*canvas*/, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter, Gtk::TreeModel::Children::iterator &prev)
+{
+       assert(layer);
+
+       //if(layer->get_canvas()==canvas)
+       {
+               for(iter=prev=layers.begin(); iter && iter != layers.end(); prev=iter++)
+               {
+                       Gtk::TreeModel::Row row = *iter;
+                       if(layer==(synfig::Layer::Handle)row[model.layer])
+                               return true;
+               }
+
+               iter=children().end();
+               //return false;
+       }
+
+       Gtk::TreeModel::Children::iterator iter2;
+
+       for(iter2 = layers.begin(); iter2 && iter2 != layers.end(); ++iter2)
+       {
+               Gtk::TreeModel::Row row = *iter2;
+               assert((bool)true);
+
+               if(row.children().empty())
+                       continue;
+
+               Canvas::Handle canvas((*row.children().begin())[model.canvas]);
+               if(!canvas)
+                       continue;
+
+               if(find_layer_row_(layer,canvas,iter2->children(),iter,prev))
+                       return true;
+       }
+
+       iter=children().end();
+       return false;
+}
+
+bool
+LayerTreeStore::find_layer_row(const synfig::Layer::Handle &layer, Gtk::TreeModel::Children::iterator &iter)
+{
+       Gtk::TreeModel::Children::iterator prev;
+       return find_layer_row_(layer,canvas_interface()->get_canvas(),children(),iter,prev);
+}
+
+bool
+LayerTreeStore::find_prev_layer_row(const synfig::Layer::Handle &layer, Gtk::TreeModel::Children::iterator &prev)
+{
+       Gtk::TreeModel::Children::iterator iter;
+       if(!find_layer_row_(layer,canvas_interface()->get_canvas(),children(),iter,prev))
+               return false;
+       if(iter==children().begin())
+               return false;
+       return true;
+}
diff --git a/synfig-studio/src/gui/layertreestore.h b/synfig-studio/src/gui/layertreestore.h
new file mode 100644 (file)
index 0000000..5b33309
--- /dev/null
@@ -0,0 +1,226 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file layertreestore.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_LAYERTREESTORE_H
+#define __SYNFIG_STUDIO_LAYERTREESTORE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/treestore.h>
+#include <synfigapp/canvasinterface.h>
+#include <synfig/value.h>
+#include <synfig/valuenode.h>
+#include <gtkmm/treeview.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 LayerTreeStore : virtual public Gtk::TreeStore
+{
+       /*
+ -- ** -- P U B L I C   T Y P E S ---------------------------------------------
+       */
+
+public:
+
+       class Model : public Gtk::TreeModel::ColumnRecord
+       {
+       public:
+               Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
+               Gtk::TreeModelColumn<Glib::ustring> label;
+               Gtk::TreeModelColumn<Glib::ustring> name;
+               Gtk::TreeModelColumn<Glib::ustring> id;
+
+               Gtk::TreeModelColumn<synfig::Canvas::Handle> canvas;
+
+               Gtk::TreeModelColumn<Glib::ustring> tooltip;
+
+
+               Gtk::TreeModelColumn<bool>                                              active;
+               Gtk::TreeModelColumn<synfig::Layer::Handle>             layer;
+               Gtk::TreeModelColumn<synfig::Canvas::Handle>                    contained_canvas;
+
+               Gtk::TreeModelColumn<bool>                                              children_lock;
+
+               Gtk::TreeModelColumn<float> z_depth;
+               Gtk::TreeModelColumn<int> index;
+
+               Model()
+               {
+                       add(icon);
+                       add(label);
+                       add(name);
+                       add(id);
+                       add(canvas);
+                       add(tooltip);
+                       add(active);
+                       add(layer);
+                       add(contained_canvas);
+                       add(z_depth);
+                       add(index);
+                       add(children_lock);
+               }
+       };
+
+       /*
+ -- ** -- P U B L I C  D A T A ------------------------------------------------
+       */
+
+public:
+
+       //! TreeModel for the layers
+       const Model model;
+
+       /*
+ -- ** -- P R I V A T E   D A T A ---------------------------------------------
+       */
+
+private:
+
+       bool queued;
+
+       sigc::connection queue_connection;
+
+       std::map<synfig::Layer::Handle, sigc::connection> subcanvas_changed_connections;
+
+       etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
+
+       Glib::RefPtr<Gdk::Pixbuf> layer_icon;
+
+       /*
+ -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
+       */
+
+private:
+
+       /*
+ -- ** -- P R O T E C T E D   M E T H O D S -----------------------------------
+       */
+
+private:
+       virtual void  set_value_impl (const Gtk::TreeModel::iterator& row, int column, const Glib::ValueBase& value);
+       virtual void  get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const;
+
+       virtual bool  row_draggable_vfunc (const TreeModel::Path& path)const;
+       virtual bool  drag_data_get_vfunc (const TreeModel::Path& path, Gtk::SelectionData& selection_data)const;
+       virtual bool  drag_data_delete_vfunc (const TreeModel::Path& path);
+       virtual bool  drag_data_received_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data);
+       virtual bool  row_drop_possible_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)const;
+
+       /*
+ -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
+       */
+
+private:
+
+       bool on_layer_tree_event(GdkEvent *event);
+
+       void on_layer_new_description(synfig::Layer::Handle handle,synfig::String desc);
+
+       void on_layer_added(synfig::Layer::Handle handle);
+
+       void on_layer_removed(synfig::Layer::Handle handle);
+
+       void on_layer_inserted(synfig::Layer::Handle handle,int depth);
+
+       void on_layer_moved(synfig::Layer::Handle handle,int depth, synfig::Canvas::Handle canvas);
+
+       void on_layer_status_changed(synfig::Layer::Handle handle,bool);
+
+       void on_layer_lowered(synfig::Layer::Handle handle);
+
+       void on_layer_raised(synfig::Layer::Handle handle);
+
+       void on_layer_param_changed(synfig::Layer::Handle handle,synfig::String param_name);
+
+       //void on_value_node_added(synfig::ValueNode::Handle value_node);
+
+       //void on_value_node_deleted(synfig::ValueNode::Handle value_node);
+
+       //void on_value_node_changed(synfig::ValueNode::Handle value_node);
+
+       //void on_value_node_replaced(synfig::ValueNode::Handle replaced_value_node,synfig::ValueNode::Handle new_value_node);
+
+       bool find_layer_row_(const synfig::Layer::Handle &handle, synfig::Canvas::Handle canvas, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter, Gtk::TreeModel::Children::iterator &prev);
+
+       bool find_canvas_row_(synfig::Canvas::Handle canvas, synfig::Canvas::Handle parent, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter);
+
+       /*
+ -- ** -- P U B L I C   M E T H O D S -----------------------------------------
+       */
+
+public:
+
+       LayerTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
+       ~LayerTreeStore();
+
+       etl::loose_handle<synfigapp::CanvasInterface> canvas_interface() { return canvas_interface_; }
+       etl::loose_handle<const synfigapp::CanvasInterface> canvas_interface()const { return canvas_interface_; }
+       etl::loose_handle<synfigapp::CanvasInterface> get_canvas_interface()const { return canvas_interface_; }
+
+       bool find_canvas_row(synfig::Canvas::Handle canvas, Gtk::TreeModel::Children::iterator &iter);
+
+       bool find_layer_row(const synfig::Layer::Handle &handle, Gtk::TreeModel::Children::iterator &iter);
+
+       bool find_prev_layer_row(const synfig::Layer::Handle &handle, Gtk::TreeModel::Children::iterator &iter);
+
+       void queue_rebuild();
+
+       void rebuild();
+
+       void refresh();
+
+       void refresh_row(Gtk::TreeModel::Row &row);
+
+       void set_row_layer(Gtk::TreeRow &row,synfig::Layer::Handle &handle);
+
+       static int z_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs);
+       static int index_sorter(const Gtk::TreeModel::iterator &rhs,const Gtk::TreeModel::iterator &lhs);
+
+       //void set_row_param(Gtk::TreeRow &row,synfig::Layer::Handle &handle,const std::string& name, const std::string& local_name, const synfig::ValueBase &value, etl::handle<synfig::ValueNode> value_node,synfig::ParamDesc *param_desc);
+
+       //virtual void set_row(Gtk::TreeRow row,synfigapp::ValueDesc value_desc);
+       static bool search_func(const Glib::RefPtr<TreeModel>&,int,const Glib::ustring&,const TreeModel::iterator&);
+
+       /*
+ -- ** -- S T A T I C   P U B L I C   M E T H O D S ---------------------------
+       */
+
+public:
+
+       static Glib::RefPtr<LayerTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
+
+
+}; // END of class LayerTreeStore
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/main.cpp b/synfig-studio/src/gui/main.cpp
new file mode 100644 (file)
index 0000000..36bf16d
--- /dev/null
@@ -0,0 +1,131 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file gtkmm/main.cpp
+**     \brief Synfig Studio Entrypoint
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 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 <config.h>
+#endif
+
+#include "app.h"
+#include <iostream>
+#include "ipc.h"
+#include <stdexcept>
+
+#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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+/* === E N T R Y P O I N T ================================================= */
+
+int main(int argc, char **argv)
+{
+
+#ifdef ENABLE_NLS
+       setlocale(LC_ALL, "");
+       bindtextdomain("synfigstudio", LOCALEDIR);
+       bind_textdomain_codeset("synfigstudio", "UTF-8");
+       textdomain("synfigstudio");
+#endif
+
+       {
+               SmartFILE file(IPC::make_connection());
+               if(file)
+               {
+                       cout << endl;
+                       cout << "   " << _("synfig studio is already running") << endl << endl;
+                       cout << "   " << _("the existing process will be used") << endl << endl;;
+
+                       // Hey, another copy of us is open!
+                       // don't bother opening us, just go ahead and
+                       // tell the other copy to load it all up
+                       if (argc>1)
+                               fprintf(file.get(),"F\n");
+
+                       while(--argc)
+                               if((argv)[argc] && (argv)[argc][0]!='-')
+                                       fprintf(file.get(),"O %s\n",etl::absolute_path((argv)[argc]).c_str());
+
+                       fprintf(file.get(),"F\n");
+
+                       return 0;
+               }
+       }
+
+       cout << endl;
+       cout << "   " << _("synfig studio -- starting up application...") << endl << endl;
+
+       try
+       {
+               studio::App app(&argc, &argv);
+
+               app.run();
+       }
+       catch(int ret)
+       {
+               std::cerr<<"Application shutdown with errors ("<<ret<<')'<<std::endl;
+               return ret;
+       }
+       catch(string str)
+       {
+               std::cerr<<"Uncaught Exception:string: "<<str<<std::endl;
+               throw;
+       }
+       catch(std::exception x)
+       {
+               std::cerr<<"Standard Exception: "<<x.what()<<std::endl;
+               throw;
+       }
+       catch(Glib::Exception& x)
+       {
+               std::cerr<<"GLib Exception: "<<x.what()<<std::endl;
+               throw;
+       }
+       catch(...)
+       {
+               std::cerr<<"Uncaught Exception"<<std::endl;
+               throw;
+       }
+
+       std::cerr<<"Application appears to have terminated successfully"<<std::endl;
+
+       return 0;
+}
diff --git a/synfig-studio/src/gui/metadatatreestore.cpp b/synfig-studio/src/gui/metadatatreestore.cpp
new file mode 100644 (file)
index 0000000..98bb7c6
--- /dev/null
@@ -0,0 +1,152 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file metadatatreestore.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 <config.h>
+#endif
+
+#include "metadatatreestore.h"
+#include <synfigapp/canvasinterface.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+static MetaDataTreeStore::Model& ModelHack()
+{
+       static MetaDataTreeStore::Model* model(0);
+       if(!model)model=new MetaDataTreeStore::Model;
+       return *model;
+}
+
+MetaDataTreeStore::MetaDataTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_):
+       Gtk::TreeStore  (ModelHack()),
+       canvas_interface_               (canvas_interface_)
+{
+       // Connect the signal
+       get_canvas()->signal_meta_data_changed().connect(sigc::mem_fun(*this,&MetaDataTreeStore::meta_data_changed));
+
+       rebuild();
+}
+
+MetaDataTreeStore::~MetaDataTreeStore()
+{
+       if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
+               synfig::info("MetaDataTreeStore::~MetaDataTreeStore(): Deleted");
+}
+
+Glib::RefPtr<MetaDataTreeStore>
+MetaDataTreeStore::create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_)
+{
+       return Glib::RefPtr<MetaDataTreeStore>(new MetaDataTreeStore(canvas_interface_));
+}
+
+void
+MetaDataTreeStore::meta_data_changed(synfig::String /*key*/)
+{
+       rebuild();
+}
+
+void
+MetaDataTreeStore::rebuild()
+{
+       clear();
+
+       std::list<String> keys(get_canvas()->get_meta_data_keys());
+
+       for(;!keys.empty();keys.pop_front())
+       {
+               Gtk::TreeRow row(*append());
+               row[model.key]=keys.front();
+       }
+}
+
+void
+MetaDataTreeStore::get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const
+{
+       if(column>=get_n_columns_vfunc())
+       {
+               g_warning("MetaDataTreeStore::set_value_impl: Bad column (%d)",column);
+               return;
+       }
+
+       if(column==model.data.index())
+       {
+               synfig::String key((Glib::ustring)(*iter)[model.key]);
+               g_value_init(value.gobj(),G_TYPE_STRING);
+               g_value_set_string(value.gobj(),get_canvas()->get_meta_data(key).c_str());
+               return;
+       }
+       else
+               Gtk::TreeStore::get_value_vfunc(iter,column,value);
+}
+
+void
+MetaDataTreeStore::set_value_impl(const Gtk::TreeModel::iterator& iter, int column, const Glib::ValueBase& value)
+{
+       if(column>=get_n_columns_vfunc())
+       {
+               g_warning("MetaDataTreeStore::set_value_impl: Bad column (%d)",column);
+               return;
+       }
+
+       if(!g_value_type_compatible(G_VALUE_TYPE(value.gobj()),get_column_type_vfunc(column)))
+       {
+               g_warning("MetaDataTreeStore::set_value_impl: Bad value type");
+               return;
+       }
+
+       if(column==model.data.index())
+       {
+               Glib::Value<Glib::ustring> x;
+               g_value_init(x.gobj(),model.data.type());
+               g_value_copy(value.gobj(),x.gobj());
+
+               synfig::String key((Glib::ustring)(*iter)[model.key]);
+               synfig::String new_data(x.get());
+
+               get_canvas_interface()->set_meta_data(key,new_data);
+       }
+       else
+               Gtk::TreeStore::set_value_impl(iter,column, value);
+}
diff --git a/synfig-studio/src/gui/metadatatreestore.h b/synfig-studio/src/gui/metadatatreestore.h
new file mode 100644 (file)
index 0000000..6ad41d4
--- /dev/null
@@ -0,0 +1,133 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file metadatatreestore.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_METADATATREESTORE_H
+#define __SYNFIG_STUDIO_METADATATREESTORE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/treestore.h>
+#include <synfigapp/canvasinterface.h>
+#include <gdkmm/pixbuf.h>
+#include <synfigapp/action.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 synfigapp { class CanvasInterface; }
+
+namespace studio {
+
+class MetaDataTreeStore : virtual public Gtk::TreeStore
+{
+       /*
+ -- ** -- P U B L I C   T Y P E S ---------------------------------------------
+       */
+
+public:
+
+       class Model : public Gtk::TreeModel::ColumnRecord
+       {
+       public:
+       public:
+               Gtk::TreeModelColumn<Glib::ustring> key;
+               Gtk::TreeModelColumn<Glib::ustring> data;
+
+               Model()
+               {
+                       add(key);
+                       add(data);
+               }
+       };
+
+       /*
+ -- ** -- P U B L I C  D A T A ------------------------------------------------
+       */
+
+public:
+
+       const Model model;
+
+       /*
+ -- ** -- P R I V A T E   D A T A ---------------------------------------------
+       */
+
+private:
+
+       etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
+
+       /*
+ -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
+       */
+
+private:
+
+       /*
+ -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
+       */
+
+private:
+
+       void meta_data_changed(synfig::String key);
+
+       /*
+ -- ** -- P U B L I C   M E T H O D S -----------------------------------------
+       */
+
+public:
+
+       ~MetaDataTreeStore();
+
+       etl::loose_handle<synfigapp::CanvasInterface> get_canvas_interface() { return canvas_interface_; }
+       etl::loose_handle<const synfigapp::CanvasInterface> get_canvas_interface()const { return canvas_interface_; }
+       synfig::Canvas::Handle get_canvas()const { return canvas_interface_->get_canvas(); }
+       synfig::Canvas::Handle get_canvas() { return canvas_interface_->get_canvas(); }
+
+       void rebuild();
+
+       void refresh() { rebuild(); }
+
+       /*
+ -- ** -- P R O T E C T E D   M E T H O D S -----------------------------------
+       */
+
+protected:
+       MetaDataTreeStore(etl::loose_handle<synfigapp::CanvasInterface>);
+       void get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const;
+       void set_value_impl(const Gtk::TreeModel::iterator& iter, int column, const Glib::ValueBase& value);
+
+public:
+
+       static Glib::RefPtr<MetaDataTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface>);
+
+}; // END of class MetaDataTreeStore
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/mod_mirror/mod_mirror.cpp b/synfig-studio/src/gui/mod_mirror/mod_mirror.cpp
new file mode 100644 (file)
index 0000000..03667bf
--- /dev/null
@@ -0,0 +1,68 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file mod_mirror.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "mod_mirror.h"
+#include "state_mirror.h"
+
+#include "../app.h"
+#include "../statemanager.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+bool
+studio::ModMirror::start_vfunc()
+{
+       App::get_state_manager()->add_state(&state_mirror);
+       return true;
+}
+
+bool
+studio::ModMirror::stop_vfunc()
+{
+       return true;
+}
diff --git a/synfig-studio/src/gui/mod_mirror/mod_mirror.h b/synfig-studio/src/gui/mod_mirror/mod_mirror.h
new file mode 100644 (file)
index 0000000..25240f5
--- /dev/null
@@ -0,0 +1,59 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file mod_mirror.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_MOD_MIRROR_H
+#define __SYNFIG_MOD_MIRROR_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <ETL/handle>
+#include "../module.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 State_Mirror;
+
+class ModMirror : public Module
+{
+       friend class State_Mirror;
+
+protected:
+       virtual bool start_vfunc();
+       virtual bool stop_vfunc();
+
+public:
+       virtual ~ModMirror() { stop(); }
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/mod_mirror/state_mirror.cpp b/synfig-studio/src/gui/mod_mirror/state_mirror.cpp
new file mode 100644 (file)
index 0000000..bcb0a3a
--- /dev/null
@@ -0,0 +1,336 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_mirror.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/entry.h>
+
+#include <synfig/valuenode_dynamiclist.h>
+#include <synfigapp/action_system.h>
+
+#include "state_mirror.h"
+#include "../state_normal.h"
+#include "../canvasview.h"
+#include "../workarea.h"
+#include "../app.h"
+
+#include <synfigapp/action.h>
+#include "../event_mouse.h"
+#include "../event_layerclick.h"
+#include "../toolbox.h"
+#include "../dialog_tooloptions.h"
+#include <gtkmm/optionmenu.h>
+#include "../duck.h"
+#include <synfigapp/main.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 ========================================================= */
+
+enum Axis {
+       AXIS_X,
+       AXIS_Y
+} ;
+
+/* === G L O B A L S ======================================================= */
+
+StateMirror studio::state_mirror;
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+class DuckDrag_Mirror : public DuckDrag_Base
+{
+       synfig::Vector center;
+
+       std::vector<synfig::Vector> positions;
+
+public:
+       Axis axis;
+
+       DuckDrag_Mirror();
+       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::StateMirror_Context : public sigc::trackable
+{
+       etl::handle<CanvasView> canvas_view_;
+       CanvasView::IsWorking is_working;
+
+       synfigapp::Settings& settings;
+
+       sigc::connection keypress_connect;
+       sigc::connection keyrelease_connect;
+
+       etl::handle<DuckDrag_Mirror> duck_dragger_;
+
+       Gtk::Table options_table;
+
+       Gtk::RadioButton::Group radiobutton_group;
+       Gtk::RadioButton radiobutton_axis_x;
+       Gtk::RadioButton radiobutton_axis_y;
+
+public:
+
+       Axis get_axis()const { return radiobutton_axis_x.get_active()?AXIS_X:AXIS_Y; }
+       void set_axis(Axis a)
+       {
+               if(a==AXIS_X)
+                       radiobutton_axis_x.set_active(true);
+               else
+                       radiobutton_axis_y.set_active(true);
+
+               duck_dragger_->axis=get_axis();
+       }
+
+       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();
+
+       StateMirror_Context(CanvasView* canvas_view);
+
+       ~StateMirror_Context();
+
+       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
+       etl::handle<synfigapp::CanvasInterface> 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();
+
+       bool key_event(GdkEventKey *event);
+};     // END of class StateMirror_Context
+
+/* === M E T H O D S ======================================================= */
+
+StateMirror::StateMirror():
+       Smach::state<StateMirror_Context>("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()
+{
+}
+
+void
+StateMirror_Context::load_settings()
+{
+       String value;
+
+       settings.get_value("mirror.axis",value);
+       set_axis((Axis)atoi(value.c_str()));
+}
+
+void
+StateMirror_Context::save_settings()
+{
+       settings.set_value("mirror.lock_aspect",strprintf("%d",(int)get_axis()));
+}
+
+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")),
+       radiobutton_axis_y(radiobutton_group,_("Vertical"))
+{
+       // Set up the tool options dialog
+       options_table.attach(*manage(new Gtk::Label(_("Mirror Tool"))), 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(radiobutton_axis_x, 0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(radiobutton_axis_y, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(*manage(new Gtk::Label(_("(Shift key toggles axis)"))), 0, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       radiobutton_axis_x.signal_toggled().connect(sigc::mem_fun(*this,&StateMirror_Context::update_axes));
+       radiobutton_axis_y.signal_toggled().connect(sigc::mem_fun(*this,&StateMirror_Context::update_axes));
+
+       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_);
+
+       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_work_area()->set_cursor(Gdk::SB_H_DOUBLE_ARROW);
+//     get_work_area()->reset_cursor();
+
+       App::toolbox->refresh();
+
+       set_axis(AXIS_X);
+       load_settings();
+}
+
+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
+}
+
+void
+StateMirror_Context::refresh_tool_options()
+{
+       App::dialog_tool_options->clear();
+       App::dialog_tool_options->set_widget(options_table);
+       App::dialog_tool_options->set_local_name(_("Mirror Tool"));
+       App::dialog_tool_options->set_name("mirror");
+}
+
+Smach::event_result
+StateMirror_Context::event_refresh_tool_options(const Smach::event& /*x*/)
+{
+       refresh_tool_options();
+       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_work_area()->reset_cursor();
+
+       keypress_connect.disconnect();
+       keyrelease_connect.disconnect();
+
+       App::dialog_tool_options->clear();
+
+       App::toolbox->refresh();
+}
+
+DuckDrag_Mirror::DuckDrag_Mirror():
+       axis(AXIS_X)
+{
+}
+
+#ifndef EPSILON
+#define EPSILON        0.0000001
+#endif
+
+void
+DuckDrag_Mirror::begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& /*offset*/)
+{
+       const DuckList selected_ducks(duckmatic->get_selected_ducks());
+       DuckList::const_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());
+               positions.push_back(p);
+       }
+
+}
+
+void
+DuckDrag_Mirror::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector)
+{
+       center=vector;
+       int i;
+
+       const DuckList selected_ducks(duckmatic->get_selected_ducks());
+       DuckList::const_iterator iter;
+
+       Time time(duckmatic->get_time());
+
+       // do the Vertex and Position ducks first
+       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)
+               {
+                       Vector p(positions[i]);
+
+                       if              (axis==AXIS_X) p[0] = -(p[0]-center[0]) + center[0];
+                       else if (axis==AXIS_Y) p[1] = -(p[1]-center[1]) + center[1];
+
+                       (*iter)->set_trans_point(p);
+               }
+
+       // then do the other ducks
+       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)
+               {
+                       // we don't need to mirror radius ducks - they're one-dimensional
+                       if ((*iter)->is_radius())
+                               continue;
+
+                       Vector p(positions[i]);
+
+                       if              (axis==AXIS_X) p[0] = -(p[0]-center[0]) + center[0];
+                       else if (axis==AXIS_Y) p[1] = -(p[1]-center[1]) + center[1];
+
+                       (*iter)->set_trans_point(p);
+               }
+}
+
+bool
+DuckDrag_Mirror::end_duck_drag(Duckmatic* duckmatic)
+{
+       duckmatic->signal_edited_selected_ducks();
+       return true;
+}
diff --git a/synfig-studio/src/gui/mod_mirror/state_mirror.h b/synfig-studio/src/gui/mod_mirror/state_mirror.h
new file mode 100644 (file)
index 0000000..f1a6364
--- /dev/null
@@ -0,0 +1,55 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_mirror.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_MIRROR_H
+#define __SYNFIG_STUDIO_STATE_MIRROR_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 StateMirror_Context;
+
+class StateMirror : public Smach::state<StateMirror_Context>
+{
+public:
+       StateMirror();
+       ~StateMirror();
+}; // END of class StateMirror
+
+extern StateMirror state_mirror;
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/mod_palette/dock_palbrowse.cpp b/synfig-studio/src/gui/mod_palette/dock_palbrowse.cpp
new file mode 100644 (file)
index 0000000..dbaff71
--- /dev/null
@@ -0,0 +1,62 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_palbrowse.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "dock_palbrowse.h"
+#include "dock_paledit.h"
+#include "mod_palette.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Dock_PalBrowse::Dock_PalBrowse():
+       Dockable("pal_browse",_("Palette Browser")/*,Gtk::StockID("gtk-select-color")*/)
+{
+}
+
+Dock_PalBrowse::~Dock_PalBrowse()
+{
+}
diff --git a/synfig-studio/src/gui/mod_palette/dock_palbrowse.h b/synfig-studio/src/gui/mod_palette/dock_palbrowse.h
new file mode 100644 (file)
index 0000000..9e039d3
--- /dev/null
@@ -0,0 +1,65 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_palbrowse.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_DOCK_PAL_BROWSE_H
+#define __SYNFIG_STUDIO_DOCK_PAL_BROWSE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "../dockable.h"
+#include <synfig/palette.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 synfigapp {
+class CanvasInterface;
+};
+
+namespace studio {
+
+/*
+
+The palette browser was intended to be a way to manage and select a single
+palette from a set of palettes that you could save to files. The palette
+editor was for editing individual palettes. Unfortunately the palette
+browser was never implemented.
+
+*/
+
+class Dock_PalBrowse : public Dockable
+{
+public:
+       Dock_PalBrowse();
+       ~Dock_PalBrowse();
+}; // END of Dock_PalBrowse
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/mod_palette/dock_paledit.cpp b/synfig-studio/src/gui/mod_palette/dock_paledit.cpp
new file mode 100644 (file)
index 0000000..718bdee
--- /dev/null
@@ -0,0 +1,396 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_paledit.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \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
+**     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 <config.h>
+#endif
+
+#include "dock_paledit.h"
+#include "../widget_color.h"
+#include <gtkmm/frame.h>
+#include <gtkmm/table.h>
+#include <gtkmm/label.h>
+#include <synfig/general.h>
+#include <synfigapp/canvasinterface.h>
+#include <synfigapp/value_desc.h>
+#include "../widget_color.h"
+#include <gtkmm/spinbutton.h>
+#include <gtkmm/menu.h>
+#include <synfigapp/main.h>
+#include "../app.h"
+#include "../dialog_color.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 ======================================================= */
+/*
+class studio::PaletteSettings : public synfigapp::Settings
+{
+       Dock_PalEdit* dialog_palette;
+       synfig::String name;
+public:
+       PaletteSettings(Dock_PalEdit* window,const synfig::String& name):
+               dialog_palette(window),
+               name(name)
+       {
+               dialog_palette->dialog_settings.add_domain(this,name);
+       }
+
+       virtual ~PaletteSettings()
+       {
+               dialog_palette->dialog_settings.remove_domain(name);
+       }
+
+       virtual bool get_value(const synfig::String& key, synfig::String& value)const
+       {
+               int i(atoi(key.c_str()));
+               if(i<0 || i>=dialog_palette->size())
+                       return false;
+               Color c(dialog_palette->get_color(i));
+               value=strprintf("%f %f %f %f",c.get_r(),c.get_g(),c.get_b(),c.get_a());
+               return true;
+       }
+
+       virtual bool set_value(const synfig::String& key,const synfig::String& value)
+       {
+               int i(atoi(key.c_str()));
+               if(i<0)
+                       return false;
+               if(i>=dialog_palette->size())
+                       dialog_palette->palette_.resize(i+1);
+               float r,g,b,a;
+               if(!strscanf(value,"%f %f %f %f",&r,&g,&b,&a))
+                       return false;
+               dialog_palette->set_color(Color(r,g,b,a),i);
+               return true;
+       }
+
+       virtual KeyList get_key_list()const
+       {
+               synfigapp::Settings::KeyList ret(synfigapp::Settings::get_key_list());
+
+               int i;
+               for(i=0;i<dialog_palette->size();i++)
+                       ret.push_back(strprintf("%03d",i));
+               return ret;
+       }
+};
+*/
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Dock_PalEdit::Dock_PalEdit():
+       Dockable("pal_edit",_("Palette Editor"),Gtk::StockID("gtk-select-color")),
+       //palette_settings(new PaletteSettings(this,"colors")),
+       table(2,2,false)
+{
+       action_group=Gtk::ActionGroup::create("action_group_pal_edit");
+       action_group->add(Gtk::Action::create(
+               "palette-add-color",
+               Gtk::StockID("gtk-add"),
+               _("Add Color"),
+               _("Add current outline color\nto the palette")
+       ),
+               sigc::mem_fun(
+                       *this,
+                       &Dock_PalEdit::on_add_pressed
+               )
+       );
+
+       App::ui_manager()->insert_action_group(action_group);
+
+    Glib::ustring ui_info =
+       "<ui>"
+       "       <toolbar action='toolbar-palette'>"
+       "       <toolitem action='palette-add-color' />"
+       "       </toolbar>"
+       "</ui>"
+       ;
+
+       App::ui_manager()->add_ui_from_string(ui_info);
+
+       set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-palette")));
+
+       /*
+       add_button(
+               Gtk::StockID("gtk-add"),
+               _("Add current outline color\nto the palette")
+       )->signal_clicked().connect(
+               sigc::mem_fun(
+                       *this,
+                       &Dock_PalEdit::on_add_pressed
+               )
+       );
+       */
+
+       add(table);
+       table.set_homogeneous(true);
+
+       set_default_palette();
+
+       show_all_children();
+}
+
+Dock_PalEdit::~Dock_PalEdit()
+{
+       //delete palette_settings;
+}
+
+void
+Dock_PalEdit::set_palette(const synfig::Palette& x)
+{
+       palette_=x;
+       refresh();
+}
+
+void
+Dock_PalEdit::on_add_pressed()
+{
+       add_color(synfigapp::Main::get_outline_color());
+}
+
+void
+Dock_PalEdit::show_menu(int i)
+{
+       Gtk::Menu* menu(manage(new Gtk::Menu()));
+       menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), menu));
+
+       menu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-select-color"),
+               sigc::bind(
+                       sigc::mem_fun(*this,&studio::Dock_PalEdit::edit_color),
+                       i
+               )
+       ));
+
+       menu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("gtk-delete"),
+               sigc::bind(
+                       sigc::mem_fun(*this,&studio::Dock_PalEdit::erase_color),
+                       i
+               )
+       ));
+
+       menu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
+
+       menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Load Default Palette"),
+               sigc::mem_fun(*this,&studio::Dock_PalEdit::set_default_palette)
+       ));
+
+       menu->popup(3,gtk_get_current_event_time());
+}
+
+int
+Dock_PalEdit::add_color(const synfig::Color& x)
+{
+       palette_.push_back(x);
+       signal_changed()();
+       refresh();
+       return size()-1;
+}
+
+void
+Dock_PalEdit::set_color(synfig::Color x, int i)
+{
+       palette_[i].color=x;
+       signal_changed()();
+       refresh();
+}
+
+Color
+Dock_PalEdit::get_color(int i)const
+{
+       return palette_[i].color;
+}
+
+void
+Dock_PalEdit::erase_color(int i)
+{
+       palette_.erase(palette_.begin()+i);
+       signal_changed()();
+       refresh();
+}
+
+void
+Dock_PalEdit::refresh()
+{
+       const int width(12);
+
+       // Clear the table
+       table.foreach(sigc::mem_fun(table,&Gtk::Table::remove));
+
+       for(int i=0;i<size();i++)
+       {
+               Widget_Color* widget_color(manage(new Widget_Color()));
+               widget_color->set_value(get_color(i));
+               widget_color->set_size_request(12,12);
+               widget_color->signal_activate().connect(
+                       sigc::bind(
+                               sigc::mem_fun(*this,&studio::Dock_PalEdit::select_fill_color),
+                               i
+                       )
+               );
+               widget_color->signal_middle_click().connect(
+                       sigc::bind(
+                               sigc::mem_fun(*this,&studio::Dock_PalEdit::select_outline_color),
+                               i
+                       )
+               );
+               widget_color->signal_right_click().connect(
+                       sigc::bind(
+                               sigc::mem_fun(*this,&studio::Dock_PalEdit::show_menu),
+                               i
+                       )
+               );
+               int c(i%width),r(i/width);
+               table.attach(*widget_color, c, c+1, r, r+1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       }
+       table.show_all();
+       queue_draw();
+}
+
+
+void
+Dock_PalEdit::edit_color(int i)
+{
+       App::dialog_color->reset();
+       App::dialog_color->set_color(get_color(i));
+       App::dialog_color->signal_edited().connect(
+               sigc::bind(
+                       sigc::mem_fun(*this,&studio::Dock_PalEdit::set_color),
+                       i
+               )
+       );
+       App::dialog_color->present();
+}
+
+void
+Dock_PalEdit::select_fill_color(int i)
+{
+       synfigapp::Main::set_fill_color(get_color(i));
+}
+
+void
+Dock_PalEdit::select_outline_color(int i)
+{
+       synfigapp::Main::set_outline_color(get_color(i));
+}
+
+void
+Dock_PalEdit::set_default_palette()
+{
+       int width=12;
+
+       palette_.clear();
+
+       // Greys
+       palette_.push_back(Color::alpha());
+       for(int i=0;i<width-1;i++)
+       {
+               Color c(
+                       float(i)/(float)(width-2),
+                       float(i)/(float)(width-2),
+                       float(i)/(float)(width-2)
+               );
+               palette_.push_back(c);
+       }
+
+       // Tans
+       for(int i=0;i<width;i++)
+       {
+               float x(float(i)/(float)(width-1));
+               const Color tan1(0.2,0.05,0);
+               const Color tan2(0.85,0.64,0.20);
+
+               palette_.push_back(Color::blend(tan2,tan1,x));
+       }
+
+       // Solids
+       palette_.push_back(Color::red());
+       palette_.push_back(Color(1.0f,0.25f,0.0f));     // Orange
+       palette_.push_back(Color::yellow());
+       palette_.push_back(Color(0.25f,1.00f,0.0f));    // yellow-green
+       palette_.push_back(Color::green());
+       palette_.push_back(Color(0.0f,1.00f,0.25f));    // green-blue
+       palette_.push_back(Color::cyan());
+       palette_.push_back(Color(0.0f,0.25f,1.0f));     // Sea Blue
+       palette_.push_back(Color::blue());
+       palette_.push_back(Color(0.25f,0.0f,1.0f));
+       palette_.push_back(Color::magenta());
+       palette_.push_back(Color(1.0f,0.0f,0.25f));
+
+
+       const int levels(3);
+
+       // Colors
+       for(int j=0;j<levels;j++)
+       for(int i=0;i<width;i++)
+       {
+               Color c(Color::red());
+               c.set_hue(c.get_hue()-Angle::rot(float(i)/(float)(width)));
+               c=c.clamped();
+               float s(float(levels-j)/float(levels));
+               s*=s;
+               c.set_r(c.get_r()*s);
+               c.set_g(c.get_g()*s);
+               c.set_b(c.get_b()*s);
+               palette_.push_back(c);
+       }
+
+
+       /*
+       const int levels(3);
+
+       for(int i=0;i<levels*levels*levels;i++)
+       {
+               Color c(
+                       float(i%levels)/(float)(levels-1),
+                       float(i/levels%levels)/(float)(levels-1),
+                       float(i/(levels*levels))/(float)(levels-1)
+               );
+               palette_.push_back(c);
+       }
+       */
+       refresh();
+}
+
+int
+Dock_PalEdit::size()const
+{
+       return palette_.size();
+}
diff --git a/synfig-studio/src/gui/mod_palette/dock_paledit.h b/synfig-studio/src/gui/mod_palette/dock_paledit.h
new file mode 100644 (file)
index 0000000..cd825ee
--- /dev/null
@@ -0,0 +1,114 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file dock_paledit.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_DOCK_PAL_EDIT_H
+#define __SYNFIG_STUDIO_DOCK_PAL_EDIT_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtk/gtk.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/table.h>
+#include <gtkmm/button.h>
+#include <gtkmm/dialog.h>
+#include <gtkmm/drawingarea.h>
+#include <gtkmm/optionmenu.h>
+#include <gtkmm/checkbutton.h>
+
+#include <synfig/gamma.h>
+#include <synfig/time.h>
+
+#include "../widget_coloredit.h"
+
+#include <synfigapp/value_desc.h>
+#include <synfig/time.h>
+
+#include "../dockable.h"
+#include <vector>
+#include <gtkmm/actiongroup.h>
+
+#include <synfig/palette.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 synfigapp {
+class CanvasInterface;
+};
+
+namespace studio {
+
+class Widget_Color;
+class PaletteSettings;
+
+class Dock_PalEdit : public Dockable
+{
+       friend class PaletteSettings;
+
+       Glib::RefPtr<Gtk::ActionGroup> action_group;
+
+       synfig::Palette palette_;
+
+       Gtk::Table table;
+
+       void on_add_pressed();
+
+       void show_menu(int i);
+
+       sigc::signal<void> signal_changed_;
+
+
+private:
+       int add_color(const synfig::Color& x);
+       void set_color(synfig::Color x, int i);
+       void erase_color(int i);
+
+       void select_fill_color(int i);
+       void select_outline_color(int i);
+       synfig::Color get_color(int i)const;
+       void edit_color(int i);
+public:
+       void set_palette(const synfig::Palette& x);
+       const synfig::Palette& get_palette()const { return palette_; }
+
+       int size()const;
+
+       void set_default_palette();
+
+       void refresh();
+
+       const sigc::signal<void>& signal_changed() { return signal_changed_; }
+
+       Dock_PalEdit();
+       ~Dock_PalEdit();
+}; // END of Dock_PalEdit
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/mod_palette/mod_palette.cpp b/synfig-studio/src/gui/mod_palette/mod_palette.cpp
new file mode 100644 (file)
index 0000000..53d5fc5
--- /dev/null
@@ -0,0 +1,80 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file mod_palette.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "mod_palette.h"
+#include "dock_paledit.h"
+#include "dock_palbrowse.h"
+
+#include "../app.h"
+#include "../dockmanager.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+bool
+studio::ModPalette::start_vfunc()
+{
+       dock_pal_edit=new Dock_PalEdit();
+       App::get_dock_manager()->register_dockable(*dock_pal_edit);
+
+       //dock_pal_browse=new Dock_PalBrowse();
+       //App::get_dock_manager()->register_dockable(*dock_pal_browse);
+
+       return true;
+}
+
+bool
+studio::ModPalette::stop_vfunc()
+{
+       //App::get_dock_manager()->unregister_dockable(*dock_pal_browse);
+       App::get_dock_manager()->unregister_dockable(*dock_pal_edit);
+
+       delete dock_pal_edit;
+       //delete dock_pal_browse;
+
+       return true;
+}
diff --git a/synfig-studio/src/gui/mod_palette/mod_palette.h b/synfig-studio/src/gui/mod_palette/mod_palette.h
new file mode 100644 (file)
index 0000000..7b18442
--- /dev/null
@@ -0,0 +1,64 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file mod_palette.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_MOD_PALETTE_H
+#define __SYNFIG_MOD_PALETTE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <ETL/handle>
+#include "../module.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 Dock_PalEdit;
+class Dock_PalBrowse;
+
+class ModPalette : public Module
+{
+       friend class Dock_PalEdit;
+       friend class Dock_PalBrowse;
+
+       Dock_PalEdit*   dock_pal_edit;
+       Dock_PalBrowse* dock_pal_browse;
+
+protected:
+       virtual bool start_vfunc();
+       virtual bool stop_vfunc();
+
+public:
+       virtual ~ModPalette() { stop(); }
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/module.cpp b/synfig-studio/src/gui/module.cpp
new file mode 100644 (file)
index 0000000..ad95ae4
--- /dev/null
@@ -0,0 +1,85 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file gtkmm/module.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "module.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Module::Module():status_(false)
+{
+}
+
+Module::~Module()
+{
+       stop();
+}
+
+bool
+Module::get_status()const
+{
+       return status_;
+}
+
+bool
+Module::start()
+{
+       if(!get_status())
+               status_=start_vfunc();
+       return get_status();
+}
+
+bool
+Module::stop()
+{
+       if(get_status() && count()<=1 && stop_vfunc())
+       {
+               status_=false;
+               return true;
+       }
+       return false;
+}
diff --git a/synfig-studio/src/gui/module.h b/synfig-studio/src/gui/module.h
new file mode 100644 (file)
index 0000000..e814bc4
--- /dev/null
@@ -0,0 +1,67 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file gtkmm/module.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_MODULE_H
+#define __SYNFIG_MODULE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <ETL/handle>
+
+/* === 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 Module : public etl::shared_object
+{
+       bool status_;
+
+protected:
+       Module();
+
+public:
+       virtual ~Module();
+
+       bool start();
+
+       bool stop();
+
+       bool get_status()const;
+
+protected:
+
+       virtual bool start_vfunc()=0;
+       virtual bool stop_vfunc()=0;
+};
+
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/onemoment.cpp b/synfig-studio/src/gui/onemoment.cpp
new file mode 100644 (file)
index 0000000..75efc2b
--- /dev/null
@@ -0,0 +1,121 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file onemoment.cpp
+**     \brief writeme
+**
+**     $Id$
+**
+**     \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
+**     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
+**
+** === N O T E S ===========================================================
+**
+** ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include <iostream>
+#include <string>
+
+#include <ETL/stringf>
+
+#include <gtkmm/image.h>
+#include <gdkmm/pixbufloader.h>
+#include <gtkmm/button.h>
+#include <gtkmm/label.h>
+#include <gtkmm/fixed.h>
+
+#include <synfig/general.h>
+
+#include "onemoment.h"
+#include "app.h"
+
+#include "general.h"
+
+#endif
+
+using namespace std;
+using namespace etl;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+#ifndef VERSION
+#define VERSION        "unknown"
+#define PACKAGE        "synfigstudio"
+#endif
+
+#ifdef WIN32
+#      ifdef IMAGE_DIR
+#              undef IMAGE_DIR
+#              define IMAGE_DIR "share\\pixmaps"
+#      endif
+#endif
+
+#ifndef IMAGE_DIR
+#      define IMAGE_DIR "/usr/local/share/pixmaps"
+#endif
+
+#ifndef IMAGE_EXT
+#      define IMAGE_EXT        "png"
+#endif
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+OneMoment::OneMoment():
+       Gtk::Window(getenv("SYNFIG_DISABLE_POPUP_WINDOWS") ? Gtk::WINDOW_TOPLEVEL : Gtk::WINDOW_POPUP)
+{
+       // Create the Label
+       Gtk::Label *label = manage(new class Gtk::Label(_("One Moment, Please...")));
+
+       set_title(_("One Moment, Please..."));
+       set_modal(false);
+       property_window_position().set_value(Gtk::WIN_POS_CENTER);
+       set_resizable(false);
+       add(*label);
+
+       Pango::AttrList attr_list;
+       Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*16));
+       pango_size.set_start_index(0);
+       pango_size.set_end_index(64);
+       attr_list.change(pango_size);
+
+       label->set_attributes(attr_list);
+
+       label->set_size_request(400,60);
+
+       get_root_window()->set_decorations(Gdk::DECOR_BORDER);
+
+       // show everything off
+       show_all();
+
+       present();
+       while(studio::App::events_pending())studio::App::iteration(false);
+}
+
+OneMoment::~OneMoment()
+{
+       hide();
+}
diff --git a/synfig-studio/src/gui/onemoment.h b/synfig-studio/src/gui/onemoment.h
new file mode 100644 (file)
index 0000000..e6e1dd9
--- /dev/null
@@ -0,0 +1,56 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file onemoment.h
+**     \brief Header File
+**
+**     $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
+**
+** === N O T E S ===========================================================
+**
+** ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_GTKMM_ONEMOMENT_H
+#define __SYNFIG_GTKMM_ONEMOMENT_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/window.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 synfig { class ProgressCallback; };
+
+namespace studio {
+
+class OneMoment : public Gtk::Window
+{
+public:
+
+       OneMoment();
+       ~OneMoment();
+};
+
+}
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/preview.cpp b/synfig-studio/src/gui/preview.cpp
new file mode 100644 (file)
index 0000000..d681d3e
--- /dev/null
@@ -0,0 +1,893 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file preview.cpp
+**     \brief Preview implementation file
+**
+**     $Id$
+**
+**     \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
+**     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 <config.h>
+#endif
+
+#include "preview.h"
+#include "app.h"
+#include "audiocontainer.h"
+#include <gtkmm/stock.h>
+#include <gtkmm/separator.h>
+
+#include <synfig/target_scanline.h>
+#include <synfig/surface.h>
+
+#include <algorithm>
+#include "asyncrenderer.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+/* === E N T R Y P O I N T ================================================= */
+
+class studio::Preview::Preview_Target : public Target_Scanline
+{
+       Surface surface;
+
+       sigc::signal<void, const Preview_Target *>              signal_frame_done_;
+
+       int scanline;
+
+       double  tbegin,tend;
+
+       int             nframes,curframe;
+
+public:
+
+       Preview_Target()
+       {
+               set_remove_alpha();
+               tbegin = tend = 0;
+               scanline = 0;
+               nframes = curframe = 0;
+       }
+
+       const RendDesc &get_rend_desc() const { return desc; }
+
+       virtual bool set_rend_desc(RendDesc *r)
+       {
+               if(Target_Scanline::set_rend_desc(r))
+               {
+                       /*synfig::warning("Succeeded in setting the desc to new one: %d x %d, %.2f fps [%.2f,%.2f]",
+                                                       desc.get_w(),desc.get_h(),desc.get_frame_rate(),
+                                       (float)desc.get_time_start(),(float)desc.get_time_end());*/
+
+                       surface.set_wh(desc.get_w(),desc.get_h());
+
+                       curframe = 0;
+                       nframes = (int)floor((desc.get_time_end() - desc.get_time_start())*desc.get_frame_rate());
+
+                       tbegin = desc.get_time_start();
+                       tend = tbegin + nframes/desc.get_frame_rate();
+
+                       return true;
+               }
+               return false;
+       }
+
+       virtual bool start_frame(ProgressCallback */*cb*/=NULL)
+       {
+               return true;
+       }
+
+       virtual void end_frame()
+       {
+               //ok... notify our subscribers...
+               signal_frame_done_(this);
+               curframe += 1;
+               //synfig::warning("Finished the frame stuff, and changed time to %.3f",t);
+       }
+
+       virtual Color * start_scanline(int scanline)
+       {
+               return surface[scanline];
+       }
+
+       virtual bool end_scanline() {return true;}
+
+       sigc::signal<void, const Preview_Target *>      &signal_frame_done() {return signal_frame_done_;}
+
+       const Surface &get_surface() const {return surface;}
+
+       float get_time() const
+       {
+               double time = ((nframes-curframe)/(double)nframes)*tbegin
+                                       + ((curframe)/(double)nframes)*tend;
+               return time;
+       }
+};
+
+studio::Preview::Preview(const studio::CanvasView::LooseHandle &h, float zoom, float f)
+:canvasview(h),zoom(zoom),fps(f)
+{
+       overbegin = false;
+       overend = false;
+}
+
+void studio::Preview::set_canvasview(const studio::CanvasView::LooseHandle &h)
+{
+       canvasview = h;
+
+       if(canvasview)
+       {
+               //perhaps reset override values...
+               const RendDesc &r = canvasview->get_canvas()->rend_desc();
+               if(r.get_frame_rate())
+               {
+                       float rate = 1/r.get_frame_rate();
+                       overbegin = false; begintime = r.get_time_start() + r.get_frame_start()*rate;
+                       overend = false; endtime = r.get_time_start() + r.get_frame_end()*rate;
+               }
+       }
+}
+
+studio::Preview::~Preview()
+{
+       signal_destroyed_(this); //tell anything that attached to us, we're dying
+}
+
+void studio::Preview::render()
+{
+       if(canvasview)
+       {
+               //render using the preview target
+               etl::handle<Preview_Target>     target = new Preview_Target;
+
+               //connect our information to his...
+               //synfig::warning("Connecting to the end frame function...");
+               target->signal_frame_done().connect(sigc::mem_fun(*this,&Preview::frame_finish));
+
+               //set the options
+               //synfig::warning("Setting Canvas");
+               target->set_canvas(get_canvas());
+               target->set_quality(quality);
+
+               //render description
+               RendDesc desc = get_canvas()->rend_desc();
+
+               //set the global fps of the preview
+               set_global_fps(desc.get_frame_rate());
+
+               desc.clear_flags();
+
+               int neww = (int)floor(desc.get_w()*zoom+0.5),
+                       newh = (int)floor(desc.get_h()*zoom+0.5);
+               float newfps = fps;
+
+               /*synfig::warning("Setting the render description: %d x %d, %f fps, [%f,%f]",
+                                               neww,newh,newfps, overbegin?begintime:(float)desc.get_time_start(),
+                                               overend?endtime:(float)desc.get_time_end());*/
+
+               desc.set_w(neww);
+               desc.set_h(newh);
+               desc.set_frame_rate(newfps);
+
+               if(overbegin)
+               {
+                       desc.set_time_start(std::max(begintime,(float)desc.get_time_start()));
+                       //synfig::warning("Set start time to %.2f...",(float)desc.get_time_start());
+               }
+               if(overend)
+               {
+                       desc.set_time_end(std::min(endtime,(float)desc.get_time_end()));
+                       //synfig::warning("Set end time to %.2f...",(float)desc.get_time_end());
+               }
+
+               //setting the description
+
+               //HACK - add on one extra frame because the renderer can't render the last frame
+               desc.set_time_end(desc.get_time_end() + 1.000001/fps);
+
+               target->set_rend_desc(&desc);
+
+               //... first we must clear our current selves of space
+               frames.resize(0);
+
+               //now tell it to go... with inherited prog. reporting...
+               //synfig::info("Rendering Asynchronously...");
+               if(renderer) renderer->stop();
+               renderer = new AsyncRenderer(target);
+               renderer->start();
+       }
+}
+
+static void free_guint8(const guint8 *mem)
+{
+       free((void*)mem);
+}
+
+void studio::Preview::frame_finish(const Preview_Target *targ)
+{
+       //copy image with time to next frame (can just push back)
+       FlipbookElem    fe;
+       float time = targ->get_time();
+       const Surface &surf = targ->get_surface();
+       const RendDesc& r = targ->get_rend_desc();
+
+       //synfig::warning("Finished a frame at %f s",time);
+
+       //copy EVERYTHING!
+       PixelFormat pf(PF_RGB);
+       const int total_bytes(r.get_w()*r.get_h()*synfig::channels(pf));
+
+       //synfig::warning("Creating a buffer");
+       unsigned char *buffer((unsigned char*)malloc(total_bytes));
+
+       if(!buffer)
+               return;
+
+       //convert all the pixels to the pixbuf... buffer... thing...
+       //synfig::warning("Converting...");
+       convert_color_format(buffer, surf[0], surf.get_w()*surf.get_h(), pf, App::gamma);
+
+       //load time
+       fe.t = time;
+       //uses and manages the memory for the buffer...
+       //synfig::warning("Create a pixmap...");
+       fe.buf =
+       Gdk::Pixbuf::create_from_data(
+               buffer, // pointer to the data
+               Gdk::COLORSPACE_RGB, // the colorspace
+               ((pf&PF_A)==PF_A), // has alpha?
+               8, // bits per sample
+               surf.get_w(),   // width
+               surf.get_h(),   // height
+               surf.get_w()*synfig::channels(pf), // stride (pitch)
+               sigc::ptr_fun(free_guint8)
+       );
+
+       //add the flipbook element to the list (assume time is correct)
+       //synfig::info("Prev: Adding %f s to the list", time);
+       frames.push_back(fe);
+
+       signal_changed()();
+}
+
+#define IMAGIFY_BUTTON(button,stockid,tooltip)                                 \
+       icon=manage(new Gtk::Image(Gtk::StockID(stockid),Gtk::ICON_SIZE_BUTTON));       \
+       button->add(*icon);     \
+       tooltips.set_tip(*button,tooltip);      \
+       icon->set_padding(0,0);\
+       icon->show();
+
+Widget_Preview::Widget_Preview()
+:Gtk::Table(5,5,false),
+adj_time_scrub(0,0,1000,1,10,0),
+scr_time_scrub(adj_time_scrub),
+b_loop(/*_("Loop")*/),
+currentindex(0),
+audiotime(0),
+adj_sound(0,0,4),
+l_lasttime("0s"),
+playing(false)
+{
+       //connect to expose events
+       //signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Preview::redraw));
+
+       //manage all the change in values etc...
+       adj_time_scrub.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_Preview::slider_move));
+       scr_time_scrub.signal_event().connect(sigc::mem_fun(*this,&Widget_Preview::scroll_move_event));
+       draw_area.signal_expose_event().connect(sigc::mem_fun(*this,&Widget_Preview::redraw));
+
+       disp_sound.set_time_adjustment(&adj_sound);
+       timedisp = -1;
+
+       //Set up signals to modify time value as it should be...
+       disp_sound.signal_start_scrubbing().connect(sigc::mem_fun(*this,&Widget_Preview::scrub_updated));
+       disp_sound.signal_scrub().connect(sigc::mem_fun(*this,&Widget_Preview::scrub_updated));
+
+       /*
+       ---------------------------------
+       |                                                               |
+       |                                                               |
+       |                                                               |
+       |                                                               |
+       |                                                               |
+       |                                                               |
+       |                                                               |
+       ---------------------------------
+       |loop|play|stop                                 | hbox
+       |lastl|lastt|rerender|haltrend  | hbox
+       |
+       |sound                                                  |
+       */
+
+       Gtk::HBox *hbox = 0;
+       Gtk::Button *button = 0;
+       Gtk::Image *icon = 0;
+
+       //should set up the dialog using attach etc.
+       attach(draw_area, 0, 1, 0, 1);
+       attach(scr_time_scrub, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
+
+       #if 1
+
+       //2nd row
+       hbox = manage(new Gtk::HBox);
+
+       button = &b_loop;
+       IMAGIFY_BUTTON(button,Gtk::Stock::REFRESH,_("Toggle Looping"));
+       hbox->pack_start(b_loop,Gtk::PACK_SHRINK,0);
+       //attach(b_loop,0,1,2,3,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK);
+
+       button = manage(new Gtk::Button(/*_("Play")*/));
+       button->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Preview::play));
+       IMAGIFY_BUTTON(button,Gtk::Stock::GO_FORWARD,_("Play"));
+       hbox->pack_start(*button,Gtk::PACK_SHRINK,0);
+       //attach(*button,1,2,2,3,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK);
+
+       button = manage(new Gtk::Button(/*_("Stop")*/));
+       button->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Preview::stop));
+       IMAGIFY_BUTTON(button,Gtk::Stock::NO,_("Stop"));
+       hbox->pack_start(*button,Gtk::PACK_SHRINK,0);
+       //attach(*button,2,3,2,3,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK);
+
+       //attack the stop render and erase all buttons to same line...
+       {
+               Gtk::VSeparator *vsep = manage(new Gtk::VSeparator);
+               hbox->pack_start(*vsep,Gtk::PACK_SHRINK,0);
+       }
+
+       button = manage(new Gtk::Button(/*_("Halt Render")*/));
+       button->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Preview::stoprender));
+       IMAGIFY_BUTTON(button,Gtk::Stock::STOP,_("Halt Render"));
+       hbox->pack_start(*button,Gtk::PACK_SHRINK,0);
+       //attach(*button,2,3,3,4,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK);
+
+       button = manage(new Gtk::Button(/*_("Re-Preview")*/));
+       button->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Preview::repreview));
+       IMAGIFY_BUTTON(button,Gtk::Stock::CONVERT,_("Re-Preview"));
+       hbox->pack_start(*button,Gtk::PACK_SHRINK,0);
+       //attach(*button,0,2,4,5,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK);
+
+       button = manage(new Gtk::Button(/*_("Erase All")*/));
+       button->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Preview::eraseall));
+       IMAGIFY_BUTTON(button,Gtk::Stock::DELETE,_("Erase All"));
+       hbox->pack_start(*button,Gtk::PACK_SHRINK,0);
+       //attach(*button,2,3,4,5,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK);
+
+       hbox->show_all();
+       attach(*hbox,0,1,2,3,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK|Gtk::FILL);
+
+       //3rd row
+       hbox = manage(new Gtk::HBox);
+       {
+               Gtk::Label *label = manage(new Gtk::Label(_("Last Rendered: ")));
+               //label->show();
+               hbox->pack_start(*label,Gtk::PACK_SHRINK,10);
+               //attach(*manage(new Gtk::Label(_("Last Rendered: "))),0,1,3,4,Gtk::SHRINK,Gtk::SHRINK);
+       }
+       //l_lasttime.show();
+       hbox->pack_start(l_lasttime,Gtk::PACK_SHRINK,0);
+       hbox->show_all();
+       attach(*hbox,0,1,3,4,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK);
+       //attach(l_lasttime,0,1,3,4,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK);
+
+       //5th row
+       disp_sound.set_size_request(-1,32);
+       attach(disp_sound,0,1,4,5,Gtk::EXPAND|Gtk::FILL,Gtk::SHRINK);
+
+       show_all();
+
+       //if(draw_area.get_window()) gc_area = Gdk::GC::create(draw_area.get_window());
+       #endif
+}
+
+studio::Widget_Preview::~Widget_Preview()
+{
+}
+
+void studio::Widget_Preview::update()
+{
+       //the meat goes in this locker...
+       double time = adj_time_scrub.get_value();
+
+       //find the frame and display it...
+       if(preview)
+       {
+               //synfig::warning("Updating at %.3f s",time);
+
+               //use time to find closest frame...
+               studio::Preview::FlipBook::const_iterator       beg = preview->begin(),end = preview->end();
+               studio::Preview::FlipBook::const_iterator       i;
+
+               i = beg;
+
+               //go to current hint if need be...
+               if(currentindex >= 0 && currentindex < (int)preview->numframes())
+               {
+                       i = beg+currentindex;
+               }
+
+               //we can't have a picture if there are none to get
+               if(beg != end)
+               {
+                       //don't bother with binary search it will just be slower...
+
+                       //synfig::info("Search for time %f",time);
+
+                       //incrementally go in either direction
+                       //(bias downward towards beg, because that's what we want)
+                       for(;i != end;++i)
+                       {
+                               //synfig::info("Look at %f",i->t);
+                               if(i->t > time) break;
+                               //synfig::info("Go past...");
+                       }
+
+                       //if(i!=beg)--i;
+
+                       //bias down, so we can't be at end... and it still is valid...
+                       for(;i != beg;)
+                       {
+                               --i;
+                               //synfig::info("Look at %f",i->t);
+                               if(i->t <= time) break;
+                               //synfig::info("Go past...");
+                       }
+
+                       /*i = preview->begin(); end = preview->end();
+                       if(i == end) return;
+
+                       j = i;
+                       for(;i != end; j = i++)
+                       {
+                               if(i->t > time) break;
+                       }*/
+
+                       //we should be at a valid edge since we biased downward
+
+                       //don't get the closest, round down... (if we can)
+                       if(i == end)
+                       {
+                               synfig::error("i == end....");
+                               //assert(0);
+                               currentbuf.clear();
+                               currentindex = 0;
+                               timedisp = -1;
+                       }else
+                       {
+                               currentbuf = i->buf;
+                               currentindex = i-beg;
+                               if(timedisp != i->t)
+                               {
+                                       timedisp = i->t;
+                                       //synfig::warning("Update at: %f seconds (%f s)",time,timedisp);
+                                       preview_draw();
+                                       //synfig::warning("success!");
+                               }
+                       }
+               }
+       }
+
+       if(disp_sound.get_profile() && adj_sound.get_value() != time)
+       {
+               //timeupdate = time;
+
+               //Set the position of the sound (short circuited for sound modifying the time)
+
+               disp_sound.set_position(time);
+               disp_sound.queue_draw();
+       }
+}
+void studio::Widget_Preview::preview_draw()
+{
+       draw_area.queue_draw();//on_expose_event();
+}
+
+bool studio::Widget_Preview::redraw(GdkEventExpose */*heh*/)
+{
+       //And render the drawing area
+       Glib::RefPtr<Gdk::Pixbuf> pxnew, px = currentbuf;
+
+       if(!px || draw_area.get_height() == 0
+               || px->get_height() == 0 || px->get_width() == 0 /*|| is_visible()*/) //made not need this line
+               return true;
+
+       //figure out the scaling factors...
+       float sx, sy;
+       int nw,nh;
+
+       sx = draw_area.get_width() / (float)px->get_width();
+       sy = draw_area.get_height() / (float)px->get_height();
+
+       //synfig::info("widget_preview redraw: now to scale the bitmap: %.3f x %.3f",sx,sy);
+
+       //round to smallest scale (fit entire thing in window without distortion)
+       if(sx > sy) sx = sy;
+       //else sy = sx;
+
+       //scale to a new pixmap and then copy over to the window
+       nw = (int)(px->get_width()*sx);
+       nh = (int)(px->get_height()*sx);
+
+       if(nw == 0 || nh == 0)return true;
+
+       pxnew = px->scale_simple(nw,nh,Gdk::INTERP_NEAREST);
+
+       //synfig::info("Now to draw to the window...");
+       //copy to window
+       Glib::RefPtr<Gdk::Window>       wind = draw_area.get_window();
+       Glib::RefPtr<Gdk::Drawable> surf = Glib::RefPtr<Gdk::Drawable>::cast_static(wind);
+       Glib::RefPtr<Gdk::GC>           gc = Gdk::GC::create(wind);
+
+       {
+               Gdk::Rectangle r(0,0,draw_area.get_width(),draw_area.get_height());
+               draw_area.get_window()->begin_paint_rect(r);
+       }
+
+       if(!wind) synfig::warning("The destination window is broken...");
+       if(!surf) synfig::warning("The destination is not drawable...");
+
+       if(surf)
+       {
+               /* Options for drawing...
+                       1) store with alpha, then clear and render with alpha every frame
+                               - more time consuming
+                               + more expandable
+                       2) store with just pixel info
+                               - less expandable
+                               + faster
+                               + better memory footprint
+               */
+               //px->composite(const Glib::RefPtr<Gdk::Pixbuf>& dest, int dest_x, int dest_y, int dest_width, int dest_height, double offset_x, double offset_y, double scale_x, double scale_y, InterpType interp_type, int overall_alpha) const
+
+               surf->draw_pixbuf(
+                       gc, //GC
+                       pxnew, //pixbuf
+                       0, 0,   // Source X and Y
+                       0, 0,   // Dest X and Y
+                       -1,-1,  // Width and Height
+                       Gdk::RGB_DITHER_NONE, // RgbDither
+                       0, 0 // Dither offset X and Y
+               );
+
+               if(timedisp >= 0)
+               {
+                       Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_pango_context()));
+                       Glib::ustring timecode(Time((double)timedisp).round(preview->get_global_fps())
+                                                                                                                       .get_string(preview->get_global_fps(),
+                                                                                                                                                       App::get_time_format()));
+                       //synfig::info("Time for preview draw is: %s for time %g", timecode.c_str(), adj_time_scrub.get_value());
+
+                       gc->set_rgb_fg_color(Gdk::Color("#FF0000"));
+                       layout->set_text(timecode);
+                       surf->draw_layout(gc,4,4,layout);
+               }
+       }
+
+       draw_area.get_window()->end_paint();
+
+       //synfig::warning("Refresh the draw area");
+       //make sure the widget refreshes
+
+       return false;
+}
+
+bool studio::Widget_Preview::play_update()
+{
+       float diff = timer.pop_time();
+       //synfig::info("Play update: diff = %.2f",diff);
+
+       if(playing)
+       {
+               //we go to the next one...
+               double time = adj_time_scrub.get_value() + diff;
+
+               //adjust it to be synced with the audio if it can...
+               {
+                       double newtime = audiotime;
+                       if(audio && audio->is_playing()) audio->get_current_time(newtime);
+
+                       if(newtime != audiotime)
+                       {
+                               //synfig::info("Adjusted time from %.3lf to %.3lf", time,newtime);
+                               time = audiotime = newtime;
+                       }
+               }
+
+               //Looping conditions...
+               if(time >= adj_time_scrub.get_upper())
+               {
+                       if(get_loop_flag())
+                       {
+                               time = adj_time_scrub.get_lower();// + time-adj_time_scrub.get_upper();
+                               currentindex = 0;
+                       }else
+                       {
+                               time = adj_time_scrub.get_upper();
+                               adj_time_scrub.set_value(time);
+                               play_stop();
+                               update();
+
+                               //synfig::info("Play Stopped: time set to %f",adj_time_scrub.get_value());
+                               return false;
+                       }
+               }
+
+               //set the new time...
+               adj_time_scrub.set_value(time);
+               adj_time_scrub.value_changed();
+
+               //update the window to the correct image we might want to do this later...
+               //update();
+               //synfig::warning("Did update pu");
+       }
+       return true;
+}
+
+void studio::Widget_Preview::slider_move()
+{
+       //if(!playing)
+       {
+               update();
+               //synfig::warning("Did update sm");
+       }
+}
+
+//for other things updating the value changed signal...
+void studio::Widget_Preview::scrub_updated(double t)
+{
+       stop();
+
+       //Attempt at being more accurate... the time is adjusted to be exactly where the sound says it is
+       //double oldt = t;
+       if(audio)
+       {
+               if(!audio->isPaused())
+               {
+                       audio->get_current_time(t);
+               }
+       }
+
+       //synfig::info("Scrubbing to %.3f, setting adj to %.3f",oldt,t);
+
+       if(adj_time_scrub.get_value() != t)
+       {
+               adj_time_scrub.set_value(t);
+               adj_time_scrub.value_changed();
+       }
+}
+
+void studio::Widget_Preview::disconnect_preview(Preview *prev)
+{
+       if(prev == preview)
+       {
+               preview = 0;
+               prevchanged.disconnect();
+       }
+}
+
+void studio::Widget_Preview::set_preview(etl::handle<Preview>  prev)
+{
+       preview = prev;
+
+       synfig::info("Setting preview");
+
+       //stop playing the mini animation...
+       stop();
+
+       if(preview)
+       {
+               //set the internal values
+               float rate = preview->get_fps();
+               synfig::info("  FPS = %f",rate);
+               if(rate)
+               {
+                       float start = preview->get_begintime();
+                       float end = preview->get_endtime();
+
+                       rate = 1/rate;
+
+                       adj_time_scrub.set_lower(start);
+                       adj_time_scrub.set_upper(end);
+                       adj_time_scrub.set_value(start);
+                       adj_time_scrub.set_step_increment(rate);
+                       adj_time_scrub.set_page_increment(10*rate);
+
+                       //if the begin time and the end time are the same there is only a single frame
+                       singleframe = end==start;
+               }else
+               {
+                       adj_time_scrub.set_lower(0);
+                       adj_time_scrub.set_upper(0);
+                       adj_time_scrub.set_value(0);
+                       adj_time_scrub.set_step_increment(0);
+                       adj_time_scrub.set_page_increment(0);
+                       singleframe = true;
+               }
+
+               //connect so future information will be found...
+               prevchanged = prev->signal_changed().connect(sigc::mem_fun(*this,&Widget_Preview::whenupdated));
+               prev->signal_destroyed().connect(sigc::mem_fun(*this,&Widget_Preview::disconnect_preview));
+               update();
+               //synfig::warning("Did update sp");
+               queue_draw();
+       }
+}
+
+void studio::Widget_Preview::whenupdated()
+{
+       l_lasttime.set_text((Time((double)(--preview->end())->t)
+                                                       .round(preview->get_global_fps())
+                                                       .get_string(preview->get_global_fps(),App::get_time_format())));
+       update();
+}
+
+void studio::Widget_Preview::clear()
+{
+       preview = 0;
+       prevchanged.disconnect();
+}
+
+void studio::Widget_Preview::play()
+{
+       if(preview && !playing)
+       {
+               //synfig::info("Playing at %lf",adj_time_scrub.get_value());
+               //audiotime = adj_time_scrub.get_value();
+               playing = true;
+
+               //adj_time_scrub.set_value(adj_time_scrub.get_lower());
+               update(); //we don't want to call play update because that will try to advance the timer
+               //synfig::warning("Did update p");
+
+               //approximate length of time in seconds, right?
+               double rate = /*std::min(*/adj_time_scrub.get_step_increment()/*,1/30.0)*/;
+               int timeout = (int)floor(1000*rate);
+
+               //synfig::info("        rate = %.3lfs = %d ms",rate,timeout);
+
+               signal_play_(adj_time_scrub.get_value());
+
+               //play the audio...
+               if(audio) audio->play(adj_time_scrub.get_value());
+
+               timecon = Glib::signal_timeout().connect(sigc::mem_fun(*this,&Widget_Preview::play_update),timeout);
+               timer.reset();
+       }
+
+}
+
+void studio::Widget_Preview::play_stop()
+{
+       playing = false;
+       signal_stop()();
+       if(audio) audio->stop(); //!< stop the audio
+       //synfig::info("Stopping...");
+}
+
+void studio::Widget_Preview::stop()
+{
+       //synfig::warning("stopping");
+       play_stop();
+       timecon.disconnect();
+}
+
+bool studio::Widget_Preview::scroll_move_event(GdkEvent *event)
+{
+       switch(event->type)
+       {
+               case GDK_BUTTON_PRESS:
+               {
+                       if(event->button.button == 1 || event->button.button == 3)
+                       {
+                               stop();
+                       }
+               }
+
+               default: break;
+       }
+
+       return false;
+}
+
+void studio::Widget_Preview::set_audioprofile(etl::handle<AudioProfile> p)
+{
+       disp_sound.set_profile(p);
+}
+
+void studio::Widget_Preview::set_audio(etl::handle<AudioContainer> a)
+{
+       audio = a;
+
+       //disconnect any previous signals
+       scrstartcon.disconnect(); scrstopcon.disconnect(); scrubcon.disconnect();
+
+       //connect the new signals
+       scrstartcon = disp_sound.signal_start_scrubbing().connect(sigc::mem_fun(*a,&AudioContainer::start_scrubbing));
+       scrstopcon = disp_sound.signal_stop_scrubbing().connect(sigc::mem_fun(*a,&AudioContainer::stop_scrubbing));
+       scrubcon = disp_sound.signal_scrub().connect(sigc::mem_fun(*a,&AudioContainer::scrub));
+}
+
+void studio::Widget_Preview::seek(float t)
+{
+       stop();
+       adj_time_scrub.set_value(t);
+}
+
+void studio::Widget_Preview::repreview()
+{
+       if(preview)
+       {
+               stoprender();
+               stop();
+               preview->get_canvasview()->preview_option();
+       }
+}
+
+void studio::Widget_Preview::stoprender()
+{
+       if(preview)
+       {
+               // don't crash if the render has already been stopped
+               if (!preview->renderer)
+                       return;
+
+#ifdef SINGLE_THREADED
+               if (preview->renderer->updating)
+                       preview->renderer->stop();
+               else
+#endif
+                       preview->renderer.detach();
+       }
+}
+
+void studio::Widget_Preview::eraseall()
+{
+       stop();
+       stoprender();
+
+       currentbuf.clear();
+       currentindex = 0;
+       timedisp = 0;
+       queue_draw();
+
+       if(preview)
+       {
+               preview->clear();
+       }
+}
diff --git a/synfig-studio/src/gui/preview.h b/synfig-studio/src/gui/preview.h
new file mode 100644 (file)
index 0000000..82c2416
--- /dev/null
@@ -0,0 +1,260 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file preview.h
+**     \brief Previews an animation
+**
+**     $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_PREVIEW_H
+#define __SYNFIG_PREVIEW_H
+
+/* === H E A D E R S ======================================================= */
+#include <ETL/handle>
+#include <ETL/clock> /* indirectly includes winnt.h on WIN32 - needs to be included before gtkmm headers, which fix this */
+
+#include <gtkmm/drawingarea.h>
+#include <gtkmm/table.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/image.h>
+#include <gdkmm/pixbuf.h>
+#include <gtkmm/dialog.h>
+#include <gtkmm/scrollbar.h>
+#include <gtkmm/checkbutton.h>
+#include <gui/canvasview.h>
+#include <gtkmm/tooltips.h>
+
+#include <synfig/time.h>
+#include <synfig/vector.h>
+#include <synfig/general.h>
+#include <synfig/renddesc.h>
+#include <synfig/canvas.h>
+
+#include "widget_sound.h"
+
+#include <vector>
+
+/* === 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 AsyncRenderer;
+
+class Preview : public sigc::trackable, public etl::shared_object
+{
+public:
+       struct FlipbookElem
+       {
+               float                                           t;
+               Glib::RefPtr<Gdk::Pixbuf>       buf; //at whatever resolution they are rendered at (resized at run time)
+       };
+
+       etl::handle<studio::AsyncRenderer>      renderer;
+
+       sigc::signal<void, Preview *>   signal_destroyed_;      //so things can reference us without fear
+
+       typedef std::vector<FlipbookElem>        FlipBook;
+private:
+
+       FlipBook                        frames;
+
+       studio::CanvasView::LooseHandle canvasview;
+
+       //synfig::RendDesc              description; //for rendering the preview...
+       float   zoom,fps;
+       float   begintime,endtime;
+       bool    overbegin,overend;
+       int             quality;
+
+       float   global_fps;
+
+       //expose the frame information etc.
+       class Preview_Target;
+       void frame_finish(const Preview_Target *);
+
+       sigc::signal0<void>     sig_changed;
+
+public:
+
+       Preview(const studio::CanvasView::LooseHandle &h = studio::CanvasView::LooseHandle(),
+                               float zoom = 0.5f, float fps = 15);
+       ~Preview();
+
+       float   get_zoom() const {return zoom;}
+       void    set_zoom(float z){zoom = z;}
+
+       float   get_fps() const {return fps;}
+       void    set_fps(float f){fps = f;}
+
+       float   get_global_fps() const {return global_fps;}
+       void    set_global_fps(float f){global_fps = f;}
+
+       float   get_begintime() const
+       {
+               if(overbegin)
+                       return begintime;
+               else if(canvasview)
+                       return get_canvas()->rend_desc().get_time_start();
+               else return -1;
+       }
+
+       float   get_endtime() const
+       {
+               if(overend)
+                       return endtime;
+               else if(canvasview)
+                       return get_canvas()->rend_desc().get_time_end();
+               else return -1;
+       }
+
+       void    set_begintime(float t)  {begintime = t;}
+       void    set_endtime(float t)    {endtime = t;}
+
+       bool get_overbegin() const {return overbegin;}
+       void set_overbegin(bool b) {overbegin = b;}
+
+       bool get_overend() const {return overend;}
+       void set_overend(bool b) {overend = b;}
+
+       int             get_quality() const {return quality;}
+       void    set_quality(int i)      {quality = i;}
+
+       synfig::Canvas::Handle  get_canvas() const {return canvasview->get_canvas();}
+       studio::CanvasView::Handle      get_canvasview() const {return canvasview;}
+
+       void set_canvasview(const studio::CanvasView::LooseHandle &h);
+
+       //signal interface
+       sigc::signal<void, Preview *> & signal_destroyed() { return signal_destroyed_; }
+       //sigc::signal<void, const synfig::RendDesc &>  &signal_desc_change() {return signal_desc_change_;}
+
+       //functions for exposing iterators through the preview
+       FlipBook::iterator      begin()         {return frames.begin();}
+       FlipBook::iterator      end()           {return frames.end();}
+
+       FlipBook::const_iterator        begin() const {return frames.begin();}
+       FlipBook::const_iterator        end() const       {return frames.end();}
+
+       void clear() {frames.clear();}
+
+       unsigned int                            numframes() const  {return frames.size();}
+
+       void render();
+
+       sigc::signal0<void>     &signal_changed() { return sig_changed; }
+};
+
+class Widget_Preview : public Gtk::Table
+{
+       Gtk::DrawingArea        draw_area;
+       Gtk::Adjustment         adj_time_scrub; //the adjustment for the managed scrollbar
+       Gtk::HScrollbar         scr_time_scrub;
+       Gtk::ToggleButton       b_loop;
+       Gtk::Tooltips           tooltips;
+
+       //Glib::RefPtr<Gdk::GC>         gc_area;
+       Glib::RefPtr<Gdk::Pixbuf>       currentbuf;
+       int                                                     currentindex;
+       //double                                                timeupdate;
+       double                                          timedisp;
+       double                                          audiotime;
+
+       //sound stuff
+       etl::handle<AudioContainer>     audio;
+       sigc::connection        scrstartcon;
+       sigc::connection        scrstopcon;
+       sigc::connection        scrubcon;
+
+       //preview encapsulation
+       etl::handle<Preview>    preview;
+       sigc::connection                prevchanged;
+
+       Widget_Sound                    disp_sound;
+       Gtk::Adjustment                 adj_sound;
+
+       Gtk::Label                              l_lasttime;
+
+       //only for internal stuff, doesn't set anything
+       bool    playing;
+       bool    singleframe;
+
+       //for accurate time tracking
+       etl::clock      timer;
+
+       //int           curindex; //for later
+       sigc::connection        timecon;
+
+       void slider_move(); //later to be a time_slider that's cooler
+       bool play_update();
+       void play_stop();
+       //bool play_frameupdate();
+       void update();
+
+       void scrub_updated(double t);
+
+       void repreview();
+
+       void whenupdated();
+
+       void eraseall();
+
+       bool scroll_move_event(GdkEvent *);
+       void disconnect_preview(Preview *);
+
+       bool redraw(GdkEventExpose *heh = 0);
+       void preview_draw();
+
+       sigc::signal<void,float>        signal_play_;
+       sigc::signal<void>                      signal_stop_;
+       sigc::signal<void,float>        signal_seek_;
+
+public:
+
+       Widget_Preview();
+       ~Widget_Preview();
+
+       //sets a signal to identify disconnection (so we don't hold onto it)...
+       void set_preview(etl::handle<Preview> prev);
+       void set_audioprofile(etl::handle<AudioProfile> p);
+       void set_audio(etl::handle<AudioContainer> a);
+
+       void clear();
+
+       void play();
+       void stop();
+       void seek(float t);
+
+       void stoprender();
+
+       sigc::signal<void,float>        &signal_play() {return signal_play_;}
+       sigc::signal<void>      &signal_stop() {return signal_stop_;}
+       sigc::signal<void,float>        &signal_seek() {return signal_seek_;}
+
+       bool get_loop_flag() const {return b_loop.get_active();}
+       void set_loop_flag(bool b) {return b_loop.set_active(b);}
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/renddesc.cpp b/synfig-studio/src/gui/renddesc.cpp
new file mode 100644 (file)
index 0000000..c88ac87
--- /dev/null
@@ -0,0 +1,620 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file gtkmm/renddesc.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \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
+**     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 <config.h>
+#endif
+
+#include "renddesc.h"
+#include <gtkmm/label.h>
+#include <gtkmm/frame.h>
+#include <gtkmm/alignment.h>
+#include <gtkmm/box.h>
+#include <ETL/misc>
+#include <synfig/general.h>
+//#include <gtkmm/separator.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 ========================================================= */
+
+#ifndef SYNFIG_MAX_PIXEL_WIDTH
+#define SYNFIG_MAX_PIXEL_WIDTH (~(1<<31))
+#endif
+
+#ifndef SYNFIG_MAX_PIXEL_HEIGHT
+#define SYNFIG_MAX_PIXEL_HEIGHT        (~(1<<31))
+#endif
+
+#ifndef DPM2DPI
+#define DPM2DPI(x)     ((x)/39.3700787402)
+#define DPI2DPM(x)     ((x)*39.3700787402)
+#endif
+
+#ifndef METERS2INCHES
+#define METERS2INCHES(x)       ((x)*39.3700787402)
+#define INCHES2METERS(x)       ((x)/39.3700787402)
+#endif
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Widget_RendDesc::Widget_RendDesc():
+       Gtk::Notebook(),
+       adjustment_width(1,1,SYNFIG_MAX_PIXEL_WIDTH),
+       adjustment_height(1,1,SYNFIG_MAX_PIXEL_HEIGHT),
+       adjustment_xres(0,0.0000000001,10000000),
+       adjustment_yres(0,0.0000000001,10000000),
+       adjustment_phy_width(0,0.0000000001,10000000),
+       adjustment_phy_height(0,0.0000000001,10000000),
+       adjustment_fps(0,0.0000000001,10000000),
+       adjustment_span(0,0.0000000001,10000000)
+{
+       update_lock=0;
+
+       create_widgets();
+       connect_signals();
+
+       Gtk::Label *image_tab_label = manage(new Gtk::Label(_("Image")));
+       Gtk::Label *time_tab_label = manage(new Gtk::Label(_("Time")));
+       Gtk::Label *other_tab_label = manage(new Gtk::Label(_("Other")));
+       Gtk::Widget *imageTab = create_image_tab();
+       Gtk::Widget *timeTab = create_time_tab();
+       Gtk::Widget *otherTab = create_other_tab();
+       append_page(*imageTab, *image_tab_label);
+       append_page(*timeTab, *time_tab_label);
+       append_page(*otherTab, *other_tab_label);
+}
+
+Widget_RendDesc::~Widget_RendDesc()
+{
+}
+
+void Widget_RendDesc::set_rend_desc(const synfig::RendDesc &rend_desc)
+{
+       if(update_lock)return;
+
+       rend_desc_=rend_desc;
+       refresh();
+}
+
+void
+Widget_RendDesc::refresh()
+{
+       UpdateLock lock(update_lock);
+       adjustment_width.set_value(rend_desc_.get_w());
+       adjustment_height.set_value(rend_desc_.get_h());
+       adjustment_phy_width.set_value(METERS2INCHES(rend_desc_.get_physical_w()));
+       adjustment_phy_height.set_value(METERS2INCHES(rend_desc_.get_physical_h()));
+       adjustment_xres.set_value(DPM2DPI(rend_desc_.get_x_res()));
+       adjustment_yres.set_value(DPM2DPI(rend_desc_.get_y_res()));
+       entry_start_time->set_fps(rend_desc_.get_frame_rate());
+       entry_start_time->set_value(rend_desc_.get_time_start());
+       entry_end_time->set_fps(rend_desc_.get_frame_rate());
+       entry_end_time->set_value(rend_desc_.get_time_end());
+
+       adjustment_fps.set_value(rend_desc_.get_frame_rate());
+       adjustment_span.set_value(rend_desc_.get_span());
+       entry_tl->set_value(rend_desc_.get_tl());
+       entry_br->set_value(rend_desc_.get_br());
+       entry_focus->set_value(rend_desc_.get_focus());
+
+       toggle_px_aspect->set_active((bool)(rend_desc_.get_flags()&RendDesc::PX_ASPECT));
+       toggle_px_width->set_active((bool)(rend_desc_.get_flags()&RendDesc::PX_W));
+       toggle_px_height->set_active((bool)(rend_desc_.get_flags()&RendDesc::PX_H));
+
+       toggle_im_aspect->set_active((bool)(rend_desc_.get_flags()&RendDesc::IM_ASPECT));
+       toggle_im_width->set_active((bool)(rend_desc_.get_flags()&RendDesc::IM_W));
+       toggle_im_height->set_active((bool)(rend_desc_.get_flags()&RendDesc::IM_H));
+       toggle_im_span->set_active((bool)(rend_desc_.get_flags()&RendDesc::IM_SPAN));
+}
+
+void Widget_RendDesc::apply_rend_desc(const synfig::RendDesc &rend_desc)
+{
+       set_rend_desc(rend_desc);
+}
+
+const synfig::RendDesc &
+Widget_RendDesc::get_rend_desc()
+{
+       return rend_desc_;
+}
+
+void
+Widget_RendDesc::on_width_changed()
+{
+       if(update_lock)return;
+       UpdateLock lock(update_lock);
+       rend_desc_.set_w(round_to_int(adjustment_width.get_value()));
+       refresh();
+       signal_changed()();
+}
+
+void
+Widget_RendDesc::on_lock_changed()
+{
+       if(update_lock)return;
+       UpdateLock lock(update_lock);
+
+#define DO_TOGGLE(x,y) if(toggle_ ## x->get_active()) \
+               rend_desc_.set_flags(rend_desc_.get_flags()|RendDesc:: y); \
+       else \
+               rend_desc_.set_flags(rend_desc_.get_flags()&~RendDesc:: y)
+
+       DO_TOGGLE(px_aspect,PX_ASPECT);
+       DO_TOGGLE(px_width,PX_W);
+       DO_TOGGLE(px_height,PX_H);
+
+       DO_TOGGLE(im_aspect,IM_ASPECT);
+       DO_TOGGLE(im_width,IM_W);
+       DO_TOGGLE(im_height,IM_H);
+       DO_TOGGLE(im_span,IM_SPAN);
+
+#undef DO_TOGGLE
+
+       refresh();
+       signal_changed()();
+}
+
+void
+Widget_RendDesc::on_height_changed()
+{
+       if(update_lock)return;
+       UpdateLock lock(update_lock);
+       rend_desc_.set_h(round_to_int(adjustment_height.get_value()));
+       refresh();
+       signal_changed()();
+}
+
+void
+Widget_RendDesc::on_phy_width_changed()
+{
+       if(update_lock)return;
+       UpdateLock lock(update_lock);
+       rend_desc_.set_physical_w(INCHES2METERS(adjustment_phy_width.get_value()));
+       refresh();
+       signal_changed()();
+}
+
+void
+Widget_RendDesc::on_phy_height_changed()
+{
+       if(update_lock)return;
+       UpdateLock lock(update_lock);
+       rend_desc_.set_physical_h(INCHES2METERS(adjustment_phy_height.get_value()));
+       refresh();
+       signal_changed()();
+}
+
+void
+Widget_RendDesc::on_xres_changed()
+{
+       if(update_lock)return;
+       UpdateLock lock(update_lock);
+       rend_desc_.set_x_res(DPI2DPM(adjustment_xres.get_value()));
+       refresh();
+       signal_changed()();
+}
+
+void
+Widget_RendDesc::on_yres_changed()
+{
+       if(update_lock)return;
+       UpdateLock lock(update_lock);
+       rend_desc_.set_y_res(DPI2DPM(adjustment_yres.get_value()));
+       refresh();
+       signal_changed()();
+}
+
+void
+Widget_RendDesc::on_start_time_changed()
+{
+       if(update_lock)return;
+       UpdateLock lock(update_lock);
+       rend_desc_.set_time_start(entry_start_time->get_value());
+       refresh();
+       signal_changed()();
+}
+
+void
+Widget_RendDesc::on_end_time_changed()
+{
+       if(update_lock)return;
+       UpdateLock lock(update_lock);
+       rend_desc_.set_time_end(entry_end_time->get_value());
+       refresh();
+       signal_changed()();
+}
+
+/*
+void
+Widget_RendDesc::on_start_frame_changed()
+{
+       if(update_lock)return;
+       UpdateLock lock(update_lock);
+       rend_desc_.set_frame_start((int)(adjustment_start_frame.get_value()+0.5));
+       refresh();
+       signal_changed()();
+}
+
+void
+Widget_RendDesc::on_end_frame_changed()
+{
+       if(update_lock)return;
+       UpdateLock lock(update_lock);
+       rend_desc_.set_frame_end((int)(adjustment_end_frame.get_value()+0.5));
+       refresh();
+       signal_changed()();
+}
+*/
+
+void
+Widget_RendDesc::on_fps_changed()
+{
+       if(update_lock)return;
+       UpdateLock lock(update_lock);
+       rend_desc_.set_frame_rate((int)(adjustment_fps.get_value()+0.5));
+       refresh();
+       signal_changed()();
+}
+
+void
+Widget_RendDesc::on_tl_changed()
+{
+       if(update_lock)return;
+       UpdateLock lock(update_lock);
+       rend_desc_.set_tl(entry_tl->get_value());
+       refresh();
+       signal_changed()();
+}
+
+void
+Widget_RendDesc::on_br_changed()
+{
+       if(update_lock)return;
+       UpdateLock lock(update_lock);
+       rend_desc_.set_br(entry_br->get_value());
+       refresh();
+       signal_changed()();
+}
+
+void
+Widget_RendDesc::on_focus_changed()
+{
+       if(update_lock)return;
+       UpdateLock lock(update_lock);
+       rend_desc_.set_focus(entry_focus->get_value());
+       refresh();
+       signal_changed()();
+}
+
+void
+Widget_RendDesc::on_span_changed()
+{
+       if(update_lock)return;
+       UpdateLock lock(update_lock);
+       rend_desc_.set_span(adjustment_span.get_value());
+       refresh();
+       signal_changed()();
+}
+
+void
+Widget_RendDesc::disable_time_section()
+{
+       time_frame->set_sensitive(false);
+
+/*
+       Gtk::Table::TableList &list=time_table->children();
+       Gtk::Table::TableList::iterator iter;
+       for(iter=list.begin();iter!=list.end();iter++)
+               iter->get_widget()->set_sensitive(false);
+*/
+}
+
+void
+Widget_RendDesc::enable_time_section()
+{
+       time_frame->set_sensitive(true);
+
+/*
+       Gtk::Table::TableList &list=time_table->children();
+       Gtk::Table::TableList::iterator iter;
+       for(iter=list.begin();iter!=list.end();iter++)
+               iter->get_widget()->set_sensitive(true);
+
+*/
+}
+
+void
+Widget_RendDesc::create_widgets()
+{
+       entry_width=manage(new Gtk::SpinButton(adjustment_width,1,0));
+       entry_width->set_alignment(1);
+       entry_height=manage(new Gtk::SpinButton(adjustment_height,1,0));
+       entry_height->set_alignment(1);
+       entry_xres=manage(new Gtk::SpinButton(adjustment_xres,0.5,1));
+       entry_xres->set_alignment(1);
+       entry_yres=manage(new Gtk::SpinButton(adjustment_yres,0.5,1));
+       entry_yres->set_alignment(1);
+       entry_phy_width=manage(new Gtk::SpinButton(adjustment_phy_width,0.25,2));
+       entry_phy_width->set_alignment(1);
+       entry_phy_height=manage(new Gtk::SpinButton(adjustment_phy_height,0.25,2));
+       entry_phy_height->set_alignment(1);
+       entry_span=manage(new Gtk::SpinButton(adjustment_span,0.1,4));
+       entry_span->set_alignment(1);
+       entry_tl=manage(new Widget_Vector());
+       entry_br=manage(new Widget_Vector());
+       entry_fps=manage(new Gtk::SpinButton(adjustment_fps,1,5));
+       entry_start_time=manage(new Widget_Time());
+       entry_end_time=manage(new Widget_Time());
+       //entry_start_frame=manage(new Gtk::SpinButton(adjustment_start_frame,1,0));
+       //entry_end_frame=manage(new Gtk::SpinButton(adjustment_end_frame,1,0));
+       entry_focus=manage(new Widget_Vector());
+       toggle_px_aspect=manage(new Gtk::CheckButton(_("_Pixel Aspect"), true));
+       toggle_px_aspect->set_alignment(0, 0.5);
+       toggle_px_width=manage(new Gtk::CheckButton(_("Pi_xel Width"), true));
+       toggle_px_width->set_alignment(0, 0.5);
+       toggle_px_height=manage(new Gtk::CheckButton(_("Pix_el Height"), true));
+       toggle_px_height->set_alignment(0, 0.5);
+       toggle_im_aspect=manage(new Gtk::CheckButton(_("Image _Aspect"), true));
+       toggle_im_aspect->set_alignment(0, 0.5);
+       toggle_im_width=manage(new Gtk::CheckButton(_("Image _Width"), true));
+       toggle_im_width->set_alignment(0, 0.5);
+       toggle_im_height=manage(new Gtk::CheckButton(_("Image _Height"), true));
+       toggle_im_height->set_alignment(0, 0.5);
+       toggle_im_span=manage(new Gtk::CheckButton(_("Image _Span"), true));
+       toggle_im_span->set_alignment(0, 0.5);
+}
+
+void
+Widget_RendDesc::connect_signals()
+{
+       entry_width->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_width_changed));
+       entry_height->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_height_changed));
+       entry_xres->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_xres_changed));
+       entry_yres->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_yres_changed));
+       entry_phy_width->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_phy_width_changed));
+       entry_phy_height->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_phy_height_changed));
+       entry_span->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_span_changed));
+       entry_tl->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_tl_changed));
+       entry_br->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_br_changed));
+       entry_fps->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_fps_changed));
+       entry_start_time->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_start_time_changed));
+       entry_end_time->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_end_time_changed));
+       //entry_start_frame->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_start_frame_changed));
+       //entry_end_frame->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_end_frame_changed));
+       entry_focus->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_RendDesc::on_focus_changed));
+       toggle_px_aspect->signal_toggled().connect(sigc::mem_fun(*this, &studio::Widget_RendDesc::on_lock_changed));
+       toggle_px_width->signal_toggled().connect(sigc::mem_fun(*this, &studio::Widget_RendDesc::on_lock_changed));
+       toggle_px_height->signal_toggled().connect(sigc::mem_fun(*this, &studio::Widget_RendDesc::on_lock_changed));
+       toggle_im_aspect->signal_toggled().connect(sigc::mem_fun(*this, &studio::Widget_RendDesc::on_lock_changed));
+       toggle_im_width->signal_toggled().connect(sigc::mem_fun(*this, &studio::Widget_RendDesc::on_lock_changed));
+       toggle_im_height->signal_toggled().connect(sigc::mem_fun(*this, &studio::Widget_RendDesc::on_lock_changed));
+       toggle_im_span->signal_toggled().connect(sigc::mem_fun(*this, &studio::Widget_RendDesc::on_lock_changed));
+}
+
+Gtk::Widget *
+Widget_RendDesc::create_image_tab()
+{
+       Gtk::Alignment *paddedPanel = manage(new Gtk::Alignment(0, 0, 1, 1));
+       paddedPanel->set_padding(12, 12, 12, 12);
+
+       Gtk::VBox *panelBox = manage(new Gtk::VBox(false, 12));
+       paddedPanel->add(*panelBox);
+
+       Gtk::Frame *imageFrame = manage(new Gtk::Frame(_("Image Size")));
+       imageFrame->set_shadow_type(Gtk::SHADOW_NONE);
+       ((Gtk::Label *) imageFrame->get_label_widget())->set_markup(_("<b>Image Size</b>"));
+       panelBox->pack_start(*imageFrame, false, false, 0);
+
+       Gtk::Alignment *tablePadding = manage(new Gtk::Alignment(0, 0, 1, 1));
+       tablePadding->set_padding(6, 0, 24, 0);
+       Gtk::Table *imageSizeTable = manage(new Gtk::Table(2, 6, false));
+       imageSizeTable->set_row_spacings(6);
+       imageSizeTable->set_col_spacings(12);
+       tablePadding->add(*imageSizeTable);
+       imageFrame->add(*tablePadding);
+
+       Gtk::Label *size_width_label = manage(new Gtk::Label(_("_Width"), 0, 0.5, true));
+       size_width_label->set_mnemonic_widget(*entry_width);
+
+       Gtk::Label *size_height_label = manage(new Gtk::Label(_("_Height"), 0, 0.5, true));
+       size_height_label->set_mnemonic_widget(*entry_height);
+
+       Gtk::Label *size_xres_label = manage(new Gtk::Label(_("_XRes"), 0, 0.5, true));
+       size_xres_label->set_mnemonic_widget(*entry_xres);
+
+       Gtk::Label *size_yres_label = manage(new Gtk::Label(_("_YRes"), 0, 0.5, true));
+       size_yres_label->set_mnemonic_widget(*entry_yres);
+
+       Gtk::Label *size_physwidth_label = manage(new Gtk::Label(_("_Physical Width"), 0, 0.5, true));
+       size_physwidth_label->set_mnemonic_widget(*entry_phy_width);
+
+       Gtk::Label *size_physheight_label = manage(new Gtk::Label(_("Phy_sical Height"), 0, 0.5, true));
+       size_physheight_label->set_mnemonic_widget(*entry_phy_height);
+
+       Gtk::Label *size_span = manage(new Gtk::Label(_("I_mage Span"), 0, 0.5, true));
+       size_span->set_mnemonic_widget(*entry_span);
+
+       imageSizeTable->attach(*size_width_label, 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       imageSizeTable->attach(*size_height_label, 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       imageSizeTable->attach(*entry_width, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       imageSizeTable->attach(*entry_height, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       imageSizeTable->attach(*size_xres_label, 2, 3, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       imageSizeTable->attach(*size_yres_label, 2, 3, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       imageSizeTable->attach(*entry_xres, 3, 4, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       imageSizeTable->attach(*entry_yres, 3, 4, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+       imageSizeTable->attach(*size_physwidth_label, 4, 5, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       imageSizeTable->attach(*size_physheight_label, 4, 5, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       imageSizeTable->attach(*entry_phy_width, 5, 6, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       imageSizeTable->attach(*entry_phy_height, 5, 6, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+       imageSizeTable->attach(*size_span, 0, 1, 2, 3, Gtk::SHRINK|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       imageSizeTable->attach(*entry_span, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       Gtk::Frame *imageAreaFrame = manage(new Gtk::Frame(_("Image Area")));
+       imageAreaFrame->set_shadow_type(Gtk::SHADOW_NONE);
+       ((Gtk::Label *) imageAreaFrame->get_label_widget())->set_markup(_("<b>Image Area</b>"));
+       panelBox->pack_start(*imageAreaFrame, false, false, 0);
+
+       Gtk::Alignment *imageAreaPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
+       imageAreaPadding->set_padding(6, 0, 24, 0);
+       imageAreaFrame->add(*imageAreaPadding);
+
+       Gtk::Table *imageAreaTable = manage(new Gtk::Table(2, 2, false));
+       imageAreaTable->set_row_spacings(6);
+       imageAreaTable->set_col_spacings(12);
+       imageAreaPadding->add(*imageAreaTable);
+
+       Gtk::Label *imageAreaTopLeftLabel = manage(new Gtk::Label(_("_Top Left"), 0, 0.5, true));
+       imageAreaTopLeftLabel->set_mnemonic_widget(*entry_tl);
+
+       Gtk::Label *imageAreaBottomRightLabel = manage(new Gtk::Label(_("_Bottom Right"), 0, 0.5, true));
+       imageAreaBottomRightLabel->set_mnemonic_widget(*entry_br);
+
+       imageAreaTable->attach(*imageAreaTopLeftLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       imageAreaTable->attach(*imageAreaBottomRightLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       imageAreaTable->attach(*entry_tl, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       imageAreaTable->attach(*entry_br, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+       paddedPanel->show_all();
+       return paddedPanel;
+}
+
+Gtk::Widget *
+Widget_RendDesc::create_time_tab()
+{
+       Gtk::Alignment *paddedPanel = manage(new Gtk::Alignment(0, 0, 1, 1));
+       paddedPanel->set_padding(12, 12, 12, 12);
+
+       Gtk::VBox *panelBox = manage(new Gtk::VBox(false, 12)); // for future widgets
+       paddedPanel->add(*panelBox);
+
+       time_frame = manage(new Gtk::Frame(_("Time Settings")));
+       time_frame->set_shadow_type(Gtk::SHADOW_NONE);
+       ((Gtk::Label *) time_frame->get_label_widget())->set_markup(_("<b>Time Settings</b>"));
+       panelBox->pack_start(*time_frame, false, false, 0);
+
+       Gtk::Alignment *timeFramePadding = manage(new Gtk::Alignment(0, 0, 1, 1));
+       timeFramePadding->set_padding(6, 0, 24, 0);
+       time_frame->add(*timeFramePadding);
+
+       Gtk::Table *timeFrameTable = manage(new Gtk::Table(3, 2, false));
+       timeFrameTable->set_row_spacings(6);
+       timeFrameTable->set_col_spacings(12);
+       timeFramePadding->add(*timeFrameTable);
+
+       Gtk::Label *timeFPSLabel = manage(new Gtk::Label(_("_Frames per second"), 0, 0.5, true));
+       timeFPSLabel->set_mnemonic_widget(*entry_fps);
+       timeFrameTable->attach(*timeFPSLabel, 0, 1, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       timeFrameTable->attach(*entry_fps, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+       Gtk::Label *timeStartLabel = manage(new Gtk::Label(_("_Start Time"), 0, 0.5, true));
+       timeStartLabel->set_mnemonic_widget(*entry_start_time);
+       timeFrameTable->attach(*timeStartLabel, 0, 1, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       timeFrameTable->attach(*entry_start_time, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+       Gtk::Label *timeEndLabel = manage(new Gtk::Label(_("_End Time"), 0, 0.5, true));
+       timeEndLabel->set_mnemonic_widget(*entry_end_time);
+       timeFrameTable->attach(*timeEndLabel, 0, 1, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       timeFrameTable->attach(*entry_end_time, 1, 2, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+       paddedPanel->show_all();
+       return paddedPanel;
+}
+
+Gtk::Widget *
+Widget_RendDesc::create_other_tab()
+{
+       Gtk::Alignment *paddedPanel = manage(new Gtk::Alignment(0, 0, 1, 1));
+       paddedPanel->set_padding(12, 12, 12, 12);
+
+       Gtk::VBox *panelBox = manage(new Gtk::VBox(false, 12));
+       paddedPanel->add(*panelBox);
+
+       Gtk::Frame *lockFrame = manage(new Gtk::Frame(_("Locks and Links")));
+       lockFrame->set_shadow_type(Gtk::SHADOW_NONE);
+       ((Gtk::Label *) lockFrame->get_label_widget())->set_markup(_("<b>Locks and Links</b>"));
+       panelBox->pack_start(*lockFrame, false, false, 0);
+
+       Gtk::Alignment *lockPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
+       lockPadding->set_padding(6, 0, 24, 0);
+       lockFrame->add(*lockPadding);
+
+       Gtk::Table *lockTable = manage(new Gtk::Table(2, 4, false));
+       lockTable->set_row_spacings(6);
+       lockTable->set_col_spacings(12);
+       lockPadding->add(*lockTable);
+
+       lockTable->attach(*toggle_im_width, 0, 1, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       lockTable->attach(*toggle_im_height, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       lockTable->attach(*toggle_im_aspect, 2, 3, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       lockTable->attach(*toggle_im_span, 3, 4, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+       lockTable->attach(*toggle_px_width, 0, 1, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       lockTable->attach(*toggle_px_height, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       lockTable->attach(*toggle_px_aspect, 2, 3, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+       Gtk::Frame *focusFrame = manage(new Gtk::Frame(_("Focus Point")));
+       focusFrame->set_shadow_type(Gtk::SHADOW_NONE);
+       ((Gtk::Label *) focusFrame->get_label_widget())->set_markup(_("<b>Focus Point</b>"));
+       panelBox->pack_start(*focusFrame, false, false, 0);
+
+       Gtk::Alignment *focusPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
+       focusPadding->set_padding(6, 0, 24, 0);
+       focusFrame->add(*focusPadding);
+
+       Gtk::HBox *focusBox = manage(new Gtk::HBox(false, 12));
+       focusPadding->add(*focusBox);
+
+       Gtk::Label *focusLabel = manage(new Gtk::Label(_("_Focus Point"), 0, 0.5, true));
+       focusLabel->set_mnemonic_widget(*entry_focus);
+       focusBox->pack_start(*focusLabel, false, false, 0);
+       focusBox->pack_start(*entry_focus, true, true, 0);
+
+       paddedPanel->show_all();
+       return paddedPanel;
+}
+
+/*
+ * vim:ts=4:sw=4
+ */
diff --git a/synfig-studio/src/gui/renddesc.h b/synfig-studio/src/gui/renddesc.h
new file mode 100644 (file)
index 0000000..48d0793
--- /dev/null
@@ -0,0 +1,161 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file gtkmm/renddesc.h
+**     \brief Header File
+**
+**     $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
+**
+** === N O T E S ===========================================================
+**
+** ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_GTKMM_RENDDESC_H
+#define __SYNFIG_GTKMM_RENDDESC_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/table.h>
+#include <gtkmm/frame.h>
+#include <synfig/renddesc.h>
+#include <gtkmm/spinbutton.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/checkbutton.h>
+#include <gtkmm/notebook.h>
+#include "widget_vector.h"
+#include "widget_time.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 Widget_RendDesc : public Gtk::Notebook
+{
+       synfig::RendDesc rend_desc_;
+       sigc::signal<void> signal_changed_;
+
+       Gtk::Adjustment adjustment_width;
+       Gtk::Adjustment adjustment_height;
+       Gtk::Adjustment adjustment_xres;
+       Gtk::Adjustment adjustment_yres;
+       Gtk::Adjustment adjustment_phy_width;
+       Gtk::Adjustment adjustment_phy_height;
+       Gtk::Adjustment adjustment_fps;
+       //Gtk::Adjustment adjustment_start_time;
+       //Gtk::Adjustment adjustment_end_time;
+       //Gtk::Adjustment adjustment_start_frame;
+       //Gtk::Adjustment adjustment_end_frame;
+       Gtk::Adjustment adjustment_span;
+
+       Gtk::SpinButton *entry_width;
+       Gtk::SpinButton *entry_height;
+       Gtk::SpinButton *entry_xres;
+       Gtk::SpinButton *entry_yres;
+       Gtk::SpinButton *entry_phy_width;
+       Gtk::SpinButton *entry_phy_height;
+       Gtk::SpinButton *entry_fps;
+//     Gtk::SpinButton *entry_start_time;
+//     Gtk::SpinButton *entry_end_time;
+//     Gtk::SpinButton *entry_start_frame;
+//     Gtk::SpinButton *entry_end_frame;
+       Gtk::SpinButton *entry_span;
+
+       Gtk::CheckButton *toggle_px_aspect;
+       Gtk::CheckButton *toggle_px_width;
+       Gtk::CheckButton *toggle_px_height;
+
+       Gtk::CheckButton *toggle_im_aspect;
+       Gtk::CheckButton *toggle_im_width;
+       Gtk::CheckButton *toggle_im_height;
+       Gtk::CheckButton *toggle_im_span;
+
+       /* Gtk::Table *time_table; */
+       Gtk::Frame *time_frame;
+
+       Widget_Vector *entry_tl;
+       Widget_Vector *entry_br;
+
+       Widget_Vector *entry_focus;
+
+       Widget_Time *entry_start_time;
+       Widget_Time *entry_end_time;
+
+       mutable int update_lock;
+
+       struct UpdateLock
+       {
+               int &locked;
+               UpdateLock(int &locked):locked(locked){locked++;}
+               ~UpdateLock(){locked--;}
+       };
+
+public:
+
+       sigc::signal<void> &signal_changed() { return signal_changed_; }
+
+       Widget_RendDesc();
+       ~Widget_RendDesc();
+
+       //! Sets the RendDesc
+       void set_rend_desc(const synfig::RendDesc &rend_desc);
+
+       //! Applies the given RendDesc to the current RendDesc
+       void apply_rend_desc(const synfig::RendDesc &rend_desc);
+
+       //! Retrieves the current RendDesc
+       const synfig::RendDesc &get_rend_desc();
+
+       void disable_time_section();
+
+       void enable_time_section();
+
+       void refresh();
+private:
+
+       void on_width_changed();
+       void on_height_changed();
+       void on_xres_changed();
+       void on_yres_changed();
+       void on_phy_width_changed();
+       void on_phy_height_changed();
+       void on_tl_changed();
+       void on_br_changed();
+       void on_fps_changed();
+       void on_start_time_changed();
+       void on_end_time_changed();
+       //void on_start_frame_changed();
+       //void on_end_frame_changed();
+       void on_lock_changed();
+       void on_focus_changed();
+       void on_span_changed();
+
+       void create_widgets();
+       void connect_signals();
+       Gtk::Widget *create_image_tab();
+       Gtk::Widget *create_time_tab();
+       Gtk::Widget *create_other_tab();
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/render.cpp b/synfig-studio/src/gui/render.cpp
new file mode 100644 (file)
index 0000000..e958682
--- /dev/null
@@ -0,0 +1,380 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file gtkmm/render.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 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 <config.h>
+#endif
+
+#include "render.h"
+#include "app.h"
+#include <gtkmm/frame.h>
+#include <gtkmm/alignment.h>
+#include <synfig/target_scanline.h>
+#include <synfig/canvas.h>
+#include "asyncrenderer.h"
+#include "dialog_targetparam.h"
+
+#include "general.h"
+
+#include <fstream>
+
+#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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+RenderSettings::RenderSettings(Gtk::Window& parent, etl::handle<synfigapp::CanvasInterface> canvas_interface):
+       Gtk::Dialog(_("Render Settings"),parent,false,true),
+       canvas_interface_(canvas_interface),
+       adjustment_quality(3,0,9),
+       entry_quality(adjustment_quality,1,0),
+       adjustment_antialias(1,1,31),
+       entry_antialias(adjustment_antialias,1,0),
+       toggle_single_frame(_("Use _current frame"), true),
+       tparam("libxvid",200)
+{
+       widget_rend_desc.show();
+       widget_rend_desc.signal_changed().connect(sigc::mem_fun(*this,&studio::RenderSettings::on_rend_desc_changed));
+       widget_rend_desc.set_rend_desc(canvas_interface_->get_canvas()->rend_desc());
+
+       canvas_interface->signal_rend_desc_changed().connect(sigc::mem_fun(*this,&RenderSettings::on_rend_desc_changed));
+
+       menu_target=manage(new class Gtk::Menu());
+
+       menu_target->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Auto"),
+                       sigc::bind(sigc::mem_fun(*this,&RenderSettings::set_target),String())
+               ));
+
+       synfig::Target::Book::iterator iter;
+       synfig::Target::Book book(synfig::Target::book());
+
+       for(iter=book.begin();iter!=book.end();iter++)
+       {
+               menu_target->items().push_back(Gtk::Menu_Helpers::MenuElem(iter->first,
+                       sigc::bind(sigc::mem_fun(*this,&RenderSettings::set_target),iter->first)
+               ));
+       }
+       optionmenu_target.set_menu(*menu_target);
+
+       optionmenu_target.set_history(0);
+
+       Gtk::Alignment *dialogPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
+       dialogPadding->set_padding(12, 12, 12, 12);
+       get_vbox()->pack_start(*dialogPadding, false, false, 0);
+
+       Gtk::VBox *dialogBox = manage(new Gtk::VBox(false, 12));
+       dialogPadding->add(*dialogBox);
+
+       Gtk::Button *choose_button(manage(new class Gtk::Button(Gtk::StockID(_("Choose...")))));
+       choose_button->show();
+       choose_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::RenderSettings::on_choose_pressed));
+
+       Gtk::Button *tparam_button(manage(new class Gtk::Button(Gtk::StockID(_("Parameters...")))));
+       tparam_button->show();
+       tparam_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::RenderSettings::on_targetparam_pressed));
+
+       Gtk::Frame *target_frame=manage(new Gtk::Frame(_("Target")));
+       target_frame->set_shadow_type(Gtk::SHADOW_NONE);
+       ((Gtk::Label *) target_frame->get_label_widget())->set_markup(_("<b>Target</b>"));
+       dialogBox->pack_start(*target_frame);
+       Gtk::Alignment *targetPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
+       targetPadding->set_padding(6, 0, 24, 0);
+       target_frame->add(*targetPadding);
+
+       Gtk::Table *target_table = manage(new Gtk::Table(2, 3, false));
+       target_table->set_row_spacings(6);
+       target_table->set_col_spacings(12);
+       targetPadding->add(*target_table);
+
+       Gtk::Label *filenameLabel = manage(new Gtk::Label(_("_Filename"), true));
+       filenameLabel->set_alignment(0, 0.5);
+       filenameLabel->set_mnemonic_widget(entry_filename);
+       target_table->attach(*filenameLabel, 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       target_table->attach(entry_filename, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       target_table->attach(*choose_button, 2, 3, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+
+       Gtk::Label *targetLabel = manage(new Gtk::Label(_("_Target"), true));
+       targetLabel->set_alignment(0, 0.5);
+       targetLabel->set_mnemonic_widget(optionmenu_target);
+       target_table->attach(*targetLabel, 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       target_table->attach(optionmenu_target, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       target_table->attach(*tparam_button, 2, 3, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+
+       toggle_single_frame.signal_toggled().connect(sigc::mem_fun(*this, &studio::RenderSettings::on_single_frame_toggle));
+
+       Gtk::Frame *settings_frame=manage(new Gtk::Frame(_("Settings")));
+       settings_frame->set_shadow_type(Gtk::SHADOW_NONE);
+       ((Gtk::Label *) settings_frame->get_label_widget())->set_markup(_("<b>Settings</b>"));
+       dialogBox->pack_start(*settings_frame);
+
+       Gtk::Alignment *settingsPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
+       settingsPadding->set_padding(6, 0, 24, 0);
+       settings_frame->add(*settingsPadding);
+
+       Gtk::Table *settings_table=manage(new Gtk::Table(2,2,false));
+       settings_table->set_row_spacings(6);
+       settings_table->set_col_spacings(12);
+       settingsPadding->add(*settings_table);
+
+       Gtk::Label *qualityLabel = manage(new Gtk::Label(_("_Quality"), true));
+       qualityLabel->set_alignment(0, 0.5);
+       qualityLabel->set_mnemonic_widget(entry_quality);
+       settings_table->attach(*qualityLabel, 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       settings_table->attach(entry_quality, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+
+       Gtk::Label *antiAliasLabel = manage(new Gtk::Label(_("_Anti-Aliasing"), true));
+       antiAliasLabel->set_alignment(0, 0.5);
+       antiAliasLabel->set_mnemonic_widget(entry_antialias);
+       settings_table->attach(*antiAliasLabel, 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       settings_table->attach(entry_antialias, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+
+       toggle_single_frame.set_alignment(0, 0.5);
+       settings_table->attach(toggle_single_frame, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+
+       dialogBox->pack_start(widget_rend_desc);
+
+
+       Gtk::Button *render_button(manage(new class Gtk::Button(Gtk::StockID("Render"))));
+       render_button->show();
+       add_action_widget(*render_button,1);
+       render_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::RenderSettings::on_render_pressed));
+
+       Gtk::Button *cancel_button(manage(new class Gtk::Button(Gtk::StockID("gtk-cancel"))));
+       cancel_button->show();
+       add_action_widget(*cancel_button,0);
+       cancel_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::RenderSettings::on_cancel_pressed));
+
+       //set_default_response(1);
+
+       set_title(_("Render Settings")+String(" - ")+canvas_interface_->get_canvas()->get_name());
+
+       toggle_single_frame.set_active(false);
+       widget_rend_desc.enable_time_section();
+
+       set_entry_filename();
+
+       get_vbox()->show_all();
+}
+
+RenderSettings::~RenderSettings()
+{
+}
+
+void
+RenderSettings::set_entry_filename()
+{
+       String filename(filename_sans_extension(canvas_interface_->get_canvas()->get_file_name()));
+
+       // if this isn't the root canvas, append (<canvasname>) to the filename
+       etl::handle<synfig::Canvas> canvas = canvas_interface_->get_canvas();
+       if (!canvas->is_root())
+       {
+               if(canvas->get_name().empty())
+                       filename+=" ("+canvas->get_id()+')';
+               else
+                       filename+=" ("+canvas->get_name()+')';
+       }
+
+       filename += ".png";
+
+       try
+       {
+               entry_filename.set_text((filename));
+       }
+       catch(...)
+       {
+               synfig::warning("Averted crash!");
+               entry_filename.set_text("output.png");
+       }
+}
+
+void
+RenderSettings::on_rend_desc_changed()
+{
+       widget_rend_desc.set_rend_desc(canvas_interface_->get_canvas()->rend_desc());
+}
+
+void
+RenderSettings::set_target(synfig::String name)
+{
+       target_name=name;
+}
+
+void
+RenderSettings::on_choose_pressed()
+{
+       String filename=entry_filename.get_text();
+       if(App::dialog_save_file("Save Render As", filename, RENDER_DIR_PREFERENCE))
+               entry_filename.set_text(filename);
+}
+
+void
+RenderSettings::on_targetparam_pressed()
+{
+       Dialog_TargetParam *dialogtp = new Dialog_TargetParam(tparam);
+       if(dialogtp->run()==Gtk::RESPONSE_OK)
+               tparam=dialogtp->get_tparam();
+
+       delete dialogtp;
+}
+
+void
+RenderSettings::on_render_pressed()
+{
+       String filename=entry_filename.get_text();
+       synfig::String calculated_target_name(target_name);
+
+       if(filename.empty())
+       {
+               canvas_interface_->get_ui_interface()->error(_("You must supply a filename!"));
+               return;
+       }
+
+       // If the target type is not yet defined,
+       // try to figure it out from the outfile.
+       if(calculated_target_name.empty())
+       {
+               try
+               {
+                       String ext(filename_extension(filename));
+                       if (ext.size()) ext=ext.substr(1); // skip initial '.'
+                       synfig::info("render target filename: '%s'; extension: '%s'", filename.c_str(), ext.c_str());
+                       if(Target::ext_book().count(ext))
+                       {
+                               calculated_target_name=Target::ext_book()[ext];
+                               synfig::info("'%s' is a known extension - using target '%s'", ext.c_str(), calculated_target_name.c_str());
+                       }
+                       else
+                       {
+                               calculated_target_name=ext;
+                               synfig::info("unknown extension");
+                       }
+               }
+               catch(std::runtime_error x)
+               {
+                       canvas_interface_->get_ui_interface()->error(_("Unable to determine proper target from filename."));
+                       return;
+               }
+       }
+
+       if(filename.empty() && calculated_target_name!="null")
+       {
+               canvas_interface_->get_ui_interface()->error(_("A filename is required for this target"));
+               return;
+       }
+
+       Target::Handle target=Target::create(calculated_target_name,filename, tparam);
+       if(!target)
+       {
+               canvas_interface_->get_ui_interface()->error(_("Unable to create target for ")+filename);
+               return;
+       }
+       // This is the only way I've found to avoid send a non writable
+       // filename path to the renderer.
+       fstream filetest (filename.c_str(), fstream::out);
+       if (filetest.fail())
+       {
+               canvas_interface_->get_ui_interface()->error(_("Unable to create file for ")+filename);
+               return;
+       }
+
+       hide();
+
+       target->set_canvas(canvas_interface_->get_canvas());
+       RendDesc rend_desc(widget_rend_desc.get_rend_desc());
+       rend_desc.set_antialias((int)adjustment_antialias.get_value());
+
+       // If we are to only render the current frame
+       if(toggle_single_frame.get_active())
+               rend_desc.set_time(canvas_interface_->get_time());
+
+       target->set_rend_desc(&rend_desc);
+       target->set_quality((int)adjustment_quality.get_value());
+       if( !target->init() ){
+               canvas_interface_->get_ui_interface()->error(_("Target initialization failure"));
+               return;
+       }
+
+       canvas_interface_->get_ui_interface()->task(_("Rendering ")+filename);
+
+       if(async_renderer)
+       {
+               async_renderer->stop();
+               async_renderer.detach();
+       }
+       async_renderer=new AsyncRenderer(target);
+       async_renderer->signal_finished().connect( sigc::mem_fun(*this,&RenderSettings::on_finished));
+       async_renderer->start();
+       /*
+       if(!target->render(canvas_interface_->get_ui_interface().get()))
+       {
+               canvas_interface_->get_ui_interface()->error(_("Render Failure"));
+               canvas_interface_->get_ui_interface()->amount_complete(0,10000);
+               return;
+       }
+
+       // Success!
+       canvas_interface_->get_ui_interface()->task(filename+_(" rendered successfully"));
+       canvas_interface_->get_ui_interface()->amount_complete(0,10000);
+       */
+       return;
+}
+
+void
+RenderSettings::on_finished()
+{
+       canvas_interface_->get_ui_interface()->task(_("File rendered successfully"));
+       canvas_interface_->get_ui_interface()->amount_complete(0,10000);
+}
+
+void
+RenderSettings::on_cancel_pressed()
+{
+       hide();
+}
+
+void
+RenderSettings::on_single_frame_toggle()
+{
+       if(toggle_single_frame.get_active())
+               widget_rend_desc.disable_time_section();
+       else
+               widget_rend_desc.enable_time_section();
+}
diff --git a/synfig-studio/src/gui/render.h b/synfig-studio/src/gui/render.h
new file mode 100644 (file)
index 0000000..729251b
--- /dev/null
@@ -0,0 +1,108 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file gtkmm/render.h
+**     \brief Template Header
+**
+**     $Id$
+**
+**     \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
+**     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_GTKMM_RENDER_H
+#define __SYNFIG_STUDIO_GTKMM_RENDER_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/tooltips.h>
+#include <gtkmm/table.h>
+#include <gtkmm/entry.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/spinbutton.h>
+#include <gtkmm/checkbutton.h>
+#include <gtkmm/tooltips.h>
+#include <gtkmm/optionmenu.h>
+
+#include <synfig/string.h>
+#include <synfig/targetparam.h>
+
+#include <synfigapp/canvasinterface.h>
+
+#include "renddesc.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 AsyncRenderer;
+
+class RenderSettings : public Gtk::Dialog
+{
+       Gtk::Tooltips tooltips;
+
+       etl::handle<synfigapp::CanvasInterface> canvas_interface_;
+       Widget_RendDesc widget_rend_desc;
+
+       Gtk::Entry entry_filename;
+
+       Gtk::Adjustment adjustment_quality;
+       Gtk::SpinButton entry_quality;
+
+       Gtk::Adjustment adjustment_antialias;
+       Gtk::SpinButton entry_antialias;
+
+       Gtk::CheckButton toggle_single_frame;
+
+       Gtk::OptionMenu optionmenu_target;
+       Gtk::Menu *menu_target;
+
+       synfig::String target_name;
+
+       void set_target(synfig::String name);
+
+       etl::handle<AsyncRenderer> async_renderer;
+
+       synfig::TargetParam tparam;
+
+public:
+       RenderSettings(Gtk::Window& parent,etl::handle<synfigapp::CanvasInterface> canvas_interface);
+       ~RenderSettings();
+       void set_entry_filename();
+
+private:
+
+       void on_rend_desc_changed();
+       void on_single_frame_toggle();
+       void on_choose_pressed();
+       void on_render_pressed();
+       void on_cancel_pressed();
+       void on_targetparam_pressed();
+
+       void on_finished();
+}; // END of class RenderSettings
+
+}; // END of namespace studio
+
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/renderer_bbox.cpp b/synfig-studio/src/gui/renderer_bbox.cpp
new file mode 100644 (file)
index 0000000..727ad02
--- /dev/null
@@ -0,0 +1,144 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file renderer_bbox.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "renderer_bbox.h"
+#include "workarea.h"
+#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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Renderer_BBox::Renderer_BBox()
+{
+}
+
+Renderer_BBox::~Renderer_BBox()
+{
+}
+
+const synfig::Rect&
+Renderer_BBox::get_bbox()
+{
+       return get_work_area()->get_canvas_view()->get_bbox();
+}
+
+void
+Renderer_BBox::render_vfunc(
+       const Glib::RefPtr<Gdk::Drawable>& drawable,
+       const Gdk::Rectangle& /*expose_area*/
+)
+{
+       assert(get_work_area());
+       if(!get_work_area())
+               return;
+
+//     const synfig::RendDesc &rend_desc(get_work_area()->get_canvas()->rend_desc());
+
+       const synfig::Vector focus_point(get_work_area()->get_focus_point());
+
+//     std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> >& tile_book(get_tile_book());
+
+       int drawable_w,drawable_h;
+       drawable->get_size(drawable_w,drawable_h);
+
+       // Calculate the window coordinates of the top-left
+       // corner of the canvas.
+//     const synfig::Vector::value_type
+//             x(focus_point[0]/get_pw()+drawable_w/2-get_w()/2),
+//             y(focus_point[1]/get_ph()+drawable_h/2-get_h()/2);
+
+       /*const synfig::Vector::value_type window_startx(window_tl[0]);
+       const synfig::Vector::value_type window_endx(window_br[0]);
+       const synfig::Vector::value_type window_starty(window_tl[1]);
+       const synfig::Vector::value_type window_endy(window_br[1]);
+       */
+//     const int
+//             tile_w(get_work_area()->get_tile_w()),
+//             tile_h(get_work_area()->get_tile_h());
+
+//     const int
+//             w(get_w()),
+//             h(get_h());
+
+       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(drawable));
+
+       //const synfig::Vector grid_size(get_grid_size());
+
+       const synfig::Vector::value_type window_startx(get_work_area()->get_window_tl()[0]);
+//     const synfig::Vector::value_type window_endx(get_work_area()->get_window_br()[0]);
+       const synfig::Vector::value_type window_starty(get_work_area()->get_window_tl()[1]);
+//     const synfig::Vector::value_type window_endy(get_work_area()->get_window_br()[1]);
+       const float pw(get_pw()),ph(get_ph());
+
+       const synfig::Point curr_point(get_bbox().get_min());
+       const synfig::Point drag_point(get_bbox().get_max());
+       if(get_bbox().area()<10000000000000000.0)
+       {
+               gc->set_function(Gdk::INVERT);
+               gc->set_rgb_fg_color(Gdk::Color("#FFFFFF"));
+               //gc->set_line_attributes(1,Gdk::LINE_ON_OFF_DASH,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+               gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+
+               Point tl(std::min(drag_point[0],curr_point[0]),std::min(drag_point[1],curr_point[1]));
+               Point br(std::max(drag_point[0],curr_point[0]),std::max(drag_point[1],curr_point[1]));
+
+               tl[0]=(tl[0]-window_startx)/pw;
+               tl[1]=(tl[1]-window_starty)/ph;
+               br[0]=(br[0]-window_startx)/pw;
+               br[1]=(br[1]-window_starty)/ph;
+               if(tl[0]>br[0])
+                       swap(tl[0],br[0]);
+               if(tl[1]>br[1])
+                       swap(tl[1],br[1]);
+
+               drawable->draw_rectangle(gc,false,
+                       round_to_int(tl[0]),
+                       round_to_int(tl[1]),
+                       round_to_int(br[0]-tl[0]),
+                       round_to_int(br[1]-tl[1])
+               );
+       }
+}
diff --git a/synfig-studio/src/gui/renderer_bbox.h b/synfig-studio/src/gui/renderer_bbox.h
new file mode 100644 (file)
index 0000000..d3d5952
--- /dev/null
@@ -0,0 +1,63 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file renderer_bbox.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_RENDERER_BBOX_H
+#define __SYNFIG_RENDERER_BBOX_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "workarearenderer.h"
+#include <vector>
+#include <synfig/vector.h>
+#include <synfig/rect.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 Renderer_BBox : public studio::WorkAreaRenderer
+{
+       synfig::Rect bbox;
+
+public:
+       Renderer_BBox();
+       ~Renderer_BBox();
+
+       const synfig::Rect& get_bbox();
+
+       void render_vfunc(const Glib::RefPtr<Gdk::Drawable>& drawable,const Gdk::Rectangle& expose_area );
+
+protected:
+       //bool get_enabled_vfunc()const;
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/renderer_canvas.cpp b/synfig-studio/src/gui/renderer_canvas.cpp
new file mode 100644 (file)
index 0000000..9608079
--- /dev/null
@@ -0,0 +1,219 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file renderer_canvas.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 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 <config.h>
+#endif
+
+#include "renderer_canvas.h"
+#include "workarea.h"
+#include <ETL/misc>
+
+#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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Renderer_Canvas::~Renderer_Canvas()
+{
+}
+std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> >&
+Renderer_Canvas::get_tile_book()
+{
+       return get_work_area()->get_tile_book();
+}
+
+bool
+Renderer_Canvas::get_full_frame()const
+{
+       return get_work_area()->get_full_frame();
+}
+
+int Renderer_Canvas::get_refreshes()const
+{
+       return get_work_area()->get_refreshes();
+}
+
+bool
+Renderer_Canvas::get_canceled()const
+{
+       return get_work_area()->get_canceled();
+}
+
+bool
+Renderer_Canvas::get_queued()const
+{
+       return get_work_area()->get_queued();
+}
+
+bool
+Renderer_Canvas::get_rendering()const
+{
+       return get_work_area()->get_rendering();
+}
+
+void
+Renderer_Canvas::render_vfunc(
+       const Glib::RefPtr<Gdk::Drawable>& drawable,
+       const Gdk::Rectangle& /*expose_area*/
+)
+{
+       assert(get_work_area());
+       if(!get_work_area())
+               return;
+
+//     const synfig::RendDesc &rend_desc(get_work_area()->get_canvas()->rend_desc());
+
+       const synfig::Vector focus_point(get_work_area()->get_focus_point());
+
+       std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> >& tile_book(get_tile_book());
+
+       int drawable_w,drawable_h;
+       drawable->get_size(drawable_w,drawable_h);
+
+       // Calculate the window coordinates of the top-left
+       // corner of the canvas.
+       const synfig::Vector::value_type
+               x(focus_point[0]/get_pw()+drawable_w/2-get_w()/2),
+               y(focus_point[1]/get_ph()+drawable_h/2-get_h()/2);
+
+       /*const synfig::Vector::value_type window_startx(window_tl[0]);
+       const synfig::Vector::value_type window_endx(window_br[0]);
+       const synfig::Vector::value_type window_starty(window_tl[1]);
+       const synfig::Vector::value_type window_endy(window_br[1]);
+       */
+       const int
+               tile_w(get_work_area()->get_tile_w()),
+               tile_h(get_work_area()->get_tile_h());
+
+       const int
+               w(get_w()),
+               h(get_h());
+
+       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(drawable));
+
+       if(!tile_book.empty())
+       {
+               if(get_full_frame())
+               {
+                       if(tile_book[0].first)
+                       {
+                               drawable->draw_pixbuf(
+                                       gc, //GC
+                                       tile_book[0].first, //pixbuf
+                                       0, 0,   // Source X and Y
+                                       round_to_int(x),round_to_int(y),        // Dest X and Y
+                                       -1,-1,  // Width and Height
+                                       Gdk::RGB_DITHER_MAX,            // RgbDither
+                                       2, 2 // Dither offset X and Y
+                                       );
+                       }
+                       if(tile_book[0].second!=get_refreshes() && get_canceled()==false && get_rendering()==false && get_queued()==false)
+                               get_work_area()->async_update_preview();
+               }
+               else
+               {
+                       int div = get_work_area()->get_low_res_pixel_size();
+                       const int width_in_tiles(w/tile_w+(((get_work_area()->get_low_resolution_flag())?((w/div)%(tile_w/div)):(w%tile_w))?1:0));
+                       const int height_in_tiles(h/tile_h+(h%tile_h?1:0));
+
+                       int u(0),v(0),tx,ty;
+                       int u1(0),v1(0),u2(width_in_tiles), v2(height_in_tiles);
+
+                       bool needs_refresh(false);
+
+                       u1=int(-x/tile_w);
+                       v1=int(-y/tile_h);
+                       u2=int((-x+drawable_w)/tile_w+1);
+                       v2=int((-y+drawable_h)/tile_h+1);
+                       if(u2>width_in_tiles)u2=width_in_tiles;
+                       if(v2>height_in_tiles)v2=height_in_tiles;
+                       if(u1<0)u1=0;
+                       if(v1<0)v1=0;
+
+                       for(v=v1;v<v2;v++)
+                       {
+                               for(u=u1;u<u2;u++)
+                               {
+                                       int index=v*width_in_tiles+u;
+                                       if(int(tile_book.size())>index && tile_book[index].first)
+                                       {
+                                               tx=u*tile_w;
+                                               ty=v*tile_w;
+
+                                               drawable->draw_pixbuf(
+                                                       gc, //GC
+                                                       tile_book[index].first, //pixbuf
+                                                       0, 0,   // Source X and Y
+                                                       round_to_int(x)+tx,round_to_int(y)+ty,  // Dest X and Y
+                                                       -1,-1,  // Width and Height
+                                                       Gdk::RGB_DITHER_MAX,            // RgbDither
+                                                       2, 2 // Dither offset X and Y
+                                                       );
+                                       }
+                                       if(tile_book[index].second!=get_refreshes())
+                                               needs_refresh=true;
+                               }
+                       }
+                       if(needs_refresh==true && get_canceled()==false && get_rendering()==false && get_queued()==false)
+                       {
+                               //queue_render_preview();
+                               get_work_area()->async_update_preview();
+                               //update_preview();
+                               //return true;
+                       }
+
+               }
+       }
+
+       // Draw the border around the rendered region
+       {
+               gc->set_rgb_fg_color(Gdk::Color("#000000"));
+               gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+               drawable->draw_rectangle(
+                       gc,
+                       false,  // Fill?
+                       round_to_int(x),round_to_int(y),        // x,y
+                       w,h     //w,h
+               );
+       }
+}
diff --git a/synfig-studio/src/gui/renderer_canvas.h b/synfig-studio/src/gui/renderer_canvas.h
new file mode 100644 (file)
index 0000000..ad2509e
--- /dev/null
@@ -0,0 +1,63 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file renderer_canvas.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_RENDERER_CANVAS_H
+#define __SYNFIG_RENDERER_CANVAS_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "workarearenderer.h"
+#include <vector>
+
+/* === 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 Renderer_Canvas : public studio::WorkAreaRenderer
+{
+
+public:
+       ~Renderer_Canvas();
+
+       std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> >& get_tile_book();
+
+       bool get_full_frame()const;
+
+       int get_refreshes()const;
+       bool get_canceled()const;
+       bool get_queued()const;
+       bool get_rendering()const;
+
+       void render_vfunc(const Glib::RefPtr<Gdk::Drawable>& drawable,const Gdk::Rectangle& expose_area );
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/renderer_dragbox.cpp b/synfig-studio/src/gui/renderer_dragbox.cpp
new file mode 100644 (file)
index 0000000..a177154
--- /dev/null
@@ -0,0 +1,154 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file renderer_dragbox.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "renderer_dragbox.h"
+#include "workarea.h"
+#include <ETL/misc>
+
+#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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Renderer_Dragbox::~Renderer_Dragbox()
+{
+}
+
+const synfig::Point&
+Renderer_Dragbox::get_drag_point()const
+{
+       return get_work_area()->get_drag_point();
+}
+
+const synfig::Point&
+Renderer_Dragbox::get_curr_point()const
+{
+       return get_work_area()->get_cursor_pos();
+}
+
+bool
+Renderer_Dragbox::get_enabled_vfunc()const
+{
+       return get_work_area()->get_dragging_mode()==WorkArea::DRAG_BOX;
+}
+
+
+void
+Renderer_Dragbox::render_vfunc(
+       const Glib::RefPtr<Gdk::Drawable>& drawable,
+       const Gdk::Rectangle& /*expose_area*/
+)
+{
+       assert(get_work_area());
+       if(!get_work_area())
+               return;
+
+       // const synfig::RendDesc &rend_desc(get_work_area()->get_canvas()->rend_desc());
+
+       const synfig::Vector focus_point(get_work_area()->get_focus_point());
+
+//     std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> >& tile_book(get_tile_book());
+
+       int drawable_w,drawable_h;
+       drawable->get_size(drawable_w,drawable_h);
+
+       // Calculate the window coordinates of the top-left
+       // corner of the canvas.
+       // const synfig::Vector::value_type
+       //      x(focus_point[0]/get_pw()+drawable_w/2-get_w()/2),
+       //      y(focus_point[1]/get_ph()+drawable_h/2-get_h()/2);
+
+       /*const synfig::Vector::value_type window_startx(window_tl[0]);
+       const synfig::Vector::value_type window_endx(window_br[0]);
+       const synfig::Vector::value_type window_starty(window_tl[1]);
+       const synfig::Vector::value_type window_endy(window_br[1]);
+       */
+       // const int
+       //      tile_w(get_work_area()->get_tile_w()),
+       //      tile_h(get_work_area()->get_tile_h());
+
+       // const int
+       //      w(get_w()),
+       //      h(get_h());
+
+       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(drawable));
+
+       //const synfig::Vector grid_size(get_grid_size());
+
+       const synfig::Vector::value_type window_startx(get_work_area()->get_window_tl()[0]);
+       // const synfig::Vector::value_type window_endx(get_work_area()->get_window_br()[0]);
+       const synfig::Vector::value_type window_starty(get_work_area()->get_window_tl()[1]);
+       // const synfig::Vector::value_type window_endy(get_work_area()->get_window_br()[1]);
+       const float pw(get_pw()),ph(get_ph());
+
+       const synfig::Point& curr_point(get_curr_point());
+       const synfig::Point& drag_point(get_drag_point());
+
+       {
+               gc->set_function(Gdk::COPY);
+               gc->set_rgb_fg_color(Gdk::Color("#000000"));
+               gc->set_line_attributes(1,Gdk::LINE_ON_OFF_DASH,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+               //gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+
+               Point tl(std::min(drag_point[0],curr_point[0]),std::min(drag_point[1],curr_point[1]));
+               Point br(std::max(drag_point[0],curr_point[0]),std::max(drag_point[1],curr_point[1]));
+
+               tl[0]=(tl[0]-window_startx)/pw;
+               tl[1]=(tl[1]-window_starty)/ph;
+               br[0]=(br[0]-window_startx)/pw;
+               br[1]=(br[1]-window_starty)/ph;
+               if(tl[0]>br[0])
+                       swap(tl[0],br[0]);
+               if(tl[1]>br[1])
+                       swap(tl[1],br[1]);
+
+               drawable->draw_rectangle(gc,false,
+                       round_to_int(tl[0]),
+                       round_to_int(tl[1]),
+                       round_to_int(br[0]-tl[0]),
+                       round_to_int(br[1]-tl[1])
+               );
+       }
+}
diff --git a/synfig-studio/src/gui/renderer_dragbox.h b/synfig-studio/src/gui/renderer_dragbox.h
new file mode 100644 (file)
index 0000000..497b903
--- /dev/null
@@ -0,0 +1,61 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file renderer_dragbox.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_RENDERER_DRAGBOX_H
+#define __SYNFIG_RENDERER_DRAGBOX_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "workarearenderer.h"
+#include <vector>
+#include <synfig/vector.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 Renderer_Dragbox : public studio::WorkAreaRenderer
+{
+
+public:
+       ~Renderer_Dragbox();
+
+       void render_vfunc(const Glib::RefPtr<Gdk::Drawable>& drawable,const Gdk::Rectangle& expose_area );
+
+       const synfig::Point& get_drag_point()const;
+       const synfig::Point& get_curr_point()const;
+
+protected:
+       bool get_enabled_vfunc()const;
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/renderer_ducks.cpp b/synfig-studio/src/gui/renderer_ducks.cpp
new file mode 100644 (file)
index 0000000..fdc6487
--- /dev/null
@@ -0,0 +1,489 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file renderer_ducks.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 2008 Chris Moore
+**  Copyright (c) 2008 Gerald Young
+**
+**     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 <config.h>
+#endif
+
+#include "renderer_ducks.h"
+#include "workarea.h"
+#include "duckmatic.h"
+#include <ETL/bezier>
+#include <ETL/misc>
+#include "widget_color.h"
+#include <synfig/distance.h>
+#include "app.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Renderer_Ducks::~Renderer_Ducks()
+{
+}
+
+/*
+bool
+Renderer_Ducks::get_enabled_vfunc()const
+{
+       return get_work_area()->grid_status();
+}
+*/
+
+struct ScreenDuck
+{
+       synfig::Point pos;
+       Gdk::Color color;
+       bool selected;
+       bool hover;
+       Real width;
+
+       ScreenDuck():width(0) { }
+};
+
+void
+Renderer_Ducks::render_vfunc(
+       const Glib::RefPtr<Gdk::Drawable>& drawable,
+       const Gdk::Rectangle& /*expose_area*/
+)
+{
+       assert(get_work_area());
+       if(!get_work_area())
+               return;
+
+       const synfig::Vector focus_point(get_work_area()->get_focus_point());
+
+
+       int drawable_w,drawable_h;
+       drawable->get_size(drawable_w,drawable_h);
+
+       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(drawable));
+
+
+       const synfig::Vector::value_type window_startx(get_work_area()->get_window_tl()[0]);
+       const synfig::Vector::value_type window_starty(get_work_area()->get_window_tl()[1]);
+
+       const float pw(get_pw()),ph(get_ph());
+
+       const std::list<etl::handle<Duckmatic::Bezier> >& bezier_list(get_work_area()->bezier_list());
+       const bool solid_lines(get_work_area()->solid_lines);
+
+       const std::list<handle<Duckmatic::Stroke> >& stroke_list(get_work_area()->stroke_list());
+
+       Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_work_area()->get_pango_context()));
+
+       // Render the strokes
+       for(std::list<handle<Duckmatic::Stroke> >::const_iterator iter=stroke_list.begin();iter!=stroke_list.end();++iter)
+       {
+               Point window_start(window_startx,window_starty);
+               vector<Gdk::Point> points;
+               std::list<synfig::Point>::iterator iter2;
+               Point holder;
+
+               for(iter2=(*iter)->stroke_data->begin();iter2!=(*iter)->stroke_data->end();++iter2)
+               {
+                       holder=*iter2-window_start;
+                       holder[0]/=pw;holder[1]/=ph;
+                       points.push_back(Gdk::Point(round_to_int(holder[0]),round_to_int(holder[1])));
+               }
+
+               gc->set_rgb_fg_color(colorconv_synfig2gdk((*iter)->color));
+               gc->set_function(Gdk::COPY);
+               gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+
+               // Draw the stroke
+               drawable->draw_lines(gc, Glib::ArrayHandle<Gdk::Point>(points));
+       }
+
+
+
+       // Render the beziers
+       for(std::list<handle<Duckmatic::Bezier> >::const_iterator iter=bezier_list.begin();iter!=bezier_list.end();++iter)
+       {
+               Point window_start(window_startx,window_starty);
+               Point p1((*iter)->p1->get_trans_point()-window_start);
+               Point p2((*iter)->p2->get_trans_point()-window_start);
+               Point c1((*iter)->c1->get_trans_point()-window_start);
+               Point c2((*iter)->c2->get_trans_point()-window_start);
+               p1[0]/=pw;p1[1]/=ph;
+               p2[0]/=pw;p2[1]/=ph;
+               c1[0]/=pw;c1[1]/=ph;
+               c2[0]/=pw;c2[1]/=ph;
+               bezier<Point> curve(p1,c1,c2,p2);
+               vector<Gdk::Point> points;
+
+               float f;
+               Point pt;
+               for(f=0;f<1.0;f+=1.0/17.0)
+               {
+                       pt=curve(f);
+                       points.push_back(Gdk::Point(round_to_int(pt[0]),round_to_int(pt[1])));
+               }
+               points.push_back(Gdk::Point(round_to_int(p2[0]),round_to_int(p2[1])));
+
+               // Draw the curve
+/*             if(solid_lines)
+               {
+                       gc->set_rgb_fg_color(DUCK_COLOR_BEZIER_1);
+                       gc->set_function(Gdk::COPY);
+                       gc->set_line_attributes(3,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+                       drawable->draw_lines(gc, Glib::ArrayHandle<Gdk::Point>(points));
+                       gc->set_rgb_fg_color(DUCK_COLOR_BEZIER_2);
+                       gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+                       drawable->draw_lines(gc, Glib::ArrayHandle<Gdk::Point>(points));
+               }
+               else
+*/
+               {
+//                     gc->set_rgb_fg_color(Gdk::Color("#ffffff"));
+//                     gc->set_function(Gdk::INVERT);
+//                     gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+//                     drawable->draw_lines(gc, Glib::ArrayHandle<Gdk::Point>(points));
+                       gc->set_rgb_fg_color(DUCK_COLOR_BEZIER_1);
+                       gc->set_function(Gdk::COPY);
+                       gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+                       drawable->draw_lines(gc, Glib::ArrayHandle<Gdk::Point>(points));
+                       gc->set_rgb_fg_color(DUCK_COLOR_BEZIER_2);
+                       gc->set_line_attributes(1,Gdk::LINE_ON_OFF_DASH,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+                       drawable->draw_lines(gc, Glib::ArrayHandle<Gdk::Point>(points));
+
+               }
+       }
+
+
+       const DuckList duck_list(get_work_area()->get_duck_list());
+       //Gtk::StateType state = Gtk::STATE_ACTIVE;
+       Gtk::ShadowType shadow=Gtk::SHADOW_OUT;
+       std::list<ScreenDuck> screen_duck_list;
+       const float radius((abs(pw)+abs(ph))*4);
+
+       etl::handle<Duck> hover_duck(get_work_area()->find_duck(get_work_area()->get_cursor_pos(),radius, get_work_area()->get_type_mask()));
+
+       // Render the ducks
+       for(std::list<handle<Duck> >::const_iterator iter=duck_list.begin();iter!=duck_list.end();++iter)
+       {
+
+               // If this type of duck has been masked, then skip it
+               if((*iter)->get_type() && (!(get_work_area()->get_type_mask() & (*iter)->get_type())))
+                       continue;
+
+//             Real x,y;
+       //      Gdk::Rectangle area;
+               Point sub_trans_point((*iter)->get_sub_trans_point());
+               Point sub_trans_origin((*iter)->get_sub_trans_origin());
+
+               if (App::restrict_radius_ducks &&
+                       (*iter)->is_radius())
+               {
+                       if (sub_trans_point[0] < sub_trans_origin[0])
+                               sub_trans_point[0] = sub_trans_origin[0];
+                       if (sub_trans_point[1] < sub_trans_origin[1])
+                               sub_trans_point[1] = sub_trans_origin[1];
+               }
+
+               Point point((*iter)->get_transform_stack().perform(sub_trans_point));
+               Point origin((*iter)->get_transform_stack().perform(sub_trans_origin));
+
+               point[0]=(point[0]-window_startx)/pw;
+               point[1]=(point[1]-window_starty)/ph;
+
+               bool has_connect(false);
+               if((*iter)->get_tangent() || (*iter)->get_type()&Duck::TYPE_ANGLE)
+               {
+                       has_connect=true;
+               }
+               if((*iter)->get_connect_duck())
+               {
+                       has_connect=true;
+                       origin=(*iter)->get_connect_duck()->get_trans_point();
+               }
+
+               origin[0]=(origin[0]-window_startx)/pw;
+               origin[1]=(origin[1]-window_starty)/ph;
+
+               bool selected(get_work_area()->duck_is_selected(*iter));
+               bool hover(*iter==hover_duck || (*iter)->get_hover());
+
+               shadow = selected?Gtk::SHADOW_IN:Gtk::SHADOW_OUT;
+
+               if(get_work_area()->get_selected_value_node())
+               {
+                       synfigapp::ValueDesc value_desc((*iter)->get_value_desc());
+                       if (value_desc.is_valid() &&
+                               ((value_desc.is_value_node()            && get_work_area()->get_selected_value_node() == value_desc.get_value_node()) ||
+                                (value_desc.parent_is_value_node()     && get_work_area()->get_selected_value_node() == value_desc.get_parent_value_node())))
+                       {
+                               gc->set_function(Gdk::COPY);
+                               gc->set_rgb_fg_color(DUCK_COLOR_SELECTED);
+                               //gc->set_line_attributes(1,Gdk::LINE_ON_OFF_DASH,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+                               gc->set_line_attributes(2,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+
+                               drawable->draw_rectangle(gc,false,
+                                       round_to_int(point[0]-5),
+                                       round_to_int(point[1]-5),
+                                       10,
+                                       10
+                               );
+                       }
+
+               }
+
+               if((*iter)->get_box_duck())
+               {
+                       Point boxpoint((*iter)->get_box_duck()->get_trans_point());
+                       boxpoint[0]=(boxpoint[0]-window_startx)/pw;
+                       boxpoint[1]=(boxpoint[1]-window_starty)/ph;
+                       Point tl(min(point[0],boxpoint[0]),min(point[1],boxpoint[1]));
+
+                       gc->set_function(Gdk::COPY);
+                       gc->set_rgb_fg_color(DUCK_COLOR_BOX_1);
+                       gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+                       drawable->draw_rectangle(gc,false,
+                               round_to_int(tl[0]),
+                               round_to_int(tl[1]),
+                               round_to_int(abs(boxpoint[0]-point[0])),
+                               round_to_int(abs(boxpoint[1]-point[1]))
+                       );
+                       gc->set_function(Gdk::COPY);
+                       gc->set_rgb_fg_color(DUCK_COLOR_BOX_2);
+                       gc->set_line_attributes(1,Gdk::LINE_ON_OFF_DASH,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+                       drawable->draw_rectangle(gc,false,
+                               round_to_int(tl[0]),
+                               round_to_int(tl[1]),
+                               round_to_int(abs(boxpoint[0]-point[0])),
+                               round_to_int(abs(boxpoint[1]-point[1]))
+                       );
+               }
+
+               ScreenDuck screen_duck;
+               screen_duck.pos=point;
+               screen_duck.selected=selected;
+               screen_duck.hover=hover;
+
+               if(!(*iter)->get_editable())
+                       screen_duck.color=(DUCK_COLOR_NOT_EDITABLE);
+               else if((*iter)->get_tangent())
+                       screen_duck.color=((*iter)->get_scalar()<0 ? DUCK_COLOR_TANGENT_1 : DUCK_COLOR_TANGENT_2);
+               else if((*iter)->get_type()&Duck::TYPE_VERTEX)
+                       screen_duck.color=DUCK_COLOR_VERTEX;
+               else if((*iter)->get_type()&Duck::TYPE_RADIUS)
+                       screen_duck.color=DUCK_COLOR_RADIUS;
+               else if((*iter)->get_type()&Duck::TYPE_WIDTH)
+                       screen_duck.color=DUCK_COLOR_WIDTH;
+               else if((*iter)->get_type()&Duck::TYPE_ANGLE)
+                       screen_duck.color=(DUCK_COLOR_ANGLE);
+               else
+                       screen_duck.color=DUCK_COLOR_OTHER;
+
+               screen_duck_list.push_front(screen_duck);
+
+               if(has_connect)
+               {
+                       if(solid_lines)
+                       {
+                               gc->set_line_attributes(3,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+                               gc->set_rgb_fg_color(DUCK_COLOR_CONNECT_OUTSIDE);
+                               gc->set_function(Gdk::COPY);
+                               drawable->draw_line(gc, (int)origin[0],(int)origin[1],(int)(point[0]),(int)(point[1]));
+                               gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+                               gc->set_rgb_fg_color(DUCK_COLOR_CONNECT_INSIDE);
+                               drawable->draw_line(gc, (int)origin[0],(int)origin[1],(int)(point[0]),(int)(point[1]));
+                       }
+                       else
+                       {
+//                             gc->set_rgb_fg_color(Gdk::Color("#ffffff"));
+//                             gc->set_function(Gdk::INVERT);
+//                             drawable->draw_line(gc, (int)origin[0],(int)origin[1],(int)(point[0]),(int)(point[1]));
+                               gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+                               gc->set_rgb_fg_color(DUCK_COLOR_CONNECT_OUTSIDE);
+                               gc->set_function(Gdk::COPY);
+                               drawable->draw_line(gc, (int)origin[0],(int)origin[1],(int)(point[0]),(int)(point[1]));
+                               gc->set_line_attributes(1,Gdk::LINE_ON_OFF_DASH,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+                               gc->set_rgb_fg_color(DUCK_COLOR_CONNECT_INSIDE);
+                               drawable->draw_line(gc, (int)origin[0],(int)origin[1],(int)(point[0]),(int)(point[1]));
+                       }
+               }
+
+               if((*iter)->is_radius())
+               {
+                       const Real mag((point-origin).mag());
+                       const int d(round_to_int(mag*2));
+                       const int x(round_to_int(origin[0]-mag));
+                       const int y(round_to_int(origin[1]-mag));
+
+                       if(solid_lines)
+                       {
+                               gc->set_rgb_fg_color(Gdk::Color("#000000"));
+                               gc->set_function(Gdk::COPY);
+                               gc->set_line_attributes(3,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+                               drawable->draw_arc(
+                                       gc,
+                                       false,
+                                       x,
+                                       y,
+                                       d,
+                                       d,
+                                       0,
+                                       360*64
+                               );
+                               gc->set_rgb_fg_color(Gdk::Color("#afafaf"));
+                       }
+                       else
+                       {
+                               gc->set_rgb_fg_color(Gdk::Color("#ffffff"));
+                               gc->set_function(Gdk::INVERT);
+                       }
+                       gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+
+                       drawable->draw_arc(
+                               gc,
+                               false,
+                               x,
+                               y,
+                               d,
+                               d,
+                               0,
+                               360*64
+                       );
+
+                       if(hover)
+                       {
+                               Real mag;
+                               if (App::restrict_radius_ducks)
+                               {
+                                       Point sub_trans_point((*iter)->get_sub_trans_point());
+                                       Point sub_trans_origin((*iter)->get_sub_trans_origin());
+
+                                       if (sub_trans_point[0] < sub_trans_origin[0])
+                                               sub_trans_point[0] = sub_trans_origin[0];
+                                       if (sub_trans_point[1] < sub_trans_origin[1])
+                                               sub_trans_point[1] = sub_trans_origin[1];
+
+                                       Point point((*iter)->get_transform_stack().perform(sub_trans_point));
+                                       Point origin((*iter)->get_transform_stack().perform(sub_trans_origin));
+
+                                       mag = (point-origin).mag();
+                               }
+                               else
+                                       mag = ((*iter)->get_trans_point()-(*iter)->get_trans_origin()).mag();
+
+                               Distance real_mag(mag, Distance::SYSTEM_UNITS);
+                               real_mag.convert(App::distance_system,get_work_area()->get_rend_desc());
+                               layout->set_text(real_mag.get_string());
+
+                               gc->set_rgb_fg_color(DUCK_COLOR_WIDTH_TEXT_1);
+                               drawable->draw_layout(
+                                       gc,
+                                       round_to_int(point[0])+1+6,
+                                       round_to_int(point[1])+1-8,
+                                       layout
+                               );
+                               gc->set_rgb_fg_color(DUCK_COLOR_WIDTH_TEXT_2);
+                               drawable->draw_layout(
+                                       gc,
+                                       round_to_int(point[0])+6,
+                                       round_to_int(point[1])-8,
+                                       layout
+                               );
+                       }
+
+               }
+
+       }
+
+
+       for(;screen_duck_list.size();screen_duck_list.pop_front())
+       {
+               int radius=4;
+               int outline=1;
+               Gdk::Color color(screen_duck_list.front().color);
+
+               if(!screen_duck_list.front().selected)
+               {
+                       color.set_red(color.get_red()*2/3);
+                       color.set_green(color.get_green()*2/3);
+                       color.set_blue(color.get_blue()*2/3);
+               }
+
+               if(screen_duck_list.front().hover && !screen_duck_list.back().hover && screen_duck_list.size()>1)
+               {
+                       screen_duck_list.push_back(screen_duck_list.front());
+                       continue;
+               }
+
+               if(screen_duck_list.front().hover)
+               {
+                       radius+=2;
+                       outline++;
+               }
+
+               gc->set_function(Gdk::COPY);
+               gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+               gc->set_rgb_fg_color(DUCK_COLOR_OUTLINE);
+               drawable->draw_arc(
+                       gc,
+                       true,
+                       round_to_int(screen_duck_list.front().pos[0]-radius),
+                       round_to_int(screen_duck_list.front().pos[1]-radius),
+                       radius*2,
+                       radius*2,
+                       0,
+                       360*64
+               );
+
+
+               gc->set_rgb_fg_color(color);
+
+               drawable->draw_arc(
+                       gc,
+                       true,
+                       round_to_int(screen_duck_list.front().pos[0]-radius+outline),
+                       round_to_int(screen_duck_list.front().pos[1]-radius+outline),
+                       radius*2-outline*2,
+                       radius*2-outline*2,
+                       0,
+                       360*64
+               );
+       }
+}
diff --git a/synfig-studio/src/gui/renderer_ducks.h b/synfig-studio/src/gui/renderer_ducks.h
new file mode 100644 (file)
index 0000000..32a6efd
--- /dev/null
@@ -0,0 +1,84 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file renderer_ducks.h
+**     \brief Template Header
+**
+**     $Id$
+**
+**     \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
+**     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_RENDERER_DUCKS_H
+#define __SYNFIG_RENDERER_DUCKS_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "workarearenderer.h"
+#include <vector>
+
+/* === M A C R O S ========================================================= */
+
+#define DUCK_COLOR_NOT_EDITABLE        Gdk::Color("#cfcfcf")
+
+#define DUCK_COLOR_ANGLE               Gdk::Color("#0000ff")
+#define DUCK_COLOR_RADIUS              Gdk::Color("#00ffff")
+#define DUCK_COLOR_TANGENT_1   Gdk::Color("#ffff00")
+#define DUCK_COLOR_TANGENT_2   Gdk::Color("#ff0000")
+#define DUCK_COLOR_VERTEX              Gdk::Color("#ff7f00")
+#define DUCK_COLOR_WIDTH               Gdk::Color("#ff00ff")
+#define DUCK_COLOR_OTHER               Gdk::Color("#00ff00")
+
+#define DUCK_COLOR_OUTLINE             Gdk::Color("#000000") // the outline around each duck
+
+#define DUCK_COLOR_BEZIER_1            Gdk::Color("#000000") // the 2 colors used to draw bezier curves
+#define DUCK_COLOR_BEZIER_2            Gdk::Color("#afafaf")
+
+#define DUCK_COLOR_BOX_1               Gdk::Color("#ffffff") // the 2 colors used to draw boxes
+#define DUCK_COLOR_BOX_2               Gdk::Color("#000000")
+
+#define DUCK_COLOR_SELECTED            Gdk::Color("#ff0000") // the color of the box drawn when a valuenode is selected
+
+#define DUCK_COLOR_CONNECT_INSIDE      Gdk::Color("#9fefef") // the color of the inside of the line connecting a vertex duck to the tangent ducks
+#define DUCK_COLOR_CONNECT_OUTSIDE     Gdk::Color("#000000") // the color of the outside of the line connecting a vertex duck to the tangent ducks
+
+#define DUCK_COLOR_WIDTH_TEXT_1        Gdk::Color("#000000") // the color of the text's shadow when hovering over a width duck
+#define DUCK_COLOR_WIDTH_TEXT_2        Gdk::Color("#ff00ff") // the color of the text when hovering over a width duck
+
+/* === 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 Renderer_Ducks : public studio::WorkAreaRenderer
+{
+
+public:
+       ~Renderer_Ducks();
+
+       void render_vfunc(const Glib::RefPtr<Gdk::Drawable>& drawable,const Gdk::Rectangle& expose_area );
+
+protected:
+//     bool get_enabled_vfunc()const;
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/renderer_grid.cpp b/synfig-studio/src/gui/renderer_grid.cpp
new file mode 100644 (file)
index 0000000..b00a593
--- /dev/null
@@ -0,0 +1,173 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file renderer_grid.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "renderer_grid.h"
+#include "workarea.h"
+#include <ETL/misc>
+
+#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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Renderer_Grid::~Renderer_Grid()
+{
+}
+
+bool
+Renderer_Grid::get_enabled_vfunc()const
+{
+       return get_work_area()->grid_status();
+}
+
+synfig::Vector
+Renderer_Grid::get_grid_size()const
+{
+       return get_work_area()->get_grid_size();
+}
+
+void
+Renderer_Grid::render_vfunc(
+       const Glib::RefPtr<Gdk::Drawable>& drawable,
+       const Gdk::Rectangle& /*expose_area*/
+)
+{
+       assert(get_work_area());
+       if(!get_work_area())
+               return;
+
+//     const synfig::RendDesc &rend_desc(get_work_area()->get_canvas()->rend_desc());
+
+       const synfig::Vector focus_point(get_work_area()->get_focus_point());
+
+//     std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> >& tile_book(get_tile_book());
+
+       int drawable_w,drawable_h;
+       drawable->get_size(drawable_w,drawable_h);
+
+       // Calculate the window coordinates of the top-left
+       // corner of the canvas.
+//     const synfig::Vector::value_type
+//             x(focus_point[0]/get_pw()+drawable_w/2-get_w()/2),
+//             y(focus_point[1]/get_ph()+drawable_h/2-get_h()/2);
+
+       /*const synfig::Vector::value_type window_startx(window_tl[0]);
+       const synfig::Vector::value_type window_endx(window_br[0]);
+       const synfig::Vector::value_type window_starty(window_tl[1]);
+       const synfig::Vector::value_type window_endy(window_br[1]);
+       */
+//     const int
+//             tile_w(get_work_area()->get_tile_w()),
+//             tile_h(get_work_area()->get_tile_h());
+
+//     const int
+//             w(get_w()),
+//             h(get_h());
+
+       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(drawable));
+
+       const synfig::Vector grid_size(get_grid_size());
+
+       const synfig::Vector::value_type window_startx(get_work_area()->get_window_tl()[0]);
+       const synfig::Vector::value_type window_endx(get_work_area()->get_window_br()[0]);
+       const synfig::Vector::value_type window_starty(get_work_area()->get_window_tl()[1]);
+       const synfig::Vector::value_type window_endy(get_work_area()->get_window_br()[1]);
+       const float pw(get_pw()),ph(get_ph());
+
+       // Draw out the grid
+       if(grid_size[0]>pw*3.5 && grid_size[1]>ph*3.5)
+       {
+               synfig::Vector::value_type x,y;
+
+               x=floor(window_startx/grid_size[0])*grid_size[0];
+               y=floor(window_starty/grid_size[1])*grid_size[1];
+
+               gc->set_function(Gdk::COPY);
+               gc->set_rgb_fg_color(Gdk::Color("#9f9f9f"));
+               gc->set_line_attributes(1,Gdk::LINE_ON_OFF_DASH,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+
+               if(x<window_endx)
+                       for(;x<window_endx;x+=grid_size[0])
+                       {
+                               drawable->draw_line(gc,
+                                       round_to_int((x-window_startx)/pw),
+                                       0,
+                                       round_to_int((x-window_startx)/pw),
+                                       drawable_h
+                               );
+                       }
+               else
+                       for(;x>window_endx;x-=grid_size[0])
+                       {
+                               drawable->draw_line(gc,
+                                       round_to_int((x-window_startx)/pw),
+                                       0,
+                                       round_to_int((x-window_startx)/pw),
+                                       drawable_h
+                               );
+                       }
+
+               if(y<window_endy)
+                       for(;y<window_endy;y+=grid_size[1])
+                       {
+                               drawable->draw_line(gc,
+                                       0,
+                                       round_to_int((y-window_starty)/ph),
+                                       drawable_w,
+                                       round_to_int((y-window_starty)/ph)
+                               );
+                       }
+               else
+                       for(;y>window_endy;y-=grid_size[1])
+                       {
+                               drawable->draw_line(gc,
+                                       0,
+                                       round_to_int((y-window_starty)/ph),
+                                       drawable_w,
+                                       round_to_int((y-window_starty)/ph)
+                               );
+                       }
+       }
+}
diff --git a/synfig-studio/src/gui/renderer_grid.h b/synfig-studio/src/gui/renderer_grid.h
new file mode 100644 (file)
index 0000000..9cb96c4
--- /dev/null
@@ -0,0 +1,59 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file renderer_grid.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_RENDERER_GRID_H
+#define __SYNFIG_RENDERER_GRID_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "workarearenderer.h"
+#include <vector>
+
+/* === 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 Renderer_Grid : public studio::WorkAreaRenderer
+{
+
+public:
+       ~Renderer_Grid();
+
+       synfig::Vector get_grid_size()const;
+
+       void render_vfunc(const Glib::RefPtr<Gdk::Drawable>& drawable,const Gdk::Rectangle& expose_area );
+
+protected:
+       bool get_enabled_vfunc()const;
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/renderer_guides.cpp b/synfig-studio/src/gui/renderer_guides.cpp
new file mode 100644 (file)
index 0000000..c1f5d9f
--- /dev/null
@@ -0,0 +1,284 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file renderer_guides.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "renderer_guides.h"
+#include "workarea.h"
+#include <ETL/misc>
+
+#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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Renderer_Guides::Renderer_Guides():
+       dragging(false)
+{
+
+}
+
+Renderer_Guides::~Renderer_Guides()
+{
+}
+
+bool
+Renderer_Guides::get_enabled_vfunc()const
+{
+       return get_work_area()->get_show_guides();
+}
+
+std::list<float>&
+Renderer_Guides::get_guide_list_x()
+{
+       return get_work_area()->get_guide_list_x();
+}
+
+std::list<float>&
+Renderer_Guides::get_guide_list_y()
+{
+       return get_work_area()->get_guide_list_y();
+}
+
+bool
+Renderer_Guides::event_vfunc(GdkEvent* event)
+{
+       synfig::Point mouse_pos;
+       // float bezier_click_pos;
+       // const float radius((abs(get_pw())+abs(get_ph()))*4);
+       int button_pressed(0);
+       float pressure(0);
+       bool is_mouse(false);
+       Gdk::ModifierType modifier(Gdk::ModifierType(0));
+
+       // Handle input stuff
+       if(
+               event->any.type==GDK_MOTION_NOTIFY ||
+               event->any.type==GDK_BUTTON_PRESS ||
+               event->any.type==GDK_2BUTTON_PRESS ||
+               event->any.type==GDK_3BUTTON_PRESS ||
+               event->any.type==GDK_BUTTON_RELEASE
+       )
+       {
+               GdkDevice *device;
+               if(event->any.type==GDK_MOTION_NOTIFY)
+               {
+                       device=event->motion.device;
+                       modifier=Gdk::ModifierType(event->motion.state);
+               }
+               else
+               {
+                       device=event->button.device;
+                       modifier=Gdk::ModifierType(event->button.state);
+               }
+
+               // Make sure we recognize the device
+               /*if(curr_input_device)
+               {
+                       if(curr_input_device!=device)
+                       {
+                               assert(device);
+                               curr_input_device=device;
+                               signal_input_device_changed()(curr_input_device);
+                       }
+               }
+               else*/ if(device)
+               {
+                       //curr_input_device=device;
+                       //signal_input_device_changed()(curr_input_device);
+               }
+
+               //assert(curr_input_device);
+
+               // Calculate the position of the
+               // input device in canvas coordinates
+               // and the buttons
+               if(!event->button.axes)
+               {
+                       mouse_pos=synfig::Point(screen_to_comp_coords(synfig::Point(event->button.x,event->button.y)));
+                       button_pressed=event->button.button;
+                       pressure=1.0f;
+                       is_mouse=true;
+                       if(isnan(event->button.x) || isnan(event->button.y))
+                               return false;
+               }
+               else
+               {
+                       double x(event->button.axes[0]);
+                       double y(event->button.axes[1]);
+                       if(isnan(x) || isnan(y))
+                               return false;
+
+                       pressure=event->button.axes[2];
+                       //synfig::info("pressure=%f",pressure);
+                       pressure-=0.04f;
+                       pressure/=1.0f-0.04f;
+
+
+                       assert(!isnan(pressure));
+
+                       mouse_pos=synfig::Point(screen_to_comp_coords(synfig::Point(x,y)));
+
+                       button_pressed=event->button.button;
+
+                       if(button_pressed==1 && pressure<0 && (event->any.type!=GDK_BUTTON_RELEASE && event->any.type!=GDK_BUTTON_PRESS))
+                               button_pressed=0;
+                       if(pressure<0)
+                               pressure=0;
+
+                       //if(event->any.type==GDK_BUTTON_PRESS && button_pressed)
+                       //      synfig::info("Button pressed on input device = %d",event->button.button);
+
+                       //if(event->button.axes[2]>0.1)
+                       //      button_pressed=1;
+                       //else
+                       //      button_pressed=0;
+               }
+       }
+       switch(event->type)
+    {
+       case GDK_BUTTON_PRESS:
+               break;
+       case GDK_MOTION_NOTIFY:
+               break;
+       case GDK_BUTTON_RELEASE:
+               break;
+       default:
+               break;
+       }
+
+       return false;
+}
+
+void
+Renderer_Guides::render_vfunc(
+       const Glib::RefPtr<Gdk::Drawable>& drawable,
+       const Gdk::Rectangle& /*expose_area*/
+)
+{
+       assert(get_work_area());
+       if(!get_work_area())
+               return;
+
+       // const synfig::RendDesc &rend_desc(get_work_area()->get_canvas()->rend_desc());
+
+       const synfig::Vector focus_point(get_work_area()->get_focus_point());
+
+       //std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> >& tile_book(get_tile_book());
+
+       int drawable_w,drawable_h;
+       drawable->get_size(drawable_w,drawable_h);
+
+       // Calculate the window coordinates of the top-left
+       // corner of the canvas.
+       // const synfig::Vector::value_type
+       //      x(focus_point[0]/get_pw()+drawable_w/2-get_w()/2),
+       //      y(focus_point[1]/get_ph()+drawable_h/2-get_h()/2);
+
+       /*const synfig::Vector::value_type window_startx(window_tl[0]);
+       const synfig::Vector::value_type window_endx(window_br[0]);
+       const synfig::Vector::value_type window_starty(window_tl[1]);
+       const synfig::Vector::value_type window_endy(window_br[1]);
+       */
+       // const int
+       //      tile_w(get_work_area()->get_tile_w()),
+       //      tile_h(get_work_area()->get_tile_h());
+
+       // const int
+       //      w(get_w()),
+       //      h(get_h());
+
+       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(drawable));
+
+       //const synfig::Vector grid_size(get_grid_size());
+
+       const synfig::Vector::value_type window_startx(get_work_area()->get_window_tl()[0]);
+       // const synfig::Vector::value_type window_endx(get_work_area()->get_window_br()[0]);
+       const synfig::Vector::value_type window_starty(get_work_area()->get_window_tl()[1]);
+       // const synfig::Vector::value_type window_endy(get_work_area()->get_window_br()[1]);
+       const float pw(get_pw()),ph(get_ph());
+
+       // Draw out the guides
+       {
+               gc->set_function(Gdk::COPY);
+               gc->set_rgb_fg_color(Gdk::Color("#9f9fff"));
+               gc->set_line_attributes(1,Gdk::LINE_ON_OFF_DASH,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+
+               Duckmatic::GuideList::const_iterator iter;
+
+               // vertical
+               for(iter=get_guide_list_x().begin();iter!=get_guide_list_x().end();++iter)
+               {
+                       const float x((*iter-window_startx)/pw);
+
+                       if(iter==get_work_area()->curr_guide)
+                               gc->set_rgb_fg_color(Gdk::Color("#ff6f6f"));
+                       else
+                               gc->set_rgb_fg_color(Gdk::Color("#6f6fff"));
+
+                       drawable->draw_line(gc,
+                               round_to_int(x),
+                               0,
+                               round_to_int(x),
+                               drawable_h
+                       );
+               }
+               // horizontal
+               for(iter=get_guide_list_y().begin();iter!=get_guide_list_y().end();++iter)
+               {
+                       const float y((*iter-window_starty)/ph);
+
+                       if(iter==get_work_area()->curr_guide)
+                               gc->set_rgb_fg_color(Gdk::Color("#ff6f6f"));
+                       else
+                               gc->set_rgb_fg_color(Gdk::Color("#6f6fff"));
+
+                       drawable->draw_line(gc,
+                               0,
+                               round_to_int(y),
+                               drawable_w,
+                               round_to_int(y)
+                       );
+               }
+       }
+}
diff --git a/synfig-studio/src/gui/renderer_guides.h b/synfig-studio/src/gui/renderer_guides.h
new file mode 100644 (file)
index 0000000..d7c7ce0
--- /dev/null
@@ -0,0 +1,62 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file renderer_guides.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_RENDERER_GUIDES_H
+#define __SYNFIG_RENDERER_GUIDES_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "workarearenderer.h"
+#include <vector>
+
+/* === 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 Renderer_Guides : public studio::WorkAreaRenderer
+{
+       bool dragging;
+public:
+       Renderer_Guides();
+       ~Renderer_Guides();
+
+       std::list<float>& get_guide_list_x();
+       std::list<float>& get_guide_list_y();
+
+       void render_vfunc(const Glib::RefPtr<Gdk::Drawable>& drawable,const Gdk::Rectangle& expose_area );
+       bool event_vfunc(GdkEvent* event);
+
+protected:
+       bool get_enabled_vfunc()const;
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/renderer_timecode.cpp b/synfig-studio/src/gui/renderer_timecode.cpp
new file mode 100644 (file)
index 0000000..48cc42b
--- /dev/null
@@ -0,0 +1,169 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file renderer_timecode.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \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
+**     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 <config.h>
+#endif
+
+#include "renderer_timecode.h"
+#include "workarea.h"
+#include <pangomm/layout.h>
+#include <pangomm/context.h>
+#include <pango/pango.h>
+#include "app.h"
+#include <cassert>
+
+#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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Renderer_Timecode::~Renderer_Timecode()
+{
+}
+
+bool
+Renderer_Timecode::get_enabled_vfunc()const
+{
+       Canvas::Handle canvas(get_work_area()->get_canvas());
+       return (canvas->rend_desc().get_time_start()!=canvas->rend_desc().get_time_end() ||
+               canvas->get_time()!=canvas->rend_desc().get_time_start());
+}
+
+synfig::Vector
+Renderer_Timecode::get_grid_size()const
+{
+       return get_work_area()->get_grid_size();
+}
+
+void
+Renderer_Timecode::render_vfunc(
+       const Glib::RefPtr<Gdk::Drawable>& drawable,
+       const Gdk::Rectangle& /*expose_area*/
+)
+{
+       assert(get_work_area());
+       if(!get_work_area())
+               return;
+
+       //const synfig::RendDesc &rend_desc(get_work_area()->get_canvas()->rend_desc());
+
+       const synfig::Vector focus_point(get_work_area()->get_focus_point());
+
+       //std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> >& tile_book(get_tile_book());
+
+       int drawable_w,drawable_h;
+       drawable->get_size(drawable_w,drawable_h);
+
+       // Calculate the window coordinates of the top-left
+       // corner of the canvas.
+//     const synfig::Vector::value_type
+//             x(focus_point[0]/get_pw()+drawable_w/2-get_w()/2),
+//             y(focus_point[1]/get_ph()+drawable_h/2-get_h()/2);
+
+       /*const synfig::Vector::value_type window_startx(window_tl[0]);
+       const synfig::Vector::value_type window_endx(window_br[0]);
+       const synfig::Vector::value_type window_starty(window_tl[1]);
+       const synfig::Vector::value_type window_endy(window_br[1]);
+       */
+//     const int
+//             tile_w(get_work_area()->get_tile_w()),
+//             tile_h(get_work_area()->get_tile_h());
+
+//     const int
+//             w(get_w()),
+//             h(get_h());
+
+       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(drawable));
+
+       //const synfig::Vector grid_size(get_grid_size());
+
+//     const synfig::Vector::value_type window_startx(get_work_area()->get_window_tl()[0]);
+//     const synfig::Vector::value_type window_endx(get_work_area()->get_window_br()[0]);
+//     const synfig::Vector::value_type window_starty(get_work_area()->get_window_tl()[1]);
+//     const synfig::Vector::value_type window_endy(get_work_area()->get_window_br()[1]);
+//     const float pw(get_pw()),ph(get_ph());
+
+       Canvas::Handle canvas(get_work_area()->get_canvas());
+       synfig::Time cur_time(canvas->get_time());
+
+       // Print out the timecode
+       {
+               Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_work_area()->get_pango_context()));
+
+/*             Glib::ustring timecode(cur_time.get_string(rend_desc.get_frame_rate(),App::get_time_format()));
+
+               try
+               {
+                       timecode+="\n"+canvas->keyframe_list().find(cur_time)->get_description();
+                       gc->set_rgb_fg_color(Gdk::Color("#FF0000"));
+               }
+               catch(synfig::Exception::NotFound)
+               {
+                       return;
+                       gc->set_rgb_fg_color(Gdk::Color("#000000"));
+               }
+
+               layout->set_text(timecode);
+*/
+
+               gc->set_rgb_fg_color(Gdk::Color("#5f0000"));
+               try
+               {
+                       int w, h;
+                       layout->set_text(canvas->keyframe_list().find(cur_time)->get_description());
+                       layout->get_size(w, h);
+                       get_work_area()->timecode_width = int(w*1.0/Pango::SCALE);
+                       get_work_area()->timecode_height = int(h*1.0/Pango::SCALE);
+               }
+               catch(synfig::Exception::NotFound)
+               {
+                       get_work_area()->timecode_width = get_work_area()->timecode_height = 0;
+                       return;
+               }
+               catch(...) {
+                       assert(0);
+               }
+
+               drawable->draw_layout(gc, 4, 4, layout);
+       }
+}
diff --git a/synfig-studio/src/gui/renderer_timecode.h b/synfig-studio/src/gui/renderer_timecode.h
new file mode 100644 (file)
index 0000000..cfd9a0b
--- /dev/null
@@ -0,0 +1,59 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file renderer_timecode.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_RENDERER_TIMECODE_H
+#define __SYNFIG_RENDERER_TIMECODE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "workarearenderer.h"
+#include <vector>
+
+/* === 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 Renderer_Timecode : public studio::WorkAreaRenderer
+{
+
+public:
+       ~Renderer_Timecode();
+
+       synfig::Vector get_grid_size()const;
+
+       void render_vfunc(const Glib::RefPtr<Gdk::Drawable>& drawable,const Gdk::Rectangle& expose_area );
+
+protected:
+       bool get_enabled_vfunc()const;
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/resolutiondial.cpp b/synfig-studio/src/gui/resolutiondial.cpp
new file mode 100644 (file)
index 0000000..b7ef2c9
--- /dev/null
@@ -0,0 +1,96 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file resolutiondial.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2009 Gerco Ballintijn
+**     Copyright (c) 2009 Carlos Lopez
+**
+**     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 <config.h>
+#endif
+
+#include "resolutiondial.h"
+#include <gtkmm/image.h>
+#include <gtkmm/stock.h>
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+ResolutionDial::ResolutionDial(Gtk::IconSize & size): Gtk::Table(3, 1, false)
+{
+
+       increase_resolution = create_icon(size, Gtk::StockID("synfig-increase_resolution"), _("Increase Display Resolution"));
+       decrease_resolution = create_icon(size, Gtk::StockID("synfig-decrease_resolution"), _("Decrease Display Resolution"));
+       use_low_resolution = create_check(_("Low Res"), _("Use Low Resolution when enabled"));
+
+       attach(*decrease_resolution, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       attach(*use_low_resolution, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       attach(*increase_resolution, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+}
+
+Gtk::Button *
+ResolutionDial::create_icon(Gtk::IconSize size, const Gtk::StockID & stockid,
+               const char * tooltip)
+{
+       Gtk::Button *button = manage(new class Gtk::Button());
+       Gtk::Image *icon = manage(new Gtk::Image(stockid, size));
+       button->add(*icon);
+       tooltips.set_tip(*button, tooltip);
+       icon->set_padding(0, 0);
+       icon->show();
+       button->set_relief(Gtk::RELIEF_NONE);
+       button->show();
+
+       return button;
+}
+
+Gtk::CheckButton *
+ResolutionDial::create_check(const char *label, const char * tooltip)
+{
+       Gtk::CheckButton *cbutton = manage(new class Gtk::CheckButton());
+       cbutton->set_label(label);
+       tooltips.set_tip(*cbutton, tooltip);
+       cbutton->show();
+
+       return cbutton;
+}
+
+void
+ResolutionDial::update_lowres(bool flag)
+{
+       use_low_resolution->set_active(flag);
+}
diff --git a/synfig-studio/src/gui/resolutiondial.h b/synfig-studio/src/gui/resolutiondial.h
new file mode 100644 (file)
index 0000000..611eb11
--- /dev/null
@@ -0,0 +1,77 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file resolutiondial.h
+**     \brief Template Header
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2008 Chris Moore
+**     Copyright (c) 2009 Gerco Ballintijn
+**     Copyright (c) 2009 Carlos Lopez
+**
+**     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_RESOLUTIONDIAL_H
+#define __SYNFIG_STUDIO_RESOLUTIONDIAL_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/tooltips.h>
+#include <gtkmm/table.h>
+#include <gtkmm/checkbutton.h>
+#include "duckmatic.h"
+
+#include "general.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 ResolutionDial : public Gtk::Table
+{
+       Gtk::Tooltips tooltips;
+
+       Gtk::Button *increase_resolution;
+       Gtk::Button *decrease_resolution;
+       Gtk::CheckButton *use_low_resolution;
+
+       Gtk::Button *create_icon(Gtk::IconSize size, const Gtk::StockID & stockid, const char * tooltip);
+       Gtk::CheckButton *create_check(const char *text, const char *tooltip);
+
+public:
+
+       ResolutionDial(Gtk::IconSize & size);
+
+       void update_lowres(bool flag);
+       Glib::SignalProxy0<void> signal_increase_resolution()  { return increase_resolution->signal_clicked(); }
+       Glib::SignalProxy0<void> signal_decrease_resolution()  { return decrease_resolution->signal_clicked(); }
+       Glib::SignalProxy0<void> signal_use_low_resolution()   { return use_low_resolution-> signal_toggled(); }
+
+}; // END of class ResolutionDial
+
+}; // END of namespace studio
+
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/smach.h b/synfig-studio/src/gui/smach.h
new file mode 100644 (file)
index 0000000..f113147
--- /dev/null
@@ -0,0 +1,49 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file smach.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_SMACH_H
+#define __SYNFIG_SMACH_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <ETL/smach>
+#include "eventkey.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 CanvasView;
+
+typedef etl::smach<CanvasView,EventKey> Smach;
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/splash.cpp b/synfig-studio/src/gui/splash.cpp
new file mode 100644 (file)
index 0000000..fe87f01
--- /dev/null
@@ -0,0 +1,252 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file splash.cpp
+**     \brief writeme
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007 Chris Moore
+**     Copyright (c) 2008 Paul Wise
+**
+**     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
+**
+** === N O T E S ===========================================================
+**
+** ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include <iostream>
+#include <string>
+
+#include <ETL/stringf>
+
+#include <gtkmm/image.h>
+#include <gtkmm/label.h>
+#include <gtkmm/frame.h>
+#include <gtkmm/fixed.h>
+
+#include <synfig/general.h>
+
+#include "splash.h"
+#include "app.h"
+
+#include "general.h"
+
+#endif
+
+using namespace std;
+using namespace etl;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+#ifndef VERSION
+#define VERSION        "unknown"
+#define PACKAGE        "synfigstudio"
+#endif
+
+#ifdef WIN32
+#      ifdef IMAGE_DIR
+#              undef IMAGE_DIR
+#              define IMAGE_DIR "share\\pixmaps"
+#      endif
+#endif
+
+#ifndef IMAGE_DIR
+#      define IMAGE_DIR "/usr/local/share/pixmaps"
+#endif
+
+#ifndef IMAGE_EXT
+#      define IMAGE_EXT        "png"
+#endif
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+class studio::SplashProgress : public synfig::ProgressCallback
+{
+       Splash &splash;
+
+public:
+
+       SplashProgress(Splash &splash):splash(splash) { }
+
+       virtual bool task(const std::string &task)
+       {
+               if(splash.tasklabel)
+               {
+                       splash.tasklabel->set_label(task);
+                       splash.tasklabel->show();
+               }
+               else
+               {
+                       cerr<<task<<endl;
+               }
+
+               while(studio::App::events_pending())studio::App::iteration(false);
+               return true;
+       }
+
+       virtual bool error(const std::string &task)
+       {
+               if(splash.tasklabel)
+               {
+                       splash.tasklabel->set_label(_("ERROR:")+task);
+                       splash.tasklabel->show();
+               }
+               else
+               {
+                       cerr<<task<<endl;
+               }
+
+               while(studio::App::events_pending())studio::App::iteration(false);
+               return true;
+       }
+
+       virtual bool warning(const std::string &task)
+       {
+               if(splash.tasklabel)
+               {
+                       splash.tasklabel->set_label(_("WARNING:")+task);
+                       splash.tasklabel->show();
+               }
+               else
+               {
+                       cerr<<task<<endl;
+               }
+
+               while(studio::App::events_pending())studio::App::iteration(false);
+               return true;
+       }
+
+       virtual bool amount_complete(int current, int total)
+       {
+               if(splash.progressbar)
+               {
+                       splash.progressbar->set_fraction((float)current/(float)total);
+                       splash.progressbar->show();
+               }
+               else
+                       cerr<<current<<'/'<<total<<endl;
+
+               while(studio::App::events_pending())studio::App::iteration(false);
+               return true;
+       }
+}; // END of class SplashProgress
+
+/* === M E T H O D S ======================================================= */
+
+Splash::Splash():
+       Gtk::Window(getenv("SYNFIG_DISABLE_POPUP_WINDOWS") ? Gtk::WINDOW_TOPLEVEL : Gtk::WINDOW_POPUP)
+{
+       std::string imagepath;
+#ifdef WIN32
+       imagepath=App::get_base_path()+ETL_DIRECTORY_SEPARATOR+IMAGE_DIR;
+#else
+       imagepath=IMAGE_DIR;
+#endif
+       char* synfig_root=getenv("SYNFIG_ROOT");
+       if(synfig_root) {
+               imagepath=synfig_root;
+               imagepath+=ETL_DIRECTORY_SEPARATOR;
+               imagepath+="share";
+               imagepath+=ETL_DIRECTORY_SEPARATOR;
+               imagepath+="pixmaps";
+               imagepath+=ETL_DIRECTORY_SEPARATOR;
+               imagepath+="synfigstudio";
+       }
+       imagepath+=ETL_DIRECTORY_SEPARATOR;
+
+       // Create the splash image
+       Gtk::Image* splash_image = manage(new class Gtk::Image());
+       splash_image->set(imagepath+"splash_screen."IMAGE_EXT);
+       splash_image->set_alignment(0.5,0.5);
+       splash_image->set_padding(0,0);
+
+       // Get the image size
+       int image_w = 350; int image_h = 0;
+       Glib::RefPtr<Gdk::Pixbuf> pixbuf = splash_image->get_pixbuf();
+       if( pixbuf ){
+               image_w = pixbuf->get_width();
+               image_h = pixbuf->get_height();
+       }
+
+       // Create the progress bar
+       progressbar = manage(new class Gtk::ProgressBar());
+       progressbar->set_size_request(image_w,24);
+
+       // Create the current task label
+       tasklabel = manage(new class Gtk::Label());
+       tasklabel->set_size_request(image_w,24);
+       tasklabel->set_use_underline(false);
+
+       // Create the Gtk::Fixed container and put all of the widgets into it
+       Gtk::Fixed* fixed = manage(new class Gtk::Fixed());
+       if( pixbuf ) fixed->put(*splash_image, 0, 0);
+       fixed->put(*progressbar, 0, image_h+24);
+       fixed->put(*tasklabel, 0, image_h);
+
+       // Create shadow around the outside of the window
+       Gtk::Frame* frame = manage(new class Gtk::Frame());
+       frame->set_shadow_type(Gtk::SHADOW_OUT);
+       frame->add(*fixed);
+
+       // Set up the parameters for this pop-up window
+       set_title("Synfig Studio "VERSION);
+       set_modal(false);
+       property_window_position().set_value(Gtk::WIN_POS_CENTER);
+       set_resizable(false);
+       set_type_hint(Gdk::WINDOW_TYPE_HINT_SPLASHSCREEN);
+       set_auto_startup_notification(false);
+       try {
+               set_icon_from_file(imagepath+"synfig_icon."+IMAGE_EXT);
+       } catch(...) {
+               synfig::warning("Unable to open "+imagepath+"synfig_icon."+IMAGE_EXT);
+       }
+       add(*frame);
+
+       // show everything off
+       if( pixbuf ) splash_image->show();
+       fixed->show();
+       frame->show();
+
+       // Once the splash is shown, we want startup stuff to continue as normal
+       signal_map().connect(sigc::mem_fun(*this, &Splash::enable_startup_notification));
+
+       cb=new SplashProgress(*this);
+}
+
+Splash::~Splash()
+{
+       delete cb;
+}
+
+synfig::ProgressCallback *
+Splash::get_callback()
+{
+       return cb;
+}
+
+void
+Splash::enable_startup_notification(){
+       set_auto_startup_notification(true);
+}
diff --git a/synfig-studio/src/gui/splash.h b/synfig-studio/src/gui/splash.h
new file mode 100644 (file)
index 0000000..5f0b9e7
--- /dev/null
@@ -0,0 +1,72 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file splash.h
+**     \brief Header File
+**
+**     $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
+**
+** === N O T E S ===========================================================
+**
+** ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_GTKMM_SPLASH_H
+#define __SYNFIG_GTKMM_SPLASH_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/window.h>
+#include <gtkmm/label.h>
+#include <gtkmm/button.h>
+#include <gtkmm/progressbar.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 synfig { class ProgressCallback; };
+
+namespace studio {
+
+class SplashProgress;
+
+class Splash : public Gtk::Window
+{
+       friend class SplashProgress;
+
+       SplashProgress *cb;
+
+       Gtk::Label *tasklabel;
+       Gtk::ProgressBar *progressbar;
+
+public:
+
+       synfig::ProgressCallback *get_callback();
+
+       void enable_startup_notification();
+
+       Splash();
+       ~Splash();
+};
+
+}
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/state_bline.cpp b/synfig-studio/src/gui/state_bline.cpp
new file mode 100644 (file)
index 0000000..ee0ca20
--- /dev/null
@@ -0,0 +1,1414 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_bline.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 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 <config.h>
+#endif
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/entry.h>
+
+#include <synfig/valuenode_dynamiclist.h>
+
+#include "state_bline.h"
+#include "state_normal.h"
+#include "canvasview.h"
+#include "workarea.h"
+#include "app.h"
+#include <synfig/valuenode_bline.h>
+#include <ETL/hermite>
+#include <ETL/calculus>
+#include <utility>
+#include "event_mouse.h"
+#include "event_layerclick.h"
+#include "toolbox.h"
+#include "dialog_tooloptions.h"
+#include <gtkmm/spinbutton.h>
+#include <synfig/transform.h>
+#include <synfigapp/main.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 ========================================================= */
+
+// if defined, show the first duck as green while drawing
+#define DISTINGUISH_FIRST_DUCK
+
+/* === G L O B A L S ======================================================= */
+
+StateBLine studio::state_bline;
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+class studio::StateBLine_Context : public sigc::trackable
+{
+       etl::handle<CanvasView> canvas_view_;
+       CanvasView::IsWorking is_working;
+
+       bool prev_table_status;
+       bool loop_;
+       bool prev_workarea_layer_status_;
+
+       int depth;
+       Canvas::Handle canvas;
+
+       Gtk::Menu menu;
+
+       Duckmatic::Push duckmatic_push;
+
+       etl::handle<Duck> curr_duck;
+
+       etl::handle<Duck> next_duck;
+
+       std::list<synfig::ValueNode_Const::Handle> bline_point_list;
+       synfigapp::Settings& settings;
+
+       bool on_vertex_change(const synfig::Point &point, synfig::ValueNode_Const::Handle value_node);
+       bool on_tangent1_change(const synfig::Point &point, synfig::ValueNode_Const::Handle value_node);
+       bool on_tangent2_change(const synfig::Point &point, synfig::ValueNode_Const::Handle value_node);
+
+
+       void popup_handle_menu(synfig::ValueNode_Const::Handle value_node);
+       void popup_vertex_menu(synfig::ValueNode_Const::Handle value_node);
+       void popup_bezier_menu(float location, synfig::ValueNode_Const::Handle value_node);
+
+       void bline_detach_handle(synfig::ValueNode_Const::Handle value_node);
+       void bline_attach_handle(synfig::ValueNode_Const::Handle value_node);
+       void bline_delete_vertex(synfig::ValueNode_Const::Handle value_node);
+       void bline_insert_vertex(synfig::ValueNode_Const::Handle value_node,float origin=0.5);
+       void loop_bline();
+       void unloop_bline();
+
+       void refresh_ducks(bool x=true);
+
+       Gtk::Table options_table;
+       Gtk::Entry entry_id;
+       Gtk::CheckButton checkbutton_layer_region;
+       Gtk::CheckButton checkbutton_layer_outline;
+       Gtk::CheckButton checkbutton_layer_curve_gradient;
+       Gtk::CheckButton checkbutton_layer_plant;
+       Gtk::CheckButton checkbutton_layer_link_origins;
+       Gtk::CheckButton checkbutton_auto_export;
+       Gtk::Button button_make;
+       Gtk::Button button_clear;
+       Gtk::Adjustment  adj_feather;
+       Gtk::SpinButton  spin_feather;
+
+
+
+public:
+
+       int layers_to_create()const
+       {
+               return
+                       get_layer_region_flag() +
+                       get_layer_outline_flag() +
+                       get_layer_curve_gradient_flag() +
+                       get_layer_plant_flag();
+       }
+
+       void sanity_check()
+       {
+               if(layers_to_create()==0)
+                       set_layer_region_flag(true);
+       }
+
+       bool get_auto_export_flag()const { return checkbutton_auto_export.get_active(); }
+       void set_auto_export_flag(bool x) { return checkbutton_auto_export.set_active(x); }
+
+       bool get_layer_region_flag()const { return checkbutton_layer_region.get_active(); }
+       void set_layer_region_flag(bool x) { return checkbutton_layer_region.set_active(x); }
+
+       bool get_layer_outline_flag()const { return checkbutton_layer_outline.get_active(); }
+       void set_layer_outline_flag(bool x) { return checkbutton_layer_outline.set_active(x); }
+
+       bool get_layer_curve_gradient_flag()const { return checkbutton_layer_curve_gradient.get_active(); }
+       void set_layer_curve_gradient_flag(bool x) { return checkbutton_layer_curve_gradient.set_active(x); }
+
+       bool get_layer_plant_flag()const { return checkbutton_layer_plant.get_active(); }
+       void set_layer_plant_flag(bool x) { return checkbutton_layer_plant.set_active(x); }
+
+       bool get_layer_link_origins_flag()const { return checkbutton_layer_link_origins.get_active(); }
+       void set_layer_link_origins_flag(bool x) { return checkbutton_layer_link_origins.set_active(x); }
+
+       Real get_feather() const { return adj_feather.get_value(); }
+       void set_feather(Real x) { return adj_feather.set_value(x); }
+       synfig::String get_id()const { return entry_id.get_text(); }
+       void set_id(const synfig::String& x) { return entry_id.set_text(x); }
+
+       Smach::event_result event_stop_handler(const Smach::event& x);
+
+       Smach::event_result event_refresh_handler(const Smach::event& x);
+
+       Smach::event_result event_mouse_click_handler(const Smach::event& x);
+       Smach::event_result event_mouse_release_handler(const Smach::event& x);
+       Smach::event_result event_mouse_motion_handler(const Smach::event& x);
+       Smach::event_result event_refresh_tool_options(const Smach::event& x);
+
+       Smach::event_result event_hijack(const Smach::event& /*x*/) { return Smach::RESULT_ACCEPT; }
+
+       void refresh_tool_options();
+
+       StateBLine_Context(CanvasView* canvas_view);
+
+       ~StateBLine_Context();
+
+       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
+       etl::handle<synfigapp::CanvasInterface> 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();}
+       const synfig::TransformStack& get_transform_stack()const { return canvas_view_->get_curr_transform_stack(); }
+
+       void load_settings();
+       void save_settings();
+       void reset();
+       void increment_id();
+       //void on_user_click(synfig::Point point);
+
+       bool run_();
+       bool run();
+
+       bool egress_on_selection_change;
+       Smach::event_result event_layer_selection_changed_handler(const Smach::event& /*x*/)
+       {
+               if(egress_on_selection_change)
+                       throw &state_normal; //throw Smach::egress_exception();
+               return Smach::RESULT_OK;
+       }
+
+};     // END of class StateBLine_Context
+
+
+/* === M E T H O D S ======================================================= */
+
+StateBLine::StateBLine():
+       Smach::state<StateBLine_Context>("bline")
+{
+       insert(event_def(EVENT_LAYER_SELECTION_CHANGED,         &StateBLine_Context::event_layer_selection_changed_handler));
+       insert(event_def(EVENT_STOP,                                            &StateBLine_Context::event_stop_handler));
+       insert(event_def(EVENT_REFRESH,                                         &StateBLine_Context::event_refresh_handler));
+       insert(event_def(EVENT_REFRESH_DUCKS,                           &StateBLine_Context::event_hijack));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,      &StateBLine_Context::event_mouse_click_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_UP,        &StateBLine_Context::event_mouse_release_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_MOTION,           &StateBLine_Context::event_mouse_motion_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DRAG,      &StateBLine_Context::event_mouse_motion_handler));
+       insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,            &StateBLine_Context::event_refresh_tool_options));
+}
+
+StateBLine::~StateBLine()
+{
+}
+
+void
+StateBLine_Context::load_settings()
+{
+       String value;
+
+       if(settings.get_value("bline.layer_region",value) && value=="0")
+               set_layer_region_flag(false);
+       else
+               set_layer_region_flag(true);
+
+       if(settings.get_value("bline.layer_outline",value) && value=="0")
+               set_layer_outline_flag(false);
+       else
+               set_layer_outline_flag(true);
+
+       if(settings.get_value("bline.layer_curve_gradient",value) && value=="1")
+               set_layer_curve_gradient_flag(true);
+       else
+               set_layer_curve_gradient_flag(false);
+
+       if(settings.get_value("bline.layer_plant",value) && value=="1")
+               set_layer_plant_flag(true);
+       else
+               set_layer_plant_flag(false);
+
+       if(settings.get_value("bline.layer_link_origins",value) && value=="0")
+               set_layer_link_origins_flag(false);
+       else
+               set_layer_link_origins_flag(true);
+
+       if(settings.get_value("bline.auto_export",value) && value=="1")
+               set_auto_export_flag(true);
+       else
+               set_auto_export_flag(false);
+
+       if(settings.get_value("bline.id",value))
+               set_id(value);
+       else
+               set_id("NewBLine");
+
+       if(settings.get_value("bline.feather",value))
+       {
+               Real n = atof(value.c_str());
+               set_feather(n);
+       }
+
+       sanity_check();
+}
+
+void
+StateBLine_Context::save_settings()
+{
+       sanity_check();
+       settings.set_value("bline.layer_outline",get_layer_outline_flag()?"1":"0");
+       settings.set_value("bline.layer_region",get_layer_region_flag()?"1":"0");
+       settings.set_value("bline.layer_curve_gradient",get_layer_curve_gradient_flag()?"1":"0");
+       settings.set_value("bline.layer_plant",get_layer_plant_flag()?"1":"0");
+       settings.set_value("bline.layer_link_origins",get_layer_link_origins_flag()?"1":"0");
+       settings.set_value("bline.auto_export",get_auto_export_flag()?"1":"0");
+       settings.set_value("bline.id",get_id().c_str());
+       settings.set_value("bline.feather",strprintf("%f",get_feather()));
+}
+
+void
+StateBLine_Context::reset()
+{
+       loop_=false;
+       bline_point_list.clear();
+       refresh_ducks();
+}
+
+void
+StateBLine_Context::increment_id()
+{
+       String id(get_id());
+       int number=1;
+       int digits=0;
+
+       if(id.empty())
+               id="NewBLine";
+
+       // If there is a number
+       // already at the end of the
+       // id, then remove it.
+       if(id[id.size()-1]<='9' && id[id.size()-1]>='0')
+       {
+               // figure out how many digits it is
+               for (digits = 0;
+                        (int)id.size()-1 >= digits && id[id.size()-1-digits] <= '9' && id[id.size()-1-digits] >= '0';
+                        digits++)
+                       ;
+
+               String str_number;
+               str_number=String(id,id.size()-digits,id.size());
+               id=String(id,0,id.size()-digits);
+               // synfig::info("---------------- \"%s\"",str_number.c_str());
+
+               number=atoi(str_number.c_str());
+       }
+       else
+       {
+               number=1;
+               digits=3;
+       }
+
+       number++;
+
+       // Add the number back onto the id
+       {
+               const String format(strprintf("%%0%dd",digits));
+               id+=strprintf(format.c_str(),number);
+       }
+
+       // Set the ID
+       set_id(id);
+}
+
+
+StateBLine_Context::StateBLine_Context(CanvasView* canvas_view):
+       canvas_view_(canvas_view),
+       is_working(*canvas_view),
+       loop_(false),
+       prev_workarea_layer_status_(get_work_area()->get_allow_layer_clicks()),
+       duckmatic_push(get_work_area()),
+       settings(synfigapp::Main::get_selected_input_device()->settings()),
+       entry_id(),
+       checkbutton_layer_region(_("Create Region BLine")),
+       checkbutton_layer_outline(_("Create Outline BLine")),
+       checkbutton_layer_curve_gradient(_("Create Curve Gradient BLine")),
+       checkbutton_layer_plant(_("Create Plant BLine")),
+       checkbutton_layer_link_origins(_("Link Origins")),
+       checkbutton_auto_export(_("Auto Export")),
+       button_make(_("Make")),
+       button_clear(_("Clear")),
+       adj_feather(0,0,10000,0.01,0.1),
+       spin_feather(adj_feather,0.01,4)
+{
+       depth=-1;
+       egress_on_selection_change=true;
+       load_settings();
+
+       // Set up the tool options dialog
+       options_table.attach(*manage(new Gtk::Label(_("BLine Tool"))),  0, 2,  0,  1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(entry_id,                                                                  0, 2,  1,  2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_outline,                                 0, 2,  2,  3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_region,                                  0, 2,  3,  4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_plant,                                   0, 2,  4,  5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_curve_gradient,                  0, 2,  5,  6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_link_origins,                    0, 2,  6,  7, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_auto_export,                                   0, 2,  7,  8, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(*manage(new Gtk::Label(_("Feather"))),     0, 1, 10, 11, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(spin_feather,                                                              1, 2, 10, 11, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       //options_table.attach(button_make, 0, 2, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       //button_make.signal_pressed().connect(sigc::mem_fun(*this,&StateBLine_Context::run));
+       options_table.show_all();
+       refresh_tool_options();
+       App::dialog_tool_options->present();
+
+       // Turn off layer clicking
+       get_work_area()->set_allow_layer_clicks(false);
+
+       // clear out the ducks
+       get_work_area()->clear_ducks();
+
+       // Refresh the work area
+       get_work_area()->queue_draw();
+
+       // Hide the tables if they are showing
+       prev_table_status=get_canvas_view()->tables_are_visible();
+       if(prev_table_status)get_canvas_view()->hide_tables();
+
+       // Disable the time bar
+       get_canvas_view()->set_sensitive_timebar(false);
+
+       // Connect a signal
+       //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateBLine_Context::on_user_click));
+       get_work_area()->set_cursor(Gdk::CROSSHAIR);
+
+       App::toolbox->refresh();
+}
+
+void
+StateBLine_Context::refresh_tool_options()
+{
+       App::dialog_tool_options->clear();
+       App::dialog_tool_options->set_widget(options_table);
+       App::dialog_tool_options->set_local_name(_("BLine Tool"));
+       App::dialog_tool_options->set_name("bline");
+
+       App::dialog_tool_options->add_button(
+               Gtk::StockID("gtk-execute"),
+               _("Make BLine and/or Region")
+       )->signal_clicked().connect(
+               sigc::hide_return(sigc::mem_fun(
+                       *this,
+                       &StateBLine_Context::run
+               ))
+       );
+
+       App::dialog_tool_options->add_button(
+               Gtk::StockID("gtk-clear"),
+               _("Clear current BLine")
+       )->signal_clicked().connect(
+               sigc::mem_fun(
+                       *this,
+                       &StateBLine_Context::reset
+               )
+       );
+}
+
+Smach::event_result
+StateBLine_Context::event_refresh_tool_options(const Smach::event& /*x*/)
+{
+       refresh_tool_options();
+       return Smach::RESULT_ACCEPT;
+}
+
+StateBLine_Context::~StateBLine_Context()
+{
+       run();
+
+       save_settings();
+       App::dialog_tool_options->clear();
+
+       get_work_area()->reset_cursor();
+
+       // Restore layer clicking
+       get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_);
+
+       // Enable the time bar
+       get_canvas_view()->set_sensitive_timebar(true);
+
+       // Bring back the tables if they were out before
+       if(prev_table_status)get_canvas_view()->show_tables();
+
+//     get_canvas_view()->get_smach().process_event(EVENT_REFRESH_DUCKS);
+
+       // Refresh the work area
+       get_work_area()->queue_draw();
+
+       App::toolbox->refresh();
+}
+
+Smach::event_result
+StateBLine_Context::event_stop_handler(const Smach::event& /*x*/)
+{
+//     synfig::info("STATE RotoBLine: Received Stop Event");
+//     run();
+       reset();
+//     throw Smach::egress_exception();
+//     get_canvas_view()->get_smach().pop_state();
+       return Smach::RESULT_ACCEPT;
+}
+
+Smach::event_result
+StateBLine_Context::event_refresh_handler(const Smach::event& /*x*/)
+{
+//     synfig::info("STATE RotoBLine: Received Refresh Event");
+       refresh_ducks();
+       return Smach::RESULT_ACCEPT;
+}
+
+bool
+StateBLine_Context::run()
+{
+       sanity_check();
+
+       String err;
+       bool success(false);
+       for(int i=5;i>0 && !success;i--)try
+       {
+               success=run_();
+       }
+       catch(String s)
+       {
+               err=s;
+       }
+       if(!success && !err.empty())
+       {
+               get_canvas_view()->get_ui_interface()->error(err);
+       }
+       return success;
+}
+
+bool
+StateBLine_Context::run_()
+{
+       curr_duck=0;
+       next_duck=0;
+
+       // Now we need to generate it
+
+       if(bline_point_list.empty())
+       {
+               return false;
+       }
+       if(bline_point_list.size()<2)
+       {
+               //get_canvas_view()->get_ui_interface()->error(_("You need at least two (2) points to create a BLine"));
+               return false;
+       }
+
+       do
+       {
+
+               // Create the action group
+               synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("New BLine"));
+
+               std::vector<BLinePoint> new_list;
+               std::list<synfig::ValueNode_Const::Handle>::iterator iter;
+               const synfig::TransformStack& transform(get_transform_stack());
+
+               for(iter=bline_point_list.begin();iter!=bline_point_list.end();++iter)
+               {
+                       BLinePoint bline_point((*iter)->get_value().get(BLinePoint()));
+                       Point new_vertex(transform.unperform(bline_point.get_vertex()));
+
+                       bline_point.set_tangent1(
+                               transform.unperform(
+                                       bline_point.get_tangent1()+bline_point.get_vertex()
+                               ) -new_vertex
+                       );
+
+                       bline_point.set_tangent2(
+                               transform.unperform(
+                                       bline_point.get_tangent2()+bline_point.get_vertex()
+                               ) -new_vertex
+                       );
+
+                       bline_point.set_vertex(new_vertex);
+
+                       new_list.push_back(bline_point);
+               }
+
+               ValueNode_BLine::Handle value_node_bline(ValueNode_BLine::create(new_list));
+               assert(value_node_bline);
+
+               ValueNode_Const::Handle value_node_origin(ValueNode_Const::create(Vector()));
+               assert(value_node_origin);
+
+               // Set the looping flag
+               value_node_bline->set_loop(loop_);
+
+               // Add the BLine to the canvas
+               if(get_auto_export_flag() && !get_canvas_interface()->add_value_node(value_node_bline,get_id()))
+               {
+                       //get_canvas_view()->get_ui_interface()->error(_("Unable to add value node"));
+                       group.cancel();
+                       increment_id();
+                       throw String(_("Unable to add value node"));
+                       return false;
+               }
+
+               Layer::Handle layer;
+
+               // we are temporarily using the layer to hold something
+               layer=get_canvas_view()->get_selection_manager()->get_selected_layer();
+
+               if(layer)
+               {
+                       if(depth<0)
+                               depth=layer->get_depth();
+                       if(!canvas)
+                               canvas=layer->get_canvas();
+               }
+               else
+                       depth=0;
+
+               if(!canvas)
+                       canvas=get_canvas_view()->get_canvas();
+
+               value_node_bline->set_member_canvas(canvas);
+
+               synfigapp::SelectionManager::LayerList layer_selection;
+               if (!getenv("SYNFIG_TOOLS_CLEAR_SELECTION"))
+                       layer_selection = get_canvas_view()->get_selection_manager()->get_selected_layers();
+
+               // count how many layers we're going to be creating
+               int layers_to_create = this->layers_to_create();
+
+               ///////////////////////////////////////////////////////////////////////////
+               //   C U R V E   G R A D I E N T
+               ///////////////////////////////////////////////////////////////////////////
+
+               if(get_layer_curve_gradient_flag())
+               {
+                       synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+                       Layer::Handle layer(get_canvas_interface()->add_layer_to("curve_gradient",canvas,depth));
+                       if (!layer)
+                       {
+                               group.cancel();
+                               throw String(_("Unable to create layer"));
+                       }
+                       layer_selection.push_back(layer);
+                       layer->set_description(get_id()+_(" Gradient"));
+                       get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+                       {
+                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                               assert(action);
+
+                               action->set_param("canvas",get_canvas());
+                               action->set_param("canvas_interface",get_canvas_interface());
+                               action->set_param("layer",layer);
+                               if(!action->set_param("param",String("bline")))
+                                       synfig::error("LayerParamConnect didn't like \"param\"");
+                               if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
+                                       synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                               if(!get_canvas_interface()->get_instance()->perform_action(action))
+                               {
+                                       //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                                       group.cancel();
+                                       throw String(_("Unable to create Gradient layer"));
+                                       return false;
+                               }
+                       }
+
+                       // only link the curve gradient's origin parameter if the option is selected and we're creating more than one layer
+                       if (get_layer_link_origins_flag() && layers_to_create > 1)
+                       {
+                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                               assert(action);
+
+                               action->set_param("canvas",get_canvas());
+                               action->set_param("canvas_interface",get_canvas_interface());
+                               action->set_param("layer",layer);
+                               if(!action->set_param("param",String("origin")))
+                                       synfig::error("LayerParamConnect didn't like \"param\"");
+                               if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+                                       synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                               if(!get_canvas_interface()->get_instance()->perform_action(action))
+                               {
+                                       //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                                       group.cancel();
+                                       throw String(_("Unable to create Gradient layer"));
+                                       return false;
+                               }
+                       }
+               }
+
+               ///////////////////////////////////////////////////////////////////////////
+               //   P L A N T
+               ///////////////////////////////////////////////////////////////////////////
+
+               if(get_layer_plant_flag())
+               {
+                       synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+                       Layer::Handle layer(get_canvas_interface()->add_layer_to("plant",canvas,depth));
+                       if (!layer)
+                       {
+                               group.cancel();
+                               throw String(_("Unable to create layer"));
+                       }
+                       layer_selection.push_back(layer);
+                       layer->set_description(get_id()+_(" Plant"));
+                       get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+                       {
+                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                               assert(action);
+
+                               action->set_param("canvas",get_canvas());
+                               action->set_param("canvas_interface",get_canvas_interface());
+                               action->set_param("layer",layer);
+                               if(!action->set_param("param",String("bline")))
+                                       synfig::error("LayerParamConnect didn't like \"param\"");
+                               if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
+                                       synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                               if(!get_canvas_interface()->get_instance()->perform_action(action))
+                               {
+                                       //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                                       group.cancel();
+                                       throw String(_("Unable to create Plant layer"));
+                                       return false;
+                               }
+                       }
+
+                       // only link the plant's origin parameter if the option is selected and we're creating more than one layer
+                       if (get_layer_link_origins_flag() && layers_to_create > 1)
+                       {
+                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                               assert(action);
+
+                               action->set_param("canvas",get_canvas());
+                               action->set_param("canvas_interface",get_canvas_interface());
+                               action->set_param("layer",layer);
+                               if(!action->set_param("param",String("origin")))
+                                       synfig::error("LayerParamConnect didn't like \"param\"");
+                               if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+                                       synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                               if(!get_canvas_interface()->get_instance()->perform_action(action))
+                               {
+                                       //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                                       group.cancel();
+                                       throw String(_("Unable to create Plant layer"));
+                                       return false;
+                               }
+                       }
+               }
+
+               ///////////////////////////////////////////////////////////////////////////
+               //   R E G I O N
+               ///////////////////////////////////////////////////////////////////////////
+
+               if(get_layer_region_flag())
+               {
+                       synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+                       Layer::Handle layer(get_canvas_interface()->add_layer_to("region",canvas,depth));
+                       if (!layer)
+                       {
+                               group.cancel();
+                               throw String(_("Unable to create layer"));
+                       }
+                       layer_selection.push_back(layer);
+                       layer->set_description(get_id()+_(" Region"));
+                       get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+                       if(get_feather())
+                       {
+                               layer->set_param("feather",get_feather());
+                               get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
+                       }
+
+                       // I don't know if it's safe to reuse the same LayerParamConnect action, so I'm
+                       // using 2 separate ones.
+                       {
+                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                               assert(action);
+
+                               action->set_param("canvas",get_canvas());
+                               action->set_param("canvas_interface",get_canvas_interface());
+                               action->set_param("layer",layer);
+                               if(!action->set_param("param",String("bline")))
+                                       synfig::error("LayerParamConnect didn't like \"param\"");
+                               if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
+                                       synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                               if(!get_canvas_interface()->get_instance()->perform_action(action))
+                               {
+                                       //get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
+                                       group.cancel();
+                                       throw String(_("Unable to create Region layer"));
+                                       return false;
+                               }
+                       }
+
+                       // only link the region's origin parameter if the option is selected and we're creating more than one layer
+                       if (get_layer_link_origins_flag() && layers_to_create > 1)
+                       {
+                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                               assert(action);
+
+                               action->set_param("canvas",get_canvas());
+                               action->set_param("canvas_interface",get_canvas_interface());
+                               action->set_param("layer",layer);
+                               if(!action->set_param("param",String("origin")))
+                                       synfig::error("LayerParamConnect didn't like \"param\"");
+                               if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+                                       synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                               if(!get_canvas_interface()->get_instance()->perform_action(action))
+                               {
+                                       //get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
+                                       group.cancel();
+                                       throw String(_("Unable to create Region layer"));
+                                       return false;
+                               }
+                       }
+               }
+
+               ///////////////////////////////////////////////////////////////////////////
+               //   O U T L I N E
+               ///////////////////////////////////////////////////////////////////////////
+
+               if(get_layer_outline_flag())
+               {
+                       synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+                       Layer::Handle layer(get_canvas_interface()->add_layer_to("outline",canvas,depth));
+                       if (!layer)
+                       {
+                               group.cancel();
+                               throw String(_("Unable to create layer"));
+                       }
+                       layer_selection.push_back(layer);
+                       layer->set_description(get_id()+_(" Outline"));
+                       get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+                       if(get_feather())
+                       {
+                               layer->set_param("feather",get_feather());
+                               get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
+                       }
+
+                       {
+                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                               assert(action);
+
+                               action->set_param("canvas",get_canvas());
+                               action->set_param("canvas_interface",get_canvas_interface());
+                               action->set_param("layer",layer);
+                               if(!action->set_param("param",String("bline")))
+                                       synfig::error("LayerParamConnect didn't like \"param\"");
+                               if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
+                                       synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                               if(!get_canvas_interface()->get_instance()->perform_action(action))
+                               {
+                                       //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                                       group.cancel();
+                                       throw String(_("Unable to create Outline layer"));
+                                       return false;
+                               }
+                       }
+
+                       // only link the outline's origin parameter if the option is selected and we're creating more than one layer
+                       if (get_layer_link_origins_flag() && layers_to_create > 1)
+                       {
+                               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                               assert(action);
+
+                               action->set_param("canvas",get_canvas());
+                               action->set_param("canvas_interface",get_canvas_interface());
+                               action->set_param("layer",layer);
+                               if(!action->set_param("param",String("origin")))
+                                       synfig::error("LayerParamConnect didn't like \"param\"");
+                               if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+                                       synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                               if(!get_canvas_interface()->get_instance()->perform_action(action))
+                               {
+                                       //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                                       group.cancel();
+                                       throw String(_("Unable to create Outline layer"));
+                                       return false;
+                               }
+                       }
+               }
+
+               egress_on_selection_change=false;
+               get_canvas_interface()->get_selection_manager()->clear_selected_layers();
+               get_canvas_interface()->get_selection_manager()->set_selected_layers(layer_selection);
+               egress_on_selection_change=true;
+
+               //if(finish_bline_dialog.get_region_flag() || finish_bline_dialog.get_bline_flag())
+               //      get_canvas_interface()->signal_dirty_preview()();
+
+       } while(0);
+
+       reset();
+       increment_id();
+       return true;
+}
+
+Smach::event_result
+StateBLine_Context::event_mouse_motion_handler(const Smach::event& x)
+{
+       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
+
+       if(curr_duck)
+       {
+               //synfig::info("Moved Duck");
+               Point p(get_work_area()->snap_point_to_grid(event.pos));
+               curr_duck->set_trans_point(p);
+               if(next_duck)
+                       next_duck->set_trans_point(p);
+               get_work_area()->queue_draw();
+               return Smach::RESULT_ACCEPT;
+       }
+
+       return Smach::RESULT_OK;
+}
+
+Smach::event_result
+StateBLine_Context::event_mouse_release_handler(const Smach::event& /*x*/)
+{
+       if(curr_duck)
+       {
+               //synfig::info("Released current duck");
+               curr_duck->signal_edited()(curr_duck->get_point());
+               if(next_duck)
+               {
+                       //synfig::info("grabbing next duck");
+                       curr_duck=next_duck;
+                       next_duck=0;
+               }
+               return Smach::RESULT_ACCEPT;
+       }
+       return Smach::RESULT_OK;
+}
+
+Smach::event_result
+StateBLine_Context::event_mouse_click_handler(const Smach::event& x)
+{
+       // synfig::info("STATE BLINE: Received mouse button down Event");
+       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
+       switch(event.button)
+       {
+       case BUTTON_LEFT:
+               {
+                       // If we are already looped up, then don't try to add anything else
+                       if(loop_)
+                               return Smach::RESULT_OK;
+
+                       BLinePoint bline_point;
+
+                       bline_point.set_vertex(get_work_area()->snap_point_to_grid(event.pos));
+                       //bline_point.set_width(synfigapp::Main::get_bline_width());
+                       bline_point.set_width(1.0f);
+                       bline_point.set_origin(0.5f);
+                       bline_point.set_split_tangent_flag(false);
+                       bline_point.set_tangent1(Vector(0,0));
+
+                       // set the tangent
+                       /*
+                       if(bline_point_list.empty())
+                       {
+                               bline_point.set_tangent1(Vector(1,1));
+                       }
+                       else
+                       {
+                               const Vector t(event.pos-bline_point_list.back()->get_value().get(BLinePoint()).get_vertex());
+                               bline_point.set_tangent1(t);
+                       }
+
+                       if(bline_point_list.size()>1)
+                       {
+                               std::list<synfig::ValueNode_Const::Handle>::iterator iter;
+                               iter=bline_point_list.end();
+                               iter--;iter--;
+                               BLinePoint prev(bline_point_list.back()->get_value().get(BLinePoint()));
+                               prev.set_tangent1(event.pos-(*iter)->get_value().get(BLinePoint()).get_vertex());
+                               bline_point_list.back()->set_value(prev);
+                       };
+                       */
+
+                       bline_point_list.push_back(ValueNode_Const::create(bline_point));
+
+                       refresh_ducks();
+                       return Smach::RESULT_ACCEPT;
+               }
+
+       default:
+               return Smach::RESULT_OK;
+       }
+}
+
+void
+StateBLine_Context::refresh_ducks(bool button_down)
+{
+       get_work_area()->clear_ducks();
+       get_work_area()->queue_draw();
+
+       if(bline_point_list.empty())
+               return;
+
+       list<ValueNode_Const::Handle>::iterator iter;
+
+       handle<WorkArea::Bezier> bezier;
+       handle<WorkArea::Duck> duck,tduck;
+       BLinePoint bline_point;
+
+       for(iter=bline_point_list.begin();iter!=bline_point_list.end();++iter)
+       {
+               ValueNode_Const::Handle value_node(*iter);
+               bline_point=(value_node->get_value().get(BLinePoint()));
+               assert(value_node);
+
+
+               // First add the duck associated with this vertex
+               duck=new WorkArea::Duck(bline_point.get_vertex());
+               duck->set_editable(true);
+#ifdef DISTINGUISH_FIRST_DUCK
+               if (iter!=bline_point_list.begin())
+                       duck->set_type(Duck::TYPE_VERTEX);
+#else
+               duck->set_type(Duck::TYPE_VERTEX);
+#endif
+               duck->set_name(strprintf("%x-vertex",value_node.get()));
+               duck->signal_edited().connect(
+                       sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::on_vertex_change),value_node)
+               );
+               duck->signal_user_click(2).connect(
+                       sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::popup_vertex_menu),value_node)
+               );
+               duck->set_guid(value_node->get_guid()^synfig::GUID::hasher(0));
+
+               get_work_area()->add_duck(duck);
+
+               // Add the tangent1 duck
+               tduck=new WorkArea::Duck(bline_point.get_tangent1());
+               tduck->set_editable(true);
+               tduck->set_name(strprintf("%x-tangent1",value_node.get()));
+               tduck->set_origin(duck);
+               tduck->set_scalar(-0.33333333333333333);
+               tduck->set_tangent(true);
+               tduck->set_guid(value_node->get_guid()^synfig::GUID::hasher(3));
+               tduck->signal_edited().connect(
+                       sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::on_tangent1_change),value_node)
+               );
+               tduck->signal_user_click(2).connect(
+                       sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::popup_handle_menu),value_node)
+               );
+
+               // See if we need to add that duck to the previous bezier
+               if(bezier)
+               {
+                       get_work_area()->add_duck(tduck);
+                       bezier->p2=duck;
+                       bezier->c2=tduck;
+
+                       bezier->signal_user_click(2).connect(
+                               sigc::bind(
+                                       sigc::mem_fun(
+                                               *this,
+                                               &studio::StateBLine_Context::popup_bezier_menu
+                                       ),
+                                       value_node
+                               )
+                       );
+
+                       //get_work_area()->add_duck(bezier->c1);
+                       //get_work_area()->add_duck(bezier->c2);
+                       get_work_area()->add_bezier(bezier);
+
+                       bezier=0;
+               }
+
+               // Now we see if we need to create a bezier
+               list<ValueNode_Const::Handle>::iterator next(iter);
+               next++;
+
+               // If our next iterator is the end, then we don't need
+               // to add a bezier.
+               //if(next==bline_point_list.end() && !loop_)
+               //      continue;
+
+               bezier=new WorkArea::Bezier();
+
+               // Add the tangent2 duck
+               tduck=new WorkArea::Duck(bline_point.get_tangent2());
+               tduck->set_editable(true);
+               tduck->set_origin(duck);
+               tduck->set_scalar(0.33333333333333333);
+               tduck->set_tangent(true);
+               if(bline_point.get_split_tangent_flag())
+               {
+                       tduck->set_name(strprintf("%x-tangent2",value_node.get()));
+                       tduck->signal_edited().connect(
+                               sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::on_tangent2_change),value_node)
+                       );
+               }
+               else
+               {
+                       tduck->set_name(strprintf("%x-tangent1",value_node.get()));
+                       tduck->signal_edited().connect(
+                               sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::on_tangent1_change),value_node)
+                       );
+               }
+               tduck->set_guid(value_node->get_guid()^synfig::GUID::hasher(4));
+               tduck->signal_user_click(2).connect(
+                       sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::popup_handle_menu),value_node)
+               );
+
+               // Setup the next bezier
+               bezier->p1=duck;
+               bezier->c1=tduck;
+
+               get_work_area()->add_duck(tduck);
+               curr_duck=tduck;
+       }
+
+       // Add the loop, if requested
+       if(bezier && loop_)
+       {
+               curr_duck=0;
+               BLinePoint bline_point(bline_point_list.front()->get_value().get(BLinePoint()));
+
+               duck=new WorkArea::Duck(bline_point.get_vertex());
+               duck->set_editable(true);
+#ifndef DISTINGUISH_FIRST_DUCK
+               duck->set_type(Duck::TYPE_VERTEX);
+#endif
+               duck->set_name(strprintf("%x-vertex",bline_point_list.front().get()));
+               duck->signal_edited().connect(
+                       sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::on_vertex_change),bline_point_list.front())
+               );
+               duck->signal_user_click(2).connect(
+                       sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::popup_vertex_menu),bline_point_list.front())
+               );
+               get_work_area()->add_duck(duck);
+
+               // Add the tangent1 duck
+               tduck=new WorkArea::Duck(bline_point.get_tangent1());
+               tduck->set_editable(true);
+               tduck->set_name(strprintf("%x-tangent1",bline_point_list.front().get()));
+               tduck->set_origin(duck);
+               tduck->set_scalar(-0.33333333333333333);
+               tduck->set_tangent(true);
+               tduck->signal_edited().connect(
+                       sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::on_tangent1_change),bline_point_list.front())
+               );
+               tduck->signal_user_click(2).connect(
+                       sigc::bind(sigc::mem_fun(*this,&studio::StateBLine_Context::popup_handle_menu),bline_point_list.front())
+               );
+               get_work_area()->add_duck(tduck);
+
+               bezier->p2=duck;
+               bezier->c2=tduck;
+
+               bezier->signal_user_click(2).connect(
+                       sigc::bind(
+                               sigc::mem_fun(
+                                       *this,
+                                       &studio::StateBLine_Context::popup_bezier_menu
+                               ),
+                               bline_point_list.front()
+                       )
+               );
+
+               //get_work_area()->add_duck(bezier->c1);
+               get_work_area()->add_bezier(bezier);
+       }
+       if(bezier && !loop_)
+       {
+               duck=new WorkArea::Duck(bline_point.get_vertex());
+               duck->set_ignore(true);
+               duck->set_name("temp");
+
+               // Add the tangent1 duck
+               tduck=new WorkArea::Duck(Vector(0,0));
+               tduck->set_ignore(true);
+               tduck->set_name("ttemp");
+               tduck->set_origin(duck);
+               tduck->set_scalar(-0.33333333333333333);
+
+               tduck->set_tangent(true);
+               bezier->p2=duck;
+               bezier->c2=tduck;
+
+               get_work_area()->add_duck(bezier->p2);
+               //get_work_area()->add_duck(bezier->c2);
+               get_work_area()->add_bezier(bezier);
+
+               duck->set_guid(synfig::GUID());
+               tduck->set_guid(synfig::GUID());
+
+               next_duck=duck;
+       }
+
+       if(!button_down)
+       {
+               if(curr_duck)
+               {
+                       if(next_duck)
+                       {
+                               curr_duck=next_duck;
+                               next_duck=0;
+                       }
+               }
+       }
+       get_work_area()->queue_draw();
+}
+
+
+bool
+StateBLine_Context::on_vertex_change(const synfig::Point &point, synfig::ValueNode_Const::Handle value_node)
+{
+       BLinePoint bline_point(value_node->get_value().get(BLinePoint()));
+       bline_point.set_vertex(point);
+       value_node->set_value(bline_point);
+       //refresh_ducks();
+       return true;
+}
+
+bool
+StateBLine_Context::on_tangent1_change(const synfig::Point &point, synfig::ValueNode_Const::Handle value_node)
+{
+       BLinePoint bline_point(value_node->get_value().get(BLinePoint()));
+       bline_point.set_tangent1(point);
+       value_node->set_value(bline_point);
+       //refresh_ducks();
+       return true;
+}
+
+bool
+StateBLine_Context::on_tangent2_change(const synfig::Point &point, synfig::ValueNode_Const::Handle value_node)
+{
+       BLinePoint bline_point(value_node->get_value().get(BLinePoint()));
+       bline_point.set_tangent2(point);
+       value_node->set_value(bline_point);
+       //refresh_ducks();
+       return true;
+}
+
+void
+StateBLine_Context::loop_bline()
+{
+       loop_=true;
+
+       refresh_ducks(false);
+}
+
+void
+StateBLine_Context::unloop_bline()
+{
+       loop_=false;
+
+       refresh_ducks(false);
+}
+
+void
+StateBLine_Context::popup_vertex_menu(synfig::ValueNode_Const::Handle value_node)
+{
+       menu.items().clear();
+
+       if(loop_)
+       {
+               menu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Unloop BLine"),
+                               sigc::mem_fun(*this,&studio::StateBLine_Context::unloop_bline)
+               ));
+       } else {
+               menu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Loop BLine"),
+                               sigc::mem_fun(*this,&studio::StateBLine_Context::loop_bline)
+               ));
+       }
+
+       menu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Delete Vertex"),
+               sigc::bind(
+                       sigc::mem_fun(*this,&studio::StateBLine_Context::bline_delete_vertex),
+                       value_node
+               )
+       ));
+
+       menu.popup(0,0);
+}
+
+void
+StateBLine_Context::popup_bezier_menu(float location, synfig::ValueNode_Const::Handle value_node)
+{
+       menu.items().clear();
+
+       menu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Insert Vertex"),
+               sigc::bind(
+                       sigc::bind(
+                               sigc::mem_fun(*this,&studio::StateBLine_Context::bline_insert_vertex),
+                               location
+                       ),
+                       value_node
+               )
+       ));
+
+       menu.popup(0,0);
+}
+
+void
+StateBLine_Context::bline_insert_vertex(synfig::ValueNode_Const::Handle value_node, float origin)
+{
+       list<ValueNode_Const::Handle>::iterator iter;
+
+       for(iter=bline_point_list.begin();iter!=bline_point_list.end();++iter)
+               if(*iter==value_node)
+               {
+                       BLinePoint bline_point;
+                       BLinePoint next_bline_point((*iter)->get_value().get(BLinePoint()));
+                       BLinePoint prev_bline_point;
+
+                       list<ValueNode_Const::Handle>::iterator prev(iter);
+                       if(iter==bline_point_list.begin())
+                       {
+                               assert(loop_);
+                               prev = bline_point_list.end();
+                       }
+                       prev--;
+
+                       prev_bline_point=(*prev)->get_value().get(BLinePoint());
+
+                       etl::hermite<Vector> curve(prev_bline_point.get_vertex(),
+                                                                          next_bline_point.get_vertex(),
+                                                                          prev_bline_point.get_tangent2(),
+                                                                          next_bline_point.get_tangent1());
+                       etl::derivative< etl::hermite<Vector> > deriv(curve);
+
+                       bline_point.set_vertex(curve(origin));
+                       bline_point.set_width((next_bline_point.get_width()-prev_bline_point.get_width())*origin+prev_bline_point.get_width());
+                       bline_point.set_tangent1(deriv(origin)*std::min(1.0f-origin,origin));
+                       bline_point.set_tangent2(bline_point.get_tangent1());
+                       bline_point.set_split_tangent_flag(false);
+                       bline_point.set_origin(origin);
+
+/*
+                       bline_point.set_vertex((next_bline_point.get_vertex()+prev_bline_point.get_vertex())*0.5);
+                       bline_point.set_width((next_bline_point.get_width()+prev_bline_point.get_width())*0.5);
+                       bline_point.set_origin(origin);
+                       bline_point.set_split_tangent_flag(false);
+                       bline_point.set_tangent1((next_bline_point.get_vertex()-prev_bline_point.get_vertex())*0.5);
+*/
+
+                       bline_point_list.insert(iter,ValueNode_Const::create(bline_point));
+                       break;
+               }
+
+       if(iter==bline_point_list.end())
+       {
+               get_canvas_view()->get_ui_interface()->error(_("Unable to find where to insert vertex, internal error, please report this bug"));
+       }
+
+       refresh_ducks(false);
+}
+
+void
+StateBLine_Context::bline_delete_vertex(synfig::ValueNode_Const::Handle value_node)
+{
+       list<ValueNode_Const::Handle>::iterator iter;
+
+       for(iter=bline_point_list.begin();iter!=bline_point_list.end();++iter)
+               if(*iter==value_node)
+               {
+                       bline_point_list.erase(iter);
+                       break;
+               }
+       if(iter==bline_point_list.end())
+       {
+               get_canvas_view()->get_ui_interface()->error(_("Unable to remove vertex, internal error, please report this bug"));
+       }
+
+       refresh_ducks(false);
+}
+
+void
+StateBLine_Context::popup_handle_menu(synfig::ValueNode_Const::Handle value_node)
+{
+       menu.items().clear();
+
+       BLinePoint bline_point(value_node->get_value().get(BLinePoint()));
+
+       if(bline_point.get_split_tangent_flag())
+               menu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Merge Tangents"),
+                       sigc::bind(
+                               sigc::mem_fun(*this,&studio::StateBLine_Context::bline_attach_handle),
+                               value_node
+                       )
+               ));
+       else
+               menu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Split Tangents"),
+                       sigc::bind(
+                               sigc::mem_fun(*this,&studio::StateBLine_Context::bline_detach_handle),
+                               value_node
+                       )
+               ));
+
+       menu.popup(0,0);
+}
+
+void
+StateBLine_Context::bline_detach_handle(synfig::ValueNode_Const::Handle value_node)
+{
+       BLinePoint bline_point(value_node->get_value().get(BLinePoint()));
+       bline_point.set_split_tangent_flag(true);
+       bline_point.set_tangent2(bline_point.get_tangent1());
+       value_node->set_value(bline_point);
+       refresh_ducks(false);
+}
+
+void
+StateBLine_Context::bline_attach_handle(synfig::ValueNode_Const::Handle value_node)
+{
+       BLinePoint bline_point(value_node->get_value().get(BLinePoint()));
+       bline_point.set_tangent1((bline_point.get_tangent1()+bline_point.get_tangent2())*0.5);
+       bline_point.set_split_tangent_flag(false);
+       value_node->set_value(bline_point);
+       refresh_ducks(false);
+}
diff --git a/synfig-studio/src/gui/state_bline.h b/synfig-studio/src/gui/state_bline.h
new file mode 100644 (file)
index 0000000..0f3ce0d
--- /dev/null
@@ -0,0 +1,55 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_bline.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_ROTOSCOPE_BLINE_H
+#define __SYNFIG_STUDIO_ROTOSCOPE_BLINE_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 StateBLine_Context;
+
+class StateBLine : public Smach::state<StateBLine_Context>
+{
+public:
+       StateBLine();
+       ~StateBLine();
+}; // END of class StateBLine
+
+extern StateBLine state_bline;
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/state_circle.cpp b/synfig-studio/src/gui/state_circle.cpp
new file mode 100644 (file)
index 0000000..ce155b0
--- /dev/null
@@ -0,0 +1,1066 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_circle.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 <config.h>
+#endif
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/entry.h>
+
+#include <synfig/valuenode_dynamiclist.h>
+#include <synfigapp/action_system.h>
+#include <synfig/valuenode_bline.h>
+
+#include "state_circle.h"
+#include "state_normal.h"
+#include "canvasview.h"
+#include "workarea.h"
+#include "app.h"
+
+#include <synfigapp/action.h>
+#include "event_mouse.h"
+#include "event_layerclick.h"
+#include "toolbox.h"
+#include "dialog_tooloptions.h"
+#include <gtkmm/optionmenu.h>
+#include "duck.h"
+#include "widget_enum.h"
+#include <synfigapp/main.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 ========================================================= */
+enum CircleFalloff
+{
+       CIRCLE_SQUARED  =0,
+       CIRCLE_INTERPOLATION_LINEAR     =1,
+       CIRCLE_COSINE   =2,
+       CIRCLE_SIGMOND  =3,
+       CIRCLE_SQRT             =4,
+       CIRCLE_NUM_FALLOFF
+};
+
+/* === G L O B A L S ======================================================= */
+
+StateCircle studio::state_circle;
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+class studio::StateCircle_Context : public sigc::trackable
+{
+       etl::handle<CanvasView> canvas_view_;
+       CanvasView::IsWorking is_working;
+
+       Duckmatic::Push duckmatic_push;
+
+       Point point_holder;
+
+       etl::handle<Duck> point2_duck;
+
+       void refresh_ducks();
+
+       bool prev_workarea_layer_status_;
+
+       //Toolbox settings
+       synfigapp::Settings& settings;
+
+       //Toolbox display
+       Gtk::Table options_table;
+
+       Gtk::Entry              entry_id; //what to name the layer
+
+       Widget_Enum             enum_falloff;
+#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
+       Widget_Enum             enum_blend;
+#endif // BLEND_METHOD_IN_TOOL_OPTIONS
+
+       Gtk::Adjustment adj_feather;
+       Gtk::Adjustment adj_number_of_bline_points;
+       Gtk::Adjustment adj_bline_point_angle_offset;
+       Gtk::SpinButton spin_feather;
+       Gtk::SpinButton spin_number_of_bline_points;
+       Gtk::SpinButton spin_bline_point_angle_offset;
+
+       Gtk::CheckButton checkbutton_invert;
+       Gtk::CheckButton checkbutton_layer_circle;
+       Gtk::CheckButton checkbutton_layer_region;
+       Gtk::CheckButton checkbutton_layer_outline;
+       Gtk::CheckButton checkbutton_layer_curve_gradient;
+       Gtk::CheckButton checkbutton_layer_plant;
+       Gtk::CheckButton checkbutton_layer_link_origins;
+       Gtk::CheckButton checkbutton_layer_origins_at_center;
+
+public:
+
+       // this only counts the layers which will have their origins linked
+       int layers_to_create()const
+       {
+               return
+                       (get_layer_circle_flag() && get_layer_origins_at_center_flag()) +
+                       get_layer_region_flag() +
+                       get_layer_outline_flag() +
+                       get_layer_curve_gradient_flag() +
+                       get_layer_plant_flag();
+       }
+
+       synfig::String get_id()const { return entry_id.get_text(); }
+       void set_id(const synfig::String& x) { return entry_id.set_text(x); }
+
+       int get_falloff()const { return enum_falloff.get_value(); }
+       void set_falloff(int x) { return enum_falloff.set_value(x); }
+
+#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
+       int get_blend()const { return enum_blend.get_value(); }
+       void set_blend(int x) { return enum_blend.set_value(x); }
+#endif // BLEND_METHOD_IN_TOOL_OPTIONS
+
+       Real get_feather()const { return adj_feather.get_value(); }
+       void set_feather(Real f) { adj_feather.set_value(f); }
+
+       Real get_number_of_bline_points()const { return adj_number_of_bline_points.get_value(); }
+       void set_number_of_bline_points(Real f) { adj_number_of_bline_points.set_value(f); }
+
+       Real get_bline_point_angle_offset()const { return adj_bline_point_angle_offset.get_value(); }
+       void set_bline_point_angle_offset(Real f) { adj_bline_point_angle_offset.set_value(f); }
+
+       bool get_invert()const { return checkbutton_invert.get_active(); }
+       void set_invert(bool i) { checkbutton_invert.set_active(i); }
+
+       bool get_layer_circle_flag()const { return checkbutton_layer_circle.get_active(); }
+       void set_layer_circle_flag(bool x) { return checkbutton_layer_circle.set_active(x); }
+
+       bool get_layer_region_flag()const { return checkbutton_layer_region.get_active(); }
+       void set_layer_region_flag(bool x) { return checkbutton_layer_region.set_active(x); }
+
+       bool get_layer_outline_flag()const { return checkbutton_layer_outline.get_active(); }
+       void set_layer_outline_flag(bool x) { return checkbutton_layer_outline.set_active(x); }
+
+       bool get_layer_curve_gradient_flag()const { return checkbutton_layer_curve_gradient.get_active(); }
+       void set_layer_curve_gradient_flag(bool x) { return checkbutton_layer_curve_gradient.set_active(x); }
+
+       bool get_layer_plant_flag()const { return checkbutton_layer_plant.get_active(); }
+       void set_layer_plant_flag(bool x) { return checkbutton_layer_plant.set_active(x); }
+
+       bool get_layer_link_origins_flag()const { return checkbutton_layer_link_origins.get_active(); }
+       void set_layer_link_origins_flag(bool x) { return checkbutton_layer_link_origins.set_active(x); }
+
+       bool get_layer_origins_at_center_flag()const { return checkbutton_layer_origins_at_center.get_active(); }
+       void set_layer_origins_at_center_flag(bool x) { return checkbutton_layer_origins_at_center.set_active(x); }
+
+       void refresh_tool_options(); //to refresh the toolbox
+
+       //events
+       Smach::event_result event_stop_handler(const Smach::event& x);
+       Smach::event_result event_refresh_handler(const Smach::event& x);
+       Smach::event_result event_mouse_click_handler(const Smach::event& x);
+       Smach::event_result event_refresh_tool_options(const Smach::event& x);
+
+       //constructor destructor
+       StateCircle_Context(CanvasView* canvas_view);
+       ~StateCircle_Context();
+
+       //Canvas interaction
+       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
+       etl::handle<synfigapp::CanvasInterface> 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();}
+
+       //Modifying settings etc.
+       void load_settings();
+       void save_settings();
+       void reset();
+       void increment_id();
+       bool egress_on_selection_change;
+       Smach::event_result event_layer_selection_changed_handler(const Smach::event& /*x*/)
+       {
+               if(egress_on_selection_change)
+                       throw &state_normal; //throw Smach::egress_exception();
+               return Smach::RESULT_OK;
+       }
+
+       void make_circle(const Point& p1, const Point& p2);
+
+};     // END of class StateCircle_Context
+
+/* === M E T H O D S ======================================================= */
+
+StateCircle::StateCircle():
+       Smach::state<StateCircle_Context>("circle")
+{
+       insert(event_def(EVENT_LAYER_SELECTION_CHANGED,&StateCircle_Context::event_layer_selection_changed_handler));
+       insert(event_def(EVENT_STOP,&StateCircle_Context::event_stop_handler));
+       insert(event_def(EVENT_REFRESH,&StateCircle_Context::event_refresh_handler));
+       insert(event_def(EVENT_REFRESH_DUCKS,&StateCircle_Context::event_refresh_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StateCircle_Context::event_mouse_click_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DRAG,&StateCircle_Context::event_mouse_click_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_UP,&StateCircle_Context::event_mouse_click_handler));
+       insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateCircle_Context::event_refresh_tool_options));
+}
+
+StateCircle::~StateCircle()
+{
+}
+
+void
+StateCircle_Context::load_settings()
+{
+       String value;
+
+       //parse the arguments yargh!
+       if(settings.get_value("circle.id",value))
+               set_id(value);
+       else
+               set_id("Circle");
+
+       if(settings.get_value("circle.fallofftype",value) && value != "")
+               set_falloff(atoi(value.c_str()));
+       else
+               set_falloff(2);
+
+#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
+       if(settings.get_value("circle.blend",value) && value != "")
+               set_blend(atoi(value.c_str()));
+       else
+               set_blend(0);//(int)Color::BLEND_COMPOSITE); //0 should be blend composites value
+#endif // BLEND_METHOD_IN_TOOL_OPTIONS
+
+       if(settings.get_value("circle.feather",value))
+               set_feather(atof(value.c_str()));
+       else
+               set_feather(0);
+
+       if(settings.get_value("circle.number_of_bline_points",value))
+               set_number_of_bline_points(atof(value.c_str()));
+       else
+               set_number_of_bline_points(4);
+
+       if(settings.get_value("circle.bline_point_angle_offset",value))
+               set_bline_point_angle_offset(atof(value.c_str()));
+       else
+               set_bline_point_angle_offset(0);
+
+       if(settings.get_value("circle.invert",value) && value != "0")
+               set_invert(true);
+       else
+               set_invert(false);
+
+       if(settings.get_value("circle.layer_circle",value) && value=="0")
+               set_layer_circle_flag(false);
+       else
+               set_layer_circle_flag(true);
+
+       if(settings.get_value("circle.layer_region",value) && value=="1")
+               set_layer_region_flag(true);
+       else
+               set_layer_region_flag(false);
+
+       if(settings.get_value("circle.layer_outline",value) && value=="1")
+               set_layer_outline_flag(true);
+       else
+               set_layer_outline_flag(false);
+
+       if(settings.get_value("circle.layer_curve_gradient",value) && value=="1")
+               set_layer_curve_gradient_flag(true);
+       else
+               set_layer_curve_gradient_flag(false);
+
+       if(settings.get_value("circle.layer_plant",value) && value=="1")
+               set_layer_plant_flag(true);
+       else
+               set_layer_plant_flag(false);
+
+       if(settings.get_value("circle.layer_link_origins",value) && value=="0")
+               set_layer_link_origins_flag(false);
+       else
+               set_layer_link_origins_flag(true);
+
+       if(settings.get_value("circle.layer_origins_at_center",value) && value=="0")
+               set_layer_origins_at_center_flag(false);
+       else
+               set_layer_origins_at_center_flag(true);
+}
+
+void
+StateCircle_Context::save_settings()
+{
+       settings.set_value("circle.id",get_id());
+       settings.set_value("circle.fallofftype",strprintf("%d",get_falloff()));
+#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
+       settings.set_value("circle.blend",strprintf("%d",get_blend()));
+#endif // BLEND_METHOD_IN_TOOL_OPTIONS
+       settings.set_value("circle.feather",strprintf("%f",(float)get_feather()));
+       settings.set_value("circle.number_of_bline_points",strprintf("%d",(int)(get_number_of_bline_points() + 0.5)));
+       settings.set_value("circle.bline_point_angle_offset",strprintf("%f",(float)get_bline_point_angle_offset()));
+       settings.set_value("circle.invert",get_invert()?"1":"0");
+       settings.set_value("circle.layer_circle",get_layer_circle_flag()?"1":"0");
+       settings.set_value("circle.layer_outline",get_layer_outline_flag()?"1":"0");
+       settings.set_value("circle.layer_region",get_layer_region_flag()?"1":"0");
+       settings.set_value("circle.layer_curve_gradient",get_layer_curve_gradient_flag()?"1":"0");
+       settings.set_value("circle.layer_plant",get_layer_plant_flag()?"1":"0");
+       settings.set_value("circle.layer_link_origins",get_layer_link_origins_flag()?"1":"0");
+       settings.set_value("circle.layer_origins_at_center",get_layer_origins_at_center_flag()?"1":"0");
+}
+
+void
+StateCircle_Context::reset()
+{
+       refresh_ducks();
+}
+
+void
+StateCircle_Context::increment_id()
+{
+       String id(get_id());
+       int number=1;
+       int digits=0;
+
+       if(id.empty())
+               id="Circle";
+
+       // If there is a number
+       // already at the end of the
+       // id, then remove it.
+       if(id[id.size()-1]<='9' && id[id.size()-1]>='0')
+       {
+               // figure out how many digits it is
+               for (digits = 0;
+                        (int)id.size()-1 >= digits && id[id.size()-1-digits] <= '9' && id[id.size()-1-digits] >= '0';
+                        digits++)
+                       ;
+
+               String str_number;
+               str_number=String(id,id.size()-digits,id.size());
+               id=String(id,0,id.size()-digits);
+
+               number=atoi(str_number.c_str());
+       }
+       else
+       {
+               number=1;
+               digits=3;
+       }
+
+       number++;
+
+       // Add the number back onto the id
+       {
+               const String format(strprintf("%%0%dd",digits));
+               id+=strprintf(format.c_str(),number);
+       }
+
+       // Set the ID
+       set_id(id);
+}
+
+StateCircle_Context::StateCircle_Context(CanvasView* canvas_view):
+       canvas_view_(canvas_view),
+       is_working(*canvas_view),
+       duckmatic_push(get_work_area()),
+       prev_workarea_layer_status_(get_work_area()->get_allow_layer_clicks()),
+       settings(synfigapp::Main::get_selected_input_device()->settings()),
+       entry_id(),                             //   value lower upper  step page
+       adj_feather(                                    0,    0,    1, 0.01, 0.1),
+       adj_number_of_bline_points(             0,    2,  120, 1   , 1  ),
+       adj_bline_point_angle_offset(   0, -360,  360, 0.1 , 1  ),
+       spin_feather(adj_feather,0.1,3),
+       spin_number_of_bline_points(adj_number_of_bline_points,1,0),
+       spin_bline_point_angle_offset(adj_bline_point_angle_offset,1,1),
+       checkbutton_invert(_("Invert")),
+       checkbutton_layer_circle(_("Create Circle Layer")),
+       checkbutton_layer_region(_("Create Region BLine")),
+       checkbutton_layer_outline(_("Create Outline BLine")),
+       checkbutton_layer_curve_gradient(_("Create Curve Gradient BLine")),
+       checkbutton_layer_plant(_("Create Plant BLine")),
+       checkbutton_layer_link_origins(_("Link Origins")),
+       checkbutton_layer_origins_at_center(_("BLine Origins at Center"))
+{
+       egress_on_selection_change=true;
+
+       // Set up the tool options dialog
+       enum_falloff.set_param_desc(ParamDesc("falloff")
+               .set_local_name(_("Falloff"))
+               .set_description(_("Determines the falloff function for the feather"))
+               .set_hint("enum")
+               .add_enum_value(CIRCLE_INTERPOLATION_LINEAR,"linear",_("Linear"))
+               .add_enum_value(CIRCLE_SQUARED,"squared",_("Squared"))
+               .add_enum_value(CIRCLE_SQRT,"sqrt",_("Square Root"))
+               .add_enum_value(CIRCLE_SIGMOND,"sigmond",_("Sigmond"))
+               .add_enum_value(CIRCLE_COSINE,"cosine",_("Cosine")));
+
+#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
+       enum_blend.set_param_desc(ParamDesc(Color::BLEND_COMPOSITE,"blend_method")
+               .set_local_name(_("Blend Method"))
+               .set_description(_("Defines the blend method to be used for circles")));
+#endif // BLEND_METHOD_IN_TOOL_OPTIONS
+
+       load_settings();
+
+       options_table.attach(*manage(new Gtk::Label(_("Circle Tool"))),         0, 2,  0,  1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(entry_id,                                                                          0, 2,  1,  2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       options_table.attach(checkbutton_layer_circle,                                          0, 2,  2,  3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_outline,                                         0, 2,  3,  4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_region,                                          0, 2,  4,  5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_plant,                                           0, 2,  5,  6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_curve_gradient,                          0, 2,  6,  7, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_link_origins,                            0, 2,  7,  8, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_origins_at_center,                       0, 2,  8,  9, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       //invert flag
+       options_table.attach(checkbutton_invert,                                                0, 2,  9, 10, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       options_table.attach(*manage(new Gtk::Label(_("Falloff:"))),            0, 1, 10, 11, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(enum_falloff,                                      1, 2, 10, 11, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       //feather stuff
+       options_table.attach(*manage(new Gtk::Label(_("Feather:"))),            0, 1, 11, 12, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(spin_feather,                                                              1, 2, 11, 12, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
+       options_table.attach(enum_blend,                                        0, 2, 12, 13, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+#endif // BLEND_METHOD_IN_TOOL_OPTIONS
+
+       options_table.attach(*manage(new Gtk::Label(_("BLine Points:"))),       0, 1, 13, 14, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(spin_number_of_bline_points,                                       1, 2, 13, 14, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+options_table.attach(*manage(new Gtk::Label(_("Point Angle Offset:"))),        0, 1, 14, 15, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(spin_bline_point_angle_offset,                                     1, 2, 14, 15, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       options_table.show_all();
+
+       refresh_tool_options();
+       App::dialog_tool_options->present();
+
+       // Turn off layer clicking
+       get_work_area()->set_allow_layer_clicks(false);
+
+       // clear out the ducks
+       get_work_area()->clear_ducks();
+
+       // Refresh the work area
+       get_work_area()->queue_draw();
+
+       // Hide the tables if they are showing
+       //prev_table_status=get_canvas_view()->tables_are_visible();
+       //if(prev_table_status)get_canvas_view()->hide_tables();
+
+       // Disable the time bar
+       //get_canvas_view()->set_sensitive_timebar(false);
+
+       // Connect a signal
+       //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateCircle_Context::on_user_click));
+       get_work_area()->set_cursor(Gdk::CROSSHAIR);
+
+       App::toolbox->refresh();
+}
+
+void
+StateCircle_Context::refresh_tool_options()
+{
+       App::dialog_tool_options->clear();
+       App::dialog_tool_options->set_widget(options_table);
+       App::dialog_tool_options->set_local_name(_("Circle Tool"));
+       App::dialog_tool_options->set_name("circle");
+}
+
+Smach::event_result
+StateCircle_Context::event_refresh_tool_options(const Smach::event& /*x*/)
+{
+       refresh_tool_options();
+       return Smach::RESULT_ACCEPT;
+}
+
+StateCircle_Context::~StateCircle_Context()
+{
+       save_settings();
+
+       // Restore layer clicking
+       get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_);
+       get_work_area()->reset_cursor();
+
+       App::dialog_tool_options->clear();
+
+       // Enable the time bar
+       //get_canvas_view()->set_sensitive_timebar(true);
+
+       // Bring back the tables if they were out before
+       //if(prev_table_status)get_canvas_view()->show_tables();
+
+       // Refresh the work area
+       get_work_area()->queue_draw();
+
+       get_canvas_view()->queue_rebuild_ducks();
+
+       App::toolbox->refresh();
+}
+
+Smach::event_result
+StateCircle_Context::event_stop_handler(const Smach::event& /*x*/)
+{
+       //throw Smach::egress_exception();
+       throw &state_normal;
+       return Smach::RESULT_OK;
+}
+
+Smach::event_result
+StateCircle_Context::event_refresh_handler(const Smach::event& /*x*/)
+{
+       refresh_ducks();
+       return Smach::RESULT_ACCEPT;
+}
+
+void
+StateCircle_Context::make_circle(const Point& _p1, const Point& _p2)
+{
+       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("New Circle"));
+       synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+       Layer::Handle layer;
+
+       Canvas::Handle canvas;
+       int depth(0);
+
+       // we are temporarily using the layer to hold something
+       layer=get_canvas_view()->get_selection_manager()->get_selected_layer();
+       if(layer)
+       {
+               depth=layer->get_depth();
+               canvas=layer->get_canvas();
+       }
+
+       synfigapp::SelectionManager::LayerList layer_selection;
+       if (!getenv("SYNFIG_TOOLS_CLEAR_SELECTION"))
+               layer_selection = get_canvas_view()->get_selection_manager()->get_selected_layers();
+
+       const synfig::TransformStack& transform(get_canvas_view()->get_curr_transform_stack());
+       const Point p1(transform.unperform(_p1));
+       const Point p2(transform.unperform(_p2));
+
+       Real radius((p2-p1).mag());
+       int points = get_number_of_bline_points();
+       Angle::deg offset(get_bline_point_angle_offset());
+       Angle::deg angle(360.0/points);
+       Real tangent(4 * ((points == 2)
+                                         ? 1
+                                         : ((2 * Angle::cos(angle/2).get() - Angle::cos(angle).get() - 1) / Angle::sin(angle).get())));
+       Vector origin;
+       Real x, y;
+
+       if (get_layer_origins_at_center_flag())
+       {
+               x = y = 0;
+               origin = p1;
+       }
+       else
+       {
+               x = p1[0];
+               y = p1[1];
+       }
+
+       std::vector<BLinePoint> new_list;
+       for (int i = 0; i < points; i++)
+       {
+               new_list.push_back(*(new BLinePoint));
+               new_list[i].set_width(1);
+               new_list[i].set_vertex(Point(radius*Angle::cos(angle*i + offset).get() + x,
+                                                                        radius*Angle::sin(angle*i + offset).get() + y));
+               new_list[i].set_tangent(Point(-radius*tangent*Angle::sin(angle*i + offset).get(),
+                                                                          radius*tangent*Angle::cos(angle*i + offset).get()));
+       }
+
+       ValueNode_BLine::Handle value_node_bline(ValueNode_BLine::create(new_list));
+       assert(value_node_bline);
+
+       ValueNode_Const::Handle value_node_origin(ValueNode_Const::create(origin));
+       assert(value_node_origin);
+
+       // Set the looping flag
+       value_node_bline->set_loop(true);
+
+       if(!canvas)
+               canvas=get_canvas_view()->get_canvas();
+
+       value_node_bline->set_member_canvas(canvas);
+
+       // count how many layers we're going to be creating
+       int layers_to_create = this->layers_to_create();
+
+       ///////////////////////////////////////////////////////////////////////////
+       //   C I R C L E
+       ///////////////////////////////////////////////////////////////////////////
+
+       if (get_layer_circle_flag() &&
+               get_falloff() >= 0 && get_falloff() < CIRCLE_NUM_FALLOFF)
+       {
+               layer=get_canvas_interface()->add_layer_to("circle",canvas,depth);
+               if (!layer)
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                       group.cancel();
+                       return;
+               }
+               layer_selection.push_back(layer);
+
+               layer->set_param("radius",(p2-p1).mag());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"radius");
+
+               layer->set_param("falloff",get_falloff());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"falloff");
+
+               layer->set_param("feather",get_feather());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
+
+               layer->set_param("invert",get_invert());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
+
+#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
+               layer->set_param("blend_method",get_blend());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"blend_method");
+#endif // BLEND_METHOD_IN_TOOL_OPTIONS
+
+               layer->set_description(get_id());
+               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+               // only link the circle's origin parameter if the option is selected, we're putting bline
+               // origins at their centers, and we're creating more than one layer
+               if (get_layer_link_origins_flag() && get_layer_origins_at_center_flag() && layers_to_create > 1)
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("origin")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create Circle layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Circle layer"));
+                               return;
+                       }
+               }
+               else
+               {
+                       layer->set_param("origin",p1);
+                       get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
+               }
+       }
+
+       ///////////////////////////////////////////////////////////////////////////
+       //   C U R V E   G R A D I E N T
+       ///////////////////////////////////////////////////////////////////////////
+
+       if(get_layer_curve_gradient_flag())
+       {
+               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+               Layer::Handle layer(get_canvas_interface()->add_layer_to("curve_gradient",canvas,depth));
+               if (!layer)
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                       group.cancel();
+                       return;
+               }
+               layer_selection.push_back(layer);
+               layer->set_description(get_id()+_(" Gradient"));
+               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
+               layer->set_param("blend_method",get_blend());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"blend_method");
+#endif // BLEND_METHOD_IN_TOOL_OPTIONS
+
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("bline")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Gradient layer"));
+                               return;
+                       }
+               }
+
+               // only link the curve gradient's origin parameter if the option is selected and we're creating more than one layer
+               if (get_layer_link_origins_flag() && layers_to_create > 1)
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("origin")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Gradient layer"));
+                               return;
+                       }
+               }
+               else
+               {
+                       layer->set_param("origin",origin);
+                       get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
+               }
+       }
+
+       ///////////////////////////////////////////////////////////////////////////
+       //   P L A N T
+       ///////////////////////////////////////////////////////////////////////////
+
+       if(get_layer_plant_flag())
+       {
+               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+               Layer::Handle layer(get_canvas_interface()->add_layer_to("plant",canvas,depth));
+               if (!layer)
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                       group.cancel();
+                       return;
+               }
+               layer_selection.push_back(layer);
+               layer->set_description(get_id()+_(" Plant"));
+               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
+               layer->set_param("blend_method",get_blend());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"blend_method");
+#endif // BLEND_METHOD_IN_TOOL_OPTIONS
+
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("bline")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Plant layer"));
+                               return;
+                       }
+               }
+
+               // only link the plant's origin parameter if the option is selected and we're creating more than one layer
+               if (get_layer_link_origins_flag() && layers_to_create > 1)
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("origin")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Plant layer"));
+                               return;
+                       }
+               }
+               else
+               {
+                       layer->set_param("origin",origin);
+                       get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
+               }
+       }
+
+       ///////////////////////////////////////////////////////////////////////////
+       //   R E G I O N
+       ///////////////////////////////////////////////////////////////////////////
+
+       if(get_layer_region_flag())
+       {
+               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+               Layer::Handle layer(get_canvas_interface()->add_layer_to("region",canvas,depth));
+               if (!layer)
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                       group.cancel();
+                       return;
+               }
+               layer_selection.push_back(layer);
+               layer->set_description(get_id()+_(" Region"));
+               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
+               layer->set_param("blend_method",get_blend());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"blend_method");
+#endif // BLEND_METHOD_IN_TOOL_OPTIONS
+
+               layer->set_param("feather",get_feather());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
+
+               layer->set_param("invert",get_invert());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
+
+               // I don't know if it's safe to reuse the same LayerParamConnect action, so I'm
+               // using 2 separate ones.
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("bline")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Region layer"));
+                               return;
+                       }
+               }
+
+               // only link the region's origin parameter if the option is selected and we're creating more than one layer
+               if (get_layer_link_origins_flag() && layers_to_create > 1)
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("origin")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Region layer"));
+                               return;
+                       }
+               }
+               else
+               {
+                       layer->set_param("origin",origin);
+                       get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
+               }
+       }
+
+       ///////////////////////////////////////////////////////////////////////////
+       //   O U T L I N E
+       ///////////////////////////////////////////////////////////////////////////
+
+       if (get_layer_outline_flag())
+       {
+               Layer::Handle layer(get_canvas_interface()->add_layer_to("outline",canvas,depth));
+               if (!layer)
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                       group.cancel();
+                       return;
+               }
+               layer_selection.push_back(layer);
+               layer->set_description(get_id()+_(" Outline"));
+               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
+               layer->set_param("blend_method",get_blend());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"blend_method");
+#endif // BLEND_METHOD_IN_TOOL_OPTIONS
+
+               layer->set_param("feather",get_feather());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
+
+               layer->set_param("invert",get_invert());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
+
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("bline")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Outline layer"));
+                               return;
+                       }
+               }
+
+               // only link the outline's origin parameter if the option is selected and we're creating more than one layer
+               if (get_layer_link_origins_flag() && layers_to_create > 1)
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("origin")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Outline layer"));
+                               return;
+                       }
+               }
+               else
+               {
+                       layer->set_param("origin",origin);
+                       get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
+               }
+       }
+
+       egress_on_selection_change=false;
+       get_canvas_interface()->get_selection_manager()->clear_selected_layers();
+       get_canvas_interface()->get_selection_manager()->set_selected_layers(layer_selection);
+       egress_on_selection_change=true;
+
+       reset();
+       increment_id();
+}
+
+Smach::event_result
+StateCircle_Context::event_mouse_click_handler(const Smach::event& x)
+{
+       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
+
+       if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_DOWN && event.button==BUTTON_LEFT)
+       {
+               point_holder=get_work_area()->snap_point_to_grid(event.pos);
+               etl::handle<Duck> duck=new Duck();
+               duck->set_point(point_holder);
+               duck->set_name("p1");
+               duck->set_type(Duck::TYPE_POSITION);
+               duck->set_editable(false);
+               get_work_area()->add_duck(duck);
+
+               point2_duck=new Duck();
+               point2_duck->set_point(Vector(0,0));
+               point2_duck->set_name("radius");
+               point2_duck->set_origin(duck);
+               point2_duck->set_radius(true);
+               point2_duck->set_scalar(-1);
+               point2_duck->set_type(Duck::TYPE_RADIUS);
+               point2_duck->set_hover(true);
+               get_work_area()->add_duck(point2_duck);
+
+               return Smach::RESULT_ACCEPT;
+       }
+
+       if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_DRAG && event.button==BUTTON_LEFT)
+       {
+               if (!point2_duck) return Smach::RESULT_OK;
+               point2_duck->set_point(point_holder-get_work_area()->snap_point_to_grid(event.pos));
+               get_work_area()->queue_draw();
+               return Smach::RESULT_ACCEPT;
+       }
+
+       if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_UP && event.button==BUTTON_LEFT)
+       {
+               Point point(get_work_area()->snap_point_to_grid(event.pos));
+
+               if (App::restrict_radius_ducks)
+               {
+                       if ((point[0] - point_holder[0]) < 0) point[0] = point_holder[0];
+                       if ((point[1] - point_holder[1]) < 0) point[1] = point_holder[1];
+               }
+
+               make_circle(point_holder, point);
+               get_work_area()->clear_ducks();
+               return Smach::RESULT_ACCEPT;
+       }
+
+       return Smach::RESULT_OK;
+}
+
+
+void
+StateCircle_Context::refresh_ducks()
+{
+       get_work_area()->clear_ducks();
+       get_work_area()->queue_draw();
+}
diff --git a/synfig-studio/src/gui/state_circle.h b/synfig-studio/src/gui/state_circle.h
new file mode 100644 (file)
index 0000000..b33ccf3
--- /dev/null
@@ -0,0 +1,56 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_circle.h
+**     \brief Circle creation state
+**
+**     $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_CIRCLE_H
+#define __SYNFIG_STUDIO_STATE_CIRCLE_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 StateCircle_Context;
+
+class StateCircle : public Smach::state<StateCircle_Context>
+{
+public:
+       StateCircle();
+       ~StateCircle();
+}; // END of class StateCircle
+
+extern StateCircle state_circle;
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/state_draw.cpp b/synfig-studio/src/gui/state_draw.cpp
new file mode 100644 (file)
index 0000000..4482045
--- /dev/null
@@ -0,0 +1,2036 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_draw.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007 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 <config.h>
+#endif
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/entry.h>
+
+#include <synfig/valuenode_dynamiclist.h>
+
+#include "state_draw.h"
+#include "state_stroke.h"
+#include "state_normal.h"
+#include "canvasview.h"
+#include "workarea.h"
+#include "app.h"
+#include <synfig/valuenode_bline.h>
+#include <synfig/valuenode_composite.h>
+#include <ETL/hermite>
+#include <ETL/calculus>
+#include <utility>
+#include "event_mouse.h"
+#include "event_layerclick.h"
+#include "toolbox.h"
+
+#include <synfigapp/blineconvert.h>
+#include <synfigapp/main.h>
+
+#include <ETL/gaussian>
+#include "dialog_tooloptions.h"
+
+#include <gtkmm/table.h>
+#include <gtkmm/label.h>
+#include <gtkmm/button.h>
+#include <gtkmm/checkbutton.h>
+#include <gtkmm/scale.h>
+#include <sigc++/connection.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 ======================================================= */
+
+StateDraw studio::state_draw;
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+class studio::StateDraw_Context : public sigc::trackable
+{
+       typedef etl::smart_ptr<std::list<synfig::Point> > StrokeData;
+       typedef etl::smart_ptr<std::list<synfig::Real> > WidthData;
+
+       typedef list< pair<StrokeData,WidthData> > StrokeQueue;
+
+       StrokeQueue stroke_queue;
+
+
+       etl::handle<CanvasView> canvas_view_;
+       CanvasView::IsWorking is_working;
+
+       bool prev_table_status;
+       bool loop_;
+       bool prev_workarea_layer_status_;
+
+       int nested;
+       sigc::connection process_queue_connection;
+
+       ValueNode_BLine::Handle last_stroke;
+       synfig::String last_stroke_id;
+
+       Gtk::Menu menu;
+
+       //Duckmatic::Push duckmatic_push;
+
+       std::list< etl::smart_ptr<std::list<synfig::Point> > > stroke_list;
+
+       void refresh_ducks();
+
+       Duckmatic::Type old_duckmask;
+
+       void fill_last_stroke();
+       Smach::event_result fill_last_stroke_and_unselect_other_layers();
+
+       Smach::event_result new_bline(std::list<synfig::BLinePoint> bline,bool loop_bline_flag,float radius);
+
+       Smach::event_result new_region(std::list<synfig::BLinePoint> bline,synfig::Real radius);
+
+       Smach::event_result extend_bline_from_begin(ValueNode_BLine::Handle value_node,std::list<synfig::BLinePoint> bline,bool complete_loop);
+       Smach::event_result extend_bline_from_end(ValueNode_BLine::Handle value_node,std::list<synfig::BLinePoint> bline,bool complete_loop);
+       void reverse_bline(std::list<synfig::BLinePoint> &bline);
+
+       synfigapp::Settings& settings;
+
+       Gtk::Table options_table;
+       Gtk::Entry entry_id;
+       Gtk::CheckButton checkbutton_pressure_width;
+       Gtk::CheckButton checkbutton_round_ends;
+       Gtk::CheckButton checkbutton_auto_loop;   // whether to loop new strokes which start and end in the same place
+       Gtk::CheckButton checkbutton_auto_extend; // whether to extend existing lines
+       Gtk::CheckButton checkbutton_auto_link;   // whether to link new ducks to existing ducks
+       Gtk::CheckButton checkbutton_region;      // whether to create regions
+       Gtk::CheckButton checkbutton_outline;     // whether to create outlines
+       Gtk::CheckButton checkbutton_auto_export;
+       Gtk::Button button_fill_last_stroke;
+
+       //pressure spinner and such
+       Gtk::Adjustment  adj_min_pressure;
+       Gtk::SpinButton  spin_min_pressure;
+       Gtk::CheckButton check_min_pressure;
+
+       Gtk::Adjustment  adj_feather;
+       Gtk::SpinButton  spin_feather;
+
+       Gtk::Adjustment  adj_globalthres;
+       Gtk::SpinButton  spin_globalthres;
+
+       Gtk::Adjustment  adj_localthres;
+       Gtk::CheckButton check_localerror;
+       void UpdateErrorBox();  //switches the stuff if need be :)
+
+       //Added by Adrian - data drive HOOOOO
+       synfigapp::BLineConverter blineconv;
+
+public:
+       synfig::String get_id()const { return entry_id.get_text(); }
+       void set_id(const synfig::String& x) { return entry_id.set_text(x); }
+
+       bool get_pressure_width_flag()const { return checkbutton_pressure_width.get_active(); }
+       void set_pressure_width_flag(bool x) { return checkbutton_pressure_width.set_active(x); }
+
+       bool get_auto_loop_flag()const { return checkbutton_auto_loop.get_active(); }
+       void set_auto_loop_flag(bool x) { return checkbutton_auto_loop.set_active(x); }
+
+       bool get_auto_extend_flag()const { return checkbutton_auto_extend.get_active(); }
+       void set_auto_extend_flag(bool x) { return checkbutton_auto_extend.set_active(x); }
+
+       bool get_auto_link_flag()const { return checkbutton_auto_link.get_active(); }
+       void set_auto_link_flag(bool x) { return checkbutton_auto_link.set_active(x); }
+
+       bool get_region_flag()const { return checkbutton_region.get_active(); }
+       void set_region_flag(bool x) { return checkbutton_region.set_active(x); }
+
+       bool get_outline_flag()const { return checkbutton_outline.get_active(); }
+       void set_outline_flag(bool x) { return checkbutton_outline.set_active(x); }
+
+       bool get_auto_export_flag()const { return checkbutton_auto_export.get_active(); }
+       void set_auto_export_flag(bool x) { return checkbutton_auto_export.set_active(x); }
+
+       Real get_min_pressure() const { return adj_min_pressure.get_value(); }
+       void set_min_pressure(Real x) { return adj_min_pressure.set_value(x); }
+
+       Real get_feather() const { return adj_feather.get_value(); }
+       void set_feather(Real x) { return adj_feather.set_value(x); }
+
+       Real get_gthres() const { return adj_globalthres.get_value(); }
+       void set_gthres(Real x) { return adj_globalthres.set_value(x); }
+
+       Real get_lthres() const { return adj_localthres.get_value(); }
+       void set_lthres(Real x) { return adj_localthres.set_value(x); }
+
+       bool get_local_error_flag() const { return check_localerror.get_active(); }
+       void set_local_error_flag(bool x) { check_localerror.set_active(x); }
+
+       bool get_min_pressure_flag()const { return check_min_pressure.get_active(); }
+       void set_min_pressure_flag(bool x) { check_min_pressure.set_active(x); }
+
+       void load_settings();
+       void save_settings();
+       void increment_id();
+
+       Smach::event_result event_stop_handler(const Smach::event& x);
+
+       Smach::event_result event_refresh_handler(const Smach::event& x);
+
+       Smach::event_result event_mouse_down_handler(const Smach::event& x);
+
+       Smach::event_result event_stroke(const Smach::event& x);
+       Smach::event_result event_refresh_tool_options(const Smach::event& x);
+       void refresh_tool_options();
+
+       Smach::event_result process_stroke(StrokeData stroke_data, WidthData width_data, bool region_flag=false);
+
+       bool process_queue();
+
+
+       StateDraw_Context(CanvasView* canvas_view);
+
+       ~StateDraw_Context();
+
+       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
+       etl::handle<synfigapp::CanvasInterface> get_canvas_interface()const{return canvas_view_->canvas_interface();}
+       synfig::Time get_time()const { return get_canvas_interface()->get_time(); }
+       synfig::Canvas::Handle get_canvas()const{return canvas_view_->get_canvas();}
+       WorkArea * get_work_area()const{return canvas_view_->get_work_area();}
+
+       //void on_user_click(synfig::Point point);
+
+//     bool run();
+};     // END of class StateDraw_Context
+
+
+/* === M E T H O D S ======================================================= */
+
+StateDraw::StateDraw():
+       Smach::state<StateDraw_Context>("draw")
+{
+       insert(event_def(EVENT_STOP,&StateDraw_Context::event_stop_handler));
+       insert(event_def(EVENT_REFRESH,&StateDraw_Context::event_refresh_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StateDraw_Context::event_mouse_down_handler));
+       insert(event_def(EVENT_WORKAREA_STROKE,&StateDraw_Context::event_stroke));
+       insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateDraw_Context::event_refresh_tool_options));
+}
+
+StateDraw::~StateDraw()
+{
+}
+
+
+void
+StateDraw_Context::load_settings()
+{
+       String value;
+
+       if(settings.get_value("draw.id",value))
+               set_id(value);
+       else
+               set_id("NewDrawing");
+
+       if(settings.get_value("draw.pressure_width",value) && value=="0")
+               set_pressure_width_flag(false);
+       else
+               set_pressure_width_flag(true);
+
+       if(settings.get_value("draw.auto_loop",value) && value=="0")
+               set_auto_loop_flag(false);
+       else
+               set_auto_loop_flag(true);
+
+       if(settings.get_value("draw.auto_extend",value) && value=="0")
+               set_auto_extend_flag(false);
+       else
+               set_auto_extend_flag(true);
+
+       if(settings.get_value("draw.auto_link",value) && value=="0")
+               set_auto_link_flag(false);
+       else
+               set_auto_link_flag(true);
+
+       if(settings.get_value("draw.region",value) && value=="0")
+               set_region_flag(false);
+       else
+               set_region_flag(true);
+
+       if(settings.get_value("draw.outline",value) && value=="0")
+               set_outline_flag(false);
+       else
+               set_outline_flag(true);
+
+       if(settings.get_value("draw.auto_export",value) && value=="1")
+               set_auto_export_flag(true);
+       else
+               set_auto_export_flag(false);
+
+       if(settings.get_value("draw.min_pressure_on",value) && value=="0")
+               set_min_pressure_flag(false);
+       else
+               set_min_pressure_flag(true);
+
+       if(settings.get_value("draw.min_pressure",value))
+       {
+               Real n = atof(value.c_str());
+               set_min_pressure(n);
+       }else
+               set_min_pressure(0);
+
+       if(settings.get_value("draw.feather",value))
+       {
+               Real n = atof(value.c_str());
+               set_feather(n);
+       }else
+               set_feather(0);
+
+       if(settings.get_value("draw.gthreshold",value))
+       {
+               Real n = atof(value.c_str());
+               set_gthres(n);
+       }
+
+       if(settings.get_value("draw.lthreshold",value))
+       {
+               Real n = atof(value.c_str());
+               set_lthres(n);
+       }
+
+       if(settings.get_value("draw.localize",value) && value == "1")
+               set_local_error_flag(true);
+       else
+               set_local_error_flag(false);
+}
+
+void
+StateDraw_Context::save_settings()
+{
+       settings.set_value("draw.id",get_id().c_str());
+       settings.set_value("draw.pressure_width",get_pressure_width_flag()?"1":"0");
+       settings.set_value("draw.auto_loop",get_auto_loop_flag()?"1":"0");
+       settings.set_value("draw.auto_extend",get_auto_extend_flag()?"1":"0");
+       settings.set_value("draw.auto_link",get_auto_link_flag()?"1":"0");
+       settings.set_value("draw.region",get_region_flag()?"1":"0");
+       settings.set_value("draw.outline",get_outline_flag()?"1":"0");
+       settings.set_value("draw.auto_export",get_auto_export_flag()?"1":"0");
+       settings.set_value("draw.min_pressure",strprintf("%f",get_min_pressure()));
+       settings.set_value("draw.feather",strprintf("%f",get_feather()));
+       settings.set_value("draw.min_pressure_on",get_min_pressure_flag()?"1":"0");
+       settings.set_value("draw.gthreshold",strprintf("%f",get_gthres()));
+       settings.set_value("draw.lthreshold",strprintf("%f",get_lthres()));
+       settings.set_value("draw.localize",get_local_error_flag()?"1":"0");
+}
+
+void
+StateDraw_Context::increment_id()
+{
+       String id(get_id());
+       int number=1;
+       int digits=0;
+
+       if(id.empty())
+               id="Drawing";
+
+       // If there is a number
+       // already at the end of the
+       // id, then remove it.
+       if(id[id.size()-1]<='9' && id[id.size()-1]>='0')
+       {
+               // figure out how many digits it is
+               for (digits = 0;
+                        (int)id.size()-1 >= digits && id[id.size()-1-digits] <= '9' && id[id.size()-1-digits] >= '0';
+                        digits++)
+                       ;
+
+               String str_number;
+               str_number=String(id,id.size()-digits,id.size());
+               id=String(id,0,id.size()-digits);
+               // synfig::info("---------------- \"%s\"",str_number.c_str());
+
+               number=atoi(str_number.c_str());
+       }
+       else
+       {
+               number=1;
+               digits=3;
+       }
+
+       number++;
+
+       // Add the number back onto the id
+       {
+               const String format(strprintf("%%0%dd",digits));
+               id+=strprintf(format.c_str(),number);
+       }
+
+       // Set the ID
+       set_id(id);
+}
+
+StateDraw_Context::StateDraw_Context(CanvasView* canvas_view):
+       canvas_view_(canvas_view),
+       is_working(*canvas_view),
+       loop_(false),
+       prev_workarea_layer_status_(get_work_area()->get_allow_layer_clicks()),
+       settings(synfigapp::Main::get_selected_input_device()->settings()),
+       entry_id(),
+       checkbutton_pressure_width(_("Pressure Width")),
+       checkbutton_auto_loop(_("Auto Loop")),
+       checkbutton_auto_extend(_("Auto Extend")),
+       checkbutton_auto_link(_("Auto Link")),
+       checkbutton_region(_("Create Region BLine")),
+       checkbutton_outline(_("Create Outline BLine")),
+       checkbutton_auto_export(_("Auto Export")),
+       button_fill_last_stroke(_("Fill Last Stroke")),
+       adj_min_pressure(0,0,1,0.01,0.1),
+       spin_min_pressure(adj_min_pressure,0.1,3),
+       check_min_pressure(_("Min Pressure")),
+       adj_feather(0,0,10000,0.01,0.1),
+       spin_feather(adj_feather,0.01,4),
+       adj_globalthres(.70f,0.01,10000,0.01,0.1),
+       spin_globalthres(adj_globalthres,0.01,3),
+       adj_localthres(20,1,100000,0.1,1),
+       check_localerror(_("LocalError"))
+
+{
+       nested=0;
+       load_settings();
+
+       UpdateErrorBox();
+
+       options_table.attach(*manage(new Gtk::Label(_("Draw Tool"))),   0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(entry_id,                                                                  0, 2,  1,  2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_outline,                                               0, 2,  2,  3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_region,                                                0, 2,  3,  4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_auto_loop,                                             0, 2,  4,  5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_auto_extend,                                   0, 2,  5,  6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_auto_link,                                             0, 2,  6,  7, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_auto_export,                                   0, 2,  7,  8, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_pressure_width,                                0, 2,  8,  9, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(check_localerror,                                                  0, 2,  9, 10, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       options_table.attach(check_min_pressure,                                                0, 1, 10, 11, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(spin_min_pressure,                                                 1, 2, 10, 11, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       options_table.attach(*manage(new Gtk::Label(_("Smooth"))),              0, 1, 11, 12, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(spin_globalthres,                                                  1, 2, 11, 12, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       options_table.attach(*manage(new Gtk::Label(_("Feather"))),     0, 1, 12, 13, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(spin_feather,                                                              1, 2, 12, 13, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       //options_table.attach(button_fill_last_stroke, 0, 2, 13, 14, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       button_fill_last_stroke.signal_pressed().connect(sigc::mem_fun(*this,&StateDraw_Context::fill_last_stroke));
+       check_localerror.signal_toggled().connect(sigc::mem_fun(*this,&StateDraw_Context::UpdateErrorBox));
+
+       options_table.show_all();
+       refresh_tool_options();
+       //App::dialog_tool_options->set_widget(options_table);
+       App::dialog_tool_options->present();
+
+
+       old_duckmask=get_work_area()->get_type_mask();
+       get_work_area()->set_type_mask(Duck::TYPE_ALL-Duck::TYPE_TANGENT-Duck::TYPE_WIDTH);
+
+       // Turn off layer clicking
+       get_work_area()->set_allow_layer_clicks(false);
+
+       // Turn off duck clicking
+       get_work_area()->set_allow_duck_clicks(false);
+
+       // clear out the ducks
+       //get_work_area()->clear_ducks();
+
+       // Refresh the work area
+       //get_work_area()->queue_draw();
+
+       // Hide the tables if they are showing
+       prev_table_status=get_canvas_view()->tables_are_visible();
+       //if(prev_table_status)get_canvas_view()->hide_tables();
+
+       // Disable the time bar
+       get_canvas_view()->set_sensitive_timebar(false);
+
+       // Connect a signal
+       //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateDraw_Context::on_user_click));
+
+       get_work_area()->set_cursor(Gdk::PENCIL);
+
+       App::toolbox->refresh();
+
+       refresh_ducks();
+}
+
+
+void StateDraw_Context::UpdateErrorBox()
+{
+       if(get_local_error_flag())
+       {
+               spin_globalthres.set_adjustment(adj_localthres);
+               spin_globalthres.set_value(adj_localthres.get_value());
+               spin_globalthres.set_increments(0.1,1);
+       }else
+       {
+               spin_globalthres.set_adjustment(adj_globalthres);
+               spin_globalthres.set_value(adj_globalthres.get_value());
+               spin_globalthres.set_increments(0.01,.1);
+       }
+
+       spin_globalthres.update();
+}
+
+void
+StateDraw_Context::refresh_tool_options()
+{
+       App::dialog_tool_options->clear();
+       App::dialog_tool_options->set_widget(options_table);
+       App::dialog_tool_options->set_local_name(_("Draw Tool"));
+       App::dialog_tool_options->set_name("draw");
+
+       App::dialog_tool_options->add_button(
+               Gtk::StockID("synfig-fill"),
+               _("Fill Last Stroke")
+       )->signal_clicked().connect(
+               sigc::mem_fun(
+                       *this,
+                       &StateDraw_Context::fill_last_stroke));
+}
+
+Smach::event_result
+StateDraw_Context::event_refresh_tool_options(const Smach::event& /*x*/)
+{
+       refresh_tool_options();
+       return Smach::RESULT_ACCEPT;
+}
+
+StateDraw_Context::~StateDraw_Context()
+{
+       save_settings();
+
+       App::dialog_tool_options->clear();
+
+       get_work_area()->set_type_mask(old_duckmask);
+
+       get_work_area()->reset_cursor();
+
+       // Restore layer clicking
+       get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_);
+
+       // Restore duck clicking
+       get_work_area()->set_allow_duck_clicks(true);
+
+       // Enable the time bar
+       get_canvas_view()->set_sensitive_timebar(true);
+
+       // Bring back the tables if they were out before
+       if(prev_table_status)get_canvas_view()->show_tables();
+
+       // Refresh the work area
+       get_work_area()->queue_draw();
+
+       App::toolbox->refresh();
+}
+
+Smach::event_result
+StateDraw_Context::event_stop_handler(const Smach::event& /*x*/)
+{
+       //throw Smach::egress_exception();
+       throw &state_normal;
+       return Smach::RESULT_OK;
+}
+
+Smach::event_result
+StateDraw_Context::event_refresh_handler(const Smach::event& /*x*/)
+{
+       refresh_ducks();
+       return Smach::RESULT_ACCEPT;
+}
+
+Smach::event_result
+StateDraw_Context::event_mouse_down_handler(const Smach::event& x)
+{
+       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
+       switch(event.button)
+       {
+       case BUTTON_LEFT:
+               {
+                       // Enter the stroke state to get the stroke
+                       get_canvas_view()->get_smach().push_state(&state_stroke);
+                       return Smach::RESULT_ACCEPT;
+               }
+
+       default:
+               return Smach::RESULT_OK;
+       }
+}
+
+#define SIMILAR_TANGENT_THRESHOLD      (0.2)
+
+struct debugclass
+{
+       synfig::String x;
+       debugclass(const synfig::String &x):x(x)
+       {
+//             synfig::warning(">>>>>>>>>>>>>>>>>>> "+x);
+       }
+       ~debugclass()
+       {
+//             synfig::warning("<<<<<<<<<<<<<<<<<<< "+x);
+       }
+};
+
+struct DepthCounter
+{
+       int &i;
+       DepthCounter(int &i):i(i) { i++; }
+       ~DepthCounter() { i--; }
+};
+
+Smach::event_result
+StateDraw_Context::event_stroke(const Smach::event& x)
+{
+//     debugclass debugger("StateDraw_Context::event_stroke(const Smach::event& x)");
+
+       const EventStroke& event(*reinterpret_cast<const EventStroke*>(&x));
+
+       assert(event.stroke_data);
+
+       get_work_area()->add_stroke(event.stroke_data,synfigapp::Main::get_outline_color());
+
+       if(nested==0)
+       {
+               DirtyTrap dirty_trap(get_work_area());
+               Smach::event_result result;
+               result=process_stroke(event.stroke_data,event.width_data,event.modifier&Gdk::CONTROL_MASK || event.modifier&Gdk::BUTTON2_MASK);
+               process_queue();
+               return result;
+       }
+
+       stroke_queue.push_back(pair<StrokeData,WidthData>(event.stroke_data,event.width_data));
+
+       return Smach::RESULT_ACCEPT;
+}
+
+bool
+StateDraw_Context::process_queue()
+{
+//     debugclass debugger("StateDraw_Context::process_queue()");
+       if(nested)
+               return true;
+       DepthCounter depth_counter(nested);
+       while(!stroke_queue.empty())
+       {
+               pair<StrokeData,WidthData> front(stroke_queue.front());
+               process_stroke(front.first,front.second);
+               stroke_queue.pop_front();
+       }
+       return false;
+}
+
+Smach::event_result
+StateDraw_Context::process_stroke(StrokeData stroke_data, WidthData width_data, bool region_flag)
+{
+//     debugclass debugger("StateDraw_Context::process_stroke");
+       DepthCounter depth_counter(nested);
+
+       const float radius(synfigapp::Main::get_bline_width().units(get_canvas()->rend_desc())+(abs(get_work_area()->get_pw())+abs(get_work_area()->get_ph()))*5);
+
+
+       // If we aren't using pressure width,
+       // then set all the width to 1
+       if(!get_pressure_width_flag())
+       {
+               std::list<synfig::Real>::iterator iter;
+               for(iter=width_data->begin();iter!=width_data->end();++iter)
+               {
+                       *iter=1.0;
+               }
+       }
+
+       //get_work_area()->add_stroke(event.stroke_data,synfigapp::Main::get_outline_color());
+       //stroke_list.push_back(event.stroke_data);
+       //refresh_ducks();
+
+       std::list<synfig::BLinePoint> bline;
+       bool loop_bline_flag(false);
+
+       //Changed by Adrian - use resident class :)
+       //synfigapp::convert_stroke_to_bline(bline, *event.stroke_data,*event.width_data, synfigapp::Main::get_bline_width());
+       blineconv.width = synfigapp::Main::get_bline_width().units(get_canvas()->rend_desc());
+
+       if(get_local_error_flag())
+       {
+               float pw = get_work_area()->get_pw();
+               float ph = get_work_area()->get_ph();
+
+               blineconv.pixelwidth = sqrt(pw*pw+ph*ph);
+               blineconv.smoothness = get_lthres();
+       }else
+       {
+               blineconv.pixelwidth = 1;
+               blineconv.smoothness = get_gthres();
+       }
+
+       blineconv(bline,*stroke_data,*width_data);
+
+       //Postprocess to require minimum pressure
+       if(get_min_pressure_flag())
+       {
+               synfigapp::BLineConverter::EnforceMinWidth(bline,get_min_pressure());
+       }
+
+       // If the start and end points are similar, then make them the same point
+       if (get_auto_loop_flag() &&
+               bline.size() > 2 &&
+               (bline.front().get_vertex() - bline.back().get_vertex()).mag() <= radius)
+       {
+               loop_bline_flag=true;
+               Vector tangent;
+               Real width(0);
+
+               while (bline.size() > 2 &&
+                          (bline.front().get_vertex() - bline.back().get_vertex()).mag() <= radius)
+               {
+                       tangent=bline.back().get_tangent1();
+                       width=bline.back().get_width();
+                       bline.pop_back();
+               }
+
+               if(abs(bline.front().get_tangent1().norm()*tangent.norm().perp())>SIMILAR_TANGENT_THRESHOLD)
+               {
+                       // If the tangents are not similar, then
+                       // split the tangents
+                       bline.front().set_split_tangent_flag(true);
+                       bline.front().set_tangent1(tangent);
+               }
+               else
+               {
+                       // If the tangents are similar, then set the tangent
+                       // to the average of the two
+                       bline.front().set_tangent((tangent+bline.front().get_tangent1())*0.5f);
+               }
+
+               // Add the widths of the two points
+               {
+                       Real tmp_width(bline.front().get_width()+width);
+                       tmp_width=tmp_width<=1?tmp_width:1;
+                       bline.front().set_width(tmp_width);
+               }
+       }
+
+       // If the bline only has one blinepoint, then there is nothing to do.
+       if(bline.size() < 2)
+       {
+               // hide the 'stroke' line we were drawing, unless the user
+               // explicitly requests that they are kept
+               if (!getenv("SYNFIG_KEEP_ABORTED_DRAW_LINES"))
+                       refresh_ducks();
+
+               return Smach::RESULT_OK;
+       }
+
+       if(region_flag)
+               return new_region(bline,radius);
+
+       return new_bline(bline,loop_bline_flag,radius);
+}
+
+Smach::event_result
+StateDraw_Context::new_bline(std::list<synfig::BLinePoint> bline,bool loop_bline_flag,float radius)
+{
+       synfigapp::SelectionManager::LayerList layer_list = get_canvas_view()->get_selection_manager()->get_selected_layers();
+
+       // Create the action group
+       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Sketch BLine"));
+
+       bool shift_origin = false;
+       Vector shift_origin_vector;
+       bool join_start_no_extend=false,join_finish_no_extend=false;
+       synfigapp::ValueDesc start_duck_value_desc,finish_duck_value_desc;
+       bool extend_start=false,extend_finish=false,complete_loop=false;
+       bool extend_start_join_same=false,extend_start_join_different=false;
+       bool extend_finish_join_same=false,extend_finish_join_different=false;
+       int start_duck_index = 0,finish_duck_index = 0; // initialized to keep the compiler happy; shouldn't be needed though
+       ValueNode_BLine::Handle start_duck_value_node_bline=NULL,finish_duck_value_node_bline=NULL;
+
+       // Find any ducks at the start or end that we might attach to
+       // (this used to only run if we didn't just draw a loop - ie. !loop_bline_flag
+       // but having loops auto-connect can be useful as well)
+       if(get_auto_extend_flag() || get_auto_link_flag())
+       {
+               etl::handle<Duck> start_duck(get_work_area()->find_duck(bline.front().get_vertex(),radius,Duck::TYPE_VERTEX));
+               etl::handle<Duck> finish_duck(get_work_area()->find_duck(bline.back().get_vertex(),radius,Duck::TYPE_VERTEX));
+
+               // check whether the start of the new line extends an
+               // existing line.  this is only the case if the new
+               // line isn't a self-contained loop, and if the new
+               // line starts at one of the ends of an existing line
+               if(start_duck)do
+               {
+                       if(!(start_duck_value_desc=start_duck->get_value_desc()))break;
+                       if(loop_bline_flag)break; // loops don't extend anything
+                       if(!start_duck_value_desc.parent_is_value_node())break;
+                       start_duck_index=start_duck_value_desc.get_index(); // which point on the line did we start drawing at
+                       start_duck_value_node_bline=ValueNode_BLine::Handle::cast_dynamic(start_duck_value_desc.get_parent_value_node());
+                       if(!get_auto_extend_flag())break;
+
+                       // don't extend looped blines
+                       if(start_duck_value_node_bline&&!start_duck_value_node_bline->get_loop()&&
+                          // did we start drawing at either end of the line?
+                          (start_duck_index==0||start_duck_index==start_duck_value_node_bline->link_count()-1))
+                       {
+                               extend_start=true;
+                               shift_origin=true;
+                               shift_origin_vector=start_duck->get_origin();
+                       }
+               }while(0);
+
+               // check whether the end of the new line extends an
+               // existing line.  this is only the case if the new
+               // line isn't a self-contained loop, and if the new
+               // line ends at one of the ends of an existing line
+               if(finish_duck)do
+               {
+                       if(!(finish_duck_value_desc=finish_duck->get_value_desc()))break;
+                       if(loop_bline_flag)break;
+                       if(!finish_duck_value_desc.parent_is_value_node())break;
+                       finish_duck_index=finish_duck_value_desc.get_index();
+                       finish_duck_value_node_bline=ValueNode_BLine::Handle::cast_dynamic(finish_duck_value_desc.get_parent_value_node());
+                       if(!get_auto_extend_flag())break;
+
+                       // don't extend looped blines
+                       if(finish_duck_value_node_bline&&!finish_duck_value_node_bline->get_loop()&&
+                          (finish_duck_index==0||finish_duck_index==finish_duck_value_node_bline->link_count()-1))
+                       {
+                               if(extend_start)
+                               {
+                                       // we've started and finished drawing at the end of a bline.  we can't
+                                       // extend both blines, so unless we started and finished at the 2 ends
+                                       // of the same bline, only extend the one we started on
+                                       if(start_duck_value_node_bline==finish_duck_value_node_bline)
+                                               complete_loop=extend_finish=true;
+                               }else{
+                                       extend_finish=true;
+                                       shift_origin=true;
+                                       shift_origin_vector=finish_duck->get_origin();
+                               }
+                       }
+               }while(0);
+
+               // if the new line's start didn't extend an existing line,
+               // check whether it needs to be linked to an existing duck
+               if(!extend_start&&get_auto_link_flag()&&start_duck&&start_duck_value_desc)
+                       switch(start_duck_value_desc.get_value_type())
+                       {
+                       case synfig::ValueBase::TYPE_BLINEPOINT:
+                               start_duck_value_desc=synfigapp::ValueDesc(LinkableValueNode::Handle::cast_dynamic(start_duck_value_desc.get_value_node()),0);
+                               // fall through
+                       case synfig::ValueBase::TYPE_VECTOR:
+                               if (shift_origin && shift_origin_vector != start_duck->get_origin())
+                                       break;
+                               shift_origin = true;
+                               shift_origin_vector = start_duck->get_origin();
+                               get_canvas_interface()->auto_export(start_duck_value_desc);
+                               if (extend_finish)
+                                       if(start_duck_value_node_bline&&start_duck_value_node_bline==finish_duck_value_node_bline)
+                                               extend_finish_join_same=true;
+                                       else
+                                               extend_finish_join_different=true;
+                               else
+                                       join_start_no_extend=true;
+                               // fall through
+                       default:break;
+                       }
+
+               // if the new line's end didn't extend an existing line,
+               // check whether it needs to be linked to an existing duck
+               if(!extend_finish&&get_auto_link_flag()&&finish_duck&&finish_duck_value_desc)
+                       switch(finish_duck_value_desc.get_value_type())
+                       {
+                       case synfig::ValueBase::TYPE_BLINEPOINT:
+                               finish_duck_value_desc=synfigapp::ValueDesc(LinkableValueNode::Handle::cast_dynamic(finish_duck_value_desc.get_value_node()),0);
+                               // fall through
+                       case synfig::ValueBase::TYPE_VECTOR:
+                               if (shift_origin && shift_origin_vector != finish_duck->get_origin())
+                                       break;
+                               shift_origin = true;
+                               shift_origin_vector = finish_duck->get_origin();
+                               get_canvas_interface()->auto_export(finish_duck_value_desc);
+                               if(extend_start)
+                                       if(finish_duck_value_node_bline&&start_duck_value_node_bline==finish_duck_value_node_bline)
+                                               extend_start_join_same=true;
+                                       else
+                                               extend_start_join_different=true;
+                               else
+                                       join_finish_no_extend=true;
+                               // fall through
+                       default:break;
+                       }
+       }
+
+       ValueNode_BLine::Handle value_node;
+       std::list<synfig::BLinePoint> trans_bline;
+
+       {
+               std::list<synfig::BLinePoint>::iterator iter;
+               const synfig::TransformStack& transform(get_canvas_view()->get_curr_transform_stack());
+
+               for(iter=bline.begin();iter!=bline.end();++iter)
+               {
+                       BLinePoint bline_point(*iter);
+                       Point new_vertex(transform.unperform(bline_point.get_vertex()));
+
+                       bline_point.set_tangent1(
+                               transform.unperform(
+                                       bline_point.get_tangent1()+bline_point.get_vertex()
+                               ) -new_vertex
+                       );
+
+                       bline_point.set_tangent2(
+                               transform.unperform(
+                                       bline_point.get_tangent2()+bline_point.get_vertex()
+                               ) -new_vertex
+                       );
+
+                       if (shift_origin)
+                               new_vertex=new_vertex-shift_origin_vector;
+
+                       bline_point.set_vertex(new_vertex);
+
+                       trans_bline.push_back(bline_point);
+               }
+               value_node=ValueNode_BLine::create(synfig::ValueBase(trans_bline,loop_bline_flag));
+
+               Canvas::Handle canvas(get_canvas_view()->get_canvas());
+               Layer::Handle layer(get_canvas_view()->get_selection_manager()->get_selected_layer());
+               if (layer) canvas=layer->get_canvas();
+               value_node->set_member_canvas(canvas);
+       }
+
+       Smach::event_result result;
+       synfig::ValueNode_DynamicList::ListEntry source;
+
+       // the new line's start extends an existing line
+       if(extend_start)
+       {
+               int target_offset = 0;
+               if(complete_loop)trans_bline.pop_back();
+               trans_bline.pop_front();
+               if(start_duck_index==0)
+               {       // We need to reverse the BLine first.
+                       reverse_bline(trans_bline);
+                       result=extend_bline_from_begin(start_duck_value_node_bline,trans_bline,complete_loop);
+                       source=start_duck_value_node_bline->list.front();
+                       target_offset=trans_bline.size();
+               }
+               else
+               {
+                       result=extend_bline_from_end(start_duck_value_node_bline,trans_bline,complete_loop);
+                       source=start_duck_value_node_bline->list.back();
+               }
+
+               if(extend_start_join_different)
+                       LinkableValueNode::Handle::cast_dynamic(source.value_node)->
+                               set_link("point",finish_duck_value_desc.get_value_node());
+               else if(extend_start_join_same)
+                       LinkableValueNode::Handle::cast_dynamic(source.value_node)->
+                               set_link("point",synfigapp::ValueDesc(LinkableValueNode::Handle::cast_dynamic(start_duck_value_node_bline->
+                                                                                                       list[target_offset+finish_duck_index].value_node),0).get_value_node());
+               return result;
+       }
+
+       // the new line's end extends an existing line
+       if(extend_finish)
+       {
+               int target_offset = 0;
+               trans_bline.pop_back();
+               if(finish_duck_index==0)
+               {
+                       result=extend_bline_from_begin(finish_duck_value_node_bline,trans_bline,false);
+                       source=finish_duck_value_node_bline->list.front();
+                       target_offset=trans_bline.size();
+               }
+               else
+               {       // We need to reverse the BLine first.
+                       reverse_bline(trans_bline);
+                       result=extend_bline_from_end(finish_duck_value_node_bline,trans_bline,false);
+                       source=finish_duck_value_node_bline->list.back();
+               }
+
+               if(extend_finish_join_different)
+                       LinkableValueNode::Handle::cast_dynamic(source.value_node)->
+                               set_link("point",start_duck_value_desc.get_value_node());
+               else if(extend_finish_join_same)
+                       LinkableValueNode::Handle::cast_dynamic(source.value_node)->
+                               set_link("point",synfigapp::ValueDesc(LinkableValueNode::Handle::cast_dynamic(finish_duck_value_node_bline->
+                                                                                                       list[target_offset+start_duck_index].value_node),0).get_value_node());
+               return result;
+       }
+
+       if (join_start_no_extend)
+               LinkableValueNode::Handle::cast_dynamic(value_node->list.front().value_node)->
+                 set_link("point",start_duck_value_desc.get_value_node());
+
+       if (join_finish_no_extend)
+               LinkableValueNode::Handle::cast_dynamic(value_node->list.back().value_node)->
+                 set_link("point",finish_duck_value_desc.get_value_node());
+
+       if(get_auto_export_flag())
+               if (!get_canvas_interface()->add_value_node(value_node,get_id()))
+               {
+                       /* it's no big deal, is it?  let's keep the shape anyway */
+                       // get_canvas_view()->get_ui_interface()->error(_("Unable to add value node"));
+                       // group.cancel();
+                       // increment_id();
+                       // return Smach::RESULT_ERROR;
+               }
+
+       last_stroke=value_node;
+       last_stroke_id=get_id();
+
+       {
+               // Create the layer(s)
+               Layer::Handle layer;
+               Canvas::Handle canvas(get_canvas_view()->get_canvas());
+               int depth(0);
+
+               // we are temporarily using the layer to hold something
+               layer=get_canvas_view()->get_selection_manager()->get_selected_layer();
+               if(layer)
+               {
+                       depth=layer->get_depth();
+                       canvas=layer->get_canvas();
+               }
+
+               // fill_last_stroke() will take care of clearing the selection if we're calling it
+               if(get_outline_flag() && get_region_flag())
+               {
+                       if (fill_last_stroke_and_unselect_other_layers() == Smach::RESULT_ERROR)
+                       {
+                               get_canvas_view()->get_selection_manager()->set_selected_layers(layer_list);
+                               get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                               group.cancel();
+                               return Smach::RESULT_ERROR;
+                       }
+               }
+               else
+                       get_canvas_interface()->get_selection_manager()->clear_selected_layers();
+
+               //int number(synfig::UniqueID().get_uid());
+
+               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+               // if they're both defined, we'll add the region later
+               if(get_outline_flag())
+               {
+                       layer=get_canvas_interface()->add_layer_to("outline",canvas,depth);
+                       if (!layer)
+                       {
+                               get_canvas_view()->get_selection_manager()->set_selected_layers(layer_list);
+                               get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                               group.cancel();
+                               return Smach::RESULT_ERROR;
+                       }
+                       layer->set_description(get_id()+_(" Outline"));
+               }
+               else
+               {
+                       layer=get_canvas_interface()->add_layer_to("region",canvas,depth);
+                       if (!layer)
+                       {
+                               get_canvas_view()->get_selection_manager()->set_selected_layers(layer_list);
+                               get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                               group.cancel();
+                               return Smach::RESULT_ERROR;
+                       }
+                       layer->set_description(get_id()+_(" Region"));
+               }
+
+               if(get_feather())
+               {
+                       layer->set_param("feather",get_feather());
+                       get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
+               }
+               assert(layer);
+               //layer->set_description(strprintf("Stroke %d",number));
+               //get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+               if (shift_origin)
+                       get_canvas_interface()->
+                         change_value(synfigapp::ValueDesc(layer,"origin"),shift_origin_vector);
+
+               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+
+               assert(action);
+
+               action->set_param("canvas",get_canvas());
+               action->set_param("canvas_interface",get_canvas_interface());
+               action->set_param("layer",layer);
+               if(!action->set_param("param",String("bline")))
+                       synfig::error("LayerParamConnect didn't like \"param\"");
+               if(!action->set_param("value_node",ValueNode::Handle(value_node)))
+                       synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+               if(!get_canvas_interface()->get_instance()->perform_action(action))
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                       group.cancel();
+                       increment_id();
+                       //refresh_ducks();
+                       return Smach::RESULT_ERROR;
+               }
+               layer_list.push_back(layer);
+               get_canvas_view()->get_selection_manager()->set_selected_layers(layer_list);
+               //refresh_ducks();
+       }
+
+       increment_id();
+       return Smach::RESULT_ACCEPT;
+}
+
+#ifdef _DEBUG
+static void
+debug_show_vertex_list(int iteration, std::list<synfigapp::ValueDesc>& vertex_list,
+                                          std::string title, int current)
+{
+       std::list<synfigapp::ValueDesc>::iterator i = vertex_list.begin();
+       printf("\n%s\n  ----- iter %d : ", title.c_str(), iteration);
+       int c = 0;
+       synfig::LinkableValueNode::Handle last = 0;
+       int start = -1;
+       int index;
+       int prev;
+       int dir = 0;
+       bool started = false;
+       for(;i!=vertex_list.end();i++,c++)
+       {
+               synfigapp::ValueDesc value_desc(*i);
+
+               if (value_desc.parent_is_value_node()) {
+                       if(value_desc.parent_is_linkable_value_node())
+                       {
+                               index = value_desc.get_index();
+                               // printf("<%d>", index);
+                               if (last == synfig::LinkableValueNode::Handle::cast_reinterpret(value_desc.get_parent_value_node()))
+                               {
+                                       // printf("\n%s:%d\n", __FILE__, __LINE__);
+                                       if (start != -1)
+                                       {
+                                               // printf("\n%s:%d\n", __FILE__, __LINE__);
+                                               if (c == current)
+                                               {
+                                                       // printf("\n%s:%d\n", __FILE__, __LINE__);
+                                                       if (dir)
+                                                       {
+                                                               if (started) printf(", "); else started = true;
+                                                               printf("%d--%d", start, prev);
+                                                       }
+                                                       else
+                                                       {
+                                                               if (started) printf(", "); else started = true;
+                                                               printf("%d", start);
+                                                       }
+                                                       printf(", *%d*", index);
+                                                       start = -1;
+                                               }
+                                               else if (dir == 0)
+                                               {
+                                                       // printf("\n%s:%d\n", __FILE__, __LINE__);
+                                                       if (index == start + 1)
+                                                       {
+                                                               // printf("\n%s:%d\n", __FILE__, __LINE__);
+                                                               dir = 1;
+                                                               prev = index;
+                                                       }
+                                                       else if (index == start - 1)
+                                                       {
+                                                               // printf("\n%s:%d\n", __FILE__, __LINE__);
+                                                               dir = -1;
+                                                               prev = index;
+                                                       }
+                                                       else
+                                                       {
+                                                               if (started) printf(", "); else started = true;
+                                                               printf("%d", start);
+                                                               start = index;
+                                                       }
+                                               }
+                                               else if (index == prev + dir)
+                                               {
+                                                       // printf("\n%s:%d\n", __FILE__, __LINE__);
+                                                       prev = index;
+                                               }
+                                               else
+                                               {
+                                                       // printf("\n%s:%d\n", __FILE__, __LINE__);
+                                                       if (started) printf(", "); else started = true;
+                                                       if (prev != start)
+                                                               printf("%d--%d", start, prev);
+                                                       else
+                                                               printf("%d", start);
+                                                       // printf("\n%s:%d\n", __FILE__, __LINE__);
+                                                       start = index;
+                                                       dir = 0;
+                                               }
+                                       }
+                                       else
+                                       {
+                                               // printf("\n%s:%d\n", __FILE__, __LINE__);
+                                               if (c == current)
+                                               {
+                                                       if (started) printf(", "); else started = true;
+                                                       printf("*%d*", index);
+                                               }
+                                               else
+                                               {
+                                                       // printf("\n%s:%d\n", __FILE__, __LINE__);
+                                                       start = index;
+                                                       dir = 0;
+                                               }
+                                       }
+                               }
+                               else
+                               {
+                                       // printf("\n%s:%d\n", __FILE__, __LINE__);
+                                       if (last)
+                                       {
+                                               // printf("\n%s:%d\n", __FILE__, __LINE__);
+                                               if (start != -1)
+                                               {
+                                                       if (started) printf(", "); else started = true;
+                                                       if (dir != 0)
+                                                               printf("%d--%d", start, prev);
+                                                       else
+                                                               printf("%d", start);
+                                               }
+                                               // printf("\n%s:%d\n", __FILE__, __LINE__);
+                                               printf(") ");
+                                       }
+                                       // printf("\n%s:%d\n", __FILE__, __LINE__);
+                                       last = synfig::LinkableValueNode::Handle::cast_reinterpret(value_desc.get_parent_value_node());
+                                       printf("%d:(", synfig::LinkableValueNode::Handle::cast_reinterpret(value_desc.get_parent_value_node())->link_count());
+                                       started = false;
+                                       // printf("\n%s:%d\n", __FILE__, __LINE__);
+                                       if (c == current)
+                                       {
+                                               start = -1;
+                                               printf("*%d*", index);
+                                       }
+                                       else
+                                       {
+                                               // printf("\n%s:%d\n", __FILE__, __LINE__);
+                                               start = index;
+                                               dir = 0;
+                                       }
+                                       // printf("\n%s:%d\n", __FILE__, __LINE__);
+                               }
+                               // printf("\n%s:%d\n", __FILE__, __LINE__);
+                       }
+                       else if (last)
+                               if (last) printf("?!) ");
+               }
+               else
+               {
+                       last = 0;
+                       printf("? ");
+               }
+       }
+       if (last)
+       {
+               if (started) printf(", "); else started = true;
+               if (start != -1)
+               {
+                       if (dir != 0)
+                               printf("%d--%d", start, prev);
+                       else
+                               printf("%d", start);
+               }
+               printf(")");
+       }
+       printf("\n");
+}
+#else  // _DEBUG
+#define debug_show_vertex_list(a,b,c,d)
+#endif // _DEBUG
+
+Smach::event_result
+StateDraw_Context::new_region(std::list<synfig::BLinePoint> bline, synfig::Real radius)
+{
+       // Create the action group
+       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Define Region"));
+
+       std::list<synfigapp::ValueDesc> vertex_list;
+
+       printf("new_region with %zd bline points\n", bline.size());
+
+       // First we need to come up with a rough list of
+       // BLinePoints that we are going to be using to
+       // define our region.
+       {
+               std::list<synfig::BLinePoint>::iterator iter;
+               for(iter=bline.begin();iter!=bline.end();++iter)
+               {
+                       etl::handle<Duck> duck(get_work_area()->find_duck(iter->get_vertex(),0,Duck::TYPE_VERTEX));
+
+                       if(!duck)
+                       {
+                               synfig::info(__FILE__":%d: Nothing to enclose!",__LINE__);
+                               return Smach::RESULT_OK;
+                       }
+
+                       assert(duck->get_type()==Duck::TYPE_VERTEX);
+
+                       synfigapp::ValueDesc value_desc(duck->get_value_desc());
+
+                       if(!value_desc)
+                       {
+                               synfig::info(__FILE__":%d: Got a hit, but no ValueDesc on this duck",__LINE__);
+                               continue;
+                       }
+
+                       switch(value_desc.get_value_type())
+                       {
+                       case synfig::ValueBase::TYPE_BLINEPOINT:
+                               //if(vertex_list.empty() || value_desc!=vertex_list.back())
+                               vertex_list.push_back(value_desc);
+                               assert(vertex_list.back().is_valid());
+
+                               break;
+                       default:
+                               break;
+                       }
+               }
+       }
+
+       assert(vertex_list.back().is_valid());
+
+       printf("vertex list with %zd bline points\n", vertex_list.size());
+
+       // Remove any duplicates
+       {
+       }
+
+       ValueNode_BLine::Handle value_node_bline;
+
+       // Now we need to test for the trivial case,
+       // which is where all of the vertices
+       // come from one BLine.
+       if(vertex_list.front().parent_is_linkable_value_node())
+       {
+               bool trivial_case(true);
+               ValueNode::Handle trivial_case_value_node;
+
+               trivial_case_value_node=vertex_list.front().get_parent_value_node();
+
+               std::list<synfigapp::ValueDesc>::iterator iter;
+               for(iter=vertex_list.begin();iter!=vertex_list.end();++iter)
+               {
+                       if(trivial_case_value_node!=iter->get_parent_value_node())
+                       {
+                               trivial_case=false;
+                               break;
+                       }
+               }
+
+               // \todo - re-enable this code
+               if(trivial_case && false)
+               {
+                       synfig::info("all points are on the same bline, so just fill that line");
+                       value_node_bline=ValueNode_BLine::Handle::cast_dynamic(trivial_case_value_node);
+
+                       synfig::info("the line has %d vertices", value_node_bline->link_count());
+
+                       if(value_node_bline->link_count() <= 2)
+                       {
+                               synfig::info(__FILE__":%d: Vertex list too small to make region.",__LINE__);
+                               return Smach::RESULT_OK;
+                       }
+               }
+       }
+
+       if(!value_node_bline)
+               if(vertex_list.size()<=2)
+               {
+                       synfig::info(__FILE__":%d: Vertex list too small to make region.",__LINE__);
+                       return Smach::RESULT_OK;
+               }
+
+       // Now we need to clean the list of vertices up
+       // a bit. This includes inserting missing vertices
+       // and removing extraneous ones.
+       // We can do this in multiple passes.
+       if(!value_node_bline)
+       {
+               debug_show_vertex_list(0, vertex_list, "before shifting stuff", -1);
+               // rearrange the list so that the first and last node are on different blines
+               std::list<synfigapp::ValueDesc>::iterator iter, start;
+               ValueNode::Handle last_value_node = vertex_list.back().get_parent_value_node();
+               for(iter = vertex_list.begin(); iter!=vertex_list.end(); iter++)
+                       if (iter->get_parent_value_node() != last_value_node)
+                       {
+                               vertex_list.insert(vertex_list.end(), vertex_list.begin(), iter);
+                               vertex_list.erase(vertex_list.begin(), iter);
+                               break;
+                       }
+
+               debug_show_vertex_list(0, vertex_list, "before detecting direction and limits", -1);
+               // rearrange the list so that the first and last node are on different blines
+               iter = vertex_list.begin();
+               while (iter!=vertex_list.end())
+               {
+                       // make a note of which bline we're looking at
+                       ValueNode::Handle parent_value_node = iter->get_parent_value_node();
+                       start = iter;
+                       int points_in_line = synfig::LinkableValueNode::Handle::cast_reinterpret(parent_value_node)->link_count();
+                       bool looped = (*parent_value_node)(get_time()).get_loop();
+                       int this_index, last_index = iter->get_index();
+                       int min_index = last_index, max_index = last_index;
+                       bool whole;
+                       int direction = 0;
+
+                       // printf("there are %d points in this line - first is index %d\n", points_in_line, last_index);
+
+                       // while we're looking at the same bline, keep going
+                       iter++;
+                       while (iter != vertex_list.end() && iter->get_parent_value_node() == parent_value_node)
+                       {
+                               this_index = iter->get_index();
+                               // printf("index went from %d to %d\n", last_index, this_index);
+                               if (looped)
+                               {
+                                       if (this_index - last_index > points_in_line/2)
+                                               while (this_index - last_index > points_in_line/2)
+                                                       this_index -= points_in_line;
+                                       else if (last_index - this_index > points_in_line/2)
+                                               while (last_index - this_index > points_in_line/2)
+                                                       this_index += points_in_line;
+                               }
+
+                               if (this_index < min_index) min_index = this_index;
+                               if (this_index > max_index) max_index = this_index;
+
+                               // printf("so let's imagine index went from %d to %d\n", last_index, this_index);
+                               if (this_index > last_index)
+                                       direction++;
+                               else if (this_index < last_index)
+                                       direction--;
+
+                               last_index = this_index;
+                               iter++;
+                       }
+
+                       // printf("min %d and max %d\n", min_index, max_index);
+                       whole = max_index - min_index >= points_in_line;
+                       min_index = (min_index % points_in_line + points_in_line) % points_in_line;
+                       max_index = (max_index % points_in_line + points_in_line) % points_in_line;
+                       // they drew around a shape more than once - what's the start/end point?  does it matter?
+                       if (whole) min_index = max_index = (min_index + max_index) / 2;
+                       // printf("processed min %d max %d whole %d\n", min_index, max_index, whole);
+
+                       if (direction < 0)
+                       {
+                               if (whole)
+                               {
+                                       // printf("whole (down) (%d) ", min_index);
+                                       for (int i = min_index; i >= 0; i--)
+                                       {
+                                               // printf("%d ", i);
+                                               vertex_list.insert(start, synfigapp::ValueDesc(parent_value_node, i));
+                                       }
+                                       for (int i = points_in_line - 1; i >= min_index; i--)
+                                       {
+                                               // printf("%d ", i);
+                                               vertex_list.insert(start, synfigapp::ValueDesc(parent_value_node, i));
+                                       }
+                               }
+                               else
+                               {
+                                       // printf("part (down) (%d -> %d) ", max_index, min_index);
+                                       for (int i = max_index; i != min_index; i--)
+                                       {
+                                               if (i == -1) i = points_in_line - 1;
+                                               // printf("%d ", i);
+                                               vertex_list.insert(start, synfigapp::ValueDesc(parent_value_node, i));
+                                       }
+                                       vertex_list.insert(start, synfigapp::ValueDesc(parent_value_node, min_index));
+                               }
+                       }
+                       else
+                       {
+                               if (whole)
+                               {
+                                       // printf("whole (%d) ", min_index);
+                                       for (int i = min_index; i < points_in_line; i++)
+                                       {
+                                               // printf("%d ", i);
+                                               vertex_list.insert(start, synfigapp::ValueDesc(parent_value_node, i));
+                                       }
+                                       for (int i = 0; i <= min_index; i++)
+                                       {
+                                               // printf("%d ", i);
+                                               vertex_list.insert(start, synfigapp::ValueDesc(parent_value_node, i));
+                                       }
+                               }
+                               else
+                               {
+                                       // printf("part (%d -> %d) ", min_index, max_index);
+                                       for (int i = min_index; i != max_index; i++)
+                                       {
+                                               if (i == points_in_line) i = 0;
+                                               // printf("%d ", i);
+                                               vertex_list.insert(start, synfigapp::ValueDesc(parent_value_node, i));
+                                       }
+                                       vertex_list.insert(start, synfigapp::ValueDesc(parent_value_node, max_index));
+                               }
+                       }
+                       // printf("\n");
+                       // debug_show_vertex_list(0, vertex_list, "after insert", -1);
+                       vertex_list.erase(start, iter);
+                       // debug_show_vertex_list(0, vertex_list, "after delete", -1);
+               }
+
+               debug_show_vertex_list(0, vertex_list, "continuous vertices", -1);
+
+               // \todo reenable or delete this section
+               int i=100;
+               for(bool done=false;!done && i<30;i++)
+               {
+                       debug_show_vertex_list(i, vertex_list, "in big loop", -1);
+
+                       // Set done to "true" for now. If
+                       // any updates are performed, we will
+                       // change it back to false.
+                       done=true;
+
+                       std::list<synfigapp::ValueDesc>::iterator prev,next;
+                       prev=vertex_list.end();prev--;  // Set prev to the last ValueDesc
+                       next=vertex_list.begin();
+                       iter=next++; // Set iter to the first value desc, and next to the second
+
+                       int current = 0;
+                       for(;iter!=vertex_list.end();prev=iter,iter++,next++,current++)
+                       {
+                               // we need to be able to erase(next) and can't do that if next is end()
+                               if (next == vertex_list.end()) next = vertex_list.begin();
+                               debug_show_vertex_list(i, vertex_list, "in loop around vertices", current);
+                               synfigapp::ValueDesc value_prev(*prev);
+                               synfigapp::ValueDesc value_desc(*iter);
+                               synfigapp::ValueDesc value_next(*next);
+
+                               assert(value_desc.is_valid());
+                               assert(value_next.is_valid());
+                               assert(value_prev.is_valid());
+
+                               // synfig::info("-------");
+                               // synfig::info(__FILE__":%d: value_prev 0x%08X:%d",__LINE__,value_prev.get_parent_value_node().get(),value_prev.get_index());
+                               // synfig::info(__FILE__":%d: value_desc 0x%08X:%d",__LINE__,value_desc.get_parent_value_node().get(),value_desc.get_index());
+                               // synfig::info(__FILE__":%d: value_next 0x%08X:%d",__LINE__,value_next.get_parent_value_node().get(),value_next.get_index());
+
+                               /*
+                                 if(value_prev.parent_is_value_node() && value_desc.parent_is_value_node() && value_next.parent_is_value_node())
+                                 {
+                                 // Remove random extraneous vertices
+                                 if(value_prev.get_parent_value_node()==value_next.get_parent_value_node() &&
+                                 value_prev.get_parent_value_node()!=value_desc.get_parent_value_node())
+                                 {
+                                 vertex_list.erase(iter);
+                                 done=false;
+                                 break;
+                                 }
+                                 }
+                               */
+
+                               // // Remove duplicate vertices
+
+                               // // if previous is the same as current or
+                               // //    current is the same as next, remove current
+                               // if(value_prev.get_value_node()==value_desc.get_value_node() ||
+                               //    value_desc.get_value_node()==value_next.get_value_node())
+                               // {
+                               //      vertex_list.erase(iter);
+                               //      done=false;
+                               //      printf("erased node - i = %d\n", i);
+                               //      break;
+                               // }
+
+                               // // if previous is the same as next, remove previous?  or next?
+                               // if(value_prev.get_value_node()==value_next.get_value_node())
+                               // {
+                               //      vertex_list.erase(next);
+                               //      // vertex_list.erase(prev);
+                               //      done=false;
+                               //      printf("erased node - i = %d\n", i);
+                               //      break;
+                               // }
+
+                               // if 'this' and 'next' both have parents
+                               if (value_desc.parent_is_value_node() && value_next.parent_is_value_node())
+                               {
+                                       // if they are both on the same bline - this has been handled by new code above
+                                       if (value_desc.get_parent_value_node() == value_next.get_parent_value_node())
+                                       {
+                                               // // if (next != vertex_list.end())
+                                               // {
+                                               //      printf("parent loop is %d and node loop is ??\n",
+                                               //                 (*(value_desc.get_parent_value_node()))(get_time()).get_loop()
+                                               //                 // value_desc.get_value_node().get_loop(),
+                                               //              );
+                                               //
+                                               //      // Fill in missing vertices
+                                               //      // \todo take loops into account: seeing (15, 2, 3, 4) probably means that (0, 1) is missing, not 14 through 3
+                                               //      if(value_desc.get_index()<value_next.get_index()-1)
+                                               //      {
+                                               //              debug_show_vertex_list(i, vertex_list,
+                                               //                                                         strprintf("same parent, different points this %d < next-1 %d",
+                                               //                                                                               value_desc.get_index(), ((value_next.get_index()-1))),
+                                               //                                                         current);
+                                               //              for (int index = value_desc.get_index()+1; index < value_next.get_index(); index++)
+                                               //              {
+                                               //                      printf("inserting up %d\n", index);
+                                               //                      vertex_list.insert(next, synfigapp::ValueDesc(value_desc.get_parent_value_node(), index));
+                                               //              }
+                                               //              debug_show_vertex_list(i, vertex_list, "new list", current);
+                                               //              done=false;
+                                               //              break;
+                                               //      }
+                                               //      if(value_next.get_index()<value_desc.get_index()-1)
+                                               //      {
+                                               //              debug_show_vertex_list(i, vertex_list,
+                                               //                                                         strprintf("same parent, different points next %d < this-1 %d",
+                                               //                                                                               value_next.get_index(), ((value_desc.get_index()-1))),
+                                               //                                                         current);
+                                               //              for (int index = value_desc.get_index()-1; index > value_next.get_index(); index--)
+                                               //              {
+                                               //                      printf("inserting down %d\n", index);
+                                               //                      vertex_list.insert(next, synfigapp::ValueDesc(value_desc.get_parent_value_node(), index));
+                                               //              }
+                                               //              debug_show_vertex_list(i, vertex_list, "new list", current);
+                                               //              done=false;
+                                               //              break;
+                                               //      }
+                                               // }
+                                       }
+                                       // 'this' and 'next' have different parents
+                                       else
+                                       {
+                                               ValueNode::Handle v1 = value_desc.get_value_node();
+                                               ValueNode::Handle v2 = value_desc.get_parent_value_node();
+                                               if (v1 == v2)
+                                                       printf("same\n");
+                                               else
+                                                       printf("different\n");
+
+                                               if (value_desc.get_value_node() != value_next.get_value_node())
+                                               {
+                                                       // Ensure that connections between blines are properly connected
+                                                       BLinePoint vertex(value_desc.get_value(get_time()).get(BLinePoint()));
+                                                       BLinePoint vertex_next(value_next.get_value(get_time()).get(BLinePoint()));
+
+                                                       //synfig::info("--------");
+                                                       //synfig::info(__FILE__":%d: vertex: [%f, %f]",__LINE__,vertex.get_vertex()[0],vertex.get_vertex()[1]);
+                                                       //synfig::info(__FILE__":%d: vertex_next: [%f, %f]",__LINE__,vertex_next.get_vertex()[0],vertex_next.get_vertex()[1]);
+
+                                                       // if this vertex is close to the next one, replace this vertex with a new one
+                                                       // and erase the next one
+                                                       printf("this point is %5.2f from the next point - compare with %5.2f\n",
+                                                                  (vertex.get_vertex()-vertex_next.get_vertex()).mag_squared(),
+                                                                  radius*radius);
+                                                       if((vertex.get_vertex()-vertex_next.get_vertex()).mag_squared()<radius*radius)
+                                                       {
+                                                               printf("in one - it's close\n");
+                                                               ValueNode_Composite::Handle value_node;
+                                                               ValueNode_Composite::Handle value_node_next;
+                                                               value_node=ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node().clone());
+                                                               value_node_next=ValueNode_Composite::Handle::cast_dynamic(value_next.get_value_node().clone());
+                                                               if(!value_node || !value_node_next)
+                                                               {
+                                                                       synfig::info(__FILE__":%d: Unable to properly connect blines.",__LINE__);
+                                                                       continue;
+                                                               }
+                                                               // \todo if next isn't split, don't we want to copy its 'Tangent 1' instead?
+                                                               value_node->set_link("t2",value_node_next->get_link("t2"));
+                                                               value_node->set_link("split",ValueNode_Const::create(true));
+
+                                                               // get_canvas_interface()->auto_export(value_node);
+                                                               printf("exporting\n");
+                                                               get_canvas_interface()->add_value_node(value_node,value_node->get_id() + strprintf("foo %d", rand()));
+
+                                                               assert(value_node->is_exported());
+                                                               // replace 'this' with the new valuenode
+                                                               *iter=synfigapp::ValueDesc(get_canvas(),value_node->get_id());
+                                                               printf("erasing next\n");
+                                                               printf("erasing next point\n");
+                                                               vertex_list.erase(next);
+                                                               done=false;
+                                                               break;
+                                                       } // this vertex isn't close to the next one
+                                                       else if (value_prev.parent_is_value_node())
+                                                       {
+                                                               printf("in two - it's far\n");
+                                                               // \todo this only makes sense if prev is on the same bline
+                                                               printf("this is index %d\n", value_desc.get_index());
+                                                               printf("prev is index %d\n", value_prev.get_index());
+                                                               bool positive_trend(value_desc.get_index()>value_prev.get_index());
+
+                                                               if(positive_trend)
+                                                               {
+                                                                       printf("positive trend\n");
+                                                                       printf("comparing index %d < link_count()-1 = %d-1 = %d\n",
+                                                                                  value_desc.get_index(),
+                                                                                  LinkableValueNode::Handle::cast_static(value_desc.get_parent_value_node())->link_count(),
+                                                                                  LinkableValueNode::Handle::cast_static(value_desc.get_parent_value_node())->link_count()-1);
+                                                                       if (value_desc.get_index()<LinkableValueNode::Handle::cast_static(value_desc.get_parent_value_node())->link_count()-1)
+                                                                       {
+                                                                               printf("in two - b\n");
+                                                                               printf("inserting node with index %d\n", value_desc.get_index()+1);
+                                                                               vertex_list.insert(next,
+                                                                                                                  synfigapp::ValueDesc(value_desc.get_parent_value_node(),
+                                                                                                                                                               value_desc.get_index()+1));
+                                                                               done=false;
+                                                                               break;
+                                                                       }
+                                                               }
+                                                               else // !positive_trend
+                                                               {
+                                                                       printf("negative trend\n");
+                                                                       if(value_desc.get_index()>0)
+                                                                       {
+                                                                               printf("in two - a\n");
+                                                                               printf("inserting node on this line with index %d\n",
+                                                                                          value_desc.get_index()-1);
+                                                                               vertex_list.insert(next,
+                                                                                                                  synfigapp::ValueDesc(value_desc.get_parent_value_node(),
+                                                                                                                                                               value_desc.get_index()-1));
+                                                                               done=false;
+                                                                               break;
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               if(vertex_list.size()<=2)
+               {
+                       synfig::info(__FILE__":%d: Vertex list too small to make region.",__LINE__);
+                       return Smach::RESULT_OK;
+               }
+
+               debug_show_vertex_list(i, vertex_list, "finished tidying list", -1);
+       }
+
+       // If we aren't the trivial case,
+       // then go ahead and create the new
+       // BLine value node
+       if(!value_node_bline)
+       {
+               synfig::info("not all points are on the same bline");
+               value_node_bline=ValueNode_BLine::create();
+
+               std::list<synfigapp::ValueDesc>::iterator iter;
+               for(iter=vertex_list.begin();iter!=vertex_list.end();++iter)
+               {
+                       // Ensure that the vertex is exported.
+                       get_canvas_interface()->auto_export(*iter);
+
+                       value_node_bline->add(iter->get_value_node());
+                       //value_node_bline->add(ValueNode_BLine::ListEntry(iter->get_value_node()));
+               }
+
+               value_node_bline->set_loop(true);
+       }
+
+       get_canvas_interface()->auto_export(value_node_bline);
+
+       // Now we create the region layer
+       // Create the layer
+       {
+               Layer::Handle layer;
+               Canvas::Handle canvas(get_canvas_view()->get_canvas());
+               int depth(0);
+
+               // we are temporarily using the layer to hold something
+               layer=get_canvas_view()->get_selection_manager()->get_selected_layer();
+               if(layer)
+               {
+                       depth=layer->get_depth();
+                       canvas=layer->get_canvas();
+               }
+
+               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+               layer=get_canvas_interface()->add_layer_to("region",canvas,depth);
+               if (!layer)
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                       group.cancel();
+                       return Smach::RESULT_ERROR;
+               }
+
+               if(get_feather())
+               {
+                       layer->set_param("feather",get_feather());
+                       get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
+               }
+               get_canvas_interface()->signal_layer_param_changed()(layer,"color");
+
+               synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+
+               assert(action);
+
+               action->set_param("canvas",get_canvas());
+               action->set_param("canvas_interface",get_canvas_interface());
+               action->set_param("layer",layer);
+               if(!action->set_param("param",String("bline")))
+                       synfig::error("LayerParamConnect didn't like \"param\"");
+               if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
+                       synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+               if(!get_canvas_interface()->get_instance()->perform_action(action))
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
+                       group.cancel();
+                       return Smach::RESULT_ERROR;
+               }
+               get_canvas_view()->get_selection_manager()->set_selected_layer(layer);
+       }
+
+       return Smach::RESULT_ACCEPT;
+}
+
+void
+StateDraw_Context::refresh_ducks()
+{
+       get_canvas_view()->queue_rebuild_ducks();
+/*
+       get_work_area()->clear_ducks();
+
+
+       std::list< etl::smart_ptr<std::list<synfig::Point> > >::iterator iter;
+
+       for(iter=stroke_list.begin();iter!=stroke_list.end();++iter)
+       {
+               get_work_area()->add_stroke(*iter);
+       }
+
+       get_work_area()->queue_draw();
+*/
+}
+
+
+Smach::event_result
+StateDraw_Context::extend_bline_from_begin(ValueNode_BLine::Handle value_node,std::list<synfig::BLinePoint> bline,bool complete_loop)
+{
+       // Create the action group
+       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Extend BLine"));
+
+       if (complete_loop)
+       {
+               synfigapp::Action::Handle action(synfigapp::Action::create("ValueNodeDynamicListLoop"));
+               assert(action);
+
+               action->set_param("canvas",get_canvas());
+               action->set_param("canvas_interface",get_canvas_interface());
+               action->set_param("value_node",ValueNode::Handle(value_node));
+
+               if(!get_canvas_interface()->get_instance()->perform_action(action))
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to set loop for bline"));
+                       group.cancel();
+                       return Smach::RESULT_ERROR;
+               }
+       }
+
+       std::list<synfig::BLinePoint>::reverse_iterator iter;
+       for(iter=bline.rbegin();!(iter==bline.rend());++iter)
+       {
+               ValueNode_Composite::Handle composite(ValueNode_Composite::create(*iter));
+
+               synfigapp::Action::Handle action(synfigapp::Action::create("ValueNodeDynamicListInsert"));
+
+               assert(action);
+               synfigapp::ValueDesc value_desc(value_node,0);
+
+               action->set_param("canvas",get_canvas());
+               action->set_param("canvas_interface",get_canvas_interface());
+               action->set_param("value_desc",value_desc);
+               if(!action->set_param("item",ValueNode::Handle(composite)))
+                       synfig::error("ACTION didn't like \"item\"");
+
+               if(!get_canvas_interface()->get_instance()->perform_action(action))
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to insert item"));
+                       group.cancel();
+                       //refresh_ducks();
+                       return Smach::RESULT_ERROR;
+               }
+       }
+       last_stroke=value_node;
+       return Smach::RESULT_ACCEPT;
+}
+
+Smach::event_result
+StateDraw_Context::extend_bline_from_end(ValueNode_BLine::Handle value_node,std::list<synfig::BLinePoint> bline,bool complete_loop)
+{
+       // Create the action group
+       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Extend BLine"));
+
+       if (complete_loop)
+       {
+               synfigapp::Action::Handle action(synfigapp::Action::create("ValueNodeDynamicListLoop"));
+               assert(action);
+
+               action->set_param("canvas",get_canvas());
+               action->set_param("canvas_interface",get_canvas_interface());
+               action->set_param("value_node",ValueNode::Handle(value_node));
+
+               if(!get_canvas_interface()->get_instance()->perform_action(action))
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to set loop for bline"));
+                       group.cancel();
+                       return Smach::RESULT_ERROR;
+               }
+       }
+
+       std::list<synfig::BLinePoint>::iterator iter;
+       for(iter=bline.begin();iter!=bline.end();++iter)
+       {
+               ValueNode_Composite::Handle composite(ValueNode_Composite::create(*iter));
+
+               synfigapp::Action::Handle action(synfigapp::Action::create("ValueNodeDynamicListInsert"));
+
+               assert(action);
+               synfigapp::ValueDesc value_desc(value_node,value_node->link_count());
+
+               action->set_param("canvas",get_canvas());
+               action->set_param("canvas_interface",get_canvas_interface());
+               action->set_param("value_desc",value_desc);
+               if(!action->set_param("item",ValueNode::Handle(composite)))
+                       synfig::error("ACTION didn't like \"item\"");
+
+               if(!get_canvas_interface()->get_instance()->perform_action(action))
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to insert item"));
+                       group.cancel();
+                       //refresh_ducks();
+                       return Smach::RESULT_ERROR;
+               }
+       }
+       last_stroke=value_node;
+       return Smach::RESULT_ACCEPT;
+}
+
+void
+StateDraw_Context::reverse_bline(std::list<synfig::BLinePoint> &bline)
+{
+       int i;
+
+       std::list<synfig::BLinePoint>::iterator iter,eiter;
+       iter=bline.begin();
+       eiter=bline.end();
+       eiter--;
+       for(i=0;i<(int)bline.size()/2;++iter,--eiter,i++)
+       {
+               iter_swap(iter,eiter);
+               iter->reverse();
+               eiter->reverse();
+       }
+}
+
+Smach::event_result
+StateDraw_Context::fill_last_stroke_and_unselect_other_layers()
+{
+       if(!last_stroke)
+               return Smach::RESULT_OK;
+
+       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Fill Stroke"));
+
+       Layer::Handle layer;
+
+       get_canvas_interface()->auto_export(last_stroke);
+
+       synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+       Canvas::Handle canvas(get_canvas_view()->get_canvas());
+       int depth(0);
+
+       layer=get_canvas_view()->get_selection_manager()->get_selected_layer();
+       if(layer)
+       {
+               depth=layer->get_depth();
+               canvas=layer->get_canvas();
+       }
+
+       get_canvas_interface()->get_selection_manager()->clear_selected_layers();
+       layer=get_canvas_interface()->add_layer_to("region", canvas, depth);
+       if (!layer) return Smach::RESULT_ERROR;
+       layer->set_description(last_stroke_id + _(" Region"));
+
+       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+
+       assert(action);
+
+       action->set_param("canvas",get_canvas());
+       action->set_param("canvas_interface",get_canvas_interface());
+       action->set_param("layer",layer);
+       if(!action->set_param("param",String("bline")))
+               synfig::error("LayerParamConnect didn't like \"param\"");
+       if(!action->set_param("value_node",ValueNode::Handle(last_stroke)))
+               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+       if(!get_canvas_interface()->get_instance()->perform_action(action))
+       {
+               get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
+               group.cancel();
+               return Smach::RESULT_OK;
+       }
+       get_canvas_view()->get_selection_manager()->set_selected_layer(layer);
+       return Smach::RESULT_OK;
+}
+
+void
+StateDraw_Context::fill_last_stroke()
+{
+       if(!last_stroke)
+               return;
+
+       synfigapp::SelectionManager::LayerList layer_list = get_canvas_view()->get_selection_manager()->get_selected_layers();
+       fill_last_stroke_and_unselect_other_layers();
+       get_canvas_view()->get_selection_manager()->set_selected_layers(layer_list);
+}
diff --git a/synfig-studio/src/gui/state_draw.h b/synfig-studio/src/gui/state_draw.h
new file mode 100644 (file)
index 0000000..2c074a5
--- /dev/null
@@ -0,0 +1,56 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_draw.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_ROTOSCOPE_H
+#define __SYNFIG_STUDIO_STATE_ROTOSCOPE_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 StateDraw_Context;
+
+class StateDraw : public Smach::state<StateDraw_Context>
+{
+public:
+       StateDraw();
+       ~StateDraw();
+}; // END of class StateDraw
+
+extern StateDraw state_draw;
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/state_eyedrop.cpp b/synfig-studio/src/gui/state_eyedrop.cpp
new file mode 100644 (file)
index 0000000..dcd57a1
--- /dev/null
@@ -0,0 +1,146 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_eyedrop.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "state_eyedrop.h"
+#include "state_normal.h"
+#include "workarea.h"
+#include <synfig/context.h>
+#include "app.h"
+#include "dialog_color.h"
+#include "event_mouse.h"
+#include "event_layerclick.h"
+#include "toolbox.h"
+#include "canvasview.h"
+#include <synfigapp/main.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 ========================================================= */
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+class studio::StateEyedrop_Context
+{
+       CanvasView *canvas_view;
+       CanvasView::IsWorking is_working;
+
+public:
+       StateEyedrop_Context(CanvasView *canvas_view);
+       ~StateEyedrop_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_workarea_mouse_button_down_handler(const Smach::event& x);
+
+}; // END of class StateEyedrop_Context
+
+/* === G L O B A L S ======================================================= */
+
+StateEyedrop studio::state_eyedrop;
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+StateEyedrop::StateEyedrop():
+       Smach::state<StateEyedrop_Context>("eyedrop")
+{
+       insert(event_def(EVENT_LAYER_SELECTION_CHANGED,&StateEyedrop_Context::event_stop_handler));
+       insert(event_def(EVENT_STOP,&StateEyedrop_Context::event_stop_handler));
+       insert(event_def(EVENT_REFRESH,&StateEyedrop_Context::event_refresh_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StateEyedrop_Context::event_workarea_mouse_button_down_handler));
+}
+
+StateEyedrop::~StateEyedrop()
+{
+}
+
+StateEyedrop_Context::StateEyedrop_Context(CanvasView *canvas_view):
+       canvas_view(canvas_view),
+       is_working(*canvas_view)
+{
+       synfig::info("Entered Eyedrop State");
+       canvas_view->work_area->set_cursor(Gdk::Cursor(Gdk::CROSSHAIR));
+
+       App::toolbox->refresh();
+}
+
+StateEyedrop_Context::~StateEyedrop_Context()
+{
+       synfig::info("Left Eyedrop State");
+       canvas_view->work_area->reset_cursor();
+       App::toolbox->refresh();
+}
+
+Smach::event_result
+StateEyedrop_Context::event_stop_handler(const Smach::event& /*x*/)
+{
+       //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;
+}
+
+Smach::event_result
+StateEyedrop_Context::event_refresh_handler(const Smach::event& /*x*/)
+{
+       synfig::info("STATE EYEDROP: Received Refresh Event");
+       canvas_view->work_area->queue_render_preview();
+       return Smach::RESULT_ACCEPT;
+}
+
+Smach::event_result
+StateEyedrop_Context::event_workarea_mouse_button_down_handler(const Smach::event& x)
+{
+       synfig::info("STATE EYEDROP: Received mouse button down Event");
+       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
+       if(event.button==BUTTON_LEFT)
+       {
+               Color color(canvas_view->get_canvas()->get_context().get_color(event.pos));
+               synfigapp::Main::set_outline_color(color);
+               studio::App::dialog_color->set_color(color);
+               return Smach::RESULT_ACCEPT;
+       }
+       return Smach::RESULT_OK;
+}
diff --git a/synfig-studio/src/gui/state_eyedrop.h b/synfig-studio/src/gui/state_eyedrop.h
new file mode 100644 (file)
index 0000000..4a90021
--- /dev/null
@@ -0,0 +1,56 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_eyedrop.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_STATE_EYEDROP_H
+#define __SYNFIG_STATE_EYEDROP_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 StateEyedrop_Context;
+
+class StateEyedrop : public Smach::state<StateEyedrop_Context>
+{
+public:
+       StateEyedrop();
+       ~StateEyedrop();
+}; // END of class StateEyedrop
+
+extern StateEyedrop state_eyedrop;
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/state_fill.cpp b/synfig-studio/src/gui/state_fill.cpp
new file mode 100644 (file)
index 0000000..f4df2ba
--- /dev/null
@@ -0,0 +1,182 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_fill.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "state_fill.h"
+#include "state_normal.h"
+#include "workarea.h"
+#include <synfig/context.h>
+#include "app.h"
+#include "dialog_color.h"
+#include "event_mouse.h"
+#include "event_layerclick.h"
+#include "toolbox.h"
+#include "canvasview.h"
+#include <synfigapp/main.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 ========================================================= */
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+class studio::StateFill_Context
+{
+       CanvasView *canvas_view;
+       CanvasView::IsWorking is_working;
+
+public:
+       StateFill_Context(CanvasView *canvas_view);
+       ~StateFill_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_workarea_layer_clicked_handler(const Smach::event& x);
+
+
+       etl::handle<CanvasView> get_canvas_view()const{return canvas_view;}
+       etl::handle<synfigapp::CanvasInterface> 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();}
+
+
+}; // END of class StateFill_Context
+
+/* === G L O B A L S ======================================================= */
+
+StateFill studio::state_fill;
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+StateFill::StateFill():
+       Smach::state<StateFill_Context>("fill")
+{
+       insert(event_def(EVENT_LAYER_SELECTION_CHANGED,&StateFill_Context::event_stop_handler));
+       insert(event_def(EVENT_STOP,&StateFill_Context::event_stop_handler));
+       insert(event_def(EVENT_REFRESH,&StateFill_Context::event_refresh_handler));
+       insert(event_def(EVENT_WORKAREA_LAYER_CLICKED,&StateFill_Context::event_workarea_layer_clicked_handler));
+}
+
+StateFill::~StateFill()
+{
+}
+
+StateFill_Context::StateFill_Context(CanvasView *canvas_view):
+       canvas_view(canvas_view),
+       is_working(*canvas_view)
+{
+       synfig::info("Entered Fill State");
+       canvas_view->work_area->set_cursor(Gdk::CROSSHAIR);
+
+       App::toolbox->refresh();
+}
+
+StateFill_Context::~StateFill_Context()
+{
+       synfig::info("Left Fill State");
+       canvas_view->work_area->reset_cursor();
+       App::toolbox->refresh();
+}
+
+Smach::event_result
+StateFill_Context::event_stop_handler(const Smach::event& /*x*/)
+{
+       synfig::info("STATE FILL: Received Stop Event");
+       //throw Smach::egress_exception();
+       throw &state_normal;
+       return Smach::RESULT_OK;
+//     canvas_view->get_smach().pop_state();
+//     return Smach::RESULT_ACCEPT;
+}
+
+Smach::event_result
+StateFill_Context::event_refresh_handler(const Smach::event& /*x*/)
+{
+       synfig::info("STATE FILL: Received Refresh Event");
+       canvas_view->work_area->queue_render_preview();
+       return Smach::RESULT_ACCEPT;
+}
+
+Smach::event_result
+StateFill_Context::event_workarea_layer_clicked_handler(const Smach::event& x)
+{
+       synfig::info("STATE FILL: Received layer clicked Event");
+       const EventLayerClick& event(*reinterpret_cast<const EventLayerClick*>(&x));
+
+       if(!event.layer)
+       {
+               get_canvas_view()->get_ui_interface()->warning(_("No layer here"));
+               return Smach::RESULT_ACCEPT;
+       }
+
+
+       //synfigapp::Action::Handle action(synfigapp::Action::create("ValueDescSet"));
+       synfigapp::ValueDesc value_desc(event.layer,"color");
+
+       if(!get_canvas_interface()->change_value(value_desc,ValueBase(synfigapp::Main::get_fill_color())))
+       {
+               get_canvas_view()->get_ui_interface()->warning(_("Unable to set layer color"));
+               return Smach::RESULT_ERROR;
+       }
+       /*
+       assert(action);
+
+       action->set_param("canvas",get_canvas());
+       action->set_param("canvas_interface",get_canvas_interface());
+       action->set_param("value_desc",value_desc);
+       action->set_param("time",get_canvas_interface()->get_time());
+       //action->set_param("layer",event.layer);
+       //if(!action->set_param("param",String("color")))
+       //      synfig::error("LayerParamConnect didn't like \"param\"");
+       if(!action->set_param("new_value",ValueBase(synfigapp::Main::get_fill_color())))
+               synfig::error("LayerParamConnect didn't like \"fill_color\"");
+
+       if(!get_canvas_interface()->get_instance()->perform_action(action))
+       {
+               get_canvas_view()->get_ui_interface()->warning(_("Unable to set layer color"));
+               return Smach::RESULT_ERROR;
+       }
+       get_canvas_view()->get_ui_interface()->task(_("Idle"));
+       */
+       return Smach::RESULT_ACCEPT;
+}
diff --git a/synfig-studio/src/gui/state_fill.h b/synfig-studio/src/gui/state_fill.h
new file mode 100644 (file)
index 0000000..349a1ce
--- /dev/null
@@ -0,0 +1,56 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_fill.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_STATE_FILL_H
+#define __SYNFIG_STATE_FILL_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 StateFill_Context;
+
+class StateFill : public Smach::state<StateFill_Context>
+{
+public:
+       StateFill();
+       ~StateFill();
+}; // END of class StateFill
+
+extern StateFill state_fill;
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/state_gradient.cpp b/synfig-studio/src/gui/state_gradient.cpp
new file mode 100644 (file)
index 0000000..8e36214
--- /dev/null
@@ -0,0 +1,546 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_gradient.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 <config.h>
+#endif
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/entry.h>
+
+#include <synfig/valuenode_dynamiclist.h>
+#include <synfigapp/action_system.h>
+
+#include "state_gradient.h"
+#include "state_normal.h"
+#include "canvasview.h"
+#include "workarea.h"
+#include "app.h"
+
+#include <synfigapp/action.h>
+#include "event_mouse.h"
+#include "event_layerclick.h"
+#include "toolbox.h"
+#include "dialog_tooloptions.h"
+#include <gtkmm/optionmenu.h>
+#include "duck.h"
+
+#include "widget_enum.h"
+#include <synfigapp/main.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 ========================================================= */
+
+enum
+{
+       GRADIENT_INTERPOLATION_LINEAR=0,
+       GRADIENT_RADIAL=1,
+       GRADIENT_CONICAL=2,
+       GRADIENT_SPIRAL=3
+};
+
+/* === G L O B A L S ======================================================= */
+
+StateGradient studio::state_gradient;
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+class studio::StateGradient_Context : public sigc::trackable
+{
+       etl::handle<CanvasView> canvas_view_;
+       CanvasView::IsWorking is_working;
+
+       Duckmatic::Push duckmatic_push;
+
+       synfigapp::Settings& settings;
+
+       Point point_holder;
+
+       etl::handle<Duck> point2_duck;
+
+       void refresh_ducks();
+
+       bool prev_workarea_layer_status_;
+
+       Gtk::Table options_table;
+       Gtk::Entry entry_id;
+       Widget_Enum enum_type;
+#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
+       Widget_Enum     enum_blend;
+#endif // BLEND_METHOD_IN_TOOL_OPTIONS
+
+public:
+       synfig::String get_id()const { return entry_id.get_text(); }
+       void set_id(const synfig::String& x) { return entry_id.set_text(x); }
+
+       int get_type()const { return enum_type.get_value(); }
+       void set_type(int x) { return enum_type.set_value(x); }
+
+#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
+       int get_blend()const { return enum_blend.get_value(); }
+       void set_blend(int x) { return enum_blend.set_value(x); }
+#endif // BLEND_METHOD_IN_TOOL_OPTIONS
+
+       Smach::event_result event_stop_handler(const Smach::event& x);
+
+       Smach::event_result event_refresh_handler(const Smach::event& x);
+
+       Smach::event_result event_mouse_click_handler(const Smach::event& x);
+       Smach::event_result event_refresh_tool_options(const Smach::event& x);
+
+       void refresh_tool_options();
+
+       StateGradient_Context(CanvasView* canvas_view);
+
+       ~StateGradient_Context();
+
+       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
+       etl::handle<synfigapp::CanvasInterface> 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 on_user_click(synfig::Point point);
+       void load_settings();
+       void save_settings();
+       void reset();
+       void increment_id();
+
+       void make_gradient(const Point& p1, const Point& p2);
+       bool egress_on_selection_change;
+       Smach::event_result event_layer_selection_changed_handler(const Smach::event& /*x*/)
+       {
+               if(egress_on_selection_change)
+                       throw &state_normal; //throw Smach::egress_exception();
+               return Smach::RESULT_OK;
+       }
+
+};     // END of class StateGradient_Context
+
+/* === M E T H O D S ======================================================= */
+
+StateGradient::StateGradient():
+       Smach::state<StateGradient_Context>("gradient")
+{
+       insert(event_def(EVENT_LAYER_SELECTION_CHANGED,&StateGradient_Context::event_layer_selection_changed_handler));
+       insert(event_def(EVENT_STOP,&StateGradient_Context::event_stop_handler));
+       insert(event_def(EVENT_TABLES_SHOW,&StateGradient_Context::event_stop_handler));
+       insert(event_def(EVENT_REFRESH,&StateGradient_Context::event_refresh_handler));
+       insert(event_def(EVENT_REFRESH_DUCKS,&StateGradient_Context::event_refresh_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StateGradient_Context::event_mouse_click_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DRAG,&StateGradient_Context::event_mouse_click_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_UP,&StateGradient_Context::event_mouse_click_handler));
+       insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateGradient_Context::event_refresh_tool_options));
+}
+
+StateGradient::~StateGradient()
+{
+}
+
+void
+StateGradient_Context::load_settings()
+{
+       String value;
+
+       if(settings.get_value("gradient.id",value))
+               set_id(value);
+       else
+               set_id("Gradient");
+
+       if(settings.get_value("gradient.type",value))
+               set_type(atoi(value.c_str()));
+       else
+               set_type(GRADIENT_INTERPOLATION_LINEAR);
+
+#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
+       if(settings.get_value("gradient.blend",value))
+               set_blend(atoi(value.c_str()));
+       else
+               set_blend(Color::BLEND_COMPOSITE);
+#endif // BLEND_METHOD_IN_TOOL_OPTIONS
+}
+
+void
+StateGradient_Context::save_settings()
+{
+       settings.set_value("gradient.id",get_id().c_str());
+       settings.set_value("gradient.type",strprintf("%d",get_type()));
+#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
+       settings.set_value("gradient.blend",strprintf("%d",get_blend()));
+#endif // BLEND_METHOD_IN_TOOL_OPTIONS
+}
+
+void
+StateGradient_Context::reset()
+{
+       refresh_ducks();
+}
+
+void
+StateGradient_Context::increment_id()
+{
+       String id(get_id());
+       int number=1;
+       int digits=0;
+
+       if(id.empty())
+               id="Gradient";
+
+       // If there is a number
+       // already at the end of the
+       // id, then remove it.
+       if(id[id.size()-1]<='9' && id[id.size()-1]>='0')
+       {
+               // figure out how many digits it is
+               for (digits = 0;
+                        (int)id.size()-1 >= digits && id[id.size()-1-digits] <= '9' && id[id.size()-1-digits] >= '0';
+                        digits++)
+                       ;
+
+               String str_number;
+               str_number=String(id,id.size()-digits,id.size());
+               id=String(id,0,id.size()-digits);
+
+               number=atoi(str_number.c_str());
+       }
+       else
+       {
+               number=1;
+               digits=3;
+       }
+
+       number++;
+
+       // Add the number back onto the id
+       {
+               const String format(strprintf("%%0%dd",digits));
+               id+=strprintf(format.c_str(),number);
+       }
+
+       // Set the ID
+       set_id(id);
+}
+
+StateGradient_Context::StateGradient_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()),
+       prev_workarea_layer_status_(get_work_area()->get_allow_layer_clicks()),
+       entry_id()
+{
+       egress_on_selection_change=true;
+       // Set up the tool options dialog
+       options_table.attach(*manage(new Gtk::Label(_("Gradient Tool"))),       0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(entry_id,                                                                          0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       enum_type.set_param_desc(ParamDesc("type")
+               .set_local_name(_("Gradient Type"))
+               .set_description(_("Determines the type of Gradient used"))
+               .set_hint("enum")
+               .add_enum_value(GRADIENT_INTERPOLATION_LINEAR,"linear",_("Linear"))
+               .add_enum_value(GRADIENT_RADIAL,"radial",_("Radial"))
+               .add_enum_value(GRADIENT_CONICAL,"conical",_("Conical"))
+               .add_enum_value(GRADIENT_SPIRAL,"spiral",_("Spiral")));
+
+#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
+       enum_blend.set_param_desc(ParamDesc(Color::BLEND_COMPOSITE,"blend_method")
+               .set_local_name(_("Blend Method"))
+               .set_description(_("The blend method the gradient will use")));
+#endif // BLEND_METHOD_IN_TOOL_OPTIONS
+
+       load_settings();
+
+       options_table.attach(enum_type, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
+       options_table.attach(enum_blend, 0, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+#endif // BLEND_METHOD_IN_TOOL_OPTIONS
+
+       options_table.show_all();
+       refresh_tool_options();
+       App::dialog_tool_options->present();
+
+
+       // Turn off layer clicking
+       get_work_area()->set_allow_layer_clicks(false);
+
+       get_work_area()->set_cursor(Gdk::CROSSHAIR);
+
+       // clear out the ducks
+       get_work_area()->clear_ducks();
+
+       // Refresh the work area
+       get_work_area()->queue_draw();
+
+       get_work_area()->refresh_cursor();
+
+       // Hide the tables if they are showing
+       get_canvas_view()->hide_tables();
+
+       // Disable the time bar
+       //get_canvas_view()->set_sensitive_timebar(false);
+
+       // Connect a signal
+       //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateGradient_Context::on_user_click));
+
+       App::toolbox->refresh();
+}
+
+void
+StateGradient_Context::refresh_tool_options()
+{
+       App::dialog_tool_options->clear();
+       App::dialog_tool_options->set_widget(options_table);
+       App::dialog_tool_options->set_local_name(_("Gradient Tool"));
+       App::dialog_tool_options->set_name("gradient");
+}
+
+Smach::event_result
+StateGradient_Context::event_refresh_tool_options(const Smach::event& /*x*/)
+{
+       refresh_tool_options();
+       return Smach::RESULT_ACCEPT;
+}
+
+StateGradient_Context::~StateGradient_Context()
+{
+       save_settings();
+
+       // Restore layer clicking
+//     get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_);
+       get_work_area()->set_allow_layer_clicks(true);
+       get_work_area()->reset_cursor();
+
+       App::dialog_tool_options->clear();
+
+       // Enable the time bar
+       //get_canvas_view()->set_sensitive_timebar(true);
+
+       // Bring back the tables if they were out before
+       //if(prev_table_status)get_canvas_view()->show_tables();
+
+       // Refresh the work area
+       get_work_area()->queue_draw();
+
+       get_canvas_view()->queue_rebuild_ducks();
+
+       //get_canvas_view()->show_tables();
+
+       get_work_area()->refresh_cursor();
+
+       App::toolbox->refresh();
+}
+
+Smach::event_result
+StateGradient_Context::event_stop_handler(const Smach::event& /*x*/)
+{
+       //throw Smach::egress_exception();
+       throw &state_normal;
+       return Smach::RESULT_OK;
+}
+
+Smach::event_result
+StateGradient_Context::event_refresh_handler(const Smach::event& /*x*/)
+{
+       refresh_ducks();
+       return Smach::RESULT_ACCEPT;
+}
+
+void
+StateGradient_Context::make_gradient(const Point& _p1, const Point& _p2)
+{
+       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("New Gradient"));
+       synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+       Layer::Handle layer;
+
+       Canvas::Handle canvas(get_canvas_view()->get_canvas());
+       int depth(0);
+
+       // we are temporarily using the layer to hold something
+       layer=get_canvas_view()->get_selection_manager()->get_selected_layer();
+       if(layer)
+       {
+               depth=layer->get_depth();
+               canvas=layer->get_canvas();
+       }
+       const synfig::TransformStack& transform(get_canvas_view()->get_curr_transform_stack());
+       const Point p1(transform.unperform(_p1));
+       const Point p2(transform.unperform(_p2));
+
+       switch(get_type())
+       {
+       case GRADIENT_INTERPOLATION_LINEAR:
+
+               layer=get_canvas_interface()->add_layer_to("linear_gradient",canvas,depth);
+               if (!layer)
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                       group.cancel();
+                       return;
+               }
+               layer->set_param("p1",p1);
+               get_canvas_interface()->signal_layer_param_changed()(layer,"p1");
+               layer->set_param("p2",p2);
+               get_canvas_interface()->signal_layer_param_changed()(layer,"p2");
+               break;
+       case GRADIENT_RADIAL:
+               layer=get_canvas_interface()->add_layer_to("radial_gradient",canvas,depth);
+               if (!layer)
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                       group.cancel();
+                       return;
+               }
+               layer->set_param("center",p1);
+               get_canvas_interface()->signal_layer_param_changed()(layer,"center");
+               layer->set_param("radius",(p2-p1).mag());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"radius");
+               break;
+       case GRADIENT_CONICAL:
+               layer=get_canvas_interface()->add_layer_to("conical_gradient",canvas,depth);
+               if (!layer)
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                       group.cancel();
+                       return;
+               }
+               layer->set_param("center",p1);
+               get_canvas_interface()->signal_layer_param_changed()(layer,"center");
+               {
+                       Vector diff(p2-p1);
+                       layer->set_param("angle",Angle::tan(diff[1],diff[0]));
+                       get_canvas_interface()->signal_layer_param_changed()(layer,"angle");
+               }
+               break;
+       case GRADIENT_SPIRAL:
+               layer=get_canvas_interface()->add_layer_to("spiral_gradient",canvas,depth);
+               if (!layer)
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                       group.cancel();
+                       return;
+               }
+               layer->set_param("center",p1);
+               get_canvas_interface()->signal_layer_param_changed()(layer,"center");
+               layer->set_param("radius",(p2-p1).mag());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"radius");
+               {
+                       Vector diff(p2-p1);
+                       layer->set_param("angle",Angle::tan(diff[1],diff[0]));
+                       get_canvas_interface()->signal_layer_param_changed()(layer,"angle");
+               }
+               break;
+
+       default:
+               return;
+       }
+
+#ifdef BLEND_METHOD_IN_TOOL_OPTIONS
+       layer->set_param("blend_method",get_blend());
+       get_canvas_interface()->signal_layer_param_changed()(layer,"blend_method");
+#endif // BLEND_METHOD_IN_TOOL_OPTIONS
+
+       layer->set_description(get_id());
+       get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+       egress_on_selection_change=false;
+       synfigapp::SelectionManager::LayerList layer_selection;
+       if (!getenv("SYNFIG_TOOLS_CLEAR_SELECTION"))
+               layer_selection = get_canvas_view()->get_selection_manager()->get_selected_layers();
+       get_canvas_interface()->get_selection_manager()->clear_selected_layers();
+       layer_selection.push_back(layer);
+       get_canvas_interface()->get_selection_manager()->set_selected_layers(layer_selection);
+       egress_on_selection_change=true;
+
+       reset();
+       increment_id();
+}
+
+Smach::event_result
+StateGradient_Context::event_mouse_click_handler(const Smach::event& x)
+{
+       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
+
+       if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_DOWN && event.button==BUTTON_LEFT)
+       {
+               point_holder=get_work_area()->snap_point_to_grid(event.pos);
+               etl::handle<Duck> duck=new Duck();
+               duck->set_point(point_holder);
+               duck->set_name("p1");
+               duck->set_type(Duck::TYPE_POSITION);
+               get_work_area()->add_duck(duck);
+
+               point2_duck=new Duck();
+               point2_duck->set_point(point_holder);
+               point2_duck->set_name("p2");
+               point2_duck->set_type(Duck::TYPE_POSITION);
+               get_work_area()->add_duck(point2_duck);
+
+               handle<Duckmatic::Bezier> bezier(new Duckmatic::Bezier());
+               bezier->p1=bezier->c1=duck;
+               bezier->p2=bezier->c2=point2_duck;
+               get_work_area()->add_bezier(bezier);
+
+               return Smach::RESULT_ACCEPT;
+       }
+
+       if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_DRAG && event.button==BUTTON_LEFT)
+       {
+               if (!point2_duck) return Smach::RESULT_OK;
+               point2_duck->set_point(get_work_area()->snap_point_to_grid(event.pos));
+               get_work_area()->queue_draw();
+               return Smach::RESULT_ACCEPT;
+       }
+
+       if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_UP && event.button==BUTTON_LEFT)
+       {
+               make_gradient(point_holder, get_work_area()->snap_point_to_grid(event.pos));
+               get_work_area()->clear_ducks();
+               return Smach::RESULT_ACCEPT;
+       }
+
+       return Smach::RESULT_OK;
+}
+
+
+void
+StateGradient_Context::refresh_ducks()
+{
+       get_work_area()->clear_ducks();
+       get_work_area()->queue_draw();
+}
diff --git a/synfig-studio/src/gui/state_gradient.h b/synfig-studio/src/gui/state_gradient.h
new file mode 100644 (file)
index 0000000..308b5ee
--- /dev/null
@@ -0,0 +1,56 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_gradient.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_GRADIENT_H
+#define __SYNFIG_STUDIO_STATE_GRADIENT_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 StateGradient_Context;
+
+class StateGradient : public Smach::state<StateGradient_Context>
+{
+public:
+       StateGradient();
+       ~StateGradient();
+}; // END of class StateGradient
+
+extern StateGradient state_gradient;
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/state_normal.cpp b/synfig-studio/src/gui/state_normal.cpp
new file mode 100644 (file)
index 0000000..c763022
--- /dev/null
@@ -0,0 +1,824 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_normal.cpp
+**     \brief Template 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 <config.h>
+#endif
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/entry.h>
+
+#include <synfig/valuenode_animated.h>
+#include <synfig/valuenode_blinecalcvertex.h>
+#include <synfig/valuenode_composite.h>
+#include <synfig/valuenode_const.h>
+#include <synfig/valuenode_dynamiclist.h>
+#include <synfigapp/action_system.h>
+
+#include "state_normal.h"
+#include "canvasview.h"
+#include "workarea.h"
+#include "app.h"
+
+#include <synfigapp/action.h>
+#include "event_mouse.h"
+#include "event_layerclick.h"
+#include "toolbox.h"
+#include "dialog_tooloptions.h"
+#include <gtkmm/optionmenu.h>
+#include "duck.h"
+#include <synfig/angle.h>
+#include <synfigapp/main.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 ========================================================= */
+
+#ifndef EPSILON
+#define EPSILON        0.0000001
+#endif
+
+/* === G L O B A L S ======================================================= */
+
+StateNormal studio::state_normal;
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+class DuckDrag_Combo : public DuckDrag_Base
+{
+       synfig::Vector last_move;
+       synfig::Vector drag_offset;
+       synfig::Vector center;
+       synfig::Vector snap;
+
+       synfig::Angle original_angle;
+       synfig::Real original_mag;
+
+       std::vector<synfig::Vector> last_;
+       std::vector<synfig::Vector> positions;
+
+
+       bool bad_drag;
+       bool move_only;
+
+public:
+       etl::handle<CanvasView> canvas_view_;
+       bool scale;
+       bool rotate;
+       bool constrain;
+       DuckDrag_Combo();
+       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<synfigapp::CanvasInterface> get_canvas_interface()const{return canvas_view_->canvas_interface();}
+};
+
+
+class studio::StateNormal_Context : public sigc::trackable
+{
+       etl::handle<CanvasView> canvas_view_;
+
+       synfigapp::Settings& settings;
+
+       sigc::connection keypress_connect;
+       sigc::connection keyrelease_connect;
+
+       etl::handle<DuckDrag_Combo> duck_dragger_;
+
+       Gtk::Table options_table;
+
+       Gtk::CheckButton checkbutton_rotate;
+       Gtk::CheckButton checkbutton_scale;
+       Gtk::CheckButton checkbutton_constrain;
+
+public:
+
+       bool get_rotate_flag()const { return checkbutton_rotate.get_active(); }
+       void set_rotate_flag(bool x) { checkbutton_rotate.set_active(x); refresh_rotate_flag(); }
+       void refresh_rotate_flag() { if(duck_dragger_)duck_dragger_->rotate=get_rotate_flag(); }
+
+       bool get_scale_flag()const { return checkbutton_scale.get_active(); }
+       void set_scale_flag(bool x) { checkbutton_scale.set_active(x); refresh_scale_flag(); }
+       void refresh_scale_flag() { if(duck_dragger_)duck_dragger_->scale=get_scale_flag(); }
+
+       bool get_constrain_flag()const { return checkbutton_constrain.get_active(); }
+       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(); }
+
+       StateNormal_Context(CanvasView* canvas_view);
+
+       ~StateNormal_Context();
+
+       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
+       etl::handle<synfigapp::CanvasInterface> 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();
+
+       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 ======================================================= */
+
+StateNormal::StateNormal():
+       Smach::state<StateNormal_Context>("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()
+{
+}
+
+void
+StateNormal_Context::load_settings()
+{
+       String value;
+
+       if(settings.get_value("normal.rotate",value) && value=="1")
+               set_rotate_flag(true);
+       else
+               set_rotate_flag(false);
+
+       if(settings.get_value("normal.scale",value) && value=="1")
+               set_scale_flag(true);
+       else
+               set_scale_flag(false);
+
+       if(settings.get_value("normal.constrain",value) && value=="1")
+               set_constrain_flag(true);
+       else
+               set_constrain_flag(false);
+
+}
+
+void
+StateNormal_Context::save_settings()
+{
+       settings.set_value("normal.rotate",get_rotate_flag()?"1":"0");
+       settings.set_value("normal.scale",get_scale_flag()?"1":"0");
+       settings.set_value("normal.constrain",get_constrain_flag()?"1":"0");
+}
+
+StateNormal_Context::StateNormal_Context(CanvasView* canvas_view):
+       canvas_view_(canvas_view),
+       settings(synfigapp::Main::get_selected_input_device()->settings()),
+       duck_dragger_(new DuckDrag_Combo()),
+       checkbutton_rotate(_("Rotate (Ctrl)")),
+       checkbutton_scale(_("Scale (Alt)")),
+       checkbutton_constrain(_("Constrain (Shift)"))
+{
+       duck_dragger_->canvas_view_=get_canvas_view();
+
+       // Set up the tool options dialog
+       options_table.attach(*manage(new Gtk::Label(_("Normal Tool"))), 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_rotate,                                                        0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_scale,                                                 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_constrain,                                                     0, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       checkbutton_rotate.signal_toggled().connect(sigc::mem_fun(*this,&StateNormal_Context::refresh_rotate_flag));
+       checkbutton_scale.signal_toggled().connect(sigc::mem_fun(*this,&StateNormal_Context::refresh_scale_flag));
+       checkbutton_constrain.signal_toggled().connect(sigc::mem_fun(*this,&StateNormal_Context::refresh_constrain_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_);
+
+       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);
+
+       //these will segfault
+//     get_work_area()->set_cursor(Gdk::CROSSHAIR);
+//     get_work_area()->reset_cursor();
+
+       App::toolbox->refresh();
+
+       load_settings();
+       refresh_scale_flag();
+}
+
+bool
+StateNormal_Context::key_pressed(GdkEventKey *event)
+{
+       switch(event->keyval)
+       {
+               case GDK_Control_L:
+               case GDK_Control_R:
+                       set_rotate_flag(true);
+                       break;
+               case GDK_Alt_L:
+               case GDK_Alt_R:
+                       set_scale_flag(true);
+                       break;
+               case GDK_Shift_L:
+               case GDK_Shift_R:
+                       set_constrain_flag(true);
+                       break;
+               default:
+                       break;
+       }
+       return false; //Pass on the event to other handlers, just in case
+}
+
+bool
+StateNormal_Context::key_released(GdkEventKey *event)
+{
+       switch(event->keyval)
+       {
+               case GDK_Control_L:
+               case GDK_Control_R:
+                       set_rotate_flag(false);
+                       break;
+               case GDK_Alt_L:
+               case GDK_Alt_R:
+                       set_scale_flag(false);
+                       break;
+               case GDK_Shift_L:
+               case GDK_Shift_R:
+                       set_constrain_flag(false);
+                       break;
+               default:
+                       break;
+       }
+       return false; //Pass on the event to other handlers
+}
+
+void
+StateNormal_Context::refresh_tool_options()
+{
+       App::dialog_tool_options->clear();
+       App::dialog_tool_options->set_widget(options_table);
+       App::dialog_tool_options->set_local_name(_("Normal Tool"));
+       App::dialog_tool_options->set_name("normal");
+}
+
+
+
+StateNormal_Context::~StateNormal_Context()
+{
+       save_settings();
+
+       get_work_area()->clear_duck_dragger();
+       get_work_area()->reset_cursor();
+
+       keypress_connect.disconnect();
+       keyrelease_connect.disconnect();
+
+       App::dialog_tool_options->clear();
+
+       App::toolbox->refresh();
+}
+
+DuckDrag_Combo::DuckDrag_Combo():
+       scale(false),
+       rotate(false),
+       constrain(false) // Lock aspect for scale; smooth move for translate
+{
+}
+
+void
+DuckDrag_Combo::begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& offset)
+{
+       last_move=Vector(1,1);
+
+       const DuckList selected_ducks(duckmatic->get_selected_ducks());
+       DuckList::const_iterator iter;
+
+       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<etl::handle<Duck> >::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_Combo::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector)
+{
+       if (!duckmatic) return;
+
+       if(bad_drag)
+               return;
+
+       //Override axis lock set in workarea when holding down the shift key
+       if (!move_only && (scale || rotate))
+               duckmatic->set_axis_lock(false);
+
+       synfig::Vector vect;
+       if (move_only || (!scale && !rotate))
+               vect= duckmatic->snap_point_to_grid(vector)-drag_offset+snap;
+       else
+               vect= duckmatic->snap_point_to_grid(vector)-center+snap;
+
+       last_move=vect;
+
+       const DuckList selected_ducks(duckmatic->get_selected_ducks());
+       DuckList::const_iterator iter;
+
+       Time time(duckmatic->get_time());
+
+       int i;
+       if( move_only || (!scale && !rotate) )
+       {
+               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)
+                               (*iter)->set_trans_point(positions[i]+vect, time);
+               }
+               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)
+                               (*iter)->set_trans_point(positions[i]+vect, time);
+               }
+       }
+
+       if (rotate)
+       {
+               Angle::deg angle(Angle::tan(vect[1],vect[0]));
+               angle=original_angle-angle;
+               if (constrain)
+               {
+                       float degrees = angle.get()/15;
+                       angle= Angle::deg (degrees>0?std::floor(degrees)*15:std::ceil(degrees)*15);
+               }
+               Real mag(vect.mag()/original_mag);
+               Real sine(Angle::sin(angle).get());
+               Real cosine(Angle::cos(angle).get());
+
+               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(scale)p*=mag;
+                       p+=center;
+                       (*iter)->set_trans_point(p, time);
+               }
+               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(scale)p*=mag;
+                       p+=center;
+                       (*iter)->set_trans_point(p, time);
+               }
+       } else if (scale)
+       {
+               if(!constrain)
+               {
+                       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]>-EPSILON)
+                       vect[0]=1;
+               if(vect[1]<EPSILON && vect[1]>-EPSILON)
+                       vect[1]=1;
+
+               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, time);
+               }
+               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, time);
+               }
+       }
+
+       // then patch up the tangents for the vertices we've moved
+       duckmatic->update_ducks();
+
+       last_move=vect;
+}
+
+bool
+DuckDrag_Combo::end_duck_drag(Duckmatic* duckmatic)
+{
+       if(bad_drag)return false;
+
+       //synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Rotate Ducks"));
+
+       if((last_move-Vector(1,1)).mag()>0.0001)
+       {
+               duckmatic->signal_edited_selected_ducks();
+               return true;
+       }
+       else
+       {
+               duckmatic->signal_user_click_selected_ducks(0);
+               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<const EventMouse*>(&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<const EventLayerClick*>(&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::Handle> layer_list(canvas_view_->get_selection_manager()->get_selected_layers());
+                       std::set<Layer::Handle> layers(layer_list.begin(),layer_list.end());
+                       if(layers.count(event.layer))
+                       {
+                               layers.erase(event.layer);
+                               layer_list=std::list<Layer::Handle>(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<synfigapp::ValueDesc> 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<synfigapp::ValueDesc>::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<const EventMouse*>(&x));
+
+       std::list<synfigapp::ValueDesc> 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/gui/state_normal.h b/synfig-studio/src/gui/state_normal.h
new file mode 100644 (file)
index 0000000..01b040b
--- /dev/null
@@ -0,0 +1,57 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_normal.h
+**     \brief Template 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_STUDIO_STATE_NORMAL_H
+#define __SYNFIG_STUDIO_STATE_NORMAL_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 StateNormal_Context;
+
+class StateNormal : public Smach::state<StateNormal_Context>
+{
+public:
+       StateNormal();
+       ~StateNormal();
+}; // END of class StateNormal
+
+extern StateNormal state_normal;
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/state_polygon.cpp b/synfig-studio/src/gui/state_polygon.cpp
new file mode 100644 (file)
index 0000000..7c11c05
--- /dev/null
@@ -0,0 +1,945 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_polygon.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 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 <config.h>
+#endif
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/entry.h>
+
+#include <synfig/valuenode_dynamiclist.h>
+#include <synfigapp/action_system.h>
+#include <synfig/valuenode_bline.h>
+
+#include "state_polygon.h"
+#include "state_normal.h"
+#include "canvasview.h"
+#include "workarea.h"
+#include "app.h"
+
+#include <synfigapp/action.h>
+#include "event_mouse.h"
+#include "event_layerclick.h"
+#include "toolbox.h"
+#include "dialog_tooloptions.h"
+#include <synfigapp/main.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 ======================================================= */
+
+StatePolygon studio::state_polygon;
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+class studio::StatePolygon_Context : public sigc::trackable
+{
+       etl::handle<CanvasView> canvas_view_;
+       CanvasView::IsWorking is_working;
+
+       bool prev_table_status;
+       bool prev_workarea_layer_status_;
+
+       Gtk::Menu menu;
+
+       Duckmatic::Push duckmatic_push;
+
+       std::list<synfig::Point> polygon_point_list;
+       synfigapp::Settings& settings;
+
+
+       bool on_polygon_duck_change(const synfig::Point &point, std::list<synfig::Point>::iterator iter);
+
+
+       void popup_handle_menu(synfigapp::ValueDesc value_desc);
+
+
+       void refresh_ducks();
+
+       Gtk::Table options_table;
+       Gtk::Entry entry_id;
+       Gtk::CheckButton checkbutton_invert;
+       Gtk::CheckButton checkbutton_layer_polygon;
+       Gtk::CheckButton checkbutton_layer_region;
+       Gtk::CheckButton checkbutton_layer_outline;
+       Gtk::CheckButton checkbutton_layer_curve_gradient;
+       Gtk::CheckButton checkbutton_layer_plant;
+       Gtk::CheckButton checkbutton_layer_link_origins;
+       Gtk::Button button_make;
+       Gtk::Adjustment  adj_feather;
+       Gtk::SpinButton  spin_feather;
+
+public:
+
+       // this counts the layers we create - they all have origins we can link
+       int layers_to_create()const
+       {
+               return
+                       get_layer_polygon_flag() +
+                       get_layer_region_flag() +
+                       get_layer_outline_flag() +
+                       get_layer_curve_gradient_flag() +
+                       get_layer_plant_flag();
+       }
+
+       synfig::String get_id()const { return entry_id.get_text(); }
+       void set_id(const synfig::String& x) { return entry_id.set_text(x); }
+
+       bool get_invert()const { return checkbutton_invert.get_active(); }
+       void set_invert(bool i) { checkbutton_invert.set_active(i); }
+
+       bool get_layer_polygon_flag()const { return checkbutton_layer_polygon.get_active(); }
+       void set_layer_polygon_flag(bool x) { return checkbutton_layer_polygon.set_active(x); }
+
+       bool get_layer_region_flag()const { return checkbutton_layer_region.get_active(); }
+       void set_layer_region_flag(bool x) { return checkbutton_layer_region.set_active(x); }
+
+       bool get_layer_outline_flag()const { return checkbutton_layer_outline.get_active(); }
+       void set_layer_outline_flag(bool x) { return checkbutton_layer_outline.set_active(x); }
+
+       bool get_layer_curve_gradient_flag()const { return checkbutton_layer_curve_gradient.get_active(); }
+       void set_layer_curve_gradient_flag(bool x) { return checkbutton_layer_curve_gradient.set_active(x); }
+
+       bool get_layer_plant_flag()const { return checkbutton_layer_plant.get_active(); }
+       void set_layer_plant_flag(bool x) { return checkbutton_layer_plant.set_active(x); }
+
+       bool get_layer_link_origins_flag()const { return checkbutton_layer_link_origins.get_active(); }
+       void set_layer_link_origins_flag(bool x) { return checkbutton_layer_link_origins.set_active(x); }
+
+       Real get_feather() const { return adj_feather.get_value(); }
+       void set_feather(Real x) { return adj_feather.set_value(x); }
+
+       Smach::event_result event_stop_handler(const Smach::event& x);
+
+       Smach::event_result event_refresh_handler(const Smach::event& x);
+
+       Smach::event_result event_mouse_click_handler(const Smach::event& x);
+       Smach::event_result event_refresh_tool_options(const Smach::event& x);
+       void refresh_tool_options();
+
+       StatePolygon_Context(CanvasView* canvas_view);
+
+       ~StatePolygon_Context();
+
+       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
+       etl::handle<synfigapp::CanvasInterface> 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 on_user_click(synfig::Point point);
+       void load_settings();
+       void save_settings();
+       void reset();
+       void increment_id();
+       bool egress_on_selection_change;
+       Smach::event_result event_layer_selection_changed_handler(const Smach::event& /*x*/)
+       {
+               if(egress_on_selection_change)
+                       throw &state_normal; //throw Smach::egress_exception();
+               return Smach::RESULT_OK;
+       }
+
+       void run();
+};     // END of class StatePolygon_Context
+
+/* === M E T H O D S ======================================================= */
+
+StatePolygon::StatePolygon():
+       Smach::state<StatePolygon_Context>("polygon")
+{
+       insert(event_def(EVENT_LAYER_SELECTION_CHANGED,&StatePolygon_Context::event_layer_selection_changed_handler));
+       insert(event_def(EVENT_STOP,&StatePolygon_Context::event_stop_handler));
+       insert(event_def(EVENT_REFRESH,&StatePolygon_Context::event_refresh_handler));
+       insert(event_def(EVENT_REFRESH_DUCKS,&StatePolygon_Context::event_refresh_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StatePolygon_Context::event_mouse_click_handler));
+       insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StatePolygon_Context::event_refresh_tool_options));
+}
+
+StatePolygon::~StatePolygon()
+{
+}
+
+void
+StatePolygon_Context::load_settings()
+{
+       String value;
+
+       if(settings.get_value("polygon.id",value))
+               set_id(value);
+       else
+               set_id("Polygon");
+
+       if(settings.get_value("polygon.invert",value) && value != "0")
+               set_invert(true);
+       else
+               set_invert(false);
+
+       if(settings.get_value("polygon.layer_polygon",value) && value=="0")
+               set_layer_polygon_flag(false);
+       else
+               set_layer_polygon_flag(true);
+
+       if(settings.get_value("polygon.layer_region",value) && value=="1")
+               set_layer_region_flag(true);
+       else
+               set_layer_region_flag(false);
+
+       if(settings.get_value("polygon.layer_outline",value) && value=="1")
+               set_layer_outline_flag(true);
+       else
+               set_layer_outline_flag(false);
+
+       if(settings.get_value("polygon.layer_curve_gradient",value) && value=="1")
+               set_layer_curve_gradient_flag(true);
+       else
+               set_layer_curve_gradient_flag(false);
+
+       if(settings.get_value("polygon.layer_plant",value) && value=="1")
+               set_layer_plant_flag(true);
+       else
+               set_layer_plant_flag(false);
+
+       if(settings.get_value("polygon.layer_link_origins",value) && value=="0")
+               set_layer_link_origins_flag(false);
+       else
+               set_layer_link_origins_flag(true);
+
+       if(settings.get_value("polygon.feather",value))
+       {
+               Real n = atof(value.c_str());
+               set_feather(n);
+       }
+}
+
+void
+StatePolygon_Context::save_settings()
+{
+       settings.set_value("polygon.id",get_id().c_str());
+       settings.set_value("polygon.invert",get_invert()?"1":"0");
+       settings.set_value("polygon.layer_polygon",get_layer_polygon_flag()?"1":"0");
+       settings.set_value("polygon.layer_outline",get_layer_outline_flag()?"1":"0");
+       settings.set_value("polygon.layer_region",get_layer_region_flag()?"1":"0");
+       settings.set_value("polygon.layer_curve_gradient",get_layer_curve_gradient_flag()?"1":"0");
+       settings.set_value("polygon.layer_plant",get_layer_plant_flag()?"1":"0");
+       settings.set_value("polygon.layer_link_origins",get_layer_link_origins_flag()?"1":"0");
+       settings.set_value("polygon.feather",strprintf("%f",get_feather()));
+}
+
+void
+StatePolygon_Context::reset()
+{
+       polygon_point_list.clear();
+       refresh_ducks();
+}
+
+void
+StatePolygon_Context::increment_id()
+{
+       String id(get_id());
+       int number=1;
+       int digits=0;
+
+       if(id.empty())
+               id="Polygon";
+
+       // If there is a number
+       // already at the end of the
+       // id, then remove it.
+       if(id[id.size()-1]<='9' && id[id.size()-1]>='0')
+       {
+               // figure out how many digits it is
+               for (digits = 0;
+                        (int)id.size()-1 >= digits && id[id.size()-1-digits] <= '9' && id[id.size()-1-digits] >= '0';
+                        digits++)
+                       ;
+
+               String str_number;
+               str_number=String(id,id.size()-digits,id.size());
+               id=String(id,0,id.size()-digits);
+
+               number=atoi(str_number.c_str());
+       }
+       else
+       {
+               number=1;
+               digits=3;
+       }
+
+       number++;
+
+       // Add the number back onto the id
+       {
+               const String format(strprintf("%%0%dd",digits));
+               id+=strprintf(format.c_str(),number);
+       }
+
+       // Set the ID
+       set_id(id);
+}
+
+StatePolygon_Context::StatePolygon_Context(CanvasView* canvas_view):
+       canvas_view_(canvas_view),
+       is_working(*canvas_view),
+       prev_workarea_layer_status_(get_work_area()->get_allow_layer_clicks()),
+       duckmatic_push(get_work_area()),
+       settings(synfigapp::Main::get_selected_input_device()->settings()),
+       entry_id(),
+       checkbutton_invert(_("Invert")),
+       checkbutton_layer_polygon(_("Create Polygon Layer")),
+       checkbutton_layer_region(_("Create Region BLine")),
+       checkbutton_layer_outline(_("Create Outline BLine")),
+       checkbutton_layer_curve_gradient(_("Create Curve Gradient BLine")),
+       checkbutton_layer_plant(_("Create Plant BLine")),
+       checkbutton_layer_link_origins(_("Link Origins")),
+       button_make(_("Make")),
+       adj_feather(0,0,10000,0.01,0.1),
+       spin_feather(adj_feather,0.01,4)
+{
+       egress_on_selection_change=true;
+       load_settings();
+
+       // Set up the tool options dialog
+       options_table.attach(*manage(new Gtk::Label(_("Polygon Tool"))),        0, 2, 0,  1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(entry_id,                                                                          0, 2, 1,  2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       options_table.attach(checkbutton_layer_polygon,                                         0, 2, 2,  3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_outline,                                         0, 2, 3,  4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_region,                                          0, 2, 4,  5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_plant,                                           0, 2, 5,  6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_curve_gradient,                          0, 2, 6,  7, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_link_origins,                            0, 2, 7,  8, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       //invert flag
+       options_table.attach(checkbutton_invert,                                                        0, 2, 8,  9, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       //feather stuff
+       options_table.attach(*manage(new Gtk::Label(_("Feather"))),             0, 1, 9, 10, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(spin_feather,                                                                      1, 2, 9, 10, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       //options_table.attach(button_make, 0, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       button_make.signal_pressed().connect(sigc::mem_fun(*this,&StatePolygon_Context::run));
+       options_table.show_all();
+       refresh_tool_options();
+       App::dialog_tool_options->present();
+
+
+       // Turn off layer clicking
+       get_work_area()->set_allow_layer_clicks(false);
+
+       // clear out the ducks
+       get_work_area()->clear_ducks();
+
+       // Refresh the work area
+       get_work_area()->queue_draw();
+
+       get_work_area()->set_cursor(Gdk::CROSSHAIR);
+
+       // Hide the tables if they are showing
+       prev_table_status=get_canvas_view()->tables_are_visible();
+       if(prev_table_status)get_canvas_view()->hide_tables();
+
+       // Disable the time bar
+       get_canvas_view()->set_sensitive_timebar(false);
+
+       // Connect a signal
+       //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StatePolygon_Context::on_user_click));
+
+       App::toolbox->refresh();
+}
+
+void
+StatePolygon_Context::refresh_tool_options()
+{
+       App::dialog_tool_options->clear();
+       App::dialog_tool_options->set_widget(options_table);
+
+       App::dialog_tool_options->set_local_name(_("Polygon Tool"));
+       App::dialog_tool_options->set_name("polygon");
+
+       App::dialog_tool_options->add_button(
+               Gtk::StockID("gtk-execute"),
+               _("Make Polygon")
+       )->signal_clicked().connect(
+               sigc::mem_fun(
+                       *this,
+                       &StatePolygon_Context::run
+               )
+       );
+
+       App::dialog_tool_options->add_button(
+               Gtk::StockID("gtk-clear"),
+               _("Clear current Polygon")
+       )->signal_clicked().connect(
+               sigc::mem_fun(
+                       *this,
+                       &StatePolygon_Context::reset
+               )
+       );
+}
+
+Smach::event_result
+StatePolygon_Context::event_refresh_tool_options(const Smach::event& /*x*/)
+{
+       refresh_tool_options();
+       return Smach::RESULT_ACCEPT;
+}
+
+StatePolygon_Context::~StatePolygon_Context()
+{
+       run();
+
+       save_settings();
+       // Restore layer clicking
+       get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_);
+
+       App::dialog_tool_options->clear();
+
+       get_work_area()->reset_cursor();
+
+       // Enable the time bar
+       get_canvas_view()->set_sensitive_timebar(true);
+
+       // Bring back the tables if they were out before
+       if(prev_table_status)get_canvas_view()->show_tables();
+
+       // Refresh the work area
+       get_work_area()->queue_draw();
+
+       App::toolbox->refresh();
+}
+
+Smach::event_result
+StatePolygon_Context::event_stop_handler(const Smach::event& /*x*/)
+{
+       synfig::info("STATE RotoPolygon: Received Stop Event");
+       //throw Smach::egress_exception();
+       reset();
+       return Smach::RESULT_ACCEPT;
+
+}
+
+Smach::event_result
+StatePolygon_Context::event_refresh_handler(const Smach::event& /*x*/)
+{
+       synfig::info("STATE RotoPolygon: Received Refresh Event");
+       refresh_ducks();
+       return Smach::RESULT_ACCEPT;
+}
+
+void
+StatePolygon_Context::run()
+{
+       if(polygon_point_list.empty())
+               return;
+
+       if(polygon_point_list.size()<3)
+       {
+               get_canvas_view()->get_ui_interface()->error("You need at least 3 points to create a polygon");
+               return;
+       }
+
+       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("New Polygon"));
+
+       Layer::Handle layer;
+
+       Canvas::Handle canvas;
+       int depth(0);
+
+       // we are temporarily using the layer to hold something
+       layer=get_canvas_view()->get_selection_manager()->get_selected_layer();
+       if(layer)
+       {
+               depth=layer->get_depth();
+               canvas=layer->get_canvas();
+       }
+
+       synfigapp::SelectionManager::LayerList layer_selection;
+       if (!getenv("SYNFIG_TOOLS_CLEAR_SELECTION"))
+               layer_selection = get_canvas_view()->get_selection_manager()->get_selected_layers();
+
+       const synfig::TransformStack& transform(get_canvas_view()->get_curr_transform_stack());
+
+       std::vector<BLinePoint> new_list;
+       std::list<synfig::Point>::iterator iter;
+       int i;
+       for(i=0,iter=polygon_point_list.begin();iter!=polygon_point_list.end();++iter,++i)
+       {
+               *iter = transform.unperform(*iter);
+               new_list.push_back(*(new BLinePoint));
+               new_list[i].set_width(1);
+               new_list[i].set_vertex(*iter);
+               new_list[i].set_tangent(Point(0,0));
+       }
+
+       ValueNode_BLine::Handle value_node_bline(ValueNode_BLine::create(new_list));
+       assert(value_node_bline);
+
+       ValueNode_Const::Handle value_node_origin(ValueNode_Const::create(Vector()));
+       assert(value_node_origin);
+
+       // Set the looping flag
+       value_node_bline->set_loop(true);
+
+       if(!canvas)
+               canvas=get_canvas_view()->get_canvas();
+
+       value_node_bline->set_member_canvas(canvas);
+
+       // count how many layers we're going to be creating
+       int layers_to_create = this->layers_to_create();
+
+       ///////////////////////////////////////////////////////////////////////////
+       //   P O L Y G O N
+       ///////////////////////////////////////////////////////////////////////////
+
+       if (get_layer_polygon_flag())
+       {
+               layer=get_canvas_interface()->add_layer_to("polygon",canvas,depth);
+               if (!layer)
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                       group.cancel();
+                       return;
+               }
+               layer_selection.push_back(layer);
+
+               layer->set_param("invert",get_invert());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
+
+               if(get_feather())
+               {
+                       layer->set_param("feather",get_feather());
+                       get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
+               }
+
+               layer->set_description(get_id());
+               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+               layer->disconnect_dynamic_param("vector_list");
+               if(!layer->set_param("vector_list",polygon_point_list))
+               {
+                       group.cancel();
+                       get_canvas_view()->get_ui_interface()->error("Unable to set layer parameter");
+                       return;
+               }
+
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("ValueDescConvert"));
+                       synfigapp::ValueDesc value_desc(layer,"vector_list");
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("value_desc",value_desc);
+                       action->set_param("type","dynamic_list");
+                       action->set_param("time",get_canvas_interface()->get_time());
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               group.cancel();
+                               get_canvas_view()->get_ui_interface()->error("Unable to execute action \"ValueDescConvert\"");
+                               return;
+                       }
+               }
+
+               // only link the polygon's origin parameter if the option is selected and we're creating more than one layer
+               if (get_layer_link_origins_flag() && layers_to_create > 1)
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("origin")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               get_canvas_view()->get_ui_interface()->error(_("Unable to create Polygon layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Polygon layer"));
+                               return;
+                       }
+               }
+       }
+
+       ///////////////////////////////////////////////////////////////////////////
+       //   C U R V E   G R A D I E N T
+       ///////////////////////////////////////////////////////////////////////////
+
+       if(get_layer_curve_gradient_flag())
+       {
+               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+               Layer::Handle layer(get_canvas_interface()->add_layer_to("curve_gradient",canvas,depth));
+               if (!layer)
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                       group.cancel();
+                       return;
+               }
+               layer_selection.push_back(layer);
+               layer->set_description(get_id()+_(" Gradient"));
+               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("bline")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Gradient layer"));
+                               return;
+                       }
+               }
+
+               // only link the curve gradient's origin parameter if the option is selected and we're creating more than one layer
+               if (get_layer_link_origins_flag() && layers_to_create > 1)
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("origin")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Gradient layer"));
+                               return;
+                       }
+               }
+       }
+
+       ///////////////////////////////////////////////////////////////////////////
+       //   P L A N T
+       ///////////////////////////////////////////////////////////////////////////
+
+       if(get_layer_plant_flag())
+       {
+               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+               Layer::Handle layer(get_canvas_interface()->add_layer_to("plant",canvas,depth));
+               if (!layer)
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                       group.cancel();
+                       return;
+               }
+               layer_selection.push_back(layer);
+               layer->set_description(get_id()+_(" Plant"));
+               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("bline")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Plant layer"));
+                               return;
+                       }
+               }
+
+               // only link the plant's origin parameter if the option is selected and we're creating more than one layer
+               if (get_layer_link_origins_flag() && layers_to_create > 1)
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("origin")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Plant layer"));
+                               return;
+                       }
+               }
+       }
+
+       ///////////////////////////////////////////////////////////////////////////
+       //   R E G I O N
+       ///////////////////////////////////////////////////////////////////////////
+
+       if(get_layer_region_flag())
+       {
+               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+               Layer::Handle layer(get_canvas_interface()->add_layer_to("region",canvas,depth));
+               if (!layer)
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                       group.cancel();
+                       return;
+               }
+               layer_selection.push_back(layer);
+               layer->set_description(get_id()+_(" Region"));
+               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+               layer->set_param("feather",get_feather());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
+
+               layer->set_param("invert",get_invert());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
+
+               // I don't know if it's safe to reuse the same LayerParamConnect action, so I'm
+               // using 2 separate ones.
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("bline")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Region layer"));
+                               return;
+                       }
+               }
+
+               // only link the region's origin parameter if the option is selected and we're creating more than one layer
+               if (get_layer_link_origins_flag() && layers_to_create > 1)
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("origin")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Region layer"));
+                               return;
+                       }
+               }
+       }
+
+       ///////////////////////////////////////////////////////////////////////////
+       //   O U T L I N E
+       ///////////////////////////////////////////////////////////////////////////
+
+       if (get_layer_outline_flag())
+       {
+               Layer::Handle layer(get_canvas_interface()->add_layer_to("outline",canvas,depth));
+               if (!layer)
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                       group.cancel();
+                       return;
+               }
+               layer_selection.push_back(layer);
+               layer->set_description(get_id()+_(" Outline"));
+               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+               layer->set_param("feather",get_feather());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
+
+               layer->set_param("invert",get_invert());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
+
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("bline")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Outline layer"));
+                               return;
+                       }
+               }
+
+               // only link the outline's origin parameter if the option is selected and we're creating more than one layer
+               if (get_layer_link_origins_flag() && layers_to_create > 1)
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("origin")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Outline layer"));
+                               return;
+                       }
+               }
+       }
+
+       egress_on_selection_change=false;
+       get_canvas_interface()->get_selection_manager()->clear_selected_layers();
+       get_canvas_interface()->get_selection_manager()->set_selected_layers(layer_selection);
+       egress_on_selection_change=true;
+
+       //post clean up stuff...
+       reset();
+       increment_id();
+}
+
+Smach::event_result
+StatePolygon_Context::event_mouse_click_handler(const Smach::event& x)
+{
+       synfig::info("STATE ROTOPOLYGON: Received mouse button down Event");
+       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
+       switch(event.button)
+       {
+       case BUTTON_LEFT:
+               polygon_point_list.push_back(get_work_area()->snap_point_to_grid(event.pos));
+               refresh_ducks();
+               return Smach::RESULT_ACCEPT;
+
+       default:
+               return Smach::RESULT_OK;
+       }
+}
+
+
+void
+StatePolygon_Context::refresh_ducks()
+{
+       get_work_area()->clear_ducks();
+       get_work_area()->queue_draw();
+
+       if(polygon_point_list.empty()) return;
+
+       std::list<synfig::Point>::iterator iter=polygon_point_list.begin();
+
+       etl::handle<WorkArea::Duck> duck;
+       duck=new WorkArea::Duck(*iter);
+       duck->set_editable(true);
+       duck->signal_edited().connect(
+               sigc::bind(sigc::mem_fun(*this,&studio::StatePolygon_Context::on_polygon_duck_change),iter)
+       );
+       duck->signal_user_click(0).connect(sigc::mem_fun(*this,&StatePolygon_Context::run));
+
+       get_work_area()->add_duck(duck);
+
+       for(++iter;iter!=polygon_point_list.end();++iter)
+       {
+               etl::handle<WorkArea::Bezier> bezier(new WorkArea::Bezier());
+               bezier->p1=bezier->c1=duck;
+
+               duck=new WorkArea::Duck(*iter);
+               duck->set_editable(true);
+               duck->set_name(strprintf("%x",&*iter));
+               duck->signal_edited().connect(
+                       sigc::bind(sigc::mem_fun(*this,&studio::StatePolygon_Context::on_polygon_duck_change),iter)
+               );
+
+               get_work_area()->add_duck(duck);
+
+               bezier->p2=bezier->c2=duck;
+               get_work_area()->add_bezier(bezier);
+       }
+       get_work_area()->queue_draw();
+}
+
+
+bool
+StatePolygon_Context::on_polygon_duck_change(const synfig::Point &point, std::list<synfig::Point>::iterator iter)
+{
+       *iter=point;
+       return true;
+}
diff --git a/synfig-studio/src/gui/state_polygon.h b/synfig-studio/src/gui/state_polygon.h
new file mode 100644 (file)
index 0000000..c633c4e
--- /dev/null
@@ -0,0 +1,55 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_polygon.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_ROTOSCOPE_POLYGON_H
+#define __SYNFIG_STUDIO_ROTOSCOPE_POLYGON_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 StatePolygon_Context;
+
+class StatePolygon : public Smach::state<StatePolygon_Context>
+{
+public:
+       StatePolygon();
+       ~StatePolygon();
+}; // END of class StatePolygon
+
+extern StatePolygon state_polygon;
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/state_rectangle.cpp b/synfig-studio/src/gui/state_rectangle.cpp
new file mode 100644 (file)
index 0000000..4f3eccb
--- /dev/null
@@ -0,0 +1,875 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_rectangle.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 <config.h>
+#endif
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/entry.h>
+
+#include <synfig/valuenode_dynamiclist.h>
+#include <synfigapp/action_system.h>
+#include <synfig/valuenode_bline.h>
+
+#include "state_rectangle.h"
+#include "state_normal.h"
+#include "canvasview.h"
+#include "workarea.h"
+#include "app.h"
+
+#include <synfigapp/action.h>
+#include "event_mouse.h"
+#include "event_layerclick.h"
+#include "toolbox.h"
+#include "dialog_tooloptions.h"
+#include <gtkmm/optionmenu.h>
+#include "duck.h"
+#include <synfigapp/main.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 ======================================================= */
+
+StateRectangle studio::state_rectangle;
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+class studio::StateRectangle_Context : public sigc::trackable
+{
+       etl::handle<CanvasView> canvas_view_;
+       CanvasView::IsWorking is_working;
+
+       Duckmatic::Push duckmatic_push;
+
+       Point point_holder;
+
+       etl::handle<Duck> point2_duck;
+
+       void refresh_ducks();
+
+       bool prev_workarea_layer_status_;
+
+       //Toolbox settings
+       synfigapp::Settings& settings;
+
+       //Toolbox display
+       Gtk::Table options_table;
+
+       Gtk::Entry              entry_id; //what to name the layer
+
+       Gtk::Adjustment adj_expand;
+       Gtk::Adjustment adj_feather;
+       Gtk::SpinButton spin_expand;
+       Gtk::SpinButton spin_feather;
+
+       Gtk::CheckButton checkbutton_invert;
+       Gtk::CheckButton checkbutton_layer_rectangle;
+       Gtk::CheckButton checkbutton_layer_region;
+       Gtk::CheckButton checkbutton_layer_outline;
+       Gtk::CheckButton checkbutton_layer_curve_gradient;
+       Gtk::CheckButton checkbutton_layer_plant;
+       Gtk::CheckButton checkbutton_layer_link_origins;
+
+public:
+
+       // this only counts the layers which use blines - they're the only
+       // ones we link the origins for
+       int layers_to_create()const
+       {
+               return
+                       get_layer_region_flag() +
+                       get_layer_outline_flag() +
+                       get_layer_curve_gradient_flag() +
+                       get_layer_plant_flag();
+       }
+
+       synfig::String get_id()const { return entry_id.get_text(); }
+       void set_id(const synfig::String& x) { return entry_id.set_text(x); }
+
+       Real get_expand()const { return adj_expand.get_value(); }
+       void set_expand(Real f) { adj_expand.set_value(f); }
+
+       Real get_feather()const { return adj_feather.get_value(); }
+       void set_feather(Real f) { adj_feather.set_value(f); }
+
+       bool get_invert()const { return checkbutton_invert.get_active(); }
+       void set_invert(bool i) { checkbutton_invert.set_active(i); }
+
+       bool get_layer_rectangle_flag()const { return checkbutton_layer_rectangle.get_active(); }
+       void set_layer_rectangle_flag(bool x) { return checkbutton_layer_rectangle.set_active(x); }
+
+       bool get_layer_region_flag()const { return checkbutton_layer_region.get_active(); }
+       void set_layer_region_flag(bool x) { return checkbutton_layer_region.set_active(x); }
+
+       bool get_layer_outline_flag()const { return checkbutton_layer_outline.get_active(); }
+       void set_layer_outline_flag(bool x) { return checkbutton_layer_outline.set_active(x); }
+
+       bool get_layer_curve_gradient_flag()const { return checkbutton_layer_curve_gradient.get_active(); }
+       void set_layer_curve_gradient_flag(bool x) { return checkbutton_layer_curve_gradient.set_active(x); }
+
+       bool get_layer_plant_flag()const { return checkbutton_layer_plant.get_active(); }
+       void set_layer_plant_flag(bool x) { return checkbutton_layer_plant.set_active(x); }
+
+       bool get_layer_link_origins_flag()const { return checkbutton_layer_link_origins.get_active(); }
+       void set_layer_link_origins_flag(bool x) { return checkbutton_layer_link_origins.set_active(x); }
+
+       void refresh_tool_options(); //to refresh the toolbox
+
+       //events
+       Smach::event_result event_stop_handler(const Smach::event& x);
+       Smach::event_result event_refresh_handler(const Smach::event& x);
+       Smach::event_result event_mouse_click_handler(const Smach::event& x);
+       Smach::event_result event_refresh_tool_options(const Smach::event& x);
+
+       //constructor destructor
+       StateRectangle_Context(CanvasView* canvas_view);
+       ~StateRectangle_Context();
+
+       //Canvas interaction
+       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
+       etl::handle<synfigapp::CanvasInterface> 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();}
+
+       //Modifying settings etc.
+       void load_settings();
+       void save_settings();
+       void reset();
+       void increment_id();
+       bool egress_on_selection_change;
+       Smach::event_result event_layer_selection_changed_handler(const Smach::event& /*x*/)
+       {
+               if(egress_on_selection_change)
+                       throw &state_normal; //throw Smach::egress_exception();
+               return Smach::RESULT_OK;
+       }
+
+       void make_rectangle(const Point& p1, const Point& p2);
+
+};     // END of class StateGradient_Context
+
+/* === M E T H O D S ======================================================= */
+
+StateRectangle::StateRectangle():
+       Smach::state<StateRectangle_Context>("rectangle")
+{
+       insert(event_def(EVENT_STOP,&StateRectangle_Context::event_stop_handler));
+       insert(event_def(EVENT_LAYER_SELECTION_CHANGED,&StateRectangle_Context::event_layer_selection_changed_handler));
+       insert(event_def(EVENT_REFRESH,&StateRectangle_Context::event_refresh_handler));
+       insert(event_def(EVENT_REFRESH_DUCKS,&StateRectangle_Context::event_refresh_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StateRectangle_Context::event_mouse_click_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DRAG,&StateRectangle_Context::event_mouse_click_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_UP,&StateRectangle_Context::event_mouse_click_handler));
+       insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateRectangle_Context::event_refresh_tool_options));
+}
+
+StateRectangle::~StateRectangle()
+{
+}
+
+void
+StateRectangle_Context::load_settings()
+{
+       String value;
+
+       //parse the arguments yargh!
+       if(settings.get_value("rectangle.id",value))
+               set_id(value);
+       else
+               set_id("Rectangle");
+
+       if(settings.get_value("rectangle.expand",value))
+               set_expand(atof(value.c_str()));
+       else
+               set_expand(0);
+
+       if(settings.get_value("rectangle.feather",value))
+               set_feather(atof(value.c_str()));
+       else
+               set_feather(0);
+
+       if(settings.get_value("rectangle.invert",value) && value != "0")
+               set_invert(true);
+       else
+               set_invert(false);
+
+       if(settings.get_value("rectangle.layer_rectangle",value) && value=="0")
+               set_layer_rectangle_flag(false);
+       else
+               set_layer_rectangle_flag(true);
+
+       if(settings.get_value("rectangle.layer_region",value) && value=="1")
+               set_layer_region_flag(true);
+       else
+               set_layer_region_flag(false);
+
+       if(settings.get_value("rectangle.layer_outline",value) && value=="1")
+               set_layer_outline_flag(true);
+       else
+               set_layer_outline_flag(false);
+
+       if(settings.get_value("rectangle.layer_curve_gradient",value) && value=="1")
+               set_layer_curve_gradient_flag(true);
+       else
+               set_layer_curve_gradient_flag(false);
+
+       if(settings.get_value("rectangle.layer_plant",value) && value=="1")
+               set_layer_plant_flag(true);
+       else
+               set_layer_plant_flag(false);
+
+       if(settings.get_value("rectangle.layer_link_origins",value) && value=="0")
+               set_layer_link_origins_flag(false);
+       else
+               set_layer_link_origins_flag(true);
+}
+
+void
+StateRectangle_Context::save_settings()
+{
+       settings.set_value("rectangle.id",get_id().c_str());
+       settings.set_value("rectangle.expand",strprintf("%f",get_expand()));
+       settings.set_value("rectangle.feather",strprintf("%f",(float)get_feather()));
+       settings.set_value("rectangle.invert",get_invert()?"1":"0");
+       settings.set_value("rectangle.layer_rectangle",get_layer_rectangle_flag()?"1":"0");
+       settings.set_value("rectangle.layer_outline",get_layer_outline_flag()?"1":"0");
+       settings.set_value("rectangle.layer_region",get_layer_region_flag()?"1":"0");
+       settings.set_value("rectangle.layer_curve_gradient",get_layer_curve_gradient_flag()?"1":"0");
+       settings.set_value("rectangle.layer_plant",get_layer_plant_flag()?"1":"0");
+       settings.set_value("rectangle.layer_link_origins",get_layer_link_origins_flag()?"1":"0");
+}
+
+void
+StateRectangle_Context::reset()
+{
+       refresh_ducks();
+}
+
+void
+StateRectangle_Context::increment_id()
+{
+       String id(get_id());
+       int number=1;
+       int digits=0;
+
+       if(id.empty())
+               id="Rectangle";
+
+       // If there is a number
+       // already at the end of the
+       // id, then remove it.
+       if(id[id.size()-1]<='9' && id[id.size()-1]>='0')
+       {
+               // figure out how many digits it is
+               for (digits = 0;
+                        (int)id.size()-1 >= digits && id[id.size()-1-digits] <= '9' && id[id.size()-1-digits] >= '0';
+                        digits++)
+                       ;
+
+               String str_number;
+               str_number=String(id,id.size()-digits,id.size());
+               id=String(id,0,id.size()-digits);
+
+               number=atoi(str_number.c_str());
+       }
+       else
+       {
+               number=1;
+               digits=3;
+       }
+
+       number++;
+
+       // Add the number back onto the id
+       {
+               const String format(strprintf("%%0%dd",digits));
+               id+=strprintf(format.c_str(),number);
+       }
+
+       // Set the ID
+       set_id(id);
+}
+
+StateRectangle_Context::StateRectangle_Context(CanvasView* canvas_view):
+       canvas_view_(canvas_view),
+       is_working(*canvas_view),
+       duckmatic_push(get_work_area()),
+       prev_workarea_layer_status_(get_work_area()->get_allow_layer_clicks()),
+       settings(synfigapp::Main::get_selected_input_device()->settings()),
+       entry_id(),
+       adj_expand(0,0,1,0.01,0.1),
+       adj_feather(0,0,1,0.01,0.1),
+       spin_expand(adj_expand,0.1,3),
+       spin_feather(adj_feather,0.1,3),
+       checkbutton_invert(_("Invert")),
+       checkbutton_layer_rectangle(_("Create Rectangle Layer")),
+       checkbutton_layer_region(_("Create Region BLine")),
+       checkbutton_layer_outline(_("Create Outline BLine")),
+       checkbutton_layer_curve_gradient(_("Create Curve Gradient BLine")),
+       checkbutton_layer_plant(_("Create Plant BLine")),
+       checkbutton_layer_link_origins(_("Link BLine Origins"))
+{
+       egress_on_selection_change=true;
+       load_settings();
+
+       // Set up the tool options dialog
+       options_table.attach(*manage(new Gtk::Label(_("Rectangle Tool"))),      0, 2,  0,  1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(entry_id,                                                                          0, 2,  1,  2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       options_table.attach(checkbutton_layer_rectangle,                                       0, 2,  2,  3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_outline,                                         0, 2,  3,  4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_region,                                          0, 2,  4,  5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_plant,                                           0, 2,  5,  6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_curve_gradient,                          0, 2,  6,  7, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_link_origins,                            0, 2,  7,  8, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       //invert flag
+       options_table.attach(checkbutton_invert,                                                        0, 2,  8,  9, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       //expand stuff
+       options_table.attach(*manage(new Gtk::Label(_("Expansion:"))),          0, 1,  9, 10, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(spin_expand,                                                                       1, 2,  9, 10, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       //feather stuff
+       options_table.attach(*manage(new Gtk::Label(_("Feather:"))),            0, 1, 10, 11, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(spin_feather,                                                                      1, 2, 10, 11, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       options_table.show_all();
+
+       //App::dialog_tool_options->set_widget(options_table);
+       refresh_tool_options();
+       App::dialog_tool_options->present();
+
+       // Turn off layer clicking
+       get_work_area()->set_allow_layer_clicks(false);
+
+       // clear out the ducks
+       get_work_area()->clear_ducks();
+
+       // Refresh the work area
+       get_work_area()->queue_draw();
+
+       get_work_area()->set_cursor(Gdk::DOTBOX);
+
+       // Hide the tables if they are showing
+       //prev_table_status=get_canvas_view()->tables_are_visible();
+       //if(prev_table_status)get_canvas_view()->hide_tables();
+
+       // Disable the time bar
+       //get_canvas_view()->set_sensitive_timebar(false);
+
+       // Connect a signal
+       //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateRectangle_Context::on_user_click));
+
+       App::toolbox->refresh();
+}
+
+void
+StateRectangle_Context::refresh_tool_options()
+{
+       App::dialog_tool_options->clear();
+       App::dialog_tool_options->set_widget(options_table);
+       App::dialog_tool_options->set_local_name(_("Rectangle Tool"));
+       App::dialog_tool_options->set_name("rectangle");
+}
+
+Smach::event_result
+StateRectangle_Context::event_refresh_tool_options(const Smach::event& /*x*/)
+{
+       refresh_tool_options();
+       return Smach::RESULT_ACCEPT;
+}
+
+StateRectangle_Context::~StateRectangle_Context()
+{
+       save_settings();
+
+       // Restore layer clicking
+       get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_);
+
+       get_work_area()->reset_cursor();
+
+       App::dialog_tool_options->clear();
+
+       // Enable the time bar
+       //get_canvas_view()->set_sensitive_timebar(true);
+
+       // Bring back the tables if they were out before
+       //if(prev_table_status)get_canvas_view()->show_tables();
+
+       // Refresh the work area
+       get_work_area()->queue_draw();
+
+       get_canvas_view()->queue_rebuild_ducks();
+
+       App::toolbox->refresh();
+}
+
+Smach::event_result
+StateRectangle_Context::event_stop_handler(const Smach::event& /*x*/)
+{
+       //throw Smach::egress_exception();
+       throw &state_normal;
+       return Smach::RESULT_OK;
+}
+
+Smach::event_result
+StateRectangle_Context::event_refresh_handler(const Smach::event& /*x*/)
+{
+       refresh_ducks();
+       return Smach::RESULT_ACCEPT;
+}
+
+void
+StateRectangle_Context::make_rectangle(const Point& _p1, const Point& _p2)
+{
+       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("New Rectangle"));
+       synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+       Layer::Handle layer;
+
+       Canvas::Handle canvas;
+       int depth(0);
+
+       // we are temporarily using the layer to hold something
+       layer=get_canvas_view()->get_selection_manager()->get_selected_layer();
+       if(layer)
+       {
+               depth=layer->get_depth();
+               canvas=layer->get_canvas();
+       }
+
+       synfigapp::SelectionManager::LayerList layer_selection;
+       if (!getenv("SYNFIG_TOOLS_CLEAR_SELECTION"))
+               layer_selection = get_canvas_view()->get_selection_manager()->get_selected_layers();
+
+       const synfig::TransformStack& transform(get_canvas_view()->get_curr_transform_stack());
+       const Point p1(transform.unperform(_p1));
+       const Point p2(transform.unperform(_p2));
+       Real x_min, x_max, y_min, y_max;
+       if (p1[0] < p2[0]) { x_min = p1[0]; x_max = p2[0]; } else { x_min = p2[0]; x_max = p1[0]; }
+       if (p1[1] < p2[1]) { y_min = p1[1]; y_max = p2[1]; } else { y_min = p2[1]; y_max = p1[1]; }
+       x_min -= get_expand(); x_max += get_expand(); y_min -= get_expand(); y_max += get_expand();
+
+       std::vector<BLinePoint> new_list;
+       for (int i = 0; i < 4; i++)
+       {
+               new_list.push_back(*(new BLinePoint));
+               new_list[i].set_width(1);
+               new_list[i].set_vertex(Point((i==0||i==3)?x_min:x_max,
+                                                                        (i==0||i==1)?y_min:y_max));
+               new_list[i].set_tangent(Point(0,0));
+       }
+
+       ValueNode_BLine::Handle value_node_bline(ValueNode_BLine::create(new_list));
+       assert(value_node_bline);
+
+       ValueNode_Const::Handle value_node_origin(ValueNode_Const::create(Vector()));
+       assert(value_node_origin);
+
+       // Set the looping flag
+       value_node_bline->set_loop(true);
+
+       if(!canvas)
+               canvas=get_canvas_view()->get_canvas();
+
+       value_node_bline->set_member_canvas(canvas);
+
+       // count how many layers we're going to be creating
+       int layers_to_create = this->layers_to_create();
+
+       ///////////////////////////////////////////////////////////////////////////
+       //   R E C T A N G L E
+       ///////////////////////////////////////////////////////////////////////////
+
+       if (get_layer_rectangle_flag())
+       {
+               layer=get_canvas_interface()->add_layer_to("rectangle",canvas,depth);
+               if (!layer)
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                       group.cancel();
+                       return;
+               }
+               layer_selection.push_back(layer);
+
+               layer->set_param("point1",p1);
+               get_canvas_interface()->signal_layer_param_changed()(layer,"point1");
+
+               layer->set_param("point2",p2);
+               get_canvas_interface()->signal_layer_param_changed()(layer,"point2");
+
+               layer->set_param("expand",get_expand());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"expand");
+
+               layer->set_param("invert",get_invert());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
+
+               layer->set_description(get_id());
+               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+       }
+
+       ///////////////////////////////////////////////////////////////////////////
+       //   C U R V E   G R A D I E N T
+       ///////////////////////////////////////////////////////////////////////////
+
+       if(get_layer_curve_gradient_flag())
+       {
+               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+               Layer::Handle layer(get_canvas_interface()->add_layer_to("curve_gradient",canvas,depth));
+               if (!layer)
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                       group.cancel();
+                       return;
+               }
+               layer_selection.push_back(layer);
+               layer->set_description(get_id()+_(" Gradient"));
+               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("bline")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Gradient layer"));
+                               return;
+                       }
+               }
+
+               // only link the curve gradient's origin parameter if the option is selected and we're creating more than one layer
+               if (get_layer_link_origins_flag() && layers_to_create > 1)
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("origin")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Gradient layer"));
+                               return;
+                       }
+               }
+       }
+
+       ///////////////////////////////////////////////////////////////////////////
+       //   P L A N T
+       ///////////////////////////////////////////////////////////////////////////
+
+       if(get_layer_plant_flag())
+       {
+               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+               Layer::Handle layer(get_canvas_interface()->add_layer_to("plant",canvas,depth));
+               if (!layer)
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                       group.cancel();
+                       return;
+               }
+               layer_selection.push_back(layer);
+               layer->set_description(get_id()+_(" Plant"));
+               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("bline")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Plant layer"));
+                               return;
+                       }
+               }
+
+               // only link the plant's origin parameter if the option is selected and we're creating more than one layer
+               if (get_layer_link_origins_flag() && layers_to_create > 1)
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("origin")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Plant layer"));
+                               return;
+                       }
+               }
+       }
+
+       ///////////////////////////////////////////////////////////////////////////
+       //   R E G I O N
+       ///////////////////////////////////////////////////////////////////////////
+
+       if(get_layer_region_flag())
+       {
+               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+               Layer::Handle layer(get_canvas_interface()->add_layer_to("region",canvas,depth));
+               if (!layer)
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                       group.cancel();
+                       return;
+               }
+               layer_selection.push_back(layer);
+               layer->set_description(get_id()+_(" Region"));
+               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+               layer->set_param("feather",get_feather());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
+
+               layer->set_param("invert",get_invert());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
+
+               // I don't know if it's safe to reuse the same LayerParamConnect action, so I'm
+               // using 2 separate ones.
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("bline")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Region layer"));
+                               return;
+                       }
+               }
+
+               // only link the region's origin parameter if the option is selected and we're creating more than one layer
+               if (get_layer_link_origins_flag() && layers_to_create > 1)
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("origin")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Region layer"));
+                               return;
+                       }
+               }
+       }
+
+       ///////////////////////////////////////////////////////////////////////////
+       //   O U T L I N E
+       ///////////////////////////////////////////////////////////////////////////
+
+       if (get_layer_outline_flag())
+       {
+               Layer::Handle layer(get_canvas_interface()->add_layer_to("outline",canvas,depth));
+               if (!layer)
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                       group.cancel();
+                       return;
+               }
+               layer_selection.push_back(layer);
+               layer->set_description(get_id()+_(" Outline"));
+               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+               layer->set_param("feather",get_feather());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
+
+               layer->set_param("invert",get_invert());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
+
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("bline")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Outline layer"));
+                               return;
+                       }
+               }
+
+               // only link the outline's origin parameter if the option is selected and we're creating more than one layer
+               if (get_layer_link_origins_flag() && layers_to_create > 1)
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("origin")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Outline layer"));
+                               return;
+                       }
+               }
+       }
+
+       egress_on_selection_change=false;
+       get_canvas_interface()->get_selection_manager()->clear_selected_layers();
+       get_canvas_interface()->get_selection_manager()->set_selected_layers(layer_selection);
+       egress_on_selection_change=true;
+
+       //post clean up stuff...
+       reset();
+       increment_id();
+}
+
+Smach::event_result
+StateRectangle_Context::event_mouse_click_handler(const Smach::event& x)
+{
+       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
+
+       if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_DOWN && event.button==BUTTON_LEFT)
+       {
+               point_holder=get_work_area()->snap_point_to_grid(event.pos);
+               etl::handle<Duck> duck=new Duck();
+               duck->set_point(point_holder);
+               duck->set_name("p1");
+               duck->set_type(Duck::TYPE_POSITION);
+               get_work_area()->add_duck(duck);
+
+               point2_duck=new Duck();
+               point2_duck->set_point(point_holder);
+               point2_duck->set_name("p2");
+               point2_duck->set_type(Duck::TYPE_POSITION);
+               point2_duck->set_box_duck(duck);
+               get_work_area()->add_duck(point2_duck);
+
+               return Smach::RESULT_ACCEPT;
+       }
+
+       if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_DRAG && event.button==BUTTON_LEFT)
+       {
+               if (!point2_duck) return Smach::RESULT_OK;
+               point2_duck->set_point(get_work_area()->snap_point_to_grid(event.pos));
+               get_work_area()->queue_draw();
+               return Smach::RESULT_ACCEPT;
+       }
+
+       if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_UP && event.button==BUTTON_LEFT)
+       {
+               make_rectangle(point_holder, get_work_area()->snap_point_to_grid(event.pos));
+               get_work_area()->clear_ducks();
+               return Smach::RESULT_ACCEPT;
+       }
+
+       return Smach::RESULT_OK;
+}
+
+
+void
+StateRectangle_Context::refresh_ducks()
+{
+       get_work_area()->clear_ducks();
+       get_work_area()->queue_draw();
+}
diff --git a/synfig-studio/src/gui/state_rectangle.h b/synfig-studio/src/gui/state_rectangle.h
new file mode 100644 (file)
index 0000000..131dd40
--- /dev/null
@@ -0,0 +1,56 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_rectangle.h
+**     \brief Rectangle creation state
+**
+**     $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_RECTANGLE_H
+#define __SYNFIG_STUDIO_STATE_RECTANGLE_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 StateRectangle_Context;
+
+class StateRectangle : public Smach::state<StateRectangle_Context>
+{
+public:
+       StateRectangle();
+       ~StateRectangle();
+}; // END of class StateRectangle
+
+extern StateRectangle state_rectangle;
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/state_rotate.cpp b/synfig-studio/src/gui/state_rotate.cpp
new file mode 100644 (file)
index 0000000..5463a41
--- /dev/null
@@ -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 <config.h>
+#endif
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/entry.h>
+
+#include <synfig/valuenode_dynamiclist.h>
+#include <synfigapp/action_system.h>
+
+#include "state_rotate.h"
+#include "state_normal.h"
+#include "canvasview.h"
+#include "workarea.h"
+#include "app.h"
+
+#include <synfigapp/action.h>
+#include "event_mouse.h"
+#include "event_layerclick.h"
+#include "toolbox.h"
+#include "dialog_tooloptions.h"
+#include <gtkmm/optionmenu.h>
+#include "duck.h"
+#include <synfig/angle.h>
+#include <synfigapp/main.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 ========================================================= */
+
+#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<synfig::Vector> positions;
+
+
+       bool bad_drag;
+       bool move_only;
+
+public:
+       etl::handle<CanvasView> 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<synfigapp::CanvasInterface> get_canvas_interface()const{return canvas_view_->canvas_interface();}
+};
+
+
+class studio::StateRotate_Context : public sigc::trackable
+{
+       etl::handle<CanvasView> canvas_view_;
+       CanvasView::IsWorking is_working;
+
+       synfigapp::Settings& settings;
+
+       etl::handle<DuckDrag_Rotate> 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<CanvasView>& get_canvas_view()const{return canvas_view_;}
+       etl::handle<synfigapp::CanvasInterface> 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<StateRotate_Context>("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<etl::handle<Duck> >::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<etl::handle<Duck> >::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/gui/state_rotate.h b/synfig-studio/src/gui/state_rotate.h
new file mode 100644 (file)
index 0000000..e2caafe
--- /dev/null
@@ -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<StateRotate_Context>
+{
+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/gui/state_scale.cpp b/synfig-studio/src/gui/state_scale.cpp
new file mode 100644 (file)
index 0000000..edfb89b
--- /dev/null
@@ -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 <config.h>
+#endif
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/entry.h>
+
+#include <synfig/valuenode_dynamiclist.h>
+#include <synfigapp/action_system.h>
+
+#include "state_scale.h"
+#include "state_normal.h"
+#include "canvasview.h"
+#include "workarea.h"
+#include "app.h"
+
+#include <synfigapp/action.h>
+#include "event_mouse.h"
+#include "event_layerclick.h"
+#include "toolbox.h"
+#include "dialog_tooloptions.h"
+#include <gtkmm/optionmenu.h>
+#include "duck.h"
+#include <synfigapp/main.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 ======================================================= */
+
+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<synfig::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<CanvasView> canvas_view_;
+       CanvasView::IsWorking is_working;
+
+       synfigapp::Settings& settings;
+
+       etl::handle<DuckDrag_Scale> 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<CanvasView>& get_canvas_view()const{return canvas_view_;}
+       etl::handle<synfigapp::CanvasInterface> 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<StateScale_Context>("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<etl::handle<Duck> >::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<etl::handle<Duck> >::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]>-EPSILON)
+               vect[0]=1;
+       if(vect[1]<EPSILON && 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/gui/state_scale.h b/synfig-studio/src/gui/state_scale.h
new file mode 100644 (file)
index 0000000..f351c12
--- /dev/null
@@ -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<StateScale_Context>
+{
+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/gui/state_sketch.cpp b/synfig-studio/src/gui/state_sketch.cpp
new file mode 100644 (file)
index 0000000..f8b77a3
--- /dev/null
@@ -0,0 +1,508 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_sketch.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 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 <config.h>
+#endif
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/entry.h>
+
+#include <synfig/valuenode_dynamiclist.h>
+
+#include "state_sketch.h"
+#include "state_normal.h"
+#include "state_stroke.h"
+#include "canvasview.h"
+#include "workarea.h"
+#include "app.h"
+#include <synfig/valuenode_bline.h>
+#include <ETL/hermite>
+#include <ETL/calculus>
+#include <utility>
+#include "event_mouse.h"
+#include "event_layerclick.h"
+#include "toolbox.h"
+
+#include <synfigapp/blineconvert.h>
+#include <synfigapp/main.h>
+
+#include <ETL/gaussian>
+
+#include "dialog_tooloptions.h"
+
+#include <gtkmm/table.h>
+#include <gtkmm/label.h>
+#include <gtkmm/button.h>
+#include <gtkmm/checkbutton.h>
+#include <gtkmm/actiongroup.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 ======================================================= */
+
+StateSketch studio::state_sketch;
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+class studio::StateSketch_Context : public sigc::trackable
+{
+       Glib::RefPtr<Gtk::ActionGroup> action_group;
+
+       etl::handle<CanvasView> canvas_view_;
+       CanvasView::IsWorking is_working;
+
+       bool prev_table_status;
+       bool prev_workarea_layer_status_;
+
+       Gtk::Table options_table;
+       Gtk::Button button_clear_sketch;
+       Gtk::Button button_undo_stroke;
+       Gtk::Button button_save_sketch;
+       Gtk::Button button_load_sketch;
+       Gtk::CheckButton checkbutton_show_sketch;
+
+       void clear_sketch();
+       void save_sketch();
+       void load_sketch();
+       void undo_stroke();
+       void toggle_show_sketch();
+
+public:
+
+       Smach::event_result event_stop_handler(const Smach::event& x);
+
+       Smach::event_result event_refresh_handler(const Smach::event& x);
+
+       Smach::event_result event_mouse_down_handler(const Smach::event& x);
+
+       Smach::event_result event_stroke(const Smach::event& x);
+
+       Smach::event_result event_refresh_tool_options(const Smach::event& x);
+       Smach::event_result event_yield_tool_options(const Smach::event& x);
+
+       void refresh_tool_options();
+       void yield_tool_options();
+
+       StateSketch_Context(CanvasView* canvas_view);
+
+       ~StateSketch_Context();
+
+       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
+       etl::handle<synfigapp::CanvasInterface> get_canvas_interface()const{return canvas_view_->canvas_interface();}
+       synfig::Time get_time()const { return get_canvas_interface()->get_time(); }
+       synfig::Canvas::Handle get_canvas()const{return canvas_view_->get_canvas();}
+       WorkArea * get_work_area()const{return canvas_view_->get_work_area();}
+
+};     // END of class StateSketch_Context
+
+
+/* === M E T H O D S ======================================================= */
+
+StateSketch::StateSketch():
+       Smach::state<StateSketch_Context>("sketch")
+{
+       insert(event_def(EVENT_STOP,&StateSketch_Context::event_stop_handler));
+       //insert(event_def(EVENT_REFRESH,&StateSketch_Context::event_refresh_handler));
+       insert(event_def(EVENT_REFRESH_DUCKS,&StateSketch_Context::event_refresh_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StateSketch_Context::event_mouse_down_handler));
+       insert(event_def(EVENT_WORKAREA_STROKE,&StateSketch_Context::event_stroke));
+       insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateSketch_Context::event_refresh_tool_options));
+       insert(event_def(EVENT_YIELD_TOOL_OPTIONS,&StateSketch_Context::event_yield_tool_options));
+}
+
+StateSketch::~StateSketch()
+{
+}
+
+void
+StateSketch_Context::save_sketch()
+{
+       synfig::String filename(basename(get_canvas()->get_file_name())+".sketch");
+
+       while(App::dialog_save_file(_("Save Sketch"), filename, SKETCH_DIR_PREFERENCE))
+       {
+               // If the filename still has wildcards, then we should
+               // continue looking for the file we want
+               if(find(filename.begin(),filename.end(),'*')!=filename.end())
+                       continue;
+
+               if(get_work_area()->save_sketch(filename))
+                       break;
+
+               get_canvas_view()->get_ui_interface()->error(_("Unable to save sketch"));
+       }
+}
+
+void
+StateSketch_Context::load_sketch()
+{
+       synfig::String filename(basename(get_canvas()->get_file_name())+".sketch");
+
+       while(App::dialog_open_file(_("Load Sketch"), filename, SKETCH_DIR_PREFERENCE))
+       {
+               // If the filename still has wildcards, then we should
+               // continue looking for the file we want
+               if(find(filename.begin(),filename.end(),'*')!=filename.end())
+                       continue;
+
+               if(get_work_area()->load_sketch(filename))
+                       break;
+
+               get_canvas_view()->get_ui_interface()->error(_("Unable to load sketch"));
+       }
+       get_work_area()->queue_draw();
+}
+
+void
+StateSketch_Context::clear_sketch()
+{
+       get_work_area()->clear_persistent_strokes();
+
+       // if the sketch is currently shown, make sure it is updated
+       //! \todo is there a better way than this of getting Duckmatic to update its stroke_list_?
+       if (checkbutton_show_sketch.get_active())
+       {
+               get_work_area()->set_show_persistent_strokes(false);
+               get_work_area()->set_show_persistent_strokes(true);
+               get_canvas_view()->get_smach().process_event(EVENT_REFRESH);
+       }
+}
+
+void
+StateSketch_Context::undo_stroke()
+{
+       if(!get_work_area()->persistent_stroke_list().empty())
+       {
+               get_work_area()->persistent_stroke_list().pop_back();
+
+               // if the sketch is currently shown, make sure it is updated
+               //! \todo is there a better way than this of getting Duckmatic to update its stroke_list_?
+               if (checkbutton_show_sketch.get_active())
+               {
+                       get_work_area()->set_show_persistent_strokes(false);
+                       get_work_area()->set_show_persistent_strokes(true);
+                       get_canvas_view()->get_smach().process_event(EVENT_REFRESH);
+               }
+       }
+}
+
+void
+StateSketch_Context::toggle_show_sketch()
+{
+       get_work_area()->set_show_persistent_strokes(checkbutton_show_sketch.get_active());
+       get_work_area()->queue_draw();
+}
+
+StateSketch_Context::StateSketch_Context(CanvasView* canvas_view):
+       action_group(Gtk::ActionGroup::create("action_group_state_sketch")),
+       canvas_view_(canvas_view),
+       is_working(*canvas_view),
+       prev_workarea_layer_status_(get_work_area()->get_allow_layer_clicks()),
+       button_clear_sketch(_("Clear Sketch")),
+       button_undo_stroke(_("Undo Stroke")),
+       button_save_sketch(_("Save Sketch")),
+       button_load_sketch(_("Load Sketch")),
+       checkbutton_show_sketch(_("Show Sketch"))
+{
+    Glib::ustring ui_info =
+       "<ui>"
+       "       <toolbar action='toolbar-sketch'>"
+       "       <toolitem action='sketch-undo' />"
+       "       <toolitem action='sketch-clear' />"
+       "       <toolitem action='sketch-save-as' />"
+       "       <toolitem action='sketch-open' />"
+       "       </toolbar>"
+       "</ui>";
+
+       action_group->add(Gtk::Action::create(
+               "sketch-undo",
+               Gtk::StockID("gtk-undo"),
+               _("Undo Last Stroke"),
+               _("Undo Last Stroke")
+       ),
+               sigc::mem_fun(
+                       *this,
+                       &studio::StateSketch_Context::undo_stroke
+               )
+       );
+
+       action_group->add(Gtk::Action::create(
+               "sketch-clear",
+               Gtk::StockID("gtk-clear"),
+               _("Clear Sketch"),
+               _("Clear Sketch")
+       ),
+               sigc::mem_fun(
+                       *this,
+                       &studio::StateSketch_Context::clear_sketch
+               )
+       );
+
+       action_group->add(Gtk::Action::create(
+               "sketch-save-as",
+               Gtk::StockID("gtk-save-as"),
+               _("Save Sketch As..."),
+               _("Save Sketch As...")
+       ),
+               sigc::mem_fun(
+                       *this,
+                       &studio::StateSketch_Context::save_sketch
+               )
+       );
+
+       action_group->add(Gtk::Action::create(
+               "sketch-save-as",
+               Gtk::StockID("gtk-save-as"),
+               _("Save Sketch As..."),
+               _("Save Sketch As...")
+       ),
+               sigc::mem_fun(
+                       *this,
+                       &studio::StateSketch_Context::save_sketch
+               )
+       );
+
+       action_group->add(Gtk::Action::create(
+               "sketch-open",
+               Gtk::StockID("gtk-open"),
+               _("Open a Sketch"),
+               _("Open a Sketch")
+       ),
+               sigc::mem_fun(
+                       *this,
+                       &studio::StateSketch_Context::load_sketch
+               )
+       );
+
+       action_group->add( Gtk::Action::create("toolbar-sketch", "Sketch Toolbar") );
+
+       App::ui_manager()->add_ui_from_string(ui_info);
+
+       checkbutton_show_sketch.set_active(get_work_area()->get_show_persistent_strokes());
+
+       button_clear_sketch.signal_clicked().connect(sigc::mem_fun(*this,&studio::StateSketch_Context::clear_sketch));
+       button_undo_stroke.signal_clicked().connect(sigc::mem_fun(*this,&studio::StateSketch_Context::undo_stroke));
+       button_save_sketch.signal_clicked().connect(sigc::mem_fun(*this,&studio::StateSketch_Context::save_sketch));
+       button_load_sketch.signal_clicked().connect(sigc::mem_fun(*this,&studio::StateSketch_Context::load_sketch));
+       checkbutton_show_sketch.signal_clicked().connect(sigc::mem_fun(*this,&studio::StateSketch_Context::toggle_show_sketch));
+
+       options_table.attach(*manage(new Gtk::Label(_("Sketch Tool"))), 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_show_sketch,                                   0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       //options_table.attach(button_undo_stroke, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       //options_table.attach(button_clear_sketch, 0, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       //options_table.attach(button_save_sketch, 0, 1, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       //options_table.attach(button_load_sketch, 1, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       options_table.show_all();
+       refresh_tool_options();
+       App::dialog_tool_options->present();
+
+       // Turn off layer clicking
+       get_work_area()->set_allow_layer_clicks(false);
+
+       get_work_area()->set_cursor(Gdk::PENCIL);
+
+       // Turn off duck clicking
+       get_work_area()->set_allow_duck_clicks(false);
+
+       // clear out the ducks
+       //get_work_area()->clear_ducks();
+
+       // Refresh the work area
+       //get_work_area()->queue_draw();
+
+       // Hide the tables if they are showing
+       prev_table_status=get_canvas_view()->tables_are_visible();
+       //if(prev_table_status)get_canvas_view()->hide_tables();
+
+       // Disable the time bar
+       //get_canvas_view()->set_sensitive_timebar(false);
+
+       // Connect a signal
+       //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateSketch_Context::on_user_click));
+
+       App::toolbox->refresh();
+}
+
+StateSketch_Context::~StateSketch_Context()
+{
+       get_work_area()->reset_cursor();
+
+       App::dialog_tool_options->clear();
+
+       // Restore layer clicking
+       get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_);
+
+       // Restore duck clicking
+       get_work_area()->set_allow_duck_clicks(true);
+
+       // Enable the time bar
+       //get_canvas_view()->set_sensitive_timebar(true);
+
+       // Bring back the tables if they were out before
+       if(prev_table_status)get_canvas_view()->show_tables();
+
+       // Refresh the work area
+       //get_work_area()->queue_draw();
+
+       App::toolbox->refresh();
+}
+
+void
+StateSketch_Context::yield_tool_options()
+{
+       App::dialog_tool_options->clear();
+       App::ui_manager()->remove_action_group(action_group);
+}
+
+void
+StateSketch_Context::refresh_tool_options()
+{
+       App::dialog_tool_options->clear();
+       App::dialog_tool_options->set_widget(options_table);
+       App::dialog_tool_options->set_local_name(_("Sketch Tool"));
+       App::dialog_tool_options->set_name("sketch");
+
+       App::ui_manager()->insert_action_group(action_group);
+       App::dialog_tool_options->set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-sketch")));
+
+       /*
+       App::dialog_tool_options->add_button(
+               Gtk::StockID("gtk-undo"),
+               _("Undo Last Stroke")
+       )->signal_clicked().connect(
+               sigc::mem_fun(
+                       *this,
+                       &studio::StateSketch_Context::undo_stroke
+               )
+       );
+       App::dialog_tool_options->add_button(
+               Gtk::StockID("gtk-clear"),
+               _("Clear Sketch")
+       )->signal_clicked().connect(
+               sigc::mem_fun(
+                       *this,
+                       &studio::StateSketch_Context::clear_sketch
+               )
+       );
+       App::dialog_tool_options->add_button(
+               Gtk::StockID("gtk-save"),
+               _("Save Sketch to a File")
+       )->signal_clicked().connect(
+               sigc::mem_fun(
+                       *this,
+                       &studio::StateSketch_Context::save_sketch
+               )
+       );
+
+       App::dialog_tool_options->add_button(
+               Gtk::StockID("gtk-open"),
+               _("Open a Sketch")
+       )->signal_clicked().connect(
+               sigc::mem_fun(
+                       *this,
+                       &studio::StateSketch_Context::load_sketch
+               )
+       );
+       */
+       //button_clear_sketch.signal_clicked().connect(sigc::mem_fun(*this,&studio::StateSketch_Context::clear_sketch));
+       //button_undo_stroke.signal_clicked().connect(sigc::mem_fun(*this,&studio::StateSketch_Context::undo_stroke));
+       //button_save_sketch.signal_clicked().connect(sigc::mem_fun(*this,&studio::StateSketch_Context::save_sketch));
+       //button_load_sketch.signal_clicked().connect(sigc::mem_fun(*this,&studio::StateSketch_Context::load_sketch));
+       //checkbutton_show_sketch.signal_clicked().connect(sigc::mem_fun(*this,&studio::StateSketch_Context::toggle_show_sketch));
+}
+
+Smach::event_result
+StateSketch_Context::event_refresh_tool_options(const Smach::event& /*x*/)
+{
+       refresh_tool_options();
+       return Smach::RESULT_ACCEPT;
+}
+
+Smach::event_result
+StateSketch_Context::event_yield_tool_options(const Smach::event& /*x*/)
+{
+       yield_tool_options();
+       return Smach::RESULT_ACCEPT;
+}
+
+Smach::event_result
+StateSketch_Context::event_stop_handler(const Smach::event& /*x*/)
+{
+       //throw Smach::egress_exception();
+       throw &state_normal;
+       return Smach::RESULT_OK;
+}
+
+Smach::event_result
+StateSketch_Context::event_refresh_handler(const Smach::event& /*x*/)
+{
+       return Smach::RESULT_ACCEPT;
+}
+
+Smach::event_result
+StateSketch_Context::event_mouse_down_handler(const Smach::event& x)
+{
+       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
+       switch(event.button)
+       {
+       case BUTTON_LEFT:
+               {
+                       // Enter the stroke state to get the stroke
+                       get_canvas_view()->get_smach().push_state(&state_stroke);
+                       return Smach::RESULT_ACCEPT;
+               }
+
+       default:
+               return Smach::RESULT_OK;
+       }
+}
+
+Smach::event_result
+StateSketch_Context::event_stroke(const Smach::event& x)
+{
+       const EventStroke& event(*reinterpret_cast<const EventStroke*>(&x));
+
+       assert(event.stroke_data);
+
+       get_work_area()->add_persistent_stroke(event.stroke_data,synfigapp::Main::get_outline_color());
+
+       return Smach::RESULT_ACCEPT;
+}
diff --git a/synfig-studio/src/gui/state_sketch.h b/synfig-studio/src/gui/state_sketch.h
new file mode 100644 (file)
index 0000000..301c81d
--- /dev/null
@@ -0,0 +1,55 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_sketch.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_SKETCH_H
+#define __SYNFIG_STUDIO_STATE_SKETCH_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 StateSketch_Context;
+
+class StateSketch : public Smach::state<StateSketch_Context>
+{
+public:
+       StateSketch();
+       ~StateSketch();
+}; // END of class StateSketch
+
+extern StateSketch state_sketch;
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/state_smoothmove.cpp b/synfig-studio/src/gui/state_smoothmove.cpp
new file mode 100644 (file)
index 0000000..f42df35
--- /dev/null
@@ -0,0 +1,388 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_smoothmove.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**  Copyright (c) 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 <config.h>
+#endif
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/entry.h>
+
+#include <synfig/valuenode_blinecalcvertex.h>
+#include <synfig/valuenode_composite.h>
+#include <synfig/valuenode_dynamiclist.h>
+#include <synfigapp/action_system.h>
+
+#include "state_smoothmove.h"
+#include "state_normal.h"
+#include "canvasview.h"
+#include "workarea.h"
+#include "app.h"
+
+#include <synfigapp/action.h>
+#include "event_mouse.h"
+#include "event_layerclick.h"
+#include "toolbox.h"
+#include "dialog_tooloptions.h"
+#include <gtkmm/optionmenu.h>
+#include "duck.h"
+#include "onemoment.h"
+#include <synfigapp/main.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 ======================================================= */
+
+StateSmoothMove studio::state_smooth_move;
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+class DuckDrag_SmoothMove : public DuckDrag_Base
+{
+       float radius;
+
+       synfig::Vector last_translate_;
+       synfig::Vector drag_offset_;
+       synfig::Vector snap;
+
+       std::vector<synfig::Vector> last_;
+       std::vector<synfig::Vector> positions;
+
+public:
+       DuckDrag_SmoothMove();
+       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);
+
+       void set_radius(float x) { radius=x; }
+       float get_radius()const { return radius; }
+};
+
+
+class studio::StateSmoothMove_Context : public sigc::trackable
+{
+       etl::handle<CanvasView> canvas_view_;
+       CanvasView::IsWorking is_working;
+
+       //Duckmatic::Push duckmatic_push;
+
+       synfigapp::Settings& settings;
+
+       etl::handle<DuckDrag_SmoothMove> duck_dragger_;
+
+       Gtk::Table options_table;
+
+       Gtk::Adjustment  adj_radius;
+       Gtk::SpinButton  spin_radius;
+
+       float pressure;
+
+public:
+       float get_radius()const { return adj_radius.get_value(); }
+       void set_radius(float x) { return adj_radius.set_value(x); }
+
+       void refresh_radius() { duck_dragger_->set_radius(get_radius()*pressure); }
+
+       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();
+
+       StateSmoothMove_Context(CanvasView* canvas_view);
+
+       ~StateSmoothMove_Context();
+
+       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
+       etl::handle<synfigapp::CanvasInterface> 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 StateSmoothMove_Context
+
+/* === M E T H O D S ======================================================= */
+
+StateSmoothMove::StateSmoothMove():
+       Smach::state<StateSmoothMove_Context>("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()
+{
+}
+
+void
+StateSmoothMove_Context::load_settings()
+{
+       String value;
+
+       if(settings.get_value("smooth_move.radius",value))
+               set_radius(atof(value.c_str()));
+       else
+               set_radius(1.0f);
+}
+
+void
+StateSmoothMove_Context::save_settings()
+{
+       settings.set_value("smooth_move.radius",strprintf("%f",get_radius()));
+}
+
+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()),
+       adj_radius(1,0,100000,0.01,0.1),
+       spin_radius(adj_radius,0.1,3)
+{
+       pressure=1.0f;
+
+       // Set up the tool options dialog
+       options_table.attach(*manage(new Gtk::Label(_("SmoothMove Tool"))),     0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(*manage(new Gtk::Label(_("Radius"))),                      0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(spin_radius,                                                                       0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       spin_radius.signal_value_changed().connect(sigc::mem_fun(*this,&StateSmoothMove_Context::refresh_radius));
+
+       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_);
+
+       App::toolbox->refresh();
+
+       get_work_area()->set_cursor(Gdk::FLEUR);
+       //get_work_area()->reset_cursor();
+
+       load_settings();
+}
+
+void
+StateSmoothMove_Context::refresh_tool_options()
+{
+       App::dialog_tool_options->clear();
+       App::dialog_tool_options->set_widget(options_table);
+       App::dialog_tool_options->set_local_name(_("Smooth Move"));
+       App::dialog_tool_options->set_name("smooth_move");
+}
+
+Smach::event_result
+StateSmoothMove_Context::event_refresh_tool_options(const Smach::event& /*x*/)
+{
+       refresh_tool_options();
+       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_work_area()->reset_cursor();
+
+       App::dialog_tool_options->clear();
+
+       App::toolbox->refresh();
+}
+
+
+
+
+DuckDrag_SmoothMove::DuckDrag_SmoothMove():radius(1.0f)
+{
+}
+
+void
+DuckDrag_SmoothMove::begin_duck_drag(Duckmatic* duckmatic, const synfig::Vector& offset)
+{
+       last_translate_=Vector(0,0);
+               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);
+
+       last_.clear();
+       positions.clear();
+       const DuckList selected_ducks(duckmatic->get_selected_ducks());
+       DuckList::const_iterator iter;
+       int i;
+       for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
+       {
+               last_.push_back(Vector(0,0));
+               positions.push_back((*iter)->get_trans_point());
+       }
+}
+
+void
+DuckDrag_SmoothMove::duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector)
+{
+       const DuckList selected_ducks(duckmatic->get_selected_ducks());
+       DuckList::const_iterator iter;
+       synfig::Vector vect(duckmatic->snap_point_to_grid(vector)-drag_offset_+snap);
+
+       int i;
+
+       Time time(duckmatic->get_time());
+
+       // process vertex and position ducks first
+       for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
+       {
+               // skip this duck if it is NOT a vertex or a position
+               if (((*iter)->get_type() != Duck::TYPE_VERTEX &&
+                        (*iter)->get_type() != Duck::TYPE_POSITION))
+                       continue;
+               Point p(positions[i]);
+
+               float dist(1.0f-(p-drag_offset_).mag()/get_radius());
+               if(dist<0)
+                       dist=0;
+
+               last_[i]=vect*dist;
+               (*iter)->set_trans_point(p+last_[i], time);
+       }
+
+       // then process non vertex and non position ducks
+       for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
+       {
+               // skip this duck if it IS a vertex or a position
+               if (!((*iter)->get_type() != Duck::TYPE_VERTEX &&
+                        (*iter)->get_type() != Duck::TYPE_POSITION))
+                       continue;
+               Point p(positions[i]);
+
+               float dist(1.0f-(p-drag_offset_).mag()/get_radius());
+               if(dist<0)
+                       dist=0;
+
+               last_[i]=vect*dist;
+               (*iter)->set_trans_point(p+last_[i], time);
+       }
+
+       // then patch up the tangents for the vertices we've moved
+       duckmatic->update_ducks();
+
+       last_translate_=vect;
+       //snap=Vector(0,0);
+}
+
+bool
+DuckDrag_SmoothMove::end_duck_drag(Duckmatic* duckmatic)
+{
+       //synfig::info("end_duck_drag(): Diff= %f",last_translate_.mag());
+       if(last_translate_.mag()>0.0001)
+       {
+               const DuckList selected_ducks(duckmatic->get_selected_ducks());
+               DuckList::const_iterator iter;
+
+               int i;
+
+               smart_ptr<OneMoment> wait;if(selected_ducks.size()>20)wait.spawn();
+
+               for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
+               {
+                       if(last_[i].mag()>0.0001)
+                               {
+                               if ((*iter)->get_type() == Duck::TYPE_ANGLE)
+                                       {
+                                               if(!(*iter)->signal_edited_angle()((*iter)->get_rotations()))
+                                               {
+                                                       throw String("Bad edit");
+                                               }
+                                       }
+                                       else if (App::restrict_radius_ducks &&
+                                                        (*iter)->is_radius())
+                                       {
+                                               Point point((*iter)->get_point());
+                                               bool changed = false;
+
+                                               if (point[0] < 0)
+                                               {
+                                                       point[0] = 0;
+                                                       changed = true;
+                                               }
+                                               if (point[1] < 0)
+                                               {
+                                                       point[1] = 0;
+                                                       changed = true;
+                                               }
+
+                                               if (changed) (*iter)->set_point(point);
+
+                                               if(!(*iter)->signal_edited()(point))
+                                               {
+                                                       throw String("Bad edit");
+                                               }
+                                       }
+                                       else
+                                       {
+                                               if(!(*iter)->signal_edited()((*iter)->get_point()))
+                                               {
+                                                       throw String("Bad edit");
+                                               }
+                                       }
+                               }
+               }
+               //duckmatic->get_selected_ducks()=new_set;
+               //duckmatic->refresh_selected_ducks();
+               return true;
+       }
+       else
+       {
+               duckmatic->signal_user_click_selected_ducks(0);
+               return false;
+       }
+}
diff --git a/synfig-studio/src/gui/state_smoothmove.h b/synfig-studio/src/gui/state_smoothmove.h
new file mode 100644 (file)
index 0000000..07442af
--- /dev/null
@@ -0,0 +1,56 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_smoothmove.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_SMOOTHMOVE_H
+#define __SYNFIG_STUDIO_STATE_SMOOTHMOVE_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 StateSmoothMove_Context;
+
+class StateSmoothMove : public Smach::state<StateSmoothMove_Context>
+{
+public:
+       StateSmoothMove();
+       ~StateSmoothMove();
+}; // END of class StateSmoothMove
+
+extern StateSmoothMove state_smooth_move;
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/state_star.cpp b/synfig-studio/src/gui/state_star.cpp
new file mode 100644 (file)
index 0000000..270571a
--- /dev/null
@@ -0,0 +1,1091 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_star.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 <config.h>
+#endif
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/entry.h>
+
+#include <synfig/valuenode_dynamiclist.h>
+#include <synfigapp/action_system.h>
+#include <synfig/valuenode_bline.h>
+
+#include "state_star.h"
+#include "state_normal.h"
+#include "canvasview.h"
+#include "workarea.h"
+#include "app.h"
+
+#include <synfigapp/action.h>
+#include "event_mouse.h"
+#include "event_layerclick.h"
+#include "toolbox.h"
+#include "dialog_tooloptions.h"
+#include <gtkmm/optionmenu.h>
+#include "duck.h"
+#include "widget_enum.h"
+#include <synfigapp/main.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 ======================================================= */
+
+StateStar studio::state_star;
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+class studio::StateStar_Context : public sigc::trackable
+{
+       etl::handle<CanvasView> canvas_view_;
+       CanvasView::IsWorking is_working;
+
+       Duckmatic::Push duckmatic_push;
+
+       Point point_holder;
+
+       etl::handle<Duck> point2_duck;
+
+       void refresh_ducks();
+
+       bool prev_workarea_layer_status_;
+
+       //Toolbox settings
+       synfigapp::Settings& settings;
+
+       //Toolbox display
+       Gtk::Table options_table;
+
+       Gtk::Entry              entry_id; //what to name the layer
+
+       Gtk::Adjustment adj_feather;
+       Gtk::Adjustment adj_number_of_points;
+       Gtk::Adjustment adj_inner_tangent;
+       Gtk::Adjustment adj_outer_tangent;
+       Gtk::Adjustment adj_inner_width;
+       Gtk::Adjustment adj_outer_width;
+       Gtk::Adjustment adj_radius_ratio;
+       Gtk::Adjustment adj_angle_offset;
+       Gtk::SpinButton spin_feather;
+       Gtk::SpinButton spin_number_of_points;
+       Gtk::SpinButton spin_inner_tangent;
+       Gtk::SpinButton spin_outer_tangent;
+       Gtk::SpinButton spin_inner_width;
+       Gtk::SpinButton spin_outer_width;
+       Gtk::SpinButton spin_radius_ratio;
+       Gtk::SpinButton spin_angle_offset;
+
+       Gtk::CheckButton checkbutton_invert;
+       Gtk::CheckButton checkbutton_regular_polygon;
+       Gtk::CheckButton checkbutton_layer_star;
+       Gtk::CheckButton checkbutton_layer_region;
+       Gtk::CheckButton checkbutton_layer_outline;
+       Gtk::CheckButton checkbutton_layer_curve_gradient;
+       Gtk::CheckButton checkbutton_layer_plant;
+       Gtk::CheckButton checkbutton_layer_link_origins;
+       Gtk::CheckButton checkbutton_layer_origins_at_center;
+
+public:
+
+       // this only counts the layers which will have their origins linked
+       int layers_to_create()const
+       {
+               return
+                       (get_layer_star_flag() && get_layer_origins_at_center_flag()) +
+                       get_layer_region_flag() +
+                       get_layer_outline_flag() +
+                       get_layer_curve_gradient_flag() +
+                       get_layer_plant_flag();
+       }
+
+       synfig::String get_id()const { return entry_id.get_text(); }
+       void set_id(const synfig::String& x) { return entry_id.set_text(x); }
+
+       Real get_feather()const { return adj_feather.get_value(); }
+       void set_feather(Real f) { adj_feather.set_value(f); }
+
+       Real get_number_of_points()const { return adj_number_of_points.get_value(); }
+       void set_number_of_points(Real f) { adj_number_of_points.set_value(f); }
+
+       Real get_inner_tangent()const { return adj_inner_tangent.get_value(); }
+       void set_inner_tangent(Real f) { adj_inner_tangent.set_value(f); }
+
+       Real get_outer_tangent()const { return adj_outer_tangent.get_value(); }
+       void set_outer_tangent(Real f) { adj_outer_tangent.set_value(f); }
+
+       Real get_inner_width()const { return adj_inner_width.get_value(); }
+       void set_inner_width(Real f) { adj_inner_width.set_value(f); }
+
+       Real get_outer_width()const { return adj_outer_width.get_value(); }
+       void set_outer_width(Real f) { adj_outer_width.set_value(f); }
+
+       Real get_radius_ratio()const { return adj_radius_ratio.get_value(); }
+       void set_radius_ratio(Real f) { adj_radius_ratio.set_value(f); }
+
+       Real get_angle_offset()const { return adj_angle_offset.get_value(); }
+       void set_angle_offset(Real f) { adj_angle_offset.set_value(f); }
+
+       bool get_invert()const { return checkbutton_invert.get_active(); }
+       void set_invert(bool i) { checkbutton_invert.set_active(i); }
+
+       bool get_regular_polygon()const { return checkbutton_regular_polygon.get_active(); }
+       void set_regular_polygon(bool i) { checkbutton_regular_polygon.set_active(i); }
+
+       bool get_layer_star_flag()const { return checkbutton_layer_star.get_active(); }
+       void set_layer_star_flag(bool x) { return checkbutton_layer_star.set_active(x); }
+
+       bool get_layer_region_flag()const { return checkbutton_layer_region.get_active(); }
+       void set_layer_region_flag(bool x) { return checkbutton_layer_region.set_active(x); }
+
+       bool get_layer_outline_flag()const { return checkbutton_layer_outline.get_active(); }
+       void set_layer_outline_flag(bool x) { return checkbutton_layer_outline.set_active(x); }
+
+       bool get_layer_curve_gradient_flag()const { return checkbutton_layer_curve_gradient.get_active(); }
+       void set_layer_curve_gradient_flag(bool x) { return checkbutton_layer_curve_gradient.set_active(x); }
+
+       bool get_layer_plant_flag()const { return checkbutton_layer_plant.get_active(); }
+       void set_layer_plant_flag(bool x) { return checkbutton_layer_plant.set_active(x); }
+
+       bool get_layer_link_origins_flag()const { return checkbutton_layer_link_origins.get_active(); }
+       void set_layer_link_origins_flag(bool x) { return checkbutton_layer_link_origins.set_active(x); }
+
+       bool get_layer_origins_at_center_flag()const { return checkbutton_layer_origins_at_center.get_active(); }
+       void set_layer_origins_at_center_flag(bool x) { return checkbutton_layer_origins_at_center.set_active(x); }
+
+       void refresh_tool_options(); //to refresh the toolbox
+
+       //events
+       Smach::event_result event_stop_handler(const Smach::event& x);
+       Smach::event_result event_refresh_handler(const Smach::event& x);
+       Smach::event_result event_mouse_click_handler(const Smach::event& x);
+       Smach::event_result event_refresh_tool_options(const Smach::event& x);
+
+       //constructor destructor
+       StateStar_Context(CanvasView* canvas_view);
+       ~StateStar_Context();
+
+       //Canvas interaction
+       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
+       etl::handle<synfigapp::CanvasInterface> 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();}
+
+       //Modifying settings etc.
+       void load_settings();
+       void save_settings();
+       void reset();
+       void increment_id();
+       bool egress_on_selection_change;
+       Smach::event_result event_layer_selection_changed_handler(const Smach::event& /*x*/)
+       {
+               if(egress_on_selection_change)
+                       throw &state_normal; //throw Smach::egress_exception();
+               return Smach::RESULT_OK;
+       }
+
+       void make_star(const Point& p1, const Point& p2);
+
+};     // END of class StateStar_Context
+
+/* === M E T H O D S ======================================================= */
+
+StateStar::StateStar():
+       Smach::state<StateStar_Context>("star")
+{
+       insert(event_def(EVENT_LAYER_SELECTION_CHANGED,&StateStar_Context::event_layer_selection_changed_handler));
+       insert(event_def(EVENT_STOP,&StateStar_Context::event_stop_handler));
+       insert(event_def(EVENT_REFRESH,&StateStar_Context::event_refresh_handler));
+       insert(event_def(EVENT_REFRESH_DUCKS,&StateStar_Context::event_refresh_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StateStar_Context::event_mouse_click_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DRAG,&StateStar_Context::event_mouse_click_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_UP,&StateStar_Context::event_mouse_click_handler));
+       insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateStar_Context::event_refresh_tool_options));
+}
+
+StateStar::~StateStar()
+{
+}
+
+void
+StateStar_Context::load_settings()
+{
+       String value;
+
+       //parse the arguments yargh!
+       if(settings.get_value("star.id",value))
+               set_id(value);
+       else
+               set_id("Star");
+
+       if(settings.get_value("star.feather",value))
+               set_feather(atof(value.c_str()));
+       else
+               set_feather(0);
+
+       if(settings.get_value("star.number_of_points",value))
+               set_number_of_points(atof(value.c_str()));
+       else
+               set_number_of_points(5);
+
+       if(settings.get_value("star.inner_tangent",value))
+               set_inner_tangent(atof(value.c_str()));
+       else
+               set_inner_tangent(0);
+
+       if(settings.get_value("star.outer_tangent",value))
+               set_outer_tangent(atof(value.c_str()));
+       else
+               set_outer_tangent(0);
+
+       if(settings.get_value("star.inner_width",value))
+               set_inner_width(atof(value.c_str()));
+       else
+               set_inner_width(1);
+
+       if(settings.get_value("star.outer_width",value))
+               set_outer_width(atof(value.c_str()));
+       else
+               set_outer_width(1);
+
+       if(settings.get_value("star.radius_ratio",value))
+               set_radius_ratio(atof(value.c_str()));
+       else
+               set_radius_ratio(0.5);
+
+       if(settings.get_value("star.angle_offset",value))
+               set_angle_offset(atof(value.c_str()));
+       else
+               set_angle_offset(0);
+
+       if(settings.get_value("star.invert",value) && value != "0")
+               set_invert(true);
+       else
+               set_invert(false);
+
+       if(settings.get_value("star.regular_polygon",value) && value != "0")
+               set_regular_polygon(true);
+       else
+               set_regular_polygon(false);
+
+       if(settings.get_value("star.layer_star",value) && value=="0")
+               set_layer_star_flag(false);
+       else
+               set_layer_star_flag(true);
+
+       if(settings.get_value("star.layer_region",value) && value=="1")
+               set_layer_region_flag(true);
+       else
+               set_layer_region_flag(false);
+
+       if(settings.get_value("star.layer_outline",value) && value=="1")
+               set_layer_outline_flag(true);
+       else
+               set_layer_outline_flag(false);
+
+       if(settings.get_value("star.layer_curve_gradient",value) && value=="1")
+               set_layer_curve_gradient_flag(true);
+       else
+               set_layer_curve_gradient_flag(false);
+
+       if(settings.get_value("star.layer_plant",value) && value=="1")
+               set_layer_plant_flag(true);
+       else
+               set_layer_plant_flag(false);
+
+       if(settings.get_value("star.layer_link_origins",value) && value=="0")
+               set_layer_link_origins_flag(false);
+       else
+               set_layer_link_origins_flag(true);
+
+       if(settings.get_value("star.layer_origins_at_center",value) && value=="0")
+               set_layer_origins_at_center_flag(false);
+       else
+               set_layer_origins_at_center_flag(true);
+}
+
+void
+StateStar_Context::save_settings()
+{
+       settings.set_value("star.id",get_id());
+       settings.set_value("star.feather",strprintf("%f",(float)get_feather()));
+       settings.set_value("star.number_of_points",strprintf("%d",(int)(get_number_of_points() + 0.5)));
+       settings.set_value("star.inner_tangent",strprintf("%f",(float)get_inner_tangent()));
+       settings.set_value("star.outer_tangent",strprintf("%f",(float)get_outer_tangent()));
+       settings.set_value("star.inner_width",strprintf("%f",(float)get_inner_width()));
+       settings.set_value("star.outer_width",strprintf("%f",(float)get_outer_width()));
+       settings.set_value("star.radius_ratio",strprintf("%f",(float)get_radius_ratio()));
+       settings.set_value("star.angle_offset",strprintf("%f",(float)get_angle_offset()));
+       settings.set_value("star.invert",get_invert()?"1":"0");
+       settings.set_value("star.regular_polygon",get_regular_polygon()?"1":"0");
+       settings.set_value("star.layer_star",get_layer_star_flag()?"1":"0");
+       settings.set_value("star.layer_outline",get_layer_outline_flag()?"1":"0");
+       settings.set_value("star.layer_region",get_layer_region_flag()?"1":"0");
+       settings.set_value("star.layer_curve_gradient",get_layer_curve_gradient_flag()?"1":"0");
+       settings.set_value("star.layer_plant",get_layer_plant_flag()?"1":"0");
+       settings.set_value("star.layer_link_origins",get_layer_link_origins_flag()?"1":"0");
+       settings.set_value("star.layer_origins_at_center",get_layer_origins_at_center_flag()?"1":"0");
+}
+
+void
+StateStar_Context::reset()
+{
+       refresh_ducks();
+}
+
+void
+StateStar_Context::increment_id()
+{
+       String id(get_id());
+       int number=1;
+       int digits=0;
+
+       if(id.empty())
+               id="Star";
+
+       // If there is a number
+       // already at the end of the
+       // id, then remove it.
+       if(id[id.size()-1]<='9' && id[id.size()-1]>='0')
+       {
+               // figure out how many digits it is
+               for (digits = 0;
+                        (int)id.size()-1 >= digits && id[id.size()-1-digits] <= '9' && id[id.size()-1-digits] >= '0';
+                        digits++)
+                       ;
+
+               String str_number;
+               str_number=String(id,id.size()-digits,id.size());
+               id=String(id,0,id.size()-digits);
+
+               number=atoi(str_number.c_str());
+       }
+       else
+       {
+               number=1;
+               digits=3;
+       }
+
+       number++;
+
+       // Add the number back onto the id
+       {
+               const String format(strprintf("%%0%dd",digits));
+               id+=strprintf(format.c_str(),number);
+       }
+
+       // Set the ID
+       set_id(id);
+}
+
+StateStar_Context::StateStar_Context(CanvasView* canvas_view):
+       canvas_view_(canvas_view),
+       is_working(*canvas_view),
+       duckmatic_push(get_work_area()),
+       prev_workarea_layer_status_(get_work_area()->get_allow_layer_clicks()),
+       settings(synfigapp::Main::get_selected_input_device()->settings()),
+       entry_id(),             //   value lower upper  step page
+       adj_feather(                    0,    0,    1, 0.01, 0.1),
+       adj_number_of_points(   0,    2,  120, 1   , 1  ),
+       adj_inner_tangent(              0,  -10,   10, 0.01, 0.1),
+       adj_outer_tangent(              0,  -10,   10, 0.01, 0.1),
+       adj_inner_width(                0,  -10,   10, 0.01, 0.1),
+       adj_outer_width(                0,  -10,   10, 0.01, 0.1),
+       adj_radius_ratio(               0,  -10,   10, 0.01, 0.1),
+       adj_angle_offset(               0, -360,  360, 0.1 , 1  ),
+       spin_feather(adj_feather,0.1,3),
+       spin_number_of_points(adj_number_of_points,1,0),
+       spin_inner_tangent(adj_inner_tangent,1,2),
+       spin_outer_tangent(adj_outer_tangent,1,2),
+       spin_inner_width(adj_inner_width,1,2),
+       spin_outer_width(adj_outer_width,1,2),
+       spin_radius_ratio(adj_radius_ratio,1,2),
+       spin_angle_offset(adj_angle_offset,1,1),
+       checkbutton_invert(_("Invert")),
+       checkbutton_regular_polygon(_("Regular Polygon")),
+       checkbutton_layer_star(_("Create Star Layer")),
+       checkbutton_layer_region(_("Create Region BLine")),
+       checkbutton_layer_outline(_("Create Outline BLine")),
+       checkbutton_layer_curve_gradient(_("Create Curve Gradient BLine")),
+       checkbutton_layer_plant(_("Create Plant BLine")),
+       checkbutton_layer_link_origins(_("Link Origins")),
+       checkbutton_layer_origins_at_center(_("BLine Origins at Center"))
+{
+       egress_on_selection_change=true;
+
+       load_settings();
+
+       // Set up the tool options dialog
+       options_table.attach(*manage(new Gtk::Label(_("Star Tool"))),                   0, 2,  0,  1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(entry_id,                                                                                  0, 2,  1,  2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_star,                                                    0, 2,  2,  3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_outline,                                                 0, 2,  3,  4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_region,                                                  0, 2,  4,  5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_plant,                                                   0, 2,  5,  6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_curve_gradient,                                  0, 2,  6,  7, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_link_origins,                                    0, 2,  7,  8, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_layer_origins_at_center,                               0, 2,  8,  9, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_invert,                                                                0, 2,  9, 10, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_regular_polygon,                                               0, 2, 10, 11, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       options_table.attach(*manage(new Gtk::Label(_("Feather:"))),                    0, 1, 11, 12, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(spin_feather,                                                                              1, 2, 11, 12, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       options_table.attach(*manage(new Gtk::Label(_("Number of Points:"))),   0, 1, 12, 13, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(spin_number_of_points,                                                             1, 2, 12, 13, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       options_table.attach(*manage(new Gtk::Label(_("Inner Tangent:"))),              0, 1, 13, 14, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(spin_inner_tangent,                                                                1, 2, 13, 14, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       options_table.attach(*manage(new Gtk::Label(_("Outer Tangent:"))),              0, 1, 14, 15, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(spin_outer_tangent,                                                                1, 2, 14, 15, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       options_table.attach(*manage(new Gtk::Label(_("Inner Width:"))),                0, 1, 15, 16, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(spin_inner_width,                                                                  1, 2, 15, 16, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       options_table.attach(*manage(new Gtk::Label(_("Outer Width:"))),                0, 1, 16, 17, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(spin_outer_width,                                                                  1, 2, 16, 17, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       options_table.attach(*manage(new Gtk::Label(_("Radius Ratio:"))),               0, 1, 17, 18, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(spin_radius_ratio,                                                                 1, 2, 17, 18, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       options_table.attach(*manage(new Gtk::Label(_("Angle Offset:"))),               0, 1, 18, 19, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(spin_angle_offset,                                                                 1, 2, 18, 19, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       options_table.show_all();
+
+       refresh_tool_options();
+       App::dialog_tool_options->present();
+
+       // Turn off layer clicking
+       get_work_area()->set_allow_layer_clicks(false);
+
+       // clear out the ducks
+       get_work_area()->clear_ducks();
+
+       // Refresh the work area
+       get_work_area()->queue_draw();
+
+       // Hide the tables if they are showing
+       //prev_table_status=get_canvas_view()->tables_are_visible();
+       //if(prev_table_status)get_canvas_view()->hide_tables();
+
+       // Disable the time bar
+       //get_canvas_view()->set_sensitive_timebar(false);
+
+       // Connect a signal
+       //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateStar_Context::on_user_click));
+       get_work_area()->set_cursor(Gdk::STAR);
+
+       App::toolbox->refresh();
+}
+
+void
+StateStar_Context::refresh_tool_options()
+{
+       App::dialog_tool_options->clear();
+       App::dialog_tool_options->set_widget(options_table);
+       App::dialog_tool_options->set_local_name(_("Star Tool"));
+       App::dialog_tool_options->set_name("star");
+}
+
+Smach::event_result
+StateStar_Context::event_refresh_tool_options(const Smach::event& /*x*/)
+{
+       refresh_tool_options();
+       return Smach::RESULT_ACCEPT;
+}
+
+StateStar_Context::~StateStar_Context()
+{
+       save_settings();
+
+       // Restore layer clicking
+       get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_);
+       get_work_area()->reset_cursor();
+
+       App::dialog_tool_options->clear();
+
+       // Enable the time bar
+       //get_canvas_view()->set_sensitive_timebar(true);
+
+       // Bring back the tables if they were out before
+       //if(prev_table_status)get_canvas_view()->show_tables();
+
+       // Refresh the work area
+       get_work_area()->queue_draw();
+
+       get_canvas_view()->queue_rebuild_ducks();
+
+       App::toolbox->refresh();
+}
+
+Smach::event_result
+StateStar_Context::event_stop_handler(const Smach::event& /*x*/)
+{
+       //throw Smach::egress_exception();
+       throw &state_normal;
+       return Smach::RESULT_OK;
+}
+
+Smach::event_result
+StateStar_Context::event_refresh_handler(const Smach::event& /*x*/)
+{
+       refresh_ducks();
+       return Smach::RESULT_ACCEPT;
+}
+
+void
+StateStar_Context::make_star(const Point& _p1, const Point& _p2)
+{
+       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("New Star"));
+       synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+       Layer::Handle layer;
+
+       Canvas::Handle canvas;
+       int depth(0);
+
+       // we are temporarily using the layer to hold something
+       layer=get_canvas_view()->get_selection_manager()->get_selected_layer();
+       if(layer)
+       {
+               depth=layer->get_depth();
+               canvas=layer->get_canvas();
+       }
+
+       synfigapp::SelectionManager::LayerList layer_selection;
+       if (!getenv("SYNFIG_TOOLS_CLEAR_SELECTION"))
+               layer_selection = get_canvas_view()->get_selection_manager()->get_selected_layers();
+
+       const synfig::TransformStack& transform(get_canvas_view()->get_curr_transform_stack());
+       const Point p1(transform.unperform(_p1));
+       const Point p2(transform.unperform(_p2));
+
+       Real radius_ratio(get_radius_ratio());
+       Real radius1((p2-p1).mag());
+       Real radius2(radius1 * radius_ratio);
+       int points = get_number_of_points();
+       Real inner_tangent = get_inner_tangent() * radius1;
+       Real outer_tangent = get_outer_tangent() * radius2;
+       Real inner_width = get_inner_width();
+       Real outer_width = get_outer_width();
+       Angle::deg offset(get_angle_offset());
+       bool regular(get_regular_polygon());
+       Angle::deg angle(360.0/points);
+       Vector origin;
+       Real x, y;
+
+       if (get_layer_origins_at_center_flag())
+       {
+               x = y = 0;
+               origin = p1;
+       }
+       else
+       {
+               x = p1[0];
+               y = p1[1];
+       }
+
+       std::vector<BLinePoint> new_list;
+       int point(0);
+       for (int i = 0; i < points; i++)
+       {
+               new_list.push_back(*(new BLinePoint));
+               new_list[point].set_width(outer_width);
+               new_list[point].set_vertex(Point(radius1*Angle::cos(angle*i + offset).get() + x,
+                                                                                radius1*Angle::sin(angle*i + offset).get() + y));
+               new_list[point++].set_tangent(Point(-Angle::sin(angle*i + offset).get(),
+                                                                                        Angle::cos(angle*i + offset).get()) * outer_tangent);
+
+               if (!regular)
+               {
+                       new_list.push_back(*(new BLinePoint));
+                       new_list[point].set_width(inner_width);
+                       new_list[point].set_vertex(Point(radius2*Angle::cos(angle*i + angle/2 + offset).get() + x,
+                                                                                        radius2*Angle::sin(angle*i + angle/2 + offset).get() + y));
+                       new_list[point++].set_tangent(Point(-Angle::sin(angle*i + angle/2 + offset).get(),
+                                                                                                Angle::cos(angle*i + angle/2 + offset).get()) * inner_tangent);
+               }
+       }
+
+       ValueNode_BLine::Handle value_node_bline(ValueNode_BLine::create(new_list));
+       assert(value_node_bline);
+
+       ValueNode_Const::Handle value_node_origin(ValueNode_Const::create(origin));
+       assert(value_node_origin);
+
+       // Set the looping flag
+       value_node_bline->set_loop(true);
+
+       if(!canvas)
+               canvas=get_canvas_view()->get_canvas();
+
+       value_node_bline->set_member_canvas(canvas);
+
+       // count how many layers we're going to be creating
+       int layers_to_create = this->layers_to_create();
+
+       ///////////////////////////////////////////////////////////////////////////
+       //   S T A R
+       ///////////////////////////////////////////////////////////////////////////
+
+       if (get_layer_star_flag())
+       {
+               layer=get_canvas_interface()->add_layer_to("star",canvas,depth);
+               if (!layer)
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                       group.cancel();
+                       return;
+               }
+               layer_selection.push_back(layer);
+
+               layer->set_param("radius1",radius1);
+               get_canvas_interface()->signal_layer_param_changed()(layer,"radius1");
+
+               layer->set_param("radius2",radius2);
+               get_canvas_interface()->signal_layer_param_changed()(layer,"radius2");
+
+               layer->set_param("angle",offset);
+               get_canvas_interface()->signal_layer_param_changed()(layer,"angle");
+
+               layer->set_param("points",points);
+               get_canvas_interface()->signal_layer_param_changed()(layer,"points");
+
+               layer->set_param("regular_polygon",regular);
+               get_canvas_interface()->signal_layer_param_changed()(layer,"regular_polygon");
+
+               layer->set_param("feather",get_feather());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
+
+               layer->set_param("invert",get_invert());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
+
+               layer->set_description(get_id());
+               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+               // only link the star's origin parameter if the option is selected, we're putting bline
+               // origins at their centers, and we're creating more than one layer
+               if (get_layer_link_origins_flag() && get_layer_origins_at_center_flag() && layers_to_create > 1)
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("origin")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create Star layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Star layer"));
+                               return;
+                       }
+               }
+               else
+               {
+                       layer->set_param("origin",p1);
+                       get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
+               }
+       }
+
+       ///////////////////////////////////////////////////////////////////////////
+       //   C U R V E   G R A D I E N T
+       ///////////////////////////////////////////////////////////////////////////
+
+       if(get_layer_curve_gradient_flag())
+       {
+               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+               Layer::Handle layer(get_canvas_interface()->add_layer_to("curve_gradient",canvas,depth));
+               if (!layer)
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                       group.cancel();
+                       return;
+               }
+               layer_selection.push_back(layer);
+               layer->set_description(get_id()+_(" Gradient"));
+               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("bline")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Gradient layer"));
+                               return;
+                       }
+               }
+
+               // only link the curve gradient's origin parameter if the option is selected and we're creating more than one layer
+               if (get_layer_link_origins_flag() && layers_to_create > 1)
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("origin")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Gradient layer"));
+                               return;
+                       }
+               }
+               else
+               {
+                       layer->set_param("origin",origin);
+                       get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
+               }
+       }
+
+       ///////////////////////////////////////////////////////////////////////////
+       //   P L A N T
+       ///////////////////////////////////////////////////////////////////////////
+
+       if(get_layer_plant_flag())
+       {
+               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+               Layer::Handle layer(get_canvas_interface()->add_layer_to("plant",canvas,depth));
+               if (!layer)
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                       group.cancel();
+                       return;
+               }
+               layer_selection.push_back(layer);
+               layer->set_description(get_id()+_(" Plant"));
+               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("bline")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Plant layer"));
+                               return;
+                       }
+               }
+
+               // only link the plant's origin parameter if the option is selected and we're creating more than one layer
+               if (get_layer_link_origins_flag() && layers_to_create > 1)
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("origin")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Plant layer"));
+                               return;
+                       }
+               }
+               else
+               {
+                       layer->set_param("origin",origin);
+                       get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
+               }
+       }
+
+       ///////////////////////////////////////////////////////////////////////////
+       //   R E G I O N
+       ///////////////////////////////////////////////////////////////////////////
+
+       if(get_layer_region_flag())
+       {
+               synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+               Layer::Handle layer(get_canvas_interface()->add_layer_to("region",canvas,depth));
+               if (!layer)
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                       group.cancel();
+                       return;
+               }
+               layer_selection.push_back(layer);
+               layer->set_description(get_id()+_(" Region"));
+               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+               layer->set_param("feather",get_feather());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
+
+               layer->set_param("invert",get_invert());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
+
+               // I don't know if it's safe to reuse the same LayerParamConnect action, so I'm
+               // using 2 separate ones.
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("bline")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Region layer"));
+                               return;
+                       }
+               }
+
+               // only link the region's origin parameter if the option is selected and we're creating more than one layer
+               if (get_layer_link_origins_flag() && layers_to_create > 1)
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("origin")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create Region layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Region layer"));
+                               return;
+                       }
+               }
+               else
+               {
+                       layer->set_param("origin",origin);
+                       get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
+               }
+       }
+
+       ///////////////////////////////////////////////////////////////////////////
+       //   O U T L I N E
+       ///////////////////////////////////////////////////////////////////////////
+
+       if (get_layer_outline_flag())
+       {
+               Layer::Handle layer(get_canvas_interface()->add_layer_to("outline",canvas,depth));
+               if (!layer)
+               {
+                       get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+                       group.cancel();
+                       return;
+               }
+               layer_selection.push_back(layer);
+               layer->set_description(get_id()+_(" Outline"));
+               get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+               layer->set_param("feather",get_feather());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"feather");
+
+               layer->set_param("invert",get_invert());
+               get_canvas_interface()->signal_layer_param_changed()(layer,"invert");
+
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("bline")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_bline)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Outline layer"));
+                               return;
+                       }
+               }
+
+               // only link the outline's origin parameter if the option is selected and we're creating more than one layer
+               if (get_layer_link_origins_flag() && layers_to_create > 1)
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("LayerParamConnect"));
+                       assert(action);
+
+                       action->set_param("canvas",get_canvas());
+                       action->set_param("canvas_interface",get_canvas_interface());
+                       action->set_param("layer",layer);
+                       if(!action->set_param("param",String("origin")))
+                               synfig::error("LayerParamConnect didn't like \"param\"");
+                       if(!action->set_param("value_node",ValueNode::Handle(value_node_origin)))
+                               synfig::error("LayerParamConnect didn't like \"value_node\"");
+
+                       if(!get_canvas_interface()->get_instance()->perform_action(action))
+                       {
+                               //get_canvas_view()->get_ui_interface()->error(_("Unable to create BLine layer"));
+                               group.cancel();
+                               throw String(_("Unable to create Outline layer"));
+                               return;
+                       }
+               }
+               else
+               {
+                       layer->set_param("origin",origin);
+                       get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
+               }
+       }
+
+       egress_on_selection_change=false;
+       get_canvas_interface()->get_selection_manager()->clear_selected_layers();
+       get_canvas_interface()->get_selection_manager()->set_selected_layers(layer_selection);
+       egress_on_selection_change=true;
+
+       reset();
+       increment_id();
+}
+
+Smach::event_result
+StateStar_Context::event_mouse_click_handler(const Smach::event& x)
+{
+       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
+
+       if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_DOWN && event.button==BUTTON_LEFT)
+       {
+               point_holder=get_work_area()->snap_point_to_grid(event.pos);
+               etl::handle<Duck> duck=new Duck();
+               duck->set_point(point_holder);
+               duck->set_name("p1");
+               duck->set_type(Duck::TYPE_POSITION);
+               duck->set_editable(false);
+               get_work_area()->add_duck(duck);
+
+               point2_duck=new Duck();
+               point2_duck->set_point(Vector(0,0));
+               point2_duck->set_name("radius");
+               point2_duck->set_origin(duck);
+               point2_duck->set_radius(true);
+               point2_duck->set_scalar(-1);
+               point2_duck->set_type(Duck::TYPE_RADIUS);
+               point2_duck->set_hover(true);
+               get_work_area()->add_duck(point2_duck);
+
+               return Smach::RESULT_ACCEPT;
+       }
+
+       if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_DRAG && event.button==BUTTON_LEFT)
+       {
+               if (!point2_duck) return Smach::RESULT_OK;
+               point2_duck->set_point(point_holder-get_work_area()->snap_point_to_grid(event.pos));
+               get_work_area()->queue_draw();
+               return Smach::RESULT_ACCEPT;
+       }
+
+       if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_UP && event.button==BUTTON_LEFT)
+       {
+               Point point(get_work_area()->snap_point_to_grid(event.pos));
+
+               if (App::restrict_radius_ducks)
+               {
+                       if ((point[0] - point_holder[0]) < 0) point[0] = point_holder[0];
+                       if ((point[1] - point_holder[1]) < 0) point[1] = point_holder[1];
+               }
+
+               make_star(point_holder, point);
+               get_work_area()->clear_ducks();
+               return Smach::RESULT_ACCEPT;
+       }
+
+       return Smach::RESULT_OK;
+}
+
+
+void
+StateStar_Context::refresh_ducks()
+{
+       get_work_area()->clear_ducks();
+       get_work_area()->queue_draw();
+}
diff --git a/synfig-studio/src/gui/state_star.h b/synfig-studio/src/gui/state_star.h
new file mode 100644 (file)
index 0000000..606f77d
--- /dev/null
@@ -0,0 +1,57 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_star.h
+**     \brief Star creation state
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_STUDIO_STATE_STAR_H
+#define __SYNFIG_STUDIO_STATE_STAR_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 StateStar_Context;
+
+class StateStar : public Smach::state<StateStar_Context>
+{
+public:
+       StateStar();
+       ~StateStar();
+}; // END of class StateStar
+
+extern StateStar state_star;
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/state_stroke.cpp b/synfig-studio/src/gui/state_stroke.cpp
new file mode 100644 (file)
index 0000000..a0f7eca
--- /dev/null
@@ -0,0 +1,198 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_stroke.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \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
+**     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 <config.h>
+#endif
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/entry.h>
+
+#include <synfig/valuenode_dynamiclist.h>
+
+#include "state_stroke.h"
+#include "canvasview.h"
+#include "workarea.h"
+#include "app.h"
+#include <synfig/valuenode_bline.h>
+#include <ETL/hermite>
+#include <ETL/calculus>
+#include <utility>
+#include "event_mouse.h"
+#include "event_layerclick.h"
+#include "toolbox.h"
+#include <synfigapp/main.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 ======================================================= */
+
+StateStroke studio::state_stroke;
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+class studio::StateStroke_Context : public sigc::trackable
+{
+       etl::handle<CanvasView> canvas_view_;
+       CanvasView::IsWorking is_working;
+
+       Duckmatic::Push duckmatic_push;
+
+       etl::smart_ptr<std::list<synfig::Point> > stroke_data;
+
+       etl::smart_ptr<std::list<synfig::Real> > width_data;
+
+       Gdk::ModifierType modifier;
+
+public:
+
+       Smach::event_result event_stop_handler(const Smach::event& x);
+
+       Smach::event_result event_refresh_handler(const Smach::event& x);
+
+       Smach::event_result event_mouse_up_handler(const Smach::event& x);
+
+       Smach::event_result event_mouse_draw_handler(const Smach::event& x);
+       Smach::event_result event_refresh_tool_options(const Smach::event& x);
+
+       StateStroke_Context(CanvasView* canvas_view);
+
+       ~StateStroke_Context();
+
+       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
+       etl::handle<synfigapp::CanvasInterface> 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();}
+
+};     // END of class StateStroke_Context
+
+
+/* === M E T H O D S ======================================================= */
+
+StateStroke::StateStroke():
+       Smach::state<StateStroke_Context>("stroke")
+{
+       insert(event_def(EVENT_STOP,&StateStroke_Context::event_stop_handler));
+       insert(event_def(EVENT_REFRESH,&StateStroke_Context::event_refresh_handler));
+//     insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StateStroke_Context::event_mouse_down_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_UP,&StateStroke_Context::event_mouse_up_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DRAG,&StateStroke_Context::event_mouse_draw_handler));
+       insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateStroke_Context::event_refresh_tool_options));
+}
+
+StateStroke::~StateStroke()
+{
+}
+
+
+StateStroke_Context::StateStroke_Context(CanvasView* canvas_view):
+       canvas_view_(canvas_view),
+       is_working(*canvas_view),
+       duckmatic_push(get_work_area())
+{
+       width_data.spawn();
+       stroke_data.spawn();
+
+       get_work_area()->add_stroke(stroke_data, synfigapp::Main::get_outline_color());
+}
+
+StateStroke_Context::~StateStroke_Context()
+{
+       duckmatic_push.restore();
+
+       App::toolbox->refresh();
+
+       // Send the stroke data to whatever previously called this state.
+       if(stroke_data->size()>=2)
+               get_canvas_view()->get_smach().process_event(EventStroke(stroke_data,width_data,modifier));
+}
+
+Smach::event_result
+StateStroke_Context::event_refresh_tool_options(const Smach::event& /*x*/)
+{
+       return Smach::RESULT_ACCEPT;
+}
+
+Smach::event_result
+StateStroke_Context::event_stop_handler(const Smach::event& /*x*/)
+{
+       throw Smach::pop_exception();
+}
+
+Smach::event_result
+StateStroke_Context::event_refresh_handler(const Smach::event& /*x*/)
+{
+       return Smach::RESULT_ACCEPT;
+}
+
+Smach::event_result
+StateStroke_Context::event_mouse_up_handler(const Smach::event& x)
+{
+       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
+       switch(event.button)
+       {
+       case BUTTON_LEFT:
+               {
+                       modifier=event.modifier;
+                       throw Smach::pop_exception();
+               }
+
+       default:
+               return Smach::RESULT_OK;
+       }
+}
+
+Smach::event_result
+StateStroke_Context::event_mouse_draw_handler(const Smach::event& x)
+{
+       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
+       switch(event.button)
+       {
+       case BUTTON_LEFT:
+               {
+                       stroke_data->push_back(event.pos);
+                       width_data->push_back(event.pressure);
+                       get_work_area()->queue_draw();
+                       return Smach::RESULT_ACCEPT;
+               }
+
+       default:
+               return Smach::RESULT_OK;
+       }
+}
diff --git a/synfig-studio/src/gui/state_stroke.h b/synfig-studio/src/gui/state_stroke.h
new file mode 100644 (file)
index 0000000..0beade5
--- /dev/null
@@ -0,0 +1,80 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_stroke.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_STROKE_H
+#define __SYNFIG_STUDIO_STATE_STROKE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include "canvasview.h"
+#include "workarea.h"
+#include <sigc++/object.h>
+#include "duckmatic.h"
+#include <synfig/blinepoint.h>
+#include <list>
+#include <ETL/smart_ptr>
+#include "eventkey.h"
+#include <gdkmm/types.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 StateStroke_Context;
+
+class StateStroke : public Smach::state<StateStroke_Context>
+{
+public:
+       StateStroke();
+       ~StateStroke();
+}; // END of class StateStroke
+
+extern StateStroke state_stroke;
+
+struct EventStroke : public Smach::event
+{
+       etl::smart_ptr<std::list<synfig::Point> > stroke_data;
+       etl::smart_ptr<std::list<synfig::Real> > width_data;
+       Gdk::ModifierType modifier;
+
+       EventStroke(etl::smart_ptr<std::list<synfig::Point> > stroke_data,
+                       etl::smart_ptr<std::list<synfig::Real> > width_data,
+                       Gdk::ModifierType modifier=Gdk::ModifierType(0)
+       ):
+               Smach::event(EVENT_WORKAREA_STROKE),
+               stroke_data(stroke_data),
+               width_data(width_data),
+               modifier(modifier)
+       { }
+}; // END of EventStroke
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/state_text.cpp b/synfig-studio/src/gui/state_text.cpp
new file mode 100644 (file)
index 0000000..f475420
--- /dev/null
@@ -0,0 +1,460 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_text.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 <config.h>
+#endif
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/entry.h>
+
+#include "state_text.h"
+#include "state_normal.h"
+#include "canvasview.h"
+#include "workarea.h"
+#include "app.h"
+
+#include <synfigapp/action.h>
+#include "event_mouse.h"
+#include "event_layerclick.h"
+#include "toolbox.h"
+#include "dialog_tooloptions.h"
+#include <gtkmm/optionmenu.h>
+#include "duck.h"
+#include "widget_enum.h"
+#include <synfigapp/main.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 ======================================================= */
+
+StateText studio::state_text;
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+class studio::StateText_Context
+{
+       etl::handle<CanvasView> canvas_view;
+       CanvasView::IsWorking is_working;
+
+       Duckmatic::Push duckmatic_push;
+
+       void refresh_ducks();
+
+       bool prev_workarea_layer_status_;
+
+       //Toolbox settings
+       synfigapp::Settings& settings;
+
+       //Toolbox display
+       Gtk::Table options_table;
+
+       Gtk::Entry              entry_id; //what to name the layer
+       Gtk::Entry              entry_family;
+       Widget_Vector   widget_size;
+       Widget_Vector   widget_orientation;
+       Gtk::CheckButton checkbutton_paragraph;
+
+public:
+       synfig::String get_id()const { return entry_id.get_text(); }
+       void set_id(const synfig::String& x) { return entry_id.set_text(x); }
+
+       bool get_paragraph_flag()const { return checkbutton_paragraph.get_active(); }
+       void set_paragraph_flag(bool x) { return checkbutton_paragraph.set_active(x); }
+
+       Vector get_size() { return widget_size.get_value(); }
+       void set_size(Vector s) { return widget_size.set_value(s); }
+
+       Vector get_orientation() { return widget_orientation.get_value(); }
+       void set_orientation(Vector s) { return widget_orientation.set_value(s); }
+
+       String get_family()const { return entry_family.get_text(); }
+       void set_family(String s) { return entry_family.set_text(s); }
+
+       void refresh_tool_options(); //to refresh the toolbox
+
+       //events
+       Smach::event_result event_stop_handler(const Smach::event& x);
+       Smach::event_result event_refresh_handler(const Smach::event& x);
+       Smach::event_result event_mouse_click_handler(const Smach::event& x);
+       Smach::event_result event_refresh_tool_options(const Smach::event& x);
+       Smach::event_result event_workarea_mouse_button_down_handler(const Smach::event& x);
+
+       //constructor destructor
+       StateText_Context(CanvasView *canvas_view);
+       ~StateText_Context();
+
+       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view;}
+       etl::handle<synfigapp::CanvasInterface> get_canvas_interface()const{return canvas_view->canvas_interface();}
+       WorkArea * get_work_area()const{return canvas_view->get_work_area();}
+
+       //Modifying settings etc.
+       void load_settings();
+       void save_settings();
+       void reset();
+       void increment_id();
+       bool egress_on_selection_change;
+       Smach::event_result event_layer_selection_changed_handler(const Smach::event& /*x*/)
+       {
+               if(egress_on_selection_change)
+                       throw &state_normal; //throw Smach::egress_exception();
+               return Smach::RESULT_OK;
+       }
+
+       void make_text(const Point& point);
+
+}; // END of class StateText_Context
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+StateText::StateText():
+       Smach::state<StateText_Context>("text")
+{
+       insert(event_def(EVENT_LAYER_SELECTION_CHANGED,&StateText_Context::event_layer_selection_changed_handler));
+       insert(event_def(EVENT_STOP,&StateText_Context::event_stop_handler));
+       insert(event_def(EVENT_REFRESH,&StateText_Context::event_refresh_handler));
+       insert(event_def(EVENT_REFRESH_DUCKS,&StateText_Context::event_refresh_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StateText_Context::event_workarea_mouse_button_down_handler));
+       insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateText_Context::event_refresh_tool_options));
+}
+
+StateText::~StateText()
+{
+}
+
+void
+StateText_Context::load_settings()
+{
+       String value;
+       Vector v;
+
+       //parse the arguments yargh!
+       if(settings.get_value("text.id",value))
+               set_id(value);
+       else
+               set_id("Text");
+
+       if(settings.get_value("text.paragraph",value) && value=="1")
+               set_paragraph_flag(true);
+       else
+               set_paragraph_flag(false);
+
+       if(settings.get_value("text.size_x",value))
+               v[0] = atof(value.c_str());
+       else
+               v[0] = 0.25;
+       if(settings.get_value("text.size_y",value))
+               v[1] = atof(value.c_str());
+       else
+               v[1] = 0.25;
+       set_size(v);
+
+       if(settings.get_value("text.orient_x",value))
+               v[0] = atof(value.c_str());
+       else
+               v[0] = 0.5;
+       if(settings.get_value("text.orient_y",value))
+               v[1] = atof(value.c_str());
+       else
+               v[1] = 0.5;
+       set_orientation(v);
+
+       if(settings.get_value("text.family",value))
+               set_family(value);
+       else
+               set_family("Sans Serif");
+}
+
+void
+StateText_Context::save_settings()
+{
+       settings.set_value("text.id",get_id());
+       settings.set_value("text.paragraph",get_paragraph_flag()?"1":"0");
+       settings.set_value("text.size_x",strprintf("%f",(float)get_size()[0]));
+       settings.set_value("text.size_y",strprintf("%f",(float)get_size()[1]));
+       settings.set_value("text.orient_x",strprintf("%f",(float)get_orientation()[0]));
+       settings.set_value("text.orient_y",strprintf("%f",(float)get_orientation()[1]));
+       settings.set_value("text.family",get_family());
+}
+
+void
+StateText_Context::reset()
+{
+       refresh_ducks();
+}
+
+void
+StateText_Context::increment_id()
+{
+       String id(get_id());
+       int number=1;
+       int digits=0;
+
+       if(id.empty())
+               id="Text";
+
+       // If there is a number
+       // already at the end of the
+       // id, then remove it.
+       if(id[id.size()-1]<='9' && id[id.size()-1]>='0')
+       {
+               // figure out how many digits it is
+               for (digits = 0;
+                        (int)id.size()-1 >= digits && id[id.size()-1-digits] <= '9' && id[id.size()-1-digits] >= '0';
+                        digits++)
+                       ;
+
+               String str_number;
+               str_number=String(id,id.size()-digits,id.size());
+               id=String(id,0,id.size()-digits);
+
+               number=atoi(str_number.c_str());
+       }
+       else
+       {
+               number=1;
+               digits=3;
+       }
+
+       number++;
+
+       // Add the number back onto the id
+       {
+               const String format(strprintf("%%0%dd",digits));
+               id+=strprintf(format.c_str(),number);
+       }
+
+       // Set the ID
+       set_id(id);
+}
+
+StateText_Context::StateText_Context(CanvasView *canvas_view):
+       canvas_view(canvas_view),
+       is_working(*canvas_view),
+       duckmatic_push(get_work_area()),
+       prev_workarea_layer_status_(get_work_area()->get_allow_layer_clicks()),
+       settings(synfigapp::Main::get_selected_input_device()->settings()),
+       entry_id(),
+       checkbutton_paragraph(_("Multiline Editor"))
+{
+       egress_on_selection_change=true;
+
+       widget_size.set_digits(2);
+       widget_size.set_canvas(canvas_view->get_canvas());
+
+       widget_orientation.set_digits(2);
+
+       options_table.attach(*manage(new Gtk::Label(_("Text Tool"))),           0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(entry_id,                                                                          0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(checkbutton_paragraph,                                                     0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(*manage(new Gtk::Label(_("Size:"))),                       0, 1, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(widget_size,                                                                       1, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(*manage(new Gtk::Label(_("Orientation:"))),        0, 1, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(widget_orientation,                                                        1, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(*manage(new Gtk::Label(_("Family:"))),                     0, 1, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(entry_family,                                                                      1, 2, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       load_settings();
+
+       options_table.show_all();
+
+       refresh_tool_options();
+       App::dialog_tool_options->present();
+
+       // Turn off layer clicking
+       get_work_area()->set_allow_layer_clicks(false);
+
+       // clear out the ducks
+       get_work_area()->clear_ducks();
+
+       // Refresh the work area
+       get_work_area()->queue_draw();
+
+       // Hide the tables if they are showing
+       //prev_table_status=get_canvas_view()->tables_are_visible();
+       //if(prev_table_status)get_canvas_view()->hide_tables();
+
+       // Disable the time bar
+       //get_canvas_view()->set_sensitive_timebar(false);
+
+       // Connect a signal
+       //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateText_Context::on_user_click));
+       get_work_area()->set_cursor(Gdk::XTERM);
+
+       App::toolbox->refresh();
+}
+
+void
+StateText_Context::refresh_tool_options()
+{
+       App::dialog_tool_options->clear();
+       App::dialog_tool_options->set_widget(options_table);
+       App::dialog_tool_options->set_local_name(_("Text Tool"));
+       App::dialog_tool_options->set_name("text");
+}
+
+Smach::event_result
+StateText_Context::event_refresh_tool_options(const Smach::event& /*x*/)
+{
+       refresh_tool_options();
+       return Smach::RESULT_ACCEPT;
+}
+
+StateText_Context::~StateText_Context()
+{
+       save_settings();
+
+       // Restore layer clicking
+       get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_);
+       get_work_area()->reset_cursor();
+
+       App::dialog_tool_options->clear();
+
+       get_work_area()->queue_draw();
+
+       get_canvas_view()->queue_rebuild_ducks();
+
+       App::toolbox->refresh();
+}
+
+Smach::event_result
+StateText_Context::event_stop_handler(const Smach::event& /*x*/)
+{
+       //throw Smach::egress_exception();
+       throw &state_normal;
+       return Smach::RESULT_OK;
+}
+
+Smach::event_result
+StateText_Context::event_refresh_handler(const Smach::event& /*x*/)
+{
+       refresh_ducks();
+       return Smach::RESULT_ACCEPT;
+}
+
+void
+StateText_Context::make_text(const Point& _point)
+{
+       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("New Text"));
+       synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
+
+       Layer::Handle layer;
+
+       Canvas::Handle canvas(get_canvas_view()->get_canvas());
+       int depth(0);
+
+       // we are temporarily using the layer to hold something
+       layer=get_canvas_view()->get_selection_manager()->get_selected_layer();
+       if(layer)
+       {
+               depth=layer->get_depth();
+               canvas=layer->get_canvas();
+       }
+
+       synfigapp::SelectionManager::LayerList layer_selection;
+       if (!getenv("SYNFIG_TOOLS_CLEAR_SELECTION"))
+               layer_selection = get_canvas_view()->get_selection_manager()->get_selected_layers();
+
+       const synfig::TransformStack& transform(get_canvas_view()->get_curr_transform_stack());
+       const Point point(transform.unperform(_point));
+
+       String text;
+       if (get_paragraph_flag())
+               App::dialog_paragraph(_("Text Paragraph"), _("Enter text here:"), text);
+       else
+               App::dialog_entry(_("Text Entry"), _("Enter text here:"), text);
+
+       layer=get_canvas_interface()->add_layer_to("text",canvas,depth);
+       if (!layer)
+       {
+               get_canvas_view()->get_ui_interface()->error(_("Unable to create layer"));
+               group.cancel();
+               return;
+       }
+       layer_selection.push_back(layer);
+
+       layer->set_param("origin",point);
+       get_canvas_interface()->signal_layer_param_changed()(layer,"origin");
+
+       layer->set_param("text",text);
+       get_canvas_interface()->signal_layer_param_changed()(layer,"text");
+
+       layer->set_param("size",get_size());
+       get_canvas_interface()->signal_layer_param_changed()(layer,"size");
+
+       layer->set_param("orient",get_orientation());
+       get_canvas_interface()->signal_layer_param_changed()(layer,"orient");
+
+       layer->set_param("family",get_family());
+       get_canvas_interface()->signal_layer_param_changed()(layer,"family");
+
+       layer->set_description(get_id());
+       get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
+
+       egress_on_selection_change=false;
+       get_canvas_interface()->get_selection_manager()->clear_selected_layers();
+       get_canvas_interface()->get_selection_manager()->set_selected_layers(layer_selection);
+       egress_on_selection_change=true;
+
+       reset();
+       increment_id();
+}
+
+Smach::event_result
+StateText_Context::event_workarea_mouse_button_down_handler(const Smach::event& x)
+{
+       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
+       if(event.button==BUTTON_LEFT)
+       {
+               make_text(get_work_area()->snap_point_to_grid(event.pos));
+
+               get_work_area()->clear_ducks();
+               return Smach::RESULT_ACCEPT;
+       }
+       return Smach::RESULT_OK;
+}
+
+void
+StateText_Context::refresh_ducks()
+{
+       get_work_area()->clear_ducks();
+       get_work_area()->queue_draw();
+}
diff --git a/synfig-studio/src/gui/state_text.h b/synfig-studio/src/gui/state_text.h
new file mode 100644 (file)
index 0000000..4b05db5
--- /dev/null
@@ -0,0 +1,57 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_text.h
+**     \brief Template Header
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_STATE_TEXT_H
+#define __SYNFIG_STATE_TEXT_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 StateText_Context;
+
+class StateText : public Smach::state<StateText_Context>
+{
+public:
+       StateText();
+       ~StateText();
+}; // END of class StateText
+
+extern StateText state_text;
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/state_width.cpp b/synfig-studio/src/gui/state_width.cpp
new file mode 100644 (file)
index 0000000..8c74daa
--- /dev/null
@@ -0,0 +1,606 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_width.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 <config.h>
+#endif
+
+#include <gtkmm/dialog.h>
+#include <gtkmm/entry.h>
+
+#include <ETL/bezier>
+
+#include <synfig/valuenode_dynamiclist.h>
+#include <synfigapp/action_system.h>
+
+#include "state_width.h"
+#include "state_normal.h"
+#include "canvasview.h"
+#include "workarea.h"
+#include "app.h"
+
+#include <synfigapp/action.h>
+#include "event_mouse.h"
+#include "event_layerclick.h"
+#include "toolbox.h"
+#include "dialog_tooloptions.h"
+#include <gtkmm/optionmenu.h>
+#include "duck.h"
+
+//#include <synfigapp/value_desc.h>
+#include <synfigapp/main.h>
+
+#include <ETL/clock>
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+using namespace synfigapp;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+
+StateWidth studio::state_width;
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+class studio::StateWidth_Context : public sigc::trackable
+{
+       etl::handle<CanvasView> canvas_view_;
+       CanvasView::IsWorking is_working;
+
+       //Point mouse_pos;
+
+       handle<Duck> center;
+       handle<Duck> radius;
+       handle<Duck> closestpoint;
+
+       map<handle<Duck>,Real>  changetable;
+
+       etl::clock      clocktime;
+       Real            lastt;
+
+       bool added;
+
+       void refresh_ducks();
+
+       bool prev_workarea_layer_clicking;
+       bool prev_workarea_duck_clicking;
+       Duckmatic::Type old_duckmask;
+
+       //Toolbox settings
+       synfigapp::Settings& settings;
+
+       //Toolbox display
+       Gtk::Table options_table;
+
+       Gtk::Adjustment adj_delta;
+       Gtk::SpinButton spin_delta;
+
+       Gtk::Adjustment adj_radius;
+       Gtk::SpinButton spin_radius;
+
+       Gtk::CheckButton check_relative;
+
+       void AdjustWidth(handle<Duckmatic::Bezier> c, float t, Real mult, bool invert);
+
+public:
+
+       Real get_delta()const { return adj_delta.get_value(); }
+       void set_delta(Real f) { adj_delta.set_value(f); }
+
+       Real get_radius()const { return adj_radius.get_value(); }
+       void set_radius(Real f) { adj_radius.set_value(f); }
+
+       bool get_relative() const { return check_relative.get_active(); }
+       void set_relative(bool r) { check_relative.set_active(r); }
+
+       void refresh_tool_options(); //to refresh the toolbox
+
+       //events
+       Smach::event_result event_stop_handler(const Smach::event& x);
+       Smach::event_result event_refresh_handler(const Smach::event& x);
+       Smach::event_result event_mouse_handler(const Smach::event& x);
+       Smach::event_result event_refresh_tool_options(const Smach::event& x);
+
+       //constructor destructor
+       StateWidth_Context(CanvasView* canvas_view);
+       ~StateWidth_Context();
+
+       //Canvas interaction
+       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
+       etl::handle<synfigapp::CanvasInterface> 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();}
+
+       //Modifying settings etc.
+       void load_settings();
+       void save_settings();
+       void reset();
+
+};     // END of class StateWidth_Context
+
+/* === M E T H O D S ======================================================= */
+
+StateWidth::StateWidth():
+       Smach::state<StateWidth_Context>("width")
+{
+       insert(event_def(EVENT_STOP,&StateWidth_Context::event_stop_handler));
+       insert(event_def(EVENT_REFRESH,&StateWidth_Context::event_refresh_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StateWidth_Context::event_mouse_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DRAG,&StateWidth_Context::event_mouse_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_UP,&StateWidth_Context::event_mouse_handler));
+       insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateWidth_Context::event_refresh_tool_options));
+}
+
+StateWidth::~StateWidth()
+{
+}
+
+void
+StateWidth_Context::load_settings()
+{
+       String value;
+
+       //parse the arguments yargh!
+       if(settings.get_value("width.delta",value))
+               set_delta(atof(value.c_str()));
+       else
+               set_delta(6);
+
+       if(settings.get_value("width.radius",value))
+               set_radius(atof(value.c_str()));
+       else
+               set_radius(15);
+
+       //defaults to false
+       if(settings.get_value("width.relative",value) && value == "1")
+               set_relative(true);
+       else
+               set_relative(false);
+}
+
+void
+StateWidth_Context::save_settings()
+{
+       settings.set_value("width.delta",strprintf("%f",get_delta()));
+       settings.set_value("width.radius",strprintf("%f",get_radius()));
+       settings.set_value("width.relative",get_relative()?"1":"0");
+}
+
+void
+StateWidth_Context::reset()
+{
+       refresh_ducks();
+}
+
+StateWidth_Context::StateWidth_Context(CanvasView* canvas_view):
+       canvas_view_(canvas_view),
+       is_working(*canvas_view),
+       prev_workarea_layer_clicking(get_work_area()->get_allow_layer_clicks()),
+       prev_workarea_duck_clicking(get_work_area()->get_allow_duck_clicks()),
+       old_duckmask(get_work_area()->get_type_mask()),
+
+       settings(synfigapp::Main::get_selected_input_device()->settings()),
+
+       adj_delta(6,0,20,0.01,0.1),
+       spin_delta(adj_delta,0.01,3),
+
+       adj_radius(200,0,1e50,1,10),
+       spin_radius(adj_radius,1,1),
+
+       check_relative(_("Relative Growth"))
+{
+       load_settings();
+
+       // Set up the tool options dialog
+       options_table.attach(*manage(new Gtk::Label(_("Width Tool"))),  0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       //expand stuff
+       options_table.attach(*manage(new Gtk::Label(_("Growth:"))),             0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(spin_delta,                                                                1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       options_table.attach(*manage(new Gtk::Label(_("Radius:"))),             0, 1, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       options_table.attach(spin_radius,                                                               1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       options_table.attach(check_relative,                                                    0, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       options_table.show_all();
+
+       refresh_tool_options();
+       App::dialog_tool_options->present();
+
+       // Turn off layer clicking
+       get_work_area()->set_allow_layer_clicks(false);
+
+       // clear out the ducks
+       //get_work_area()->clear_ducks();
+
+       // Refresh the work area
+       get_work_area()->queue_draw();
+
+       //Create the new ducks
+       added = false;
+
+       if(!center)
+       {
+               center = new Duck();
+               center->set_name("p1");
+               center->set_type(Duck::TYPE_POSITION);
+       }
+
+       if(!radius)
+       {
+               radius = new Duck();
+               radius->set_origin(center);
+               radius->set_radius(true);
+               radius->set_type(Duck::TYPE_RADIUS);
+               radius->set_name("radius");
+       }
+
+       if(!closestpoint)
+       {
+               closestpoint = new Duck();
+               closestpoint->set_name("closest");
+               closestpoint->set_type(Duck::TYPE_POSITION);
+       }
+
+       //Disable duck clicking for the maximum coolness :)
+       get_work_area()->set_allow_duck_clicks(false);
+       get_work_area()->set_type_mask((Duck::Type)((int)Duck::TYPE_WIDTH + (int)Duck::TYPE_RADIUS));
+
+       // Turn the mouse pointer to crosshairs
+       get_work_area()->set_cursor(Gdk::CROSSHAIR);
+
+       // Hide the tables if they are showing
+       //prev_table_status=get_canvas_view()->tables_are_visible();
+       //if(prev_table_status)get_canvas_view()->hide_tables();
+
+       // Disable the time bar
+       //get_canvas_view()->set_sensitive_timebar(false);
+
+       // Connect a signal
+       //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateWidth_Context::on_user_click));
+
+       App::toolbox->refresh();
+}
+
+void
+StateWidth_Context::refresh_tool_options()
+{
+       App::dialog_tool_options->clear();
+       App::dialog_tool_options->set_widget(options_table);
+       App::dialog_tool_options->set_local_name(_("Width Tool"));
+       App::dialog_tool_options->set_name("width");
+}
+
+Smach::event_result
+StateWidth_Context::event_refresh_tool_options(const Smach::event& /*x*/)
+{
+       refresh_tool_options();
+       return Smach::RESULT_ACCEPT;
+}
+
+StateWidth_Context::~StateWidth_Context()
+{
+       save_settings();
+
+       //remove ducks if need be
+       if(added)
+       {
+               get_work_area()->erase_duck(center);
+               get_work_area()->erase_duck(radius);
+               get_work_area()->erase_duck(closestpoint);
+               added = false;
+       }
+
+       // Restore Duck clicking
+       get_work_area()->set_allow_duck_clicks(prev_workarea_duck_clicking);
+
+       // Restore layer clicking
+       get_work_area()->set_allow_layer_clicks(prev_workarea_layer_clicking);
+
+       // Restore the mouse pointer
+       get_work_area()->reset_cursor();
+
+       // Restore duck masking
+       get_work_area()->set_type_mask(old_duckmask);
+
+       // Tool options be rid of ye!!
+       App::dialog_tool_options->clear();
+
+       // Enable the time bar
+       //get_canvas_view()->set_sensitive_timebar(true);
+
+       // Bring back the tables if they were out before
+       //if(prev_table_status)get_canvas_view()->show_tables();
+
+       // Refresh the work area
+       get_work_area()->queue_draw();
+
+       App::toolbox->refresh();
+}
+
+Smach::event_result
+StateWidth_Context::event_stop_handler(const Smach::event& /*x*/)
+{
+       //throw Smach::egress_exception();
+       throw &state_normal;
+       return Smach::RESULT_OK;
+}
+
+Smach::event_result
+StateWidth_Context::event_refresh_handler(const Smach::event& /*x*/)
+{
+       refresh_ducks();
+       return Smach::RESULT_ACCEPT;
+}
+
+void
+StateWidth_Context::AdjustWidth(handle<Duckmatic::Bezier> c, float t, Real mult, bool invert)
+{
+       //Leave the function if there is no curve
+       if(!c)return;
+
+       Real amount1=0,amount2=0;
+
+       //decide how much to change each width
+       /*
+       t \in [0,1]
+
+       both pressure and multiply amount are in mult
+               (may want to change this to allow different types of falloff)
+
+       rsq is the squared distance from the point on the curve (also part of the falloff)
+
+
+       */
+       //may want to provide a different falloff function...
+       if(t <= 0.2)
+               amount1 = mult;
+       else if(t >= 0.8)
+               amount2 = mult;
+       else
+       {
+               t = (t-0.2)/0.6;
+               amount1 = (1-t)*mult;
+               amount2 = t*mult;
+       }
+
+       if(invert)
+       {
+               amount1 *= -1;
+               amount2 *= -1;
+       }
+
+       handle<Duck>    p1 = c->p1;
+       handle<Duck>    p2 = c->p2;
+
+       handle<Duck>    w1,w2;
+
+       //find w1,w2
+       {
+               const DuckList dl = get_work_area()->get_duck_list();
+
+               DuckList::const_iterator i = dl.begin();
+
+               for(;i != dl.end(); ++i)
+               {
+                       if((*i)->get_type() == Duck::TYPE_WIDTH)
+                       {
+                               if((*i)->get_origin_duck() == p1)
+                               {
+                                       w1 = *i;
+                               }
+
+                               if((*i)->get_origin_duck() == p2)
+                               {
+                                       w2 = *i;
+                               }
+                       }
+               }
+       }
+
+       if(amount1 != 0 && w1)
+       {
+               Real width = w1->get_point().mag();
+
+               width += amount1;
+               w1->set_point(Vector(width,0));
+
+               //log in the list of changes...
+               //to truly be changed after everything is said and done
+               changetable[w1] = width;
+       }
+
+       if(amount2 != 0 && w2)
+       {
+               Real width = w2->get_point().mag();
+
+               width += amount2;
+               w2->set_point(Vector(width,0));
+
+               //log in the list of changes...
+               //to truly be changed after everything is said and done
+               changetable[w2] = width;
+       }
+}
+
+Smach::event_result
+StateWidth_Context::event_mouse_handler(const Smach::event& x)
+{
+       const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
+
+       //handle the click
+       if( (event.key == EVENT_WORKAREA_MOUSE_BUTTON_DOWN || event.key == EVENT_WORKAREA_MOUSE_BUTTON_DRAG)
+                       && event.button == BUTTON_LEFT )
+       {
+               const Real pw = get_work_area()->get_pw();
+               const Real ph = get_work_area()->get_ph();
+               const Real scale = sqrt(pw*pw+ph*ph);
+               const Real rad = get_relative() ? scale * get_radius() : get_radius();
+
+               bool invert = (event.modifier&Gdk::CONTROL_MASK);
+
+               const Real threshold = 0.08;
+
+               float t = 0;
+               Real rsq = 0;
+
+               Real dtime = 1/60.0;
+
+               //if we're dragging get the difference in time between now and then
+               if(event.key == EVENT_WORKAREA_MOUSE_BUTTON_DRAG)
+               {
+                       dtime = min(1/15.0,clocktime());
+               }
+               clocktime.reset();
+
+               //make way for new ducks
+               //get_work_area()->clear_ducks();
+
+               //update positions
+               //mouse_pos = event.pos;
+
+               center->set_point(event.pos);
+               if(!added)get_work_area()->add_duck(center);
+
+               radius->set_scalar(rad);
+               if(!added)get_work_area()->add_duck(radius);
+
+               //the other duck is at the current duck
+               closestpoint->set_point(event.pos);
+               if(!added)get_work_area()->add_duck(closestpoint);
+
+               //get the closest curve...
+               handle<Duckmatic::Bezier>       c;
+               if(event.pressure >= threshold)
+                       c = get_work_area()->find_bezier(event.pos,scale*8,rad,&t);
+
+               //run algorithm on event.pos to get 2nd placement
+               if(!c.empty())
+               {
+                       bezier<Point> curve;
+                       Point p;
+
+                       curve[0] = c->p1->get_trans_point();
+                       curve[1] = c->c1->get_trans_point();
+                       curve[2] = c->c2->get_trans_point();
+                       curve[3] = c->p2->get_trans_point();
+
+                       p = curve(t);
+                       rsq = (p-event.pos).mag_squared();
+
+                       const Real r = rad*rad;
+
+                       if(rsq < r)
+                       {
+                               closestpoint->set_point(curve(t));
+
+                               //adjust the width...
+                               //squared falloff for radius... [0,1]
+
+                               Real ri = (r - rsq)/r;
+                               AdjustWidth(c,t,ri*event.pressure*get_delta()*dtime,invert);
+                       }
+               }
+
+               //the points have been added
+               added = true;
+
+               //draw where it is yo!
+               get_work_area()->queue_draw();
+
+               return Smach::RESULT_ACCEPT;
+       }
+
+       if(event.key == EVENT_WORKAREA_MOUSE_BUTTON_UP && event.button == BUTTON_LEFT)
+       {
+               if(added)
+               {
+                       get_work_area()->erase_duck(center);
+                       get_work_area()->erase_duck(radius);
+                       get_work_area()->erase_duck(closestpoint);
+                       added = false;
+               }
+
+               //Affect the width changes here...
+               map<handle<Duck>,Real>::iterator i = changetable.begin();
+
+               synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Sketch Width"));
+               for(; i != changetable.end(); ++i)
+               {
+                       //for each duck modify IT!!!
+                       ValueDesc desc = i->first->get_value_desc();
+
+                       if(     desc.get_value_type() == ValueBase::TYPE_REAL )
+                       {
+                               Action::Handle action(Action::create("ValueDescSet"));
+                               assert(action);
+
+                               action->set_param("canvas",get_canvas());
+                               action->set_param("canvas_interface",get_canvas_interface());
+
+                               action->set_param("value_desc",desc);
+                               action->set_param("new_value",ValueBase(i->second));
+                               action->set_param("time",get_canvas_view()->get_time());
+
+                               if(!action->is_ready() || !get_canvas_view()->get_instance()->perform_action(action))
+                               {
+                                       group.cancel();
+                                       synfig::warning("Changing the width action has failed");
+                                       return Smach::RESULT_ERROR;
+                               }
+                       }
+               }
+
+               changetable.clear();
+
+               get_work_area()->queue_draw();
+
+               return Smach::RESULT_ACCEPT;
+       }
+
+       return Smach::RESULT_OK;
+}
+
+
+void
+StateWidth_Context::refresh_ducks()
+{
+       get_work_area()->clear_ducks();
+       get_work_area()->queue_draw();
+}
diff --git a/synfig-studio/src/gui/state_width.h b/synfig-studio/src/gui/state_width.h
new file mode 100644 (file)
index 0000000..f649140
--- /dev/null
@@ -0,0 +1,56 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_width.h
+**     \brief Width creation state
+**
+**     $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_WIDTH_H
+#define __SYNFIG_STUDIO_STATE_WIDTH_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 StateWidth_Context;
+
+class StateWidth : public Smach::state<StateWidth_Context>
+{
+public:
+       StateWidth();
+       ~StateWidth();
+}; // END of class StateWidth
+
+extern StateWidth state_width;
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/state_zoom.cpp b/synfig-studio/src/gui/state_zoom.cpp
new file mode 100644 (file)
index 0000000..56363e6
--- /dev/null
@@ -0,0 +1,263 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_zoom.cpp
+**     \brief Zoom Tool Implementation 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 <config.h>
+#endif
+
+#include <sigc++/signal.h>
+#include <sigc++/object.h>
+
+#include <ETL/handle>
+#include <synfig/vector.h>
+
+
+#include "state_zoom.h"
+#include "state_normal.h"
+#include "event_mouse.h"
+#include "canvasview.h"
+#include "workarea.h"
+#include "app.h"
+#include "toolbox.h"
+#include <synfigapp/main.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 ======================================================= */
+StateZoom studio::state_zoom;
+
+const float ZOOMFACTOR = 1.25f;
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+class studio::StateZoom_Context : public sigc::trackable
+{
+       etl::handle<CanvasView> canvas_view_;
+       CanvasView::IsWorking is_working;
+
+       Point p1,p2;
+
+       bool prev_workarea_layer_status_;
+
+public:
+
+       //events
+       Smach::event_result event_stop_handler(const Smach::event& x);
+       Smach::event_result event_refresh_handler(const Smach::event& x);
+       Smach::event_result event_mouse_click_handler(const Smach::event& x);
+
+       //constructor destructor
+       StateZoom_Context(CanvasView* canvas_view);
+       ~StateZoom_Context();
+
+       //Canvas interaction
+       const etl::handle<CanvasView>& get_canvas_view()const{return canvas_view_;}
+       etl::handle<synfigapp::CanvasInterface> 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 zoom(const Point& p1, const Point& p2);
+
+};     // END of class StateZoom_Context
+
+/* === M E T H O D S ======================================================= */
+
+StateZoom::StateZoom():
+       Smach::state<StateZoom_Context>("zoom")
+{
+       insert(event_def(EVENT_STOP,&StateZoom_Context::event_stop_handler));
+       insert(event_def(EVENT_REFRESH,&StateZoom_Context::event_refresh_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,&StateZoom_Context::event_mouse_click_handler));
+       //insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DRAG,&StateZoom_Context::event_mouse_click_handler));
+       insert(event_def(EVENT_WORKAREA_BOX,&StateZoom_Context::event_mouse_click_handler));
+       //insert(event_def(EVENT_WORKAREA_BUTTON_CLICK,&StateZoom_Context::event_mouse_click_handler));
+       insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_UP,&StateZoom_Context::event_mouse_click_handler));
+}
+
+StateZoom::~StateZoom()
+{
+}
+
+StateZoom_Context::StateZoom_Context(CanvasView* canvas_view):
+       canvas_view_(canvas_view),
+       is_working(*canvas_view),
+       prev_workarea_layer_status_(get_work_area()->get_allow_layer_clicks())
+{
+       // Turn off layer clicking
+       get_work_area()->set_allow_layer_clicks(false);
+
+       // clear out the ducks
+       get_work_area()->clear_ducks(); //???
+
+       // Refresh the work area
+       get_work_area()->queue_draw();
+
+       // Hide the tables if they are showing
+       //prev_table_status=get_canvas_view()->tables_are_visible();
+       //if(prev_table_status)get_canvas_view()->hide_tables();
+
+       // Disable the time bar
+       //get_canvas_view()->set_sensitive_timebar(false);
+
+       // Connect a signal
+       //get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateZoom_Context::on_user_click));
+       get_work_area()->set_cursor(Gdk::CROSSHAIR);
+
+       App::toolbox->refresh();
+}
+
+StateZoom_Context::~StateZoom_Context()
+{
+       // Restore layer clicking
+       get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_);
+       get_work_area()->reset_cursor();
+
+       // Enable the time bar
+       //get_canvas_view()->set_sensitive_timebar(true);
+
+       // Bring back the tables if they were out before
+       //if(prev_table_status)get_canvas_view()->show_tables();
+
+       // Refresh the work area
+       get_work_area()->queue_draw();
+
+       App::toolbox->refresh();
+
+       get_canvas_view()->get_smach().process_event(EVENT_REFRESH_DUCKS);
+}
+
+Smach::event_result
+StateZoom_Context::event_stop_handler(const Smach::event& /*x*/)
+{
+       //throw Smach::egress_exception();
+       throw &state_normal;
+       return Smach::RESULT_OK;
+}
+
+Smach::event_result
+StateZoom_Context::event_refresh_handler(const Smach::event& /*x*/)
+{
+       return Smach::RESULT_ACCEPT;
+}
+
+Smach::event_result
+StateZoom_Context::event_mouse_click_handler(const Smach::event& x)
+{
+       if(x.key==EVENT_WORKAREA_BOX)
+       {
+               const EventBox& event(*reinterpret_cast<const EventBox*>(&x));
+
+               if(event.button==BUTTON_LEFT)
+               {
+                       Point tl = get_work_area()->get_window_tl();
+                       Point br = get_work_area()->get_window_br();
+                       Vector  window_span = br - tl, window_middle = (br+tl)/2;
+                       Vector  box_span = event.p2 - event.p1, box_middle = (event.p1+event.p2)/2;
+                       Point newpos;
+                       float zoom;
+
+                       if(event.modifier & Gdk::CONTROL_MASK) //zoom out...
+                       {
+                               if (window_span[0] == 0 || window_span[1] == 0) zoom = 1;
+                               else zoom = max(abs(box_span[0]/window_span[0]), abs(box_span[1]/window_span[1]));
+
+                               // focus_point is -1 times the real position for some reason...
+                               // center the window so the old contents fill the drawn box
+                               newpos = -((window_middle - box_middle)/zoom + window_middle);
+                       }
+                       else                            // zoom in
+                       {
+                               if (box_span[0] == 0 || box_span[1] == 0) zoom = 1;
+                               else zoom = min(abs(window_span[0]/box_span[0]), abs(window_span[1]/box_span[1]));
+
+                               // center the window at the center of the box
+                               newpos = -(-get_work_area()->get_focus_point() + (box_middle - window_middle));
+                       }
+
+                       get_work_area()->set_focus_point(newpos);
+                       get_work_area()->set_zoom(get_work_area()->get_zoom()*zoom);
+
+                       return Smach::RESULT_ACCEPT;
+               }
+       }
+
+       if(x.key==EVENT_WORKAREA_MOUSE_BUTTON_UP)
+       {
+               const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
+
+               if(event.button==BUTTON_LEFT)
+               {
+                       Point evpos;
+
+                       //make the event pos be in the same space...
+                       //   The weird ass inverted center normalized space...
+                       {
+                               const Point realcenter = (get_work_area()->get_window_tl() + get_work_area()->get_window_br())/2;
+                               evpos = -(event.pos - realcenter) + get_work_area()->get_focus_point();
+                       }
+
+                       /*      Zooming:
+                               focus point must zoom about the point evpos...
+
+                               trans about an origin not 0:
+                               p' = A(p - o) + o
+                       */
+
+                       Vector v = get_work_area()->get_focus_point() - evpos;
+
+                       if(event.modifier & Gdk::CONTROL_MASK) //zoom out...
+                       {
+                               v*=ZOOMFACTOR;
+                               //get_work_area()->zoom_out();
+                               get_work_area()->set_focus_point(evpos + v);
+                               get_work_area()->set_zoom(get_work_area()->get_zoom()/ZOOMFACTOR);
+                       }else //zoom in
+                       {
+                               v/=ZOOMFACTOR;
+                               //get_work_area()->zoom_in();
+                               get_work_area()->set_focus_point(evpos + v);
+                               get_work_area()->set_zoom(get_work_area()->get_zoom()*ZOOMFACTOR);
+                       }
+
+                       return Smach::RESULT_ACCEPT;
+               }
+       }
+
+       return Smach::RESULT_OK;
+}
diff --git a/synfig-studio/src/gui/state_zoom.h b/synfig-studio/src/gui/state_zoom.h
new file mode 100644 (file)
index 0000000..e5e7260
--- /dev/null
@@ -0,0 +1,55 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file state_zoom.h
+**     \brief Zoom tool 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_STATE_ZOOM_H
+#define __SYNFIG_STATE_ZOOM_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 StateZoom_Context;
+
+class StateZoom : public Smach::state<StateZoom_Context>
+{
+public:
+       StateZoom();
+       ~StateZoom();
+}; // END of class StateZoom
+
+extern StateZoom state_zoom;
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/statemanager.cpp b/synfig-studio/src/gui/statemanager.cpp
new file mode 100644 (file)
index 0000000..645658a
--- /dev/null
@@ -0,0 +1,128 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file statemanager.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \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
+**     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 <config.h>
+#endif
+
+#include "statemanager.h"
+#include <gtkmm/actiongroup.h>
+#include <gtkmm/action.h>
+#include <synfig/string.h>
+#include "app.h"
+#include "toolbox.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+StateManager::StateManager():
+       state_group(Gtk::ActionGroup::create("action_group_state_manager")),
+       merge_id(App::ui_manager()->new_merge_id())
+{
+       App::ui_manager()->insert_action_group(get_action_group());
+}
+
+StateManager::~StateManager()
+{
+       App::ui_manager()->remove_ui(merge_id);
+
+       for(;!merge_id_list.empty();merge_id_list.pop_back())
+               App::ui_manager()->remove_ui(merge_id_list.back());
+}
+
+void
+StateManager::change_state_(const Smach::state_base *state)
+{
+       App::toolbox->change_state_(state);
+}
+
+void
+StateManager::add_state(const Smach::state_base *state)
+{
+       String name(state->get_name());
+
+       Gtk::StockItem stock_item;
+       Gtk::Stock::lookup(Gtk::StockID("synfig-"+name),stock_item);
+
+       Glib::RefPtr<Gtk::Action> action(
+               Gtk::Action::create(
+                       "state-"+name,
+                       stock_item.get_stock_id(),
+                       stock_item.get_label(),
+                       stock_item.get_label()
+               )
+       );
+       /*action->set_sensitive(false);*/
+       state_group->add(action);
+
+       action->signal_activate().connect(
+               sigc::bind(
+                       sigc::mem_fun(*this,&studio::StateManager::change_state_),
+                       state
+               )
+       );
+
+       App::ui_manager()->ensure_update();
+
+       /*App::ui_manager()->add_ui(
+               merge_id,
+               "/main-menu/menu-state",
+               "state-"+name,
+               "state-"+name
+       );
+       */
+
+       String uid_def("<ui><popup action='menu-main'><menu action='menu-state'><menuitem action='state-"+name+"' /></menu></popup></ui>");
+       merge_id_list.push_back(App::ui_manager()->add_ui_from_string(uid_def));
+
+       App::ui_manager()->ensure_update();
+
+       App::toolbox->add_state(state);
+}
+
+Glib::RefPtr<Gtk::ActionGroup>
+StateManager::get_action_group()
+{
+       return state_group;
+}
diff --git a/synfig-studio/src/gui/statemanager.h b/synfig-studio/src/gui/statemanager.h
new file mode 100644 (file)
index 0000000..0aeb609
--- /dev/null
@@ -0,0 +1,69 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file statemanager.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_STATEMANAGER_H
+#define __SYNFIG_STATEMANAGER_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <glibmm/refptr.h>
+#include <vector>
+#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 Gtk { class ActionGroup; }
+
+typedef unsigned int guint;
+
+namespace studio {
+       class StateManager
+{
+private:
+       Glib::RefPtr<Gtk::ActionGroup> state_group;
+
+       guint merge_id;
+       std::vector<guint> merge_id_list;
+
+       void change_state_(const Smach::state_base *state);
+
+public:
+       StateManager();
+
+       ~StateManager();
+
+       void add_state(const Smach::state_base *state);
+
+       Glib::RefPtr<Gtk::ActionGroup> get_action_group();
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/toggleducksdial.cpp b/synfig-studio/src/gui/toggleducksdial.cpp
new file mode 100644 (file)
index 0000000..00ea236
--- /dev/null
@@ -0,0 +1,95 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file toggleducksdial.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2009 Gerco Ballintijn
+**     Copyright (c) 2009 Carlos Lopez
+**
+**     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 <config.h>
+#endif
+
+#include "toggleducksdial.h"
+#include <gtkmm/image.h>
+#include <gtkmm/stock.h>
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+ToggleDucksDial::ToggleDucksDial(Gtk::IconSize & size): Gtk::Table(1, 6, false)
+{
+       ducks_position = create_label_button(size, "synfig-toggle_duck_position", _("Toggle position ducks"));
+       ducks_vertex = create_label_button(size, "synfig-toggle_duck_vertex", _("Toggle vertex ducks"));
+       ducks_tangent = create_label_button(size, "synfig-toggle_duck_tangent", _("Toggle tangent ducks"));
+       ducks_radius = create_label_button(size, "synfig-toggle_duck_radius", _("Toggle radius ducks"));
+       ducks_width = create_label_button(size, "synfig-toggle_duck_width", _("Toggle width ducks"));
+       ducks_angle = create_label_button(size, "synfig-toggle_duck_angle", _("Toggle angle ducks"));
+
+       attach(*ducks_position, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       attach(*ducks_vertex, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       attach(*ducks_tangent, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       attach(*ducks_radius, 3, 4, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       attach(*ducks_width, 4, 5, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       attach(*ducks_angle, 5, 6, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+}
+
+Gtk::ToggleButton *
+ToggleDucksDial::create_label_button(Gtk::IconSize iconsize, const char *stockid,
+               const char * tooltip)
+{
+       Gtk::ToggleButton *tbutton = manage(new class Gtk::ToggleButton());
+       Gtk::Image *icon = manage(new Gtk::Image(Gtk::StockID(stockid), iconsize));
+       tooltips.set_tip(*tbutton, tooltip);
+       tbutton->add(*icon);
+       icon->set_padding(0, 0);
+       icon->show();
+       tbutton->set_relief(Gtk::RELIEF_NONE);
+       tbutton->show();
+
+       return tbutton;
+}
+
+void
+ToggleDucksDial::update_toggles(Duck::Type mask)
+{
+       ducks_position-> set_active((mask & Duck::TYPE_POSITION));
+       ducks_vertex  -> set_active((mask & Duck::TYPE_VERTEX));
+       ducks_tangent -> set_active((mask & Duck::TYPE_TANGENT));
+       ducks_radius  -> set_active((mask & Duck::TYPE_RADIUS));
+       ducks_width   -> set_active((mask & Duck::TYPE_WIDTH));
+       ducks_angle   -> set_active((mask & Duck::TYPE_ANGLE));
+}
diff --git a/synfig-studio/src/gui/toggleducksdial.h b/synfig-studio/src/gui/toggleducksdial.h
new file mode 100644 (file)
index 0000000..832e212
--- /dev/null
@@ -0,0 +1,81 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file toggleducksdial.h
+**     \brief Template Header
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2008 Chris Moore
+**     Copyright (c) 2009 Gerco Ballintijn
+**     Copyright (c) 2009 Carlos Lopez
+**
+**     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_TOOGLEDUCKSDIAL_H
+#define __SYNFIG_STUDIO_TOOGLEDUCKSDIAL_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/tooltips.h>
+#include <gtkmm/table.h>
+#include <gtkmm/togglebutton.h>
+#include "duckmatic.h"
+
+#include "general.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 ToggleDucksDial : public Gtk::Table
+{
+       Gtk::Tooltips tooltips;
+
+       Gtk::ToggleButton *ducks_position;
+       Gtk::ToggleButton *ducks_vertex;
+       Gtk::ToggleButton *ducks_tangent;
+       Gtk::ToggleButton *ducks_radius;
+       Gtk::ToggleButton *ducks_width;
+       Gtk::ToggleButton *ducks_angle;
+
+       Gtk::ToggleButton *create_label_button(Gtk::IconSize iconsize, const char * stockid, const char * tooltip);
+
+public:
+
+       ToggleDucksDial(Gtk::IconSize & size);
+       void update_toggles(Duck::Type mask);
+       Glib::SignalProxy0<void> signal_ducks_position()  { return ducks_position->signal_toggled(); }
+       Glib::SignalProxy0<void> signal_ducks_vertex()    { return ducks_vertex->  signal_toggled(); }
+       Glib::SignalProxy0<void> signal_ducks_tangent()   { return ducks_tangent-> signal_toggled(); }
+       Glib::SignalProxy0<void> signal_ducks_radius()    { return ducks_radius->  signal_toggled(); }
+       Glib::SignalProxy0<void> signal_ducks_width()     { return ducks_width->   signal_toggled(); }
+       Glib::SignalProxy0<void> signal_ducks_angle()     { return ducks_angle->   signal_toggled(); }
+
+}; // END of class ToggleDucksDial
+
+}; // END of namespace studio
+
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/toolbox.cpp b/synfig-studio/src/gui/toolbox.cpp
new file mode 100644 (file)
index 0000000..ea40e7d
--- /dev/null
@@ -0,0 +1,648 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file toolbox.cpp
+**     \brief writeme
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 2008 Chris Moore
+**  Copyright (c) 2008 Paul Wise
+**     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
+**
+** === N O T E S ===========================================================
+**
+** ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+#include <gtkmm/uimanager.h>
+
+#include <gtkmm/ruler.h>
+#include <gtkmm/arrow.h>
+#include <gtkmm/image.h>
+#include <gdkmm/pixbufloader.h>
+#include <gtkmm/viewport.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/table.h>
+#include <gtkmm/statusbar.h>
+#include <gtkmm/menubar.h>
+#include <gtkmm/menu.h>
+#include <gtkmm/button.h>
+#include <gtkmm/toolbar.h>
+#include <gtkmm/box.h>
+#include <gtkmm/image.h>
+#include <gtkmm/stock.h>
+#include <gtkmm/handlebox.h>
+
+#include <gtkmm/inputdialog.h>
+
+#include <sigc++/signal.h>
+#include <sigc++/hide.h>
+#include <sigc++/slot.h>
+#include <sigc++/retype_return.h>
+#include <sigc++/retype.h>
+
+#include <sstream>
+
+#include "toolbox.h"
+#include "instance.h"
+#include "app.h"
+#include "canvasview.h"
+#include "dialog_gradient.h"
+#include "dialog_color.h"
+#include "dialog_tooloptions.h"
+#include "dialog_preview.h"
+#include "dockable.h"
+#include "dockmanager.h"
+#include "dockdialog.h"
+
+#include "widget_defaults.h"
+
+#include <synfigapp/main.h>
+
+#include "general.h"
+
+#endif
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+using namespace studio;
+using namespace sigc;
+
+/* === M A C R O S ========================================================= */
+
+#define GRAB_HINT_DATA(y,default)      { \
+               String x; \
+               if(synfigapp::Main::settings().get_value(String("pref.")+y+"_hints",x)) \
+               { \
+                       set_type_hint((Gdk::WindowTypeHint)atoi(x.c_str()));    \
+               } else {\
+                       set_type_hint(default); \
+               } \
+       }
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+#define TOGGLE_TOOLBOX_BUTTON(button,stockid,tooltip)  \
+       button = manage(new class Gtk::ToggleButton()); \
+       icon=manage(new Gtk::Image(Gtk::StockID(stockid),Gtk::IconSize(4)));    \
+       button->add(*icon);     \
+       tooltips.set_tip(*button,tooltip);      \
+       icon->show();   \
+       button->show()
+
+#define TOOLBOX_BUTTON(button,stockid,tooltip) \
+       button = manage(new class Gtk::Button());       \
+       icon=manage(new Gtk::Image(Gtk::StockID(stockid),Gtk::IconSize(4)));    \
+       button->add(*icon);     \
+       tooltips.set_tip(*button,tooltip);      \
+       icon->show();   \
+       button->show()
+
+#define ADD_TOOLBOX_BUTTON(button,stockid,tooltip)     Gtk::Button *TOOLBOX_BUTTON(button,stockid,tooltip)
+
+void
+save_selected_instance()
+{
+       if(!studio::App::get_selected_instance())
+       {
+               App::dialog_error_blocking(_("Cannot save"),_("Nothing to save"));
+               return;
+       }
+
+       studio::App::get_selected_instance()->save();
+}
+
+void
+save_as_selected_instance()
+{
+       if(!studio::App::get_selected_instance())
+       {
+               App::dialog_error_blocking(_("Cannot save as"),_("Nothing to save"));
+               return;
+       }
+
+       studio::App::get_selected_instance()->dialog_save_as();
+}
+
+void
+save_all()
+{
+       std::list<etl::handle<Instance> >::iterator iter;
+       for(iter=App::instance_list.begin();iter!=App::instance_list.end();iter++)
+               (*iter)->save();
+}
+
+void
+close_selected_instance()
+{
+       etl::handle<studio::Instance> instance=studio::App::get_selected_instance();
+
+       if(!instance)
+       {
+               App::dialog_error_blocking(_("Cannot close"),_("Nothing to close"));
+               return;
+       }
+
+       instance->safe_close();
+
+       //assert(instance.unique());
+}
+
+
+static void
+show_dialog_input()
+{
+       App::dialog_input->present();
+}
+
+void _create_stock_dialog1()
+{
+       DockDialog* dock_dialog(new DockDialog);
+       dock_dialog->set_contents("canvases history");
+       dock_dialog->set_composition_selector(true);
+       dock_dialog->present();
+}
+void _create_stock_dialog2()
+{
+       DockDialog* dock_dialog(new DockDialog);
+       dock_dialog->set_contents("layers children keyframes | params");
+       dock_dialog->present();
+}
+
+Toolbox::Toolbox():
+       Gtk::Window(Gtk::WINDOW_TOPLEVEL),
+       dialog_settings(this,"toolbox")
+{
+       GRAB_HINT_DATA(
+               "toolbox",
+//#ifdef __APPLE__
+               Gdk::WINDOW_TYPE_HINT_NORMAL
+//#else
+//             Gdk::WINDOW_TYPE_HINT_UTILITY
+//#endif
+       );
+       set_keep_above(false);
+       set_role("toolbox");
+
+
+
+       recent_files_menu= manage(new class Gtk::Menu());
+
+       Gtk::Menu       *filemenu       =manage(new class Gtk::Menu());
+
+       dock_dialogs=manage(new class Gtk::Menu());
+
+       dock_dialogs->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Vertical Dock: Canvases, History"),sigc::ptr_fun(_create_stock_dialog1)));
+       dock_dialogs->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Horizontal Dock: Layers, Children, Params"),sigc::ptr_fun(_create_stock_dialog2)));
+       dock_dialogs->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
+       dock_dialogs->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Reset Windows to Original Layout"),sigc::ptr_fun(App::reset_initial_window_configuration)));
+       dock_dialogs->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
+
+
+       filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::NEW,
+               sigc::ptr_fun(&studio::App::new_instance)));
+       filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::OPEN,
+               sigc::bind(sigc::ptr_fun(&studio::App::dialog_open), "")));
+
+       filemenu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Open Recent"),*recent_files_menu));
+
+       filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-saveall"),
+               sigc::ptr_fun(save_all)));
+       filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::CLOSE,
+               sigc::ptr_fun(close_selected_instance)));
+       filemenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
+       filemenu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Panels"),*dock_dialogs));
+
+       filemenu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Input Devices..."),
+               sigc::ptr_fun(&show_dialog_input)));
+       filemenu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Setup..."),
+               sigc::ptr_fun(&studio::App::show_setup)));
+
+       filemenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
+       filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID(Gtk::Stock::QUIT),
+               sigc::ptr_fun(studio::App::quit)));
+
+#define WIKI(title,page)                                                                                       \
+       helpmenu->items().push_back(Gtk::Menu_Helpers::MenuElem(title,  \
+               sigc::bind(sigc::ptr_fun(&studio::App::open_url),String("http://synfig.org")+page)))
+
+       Gtk::Menu       *helpmenu = manage(new class Gtk::Menu());
+       helpmenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::HELP, sigc::ptr_fun(studio::App::dialog_help)));
+       helpmenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
+
+       /* TRANSLATORS: Help menu entry */ WIKI(_("Synfig Wiki"),                               /* TRANSLATORS: a wiki page */ _("/Main_Page")                          );
+       /* TRANSLATORS: Help menu entry */ WIKI(_("Tutorials"),                                 /* TRANSLATORS: a wiki page */ _("/Tutorials")                          );
+       /* TRANSLATORS: Help menu entry */ WIKI(_("Frequently Asked Questions"),/* TRANSLATORS: a wiki page */ _("/FAQ")                                        );
+       /* TRANSLATORS: Help menu entry */ WIKI(_("Get Support"),                               /* TRANSLATORS: a wiki page */ _("/Contact")                    );
+       /* TRANSLATORS: Help menu entry */ WIKI(_("Keyboard Shortcuts"),                /* TRANSLATORS: a wiki page */ _("/Keyboard_Shortcuts")         );
+       /* TRANSLATORS: Help menu entry */ WIKI(_("Mouse Shortcuts"),                   /* TRANSLATORS: a wiki page */ _("/Mouse_Shortcuts")            );
+       /* TRANSLATORS: Help menu entry */ WIKI(_("All Pages"), "/Special:Allpages" );
+
+       helpmenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
+       helpmenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-about"),
+               sigc::ptr_fun(studio::App::dialog_about)));
+
+       Gtk::MenuBar *menubar1 = manage(new class Gtk::MenuBar());
+       menubar1->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_File"),*filemenu));
+       menubar1->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Help"),*helpmenu));
+
+
+       menubar1->show();
+
+       Gtk::Image *icon;
+
+       ADD_TOOLBOX_BUTTON(button_new,"gtk-new",_("New..."));
+       ADD_TOOLBOX_BUTTON(button_open,"gtk-open",_("Open..."));
+       ADD_TOOLBOX_BUTTON(button_save,"gtk-save",_("Save"));
+       ADD_TOOLBOX_BUTTON(button_saveas,"gtk-save-as",_("Save As..."));
+       ADD_TOOLBOX_BUTTON(button_save_all,"synfig-saveall",_("Save All"));
+       TOOLBOX_BUTTON(button_undo,"gtk-undo",_("Undo"));
+       TOOLBOX_BUTTON(button_redo,"gtk-redo",_("Redo"));
+       ADD_TOOLBOX_BUTTON(button_setup,"gtk-properties",_("Setup"));
+       ADD_TOOLBOX_BUTTON(button_about,"synfig-about",_("About Synfig Studio"));
+       ADD_TOOLBOX_BUTTON(button_help,"gtk-help",_("Help"));
+
+       button_setup->signal_clicked().connect(sigc::ptr_fun(studio::App::show_setup));
+       button_about->signal_clicked().connect(sigc::ptr_fun(studio::App::dialog_about));
+       button_help->signal_clicked().connect(sigc::ptr_fun(studio::App::dialog_help));
+       button_new->signal_clicked().connect(sigc::ptr_fun(studio::App::new_instance));
+       button_open->signal_clicked().connect(sigc::bind(sigc::ptr_fun(studio::App::dialog_open), ""));
+       button_save->signal_clicked().connect(sigc::ptr_fun(save_selected_instance));
+       button_saveas->signal_clicked().connect(sigc::ptr_fun(save_as_selected_instance));
+       button_save_all->signal_clicked().connect(sigc::ptr_fun(save_all));
+       button_undo->signal_clicked().connect(sigc::ptr_fun(studio::App::undo));
+       button_redo->signal_clicked().connect(sigc::ptr_fun(studio::App::redo));
+
+       // Create the file button cluster
+       Gtk::Table *file_buttons=manage(new class Gtk::Table());
+
+       file_buttons->attach(*button_new,      0,1, 0,1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       file_buttons->attach(*button_open,     1,2, 0,1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       file_buttons->attach(*button_save,     2,3, 0,1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       file_buttons->attach(*button_saveas,   3,4, 0,1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       file_buttons->attach(*button_save_all, 4,5, 0,1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+
+       file_buttons->attach(*button_undo,     0,1, 1,2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       file_buttons->attach(*button_redo,     1,2, 1,2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       file_buttons->attach(*button_setup,    2,3, 1,2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       file_buttons->attach(*button_about,    3,4, 1,2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       file_buttons->attach(*button_help,     4,5, 1,2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+
+       file_buttons->show();
+
+       tool_table=manage(new class Gtk::Table());
+       tool_table->show();
+       Gtk::HandleBox* handle_tools(manage(new Gtk::HandleBox()));
+       handle_tools->add(*tool_table);
+       handle_tools->show();
+       handle_tools->set_handle_position(Gtk::POS_TOP);
+       handle_tools->set_snap_edge(Gtk::POS_TOP);
+
+       Widget_Defaults* widget_defaults(manage(new Widget_Defaults()));
+       widget_defaults->show();
+       Gtk::HandleBox* handle_defaults(manage(new Gtk::HandleBox()));
+       handle_defaults->add(*widget_defaults);
+       handle_defaults->show();
+       handle_defaults->set_handle_position(Gtk::POS_TOP);
+       handle_defaults->set_snap_edge(Gtk::POS_TOP);
+
+       // Create the toplevel table
+       Gtk::Table *table1 = manage(new class Gtk::Table(1, 2, false));
+       table1->set_row_spacings(0);
+       table1->set_col_spacings(0);
+       table1->attach(*menubar1,        0,1, 0,1, Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK, 0, 0);
+       table1->attach(*file_buttons,    0,1, 1,2, Gtk::FILL|Gtk::EXPAND,Gtk::EXPAND|Gtk::FILL, 0, 0);
+       table1->attach(*handle_tools,    0,1, 2,3, Gtk::FILL|Gtk::EXPAND,Gtk::EXPAND|Gtk::FILL, 0, 0);
+       table1->attach(*handle_defaults, 0,1, 3,4, Gtk::FILL|Gtk::EXPAND,Gtk::EXPAND|Gtk::FILL, 0, 0);
+       table1->show_all();
+
+
+
+       // Set the parameters for this window
+       add(*table1);
+       set_title(_("Synfig Studio"));
+       set_modal(false);
+       property_window_position().set_value(Gtk::WIN_POS_NONE);
+       signal_delete_event().connect(sigc::ptr_fun(App::shutdown_request));
+       set_resizable(false);
+
+
+
+       App::signal_instance_selected().connect(
+               sigc::hide(
+                       sigc::mem_fun(*this,&studio::Toolbox::update_undo_redo)
+               )
+       );
+
+       App::signal_recent_files_changed().connect(
+                       sigc::mem_fun(*this,&studio::Toolbox::on_recent_files_changed)
+       );
+
+       button_undo->set_sensitive(false);
+       button_redo->set_sensitive(false);
+
+       std::list<Gtk::TargetEntry> listTargets;
+       listTargets.push_back( Gtk::TargetEntry("text/plain") );
+       listTargets.push_back( Gtk::TargetEntry("image") );
+//     listTargets.push_back( Gtk::TargetEntry("image/x-sif") );
+
+       drag_dest_set(listTargets);
+       signal_drag_data_received().connect( sigc::mem_fun(*this, &studio::Toolbox::on_drop_drag_data_received) );
+
+       App::dock_manager->signal_dockable_registered().connect(sigc::mem_fun(*this,&Toolbox::dockable_registered));
+
+       changing_state_=false;
+
+
+       add_accel_group(App::ui_manager()->get_accel_group());
+
+       App::signal_present_all().connect(sigc::mem_fun0(*this,&Toolbox::present));
+}
+
+Toolbox::~Toolbox()
+{
+       hide();
+       //studio::App::cb.task(_("Toolbox: I was nailed!"));
+       //studio::App::quit();
+
+       if(studio::App::toolbox==this)
+               studio::App::toolbox=NULL;
+
+}
+
+void
+Toolbox::set_active_state(const synfig::String& statename)
+{
+       std::map<synfig::String,Gtk::ToggleButton *>::iterator iter;
+
+       changing_state_=true;
+
+       synfigapp::Main::set_state(statename);
+
+       try
+       {
+
+               for(iter=state_button_map.begin();iter!=state_button_map.end();++iter)
+               {
+                       if(iter->first==statename)
+                       {
+                               if(!iter->second->get_active())
+                                       iter->second->set_active(true);
+                       }
+                       else
+                       {
+                               if(iter->second->get_active())
+                                       iter->second->set_active(false);
+                       }
+               }
+       }
+       catch(...)
+       {
+               changing_state_=false;
+               throw;
+       }
+       changing_state_=false;
+}
+
+void
+Toolbox::change_state(const synfig::String& statename)
+{
+       etl::handle<studio::CanvasView> canvas_view(studio::App::get_selected_canvas_view());
+       if(canvas_view)
+       {
+               if(statename==canvas_view->get_smach().get_state_name())
+               {
+                       return;
+               }
+
+               if(state_button_map.count(statename))
+               {
+                       state_button_map[statename]->clicked();
+               }
+               else
+               {
+                       synfig::error("Unknown state \"%s\"",statename.c_str());
+               }
+       }
+}
+
+void
+Toolbox::change_state_(const Smach::state_base *state)
+{
+       if(changing_state_)
+               return;
+       changing_state_=true;
+
+       try
+       {
+               etl::handle<studio::CanvasView> canvas_view(studio::App::get_selected_canvas_view());
+               if(canvas_view)
+                               canvas_view->get_smach().enter(state);
+               else
+                       refresh();
+       }
+       catch(...)
+       {
+               changing_state_=false;
+               throw;
+       }
+
+       changing_state_=false;
+}
+
+void
+Toolbox::add_state(const Smach::state_base *state)
+{
+       Gtk::Image *icon;
+
+       assert(state);
+
+       String name=state->get_name();
+
+       Gtk::StockItem stock_item;
+       Gtk::Stock::lookup(Gtk::StockID("synfig-"+name),stock_item);
+
+       Gtk::ToggleButton* button;
+       button=manage(new class Gtk::ToggleButton());
+
+       icon=manage(new Gtk::Image(stock_item.get_stock_id(),Gtk::IconSize(4)));
+       button->add(*icon);
+       tooltips.set_tip(*button,stock_item.get_label());
+       icon->show();
+       button->show();
+
+       int row=state_button_map.size()/5;
+       int col=state_button_map.size()%5;
+
+       tool_table->attach(*button,col,col+1,row,row+1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+
+       state_button_map[name]=button;
+
+       button->signal_clicked().connect(
+               sigc::bind(
+                       sigc::mem_fun(*this,&studio::Toolbox::change_state_),
+                       state
+               )
+       );
+
+       refresh();
+}
+
+
+void
+Toolbox::update_undo_redo()
+{
+       etl::handle<Instance> instance=App::get_selected_instance();
+       if(instance)
+       {
+               button_undo->set_sensitive(instance->get_undo_status());
+               button_redo->set_sensitive(instance->get_redo_status());
+       }
+
+       // This should probably go elsewhere, but it should
+       // work fine here with no troubles.
+       // These next several lines just adjust the tool buttons
+       // so that they are only clickable when they should be.
+       if(instance && App::get_selected_canvas_view())
+       {
+               std::map<synfig::String,Gtk::ToggleButton *>::iterator iter;
+
+               for(iter=state_button_map.begin();iter!=state_button_map.end();++iter)
+                       iter->second->set_sensitive(true);
+       }
+       else
+       {
+               std::map<synfig::String,Gtk::ToggleButton *>::iterator iter;
+
+               for(iter=state_button_map.begin();iter!=state_button_map.end();++iter)
+                       iter->second->set_sensitive(false);
+       }
+
+       etl::handle<CanvasView> canvas_view=App::get_selected_canvas_view();
+       if(canvas_view && canvas_view->get_smach().get_state_name())
+       {
+               set_active_state(canvas_view->get_smach().get_state_name());
+       }
+       else
+               set_active_state("none");
+
+}
+
+void
+Toolbox::on_recent_files_changed()
+{
+       while(recent_files_menu->get_children().size())
+               recent_files_menu->remove(**recent_files_menu->get_children().begin());
+
+       list<string>::const_iterator iter;
+       for(iter=App::get_recent_files().begin();iter!=App::get_recent_files().end();iter++)
+       {
+               string raw = basename(*iter), quoted;
+               size_t pos = 0, last_pos = 0;
+
+               // replace _ in filenames by __ or it won't show up in the menu
+               for (pos = last_pos = 0; (pos = raw.find('_', pos)) != string::npos; last_pos = pos)
+                       quoted += raw.substr(last_pos, ++pos - last_pos) + '_';
+               quoted += raw.substr(last_pos);
+
+               recent_files_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(quoted,
+                       sigc::hide_return(sigc::bind(sigc::ptr_fun(&App::open),*iter))
+               ));
+       }
+
+       // HACK
+       show();
+}
+
+void
+Toolbox::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);
+
+       if ((selection_data_.get_length() >= 0) && (selection_data_.get_format() == 8))
+       {
+               synfig::String selection_data((gchar *)(selection_data_.get_data()));
+
+               // For some reason, GTK hands us a list of URLs separated
+               // by not only Carriage-Returns, but also Line-Feeds.
+               // Line-Feeds will mess us up. Remove all the line-feeds.
+               while(selection_data.find_first_of('\r')!=synfig::String::npos)
+                       selection_data.erase(selection_data.begin()+selection_data.find_first_of('\r'));
+
+               std::stringstream stream(selection_data);
+
+               while(stream)
+               {
+                       synfig::String filename,URI;
+                       getline(stream,filename);
+
+                       // If we don't have a filename, move on.
+                       if(filename.empty())
+                               continue;
+
+                       // Make sure this URL is of the "file://" type.
+                       URI=String(filename.begin(),filename.begin()+sizeof("file://")-1);
+                       if(URI!="file://")
+                       {
+                               synfig::warning("Unknown URI (%s) in \"%s\"",URI.c_str(),filename.c_str());
+                               continue;
+                       }
+
+                       // Strip the "file://" part from the filename
+                       filename=synfig::String(filename.begin()+sizeof("file://")-1,filename.end());
+
+                       synfig::info("Attempting to open "+filename);
+                       if(App::open(filename))
+                               success=true;
+                       else
+                               synfig::error("Drop failed: Unable to open "+filename);
+               }
+       }
+       else
+               synfig::error("Drop failed: bad selection data");
+
+       // Finish the drag
+       context->drag_finish(success, false, time);
+}
+
+void
+Toolbox::dockable_registered(Dockable* x)
+{
+       dock_dialogs->items().push_back(
+               Gtk::Menu_Helpers::MenuElem(
+                       x->get_local_name(),
+                       sigc::mem_fun(
+                               *x,
+                               &Dockable::present
+                       )
+               )
+       );
+}
diff --git a/synfig-studio/src/gui/toolbox.h b/synfig-studio/src/gui/toolbox.h
new file mode 100644 (file)
index 0000000..21696ab
--- /dev/null
@@ -0,0 +1,108 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file toolbox.h
+**     \brief Header File
+**
+**     $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
+**
+** === N O T E S ===========================================================
+**
+** ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_GTKMM_TOOLBOX_H
+#define __SYNFIG_GTKMM_TOOLBOX_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/window.h>
+#include <gtkmm/tooltips.h>
+#include <gtkmm/button.h>
+#include <gtkmm/togglebutton.h>
+#include <gtkmm/menu.h>
+#include <gtkmm/table.h>
+#include <synfig/string.h>
+#include "smach.h"
+#include <map>
+#include "dialogsettings.h"
+
+/* === M A C R O S ========================================================= */
+
+// uncomment to enable the blend method selector in the tool options
+// panel for the circle and gradient tools
+//
+// #define BLEND_METHOD_IN_TOOL_OPTIONS
+
+/* === 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 Dockable;
+class StateManager;
+
+class Toolbox : public Gtk::Window
+{
+       friend class studio::StateManager;
+
+       DialogSettings dialog_settings;
+
+       Gtk::Tooltips tooltips;
+       Gtk::Button *button_undo;
+       Gtk::Button *button_redo;
+
+       Gtk::Table *tool_table;
+
+       std::map<synfig::String,Gtk::ToggleButton *> state_button_map;
+
+       Gtk::Menu       *recent_files_menu;
+
+       Gtk::Menu       *dock_dialogs;
+
+       bool changing_state_;
+
+       void on_recent_files_changed();
+       void on_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& selection_data, guint info, guint time);
+
+       void change_state_(const Smach::state_base *state);
+
+public:
+
+       void change_state(const synfig::String& statename);
+
+       void update_undo_redo();
+
+       void refresh() { update_undo_redo(); }
+
+       void set_active_state(const synfig::String& statename);
+
+       void add_state(const Smach::state_base *state);
+
+
+       void dockable_registered(Dockable* x);
+
+       Toolbox();
+       virtual ~Toolbox();
+
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/valuelink.cpp b/synfig-studio/src/gui/valuelink.cpp
new file mode 100644 (file)
index 0000000..3f10980
--- /dev/null
@@ -0,0 +1,172 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file valuelink.cpp
+**     \brief ValueBase Link Implementation File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2004 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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "valuelink.h"
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+
+using studio::ValueBaseLink;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+/* === E N T R Y P O I N T ================================================= */
+
+//structors
+ValueBaseLink::ValueBaseLink()
+{
+       assert(0); //CHECK: This class does not appear to be used.
+}
+
+ValueBaseLink::~ValueBaseLink()
+{
+}
+
+//link access
+
+ValueNode::LooseHandle ValueBaseLink::get_link_vfunc(int i)const
+{
+       /*list_type::const_iterator     it = list.begin();
+
+       while(it != list.end() && i-- > 0)
+       {
+               ++it;
+       }
+
+       if(it == list.end())
+       {
+               return ValueNode::LooseHandle();
+       }else
+       {
+               return *it;
+       }*/
+       if(i >= 0 && i < (int)list.size())
+       {
+               return list[i];
+       }else
+       {
+               return ValueNode::LooseHandle();
+       }
+}
+
+//more link access
+int ValueBaseLink::link_count()const
+{
+       return list.size();
+}
+
+String ValueBaseLink::link_local_name(int i)const
+{
+       ValueNode::LooseHandle h = get_link(i);
+
+       if(h)
+       {
+               return h->get_local_name();
+       }else return String();
+}
+
+String ValueBaseLink::link_name(int i)const
+{
+       ValueNode::LooseHandle h = get_link(i);
+
+       if(h)
+       {
+               return h->get_name();
+       }else return String();
+}
+
+int ValueBaseLink::get_link_index_from_name(const synfig::String &name)const
+{
+       throw Exception::BadLinkName(name);
+}
+
+//list management stuff
+ValueBaseLink::list_type::const_iterator ValueBaseLink::findlink(synfig::ValueNode::Handle x) const
+{
+       for(list_type::const_iterator i = list.begin(); i != list.end(); ++i)
+       {
+               if(*i == x)
+               {
+                       return i;
+               }
+       }
+
+       return list.end();
+}
+ValueBaseLink::list_type::iterator ValueBaseLink::findlink(synfig::ValueNode::Handle x)
+{
+       for(list_type::iterator i = list.begin(); i != list.end(); ++i)
+       {
+               if(*i == x)
+               {
+                       return i;
+               }
+       }
+
+       return list.end();
+}
+
+void ValueBaseLink::add(synfig::ValueNode::Handle v)
+{
+       list_type::iterator i = findlink(v);
+
+       if(i != list.end())
+       {
+               list.push_back(v);
+       }
+}
+
+void ValueBaseLink::remove(synfig::ValueNode::Handle v)
+{
+       list_type::iterator i = findlink(v);
+
+       if(i != list.end())
+       {
+               if(i != list.end()-1)
+               {
+                       *i = list.back();
+               }
+               list.pop_back();
+       }
+}
diff --git a/synfig-studio/src/gui/valuelink.h b/synfig-studio/src/gui/valuelink.h
new file mode 100644 (file)
index 0000000..a2d999b
--- /dev/null
@@ -0,0 +1,82 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file valuelink.h
+**     \brief ValueBase Link Header
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2004 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_VALUELINK_H
+#define __SYNFIG_VALUELINK_H
+
+/* === H E A D E R S ======================================================= */
+#include <synfig/valuenode.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 {
+
+/* NOTE: DO NOT USE THE INDEX BASED INTERFACE... THINGS WILL CHANGE
+*/
+class ValueBaseLink : public synfig::LinkableValueNode
+{
+       typedef std::vector<ValueNode::Handle> list_type;
+       list_type       list;
+
+protected:
+       //stuff I don't want
+       virtual bool set_link_vfunc(int /*i*/,synfig::ValueNode::Handle /*x*/) {return false;}
+       virtual LinkableValueNode* create_new()const {return 0;}
+
+       //new stuff I need
+       list_type::const_iterator findlink(synfig::ValueNode::Handle x) const;
+       list_type::iterator findlink(synfig::ValueNode::Handle x);
+
+public: //linkable interface
+
+       //stuff I do want
+       virtual synfig::ValueNode::LooseHandle get_link_vfunc(int i)const;
+       virtual int link_count()const;
+
+       //I have to support the thing because it's too much work otherwise
+       virtual synfig::String link_local_name(int i)const;
+       virtual synfig::String link_name(int i)const;
+
+public:
+       ValueBaseLink();
+       virtual ~ValueBaseLink();
+
+       //don't want
+       virtual int get_link_index_from_name(const synfig::String &name)const;
+
+       //new add and subtract stuff
+       virtual void add(synfig::ValueNode::Handle v);
+       virtual void remove(synfig::ValueNode::Handle v);
+
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/widget_canvaschooser.cpp b/synfig-studio/src/gui/widget_canvaschooser.cpp
new file mode 100644 (file)
index 0000000..568c4b0
--- /dev/null
@@ -0,0 +1,167 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_canvaschooser.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \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
+**     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 <config.h>
+#endif
+
+#include "widget_canvaschooser.h"
+#include <gtkmm/menu.h>
+#include "app.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Widget_CanvasChooser::Widget_CanvasChooser()
+{
+}
+
+Widget_CanvasChooser::~Widget_CanvasChooser()
+{
+}
+
+void
+Widget_CanvasChooser::set_parent_canvas(synfig::Canvas::Handle x)
+{
+       assert(x);
+       parent_canvas=x;
+}
+
+void
+Widget_CanvasChooser::set_value_(synfig::Canvas::Handle data)
+{
+       set_value(data);
+       activate();
+}
+
+void
+Widget_CanvasChooser::set_value(synfig::Canvas::Handle data)
+{
+       assert(parent_canvas);
+       canvas=data;
+
+       canvas_menu=manage(new class Gtk::Menu());
+
+       synfig::Canvas::Children::iterator iter;
+       synfig::Canvas::Children &children(parent_canvas->children());
+       String label;
+
+       if(canvas)
+       {
+               label=canvas->get_name().empty()?canvas->get_id():canvas->get_name();
+               canvas_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(label));
+       }
+
+       for(iter=children.begin();iter!=children.end();iter++)
+               if(*iter!=canvas)
+               {
+                       label=(*iter)->get_name().empty()?(*iter)->get_id():(*iter)->get_name();
+                       canvas_menu->items().push_back(
+                               Gtk::Menu_Helpers::MenuElem(
+                                       label,
+                                       sigc::bind(
+                                               sigc::mem_fun(
+                                                       *this,
+                                                       &Widget_CanvasChooser::set_value_
+                                               ),
+                                               *iter
+                                       )
+                               )
+                       );
+               }
+       canvas_menu->items().push_back(
+               Gtk::Menu_Helpers::MenuElem(
+                       _("Other..."),
+                       sigc::mem_fun(*this,&Widget_CanvasChooser::chooser_menu)
+               )
+       );
+       set_menu(*canvas_menu);
+
+       if(canvas)
+               set_history(0);
+}
+
+const etl::handle<synfig::Canvas> &
+Widget_CanvasChooser::get_value()
+{
+       return canvas;
+}
+
+void
+Widget_CanvasChooser::chooser_menu()
+{
+       String canvas_name;
+
+       if (!App::dialog_entry(_("Choose Canvas"),_("Enter the relative name of the canvas that you want"),canvas_name))
+       {
+               // the user hit 'cancel', so set the parameter back to its previous value
+               set_value_(canvas);
+               return;
+       }
+
+       if (canvas_name == "")
+       {
+               App::dialog_error_blocking(_("Error"),_("No canvas name was specified"));
+               set_value_(canvas);
+               return;
+       }
+
+       Canvas::Handle new_canvas;
+       try
+       {
+               String warnings;
+               new_canvas=parent_canvas->find_canvas(canvas_name, warnings);
+               set_value_(new_canvas);
+       }
+       catch(std::runtime_error x)
+       {
+               App::dialog_error_blocking(_("Error:Exception Thrown"),String(_("Error selecting canvas:\n\n")) + x.what());
+               set_value_(canvas);
+       }
+       catch(...)
+       {
+               App::dialog_error_blocking(_("Error"),_("Unknown Exception"));
+               set_value_(canvas);
+       }
+}
diff --git a/synfig-studio/src/gui/widget_canvaschooser.h b/synfig-studio/src/gui/widget_canvaschooser.h
new file mode 100644 (file)
index 0000000..afa9287
--- /dev/null
@@ -0,0 +1,67 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_canvaschooser.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_WIDGET_CANVASCHOOSER_H
+#define __SYNFIG_STUDIO_WIDGET_CANVASCHOOSER_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <synfig/canvas.h>
+#include <gtkmm/optionmenu.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 Gtk { class Menu; };
+
+namespace studio {
+
+class Widget_CanvasChooser : public Gtk::OptionMenu
+{
+       Gtk::Menu *canvas_menu;
+       synfig::Canvas::Handle parent_canvas;
+
+       synfig::Canvas::Handle canvas;
+       void set_value_(synfig::Canvas::Handle data);
+public:
+
+       Widget_CanvasChooser();
+       ~Widget_CanvasChooser();
+
+       void set_parent_canvas(synfig::Canvas::Handle x);
+       void set_value(synfig::Canvas::Handle data);
+       const synfig::Canvas::Handle &get_value();
+private:
+       void chooser_menu();
+}; // END of class Widget_CanvasChooser
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/widget_color.cpp b/synfig-studio/src/gui/widget_color.cpp
new file mode 100644 (file)
index 0000000..1c53b5e
--- /dev/null
@@ -0,0 +1,200 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_color.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "widget_color.h"
+#include <cmath>
+#include "app.h"
+#include <gtkmm/drawingarea.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+Gdk::Color
+studio::colorconv_synfig2gdk(const synfig::Color &c_)
+{
+       const synfig::Color c(c_.clamped());
+       Gdk::Color ret;
+       ret.set_rgb(
+                       256*App::gamma.r_F32_to_U8(c.get_r()),
+                       256*App::gamma.g_F32_to_U8(c.get_g()),
+                       256*App::gamma.b_F32_to_U8(c.get_b())
+               );
+       return ret;
+}
+
+void
+studio::render_color_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::Color &color)
+{
+       const int height(ca.get_height());
+       const int width(ca.get_width());
+
+       const int square_size(height/2);
+
+       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(window));
+
+       if(color.get_alpha()!=1.0)
+       {
+               // In this case we need to render the alpha squares
+
+               const Color bg1(Color::blend(color,Color(0.75, 0.75, 0.75),1.0).clamped());
+               const Color bg2(Color::blend(color,Color(0.5, 0.5, 0.5),1.0).clamped());
+
+               Gdk::Color gdk_c1(colorconv_synfig2gdk(bg1));
+               Gdk::Color gdk_c2(colorconv_synfig2gdk(bg2));
+
+               bool toggle(false);
+               for(int i=0;i<width;i+=square_size)
+               {
+                       const int square_width(min(square_size,width-i));
+
+                       if(toggle)
+                       {
+                               gc->set_rgb_fg_color(gdk_c1);
+                               window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), square_width, square_size);
+
+                               gc->set_rgb_fg_color(gdk_c2);
+                               window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y()+square_size, square_width, square_size);
+                               toggle=false;
+                       }
+                       else
+                       {
+                               gc->set_rgb_fg_color(gdk_c2);
+                               window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), square_width, square_size);
+
+                               gc->set_rgb_fg_color(gdk_c1);
+                               window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y()+square_size, square_width, square_size);
+                               toggle=true;
+                       }
+               }
+       }
+       else
+       {
+               // In this case we have a solid color to use
+               Gdk::Color gdk_c1(colorconv_synfig2gdk(color));
+
+               gc->set_rgb_fg_color(gdk_c1);
+               window->draw_rectangle(gc, true, ca.get_x(), ca.get_y(), width-1, height-1);
+       }
+       gc->set_rgb_fg_color(Gdk::Color("#ffffff"));
+       window->draw_rectangle(gc, false, ca.get_x()+1, ca.get_y()+1, width-3, height-3);
+       gc->set_rgb_fg_color(Gdk::Color("#000000"));
+       window->draw_rectangle(gc, false, ca.get_x(), ca.get_y(), width-1, height-1);
+}
+
+/* === C L A S S E S ======================================================= */
+
+
+/* === M E T H O D S ======================================================= */
+
+Widget_Color::Widget_Color()
+{
+       color=Color(0,0,0,0);
+       set_size_request(-1,16);
+
+       signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Color::redraw));
+       add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
+
+}
+
+Widget_Color::~Widget_Color()
+{
+}
+
+void
+Widget_Color::set_value(const synfig::Color &data)
+{
+       assert(data.is_valid());
+       color=data;
+       queue_draw();
+}
+
+const synfig::Color &
+Widget_Color::get_value()
+{
+       assert(color.is_valid());
+       return color;
+}
+
+bool
+Widget_Color::on_event(GdkEvent *event)
+{
+       switch(event->type)
+       {
+       case GDK_BUTTON_PRESS:
+               if(event->button.button==1)
+               {
+                       signal_activate_();
+                       return true;
+               }
+               if(event->button.button==2)
+               {
+                       signal_middle_click_();
+                       return true;
+               }
+               if(event->button.button==3)
+               {
+                       signal_right_click_();
+                       return true;
+               }
+               break;
+
+       default:
+               break;
+       }
+       return false;
+}
+
+bool
+Widget_Color::redraw(GdkEventExpose */*bleh*/)
+{
+       //Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
+
+       const int h(get_height());
+       const int w(get_width());
+
+       render_color_to_window(get_window(),Gdk::Rectangle(0,0,w,h),color);
+
+       return true;
+}
diff --git a/synfig-studio/src/gui/widget_color.h b/synfig-studio/src/gui/widget_color.h
new file mode 100644 (file)
index 0000000..14e3db1
--- /dev/null
@@ -0,0 +1,80 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_color.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_WIDGET_COLOR_H
+#define __SYNFIG_STUDIO_WIDGET_COLOR_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/box.h>
+#include <gtkmm/table.h>
+#include <gtkmm/spinbutton.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/drawingarea.h>
+#include <synfig/color.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 {
+
+
+Gdk::Color colorconv_synfig2gdk(const synfig::Color &c);
+
+void render_color_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::Color &color);
+
+class Widget_Color : public Gtk::DrawingArea
+{
+       synfig::Color color;
+
+       sigc::signal<void> signal_activate_;
+       sigc::signal<void> signal_middle_click_;
+       sigc::signal<void> signal_right_click_;
+
+protected:
+
+public:
+       sigc::signal<void>& signal_activate() { return signal_activate_; }
+       sigc::signal<void>& signal_clicked() { return signal_activate_; }
+       sigc::signal<void>& signal_middle_click() { return signal_middle_click_; }
+       sigc::signal<void>& signal_right_click() { return signal_right_click_; }
+
+       void set_value(const synfig::Color &data);
+       const synfig::Color &get_value();
+       Widget_Color();
+       ~Widget_Color();
+private:
+       bool redraw(GdkEventExpose*bleh);
+       bool on_event(GdkEvent *event);
+
+}; // END of class Widget_Color
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/widget_coloredit.cpp b/synfig-studio/src/gui/widget_coloredit.cpp
new file mode 100644 (file)
index 0000000..5e3175a
--- /dev/null
@@ -0,0 +1,587 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_coloredit.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007 Chris Moore
+**  Copyright (c) 2008 Paul Wise
+**
+**     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 <config.h>
+#endif
+
+#include "widget_coloredit.h"
+#include <cmath>
+#include "app.h"
+#include <gtkmm/drawingarea.h>
+#include <pangomm/attributes.h>
+#include <pangomm/attrlist.h>
+#include <algorithm>
+#include <gtkmm/notebook.h>
+#include <gtkmm/box.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 ========================================================= */
+
+#define SPINBUTTON_WIDTH 100
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === C L A S S E S ======================================================= */
+
+ColorSlider::ColorSlider(const ColorSlider::Type &x):
+       type(x)
+{
+       signal_expose_event().connect(sigc::mem_fun(*this, &ColorSlider::redraw));
+       set_size_request(-1,12);
+       add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
+       add_events(Gdk::BUTTON1_MOTION_MASK);
+}
+
+void
+ColorSlider::set_type(Type x) { type=x; queue_draw(); }
+
+void
+ColorSlider::set_color(synfig::Color x) { color_=x; queue_draw(); }
+
+void
+ColorSlider::slider_color_TYPE_R(synfig::Color &color, float amount) { color.set_r(amount); }
+void
+ColorSlider::slider_color_TYPE_G(synfig::Color &color, float amount) { color.set_g(amount); }
+void
+ColorSlider::slider_color_TYPE_B(synfig::Color &color, float amount) { color.set_b(amount); }
+void
+ColorSlider::slider_color_TYPE_Y(synfig::Color &color, float amount) { color.set_y(amount); }
+void
+ColorSlider::slider_color_TYPE_U(synfig::Color &color, float amount) { color.set_u(amount-0.5f); }
+void
+ColorSlider::slider_color_TYPE_V(synfig::Color &color, float amount) { color.set_v(amount-0.5f); }
+void
+ColorSlider::slider_color_TYPE_HUE(synfig::Color &color, float amount) { color.set_uv_angle(Angle::rot(amount)); }
+void
+ColorSlider::slider_color_TYPE_SAT(synfig::Color &color, float amount) { color.set_s(amount*0.5f); }
+void
+ColorSlider::slider_color_TYPE_A(synfig::Color &color, float amount) { color.set_a(amount); }
+
+void
+ColorSlider::adjust_color(Type type, synfig::Color &color, float amount)
+{
+       static const slider_color_func jump_table[int(TYPE_END)] =
+       {
+               slider_color_TYPE_R,
+               slider_color_TYPE_G,
+               slider_color_TYPE_B,
+               slider_color_TYPE_Y,
+               slider_color_TYPE_U,
+               slider_color_TYPE_V,
+               slider_color_TYPE_HUE,
+               slider_color_TYPE_SAT,
+               slider_color_TYPE_A,
+       };
+       jump_table[int(type)](color,amount);
+}
+
+bool
+ColorSlider::redraw(GdkEventExpose */*bleh*/)
+{
+       Color color(color_);
+
+       static const slider_color_func jump_table[int(TYPE_END)] =
+       {
+               slider_color_TYPE_R,
+               slider_color_TYPE_G,
+               slider_color_TYPE_B,
+               slider_color_TYPE_Y,
+               slider_color_TYPE_U,
+               slider_color_TYPE_V,
+               slider_color_TYPE_HUE,
+               slider_color_TYPE_SAT,
+               slider_color_TYPE_A,
+       };
+
+       slider_color_func color_func(jump_table[int(type)]);
+
+       float amount;
+       switch(type)
+       {
+               case TYPE_R: amount=color.get_r(); break;
+               case TYPE_G: amount=color.get_g(); break;
+               case TYPE_B: amount=color.get_b(); break;
+               case TYPE_Y: amount=color.get_y(); break;
+               case TYPE_U: amount=color.get_u()+0.5; break;
+               case TYPE_V: amount=color.get_v()+0.5; break;
+               case TYPE_HUE: amount=Angle::rot(color.get_uv_angle()).get(); amount-=floor(amount); break;
+               case TYPE_SAT: amount=color.get_s()*2.0; break;
+               case TYPE_A: amount=color.get_a(); break;
+               default: amount=0; break;
+       }
+       if(use_colorspace_gamma() && (type<TYPE_U))
+               amount=gamma_in(amount);
+
+       const int height(get_height());
+       const int width(get_width());
+
+       Gdk::Rectangle ca(0,0,width,height);
+
+       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
+       const Color bg1(0.75, 0.75, 0.75);
+       const Color bg2(0.5, 0.5, 0.5);
+       int i;
+       for(i=width-1;i>=0;i--)
+       {
+               color_func(color,
+                                  (use_colorspace_gamma() && type<TYPE_U)
+                                  ? gamma_out(float(i)/float(width))
+                                  :              (float(i)/float(width)));
+               const Color c1(Color::blend(color,bg1,1.0).clamped());
+               const Color c2(Color::blend(color,bg2,1.0).clamped());
+               assert(c1.is_valid());
+               assert(c2.is_valid());
+
+               if((i*2/height)&1)
+               {
+                       gc->set_rgb_fg_color(colorconv_synfig2gdk(c1));
+                       get_window()->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), 1, height/2);
+
+                       gc->set_rgb_fg_color(colorconv_synfig2gdk(c2));
+                       get_window()->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y()+height/2, 1, height/2);
+               }
+               else
+               {
+                       gc->set_rgb_fg_color(colorconv_synfig2gdk(c2));
+                       get_window()->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), 1, height/2);
+
+                       gc->set_rgb_fg_color(colorconv_synfig2gdk(c1));
+                       get_window()->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y()+height/2, 1, height/2);
+               }
+       }
+
+       get_style()->paint_arrow(
+               get_window(),
+               Gtk::STATE_SELECTED,
+               Gtk::SHADOW_OUT,
+               ca,
+               *this,
+               " ",
+               Gtk::ARROW_UP,
+               1,
+               int(amount*width)-height/2,
+               0,
+               height,
+               height
+       );
+
+       gc->set_rgb_fg_color(Gdk::Color("#ffffff"));
+       get_window()->draw_rectangle(gc, false, ca.get_x()+1, ca.get_y()+1, width-3, height-3);
+       gc->set_rgb_fg_color(Gdk::Color("#000000"));
+       get_window()->draw_rectangle(gc, false, ca.get_x(), ca.get_y(), width-1, height-1);
+       return true;
+}
+
+bool
+ColorSlider::on_event(GdkEvent *event)
+{
+       const int width(get_width());
+       float x = 0;
+       if( GDK_SCROLL == event->type ){
+               Color color(color_);
+               float amount;
+               switch(type)
+               {
+                       case TYPE_R: amount=color.get_r(); break;
+                       case TYPE_G: amount=color.get_g(); break;
+                       case TYPE_B: amount=color.get_b(); break;
+                       case TYPE_Y: amount=color.get_y(); break;
+                       case TYPE_U: amount=color.get_u()+0.5; break;
+                       case TYPE_V: amount=color.get_v()+0.5; break;
+                       case TYPE_HUE: amount=Angle::rot(color.get_uv_angle()).get(); amount-=floor(amount); break;
+                       case TYPE_SAT: amount=color.get_s()*2.0; break;
+                       case TYPE_A: amount=color.get_a(); break;
+                       default: amount=0; break;
+               }
+               if(use_colorspace_gamma() && (type<TYPE_U))
+                       amount=gamma_in(amount);
+               x = amount*width;
+               switch(event->scroll.direction){
+                       case GDK_SCROLL_UP:
+                       case GDK_SCROLL_RIGHT:
+                               x+=1.0;
+                               break;
+                       case GDK_SCROLL_DOWN:
+                       case GDK_SCROLL_LEFT:
+                               x-=1.0;
+                               break;
+               }
+       } else {
+               x = float(event->button.x);
+       }
+
+       float pos(x/width);
+       if(pos<0 || x<=0)pos=0;
+       if(pos>1)pos=1;
+
+       if(use_colorspace_gamma() && (type<TYPE_U))
+               pos=gamma_out(pos);
+       if(pos<0 || event->button.x<=0)pos=0;
+       if(pos>1)pos=1;
+
+       switch(event->type)
+       {
+       case GDK_SCROLL:
+               signal_slider_moved_(type,pos);
+               queue_draw();
+               signal_activated_();
+               return true;
+
+       case GDK_BUTTON_RELEASE:
+               signal_activated_();
+               return true;
+
+       case GDK_BUTTON_PRESS:
+       case GDK_MOTION_NOTIFY:
+//             adjust_color(type,color_,pos);
+               signal_slider_moved_(type,pos);
+               queue_draw();
+               return true;
+               break;
+       default:
+               break;
+       }
+       return false;
+}
+
+/* === M E T H O D S ======================================================= */
+
+Widget_ColorEdit::Widget_ColorEdit():
+       R_adjustment(0,-10000000,10000000,1,10,0),
+       G_adjustment(0,-10000000,10000000,1,10,0),
+       B_adjustment(0,-10000000,10000000,1,10,0),
+       A_adjustment(0,-10000000,10000000,1,10,0)
+{
+       notebook=manage(new Gtk::Notebook);
+
+       Gtk::Table* rgb_table(manage(new Gtk::Table()));
+       Gtk::Table* yuv_table(manage(new Gtk::Table()));
+       Gtk::Table* main_table(this);
+
+       {
+               Gtk::VBox* rgb_box(manage(new Gtk::VBox()));
+               Gtk::VBox* yuv_box(manage(new Gtk::VBox()));
+               rgb_box->pack_start(*rgb_table,false,false);
+               yuv_box->pack_start(*yuv_table,false,false);
+               notebook->append_page(*rgb_box,_("RGB"));
+               notebook->append_page(*yuv_box,_("YUV"));
+       }
+
+       color=Color(0,0,0,0);
+
+       set_size_request(200,-1);
+       hold_signals=true;
+
+       Gtk::Label *label;
+
+       R_adjustment.set_lower(-10000000);
+       G_adjustment.set_lower(-10000000);
+       B_adjustment.set_lower(-10000000);
+       A_adjustment.set_lower(-10000000);
+
+       clamp_=true;
+
+       Pango::AttrList attr_list;
+       Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*7));
+       pango_size.set_start_index(0);
+       pango_size.set_end_index(64);
+       attr_list.change(pango_size);
+
+       widget_color.set_size_request(-1,16);
+       attach(widget_color, 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       attach(*notebook, 0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+#define SLIDER_ROW(i,n,l) \
+       slider_##n=manage(new ColorSlider(ColorSlider::TYPE_##n));      \
+       slider_##n->signal_slider_moved().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_slider_moved)); \
+       /*slider_##n->signal_activated().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::activated));*/ \
+       slider_##n->signal_activated().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_value_changed)); \
+       label=manage(new class Gtk::Label(l,0.0,0.5)); \
+       label->set_use_markup(false); \
+       label->set_use_underline(false); \
+       label->set_attributes(attr_list); \
+       table->attach(*label, 0, 1, 1+2*i, 2+2*i, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);  \
+       table->attach(*slider_##n, 0, 1, 2+2*i, 3+2*i, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0)
+
+#define ATTACH_SPIN_BUTTON(i,n) \
+       spinbutton_##n=manage(new class Gtk::SpinButton(n##_adjustment,1,0)); \
+       spinbutton_##n->set_update_policy(Gtk::UPDATE_ALWAYS); \
+       spinbutton_##n->set_size_request(SPINBUTTON_WIDTH,-1); \
+       spinbutton_##n->show(); \
+       table->attach(*spinbutton_##n, 1, 2, 1+2*i, 3+2*i, Gtk::SHRINK, Gtk::EXPAND, 2, 0)
+
+       {
+               Gtk::Table* table(rgb_table);
+               SLIDER_ROW(0,R,_("Red"));
+               ATTACH_SPIN_BUTTON(0,R);
+               SLIDER_ROW(1,G,_("Green"));
+               ATTACH_SPIN_BUTTON(1,G);
+               SLIDER_ROW(2,B,_("Blue"));
+               ATTACH_SPIN_BUTTON(2,B);
+
+               hex_color_label = manage(new Gtk::Label(_("HTML code"), 0.0, 0.5));
+               hex_color_label->set_use_markup(false);
+               hex_color_label->set_use_underline(false);
+               hex_color_label->set_attributes(attr_list);
+               table->attach(*hex_color_label, 0, 1, 7, 8, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+
+               hex_color = manage(new Gtk::Entry());
+               hex_color->set_width_chars(8);
+               hex_color->signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_hex_edited));
+               table->attach(*hex_color, 0, 1, 8, 9, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       }
+       {
+               Gtk::Table* table(yuv_table);
+               SLIDER_ROW(0,Y,_("Luma"));
+               SLIDER_ROW(1,HUE,_("Hue"));
+               SLIDER_ROW(2,SAT,_("Saturation"));
+               SLIDER_ROW(3,U,_("U"));
+               SLIDER_ROW(4,V,_("V"));
+       }
+       {
+               Gtk::Table* table(main_table);
+               SLIDER_ROW(1,A,_("Alpha"));
+               ATTACH_SPIN_BUTTON(1,A);
+       }
+
+#undef SLIDER_ROW
+#undef ATTACH_SPIN_BUTTON
+
+       spinbutton_R->signal_activate().connect(sigc::mem_fun(*spinbutton_G,&Gtk::SpinButton::grab_focus));
+       spinbutton_G->signal_activate().connect(sigc::mem_fun(*spinbutton_B,&Gtk::SpinButton::grab_focus));
+       spinbutton_B->signal_activate().connect(sigc::mem_fun(*spinbutton_A,&Gtk::SpinButton::grab_focus));
+       spinbutton_A->signal_activate().connect(sigc::mem_fun(*spinbutton_R,&Gtk::SpinButton::grab_focus));
+
+       R_adjustment.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_value_changed));
+       G_adjustment.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_value_changed));
+       B_adjustment.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_value_changed));
+       A_adjustment.signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_ColorEdit::on_value_changed));
+
+       show_all_children();
+
+       set_digits(1);
+       set_value(color);
+
+       hold_signals=false;
+}
+
+Widget_ColorEdit::~Widget_ColorEdit()
+{
+}
+
+void
+Widget_ColorEdit::on_slider_moved(ColorSlider::Type type, float amount)
+{
+       Color color(get_value_raw());
+
+       assert(color.is_valid());
+       ColorSlider::adjust_color(type,color,amount);
+       assert(color.is_valid());
+
+       // If a non-primary colorslider is adjusted,
+       // we want to make sure that we clamp
+       if(type>ColorSlider::TYPE_B && (color.get_r()<0 ||color.get_g()<0 ||color.get_b()<0))
+               clamp_=true;
+
+       /*
+       if(type==ColorSlider::TYPE_R && color.get_r()<0)clamp_=false;
+       if(type==ColorSlider::TYPE_G && color.get_g()<0)clamp_=false;
+       if(type==ColorSlider::TYPE_B && color.get_b()<0)clamp_=false;
+       */
+       clamp_=false;
+
+       set_value(color);
+       assert(color.is_valid());
+}
+
+void
+Widget_ColorEdit::on_hex_edited()
+{
+       Color color(get_value_raw());
+       String s = hex_color->get_text();
+       color.set_hex(s);
+       set_value(color);
+       signal_value_changed_();
+}
+
+void
+Widget_ColorEdit::on_value_changed()
+{
+       if(hold_signals)
+               return;
+
+       const Color color(get_value_raw());
+       assert(color.is_valid());
+       slider_R->set_color(color);
+       slider_G->set_color(color);
+       slider_B->set_color(color);
+       slider_Y->set_color(color);
+       slider_U->set_color(color);
+       slider_V->set_color(color);
+       slider_HUE->set_color(color);
+       slider_SAT->set_color(color);
+       slider_A->set_color(color);
+       hex_color->set_text(color.get_hex());
+       widget_color.set_value(color);
+
+       activate();
+       signal_value_changed_();
+}
+
+void
+Widget_ColorEdit::set_has_frame(bool x)
+{
+       spinbutton_R->set_has_frame(x);
+       spinbutton_G->set_has_frame(x);
+       spinbutton_B->set_has_frame(x);
+       spinbutton_A->set_has_frame(x);
+       spinbutton_R->set_size_request(SPINBUTTON_WIDTH,-1);
+       spinbutton_G->set_size_request(SPINBUTTON_WIDTH,-1);
+       spinbutton_B->set_size_request(SPINBUTTON_WIDTH,-1);
+       spinbutton_A->set_size_request(SPINBUTTON_WIDTH,-1);
+}
+
+void
+Widget_ColorEdit::set_digits(int x)
+{
+       spinbutton_R->set_digits(x);
+       spinbutton_G->set_digits(x);
+       spinbutton_B->set_digits(x);
+       spinbutton_A->set_digits(x);
+       spinbutton_R->set_size_request(SPINBUTTON_WIDTH,-1);
+       spinbutton_G->set_size_request(SPINBUTTON_WIDTH,-1);
+       spinbutton_B->set_size_request(SPINBUTTON_WIDTH,-1);
+       spinbutton_A->set_size_request(SPINBUTTON_WIDTH,-1);
+}
+
+void
+Widget_ColorEdit::set_value(const synfig::Color &data)
+{
+       assert(data.is_valid());
+       hold_signals=true;
+       clamp_=false;
+
+       color=data;
+
+       if(use_colorspace_gamma())
+       {
+               R_adjustment.set_value(gamma_in(color.get_r())*100);
+               G_adjustment.set_value(gamma_in(color.get_g())*100);
+               B_adjustment.set_value(gamma_in(color.get_b())*100);
+       }
+       else
+       {
+               R_adjustment.set_value(color.get_r()*100);
+               G_adjustment.set_value(color.get_g()*100);
+               B_adjustment.set_value(color.get_b()*100);
+       }
+       A_adjustment.set_value(color.get_a()*100);
+
+       slider_R->set_color(color);
+       slider_G->set_color(color);
+       slider_B->set_color(color);
+       slider_Y->set_color(color);
+       slider_U->set_color(color);
+       slider_V->set_color(color);
+       slider_HUE->set_color(color);
+       slider_SAT->set_color(color);
+       slider_A->set_color(color);
+       hex_color->set_text(color.get_hex());
+       widget_color.set_value(color);
+
+       hold_signals=false;
+}
+
+synfig::Color
+Widget_ColorEdit::get_value_raw()
+{
+       Color color;
+       if(use_colorspace_gamma())
+       {
+               color.set_r(gamma_out(R_adjustment.get_value()/100.0f));
+               color.set_g(gamma_out(G_adjustment.get_value()/100.0f));
+               color.set_b(gamma_out(B_adjustment.get_value()/100.0f));
+       }
+       else
+       {
+               color.set_r(R_adjustment.get_value()/100);
+               color.set_g(G_adjustment.get_value()/100);
+               color.set_b(B_adjustment.get_value()/100);
+       }
+       color.set_a(A_adjustment.get_value()/100);
+       assert(color.is_valid());
+
+       return color;
+}
+
+const synfig::Color &
+Widget_ColorEdit::get_value()
+{
+       if(use_colorspace_gamma())
+       {
+               color.set_r(gamma_out(R_adjustment.get_value()/100.0f));
+               color.set_g(gamma_out(G_adjustment.get_value()/100.0f));
+               color.set_b(gamma_out(B_adjustment.get_value()/100.0f));
+               assert(color.is_valid());
+       }
+       else
+       {
+               color.set_r(R_adjustment.get_value()/100);
+               color.set_g(G_adjustment.get_value()/100);
+               color.set_b(B_adjustment.get_value()/100);
+               assert(color.is_valid());
+       }
+       color.set_a(A_adjustment.get_value()/100);
+       assert(color.is_valid());
+
+       if(notebook->get_current_page()!=0)
+               color=color.clamped();
+
+       /*{
+               // Clamp out negative values
+               color.set_r(std::max(0.0f,(float)color.get_r()));
+               color.set_g(std::max(0.0f,(float)color.get_g()));
+               color.set_b(std::max(0.0f,(float)color.get_b()));
+       }*/
+
+       return color;
+}
diff --git a/synfig-studio/src/gui/widget_coloredit.h b/synfig-studio/src/gui/widget_coloredit.h
new file mode 100644 (file)
index 0000000..63dcfa6
--- /dev/null
@@ -0,0 +1,188 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_coloredit.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_WIDGET_COLOREDIT_H
+#define __SYNFIG_STUDIO_WIDGET_COLOREDIT_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/box.h>
+#include <gtkmm/table.h>
+#include <gtkmm/spinbutton.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/drawingarea.h>
+#include <synfig/color.h>
+#include "widget_color.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 Gtk {
+       class Notebook;
+};
+
+namespace studio {
+
+class ColorSlider : public Gtk::DrawingArea
+{
+public:
+       enum Type
+       {
+               TYPE_R,
+               TYPE_G,
+               TYPE_B,
+               TYPE_Y,
+               TYPE_U,
+               TYPE_V,
+               TYPE_HUE,
+               TYPE_SAT,
+               TYPE_A,
+
+               TYPE_END
+       };
+
+private:
+
+       sigc::signal<void,Type,float> signal_slider_moved_;
+       sigc::signal<void> signal_activated_;
+
+       Type type;
+       synfig::Color color_;
+
+public:
+
+       sigc::signal<void,Type,float>& signal_slider_moved() { return signal_slider_moved_; }
+       sigc::signal<void>& signal_activated() { return signal_activated_; }
+
+       Type
+       get_type()const { return type; }
+
+       const synfig::Color&
+       get_color()const { return color_; }
+
+
+       ColorSlider(const Type &x=TYPE_Y);
+
+       void
+       set_type(Type x);
+
+       void
+       set_color(synfig::Color x);
+
+       static void adjust_color(Type type, synfig::Color &color, float amount);
+
+private:
+       typedef void (*slider_color_func)(synfig::Color &,float);
+
+       static void slider_color_TYPE_R(synfig::Color &color, float amount);
+       static void slider_color_TYPE_G(synfig::Color &color, float amount);
+       static void slider_color_TYPE_B(synfig::Color &color, float amount);
+       static void slider_color_TYPE_Y(synfig::Color &color, float amount);
+       static void slider_color_TYPE_U(synfig::Color &color, float amount);
+       static void slider_color_TYPE_V(synfig::Color &color, float amount);
+       static void slider_color_TYPE_HUE(synfig::Color &color, float amount);
+       static void slider_color_TYPE_SAT(synfig::Color &color, float amount);
+       static void slider_color_TYPE_A(synfig::Color &color, float amount);
+
+
+       bool
+       redraw(GdkEventExpose*bleh);
+       bool on_event(GdkEvent *event);
+}; // END of class ColorSlider
+
+
+class Widget_ColorEdit : public Gtk::Table
+{
+       sigc::signal<void> signal_activated_;
+       sigc::signal<void> signal_value_changed_;
+
+       ColorSlider *slider_R;
+       ColorSlider *slider_G;
+       ColorSlider *slider_B;
+       Gtk::Label *hex_color_label;
+       Gtk::Entry *hex_color;
+
+       ColorSlider *slider_A;
+       ColorSlider *slider_Y;
+       ColorSlider *slider_U;
+       ColorSlider *slider_V;
+       ColorSlider *slider_SAT;
+       ColorSlider *slider_HUE;
+
+       Widget_Color widget_color;
+
+       bool hold_signals;
+
+       bool clamp_;
+
+       Gtk::SpinButton *spinbutton_R;
+       Gtk::SpinButton *spinbutton_G;
+       Gtk::SpinButton *spinbutton_B;
+       Gtk::SpinButton *spinbutton_A;
+
+       Gtk::Adjustment R_adjustment;
+       Gtk::Adjustment G_adjustment;
+       Gtk::Adjustment B_adjustment;
+       Gtk::Adjustment A_adjustment;
+
+       synfig::Color color;
+
+       Gtk::Notebook* notebook;
+
+protected:
+
+       void on_value_changed();
+
+public:
+
+       sigc::signal<void>& signal_activated() { return signal_activated_; }
+
+       sigc::signal<void>& signal_activate() { return signal_activated_; }
+
+       void on_slider_moved(ColorSlider::Type type, float amount);
+       void on_hex_edited();
+
+       //Glib::SignalProxy0<void> signal_activate() { return spinbutton_A->signal_activate(); }
+
+       sigc::signal<void>& signal_value_changed() { return signal_value_changed_; }
+
+       void activated() { signal_activated_(); }
+       void activate() { signal_activated_(); }
+       void set_value(const synfig::Color &data);
+       const synfig::Color &get_value();
+       synfig::Color get_value_raw();
+       void set_has_frame(bool x);
+       void set_digits(int x);
+       Widget_ColorEdit();
+       ~Widget_ColorEdit();
+}; // END of class Widget_ColorEdit
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/widget_compselect.cpp b/synfig-studio/src/gui/widget_compselect.cpp
new file mode 100644 (file)
index 0000000..51eb3db
--- /dev/null
@@ -0,0 +1,173 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_compselect.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include <gtkmm/menu.h>
+#include "widget_compselect.h"
+#include <ETL/stringf>
+#include <synfig/valuenode.h>
+#include "instance.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Widget_CompSelect::Widget_CompSelect()
+{
+       App::signal_instance_created().connect(sigc::mem_fun(*this,&studio::Widget_CompSelect::new_instance));
+       App::signal_instance_deleted().connect(sigc::mem_fun(*this,&studio::Widget_CompSelect::delete_instance));
+       App::signal_instance_selected().connect(sigc::mem_fun(*this,&studio::Widget_CompSelect::set_selected_instance_signal));
+
+       set_menu(instance_list_menu);
+       refresh();
+}
+
+Widget_CompSelect::~Widget_CompSelect()
+{
+}
+
+void
+Widget_CompSelect::set_selected_instance_signal(etl::handle<studio::Instance> x)
+{
+       set_selected_instance(x);
+}
+
+void
+Widget_CompSelect::set_selected_instance_(etl::handle<studio::Instance> instance)
+{
+       if(studio::App::shutdown_in_progress)
+               return;
+
+       selected_instance=instance;
+}
+
+void
+Widget_CompSelect::set_selected_instance(etl::loose_handle<studio::Instance> x)
+{
+       if(studio::App::shutdown_in_progress)
+               return;
+
+       // if it's already selected, don't select it again
+       if (x==selected_instance)
+               return;
+
+       std::list<etl::handle<studio::Instance> >::iterator iter;
+
+       if(x)
+       {
+               int i;
+               for(i=0,iter=studio::App::instance_list.begin();iter!=studio::App::instance_list.end() && ((*iter)!=x);iter++,i++)
+                       ;
+
+               assert(*iter==x);
+
+               set_history(i);
+       }
+       else
+               set_history(0);
+
+       set_selected_instance_(x);
+}
+
+void
+Widget_CompSelect::new_instance(etl::handle<studio::Instance> instance)
+{
+       if(studio::App::shutdown_in_progress)
+               return;
+
+       assert(instance);
+
+       etl::loose_handle<studio::Instance> loose_instance(instance);
+
+       instance->synfigapp::Instance::signal_filename_changed().connect(sigc::mem_fun(*this,&Widget_CompSelect::refresh));
+       instance->synfigapp::Instance::signal_filename_changed().connect(
+               sigc::bind<etl::loose_handle<studio::Instance> >(
+                       sigc::mem_fun(*this,&Widget_CompSelect::set_selected_instance),
+                       loose_instance
+               )
+       );
+
+       {
+               std::string name=basename(instance->get_file_name());
+
+               instance_list_menu.items().push_back(Gtk::Menu_Helpers::MenuElem(name,
+                       sigc::bind<etl::loose_handle<studio::Instance> >(sigc::ptr_fun(&studio::App::set_selected_instance),loose_instance)     ));
+       }
+
+}
+
+void
+Widget_CompSelect::delete_instance(etl::handle<studio::Instance> instance)
+{
+       refresh();
+
+       if(selected_instance==instance)
+       {
+               set_selected_instance(0);
+               set_history(0);
+       }
+}
+
+void
+Widget_CompSelect::refresh()
+{
+       remove_menu();
+
+       if(!instance_list_menu.items().empty())
+               instance_list_menu.items().clear();
+
+       if(studio::App::shutdown_in_progress)
+               return;
+
+       std::list<etl::handle<studio::Instance> >::iterator iter;
+       for(iter=studio::App::instance_list.begin();iter!=studio::App::instance_list.end();iter++)
+       {
+               std::string name=basename((*iter)->get_file_name());
+
+               instance_list_menu.items().push_back(Gtk::Menu_Helpers::MenuElem(name,
+                       sigc::bind<etl::loose_handle<studio::Instance> >(sigc::ptr_fun(&studio::App::set_selected_instance),*iter)      ));
+       }
+       set_menu(instance_list_menu);
+}
diff --git a/synfig-studio/src/gui/widget_compselect.h b/synfig-studio/src/gui/widget_compselect.h
new file mode 100644 (file)
index 0000000..4618a1b
--- /dev/null
@@ -0,0 +1,74 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_compselect.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_WIDGET_COMPSELECT_H
+#define __SYNFIG_STUDIO_WIDGET_COMPSELECT_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/optionmenu.h>
+#include <gtkmm/menu.h>
+#include "app.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 Gtk { class Menu; };
+
+namespace studio {
+
+class Widget_CompSelect : public Gtk::OptionMenu
+{
+       Gtk::Menu       instance_list_menu;
+
+
+       etl::loose_handle<studio::Instance>     selected_instance;
+       void set_selected_instance_(etl::handle<studio::Instance> x);
+
+       void new_instance(etl::handle<studio::Instance> x);
+
+       void delete_instance(etl::handle<studio::Instance> x);
+
+       void set_selected_instance(etl::loose_handle<studio::Instance> x);
+
+       void set_selected_instance_signal(etl::handle<studio::Instance> x);
+
+public:
+
+       Widget_CompSelect();
+       ~Widget_CompSelect();
+
+       etl::loose_handle<studio::Instance> get_selected_instance() { return selected_instance; }
+
+       void refresh();
+}; // END of class Widget_CompSelect
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/widget_curves.cpp b/synfig-studio/src/gui/widget_curves.cpp
new file mode 100644 (file)
index 0000000..2260dad
--- /dev/null
@@ -0,0 +1,588 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_curves.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**  Copyright (c) 2008 Gerco Ballintijn
+**
+**     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 <config.h>
+#endif
+
+#include "widget_curves.h"
+#include <cmath>
+#include "app.h"
+#include <gtkmm/drawingarea.h>
+#include <map>
+#include <vector>
+#include <ETL/misc>
+#include <sigc++/object.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/*
+void
+studio::render_color_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::Color &color)
+{
+       const int height(ca.get_height());
+       const int width(ca.get_width());
+
+       const int square_size(height/2);
+
+       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(window));
+
+       if(color.get_alpha()!=1.0)
+       {
+               // In this case we need to render the alpha squares
+
+               const Color bg1(Color::blend(color,Color(0.75, 0.75, 0.75),1.0).clamped());
+               const Color bg2(Color::blend(color,Color(0.5, 0.5, 0.5),1.0).clamped());
+
+               Gdk::Color gdk_c1(colorconv_synfig2gdk(bg1));
+               Gdk::Color gdk_c2(colorconv_synfig2gdk(bg2));
+
+               bool toggle(false);
+               for(int i=0;i<width;i+=square_size)
+               {
+                       const int square_width(min(square_size,width-i));
+
+                       if(toggle)
+                       {
+                               gc->set_rgb_fg_color(gdk_c1);
+                               window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), square_width, square_size);
+
+                               gc->set_rgb_fg_color(gdk_c2);
+                               window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y()+square_size, square_width, square_size);
+                               toggle=false;
+                       }
+                       else
+                       {
+                               gc->set_rgb_fg_color(gdk_c2);
+                               window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), square_width, square_size);
+
+                               gc->set_rgb_fg_color(gdk_c1);
+                               window->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y()+square_size, square_width, square_size);
+                               toggle=true;
+                       }
+               }
+       }
+       else
+       {
+               // In this case we have a solid color to use
+               Gdk::Color gdk_c1(colorconv_synfig2gdk(color));
+
+               gc->set_rgb_fg_color(gdk_c1);
+               window->draw_rectangle(gc, true, ca.get_x(), ca.get_y(), width-1, height-1);
+       }
+       gc->set_rgb_fg_color(Gdk::Color("#ffffff"));
+       window->draw_rectangle(gc, false, ca.get_x()+1, ca.get_y()+1, width-3, height-3);
+       gc->set_rgb_fg_color(Gdk::Color("#000000"));
+       window->draw_rectangle(gc, false, ca.get_x(), ca.get_y(), width-1, height-1);
+}
+*/
+
+/* === C L A S S E S ======================================================= */
+
+
+
+struct studio::Widget_Curves::Channel
+{
+       synfig::String name;
+       Gdk::Color color;
+       std::map<synfig::Real,synfig::Real> values;
+};
+
+struct studio::Widget_Curves::CurveStruct : sigc::trackable
+{
+       synfigapp::ValueDesc value_desc;
+       std::vector<Channel> channels;
+
+       CurveStruct(const synfigapp::ValueDesc& x):
+               value_desc(x)
+       {
+               switch(value_desc.get_value_type())
+               {
+                       case ValueBase::TYPE_REAL:
+                               channels.push_back(Channel());
+                               channels.back().name="real";
+                               channels.back().color=Gdk::Color("#007f7f");
+                               break;
+                       case ValueBase::TYPE_TIME:
+                               channels.push_back(Channel());
+                               channels.back().name="time";
+                               channels.back().color=Gdk::Color("#7f7f00");
+                               break;
+                       case ValueBase::TYPE_INTEGER:
+                               channels.push_back(Channel());
+                               channels.back().name="int";
+                               channels.back().color=Gdk::Color("#7f0000");
+                               break;
+                       case ValueBase::TYPE_BOOL:
+                               channels.push_back(Channel());
+                               channels.back().name="bool";
+                               channels.back().color=Gdk::Color("#ff7f00");
+                               break;
+                       case ValueBase::TYPE_ANGLE:
+                               channels.push_back(Channel());
+                               channels.back().name="theta";
+                               channels.back().color=Gdk::Color("#004f4f");
+                               break;
+                       case ValueBase::TYPE_COLOR:
+                               channels.push_back(Channel());
+                               channels.back().name="red";
+                               channels.back().color=Gdk::Color("#7f0000");
+                               channels.push_back(Channel());
+                               channels.back().name="green";
+                               channels.back().color=Gdk::Color("#007f00");
+                               channels.push_back(Channel());
+                               channels.back().name="blue";
+                               channels.back().color=Gdk::Color("#00007f");
+                               channels.push_back(Channel());
+                               channels.back().name="alpha";
+                               channels.back().color=Gdk::Color("#000000");
+                               break;
+                       case ValueBase::TYPE_VECTOR:
+                               channels.push_back(Channel());
+                               channels.back().name="x";
+                               channels.back().color=Gdk::Color("#7f007f");
+                               channels.push_back(Channel());
+                               channels.back().name="y";
+                               channels.back().color=Gdk::Color("#007f7f");
+                               break;
+                       case ValueBase::TYPE_BLINEPOINT:
+                               channels.push_back(Channel());
+                               channels.back().name="v.x";
+                               channels.back().color=Gdk::Color("#ff7f00");
+                               channels.push_back(Channel());
+                               channels.back().name="v.y";
+                               channels.back().color=Gdk::Color("#7f3f00");
+
+                               channels.push_back(Channel());
+                               channels.back().name="width";
+                               channels.back().color=Gdk::Color("#000000");
+
+                               channels.push_back(Channel());
+                               channels.back().name="origin";
+                               channels.back().color=Gdk::Color("#ffffff");
+
+                               channels.push_back(Channel());
+                               channels.back().name="tsplit";
+                               channels.back().color=Gdk::Color("#ff00ff");
+
+                               channels.push_back(Channel());
+                               channels.back().name="t1.x";
+                               channels.back().color=Gdk::Color("#ff0000");
+                               channels.push_back(Channel());
+                               channels.back().name="t1.y";
+                               channels.back().color=Gdk::Color("#7f0000");
+
+                               channels.push_back(Channel());
+                               channels.back().name="t2.x";
+                               channels.back().color=Gdk::Color("#ffff00");
+                               channels.push_back(Channel());
+                               channels.back().name="t2.y";
+                               channels.back().color=Gdk::Color("#7f7f00");
+                               break;
+                       default:
+                               throw synfig::Exception::BadType("Bad type for curves");
+               }
+       }
+
+       void clear_all_values()
+       {
+               std::vector<Channel>::iterator iter;
+               for(iter=channels.begin();iter!=channels.end();++iter)
+                       iter->values.clear();
+       }
+
+       synfig::Real get_value(int chan, synfig::Real time, synfig::Real tolerance)
+       {
+               std::map<synfig::Real,synfig::Real>::iterator iter;
+
+               // First check to see if we have a value
+               // that is "close enough" to the time
+               // we are looking for
+               iter=channels[chan].values.lower_bound(time);
+               if(iter!=channels[chan].values.end() && iter->first-time<=tolerance)
+                       return -iter->second;
+
+               // Since that didn't work, we now need
+               // to go ahead and figure out what the
+               // actual value is at that time.
+               ValueBase value(value_desc.get_value(time));
+               switch(value.get_type())
+               {
+                       case ValueBase::TYPE_REAL:
+                               channels[0].values[time]=value.get(Real());
+                               break;
+                       case ValueBase::TYPE_TIME:
+                               channels[0].values[time]=value.get(Time());
+                               break;
+                       case ValueBase::TYPE_INTEGER:
+                               channels[0].values[time]=value.get(int());
+                               break;
+                       case ValueBase::TYPE_BOOL:
+                               channels[0].values[time]=value.get(bool());
+                               break;
+                       case ValueBase::TYPE_ANGLE:
+                               channels[0].values[time]=Angle::rad(value.get(Angle())).get();
+                               break;
+                       case ValueBase::TYPE_COLOR:
+                               channels[0].values[time]=value.get(Color()).get_r();
+                               channels[1].values[time]=value.get(Color()).get_g();
+                               channels[2].values[time]=value.get(Color()).get_b();
+                               channels[3].values[time]=value.get(Color()).get_a();
+                               break;
+                       case ValueBase::TYPE_VECTOR:
+                               channels[0].values[time]=value.get(Vector())[0];
+                               channels[1].values[time]=value.get(Vector())[1];
+                               break;
+                       case ValueBase::TYPE_BLINEPOINT:
+                               channels[0].values[time]=value.get(BLinePoint()).get_vertex()[0];
+                               channels[1].values[time]=value.get(BLinePoint()).get_vertex()[1];
+                               channels[2].values[time]=value.get(BLinePoint()).get_width();
+                               channels[3].values[time]=value.get(BLinePoint()).get_origin();
+                               channels[4].values[time]=value.get(BLinePoint()).get_split_tangent_flag();
+                               channels[5].values[time]=value.get(BLinePoint()).get_tangent1()[0];
+                               channels[6].values[time]=value.get(BLinePoint()).get_tangent1()[1];
+                               channels[7].values[time]=value.get(BLinePoint()).get_tangent2()[0];
+                               channels[8].values[time]=value.get(BLinePoint()).get_tangent2()[1];
+                               break;
+                       default:
+                               return 0;
+               }
+
+               return -channels[chan].values[time];
+       }
+
+       static bool is_not_supported(const synfigapp::ValueDesc& x)
+       {
+               return x.get_value_type() == ValueBase::TYPE_STRING
+                       || x.get_value_type() == ValueBase::TYPE_CANVAS
+                       || x.get_value_type() == ValueBase::TYPE_GRADIENT
+                       || x.get_value_type() == ValueBase::TYPE_LIST
+                       || x.get_value_type() == ValueBase::TYPE_SEGMENT;
+       }
+};
+
+/* === M E T H O D S ======================================================= */
+
+Widget_Curves::Widget_Curves():
+       range_adjustment_(new Gtk::Adjustment(-1,-2,2,0.1,0.1,2))
+{
+       set_size_request(64,64);
+
+       range_adjustment_->signal_changed().connect(
+               sigc::mem_fun(
+                       *this,
+                       &Widget_Curves::queue_draw
+               )
+       );
+       range_adjustment_->signal_value_changed().connect(
+               sigc::mem_fun(
+                       *this,
+                       &Widget_Curves::queue_draw
+               )
+       );
+       //set_vadjustment(*range_adjustment_);
+
+       signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Curves::redraw));
+       add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
+
+}
+
+Widget_Curves::~Widget_Curves()
+{
+}
+
+void
+Widget_Curves::set_time_adjustment(Gtk::Adjustment&x)
+{
+       time_adjustment_=&x;
+       time_adjustment_->signal_changed().connect(
+               sigc::mem_fun(
+                       *this,
+                       &Widget_Curves::queue_draw
+               )
+       );
+       time_adjustment_->signal_value_changed().connect(
+               sigc::mem_fun(
+                       *this,
+                       &Widget_Curves::queue_draw
+               )
+       );
+       //set_hadjustment(*time_adjustment_);
+}
+
+void
+Widget_Curves::clear()
+{
+       curve_list_.clear();
+}
+
+void
+Widget_Curves::refresh()
+{
+       std::list<CurveStruct>::iterator curve_iter;
+       for(curve_iter=curve_list_.begin();curve_iter!=curve_list_.end();++curve_iter)
+       {
+               curve_iter->clear_all_values();
+       }
+       queue_draw();
+}
+
+void
+Widget_Curves::set_value_descs(std::list<synfigapp::ValueDesc> value_descs)
+{
+       curve_list_.clear();
+
+       std::list<synfigapp::ValueDesc>::iterator iter;
+       for(iter=value_descs.begin();iter!=value_descs.end();++iter)
+       {
+               if (CurveStruct::is_not_supported(*iter))
+                       continue;
+
+               try {
+                       curve_list_.push_back(*iter);
+                       if(iter->is_value_node())
+                       {
+                               iter->get_value_node()->signal_changed().connect(
+                                       sigc::mem_fun(
+                                               *this,
+                                               &studio::Widget_Curves::refresh
+                                       )
+                               );
+                       }
+                       if(iter->parent_is_value_node())
+                       {
+                               iter->get_parent_value_node()->signal_changed().connect(
+                                       sigc::mem_fun(
+                                               *this,
+                                               &studio::Widget_Curves::refresh
+                                       )
+                               );
+                       }
+                       if(iter->parent_is_layer_param())
+                       {
+                               iter->get_layer()->signal_changed().connect(
+                                       sigc::mem_fun(
+                                               *this,
+                                               &studio::Widget_Curves::refresh
+                                       )
+                               );
+                       }
+               }catch(synfig::Exception::BadType)
+               {
+                       continue;
+               }
+       }
+       queue_draw();
+}
+
+bool
+Widget_Curves::on_event(GdkEvent *event)
+{
+       switch(event->type)
+       {
+       case GDK_SCROLL:
+               switch(event->scroll.direction)
+               {
+                       case GDK_SCROLL_UP:
+                               range_adjustment_->set_page_size(range_adjustment_->get_page_size()/1.25);
+                               range_adjustment_->changed();
+                               break;
+                       case GDK_SCROLL_DOWN:
+                               range_adjustment_->set_page_size(range_adjustment_->get_page_size()*1.25);
+                               range_adjustment_->changed();
+                               break;
+                       default:
+                               break;
+               }
+               break;
+       default:
+               return Gtk::DrawingArea::on_event(event);
+               break;
+       }
+
+       return true;
+
+/*     switch(event->type)
+       {
+       case GDK_BUTTON_PRESS:
+               if(event->button.button==1)
+               {
+                       signal_activate_();
+                       return true;
+               }
+               if(event->button.button==3)
+               {
+                       signal_secondary_();
+                       return true;
+               }
+               break;
+
+       default:
+               break;
+       }
+       return false;
+*/
+}
+
+bool
+Widget_Curves::redraw(GdkEventExpose */*bleh*/)
+{
+       const int h(get_height());
+       const int w(get_width());
+       get_window()->clear();
+
+       if(!time_adjustment_ || !range_adjustment_ || !h || !w)
+               return false;
+
+       if(!curve_list_.size())
+               return false;
+
+       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
+
+       const Real t_begin(time_adjustment_->get_lower());
+       const Real t_end(time_adjustment_->get_upper());
+       const Real dt((t_end-t_begin)/w);
+
+       const Real r_bottom(range_adjustment_->get_value());
+       const Real r_top(r_bottom+range_adjustment_->get_page_size());
+       const Real dr((r_top-r_bottom)/h);
+       Real r_max(-100000000);
+       Real r_min(100000000);
+
+       std::list<CurveStruct>::iterator curve_iter;
+
+       vector<Gdk::Point> points[10];
+
+       gc->set_function(Gdk::COPY);
+       gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+
+       // Draw zero mark
+       gc->set_rgb_fg_color(Gdk::Color("#4f4f4f"));
+       get_window()->draw_rectangle(gc, false, 0, round_to_int((0-r_bottom)/dr), w, 0);
+
+       // This try to find a valid vanvas to show the keyframes of those
+       // valuenodes. If not canvas found then no keyframes marks are shown.
+       synfig::Canvas::Handle canvas=0;
+       for(curve_iter=curve_list_.begin();curve_iter!=curve_list_.end();++curve_iter)
+       {
+               canvas=curve_iter->value_desc.get_canvas();
+               if(canvas)
+                       break;
+       }
+
+       if(canvas)
+       {
+       // Draw vertical lines for the keyframes marks.
+               const synfig::KeyframeList& keyframe_list(canvas->keyframe_list());
+               synfig::KeyframeList::const_iterator iter;
+
+               for(iter=keyframe_list.begin();iter!=keyframe_list.end();++iter)
+               {
+                       if(!iter->get_time().is_valid())
+                               continue;
+
+                       const int x((int)((float)w/(t_end-t_begin)*(iter->get_time()-t_begin)));
+                       if(iter->get_time()>=t_begin && iter->get_time()<t_end)
+                       {
+                               gc->set_rgb_fg_color(Gdk::Color("#a07f7f")); // It should be user selectable
+                               get_window()->draw_rectangle(gc, true, x, 0, 1, h);
+                       }
+               }
+       }
+
+       // Draw current time
+       gc->set_rgb_fg_color(Gdk::Color("#0000ff")); // It should be user selectable
+       get_window()->draw_rectangle(gc, false, round_to_int((time_adjustment_->get_value()-t_begin)/dt), 0, 0, h);
+
+       // Draw curves for the valuenodes stored in the curve list
+       for(curve_iter=curve_list_.begin();curve_iter!=curve_list_.end();++curve_iter)
+       {
+               Real t;
+               int i;
+               int channels(curve_iter->channels.size());
+               for(i=0;i<channels;i++)
+                       points[i].clear();
+
+               for(i=0,t=t_begin;i<w;i++,t+=dt)
+               {
+                       for(int chan=0;chan<channels;chan++)
+                       {
+                               Real x(curve_iter->get_value(chan,t,dt));
+                               r_max=max(r_max,x);
+                               r_min=min(r_min,x);
+                               points[chan].push_back(
+                                       Gdk::Point(
+                                               i,
+                                               round_to_int(
+                                                       (
+                                                               x-r_bottom
+                                                       )/dr
+                                               )
+                                       )
+                               );
+                       }
+               }
+
+               for(int chan=0;chan<channels;chan++)
+               {
+                       gc->set_rgb_fg_color(curve_iter->channels[chan].color);
+
+                       // Draw the curve
+                       get_window()->draw_lines(gc, Glib::ArrayHandle<Gdk::Point>(points[chan]));
+
+                       Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_pango_context()));
+
+                       layout->set_text(curve_iter->channels[chan].name);
+                       get_window()->draw_layout(gc, 1, points[chan][0].get_y()+1, layout);
+               }
+       }
+
+       if(!curve_list_.empty())
+       {
+               range_adjustment_->set_upper(r_max+range_adjustment_->get_page_size()/2);
+               range_adjustment_->set_lower(r_min-range_adjustment_->get_page_size()/2);
+       }
+       get_window()->get_update_area();
+
+       return true;
+}
diff --git a/synfig-studio/src/gui/widget_curves.h b/synfig-studio/src/gui/widget_curves.h
new file mode 100644 (file)
index 0000000..4fcf66f
--- /dev/null
@@ -0,0 +1,81 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_curves.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_WIDGET_CURVES_H
+#define __SYNFIG_STUDIO_WIDGET_CURVES_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/box.h>
+#include <gtkmm/table.h>
+#include <gtkmm/spinbutton.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/drawingarea.h>
+#include <gtkmm/layout.h>
+#include <synfig/color.h>
+#include <synfigapp/value_desc.h>
+#include <list>
+
+/* === 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 Widget_Curves : public Gtk::DrawingArea
+{
+       struct Channel;
+       struct CurveStruct;
+
+       Gtk::Adjustment* time_adjustment_;
+       Gtk::Adjustment* range_adjustment_;
+
+       std::list<CurveStruct> curve_list_;
+
+public:
+
+       Widget_Curves();
+       ~Widget_Curves();
+
+       void set_value_descs(std::list<synfigapp::ValueDesc> value_descs);
+       void clear();
+       void refresh();
+
+       Gtk::Adjustment& get_range_adjustment() { return *range_adjustment_; }
+       Gtk::Adjustment& get_time_adjustment() { return *time_adjustment_; }
+       void set_time_adjustment(Gtk::Adjustment&);
+
+private:
+       bool redraw(GdkEventExpose*bleh);
+       bool on_event(GdkEvent *event);
+
+}; // END of class Widget_Curves
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/widget_defaults.cpp b/synfig-studio/src/gui/widget_defaults.cpp
new file mode 100644 (file)
index 0000000..20cabfe
--- /dev/null
@@ -0,0 +1,611 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_defaults.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**  Copyright (c) 2008 Chris Moore
+**  Copyright (c) 2008 Carlos López
+**
+**     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 <config.h>
+#endif
+
+#include "widget_defaults.h"
+#include "widget_color.h"
+#include "widget_gradient.h"
+#include "dialog_color.h"
+#include "dialog_gradient.h"
+#include "app.h"
+#include <gtkmm/menu.h>
+#include <gtkmm/scale.h>
+#include <synfig/exception.h>
+#include <synfigapp/main.h>
+#include "canvasview.h"
+#include "widget_distance.h"
+#include "widget_enum.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 ========================================================= */
+
+#define GRADIENT_HEIGHT                16
+#define DEFAULT_INCREMENT      (0.25)
+#define DEFAULT_WIDTH          (synfig::Distance(3,synfig::Distance::SYSTEM_POINTS))
+
+/* === G L O B A L S ======================================================= */
+
+class studio::Widget_Brush : public Gtk::DrawingArea
+{
+public:
+       Widget_Brush()
+       {
+               signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Brush::redraw));
+
+               set_size_request(24,24);
+               add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
+               add_events(Gdk::BUTTON1_MOTION_MASK);
+
+               synfigapp::Main::signal_outline_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Brush::queue_draw));
+               synfigapp::Main::signal_fill_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Brush::queue_draw));
+               synfigapp::Main::signal_bline_width_changed().connect(sigc::mem_fun(*this,&studio::Widget_Brush::queue_draw));
+               studio::App::signal_instance_selected().connect(sigc::hide(sigc::mem_fun(*this,&studio::Widget_Brush::queue_draw)));
+       }
+
+       bool
+       redraw(GdkEventExpose */*bleh*/)
+       {
+               Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
+
+               const int h(get_height());
+               const int w(get_width());
+
+               float pixelsize(0);
+               if(App::get_selected_canvas_view())
+               {
+                       const RendDesc& rend_desc(App::get_selected_canvas_view()->get_canvas()->rend_desc());
+                       pixelsize=synfigapp::Main::get_bline_width().get(Distance::SYSTEM_PIXELS,rend_desc);
+               }
+               else
+               {
+                       RendDesc rend_desc;
+                       pixelsize=synfigapp::Main::get_bline_width().get(Distance::SYSTEM_PIXELS,rend_desc);
+               }
+               // Fill in the fill color
+               render_color_to_window(get_window(),Gdk::Rectangle(0,0,w,h),synfigapp::Main::get_fill_color());
+
+/*
+               gc->set_rgb_fg_color(colorconv_synfig2gdk(synfigapp::Main::get_fill_color()));
+               gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+               get_window()->draw_rectangle(
+                       gc,
+                       true,   // Fill?
+                       0,0,    // x,y
+                       w,h     //w,h
+               );
+*/
+
+               // Draw in the circle
+               gc->set_rgb_fg_color(colorconv_synfig2gdk(synfigapp::Main::get_outline_color()));
+               gc->set_function(Gdk::COPY);
+               gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+               get_window()->draw_arc(
+                       gc,
+                       true,
+                       round_to_int(((float)w/2.0f)-pixelsize/2.0f),
+                       round_to_int(((float)h/2.0f)-pixelsize/2.0f),
+                       round_to_int(pixelsize+0.6),
+                       round_to_int(pixelsize+0.6),
+                       0,
+                       360*64
+               );
+
+               return true;
+       }
+
+       bool
+       on_event(GdkEvent *event)
+       {
+//             const int x(static_cast<int>(event->button.x));
+               const int y(static_cast<int>(event->button.y));
+
+               const int h(get_height());
+//             const int w(get_width());
+
+               switch(event->type)
+               {
+                       case GDK_MOTION_NOTIFY:
+                               break;
+                       case GDK_BUTTON_RELEASE:
+                               if(event->button.button==1) // Left click
+                               {
+                                       Distance dist(synfigapp::Main::get_bline_width());
+
+                                       if(y<h/2) // increase BLine size
+                                       {
+                                               dist+=DEFAULT_INCREMENT;
+                                       }
+                                       else // Decrease BLine size
+                                       {
+                                               dist-=DEFAULT_INCREMENT;
+                                       }
+                                       synfigapp::Main::set_bline_width(dist);
+                                       return true;
+                               }
+                               if(event->button.button==3)
+                               {
+                                       // right click on bline width
+                                       synfigapp::Main::set_bline_width(DEFAULT_WIDTH);
+                                       return true;
+                               }
+                               break;
+                       case GDK_SCROLL:
+                               {
+                                       Distance dist(synfigapp::Main::get_bline_width());
+
+                                       switch(event->scroll.direction){
+                                               case GDK_SCROLL_UP:
+                                               case GDK_SCROLL_RIGHT:
+                                                       dist+=DEFAULT_INCREMENT;
+                                               break;
+                                               case GDK_SCROLL_DOWN:
+                                               case GDK_SCROLL_LEFT:
+                                                       dist-=DEFAULT_INCREMENT;
+                                               break;
+                                       }
+                                       synfigapp::Main::set_bline_width(dist);
+                                       return true;
+                               }
+                       default:
+                               break;
+               }
+
+               return false;
+       }
+
+};
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Widget_Defaults::Widget_Defaults()
+{
+       //set_size_request(48,48+GRADIENT_HEIGHT+16);
+       //set_size_request(48,-1);
+
+       {
+               Gtk::Table* subtable(manage(new Gtk::Table()));
+
+               // Outline Color
+               widget_otln_color=manage(new Widget_Color());
+               widget_otln_color->show();
+               widget_otln_color->set_size_request(16,16);
+               widget_otln_color->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Defaults::on_otln_color_clicked));
+               subtable->attach(*widget_otln_color, 0, 4, 0, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+               tooltips_.set_tip(*widget_otln_color,_("Outline Color"));
+
+               // Fill Color
+               widget_fill_color=manage(new Widget_Color());
+               widget_fill_color->show();
+               widget_fill_color->set_size_request(16,16);
+               widget_fill_color->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Defaults::on_fill_color_clicked));
+               subtable->attach(*widget_fill_color, 3, 7, 3, 7, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+               tooltips_.set_tip(*widget_fill_color,_("Fill Color"));
+
+               Gtk::Image* icon;
+
+               // Swap button
+               Gtk::Button* button_swap(manage(new Gtk::Button()));
+               button_swap->show();
+               button_swap->set_relief(Gtk::RELIEF_NONE);
+               button_swap->set_border_width(0);
+               icon=manage(new Gtk::Image(Gtk::StockID("synfig-swap_colors"),Gtk::IconSize(1)));
+               icon->show();
+               button_swap->add(*icon);
+               //button_swap->get_child()->set_size_request(16/3,16/3);
+               //button_swap->set_size_request(16/3,16/3);
+               dynamic_cast<Gtk::Misc*>(button_swap->get_child())->set_padding(0,0);
+               button_swap->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Defaults::on_swap_color_clicked));
+               subtable->attach(*button_swap, 4, 7, 0, 3, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+               tooltips_.set_tip(*button_swap,_("Swap Fill and\nOutline Colors"));
+
+               // Reset button
+               Gtk::Button* button_reset(manage(new Gtk::Button()));
+               button_reset->show();
+               button_reset->set_relief(Gtk::RELIEF_NONE);
+               button_reset->set_border_width(0);
+               icon=manage(new Gtk::Image(Gtk::StockID("synfig-reset_colors"),Gtk::IconSize(1)));
+               icon->show();
+               button_reset->add(*icon);
+               dynamic_cast<Gtk::Misc*>(button_reset->get_child())->set_padding(0,0);
+               //button_reset->set_size_request(16/3,16/3);
+               button_reset->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Defaults::on_reset_color_clicked));
+               subtable->attach(*button_reset, 0, 3, 4, 7, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+               tooltips_.set_tip(*button_reset,_("Reset Colors to Black and White"));
+
+
+               attach(*subtable, 0, 1, 0, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 1, 1);
+               subtable->set_size_request(36,36);
+               subtable->set_homogeneous(true);
+               subtable->show();
+       }
+       widget_brush=manage(new Widget_Brush());
+       widget_brush->show();
+       widget_brush->set_size_request(36,36);
+       attach(*widget_brush,1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 1, 1);
+       tooltips_.set_tip(*widget_brush,_("Brush Preview"));
+
+       widget_bline_width=manage(new Widget_Distance());
+       widget_bline_width->show();
+       bline_width_refresh();
+       widget_bline_width->set_digits(2);
+       widget_bline_width->set_range(0,10000000);
+       widget_bline_width->set_size_request(24,-1);
+       widget_bline_width->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_bline_width_changed));
+       attach(*widget_bline_width,1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       tooltips_.set_tip(*widget_bline_width,_("Brush Size"));
+
+
+       widget_blend_method=manage(new Widget_Enum());
+       widget_blend_method->show();
+       widget_blend_method->signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_blend_method_changed));
+       widget_blend_method->set_param_desc(ParamDesc(Color::BLEND_COMPOSITE,"blend_method"));
+       attach(*widget_blend_method,0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 1, 1);
+       tooltips_.set_tip(*widget_blend_method,_("Default Blend Method"));
+
+       widget_interpolation=manage(new Widget_Enum());
+       widget_interpolation->show();
+       widget_interpolation->signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_interpolation_changed));
+       widget_interpolation->set_param_desc(
+               ParamDesc("interpolation")
+                       .set_hint("enum")
+                       .add_enum_value(INTERPOLATION_TCB,"auto",_("_TCB"))
+                       .add_enum_value(INTERPOLATION_CONSTANT,"constant",_("_Constant"))
+                       .add_enum_value(INTERPOLATION_HALT,"ease",_("_Ease In/Out"))
+                       .add_enum_value(INTERPOLATION_LINEAR,"linear",_("_Linear"))
+       );
+       attach(*widget_interpolation,0, 2, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 1, 1);
+       tooltips_.set_tip(*widget_interpolation,_("Default Interpolation"));
+
+       widget_opacity=manage(new Gtk::HScale(0.0f,1.01f,0.01f));
+       widget_opacity->show();
+       widget_opacity->set_digits(2);
+       widget_opacity->set_value_pos(Gtk::POS_LEFT);
+       widget_opacity->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_opacity_changed));
+       attach(*widget_opacity,0, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 1, 1);
+       tooltips_.set_tip(*widget_opacity,_("Default Opacity"));
+
+       widget_gradient=manage(new Widget_Gradient());
+       widget_gradient->show();
+       widget_gradient->set_size_request(-1,GRADIENT_HEIGHT);
+       widget_gradient->signal_clicked().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_gradient_clicked));
+       attach(*widget_gradient,0, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 1, 1);
+       tooltips_.set_tip(*widget_gradient,_("Default Gradient"));
+
+
+       // Signals
+       synfigapp::Main::signal_opacity_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::opacity_refresh));
+       synfigapp::Main::signal_bline_width_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::bline_width_refresh));
+       synfigapp::Main::signal_outline_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::otln_color_refresh));
+       synfigapp::Main::signal_fill_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::fill_color_refresh));
+       synfigapp::Main::signal_gradient_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::gradient_refresh));
+       synfigapp::Main::signal_blend_method_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::blend_method_refresh));
+       synfigapp::Main::signal_interpolation_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::interpolation_refresh));
+
+       otln_color_refresh();
+       fill_color_refresh();
+       gradient_refresh();
+       blend_method_refresh();
+       opacity_refresh();
+       interpolation_refresh();
+/*
+       set_size_request(48,48+GRADIENT_HEIGHT);
+       signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Defaults::redraw));
+       add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
+       add_events(Gdk::BUTTON1_MOTION_MASK);
+
+       synfigapp::Main::signal_outline_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::queue_draw));
+       synfigapp::Main::signal_fill_color_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::queue_draw));
+       synfigapp::Main::signal_gradient_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::queue_draw));
+       synfigapp::Main::signal_bline_width_changed().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::queue_draw));
+
+       if(App::dialog_gradient)
+       {
+               App::dialog_gradient->set_gradient(synfigapp::Main::get_gradient());
+               App::dialog_gradient->reset();
+               App::dialog_gradient->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_gradient));
+       }
+
+       if(App::dialog_color)
+       {
+               App::dialog_color->set_color(synfigapp::Main::get_outline_color());
+               App::dialog_color->reset();
+               App::dialog_color->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_outline_color));
+       }
+*/
+}
+
+Widget_Defaults::~Widget_Defaults()
+{
+}
+
+void
+Widget_Defaults::otln_color_refresh()
+{
+       widget_otln_color->set_value(synfigapp::Main::get_outline_color());
+}
+
+void
+Widget_Defaults::fill_color_refresh()
+{
+       widget_fill_color->set_value(synfigapp::Main::get_fill_color());
+}
+
+void
+Widget_Defaults::gradient_refresh()
+{
+       widget_gradient->set_value(synfigapp::Main::get_gradient());
+}
+
+void
+Widget_Defaults::bline_width_refresh()
+{
+       widget_bline_width->set_value(synfigapp::Main::get_bline_width());
+}
+
+void
+Widget_Defaults::blend_method_refresh()
+{
+       widget_blend_method->set_value(synfigapp::Main::get_blend_method());
+}
+
+void
+Widget_Defaults::interpolation_refresh()
+{
+       widget_interpolation->set_value(synfigapp::Main::get_interpolation());
+}
+
+void
+Widget_Defaults::opacity_refresh()
+{
+       widget_opacity->set_value(synfigapp::Main::get_opacity());
+}
+
+void
+Widget_Defaults::on_opacity_changed()
+{
+       synfigapp::Main::set_opacity(widget_opacity->get_value());
+}
+
+void
+Widget_Defaults::on_blend_method_changed()
+{
+       synfigapp::Main::set_blend_method(Color::BlendMethod(widget_blend_method->get_value()));
+}
+
+void
+Widget_Defaults::on_interpolation_changed()
+{
+       synfigapp::Main::set_interpolation(Waypoint::Interpolation(widget_interpolation->get_value()));
+}
+
+void
+Widget_Defaults::on_bline_width_changed()
+{
+       synfigapp::Main::set_bline_width(widget_bline_width->get_value());
+}
+
+void
+Widget_Defaults::on_otln_color_clicked()
+{
+       // Left click on outline color
+       App::dialog_color->set_color(synfigapp::Main::get_outline_color());
+       App::dialog_color->reset();
+       App::dialog_color->signal_edited().connect(sigc::ptr_fun(synfigapp::Main::set_outline_color));
+       App::dialog_color->present();
+}
+
+void
+Widget_Defaults::on_fill_color_clicked()
+{
+       // Left click on fill color
+       App::dialog_color->set_color(synfigapp::Main::get_fill_color());
+       App::dialog_color->reset();
+       App::dialog_color->signal_edited().connect(sigc::ptr_fun(synfigapp::Main::set_fill_color));
+       App::dialog_color->present();
+}
+
+void
+Widget_Defaults::on_swap_color_clicked()
+{
+       synfigapp::Main::color_swap();
+}
+
+void
+Widget_Defaults::on_reset_color_clicked()
+{
+       synfigapp::Main::set_fill_color(Color::white());
+       synfigapp::Main::set_outline_color(Color::black());
+}
+
+void
+Widget_Defaults::on_gradient_clicked()
+{
+       App::dialog_gradient->set_gradient(synfigapp::Main::get_gradient());
+       App::dialog_gradient->reset();
+       App::dialog_gradient->signal_edited().connect(sigc::ptr_fun(synfigapp::Main::set_gradient));
+       App::dialog_gradient->set_default_button_set_sensitive(false);
+       App::dialog_gradient->present();
+}
+
+/*
+bool
+Widget_Defaults::redraw(GdkEventExpose*bleh)
+{
+       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
+
+       const int h(get_height());
+       const int w(get_width());
+       const int size=std::min(h-GRADIENT_HEIGHT,w);
+
+       render_color_to_window(get_window(),Gdk::Rectangle(size/4,size/4,size/4*3-1,size/4*3-1),synfigapp::Main::get_fill_color());
+       render_color_to_window(get_window(),Gdk::Rectangle(0,0,size/4*3-1,size/4*3-1),synfigapp::Main::get_outline_color());
+       render_gradient_to_window(get_window(),Gdk::Rectangle(0,h-GRADIENT_HEIGHT,w,GRADIENT_HEIGHT-1),synfigapp::Main::get_gradient());
+
+
+
+
+
+       Glib::RefPtr<Pango::Layout> layout(Pango::Layout::create(get_pango_context()));
+
+       gc->set_rgb_fg_color(Gdk::Color("#FF0000"));
+       layout->set_text(synfigapp::Main::get_bline_width().get_string(2));
+       layout->set_alignment(Pango::ALIGN_CENTER);
+       layout->set_width(w/2);
+       get_window()->draw_layout(gc, w*3/4, (h-GRADIENT_HEIGHT)-16, layout);
+
+       return true;
+}
+
+bool
+Widget_Defaults::on_event(GdkEvent *event)
+{
+       const int x(static_cast<int>(event->button.x));
+       const int y(static_cast<int>(event->button.y));
+
+       const int h(get_height());
+       const int w(get_width());
+       const int size=std::min(h-GRADIENT_HEIGHT,w);
+
+       switch(event->type)
+       {
+       case GDK_MOTION_NOTIFY:
+               break;
+       case GDK_BUTTON_PRESS:
+//                     if(event->button.button==1 && y>get_height()-CONTROL_HEIGHT)
+               break;
+       case GDK_BUTTON_RELEASE:
+               if(event->button.button==1)
+               {
+                       if(y>size)
+                       {
+                               // Left click on gradient
+                               App::dialog_gradient->set_gradient(synfigapp::Main::get_gradient());
+                               App::dialog_gradient->reset();
+                               App::dialog_gradient->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_gradient));
+                               App::dialog_gradient->present();
+                               return true;
+                       }
+                       if(x>0 && x<=size)
+                       {
+                               if(x<size*3/4 && y<size*3/4)
+                               {
+                                       // Left click on outline coloe
+                                       App::dialog_color->set_color(synfigapp::Main::get_outline_color());
+                                       App::dialog_color->reset();
+                                       App::dialog_color->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_outline_color));
+                                       App::dialog_color->present();
+                                       return true;
+                               }
+                               if(x>size*3/4 && y>size/4)
+                               {
+                                       // Left click on fill color
+                                       App::dialog_color->set_color(synfigapp::Main::get_fill_color());
+                                       App::dialog_color->reset();
+                                       App::dialog_color->signal_edited().connect(sigc::mem_fun(synfigapp::Main::set_fill_color));
+                                       App::dialog_color->present();
+                                       return true;
+                               }
+                       }
+                       if(x>size) // Left click on BLine Width
+                       {
+                               Distance dist(synfigapp::Main::get_bline_width());
+
+                               if(y<size/2) // increase BLine size
+                               {
+                                       dist+=DEFAULT_INCREMENT;
+                               }
+                               else // Decrease BLine size
+                               {
+                                       dist-=DEFAULT_INCREMENT;
+                               }
+                               synfigapp::Main::set_bline_width(dist);
+                       }
+               }
+               if(event->button.button==3)
+               {
+                       if(y>size)
+                       {
+                               // right click on gradient
+                               synfigapp::Main::set_gradient_default_colors();
+                               return true;
+                       }
+                       else
+                       {
+                               if(x<size)
+                               {
+                                       // right click on colors
+                                       synfigapp::Main::color_swap();
+                                       return true;
+                               }
+
+                               if(x>w/2)
+                               {
+                                       // right click on bline width
+                                       synfigapp::Main::set_bline_width(DEFAULT_WIDTH);
+                               }
+
+                       }
+               }
+               break;
+       case GDK_SCROLL:
+               {
+                       Distance dist(synfigapp::Main::get_bline_width());
+
+                       if(event->scroll.direction==GDK_SCROLL_UP)
+                       {
+                               dist+=DEFAULT_INCREMENT;
+                       }
+                       else if(event->scroll.direction==GDK_SCROLL_DOWN)
+                       {
+                               dist-=DEFAULT_INCREMENT;
+                       }
+                       synfigapp::Main::set_bline_width(dist);
+               }
+       default:
+               break;
+       }
+
+       return false;
+}
+*/
diff --git a/synfig-studio/src/gui/widget_defaults.h b/synfig-studio/src/gui/widget_defaults.h
new file mode 100644 (file)
index 0000000..705e2da
--- /dev/null
@@ -0,0 +1,99 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_defaults.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_WIDGET_DEFAULTS_H
+#define __SYNFIG_STUDIO_WIDGET_DEFAULTS_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/drawingarea.h>
+#include <gtkmm/table.h>
+#include <synfig/gradient.h>
+#include "widget_gradient.h"
+#include <gtkmm/tooltips.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 Gtk { class HScale; }
+
+namespace studio {
+
+class Widget_Brush;
+class Widget_Color;
+class Widget_Distance;
+class Widget_Enum;
+
+class Widget_Defaults : public Gtk::Table
+{
+       Widget_Brush *widget_brush;
+       Widget_Color *widget_otln_color;
+       Widget_Color *widget_fill_color;
+       Widget_Distance *widget_bline_width;
+       Widget_Gradient *widget_gradient;
+       Widget_Enum     *widget_blend_method;
+       Widget_Enum     *widget_interpolation;
+       Gtk::HScale *widget_opacity;
+
+       void otln_color_refresh();
+       void fill_color_refresh();
+       void gradient_refresh();
+       void bline_width_refresh();
+       void interpolation_refresh();
+
+       void on_bline_width_changed();
+       void on_otln_color_clicked();
+       void on_fill_color_clicked();
+       void on_swap_color_clicked();
+       void on_reset_color_clicked();
+       void on_gradient_clicked();
+       void on_interpolation_changed();
+
+       void blend_method_refresh();
+       void on_blend_method_changed();
+
+       void opacity_refresh();
+       void on_opacity_changed();
+
+       Gtk::Tooltips tooltips_;
+
+public:
+
+       Widget_Defaults();
+
+       ~Widget_Defaults();
+
+//     bool redraw(GdkEventExpose*bleh=NULL);
+
+//     bool on_event(GdkEvent *event);
+}; // END of class BlackLevelSelector
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/widget_distance.cpp b/synfig-studio/src/gui/widget_distance.cpp
new file mode 100644 (file)
index 0000000..050b411
--- /dev/null
@@ -0,0 +1,99 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_distance.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include <gtkmm/entry.h>
+#include <gtkmm/button.h>
+#include "widget_distance.h"
+#include "app.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Widget_Distance::Widget_Distance():
+       Gtk::SpinButton(0.05,5),
+       distance_(1, Distance::SYSTEM_POINTS),
+       adjustment(0,-100000000,100000000,1,1,0)
+{
+       set_adjustment(adjustment);
+       set_numeric(false);
+}
+
+Widget_Distance::~Widget_Distance()
+{
+}
+
+int
+Widget_Distance::on_input(double* new_value)
+{
+       distance_=synfig::String(get_text());
+       *new_value=distance_.get();
+       return 1;
+}
+
+bool
+Widget_Distance::on_output()
+{
+       try{
+       distance_=get_adjustment()->get_value();
+       set_text(distance_.get_string(get_digits()));
+       } catch (...) { /* synfig::error("Widget_Distance::on_output(): Caught something..."); */ }
+       return true;
+}
+
+void
+Widget_Distance::set_value(const synfig::Distance &data)
+{
+       distance_=data;
+       get_adjustment()->set_value(distance_.get());
+}
+
+synfig::Distance
+Widget_Distance::get_value() const
+{
+       distance_=get_adjustment()->get_value();
+       return distance_;
+}
diff --git a/synfig-studio/src/gui/widget_distance.h b/synfig-studio/src/gui/widget_distance.h
new file mode 100644 (file)
index 0000000..3bf625c
--- /dev/null
@@ -0,0 +1,72 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_distance.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_WIDGET_DISTANCE_H
+#define __SYNFIG_STUDIO_WIDGET_DISTANCE_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <sigc++/signal.h>
+#include <sigc++/slot.h>
+#include <gtkmm/spinbutton.h>
+#include <gtkmm/adjustment.h>
+#include <synfig/distance.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 Gtk { class Entry; class Button; };
+
+namespace studio {
+
+class Widget_Distance : public Gtk::SpinButton
+{
+       //sigc::signal<void> signal_value_changed_;
+
+       mutable synfig::Distance distance_;
+
+       Gtk::Adjustment adjustment;
+
+protected:
+
+       int     on_input(double* new_value);
+       bool on_output();
+
+public:
+       //sigc::signal<void> &signal_value_changed() { return signal_value_changed_; }
+
+       void set_value(const synfig::Distance &data);
+       synfig::Distance get_value()const;
+       Widget_Distance();
+       ~Widget_Distance();
+}; // END of class Widget_Distance
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/widget_enum.cpp b/synfig-studio/src/gui/widget_enum.cpp
new file mode 100644 (file)
index 0000000..2a58909
--- /dev/null
@@ -0,0 +1,115 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_enum.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include <gtkmm/menu.h>
+#include "widget_enum.h"
+#include <ETL/stringf>
+#include <synfig/valuenode.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Widget_Enum::Widget_Enum()
+{
+}
+
+Widget_Enum::~Widget_Enum()
+{
+}
+
+void
+Widget_Enum::set_param_desc(const synfig::ParamDesc &x)
+{
+       param_desc=x;
+       //refresh();
+}
+
+void
+Widget_Enum::set_value_(int data)
+{
+       set_value(data);
+       activate();
+}
+
+void
+Widget_Enum::refresh()
+{
+       enum_menu = manage(new class Gtk::Menu());
+
+       std::list<synfig::ParamDesc::EnumData> enum_list=param_desc.get_enum_list();
+       std::list<synfig::ParamDesc::EnumData>::iterator iter;
+
+       String name=strprintf("(%d)",value);
+
+       for(iter=enum_list.begin();iter!=enum_list.end();iter++)
+               if(iter->value!=value)
+                       enum_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(iter->local_name,
+                               sigc::bind(sigc::mem_fun(*this,&Widget_Enum::set_value_),iter->value)
+                       ));
+               else
+                       name=iter->local_name;
+
+       enum_menu->items().push_front(Gtk::Menu_Helpers::MenuElem(name));
+
+       set_menu(*enum_menu);
+}
+
+void
+Widget_Enum::set_value(int data)
+{
+       value=data;
+
+       refresh();
+
+       set_history(0);
+}
+
+int
+Widget_Enum::get_value() const
+{
+       return value;
+}
diff --git a/synfig-studio/src/gui/widget_enum.h b/synfig-studio/src/gui/widget_enum.h
new file mode 100644 (file)
index 0000000..1059d34
--- /dev/null
@@ -0,0 +1,67 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_enum.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_WIDGET_ENUM_H
+#define __SYNFIG_STUDIO_WIDGET_ENUM_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <synfig/layer.h>
+#include <gtkmm/optionmenu.h>
+#include <synfig/paramdesc.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 Gtk { class Menu; };
+
+namespace studio {
+
+class Widget_Enum : public Gtk::OptionMenu
+{
+       Gtk::Menu *enum_menu;
+       synfig::ParamDesc param_desc;
+
+       int value;
+       void set_value_(int data);
+public:
+
+       Widget_Enum();
+       ~Widget_Enum();
+
+       void set_param_desc(const synfig::ParamDesc &x);
+       void refresh();
+
+       void set_value(int data);
+       int get_value() const;
+}; // END of class Widget_Enum
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/widget_filename.cpp b/synfig-studio/src/gui/widget_filename.cpp
new file mode 100644 (file)
index 0000000..1e94ef7
--- /dev/null
@@ -0,0 +1,134 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_filename.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 <config.h>
+#endif
+
+#include <gtkmm/entry.h>
+#include <gtkmm/button.h>
+#include "widget_filename.h"
+#include "app.h"
+#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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Widget_Filename::Widget_Filename()
+{
+       entry_filename=manage(new Gtk::Entry());
+       label_find= manage(new Gtk::Label(_("Find")));
+       button_choose=manage(new Gtk::Button());
+       Pango::AttrList attr_list;
+       {
+               Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*7));
+               pango_size.set_start_index(0);
+               pango_size.set_end_index(64);
+               attr_list.change(pango_size);
+       }
+       label_find->set_attributes(attr_list);
+       label_find->set_ellipsize(Pango::ELLIPSIZE_END);
+       button_choose->add(*label_find);
+
+       pack_start(*entry_filename);
+       pack_start(*button_choose);
+       entry_filename->show();
+       button_choose->show();
+       label_find->show();
+
+       button_choose->signal_clicked().connect(sigc::mem_fun(*this, &studio::Widget_Filename::on_button_choose_pressed));
+       //entry_filename->signal_value_changed().connect(sigc::mem_fun(*this, &studio::Widget_Filename::on_value_changed));
+       entry_filename->signal_activate().connect(sigc::mem_fun(*this, &studio::Widget_Filename::on_value_changed));
+}
+
+Widget_Filename::~Widget_Filename()
+{
+}
+
+void
+Widget_Filename::set_has_frame(bool x)
+{
+       entry_filename->set_has_frame(x);
+}
+
+
+void
+Widget_Filename::set_value(const std::string &data)
+{
+       entry_filename->set_text(data);
+}
+
+string
+Widget_Filename::get_value() const
+{
+       try
+       {
+               return entry_filename->get_text();
+       }
+       catch(...)
+       {
+               throw string("Caught unknown exception");
+       }
+}
+
+void
+Widget_Filename::on_value_changed()
+{
+       signal_value_changed()();
+}
+
+void
+Widget_Filename::on_button_choose_pressed()
+{
+       string filename=entry_filename->get_text();
+       if(filename.empty())
+               filename=".";
+       else
+               filename = etl::absolute_path(
+                       etl::dirname(App::get_selected_canvas_view()->get_canvas()->get_file_name()) +
+                       ETL_DIRECTORY_SEPARATOR +
+                       filename);
+       if(App::dialog_open_file(_("Choose File"), filename, MISC_DIR_PREFERENCE))
+               entry_filename->set_text(filename);
+}
diff --git a/synfig-studio/src/gui/widget_filename.h b/synfig-studio/src/gui/widget_filename.h
new file mode 100644 (file)
index 0000000..69cfb48
--- /dev/null
@@ -0,0 +1,73 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_filename.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_WIDGET_FILENAME_H
+#define __SYNFIG_STUDIO_WIDGET_FILENAME_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <sigc++/signal.h>
+#include <sigc++/slot.h>
+#include <gtkmm/box.h>
+#include <gtkmm/entry.h>
+#include <gtkmm/button.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 Gtk { class Entry; class Button; };
+
+namespace studio {
+
+class Widget_Filename : public Gtk::HBox
+{
+       Gtk::Entry *entry_filename;
+       Gtk::Button *button_choose;
+       Gtk::Label *label_find;
+
+       void on_button_choose_pressed();
+
+       sigc::signal<void> signal_value_changed_;
+
+public:
+       sigc::signal<void> &signal_value_changed() { return signal_value_changed_; }
+       Glib::SignalProxy0<void> signal_activate() { return entry_filename->signal_activate(); }
+
+       void on_value_changed();
+
+       void set_value(const  std::string &data);
+       std::string get_value() const;
+       void set_has_frame(bool x);
+       Widget_Filename();
+       ~Widget_Filename();
+}; // END of class Widget_Filename
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/widget_gradient.cpp b/synfig-studio/src/gui/widget_gradient.cpp
new file mode 100644 (file)
index 0000000..c964599
--- /dev/null
@@ -0,0 +1,370 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_gradient.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \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
+**     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 <config.h>
+#endif
+
+#include "widget_gradient.h"
+#include "app.h"
+#include <gtkmm/menu.h>
+#include <synfig/exception.h>
+#include <ETL/misc>
+
+#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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+void
+studio::render_gradient_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::Gradient &gradient)
+{
+       int     height = ca.get_height();
+       int     width = ca.get_width()-4;
+
+       float sample_width(1.0f/(float)width);
+       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(window));
+       const Color bg1(0.25, 0.25, 0.25);
+       const Color bg2(0.5, 0.5, 0.5);
+       Gdk::Color gdk_c;
+       int i;
+       for(i=0;i<width;i++)
+       {
+               const Color c(gradient(float(i)/float(width),sample_width));
+               const Color c1(Color::blend(c,bg1,1.0).clamped());
+               const Color c2(Color::blend(c,bg2,1.0).clamped());
+               gushort r1(256*App::gamma.r_F32_to_U8(c1.get_r()));
+               gushort g1(256*App::gamma.g_F32_to_U8(c1.get_g()));
+               gushort b1(256*App::gamma.b_F32_to_U8(c1.get_b()));
+               gushort r2(256*App::gamma.r_F32_to_U8(c2.get_r()));
+               gushort g2(256*App::gamma.g_F32_to_U8(c2.get_g()));
+               gushort b2(256*App::gamma.b_F32_to_U8(c2.get_b()));
+
+               if((i*2/height)&1)
+               {
+                       gdk_c.set_rgb(r1,g1,b1);
+                       gc->set_rgb_fg_color(gdk_c);
+                       window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y(), 1, height/2);
+
+                       gdk_c.set_rgb(r2,g2,b2);
+                       gc->set_rgb_fg_color(gdk_c);
+                       window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y()+height/2, 1, height/2);
+               }
+               else
+               {
+                       gdk_c.set_rgb(r2,g2,b2);
+                       gc->set_rgb_fg_color(gdk_c);
+                       window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y(), 1, height/2);
+
+                       gdk_c.set_rgb(r1,g1,b1);
+                       gc->set_rgb_fg_color(gdk_c);
+                       window->draw_rectangle(gc, true, ca.get_x()+i+2, ca.get_y()+height/2, 1, height/2);
+               }
+       }
+       gc->set_rgb_fg_color(Gdk::Color("#ffffff"));
+       window->draw_rectangle(gc, false, ca.get_x()+1, ca.get_y()+1, ca.get_width()-3, height-3);
+       gc->set_rgb_fg_color(Gdk::Color("#000000"));
+       window->draw_rectangle(gc, false, ca.get_x(), ca.get_y(), ca.get_width()-1, height-1);
+}
+
+/* === M E T H O D S ======================================================= */
+
+Widget_Gradient::Widget_Gradient():
+       editable_(false)
+{
+       set_size_request(-1,64);
+       signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Gradient::redraw));
+       add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
+       add_events(Gdk::BUTTON1_MOTION_MASK);
+
+}
+
+Widget_Gradient::~Widget_Gradient()
+{
+}
+
+#define CONTROL_HEIGHT         16
+bool
+Widget_Gradient::redraw(GdkEventExpose */*bleh*/)
+{
+       const int h(get_height());
+       const int w(get_width());
+
+       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
+       Gdk::Rectangle area(0,0,w,h);
+       if(!editable_)
+       {
+               render_gradient_to_window(get_window(),area,gradient_);
+               return true;
+       }
+
+       render_gradient_to_window(get_window(),Gdk::Rectangle(0,0,w,h-CONTROL_HEIGHT),gradient_);
+
+       gc->set_rgb_fg_color(Gdk::Color("#7f7f7f"));
+       get_window()->draw_rectangle(gc, false, 0, h-CONTROL_HEIGHT, w, CONTROL_HEIGHT);
+
+       Gradient::iterator iter,selected_iter;
+       bool show_selected(false);
+       for(iter=gradient_.begin();iter!=gradient_.end();iter++)
+       {
+               if(*iter!=selected_cpoint)
+               get_style()->paint_arrow(
+                       get_window(),
+                       (*iter==selected_cpoint)?Gtk::STATE_SELECTED:Gtk::STATE_ACTIVE,
+                       Gtk::SHADOW_OUT,
+                       area,
+                       *this,
+                       " ",
+                       Gtk::ARROW_UP,
+                       1,
+                       int(iter->pos*w)-CONTROL_HEIGHT/2+1,
+                       h-CONTROL_HEIGHT,
+                       CONTROL_HEIGHT,
+                       CONTROL_HEIGHT
+               );
+               else
+               {
+                       selected_iter=iter;
+                       show_selected=true;
+               }
+       }
+
+       // we do this so that we can be sure that
+       // the selected marker is shown on top
+       if(show_selected)
+       {
+               get_style()->paint_arrow(
+                       get_window(),
+                       Gtk::STATE_SELECTED,
+                       Gtk::SHADOW_OUT,
+                       area,
+                       *this,
+                       " ",
+                       Gtk::ARROW_UP,
+                       1,
+                       round_to_int(selected_iter->pos*w)-CONTROL_HEIGHT/2+1,
+                       h-CONTROL_HEIGHT,
+                       CONTROL_HEIGHT,
+                       CONTROL_HEIGHT
+               );
+       }
+
+       return true;
+}
+
+void
+Widget_Gradient::insert_cpoint(float x)
+{
+       Gradient::CPoint new_cpoint;
+       new_cpoint.pos=x;
+       new_cpoint.color=gradient_(x);
+       gradient_.push_back(new_cpoint);
+       gradient_.sort();
+       gradient_.sort();
+       set_selected_cpoint(new_cpoint);
+       queue_draw();
+}
+
+void
+Widget_Gradient::remove_cpoint(float x)
+{
+       gradient_.erase(gradient_.proximity(x));
+       signal_value_changed_();
+       queue_draw();
+}
+
+void
+Widget_Gradient::popup_menu(float x)
+{
+       Gtk::Menu* menu(manage(new Gtk::Menu()));
+       menu->signal_hide().connect(sigc::bind(sigc::ptr_fun(&delete_widget), menu));
+
+       menu->items().clear();
+
+       menu->items().push_back(
+               Gtk::Menu_Helpers::MenuElem(
+                       _("Insert CPoint"),
+                       sigc::bind(
+                               sigc::mem_fun(*this,&studio::Widget_Gradient::insert_cpoint),
+                               x
+                       )
+               )
+       );
+
+       if(!gradient_.empty())
+       {
+               menu->items().push_back(
+                       Gtk::Menu_Helpers::MenuElem(
+                               _("Remove CPoint"),
+                               sigc::bind(
+                                       sigc::mem_fun(*this,&studio::Widget_Gradient::remove_cpoint),
+                                       x
+                               )
+                       )
+               );
+       }
+
+       menu->popup(0,0);
+}
+
+void
+Widget_Gradient::set_value(const synfig::Gradient& x)
+{
+       gradient_=x;
+       if(gradient_.size())
+               set_selected_cpoint(*gradient_.proximity(0.0f));
+       queue_draw();
+}
+
+void
+Widget_Gradient::set_selected_cpoint(const synfig::Gradient::CPoint &x)
+{
+       selected_cpoint=x;
+       signal_cpoint_selected_(selected_cpoint);
+       queue_draw();
+}
+
+void
+Widget_Gradient::update_cpoint(const synfig::Gradient::CPoint &x)
+{
+       try
+       {
+               Gradient::iterator iter(gradient_.find(x));
+               iter->pos=x.pos;
+               iter->color=x.color;
+               gradient_.sort();
+               queue_draw();
+       }
+       catch(synfig::Exception::NotFound)
+       {
+               // Yotta...
+       }
+}
+
+bool
+Widget_Gradient::on_event(GdkEvent *event)
+{
+       //if(editable_)
+       {
+               const int x(static_cast<int>(event->button.x));
+               const int y(static_cast<int>(event->button.y));
+
+               float pos((float)x/(float)get_width());
+               if(pos<0.0f)pos=0.0f;
+               if(pos>1.0f)pos=1.0f;
+
+               switch(event->type)
+               {
+               case GDK_MOTION_NOTIFY:
+                       if(editable_ && y>get_height()-CONTROL_HEIGHT)
+                       {
+                               if(!gradient_.size()) return true;
+                               Gradient::iterator iter(gradient_.find(selected_cpoint));
+                               //! Use SHIFT to stack two CPoints together.
+                               if(event->button.state&GDK_SHIFT_MASK)
+                               {
+                                       float begin(-100000000),end(100000000);
+                                       Gradient::iterator before(iter),after(iter);
+                                       after++;
+                                       if(iter!=gradient_.begin())
+                                       {
+                                               before--;
+                                               begin=before->pos;
+                                       }
+                                       if(after!=gradient_.end())
+                                       {
+                                               end=after->pos;
+                                       }
+
+                                       if(pos>end)
+                                               pos=end;
+                                       if(pos<begin)
+                                               pos=begin;
+
+                                       iter->pos=pos;
+                               }
+                               else
+                               {
+                                       iter->pos=pos;
+                                       gradient_.sort();
+                               }
+
+//                             signal_value_changed_();
+                               changed_=true;
+                               queue_draw();
+                               return true;
+                       }
+                       break;
+               case GDK_BUTTON_PRESS:
+                       changed_=false;
+                       if(event->button.button==1)
+                       {
+                               if(editable_ && y>get_height()-CONTROL_HEIGHT)
+                               {
+                                       set_selected_cpoint(*gradient_.proximity(pos));
+                                       queue_draw();
+                                       return true;
+                               }
+                               else
+                               {
+                                       signal_clicked_();
+                                       return true;
+                               }
+                       }
+                       else if(editable_ && event->button.button==3)
+                       {
+                               popup_menu(pos);
+                               return true;
+                       }
+                       break;
+               case GDK_BUTTON_RELEASE:
+                       if(editable_ && event->button.button==1 && y>get_height()-CONTROL_HEIGHT)
+                       {
+                               set_selected_cpoint(*gradient_.proximity(pos));
+                               if(changed_)signal_value_changed_();
+                               return true;
+                       }
+               default:
+                       break;
+               }
+       }
+
+       return false;
+}
diff --git a/synfig-studio/src/gui/widget_gradient.h b/synfig-studio/src/gui/widget_gradient.h
new file mode 100644 (file)
index 0000000..5f5bc73
--- /dev/null
@@ -0,0 +1,102 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_gradient.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_WIDGET_GRADIENT_H
+#define __SYNFIG_STUDIO_WIDGET_GRADIENT_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/drawingarea.h>
+#include <synfig/gradient.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 {
+
+void render_gradient_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::Gradient &gradient);
+
+class Widget_Gradient : public Gtk::DrawingArea
+{
+       sigc::signal<void> signal_value_changed_;
+       sigc::signal<void> signal_clicked_;
+
+       sigc::signal<void,synfig::Gradient::CPoint> signal_cpoint_selected_;
+
+       synfig::Gradient gradient_;
+
+       bool editable_;
+
+       bool changed_;
+
+       synfig::Gradient::CPoint        selected_cpoint;
+
+       void popup_menu(float x);
+
+       void insert_cpoint(float x);
+
+       void remove_cpoint(float x);
+
+public:
+
+       Widget_Gradient();
+
+       ~Widget_Gradient();
+
+       sigc::signal<void>& signal_value_changed() { return signal_value_changed_; }
+       sigc::signal<void>& signal_clicked() { return signal_clicked_; }
+
+       sigc::signal<void,synfig::Gradient::CPoint>& signal_cpoint_selected() { return signal_cpoint_selected_; }
+
+       void set_value(const synfig::Gradient& x);
+
+       const synfig::Gradient& get_value()const { return gradient_; }
+
+       void set_editable(bool x=true) { editable_=x; }
+
+       bool get_editable()const { return editable_; }
+
+
+
+       void set_selected_cpoint(const synfig::Gradient::CPoint &x);
+
+       const synfig::Gradient::CPoint& get_selected_cpoint() { return selected_cpoint; }
+
+       void update_cpoint(const synfig::Gradient::CPoint &x);
+
+
+
+       bool redraw(GdkEventExpose*bleh=NULL);
+
+       bool on_event(GdkEvent *event);
+}; // END of class BlackLevelSelector
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/widget_keyframe_list.cpp b/synfig-studio/src/gui/widget_keyframe_list.cpp
new file mode 100644 (file)
index 0000000..9af70bf
--- /dev/null
@@ -0,0 +1,425 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_keyframe_list.cpp
+**     \brief A custom widget to manage keyframes in the timeline.
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007 Chris Moore
+**     Copyright (c) 2009 Carlos López
+**
+**     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 <config.h>
+#endif
+
+#include "widget_keyframe_list.h"
+#include "app.h"
+#include <gtkmm/menu.h>
+#include <synfig/exception.h>
+#include <ETL/misc>
+
+#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 ========================================================= */
+#define WIDGET_KEYFRAME_LIST_DEFAULT_FPS 24.0
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Widget_Keyframe_List::Widget_Keyframe_List():
+       adj_default(0,0,2,1/WIDGET_KEYFRAME_LIST_DEFAULT_FPS,10/WIDGET_KEYFRAME_LIST_DEFAULT_FPS),
+       kf_list_(&default_kf_list_),
+       time_ratio("4f", WIDGET_KEYFRAME_LIST_DEFAULT_FPS)
+{
+       adj_timescale=0;
+       editable_=true;
+       fps=WIDGET_KEYFRAME_LIST_DEFAULT_FPS;
+       set_size_request(-1,64);
+       //!This signal is called when the widget need to be redrawn
+       signal_expose_event().connect(sigc::mem_fun(*this, &studio::Widget_Keyframe_List::redraw));
+       //! The widget respond to mouse button press and release and to
+       //! left button motion
+       add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
+       add_events(Gdk::BUTTON1_MOTION_MASK /*| Gdk::BUTTON3_MOTION_MASK*/);
+       add_events(Gdk::POINTER_MOTION_MASK);
+       set_time_adjustment(&adj_default);
+       queue_draw();
+}
+
+Widget_Keyframe_List::~Widget_Keyframe_List()
+{
+}
+
+bool
+Widget_Keyframe_List::redraw(GdkEventExpose */*bleh*/)
+{
+
+       const int h(get_height());
+       const int w(get_width());
+
+       //!Boundaries of the drawing area in time units.
+       synfig::Time top(adj_timescale->get_upper());
+       synfig::Time bottom(adj_timescale->get_lower());
+
+       //! The graphic context
+       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
+       //! A rectangle that defines the drawing area.
+       Gdk::Rectangle area(0,0,w,h);
+
+       //! draw a background
+       gc->set_rgb_fg_color(Gdk::Color("#9d9d9d"));
+       get_window()->draw_rectangle(gc, true, 0, 0, w, h);
+
+       if(!editable_)
+       {
+               return true; //needs fixing!
+       }
+       //!Returns if there are not keyframes to draw.
+       if (kf_list_->empty()) return false;
+
+       //!Loop all the keyframes
+       synfig::KeyframeList::iterator iter,selected_iter;
+       bool show_selected(false);
+       for(iter=kf_list_->begin();iter!=kf_list_->end();iter++)
+       {
+               //!do not draw keyframes out of the widget boundaries
+               if (iter->get_time()>top || iter->get_time()<bottom)
+                       continue;
+               //! If the keyframe is not the selected one
+               if(*iter!=selected_kf)
+               {
+                       const int x((int)((float)(iter->get_time()-bottom) * (w/(top-bottom)) ) );
+                       get_style()->paint_arrow(get_window(), Gtk::STATE_NORMAL,
+                       Gtk::SHADOW_OUT, area, *this, " ", Gtk::ARROW_DOWN, 1,
+                       x-h/2+1, 0, h, h );
+               }
+               else
+               {
+                       selected_iter=iter;
+                       show_selected=true;
+               }
+       }
+
+       // we do this so that we can be sure that
+       // the selected keyframe is shown on top
+       if(show_selected)
+       {
+               // If not dragging just show the selected keyframe
+               if (!dragging_)
+               {
+                       int x((int)((float)(selected_iter->get_time()-bottom) * (w/(top-bottom)) ) );
+                       get_style()->paint_arrow(get_window(), Gtk::STATE_SELECTED,
+                       Gtk::SHADOW_OUT, area, *this, " ", Gtk::ARROW_DOWN, 1,
+                       x-h/2+1, 0, h, h );
+               }
+               // If dragging then show the selected as insensitive and the
+               // dragged as selected
+               else
+               {
+                       int x((int)((float)(selected_iter->get_time()-bottom) * (w/(top-bottom)) ) );
+                       get_style()->paint_arrow(get_window(), Gtk::STATE_INSENSITIVE,
+                       Gtk::SHADOW_OUT, area, *this, " ", Gtk::ARROW_DOWN, 1,
+                       x-h/2, 0, h, h );
+                       x=(int)((float)(dragging_kf_time-bottom) * (w/(top-bottom)) ) ;
+                       get_style()->paint_arrow(get_window(), Gtk::STATE_SELECTED,
+                       Gtk::SHADOW_OUT, area, *this, " ", Gtk::ARROW_DOWN, 1,
+                       x-h/2+1, 0, h, h );
+               }
+       }
+       return true;
+}
+
+
+void
+Widget_Keyframe_List::set_kf_list(synfig::KeyframeList* x)
+{
+       kf_list_=x;
+       set_selected_keyframe(selected_none);
+       selected_=false;
+       dragging_=false;
+}
+
+void
+Widget_Keyframe_List::set_selected_keyframe(const synfig::Keyframe &x)
+{
+       selected_kf=x;
+       selected_=true;
+       dragging_kf_time=selected_kf.get_time();
+       //signal_keyframe_selected_(selected_kf);
+       dragging_=false;
+       queue_draw();
+}
+
+bool
+Widget_Keyframe_List::perform_move_kf(bool delta=false)
+{
+       if(!selected_)
+               return false;
+       if(dragging_kf_time == selected_kf.get_time())
+               return false; // change this checking if not sticked to integer frames
+       Time selected_kf_time(selected_kf.get_time());
+       Time prev, next;
+       kf_list_->find_prev_next(selected_kf_time, prev, next);
+       // Not possible to set delta to the first keyframe
+       // perform normal movement
+       // As suggested by Zelgadis it is better to not perform anything.
+       if (prev==Time::begin() && delta==true)
+       {
+               synfig::info(_("Not possible to ALT-drag the first keyframe"));
+               return false;
+       }
+       if(!delta)
+               {
+                       synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeSet"));
+                       if(!action)
+                       return false;
+                       selected_kf.set_time(dragging_kf_time);
+                       action->set_param("canvas",canvas_interface_->get_canvas());
+                       action->set_param("canvas_interface",canvas_interface_);
+                       action->set_param("keyframe",selected_kf);
+                       try
+                       {
+                               canvas_interface_->get_instance()->perform_action(action);
+                       }
+                       catch(...)
+                       {
+                               return false;
+                       }
+               }
+       else
+               {
+                       Keyframe prev_kf(*kf_list_->find_prev(selected_kf_time));
+                       Time prev_kf_time(prev_kf.get_time());
+                       if (prev_kf_time >= dragging_kf_time) //Not allowed
+                       {
+                               synfig::warning(_("Delta set not allowed"));
+                               synfig::info("Widget_Keyframe_List::perform_move_kf(%i)::prev_kf_time=%s", delta, prev_kf_time.get_string().c_str());
+                               synfig::info("Widget_Keyframe_List::perform_move_kf(%i)::dragging_kf_time=%s", delta, dragging_kf_time.get_string().c_str());
+                               return false;
+                       }
+                       else
+                       {
+                               Time old_delta_time(selected_kf_time-prev_kf_time);
+                               Time new_delta_time(dragging_kf_time-prev_kf_time);
+                               Time change_delta(new_delta_time-old_delta_time);
+                               synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeSetDelta"));
+                               if(!action)
+                                       return false;
+                               action->set_param("canvas",canvas_interface_->get_canvas());
+                               action->set_param("canvas_interface",canvas_interface_);
+                               action->set_param("keyframe",prev_kf);
+                               action->set_param("delta",change_delta);
+                               canvas_interface_->get_instance()->perform_action(action);
+                       }
+               }
+       queue_draw();
+       return true;
+}
+
+bool
+Widget_Keyframe_List::on_event(GdkEvent *event)
+{
+       const int x(static_cast<int>(event->button.x));
+       //const int y(static_cast<int>(event->button.y));
+       //!Boundaries of the drawing area in time units.
+       synfig::Time top(adj_timescale->get_upper());
+       synfig::Time bottom(adj_timescale->get_lower());
+       //!pos is the [0,1] relative horizontal place on the widget
+       float pos((float)x/(get_width()));
+       if(pos<0.0f)pos=0.0f;
+       if(pos>1.0f)pos=1.0f;
+       //! The time where the event x is
+       synfig::Time t((float)(bottom+pos*(top-bottom)));
+       //Do not respond mouse events if the list is empty
+       if(!kf_list_->size())
+               return true;
+
+       //! here the guts of the event
+       switch(event->type)
+       {
+       case GDK_MOTION_NOTIFY:
+               if(editable_)
+               {
+                       // here is captured mouse motion
+                       // AND left or right mouse button pressed
+                       if (event->motion.state & (GDK_BUTTON1_MASK /*| GDK_BUTTON3_MASK*/))
+                       {
+                               // stick to integer frames. It can be optional in the future
+                               if(fps) t = floor(t*fps + 0.5)/fps;
+                               dragging_kf_time=t;
+                               dragging_=true;
+                               queue_draw();
+                               return true;
+                       }
+                       // here is captured mouse motion
+                       // AND NOT left or right mouse button pressed
+                       else
+                       {
+                               Glib::ustring ttip="";
+                               synfig::Time p_t,n_t;
+                               kf_list_->find_prev_next(t, p_t, n_t);
+                               if( (p_t==Time::begin()         &&      n_t==Time::end())
+                               ||
+                               ((t-p_t)>time_ratio     && (n_t-t)>time_ratio)
+                               )
+                               {
+                                       ttip = _("Click and drag keyframes");
+                               }
+                               else if ((t-p_t)<(n_t-t))
+                               {
+                                       synfig::Keyframe kf(*kf_list_->find_prev(t));
+                                       synfig::String kf_name(kf.get_description().c_str());
+                                       ttip = kf_name.c_str();
+                               }
+                               else
+                               {
+                                       synfig::Keyframe kf(*kf_list_->find_next(t));
+                                       synfig::String kf_name(kf.get_description().c_str());
+                                       ttip = kf_name.c_str();
+                               }
+                               tooltips.set_tip(*this, ttip);
+                               dragging_=false;
+                               queue_draw();
+                               return true;
+                       }
+               }
+               break;
+       case GDK_BUTTON_PRESS:
+               changed_=false;
+               dragging_=false;
+               if(event->button.button==1 /*|| event->button.button==3*/)
+               {
+                       if(editable_)
+                       {
+                               synfig::Time prev_t,next_t;
+                               kf_list_->find_prev_next(t, prev_t, next_t);
+                               if( (prev_t==Time::begin()      &&      next_t==Time::end())
+                               ||
+                               ((t-prev_t)>time_ratio  && (next_t-t)>time_ratio)
+                               )
+                               {
+                                       set_selected_keyframe(selected_none);
+                                       selected_=false;
+                                       queue_draw();
+                               }
+                               else if ((t-prev_t)<(next_t-t))
+                               {
+                                       set_selected_keyframe(*(kf_list_->find_prev(t)));
+                                       queue_draw();
+                                       selected_=true;
+                               }
+                               else
+                               {
+                                       set_selected_keyframe(*(kf_list_->find_next(t)));
+                                       queue_draw();
+                                       selected_=true;
+                               }
+                               return true;
+                       }
+                       else
+                       {
+                               return false;
+                       }
+               }
+
+               break;
+       case GDK_BUTTON_RELEASE:
+               if(editable_ && (event->button.button==1 /*|| event->button.button==3*/))
+               {
+                       // stick to integer frames.
+                       if(fps) t = floor(t*fps + 0.5)/fps;
+                       bool stat=false;
+                       if(dragging_)
+                               {
+                                       //if (event->button.button==3)
+                                       if(event->button.state & GDK_MOD1_MASK)
+                                       {
+                                               stat=perform_move_kf(true);
+                                       }
+                                       else
+                                       {
+                                               stat=perform_move_kf(false);
+                                       }
+                               }
+                       dragging_=false;
+                       return stat;
+               }
+               break;
+       default:
+               break;
+       }
+       return false;
+}
+
+
+void Widget_Keyframe_List::set_time_adjustment(Gtk::Adjustment *x)
+{
+       //disconnect old connections
+       time_value_change.disconnect();
+       time_other_change.disconnect();
+
+       //connect update function to new adjustment
+       adj_timescale = x;
+
+       if(x)
+       {
+               time_value_change = x->signal_value_changed().connect(sigc::mem_fun(*this,&Widget_Keyframe_List::queue_draw));
+               time_other_change = x->signal_changed().connect(sigc::mem_fun(*this,&Widget_Keyframe_List::queue_draw));
+       }
+}
+
+void
+Widget_Keyframe_List::set_fps(float d)
+{
+       if(fps != d)
+       {
+               fps = d;
+               //update everything since we need to redraw already
+               queue_draw();
+       }
+}
+
+void
+Widget_Keyframe_List::set_canvas_interface(etl::loose_handle<synfigapp::CanvasInterface> h)
+{
+       canvas_interface_=h;
+       // Store the values used fomr the canvas interface.
+       if (canvas_interface_)
+       {
+               set_fps(canvas_interface_->get_canvas()->rend_desc().get_frame_rate());
+               set_kf_list(&canvas_interface_->get_canvas()->keyframe_list());
+       }
+}
+
+
diff --git a/synfig-studio/src/gui/widget_keyframe_list.h b/synfig-studio/src/gui/widget_keyframe_list.h
new file mode 100644 (file)
index 0000000..1e41770
--- /dev/null
@@ -0,0 +1,150 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_keyframe_list.h
+**     \brief A custom widget to manage keyframes in the timeline.
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2009 Carlos López
+**
+**     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_WIDGET_KEYFRAME_LIST_H
+#define __SYNFIG_STUDIO_WIDGET_KEYFRAME_LIST_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/drawingarea.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/tooltips.h>
+#include <synfig/keyframe.h>
+#include <sigc++/connection.h>
+#include <synfigapp/canvasinterface.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 Widget_Keyframe_List : public Gtk::DrawingArea
+{
+       //! Tooltips class. It is deprecated since gtkmm 2.12
+       //! replace with Tooltip class or use the own tooltip widget's members
+       Gtk::Tooltips tooltips;
+
+       //! The canvas interface being watched
+       etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_;
+
+       //! Time adjustment window
+       Gtk::Adjustment adj_default;
+       Gtk::Adjustment *adj_timescale;
+
+       //!The list of keyframes to be drawn on the widget and moved with mouse
+       synfig::KeyframeList default_kf_list_;
+       mutable synfig::KeyframeList* kf_list_;
+
+       //! The frames per second of the canvas
+       float fps;
+
+       //! Time radius to click a keyframe
+       synfig::Time time_ratio;
+
+       //!True if it is editable. Keyframes can be moved.
+       bool editable_;
+
+       //!True if a keyframe is being dragged.
+       bool dragging_;
+
+       //!True if a keyframe has been moved
+       bool changed_;
+
+       //!Holds the selected keyframe of the keyframe list
+       synfig::Keyframe selected_kf;
+       synfig::Keyframe selected_none;
+       bool selected_;
+
+       //!The time of the selected keyframe
+       synfig::Time selected_kf_time;
+
+       //!The time of the selected keyframe during draging
+       synfig::Time dragging_kf_time;
+
+       //!Connectors for handling the signals of the time adjustment
+       sigc::connection time_value_change;
+       sigc::connection time_other_change;
+
+public:
+
+       //!Default constructor
+       Widget_Keyframe_List();
+
+       //!Destructror
+       ~Widget_Keyframe_List();
+
+       //!Loads a new keyframe list on the widget.
+       void set_kf_list(synfig::KeyframeList* x);
+
+       //!Member for private data.
+       synfig::KeyframeList* get_kf_list()const { return kf_list_; }
+
+       //!Member for private data
+       void set_editable(bool x=true) { editable_=x; }
+
+       //!Member for private data
+       bool get_editable()const { return editable_; }
+
+
+       //!Store the selected keyframe value
+       void set_selected_keyframe(const synfig::Keyframe &x);
+
+       //!Returns the selected keyframe
+       const synfig::Keyframe& get_selected_keyframe() { return selected_kf; }
+
+       //! Set the time adjustment and proper connects its change signals
+       void set_time_adjustment(Gtk::Adjustment *x);
+
+       //! Set the fps
+       void set_fps(float x);
+
+       //! Set the canvas interface
+       void set_canvas_interface(etl::loose_handle<synfigapp::CanvasInterface> h);
+
+       //! Performs the keyframe movement. Returns true if it was sucessful
+       //! @return true: if success otherwise false
+       //! |delta=false: permorm normal move. true: perform delta movement
+       bool perform_move_kf(bool delta);
+
+
+
+/* ======================= EVENTS HANDLERS ===========================*/
+       //!Redraw event. Should draw all the keyframes +  the selected + the dragged
+       bool redraw(GdkEventExpose*bleh=NULL);
+
+       //!Mouse event handler.
+       bool on_event(GdkEvent *event);
+}; // END of class Keyframe_List
+
+}; // END of namespace studio
+
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/widget_sound.cpp b/synfig-studio/src/gui/widget_sound.cpp
new file mode 100644 (file)
index 0000000..3d43731
--- /dev/null
@@ -0,0 +1,323 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_sound.cpp
+**     \brief Widget Sound Implementation File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include <gtkmm/adjustment.h>
+
+#include <synfig/general.h>
+#include <ETL/clock>
+
+#include "widget_sound.h"
+#include "audiocontainer.h"
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+//using namespace synfig;
+
+using studio::AudioProfile;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+/* === E N T R Y P O I N T ================================================= */
+
+studio::Widget_Sound::Widget_Sound()
+{
+}
+
+studio::Widget_Sound::~Widget_Sound()
+{
+}
+
+void studio::Widget_Sound::set_position(double t)
+{
+       //synfig::info("Setting position to %.2lf s", t);
+       if(adj_timescale && t != adj_timescale->get_value())
+       {
+               float upper = adj_timescale->get_upper();
+               float lower = adj_timescale->get_lower();
+               float framesize =  upper - lower;
+
+               if(t < lower)
+               {
+                       lower -= ceil((lower-t)/framesize)*framesize;
+                       upper = lower + framesize;
+                       adj_timescale->set_lower(lower); adj_timescale->set_upper(upper);
+                       adj_timescale->set_value(t);
+                       adj_timescale->changed(); adj_timescale->value_changed();
+               }else
+               if(t > upper)
+               {
+                       lower += ceil((t-upper)/framesize)*framesize;
+                       upper = lower + framesize;
+                       adj_timescale->set_lower(lower); adj_timescale->set_upper(upper);
+                       adj_timescale->set_value(t);
+                       adj_timescale->changed(); adj_timescale->value_changed();
+               }else
+               {
+                       adj_timescale->set_value(t);
+                       adj_timescale->value_changed();
+               }
+       }
+}
+
+double studio::Widget_Sound::get_position() const
+{
+       if(adj_timescale)
+       {
+               return adj_timescale->get_value();
+       }
+       return 0;
+}
+
+bool studio::Widget_Sound::set_profile(etl::handle<AudioProfile>       p)
+{
+       clear();
+
+       //set the profile
+       audioprof = p;
+
+       if(!audioprof)
+       {
+               clear();
+               return false;
+       }
+
+       return true;
+}
+
+etl::handle<AudioProfile>      studio::Widget_Sound::get_profile() const
+{
+       return audioprof;
+}
+
+void studio::Widget_Sound::clear()
+{
+       audioprof.detach();
+}
+
+void studio::Widget_Sound::draw()
+{
+       on_expose_event();
+}
+
+bool studio::Widget_Sound::on_expose_event(GdkEventExpose */*heh*/)
+{
+       if(!get_window()) return false;
+
+       //clear the background to dark grey
+       Glib::RefPtr<Gdk::GC>   gc = Gdk::GC::create(get_window());
+
+       if(!gc) return false;
+
+       {
+               Gdk::Rectangle r(0,0,get_width(),get_height());
+               get_window()->begin_paint_rect(r);
+       }
+       Gdk::Color      c("#3f3f3f");
+       gc->set_rgb_fg_color(c);
+       gc->set_background(c);
+
+       int w = get_width();
+       int baseline = get_height()/2;
+       get_window()->draw_rectangle(gc,true,0,0,w,get_height());
+
+       //set up the color to be blue
+       c.set_rgb_p(0,0.5,1);
+       gc->set_rgb_fg_color(c);
+
+       //draw the base line
+       get_window()->draw_line(gc,0,baseline,w,baseline);
+
+       //redraw all the samples from begin to end, but only if we have samples to draw (or there is no space to draw)
+
+       //synfig::warning("Ok rendered everything, now must render actual sound wave");
+       if(!audioprof || !adj_timescale || !w)
+       {
+               get_window()->end_paint();
+               return true;
+       }
+
+       //draw you fool!
+       float framesize = adj_timescale->get_upper() - adj_timescale->get_lower();
+       if(framesize)
+       {
+               float delta=0,cum=0;
+
+               //position in sample space
+               int begin=0,end=0;
+               int     cur=0,maxs=0,mins=0;
+
+               int       i=0; //pixel counter
+
+               //etl::clock    check; check.reset();
+
+               float position = adj_timescale->get_value();
+               float samplerate = audioprof->get_samplerate();
+               int             posi = 0;
+               //enforce position inside of frame size
+               {
+                       float offset = audioprof->get_offset();
+
+                       //clamp begin and end to framesize
+                       float beginf = adj_timescale->get_lower();
+                       float endf = adj_timescale->get_upper();
+
+                       posi = round_to_int((position-beginf)*w/framesize);
+                       //posi = (int)((position-beginf)*w/framesize);
+
+                       //calculate in sample space from seconds
+                       begin = round_to_int((beginf - offset)*samplerate);
+                       end = round_to_int((endf - offset)*samplerate);
+                       //begin = (int)((beginf - offset)*samplerate);
+                       //end = (int)((endf - offset)*samplerate);
+               }
+
+               delta = (end - begin)/(float)w; //samples per pixel
+
+               /*synfig::warning("Rendering a framesize of %f secs from [%d,%d) samples to %d samples, took %f sec",
+                                               framesize, begin, end, w, check());*/
+
+               cur = begin;
+               i = 0; cum = 0;
+               for(int i=0;i<w;++i)
+               {
+                       //get the maximum of the collected samples
+                       maxs = 0;
+                       mins = 0;
+                       for(;cum < delta; ++cum, ++cur)
+                       {
+                               maxs = std::max(maxs,(int)(*audioprof)[cur]);
+                               mins = std::min(mins,(int)(*audioprof)[cur]);
+                       }
+                       cum -= delta;
+
+                       //draw spike if not needed be
+                       if(maxs||mins)
+                       {
+                               int top = maxs * baseline / 64;
+                               int bot = mins * baseline / 64;
+
+                               get_window()->draw_line(gc,i,baseline+bot,i,baseline+top);
+                       }
+               }
+
+               //synfig::warning("Drawing audio line");
+               c.set_rgb_p(1,0,0);
+               gc->set_rgb_fg_color(c);
+               get_window()->draw_line(gc,posi,0,posi,get_height());
+       }
+       get_window()->end_paint();
+
+       return true;
+}
+
+//--- Handle the single clicking and dragging for scrubbing
+
+bool studio::Widget_Sound::on_motion_notify_event(GdkEventMotion* event)
+{
+       Gdk::ModifierType       mod = Gdk::ModifierType(event->state);
+
+       //if we are scrubbing
+       if(mod & Gdk::BUTTON1_MASK)
+       {
+               //Can't do this if we don't have a time frame (heheh...)
+               if(!adj_timescale) return false;
+
+               double beg = adj_timescale->get_lower(), end = adj_timescale->get_upper();
+
+               //find event position in time
+               double t = beg + event->x * (end-beg) / get_width();
+
+               //signal that we are scrubbing to this new value...
+               signal_scrub()(t);
+
+
+               // We should be able to just call
+               // Widget_Timeslider::on_motion_notify_event(),
+               // but that seems to cause the program to halt
+               // for some reason. So for now, let's do the job ourselves
+               //adj_timescale->set_value(t);
+               //adj_timescale->changed();
+               //return true;
+       }
+
+       return Widget_Timeslider::on_motion_notify_event(event);
+}
+
+bool studio::Widget_Sound::on_button_press_event(GdkEventButton *event)
+{
+       //Assume button PRESS
+
+       //if we are starting... using left click
+       if(event->button == 1)
+       {
+               if(!adj_timescale) return false;
+
+               double beg = adj_timescale->get_lower(), end = adj_timescale->get_upper();
+
+               //find event position in time
+               double t = beg + event->x * (end-beg) / get_width();
+
+               //signal the attached scrubbing devices...
+               signal_start_scrubbing()(t);
+
+               return true;
+       }
+
+       return Widget_Timeslider::on_button_press_event(event);
+}
+
+bool studio::Widget_Sound::on_button_release_event(GdkEventButton *event)
+{
+       //Assume button RELEASE
+
+       //if we are ending... using left click
+       if(event->button == 1)
+       {
+               //signal the scrubbing device... to stop
+               signal_stop_scrubbing()();
+
+               return true;
+       }
+
+       return Widget_Timeslider::on_button_release_event(event);
+}
diff --git a/synfig-studio/src/gui/widget_sound.h b/synfig-studio/src/gui/widget_sound.h
new file mode 100644 (file)
index 0000000..0db129d
--- /dev/null
@@ -0,0 +1,99 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_sound.h
+**     \brief Widget Sound 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_WIDGET_SOUND_H
+#define __SYNFIG_WIDGET_SOUND_H
+
+/* === H E A D E R S ======================================================= */
+#include <ETL/handle>
+
+#include <gtkmm/drawingarea.h>
+
+#include "widget_timeslider.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 AudioProfile;
+class AudioContainer;
+
+/*     What can widget sound do?
+       Options:
+       1. Just draw the sound
+       2. Scroll time and draw the sound
+       3. Play, stop, and scrub the sound... (full interaction...)
+       4. Provide hooks for scrubbing to work... (and possibly play and stop in the future)
+
+       Going with 4 for now...
+*/
+class Widget_Sound : public Widget_Timeslider
+{
+       etl::handle<AudioProfile>       audioprof;
+
+       //event override interface
+       virtual bool on_expose_event(GdkEventExpose *heh = 0);
+
+       //for scrubbing... (click is start, drag is scrub, and release is stop...)
+       virtual bool on_motion_notify_event(GdkEventMotion* event);
+       virtual bool on_button_press_event(GdkEventButton *event);
+       virtual bool on_button_release_event(GdkEventButton *event);
+
+       //Might want a signal setup for scrubbing... and here it is
+       sigc::signal1<void,double>      signal_start_scrubbing_;
+       sigc::signal1<void,double>      signal_scrub_;
+       sigc::signal0<void>                     signal_stop_scrubbing_;
+
+public: //structors
+       Widget_Sound();
+       ~Widget_Sound();
+
+public: //accessors
+       bool set_profile(etl::handle<AudioProfile>      p);
+       etl::handle<AudioProfile>       get_profile() const;
+
+       //for signal interface
+       sigc::signal1<void,double>      &       signal_start_scrubbing()        {return signal_start_scrubbing_;}
+       sigc::signal1<void,double>      &       signal_scrub()                          {return signal_scrub_;}
+       sigc::signal0<void>                     &       signal_stop_scrubbing()         {return signal_stop_scrubbing_;}
+
+public: //get set interface
+       void set_position(double t);
+       double get_position() const;
+
+public: //interface
+       void draw();
+
+       void clear();
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/widget_time.cpp b/synfig-studio/src/gui/widget_time.cpp
new file mode 100644 (file)
index 0000000..2467c70
--- /dev/null
@@ -0,0 +1,167 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_time.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2008 Chris Moore
+**  Copyright (c) 2008 Paul Wise
+**
+**     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 <config.h>
+#endif
+
+#include <gtkmm/entry.h>
+#include <gtkmm/button.h>
+#include "widget_time.h"
+#include "app.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Widget_Time::Widget_Time():
+       fps_(0),
+       time_(0)
+{
+       signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Time::refresh_value));
+       signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Time::refresh_text));
+}
+
+Widget_Time::~Widget_Time()
+{
+}
+
+void
+Widget_Time::refresh_text()
+{
+       set_text(time_.get_string(fps_,App::get_time_format()));
+}
+
+
+void
+Widget_Time::set_value(const synfig::Time &data)
+{
+       time_=data;
+       refresh_text();
+}
+
+synfig::Time
+Widget_Time::get_value() const
+{
+       return time_;
+}
+
+void
+Widget_Time::set_fps(float x)
+{
+       fps_=Time(x);
+       refresh_text();
+}
+
+void
+Widget_Time::refresh_value()
+{
+       try
+       {
+               Time newtime(get_text(),fps_);
+               if(abs(newtime-time_)>=0.001)
+               {
+                       time_=newtime;
+                       refresh_text();
+                       signal_value_changed()();
+               }
+       }
+       catch(...)
+       {
+               throw string("Caught unknown exception");
+       }
+}
+
+bool
+Widget_Time::on_event(GdkEvent* event)
+{
+       const Time scroll_amount(0.25);
+
+       switch(event->type)
+       {
+       case GDK_SCROLL:
+               if(event->scroll.direction==GDK_SCROLL_DOWN || event->scroll.direction==GDK_SCROLL_LEFT)
+               {
+                       time_-=scroll_amount;
+                       refresh_text();
+                       signal_value_changed()();
+               }
+               else if(event->scroll.direction==GDK_SCROLL_UP || event->scroll.direction==GDK_SCROLL_RIGHT)
+               {
+                       time_+=scroll_amount;
+                       refresh_text();
+                       signal_value_changed()();
+               }
+               return true;
+               break;
+       case GDK_BUTTON_PRESS:
+       case GDK_2BUTTON_PRESS:
+       case GDK_3BUTTON_PRESS:
+               if (!has_focus())
+                       grab_focus();
+               break;
+       default:
+               break;
+       }
+
+       return Gtk::Entry::on_event(event);
+}
+
+bool
+Widget_Time::on_focus_out_event(GdkEventFocus* event)
+{
+       refresh_value();
+       refresh_text();
+       return Gtk::Entry::on_focus_out_event(event);
+}
+
+bool
+Widget_Time::on_focus_in_event(GdkEventFocus* event)
+{
+       // if defined, show the full time format "0h 0m 5s 0f" when the time widget gets focus
+       if (getenv("SYNFIG_SHOW_FULL_TIME_ON_FOCUS"))
+               set_text(time_.get_string(fps_,App::get_time_format()|Time::FORMAT_FULL));
+
+       return Gtk::Entry::on_focus_in_event(event);
+}
diff --git a/synfig-studio/src/gui/widget_time.h b/synfig-studio/src/gui/widget_time.h
new file mode 100644 (file)
index 0000000..7332610
--- /dev/null
@@ -0,0 +1,84 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_time.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_WIDGET_TIME_H
+#define __SYNFIG_STUDIO_WIDGET_TIME_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <sigc++/signal.h>
+#include <sigc++/slot.h>
+#include <gtkmm/entry.h>
+#include <synfig/time.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 Gtk { class Entry; class Button; };
+
+namespace studio {
+
+class Widget_Time : public Gtk::Entry
+{
+
+
+       sigc::signal<void> signal_value_changed_;
+
+       float fps_;
+
+       synfig::Time time_;
+
+protected:
+       bool on_focus_out_event(GdkEventFocus* event);
+
+       bool on_focus_in_event(GdkEventFocus* event);
+
+       //void on_activate();
+
+       void refresh_text();
+
+       void refresh_value();
+
+       bool on_event(GdkEvent* event);
+
+public:
+       sigc::signal<void> &signal_value_changed() { return signal_value_changed_; }
+
+
+
+       void set_value(const synfig::Time &data);
+       synfig::Time get_value()const;
+       void set_fps(float x);
+       Widget_Time();
+       ~Widget_Time();
+}; // END of class Widget_Time
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/widget_timeslider.cpp b/synfig-studio/src/gui/widget_timeslider.cpp
new file mode 100644 (file)
index 0000000..ed5d63c
--- /dev/null
@@ -0,0 +1,966 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_timeslider.cpp
+**     \brief Time Slider Widget Implementation File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2004 Adrian Bentley
+**     Copyright (c) 2007, 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 <config.h>
+#endif
+
+#include "widget_timeslider.h"
+
+#include <ETL/misc>
+
+#include <cmath>
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+
+using studio::Widget_Timeslider;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+const double zoominfactor = 0.75;
+const double zoomoutfactor = 1/zoominfactor;
+
+/* === P R O C E D U R E S ================================================= */
+
+Gdk::Color get_interp_color(synfig::Interpolation x)
+{
+       switch(x)
+       {
+       case INTERPOLATION_TCB:
+               return Gdk::Color("#00B000");
+
+               break;
+
+       case INTERPOLATION_LINEAR:
+               return Gdk::Color("#B0B000");
+               break;
+
+       case INTERPOLATION_CONSTANT:
+               return Gdk::Color("#C70000");
+               break;
+
+       case INTERPOLATION_HALT:
+               return Gdk::Color("#00b0b0");
+               break;
+
+       case INTERPOLATION_MANUAL:
+               return Gdk::Color("#B000B0");
+               break;
+
+       case INTERPOLATION_UNDEFINED: default:
+               return Gdk::Color("#808080");
+               break;
+       }
+}
+
+static Gdk::Color
+color_darken(Gdk::Color x, float amount)
+{
+       double   red = x.get_red_p()   * amount;
+       double green = x.get_green_p() * amount;
+       double  blue = x.get_blue_p()  * amount;
+
+       x.set_rgb_p(  red > 1 ? 1 : red,
+                               green > 1 ? 1 : green,
+                                blue > 1 ? 1 : blue);
+
+       return x;
+}
+
+void
+studio::render_time_point_to_window(
+       const Glib::RefPtr<Gdk::Drawable>& window,
+       const Gdk::Rectangle& area,
+       const synfig::TimePoint &tp,
+       bool selected
+)
+{
+       Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(window));
+       const Gdk::Color black("#000000");
+
+       if(selected)
+               gc->set_line_attributes(2,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+       else
+               gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+
+       Gdk::Color color;
+       std::vector<Gdk::Point> points;
+
+/*-    BEFORE ------------------------------------- */
+
+       color=get_interp_color(tp.get_before());
+       color=color_darken(color,1.0f);
+       if(selected)color=color_darken(color,1.3f);
+       gc->set_rgb_fg_color(color);
+
+       switch(tp.get_before())
+       {
+       case INTERPOLATION_TCB:
+               window->draw_arc(
+                       gc,
+                       true,
+                       area.get_x(),
+                       area.get_y(),
+                       area.get_width(),
+                       area.get_height(),
+                       64*90,
+                       64*180
+               );
+               gc->set_rgb_fg_color(black);
+               window->draw_arc(
+                       gc,
+                       false,
+                       area.get_x(),
+                       area.get_y(),
+                       area.get_width(),
+                       area.get_height(),
+                       64*90,
+                       64*180
+               );
+               break;
+
+       case INTERPOLATION_HALT:
+               window->draw_arc(
+                       gc,
+                       true,
+                       area.get_x(),
+                       area.get_y(),
+                       area.get_width(),
+                       area.get_height()*2,
+                       64*90,
+                       64*90
+               );
+               gc->set_rgb_fg_color(black);
+               window->draw_arc(
+                       gc,
+                       false,
+                       area.get_x(),
+                       area.get_y(),
+                       area.get_width(),
+                       area.get_height()*2,
+                       64*90,
+                       64*90
+               );
+               break;
+
+       case INTERPOLATION_LINEAR:
+               points.clear();
+               points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
+               points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()));
+               points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
+               window->draw_polygon(gc,true,points);
+               gc->set_rgb_fg_color(black);
+               window->draw_lines(gc,points);
+               break;
+
+       case INTERPOLATION_CONSTANT:
+               points.clear();
+               points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
+               points.push_back(Gdk::Point(area.get_x()+area.get_width()/4,area.get_y()));
+               points.push_back(Gdk::Point(area.get_x()+area.get_width()/4,area.get_y()+area.get_height()/2));
+               points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()/2));
+               points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()));
+               points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
+               window->draw_polygon(gc,true,points);
+               gc->set_rgb_fg_color(black);
+               window->draw_lines(gc,points);
+               break;
+
+       case INTERPOLATION_UNDEFINED: default:
+               points.clear();
+               points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
+               points.push_back(Gdk::Point(area.get_x()+area.get_width()/3,area.get_y()));
+               points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()/3));
+               points.push_back(Gdk::Point(area.get_x(),area.get_y()+area.get_height()-area.get_height()/3));
+               points.push_back(Gdk::Point(area.get_x()+area.get_width()/3,area.get_y()+area.get_height()));
+               points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
+               window->draw_polygon(gc,true,points);
+               gc->set_rgb_fg_color(black);
+               window->draw_lines(gc,points);
+               break;
+       }
+
+/*-    AFTER -------------------------------------- */
+
+       color=get_interp_color(tp.get_after());
+       color=color_darken(color,0.8f);
+       if(selected)color=color_darken(color,1.3f);
+       gc->set_rgb_fg_color(color);
+
+       switch(tp.get_after())
+       {
+       case INTERPOLATION_TCB:
+               window->draw_arc(
+                       gc,
+                       true,
+                       area.get_x(),
+                       area.get_y(),
+                       area.get_width(),
+                       area.get_height(),
+                       64*270,
+                       64*180
+               );
+               gc->set_rgb_fg_color(black);
+               window->draw_arc(
+                       gc,
+                       false,
+                       area.get_x(),
+                       area.get_y(),
+                       area.get_width(),
+                       area.get_height(),
+                       64*270,
+                       64*180
+               );
+               break;
+
+       case INTERPOLATION_HALT:
+               window->draw_arc(
+                       gc,
+                       true,
+                       area.get_x(),
+                       area.get_y()-area.get_height(),
+                       area.get_width(),
+                       area.get_height()*2,
+                       64*270,
+                       64*90
+               );
+               gc->set_rgb_fg_color(black);
+               window->draw_arc(
+                       gc,
+                       false,
+                       area.get_x(),
+                       area.get_y()-area.get_height(),
+                       area.get_width(),
+                       area.get_height()*2,
+                       64*270,
+                       64*90
+               );
+               break;
+
+       case INTERPOLATION_LINEAR:
+               points.clear();
+               points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
+               points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()));
+               points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
+               window->draw_polygon(gc,true,points);
+               gc->set_rgb_fg_color(black);
+               window->draw_lines(gc,points);
+               break;
+
+       case INTERPOLATION_CONSTANT:
+               points.clear();
+               points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
+               points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()));
+               points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()+area.get_height()/2));
+               points.push_back(Gdk::Point(area.get_x()+area.get_width()-area.get_width()/4,area.get_y()+area.get_height()/2));
+               points.push_back(Gdk::Point(area.get_x()+area.get_width()-area.get_width()/4,area.get_y()+area.get_height()));
+               points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
+               window->draw_polygon(gc,true,points);
+               gc->set_rgb_fg_color(black);
+               window->draw_lines(gc,points);
+               break;
+
+       case INTERPOLATION_UNDEFINED: default:
+               points.clear();
+               points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()));
+               points.push_back(Gdk::Point(area.get_x()+area.get_width()-area.get_width()/3,area.get_y()));
+               points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()+area.get_height()/3));
+               points.push_back(Gdk::Point(area.get_x()+area.get_width(),area.get_y()+area.get_height()-area.get_height()/3));
+               points.push_back(Gdk::Point(area.get_x()+area.get_width()-area.get_width()/3,area.get_y()+area.get_height()));
+               points.push_back(Gdk::Point(area.get_x()+area.get_width()/2,area.get_y()+area.get_height()));
+               window->draw_polygon(gc,true,points);
+               gc->set_rgb_fg_color(black);
+               window->draw_lines(gc,points);
+               break;
+       }
+
+}
+
+/* === M E T H O D S ======================================================= */
+
+/* === E N T R Y P O I N T ================================================= */
+double defaultfps = 24;
+const int fullheight = 20;
+
+Widget_Timeslider::Widget_Timeslider()
+:layout(Pango::Layout::create(get_pango_context())),
+adj_default(0,0,2,1/defaultfps,10/defaultfps),
+adj_timescale(0),
+//invalidated(false),
+last_event_time(0),
+fps(defaultfps),
+dragscroll(false)
+{
+       set_size_request(-1,fullheight);
+
+       //                click                    scroll                     zoom
+       add_events( Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK
+                               | Gdk::BUTTON_MOTION_MASK | Gdk::SCROLL_MASK );
+
+       set_time_adjustment(&adj_default);
+       //update_times();
+}
+
+Widget_Timeslider::~Widget_Timeslider()
+{
+}
+
+void Widget_Timeslider::set_time_adjustment(Gtk::Adjustment *x)
+{
+       //disconnect old connections
+       time_value_change.disconnect();
+       time_other_change.disconnect();
+
+       //connect update function to new adjustment
+       adj_timescale = x;
+
+       if(x)
+       {
+               time_value_change = x->signal_value_changed().connect(sigc::mem_fun(*this,&Widget_Timeslider::queue_draw));
+               time_other_change = x->signal_changed().connect(sigc::mem_fun(*this,&Widget_Timeslider::queue_draw));
+               //invalidated = true;
+               //refresh();
+       }
+}
+
+void Widget_Timeslider::set_global_fps(float d)
+{
+       if(fps != d)
+       {
+               fps = d;
+
+               //update everything since we need to redraw already
+               //invalidated = true;
+               //refresh();
+               queue_draw();
+       }
+}
+
+/*void Widget_Timeslider::update_times()
+{
+       if(adj_timescale)
+       {
+               start = adj_timescale->get_lower();
+               end = adj_timescale->get_upper();
+               current = adj_timescale->get_value();
+       }
+}*/
+
+void Widget_Timeslider::refresh()
+{
+}
+/*
+{
+       if(invalidated)
+       {
+               queue_draw();
+       }else if(adj_timescale)
+       {
+               double  l = adj_timescale->get_lower(),
+                               u = adj_timescale->get_upper(),
+                               v = adj_timescale->get_value();
+
+               bool invalid = (l != start) || (u != end) || (v != current);
+
+               start = l;
+               end = u;
+               current = v;
+
+               if(invalid) queue_draw();
+       }
+}*/
+
+bool Widget_Timeslider::redraw(bool /*doublebuffer*/)
+{
+       Glib::RefPtr<Gdk::Window> window = get_window();
+
+       if(!window) return false;
+
+       Glib::RefPtr<Gdk::GC>   gc = Gdk::GC::create(window);
+       if(!gc) return false;
+
+       //synfig::info("Drawing Timeslider");
+       //clear and update to current values
+       //invalidated = false;
+       //update_times();
+
+       //draw grey rectangle
+       Gdk::Color      c("#7f7f7f");
+       gc->set_rgb_fg_color(c);
+       gc->set_background(c);
+
+       //Get the data for the window and the params to draw it...
+       int w = get_width(), h = get_height();
+
+       window->draw_rectangle(gc,true,0,0,w,h);
+
+       const double EPSILON = 1e-6;
+       if(!adj_timescale || w == 0) return true;
+
+       //Get the time information since we now know it's valid
+       double  start = adj_timescale->get_lower(),
+                       end = adj_timescale->get_upper(),
+                       current = adj_timescale->get_value();
+
+       if(end-start < EPSILON) return true;
+
+       //synfig::info("Drawing Lines");
+
+       //draw all the time stuff
+       double dtdp = (end - start)/get_width();
+       double dpdt = 1/dtdp;
+
+       //lines
+
+       //Draw the time line...
+       double tpx = (current-start)*dpdt;
+       gc->set_rgb_fg_color(Gdk::Color("#ffaf00"));
+       window->draw_line(gc,round_to_int(tpx),0,round_to_int(tpx),fullheight);
+
+       //normal line/text color
+       gc->set_rgb_fg_color(Gdk::Color("#333333"));
+
+       int ifps = round_to_int(fps);
+       if (ifps < 1) ifps = 1;
+
+       std::vector<double> ranges;
+
+       unsigned int pos = 0;
+
+       // build a list of all the factors of the frame rate
+       for (int i = 1; i*i <= ifps; i++)
+               if ((ifps%i) == 0)
+               {
+                       ranges.insert(ranges.begin()+pos, i/fps);
+                       if (i*i != ifps)
+                               ranges.insert(ranges.begin()+pos+1, ifps/i/fps);
+                       pos++;
+               }
+
+       // fill in any gaps where one factor is more than 2 times the previous
+       std::vector<double>::iterator iter, next;
+       pos = 0;
+       for (pos = 0; pos < ranges.size()-1; pos++)
+       {
+               iter = ranges.begin()+pos;
+               next = iter+1;
+               if (*iter*2 < *next)
+                       ranges.insert(next, *iter*2);
+       }
+
+       double more_ranges[] = {
+               2, 3, 5, 10, 20, 30, 60, 90, 120, 180,
+               300, 600, 1200, 1800, 2700, 3600, 3600*2,
+               3600*4, 3600*8, 3600*16, 3600*32, 3600*64,
+               3600*128, 3600*256, 3600*512, 3600*1024 };
+
+       ranges.insert(ranges.end(), more_ranges, more_ranges + sizeof(more_ranges)/sizeof(double));
+
+       double lowerrange = dtdp*140, upperrange = dtdp*280;
+       double midrange = (lowerrange + upperrange)/2;
+
+       //find most ideal scale
+       double scale;
+       next = binary_find(ranges.begin(), ranges.end(), midrange);
+       iter = next++;
+
+       if (iter == ranges.end()) iter--;
+       if (next == ranges.end()) next--;
+
+       if (abs(*next - midrange) < abs(*iter - midrange))
+               iter = next;
+
+       scale = *iter;
+
+       // subdivide into this many tick marks (8 or less)
+       int subdiv = round_to_int(scale * ifps);
+
+       if (subdiv > 8)
+       {
+               const int ideal = subdiv;
+
+               // find a number of tick marks that nicely divides the scale
+               // (5 minutes divided by 6 is 50s, but that's not 'nice' -
+               //  5 ticks of 1m each is much simpler than 6 ticks of 50s)
+               for (subdiv = 8; subdiv > 0; subdiv--)
+                       if ((ideal <= ifps*2       && (ideal % (subdiv           )) == 0) ||
+                               (ideal <= ifps*2*60    && (ideal % (subdiv*ifps      )) == 0) ||
+                               (ideal <= ifps*2*60*60 && (ideal % (subdiv*ifps*60   )) == 0) ||
+                               (true                  && (ideal % (subdiv*ifps*60*60)) == 0))
+                               break;
+
+               // if we didn't find anything, use 4 ticks
+               if (!subdiv)
+                       subdiv = 4;
+       }
+
+       time_per_tickmark = scale / subdiv;
+
+       //get first valid line and its position in pixel space
+       double time = 0;
+       double pixel = 0;
+
+       int sdindex = 0;
+
+       double subr = scale / subdiv;
+
+       //get its position inside...
+       time = ceil(start/subr)*subr - start;
+       pixel = time*dpdt;
+
+       //absolute time of the line to be drawn
+       time += start;
+
+       { //inside the big'n
+               double t = (time/scale - floor(time/scale))*subdiv; // the difference from the big mark in 0:1
+               //sdindex = (int)floor(t + 0.5); //get how far through the range it is...
+               sdindex = round_to_int(t); //get how far through the range it is...
+               if (sdindex == subdiv) sdindex = 0;
+
+               //synfig::info("Extracted fr %.2lf -> %d", t, sdindex);
+       }
+
+       //synfig::info("Initial values: %.4lf t, %.1lf pixels, %d i", time,pixel,sdindex);
+
+       //loop to draw
+       const int heightbig = 12;
+       const int heightsmall = 4;
+
+       int width = get_width();
+       while( pixel < width )
+       {
+               int xpx = round_to_int(pixel);
+
+               //draw big
+               if(sdindex == 0)
+               {
+                       window->draw_line(gc,xpx,0,xpx,heightbig);
+                       //round the time to nearest frame and draw the text
+                       Time tm((double)time);
+                       if(get_global_fps()) tm.round(get_global_fps());
+                       Glib::ustring timecode(tm.get_string(get_global_fps(),App::get_time_format()));
+
+                       //gc->set_rgb_fg_color(Gdk::Color("#000000"));
+                       layout->set_text(timecode);
+                       Pango::AttrList attr_list;
+                       // Aproximately a font size of 8 pixels.
+                       // Pango::SCALE = 1024
+                       // create_attr_size waits a number in 1000th of pixels.
+                       // Should be user customizable in the future. Now it is fixed to 10
+                       Pango::AttrInt pango_size(Pango::Attribute::create_attr_size(Pango::SCALE*10));
+                       pango_size.set_start_index(0);
+                       pango_size.set_end_index(64);
+                       attr_list.change(pango_size);
+                       layout->set_attributes(attr_list);
+                       window->draw_layout(gc,xpx+2,0,layout);
+               }else
+               {
+                       window->draw_line(gc,xpx,0,xpx,heightsmall);
+               }
+
+               //increment time and position
+               pixel += subr / dtdp;
+               time += subr;
+
+               //increment index
+               if(++sdindex >= subdiv) sdindex -= subdiv;
+       }
+
+       return true;
+}
+
+bool Widget_Timeslider::on_motion_notify_event(GdkEventMotion* event) //for dragging
+{
+       if(!adj_timescale) return false;
+
+       Gdk::ModifierType mod = Gdk::ModifierType(event->state);
+
+       //scrolling...
+
+       //NOTE: we might want to address the possibility of dragging with both buttons held down
+
+       if(mod & Gdk::BUTTON2_MASK)
+       {
+
+               //we need this for scrolling by dragging
+               double  curx = event->x;
+
+               double  start = adj_timescale->get_lower(),
+                               end = adj_timescale->get_upper();
+
+               if(dragscroll)
+               {
+                       if(event->time-last_event_time<30)
+                               return false;
+                       else
+                               last_event_time=event->time;
+
+                       if(abs(lastx - curx) < 1 && end != start) return true;
+                       //translate the window and correct it
+
+                       //update our stuff so we are operating correctly
+                       //invalidated = true;
+                       //update_times();
+
+                       //Note: Use inverse of mouse movement because of conceptual space relationship
+                       double diff = lastx - curx; //curx - lastx;
+
+                       //NOTE: This might be incorrect...
+                       //fraction to move...
+                       double dpx = (end - start)/get_width();
+                       lastx = curx;
+
+                       diff *= dpx;
+
+                       //Adjust...
+                       start += diff;
+                       end += diff;
+
+                       //But clamp to bounds if they exist...
+                       //HACK - bounds should not be required for this slider
+                       if(adj_bounds)
+                       {
+                               if(start < adj_bounds->get_lower())
+                               {
+                                       diff = adj_bounds->get_lower() - start;
+                                       start += diff;
+                                       end += diff;
+                               }
+
+                               if(end > adj_bounds->get_upper())
+                               {
+                                       diff = adj_bounds->get_upper() - end;
+                                       start += diff;
+                                       end += diff;
+                               }
+                       }
+
+                       //synfig::info("Scrolling timerange to (%.4f,%.4f)",start,end);
+
+                       adj_timescale->set_lower(start);
+                       adj_timescale->set_upper(end);
+
+                       adj_timescale->changed();
+               }else
+               {
+                       dragscroll = true;
+                       lastx = curx;
+                       //lasty = cury;
+               }
+
+               return true;
+       }
+
+       if(mod & Gdk::BUTTON1_MASK)
+       {
+               double curx = event->x;
+
+               //get time from drag...
+               double  start = adj_timescale->get_lower(),
+                               end = adj_timescale->get_upper(),
+                               current = adj_timescale->get_value();
+               double t = start + curx*(end - start)/get_width();
+
+               //snap it to fps - if they exist...
+               if(fps)
+               {
+                       t = floor(t*fps + 0.5)/fps;
+               }
+
+               //set time if needed
+               if(current != t)
+               {
+                       adj_timescale->set_value(t);
+
+                       //Fixed this to actually do what it's supposed to...
+                       if(event->time-last_event_time>50)
+                       {
+                               adj_timescale->value_changed();
+                               last_event_time = event->time;
+                       }
+               }
+
+               return true;
+       }
+
+       return false;
+}
+
+bool Widget_Timeslider::on_scroll_event(GdkEventScroll* event) //for zooming
+{
+       if(!adj_timescale) return false;
+
+       //Update so we are calculating based on current values
+       //update_times();
+
+       //figure out if we should center ourselves on the current time
+       bool center = false;
+
+       //we want to zoom in on the time value if control is held down
+       if(Gdk::ModifierType(event->state) & Gdk::CONTROL_MASK)
+               center = true;
+
+       switch(event->direction)
+       {
+               case GDK_SCROLL_UP: //zoom in
+                       zoom_in(center);
+                       return true;
+
+               case GDK_SCROLL_DOWN: //zoom out
+                       zoom_out(center);
+                       return true;
+
+               case GDK_SCROLL_RIGHT:
+               case GDK_SCROLL_LEFT:
+               {
+                       double t = adj_timescale->get_value();
+                       double orig_t = t;
+                       double start = adj_timescale->get_lower();
+                       double end = adj_timescale->get_upper();
+                       double lower = adj_bounds->get_lower();
+                       double upper = adj_bounds->get_upper();
+                       double adj = time_per_tickmark;
+
+                       if( event->direction == GDK_SCROLL_RIGHT )
+                       {
+                               // step forward one tick
+                               t += adj;
+
+                               // don't go past the end of time
+                               if (t > upper)
+                                       t = upper;
+
+                               // if we are already in the right half of the slider
+                               if ((t-start)*2 > (end-start))
+                               {
+                                       // if we can't scroll the background left one whole tick, scroll it to the end
+                                       if (end > upper - (t-orig_t))
+                                       {
+                                               adj_timescale->set_lower(upper - (end-start));
+                                               adj_timescale->set_upper(upper);
+                                       }
+                                       // else scroll the background left
+                                       else
+                                       {
+                                               adj_timescale->set_lower(start + (t-orig_t));
+                                               adj_timescale->set_upper(start + (t-orig_t) + (end-start));
+                                       }
+                               }
+                       }
+                       else
+                       {
+                               // step backwards one tick
+                               t -= adj;
+
+                               // don't go past the start of time
+                               if (t < lower)
+                                       t = lower;
+
+                               // if we are already in the left half of the slider
+                               if ((t-start)*2 < (end-start))
+                               {
+                                       // if we can't scroll the background right one whole tick, scroll it to the beginning
+                                       if (start < lower + (orig_t-t))
+                                       {
+                                               adj_timescale->set_lower(lower);
+                                               adj_timescale->set_upper(lower + (end-start));
+                                       }
+                                       // else scroll the background right
+                                       else
+                                       {
+                                               adj_timescale->set_lower(start - (orig_t-t));
+                                               adj_timescale->set_upper(start - (orig_t-t) + (end-start));
+                                       }
+                               }
+                       }
+
+                       if(adj_timescale)
+                       {
+                               adj_timescale->set_value(t);
+                               adj_timescale->value_changed();
+                       }
+                       return true;
+               }
+               default:
+                       return false;
+       }
+}
+
+void Widget_Timeslider::zoom_in(bool centerontime)
+{
+       if(!adj_timescale) return;
+
+       double  start = adj_timescale->get_lower(),
+                       end = adj_timescale->get_upper(),
+                       current = adj_timescale->get_value();
+
+       double focuspoint = centerontime ? current : (start + end)/2;
+
+       //calculate new beginning and end
+       end = focuspoint + (end-focuspoint)*zoominfactor;
+       start = focuspoint + (start-focuspoint)*zoominfactor;
+
+       //synfig::info("Zooming in timerange to (%.4f,%.4f)",start,end);
+       if(adj_bounds)
+       {
+               if(start < adj_bounds->get_lower())
+               {
+                       start = adj_bounds->get_lower();
+               }
+
+               if(end > adj_bounds->get_upper())
+               {
+                       end = adj_bounds->get_upper();
+               }
+       }
+
+       //reset values
+       adj_timescale->set_lower(start);
+       adj_timescale->set_upper(end);
+
+       //call changed function
+       adj_timescale->changed();
+}
+
+void Widget_Timeslider::zoom_out(bool centerontime)
+{
+       if(!adj_timescale) return;
+
+       double  start = adj_timescale->get_lower(),
+                       end = adj_timescale->get_upper(),
+                       current = adj_timescale->get_value();
+
+       double focuspoint = centerontime ? current : (start + end)/2;
+
+       //calculate new beginning and end
+       end = focuspoint + (end-focuspoint)*zoomoutfactor;
+       start = focuspoint + (start-focuspoint)*zoomoutfactor;
+
+       //synfig::info("Zooming out timerange to (%.4f,%.4f)",start,end);
+       if(adj_bounds)
+       {
+               if(start < adj_bounds->get_lower())
+               {
+                       start = adj_bounds->get_lower();
+               }
+
+               if(end > adj_bounds->get_upper())
+               {
+                       end = adj_bounds->get_upper();
+               }
+       }
+
+       //reset values
+       adj_timescale->set_lower(start);
+       adj_timescale->set_upper(end);
+
+       //call changed function
+       adj_timescale->changed();
+}
+
+bool Widget_Timeslider::on_button_press_event(GdkEventButton *event) //for clicking
+{
+       switch(event->button)
+       {
+               //time click...
+               case 1:
+               {
+                       double  start = adj_timescale->get_lower(),
+                                       end = adj_timescale->get_upper(),
+                                       current = adj_timescale->get_value();
+
+                       double w = get_width();
+                       double t = start + (end - start) * event->x / w;
+
+                       t = floor(t*fps + 0.5)/fps;
+
+                       /*synfig::info("Clicking time from %.3lf to %.3lf [(%.2lf,%.2lf) %.2lf / %.2lf ... %.2lf",
+                                               current, vt, start, end, event->x, w, fps);*/
+
+                       if(t != current)
+                       {
+                               current = t;
+
+                               if(adj_timescale)
+                               {
+                                       adj_timescale->set_value(current);
+                                       adj_timescale->value_changed();
+                               }
+                       }
+
+                       break;
+               }
+
+               //scroll click
+               case 2:
+               {
+                       //start dragging
+                       dragscroll = true;
+                       lastx = event->x;
+                       //lasty = event->y;
+
+                       return true;
+               }
+
+               default:
+               {
+                       break;
+               }
+       }
+
+       return false;
+}
+
+bool Widget_Timeslider::on_button_release_event(GdkEventButton *event) //end drag
+{
+       switch(event->button)
+       {
+               case 2:
+               {
+                       //start dragging
+                       dragscroll = false;
+                       return true;
+               }
+
+               default:
+               {
+                       break;
+               }
+       }
+
+       return false;
+}
diff --git a/synfig-studio/src/gui/widget_timeslider.h b/synfig-studio/src/gui/widget_timeslider.h
new file mode 100644 (file)
index 0000000..49cdc13
--- /dev/null
@@ -0,0 +1,133 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_timeslider.h
+**     \brief Time Slider Widget Header
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2004 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_WIDGET_TIMESLIDER_H
+#define __SYNFIG_WIDGET_TIMESLIDER_H
+
+/* === H E A D E R S ======================================================= */
+#include <gtkmm/drawingarea.h>
+#include <gtkmm/adjustment.h>
+
+#include <synfig/time.h>
+#include "canvasview.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 {
+
+void render_time_point_to_window(const Glib::RefPtr<Gdk::Drawable>& window,const Gdk::Rectangle& ca,const synfig::TimePoint &tp,bool selected=false);
+
+
+/* Design for the timeslider...
+
+       Concept: Scalable ruler
+               Ticks are done every so often (30 s, 10 frames, 5 frames, etc.)
+               Print out frame numbers next to the big ticks
+               Show blue pills in separate area (above or below)
+*/
+
+class Widget_Timeslider : public Gtk::DrawingArea
+{
+protected: //implementation that other interfaces can see
+       Glib::RefPtr<Pango::Layout> layout; //implementation awesomeness for text drawing
+
+       Gtk::Adjustment adj_default;
+       Gtk::Adjustment *adj_timescale;
+
+       //HACK - I should not have to see this...
+       Gtk::Adjustment *adj_bounds;
+       double time_per_tickmark;
+
+       //Statistics used for drawing stuff (and making sure we don't if we don't need to)
+       /*double start,end;
+       double current;
+
+       bool invalidated;*/
+
+       guint32 last_event_time;
+
+       float fps;
+
+       sigc::connection time_value_change;
+       sigc::connection time_other_change;
+
+       //TODO: fill out blue pill stuff
+
+       //input functions
+
+       virtual bool on_motion_notify_event(GdkEventMotion* event); //for dragging
+       virtual bool on_scroll_event(GdkEventScroll* event); //for zooming
+       virtual bool on_button_press_event(GdkEventButton *event); //for clicking
+       virtual bool on_button_release_event(GdkEventButton *event); //for clicking
+
+       virtual bool on_expose_event(GdkEventExpose */*event*/) {redraw(); return true;}//for drawing
+
+       virtual bool redraw(bool doublebuffer = false);
+
+       //void update_times();
+
+       void zoom_in(bool centerontime = false);
+       void zoom_out(bool centerontime = false);
+
+       //Drag the Frame
+       bool dragscroll;
+
+       /*NOTE: if we can set the mouse position to the original position
+                       this would only have to be set once (and it would be good otherwise too)
+       */
+       double lastx; //last mouse position for dragging
+
+public: //structors
+       Widget_Timeslider();
+       ~Widget_Timeslider();
+
+public: //Normal Interface
+
+       void draw() {redraw();}
+       virtual void refresh(); //reget bluepills, time values and queue_draw if need be
+
+public: //Time Interface
+
+       //Run FPS stuff through it to the MAX
+       double get_global_fps() const {return fps;}
+       void set_global_fps(float d);
+
+       //accessors for the time adjustment
+       Gtk::Adjustment &get_time_adjustment() const {return *adj_timescale;}
+       void set_time_adjustment(Gtk::Adjustment *x);
+
+       //HACK - I should not have to see these bounds (should be boundless)
+       Gtk::Adjustment &get_bounds_adjustment() const {return *adj_bounds;}
+       void set_bounds_adjustment(Gtk::Adjustment *x) {adj_bounds = x;}
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/widget_value.cpp b/synfig-studio/src/gui/widget_value.cpp
new file mode 100644 (file)
index 0000000..c6a8b97
--- /dev/null
@@ -0,0 +1,486 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_value.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include <gtkmm/label.h>
+#include "widget_value.h"
+#include <ETL/stringf>
+#include <gtkmm/celleditable.h>
+#include <gtkmm/editable.h>
+#include <gtkmm/entry.h>
+#include <gtkmm/eventbox.h>
+#include <gtk/gtkentry.h> /* see XXX below */
+#include "app.h"
+
+
+#include "widget_vector.h"
+#include "widget_filename.h"
+#include "widget_enum.h"
+#include "widget_coloredit.h"
+#include "widget_canvaschooser.h"
+#include "widget_time.h"
+#include "app.h"
+#include "widget_distance.h"
+
+#include "general.h"
+
+#endif
+
+using namespace synfig;
+using namespace etl;
+using namespace std;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+#define DIGITS         15
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Widget_ValueBase::Widget_ValueBase():
+       Glib::ObjectBase        (typeid(Widget_ValueBase)),
+       Gtk::HBox(),
+       real_adjustment(0,-2000000000,2000000000,0.05,0.05,0),
+       integer_adjustment(0,-2000000000,2000000000,1,1,0),
+       angle_adjustment(0,-2000000000,2000000000,1,1,0)
+{
+       set_no_show_all();
+
+       label=manage(new class Gtk::Label("Unknown Datatype"));
+       pack_start(*label);
+       label->show();
+
+       vector_widget=manage(new class Widget_Vector());
+       pack_start(*vector_widget);
+
+       color_widget=manage(new class Widget_ColorEdit());
+       pack_start(*color_widget);
+
+       enum_widget=manage(new class Widget_Enum());
+       pack_start(*enum_widget);
+
+       real_widget=manage(new class Gtk::SpinButton(real_adjustment,0.05,DIGITS));
+       pack_start(*real_widget);
+
+       integer_widget=manage(new class Gtk::SpinButton(integer_adjustment,1,0));
+       pack_start(*integer_widget);
+
+       angle_widget=manage(new class Gtk::SpinButton(angle_adjustment,15,2));
+       pack_start(*angle_widget);
+
+       bool_widget=manage(new class Gtk::CheckButton());
+       pack_start(*bool_widget);
+
+       //color_widget=manage(new class Gtk::ColorSelection());
+       //pack_start(*color_widget);
+
+       string_widget=manage(new class Gtk::Entry());
+       pack_start(*string_widget);
+
+       canvas_widget=manage(new class Widget_CanvasChooser());
+       pack_start(*canvas_widget);
+
+       filename_widget=manage(new class Widget_Filename());
+       pack_start(*filename_widget);
+
+       time_widget=manage(new class Widget_Time());
+       pack_start(*time_widget);
+
+       distance_widget=manage(new class Widget_Distance());
+       pack_start(*distance_widget);
+
+
+       vector_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
+       color_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
+       enum_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
+       real_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
+       integer_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
+       angle_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
+       string_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
+       canvas_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
+       filename_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
+       time_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
+       distance_widget->signal_activate().connect(sigc::mem_fun(*this,&Widget_ValueBase::activate));
+
+       /*signal_focus_in_event().connect(
+               sigc::bind_return(
+               sigc::hide(
+                       sigc::mem_fun(*this,&Widget_ValueBase::grab_focus)
+               ),false
+               )
+       );*/
+}
+
+Widget_ValueBase::~Widget_ValueBase()
+{
+}
+
+void
+Widget_ValueBase::activate()
+{
+       signal_activate()();
+}
+
+void
+Widget_ValueBase::inside_cellrenderer()
+{
+       string_widget->set_has_frame(false);
+       string_widget->gobj()->is_cell_renderer = true; // XXX
+
+       real_widget->set_has_frame(false);
+       //static_cast<Gtk::Entry*>(real_widget)->gobj()->is_cell_renderer = true; // XXX
+
+       distance_widget->set_has_frame(false);
+       //static_cast<Gtk::Entry*>(distance_widget)->gobj()->is_cell_renderer = true; // XXX
+
+       integer_widget->set_has_frame(false);
+       //static_cast<Gtk::Entry*>(integer_widget)->gobj()->is_cell_renderer = true; // XXX
+       vector_widget->set_has_frame(false);
+    //vector_widget->set_digits(10);
+
+       color_widget->set_has_frame(false);
+    //color_widget->set_digits(10);
+       filename_widget->set_has_frame(false);
+       time_widget->set_has_frame(false);
+}
+
+void
+Widget_ValueBase::set_sensitive(bool x)
+{
+       Gtk::HBox::set_sensitive(x);
+       label->set_sensitive(x);
+       vector_widget->set_sensitive(x);
+       real_widget->set_sensitive(x);
+       integer_widget->set_sensitive(x);
+       bool_widget->set_sensitive(x);
+    color_widget->set_sensitive(x);
+       string_widget->set_sensitive(x);
+       canvas_widget->set_sensitive(x);
+       enum_widget->set_sensitive(x);
+       angle_widget->set_sensitive(x);
+       filename_widget->set_sensitive(x);
+       time_widget->set_sensitive(x);
+       distance_widget->set_sensitive(x);
+}
+
+void
+Widget_ValueBase::set_value(const synfig::ValueBase &data)
+{
+       label->hide();
+       vector_widget->hide();
+       real_widget->hide();
+       integer_widget->hide();
+       bool_widget->hide();
+    color_widget->hide();
+       string_widget->hide();
+       canvas_widget->hide();
+       enum_widget->hide();
+       angle_widget->hide();
+       filename_widget->hide();
+       time_widget->hide();
+       distance_widget->hide();
+
+       value=data;
+       try{
+       switch(value.get_type())
+       {
+       case ValueBase::TYPE_VECTOR:
+               vector_widget->set_canvas(canvas);
+               vector_widget->set_value(value.get(Vector()));
+               vector_widget->show();
+               break;
+       case ValueBase::TYPE_REAL:
+               if(param_desc.get_is_distance() && canvas)
+               {
+                       Distance dist(value.get(Real()),Distance::SYSTEM_UNITS);
+                       dist.convert(App::distance_system,canvas->rend_desc());
+                       distance_widget->set_value(dist);
+                       distance_widget->show();
+               }
+               else
+               {
+                       real_widget->set_value(value.get(Real()));
+                       real_widget->show();
+               }
+               break;
+       case ValueBase::TYPE_TIME:
+               if(canvas)time_widget->set_fps(canvas->rend_desc().get_frame_rate());
+               time_widget->set_value(value.get(Time()));
+               time_widget->show();
+               break;
+       case ValueBase::TYPE_ANGLE:
+               angle_widget->set_value(Angle::deg(value.get(Angle())).get());
+               angle_widget->show();
+               break;
+       case ValueBase::TYPE_INTEGER:
+               if(param_desc.get_hint()!="enum")
+               {
+                       integer_widget->set_value(value.get(int()));
+                       integer_widget->show();
+               }
+               else
+               {
+                       enum_widget->set_param_desc(param_desc);
+                       enum_widget->set_value(value.get(int()));
+                       enum_widget->show();
+               }
+               break;
+       case ValueBase::TYPE_CANVAS:
+               assert(canvas);
+               canvas_widget->set_parent_canvas(canvas);
+               canvas_widget->set_value(value.get(etl::loose_handle<synfig::Canvas>()));
+               canvas_widget->show();
+               break;
+       case ValueBase::TYPE_BOOL:
+               bool_widget->set_active(value.get(bool()));
+               bool_widget->show();
+               break;
+       case ValueBase::TYPE_STRING:
+               if(param_desc.get_hint()!="filename")
+               {
+                       string_widget->set_text(value.get(string()));
+                       string_widget->show();
+               }
+               else
+               {
+                       filename_widget->set_value(value.get(string()));
+                       filename_widget->show();
+               }
+               break;
+       case ValueBase::TYPE_COLOR:
+        {
+               color_widget->set_value(value.get(synfig::Color()));
+               color_widget->show();
+/*
+                       Gdk::Color gdkcolor;
+                       synfig::Color color=value.get(synfig::Color());
+                       gdkcolor.set_rgb_p(color.get_r(),color.get_g(),color.get_b());
+                       color_widget->set_current_color(gdkcolor);
+                       color_widget->set_has_opacity_control(true);
+                       color_widget->set_current_alpha((unsigned short)(color.get_a()*65535.0));
+                       color_widget->show();
+*/
+               }
+               break;
+       default:
+               label->show();
+               break;
+       }
+       }catch(...) { synfig::error(__FILE__":%d: Caught something that was thrown",__LINE__); }
+}
+
+const synfig::ValueBase &
+Widget_ValueBase::get_value()
+{
+       switch(value.get_type())
+       {
+       case ValueBase::TYPE_VECTOR:
+               value=vector_widget->get_value();
+               break;
+       case ValueBase::TYPE_REAL:
+               if(param_desc.get_is_distance() && canvas)
+                       value=distance_widget->get_value().units(canvas->rend_desc());
+               else
+                       value=real_widget->get_value();
+               break;
+       case ValueBase::TYPE_TIME:
+               value=time_widget->get_value();
+               break;
+       case ValueBase::TYPE_ANGLE:
+               value=Angle::deg(angle_widget->get_value());
+               break;
+       case ValueBase::TYPE_CANVAS:
+               value=canvas_widget->get_value();
+               break;
+       case ValueBase::TYPE_INTEGER:
+               if(param_desc.get_hint()!="enum")
+               {
+                       value=integer_widget->get_value_as_int();
+               }
+               else
+               {
+                       value=enum_widget->get_value();
+               }
+
+               break;
+       case ValueBase::TYPE_BOOL:
+               value=bool_widget->get_active();
+               break;
+       case ValueBase::TYPE_STRING:
+               if(param_desc.get_hint()!="filename")
+               {
+                       value=string(string_widget->get_text());
+               }
+               else
+               {
+                       value=string(filename_widget->get_value());
+               }
+               break;
+       case ValueBase::TYPE_COLOR:
+        {
+                       value=color_widget->get_value();
+/*
+                       Gdk::Color gdkcolor;
+                       synfig::Color color;
+                       gdkcolor=color_widget->get_current_color();
+                       color.set_r(gdkcolor.get_red_p());
+            color.set_g(gdkcolor.get_green_p());
+            color.set_b(gdkcolor.get_blue_p());
+                       color.set_a(color_widget->get_current_alpha()/65535.0);
+
+                       value=color;
+*/
+               }
+               break;
+       default:
+               break;
+       }
+
+       return value;
+}
+
+
+void
+Widget_ValueBase::on_grab_focus()
+{
+       switch(value.get_type())
+       {
+       case ValueBase::TYPE_VECTOR:
+               vector_widget->grab_focus();
+               break;
+       case ValueBase::TYPE_REAL:
+               if(param_desc.get_is_distance()&& canvas)
+                       distance_widget->grab_focus();
+               else
+                       real_widget->grab_focus();
+               break;
+       case ValueBase::TYPE_TIME:
+               time_widget->grab_focus();
+               break;
+       case ValueBase::TYPE_ANGLE:
+               angle_widget->grab_focus();
+               break;
+       case ValueBase::TYPE_CANVAS:
+               canvas_widget->grab_focus();
+               break;
+       case ValueBase::TYPE_INTEGER:
+               if(param_desc.get_hint()!="enum")
+               {
+                       integer_widget->grab_focus();
+               }
+               else
+               {
+                       enum_widget->grab_focus();
+               }
+
+               break;
+       case ValueBase::TYPE_BOOL:
+               bool_widget->grab_focus();
+               break;
+       case ValueBase::TYPE_STRING:
+               if(param_desc.get_hint()!="filename")
+               {
+                       string_widget->grab_focus();
+               }
+               else
+               {
+                       filename_widget->grab_focus();
+               }
+               break;
+       case ValueBase::TYPE_COLOR:
+        {
+                       color_widget->grab_focus();
+               }
+               break;
+       default:
+               break;
+       }
+}
+
+/*
+Glib::SignalProxy0<void>
+Widget_ValueBase::signal_activate()
+{
+       switch(value.get_type())
+       {
+       case ValueBase::TYPE_VECTOR:
+               return vector_widget->signal_activate();
+               break;
+       case ValueBase::TYPE_REAL:
+               if(param_desc.get_is_distance()&& canvas)
+                       return distance_widget->signal_activate();
+               else
+                       return real_widget->signal_activate();
+
+               break;
+       case ValueBase::TYPE_TIME:
+               return time_widget->signal_activate();
+               break;
+       case ValueBase::TYPE_ANGLE:
+               return angle_widget->signal_activate();
+               break;
+       case ValueBase::TYPE_CANVAS:
+               return canvas_widget->signal_activate();
+               break;
+       case ValueBase::TYPE_INTEGER:
+               if(param_desc.get_hint()!="enum")
+                       return integer_widget->signal_activate();
+               else
+                       return enum_widget->signal_activate();
+
+               break;
+       case ValueBase::TYPE_BOOL:
+               return string_widget->signal_activate();
+               break;
+       case ValueBase::TYPE_STRING:
+               if(param_desc.get_hint()!="filename")
+               {
+                       return string_widget->signal_activate();
+               }
+               else
+               {
+                       return filename_widget->signal_activate();
+               }
+               break;
+       case ValueBase::TYPE_COLOR:
+        {
+                       return color_widget->signal_activate();
+               }
+               break;
+       default:
+               return string_widget->signal_activate();
+               break;
+       }
+}
+*/
diff --git a/synfig-studio/src/gui/widget_value.h b/synfig-studio/src/gui/widget_value.h
new file mode 100644 (file)
index 0000000..99bdf5b
--- /dev/null
@@ -0,0 +1,136 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_value.h
+**     \brief Template File
+**
+**     $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_GTKMM_VALUE_H
+#define __SYNFIG_GTKMM_VALUE_H
+
+/* === H E A D E R S ======================================================= */
+
+//#include <gtk/gtk.h>
+//#include <gtkmm/ruler.h>
+//#include <gtkmm/arrow.h>
+//#include <gtkmm/image.h>
+//#include <gdkmm/pixbufloader.h>
+//#include <gtkmm/viewport.h>
+#include <gtkmm/adjustment.h>
+//#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/table.h>
+//#include <gtkmm/statusbar.h>
+#include <gtkmm/button.h>
+#include <gtkmm/label.h>
+//#include <gtkmm/paned.h>
+//#include <gtkmm/treeview.h>
+//#include <gtkmm/treestore.h>
+#include <gtkmm/box.h>
+#include <gtkmm/spinbutton.h>
+//#include <gtkmm/cellrenderer.h>
+#include <gtkmm/checkbutton.h>
+
+//#include <gtkmm/colorselection.h>
+#include <gtkmm/optionmenu.h>
+
+//#include <synfig/synfig.h>
+#include <synfig/paramdesc.h>
+#include <synfig/value.h>
+#include <synfig/canvas.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 Widget_Color;
+class Widget_ColorEdit;
+class Widget_CanvasChooser;
+class Widget_Enum;
+class Widget_Filename;
+class Widget_Vector;
+class Widget_Time;
+class Widget_Distance;
+
+class Widget_ValueBase : public Gtk::HBox
+{
+       Gtk::Label *label;
+       synfig::ValueBase value;
+
+       Widget_Vector *vector_widget;
+       Gtk::SpinButton *real_widget;
+       Gtk::Adjustment real_adjustment;
+       Gtk::SpinButton *integer_widget;
+       Gtk::Adjustment integer_adjustment;
+       Gtk::SpinButton *angle_widget;
+       Gtk::Adjustment angle_adjustment;
+
+       Gtk::CheckButton *bool_widget;
+       //Gtk::ColorSelection *color_widget;
+       Widget_ColorEdit *color_widget;
+       Widget_CanvasChooser *canvas_widget;
+       Widget_Enum *enum_widget;
+       Widget_Filename *filename_widget;
+       Widget_Time *time_widget;
+       Gtk::Entry *string_widget;
+       Widget_Distance *distance_widget;
+
+//     std::string hint;
+
+       synfig::ParamDesc param_desc;
+       etl::handle<synfig::Canvas> canvas;
+       sigc::signal<void> signal_value_changed_;
+       sigc::signal<void> signal_activate_;
+
+public:
+       sigc::signal<void> &signal_value_changed() { return signal_value_changed_; }
+
+       void activate();
+
+       sigc::signal<void>& signal_activate() { return signal_activate_; }
+
+       void set_value(const synfig::ValueBase &data);
+       const synfig::ValueBase &get_value();
+
+       void on_grab_focus();
+
+       void set_param_desc(const synfig::ParamDesc &x) { param_desc=x; }
+       const synfig::ParamDesc &get_param_desc() { return param_desc; }
+
+       void set_sensitive(bool x);
+
+       //void set_hint(std::string x) { hint=x; }
+//     std::string get_hint() { return hint; }
+
+       void set_canvas(etl::handle<synfig::Canvas> x) { canvas=x; assert(canvas); }
+       void inside_cellrenderer();
+       Widget_ValueBase();
+       ~Widget_ValueBase();
+};
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/widget_vector.cpp b/synfig-studio/src/gui/widget_vector.cpp
new file mode 100644 (file)
index 0000000..f905d34
--- /dev/null
@@ -0,0 +1,244 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_vector.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include <gtkmm/spinbutton.h>
+#include "widget_vector.h"
+#include "widget_distance.h"
+#include "app.h"
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace synfig;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+#define DIGITS         10
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Widget_Vector::Widget_Vector():
+       Gtk::HBox(false, 5),
+       x_adjustment(0,-100000000,100000000,0.05,0.05,0),
+       y_adjustment(0,-100000000,100000000,0.05,0.05,0)
+{
+       Gtk::Label *label;
+
+       label=manage(new class Gtk::Label("X:"));
+       label->set_alignment(0, 0.5);
+       label->show();
+       pack_start(*label, Gtk::PACK_SHRINK);
+
+       spinbutton_x=manage(new class Gtk::SpinButton(x_adjustment,0.05,DIGITS));
+       spinbutton_x->set_alignment(1);
+       spinbutton_x->set_update_policy(Gtk::UPDATE_ALWAYS);
+       spinbutton_x->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Vector::on_value_changed));
+       pack_start(*spinbutton_x, Gtk::PACK_EXPAND_WIDGET);
+
+       distance_x=manage(new Widget_Distance());
+       distance_x->set_digits(4);
+       distance_x->set_update_policy(Gtk::UPDATE_ALWAYS);
+       distance_x->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Vector::on_value_changed));
+       pack_start(*distance_x, Gtk::PACK_EXPAND_WIDGET);
+
+       label=manage(new class Gtk::Label("Y:"));
+       label->set_alignment(0, 0.5);
+       label->show();
+       pack_start(*label, Gtk::PACK_SHRINK);
+
+       spinbutton_y=manage(new class Gtk::SpinButton(y_adjustment,0.05,DIGITS));
+       spinbutton_y->set_alignment(1);
+       spinbutton_y->set_update_policy(Gtk::UPDATE_ALWAYS);
+       spinbutton_y->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Vector::on_value_changed));
+       spinbutton_y->signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Vector::activate));
+       pack_start(*spinbutton_y, Gtk::PACK_EXPAND_WIDGET);
+
+       distance_y=manage(new Widget_Distance());
+       distance_y->set_digits(4);
+       distance_y->set_update_policy(Gtk::UPDATE_ALWAYS);
+       distance_y->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Widget_Vector::on_value_changed));
+       distance_y->signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Vector::activate));
+       pack_start(*distance_y, Gtk::PACK_EXPAND_WIDGET);
+
+       spinbutton_x->show();
+       spinbutton_y->show();
+
+       spinbutton_x->signal_activate().connect(sigc::mem_fun(*spinbutton_y,&Gtk::SpinButton::grab_focus));
+       distance_x->signal_activate().connect(sigc::mem_fun(*distance_y,&Gtk::SpinButton::grab_focus));
+}
+
+Widget_Vector::~Widget_Vector()
+{
+}
+
+void
+Widget_Vector::on_grab_focus()
+{
+       if(canvas_)
+               distance_x->grab_focus();
+       else
+               spinbutton_x->grab_focus();
+}
+
+void
+Widget_Vector::set_has_frame(bool x)
+{
+       if(spinbutton_x)
+       {
+               spinbutton_x->set_has_frame(x);
+               spinbutton_y->set_has_frame(x);
+               spinbutton_x->set_size_request(48,-1);
+               spinbutton_y->set_size_request(48,-1);
+       }
+
+       distance_x->set_has_frame(x);
+       distance_y->set_has_frame(x);
+       distance_x->set_size_request(48,-1);
+       distance_y->set_size_request(48,-1);
+}
+
+void
+Widget_Vector::set_digits(int x)
+{
+       if(spinbutton_x)
+       {
+               spinbutton_x->set_digits(x);
+               spinbutton_y->set_digits(x);
+               spinbutton_x->set_size_request(48,-1);
+               spinbutton_y->set_size_request(48,-1);
+       }
+
+       distance_x->set_digits(x);
+       distance_y->set_digits(x);
+       distance_x->set_size_request(48,-1);
+       distance_y->set_size_request(48,-1);
+}
+
+void
+Widget_Vector::set_value(const synfig::Vector &data)
+{
+       vector=data;
+
+       if(canvas_){try
+       {
+               Distance distx(vector[0],Distance::SYSTEM_UNITS),disty(vector[1],Distance::SYSTEM_UNITS);
+               distx.convert(App::distance_system,canvas_->rend_desc());
+               disty.convert(App::distance_system,canvas_->rend_desc());
+               distance_x->set_value(distx);
+               distance_y->set_value(disty);
+               spinbutton_x->hide();
+               spinbutton_y->hide();
+       }catch(...) { synfig::error("Widget_Vector::set_value(): Caught something that was thrown"); }}
+       else
+       {
+               spinbutton_x->set_value(vector[0]);
+               spinbutton_y->set_value(vector[1]);
+               distance_x->hide();
+               distance_y->hide();
+       }
+}
+
+const synfig::Vector &
+Widget_Vector::get_value()
+{
+       if(!canvas_ && spinbutton_x)
+       {
+               vector[0]=spinbutton_x->get_value();
+               vector[1]=spinbutton_y->get_value();
+               distance_x->hide();
+               distance_y->hide();
+       }
+       else try
+       {
+               vector[0]=distance_x->get_value().units(canvas_->rend_desc());
+               vector[1]=distance_y->get_value().units(canvas_->rend_desc());
+               spinbutton_x->hide();
+               spinbutton_y->hide();
+       }catch(...) { synfig::error("Widget_Vector::set_value(): Caught something that was thrown"); }
+       return vector;
+}
+
+void
+Widget_Vector::on_value_changed()
+{
+       signal_value_changed()();
+}
+
+void
+Widget_Vector::set_canvas(synfig::Canvas::LooseHandle x)
+{
+       canvas_=x;
+       if(x)
+       {
+               if(spinbutton_x)
+               {
+                       spinbutton_x->hide();
+                       spinbutton_y->hide();
+               }
+               distance_x->show();
+               distance_y->show();
+       }
+       else
+       {
+               if(spinbutton_x)
+               {
+                       spinbutton_x->show();
+                       spinbutton_y->show();
+               }
+               distance_x->hide();
+               distance_y->hide();
+       }
+}
+
+void
+Widget_Vector::show_all_vfunc()
+{
+       if(canvas_)
+       {
+               distance_x->show();
+               distance_y->show();
+       }
+       else
+       {
+               spinbutton_x->show();
+               spinbutton_y->show();
+       }
+       show();
+}
diff --git a/synfig-studio/src/gui/widget_vector.h b/synfig-studio/src/gui/widget_vector.h
new file mode 100644 (file)
index 0000000..36ccbbe
--- /dev/null
@@ -0,0 +1,96 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_vector.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_WIDGET_VECTOR_H
+#define __SYNFIG_STUDIO_WIDGET_VECTOR_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/box.h>
+#include <gtkmm/adjustment.h>
+#include <synfig/vector.h>
+#include <synfig/distance.h>
+#include <synfig/canvas.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 Gtk { class SpinButton; };
+
+namespace studio {
+
+class Widget_Distance;
+
+class Widget_Vector : public Gtk::HBox
+{
+       Gtk::SpinButton* spinbutton_x;
+       Gtk::SpinButton* spinbutton_y;
+
+       Widget_Distance* distance_x;
+       Widget_Distance* distance_y;
+
+       Gtk::Adjustment x_adjustment;
+       Gtk::Adjustment y_adjustment;
+
+       synfig::Vector vector;
+
+       sigc::signal<void> signal_value_changed_;
+
+       sigc::signal<void> signal_activate_;
+
+       synfig::Canvas::LooseHandle canvas_;
+
+public:
+
+       void activate() { signal_activate_(); }
+
+       void set_canvas(synfig::Canvas::LooseHandle);
+       synfig::Canvas::LooseHandle get_canvas()const { return canvas_; }
+
+       sigc::signal<void>& signal_value_changed() { return signal_value_changed_; }
+
+       sigc::signal<void>& signal_activate() { return signal_activate_; }
+
+       void on_value_changed();
+       void on_grab_focus();
+
+       void set_value(const synfig::Vector &data);
+       const synfig::Vector &get_value();
+       void set_has_frame(bool x);
+       void set_digits(int x);
+       Widget_Vector();
+       ~Widget_Vector();
+
+protected:
+       void show_all_vfunc();
+}; // END of class Widget_Vector
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/widget_waypoint.cpp b/synfig-studio/src/gui/widget_waypoint.cpp
new file mode 100644 (file)
index 0000000..d456130
--- /dev/null
@@ -0,0 +1,281 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_waypoint.cpp
+**     \brief Template Header
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2008 Chris Moore
+**  Copyright (c) 2008 Paul Wise
+**
+**     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 <config.h>
+#endif
+
+#include <gtkmm/label.h>
+#include <gtkmm/frame.h>
+#include <gtkmm/alignment.h>
+#include "dialog_waypoint.h"
+#include <gtk/gtk.h>
+#include <gtkmm/spinbutton.h>
+#include <gtkmm/combo.h>
+#include <ETL/stringf>
+#include "widget_value.h"
+#include "app.h"
+#include <gtkmm/menu.h>
+#include <gtkmm/optionmenu.h>
+#include "widget_time.h"
+#include "widget_waypoint.h"
+#include "general.h"
+
+#endif
+
+using namespace synfig;
+using namespace std;
+using namespace etl;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Widget_Waypoint::Widget_Waypoint(etl::handle<synfig::Canvas> canvas):
+       Gtk::Alignment(0, 0, 1, 1),
+       waypoint(synfig::ValueBase(),0),
+       adj_tension(0.0,-20,20,0.1,1),
+       adj_continuity(0.0,-20,20,0.1,1),
+       adj_bias(0.0,-20,20,0.1,1),
+       adj_temporal_tension(0.0,-20,20,0.1,1)
+{
+       value_widget=manage(new Widget_ValueBase());
+       value_widget->set_canvas(canvas);
+       value_widget->show();
+
+       value_node_label=manage(new Gtk::Label(_("(Non-static value)")));
+
+
+       time_widget=manage(new Widget_Time());
+       time_widget->set_fps(canvas->rend_desc().get_frame_rate());
+       //spinbutton=manage(new Gtk::SpinButton(time_adjustment,0.05,3));
+       //spinbutton->set_update_policy(Gtk::UPDATE_ALWAYS);
+       //spinbutton->show();
+
+       before_options=manage(new class Gtk::Menu());
+       before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("TCB Smooth")));
+       before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Constant")));
+       before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Linear")));
+       before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Ease In")));
+       // before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Manual")));
+
+       after_options=manage(new class Gtk::Menu());
+       after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("TCB Smooth")));
+       after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Constant")));
+       after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Linear")));
+       after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Ease Out")));
+       // after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Manual")));
+
+       before=manage(new class Gtk::OptionMenu());
+       before->show();
+       before->set_menu(*before_options);
+
+       after=manage(new class Gtk::OptionMenu());
+       after->show();
+       after->set_menu(*after_options);
+
+       spin_tension=manage(new class Gtk::SpinButton(adj_tension,0.1,3));
+       spin_tension->show();
+       spin_continuity=manage(new class Gtk::SpinButton(adj_continuity,0.1,3));
+       spin_continuity->show();
+       spin_bias=manage(new class Gtk::SpinButton(adj_bias,0.1,3));
+       spin_bias->show();
+       spin_temporal_tension=manage(new class Gtk::SpinButton(adj_temporal_tension,0.1,3));
+       spin_temporal_tension->show();
+
+       set_padding(12, 12, 12, 12);
+
+       Gtk::VBox *widgetBox = manage(new Gtk::VBox(false, 12));
+       add(*widgetBox);
+
+       Gtk::Frame *waypointFrame = manage(new Gtk::Frame(_("Waypoint")));
+       waypointFrame->set_shadow_type(Gtk::SHADOW_NONE);
+       ((Gtk::Label *) waypointFrame->get_label_widget())->set_markup(_("<b>Waypoint</b>"));
+       widgetBox->pack_start(*waypointFrame, false, false, 0);
+
+       Gtk::Alignment *waypointPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
+       waypointPadding->set_padding(6, 0, 24, 0);
+       waypointFrame->add(*waypointPadding);
+
+       Gtk::Table *waypointTable = manage(new Gtk::Table(2, 2, false));
+       waypointTable->set_row_spacings(6);
+       waypointTable->set_col_spacings(12);
+       waypointPadding->add(*waypointTable);
+
+       Gtk::Label *waypointValueLabel = manage(new Gtk::Label(_("_Value"), true));
+       waypointValueLabel->set_alignment(0, 0.5);
+       waypointValueLabel->set_mnemonic_widget(*value_widget);
+       waypointTable->attach(*waypointValueLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       waypointTable->attach(*value_widget, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       waypointTable->attach(*value_node_label, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+       Gtk::Label *waypointTimeLabel = manage(new Gtk::Label(_("_Time"), true));
+       waypointTimeLabel->set_alignment(0, 0.5);
+       waypointTimeLabel->set_mnemonic_widget(*time_widget);
+       waypointTable->attach(*waypointTimeLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       waypointTable->attach(*time_widget, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+       Gtk::Frame *interpolationFrame = manage(new Gtk::Frame(_("Interpolation")));
+       interpolationFrame->set_shadow_type(Gtk::SHADOW_NONE);
+       ((Gtk::Label *) interpolationFrame->get_label_widget())->set_markup(_("<b>Interpolation</b>"));
+       widgetBox->pack_start(*interpolationFrame, false, false, 0);
+
+       Gtk::Alignment *interpolationPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
+       interpolationPadding->set_padding(6, 0, 24, 0);
+       interpolationFrame->add(*interpolationPadding);
+
+       Gtk::Table *interpolationTable = manage(new Gtk::Table(2, 2, false));
+       interpolationTable->set_row_spacings(6);
+       interpolationTable->set_col_spacings(12);
+       interpolationPadding->add(*interpolationTable);
+
+       Gtk::Label *interpolationInLabel = manage(new Gtk::Label(_("_In Interpolation"), true));
+       interpolationInLabel->set_alignment(0, 0.5);
+       interpolationInLabel->set_mnemonic_widget(*before);
+       interpolationTable->attach(*interpolationInLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       interpolationTable->attach(*before, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+       Gtk::Label *interpolationOutLabel = manage(new Gtk::Label(_("_Out Interpolation"), true));
+       interpolationOutLabel->set_alignment(0, 0.5);
+       interpolationOutLabel->set_mnemonic_widget(*after);
+       interpolationTable->attach(*interpolationOutLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       interpolationTable->attach(*after, 1, 2, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+       Gtk::Frame *tcbFrame = manage(new Gtk::Frame(_("TCB Parameters")));
+       tcbFrame->set_shadow_type(Gtk::SHADOW_NONE);
+       ((Gtk::Label *) tcbFrame->get_label_widget())->set_markup(_("<b>TCB Parameter</b>"));
+       widgetBox->pack_start(*tcbFrame, false, false, 0);
+
+       Gtk::Alignment *tcbPadding = manage(new Gtk::Alignment(0, 0, 1, 1));
+       tcbPadding->set_padding(6, 0, 24, 0);
+       tcbFrame->add(*tcbPadding);
+
+       Gtk::Table *tcbTable = manage(new Gtk::Table(4, 2, false));
+       tcbTable->set_row_spacings(6);
+       tcbTable->set_col_spacings(12);
+       tcbPadding->add(*tcbTable);
+
+       Gtk::Label *tensionLabel = manage(new Gtk::Label(_("T_ension"), true));
+       tensionLabel->set_alignment(0, 0.5);
+       tensionLabel->set_mnemonic_widget(*spin_tension);
+       spin_tension->set_alignment(1);
+       tcbTable->attach(*tensionLabel, 0, 1, 0, 1, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       tcbTable->attach(*spin_tension, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+       Gtk::Label *continuityLabel = manage(new Gtk::Label(_("_Continuity"), true));
+       continuityLabel->set_alignment(0, 0.5);
+       continuityLabel->set_mnemonic_widget(*spin_continuity);
+       spin_continuity->set_alignment(1);
+       tcbTable->attach(*continuityLabel, 0, 1, 1, 2, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       tcbTable->attach(*spin_continuity, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+       Gtk::Label *biasLabel = manage(new Gtk::Label(_("_Bias"), true));
+       biasLabel->set_alignment(0, 0.5);
+       biasLabel->set_mnemonic_widget(*spin_bias);
+       spin_bias->set_alignment(1);
+       tcbTable->attach(*biasLabel, 0, 1, 2, 3, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       tcbTable->attach(*spin_bias, 1, 2, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+       Gtk::Label *temporalTensionLabel = manage(new Gtk::Label(_("Te_mporal Tension"), true));
+       temporalTensionLabel->set_alignment(0, 0.5);
+       temporalTensionLabel->set_mnemonic_widget(*spin_temporal_tension);
+       spin_temporal_tension->set_alignment(1);
+       tcbTable->attach(*temporalTensionLabel, 0, 1, 3, 4, Gtk::SHRINK | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+       tcbTable->attach(*spin_temporal_tension, 1, 2, 3, 4, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
+
+       show_all();
+       hide();
+       //attach(*hbox, 1, 4, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       set_canvas(canvas);
+}
+
+void
+Widget_Waypoint::set_canvas(synfig::Canvas::Handle x)
+{
+       canvas=x;
+       assert(canvas);
+
+       time_widget->set_fps(canvas->rend_desc().get_frame_rate());
+       value_widget->set_canvas(canvas);
+}
+
+void
+Widget_Waypoint::set_waypoint(synfig::Waypoint &x)
+{
+       time_widget->set_fps(canvas->rend_desc().get_frame_rate());
+
+       waypoint=x;
+
+       //! \todo This really needs to be fixed to support value node waypoints!
+       if(waypoint.is_static())
+       {
+               value_widget->set_value(waypoint.get_value());
+               value_widget->show();
+               value_node_label->hide();
+       }
+       else
+       {
+               value_widget->hide();
+               value_node_label->show();
+       }
+
+       time_widget->set_value(waypoint.get_time());
+
+       before->set_history((int)waypoint.get_before());
+       after->set_history((int)waypoint.get_after());
+
+       adj_tension.set_value(waypoint.get_tension());
+       adj_continuity.set_value(waypoint.get_continuity());
+       adj_bias.set_value(waypoint.get_bias());
+       adj_temporal_tension.set_value(waypoint.get_temporal_tension());
+
+}
+const synfig::Waypoint &
+Widget_Waypoint::get_waypoint()const
+{
+       //! \todo This too!
+       waypoint.set_time(time_widget->get_value());
+       if(waypoint.is_static())
+               waypoint.set_value(value_widget->get_value());
+       //int i;
+
+       waypoint.set_before((synfig::Waypoint::Interpolation)before->get_history());
+       waypoint.set_after((synfig::Waypoint::Interpolation)after->get_history());
+
+       waypoint.set_tension(adj_tension.get_value());
+       waypoint.set_continuity(adj_continuity.get_value());
+       waypoint.set_bias(adj_bias.get_value());
+       waypoint.set_temporal_tension(adj_temporal_tension.get_value());
+       return waypoint;
+}
diff --git a/synfig-studio/src/gui/widget_waypoint.h b/synfig-studio/src/gui/widget_waypoint.h
new file mode 100644 (file)
index 0000000..be87119
--- /dev/null
@@ -0,0 +1,96 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_waypoint.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_GTKMM_WIDGET_WAYPOINT_H
+#define __SYNFIG_GTKMM_WIDGET_WAYPOINT_H
+
+/* === H E A D E R S ======================================================= */
+
+//#include <gtk/gtk.h>
+//#include <gtkmm/arrow.h>
+//#include <gtkmm/image.h>
+//#include <gdkmm/pixbufloader.h>
+//#include <gtkmm/viewport.h>
+#include <gtkmm/adjustment.h>
+//#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/table.h>
+#include <gtkmm/button.h>
+//#include <gtkmm/progressbar.h>
+//#include <gtkmm/paned.h>
+#include <gtkmm/box.h>
+//#include <gtkmm/scrollbar.h>
+#include <gtkmm/combo.h>
+#include <gtkmm/optionmenu.h>
+#include <gtkmm/spinbutton.h>
+#include <gtkmm/alignment.h>
+
+#include <synfigapp/value_desc.h>
+#include <synfig/waypoint.h>
+//#include <synfig/valuenode_dynamiclist.h>
+#include <synfig/string.h>
+#include <synfig/time.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 Widget_ValueBase;
+class Widget_Time;
+class Widget_Waypoint;
+
+class Widget_Waypoint : public Gtk::Alignment
+{
+    Widget_ValueBase *value_widget;
+       Gtk::Label *value_node_label;
+       Gtk::Label *label;
+       Widget_Time *time_widget;
+       mutable synfig::Waypoint waypoint;
+       synfig::Canvas::Handle canvas;
+       //Gtk::Adjustment time_adjustment;
+
+       Gtk::Combo *in,*out;
+       Gtk::OptionMenu *before, *after;
+       Gtk::Menu *before_options,*after_options;
+
+       Gtk::SpinButton *spin_tension, *spin_continuity, *spin_bias, *spin_temporal_tension;
+       Gtk::Adjustment adj_tension, adj_continuity, adj_bias, adj_temporal_tension;
+//     Gtk::ComboDropDownItem item;
+
+public:
+       Widget_Waypoint(etl::handle<synfig::Canvas> canvas);
+       void set_canvas(synfig::Canvas::Handle x);
+       void set_waypoint(synfig::Waypoint &x);
+       const synfig::Waypoint &get_waypoint()const;
+}; // END of class Widget_Waypoint
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/widget_waypointmodel.cpp b/synfig-studio/src/gui/widget_waypointmodel.cpp
new file mode 100644 (file)
index 0000000..28dacd5
--- /dev/null
@@ -0,0 +1,191 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_waypointmodel.cpp
+**     \brief Template Header
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**  Copyright (c) 2008 Paul Wise
+**
+**     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 <config.h>
+#endif
+
+#include <gtkmm/label.h>
+#include <gtkmm/spinbutton.h>
+#include <ETL/stringf>
+#include "widget_value.h"
+#include "app.h"
+#include <gtkmm/menu.h>
+#include <gtkmm/optionmenu.h>
+#include "widget_time.h"
+#include "widget_waypointmodel.h"
+#include "general.h"
+
+#endif
+
+using namespace synfig;
+using namespace std;
+using namespace etl;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Widget_WaypointModel::Widget_WaypointModel():
+       Gtk::Table(4,3,false),
+       adj_tension(0.0,-20,20,0.1,1),
+       adj_continuity(0.0,-20,20,0.1,1),
+       adj_bias(0.0,-20,20,0.1,1),
+       adj_temporal_tension(0.0,-20,20,0.1,1),
+       checkbutton_after(_("Out:")),
+       checkbutton_before(_("In:")),
+       checkbutton_tension(_("Tension:")),
+       checkbutton_continuity(_("Continuity:")),
+       checkbutton_bias(_("Bias:")),
+       checkbutton_temporal_tension(_("Temporal Tension:"))
+{
+       before_options=manage(new class Gtk::Menu());
+       before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("TCB Smooth")));
+       before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Constant")));
+       before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Linear")));
+       before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Ease In")));
+       // before_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Manual")));
+
+       after_options=manage(new class Gtk::Menu());
+       after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("TCB Smooth")));
+       after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Constant")));
+       after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Linear")));
+       after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Ease Out")));
+       // after_options->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Manual")));
+
+       before=manage(new class Gtk::OptionMenu());
+       before->show();
+       before->set_menu(*before_options);
+
+       after=manage(new class Gtk::OptionMenu());
+       after->show();
+       after->set_menu(*after_options);
+
+       spin_tension=manage(new class Gtk::SpinButton(adj_tension,0.1,3));
+       spin_tension->show();
+       spin_continuity=manage(new class Gtk::SpinButton(adj_continuity,0.1,3));
+       spin_continuity->show();
+       spin_bias=manage(new class Gtk::SpinButton(adj_bias,0.1,3));
+       spin_bias->show();
+       spin_temporal_tension=manage(new class Gtk::SpinButton(adj_temporal_tension,0.1,3));
+       spin_temporal_tension->show();
+
+       checkbutton_before.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
+       checkbutton_after.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
+       checkbutton_tension.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
+       checkbutton_continuity.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
+       checkbutton_bias.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
+       checkbutton_temporal_tension.signal_toggled().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
+
+       adj_tension.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
+       adj_continuity.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
+       adj_bias.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
+       adj_temporal_tension.signal_value_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
+
+       before->signal_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
+       after->signal_changed().connect(sigc::mem_fun(*this,&Widget_WaypointModel::on_change));
+
+       attach(checkbutton_before, 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       attach(*before, 1, 2, 0,1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       attach(checkbutton_after, 2, 3, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       attach(*after, 3, 4, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       attach(checkbutton_tension, 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       attach(*spin_tension, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       attach(checkbutton_continuity, 2, 3, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       attach(*spin_continuity, 3, 4, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       attach(checkbutton_bias, 0, 1, 2, 3, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       attach(*spin_bias, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       attach(checkbutton_temporal_tension, 2, 3, 2, 3, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       attach(*spin_temporal_tension, 3, 4, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       show_all();
+       hide();
+       updating=false;
+       on_change();
+}
+
+void
+Widget_WaypointModel::on_change()
+{
+       if(updating)
+               return;
+
+       waypoint_model.set_before((Waypoint::Interpolation)before->get_history());
+       waypoint_model.set_after((Waypoint::Interpolation)after->get_history());
+
+       waypoint_model.set_tension(adj_tension.get_value());
+       waypoint_model.set_continuity(adj_continuity.get_value());
+       waypoint_model.set_bias(adj_bias.get_value());
+       waypoint_model.set_temporal_tension(adj_temporal_tension.get_value());
+
+       waypoint_model.set_before_flag(checkbutton_before.get_active());
+       waypoint_model.set_after_flag(checkbutton_after.get_active());
+       waypoint_model.set_tension_flag(checkbutton_tension.get_active());
+       waypoint_model.set_continuity_flag(checkbutton_continuity.get_active());
+       waypoint_model.set_bias_flag(checkbutton_bias.get_active());
+       waypoint_model.set_temporal_tension_flag(checkbutton_temporal_tension.get_active());
+
+       before->set_sensitive(checkbutton_before.get_active());
+       after->set_sensitive(checkbutton_after.get_active());
+       spin_tension->set_sensitive(checkbutton_tension.get_active());
+       spin_continuity->set_sensitive(checkbutton_continuity.get_active());
+       spin_bias->set_sensitive(checkbutton_bias.get_active());
+       spin_temporal_tension->set_sensitive(checkbutton_temporal_tension.get_active());
+}
+
+void
+Widget_WaypointModel::set_waypoint_model(synfig::Waypoint::Model &x)
+{
+       waypoint_model=x;
+       updating=true;
+
+       before->set_history((int)waypoint_model.get_before());
+       after->set_history((int)waypoint_model.get_after());
+
+       adj_tension.set_value(waypoint_model.get_tension());
+       adj_continuity.set_value(waypoint_model.get_continuity());
+       adj_bias.set_value(waypoint_model.get_bias());
+       adj_temporal_tension.set_value(waypoint_model.get_temporal_tension());
+
+       checkbutton_before.set_active(waypoint_model.get_before_flag());
+       checkbutton_after.set_active(waypoint_model.get_after_flag());
+       checkbutton_tension.set_active(waypoint_model.get_tension_flag());
+       checkbutton_continuity.set_active(waypoint_model.get_continuity_flag());
+       checkbutton_bias.set_active(waypoint_model.get_bias_flag());
+       checkbutton_temporal_tension.set_active(waypoint_model.get_temporal_tension_flag());
+
+       updating=false;
+
+       on_change();
+}
diff --git a/synfig-studio/src/gui/widget_waypointmodel.h b/synfig-studio/src/gui/widget_waypointmodel.h
new file mode 100644 (file)
index 0000000..d8628a7
--- /dev/null
@@ -0,0 +1,95 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file widget_waypointmodel.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_GTKMM_WIDGET_WAYPOINTMODEL_H
+#define __SYNFIG_GTKMM_WIDGET_WAYPOINTMODEL_H
+
+/* === H E A D E R S ======================================================= */
+
+//#include <gtk/gtk.h>
+//#include <gtkmm/arrow.h>
+//#include <gtkmm/image.h>
+//#include <gdkmm/pixbufloader.h>
+//#include <gtkmm/viewport.h>
+//#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/table.h>
+#include <gtkmm/button.h>
+//#include <gtkmm/progressbar.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/box.h>
+#include <gtkmm/combo.h>
+#include <gtkmm/optionmenu.h>
+#include <gtkmm/spinbutton.h>
+#include <gtkmm/checkbutton.h>
+
+
+#include <synfig/waypoint.h>
+#include <synfig/string.h>
+#include <synfig/time.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 Widget_Time;
+class Widget_WaypointModel;
+
+class Widget_WaypointModel : public Gtk::Table
+{
+       synfig::Waypoint::Model waypoint_model;
+
+       bool updating;
+
+       Gtk::Combo *in,*out;
+       Gtk::OptionMenu *before, *after;
+       Gtk::Menu *before_options,*after_options;
+
+       Gtk::SpinButton *spin_tension, *spin_continuity, *spin_bias, *spin_temporal_tension;
+       Gtk::Adjustment adj_tension, adj_continuity, adj_bias, adj_temporal_tension;
+
+       Gtk::CheckButton checkbutton_after;
+       Gtk::CheckButton checkbutton_before;
+       Gtk::CheckButton checkbutton_tension;
+       Gtk::CheckButton checkbutton_continuity;
+       Gtk::CheckButton checkbutton_bias;
+       Gtk::CheckButton checkbutton_temporal_tension;
+
+       void on_change();
+
+public:
+       Widget_WaypointModel();
+       void set_waypoint_model(synfig::Waypoint::Model &x);
+       const synfig::Waypoint::Model &get_waypoint_model()const { return waypoint_model; }
+}; // END of class Widget_WaypointModel
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/workarea.cpp b/synfig-studio/src/gui/workarea.cpp
new file mode 100644 (file)
index 0000000..d2a1f3b
--- /dev/null
@@ -0,0 +1,2798 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file workarea.cpp
+**     \brief Template Header
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2006 Yue Shi Lai
+**     Copyright (c) 2007, 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 <config.h>
+#endif
+
+#include <sigc++/adaptors/hide.h>
+
+#include "workarea.h"
+#include "canvasview.h"
+#include "app.h"
+#include <gtkmm/window.h>
+#include <gtkmm/image.h>
+#include <gtkmm/drawingarea.h>
+#include <gtkmm/ruler.h>
+#include <gtkmm/arrow.h>
+#include <gtkmm/image.h>
+#include <gtkmm/scrollbar.h>
+#include <cmath>
+#include <sigc++/retype_return.h>
+#include <sigc++/retype.h>
+#include <sigc++/hide.h>
+#include <ETL/misc>
+
+#include <synfig/target_scanline.h>
+#include <synfig/target_tile.h>
+#include <synfig/surface.h>
+#include <synfig/valuenode_composite.h>
+#include <synfigapp/canvasinterface.h>
+#include "event_mouse.h"
+#include "event_layerclick.h"
+#include "widget_color.h"
+#include <synfig/distance.h>
+#include "workarearenderer.h"
+
+#include "renderer_canvas.h"
+#include "renderer_grid.h"
+#include "renderer_guides.h"
+#include "renderer_timecode.h"
+#include "renderer_ducks.h"
+#include "renderer_dragbox.h"
+#include "renderer_bbox.h"
+#include "asyncrenderer.h"
+#include <gtkmm/frame.h>
+
+#include <synfig/mutex.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 ========================================================= */
+
+#ifndef stratof
+#define stratof(X) (atof((X).c_str()))
+#define stratoi(X) (atoi((X).c_str()))
+#endif
+
+
+/* === G L O B A L S ======================================================= */
+
+/* === C L A S S E S ======================================================= */
+
+class studio::WorkAreaTarget : public synfig::Target_Tile
+{
+public:
+       WorkArea *workarea;
+       bool low_res;
+       int w,h;
+       int real_tile_w,real_tile_h;
+       //std::vector<Glib::RefPtr<Gdk::Pixbuf> >::iterator tile_iter;
+
+       int twindow_start, twindow_width, twindow_height, twindow_pad;
+       int refresh_id;
+
+       bool onionskin;
+       bool onion_first_tile;
+       int onion_layers;
+
+       std::list<synfig::Time> onion_skin_queue;
+
+       synfig::Mutex mutex;
+
+       void set_onion_skin(bool x, int *onions)
+       {
+               onionskin=x;
+
+               Time time(rend_desc().get_time_start());
+
+               if(!onionskin)
+                       return;
+               onion_skin_queue.push_back(time);
+
+               try
+               {
+               Time thistime=time;
+               for(int i=0; i<onions[0]; i++)
+                       {
+                               Time keytime=get_canvas()->keyframe_list().find_prev(thistime)->get_time();
+                               onion_skin_queue.push_back(keytime);
+                               thistime=keytime;
+                       }
+               }
+               catch(...)
+               {  }
+
+               try
+               {
+               Time thistime=time;
+               for(int i=0; i<onions[1]; i++)
+                       {
+                               Time keytime=get_canvas()->keyframe_list().find_next(thistime)->get_time();
+                               onion_skin_queue.push_back(keytime);
+                               thistime=keytime;
+                       }
+               }
+               catch(...)
+               {  }
+
+               onion_layers=onion_skin_queue.size();
+
+               onion_first_tile=false;
+       }
+public:
+
+       WorkAreaTarget(WorkArea *workarea,int w, int h):
+               workarea(workarea),
+               low_res(workarea->get_low_resolution_flag()),
+               w(w),
+               h(h),
+               real_tile_w(workarea->tile_w),
+               real_tile_h(workarea->tile_h),
+               refresh_id(workarea->refreshes),
+               onionskin(false),
+               onion_layers(0)
+       {
+               //set_remove_alpha();
+               //set_avoid_time_sync();
+               set_clipping(true);
+               if(low_res)
+               {
+                       int div = workarea->get_low_res_pixel_size();
+                       set_tile_w(workarea->tile_w/div);
+                       set_tile_h(workarea->tile_h/div);
+               }
+               else
+               {
+                       set_tile_w(workarea->tile_w);
+                       set_tile_h(workarea->tile_h);
+               }
+               set_canvas(workarea->get_canvas());
+               set_quality(workarea->get_quality());
+       }
+
+       ~WorkAreaTarget()
+       {
+               workarea->queue_draw();
+       }
+
+       virtual bool set_rend_desc(synfig::RendDesc *newdesc)
+       {
+               assert(workarea);
+               newdesc->set_flags(RendDesc::PX_ASPECT|RendDesc::IM_SPAN);
+               if(low_res) {
+                       int div = workarea->get_low_res_pixel_size();
+                       newdesc->set_wh(w/div,h/div);
+               }
+               else
+                       newdesc->set_wh(w,h);
+
+               if(
+                               workarea->get_w()!=w
+                       ||      workarea->get_h()!=h
+               ) workarea->set_wh(w,h,4);
+
+               workarea->full_frame=false;
+
+               desc=*newdesc;
+               return true;
+       }
+
+       virtual int total_tiles()const
+       {
+               int tw(rend_desc().get_w()/get_tile_w());
+               int th(rend_desc().get_h()/get_tile_h());
+               if(rend_desc().get_w()%get_tile_w()!=0)tw++;
+               if(rend_desc().get_h()%get_tile_h()!=0)th++;
+               return tw*th;
+       }
+
+       virtual int next_frame(Time& time)
+       {
+               synfig::Mutex::Lock lock(mutex);
+
+               if(!onionskin)
+                       return synfig::Target_Tile::next_frame(time);
+
+               onion_first_tile=(onion_layers==(signed)onion_skin_queue.size());
+
+               if(!onion_skin_queue.empty())
+               {
+                       time=onion_skin_queue.front();
+                       onion_skin_queue.pop_front();
+               }
+               else
+                       return 0;
+
+               return onion_skin_queue.size()+1;
+       }
+
+       virtual int next_tile(int& x, int& y)
+       {
+               synfig::Mutex::Lock lock(mutex);
+               //if(workarea->tile_queue.empty()) return 0;
+
+               //int curr_tile(workarea->tile_queue.front());
+               //workarea->tile_queue.pop_front();
+               int curr_tile(workarea->next_unrendered_tile(refresh_id-onion_skin_queue.size()));
+               if(curr_tile<0)
+                       return 0;
+
+               // Width of the image(in tiles)
+               int tw(rend_desc().get_w()/get_tile_w());
+               if(rend_desc().get_w()%get_tile_w()!=0)tw++;
+
+               y=(curr_tile/tw)*get_tile_w();
+               x=(curr_tile%tw)*get_tile_h();
+
+               // Mark this tile as "up-to-date"
+               if(onionskin)
+                       workarea->tile_book[curr_tile].second=refresh_id-onion_skin_queue.size();
+               else
+                       workarea->tile_book[curr_tile].second=refresh_id;
+
+               return total_tiles()-curr_tile+1;
+       }
+
+
+       virtual bool start_frame(synfig::ProgressCallback */*cb*/)
+       {
+               synfig::Mutex::Lock lock(mutex);
+
+               int tw(rend_desc().get_w()/get_tile_w());
+               if(rend_desc().get_w()%get_tile_w()!=0)tw++;
+               int th(rend_desc().get_h()/get_tile_h());
+               if(rend_desc().get_h()%get_tile_h()!=0)th++;
+
+               twindow_start=0;
+               twindow_width=tw;
+               twindow_height=th;
+               twindow_pad=0;
+
+               workarea->tile_book.resize(total_tiles());
+               //tile_iter=workarea->tile_book.begin()+twindow_start;
+               return true;
+       }
+
+       static void free_buff(const guint8 *x) { free(const_cast<guint8*>(x)); }
+
+       virtual bool add_tile(const synfig::Surface &surface, int x, int y)
+       {
+               synfig::Mutex::Lock lock(mutex);
+               assert(surface);
+
+               PixelFormat pf(PF_RGB);
+
+               const int total_bytes(get_tile_w()*get_tile_h()*synfig::channels(pf));
+
+               unsigned char *buffer((unsigned char*)malloc(total_bytes));
+
+               if(!surface || !buffer)
+                       return false;
+               {
+                       unsigned char *dest(buffer);
+                       const Color *src(surface[0]);
+                       int w(get_tile_w());
+                       int h(get_tile_h());
+                       int x(surface.get_w()*surface.get_h());
+                       //if(low_res) {
+                       //      int div = workarea->get_low_res_pixel_size();
+                       //      w/=div,h/=div;
+                       //}
+                       Color dark(0.6,0.6,0.6);
+                       Color lite(0.8,0.8,0.8);
+                       for(int i=0;i<x;i++)
+                               dest=Color2PixelFormat(
+                                       Color::blend(
+                                               (*(src++)),
+                                               ((i/surface.get_w())*8/h+(i%surface.get_w())*8/w)&1?dark:lite,
+                                               1.0f
+                                       ).clamped(),
+                                       pf,dest,App::gamma
+                               );
+               }
+
+               x/=get_tile_w();
+               y/=get_tile_h();
+               int tw(rend_desc().get_w()/get_tile_w());
+               if(rend_desc().get_w()%get_tile_w()!=0)tw++;
+               unsigned int index=y*tw+x;
+
+               // Sanity check
+               if(index>workarea->tile_book.size())
+                       return false;
+
+               Glib::RefPtr<Gdk::Pixbuf> pixbuf;
+
+               pixbuf=Gdk::Pixbuf::create_from_data(
+                       buffer, // pointer to the data
+                       Gdk::COLORSPACE_RGB, // the colorspace
+                       ((pf&PF_A)==PF_A), // has alpha?
+                       8, // bits per sample
+                       surface.get_w(),        // width
+                       surface.get_h(),        // height
+                       surface.get_w()*synfig::channels(pf), // stride (pitch)
+                       sigc::ptr_fun(&WorkAreaTarget::free_buff)
+               );
+
+               if(low_res)
+               {
+                       // We need to scale up
+                       int div = workarea->get_low_res_pixel_size();
+                       pixbuf=pixbuf->scale_simple(
+                               surface.get_w()*div,
+                               surface.get_h()*div,
+                               Gdk::INTERP_NEAREST
+                       );
+               }
+
+               if(!onionskin || onion_first_tile || !workarea->tile_book[index].first)
+               {
+                       workarea->tile_book[index].first=pixbuf;
+               }
+               else
+               {
+                       pixbuf->composite(
+                               workarea->tile_book[index].first, // Dest
+                               0,//int dest_x
+                               0,//int dest_y
+                               pixbuf->get_width(), // dest width
+                               pixbuf->get_height(), // dest_height,
+                               0, // double offset_x
+                               0, // double offset_y
+                               1, // double scale_x
+                               1, // double scale_y
+                               Gdk::INTERP_NEAREST, // interp
+                               255/(onion_layers-onion_skin_queue.size()+1) //int overall_alpha
+                       );
+               }
+
+               //if(index%2)
+                       workarea->queue_draw();
+               assert(workarea->tile_book[index].first);
+               return true;
+       }
+
+       virtual void end_frame()
+       {
+               //workarea->queue_draw();
+       }
+};
+
+
+class studio::WorkAreaTarget_Full : public synfig::Target_Scanline
+{
+public:
+       WorkArea *workarea;
+       bool low_res;
+       int w,h;
+       int real_tile_w,real_tile_h;
+       //std::vector<Glib::RefPtr<Gdk::Pixbuf> >::iterator tile_iter;
+
+       int twindow_start, twindow_width, twindow_height, twindow_pad;
+       int refresh_id;
+
+       bool onionskin;
+       bool onion_first_tile;
+       int onion_layers;
+
+       Surface surface;
+
+       std::list<synfig::Time> onion_skin_queue;
+
+       void set_onion_skin(bool x, int *onions)
+       {
+               onionskin=x;
+
+               Time time(rend_desc().get_time_start());
+
+               if(!onionskin)
+                       return;
+               onion_skin_queue.push_back(time);
+               //onion_skin_queue.push_back(time-1);
+               //onion_skin_queue.push_back(time+1);
+               try
+               {
+               Time thistime=time;
+               for(int i=0; i<onions[0]; i++)
+                       {
+                               Time keytime=get_canvas()->keyframe_list().find_prev(thistime)->get_time();
+                               onion_skin_queue.push_back(keytime);
+                               thistime=keytime;
+                       }
+               }
+               catch(...)
+               {  }
+
+               try
+               {
+               Time thistime=time;
+               for(int i=0; i<onions[1]; i++)
+                       {
+                               Time keytime=get_canvas()->keyframe_list().find_next(thistime)->get_time();
+                               onion_skin_queue.push_back(keytime);
+                               thistime=keytime;
+                       }
+               }
+               catch(...)
+               {  }
+
+               onion_layers=onion_skin_queue.size();
+
+               onion_first_tile=false;
+       }
+public:
+
+       WorkAreaTarget_Full(WorkArea *workarea,int w, int h):
+               workarea(workarea),
+               low_res(workarea->get_low_resolution_flag()),
+               w(w),
+               h(h),
+               refresh_id(workarea->refreshes),
+               onionskin(false),
+               onion_layers(0)
+       {
+               set_canvas(workarea->get_canvas());
+               set_quality(workarea->get_quality());
+       }
+
+       ~WorkAreaTarget_Full()
+       {
+       }
+
+       virtual bool set_rend_desc(synfig::RendDesc *newdesc)
+       {
+               assert(workarea);
+               newdesc->set_flags(RendDesc::PX_ASPECT|RendDesc::IM_SPAN);
+               if(low_res)
+               {
+                       int div = workarea->get_low_res_pixel_size();
+                       newdesc->set_wh(w/div,h/div);
+               }
+               else
+                       newdesc->set_wh(w,h);
+
+               if(
+                               workarea->get_w()!=w
+                       ||      workarea->get_h()!=h
+               ) workarea->set_wh(w,h,4);
+
+               surface.set_wh(newdesc->get_w(),newdesc->get_h());
+
+               desc=*newdesc;
+               workarea->full_frame=true;
+               workarea->tile_book.resize(1);
+               return true;
+       }
+
+       virtual int next_frame(Time& time)
+       {
+               // Mark this tile as "up-to-date"
+               if(onionskin)
+                       workarea->tile_book[0].second=refresh_id-onion_skin_queue.size();
+               else
+                       workarea->tile_book[0].second=refresh_id;
+
+               if(!onionskin)
+                       return synfig::Target_Scanline::next_frame(time);
+
+               onion_first_tile=(onion_layers==(signed)onion_skin_queue.size());
+
+               if(!onion_skin_queue.empty())
+               {
+                       time=onion_skin_queue.front();
+                       onion_skin_queue.pop_front();
+               }
+               else
+                       return 0;
+               return onion_skin_queue.size()+1;
+       }
+
+
+       virtual bool start_frame(synfig::ProgressCallback */*cb*/)
+       {
+               return true;
+       }
+
+       virtual Color * start_scanline(int scanline)
+       {
+               return surface[scanline];
+       }
+
+       virtual bool end_scanline()
+       {
+               return true;
+       }
+
+       static void free_buff(const guint8 *x) { free(const_cast<guint8*>(x)); }
+
+       virtual void end_frame()
+       {
+               assert(surface);
+
+               PixelFormat pf(PF_RGB);
+
+               const int total_bytes(surface.get_w()*surface.get_h()*synfig::channels(pf));
+
+               unsigned char *buffer((unsigned char*)malloc(total_bytes));
+
+               if(!surface || !buffer)
+                       return;
+               {
+                       unsigned char *dest(buffer);
+                       const Color *src(surface[0]);
+                       int w(surface.get_w());
+                       //int h(surface.get_h());
+                       int x(surface.get_w()*surface.get_h());
+                       //if(low_res) {
+                       //      int div = workarea->get_low_res_pixel_size();
+                       //      w/=div,h/=div;
+                       //}
+                       Color dark(0.6,0.6,0.6);
+                       Color lite(0.8,0.8,0.8);
+                       int tw=workarea->tile_w;
+                       int th=workarea->tile_h;
+                       if(low_res)
+                       {
+                               int div = workarea->get_low_res_pixel_size();
+                               tw/=div;
+                               th/=div;
+                       }
+                       for(int i=0;i<x;i++)
+                               dest=Color2PixelFormat(
+                                       Color::blend(
+                                               (*(src++)),
+                                               ((i/w)*8/th+(i%w)*8/tw)&1?dark:lite,
+                                               1.0f
+                                       ).clamped(),
+                                       pf,
+                                       dest,
+                                       App::gamma
+                               );
+               }
+
+               Glib::RefPtr<Gdk::Pixbuf> pixbuf;
+
+               pixbuf=Gdk::Pixbuf::create_from_data(
+                       buffer, // pointer to the data
+                       Gdk::COLORSPACE_RGB, // the colorspace
+                       ((pf&PF_A)==PF_A), // has alpha?
+                       8, // bits per sample
+                       surface.get_w(),        // width
+                       surface.get_h(),        // height
+                       surface.get_w()*synfig::channels(pf), // stride (pitch)
+                       sigc::ptr_fun(&WorkAreaTarget::free_buff)
+               );
+
+               if(low_res)
+               {
+                       // We need to scale up
+                       int div = workarea->get_low_res_pixel_size();
+                       pixbuf=pixbuf->scale_simple(
+                               surface.get_w()*div,
+                               surface.get_h()*div,
+                               Gdk::INTERP_NEAREST
+                       );
+               }
+
+               int index=0;
+
+               if(!onionskin || onion_first_tile || !workarea->tile_book[index].first)
+               {
+                       workarea->tile_book[index].first=pixbuf;
+               }
+               else
+               {
+                       pixbuf->composite(
+                               workarea->tile_book[index].first, // Dest
+                               0,//int dest_x
+                               0,//int dest_y
+                               pixbuf->get_width(), // dest width
+                               pixbuf->get_height(), // dest_height,
+                               0, // double offset_x
+                               0, // double offset_y
+                               1, // double scale_x
+                               1, // double scale_y
+                               Gdk::INTERP_NEAREST, // interp
+                               255/(onion_layers-onion_skin_queue.size()+1) //int overall_alpha
+                       );
+               }
+
+               workarea->queue_draw();
+               assert(workarea->tile_book[index].first);
+       }
+};
+
+
+
+
+/* === M E T H O D S ======================================================= */
+
+
+WorkArea::WorkArea(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface):
+       Gtk::Table(3, 3, false), /* 3 columns by 3 rows*/
+       canvas_interface(canvas_interface),
+       canvas(canvas_interface->get_canvas()),
+       scrollx_adjustment(0,-4,4,0.01,0.1),
+       scrolly_adjustment(0,-4,4,0.01,0.1),
+       w(TILE_SIZE),
+       h(TILE_SIZE),
+       last_event_time(0),
+       progresscallback(0),
+       dragging(DRAG_NONE),
+       show_grid(false),
+       tile_w(TILE_SIZE),
+       tile_h(TILE_SIZE),
+       timecode_width(0),
+       timecode_height(0)
+{
+       show_guides=true;
+       curr_input_device=0;
+       full_frame=false;
+       allow_duck_clicks=true;
+       allow_layer_clicks=true;
+       render_idle_func_id=0;
+       zoom=prev_zoom=1.0;
+       quality=10;
+       low_res_pixel_size=2;
+       rendering=false;
+       canceled_=false;
+       low_resolution=true;
+       pw=0.001;
+       ph=0.001;
+       last_focus_point=Point(0,0);
+       onion_skin=false;
+       onion_skins[0]=0;
+       onion_skins[1]=0;
+       queued=false;
+       dirty_trap_enabled=false;
+       solid_lines=true;
+
+       dirty_trap_queued=0;
+
+       meta_data_lock=false;
+
+       insert_renderer(new Renderer_Canvas,    000);
+       insert_renderer(new Renderer_Grid,              100);
+       insert_renderer(new Renderer_Guides,    200);
+       insert_renderer(new Renderer_Ducks,             300);
+       insert_renderer(new Renderer_BBox,              399);
+       insert_renderer(new Renderer_Dragbox,   400);
+       insert_renderer(new Renderer_Timecode,  500);
+
+       signal_duck_selection_changed().connect(sigc::mem_fun(*this,&studio::WorkArea::queue_draw));
+       signal_strokes_changed().connect(sigc::mem_fun(*this,&studio::WorkArea::queue_draw));
+       signal_grid_changed().connect(sigc::mem_fun(*this,&studio::WorkArea::queue_draw));
+       signal_grid_changed().connect(sigc::mem_fun(*this,&studio::WorkArea::save_meta_data));
+       signal_sketch_saved().connect(sigc::mem_fun(*this,&studio::WorkArea::save_meta_data));
+
+       // Not that it really makes a difference... (setting this to zero, that is)
+       refreshes=0;
+
+       drawing_area=manage(new class Gtk::DrawingArea());
+       drawing_area->show();
+       drawing_area->set_extension_events(Gdk::EXTENSION_EVENTS_ALL);
+
+       drawing_frame=manage(new Gtk::Frame);
+       drawing_frame->add(*drawing_area);
+       //drawing_frame->set_shadow_type(Gtk::SHADOW_NONE);
+       //drawing_frame->property_border_width()=5;
+       //drawing_frame->modify_fg(Gtk::STATE_NORMAL,Gdk::Color("#00ffff"));
+       //drawing_frame->modify_base(Gtk::STATE_NORMAL,Gdk::Color("#ff00ff"));
+       /*drawing_frame->modify_fg(Gtk::STATE_ACTIVE,Gdk::Color("#00ffff"));
+       drawing_frame->modify_base(Gtk::STATE_ACTIVE,Gdk::Color("#ff00ff"));
+       drawing_frame->modify_bg(Gtk::STATE_ACTIVE,Gdk::Color("#00ff00"));
+       drawing_frame->modify_fg(Gtk::STATE_INSENSITIVE,Gdk::Color("#00ffff"));
+       drawing_frame->modify_base(Gtk::STATE_INSENSITIVE,Gdk::Color("#ff00ff"));
+       drawing_frame->modify_bg(Gtk::STATE_INSENSITIVE,Gdk::Color("#00ff00"));
+       drawing_frame->modify_fg(Gtk::STATE_SELECTED,Gdk::Color("#00ffff"));
+       drawing_frame->modify_base(Gtk::STATE_SELECTED,Gdk::Color("#ff00ff"));
+       drawing_frame->modify_bg(Gtk::STATE_SELECTED,Gdk::Color("#00ff00"));
+       */
+       //drawing_frame->set_state(Gtk::STATE_NORMAL);
+
+       drawing_frame->show();
+
+       attach(*drawing_frame, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       Gtk::IconSize iconsize=Gtk::IconSize::from_name("synfig-small_icon");
+
+
+       // Create the vertical and horizontal rulers
+       vruler = manage(new class Gtk::VRuler());
+       hruler = manage(new class Gtk::HRuler());
+       vruler->set_metric(Gtk::PIXELS);
+       hruler->set_metric(Gtk::PIXELS);
+       Pango::FontDescription fd(hruler->get_style()->get_font());
+       fd.set_size(Pango::SCALE*8);
+       vruler->modify_font(fd);
+       hruler->modify_font(fd);
+       vruler->show();
+       hruler->show();
+       attach(*vruler, 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+       attach(*hruler, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       hruler->signal_event().connect(sigc::mem_fun(*this, &WorkArea::on_hruler_event));
+       vruler->signal_event().connect(sigc::mem_fun(*this, &WorkArea::on_vruler_event));
+       hruler->add_events(Gdk::BUTTON1_MOTION_MASK | Gdk::BUTTON2_MOTION_MASK |Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
+       vruler->add_events(Gdk::BUTTON1_MOTION_MASK | Gdk::BUTTON2_MOTION_MASK |Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK);
+
+       // Create the menu button
+       menubutton=manage(new class Gtk::Button());
+       Gtk::Arrow *arrow1 = manage(new class Gtk::Arrow(Gtk::ARROW_RIGHT, Gtk::SHADOW_OUT));
+       arrow1->set_size_request(10,10);
+       menubutton->add(*arrow1);
+       menubutton->show_all();
+       menubutton->signal_pressed().connect(sigc::mem_fun(*this, &WorkArea::popup_menu));
+       attach(*menubutton, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+
+       Gtk::HBox *hbox = manage(new class Gtk::HBox(false, 0));
+
+       Gtk::VScrollbar *vscrollbar1 = manage(new class Gtk::VScrollbar(*get_scrolly_adjustment()));
+       Gtk::HScrollbar *hscrollbar1 = manage(new class Gtk::HScrollbar(*get_scrollx_adjustment()));
+       vscrollbar1->show();
+       attach(*vscrollbar1, 2, 3, 1, 2, Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+       ZoomDial *zoomdial=manage(new class ZoomDial(iconsize));
+       zoomdial->signal_zoom_in().connect(sigc::mem_fun(*this, &studio::WorkArea::zoom_in));
+       zoomdial->signal_zoom_out().connect(sigc::mem_fun(*this, &studio::WorkArea::zoom_out));
+       zoomdial->signal_zoom_fit().connect(sigc::mem_fun(*this, &studio::WorkArea::zoom_fit));
+       zoomdial->signal_zoom_norm().connect(sigc::mem_fun(*this, &studio::WorkArea::zoom_norm));
+
+       hbox->pack_end(*hscrollbar1, Gtk::PACK_EXPAND_WIDGET,0);
+       hscrollbar1->show();
+       hbox->pack_start(*zoomdial, Gtk::PACK_SHRINK,0);
+       zoomdial->show();
+
+       attach(*hbox, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+       hbox->show();
+
+       drawing_area->add_events(Gdk::KEY_PRESS_MASK | Gdk::KEY_RELEASE_MASK);
+       add_events(Gdk::KEY_PRESS_MASK);
+       drawing_area->add_events(Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK);
+       drawing_area->add_events(Gdk::BUTTON1_MOTION_MASK | Gdk::BUTTON2_MOTION_MASK |Gdk::POINTER_MOTION_MASK);
+
+       // ----------------- Attach signals
+
+       drawing_area->signal_expose_event().connect(sigc::mem_fun(*this, &WorkArea::refresh));
+       drawing_area->signal_event().connect(sigc::mem_fun(*this, &WorkArea::on_drawing_area_event));
+       drawing_area->signal_size_allocate().connect(sigc::hide(sigc::mem_fun(*this, &WorkArea::refresh_dimension_info)));
+
+
+
+       canvas_interface->signal_rend_desc_changed().connect(sigc::mem_fun(*this, &WorkArea::refresh_dimension_info));
+       // When either of the scrolling adjustments change, then redraw.
+       get_scrollx_adjustment()->signal_value_changed().connect(sigc::mem_fun(*this, &WorkArea::queue_scroll));
+       get_scrolly_adjustment()->signal_value_changed().connect(sigc::mem_fun(*this, &WorkArea::queue_scroll));
+       get_scrollx_adjustment()->signal_value_changed().connect(sigc::mem_fun(*this, &WorkArea::refresh_dimension_info));
+       get_scrolly_adjustment()->signal_value_changed().connect(sigc::mem_fun(*this, &WorkArea::refresh_dimension_info));
+
+       get_canvas()->signal_meta_data_changed("grid_size").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
+       get_canvas()->signal_meta_data_changed("grid_snap").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
+       get_canvas()->signal_meta_data_changed("grid_show").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
+       get_canvas()->signal_meta_data_changed("guide_show").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
+       get_canvas()->signal_meta_data_changed("guide_x").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
+       get_canvas()->signal_meta_data_changed("guide_y").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
+       get_canvas()->signal_meta_data_changed("onion_skin").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
+       get_canvas()->signal_meta_data_changed("guide_snap").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
+       get_canvas()->signal_meta_data_changed("sketch").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
+       get_canvas()->signal_meta_data_changed("solid_lines").connect(sigc::mem_fun(*this,&WorkArea::load_meta_data));
+
+       queued=false;
+       meta_data_lock=false;
+       set_focus_point(Point(0,0));
+
+
+       load_meta_data();
+       // Load sketch
+       {
+               String data(canvas->get_meta_data("sketch"));
+               if(!data.empty())
+               {
+                       if(!load_sketch(data))
+                               load_sketch(dirname(canvas->get_file_name())+ETL_DIRECTORY_SEPARATOR+basename(data));
+               }
+       }
+
+       hruler->property_max_size()=double(10.0);
+       vruler->property_max_size()=double(10.0);
+
+       drawing_area->set_flags(drawing_area->get_flags()|Gtk::CAN_FOCUS);
+}
+
+WorkArea::~WorkArea()
+{
+//     delete [] buffer;
+
+       // don't leave the render function queued if we are about to vanish;
+       // that causes crashes
+       if(render_idle_func_id)
+               render_idle_func_id=0;
+}
+
+#ifdef SINGLE_THREADED
+bool
+WorkArea::get_updating()const
+{
+       return App::single_threaded && async_renderer && async_renderer->updating;
+}
+#endif
+
+#ifdef SINGLE_THREADED
+void
+WorkArea::stop_updating(bool cancel)
+{
+       async_renderer->stop();
+       if (cancel) canceled_=true;
+}
+#endif
+
+void
+WorkArea::save_meta_data()
+{
+       if(meta_data_lock)
+               return;
+       meta_data_lock=true;
+
+       Vector s(get_grid_size());
+       canvas_interface->set_meta_data("grid_size",strprintf("%f %f",s[0],s[1]));
+       canvas_interface->set_meta_data("grid_snap",get_grid_snap()?"1":"0");
+       canvas_interface->set_meta_data("guide_snap",get_guide_snap()?"1":"0");
+       canvas_interface->set_meta_data("guide_show",get_show_guides()?"1":"0");
+       canvas_interface->set_meta_data("grid_show",show_grid?"1":"0");
+       canvas_interface->set_meta_data("onion_skin",onion_skin?"1":"0");
+       {
+               String data;
+               GuideList::const_iterator iter;
+               for(iter=get_guide_list_x().begin();iter!=get_guide_list_x().end();++iter)
+               {
+                       if(!data.empty())
+                               data+=' ';
+                       data+=strprintf("%f",*iter);
+               }
+               if(!data.empty())
+                       canvas_interface->set_meta_data("guide_x",data);
+
+               data.clear();
+               for(iter=get_guide_list_y().begin();iter!=get_guide_list_y().end();++iter)
+               {
+                       if(!data.empty())
+                               data+=' ';
+                       data+=strprintf("%f",*iter);
+               }
+               if(!data.empty())
+                       canvas_interface->set_meta_data("guide_y",data);
+       }
+
+       if(get_sketch_filename().size())
+       {
+               if(dirname(canvas->get_file_name())==dirname(get_sketch_filename()))
+                       canvas_interface->set_meta_data("sketch",basename(get_sketch_filename()));
+               else
+                       canvas_interface->set_meta_data("sketch",get_sketch_filename());
+       }
+
+       meta_data_lock=false;
+}
+
+void
+WorkArea::load_meta_data()
+{
+       if(meta_data_lock)
+               return;
+       meta_data_lock=true;
+
+       String data;
+
+       data=canvas->get_meta_data("grid_size");
+       if(!data.empty())
+       {
+               float gx(get_grid_size()[0]),gy(get_grid_size()[1]);
+
+               String::iterator iter(find(data.begin(),data.end(),' '));
+               String tmp(data.begin(),iter);
+
+               if(!tmp.empty())
+                       gx=stratof(tmp);
+               else
+                       synfig::error("WorkArea::load_meta_data(): Unable to parse data for \"grid_size\", which was \"%s\"",data.c_str());
+
+               if(iter==data.end())
+                       tmp.clear();
+               else
+                       tmp=String(iter+1,data.end());
+
+               if(!tmp.empty())
+                       gy=stratof(tmp);
+               else
+                       synfig::error("WorkArea::load_meta_data(): Unable to parse data for \"grid_size\", which was \"%s\"",data.c_str());
+
+               set_grid_size(Vector(gx,gy));
+       }
+
+       data=canvas->get_meta_data("grid_show");
+       if(data.size() && (data=="1" || data[0]=='t' || data[0]=='T'))
+               show_grid=true;
+       if(data.size() && (data=="0" || data[0]=='f' || data[0]=='F'))
+               show_grid=false;
+
+       data=canvas->get_meta_data("solid_lines");
+       if(data.size() && (data=="1" || data[0]=='t' || data[0]=='T'))
+               solid_lines=true;
+       if(data.size() && (data=="0" || data[0]=='f' || data[0]=='F'))
+               solid_lines=false;
+
+       data=canvas->get_meta_data("guide_show");
+       if(data.size() && (data=="1" || data[0]=='t' || data[0]=='T'))
+               show_guides=true;
+       if(data.size() && (data=="0" || data[0]=='f' || data[0]=='F'))
+               show_guides=false;
+
+       data=canvas->get_meta_data("grid_snap");
+       if(data.size() && (data=="1" || data[0]=='t' || data[0]=='T'))
+               set_grid_snap(true);
+       if(data.size() && (data=="0" || data[0]=='f' || data[0]=='F'))
+               set_grid_snap(false);
+
+       data=canvas->get_meta_data("guide_snap");
+       if(data.size() && (data=="1" || data[0]=='t' || data[0]=='T'))
+               set_guide_snap(true);
+       if(data.size() && (data=="0" || data[0]=='f' || data[0]=='F'))
+               set_guide_snap(false);
+
+       data=canvas->get_meta_data("onion_skin");
+       if(data.size() && (data=="1" || data[0]=='t' || data[0]=='T'))
+               set_onion_skin(true);
+       if(data.size() && (data=="0" || data[0]=='f' || data[0]=='F'))
+               set_onion_skin(false);
+
+       data=canvas->get_meta_data("guide_x");
+       get_guide_list_x().clear();
+       while(!data.empty())
+       {
+               String::iterator iter(find(data.begin(),data.end(),' '));
+               String guide(data.begin(),iter);
+
+               if(!guide.empty())
+                       get_guide_list_x().push_back(stratof(guide));
+
+               if(iter==data.end())
+                       data.clear();
+               else
+                       data=String(iter+1,data.end());
+       }
+       //sort(get_guide_list_x());
+
+       data=canvas->get_meta_data("guide_y");
+       get_guide_list_y().clear();
+       while(!data.empty())
+       {
+               String::iterator iter(find(data.begin(),data.end(),' '));
+               String guide(data.begin(),iter);
+
+               if(!guide.empty())
+                       get_guide_list_y().push_back(stratof(guide));
+
+               if(iter==data.end())
+                       data.clear();
+               else
+                       data=String(iter+1,data.end());
+       }
+       //sort(get_guide_list_y());
+
+       meta_data_lock=false;
+       queue_draw();
+}
+
+void
+WorkArea::set_onion_skin(bool x)
+{
+       if(onion_skin==x)
+               return;
+       onion_skin=x;
+       save_meta_data();
+       queue_render_preview();
+       signal_onion_skin_changed()();
+}
+
+bool
+WorkArea::get_onion_skin()const
+{
+       return onion_skin;
+}
+
+void WorkArea::set_onion_skins(int *onions)
+{
+       onion_skins[0]=onions[0];
+       onion_skins[1]=onions[1];
+       if(onion_skin)
+               queue_render_preview();
+}
+
+void
+WorkArea::enable_grid()
+{
+       show_grid=true;
+       save_meta_data();
+       queue_draw();
+}
+
+void
+WorkArea::disable_grid()
+{
+       show_grid=false;
+       save_meta_data();
+       queue_draw();
+}
+
+void
+WorkArea::set_show_guides(bool x)
+{
+       show_guides=x;
+       save_meta_data();
+       queue_draw();
+}
+
+void
+WorkArea::toggle_grid()
+{
+       show_grid=!show_grid;
+       save_meta_data();
+       queue_draw();
+}
+
+void
+WorkArea::set_low_resolution_flag(bool x)
+{
+       if(x!=low_resolution)
+       {
+               low_resolution=x;
+               queue_render_preview();
+       }
+}
+
+void
+WorkArea::toggle_low_resolution_flag()
+{
+       set_low_resolution_flag(!get_low_resolution_flag());
+}
+
+void
+WorkArea::popup_menu()
+{
+       signal_popup_menu()();
+}
+
+void
+WorkArea::set_grid_size(const synfig::Vector &s)
+{
+       Duckmatic::set_grid_size(s);
+       save_meta_data();
+       queue_draw();
+}
+
+void
+WorkArea::set_focus_point(const synfig::Point &point)
+{
+       // These next three lines try to ensure that we place the
+       // focus on a pixel boundary
+       /*Point adjusted(point[0]/abs(get_pw()),point[1]/abs(get_ph()));
+       adjusted[0]=(abs(adjusted[0]-floor(adjusted[0]))<0.5)?floor(adjusted[0])*abs(get_pw()):ceil(adjusted[0])*abs(get_ph());
+       adjusted[1]=(abs(adjusted[1]-floor(adjusted[1]))<0.5)?floor(adjusted[1])*abs(get_ph()):ceil(adjusted[1])*abs(get_ph());
+       */
+       const synfig::Point& adjusted(point);
+
+       synfig::RendDesc &rend_desc(get_canvas()->rend_desc());
+       Real x_factor=(rend_desc.get_br()[0]-rend_desc.get_tl()[0]>0)?-1:1;
+       Real y_factor=(rend_desc.get_br()[1]-rend_desc.get_tl()[1]>0)?-1:1;
+
+       get_scrollx_adjustment()->set_value(adjusted[0]*x_factor);
+       get_scrolly_adjustment()->set_value(adjusted[1]*y_factor);
+}
+
+synfig::Point
+WorkArea::get_focus_point()const
+{
+       synfig::RendDesc &rend_desc(get_canvas()->rend_desc());
+       Real x_factor=(rend_desc.get_br()[0]-rend_desc.get_tl()[0]>0)?-1:1;
+       Real y_factor=(rend_desc.get_br()[1]-rend_desc.get_tl()[1]>0)?-1:1;
+
+       return synfig::Point(get_scrollx_adjustment()->get_value()*x_factor, get_scrolly_adjustment()->get_value()*y_factor);
+}
+
+bool
+WorkArea::set_wh(int W, int H,int CHAN)
+{
+       // If our size is already set, don't set it again
+       if(W==w && H==h && CHAN==bpp)
+       {
+               return true;
+       }
+       if(W<=0 || H<=0 || CHAN<=0)
+               return false;
+
+       assert(W>0);
+       assert(H>0);
+       assert(CHAN>0);
+
+       // Set all of the parameters
+       w=W;
+       h=H;
+       bpp=CHAN;
+
+       refresh_dimension_info();
+
+       tile_book.clear();
+
+       return true;
+}
+
+bool
+WorkArea::on_key_press_event(GdkEventKey* event)
+{
+       if(get_selected_ducks().empty())
+               return false;
+
+       Real multiplier(1.0);
+
+       if(Gdk::ModifierType(event->state)&GDK_SHIFT_MASK)
+               multiplier=10.0;
+
+       Vector nudge;
+       switch(event->keyval)
+       {
+               case GDK_Left:
+                       nudge=Vector(-pw,0);
+                       break;
+               case GDK_Right:
+                       nudge=Vector(pw,0);
+                       break;
+               case GDK_Up:
+                       nudge=Vector(0,-ph);
+                       break;
+               case GDK_Down:
+                       nudge=Vector(0,ph);
+                       break;
+               default:
+                       return false;
+                       break;
+       }
+
+       synfigapp::Action::PassiveGrouper grouper(instance.get(),_("Nudge"));
+
+       // Grid snap does not apply to nudging
+       bool grid_snap_holder(get_grid_snap());
+       bool guide_snap_holder(get_guide_snap());
+       set_grid_snap(false);
+
+       try {
+               start_duck_drag(get_selected_duck()->get_trans_point());
+               translate_selected_ducks(get_selected_duck()->get_trans_point()+nudge*multiplier);
+               end_duck_drag();
+       }
+       catch(String)
+       {
+               canvas_view->duck_refresh_flag=true;
+               canvas_view->queue_rebuild_ducks();
+       }
+
+       set_grid_snap(grid_snap_holder);
+       set_guide_snap(guide_snap_holder);
+
+       return true;
+}
+
+bool
+WorkArea::on_drawing_area_event(GdkEvent *event)
+{
+       synfig::Point mouse_pos;
+    float bezier_click_pos;
+       const float radius((abs(pw)+abs(ph))*4);
+       int button_pressed(0);
+       float pressure(0);
+       bool is_mouse(false);
+       Gdk::ModifierType modifier(Gdk::ModifierType(0));
+
+       // Handle input stuff
+       if(
+               event->any.type==GDK_MOTION_NOTIFY ||
+               event->any.type==GDK_BUTTON_PRESS ||
+               event->any.type==GDK_2BUTTON_PRESS ||
+               event->any.type==GDK_3BUTTON_PRESS ||
+               event->any.type==GDK_BUTTON_RELEASE
+       )
+       {
+               GdkDevice *device;
+               if(event->any.type==GDK_MOTION_NOTIFY)
+               {
+                       device=event->motion.device;
+                       modifier=Gdk::ModifierType(event->motion.state);
+               }
+               else
+               {
+                       device=event->button.device;
+                       modifier=Gdk::ModifierType(event->button.state);
+                       drawing_area->grab_focus();
+               }
+
+               // Make sure we recognize the device
+               if(curr_input_device)
+               {
+                       if(curr_input_device!=device)
+                       {
+                               assert(device);
+                               curr_input_device=device;
+                               signal_input_device_changed()(curr_input_device);
+                       }
+               }
+               else if(device)
+               {
+                       curr_input_device=device;
+                       signal_input_device_changed()(curr_input_device);
+               }
+
+               assert(curr_input_device);
+
+               // Calculate the position of the
+               // input device in canvas coordinates
+               // and the buttons
+               if(!event->button.axes)
+               {
+                       mouse_pos=synfig::Point(screen_to_comp_coords(synfig::Point(event->button.x,event->button.y)));
+                       button_pressed=event->button.button;
+                       pressure=1.0f;
+                       is_mouse=true;
+                       if(isnan(event->button.x) || isnan(event->button.y))
+                               return false;
+               }
+               else
+               {
+                       double x(event->button.axes[0]);
+                       double y(event->button.axes[1]);
+                       if(isnan(x) || isnan(y))
+                               return false;
+
+                       pressure=event->button.axes[2];
+                       //synfig::info("pressure=%f",pressure);
+                       pressure-=0.04f;
+                       pressure/=1.0f-0.04f;
+
+
+                       assert(!isnan(pressure));
+
+                       mouse_pos=synfig::Point(screen_to_comp_coords(synfig::Point(x,y)));
+
+                       button_pressed=event->button.button;
+
+                       if(button_pressed==1 && pressure<0 && (event->any.type!=GDK_BUTTON_RELEASE && event->any.type!=GDK_BUTTON_PRESS))
+                               button_pressed=0;
+                       if(pressure<0)
+                               pressure=0;
+
+                       //if(event->any.type==GDK_BUTTON_PRESS && button_pressed)
+                       //      synfig::info("Button pressed on input device = %d",event->button.button);
+
+                       //if(event->button.axes[2]>0.1)
+                       //      button_pressed=1;
+                       //else
+                       //      button_pressed=0;
+               }
+       }
+       // GDK mouse scrolling events
+       else if(event->any.type==GDK_SCROLL)
+       {
+               // GDK information needed to properly interpret mouse
+               // scrolling events are: scroll.state, scroll.x/scroll.y, and
+               // scroll.direction. The value of scroll.direction will be
+               // obtained later.
+
+               modifier=Gdk::ModifierType(event->scroll.state);
+               mouse_pos=synfig::Point(screen_to_comp_coords(synfig::Point(event->scroll.x,event->scroll.y)));
+       }
+
+       // Handle the renderables
+       {
+               std::set<etl::handle<WorkAreaRenderer> >::iterator iter;
+               for(iter=renderer_set_.begin();iter!=renderer_set_.end();++iter)
+               {
+                       if((*iter)->get_enabled())
+                               if((*iter)->event_vfunc(event))
+                               {
+                                       // Event handled. Return true.
+                                       return true;
+                               }
+               }
+       }
+
+       // Event hasn't been handled, pass it down
+       switch(event->type)
+    {
+       case GDK_BUTTON_PRESS:
+               {
+               switch(button_pressed)
+               {
+               case 1: // Attempt to click on a duck
+               {
+                       etl::handle<Duck> duck;
+                       dragging=DRAG_NONE;
+
+                       if(allow_duck_clicks)
+                       {
+                               duck=find_duck(mouse_pos,radius);
+
+                               if(duck)
+                               {
+                                       // make a note of whether the duck we click on was selected or not
+                                       if(duck_is_selected(duck))
+                                               clicked_duck=duck;
+                                       else
+                                       {
+                                               clicked_duck=0;
+                                               // if CTRL isn't pressed, clicking an unselected duck will unselect all other ducks
+                                               if(!(modifier&GDK_CONTROL_MASK))
+                                                       clear_selected_ducks();
+                                               select_duck(duck);
+                                       }
+                               }
+                       }
+                       //else
+                       //      clear_selected_ducks();
+
+
+
+                       selected_bezier=find_bezier(mouse_pos,radius,&bezier_click_pos);
+                       if(duck)
+                       {
+                               if (!duck->get_editable())
+                                       return true;
+
+                               //get_selected_duck()->signal_user_click(0)();
+                               //if(clicked_duck)clicked_duck->signal_user_click(0)();
+
+                               // if the user is holding shift while clicking on a tangent duck, consider splitting the tangent
+                               if (event->motion.state&GDK_SHIFT_MASK && duck->get_type() == Duck::TYPE_TANGENT)
+                               {
+                                       synfigapp::ValueDesc value_desc = duck->get_value_desc();
+
+                                       // we have the tangent, but need the vertex - that's the parent
+                                       if (value_desc.parent_is_value_node()) {
+                                               ValueNode_Composite::Handle parent_value_node = value_desc.get_parent_value_node();
+
+                                               // if the tangent isn't split, then split it
+                                               if (!((*(parent_value_node->get_link("split")))(get_time()).get(bool())))
+                                               {
+                                                       if (get_canvas_view()->canvas_interface()->
+                                                               change_value(synfigapp::ValueDesc(parent_value_node,
+                                                                                                                                 parent_value_node->get_link_index_from_name("split")),
+                                                                                        true))
+                                                       {
+                                                               // rebuild the ducks from scratch, so the tangents ducks aren't connected
+                                                               get_canvas_view()->rebuild_ducks();
+
+                                                               // reprocess the mouse click
+                                                               return on_drawing_area_event(event);
+                                                       }
+                                                       else
+                                                               return true;
+                                               }
+                                       } else {
+                                               // I don't know how to access the vertex from the tangent duck when originally drawing the bline in the bline tool
+
+                                               // synfig::ValueNode::Handle vn = value_desc.get_value_node();
+                                               synfig::info("parent isn't value node?  shift-drag-tangent doesn't work in bline tool yet...");
+                                       }
+                               }
+
+                               dragging=DRAG_DUCK;
+                               drag_point=mouse_pos;
+                               //drawing_area->queue_draw();
+                               start_duck_drag(mouse_pos);
+                               get_canvas_view()->reset_cancel_status();
+                               return true;
+                       }
+// I commented out this section because
+// it was causing issues when rotoscoping.
+// At the moment, we don't need it, so
+// this was the easiest way to fix the problem.
+/*
+                       else
+                       if(selected_bezier)
+                       {
+                               selected_duck=0;
+                               selected_bezier->signal_user_click(0)(bezier_click_pos);
+                       }
+*/
+                       else
+                       {
+                               //clear_selected_ducks();
+                               selected_bezier=0;
+                               if(canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,BUTTON_LEFT,mouse_pos,pressure,modifier))==Smach::RESULT_OK)
+                               {
+                                       // Check for a guide click
+                                       GuideList::iterator iter;
+
+                                       iter=find_guide_x(mouse_pos,radius);
+                                       if(iter==get_guide_list_x().end())
+                                       {
+                                               curr_guide_is_x=false;
+                                               iter=find_guide_y(mouse_pos,radius);
+                                       }
+                                       else
+                                               curr_guide_is_x=true;
+                                       if(iter!=get_guide_list_x().end() && iter!=get_guide_list_y().end())
+                                       {
+                                               dragging=DRAG_GUIDE;
+                                               curr_guide=iter;
+                                               return true;
+                                       }
+
+
+                                       // All else fails, try making a selection box
+                                       dragging=DRAG_BOX;
+                                       curr_point=drag_point=mouse_pos;
+                                       return true;
+                               }
+                       }
+                       break;
+               }
+               case 2: // Attempt to drag and move the window
+               {
+                       etl::handle<Duck> duck=find_duck(mouse_pos,radius);
+                       etl::handle<Bezier> bezier=find_bezier(mouse_pos,radius,&bezier_click_pos);
+                       if(duck)
+                               duck->signal_user_click(1)();
+                       else
+                       if(bezier)
+                               bezier->signal_user_click(1)(bezier_click_pos);
+
+                       if(canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,BUTTON_MIDDLE,mouse_pos,pressure,modifier))==Smach::RESULT_OK)
+                       if(is_mouse)
+                       {
+                               dragging=DRAG_WINDOW;
+                               drag_point=mouse_pos;
+                               signal_user_click(1)(mouse_pos);
+                       }
+                       break;
+               }
+               case 3: // Attempt to either get info on a duck, or open the menu
+               {
+                       etl::handle<Duck> duck=find_duck(mouse_pos,radius);
+                       etl::handle<Bezier> bezier=find_bezier(mouse_pos,radius,&bezier_click_pos);
+
+                       Layer::Handle layer(get_canvas()->find_layer(mouse_pos));
+                       if(duck)
+                       {
+                               if(get_selected_ducks().size()<=1)
+                                       duck->signal_user_click(2)();
+                               else
+                                       canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MULTIPLE_DUCKS_CLICKED,BUTTON_RIGHT,mouse_pos,pressure,modifier));
+                               return true;
+                       }
+                       else if(bezier)
+                       {
+                               bezier->signal_user_click(2)(bezier_click_pos);
+                               return true;
+                       }
+                       else if (layer)
+                       {
+                               if(canvas_view->get_smach().process_event(EventLayerClick(layer,BUTTON_RIGHT,mouse_pos))==Smach::RESULT_OK)
+                                       return false;
+                               return true;
+                       }
+                       else
+                               canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,BUTTON_RIGHT,mouse_pos,pressure,modifier));
+                       /*
+                       if(canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_BUTTON_DOWN,BUTTON_RIGHT,mouse_pos,pressure,modifier))==Smach::RESULT_OK)
+                       {
+                               //popup_menu();
+                               return true;
+                       }
+                       */
+                       break;
+               }
+               case 4:
+                       signal_user_click(3)(mouse_pos);
+                       break;
+               case 5:
+                       signal_user_click(4)(mouse_pos);
+                       break;
+               default:
+                       break;
+               }
+               }
+               break;
+       case GDK_MOTION_NOTIFY:
+               curr_point=mouse_pos;
+
+               if(event->motion.time-last_event_time<25)
+                       return true;
+               else
+                       last_event_time=event->motion.time;
+
+               signal_cursor_moved_();
+
+               // Guide/Duck highlights on hover
+               if(dragging==DRAG_NONE)
+               {
+                       GuideList::iterator iter;
+
+                       iter=find_guide_x(mouse_pos,radius);
+                       if(iter==get_guide_list_x().end())
+                               iter=find_guide_y(mouse_pos,radius);
+
+                       if(iter!=curr_guide)
+                       {
+                               curr_guide=iter;
+                               drawing_area->queue_draw();
+                       }
+
+                       etl::handle<Duck> duck;
+                       duck=find_duck(mouse_pos,radius);
+                       if(duck!=hover_duck)
+                       {
+                               hover_duck=duck;
+                               drawing_area->queue_draw();
+                       }
+               }
+
+
+               if(dragging==DRAG_DUCK)
+               {
+                       if(canvas_view->get_cancel_status())
+                       {
+                               dragging=DRAG_NONE;
+                               canvas_view->queue_rebuild_ducks();
+                               return true;
+                       }
+                       /*
+                       Point point((mouse_pos-selected_duck->get_origin())/selected_duck->get_scalar());
+                       if(get_grid_snap())
+                       {
+                               point[0]=floor(point[0]/grid_size[0]+0.5)*grid_size[0];
+                               point[1]=floor(point[1]/grid_size[1]+0.5)*grid_size[1];
+                       }
+                       selected_duck->set_point(point);
+                       */
+
+                       //Point p(mouse_pos);
+
+                       set_axis_lock(event->motion.state&GDK_SHIFT_MASK);
+
+                       translate_selected_ducks(mouse_pos);
+
+                       drawing_area->queue_draw();
+               }
+
+               if(dragging==DRAG_BOX)
+               {
+                       curr_point=mouse_pos;
+                       drawing_area->queue_draw();
+               }
+
+               if(dragging==DRAG_GUIDE)
+               {
+                       if(curr_guide_is_x)
+                               *curr_guide=mouse_pos[0];
+                       else
+                               *curr_guide=mouse_pos[1];
+                       drawing_area->queue_draw();
+               }
+
+               if(dragging!=DRAG_WINDOW)
+               {       // Update those triangle things on the rulers
+                       const synfig::Point point(mouse_pos);
+                       hruler->property_position()=Distance(point[0],Distance::SYSTEM_UNITS).get(App::distance_system,get_canvas()->rend_desc());
+                       vruler->property_position()=Distance(point[1],Distance::SYSTEM_UNITS).get(App::distance_system,get_canvas()->rend_desc());
+               }
+
+               if(dragging == DRAG_WINDOW)
+                       set_focus_point(get_focus_point() + mouse_pos-drag_point);
+               else if (event->motion.state & GDK_BUTTON1_MASK &&
+                               canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_BUTTON_DRAG, BUTTON_LEFT,
+                                                                                                                                 mouse_pos,pressure,modifier)) == Smach::RESULT_ACCEPT)
+                       return true;
+               else if (event->motion.state & GDK_BUTTON2_MASK &&
+                                canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_BUTTON_DRAG, BUTTON_MIDDLE,
+                                                                                                                                  mouse_pos, pressure, modifier)) == Smach::RESULT_ACCEPT)
+                       return true;
+               else if (event->motion.state & GDK_BUTTON3_MASK &&
+                                canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_BUTTON_DRAG, BUTTON_RIGHT,
+                                                                                                                                  mouse_pos, pressure, modifier)) == Smach::RESULT_ACCEPT)
+                       return true;
+               else if(canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_MOTION, BUTTON_NONE,
+                                                                                                                                 mouse_pos, pressure,modifier)) == Smach::RESULT_ACCEPT)
+                       return true;
+
+               break;
+
+       case GDK_BUTTON_RELEASE:
+       {
+               bool ret(false);
+
+               if(dragging==DRAG_GUIDE)
+               {
+                       dragging=DRAG_NONE;
+                       save_meta_data();
+                       return true;
+               }
+               else
+               if(dragging==DRAG_DUCK)
+               {
+                       synfigapp::Action::PassiveGrouper grouper(instance.get(),_("Move"));
+                       dragging=DRAG_NONE;
+                       //translate_selected_ducks(mouse_pos);
+                       set_axis_lock(false);
+
+                       try{
+                       get_canvas_view()->duck_refresh_flag=false;
+                       get_canvas_view()->duck_refresh_needed=false;
+                       const bool drag_did_anything(end_duck_drag());
+                       get_canvas_view()->duck_refresh_flag=true;
+                       if(!drag_did_anything)
+                       {
+                               // if we originally clicked on a selected duck ...
+                               if(clicked_duck)
+                               {
+                                       // ... and CTRL is pressed, then just toggle the clicked duck
+                                       //     otherwise make the clicked duck the only selected duck
+                                       if(modifier&GDK_CONTROL_MASK)
+                                               unselect_duck(clicked_duck);
+                                       else
+                                       {
+                                               clear_selected_ducks();
+                                               select_duck(clicked_duck);
+                                       }
+                                       clicked_duck->signal_user_click(0)();
+                               }
+                       }
+                       else
+                       {
+                               if(canvas_view->duck_refresh_needed)
+                                       canvas_view->queue_rebuild_ducks();
+                               return true;
+                       }
+                       }catch(String)
+                       {
+                               canvas_view->duck_refresh_flag=true;
+                               canvas_view->queue_rebuild_ducks();
+                               return true;
+                       }
+                       //queue_draw();
+                       clicked_duck=0;
+
+                       ret=true;
+               }
+
+               if(dragging==DRAG_BOX)
+               {
+                       dragging=DRAG_NONE;
+                       if((drag_point-mouse_pos).mag()>radius/2.0f)
+                       {
+                               if(canvas_view->get_smach().process_event(EventBox(drag_point,mouse_pos,MouseButton(event->button.button),modifier))==Smach::RESULT_ACCEPT)
+                                       return true;
+
+                               // when dragging a box around some ducks:
+                               // SHIFT selects; CTRL toggles; SHIFT+CTRL unselects; <none> clears all then selects
+                               if(modifier&GDK_SHIFT_MASK)
+                                       select_ducks_in_box(drag_point,mouse_pos);
+
+                               if(modifier&GDK_CONTROL_MASK)
+                                       toggle_select_ducks_in_box(drag_point,mouse_pos);
+                               else if(!(modifier&GDK_SHIFT_MASK))
+                               {
+                                       clear_selected_ducks();
+                                       select_ducks_in_box(drag_point,mouse_pos);
+                               }
+                               ret=true;
+                       }
+                       else
+                       {
+                               if(allow_layer_clicks)
+                               {
+                                       Layer::Handle layer(get_canvas()->find_layer(drag_point));
+                                       //if(layer)
+                                       {
+                                               if(canvas_view->get_smach().process_event(EventLayerClick(layer,BUTTON_LEFT,mouse_pos,modifier))==Smach::RESULT_OK)
+                                                       signal_layer_selected_(layer);
+                                               ret=true;
+                                       }
+                               }
+                               else
+                               {
+                                       signal_user_click(0)(mouse_pos);
+                               }
+                       }
+               }
+
+               dragging=DRAG_NONE;
+
+               if(canvas_view->get_smach().process_event(EventMouse(EVENT_WORKAREA_MOUSE_BUTTON_UP,MouseButton(event->button.button),mouse_pos,pressure,modifier))==Smach::RESULT_ACCEPT)
+                       ret=true;
+
+               return ret;
+       }
+               break;
+       case GDK_SCROLL:
+       {
+               // Handle a mouse scrolling event like Xara Xtreme and
+               // Inkscape:
+
+               // Scroll up/down: scroll up/down
+               // Shift + scroll up/down: scroll left/right
+               // Control + scroll up/down: zoom in/out
+
+               if(modifier&GDK_CONTROL_MASK)
+               {
+
+                       // The zoom is performed while preserving the pointer
+                       // position as a fixed point (similarly to Xara Xtreme and
+                       // Inkscape).
+
+                       // The strategy used below is to scroll to the updated
+                       // position, then zoom. This is easy to implement within
+                       // the present architecture, but has the disadvantage of
+                       // triggering multiple visible refreshes. Note: 1.25 is
+                       // the hard wired ratio in zoom_in()/zoom_out(). The
+                       // variable "drift" compensates additional inaccuracies in
+                       // the zoom. There is also an additional minus sign for
+                       // the inverted y coordinates.
+
+                       // FIXME: One might want to figure out where in the code
+                       // this empirical drift is been introduced.
+
+                       const synfig::Point scroll_point(get_scrollx_adjustment()->get_value(),get_scrolly_adjustment()->get_value());
+                       const double drift = 0.052;
+
+                       switch(event->scroll.direction)
+                       {
+                               case GDK_SCROLL_UP:
+                               case GDK_SCROLL_RIGHT:
+                                       get_scrollx_adjustment()->set_value(scroll_point[0]+(mouse_pos[0]-scroll_point[0])*(1.25-(1+drift)));
+                                       get_scrolly_adjustment()->set_value(scroll_point[1]-(mouse_pos[1]+scroll_point[1])*(1.25-(1+drift)));
+                                       zoom_in();
+                                       break;
+                               case GDK_SCROLL_DOWN:
+                               case GDK_SCROLL_LEFT:
+                                       get_scrollx_adjustment()->set_value(scroll_point[0]+(mouse_pos[0]-scroll_point[0])*(1/1.25-(1+drift)));
+                                       get_scrolly_adjustment()->set_value(scroll_point[1]-(mouse_pos[1]+scroll_point[1])*(1/1.25-(1+drift)));
+                                       zoom_out();
+                                       break;
+                               default:
+                                       break;
+                       }
+               }
+               else if(modifier&GDK_SHIFT_MASK)
+               {
+                       // Scroll in either direction by 20 pixels. Ideally, the
+                       // amount of pixels per scrolling event should be
+                       // configurable. Xara Xtreme currently uses an (hard
+                       // wired) amount 20 pixel, Inkscape defaults to 40 pixels.
+
+                       const int scroll_pixel = 20;
+
+                       switch(event->scroll.direction)
+                       {
+                               case GDK_SCROLL_UP:
+                                       get_scrollx_adjustment()->set_value(get_scrollx_adjustment()->get_value()-scroll_pixel*pw);
+                                       break;
+                               case GDK_SCROLL_DOWN:
+                                       get_scrollx_adjustment()->set_value(get_scrollx_adjustment()->get_value()+scroll_pixel*pw);
+                                       break;
+                               case GDK_SCROLL_LEFT:
+                                       get_scrolly_adjustment()->set_value(get_scrolly_adjustment()->get_value()+scroll_pixel*ph);
+                                       break;
+                               case GDK_SCROLL_RIGHT:
+                                       get_scrolly_adjustment()->set_value(get_scrolly_adjustment()->get_value()-scroll_pixel*ph);
+                                       break;
+                               default:
+                                       break;
+                       }
+               }
+               else
+               {
+                       // Scroll in either direction by 20 pixels. Ideally, the
+                       // amount of pixels per scrolling event should be
+                       // configurable. Xara Xtreme currently uses an (hard
+                       // wired) amount 20 pixel, Inkscape defaults to 40 pixels.
+
+                       const int scroll_pixel = 20;
+
+                       switch(event->scroll.direction)
+                       {
+                               case GDK_SCROLL_UP:
+                                       get_scrolly_adjustment()->set_value(get_scrolly_adjustment()->get_value()+scroll_pixel*ph);
+                                       break;
+                               case GDK_SCROLL_DOWN:
+                                       get_scrolly_adjustment()->set_value(get_scrolly_adjustment()->get_value()-scroll_pixel*ph);
+                                       break;
+                               case GDK_SCROLL_LEFT:
+                                       get_scrollx_adjustment()->set_value(get_scrollx_adjustment()->get_value()-scroll_pixel*pw);
+                                       break;
+                               case GDK_SCROLL_RIGHT:
+                                       get_scrollx_adjustment()->set_value(get_scrollx_adjustment()->get_value()+scroll_pixel*pw);
+                                       break;
+                               default:
+                                       break;
+                       }
+               }
+       }
+               break;
+       default:
+               break;
+       }
+               return false;
+}
+
+bool
+WorkArea::on_hruler_event(GdkEvent */*event*/)
+{
+/*
+       switch(event->type)
+    {
+       case GDK_BUTTON_PRESS:
+               if(dragging==DRAG_NONE)
+               {
+                       dragging=DRAG_GUIDE;
+                       curr_guide=get_guide_list_y().insert(get_guide_list_y().begin());
+                       curr_guide_is_x=false;
+               }
+               return true;
+               break;
+
+       case GDK_MOTION_NOTIFY:
+               // Guide movement
+               if(dragging==DRAG_GUIDE && curr_guide_is_x==false)
+               {
+                       double y,x;
+                       if(event->button.axes)
+                       {
+                               x=(event->button.axes[0]);
+                               y=(event->button.axes[1]);
+                       }
+                       else
+                       {
+                               x=event->button.x;
+                               y=event->button.y;
+                       }
+
+                       if(isnan(y) || isnan(x))
+                               return false;
+
+                       *curr_guide=synfig::Point(screen_to_comp_coords(synfig::Point(x,y)))[1];
+
+                       queue_draw();
+               }
+               return true;
+               break;
+
+       case GDK_BUTTON_RELEASE:
+               if(dragging==DRAG_GUIDE && curr_guide_is_x==false)
+               {
+                       dragging=DRAG_NONE;
+                       get_guide_list_y().erase(curr_guide);
+               }
+               break;
+               return true;
+       default:
+               break;
+       }
+*/
+       return false;
+}
+
+bool
+WorkArea::on_vruler_event(GdkEvent */*event*/)
+{
+/*
+       switch(event->type)
+    {
+       case GDK_BUTTON_PRESS:
+               if(dragging==DRAG_NONE)
+               {
+                       dragging=DRAG_GUIDE;
+                       curr_guide=get_guide_list_x().insert(get_guide_list_x().begin());
+                       curr_guide_is_x=true;
+               }
+               return true;
+               break;
+       case GDK_BUTTON_RELEASE:
+               if(dragging==DRAG_GUIDE && curr_guide_is_x==true)
+               {
+                       dragging=DRAG_NONE;
+                       get_guide_list_x().erase(curr_guide);
+               }
+               break;
+               return true;
+       default:
+               break;
+       }
+*/
+       return false;
+}
+
+
+void
+WorkArea::refresh_dimension_info()
+{
+       synfig::RendDesc &rend_desc(get_canvas()->rend_desc());
+
+       canvaswidth=rend_desc.get_br()[0]-rend_desc.get_tl()[0];
+       canvasheight=rend_desc.get_br()[1]-rend_desc.get_tl()[1];
+
+       pw=canvaswidth/w;
+       ph=canvasheight/h;
+
+       scrollx_adjustment.set_page_increment(abs(get_grid_size()[0]));
+       scrollx_adjustment.set_step_increment(abs(pw));
+       scrollx_adjustment.set_lower(-abs(canvaswidth));
+       scrollx_adjustment.set_upper(abs(canvaswidth));
+       scrolly_adjustment.set_lower(-abs(canvasheight));
+       scrolly_adjustment.set_upper(abs(canvasheight));
+       scrolly_adjustment.set_step_increment(abs(ph));
+       scrolly_adjustment.set_page_increment(abs(get_grid_size()[1]));
+
+
+
+       if(drawing_area->get_width()<=0 || drawing_area->get_height()<=0 || w==0 || h==0)
+               return;
+
+       const synfig::Point focus_point(get_focus_point());
+       const synfig::Real x(focus_point[0]/pw+drawing_area->get_width()/2-w/2);
+       const synfig::Real y(focus_point[1]/ph+drawing_area->get_height()/2-h/2);
+
+       window_tl[0]=rend_desc.get_tl()[0]-pw*x;
+       window_br[0]=rend_desc.get_br()[0]+pw*(drawing_area->get_width()-x-w);
+
+       window_tl[1]=rend_desc.get_tl()[1]-ph*y;
+       window_br[1]=rend_desc.get_br()[1]+ph*(drawing_area->get_height()-y-h);
+
+       hruler->property_lower()=Distance(window_tl[0],Distance::SYSTEM_UNITS).get(App::distance_system,rend_desc);
+       hruler->property_upper()=Distance(window_br[0],Distance::SYSTEM_UNITS).get(App::distance_system,rend_desc);
+       vruler->property_lower()=Distance(window_tl[1],Distance::SYSTEM_UNITS).get(App::distance_system,rend_desc);
+       vruler->property_upper()=Distance(window_br[1],Distance::SYSTEM_UNITS).get(App::distance_system,rend_desc);
+
+       view_window_changed();
+}
+
+
+synfig::Point
+WorkArea::screen_to_comp_coords(synfig::Point pos)const
+{
+       synfig::RendDesc &rend_desc(get_canvas()->rend_desc());
+       //synfig::Vector::value_type canvaswidth=rend_desc.get_br()[0]-rend_desc.get_tl()[0];
+       //synfig::Vector::value_type canvasheight=rend_desc.get_br()[1]-rend_desc.get_tl()[1];
+       //synfig::Vector::value_type pw=canvaswidth/w;
+       //synfig::Vector::value_type ph=canvasheight/h;
+       Vector focus_point=get_focus_point();
+       synfig::Vector::value_type x=focus_point[0]/pw+drawing_area->get_width()/2-w/2;
+       synfig::Vector::value_type y=focus_point[1]/ph+drawing_area->get_height()/2-h/2;
+
+       return rend_desc.get_tl()-synfig::Point(pw*x,ph*y)+synfig::Point(pw*pos[0],ph*pos[1]);
+}
+
+synfig::Point
+WorkArea::comp_to_screen_coords(synfig::Point /*pos*/)const
+{
+       synfig::warning("WorkArea::comp_to_screen_coords: Not yet implemented");
+       return synfig::Point();
+}
+
+int
+WorkArea::next_unrendered_tile(int refreshes)const
+{
+       //assert(!tile_book.empty());
+       if(tile_book.empty())
+               return -1;
+
+       //const synfig::RendDesc &rend_desc(get_canvas()->rend_desc());
+
+       const synfig::Vector focus_point(get_focus_point());
+
+       // Calculate the window coordinates of the top-left
+       // corner of the canvas.
+       const synfig::Vector::value_type
+               x(focus_point[0]/pw+drawing_area->get_width()/2-w/2),
+               y(focus_point[1]/ph+drawing_area->get_height()/2-h/2);
+
+       int div = low_res_pixel_size;
+       const int width_in_tiles(w/tile_w+((low_resolution?((w/div)%(tile_w/div)):(w%tile_w))?1:0));
+       const int height_in_tiles(h/tile_h+(h%tile_h?1:0));
+
+       int
+               u(0),v(0),
+               u1(int(-x/tile_w)),
+               v1(int(-y/tile_h)),
+               u2(int((-x+drawing_area->get_width())/tile_w+1)),
+               v2(int((-y+drawing_area->get_height())/tile_h+1));
+
+       if(u2>width_in_tiles)u2=width_in_tiles;
+       if(v2>height_in_tiles)v2=height_in_tiles;
+       if(u1<0)u1=0;
+       if(v1<0)v1=0;
+
+       int last_good_tile(-1);
+
+       for(v=v1;v<v2;v++)
+               for(u=u1;u<u2;u++)
+               {
+                       int index(v*width_in_tiles+u);
+                       if(tile_book[index].second<refreshes)
+                       {
+                               last_good_tile=index;
+                               if(rand()%8==0)
+                                       return index;
+                       }
+               }
+       return last_good_tile;
+}
+
+/*
+template <typename F, typename T=WorkAreaRenderer, typename R=typename F::result_type>
+class handle2ptr_t : public std::unary_function<typename etl::handle<T>,R>
+{
+private:
+       F func;
+public:
+       handle2ptr_t(const F &func):func(func) { };
+
+       R operator()(typename etl::handle<T> x) { return func(*x); }
+};
+
+template <typename F>
+handle2ptr_t<F>
+handle2ptr(F func)
+{
+       return handle2ptr_t<F>(func);
+}
+       for_each(
+               renderer_set_.begin(),
+               renderer_set_.end(),
+               handle2ptr(
+                       sigc::bind(
+                               sigc::bind(
+                                       sigc::mem_fun(
+                                               &WorkAreaRenderer::render_vfunc
+                                       ),
+                                       Gdk::Rectangle(event->area)
+                               ),
+                               drawing_area->get_window()
+                       )
+               )
+       );
+*/
+
+bool
+WorkArea::refresh(GdkEventExpose*event)
+{
+       assert(get_canvas());
+
+       drawing_area->get_window()->clear();
+
+       //const synfig::RendDesc &rend_desc(get_canvas()->rend_desc());
+
+       const synfig::Vector focus_point(get_focus_point());
+
+       // Update the old focus point
+       last_focus_point=focus_point;
+
+       // Draw out the renderables
+       {
+               std::set<etl::handle<WorkAreaRenderer> >::iterator iter;
+               for(iter=renderer_set_.begin();iter!=renderer_set_.end();++iter)
+               {
+                       if((*iter)->get_enabled())
+                               (*iter)->render_vfunc(
+                                       drawing_area->get_window(),
+                                       Gdk::Rectangle(&event->area)
+                               );
+               }
+       }
+
+       // Calculate the window coordinates of the top-left
+       // corner of the canvas.
+       //const synfig::Vector::value_type
+       //      x(focus_point[0]/pw+drawing_area->get_width()/2-w/2),
+       //      y(focus_point[1]/ph+drawing_area->get_height()/2-h/2);
+
+       //const synfig::Vector::value_type window_startx(window_tl[0]);
+       //const synfig::Vector::value_type window_endx(window_br[0]);
+       //const synfig::Vector::value_type window_starty(window_tl[1]);
+       //const synfig::Vector::value_type window_endy(window_br[1]);
+
+       Glib::RefPtr<Gdk::GC> gc=Gdk::GC::create(drawing_area->get_window());
+
+       // If we are in animate mode, draw a red border around the screen
+       if(canvas_interface->get_mode()&synfigapp::MODE_ANIMATE)
+       {
+// #define USE_FRAME_BACKGROUND_TO_SHOW_EDIT_MODE
+#ifdef USE_FRAME_BACKGROUND_TO_SHOW_EDIT_MODE
+               // This method of drawing the red border doesn't work on any
+               // Gtk theme which uses the crux-engine, hcengine, industrial,
+               // mist, or ubuntulooks engine, such as the default ubuntu
+               // 'Human' theme.
+               drawing_frame->modify_bg(Gtk::STATE_NORMAL,Gdk::Color("#FF0000"));
+#else
+               // So let's do it in a more primitive fashion.
+               gc->set_rgb_fg_color(Gdk::Color("#FF0000"));
+               gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+               drawing_area->get_window()->draw_rectangle(
+                       gc,
+                       false,  // Fill?
+                       0,0,    // x,y
+                       drawing_area->get_width()-1,drawing_area->get_height()-1); // w,h
+#endif
+       }
+#ifdef USE_FRAME_BACKGROUND_TO_SHOW_EDIT_MODE
+       else
+               drawing_frame->unset_bg(Gtk::STATE_NORMAL);
+#endif
+
+       return true;
+}
+
+void
+WorkArea::done_rendering()
+{
+/*
+       assert(buffer);
+       assert(w>0);
+       assert(h>0);
+       pix_buf=Gdk::Pixbuf::create_from_data(
+               buffer, // pointer to the data
+               Gdk::COLORSPACE_RGB, // the colorspace
+               true, // has alpha?
+               8, // bits per sample
+               w,      // width
+               h,      // height
+               w*bpp); // stride (pitch)
+       assert(pix_buf);
+*/
+}
+
+
+void
+WorkArea::set_quality(int x)
+{
+       if(x==quality)
+               return;
+       quality=x;
+       queue_render_preview();
+}
+
+void
+WorkArea::set_low_res_pixel_size(int x)
+{
+       if(x==low_res_pixel_size)
+               return;
+       low_res_pixel_size=x;
+       queue_render_preview();
+}
+
+namespace studio
+{
+class WorkAreaProgress : public synfig::ProgressCallback
+{
+       WorkArea *work_area;
+       ProgressCallback *cb;
+
+public:
+
+       WorkAreaProgress(WorkArea *work_area,ProgressCallback *cb):
+               work_area(work_area),cb(cb)
+       {
+               assert(cb);
+       }
+
+       virtual bool
+       task(const std::string &str)
+       {
+               if(work_area->dirty)
+                       return false;
+               return cb->task(str);
+       }
+
+       virtual bool
+       error(const std::string &err)
+       {
+               if(work_area->dirty)
+                       return false;
+               return cb->error(err);
+       }
+
+       virtual bool
+       amount_complete(int current, int total)
+       {
+               if(work_area->dirty)
+                       return false;
+               return cb->amount_complete(current,total);
+       }
+};
+}
+
+bool
+studio::WorkArea::async_update_preview()
+{
+#ifdef SINGLE_THREADED
+       if (get_updating())
+       {
+               stop_updating();
+               queue_render_preview();
+               return false;
+       }
+#endif
+
+       async_renderer=0;
+
+       queued=false;
+       canceled_=false;
+       get_canvas_view()->reset_cancel_status();
+
+       // This object will mark us as busy until
+       // we are done.
+       //studio::App::Busy busy;
+
+       //WorkAreaProgress callback(this,get_canvas_view()->get_ui_interface().get());
+       //synfig::ProgressCallback *cb=&callback;
+
+       if(!is_visible())return false;
+
+       /*
+       // If we are queued to render the scene at the next idle
+       // go ahead and de-queue it.
+       if(render_idle_func_id)
+       {
+               g_source_remove(render_idle_func_id);
+               //queued=false;
+               render_idle_func_id=0;
+       }
+       */
+
+       dirty=false;
+       get_canvas_view()->reset_cancel_status();
+
+       //bool ret=false;
+       RendDesc desc=get_canvas()->rend_desc();
+
+       int w=(int)(desc.get_w()*zoom);
+       int h=(int)(desc.get_h()*zoom);
+
+       // ensure that the size we draw is at least one pixel in each dimension
+       int min_size = low_resolution ? low_res_pixel_size : 1;
+       if (w < min_size) w = min_size;
+       if (h < min_size) h = min_size;
+
+       // Setup the description parameters
+       desc.set_antialias(1);
+       desc.set_time(cur_time);
+
+       set_rend_desc(desc);
+
+       // Create the render target
+       handle<Target> target;
+
+       // if we have lots of pixels to render and the tile renderer isn't disabled, use it
+       int div;
+       div = low_resolution ? low_res_pixel_size : 1;
+       if ((w*h > 240*div*135*div && !getenv("SYNFIG_DISABLE_TILE_RENDER")) || getenv("SYNFIG_FORCE_TILE_RENDER"))
+       {
+               // do a tile render
+               handle<WorkAreaTarget> trgt(new class WorkAreaTarget(this,w,h));
+
+               trgt->set_rend_desc(&desc);
+               trgt->set_onion_skin(get_onion_skin(), onion_skins);
+               target=trgt;
+       }
+       else
+       {
+               // do a scanline render
+               handle<WorkAreaTarget_Full> trgt(new class WorkAreaTarget_Full(this,w,h));
+
+               trgt->set_rend_desc(&desc);
+               trgt->set_onion_skin(get_onion_skin(), onion_skins);
+               target=trgt;
+       }
+
+       // We can rest assured that our time has already
+       // been set, so there is no need to have to
+       // recalculate that over again.
+       // UPDATE: This is kind of needless with
+       // the way that time is handled now in SYNFIG.
+       //target->set_avoid_time_sync(true);
+       async_renderer=new AsyncRenderer(target);
+       async_renderer->signal_finished().connect(
+               sigc::mem_fun(this,&WorkArea::async_update_finished)
+       );
+
+       rendering=true;
+       async_renderer->start();
+
+       synfig::ProgressCallback *cb=get_canvas_view()->get_ui_interface().get();
+
+       rendering=true;
+       cb->task(_("Rendering..."));
+       rendering=true;
+
+       return true;
+}
+
+void
+studio::WorkArea::async_update_finished()
+{
+       synfig::ProgressCallback *cb=get_canvas_view()->get_ui_interface().get();
+
+       rendering=false;
+
+       if(!async_renderer)
+               return;
+
+       // If we completed successfully, then
+       // we aren't dirty anymore
+       if(async_renderer->has_success())
+       {
+               dirty=false;
+               //queued=false;
+               cb->task(_("Idle"));
+       }
+       else
+       {
+               dirty=true;
+               cb->task(_("Render Failed"));
+       }
+       //get_canvas_view()->reset_cancel_status();
+       done_rendering();
+}
+
+bool
+studio::WorkArea::sync_update_preview()
+{
+       //      const Time &time(cur_time);
+
+       canceled_=false;
+       get_canvas_view()->reset_cancel_status();
+
+       async_renderer=0;
+
+again:
+       // This object will mark us as busy until
+       // we are done.
+       studio::App::Busy busy;
+
+       WorkAreaProgress callback(this,get_canvas_view()->get_ui_interface().get());
+       synfig::ProgressCallback *cb=&callback;
+
+       // We don't want to render if we are already rendering
+       if(rendering)
+       {
+               dirty=true;
+               return false;
+       }
+
+       if(!is_visible())return false;
+       get_canvas()->set_time(get_time());
+       get_canvas_view()->get_smach().process_event(EVENT_REFRESH_DUCKS);
+       signal_rendering()();
+
+       // If we are queued to render the scene at the next idle
+       // go ahead and de-queue it.
+       if(render_idle_func_id)
+       {
+               g_source_remove(render_idle_func_id);
+               //queued=false;
+               render_idle_func_id=0;
+       }
+       // Start rendering
+       rendering=true;
+
+       dirty=false;
+       get_canvas_view()->reset_cancel_status();
+
+       RendDesc desc=get_canvas()->rend_desc();
+       //newdesc->set_flags(RendDesc::PX_ASPECT|RendDesc::IM_SPAN);
+
+       int w=(int)(desc.get_w()*zoom);
+       int h=(int)(desc.get_h()*zoom);
+
+       // Setup the description parameters
+       desc.set_antialias(1);
+       desc.set_time(cur_time);
+       //desc.set_wh(w,h);
+
+       set_rend_desc(desc);
+
+       // Create the render target
+       handle<WorkAreaTarget> target(new class WorkAreaTarget(this,w,h));
+
+       target->set_rend_desc(&desc);
+
+       // We can rest assured that our time has already
+       // been set, so there is no need to have to
+       // recalculate that over again.
+       target->set_avoid_time_sync(true);
+
+       if(cb)
+               cb->task(strprintf(_("Rendering canvas %s..."),get_canvas()->get_name().c_str()));
+
+       bool ret = target->render(cb);
+
+       if(!ret && !get_canvas_view()->get_cancel_status() && dirty)
+       {
+               rendering=false;
+               //canceled_=true;
+               goto again;
+       }
+       if(get_canvas_view()->get_cancel_status())
+               canceled_=true;
+
+       if(cb)
+       {
+               if(ret)
+                       cb->task(_("Idle"));
+               else
+                       cb->task(_("Render Failed"));
+               cb->amount_complete(0,1);
+       }
+
+       // Refresh the work area to make sure that
+       // it is being displayed correctly
+       drawing_area->queue_draw();
+
+       // If we completed successfully, then
+       // we aren't dirty anymore
+       if(ret)
+       {
+               dirty=false;
+               //queued=false;
+       }
+       else dirty=true;
+       rendering=false;
+       //get_canvas_view()->reset_cancel_status();
+       done_rendering();
+       return ret;
+}
+
+void
+studio::WorkArea::async_render_preview(synfig::Time time)
+{
+       cur_time=time;
+       //tile_book.clear();
+
+       refreshes+=5;
+       if(!is_visible())return;
+
+       get_canvas()->set_time(get_time());
+       get_canvas_view()->get_smach().process_event(EVENT_REFRESH_DUCKS);
+       signal_rendering()();
+
+       async_update_preview();
+}
+void
+WorkArea::async_render_preview()
+{
+       return async_render_preview(get_canvas_view()->get_time());
+}
+
+bool
+studio::WorkArea::sync_render_preview(synfig::Time time)
+{
+       cur_time=time;
+       //tile_book.clear();
+       refreshes+=5;
+       if(!is_visible())return false;
+       return sync_update_preview();
+}
+
+bool
+WorkArea::sync_render_preview()
+{
+       return sync_render_preview(get_canvas_view()->get_time());
+}
+
+void
+WorkArea::sync_render_preview_hook()
+{
+       sync_render_preview(get_canvas_view()->get_time());
+}
+
+void
+WorkArea::queue_scroll()
+{
+//     const synfig::RendDesc &rend_desc(get_canvas()->rend_desc());
+
+       const synfig::Point focus_point(get_focus_point());
+
+       const synfig::Real
+               new_x(focus_point[0]/pw+drawing_area->get_width()/2-w/2),
+               new_y(focus_point[1]/ph+drawing_area->get_height()/2-h/2);
+
+       const synfig::Real
+               old_x(last_focus_point[0]/pw+drawing_area->get_width()/2-w/2),
+               old_y(last_focus_point[1]/ph+drawing_area->get_height()/2-h/2);
+
+       // If the coordinates didn't change, we shouldn't queue a draw
+       if(old_x==new_x && old_y==new_y)
+               return;
+
+       const int
+               dx(round_to_int(old_x)-round_to_int(new_x)),
+               dy(round_to_int(old_y)-round_to_int(new_y));
+
+       drawing_area->get_window()->scroll(-dx,-dy);
+
+       if (timecode_width && timecode_height)
+       {
+               drawing_area->queue_draw_area(4,       4,    4+timecode_width,    4+timecode_height);
+               drawing_area->queue_draw_area(4-dx, 4-dy, 4-dx+timecode_width, 4-dy+timecode_height);
+       }
+
+#ifndef USE_FRAME_BACKGROUND_TO_SHOW_EDIT_MODE
+       if(canvas_interface->get_mode()&synfigapp::MODE_ANIMATE)
+       {
+               int maxx = drawing_area->get_width()-1;
+               int maxy = drawing_area->get_height()-1;
+
+               if (dx > 0)
+               {
+                       drawing_area->queue_draw_area(      0, 0,       1, maxy);
+                       drawing_area->queue_draw_area(maxx-dx, 0, maxx-dx, maxy);
+               }
+               else if (dx < 0)
+               {
+                       drawing_area->queue_draw_area(   maxx, 0,    maxx, maxy);
+                       drawing_area->queue_draw_area(    -dx, 0,     -dx, maxy);
+               }
+               if (dy > 0)
+               {
+                       drawing_area->queue_draw_area(0,       0, maxx,       1);
+                       drawing_area->queue_draw_area(0, maxy-dy, maxx, maxy-dy);
+               }
+               else if (dy < 0)
+               {
+                       drawing_area->queue_draw_area(0,    maxy, maxx,    maxy);
+                       drawing_area->queue_draw_area(0,     -dy, maxx,     -dy);
+               }
+       }
+#endif // USE_FRAME_BACKGROUND_TO_SHOW_EDIT_MODE
+
+       last_focus_point=focus_point;
+}
+
+void
+studio::WorkArea::zoom_in()
+{
+       set_zoom(zoom*1.25);
+}
+
+void
+studio::WorkArea::zoom_out()
+{
+       set_zoom(zoom/1.25);
+}
+
+void
+studio::WorkArea::zoom_fit()
+{
+       float new_zoom(min(drawing_area->get_width() * zoom / w,
+                                          drawing_area->get_height() * zoom / h) * 0.995);
+       if (zoom / new_zoom > 0.995 && new_zoom / zoom > 0.995)
+       {
+               set_zoom(prev_zoom);
+               return set_focus_point(previous_focus);
+       }
+       previous_focus = get_focus_point();
+       prev_zoom = zoom;
+       set_zoom(new_zoom);
+       set_focus_point(Point(0,0));
+}
+
+void
+studio::WorkArea::zoom_norm()
+{
+       if (zoom == 1.0) return set_zoom(prev_zoom);
+       prev_zoom = zoom;
+       set_zoom(1.0f);
+}
+
+gboolean
+studio::WorkArea::__render_preview(gpointer data)
+{
+       WorkArea *work_area(static_cast<WorkArea*>(data));
+
+       // there's no point anyone trying to cancel the timer now - it's gone off already
+       work_area->render_idle_func_id = 0;
+
+       work_area->queued=false;
+       work_area->async_render_preview(work_area->get_canvas_view()->get_time());
+
+       return 0;
+}
+
+void
+studio::WorkArea::queue_render_preview()
+{
+       //synfig::info("queue_render_preview(): called for %s", get_canvas_view()->get_time().get_string().c_str());
+
+       if(queued==true)
+       {
+               return;
+               //synfig::info("queue_render_preview(): already queued, unqueuing");
+/*             if(render_idle_func_id)
+                       g_source_remove(render_idle_func_id);
+               render_idle_func_id=0;
+               queued=false;
+*/
+               //async_renderer=0;
+       }
+
+       if(dirty_trap_enabled)
+       {
+               dirty_trap_queued++;
+               return;
+       }
+
+       int queue_time=50;
+
+       if(rendering)
+               queue_time+=250;
+
+
+       if(queued==false)
+       {
+               //synfig::info("queue_render_preview(): (re)queuing...");
+               //render_idle_func_id=g_idle_add_full(G_PRIORITY_DEFAULT,__render_preview,this,NULL);
+               render_idle_func_id=g_timeout_add_full(
+                       G_PRIORITY_DEFAULT,     // priority -
+                       queue_time,                     // interval - the time between calls to the function, in milliseconds (1/1000ths of a second)
+                       __render_preview,       // function - function to call
+                       this,                           // data     - data to pass to function
+                       NULL);                          // notify   - function to call when the idle is removed, or NULL
+               queued=true;
+       }
+/*     else if(rendering)
+       {
+               refreshes+=5;
+               dirty=true;
+               queue_draw();
+       }
+*/
+}
+
+DirtyTrap::DirtyTrap(WorkArea *work_area):work_area(work_area)
+{
+       work_area->dirty_trap_enabled=true;
+
+       work_area->dirty_trap_queued=0;
+}
+
+DirtyTrap::~DirtyTrap()
+{
+       work_area->dirty_trap_enabled=false;
+       if(work_area->dirty_trap_queued)
+               work_area->queue_render_preview();
+}
+
+void
+studio::WorkArea::queue_draw_preview()
+{
+       drawing_area->queue_draw();
+}
+
+void
+studio::WorkArea::set_cursor(const Gdk::Cursor& x)
+{
+       drawing_area->get_window()->set_cursor(x);
+}
+void
+studio::WorkArea::set_cursor(Gdk::CursorType x)
+{
+       drawing_area->get_window()->set_cursor(Gdk::Cursor(x));
+}
+
+//#include "iconcontroller.h"
+void
+studio::WorkArea::refresh_cursor()
+{
+//     set_cursor(IconController::get_tool_cursor(canvas_view->get_smach().get_state_name(),drawing_area->get_window()));
+}
+
+void
+studio::WorkArea::reset_cursor()
+{
+       drawing_area->get_window()->set_cursor(Gdk::Cursor(Gdk::TOP_LEFT_ARROW));
+//     set_cursor(Gdk::TOP_LEFT_ARROW);
+}
+
+void
+studio::WorkArea::set_zoom(float z)
+{
+       z=max(1.0f/128.0f,min(128.0f,z));
+       if(z==zoom)
+               return;
+       zoom = z;
+       refresh_dimension_info();
+       /*if(async_renderer)
+       {
+               async_renderer->stop();
+               async_renderer=0;
+       }*/
+       refreshes+=5;
+       async_update_preview();
+       //queue_render_preview();
+}
+
+void
+WorkArea::set_selected_value_node(etl::loose_handle<synfig::ValueNode> x)
+{
+       if(x!=selected_value_node_)
+       {
+               selected_value_node_=x;
+               queue_draw();
+       }
+}
+
+void
+WorkArea::insert_renderer(const etl::handle<WorkAreaRenderer> &x)
+{
+       renderer_set_.insert(x);
+       x->set_work_area(this);
+       queue_draw();
+}
+
+void
+WorkArea::insert_renderer(const etl::handle<WorkAreaRenderer> &x, int priority)
+{
+       x->set_priority(priority);
+       insert_renderer(x);
+}
+
+void
+WorkArea::erase_renderer(const etl::handle<WorkAreaRenderer> &x)
+{
+       x->set_work_area(0);
+       renderer_set_.erase(x);
+       queue_draw();
+}
+
+void
+WorkArea::resort_render_set()
+{
+       std::set<etl::handle<WorkAreaRenderer> > tmp(
+               renderer_set_.begin(),
+               renderer_set_.end()
+       );
+       renderer_set_.swap(tmp);
+       queue_draw();
+}
diff --git a/synfig-studio/src/gui/workarea.h b/synfig-studio/src/gui/workarea.h
new file mode 100644 (file)
index 0000000..989ac8d
--- /dev/null
@@ -0,0 +1,515 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file workarea.h
+**     \brief Template Header
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 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
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_GTKMM_WORKAREA_H
+#define __SYNFIG_GTKMM_WORKAREA_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <list>
+#include <map>
+#include <set>
+
+#include <ETL/smart_ptr>
+#include <ETL/handle>
+
+#include <gtkmm/drawingarea.h>
+#include <gtkmm/table.h>
+#include <gtkmm/adjustment.h>
+#include <gtkmm/ruler.h>
+#include <gtkmm/image.h>
+#include <gdkmm/pixbuf.h>
+#include <gdkmm/cursor.h>
+#include <gdkmm/device.h>
+
+#include <synfig/time.h>
+#include <synfig/vector.h>
+#include <synfig/general.h>
+#include <synfig/renddesc.h>
+#include <synfig/canvas.h>
+
+#include "zoomdial.h"
+#include "duckmatic.h"
+#include "instance.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 etl {
+
+template <typename T_, typename C_=std::less<T_,T_> >
+class dereferenced_compare
+{
+public:
+       typedef etl::loose_handle<T_> first_argument_type;
+       typedef etl::loose_handle<T_> second_argument_type;
+       typedef bool result_type;
+
+}
+};
+*/
+
+namespace synfigapp { class CanvasInterface; };
+
+namespace synfig { class Layer; };
+namespace Gtk { class Frame; };
+
+namespace studio
+{
+class WorkAreaTarget;
+class WorkAreaTarget_Full;
+
+class Instance;
+class CanvasView;
+class WorkArea;
+class WorkAreaRenderer;
+class AsyncRenderer;
+class DirtyTrap
+{
+       friend class WorkArea;
+       WorkArea *work_area;
+public:
+       DirtyTrap(WorkArea *work_area);
+       ~DirtyTrap();
+};
+
+
+class WorkArea : public Gtk::Table, public Duckmatic
+{
+       friend class WorkAreaTarget;
+       friend class WorkAreaTarget_Full;
+       friend class DirtyTrap;
+       friend class WorkAreaRenderer;
+       friend class WorkAreaProgress;
+
+       /*
+ -- ** -- P U B L I C   T Y P E S ---------------------------------------------
+       */
+
+public:
+
+       void insert_renderer(const etl::handle<WorkAreaRenderer> &x);
+       void insert_renderer(const etl::handle<WorkAreaRenderer> &x,int priority);
+       void erase_renderer(const etl::handle<WorkAreaRenderer> &x);
+       void resort_render_set();
+
+       enum DragMode
+       {
+               DRAG_NONE=0,
+               DRAG_WINDOW,
+               DRAG_DUCK,
+               DRAG_GUIDE,
+               DRAG_BOX
+       };
+
+       /*
+ -- ** -- P R I V A T E   D A T A ---------------------------------------------
+       */
+
+private:
+
+       std::set<etl::handle<WorkAreaRenderer> > renderer_set_;
+
+       etl::handle<studio::AsyncRenderer> async_renderer;
+
+
+       etl::loose_handle<synfigapp::CanvasInterface> canvas_interface;
+       etl::handle<synfig::Canvas> canvas;
+       etl::loose_handle<studio::Instance> instance;
+       etl::loose_handle<studio::CanvasView> canvas_view;
+
+       // Widgets
+       Gtk::DrawingArea *drawing_area;
+       Gtk::Adjustment scrollx_adjustment;
+       Gtk::Adjustment scrolly_adjustment;
+       Gtk::VRuler *vruler;
+       Gtk::HRuler *hruler;
+       Gtk::Button *menubutton;
+       Gtk::Frame *drawing_frame;
+
+       GdkDevice* curr_input_device;
+
+       // Bleh!
+       int     w;                                              //!< Width of the image (in pixels)
+       int     h;                                              //!< Height of the image (in pixels)
+       synfig::Real    canvaswidth;    //!< Width of the canvas
+       synfig::Real    canvasheight;   //!< Height of the canvas
+       synfig::Real    pw;                             //!< The width of a pixel
+       synfig::Real    ph;                             //!< The height of a pixel
+       float zoom;                                     //!< Zoom factor
+       float prev_zoom;                        //!< Previous Zoom factor
+       synfig::Point window_tl;                //!< The (theoretical) top-left corner of the view window
+       synfig::Point window_br;                //!< The (theoretical) bottom-right corner of the view window
+
+       guint32 last_event_time;
+
+       int bpp;
+       //unsigned char *buffer;
+
+       //! ???
+       synfig::ProgressCallback *progresscallback;
+
+       //! ???
+       synfig::RendDesc desc;
+
+       //! This flag is set if the user is dragging the video window
+       /*! \see drag_point */
+       DragMode dragging;
+
+       etl::handle<Duckmatic::Duck> clicked_duck;
+       etl::handle<Duckmatic::Duck> hover_duck;
+
+       //! When dragging the viewport, this is set to the origin of the drag
+       synfig::Point drag_point;
+
+       synfig::Point curr_point;
+
+       //! ???
+       synfig::Point previous_focus;
+
+       //! This flag is set if the grid should be drawn
+       bool show_grid;
+
+       //! This flag is set if the guides should be drawn
+       bool show_guides;
+
+       bool low_resolution;
+
+       bool meta_data_lock;
+
+       //! This flag is set if the entire frame is rendered rather than using tiles
+       bool full_frame;
+
+       //Glib::RefPtr<Gdk::Pixbuf> pix_buf;
+
+       //! This vector holds all of the tiles for this image
+       std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> > tile_book;
+
+       //! This integer describes the total times that the work are has been refreshed
+       int refreshes;
+
+       //! This list holds the queue of tiles that need to be rendered
+       //std::list<int> tile_queue;
+
+       int tile_w, tile_h;
+
+       gint render_idle_func_id;
+
+       //! The coordinates of the focus the last time a part of the screen was refreshed
+       synfig::Point last_focus_point;
+
+       bool canceled_;
+
+       int quality;
+       int low_res_pixel_size;
+
+       bool dirty_trap_enabled;
+
+       int dirty_trap_queued;
+
+
+       bool onion_skin;
+       //! stores the future [1] and past [0] onion skins based on keyframes
+       int onion_skins[2];
+
+       etl::loose_handle<synfig::ValueNode> selected_value_node_;
+
+       bool allow_duck_clicks;
+       bool allow_layer_clicks;
+       bool cancel;
+       bool curr_guide_is_x;
+       bool dirty;
+       bool queued;
+       bool rendering;
+
+       /*
+ -- ** -- P U B L I C   D A T A -----------------------------------------------
+       */
+
+public:
+
+       const etl::loose_handle<synfig::ValueNode>& get_selected_value_node() { return  selected_value_node_; }
+       const synfig::Point& get_drag_point()const { return drag_point; }
+       std::vector< std::pair<Glib::RefPtr<Gdk::Pixbuf>,int> >& get_tile_book(){ return tile_book; }
+       int get_refreshes()const { return refreshes; }
+       bool get_canceled()const { return canceled_; }
+       bool get_queued()const { return queued; }
+       bool get_rendering()const { return rendering; }
+#ifdef SINGLE_THREADED
+       bool get_updating()const;
+       void stop_updating(bool cancel = false);
+#endif
+       bool get_full_frame()const { return full_frame; }
+       //int get_w()const { return w; }
+       //int get_h()const { return h; }
+
+       int get_tile_w()const { return tile_w; }
+       int get_tile_h()const { return tile_h; }
+
+       bool get_allow_layer_clicks() { return allow_layer_clicks; }
+       void set_allow_layer_clicks(bool value) { allow_layer_clicks=value; }
+
+       bool get_allow_duck_clicks() { return allow_duck_clicks; }
+       void set_allow_duck_clicks(bool value) { allow_duck_clicks=value; }
+
+       // used in renderer_ducks.cpp
+       bool solid_lines;
+
+       // used in renderer_guides.cpp
+       GuideList::iterator curr_guide;
+
+       // used in renderer_timecode.cpp
+       int timecode_width, timecode_height;
+
+       /*
+ -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
+       */
+
+private:
+
+       //unsigned char *get_buffer() { return buffer; }
+       bool set_wh(int w, int h,int chan=3);
+
+       int next_unrendered_tile(int refreshes)const;
+       int next_unrendered_tile()const { return next_unrendered_tile(refreshes); }
+
+       /*
+ -- ** -- S I G N A L S -------------------------------------------------------
+       */
+
+private:
+
+       sigc::signal<void,GdkDevice* > signal_input_device_changed_;
+
+       //! One signal per button
+       sigc::signal<void,synfig::Point> signal_user_click_[5];
+
+       sigc::signal<void> signal_popup_menu_;
+
+       sigc::signal<void> signal_cursor_moved_;
+       sigc::signal<void> signal_rendering_;
+
+       sigc::signal<void> signal_onion_skin_changed_;
+
+       //! Signal for when the user clicks on a layer
+       sigc::signal<void, etl::handle<synfig::Layer> > signal_layer_selected_;
+
+       sigc::signal<void> signal_view_window_changed_;
+
+public:
+
+       sigc::signal<void>& signal_onion_skin_changed() { return signal_onion_skin_changed_; }
+
+       sigc::signal<void>& signal_rendering() { return signal_rendering_; }
+
+       sigc::signal<void>& signal_cursor_moved() { return signal_cursor_moved_; }
+
+       sigc::signal<void>& signal_view_window_changed() { return signal_view_window_changed_; }
+       void view_window_changed() { signal_view_window_changed()(); }
+
+       sigc::signal<void,GdkDevice* >& signal_input_device_changed() { return signal_input_device_changed_; }
+
+       sigc::signal<void> &signal_popup_menu() { return signal_popup_menu_; }
+
+       //! One signal per button (5 buttons)
+       sigc::signal<void,synfig::Point> &signal_user_click(int button=0){ return signal_user_click_[button]; }
+
+       sigc::signal<void, etl::handle<synfig::Layer> >& signal_layer_selected() { return signal_layer_selected_; }
+
+       /*
+ -- ** -- P U B L I C   M E T H O D S -----------------------------------------
+       */
+
+public:
+       void set_onion_skin(bool x);
+       bool get_onion_skin()const;
+       void toggle_onion_skin() { set_onion_skin(!get_onion_skin()); }
+       void set_onion_skins(int *onions);
+
+       void set_selected_value_node(etl::loose_handle<synfig::ValueNode> x);
+
+       bool is_dragging() { return dragging!=DRAG_NONE; }
+
+       DragMode get_dragging_mode() { return dragging; }
+
+       WorkArea(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface);
+       virtual ~WorkArea();
+
+       void set_cursor(const Gdk::Cursor& x);
+       void set_cursor(Gdk::CursorType x);
+
+       const synfig::Point& get_cursor_pos()const { return curr_point; }
+
+       Gtk::Adjustment *get_scrollx_adjustment() { return &scrollx_adjustment; }
+       Gtk::Adjustment *get_scrolly_adjustment() { return &scrolly_adjustment; }
+       const Gtk::Adjustment *get_scrollx_adjustment()const { return &scrollx_adjustment; }
+       const Gtk::Adjustment *get_scrolly_adjustment()const { return &scrolly_adjustment; }
+
+       void set_instance(etl::loose_handle<studio::Instance> x) { instance=x; }
+       void set_canvas(etl::handle<synfig::Canvas> x) { canvas=x; }
+       void set_canvas_view(etl::loose_handle<studio::CanvasView> x) { canvas_view=x; }
+       etl::handle<synfig::Canvas> get_canvas()const { return canvas; }
+       etl::handle<studio::Instance> get_instance()const { return instance; }
+       etl::loose_handle<studio::CanvasView> get_canvas_view()const { return canvas_view; }
+
+       void refresh_dimension_info();
+
+       //! Enables showing of the grid
+       void enable_grid();
+
+       //! Disables showing of the grid
+       void disable_grid();
+
+       //! Toggles the showing of the grid
+       void toggle_grid();
+
+       //! Returns the state of the show_grid flag
+       bool grid_status()const { return show_grid; }
+
+       void toggle_grid_snap() { Duckmatic::toggle_grid_snap(); }
+
+       bool get_show_guides()const { return show_guides; }
+       void set_show_guides(bool x);
+       void toggle_show_guides() { set_show_guides(!get_show_guides()); }
+
+       bool get_low_resolution_flag()const { return low_resolution; }
+       void set_low_resolution_flag(bool x);
+       void toggle_low_resolution_flag();
+
+       //! ???
+       void queue_scroll();
+
+       //! Sets the size of the grid
+       void set_grid_size(const synfig::Vector &s);
+
+       //! ??
+       void popup_menu();
+
+       int get_quality()const { return quality; }
+       int get_low_res_pixel_size()const { return low_res_pixel_size; }
+
+       void set_quality(int x);
+       void set_low_res_pixel_size(int x);
+
+
+       int get_w()const { return w; }
+       int get_h()const { return h; }
+       int get_bpp()const { return bpp; }
+
+       //! ??
+       const synfig::RendDesc &get_rend_desc()const { return desc; }
+
+       //! ??
+       void set_rend_desc(const synfig::RendDesc &x) { desc=x; }
+
+       //! Converts screen coords (ie: pixels) to composition coordinates
+       synfig::Point screen_to_comp_coords(synfig::Point pos)const;
+
+       //! Converts composition coordinates to screen coords (ie: pixels)
+       synfig::Point comp_to_screen_coords(synfig::Point pos)const;
+
+       float get_pw()const { return pw; }
+       float get_ph()const { return ph; }
+
+       const synfig::Point &get_window_tl()const { return window_tl; }
+       const synfig::Point &get_window_br()const { return window_br; }
+
+
+       bool async_update_preview();
+       void async_update_finished();
+       void async_render_preview(synfig::Time time);
+       void async_render_preview();
+
+       bool sync_update_preview();
+       bool sync_render_preview(synfig::Time time);
+       bool sync_render_preview();
+       void sync_render_preview_hook();
+
+       void queue_render_preview();
+
+
+       void queue_draw_preview();
+
+       void zoom_in();
+       void zoom_out();
+       void zoom_fit();
+       void zoom_norm();
+       float get_zoom()const { return zoom; }
+
+       void set_zoom(float z);
+
+
+       void set_progress_callback(synfig::ProgressCallback *x) { progresscallback=x; }
+       synfig::ProgressCallback *get_progress_callback() { return progresscallback; }
+
+       void set_focus_point(const synfig::Point &x);
+
+       synfig::Point get_focus_point()const;
+
+       void done_rendering();
+
+       bool refresh(GdkEventExpose*bleh=NULL);
+
+       void reset_cursor();
+       void refresh_cursor();
+
+       void save_meta_data();
+       void load_meta_data();
+
+       /*
+ -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
+       */
+
+private:
+       bool on_key_press_event(GdkEventKey* event);
+       bool on_drawing_area_event(GdkEvent* event);
+       bool on_hruler_event(GdkEvent* event);
+       bool on_vruler_event(GdkEvent* event);
+
+       /*
+ -- ** -- S T A T I C   P U B L I C   M E T H O D S ---------------------------
+       */
+
+public:
+
+       /*
+ -- ** -- S T A T I C   P R I V A T E   M E T H O D S -------------------------
+       */
+
+private:
+
+       static gboolean __render_preview(gpointer data);
+
+}; // END of class WorkArea
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/workarearenderer.cpp b/synfig-studio/src/gui/workarearenderer.cpp
new file mode 100644 (file)
index 0000000..303bc03
--- /dev/null
@@ -0,0 +1,134 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file workarearenderer.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "workarearenderer.h"
+#include "workarea.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 ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+WorkAreaRenderer::WorkAreaRenderer():
+       enabled_(true),
+       priority_(0)
+{
+}
+
+WorkAreaRenderer::~WorkAreaRenderer()
+{
+}
+
+bool
+WorkAreaRenderer::get_enabled_vfunc()const
+{
+       return enabled_;
+}
+
+void
+WorkAreaRenderer::set_enabled(bool x)
+{
+       if(x==enabled_)
+               return;
+       enabled_=x;
+       signal_changed()();
+}
+
+void
+WorkAreaRenderer::set_priority(int x)
+{
+       if(x==priority_)
+               return;
+       priority_=x;
+       signal_changed()();
+}
+
+void
+WorkAreaRenderer::set_work_area(WorkArea* x)
+{
+       work_area_=x;
+}
+
+void
+WorkAreaRenderer::render_vfunc(
+       const Glib::RefPtr<Gdk::Drawable>& /*window*/,
+       const Gdk::Rectangle& /*expose_area*/
+)
+{
+}
+
+bool
+WorkAreaRenderer::event_vfunc(
+       GdkEvent* /*event*/
+)
+{
+       return false;
+}
+
+int
+WorkAreaRenderer::get_w()const
+{ return get_work_area()->get_w(); }
+int
+WorkAreaRenderer::get_h()const
+{ return get_work_area()->get_h(); }
+
+float
+WorkAreaRenderer::get_pw()const
+{ return get_work_area()->get_pw(); }
+float
+WorkAreaRenderer::get_ph()const
+{ return get_work_area()->get_ph(); }
+
+synfig::Point
+WorkAreaRenderer::screen_to_comp_coords(synfig::Point pos)const
+{
+       return get_work_area()->screen_to_comp_coords(pos);
+}
+
+synfig::Point
+WorkAreaRenderer::comp_to_screen_coords(synfig::Point pos)const
+{
+       return get_work_area()->comp_to_screen_coords(pos);
+}
diff --git a/synfig-studio/src/gui/workarearenderer.h b/synfig-studio/src/gui/workarearenderer.h
new file mode 100644 (file)
index 0000000..fd79bb6
--- /dev/null
@@ -0,0 +1,116 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file workarearenderer.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_WORKAREARENDERER_H
+#define __SYNFIG_WORKAREARENDERER_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <ETL/handle>
+#include <sigc++/signal.h>
+#include <sigc++/object.h>
+#include <synfig/vector.h>
+#include <gdkmm/drawable.h>
+#include <gdkmm/rectangle.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 WorkArea;
+
+class WorkAreaRenderer : public etl::shared_object, public sigc::trackable
+{
+public:
+       typedef etl::handle<WorkAreaRenderer> Handle;
+       typedef etl::loose_handle<WorkAreaRenderer> LooseHandle;
+
+private:
+       bool enabled_;
+       int priority_;
+
+       sigc::signal<void> signal_changed_;
+
+       WorkArea* work_area_;
+
+public:
+
+       sigc::signal<void>& signal_changed() { return signal_changed_; }
+
+public:
+       int get_w()const;
+       int get_h()const;
+
+       float get_pw()const;
+       float get_ph()const;
+
+       //! Converts screen coords (ie: pixels) to composition coordinates
+       synfig::Point screen_to_comp_coords(synfig::Point pos)const;
+
+       //! Converts composition coordinates to screen coords (ie: pixels)
+       synfig::Point comp_to_screen_coords(synfig::Point pos)const;
+
+       WorkAreaRenderer();
+       virtual ~WorkAreaRenderer();
+
+       bool get_enabled()const { return get_enabled_vfunc(); }
+       int get_priority()const { return priority_; }
+       WorkArea* get_work_area()const { return work_area_; }
+
+       void set_enabled(bool x);
+       void set_priority(int x);
+       void set_work_area(WorkArea* work_area_);
+
+       virtual void render_vfunc(
+               const Glib::RefPtr<Gdk::Drawable>& window,
+               const Gdk::Rectangle& expose_area
+       );
+
+       virtual bool event_vfunc(
+               GdkEvent* event
+       );
+
+protected:
+
+       virtual bool get_enabled_vfunc()const;
+
+public:
+       bool operator<(const WorkAreaRenderer &rhs)
+               { return priority_<rhs.priority_; }
+};
+
+inline bool operator<(const WorkAreaRenderer::Handle &lhs,const WorkAreaRenderer::Handle &rhs)
+       { return lhs->get_priority() < rhs->get_priority(); }
+
+inline bool operator<(const WorkAreaRenderer::LooseHandle &lhs,const WorkAreaRenderer::LooseHandle &rhs)
+       { return lhs->get_priority() < rhs->get_priority(); }
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/zoomdial.cpp b/synfig-studio/src/gui/zoomdial.cpp
new file mode 100644 (file)
index 0000000..ae2f4a4
--- /dev/null
@@ -0,0 +1,81 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file zoomdial.cpp
+**     \brief Template File
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+#      include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+#      include <config.h>
+#endif
+
+#include "zoomdial.h"
+#include <gtkmm/image.h>
+#include <gtkmm/stock.h>
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace studio;
+
+/* === M A C R O S ========================================================= */
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+ZoomDial::ZoomDial(Gtk::IconSize & size): Table(3, 1, false)
+{
+       zoom_in = create_icon(size, Gtk::Stock::ZOOM_IN, _("Zoom In"));
+       zoom_out = create_icon(size, Gtk::Stock::ZOOM_OUT, _("Zoom Out"));
+       zoom_fit = create_icon(size, Gtk::Stock::ZOOM_FIT, _("Zoom to Fit"));
+       zoom_norm = create_icon(size, Gtk::Stock::ZOOM_100, _("Zoom to 100%"));
+
+       attach(*zoom_out, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       attach(*zoom_norm, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       attach(*zoom_fit, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+       attach(*zoom_in, 3, 4, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
+}
+
+Gtk::Button *
+ZoomDial::create_icon(Gtk::IconSize size, const Gtk::BuiltinStockID & stockid,
+               const char * tooltip)
+{
+       Gtk::Button *button = manage(new class Gtk::Button());
+       Gtk::Image *icon = manage(new Gtk::Image(stockid, size));
+       button->add(*icon);
+       tooltips.set_tip(*button, tooltip);
+       icon->set_padding(0, 0);
+       icon->show();
+       button->set_relief(Gtk::RELIEF_NONE);
+       button->show();
+
+       return button;
+}
+
diff --git a/synfig-studio/src/gui/zoomdial.h b/synfig-studio/src/gui/zoomdial.h
new file mode 100644 (file)
index 0000000..1d9d63a
--- /dev/null
@@ -0,0 +1,70 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file zoomdial.h
+**     \brief Template Header
+**
+**     $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
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_STUDIO_ZOOMDIAL_H
+#define __SYNFIG_STUDIO_ZOOMDIAL_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/tooltips.h>
+#include <gtkmm/table.h>
+#include <gtkmm/button.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 ZoomDial : public Gtk::Table
+{
+       Gtk::Tooltips tooltips;
+
+       Gtk::Button *zoom_in;
+       Gtk::Button *zoom_out;
+       Gtk::Button *zoom_fit;
+       Gtk::Button *zoom_norm;
+
+       Gtk::Button *create_icon(Gtk::IconSize size, const Gtk::BuiltinStockID & stockid,
+                       const char * tooltip);
+
+public:
+       ZoomDial(Gtk::IconSize &size);
+
+       Glib::SignalProxy0<void> signal_zoom_in()   { return zoom_in->signal_clicked(); }
+       Glib::SignalProxy0<void> signal_zoom_out()  { return zoom_out->signal_clicked(); }
+       Glib::SignalProxy0<void> signal_zoom_fit()  { return zoom_fit->signal_clicked(); }
+       Glib::SignalProxy0<void> signal_zoom_norm() { return zoom_norm->signal_clicked(); }
+
+}; // END of class ZoomDial
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif