X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Fstate_bline.cpp;h=dc543ff469c8d59695091441dbb2c409abf7fd5e;hb=11c0abb278300f2c4439b538b300433078a19a78;hp=f2ba41be011ca40b44a1ddfa4bf320f335727542;hpb=02252941b29de64037116f4d37991a38d9ff0d94;p=synfig.git diff --git a/synfig-studio/trunk/src/gtkmm/state_bline.cpp b/synfig-studio/trunk/src/gtkmm/state_bline.cpp index f2ba41b..dc543ff 100644 --- a/synfig-studio/trunk/src/gtkmm/state_bline.cpp +++ b/synfig-studio/trunk/src/gtkmm/state_bline.cpp @@ -1,20 +1,21 @@ /* === S Y N F I G ========================================================= */ -/*! \file rotoscope_bline.cpp +/*! \file state_bline.cpp ** \brief Template File ** -** $Id: state_bline.cpp,v 1.1.1.1 2005/01/07 03:34:36 darco Exp $ +** $Id$ ** ** \legal -** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley ** -** This software and associated documentation -** are CONFIDENTIAL and PROPRIETARY property of -** the above-mentioned copyright holder. +** This package is free software; you can redistribute it and/or +** modify it under the terms of the GNU General Public License as +** published by the Free Software Foundation; either version 2 of +** the License, or (at your option) any later version. ** -** You may not copy, print, publish, or in any -** other way distribute this software without -** a prior written agreement with -** the copyright holder. +** This package is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. ** \endlegal */ /* ========================================================================= */ @@ -70,7 +71,7 @@ class studio::StateBLine_Context : public sigc::trackable { etl::handle canvas_view_; CanvasView::IsWorking is_working; - + bool prev_table_status; bool loop_; bool prev_workarea_layer_status_; @@ -81,14 +82,14 @@ class studio::StateBLine_Context : public sigc::trackable Gtk::Menu menu; Duckmatic::Push duckmatic_push; - + etl::handle curr_duck; etl::handle next_duck; - + std::list 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); @@ -103,9 +104,10 @@ class studio::StateBLine_Context : public sigc::trackable 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; @@ -116,9 +118,9 @@ class studio::StateBLine_Context : public sigc::trackable Gtk::Button button_clear; Gtk::Adjustment adj_feather; Gtk::SpinButton spin_feather; - - - + + + public: int layers_to_create()const @@ -128,7 +130,7 @@ public: get_layer_bline_flag()+ get_layer_curve_gradient_flag(); } - + void sanity_check() { if(layers_to_create()==0) @@ -137,13 +139,13 @@ public: 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_bline_flag()const { return checkbutton_layer_bline.get_active(); } void set_layer_bline_flag(bool x) { return checkbutton_layer_bline.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); } @@ -161,8 +163,8 @@ public: 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; } - + Smach::event_result event_hijack(const Smach::event& /*x*/) { return Smach::RESULT_ACCEPT; } + void refresh_tool_options(); StateBLine_Context(CanvasView* canvas_view); @@ -174,7 +176,7 @@ public: 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(); @@ -183,15 +185,15 @@ public: bool run_(); bool run(); - + bool no_egress_on_selection_change; - Smach::event_result event_layer_selection_changed_handler(const Smach::event& x) + Smach::event_result event_layer_selection_changed_handler(const Smach::event& /*x*/) { if(!no_egress_on_selection_change) throw Smach::egress_exception(); return Smach::RESULT_OK; } - + }; // END of class StateBLine_Context @@ -209,7 +211,7 @@ StateBLine::StateBLine(): 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() { @@ -217,7 +219,7 @@ StateBLine::~StateBLine() void StateBLine_Context::load_settings() -{ +{ String value; if(settings.get_value("bline.layer_region",value) && value=="0") @@ -256,7 +258,7 @@ StateBLine_Context::load_settings() void StateBLine_Context::save_settings() -{ +{ sanity_check(); settings.set_value("bline.layer_bline",get_layer_bline_flag()?"1":"0"); settings.set_value("bline.layer_region",get_layer_region_flag()?"1":"0"); @@ -280,10 +282,10 @@ 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. @@ -291,12 +293,12 @@ StateBLine_Context::increment_id() { // 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++)while(false); - + 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 @@ -304,15 +306,15 @@ StateBLine_Context::increment_id() 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); } @@ -322,7 +324,7 @@ StateBLine_Context::StateBLine_Context(CanvasView* canvas_view): canvas_view_(canvas_view), is_working(*canvas_view), loop_(false), - prev_workarea_layer_status_(get_work_area()->allow_layer_clicks), + 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(), @@ -338,38 +340,38 @@ StateBLine_Context::StateBLine_Context(CanvasView* canvas_view): depth=-1; no_egress_on_selection_change=false; 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(*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_region, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); - options_table.attach(checkbutton_layer_bline, 0, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); - options_table.attach(checkbutton_layer_curve_gradient, 0, 2, 4, 5, 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(checkbutton_layer_region, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + options_table.attach(checkbutton_layer_bline, 0, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + options_table.attach(checkbutton_layer_curve_gradient, 0, 2, 4, 5, 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(checkbutton_auto_export, 0, 2, 11, 12, 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); + options_table.attach(checkbutton_auto_export, 0, 2, 11, 12, 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()->allow_layer_clicks=false; - + 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(); - - // Hide the time bar - get_canvas_view()->hide_timebar(); - + + // 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_canvas_view()->work_area->set_cursor(Gdk::CROSSHAIR); @@ -407,7 +409,7 @@ StateBLine_Context::refresh_tool_options() } Smach::event_result -StateBLine_Context::event_refresh_tool_options(const Smach::event& x) +StateBLine_Context::event_refresh_tool_options(const Smach::event& /*x*/) { refresh_tool_options(); return Smach::RESULT_ACCEPT; @@ -423,17 +425,16 @@ StateBLine_Context::~StateBLine_Context() get_canvas_view()->work_area->reset_cursor(); // Restore layer clicking - get_work_area()->allow_layer_clicks=prev_workarea_layer_status_; + get_work_area()->set_allow_layer_clicks(prev_workarea_layer_status_); - // Show the time bar - if(get_canvas_view()->get_canvas()->rend_desc().get_time_start()!=get_canvas_view()->get_canvas()->rend_desc().get_time_end()) - get_canvas_view()->show_timebar(); + // 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(); @@ -441,7 +442,7 @@ StateBLine_Context::~StateBLine_Context() } Smach::event_result -StateBLine_Context::event_stop_handler(const Smach::event& x) +StateBLine_Context::event_stop_handler(const Smach::event& /*x*/) { synfig::info("STATE RotoBLine: Received Stop Event"); // run(); @@ -452,7 +453,7 @@ StateBLine_Context::event_stop_handler(const Smach::event& x) } Smach::event_result -StateBLine_Context::event_refresh_handler(const Smach::event& x) +StateBLine_Context::event_refresh_handler(const Smach::event& /*x*/) { synfig::info("STATE RotoBLine: Received Refresh Event"); refresh_ducks(); @@ -488,7 +489,7 @@ StateBLine_Context::run_() next_duck=0; // Now we need to generate it - + if(bline_point_list.empty()) { return false; @@ -498,22 +499,22 @@ StateBLine_Context::run_() //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 new_list; std::list::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() @@ -525,19 +526,19 @@ StateBLine_Context::run_() 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); - + // 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())) { @@ -547,9 +548,9 @@ StateBLine_Context::run_() 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(); @@ -562,12 +563,12 @@ StateBLine_Context::run_() } else depth=0; - + if(!canvas) canvas=get_canvas_view()->get_canvas(); synfigapp::SelectionManager::LayerList layer_selection; - + // If we were asked to create a region layer, go ahead and do so if(get_layer_region_flag()) { @@ -584,16 +585,16 @@ StateBLine_Context::run_() layer->set_param("feather",get_feather()); get_canvas_interface()->signal_layer_param_changed()(layer,"feather"); } - + if(get_layer_bline_flag()) layer->set_param("color",synfigapp::Main::get_background_color()); - + synfigapp::Action::Handle action(synfigapp::Action::create("layer_param_connect")); - + assert(action); - - action->set_param("canvas",get_canvas()); - action->set_param("canvas_interface",get_canvas_interface()); + + 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\""); @@ -623,17 +624,17 @@ StateBLine_Context::run_() layer->set_param("feather",get_feather()); get_canvas_interface()->signal_layer_param_changed()(layer,"feather"); } - + assert(layer); synfigapp::Action::Handle action(synfigapp::Action::create("layer_param_connect")); assert(action); - - action->set_param("canvas",get_canvas()); - action->set_param("canvas_interface",get_canvas_interface()); - action->set_param("layer",layer); + + 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))) @@ -645,7 +646,7 @@ StateBLine_Context::run_() group.cancel(); throw String(_("Unable to create Outline layer")); return false; - } + } /*if(get_layer_region_flag() && !get_auto_export_flag()) { @@ -654,7 +655,7 @@ StateBLine_Context::run_() } - + // If we were asked to create a CurveGradient layer, go ahead and do so if(get_layer_curve_gradient_flag()) { @@ -664,17 +665,17 @@ StateBLine_Context::run_() layer_selection.push_back(layer); layer->set_description(get_id()+_(" Gradient")); get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description()); - + assert(layer); synfigapp::Action::Handle action(synfigapp::Action::create("layer_param_connect")); assert(action); - - action->set_param("canvas",get_canvas()); - action->set_param("canvas_interface",get_canvas_interface()); - action->set_param("layer",layer); + + 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))) @@ -686,7 +687,7 @@ StateBLine_Context::run_() group.cancel(); throw String(_("Unable to create Gradient layer")); return false; - } + } /*if(get_layer_region_flag() && !get_auto_export_flag()) { @@ -698,10 +699,10 @@ StateBLine_Context::run_() get_canvas_interface()->get_selection_manager()->clear_selected_layers(); get_canvas_interface()->get_selection_manager()->set_selected_layers(layer_selection); no_egress_on_selection_change=false; - + //if(finish_bline_dialog.get_region_flag() || finish_bline_dialog.get_bline_flag()) // get_canvas_interface()->signal_dirty_preview()(); - + } while(0); reset(); @@ -713,7 +714,7 @@ Smach::event_result StateBLine_Context::event_mouse_motion_handler(const Smach::event& x) { const EventMouse& event(*reinterpret_cast(&x)); - + if(curr_duck) { //synfig::info("Moved Duck"); @@ -724,12 +725,12 @@ StateBLine_Context::event_mouse_motion_handler(const Smach::event& x) 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) +StateBLine_Context::event_mouse_release_handler(const Smach::event& /*x*/) { if(curr_duck) { @@ -758,16 +759,16 @@ StateBLine_Context::event_mouse_click_handler(const Smach::event& x) // 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()) @@ -779,7 +780,7 @@ StateBLine_Context::event_mouse_click_handler(const Smach::event& x) 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::iterator iter; @@ -790,17 +791,17 @@ StateBLine_Context::event_mouse_click_handler(const Smach::event& x) bline_point_list.back()->set_value(prev); }; */ - + bline_point_list.push_back(ValueNode_Const::create(bline_point)); - + refresh_ducks(); return Smach::RESULT_ACCEPT; } - + case BUTTON_RIGHT: // Intercept the right-button click to short-circut the pop-up menu return Smach::RESULT_ACCEPT; - - default: + + default: return Smach::RESULT_OK; } } @@ -810,7 +811,7 @@ StateBLine_Context::refresh_ducks(bool button_down) { get_work_area()->clear_ducks(); get_work_area()->queue_draw(); - + if(bline_point_list.empty()) return; @@ -819,7 +820,7 @@ StateBLine_Context::refresh_ducks(bool button_down) handle bezier; handle duck,tduck; BLinePoint bline_point; - + for(iter=bline_point_list.begin();iter!=bline_point_list.end();++iter) { ValueNode_Const::Handle value_node(*iter); @@ -827,7 +828,7 @@ StateBLine_Context::refresh_ducks(bool button_down) assert(value_node); - // First add the duck associated with this vertex + // First add the duck associated with this vertex duck=new WorkArea::Duck(bline_point.get_vertex()); duck->set_editable(true); duck->set_type(Duck::TYPE_VERTEX); @@ -840,7 +841,7 @@ StateBLine_Context::refresh_ducks(bool button_down) ); duck->set_guid(value_node->get_guid()^GUID::hasher(0)); - get_work_area()->add_duck(duck); + get_work_area()->add_duck(duck); // Add the tangent1 duck tduck=new WorkArea::Duck(bline_point.get_tangent1()); @@ -856,11 +857,11 @@ StateBLine_Context::refresh_ducks(bool button_down) 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); + get_work_area()->add_duck(tduck); bezier->p2=duck; bezier->c2=tduck; @@ -874,22 +875,22 @@ StateBLine_Context::refresh_ducks(bool button_down) ) ); - //get_work_area()->add_duck(bezier->c1); - //get_work_area()->add_duck(bezier->c2); + //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::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 @@ -916,15 +917,15 @@ StateBLine_Context::refresh_ducks(bool button_down) 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); + get_work_area()->add_duck(tduck); curr_duck=tduck; } - + // Add the loop, if requested if(bezier && loop_) { @@ -940,7 +941,7 @@ StateBLine_Context::refresh_ducks(bool button_down) 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); + get_work_area()->add_duck(duck); // Add the tangent1 duck tduck=new WorkArea::Duck(bline_point.get_tangent1()); @@ -955,8 +956,8 @@ StateBLine_Context::refresh_ducks(bool button_down) 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); - + get_work_area()->add_duck(tduck); + bezier->p2=duck; bezier->c2=tduck; @@ -970,7 +971,7 @@ StateBLine_Context::refresh_ducks(bool button_down) ) ); - //get_work_area()->add_duck(bezier->c1); + //get_work_area()->add_duck(bezier->c1); get_work_area()->add_bezier(bezier); } if(bezier && !loop_) @@ -990,16 +991,16 @@ StateBLine_Context::refresh_ducks(bool button_down) bezier->p2=duck; bezier->c2=tduck; - get_work_area()->add_duck(bezier->p2); - //get_work_area()->add_duck(bezier->c2); + get_work_area()->add_duck(bezier->p2); + //get_work_area()->add_duck(bezier->c2); get_work_area()->add_bezier(bezier); duck->set_guid(GUID()); tduck->set_guid(GUID()); - + next_duck=duck; } - + if(!button_down) { if(curr_duck) @@ -1011,7 +1012,7 @@ StateBLine_Context::refresh_ducks(bool button_down) } } } - get_work_area()->queue_draw(); + get_work_area()->queue_draw(); } @@ -1054,17 +1055,29 @@ StateBLine_Context::loop_bline() } 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_ && value_node==bline_point_list.front()) + 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), @@ -1097,7 +1110,7 @@ void StateBLine_Context::bline_insert_vertex(synfig::ValueNode_Const::Handle value_node, float origin) { list::iterator iter; - + for(iter=bline_point_list.begin();iter!=bline_point_list.end();++iter) if(*iter==value_node) { @@ -1105,10 +1118,10 @@ StateBLine_Context::bline_insert_vertex(synfig::ValueNode_Const::Handle value_no --prev; BLinePoint bline_point; - + BLinePoint next_bline_point((*iter)->get_value().get(BLinePoint())); BLinePoint prev_bline_point; - + if(iter!=bline_point_list.begin()) { prev_bline_point=(*prev)->get_value().get(BLinePoint()); @@ -1134,7 +1147,7 @@ StateBLine_Context::bline_insert_vertex(synfig::ValueNode_Const::Handle value_no 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); @@ -1152,14 +1165,14 @@ StateBLine_Context::bline_insert_vertex(synfig::ValueNode_Const::Handle value_no get_canvas_view()->get_ui_interface()->error("Unable to find where to insert vertex, internal error, please report this bug"); } - refresh_ducks(false); + refresh_ducks(false); } void StateBLine_Context::bline_delete_vertex(synfig::ValueNode_Const::Handle value_node) { list::iterator iter; - + for(iter=bline_point_list.begin();iter!=bline_point_list.end();++iter) if(*iter==value_node) { @@ -1171,7 +1184,7 @@ StateBLine_Context::bline_delete_vertex(synfig::ValueNode_Const::Handle value_no get_canvas_view()->get_ui_interface()->error("Unable to remove vertex, internal error, please report this bug"); } - refresh_ducks(false); + refresh_ducks(false); } void