// this was causing a crash before
canvas_interface()->signal_dirty_preview().clear();
- synfig::info("CanvasView:~CanvasView(): Destructor Finished");
+ 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()
{
set_time(current_time_widget->get_value());
}
-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().connect(sigc::mem_fun(*this, &studio::CanvasView::on_waypoint_clicked));
- 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
- 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();
+// 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().connect(sigc::mem_fun(*this, &studio::CanvasView::on_waypoint_clicked));
+// if(children_tree)children_tree->get_selection()->signal_changed().connect(SLOT_EVENT(EVENT_REFRESH_DUCKS));
+//
+// return children_tree;
+// }
- // 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().connect(sigc::mem_fun(*this, &studio::CanvasView::on_waypoint_clicked));
- layer_tree->get_selection()->signal_changed().connect(SLOT_EVENT(EVENT_REFRESH_DUCKS));
+// 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;
+// }
- layer_tree->hide();
- return layer_tree;
-}
+// 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().connect(sigc::mem_fun(*this, &studio::CanvasView::on_waypoint_clicked));
+// layer_tree->get_selection()->signal_changed().connect(SLOT_EVENT(EVENT_REFRESH_DUCKS));
+//
+// layer_tree->hide();
+// return layer_tree;
+// }
void
CanvasView::init_menus()
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==9) // default quality
+ if (i==8) // default quality
{
action->set_active();
work_area->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)
);
sigc::mem_fun0(*preview_dialog, &studio::Dialog_Preview::present)
);
- action_group->add( Gtk::Action::create("toggle-grid-show", _("Toggle Grid Show")),
- sigc::mem_fun(*work_area, &studio::WorkArea::toggle_grid)
- );
- action_group->add( Gtk::Action::create("toggle-grid-snap", _("Toggle Grid Snap")),
- sigc::mem_fun(*work_area, &studio::WorkArea::toggle_grid_snap)
- );
- action_group->add( Gtk::Action::create("toggle-guide-show", _("Toggle Guide Show")),
- sigc::mem_fun(*work_area, &studio::WorkArea::toggle_guide_snap)
- );
- action_group->add( Gtk::Action::create("toggle-low-res", _("Toggle Low-Res")),
- sigc::mem_fun(*work_area, &studio::WorkArea::toggle_low_resolution_flag)
- );
- action_group->add( Gtk::Action::create("toggle-onion-skin", _("Toggle Onion Skin")),
- sigc::mem_fun(*work_area, &studio::WorkArea::toggle_onion_skin)
- );
+ {
+ Glib::RefPtr<Gtk::ToggleAction> action;
+
+ action = Gtk::ToggleAction::create("toggle-grid-show", _("Show Grid"));
+ action->set_active(work_area->grid_status());
+ action_group->add(action, sigc::mem_fun(*work_area, &studio::WorkArea::toggle_grid));
+
+ action = Gtk::ToggleAction::create("toggle-grid-snap", _("Snap to Grid"));
+ action->set_active(work_area->get_grid_snap());
+ action_group->add(action, sigc::mem_fun(*work_area, &studio::WorkArea::toggle_grid_snap));
+
+ 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(*work_area, &studio::WorkArea::toggle_low_resolution_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(*work_area, &studio::WorkArea::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)
sigc::mem_fun(*work_area, &studio::WorkArea::zoom_norm)
);
-
{
Glib::RefPtr<Gtk::Action> action;
{
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);
- }
+ 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
}
void
+CanvasView::decrease_low_res_pixel_size()
+{
+ 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;
+ }
+}
+
+void
+CanvasView::increase_low_res_pixel_size()
+{
+ list<int> sizes = CanvasView::get_pixel_sizes();
+ int pixel_size = work_area->get_low_res_pixel_size();
+
+ if (!work_area->get_low_resolution_flag())
+ {
+ work_area->set_low_resolution_flag(true);
+ 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;
+ }
+}
+
+void
CanvasView::on_dirty_preview()
{
if(!is_playing_)
void
CanvasView::image_import()
{
- String filename(dirname(get_canvas()->get_file_name()));
- if(App::dialog_open_file(_("Import Image"), filename))
+ // String filename(dirname(get_canvas()->get_file_name()));
+ String filename("*.*");
+ if(App::dialog_open_file(_("Import Image"), filename, IMAGE_DIR_PREFERENCE))
canvas_interface()->import(filename);
}
}
bool
-CanvasView::on_delete_event(GdkEventAny* event)
+CanvasView::on_delete_event(GdkEventAny* event __attribute__ ((unused)))
{
close_view();