class studio::AboutProgress : public synfig::ProgressCallback
{
About &about;
-
+
public:
AboutProgress(About &about):about(about) { }
-
+
virtual bool task(const std::string &task)
{
if(about.tasklabel)
if(synfig_root) {
imagepath=synfig_root;
imagepath+=ETL_DIRECTORY_SEPERATOR;
-
+
imagepath+="share/pixmaps";
}
imagepath+=ETL_DIRECTORY_SEPERATOR;
-
-
+
+
// Create the Logo
Gtk::Image *Logo = manage(new class Gtk::Image());
Logo->set(imagepath+"about_dialog."IMAGE_EXT);
Logo->set_size_request(image_w,image_h);
Logo->set_alignment(0.5,0.5);
Logo->set_padding(0,0);
-
+
// Create the Copyright Label
Gtk::Label *CopyrightLabel = manage(new class Gtk::Label(SYNFIG_COPYRIGHT));
CopyrightLabel->set_size_request(image_w,24);
VersionLabel->set_padding(0,0);
VersionLabel->set_justify(Gtk::JUSTIFY_CENTER);
VersionLabel->set_line_wrap(false);
-
+
// Set the version label to contain the correct information
string ver;
ver+="Version "VERSION" ("__DATE__" "__TIME__")\n";
Gtk::Image *image2 = manage(new class Gtk::Image(Gtk::StockID("gtk-close"), Gtk::IconSize(4)));
image2->set_alignment(0.5,0.5);
image2->set_padding(0,0);
-
+
// Create the close button, and attach the image to it
CloseButton = manage(new class Gtk::Button());
CloseButton->set_size_request(24,24);
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 *fixed1 = manage(new class Gtk::Fixed());
fixed1->put(*Logo, 0, 0);
if(x==true)
CloseButton->show();
else
- CloseButton->hide();
+ CloseButton->hide();
}
synfig::ProgressCallback *
namespace studio {
class AboutProgress;
-
+
class About : public Gtk::Window
{
friend class AboutProgress;
-
+
AboutProgress *cb;
-
+
Gtk::Tooltips _tooltips;
Gtk::Label *tasklabel;
void close();
bool can_self_destruct;
-
+
public:
-
- synfig::ProgressCallback *get_callback();
+
+ synfig::ProgressCallback *get_callback();
void set_can_self_destruct(bool x);
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();
}
}
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;
+ 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);
/* 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
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,
+ Adjust_Window(double value, double lower, double upper,
double step_increment=1, double page_increment=10, double page_size=0,
Gtk::Adjustment *adj = 0);
double get_sub_lower() const;
double get_sub_upper() const;
};
-
+
}; // END of namespace studio
/* === E N D =============================================================== */
);
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();
);
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();
);
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
error(const std::string &err)
- {
+ {
Gtk::MessageDialog dialog(err, false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE, true);
dialog.show();
dialog.run();
int i;
unwound->element.serial=0;
unwound->element.checksum=0;
-
+
for(i=0;i<16;i++)
{
U8 data;
-
+
switch(key[i])
{
case '0': data=0; break;
V_KeyUnwound unwound_key;
U32 appid_mask_a=hash_U32(appid);
U32 appid_mask_b=hash_U32(appid_mask_a);
-
+
if(!v_unwind_key(&unwound_key, key))
{
// Invalid characters in key
return 0;
}
-
+
// Undo obfuscation pass
{
unwound_key.raw[endian_fix(i)]^=(next>>24);
}
}
-
+
unwound_key.element.serial^=appid_mask_a;
unwound_key.element.checksum^=appid_mask_b;
*serial=unwound_key.element.serial;
-
+
return unwound_key.element.checksum==hash_U32(unwound_key.element.serial);
}
license_file="/usr/local/etc/.synfiglicense";
#else
license_file=basedir+"\\etc\\.synfiglicense";
-#endif
-
+#endif
+
try {
key=Glib::file_get_contents(license_file);
} catch (Glib::FileError) { }
while(!v_key_check(key.c_str(),&serial,0xdeadbeef))
{
key.clear();
-
+
if(!App::dialog_entry(
_("Synfig Studio Authentication"),
_("Please enter your license key below. You will not\nbe able to use this software without a valid license key."),
))
throw String("No License");
}
-
+
FILE* file=fopen(license_file.c_str(),"w");
if(file)
{
return serial;
#else
return 1;
-#endif
+#endif
}
/*
DEBUGPOINT();
std::list<Glib::RefPtr<Gtk::ActionGroup> > prev_groups(ui_manager->get_action_groups());
std::list<Glib::RefPtr<Gtk::ActionGroup> >::reverse_iterator iter;
-
+
DEBUGPOINT();
for(iter=prev_groups.rbegin();iter!=prev_groups.rend();++iter)
{
}
DEBUGPOINT();
ui_manager->insert_action_group(group,0);
-
+
DEBUGPOINT();
for(;!prev_groups.empty();prev_groups.pop_front())
{
value=strprintf("%i",App::auto_recover->get_timeout());
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,
);
App::gamma.set_all(r,g,b,blk);
-
+
return true;
}
if(key=="time_format")
App::distance_system=Distance::ident_system(value);;
return true;
}
-
+
return synfigapp::Settings::set_value(key,value);
}
-
+
virtual KeyList get_key_list()const
{
KeyList ret(synfigapp::Settings::get_key_list());
Glib::RefPtr<Gtk::ActionGroup> toolbox_action_group = Gtk::ActionGroup::create("toolbox");
Glib::RefPtr<Gtk::ActionGroup> actions_action_group = Gtk::ActionGroup::create();
-
+
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") );
iter->second.local_name,iter->second.local_name
));
}
-
+
#define DEFINE_ACTION(x,stock) { Glib::RefPtr<Gtk::Action> action( Gtk::Action::create(x, stock) ); /*action->set_sensitive(false);*/ actions_action_group->add(action); }
#define DEFINE_ACTION2(x,stock,label) { Glib::RefPtr<Gtk::Action> action( Gtk::Action::create(x, stock,label,label) ); /*action->set_sensitive(false);*/ actions_action_group->add(action); }
#define DEFINE_ACTION_SIG(group,x,stock,sig) { Glib::RefPtr<Gtk::Action> action( Gtk::Action::create(x, stock) ); /*action->set_sensitive(false);*/ group->add(action,sig); }
// Set up synfigapp actions
/*{
synfigapp::Action::Book::iterator iter;
-
+
for(iter=synfigapp::Action::book().begin();iter!=synfigapp::Action::book().end();++iter)
{
Gtk::StockID stock_id;
-
+
if(!(iter->second.category&synfigapp::Action::CATEGORY_HIDDEN))
{
//Gtk::Image* image(manage(new Gtk::Image()));
//else if(iter->second.task=="duplicate") stock_id=Gtk::Stock::COPY;
else if(iter->second.task=="remove") stock_id=Gtk::Stock::DELETE;
else stock_id=Gtk::StockID("synfig-"+iter->second.task);
-
+
actions_action_group->add(Gtk::Action::create(
"action-"+iter->second.name,
stock_id,
ACCEL("<Actions>//state-gradient","<Mod1>g");
ACCEL("<Actions>//state-zoom","<Mod1>z");
ACCEL("<Actions>//canvas-zoom-fit","<Control><Shift>z");
-
+
#undef ACCEL
}
IconControler(etl::dirname((*argv)[0]))
{
app_base_path_=etl::dirname(etl::dirname((*argv)[0]));
-
+
int serial_;
serial_=check_license(app_base_path_);
-
-
+
+
ui_interface_=new GlobalUIInterface();
gdk_rgb_init();
Glib::thread_init();
distance_system=Distance::SYSTEM_UNITS;
-
+
if(mkdir(get_user_app_directory().c_str(),ACCESSPERMS)<0)
{
if(errno!=EEXIST)
{
synfig::info("Created directory \"%s\"",get_user_app_directory().c_str());
}
-
-
+
+
ipc=new IPC();
-
+
try
{
if(!SYNFIG_CHECK_VERSION())
throw 39;
}
Glib::set_application_name(_("SYNFIG Studio"));
-
+
About about_window;
about_window.set_can_self_destruct(false);
about_window.show();
shutdown_in_progress=false;
SuperCallback synfig_init_cb(about_window.get_callback(),0,9000,10000);
SuperCallback studio_init_cb(about_window.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(...)
// 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 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 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();
state_manager->add_state(&state_rotate);
state_manager->add_state(&state_bline);
-
-
+
+
state_manager->add_state(&state_circle);
state_manager->add_state(&state_rectangle);
state_manager->add_state(&state_gradient);
state_manager->add_state(&state_eyedrop);
state_manager->add_state(&state_fill);
-
+
state_manager->add_state(&state_zoom);
// Disabled this tool because it should be
// considered deprecated. Use the bline tool instead.
if(getenv("SYNFIG_ENABLE_POLYGON")) state_manager->add_state(&state_polygon);
-
+
// These tools are disabled by default for now,
// because they tend to confuse users.
if(getenv("SYNFIG_ENABLE_DRAW" )) state_manager->add_state(&state_draw);
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 ) );
studio_init_cb.task("Loading Settings...");
load_settings();
studio_init_cb.task("Checking auto-recover...");
-
+
studio_init_cb.amount_complete(9900,10000);
-
+
if(auto_recover->recovery_needed())
{
about_window.hide();
}
about_window.show();
}
-
+
// Look for any files given on the command line,
// and load them if found.
for(;*argc>=1;(*argc)--)
open((*argv)[*argc]);
about_window.show();
}
-
+
studio_init_cb.task("Done.");
studio_init_cb.amount_complete(10000,10000);
-
+
toolbox->present();
}
catch(...)
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;
toolbox->hide();
-// studio::App::iteration(false);
-
+// studio::App::iteration(false);
+
delete toolbox;
-
-// studio::App::iteration(false);
-// studio::App::iteration(false);
+// studio::App::iteration(false);
+
+// studio::App::iteration(false);
delete dialog_setup;
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 outselves into one
if(!is_absolute_path(filename))
filename=absolute_path(filename);
-
+
list<string>::iterator iter;
// Check to see if the file is already on the list.
// If it is, then remove it from the list
break;
}
-
+
// Push the filename to the front of the list
recent_files.push_front(filename);
-
+
// Clean out the files at the end of the list.
while(recent_files.size()>(unsigned)get_max_recent_files())
recent_files.pop_back();
-
+
signal_recent_files_changed_();
-
+
return;
}
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);
std::string filename=get_config_file("settings");
synfigapp::Main::settings().save_to_file(filename);
- setlocale(LC_NUMERIC,old_locale);
+ setlocale(LC_NUMERIC,old_locale);
}
catch(...)
{
std::string filename=get_config_file("recentfiles");
std::ifstream file(filename.c_str());
-
+
while(file)
{
std::string recent_file;
synfigapp::Main::settings().set_value("window.toolbox.pos","4 4");
}
}
- setlocale(LC_NUMERIC,old_locale);
+ setlocale(LC_NUMERIC,old_locale);
}
catch(...)
{
App::quit()
{
if(shutdown_in_progress)return;
-
-
+
+
get_ui_interface()->task("Quit Request");
if(Busy::count)
{
return;
}
}
-*/
-
+*/
+
// This next line causes things to crash for some reason
- //(*iter)->close();
+ //(*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();
#ifdef WIN32
#include <gdk/gdkwin32.h>
#endif
-
+
bool
App::dialog_open_file(const std::string &title, std::string &filename)
{
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.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
synfig::String prev_path;
if(!_preferences.get_value("curr_path",prev_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::StockID("gtk-ok"),GTK_RESPONSE_ACCEPT);
delete dialog;
return false;
/*
-
+
GtkWidget *ok;
GtkWidget *cancel;
int val=0;
-
+
GtkWidget *fileselection;
fileselection = gtk_file_selection_new(title.c_str());
-
+
if(basename(filename)==filename)
{
- gtk_file_selection_set_filename(GTK_FILE_SELECTION(fileselection),(prev_path+ETL_DIRECTORY_SEPERATOR).c_str());
+ gtk_file_selection_set_filename(GTK_FILE_SELECTION(fileselection),(prev_path+ETL_DIRECTORY_SEPERATOR).c_str());
}
else
gtk_file_selection_set_filename(GTK_FILE_SELECTION(fileselection),dirname(filename).c_str());
ok=GTK_FILE_SELECTION(fileselection)->ok_button;
cancel=GTK_FILE_SELECTION(fileselection)->cancel_button;
- gtk_signal_connect(GTK_OBJECT(ok),"clicked",GTK_SIGNAL_FUNC(Signal_Open_Ok),&val);
- gtk_signal_connect(GTK_OBJECT(cancel),"clicked",GTK_SIGNAL_FUNC(Signal_Open_Cancel),&val);
+ gtk_signal_connect(GTK_OBJECT(ok),"clicked",GTK_SIGNAL_FUNC(Signal_Open_Ok),&val);
+ gtk_signal_connect(GTK_OBJECT(cancel),"clicked",GTK_SIGNAL_FUNC(Signal_Open_Cancel),&val);
gtk_widget_show(fileselection);
while(!val)
- iteration();
-
-
+ iteration();
+
+
if(val==1)
{
filename=gtk_file_selection_get_filename(GTK_FILE_SELECTION(fileselection));
{
#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.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;
synfig::String prev_path;
if(!_preferences.get_value("curr_path",prev_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::StockID("gtk-ok"),GTK_RESPONSE_ACCEPT);
{
#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.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;
synfig::String prev_path;
if(!_preferences.get_value("curr_path",prev_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::StockID("gtk-ok"),GTK_RESPONSE_ACCEPT);
);
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);
{
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();
+ dialog.run();
}
bool
try
{
OneMoment one_moment;
-
+
etl::handle<synfig::Canvas> canvas(open_canvas_as(filename,as));
if(canvas && get_instance(canvas))
{
get_instance(canvas)->find_canvas_view(canvas)->present();
- throw (String)strprintf(_("\"%s\" appears to already be open!"),filename.c_str());
+ throw (String)strprintf(_("\"%s\" appears to already be open!"),filename.c_str());
}
if(!canvas)
throw (String)strprintf(_("Unable to open file \"%s\""),filename.c_str());
add_recent_file(as);
-
+
handle<Instance> instance(Instance::create(canvas));
if(!instance)
throw (String)strprintf(_("Unable to create instance for \"%s\""),filename.c_str());
-
+
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();
}
}
_preferences.set_value("curr_path",dirname(as));
-
+
return true;
}
canvas->set_name(strprintf("Untitled%d",Instance::get_count()));
String file_name(strprintf("untitled%d.sif",Instance::get_count()));
-
+
canvas->rend_desc().set_frame_rate(24.0);
canvas->rend_desc().set_time_start(0.0);
canvas->rend_desc().set_time_end(00.0);
canvas->rend_desc().set_antialias(1);
canvas->rend_desc().set_flags(RendDesc::PX_ASPECT|RendDesc::IM_SPAN);
canvas->set_file_name(file_name);
-
+
Instance::create(canvas)->find_canvas_view(canvas)->canvas_properties.present();
}
};
class Preferences;
-
+
namespace studio {
typedef Gtk::UIManager UIManager;
class Dock_Navigator;
class Dock_LayerGroups;
class IPC;
-
+
class Module;
class StateManager;
class IconControler;
-
+
class App : public Gtk::Main, private IconControler
{
friend class Preferences;
friend class Dialog_Setup;
-
+
/*
-- ** -- P U B L I C T Y P E S ---------------------------------------------
*/
static etl::handle<CanvasView> selected_canvas_view;
static Glib::RefPtr<UIManager> ui_manager_;
-
+
// static std::list< etl::handle< Module > > module_list_;
/*
static std::list<etl::handle<Instance> > instance_list;
- static bool shutdown_in_progress;
+ static bool shutdown_in_progress;
static bool use_colorspace_gamma;
static void dialog_open();
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 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);
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 synfig::String get_user_app_directory();
{
public:
etl::handle<synfig::Target_Tile> warm_target;
-
+
struct tile_t
{
Surface surface;
};
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)
ready_connection=tile_ready_signal.connect(sigc::mem_fun(*this,&AsyncTarget_Tile::tile_ready));
#endif
}
-
+
~AsyncTarget_Tile()
{
ready_connection.disconnect();
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);
}
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);
tile_ready_signal();
#endif
}
-
+
return alive_flag;
}
while(!tile_queue.empty() && alive_flag)
{
tile_t& tile(tile_queue.front());
-
+
alive_flag=warm_target->add_tile(tile.surface,tile.x,tile.y);
-
+
tile_queue.pop_front();
}
cond_tile_queue_empty.signal();
{
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
#endif
surface.set_wh(warm_target->rend_desc().get_w(),warm_target->rend_desc().get_h());
}
-
+
~AsyncTarget_Scanline()
{
ready_connection.disconnect();
Glib::Mutex::Lock lock(mutex);
alive_flag=false;
}
-
+
virtual bool start_frame(synfig::ProgressCallback *cb=0)
- {
+ {
return alive_flag;
}
-
+
virtual void end_frame()
{
{
}
}
-
+
virtual Color * start_scanline(int scanline)
{
Glib::Mutex::Lock lock(mutex);
return surface[scanline];
}
-
+
virtual bool end_scanline()
{
return alive_flag;
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<synfig::Target_Scanline>::cast_dynamic(target_)
)
);
-
+
signal_stop_.connect(sigc::mem_fun(*wrap_target,&AsyncTarget_Scanline::set_dead));
-
+
target=wrap_target;
}
}
{
Glib::Mutex::Lock lock(mutex);
done_connection.disconnect();
-
+
if(render_thread)
{
signal_stop_();
-
+
#if REJOIN_ON_STOP
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;
}
#ifndef GLIB_DISPATCHER_BROKEN
done_connection=signal_done_.connect(mem_fun(*this,&AsyncRenderer::stop));
#endif
-
+
render_thread=Glib::Thread::create(
sigc::mem_fun(*this,&AsyncRenderer::render_target),
#if REJOIN_ON_STOP
AsyncRenderer::render_target()
{
etl::handle<Target> target(AsyncRenderer::target);
-
+
if(target && target->render())
{
success=true;
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;
*/
protected:
-
+
};
}; // END of namespace studio
bool build_profile(FSOUND_SAMPLE *sample, double &samplerate, std::vector<char> &samples)
{
#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
+
+ //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;
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)
//insert onto new list
samples.push_back(maxs);
samples.push_back(mins);
-
+
//and flush all the used samples for curaccum
curaccum -= 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)
//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;
/* 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
+ // 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();
+
+ 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)
{
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
+ // WE ARE LOSING A TINY AMOUNT OF PRECISION ACCURACY EVERY UPDATE
// (THIS SHOULDN'T BE A PROBLEM)
- const double p0 = FSOUND_GetCurrentPosition(channel);
+ const double p0 = FSOUND_GetCurrentPosition(channel);
double curdp = 0;
-
+
if(!FSOUND_GetPaused(channel))
{
curdp = FSOUND_GetFrequency(channel) * deltatime;
}
- //need to rescale derivative...
+ //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,false);
if(!FSOUND_SetFrequency(channel,freq))
{
- //ERROR WILL ROBINSON!!!...
+ //ERROR WILL ROBINSON!!!...
printf("Error in Freq... what do I do?\n");
}
}
- }
+ }
};
struct scrubuserdata
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();
+ lock.UnLockWrite();
}*/
-
+
scrubinfo * volatile * scrub;
};
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...
+
+ //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
+
+ //loop through the list and process all the active scrub units
std::vector<scrubinfo**>::iterator i = v.begin(),
- end = v.end();
+ end = v.end();
for(;i != end; ++i)
{
//check to make sure this object is active...
}
}
*/
-
+
if(sd.scrub && *sd.scrub)
{
//dsp += " processing...";
- scrubinfo * info = (*sd.scrub);
+ scrubinfo * info = (*sd.scrub);
info->scrub_dsp_process();
}
}
-
+
//synfig::info(dsp);
return newbuffer;
{
bool loaded;
int refcount;
-
+
public:
FMODInitializer():loaded(false),refcount(0) {}
- ~FMODInitializer()
+ ~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)
{
--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();
+ FSOUND_Close();
#endif
loaded = false;
}
//---------- 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....
+ //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;}
void set_scrubbing(bool s)
{
#ifdef WITH_FMOD
if(s)
scrptr = &scrinfo;
- else
+ else
#endif
scrptr = 0;
}
-
+
//helper to make sure we are actually playing (and to get a new channel...)
bool init_play()
{
FSOUND_SetFrequency(channel,sfreq);
}
return true;
-
+
#else
-
+
return false;
-
+
#endif
}
-
+
public: //structors
AudioImp()
:sample(0),
length(0),
offset(0),
playing(false),
- scrptr(0)
+ 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...
{
FSOUND_SetPaused(channel,false);
}
#endif
-
+
return false; //so the timer doesn't repeat itself
- }
-
+ }
+
bool isRunning()
{
#ifdef WITH_FMOD
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)
+ void set_offset(const double &d)
{
offset = d;
}
-
+
//Will override the parameter timevalue if the sound is running, and not if it's not...
bool get_current_time(double &out)
{
{
#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;
{
imp = new AudioImp;
}
-
+
profilevalid = false;
return imp->load(filename,filedirectory);
}
handle<studio::AudioProfile> studio::AudioContainer::get_profile(float samplerate)
{
#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...
+
+ //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))
{
return handle<studio::AudioProfile>();
}
-
+
#else
-
+
return handle<studio::AudioProfile>();
-
+
#endif
}
void studio::AudioContainer::clear()
{
- if(imp)
+ if(imp)
{
delete imp;
imp = 0;
}
-
+
profilevalid = false;
}
-
+
void studio::AudioContainer::play(double t)
{
if(imp) imp->play(t);
bool AudioContainer::is_playing() const
{
- if(imp)
+ if(imp)
return imp->playing;
return false;
}
bool AudioContainer::is_scrubbing() const
{
- if(imp)
+ if(imp)
return imp->is_scrubbing();
return false;
}
//----------- Audio imp information -------------------
-bool studio::AudioContainer::AudioImp::load(const std::string &filename,
+bool studio::AudioContainer::AudioImp::load(const std::string &filename,
const std::string &filedirectory)
{
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))
{
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...");
+ 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;
+
+ //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
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);
-
+ 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
+
+ #endif
}
void studio::AudioContainer::AudioImp::stop()
#ifdef WITH_FMOD
if(fmodinit.is_loaded() && playing && isRunning())
- {
+ {
FSOUND_SetPaused(channel,true);
}
#endif
-
+
playing = false;
}
{
#ifdef WITH_FMOD
delaycon.disconnect();
-
+
stop();
stop_scrubbing();
-
+
if(sample)
{
if(FSOUND_IsPlaying(channel))
FSOUND_Sample_Free(sample);
fmodinit.decref();
}
-
+
playing = false;
-
+
#else
channel = 0;
#endif
-
+
sample = 0;
- playing = false;
+ playing = false;
}
void AudioContainer::AudioImp::start_scrubbing(double t)
{
//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...)
+
+ //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);
void 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
//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),
*/
double oldpos = curscrubpos;
double newpos = (t - get_offset()) * sfreq;
-
+
curscrubpos = newpos;
-
- //Ok the sound is running, now we need to tweek it
+
+ //Ok the sound is running, now we need to tweek it
if(newpos > oldpos)
{
//Outside so completely stopped...
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.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?)
+
+ //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);
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)
{
{
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);
-
+ FSOUND_SetCurrentPosition(channel,length-1);
+
scrinfo.Lock();
scrinfo.pos = length-1;
scrinfo.delaystart = delay_factor*buffer_length_sec;
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?)
+
+ //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...
+
+ //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;
{
public:
typedef std::vector<char> SampleProfile;
-
+
private:
SampleProfile samples;
double samplerate; //samples / second of the profile
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;
class AudioContainer : public sigc::trackable, public etl::shared_object
{
etl::handle<AudioProfile> prof;
-
+
struct AudioImp;
AudioImp *imp;
-
- bool profilevalid; //this is only half useful
+
+ 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();
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();
bool isRunning() const;
bool isPaused() const;
};
-
+
} // END of namespace studio
/* === E N D =============================================================== */
{
// Three Minutes
set_timeout(3*60*1000);
-
+
if(mkdir(get_shadow_directory().c_str(),ACCESSPERMS)<0)
{
if(errno!=EEXIST)
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];
}
}
hash1^=hash2;
-
+
return Glib::build_filename(get_shadow_directory(),strprintf("%08X-%s",hash1,basename(filename).c_str()));
-
+
// return dirname(filename) + ETL_DIRECTORY_SEPERATOR + ".shadow_" + basename(filename);
}
#ifdef HAVE_FORK
pid=fork();
#endif
-
+
if(pid<=0)
{
#ifdef HAVE_SETPRIORITY
// 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
// 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);
}
synfig::error("AutoRecover::auto_backup(): UNKNOWN EXCEPTION THROWN.");
synfig::error("AutoRecover::auto_backup(): FILES NOT BACKED UP.");
}
-
+
#ifdef HAVE_FORK
if(pid==0)
{
),
60*1000
);
-#endif
-
+#endif
+
// Also go ahead and save the settings
App::save_settings();
-
+
return true;
}
if(!filename.empty())
return true;
}
-
+
return false;
}
if(!file)
return false;
bool success=true;
-
+
while(file)
{
std::string 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();
}
void set_timeout(int milliseconds);
int get_timeout()const { return timeout; }
-
+
static synfig::String get_shadow_directory();
-
+
bool recovery_needed()const;
bool recover();
-
+
void normal_shutdown();
-
+
void clear_backup(synfig::Canvas::Handle canvas);
}; // END of class AutoRecover
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);
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);
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();
}
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);
canvas_view_->work_area->enable_grid_snap();
else
canvas_view_->work_area->disable_grid_snap();
-
+
if(toggle_grid_show.get_active())
canvas_view_->work_area->enable_grid();
else
{
class CanvasView;
-
+
class CanvasOptions : public Gtk::Dialog
{
Gtk::Tooltips tooltips;
Widget_Vector vector_grid_size;
Gtk::CheckButton toggle_time_snap;
-
+
public:
CanvasOptions(etl::loose_handle<CanvasView> canvas_view);
~CanvasOptions();
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);
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(*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));
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);
+ 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);
cancel_button->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasProperties::on_cancel_pressed));
//set_default_response(1);
-
+
get_vbox()->show_all();
refresh();
{
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->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));
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));
+ 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;
}
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();
canvas_interface_->set_name(entry_name.get_text());
if(entry_description.get_text()!=canvas_interface_->get_canvas()->get_description())
canvas_interface_->set_description(entry_description.get_text());
-
+
dirty_rend_desc=false;
}
namespace synfigapp { class CanvasInterface; };
namespace studio
-{
+{
class CanvasProperties : public Gtk::Dialog
{
Gtk::Tooltips tooltips;
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();
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());
}
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());
}
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());
}
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());
}
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(!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);
-
+ return Gtk::TreeStore::get_value_vfunc(iter,column,value);
+
g_value_init(value.gobj(),x.value_type());
g_value_copy(x.gobj(),value.gobj());
}
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());
}
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());
}
x.set(canvas->get_id());
else
if(!canvas->get_name().empty())
- x.set(canvas->get_name());
+ x.set(canvas->get_name());
else
- x.set(_("[Unnamed]"));
+ 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]));
+ 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()+')');
+ 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());
}
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());
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())
{
CanvasTreeStore::find_next_value_node(const ValueNode::Handle& value_node, Gtk::TreeIter& iter)
{
if(!iter) return find_first_value_node(value_node,iter);
-
+
if(iter) do {
if(!iter->children().empty())
{
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();
//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();
erase(row);
return;
}
-
+
// We should never get to this point
assert(0);
}
(!bool(row[model.is_value_node]) && row[model.link_count]!=0))
{
set_row(row,value_desc,do_children);
- return;
+ 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]);
+ 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()+')';
+ 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;
+ return;
}
}
else
{
- //row[model.label] = Glib::ustring(row[model.name]);
+ //row[model.label] = Glib::ustring(row[model.name]);
//row[model.is_value_node] = false;
//row[model.is_editable] = true;
}
}
if(!do_children)
- return;
-
+ return;
+
Gtk::TreeModel::Children children = row.children();
Gtk::TreeModel::Children::iterator iter;
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;
+ return;
}
LinkableValueNode::Handle linkable;
{
// Gtk::TreeModel::Children children = row.children();
// while(!children.empty() && erase(children.begin()));
-
+
set_row(row,value_desc);
- return;
+ 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]);
+ 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()+')';
+ row[model.label] = Glib::ustring(row[model.name])+" ("+value_node->get_id()+')';
}
else
{
- row[model.label] = Glib::ustring(row[model.name]);
+ 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;
+ return;
Gtk::TreeModel::Children children = row.children();
Gtk::TreeModel::Children::iterator iter;
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);
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;
}
COLUMNID_VALUE,
COLUMNID_TIME_TRACK,
COLUMNID_TYPE,
-
+
COLUMNID_END //!< \internal
};
#define COLUMNID_NAME COLUMNID_ID
Gtk::TreeModelColumn<bool> is_shared;
Gtk::TreeModelColumn<bool> is_exported;
-
+
Gtk::TreeModelColumn<synfigapp::ValueDesc> value_desc;
-
+
Gtk::TreeModelColumn<Glib::ustring> tooltip;
Model()
add(value_desc);
add(link_count);
add(link_id);
-
+
add(tooltip);
}
};
*/
public:
-
+
const Model model;
//std::multimap<etl::handle<ValueNode>, sigc::connection> connection_map;
*/
public:
-
+
CanvasTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
~CanvasTreeStore();
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);
*/
public:
-
+
}; // END of class CanvasTreeStore
}; // END of namespace studio
#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_subtract.h>
+#include <synfig/valuenode_linear.h>
+#include <synfig/valuenode_timedswap.h>
#include <synfig/valuenode_scale.h>
#include <synfig/valuenode_dynamiclist.h>
#include <synfig/valuenode_twotone.h>
#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):
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
scrub_timer.reset();
return;
}
-
+
// If we aren't scrubbing already, enable it
if(!scrubbing)
{
- scrubbing=true;
+ 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(
scrub_timer.reset();
}
-
+
void end_of_scrubbing()
- {
+ {
scrubbing=false;
audio_container()->stop_scrubbing();
scrub_timer.reset();
}
-
+
handle<AudioContainer> audio_container()
{
assert(canvas_view->audio);
}
};
-
+
class studio::CanvasViewUIInterface : public synfigapp::UIInterface
{
CanvasView *view;
CanvasViewUIInterface(CanvasView *view):
view(view)
{
-
+
view->statusbar->push("Idle");
}
);
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();
);
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();
);
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();
task(const std::string &task)
{
if(!view->is_playing_)
- {
+ {
view->statusbar->pop();
view->statusbar->push(task);
}
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
{
view->statusbar->pop();
view->statusbar->push(err);
-
+
//while(studio::App::events_pending())studio::App::iteration(false);
if(view->cancel)return false;
return true;
amount_complete(int current, int total)
{
if(!view->is_playing_)
- {
+ {
if(!view->working_depth)
{
if(current)
if(view->cancel){/*view->cancel=false;*/return false;}
return true;
}
-
+
void
not_implemented()
{
public:
CanvasViewSelectionManager(CanvasView *view): view(view)
-{
-
+{
+
}
-
+
private:
void _set_selected_layer(const synfig::Layer::Handle &layer)
// 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());
*/
}
public:
-
+
//! Returns the number of layers selected.
virtual int get_selected_layer_count()const
{
virtual LayerList get_selected_layers()const
{
// assert(view->layer_tree);
-
+
if(!view->layer_tree) { DEBUGPOINT(); synfig::error("canvas_view.layer_tree not defined!?"); 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) { DEBUGPOINT(); synfig::error("canvas_view.layer_tree not defined!?"); 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) { DEBUGPOINT(); synfig::error("canvas_view.layer_tree not defined!?"); return; }
view->layer_tree->select_layers(layer_list);
//view->get_smach().process_event(EVENT_REFRESH_DUCKS);
virtual void set_selected_layer(const synfig::Layer::Handle &layer)
{
// assert(view->layer_tree);
-
+
if(!view->layer_tree) { DEBUGPOINT(); synfig::error("canvas_view.layer_tree not defined!?"); return; }
view->layer_tree->select_layer(layer);
//view->queue_rebuild_ducks();
{
return get_selected_children().size();
}
-
+
static inline void __child_grabber(const Gtk::TreeModel::iterator& iter, ChildrenList* ret)
{
const CanvasView::ChildrenTreeModel children_tree_model;
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(
&ret
)
);
-
+
/*
Gtk::TreeModel::Children::iterator iter(view->children_tree_store()->children().begin());
iter++;
*/
return ret;
}
-
+
//! Returns the first value_node selected or an empty handle if none are selected.
virtual ChildrenList::value_type get_selected_child()const
{
return children.front();
}
-
+
//! Sets which value_nodes should be selected
virtual void set_selected_children(const ChildrenList &children_list)
{
{
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();
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)
}
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;
time_adjustment_ (0,0,25,0,0,0),
time_window_adjustment_ (0,0,25,0,0,0),
statusbar (manage(new class Gtk::Statusbar())),
-
+
timeslider (new Widget_Timeslider),
-
+
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_),
layer_tree=0;
children_tree=0;
duck_refresh_flag=true;
-
+
smach_.set_default_state(&state_normal);
-
+
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);
//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, 3, false));
+
+ Gtk::Table *layout_table= manage(new class Gtk::Table(1, 3, 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);
- init_menus();
+ 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();
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_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));
)
)
);
-
+
//MUCH TIME STUFF TAKES PLACE IN HERE
refresh_rend_desc();
refresh_time_window();
- /*! \todo We shouldn't need to do this at construction --
+ /*! \todo We shouldn't need to do this at construction --
** This should be preformed 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
+ /*! \todo In other words, this is a zoom-to-fit, and should be
** in it's own function.
*/
int w=get_canvas()->rend_desc().get_w()+70;
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;
+ 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") );
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
+
+ //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_type_hint(Gdk::WINDOW_TYPE_HINT_UTILITY);
}
*/
-
- refresh_rend_desc();
+
+ refresh_rend_desc();
hide_tables();
- on_time_changed();
- //synfig::info("Canvasview: Constructor Done");
+ on_time_changed();
+ //synfig::info("Canvasview: Constructor Done");
}
CanvasView::~CanvasView()
if(ext_widget_book_.begin()->second)
delete ext_widget_book_.begin()->second;
}
-
+
//delete preview
audio.reset();
-
+
hide();
-
+
synfig::info("CanvasView:~CanvasView(): Destructor Finished");
}
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);
-
-
+
+
tooltips.set_tip(*time_window_scroll,_("Moves the time window"));
tooltips.set_tip(*timeslider,_("Changes the current time"));
time_window_scroll->show();
//time_scroll->signal_value_changed().connect(sigc::mem_fun(*work_area, &studio::WorkArea::render_preview_hook));
//time_scroll->set_update_policy(Gtk::UPDATE_DISCONTINUOUS);
-
+
NORMAL_BUTTON(animatebutton,"gtk-yes","Animate");
animatebutton->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::on_animate_button_pressed));
animatebutton->show();
NORMAL_BUTTON(keyframebutton,"synfig-keyframe_lock_all","All Keyframes Locked");
keyframebutton->signal_clicked().connect(sigc::mem_fun(*this, &studio::CanvasView::on_keyframe_button_pressed));
keyframebutton->show();
-
+
Gtk::Table *table= manage(new class Gtk::Table(2, 3, false));
//setup the audio display
- disp_audio->set_size_request(-1,32); //disp_audio.show();
+ 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_stop_scrubbing().connect(
sigc::mem_fun(*audio,&AudioContainer::stop_scrubbing)
);
-
+
table->attach(*manage(disp_audio), 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK);
table->attach(*timeslider, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK, 0, 0);
table->attach(*time_window_scroll, 0, 1, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK, 0, 0);
refreshbutton->signal_clicked().connect(SLOT_EVENT(EVENT_REFRESH));
stopbutton->signal_clicked().connect(SLOT_EVENT(EVENT_STOP));
-
+
statusbartable->show_all();
return statusbartable;
}
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;
+ return children_tree;
}
Gtk::Widget*
//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->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
//scroll_layer_tree->show();
-
- Gtk::Table *layout_table= manage(new Gtk::Table(1, 2, false));
+
+ 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"));
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;
+
+ return layout_table;
}
Gtk::Widget*
layer_tree->get_selection()->signal_changed().connect(SLOT_EVENT(EVENT_REFRESH_DUCKS));
layer_tree->hide();
- return layer_tree;
+ return layer_tree;
}
void
layermenu.set_accel_path("<Canvas-view>/Layer");
*/
//cache the position of desired widgets
-
+
/*Menus to worry about:
- filemenu
- editmenu
- viewmenu
*/
action_group = Gtk::ActionGroup::create();
-
+
//action_group->add( Gtk::Action::create("MenuFile", "_File") );
action_group->add( Gtk::Action::create("save", Gtk::Stock::SAVE),
hide_return(sigc::mem_fun(*get_instance().get(), &studio::Instance::save))
sigc::mem_fun0(canvas_options,&studio::CanvasOptions::present)
);
action_group->add( Gtk::Action::create("close", Gtk::StockID("gtk-close")),
- sigc::hide_return(sigc::mem_fun(*this,&studio::CanvasView::close))
+ sigc::hide_return(sigc::mem_fun(*this,&studio::CanvasView::close))
);
//action_group->add( Gtk::Action::create("undo", Gtk::StockID("gtk-undo")),
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("play", Gtk::StockID("synfig-play")),
sigc::mem_fun(*this, &studio::CanvasView::play)
);
-
+
action_group->add( Gtk::Action::create("dialog-flipbook", _("Flipbook Dialog")),
sigc::mem_fun0(*preview_dialog, &studio::Dialog_Preview::present)
);
{
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=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) );
-
+
}
sigc::mem_fun(*this, &studio::CanvasView::toggle_duck_mask), \
Duck::TYPE_##upper \
) \
- )
+ )
DUCK_MASK(position,POSITION);
DUCK_MASK(tangent,TANGENT);
DUCK_MASK(vertex,VERTEX);
{
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("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 =
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
-
+#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::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)
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
viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Mask Ducks"),duckmaskmenu));
}
-
+
// Preview Quality Menu
if(1)
{
}
viewmenu.items().push_back(Gtk::Menu_Helpers::MenuElem(_("Preview Quality"),qualitymenu));
}
-
+
viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-play"),
sigc::mem_fun(*this, &studio::CanvasView::play)));
viewmenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("Flipbook Dialog"),
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)),
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));
canvasmenu.set_accel_path("<synfig>/Canvas");
viewmenu.set_accel_path("<synfig>/View");
duckmaskmenu.set_accel_path("<synfig>/DuckMask");
-#endif
+#endif
}
void
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();
}
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();
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);
+ get_selection_manager()->set_selected_layer(layer);
}
}
//Gtk::Menu* menu(manage(new Gtk::Menu));
Gtk::Menu* menu(¶mmenu);
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")
)
));
}
-
+
add_actions_to_menu(menu, param_list,synfigapp::Action::CATEGORY_LAYER);
-
+
menu->popup(3,gtk_get_current_event_time());
}
{
/* if(lyr.second.category==_("Do Not Use"))
return;
-
+
if(category_map->count(lyr.second.category)==0)
(*category_map)[lyr.second.category]=manage(new Gtk::Menu());
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.items().push_back(Gtk::Menu_Helpers::MenuElem(iter->first,*iter->second));
menu.show();
*/
{
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()))
//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();
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();
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",
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;
}
{
synfigapp::Action::Handle action(synfigapp::Action::create("layer_activate"));
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())))
action->set_param("new_status",!layer->active());
assert(action->is_ready());
-
+
canvas_interface()->get_instance()->perform_action(action);
}
{
parammenu.items().clear();
get_instance()->make_param_menu(¶mmenu,get_canvas(),value_desc,location);
-
+
parammenu.popup(3,gtk_get_current_event_time());
}
bool
CanvasView::on_layer_user_click(int button, Gtk::TreeRow row, LayerTree::ColumnID column_id)
-{
+{
switch(button)
{
case 3:
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;
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];
{
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()));
build_new_layer_menu(*newlayers);
-
+
parammenu.items().push_back(Gtk::Menu_Helpers::MenuElem("New Layer",*newlayers));
if(!multiple_selected && layer->get_name()=="PasteCanvas")
{
)
));
}
-
+
add_actions_to_menu(¶mmenu, 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;
}
return true;
break;
-
+
default:
return false;
- break;
+ break;
}
}
bool
CanvasView::on_children_user_click(int button, Gtk::TreeRow row, ChildrenTree::ColumnID column_id)
-{
+{
switch(button)
{
case 3:
}
return true;
break;
-
+
default:
return false;
- break;
+ break;
}
}
case GDK_BUTTON_PRESS:
switch(event->button.button)
{
- case 3:
+ case 3:
{
//keyframemenu.popup(event->button.button,gtk_get_current_event_time());
return true;
//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();
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"));
+ 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_adjustment().set_value(time);
time_adjustment().value_changed();
-
+
// Shouldn't these trees just hook into
// the time changed signal...?
//YES THEY SHOULD...
{
time_window_adjustment().set_page_size(time_window_adjustment().get_page_size()*0.75);
time_window_adjustment().changed();
-
+
refresh_time_window();
}
{
time_window_adjustment().set_page_size(time_window_adjustment().get_page_size()/0.75);
time_window_adjustment().changed();
-
+
refresh_time_window();
}
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]);
{
Gtk::Image *icon;
icon=manage(new Gtk::Image(Gtk::StockID("gtk-no"),Gtk::ICON_SIZE_BUTTON));
- animatebutton->remove();
- animatebutton->add(*icon);
+ animatebutton->remove();
+ animatebutton->add(*icon);
tooltips.set_tip(*animatebutton,_("In Animate Editing Mode"));
icon->set_padding(0,0);
icon->show();
{
Gtk::Image *icon;
icon=manage(new Gtk::Image(Gtk::StockID("gtk-yes"),Gtk::ICON_SIZE_BUTTON));
- animatebutton->remove();
- animatebutton->add(*icon);
+ animatebutton->remove();
+ animatebutton->add(*icon);
tooltips.set_tip(*animatebutton,_("Not in Animate Editing Mode"));
icon->set_padding(0,0);
icon->show();
{
Gtk::Image *icon;
icon=manage(new Gtk::Image(Gtk::StockID("synfig-keyframe_lock_all"),Gtk::ICON_SIZE_BUTTON));
- keyframebutton->remove();
- keyframebutton->add(*icon);
+ keyframebutton->remove();
+ keyframebutton->add(*icon);
tooltips.set_tip(*keyframebutton,_("All Keyframes Locked"));
icon->set_padding(0,0);
icon->show();
{
Gtk::Image *icon;
icon=manage(new Gtk::Image(Gtk::StockID("synfig-keyframe_lock_future"),Gtk::ICON_SIZE_BUTTON));
- keyframebutton->remove();
- keyframebutton->add(*icon);
+ keyframebutton->remove();
+ keyframebutton->add(*icon);
tooltips.set_tip(*keyframebutton,_("Future Keyframes Locked"));
icon->set_padding(0,0);
icon->show();
{
Gtk::Image *icon;
icon=manage(new Gtk::Image(Gtk::StockID("synfig-keyframe_lock_past"),Gtk::ICON_SIZE_BUTTON));
- keyframebutton->remove();
- keyframebutton->add(*icon);
+ keyframebutton->remove();
+ keyframebutton->add(*icon);
tooltips.set_tip(*keyframebutton,_("Past Keyframes Locked"));
icon->set_padding(0,0);
icon->show();
{
Gtk::Image *icon;
icon=manage(new Gtk::Image(Gtk::StockID("synfig-keyframe_lock_none"),Gtk::ICON_SIZE_BUTTON));
- keyframebutton->remove();
- keyframebutton->add(*icon);
+ keyframebutton->remove();
+ keyframebutton->add(*icon);
tooltips.set_tip(*keyframebutton,_("No Keyframes Locked"));
icon->set_padding(0,0);
icon->show();
}
-
+
work_area->queue_draw();
}
CanvasView::on_keyframe_button_pressed()
{
synfigapp::CanvasInterface::Mode mode(get_mode());
-
+
if((mode&synfigapp::MODE_ANIMATE_FUTURE) && (mode&synfigapp::MODE_ANIMATE_PAST))
{
set_mode(get_mode()-synfigapp::MODE_ANIMATE_FUTURE);
{
int transforms(0);
String layer_name;
-
-#define QUEUE_REBUILD_DUCKS sigc::mem_fun(*this,&CanvasView::queue_rebuild_ducks)
+
+#define QUEUE_REBUILD_DUCKS sigc::mem_fun(*this,&CanvasView::queue_rebuild_ducks)
if(!canvas)
{
// 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 pf 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())
*this,
&studio::CanvasView::selected_layer_color_set
)
- );
+ );
}
*/
}
}
}
-
+
layer_name=layer->get_name();
-
+
if(layer->active())
{
Transform::Handle trans(layer->get_transform());
}
*/
}
-
+
// 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()));
-
+
if(!scale.is_equal_to(Vector(1,1)))
transform_stack.push(new Transform_Scale(scale,origin));
if(!scale.is_equal_to(Vector(0,0)))
transform_stack.push(new Transform_Translate(origin));
-
+
rebuild_ducks_layer_(transform_stack,child_canvas,selected_list);
-
+
if(!scale.is_equal_to(Vector(0,0)))
transform_stack.pop();
if(!scale.is_equal_to(Vector(1,1)))
#if 0
if(rebuild_ducks_queued)
return;
-#else
+#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),
),
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_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...
+
+ // 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);
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;
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(),
// 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;
+
+ 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(
);
timewindreset = true;
}
-
+
while( time + timer() < Time(time_window_adjustment().get_sub_lower()) )
{
time_window_adjustment().set_value(
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;
-
+
studio::App::iteration(false);
-
+
if(get_cancel_status())
return;
}
- is_playing_=false;
+ is_playing_=false;
time_adjustment().set_value(endtime);
time_adjustment().value_changed();
{
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->add(*manage(new Gtk::Image(Gtk::StockID("gtk-go-down"),iconsize)));
treetogglebutton->show_all();
notebook->show();
}
{
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->add(*manage(new Gtk::Image(Gtk::StockID("gtk-go-up"),iconsize)));
treetogglebutton->show_all();
notebook->hide();
}
{
timebar->show();
current_time_widget->show();
-
+
//keyframe_tab_child->show();
if(layer_tree)
layer_tree->set_show_timetrack(true);
&Gtk::Widget::show
)
));
-
+
waypoint_menu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-duplicate"),
sigc::bind(
sigc::bind(
//synfig::info("Droped data of type \"%s\"",selection_data.get_data_type());
//synfig::info("Droped 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
break;
synfigapp::Action::Handle action(synfigapp::Action::create("layer_add"));
-
+
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 successfuly 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 URL's seperated
// by not only Carrage-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;
try{ext=(String(filename.begin()+filename.find_last_of('.')+1,filename.end()));}catch(...){continue;}
-
+
// If this is a SIF file, then we need to do things slightly differently
if(ext=="sketch")
{
{
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()));
{
ui_interface_->error("I am unable to duplicate the keyframe");
return;
- }
+ }
keyframe=row[model.keyframe];
synfigapp::Action::Handle action(synfigapp::Action::create("keyframe_duplicate"));
{
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);
{
ui_interface_->error("I am unable to remove the keyframe");
return;
- }
+ }
keyframe=row[model.keyframe];
synfigapp::Action::Handle action(synfigapp::Action::create("keyframe_remove"));
{
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);
if(duck_mask_position)
duck_mask_position->set_active(!is_currently_on);
break;
-
+
case Duck::TYPE_VERTEX:
if(duck_mask_vertex)
duck_mask_vertex->set_active(!is_currently_on);
break;
-
+
case Duck::TYPE_TANGENT:
if(duck_mask_tangent)
duck_mask_tangent->set_active(!is_currently_on);
break;
-
+
case Duck::TYPE_RADIUS:
if(duck_mask_radius)
duck_mask_radius->set_active(!is_currently_on);
break;
-
+
case Duck::TYPE_WIDTH:
if(duck_mask_width)
duck_mask_width->set_active(!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();
}
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());
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();
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_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);
//render it out...
prev->render();
-
+
Dialog_Preview *pd = preview_dialog.get();
assert(pd);
-
+
pd->set_preview(prev.get());
pd->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);
}
{
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());
disp_audio->set_profile(etl::handle<AudioProfile>());
}else
{
- //save in canvasview
+ //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!");
+ 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();
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());
}
{
synfig::info("Playing audio at %f s",t);
audio->play(t);
- }
+ }
}
void
}
if(event)
return Gtk::Window::on_delete_event(event);
-
+
return true;
}
#if _DEBUG
#define DEBUGPOINT_CLASS(x) struct debugpointclass_ ## x { debugpointclass_ ## x () { DEBUGPOINT(); } ~debugpointclass_ ## x () { DEBUGPOINT(); } } badfthguae_ ## x ;
#else
-#define DEBUGPOINT_CLASS(x)
+#define DEBUGPOINT_CLASS(x)
#endif
#endif
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;
SigC::Connection playcon;
SigC::Connection stopcon;
-
+
std::auto_ptr<UniversalScrubber> universal_scrubber;
-
+
//! Tooltip controler
Gtk::Tooltips tooltips;
//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::ProgressBar *progressbar;
Gtk::Statusbar *statusbar;
-
+
Gtk::TreeRow children_canvas_row;
Gtk::TreeRow children_valuenode_row;
-
+
Gtk::Button *stopbutton;
Gtk::Button *refreshbutton;
Gtk::Button *treetogglebutton;
Widget_Time *current_time_widget;
void on_current_time_widget_changed();
-
+
std::auto_ptr<Widget_Timeslider> timeslider;
std::list<sigc::connection> duck_changed_connections;
Gtk::Button *animatebutton;
Gtk::Button *keyframebutton;
-
+
/* DEBUGPOINT_CLASS(8);
Gtk::Menu duckmaskmenu;
Glib::RefPtr<Gtk::ToggleAction> duck_mask_angle;
Gtk::RadioButtonGroup quality_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_;
*/
private:
-
+
// Constructor is private to force the use of the "create()" constructor
CanvasView(etl::loose_handle<Instance> instance,etl::handle<synfigapp::CanvasInterface> canvas_interface);
void time_was_changed();
- void refresh_rend_desc();
-
+ void refresh_rend_desc();
+
void toggle_duck_mask(Duckmatic::Type type);
Gtk::Widget *create_work_area();
void popup_param_menu_bezier(float location, synfigapp::ValueDesc value_desc)
{ popup_param_menu(value_desc,location); }
-
+
void popup_param_menu(synfigapp::ValueDesc value_desc, float location=0);
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*>*);
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_; }
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(); }
//! \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();
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(synfigapp::ValueDesc,synfig::Waypoint, int button);
-
+
void preview_option() {on_preview_option();}
-
+
void present();
-
+
/*
-- ** -- S I G N A L T E R M I N A L S -------------------------------------
*/
private:
-
+
void on_unselect_layers();
void on_input_device_changed(GdkDevice*);
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);
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_duplicate_pressed();
void on_layer_delete_pressed();
*/
-
+
void on_keyframe_add_pressed();
void on_keyframe_duplicate_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);
void on_layer_toggle(synfig::Layer::Handle);
//void on_waypoint_clicked(synfigapp::ValueDesc,synfig::ValueNode_Animated::WaypointList::iterator, int button);
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();
protected:
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);
}; // END of class CanvasView
{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,
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);
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));
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,
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_),
if(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 =
+
+ 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)
{
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();
-
+
//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;
}
{
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();
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);
{
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)
{
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 = i->get_time();
-
+
if(!t.is_valid())
continue;
-
- //if it found it... (might want to change comparison, and optimize
+
+ //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) != sel_times.end())
{
if(dragging) //skip if we're dragging because we'll render it later
{
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_height()-2
);
render_time_point_to_window(window,area2,*i,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,
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_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(
shadow=Gtk::SHADOW_OUT;
selected=false;
}
-
-
+
+
widget.get_style()->paint_diamond(
Glib::RefPtr<Gdk::Window>::cast_static(window),
state,
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);
+ 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());
-
+ status_at_time=!list_entry.status_at_time(Time::end());
+
if(!is_off && status_at_time)
{
xstart=x;
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)
{
is_off=false;
}
*/
-
-
-
+
+
+
if(iter->time>=adjustment->get_lower() && iter->time<adjustment->get_upper())
{
int w(1);
{
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);
{
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;
- {
+
+ mode = NONE;
+ {
Gdk::ModifierType mod;
Gdk::Event(event).get_state(mod);
mode = mod;
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;
+ break;
}
- actual_time = curr_time;
+ 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:
if(/*!value_node && */event->button.button == 1)
{
Time stime;
-
+
/*! UI specification:
-
+
When nothing is selected, clicking on a point in either normal mode order
- addative mode will select the time point closest to the click.
+ addative 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);
-
+
bool clickfound = tset && get_closest_time(*tset,actual_time,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
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);
+ 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;
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);
}
// Perhaps I sould 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);
-
+
bool clickfound = tset && get_closest_time(*tset,actual_time,pixel_width*cell_area.get_height(),stime);
-
+
etl::handle<synfig::Node> node;
if(valdesc.get_value(stime).get_type()==ValueBase::TYPE_CANVAS)
{
{
node=valdesc.get_value_node();
}
-
+
if(clickfound && node)
{
show_timepoint_menu(node, stime, actual_time<stime?SIDE_LEFT:SIDE_RIGHT);
//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:
{
DEBUGPOINT();
-
+
//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_(path,*selected_waypoint,event->button.button-1);
return true;
}
*/
-
+
//Time point stuff...
if(event->button.button == 1)
{
synfigapp::Action::ParamList param_list;
param_list.add("canvas",canvas_interface()->get_canvas());
param_list.add("canvas_interface",canvas_interface());
-
+
if(sel_value.get_value_type() == synfig::ValueBase::TYPE_CANVAS)
{
param_list.add("addcanvas",sel_value.get_value().get(Canvas::Handle()));
{
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())
}else if(delmode) //DELETE
{
etl::handle<studio::Instance>::cast_static(canvas_interface()->get_instance())
- ->process_action("timepoint_delete", param_list);
+ ->process_action("timepoint_delete", param_list);
}else //MOVE
{
etl::handle<studio::Instance>::cast_static(canvas_interface()->get_instance())
- ->process_action("timepoint_move", param_list);
+ ->process_action("timepoint_move", param_list);
}
-
+
//now replace all the selected with the new selected
- sel_times = newset;
+ sel_times = newset;
}
}
-
-
-
+
+
+
/*if(value_node && selection)
{
if(selected_time==drag_time && event->button.button!=3)
}
}
}*/
-
+
//if(selection)
// selected_time=iter->time;
//selected_time=iter->get_time();
//std::cerr<<"unknown event type "<<event->type<<std::endl;
return false;
break;
- }
+ }
{
Waypoint waypoint(*iter);
waypoint.apply_model(model);
-
+
synfigapp::Action::Handle action(synfigapp::Action::create("waypoint_set"));
-
+
assert(action);
-
+
action->set_param("canvas",canvas_interface->get_canvas());
action->set_param("canvas_interface",canvas_interface);
{
Gtk::Menu* interp_menu(manage(new Gtk::Menu()));
Waypoint::Model model;
-
+
if(side==SIDE_LEFT)model.set_before(INTERPOLATION_TCB);
else model.set_after(INTERPOLATION_TCB);
interp_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("TCB"),
canvas_interface()
)
));
-
-
+
+
menu->items().push_back(
Gtk::Menu_Helpers::MenuElem(
side==SIDE_LEFT?_("Change \"In\" Interp."):_("Change \"Out\" Interp."),
private:
//! Time adjustment window
Gtk::Adjustment adjustment_;
-
+
//! Signal for when the user clicks on a waypoint
sigc::signal<void, const Glib::ustring&,synfig::Waypoint, int> signal_waypoint_clicked_;
//! 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...)
//! ???
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_;
/*
*/
private:
-
+
//! ValueBase Desc
Glib::Property<synfigapp::ValueDesc> property_valuedesc_;
CellRenderer_TimeTrack();
~CellRenderer_TimeTrack();
-
+
void show_timepoint_menu(const etl::handle<synfig::Node>& node, const synfig::Time& time, Side side=SIDE_RIGHT);
void set_adjustment(Gtk::Adjustment &x);
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());
//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::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_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()
{
DEBUGPOINT();
}
-
+
void on_editing_done()
{
hide();
if(valuewidget)
valuewidget->set_param_desc(data);
}
-
+
const synfig::ValueBase &get_value()
{
if(valuewidget)
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)
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));
attr_list.change(pango_size);
}
property_attributes()=attr_list;
-
+
property_foreground()=Glib::ustring("#7f7f7f");
property_inconsistant()=false;
}
{
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
+ else
value=ValueBase((String)str);
-
+
if(old_value!=value)
signal_edited_(path,value);
}
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()))
{
break;
}
}
-
+
break;
case ValueBase::TYPE_VECTOR:
{
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())
case ValueBase::TYPE_BOOL:
{
widget.get_style()->paint_check(
- Glib::RefPtr<Gdk::Window>::cast_static(window), state,
+ 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*/,
break;
default:
property_text()=static_cast<Glib::ustring>(_("UNKNOWN"));
- break;
+ break;
}
CellRendererText::render_vfunc(window,widget,background_area,ca,expose_area,flags);
}
// 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_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->present();
-
+
return NULL;
case ValueBase::TYPE_COLOR:
)
);
App::dialog_color->present();
-
+
return NULL;
case ValueBase::TYPE_STRING:
if(get_param_desc().get_hint()=="paragraph")
if(get_paragraph(string))
{
signal_edited_(path,ValueBase(string));
- }
+ }
return NULL;
}
if(get_param_desc().get_hint()!="filename")
if(old_value!=value)
signal_edited_(value_entry->get_path(),value);
-
+
//delete value_entry;
//value_entry=0;
- }
+ }
}
void gradient_edited(synfig::Gradient gradient, Glib::ustring path);
void color_edited(synfig::Color color, Glib::ustring path);
-
+
public:
sigc::signal<void, const Glib::ustring&> &signal_secondary_click()
{return signal_secondary_click_; }
etl::handle<synfig::Canvas> get_canvas()const { return property_canvas_; }
synfig::ParamDesc get_param_desc()const { return property_param_desc_; }
-
+
CellRenderer_ValueBase();
~CellRenderer_ValueBase();
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,
// Pack the label into the column
column->pack_start(model.label,true);
- // Finish setting up the column
+ // Finish setting up the column
column->set_reorderable();
column->set_resizable();
column->set_clickable();
column->set_min_width(150);
column->set_sort_column_id(model.label);
tree_view.append_column(*column);
-
+
}
{ // --- T Y P E --------------------------------------------------------
int cols_count = tree_view.append_column(_("Type"),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));
{ // --- 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;
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();
// 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
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);
-
-
+
+
/*
Gtk::Image *icon;
//Gtk::IconSize iconsize(Gtk::IconSize::from_name("synfig-small_icon"));
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);
void
ChildrenTree::on_selection_changed()
-{
+{
if(0)
{
button_raise->set_sensitive(false);
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;
ChildrenTree::on_waypoint_clicked(const Glib::ustring &path_string, synfig::Waypoint waypoint,int button)
{
Gtk::TreePath path(path_string);
-
+
const Gtk::TreeRow row = *(tree_view.get_model()->get_iter(path));
-
+
signal_waypoint_clicked()(static_cast<synfigapp::ValueDesc>(row[model.value_desc]),waypoint,button);
}
)
) break;
const Gtk::TreeRow row = *(tree_view.get_model()->get_iter(path));
-
+
if(column->get_first_cell_renderer()==cellrenderer_time_track)
{
return signal_user_click()(event->button.button,row,COLUMNID_TIME_TRACK);
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;
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
*/
public:
-
+
ChildrenTreeStore::Model model;
-
+
/*
-- ** -- P R I V A T E D A T A ---------------------------------------------
*/
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 -------------------------------------
*/
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();
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();
}
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::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_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]);
{
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.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();
+ row[model.label] = canvas->get_name();
else
- row[model.label] = _("[Unnamed]");
-
+ row[model.label] = _("[Unnamed]");
+
row[model.canvas] = canvas;
row[model.type] = _("Canvas");
//row[model.is_canvas] = true;
// return;
Gtk::TreeRow row = *prepend(value_node_row.children());
-
+
set_row(row,synfigapp::ValueDesc(canvas_interface()->get_canvas(),value_node->get_id()),false);
}
ChildrenTreeStore::on_value_node_deleted(etl::handle<ValueNode> value_node)
{
Gtk::TreeIter iter;
- //int i(0);
+ //int i(0);
if(find_first_value_node(value_node,iter))
{
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);
+ int i(0);
if(!value_node->is_exported() && find_first_value_node(value_node,iter))
{
i++;
refresh_row(row);
}while(find_next_value_node(value_node,iter));
-
+
if(!i)
{
refresh_value_nodes();
return false;
}
-
+
}
catch(...)
{
return false;
}
}
-
+
return false;
}
// 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);
+ int i(0);
while(find_next_value_node(value_node,iter))
{
Gtk::TreeRow row(*iter);
//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);
}
catch(std::exception x)
{
g_warning(x.what());
- }
+ }
}
*/
public:
-
+
//! TreeModel for the layers
const Model model;
*/
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 -------------------------------------
*/
*/
public:
-
+
ChildrenTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
~ChildrenTreeStore();
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; }
/*
*/
public:
-
+
static Glib::RefPtr<ChildrenTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
}; // END of class ChildrenTreeStore
#define COLUMNID_JUMP (787584)
#define ColumnID int
-
+
/* === G L O B A L S ======================================================= */
/* === P R O C E D U R E S ================================================= */
notebook->append_page(*create_canvas_tree(),"Canvases");
notebook->append_page(*create_action_tree(),"History");
-
+
/*
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);
//#ifdef NDEBUG
// column->add_attribute(icon_cellrenderer->property_pixbuf(), canvas_tree_model.icon);
//#endif
-
+
canvas_tree->append_column(*column);
}
canvas_tree->set_rules_hint();
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::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_id(COLUMNID_JUMP);
action_tree->append_column(*column);
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));
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;
}
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();
}
}
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();
}
}
else
instance_selector->set_history(0);
- set_selected_instance_(x);
+ set_selected_instance_(x);
}
void
{
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> >(
loose_instance
)
);
-
+
{
std::string name=basename(instance->get_file_name());
)
) 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)
{
}
}
}
-
+
case GDK_BUTTON_RELEASE:
break;
default:
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);
+ 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;
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());
}
class CompView : public Gtk::Window
{
DialogSettings dialog_settings;
-
+
Gtk::Tooltips tooltips;
Gtk::OptionMenu *instance_selector;
void clear_history();
void clear_redo();
-
+
public:
CompView();
~CompView();
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);
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);
gdk_device_set_mode(device,GDK_MODE_SCREEN);
-
+
synfigapp::InputDevice::Handle input_device;
input_device=synfigapp::Main::add_input_device(device->name,synfigapp::InputDevice::Type(device->source));
if(input_device->get_type()==synfigapp::InputDevice::TYPE_MOUSE)
synfigapp::Main::select_input_device(input_device);
- }
+ }
}
}
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::hide_return(sigc::mem_fun(*this, &Dialog_Color::on_close_pressed)));
+ cancel_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)));
Gtk::Table* table(manage(new Gtk::Table(2,2,false)));
widget_color=manage(new Widget_ColorEdit());
widget_color->signal_value_changed().connect(sigc::mem_fun(*this,&studio::Dialog_Color::on_color_changed));
//widget_color->signal_activate().connect(sigc::mem_fun(*this,&studio::Dialog_Color::on_color_changed));
- table->attach(*widget_color, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ table->attach(*widget_color, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
add_accel_group(App::ui_manager()->get_accel_group());
namespace studio {
class Widget_Color;
-
+
class Dialog_Color : public Gtk::Dialog
{
DialogSettings dialog_settings;
-
+
sigc::signal<void,synfig::Color> signal_edited_;
//sigc::signal<void,synfig::Color> signal_apply_;
Widget_ColorEdit* widget_color;
bool busy_;
-
+
public:
bool busy()const { return busy_; }
-
+
sigc::signal<void,synfig::Color>& signal_edited() { return signal_edited_; }
-
+
//sigc::signal<void,synfig::Color>& signal_apply() { return signal_apply_; }
-
+
void set_color(const synfig::Color& x) { widget_color->set_value(x); }
synfig::Color get_color()const { return widget_color->get_value(); }
-
+
void reset();
-
+
Dialog_Color();
~Dialog_Color();
set_keep_above(false);
set_role("gradient_editor");
-
+
// Setup the buttons
Gtk::Button *grab_button(manage(new class Gtk::Button(Gtk::StockID("Grab"))));
grab_button->show();
add_action_widget(*apply_button,1);
apply_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Gradient::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_Gradient::hide));
+ 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_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);
+ //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);
+ 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);
+ 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();
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(
x
)
);
-
+
present();
}
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_ok_pressed();
void on_apply_pressed();
void on_grab_pressed();
-
+
void on_cpoint_selected(synfig::Gradient::CPoint x);
void on_values_adjusted();
Widget_ColorEdit* widget_color;
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 reset();
-
+
Dialog_Gradient();
~Dialog_Gradient();
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);
get_vbox()->pack_start(*table);
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(*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);
{
if(widget_waypoint_model->get_waypoint_model().is_trivial())
return;
-
+
synfigapp::Action::Handle action(synfigapp::Action::create("keyframe_waypoint_set"));
-
+
assert(action);
-
- action->set_param("canvas",canvas_interface->get_canvas());
- action->set_param("canvas_interface",canvas_interface);
+
+ 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))
{
}
{
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();
private:
}; // END of class RenderSettings
-
+
}; // END of namespace studio
/* === E N D =============================================================== */
{
//framerate = 15.0f;
//zoom = 0.2f;
-
- //set the fps of the time widgets
+
+ //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::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);
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>"));
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);
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);
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();
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();
time_end.set_sensitive(get_end_override());
}
-void studio::Dialog_PreviewOptions::set_global_fps(float f)
-{
- globalfps = f;
- time_begin.set_fps(f);
+void studio::Dialog_PreviewOptions::set_global_fps(float f)
+{
+ globalfps = f;
+ time_begin.set_fps(f);
time_end.set_fps(f);
}
{
Widget_Preview preview;
DialogSettings settings;
-
+
//etl::handle<synfig::Canvas> canvas;
-
+
public:
Dialog_Preview();
~Dialog_Preview();
class Dialog_PreviewOptions : public Gtk::Dialog
{
- //all the info needed to construct a render description...
+ //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();
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_;}
};
Gtk::Table *gamma_table=manage(new Gtk::Table(2,2,false));
notebook->append_page(*gamma_table,_("Gamma"));
//gamma_frame->add(*gamma_table);
-
- gamma_table->attach(gamma_pattern, 0, 2, 0, 1, Gtk::EXPAND, Gtk::SHRINK|Gtk::FILL, 0, 0);
+
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ //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."));
-
+
// Misc - Timestamp
timestamp_menu=manage(new class Gtk::Menu());
- misc_table->attach(*manage(new Gtk::Label(_("Timestamp"))), 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
- misc_table->attach(timestamp_optionmenu, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+ misc_table->attach(*manage(new Gtk::Label(_("Timestamp"))), 0, 1, 0, 1, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+ misc_table->attach(timestamp_optionmenu, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
#define ADD_TIMESTAMP(desc,x) \
timestamp_menu->items().push_back( \
ADD_TIMESTAMP("HHhMMmSSsFFf",Time::FORMAT_NORMAL|Time::FORMAT_NOSPACES|Time::FORMAT_FULL);
timestamp_optionmenu.set_menu(*timestamp_menu);
-
+
#undef ADD_TIMESTAMP
{
widget_enum=manage(new Widget_Enum());
widget_enum->set_param_desc(param_desc);
- misc_table->attach(*manage(new Gtk::Label(_("Unit System"))), 0, 1, 3, 4, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
- misc_table->attach(*widget_enum, 1, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+ misc_table->attach(*manage(new Gtk::Label(_("Unit System"))), 0, 1, 3, 4, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+ misc_table->attach(*widget_enum, 1, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
}
// Misc - recent files
Gtk::SpinButton* recent_files_spinbutton(manage(new Gtk::SpinButton(adj_recent_files,1,0)));
- misc_table->attach(*manage(new Gtk::Label(_("Recent Files"))), 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
- misc_table->attach(*recent_files_spinbutton, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+ misc_table->attach(*manage(new Gtk::Label(_("Recent Files"))), 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+ misc_table->attach(*recent_files_spinbutton, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
// Misc - use_colorspace_gamma
- misc_table->attach(toggle_use_colorspace_gamma, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
-
+ misc_table->attach(toggle_use_colorspace_gamma, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+
show_all_children();
}
{
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());
-
+ 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();
App::distance_system=Distance::System(widget_enum->get_value());
-
+
App::save_settings();
}
void
Dialog_Setup::refresh()
{
- 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());
+ 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());
-
+
// Refresh the temporary gamma
gamma_pattern.set_gamma_r(1.0/adj_gamma_r.get_value());
gamma_pattern.set_gamma_g(1.0/adj_gamma_g.get_value());
gamma_pattern.set_black_level(black_level_selector.get_value());
gamma_pattern.set_red_blue_level(red_blue_level_selector.get_value());
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);
set_size_request(tile_w*4,tile_h*3);
signal_expose_event().connect(sigc::mem_fun(*this, &studio::GammaPattern::redraw));
}
-
+
GammaPattern::~GammaPattern()
{
}
GammaPattern::refresh()
{
black[0].set_rgb_p(
- r_F32_to_F32(0.0),
- g_F32_to_F32(0.0),
+ 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),
+ 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),
+ 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),
+ r_F32_to_F32(0.25),
+ g_F32_to_F32(0.25),
b_F32_to_F32(0.25)
);
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);
}
{
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);
}
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);
+ 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);
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);
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()));
+ 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"));
RedBlueLevelSelector::RedBlueLevelSelector()
{
- set_size_request(-1,24);
+ 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);
Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
int i;
-
+
// Draw the gradient
for(i=0;i<w;i++)
{
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);
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()));
+ 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"));
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; };
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);
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; }
+ const float &get_value()const { return level; }
bool redraw(GdkEventExpose*bleh=NULL);
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; }
+ const float &get_value()const { return level; }
bool redraw(GdkEventExpose*bleh=NULL);
class Dialog_Setup : public Gtk::Dialog
{
-
+
void on_ok_pressed();
void on_apply_pressed();
void on_black_level_change();
void on_red_blue_level_change();
- GammaPattern gamma_pattern;
+ 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::CheckButton toggle_use_colorspace_gamma;
synfig::Time::Format time_format;
-
+
Gtk::Menu *timestamp_menu;
Widget_Enum *widget_enum;
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();
table->attach(soundfile,0,1,0,1);
table->attach(offset,1,2,0,1);
table->attach(okbutton,0,2,1,2);
-
+
table->show_all();
get_vbox()->pack_start(*table);
-
+
offset.set_value(0);
-
+
okbutton.signal_clicked().connect(sigc::mem_fun(*this,&Dialog_SoundSelect::on_ok));
}
void studio::Dialog_SoundSelect::on_ok()
{
hide();
-
+
//signal_finish_(a);
signal_file_changed_(soundfile.get_value());
signal_offset_changed_(offset.get_value());
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();
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 =============================================================== */
{
//scrolled_.add(sub_vbox_);
//scrolled_.set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC);
- //scrolled_.show();
+ //scrolled_.show();
//get_vbox()->pack_start(scrolled_);
add(sub_vbox_);
-
+
set_widget(empty_label);
empty_label.show();
}
/* === 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::ScrolledWindow scrolled_;
Gtk::VBox sub_vbox_;
-
+
public:
-
+
void clear();
void set_widget(Gtk::Widget&);
void set_name(const synfig::String& name);
add_action_widget(*cancel_button,0);
cancel_button->signal_clicked().connect(sigc::mem_fun(*this, &Dialog_Waypoint::hide));
-
+
waypointwidget->show_all();
}
void
Dialog_Waypoint::on_apply_pressed()
{
- signal_changed_();
+ signal_changed_();
}
void
Dialog_Waypoint::on_delete_pressed()
{
hide();
- signal_delete_();
+ signal_delete_();
}
void
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_;
{
if(value.empty())
return false;
-
- if(key=="pos")
+
+ if(key=="pos")
{
int x,y;
if(!strscanf(value,"%d %d",&x, &y))
window->move(x,y);
return true;
}
- if(key=="size")
+ if(key=="size")
{
int x,y;
if(!strscanf(value,"%d %d",&x, &y))
window->set_default_size(x,y);
return true;
}
- if(key=="x")
+ if(key=="x")
{
int x,y; window->get_position(x,y);
x=atoi(value.c_str());
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;
}
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());
/*
//#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->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);
if (x==selected_instance)
return;
- set_selected_instance_(x);
+ set_selected_instance_(x);
}
void
{
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> >(
loose_instance
)
);
-
+
present();
-
+
}
void
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; }
void refresh_instances();
bool close();
-
+
void on_row_activate(const Gtk::TreeModel::Path &path, Gtk::TreeViewColumn *);
//bool on_tree_event(GdkEvent *event);
),
false
)
- )
+ )
);
*/
synfig::info("%s init_canvas_view() Starting init...",get_local_name().c_str());
);
}
*/
-
+
#ifdef _DEBUG
synfig::info("%s canvas_view_changed: start",get_local_name().c_str());
#endif
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);
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);
}
if(canvas_view)
{
Gtk::Widget* tree_view(canvas_view->get_ext_widget(get_name()));
-
+
add(*tree_view);
tree_view->show();
}
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);
{
last_widget_curves_=0;
table_=0;
-
+
hscrollbar_=new Gtk::HScrollbar();
vscrollbar_=new Gtk::VScrollbar();
widget_timeslider_= new Widget_Timeslider();
curves->clear();
return;
}
-
+
std::list<synfigapp::ValueDesc> value_descs;
//std::list<Gtk::TreePath> path_list(
//param_tree_view->get_selection()->selected_foreach_iter(tmp);
iter=param_tree_view->get_selection()->get_selected();
-
+
value_descs.push_back((*iter)[model.value_desc]);
curves->set_value_descs(value_descs);
-
- //curves->set_value_descs(tmp.value_descs);
+
+ //curves->set_value_descs(tmp.value_descs);
}
void
{
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(
),param_tree_view
)
);
-
+
canvas_view->set_ext_widget(get_name(),curves);
}
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;
table_=0;
}
-
+
if(canvas_view)
{
last_widget_curves_=dynamic_cast<Widget_Curves*>(
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();
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);
{
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"),
_("Undo previous action"),
_("Undo previous action")
),
- sigc::ptr_fun(studio::App::undo)
+ sigc::ptr_fun(studio::App::undo)
);
action_group->add(Gtk::Action::create(
"redo",
_("Redo previous action"),
_("Redo previous action")
),
- sigc::ptr_fun(studio::App::redo)
+ sigc::ptr_fun(studio::App::redo)
);
action_group->add( Gtk::Action::create("toolbar-history", "History") );
action_group->set_sensitive(false);
- set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-history")));
+ set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-history")));
add(*create_action_tree());
-
+
/*
add_button(
Gtk::StockID("synfig-clear_undo"),
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::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_id(COLUMNID_JUMP);
action_tree->append_column(*column);
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,&Dock_History::on_row_activate));
action_tree->signal_event().connect(sigc::mem_fun(*this,&Dock_History::on_action_event));
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();
}
}
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();
}
}
std::list<etl::handle<studio::Instance> >::iterator iter;
- set_selected_instance_(x);
+ set_selected_instance_(x);
}
void
)
) 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)
{
}
}
}
-
+
case GDK_BUTTON_RELEASE:
break;
default:
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());
}
namespace studio {
class Dock_History : public Dock_CanvasSpecific
-{
+{
Glib::RefPtr<Gtk::ActionGroup> action_group;
Gtk::TreeView *action_tree;
void on_action_toggle(const Glib::ustring& path);
void update_undo_redo();
-
+
Dock_History();
~Dock_History();
protected:
void studio::Dock_Info::on_mouse_move()
{
Point pos = get_canvas_view()->work_area->get_cursor_pos();
-
- Distance xv(pos[0],Distance::SYSTEM_UNITS);
+
+ 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);
+
+ 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));
+
+ 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);
+ 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));
: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);
-
+
//seperator
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);
}
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));
{
//bool valid;
//synfig::Point pos;
-
+
Gtk::Label r,g,b,a;
Gtk::Label x,y;
-
- SigC::Connection mousecon;
-
- void on_mouse_move();
-
+
+ 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 =============================================================== */
App::ui_manager()->add_ui_from_string(ui_info);
- set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-keyframe")));
+ set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-keyframe")));
}
Dock_Keyframes::~Dock_Keyframes()
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();
class KeyframeTree;
class KeyframeActionManager;
-
+
class Dock_Keyframes : public Dock_CanvasSpecific
-{
+{
Glib::RefPtr<Gtk::ActionGroup> action_group;
/*
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);
Dock_CanvasSpecific("groups",_("Groups"),Gtk::StockID("synfig-group")),
action_group_group_ops(Gtk::ActionGroup::create()),
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 =
App::ui_manager()->add_ui_from_string(ui_info);
- set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-groups")));
+ set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-groups")));
}
Dock_LayerGroups::~Dock_LayerGroups()
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();
+ clear_previous();
group_action_manager->clear();
group_action_manager->set_canvas_interface(0);
group_action_manager->set_group_tree(0);
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;
action_group_new_layers=Gtk::ActionGroup::create();
action_group_layer_ops=Gtk::ActionGroup::create();
-
+
std::map<synfig::String,synfig::String> category_map;
// Build layer creation actions
for(iter=synfig::Layer::book().begin();iter!=synfig::Layer::book().end();++iter)
{
synfig::Layer::Book::value_type lyr(*iter);
-
+
if(lyr.second.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()),
);
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><menubar action='menu-main'><menu action='menu-layer'><menu action='menu-layer-new'>";
std::map<synfig::String,synfig::String>::iterator iter;
}
layer_ui_info+="</menu></menu></menubar></ui>";
-
+
App::ui_manager()->insert_action_group(action_group_categories);
App::ui_manager()->insert_action_group(action_group_new_layers);
App::ui_manager()->add_ui_from_string(layer_ui_info);
}
-
-
+
+
action_group_layer_ops->add( Gtk::Action::create("toolbar-layer", "Layer Ops") );
App::ui_manager()->insert_action_group(action_group_layer_ops);
action_group_new_layers->set_sensitive(false);
- set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-layer")));
+ set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-layer")));
{
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(
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);
+ assert(ref_count.count()==1);
*/
}
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);
layer_action_manager->set_canvas_interface(0);
layer_action_manager->set_layer_tree(0);
}
-
- clear_previous();
+
+ clear_previous();
}
}
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);
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);
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:
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);
}
//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));
renderer->start();
{
//convert it into our pixmap
PixelFormat pf(PF_RGB);
-
+
//synfig::warning("Nav: It hath succeeded!!!");
-
+
//assert(renderer && renderer->has_success());
DEBUGPOINT();
//synfig::warning("Nav: now we know it really succeeded");
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 =
+
+ prev =
Gdk::Pixbuf::create_from_data(
bytes, // pointer to the data
Gdk::COLORSPACE_RGB, // the colorspace
convert_color_format((unsigned char *)prev->get_pixels(), (*surface)[0], dw*dh, pf, App::gamma);
}
}
- queue_draw();
+ queue_draw();
}
/* zoom slider is on exponential scale
//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)
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
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: 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
}
}
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);
+ 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)
}
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));
+ 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;
{
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;
-
+ 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((prev->get_width() / drawto.get_width()) < (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;
}
}
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);
}else
{
clear_previous();
- //add(dummy);
+ //add(dummy);
}
}
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
+
+ //The drawing stuff
Gtk::DrawingArea drawto;
-
+
//The input stuff
Gtk::Adjustment adj_zoom;
Gtk::Label zoom_print;
-
+
//zoom window stuff
bool scrolling;
-
+
//asyncronous 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();
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 =============================================================== */
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(
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;
if(canvas_view)
{
Gtk::Widget* tree_view(canvas_view->get_ext_widget(get_name()));
-
+
add(*tree_view);
tree_view->show();
show_all();
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);
CellRenderer_TimeTrack *cellrenderer_time_track;
Glib::RefPtr<LayerParamTreeStore> param_tree_store_;
-
- Gtk::TreeView *mimic_tree_view;
+
+ Gtk::TreeView *mimic_tree_view;
public:
sigc::signal<void,synfigapp::ValueDesc,synfig::Waypoint,int> signal_waypoint_clicked;
{
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;
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);
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()->get_lower()
)
);
mimic_tree_view->get_vadjustment()->value_changed();
)
) break;
const Gtk::TreeRow row = *(get_model()->get_iter(path));
-
+
if(column && column->get_first_cell_renderer()==cellrenderer_time_track)
{
Gdk::Rectangle rect;
return true;
//return signal_param_user_click()(event->button.button,row,COLUMNID_TIME_TRACK);
}
-/* else
+/* else
{
if(event->button.button==3)
{
if(layer_list.size()<=1)
{
synfigapp::ValueDesc value_desc(row[model.value_desc]);
- Gtk::Menu* menu(manage(new Gtk::Menu()));
+ Gtk::Menu* menu(manage(new Gtk::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()));
+ Gtk::Menu* menu(manage(new Gtk::Menu()));
std::list<synfigapp::ValueDesc> value_desc_list;
ParamDesc param_desc(row[model.param_desc]);
for(;!layer_list.empty();layer_list.pop_back())
*/
}
break;
-
+
case GDK_MOTION_NOTIFY:
{
Gtk::TreeModel::Path path;
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;
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;
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)
{
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("waypoint_set_smart", 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>(
);
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());
-
+
cellrenderer_time_track->set_fixed_size(-1,18);
}
}
-
+
void
on_waypoint_clicked(const Glib::ustring &path_string, synfig::Waypoint waypoint,int button)
{
/*
Gtk::TreePath path(path_string);
-
+
const Gtk::TreeRow row = *(get_model()->get_iter(path));
if(!row)
return;
*/
-
+
ValueNode::Handle value_node(waypoint.get_parent_value_node());
assert(value_node);
synfig::error(__FILE__":%d: Unable to find the valuenode",__LINE__);
return;
}
-
+
if(!row)
return;
-
+
synfigapp::ValueDesc value_desc(static_cast<synfigapp::ValueDesc>(row[model.value_desc]));
signal_waypoint_clicked(value_desc,waypoint,button);
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")
tree_view->signal_waypoint_clicked.connect(sigc::mem_fun(*canvas_view, &studio::CanvasView::on_waypoint_clicked));
-
+
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));
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;
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());
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_);
table_->show_all();
show_all();
{
parent_=0;
scrolled_=0;
-
+
use_scrolled_=true;
-
+
//set_title(local_name);
//set_type_hint(Gdk::WINDOW_TYPE_HINT_UTILITY);
-
+
title_label_.show();
attach_dnd_to(title_label_);
-
+
//scrolled_.set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC);
- //scrolled_.show();
+ //scrolled_.show();
//scrolled_.set_shadow_type(Gtk::SHADOW_NONE);
toolbar_=0;
//button_box_.show();
-
+
Gtk::Table* table(this);
{
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);
}
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_size_request(175,120);
//scrolled_.set_shadow_type(Gtk::SHADOW_NONE);
-
+
}
Dockable::~Dockable()
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));
+ widget.signal_drag_data_received().connect(sigc::mem_fun(*this,&Dockable::on_drag_data_received));
}
void
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
context->drag_finish(true, false, time);
return;
}
-
+
context->drag_finish(false, false, time);
}
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_;
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);
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))
{
else
{
// Bad icon, try to make a label
-
+
Glib::ustring text(get_local_name());
Gtk::Label* label(manage(new Gtk::Label(text)));
label->show();
}
}
-
+
return event_box;
}
/* === 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;
//Gtk::HBox button_box_;
Gtk::HBox header_box_;
//Gtk::VBox vbox_;
-
+
//Gtk::HandleBox handle_box_;
Gtk::ScrolledWindow *scrolled_;
Gtk::Widget *prev_widget_;
bool use_scrolled_;
-
+
Gtk::StockID stock_id_;
DockBook* parent_;
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();
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());
-
+
+ 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);
context->drag_finish(true, false, time);
return;
}
-
+
context->drag_finish(false, false, time);
}
DockBook::add(Dockable& dockable, int position)
{
dockable.detach();
-
+
if(position==-1)
append_page(dockable, " ");
else
&dockable
)
);
-
+
dockable.parent_=this;
dockable.show();
//set_current_page(get_n_pages()-1);
-
+
signal_changed_();
}
DockBook::refresh_tab(Dockable* dockable)
{
Gtk::Widget* label(dockable->create_tab_label());
-
+
label->signal_button_press_event().connect(
sigc::bind(
sigc::mem_fun(
if(!deleting_)
{
signal_changed_();
-
+
if(get_n_pages()==0)
signal_empty()();
}
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;
}
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;
}
dock=String(str.begin(),str.begin()+separator);
str=String(str.begin()+separator+1,str.end());
}
-
+
try
{
add(App::dock_manager->find_dockable(dock));
{
if(event->button!=3)
return false;
-
+
Gtk::Menu *tabmenu=manage(new class Gtk::Menu());
-
+
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;
}
/* === 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;
sigc::signal<void> signal_empty_;
sigc::signal<void> signal_changed_;
-
- Gtk::Tooltips tooltips_;
-
+
+ Gtk::Tooltips tooltips_;
+
bool deleting_;
-
+
protected:
public:
DockBook();
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);
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",
#endif
);
set_keep_above(false);
-
+
// Set up the window
//set_type_hint(Gdk::WINDOW_TYPE_HINT_UTILITY);
set_title("Dock Dialog");
-
+
// Register with the dock manager
App::dock_manager->dock_dialog_list_.push_back(this);
-
- // connect our signals
+
+ // connect our signals
signal_delete_event().connect(
sigc::hide(
sigc::mem_fun(*this,&DockDialog::close)
)
);
-
+
/*
App::signal_canvas_view_focus().connect(
sigc::hide(
// 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
// theoreticly do the same thing after this
// class is destroyed, but it doesn't seem to
context->drag_finish(true, false, time);
return;
}
-
+
context->drag_finish(false, false, time);
}
context->drag_finish(true, false, time);
return;
}
-
+
context->drag_finish(false, false, time);
}
DockDialog::prepend_dock_book()
{
if(is_deleting)return 0;
-
+
dock_book_list.push_front(new DockBook);
last_dock_book=dock_book_list.front();
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(
if(last_dock_book==dock_book)
last_dock_book=dock_book_list.front();
}
-
+
refresh();
-
+
return;
}
}
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") );
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();
pannels_.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));
-
+
pannels_.push_back(parent);
-
+
if(pannels_.size()<=dock_book_sizes_.size())
pannels_.back()->set_position(dock_book_sizes_[pannels_.size()-1]);
pannels_.back()->property_position().signal_changed().connect(
//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));
pannels_.push_back(current);
-
+
if(pannels_.size()<=dock_book_sizes_.size())
pannels_.back()->set_position(dock_book_sizes_[pannels_.size()-1]);
pannels_.back()->property_position().signal_changed().connect(
current->add1(**iter);
//(*iter)->show();
//current->show();
-
+
parent=current;
}
parent->add2(**iter);
//(*iter)->show();
}
-
+
box->show_all();
if(!composition_selector_)
widget_comp_select->hide();
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)
{
synfig::info("DockDialog::close(): DELETED!");
empty_sig.disconnect();
//get_dock_book().clear();
- delete this;
+ delete this;
return true;
}
ret+=is_horizontal?" | ":" - ";
ret+=(*iter)->get_contents();
}
-
-
+
+
return ret;
}
is_horizontal=false;
}
}
-
+
synfig::String book_contents;
if(separator==synfig::String::npos)
{
book_contents=String(str.begin(),str.begin()+separator);
str=String(str.begin()+separator+1,str.end());
}
-
+
try
{
append_dock_book()->set_contents(book_contents);
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;
SigC::Connection empty_sig;
bool composition_selector_;
-
+
bool is_deleting;
-
+
bool is_horizontal;
-
+
private:
std::list<DockBook*> dock_book_list;
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();
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");
{
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();
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 {
-
+
vector<int> data;
String::size_type n=0;
String value_(value);
n=value_.find(" ");
if(n!=String::npos)
n++;
-
+
}
dock_dialog.set_dock_book_sizes(data);
}
}
return synfigapp::Settings::set_value(key_,value);
}
-
+
virtual KeyList get_key_list()const
{
synfigapp::Settings::KeyList ret(synfigapp::Settings::get_key_list());
{
Dockable* dockable(dockable_list_.back());
synfig::info("DockManager::~DockManager(): Deleting dockable \"%s\"",dockable->get_name().c_str());
- dockable_list_.pop_back();
+ dockable_list_.pop_back();
delete dockable;
}
}
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");
}
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");
}
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:
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
{
return transform_stack_.perform(get_sub_trans_point());
}
-
+
void
Duck::set_trans_point(const synfig::Point &x)
{
namespace studio {
class Duckmatic;
-
+
/*! \class Duck
** \writeme */
class Duck : public etl::shared_object
{
friend class Duckmatic;
-
+
public:
enum Type
{
typedef etl::handle<Duck> Handle;
typedef etl::loose_handle<Duck> LooseHandle;
-
+
private:
sigc::signal<bool,const synfig::Point &> signal_edited_;
sigc::signal<void> signal_user_click_[5];
-
+
Type type_;
synfig::Point point;
etl::smart_ptr<synfig::Point> shared_point;
-
+
synfig::Point origin;
synfig::String name;
synfig::Real scalar;
etl::handle<Duck> connect_duck;
etl::handle<Duck> box_duck;
- synfig::GUID guid_;
+ synfig::GUID guid_;
// Flags
bool editable;
bool radius_;
bool tangent_;
-
+
synfig::TransformStack transform_stack_;
synfigapp::ValueDesc value_desc_;
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<void> &signal_user_click(int i=0) { assert(i>=0); assert(i<5); return signal_user_click_[i]; }
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; }
//! 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::Point get_trans_point()const;
-
+
void set_trans_point(const synfig::Point &x);
synfig::Point get_sub_trans_point()const;
//! Retrieves the origin location
synfig::Point get_origin()const;
-
+
//! Retrieves the origin duck
- const etl::handle<Duck> & get_origin_duck() const;
+ 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;
}; // END of class Duck
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));
*/
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)
void
Duckmatic::select_all_ducks()
{
- DuckMap::const_iterator iter;
+ 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);
vmax[1]=std::max(tl[1],br[1]);
// Type type(get_type_mask());
-
- DuckMap::const_iterator iter;
+
+ DuckMap::const_iterator iter;
for(iter=duck_map.begin();iter!=duck_map.end();++iter)
{
Point p(iter->second->get_trans_point());
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;
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;
if(has_guide_y)
ret[1]=*guide_y;
}
-
+
if(axis_lock)
{
ret-=drag_offset_;
ret[1]=0;
ret+=drag_offset_;
}
-
+
return ret;
}
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)
{
synfig::Vector vect(duckmatic->snap_point_to_grid(vector)-drag_offset_);
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;
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)
{
duck->set_shared_point(point);
duck_data_share_map[duck->get_data_guid()]=point;
}
-
+
duck_map.insert(duck);
}
stroke->stroke_data=stroke_point_list;
stroke->color=color;
- stroke_list_.push_back(stroke);
+ stroke_list_.push_back(stroke);
}
void
void
Duckmatic::erase_duck(const etl::handle<Duck> &duck)
{
- duck_map.erase(duck->get_guid());
+ duck_map.erase(duck->get_guid());
}
etl::handle<Duckmatic::Duck>
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)
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;
for(iter=duck_map.begin();iter!=duck_map.end();++iter)
{
const Duck::Handle& duck(iter->second);
-
+
if(!duck->get_editable())
continue;
Real dist((duck->get_trans_point()-point).mag_squared());
etl::handle<Duckmatic::Bezier>
Duckmatic::find_bezier(synfig::Point point, synfig::Real radius,float* location)
{
- return find_bezier(point,radius,radius,location);
+ return find_bezier(point,radius,radius,location);
}
-etl::handle<Duckmatic::Bezier>
+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[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
+#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
-
+ step = min(step,0.1); //10 is minimum
+
d = find_closest(curve,pos,step,&closest,&time);
#endif
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;
+
+ return 0;
}
if(!file)return false;
file<<"SKETCH"<<endl;
-
+
std::list<etl::handle<Stroke> >::const_iterator iter;
-
+
for(iter=persistant_stroke_list_.begin();iter!=persistant_stroke_list_.end();++iter)
{
file<<"C "
Duckmatic::load_sketch(const synfig::String& filename)
{
std::ifstream file(filename.c_str());
-
+
if(!file)
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':
break;
}
}
-
+
sketch_filename_=filename;
return true;
}
Duckmatic::Push::Push(Duckmatic *duckmatic_):
duckmatic_(duckmatic_)
{
- duck_map=duckmatic_->duck_map;
- bezier_list_=duckmatic_->bezier_list_;
+ 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_;
void
Duckmatic::Push::restore()
{
- duckmatic_->duck_map=duck_map;
- duckmatic_->bezier_list_=bezier_list_;
+ 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_;
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();
+ 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 GUID calc_duck_guid(const synfigapp::ValueDesc& x,const synfig::TransformStack& transform_stack)
{
GUID ret(0);
-
+
if(x.parent_is_layer_param())
{
ret=x.get_layer()->get_guid()^GUID::hasher(x.get_param_name());
}
ret^=transform_stack.get_guid();
- return ret;
+ return ret;
}
/*
{
GUID duck_guid(calc_duck_guid(value_desc,transform_stack)^GUID::hasher(modifier));
etl::handle<Duck> duck=new Duck();
-
+
return duck;
}
*/
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)
+#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_editable(true);
}
-
+
if(param_desc && param_desc!=REAL_COOKIE)
{
if(!param_desc->get_origin().empty())
0.0f
),
value_desc
- )
+ )
);
duck->set_guid(calc_duck_guid(value_desc,transform_stack)^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));
{
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()));
//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())
0.0f
),
value_desc
- )
+ )
);
duck->set_guid(calc_duck_guid(value_desc,transform_stack)^GUID::hasher(multiple));
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()));
//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)
{
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())
{
}
else
duck->set_type(Duck::TYPE_POSITION);
-
+
duck->set_scalar(param_desc->get_scalar());
}
else
{
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()))
)
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=last_duck();
bezier->c1->set_type(Duck::TYPE_TANGENT);
bezier->c1->set_origin(bezier->p1);
bezier->c1->set_scalar(0.33333333333333333);
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=last_duck();
bezier->c2->set_type(Duck::TYPE_TANGENT);
bezier->c2->set_origin(bezier->p2);
bezier->c2->set_scalar(-0.33333333333333333);
value_desc
)
);
-
+
add_bezier(bezier);
}
else if(value_desc.get_value().is_valid())
name=guid_string(value_desc);
}
- duck_p=new class Duck(segment.p1);
- duck_p->set_name(name+".P1");
+ duck_p=new class Duck(segment.p1);
+ duck_p->set_name(name+".P1");
duck_p->set_type(Duck::TYPE_VERTEX);
- add_duck(duck_p);
+ add_duck(duck_p);
- duck_c=new class Duck(segment.t1);
- duck_c->set_name(name+".T1");
+ duck_c=new class Duck(segment.t1);
+ duck_c->set_name(name+".T1");
duck_c->set_type(Duck::TYPE_TANGENT);
- add_duck(duck_c);
+ add_duck(duck_c);
duck_c->set_origin(duck_p);
duck_c->set_scalar(0.33333333333333333);
duck_c->set_tangent(true);
bezier->p1=duck_p;
bezier->c1=duck_c;
- duck_p=new class Duck(segment.p2);
- duck_p->set_name(name+".P2");
+ duck_p=new class Duck(segment.p2);
+ duck_p->set_name(name+".P2");
duck_p->set_type(Duck::TYPE_VERTEX);
- add_duck(duck_p);
+ add_duck(duck_p);
- duck_c=new class Duck(segment.t2);
+ duck_c=new class Duck(segment.t2);
duck_c->set_type(Duck::TYPE_TANGENT);
- duck_c->set_name(name+".T2");
- add_duck(duck_c);
+ duck_c->set_name(name+".T2");
+ add_duck(duck_c);
duck_c->set_origin(duck_p);
duck_c->set_scalar(-0.33333333333333333);
duck_c->set_tangent(true);
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());
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(-0.33333333333333333);
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()))
{
}
return true;
}
-
+
}
break;
case ValueBase::TYPE_LIST:
{
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()));
if(amount<0.9999f)
continue;
if(first==-1)first=i;
-
+
BLinePoint bline_point((*value_node->get_link(i))(get_time()));
-
+
ValueNode_Composite::Handle vertex_value_node(
ValueNode_Composite::Handle::cast_dynamic(
value_node->get_link(i)
)
);
-
+
// Add the vertex duck
if(vertex_value_node)
{
)
);
duck->set_value_desc(synfigapp::ValueDesc(value_node,i));
-
+
if(param_desc)
{
if(!param_desc->get_origin().empty())
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(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);
}
duck->set_guid(calc_duck_guid(synfigapp::ValueDesc(value_node,i),transform_stack)^GUID::hasher(".v"));
duck=add_similar_duck(duck);
-// add_duck(duck);
+// add_duck(duck);
}
// Add the width duck only if we have a hint of scale
else
synfig::error("Unable to add width duck!");
}
-
+
if(bezier)
{
// Add the tangent1 duck
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_name(strprintf("%x-tangent1",value_node->get_link(i).get()));
tduck->set_guid(calc_duck_guid(synfigapp::ValueDesc(value_node,i),transform_stack)^GUID::hasher(".t1"));
tduck=add_similar_duck(tduck);
// add_duck(duck);
tduck->set_origin(duck);
tduck->set_scalar(-0.33333333333333333);
tduck->set_tangent(true);
-
+
bezier->p2=duck;
bezier->c2=tduck;
add_bezier(bezier);
bezier=0;
}
-
+
if(i+1>=value_node->link_count() && !value_node->get_loop())
continue;
-
+
bezier=new Bezier();
-
+
// Add the tangent2 duck
if(vertex_value_node)
{
{
tduck=new Duck(bline_point.get_tangent2());
tduck->set_transform_stack(transform_stack);
- //tduck->set_name(strprintf("%x-tangent2",value_node->get_link(i).get()));
+ //tduck->set_name(strprintf("%x-tangent2",value_node->get_link(i).get()));
tduck->set_name(guid_string(synfigapp::ValueDesc(value_node,i))+".t2");
tduck->set_guid(calc_duck_guid(synfigapp::ValueDesc(value_node,i),transform_stack)^GUID::hasher(".t2"));
}
{
tduck=new Duck(bline_point.get_tangent1());
tduck->set_transform_stack(transform_stack);
- //tduck->set_name(strprintf("%x-tangent1",value_node->get_link(i).get()));
+ //tduck->set_name(strprintf("%x-tangent1",value_node->get_link(i).get()));
tduck->set_name(guid_string(synfigapp::ValueDesc(value_node,i))+".t1");
tduck->set_guid(calc_duck_guid(synfigapp::ValueDesc(value_node,i),transform_stack)^GUID::hasher(".t1"));
}
tduck->set_origin(duck);
tduck->set_scalar(0.33333333333333333);
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 vertex_value_node(
ValueNode_Composite::Handle::cast_dynamic(
value_node->get_link(first)
)
);
-
+
// Add the vertex duck
duck=first_duck;
/*
duck->set_origin(value_desc.get_layer()->get_param(param_desc->get_origin()).get(synfig::Point()));
}
duck->set_editable(false);
- duck->set_name(strprintf("%x-vertex",value_node->get_link(first).get()));
+ duck->set_name(strprintf("%x-vertex",value_node->get_link(first).get()));
duck->set_type(Duck::TYPE_VERTEX);
duck=add_similar_duck(duck);
}
*/
-
+
// Add the tangent1 duck
if(vertex_value_node)
{
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->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,i),transform_stack)^GUID::hasher(".t1"));
//add_duck(duck);
tduck->set_origin(duck);
tduck->set_scalar(-0.33333333333333333);
tduck->set_tangent(true);
-
+
bezier->p2=duck;
bezier->c2=tduck;
bezier->signal_user_click(2).connect(
add_bezier(bezier);
bezier=0;
-
+
}
return true;
}
- else // Check for DynamicList
+ 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;
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;
etl::handle<Duck> duck(last_duck());
-
+
if(param_desc)
{
synfigapp::ValueDesc value_desc_origin(value_desc.get_layer(),param_desc->get_origin());
{
// WRITEME
}
-
+
return true;
}
class CanvasView;
class Duckmatic;
-
+
class DuckDrag_Base : public etl::shared_object
{
public:
{
friend class DuckDrag_Base;
friend class DuckDrag_Translate;
-
+
/*
-- ** -- P U B L I C T Y P E S ---------------------------------------------
*/
-
+
public:
#ifdef HASH_MAP_H
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 ---------------------------------------------
*/
synfig::GUID last_duck_guid;
- std::list<etl::handle<Bezier> > bezier_list_;
+ std::list<etl::handle<Bezier> > bezier_list_;
//! I cannot recall what this is for
//synfig::Vector snap;
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 -----------------------------------------
*/
bool show_persistant_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;
*/
public:
-
+
Duckmatic();
virtual ~Duckmatic();
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_persistant_strokes()const { return show_persistant_strokes; }
void set_show_persistant_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; }
+
+ //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<Bezier> >& bezier_list()const { return bezier_list_; }
const std::list<etl::handle<Stroke> >& stroke_list()const { return stroke_list_; }
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 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 translate_selected_ducks(const synfig::Vector& vector);
bool end_duck_drag();
- void signal_edited_selected_ducks();
+ void signal_edited_selected_ducks();
+
+ void signal_user_click_selected_ducks(int button);
- 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_persistant_stroke(etl::smart_ptr<std::list<synfig::Point> > stroke_point_list, const synfig::Color& color=synfig::Color(0,0,0));
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_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 select_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_; }
class Duckmatic::Push
{
Duckmatic *duckmatic_;
- DuckMap duck_map;
+ 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();
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; }
private:
sigc::signal<void,float> signal_user_click_[5];
public:
-
+
etl::smart_ptr<std::list<synfig::Point> > stroke_data;
synfig::Color color;
cos_val(synfig::Angle::cos(angle).get())
{
}
-
+
synfig::Vector perform(const synfig::Vector& x)const
{
synfig::Point pos(x-origin);
/* === C L A S S E S & S T R U C T S ======================================= */
namespace studio {
-
+
class Transform_Translate : public synfig::Transform
{
private:
/* === 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_RIGHT,
BUTTON_UP,
BUTTON_DOWN,
-
+
BUTTON_END
};
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),
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),
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_STROKE,
- EVENT_END //!< Not a valid event
+ EVENT_END //!< Not a valid event
};
};
{
if(queued)
return;
-
+
//queue_refresh_connection.disconnect();
queue_refresh_connection=Glib::signal_idle().connect(
sigc::bind_return(
false
)
);
-
+
queued=true;
}
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(
// 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)
{
std::list<synfig::String>::iterator iter;
-
+
for(iter=selected_groups.begin();iter!=selected_groups.end();++iter)
{
param_list.add("group",(synfig::String)*iter);
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><menubar action='menu-main'><menu action='menu-group'>"+ui_info+"</menu></menubar></ui>";
LayerGroupTreeStore::Model model;
String group_name;
-
+
Gtk::TreeIter selected_iter;
-
+
if(group_tree_->get_selection()->count_selected_rows())
{
selected_iter=(
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);
}
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:
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);
+ 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);
- }
+ insert_action(*(append()),*iter,true,false,true);
+ }
}
void
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();
+ row[model.canvas_id] = specific_action->get_canvas()->get_id();
}
etl::handle<synfigapp::Action::Group> group;
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);
+
+ //row[model.icon] = Gtk::Button().render_icon(Gtk::StockID("synfig-canvas"),Gtk::ICON_SIZE_SMALL_TOOLBAR);
}
{
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;
{
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;
{
Gtk::TreeModel::Children::iterator iter;
Gtk::TreeModel::Children children_(children());
-
+
for(iter=children_.begin(); iter != children_.end(); ++iter)
{
Gtk::TreeModel::Row row = *iter;
row[model.is_active]=action->is_active();
return;
}
- }
+ }
}
namespace studio {
class Instance;
-
+
class HistoryTreeStore : virtual public Gtk::TreeStore
{
/*
*/
public:
-
+
const Model model;
/*
private:
etl::loose_handle<studio::Instance> instance_;
- Gtk::TreeIter curr_row;
+ Gtk::TreeIter curr_row;
/*
-- ** -- 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_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);
*/
public:
-
+
HistoryTreeStore(etl::loose_handle<studio::Instance> instance_);
~HistoryTreeStore();
public:
static Glib::RefPtr<HistoryTreeStore> create(etl::loose_handle<studio::Instance> instance);
-
+
}; // END of class HistoryTreeStore
}; // END of namespace studio
if(synfig_root) {
path_to_icons=synfig_root;
path_to_icons+=ETL_DIRECTORY_SEPERATOR;
-
+
path_to_icons+="share/pixmaps";
}
path_to_icons+=ETL_DIRECTORY_SEPERATOR;
{
synfig::warning("Unable to open "+path_to_icons+"synfig_icon."+IMAGE_EXT);
}
-
+
/*
#define INIT_STOCK_ICON(name,iconfile,desc) \
stock_##name=Gtk::StockItem(Gtk::StockID("synfig-" #name),desc); \
#define INIT_STOCK_ITEM(name,desc) \
stock_##name=Gtk::StockItem(Gtk::StockID("synfig-" #name),desc); \
- Gtk::Stock::add(stock_##name);
+ Gtk::Stock::add(stock_##name);
INIT_STOCK_ICON(swap_colors,"swap_colors_icon."IMAGE_EXT,_("Swap Colors"));
INIT_STOCK_ICON(canvas,"canvas_icon."IMAGE_EXT,_("Canvas"));
INIT_STOCK_ICON(mirror,"mirror_icon."IMAGE_EXT,_("Mirror Tool"));
icon_factory->add_default();
-
+
Gtk::IconSize::register_new("synfig-small_icon",12,12);
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);
);
*/
DEBUGPOINT();
-
+
Gdk::Color FG("#000000");
Gdk::Color BG("#FF00FF");
-
+
DEBUGPOINT();
return Gdk::Cursor(pixmap, pixmap, FG, BG, 0, 0);
}
}
else
{
- return Gtk::StockID("synfig-value_node");
+ return Gtk::StockID("synfig-value_node");
}
}
else if(action.task=="set_off") stock_id=Gtk::Stock::NO;
else if(action.task=="remove") stock_id=Gtk::Stock::DELETE;
else stock_id=Gtk::StockID("synfig-"+action.task);
-
+
return stock_id;
}
canvas_tree_store_=Gtk::TreeStore::create(model);
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)));
)
)
);
-
+
canvas_tree_store_=Gtk::TreeStore::create(canvas_tree_model);
-
+
refresh_canvas_tree();
}
// 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;
+
+ return instance;
}
handle<CanvasView>
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);
}
}
return synfigapp::Instance::save();
-
+
}
void
studio::Instance::dialog_save_as()
{
string filename="*.sif";
-
+
Canvas::Handle canvas(get_canvas());
-
+
{
OneMoment one_moment;
std::set<Node*>::iterator iter;
"files that are currently open. Close these\n"
"other files first before trying to use \"SaveAs\"."
);
-
+
return;
}
if(parent_layer)
}
}
}
-
+
while(App::dialog_saveas_file("SaveAs", filename))
{
// If the filename still has wildcards, then we should
{
continue;
}
-
+
if(save_as(filename))
break;
-
+
App::dialog_error_blocking("SaveAs - Error","Unable to save file");
}
}
-
+
void
Instance::update_all_titles()
{
}
}
-
+
void
Instance::insert_canvas(Gtk::TreeRow row,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.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] = canvas->get_id();
else
if(!canvas->get_name().empty())
- row[canvas_tree_model.label] = canvas->get_name();
+ row[canvas_tree_model.label] = canvas->get_name();
else
- row[canvas_tree_model.label] = _("[Unnamed]");
-
+ 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);
}
if(!App::dialog_entry(_("CVS Commit"),_("Enter a log message describing the changes you have made"), message))
return;
-
+
OneMoment one_moment;
cvs_commit(message);
}
try
{
string message;
-
+
//if(!App::dialog_entry(_("CVS Add"),_("Enter a log message describing the file"), message))
// return;
OneMoment one_moment;
App::dialog_error_blocking(_("Info"),_("This file is up-to-date"));
return;
}
-
+
try
{
String filename(get_file_name());
OneMoment one_moment;
time_t oldtime=get_original_timestamp();
cvs_update();
- calc_repository_info();
+ calc_repository_info();
// If something has been updated...
if(oldtime!=get_original_timestamp())
{
String filename(instance->get_file_name());
Canvas::Handle canvas(instance->get_canvas());
-
+
instance->close();
if(canvas->count()!=1)
one_moment.show();
}
canvas=0;
-
+
App::open(filename);
}
if(answer==synfigapp::UIInterface::RESPONSE_CANCEL)
return false;
}
-
+
close();
return true;
{
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("Action CandidateList is empty!");
-
+
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(
{
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("Action CandidateList is empty!");
-
+
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);
-
+
/*
if(iter->task=="raise")
Gtk::Stock::lookup(Gtk::Stock::GO_UP,Gtk::ICON_SIZE_MENU,*image);
{
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())
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))
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()))
}
}
}
-
+
if(!action->is_ready())
{
synfig::error("Action not ready");
Instance::make_param_menu(Gtk::Menu *menu,synfig::Canvas::Handle canvas, synfigapp::ValueDesc value_desc, float location)
{
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);
param_list2.add("origin",location);
}
-
+
// Populate the convert menu by looping through
// the ValueNode book and find the ones that are
// relevant.
}
}
- parammenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::CONVERT,*convert_menu));
+ parammenu.items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::CONVERT,*convert_menu));
}
if(param_list2.empty())
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
{
WaypointList::iterator iter(value_node->find(canvas->get_time()));
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();
-
+
DEBUGPOINT();
if(dialog.run()==0 || widget_waypoint_model.get_waypoint_model().is_trivial())
return;
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.
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("value_desc_connect");
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"));
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("waypoint_set_smart"));
if(!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("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;
}
-
+
}
}
namespace studio {
class CanvasView;
-
+
class Instance : public synfigapp::Instance
{
Gtk::TreeModelColumn<bool> is_editable;
Gtk::TreeModelColumn<synfigapp::ValueDesc> value_desc;
-
+
CanvasTreeModel()
{
add(value);
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"
//! List of canvas view windows
CanvasViewList canvas_view_list_;
-
+
bool undo_status_;
bool redo_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_; }
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)const;
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();
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;
if(connected)
do {
String data;
- char c;
+ char c;
do
{
success= ReadFile(
cmd_queue.push_back(data);
cmd_dispatcher->emit();
} while(success && read_bytes);
-
+
CloseHandle(pipe_handle);
}
}
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);
else
{
file=SmartFILE(fdopen(fd,"r"));
-
+
Glib::signal_io().connect(
sigc::mem_fun(this,&IPC::fifo_activity),
fd,
// fclose(file.get());
remove(fifo_path().c_str());
-
+
//if(fd>=0)
// close(fd);
}
IPC::fifo_activity(Glib::IOCondition cond)
{
synfig::info(__FILE__":%d: fifo activity",__LINE__);
-
+
if(cond&(Glib::IO_ERR|Glib::IO_HUP|Glib::IO_NVAL))
{
if(cond&(Glib::IO_ERR))
command+=tmp;
} while(tmp!='\n');
}
-
+
process_command(command);
return true;
}
{
if(command_line.empty())
return false;
-
+
char cmd=command_line[0];
-
+
String args(command_line.begin()+1,command_line.end());
while(!args.empty() && args[0]==' ') args.erase(args.begin());
while(!args.empty() && args[args.size()-1]=='\n' || args[args.size()-1]==' ') args.erase(args.end()-1);
-
+
switch(toupper(cmd))
{
case 'F': // Focus/Foreground
synfig::warning("Received unknown command '%c' with arg '%s'",cmd,args.c_str());
break;
}
-
+
return true;
}
NULL, // security attributes
OPEN_EXISTING, // creation disposition
FILE_ATTRIBUTE_NORMAL, // flags and attributes
- NULL // template file
+ NULL // template file
);
if(pipe_handle==INVALID_HANDLE_VALUE)
{
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"));
static bool process_command(const synfig::String& cmd);
}; // END of class IPC
-
+
}; // END of namespace studio
/* === E N D =============================================================== */
{
if(queued)
return;
-
+
//queue_refresh_connection.disconnect();
queue_refresh_connection=Glib::signal_idle().connect(
sigc::bind_return(
false
)
);
-
+
queued=true;
}
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()));
KeyframeActionManager::refresh()
{
KeyframeTreeStore::Model model;
-
+
if(queued)
{
queued=false;
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());
{
action_group_->remove(action_group_->get_action("action-keyframe_add"));
}
-
+
action_group_->add(Gtk::Action::create(
"action-keyframe_add",
Gtk::StockID("gtk-add"),
),
sigc::mem_fun(*this,&KeyframeActionManager::on_add_keyframe)
);
-
+
try
{
canvas_interface_->get_canvas()->keyframe_list().find(canvas_interface_->get_time());
catch(...)
{
}
-
+
{
Glib::RefPtr<Gtk::Action> action(Gtk::Action::create("keyframe-properties", Gtk::StockID("gtk-properties"), _("Keyframe Properties")));
action_group_->add(action,sigc::mem_fun(*this,&KeyframeActionManager::on_keyframe_properties));
}
ui_info="<ui><menubar action='menu-main'><menu action='menu-keyframe'>"+ui_info+"</menu></menubar></ui>";
- popup_id_=get_ui_manager()->add_ui_from_string(ui_info);
+ popup_id_=get_ui_manager()->add_ui_from_string(ui_info);
#ifdef ONE_ACTION_GROUP
#else
get_ui_manager()->insert_action_group(action_group_);
class KeyframeActionManager
{
sigc::signal<void> signal_show_keyframe_properties_;
-
+
Glib::RefPtr<Gtk::UIManager> ui_manager_;
//Glib::RefPtr<Gtk::TreeSelection> tree_selection_;
KeyframeTree* keyframe_tree_;
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_; }
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();
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();
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_sort_column_id(COLUMNID_JUMP);
column->set_clickable(false);
//append_column_editable(_("Description"),model.description);
{
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);
// 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);
}
{
keyframe_tree_store_=keyframe_tree_store;
KeyframeTreeStore::Model model;
-
+
if(true)
{
Glib::RefPtr<Gtk::TreeModelSort> sorted_store(Gtk::TreeModelSort::create(keyframe_tree_store_));
}
else
Gtk::TreeView::set_model(keyframe_tree_store);
-
+
keyframe_tree_store_->canvas_interface()->signal_rend_desc_changed().connect(
sigc::mem_fun(
*this,
KeyframeTree::set_editable(bool x)
{
editable_=x;
-
+
if(editable_)
{
cell_renderer_time->property_editable()=true;
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())
{
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;
}
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())
)
) 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)
{
)
) 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:
COLUMNID_TIME,
COLUMNID_DESCRIPTION,
COLUMNID_JUMP,
-
+
COLUMNID_END //!< \internal
};
*/
public:
-
+
KeyframeTreeStore::Model model;
-
+
/*
-- ** -- P R I V A T E D A T A ---------------------------------------------
*/
*/
private:
-
+
/*
-- ** -- S I G N A L T E R M I N A L 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_; }
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;
}
*/
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)
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_; }
};
if(!gtype_)
{
class_init_func_ = &KeyframeTreeStore_Class::class_init_function;
-
+
const GTypeInfo derived_info =
{
sizeof(GObjectClass),
0,
NULL
};
-
+
gtype_ = g_type_register_static(G_TYPE_OBJECT, "KeyframeTreeStore", &derived_info, GTypeFlags(0));
Gtk::TreeModel::add_interface(get_type());
}
{
Gtk::TreeModel::Children::iterator iter;
const Gtk::TreeModel::Children children(children());
- path_table_.clear();
+ path_table_.clear();
for(iter = children.begin(); iter != children.end(); ++iter)
{
Gtk::TreeModel::Row row(*iter);
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;
}
_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())
{
//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("keyframe_set_delta"));
-
+
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
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("keyframe_set"));
-
+
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())
keyframe.set_description(x.get());
synfigapp::Action::Handle action(synfigapp::Action::create("keyframe_set"));
-
+
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())
catch(std::exception x)
{
g_warning(x.what());
- }
+ }
}
Gtk::TreeModelFlags
return false;
_keyframe_iterator *next(new _keyframe_iterator());
- iter_next.gobj()->user_data=static_cast<gpointer>(next);
+ iter_next.gobj()->user_data=static_cast<gpointer>(next);
next->ref_count=1;
next->index=iter->index+1;
next->iter=iter->iter;
if(next->iter==canvas_interface()->get_canvas()->keyframe_list().end())
return false;
-
- iter_next.gobj()->stamp=stamp_;
+
+ iter_next.gobj()->stamp=stamp_;
return true;
}
// 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);
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_;
+ gtk_iter->stamp=stamp_;
- return true;
+ return true;
}
bool
if(parent)
return 0;
-
+
return canvas_interface()->get_canvas()->keyframe_list().size();
}
*/
}
++iter->iter;
}
- xiter.gobj()->user_data=static_cast<gpointer>(iter);
- xiter.gobj()->stamp=stamp_;
+ xiter.gobj()->user_data=static_cast<gpointer>(iter);
+ xiter.gobj()->stamp=stamp_;
return true;
}
}
-
+
_keyframe_iterator *iter(new _keyframe_iterator());
iter->ref_count=1;
iter->index=n;
}
++iter->iter;
}
-
+
gtk_iter->user_data=static_cast<gpointer>(iter);
- gtk_iter->stamp=stamp_;
+ gtk_iter->stamp=stamp_;
return true;
}
if(!iter->ref_count)
{
delete iter;
-
+
// Make this iterator invalid
gtk_iter->stamp=0;
}
return path;
_keyframe_iterator *iter(static_cast<_keyframe_iterator*>(gtk_iter->gobj()->user_data));
-
+
path.append_index(iter->index);
return path;
{
Glib::Value<synfig::Time> x;
g_value_init(x.gobj(),x.value_type());
-
+
synfig::Keyframe prev_keyframe(*iter->iter);
synfig::Keyframe keyframe;
{
}
keyframe=*tmp;
}
-
+
Time delta(0);
try {
delta=keyframe.get_time()-prev_keyframe.get_time();
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++;
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();
catch(std::exception x)
{
g_warning(x.what());
- }
+ }
}
void
try
{
if(1)
- {
+ {
Gtk::TreeRow row(find_row(keyframe));
dump_iterator(row,"remove_keyframe,row");
Gtk::TreePath path(get_path(row));
{
DEBUGPOINT();
g_warning(x.what());
- }
+ }
}
void
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)
{
DEBUGPOINT();
{
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);
+ row_changed(get_path(row),row);
}
catch(std::exception x)
{
DEBUGPOINT();
g_warning(x.what());
- }
+ }
}
namespace studio {
class KeyframeTreeStore_Class;
-
+
class KeyframeTreeStore :
public Glib::Object,
public Gtk::TreeModel,
Gtk::TreeModelColumn<Glib::ustring> description;
Gtk::TreeModelColumn<synfig::Keyframe> keyframe;
Gtk::TreeModelColumn<synfig::Time> time_delta;
-
+
Model()
{
add(time);
*/
public:
-
+
const Model model;
/*
//! Unique stamp for this TreeModel.
int stamp_;
-
+
static KeyframeTreeStore_Class keyframe_tree_store_class_;
//std::map<synfig::Keyframe,TreeRowReferenceHack> path_table_;
** constructed or when large numbers of
** iterators become invalid. */
void reset_stamp();
-
+
//void reset_path_table();
/*
*/
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 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 -------------------------------------
*/
*/
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(); }
{
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
*key = AccelKey(ac.accel_key,(Gdk::ModifierType)ac.accel_mods,string(path));
return true;
}
-
+
return false;
}
{
string n(filename);
n += ".skm";
-
+
AccelMap::load(filename);
-
- return true;
+
+ return true;
}
bool KeyMapSettings::save(const char *filename)
{
string n(filename);
n += ".skm";
-
+
AccelMap::save(filename);
-
+
return true;
}
{
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);
&LayerActionManager::paste
)
);
-
-
+
+
action_amount_inc_=Gtk::Action::create(
"amount-inc",
Gtk::StockID("gtk-add"),
{
if(queued)
return;
-
+
//queue_refresh_connection.disconnect();
queue_refresh_connection=Glib::signal_idle().connect(
sigc::bind_return(
false
)
);
-
+
queued=true;
}
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;
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(
sigc::mem_fun(*this, &LayerActionManager::queue_refresh)
)
);
-
+
if(!canvas_set)
{
param_list.add("canvas",Canvas::Handle((*iter)->get_canvas()));
param_list.add("layer",Layer::Handle(*iter));
}
}
-
+
if(!multiple_selected && layer->get_name()=="PasteCanvas")
{
action_group_->add(Gtk::Action::create(
add_actions_to_group(action_group_, ui_info, param_list, synfigapp::Action::CATEGORY_LAYER);
}
}
-
+
ui_info="<ui><menubar action='menu-main'><menu action='menu-layer'>"+ui_info+"<separator/><menuitem action='cut' /><menuitem action='copy' /><menuitem action='paste' /><separator/></menu></menubar></ui>";
- popup_id_=get_ui_manager()->add_ui_from_string(ui_info);
+ popup_id_=get_ui_manager()->add_ui_from_string(ui_info);
#ifdef ONE_ACTION_GROUP
#else
get_ui_manager()->insert_action_group(action_group_);
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));
}
action_paste_->set_sensitive(!clipboard_.empty());
-
+
//queue_refresh();
}
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("layer_add"));
-
+
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;
}
-
+
synfig::info("DEPTH=%d",depth);
// Action to move the layer (if necessary)
if(depth>0)
{
synfigapp::Action::Handle action(synfigapp::Action::create("layer_move"));
-
+
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"));
+ //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"));
+ //get_ui_interface()->error(_("Move Action Not Ready"));
//return 0;
return;
}
- }
+ }
depth++;
}
get_canvas_interface()->get_selection_manager()->clear_selected_layers();
LayerActionManager::amount_inc()
{
float adjust(0.1);
-
+
// Create the action group
synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Decrease Amount"));
-
+
if(adjust>0)
group.set_name(_("Increase Amount"));
LayerActionManager::amount_dec()
{
float adjust(-0.1);
-
+
// Create the action group
synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Decrease Amount"));
-
+
if(adjust>0)
group.set_name(_("Increase Amount"));
Glib::RefPtr<Gtk::ActionGroup> action_group_;
Gtk::UIManager::ui_merge_id popup_id_;
-
+
Glib::RefPtr<Gtk::ActionGroup> action_group_copy_paste;
std::list<synfig::Layer::Handle> clipboard_;
-
+
sigc::connection selection_changed_connection;
bool queued;
{
const LayerGroupTreeStore::Model model;
-
+
{ // --- O N / O F F ----------------------------------------------------
int index;
index=append_column_editable(_(" "),model.active);
//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);
// 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);
{
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_));
LayerGroupTree::set_editable(bool x)
{
editable_=x;
-/*
+/*
if(editable_)
{
cell_renderer_time->property_editable()=true;
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())
{
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;
}
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())
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)
{
)
) break;
const Gtk::TreeRow row = *(get_model()->get_iter(path));
-
+
LayerList layer_list(row[model.all_layers]);
if(!layer_list.empty())
{
*/
public:
-
+
LayerGroupTreeStore::Model model;
-
+
/*
-- ** -- P R I V A T E D A T A ---------------------------------------------
*/
*/
private:
-
+
/*
-- ** -- S I G N A L T E R M I N A L S -------------------------------------
*/
*/
public:
-
+
LayerGroupTree();
~LayerGroupTree();
void set_cursor(const Gtk::TreeModel::Path& path, bool start_editing=false);
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;
+ LayerList get_selected_layers()const;
}; // END of LayerGroupTree
}; // END of namespace studio
Glib::ustring substr(x.uppercase());
Glib::ustring label((*iter)[model.label]);
label=label.uppercase();
-
+
return label.find(substr)==Glib::ustring::npos;
}
{
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])
layer_list.push_back((Layer::Handle)(*iter)[model.layer]);
x.set(layer_list);
}
-
+
g_value_init(value.gobj(),x.value_type());
value=x;
}
{
Glib::Value<LayerList> x;
g_value_init(x.gobj(),x.value_type());
-
+
if((bool)(*iter)[model.is_group])
{
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;
}
{
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());
-
-
+
+
if(!layer->get_description().empty())
x.set(layer->get_description());
else
x.set(layer->get_local_name());
-
+
g_value_init(value.gobj(),x.value_type());
//g_value_copy(x.gobj(),value.gobj());
value=x;
x.set(layer->get_local_name());
-
+
g_value_init(value.gobj(),x.value_type());
//g_value_copy(x.gobj(),value.gobj());
value=x;
x.set(layer->get_canvas());
-
+
g_value_init(value.gobj(),x.value_type());
//g_value_copy(x.gobj(),value.gobj());
value=x;
}
else
x.set(false);
-
+
g_value_init(value.gobj(),x.value_type());
g_value_copy(x.gobj(),value.gobj());
}
}
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());
}
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("layer_set_desc"));
-
+
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;
}
{
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)
{
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
else
{
synfigapp::Action::Handle action(synfigapp::Action::create("group_rename"));
-
+
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;
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("layer_activate"));
-
+
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;
}
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);
}
}
catch(std::exception x)
{
g_warning(x.what());
- }
+ }
}
{
//if(!get_iter(path)) return false;
// Gtk::TreeModel::Row row(*get_iter(path));
-
+
return true;
// return (bool)true;
}
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;
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 true;
}
-
+
return false;
}
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)
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());
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("group_add_layers"));
-
+
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);
{
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))
{
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("group_rename"));
-
+
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();
{
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);
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())
{
dest_layer_depth--;
if(dest_canvas==src->get_canvas() && dest_layer_depth==src->get_depth())
continue;
-
+
synfigapp::Action::Handle action(synfigapp::Action::create("layer_move"));
action->set_param("canvas",dest_canvas);
action->set_param("canvas_interface",canvas_interface());
// Reselect the previously selected layers
canvas_interface()->get_selection_manager()->set_selected_layers(selected_layer_list);
-
+
return ret;
*/
return false;
rebuilding=true;
etl::clock timer;timer.reset();
try {
-
+
// Clear out the current list
clear();
Canvas::Handle canvas(canvas_interface()->get_canvas());
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 and add all the layers
/*std::for_each(
canvas_interface()->get_canvas()->rbegin(), canvas_interface()->get_canvas()->rend(),
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();
}
if(find_group_row(group, iter))
return *iter;
}
-
+
if(group.find(GROUP_NEST_CHAR)!=String::npos)
{
Gtk::TreeModel::Children::iterator iter;
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())));
LayerGroupTreeStore::on_group_removed(synfig::String group)
{
//DEBUGPOINT();
-
+
Gtk::TreeModel::Children::iterator iter;
if(find_group_row(group,iter) && iter->children().size()==0)
erase(iter);
else
return false;
-
+
return true;
}
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();
}
if(find_layer_row(handle,iter))
{
Gtk::TreeRow row(*iter);
-
- Layer::Handle layer(row[model.layer]);
-
+
+ Layer::Handle layer(row[model.layer]);
+
if(desc.empty())
{
//row[model.label]=layer->get_local_name();
//row[model.label]=layer->get_description();
row[model.tooltip]=layer->get_local_name();
}
- else
+ else
{
rebuild();
}
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++)
if((bool)row[model.is_layer] && layer==(synfig::Layer::Handle)row[model.layer])
return true;
}
-
+
iter=children().end();
//DEBUGPOINT();
//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;
}
if((bool)row[model.is_group] && group==(Glib::ustring)row[model.group_name])
return true;
}
-
+
iter=children().end();
//DEBUGPOINT();
//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;
}
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<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);
*/
public:
-
+
//! TreeModel for the layers
const Model model;
-
+
bool rebuilding;
/*
*/
public:
-
+
LayerGroupTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
~LayerGroupTreeStore();
*/
public:
-
+
static Glib::RefPtr<LayerGroupTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
}; // END of class LayerGroupTreeStore
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();
}
synfig::error("LayerParamTreeStore::get_value_vfunc(): Bad column!");
return;
}
-
+
/* if(column==model.label.index())
{
synfig::Layer::Handle layer((*iter)[model.layer]);
x.set(layer->get_description());
else
x.set(layer->get_local_name());
-
+
g_value_init(value.gobj(),x.value_type());
g_value_copy(x.gobj(),value.gobj());
}
{
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());
}
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());
}
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());
}
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;
}
}
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("layer_activate"));
-
+
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;
}
catch(std::exception x)
{
g_warning(x.what());
- }
+ }
}
if(queued)queued=false;
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());
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(ParamVocab x)
{
ParamVocab::iterator iter;
-
+
for(iter=vocab.begin();iter!=vocab.end();++iter)
{
ParamVocab::iterator iter2(find_param_desc(x,iter->get_name()));
}
}
}
-
+
} rebuild_helper;
-
+
{
LayerList::iterator iter(layer_list.begin());
rebuild_helper.vocab=(*iter)->get_param_vocab();
-
+
for(++iter;iter!=layer_list.end();++iter)
{
rebuild_helper.process_vocab((*iter)->get_param_vocab());
);
}
}
-
+
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())
{
row[model.is_inconsistent] = true;
while(!row.children().empty() && erase(row.children().begin()));
break;
- }
+ }
}
- }
+ }
}
void
LayerParamTreeStore::refresh()
{
if(queued)queued=false;
-
+
Gtk::TreeModel::Children children_(children());
-
+
Gtk::TreeModel::Children::iterator iter;
-
+
if(!children_.empty())
for(iter = children_.begin(); iter && iter != children_.end(); ++iter)
{
{
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)
row[model.is_inconsistent] = true;
while(!row.children().empty() && erase(row.children().begin()));
return;
- }
+ }
}
}
namespace studio {
class LayerTree;
-
+
class LayerParamTreeStore : public CanvasTreeStore
{
/*
*/
public:
-
+
//! TreeModel for the layer parameters
class Model : public CanvasTreeStore::Model
{
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_;
*/
public:
-
+
LayerParamTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_,
LayerTree* layer_tree);
~LayerParamTreeStore();
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
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->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);
+ 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_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);
{
const LayerTreeStore::Model model;
-
+
{ // --- O N / O F F ----------------------------------------------------
//int index;
//index=get_layer_tree_view().append_column_editable(_(" "),layer_model.active);
// 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));
+ 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;
//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);
// Set up the icon cell-renderer
Gtk::CellRendererText* cellrenderer = Gtk::manage( new Gtk::CellRendererText() );
- cellrenderer->signal_edited().connect(sigc::mem_fun(*this, &studio::LayerTree::on_layer_renamed));
+ cellrenderer->signal_edited().connect(sigc::mem_fun(*this, &studio::LayerTree::on_layer_renamed));
cellrenderer->property_editable()=true;
-
+
column->pack_start(*cellrenderer,false);
column->add_attribute(cellrenderer->property_text(), layer_model.label);
get_layer_tree_view().append_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);
// 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();
//scroll->add(get_layer_tree_view());
scroll->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
scroll->show();
-
+
return scroll;
}
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(_("Param")) );
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() );
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
+ // Finish setting up the column
column->set_reorderable();
column->set_resizable();
column->set_clickable();
-
+
param_tree_view().append_column(*column);
}
{ // --- V A L U E -----------------------------------------------------
Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("ValueBase")) );
-
+
// 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));
/*{ // --- 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;
//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();
}*/
-
+
// This makes things easier to read.
param_tree_view().set_rules_hint();
-
+
// Make us more sensitive to several events
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);
-
+
param_tree_view().signal_event().connect(sigc::mem_fun(*this, &studio::LayerTree::on_param_tree_event));
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->show();
//column_time_track->set_visible(false);
-
+
return scroll;
}
{
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--)
{
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_=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_id(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(
¶m_tree_view(),
param_tree_store_=LayerParamTreeStore::create(layer_tree_store_->canvas_interface(), this);
param_tree_view().set_model(param_tree_store_);
}
-
+
/* if(cellrenderer_time_track && layer_tree_store_ && layer_tree_store_->canvas_interface())
{
cellrenderer_time_track->set_canvas_interface(layer_tree_store_->canvas_interface());
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))
{
last_top_selected_layer=0;
}
}
-
-
+
+
if(layer_list.empty())
{
button_raise->set_sensitive(false);
button_lower->set_sensitive(true);
button_duplicate->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_as(Real()))
{
quick_layer=*layer_list.begin();
}
else
quick_layer=0;
-
+
if(quick_layer)
{
layer_amount_hscale->set_sensitive(true);
disable_amount_changed_signal=false;
}
else
- blend_method_widget.set_sensitive(false);
+ blend_method_widget.set_sensitive(false);
}
else
{
- layer_amount_hscale->set_sensitive(false);
+ layer_amount_hscale->set_sensitive(false);
blend_method_widget.set_sensitive(false);
}
}
return;
if(!quick_layer)
return;
-
+
if(quick_layer->get_param("blend_method").is_valid())
{
disable_amount_changed_signal=true;
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;
LayerTree::on_edited_value(const Glib::ustring&path_string,synfig::ValueBase value)
{
Gtk::TreePath path(path_string);
-
+
const Gtk::TreeRow row = *(param_tree_view().get_model()->get_iter(path));
if(!row)
return;
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;
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;
+ row[layer_model.active]=!active;
}
void
LayerTree::on_waypoint_clicked(const Glib::ustring &path_string, synfig::Waypoint waypoint,int button)
{
Gtk::TreePath path(path_string);
-
+
const Gtk::TreeRow row = *(param_tree_view().get_model()->get_iter(path));
if(!row)
return;
-
+
signal_waypoint_clicked()(static_cast<synfigapp::ValueDesc>(row[param_model.value_desc]),waypoint,button);
}
)
) break;
const Gtk::TreeRow row = *(get_layer_tree_view().get_model()->get_iter(path));
-
+
//if(column->get_first_cell_renderer()==cellrenderer_time_track)
// return signal_layer_user_click()(event->button.button,row,COLUMNID_TIME_TRACK);
//else
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;
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));
-
+
/*
if(cellrenderer_time_track==column->get_first_cell_renderer())
{
)
) break;
const Gtk::TreeRow row = *(param_tree_view().get_model()->get_iter(path));
-
+
/* if(column && column->get_first_cell_renderer()==cellrenderer_time_track)
{
Gdk::Rectangle rect;
return true;
//return signal_param_user_click()(event->button.button,row,COLUMNID_TIME_TRACK);
}
- else
+ else
*/ {
if(event->button.button==3)
{
if(layer_list.size()<=1)
{
synfigapp::ValueDesc value_desc(row[param_model.value_desc]);
- Gtk::Menu* menu(manage(new Gtk::Menu()));
+ Gtk::Menu* menu(manage(new Gtk::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()));
+ Gtk::Menu* menu(manage(new Gtk::Menu()));
std::list<synfigapp::ValueDesc> value_desc_list;
ParamDesc param_desc(row[param_model.param_desc]);
for(;!layer_list.empty();layer_list.pop_back())
}
}
break;
-
+
case GDK_MOTION_NOTIFY:
{
Gtk::TreeModel::Path path;
cell_x,cell_y //int&cell_x,int&cell_y
)
) break;
-
+
if(!param_tree_view().get_model()->get_iter(path))
break;
-
+
Gtk::TreeRow row = *(param_tree_view().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;
cell_x,cell_y //int&cell_x,int&cell_y
)
) break;
-
+
if(!param_tree_view().get_model()->get_iter(path))
break;
-
+
Gtk::TreeRow row = *(param_tree_view().get_model()->get_iter(path));
-
+
/* if(column && cellrenderer_time_track==column->get_first_cell_renderer())
{
Gdk::Rectangle rect;
param_tree_view().queue_draw();
param_tree_view().queue_draw_area(rect.get_x(),rect.get_y(),rect.get_width(),rect.get_height());
return true;
-
+
}
*/
}
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));
}
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("layer_lower"));
action->set_param_list(param_list);
layer_tree_store_->canvas_interface()->get_instance()->perform_action(action);
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("layer_duplicate"));
action->set_param_list(param_list);
layer_tree_store_->canvas_interface()->get_instance()->perform_action(action);
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("layer_remove"));
action->set_param_list(param_list);
layer_tree_store_->canvas_interface()->get_instance()->perform_action(action);
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;
}
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]);
}
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("layer_move"));
action->set_param("canvas",dest_canvas);
action->set_param("canvas_interface",layer_tree_store_->canvas_interface());
}
}while(0);
}
-
+
// Finish the drag
context->drag_finish(success, false, time);
}
{
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))
/* === C L A S S E S & S T R U C T S ======================================= */
-namespace Gtk { class TreeModelSort; };
+namespace Gtk { class TreeModelSort; };
namespace studio {
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;
Gtk::TreeView* param_tree_view_;
-
+
Gtk::HBox *hbox;
Glib::RefPtr<LayerTreeStore> layer_tree_store_;
Glib::RefPtr<LayerParamTreeStore> param_tree_store_;
-
+
Glib::RefPtr<Gtk::TreeModelSort> sorted_layer_tree_store_;
// CellRenderer_TimeTrack *cellrenderer_time_track;
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 -------------------------------------
*/
void on_blend_method_changed();
public:
-
+
void on_raise_pressed();
void on_lower_pressed();
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();
sigc::signal<void,synfigapp::ValueDesc,synfig::Waypoint,int>& signal_waypoint_clicked() { return signal_waypoint_clicked_; }
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);
//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::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)
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]);
}
Glib::ustring substr(x.uppercase());
Glib::ustring label((*iter)[model.label]);
label=label.uppercase();
-
+
return label.find(substr)==Glib::ustring::npos;
}
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());
}
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());
}
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_as(bool()))
x.set(v.get(bool()));
-
+
g_value_init(value.gobj(),x.value_type());
g_value_copy(x.gobj(),value.gobj());
}
x.set(layer->get_description());
else
x.set(layer->get_local_name());
-
+
g_value_init(value.gobj(),x.value_type());
//g_value_copy(x.gobj(),value.gobj());
value=x;
x.set(layer->get_local_name());
-
+
g_value_init(value.gobj(),x.value_type());
//g_value_copy(x.gobj(),value.gobj());
value=x;
x.set(layer->get_canvas());
-
+
g_value_init(value.gobj(),x.value_type());
//g_value_copy(x.gobj(),value.gobj());
value=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());
}
//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());
}
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("layer_set_desc"));
-
+
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;
}
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("layer_activate"));
-
+
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;
}
catch(std::exception x)
{
g_warning(x.what());
- }
+ }
}
{
//if(!get_iter(path)) return false;
// Gtk::TreeModel::Row row(*get_iter(path));
-
+
return true;
// return (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;
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;
//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)
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();
{
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))
{
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())
{
// dest_layer_depth--;
if(dest_canvas==src->get_canvas() && dest_layer_depth==src->get_depth())
continue;
-
+
synfigapp::Action::Handle action(synfigapp::Action::create("layer_move"));
action->set_param("canvas",dest_canvas);
action->set_param("canvas_interface",canvas_interface());
continue;
}
/*else // In this case we need to remove and then add
- {
-
+ {
+
synfigapp::Action::Handle action;
action=synfigapp::Action::create("layer_remove");
action->set_param("canvas",Canvas::Handle(src->get_canvas()));
ret=false;
return false;
}
- }
+ }
ret=true;
}
*/
// Reselect the previously selected layers
canvas_interface()->get_selection_manager()->set_selected_layers(selected_layer_list);
-
+
return ret;
}
// Clear out the current list
clear();
-
+
// Go ahead and and add all the layers
std::for_each(
canvas_interface()->get_canvas()->rbegin(), canvas_interface()->get_canvas()->rend(),
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)
{
Layer::Handle layer=row[model.layer];
/*
{
- row[model.name] = layer->get_local_name();
+ row[model.name] = layer->get_local_name();
if(layer->get_description().empty())
{
row[model.label] = layer->get_local_name();
}
else
{
- row[model.label] = layer->get_description();
+ 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);
-
+ // row_changed(get_path(row),row);
+
Gtk::TreeModel::Children children = row.children();
Gtk::TreeModel::Children::iterator iter;
LayerTreeStore::set_row_layer(Gtk::TreeRow &row,synfig::Layer::Handle &handle)
{
//row[model.id] = handle->get_name();
- //row[model.name] = handle->get_local_name();
+ //row[model.name] = handle->get_local_name();
/*if(handle->get_description().empty())
{
//row[model.label] = handle->get_local_name();
}
else
{
- //row[model.label] = handle->get_description();
+ //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;
+ //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()))
void
LayerTreeStore::on_layer_inserted(synfig::Layer::Handle handle,int depth)
-{
+{
if(depth==0)
{
on_layer_added(handle);
}
children_=iter->children();
}
-
+
Gtk::TreeModel::Children::iterator iter(children_.begin());
while(depth-- && iter)
{
return;
}
}
-
+
Gtk::TreeModel::Row row(*insert(iter));
set_row_layer(row,handle);
-
+
}
void
void
LayerTreeStore::on_layer_lowered(synfig::Layer::Handle layer)
-{
+{
Gtk::TreeModel::Children::iterator iter, iter2;
if(find_layer_row(layer,iter))
{
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);
-
+ set_row_layer(row2,layer2);
+
}
else
rebuild();
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();
}
{
//DEBUGPOINT();
Gtk::TreeModel::Children children(iter->children());
-
+
for(iter = children.begin(); iter && iter != children.end(); ++iter)
{
if((Glib::ustring)(*iter)[model.param_name]==param_name)
//DEBUGPOINT();
Gtk::TreeRow row=*iter;
refresh_row(row);
- return;
+ return;
}
}
}
if(find_layer_row(handle,iter))
{
Gtk::TreeRow row(*iter);
-
- Layer::Handle layer(row[model.layer]);
-
+
+ Layer::Handle layer(row[model.layer]);
+
if(desc.empty())
{
//row[model.label]=layer->get_local_name();
//row[model.label]=layer->get_description();
row[model.tooltip]=layer->get_local_name();
}
- else
+ 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;
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;
}
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++)
if(layer==(synfig::Layer::Handle)row[model.layer])
return true;
}
-
+
iter=children().end();
//DEBUGPOINT();
//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;
}
*/
public:
-
+
//! TreeModel for the layers
const Model model;
*/
public:
-
+
LayerTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
~LayerTreeStore();
*/
public:
-
+
static Glib::RefPtr<LayerTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
fprintf(file.get(),"O %s\n",etl::absolute_path((argv)[argc]).c_str());
}
}
-
+
fprintf(file.get(),"F\n");
return 0;
}
std::cerr<<"Application appears to have terminated successfuly"<<std::endl;
-
+
return 0;
}
{
// Connect the signal
get_canvas()->signal_meta_data_changed().connect(sigc::mem_fun(*this,&MetaDataTreeStore::meta_data_changed));
-
+
rebuild();
}
MetaDataTreeStore::rebuild()
{
clear();
-
+
std::list<String> keys(get_canvas()->get_meta_data_keys());
-
+
for(;!keys.empty();keys.pop_front())
{
Gtk::TreeRow row(*append());
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
namespace synfigapp { class CanvasInterface; }
namespace studio {
-
+
class MetaDataTreeStore : virtual public Gtk::TreeStore
{
/*
*/
public:
-
+
const Model model;
/*
*/
private:
-
+
/*
-- ** -- S I G N A L T E R M I N A L S -------------------------------------
*/
*/
public:
-
+
~MetaDataTreeStore();
etl::loose_handle<synfigapp::CanvasInterface> get_canvas_interface() { return canvas_interface_; }
public:
static Glib::RefPtr<MetaDataTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface>);
-
+
}; // END of class MetaDataTreeStore
}; // END of namespace studio
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 =============================================================== */
synfig::Vector center;
std::vector<synfig::Vector> positions;
-
-
+
+
public:
Axis axis;
class studio::StateMirror_Context : public sigc::trackable
{
etl::handle<CanvasView> canvas_view_;
-
+
synfigapp::Settings& settings;
etl::handle<DuckDrag_Mirror> duck_dragger_;
Gtk::Table options_table;
-
-
+
+
Gtk::CheckButton checkbutton_axis_x;
Gtk::CheckButton checkbutton_axis_y;
-
+
public:
Axis get_axis()const { return checkbutton_axis_x.get_active()?AXIS_X:AXIS_Y; }
checkbutton_axis_y.set_active(true);
checkbutton_axis_x.set_active(false);
}
-
+
duck_dragger_->axis=get_axis();
}
-
+
void update_axis_y()
{
checkbutton_axis_x.set_active(!checkbutton_axis_y.get_active());
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 StateMirror_Context
Smach::state<StateMirror_Context>("mirror")
{
insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateMirror_Context::event_refresh_tool_options));
-}
+}
StateMirror::~StateMirror()
{
void
StateMirror_Context::load_settings()
-{
+{
String value;
settings.get_value("mirror.axis",value);
void
StateMirror_Context::save_settings()
-{
+{
settings.set_value("mirror.lock_aspect",strprintf("%d",(int)get_axis()));
}
duck_dragger_(new DuckDrag_Mirror()),
checkbutton_axis_x(_("Horizontal")),
checkbutton_axis_y(_("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(*manage(new Gtk::Label(_("Mirror Tool"))), 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
options_table.attach(checkbutton_axis_x, 0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
options_table.attach(checkbutton_axis_y, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
checkbutton_axis_x.signal_toggled().connect(sigc::mem_fun(*this,&StateMirror_Context::update_axis_x));
checkbutton_axis_y.signal_toggled().connect(sigc::mem_fun(*this,&StateMirror_Context::update_axis_y));
-
+
options_table.show_all();
refresh_tool_options();
App::dialog_tool_options->present();
-
+
get_work_area()->allow_layer_clicks=true;
get_work_area()->set_duck_dragger(duck_dragger_);
{
center=vector;
int i;
-
+
const DuckList selected_ducks(duckmatic->get_selected_ducks());
DuckList::const_iterator iter;
for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
Vector p(positions[i]);
//Point p((*iter)->get_trans_point());
-
+
if(axis==AXIS_X)
p[0]=-(p[0]-center[0])+center[0];
if(axis==AXIS_Y)
p[1]=-(p[1]-center[1])+center[1];
-
+
(*iter)->set_trans_point(p);
}
for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
Vector p(positions[i]);
//Point p((*iter)->get_trans_point());
-
+
if(axis==AXIS_X)
p[0]=-(p[0]-center[0])+center[0];
if(axis==AXIS_Y)
p[1]=-(p[1]-center[1])+center[1];
-
+
(*iter)->set_trans_point(p);
}
}
Dock_PalBrowse::Dock_PalBrowse():
Dockable("pal_browse",_("Palette Browser")/*,Gtk::StockID("gtk-select-color")*/)
-{
+{
}
Dock_PalBrowse::~Dock_PalBrowse()
{
dialog_palette->dialog_settings.add_domain(this,name);
}
-
+
virtual ~PaletteSettings()
{
dialog_palette->dialog_settings.remove_domain(name);
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()));
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));
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();
DEBUGPOINT();
action_group->add(Gtk::Action::create(
&Dock_PalEdit::on_add_pressed
)
);
-
+
App::ui_manager()->insert_action_group(action_group);
Glib::ustring ui_info =
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(table);
table.set_homogeneous(true);
-
+
set_default_palette();
-
+
show_all_children();
}
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()));
)
);
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.attach(*widget_color, c, c+1, r, r+1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
}
table.show_all();
queue_draw();
{
synfigapp::Main::set_foreground_color(get_color(i));
}
-
+
void
Dock_PalEdit::set_default_palette()
{
int width=12;
-
+
palette_.clear();
// Greys
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));
}
palette_.push_back(Color::magenta());
palette_.push_back(Color(1.0f,0.0f,0.25f));
-
+
const int levels(3);
// Colors
palette_.push_back(c);
}
-
+
/*
const int levels(3);
-
+
for(int i=0;i<levels*levels*levels;i++)
{
Color c(
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_;
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
dock_pal_browse=new Dock_PalBrowse();
App::get_dock_manager()->register_dockable(*dock_pal_browse);
-
+
return true;
}
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 =============================================================== */
Module::Module():status_(false)
{
}
-
+
Module::~Module()
{
stop();
class Module : public etl::shared_object
{
bool status_;
-
+
protected:
Module();
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 =============================================================== */
OneMoment::OneMoment(): Gtk::Window(Gtk::WINDOW_POPUP)
{
-
+
// Create the Copyright Label
Gtk::Label *label = manage(new class Gtk::Label(_("One Moment, Please...")));
// show everything off
show_all();
-
+
present();
while(studio::App::events_pending())studio::App::iteration(false);
}
class OneMoment : public Gtk::Window
{
public:
-
+
OneMoment();
~OneMoment();
};
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()
/*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;
+
+ 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 true;
}
return false;
}
-
+
virtual bool start_frame(ProgressCallback *cb=NULL)
{
- return true;
+ return true;
}
-
+
virtual void end_frame()
{
//ok... notify our subscribers...
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
+
+ float get_time() const
{
double time = ((nframes-curframe)/(double)nframes)*tbegin
+ ((curframe)/(double)nframes)*tend;
void studio::Preview::set_canvasview(const studio::CanvasView::LooseHandle &h)
{
canvasview = h;
-
+
if(canvasview)
{
//perhaps reset override values...
{
//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()));
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 - BECAUSE THE RENDERER CAN'T RENDER INCLUDING THE LAST FRAME
desc.set_time_end(desc.get_time_end() + 1.3/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();
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));
return;
//convert all the pixles to the pixbuf... buffer... thing...
- //synfig::warning("Converting...");
+ //synfig::warning("Converting...");
convert_color_format(buffer, surf[0], surf.get_w()*surf.get_h(), pf, App::gamma);
-
+
//load time
- fe.t = time;
+ fe.t = time;
//uses and manages the memory for the buffer...
//synfig::warning("Create a pixmap...");
- fe.buf =
+ fe.buf =
Gdk::Pixbuf::create_from_data(
buffer, // pointer to the data
Gdk::COLORSPACE_RGB, // the colorspace
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()();
}
button->add(*icon); \
tooltips.set_tip(*button,tooltip); \
icon->set_padding(0,0);\
- icon->show();
+ icon->show();
Widget_Preview::Widget_Preview()
:Gtk::Table(5,5,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.
+
+ //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);
{
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
}
{
//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);
-
+ //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
+
+ //incrementally go in either direction
//(bias downward towards beg, because that's what we want)
for(;i != end;++i)
{
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...
+
+ //if(i!=beg)--i;
+
+ //bias down, so we can't be at end... and it still is valid...
for(;i != beg;)
{
--i;
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)
{
timedisp = i->t;
//synfig::warning("Update at: %f seconds (%f s)",time,timedisp);
preview_draw();
- //synfig::warning("success!");
+ //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();
}
}
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
+
+ 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();
if(!wind) synfig::warning("The destination window is broken...");
if(!surf) synfig::warning("The destination is not drawable...");
-
+
if(surf)
{
/* Options for drawing...
+ 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
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::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;
}
{
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())
{
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");
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())
+ 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)
void studio::Widget_Preview::set_preview(handle<Preview> prev)
{
preview = prev;
-
+
synfig::info("Setting preview");
-
+
//stop playing the mini animation...
stop();
-
+
if(preview)
{
//set the internal values
{
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_upper(0);
adj_time_scrub.set_value(0);
adj_time_scrub.set_step_increment(0);
- adj_time_scrub.set_page_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));
//audiotime = adj_time_scrub.get_value();
playing = true;
- //adj_time_scrub.set_value(adj_time_scrub.get_lower());
+ //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();
+
+ timecon = Glib::signal_timeout().connect(sigc::mem_fun(*this,&Widget_Preview::play_update),timeout);
+ timer.reset();
}
-
+
}
void studio::Widget_Preview::play_stop()
stop();
}
}
-
+
default: break;
}
-
+
return false;
}
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));
preview->renderer.detach();
}
}
-
+
void studio::Widget_Preview::eraseall()
{
stop();
stoprender();
-
+
currentbuf.clear();
currentindex = 0;
timedisp = 0;
queue_draw();
-
+
if(preview)
{
preview->clear();
namespace studio {
class AsyncRenderer;
-
+
class Preview : public sigc::trackable, public etl::shared_object
{
public:
};
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...
//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(),
+
+ 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
+
+ float get_begintime() const
{
if(overbegin)
return begintime;
return get_canvas()->rend_desc().get_time_start();
else return -1;
}
-
+
float get_endtime() const
{
if(overend)
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; }
};
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
+
+ //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);
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 =============================================================== */
//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::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;
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);
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();
Gtk::Widget *create_time_tab();
Gtk::Widget *create_other_tab();
};
-
+
}; // END of namespace studio
/* === E N D =============================================================== */
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"),
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,
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::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>"));
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);
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);
-
+ 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, 3, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+ target_table->attach(*targetLabel, 0, 1, 1, 2, Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 0, 0);
+ target_table->attach(optionmenu_target, 1, 3, 1, 2, Gtk::EXPAND|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::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);
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);
+ 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);
-
+ 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);
+ 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);
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(true);
widget_rend_desc.disable_time_section();
-
+
try
{
synfig::warning("Averted crash!");
entry_filename.set_text("output.png");
}
-
+
get_vbox()->show_all();
}
RenderSettings::on_render_pressed()
{
String filename=entry_filename.get_text();
-
+
if(filename.empty())
{
canvas_interface_->get_ui_interface()->error(_("You must supply a filename!"));
catch(std::runtime_error x)
{
canvas_interface_->get_ui_interface()->error(_("Unable to determine proper target from filename."));
- return;
+ 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());
canvas_interface_->get_ui_interface()->amount_complete(0,10000);
return;
}
-
+
// Success!
- canvas_interface_->get_ui_interface()->task(filename+_(" rendered sucessfuly"));
+ canvas_interface_->get_ui_interface()->task(filename+_(" rendered sucessfuly"));
canvas_interface_->get_ui_interface()->amount_complete(0,10000);
*/
- return;
+ return;
}
void
RenderSettings::on_finished()
{
- canvas_interface_->get_ui_interface()->task(_("File rendered sucessfuly"));
+ canvas_interface_->get_ui_interface()->task(_("File rendered sucessfuly"));
canvas_interface_->get_ui_interface()->amount_complete(0,10000);
}
-
+
void
RenderSettings::on_cancel_pressed()
{
namespace studio
{
class AsyncRenderer;
-
+
class RenderSettings : public Gtk::Dialog
{
Gtk::Tooltips tooltips;
Gtk::Entry entry_filename;
Gtk::Adjustment adjustment_quality;
- Gtk::SpinButton entry_quality;
+ Gtk::SpinButton entry_quality;
Gtk::Adjustment adjustment_antialias;
- Gtk::SpinButton entry_antialias;
+ Gtk::SpinButton entry_antialias;
Gtk::CheckButton toggle_single_frame;
Gtk::Menu *menu_target;
synfig::String target_name;
-
+
void set_target(synfig::String name);
etl::handle<AsyncRenderer> async_renderer;
void on_choose_pressed();
void on_render_pressed();
void on_cancel_pressed();
-
+
void on_finished();
}; // END of class RenderSettings
-
+
}; // END of namespace studio
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
// 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_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)
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]),
class Renderer_BBox : public studio::WorkAreaRenderer
{
synfig::Rect bbox;
-
+
public:
Renderer_BBox();
~Renderer_BBox();
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
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())
{
{
const int width_in_tiles(w/tile_w+(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);
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++)
// 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);
+ gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
drawable->draw_rectangle(
gc,
false, // Fill?
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;
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
// 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_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"));
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]),
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;
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]);
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));
+ drawable->draw_lines(gc, Glib::ArrayHandle<Gdk::Point>(points));
}
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)
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(Gdk::Color("#000000"));
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));
+ drawable->draw_lines(gc, Glib::ArrayHandle<Gdk::Point>(points));
gc->set_rgb_fg_color(Gdk::Color("#afafaf"));
gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
- drawable->draw_lines(gc, Glib::ArrayHandle<Gdk::Point>(points));
+ 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));
+// drawable->draw_lines(gc, Glib::ArrayHandle<Gdk::Point>(points));
gc->set_rgb_fg_color(Gdk::Color("#000000"));
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));
+ drawable->draw_lines(gc, Glib::ArrayHandle<Gdk::Point>(points));
gc->set_rgb_fg_color(Gdk::Color("#afafaf"));
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));
+ drawable->draw_lines(gc, Glib::ArrayHandle<Gdk::Point>(points));
}
}
// 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 point((*iter)->get_trans_point());
if((*iter)->get_connect_duck())
{
has_connect=true;
- origin=(*iter)->get_connect_duck()->get_trans_point();
+ 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);
-
+
shadow = selected?Gtk::SHADOW_IN:Gtk::SHADOW_OUT;
-
+
if(get_work_area()->get_selected_value_node())
{
synfigapp::ValueDesc value_desc((*iter)->get_value_desc());
gc->set_rgb_fg_color(Gdk::Color("#FF0000"));
//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
);
}
-
+
}
if((*iter)->get_box_duck())
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(Gdk::Color("#000000"));
gc->set_line_attributes(1,Gdk::LINE_ON_OFF_DASH,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
round_to_int(tl[1]),
round_to_int(abs(boxpoint[0]-point[0])),
round_to_int(abs(boxpoint[1]-point[1]))
- );
+ );
}
ScreenDuck screen_duck;
else if((*iter)->get_type()&Duck::TYPE_WIDTH)
screen_duck.color=Gdk::Color("#ff00ff");
else if((*iter)->get_type()&Duck::TYPE_ANGLE)
- screen_duck.color=(Gdk::Color("#0000ff"));
+ screen_duck.color=(Gdk::Color("#0000ff"));
else
- screen_duck.color=Gdk::Color("#00ff00");
-
+ screen_duck.color=Gdk::Color("#00ff00");
+
screen_duck_list.push_front(screen_duck);
if(has_connect)
gc->set_line_attributes(3,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
gc->set_rgb_fg_color(Gdk::Color("#000000"));
gc->set_function(Gdk::COPY);
- drawable->draw_line(gc, (int)origin[0],(int)origin[1],(int)(point[0]),(int)(point[1]));
+ 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(Gdk::Color("#9fefef"));
- drawable->draw_line(gc, (int)origin[0],(int)origin[1],(int)(point[0]),(int)(point[1]));
+ 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]));
+// 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(Gdk::Color("#000000"));
gc->set_function(Gdk::COPY);
- drawable->draw_line(gc, (int)origin[0],(int)origin[1],(int)(point[0]),(int)(point[1]));
+ 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(Gdk::Color("#9fefef"));
- drawable->draw_line(gc, (int)origin[0],(int)origin[1],(int)(point[0]),(int)(point[1]));
+ drawable->draw_line(gc, (int)origin[0],(int)origin[1],(int)(point[0]),(int)(point[1]));
}
}
d,
0,
360*64
- );
+ );
gc->set_rgb_fg_color(Gdk::Color("#afafaf"));
}
else
gc->set_function(Gdk::INVERT);
}
gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
-
+
drawable->draw_arc(
gc,
false,
d,
0,
360*64
- );
+ );
if(hover)
{
Distance real_mag(((*iter)->get_trans_point()-(*iter)->get_trans_origin()).mag(),Distance::SYSTEM_UNITS);
real_mag.convert(App::distance_system,get_work_area()->get_rend_desc());
- layout->set_text(real_mag.get_string());
+ layout->set_text(real_mag.get_string());
gc->set_rgb_fg_color(Gdk::Color("#000000"));
drawable->draw_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(Gdk::Color("#000000"));
radius*2,
0,
360*64
- );
+ );
gc->set_rgb_fg_color(color);
radius*2-outline*2,
0,
360*64
- );
+ );
}
}
class Renderer_Ducks : public studio::WorkAreaRenderer
{
-
+
public:
~Renderer_Ducks();
-
+
void render_vfunc(const Glib::RefPtr<Gdk::Drawable>& drawable,const Gdk::Rectangle& expose_area );
protected:
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
// 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_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)
{
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);
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 );
Renderer_Guides::Renderer_Guides():
dragging(false)
{
-
+
}
Renderer_Guides::~Renderer_Guides()
float pressure(0);
bool is_mouse(false);
Gdk::ModifierType modifier(Gdk::ModifierType(0));
-
+
// Handle input stuff
if(
event->any.type==GDK_MOTION_NOTIFY ||
device=event->button.device;
modifier=Gdk::ModifierType(event->button.state);
}
-
+
// Make sure we recognise the device
/*if(curr_input_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
//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)
//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;
+ // button_pressed=0;
}
}
switch(event->type)
default:
break;
}
-
+
return false;
}
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
// 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]);
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,
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
// 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]);
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
return;
gc->set_rgb_fg_color(Gdk::Color("#000000"));
}
-
- layout->set_text(timecode);
+
+ layout->set_text(timecode);
*/
gc->set_rgb_fg_color(Gdk::Color("#5f0000"));
try
{
- layout->set_text(canvas->keyframe_list().find(cur_time)->get_description());
+ layout->set_text(canvas->keyframe_list().find(cur_time)->get_description());
}
catch(synfig::Exception::NotFound)
{
catch(...) {
assert(0);
}
-
+
drawable->draw_layout(gc, 4, 4, layout);
- }
+ }
}
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 );
namespace studio {
class CanvasView;
-
+
typedef etl::smach<CanvasView,EventKey> Smach;
}; // END of namespace studio
{
etl::handle<CanvasView> canvas_view_;
CanvasView::IsWorking is_working;
-
+
bool prev_table_status;
bool loop_;
bool prev_workarea_layer_status_;
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 unloop_bline();
void refresh_ducks(bool x=true);
-
+
Gtk::Table options_table;
Gtk::Entry entry_id;
Gtk::CheckButton checkbutton_layer_region;
Gtk::Button button_clear;
Gtk::Adjustment adj_feather;
Gtk::SpinButton spin_feather;
-
-
-
+
+
+
public:
int layers_to_create()const
get_layer_bline_flag()+
get_layer_curve_gradient_flag();
}
-
+
void sanity_check()
{
if(layers_to_create()==0)
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); }
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);
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();
bool run_();
bool run();
-
+
bool no_egress_on_selection_change;
Smach::event_result event_layer_selection_changed_handler(const Smach::event& x)
{
throw Smach::egress_exception();
return Smach::RESULT_OK;
}
-
+
}; // END of class StateBLine_Context
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")
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");
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.
{
// 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
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);
}
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;
-
+
// 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();
-
+
// 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);
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();
next_duck=0;
// Now we need to generate it
-
+
if(bline_point_list.empty())
{
return false;
//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()
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()))
{
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();
}
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())
{
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\"");
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)))
group.cancel();
throw String(_("Unable to create Outline layer"));
return false;
- }
+ }
/*if(get_layer_region_flag() && !get_auto_export_flag())
{
}
-
+
// If we were asked to create a CurveGradient layer, go ahead and do so
if(get_layer_curve_gradient_flag())
{
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)))
group.cancel();
throw String(_("Unable to create Gradient layer"));
return false;
- }
+ }
/*if(get_layer_region_flag() && !get_auto_export_flag())
{
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();
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");
get_work_area()->queue_draw();
return Smach::RESULT_ACCEPT;
}
-
+
return Smach::RESULT_OK;
}
// 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())
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;
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;
}
}
{
get_work_area()->clear_ducks();
get_work_area()->queue_draw();
-
+
if(bline_point_list.empty())
return;
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);
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);
);
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());
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;
)
);
- //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<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->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_)
{
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());
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;
)
);
- //get_work_area()->add_duck(bezier->c1);
+ //get_work_area()->add_duck(bezier->c1);
get_work_area()->add_bezier(bezier);
}
if(bezier && !loop_)
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)
}
}
}
- get_work_area()->queue_draw();
+ get_work_area()->queue_draw();
}
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),
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)
{
--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());
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);
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<ValueNode_Const::Handle>::iterator iter;
-
+
for(iter=bline_point_list.begin();iter!=bline_point_list.end();++iter)
if(*iter==value_node)
{
get_canvas_view()->get_ui_interface()->error("Unable to remove vertex, internal error, please report this bug");
}
- refresh_ducks(false);
+ refresh_ducks(false);
}
void
}; // END of class StateBLine
extern StateBLine state_bline;
-
+
}; // END of namespace studio
/* === E N D =============================================================== */
{
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;
Widget_Enum enum_blend;
-
+
Gtk::Adjustment adj_feather;
Gtk::SpinButton spin_feather;
-
+
Gtk::CheckButton check_invert;
-
+
public:
synfig::String get_id()const { return entry_id.get_text(); }
int get_falloff()const { return enum_falloff.get_value(); }
void set_falloff(int x) { return enum_falloff.set_value(x); }
-
+
int get_blend()const { return enum_blend.get_value(); }
void set_blend(int x) { return enum_blend.set_value(x); }
-
+
Real get_feather()const { return adj_feather.get_value(); }
void set_feather(Real f) { adj_feather.set_value(f); }
-
+
bool get_invert()const { return check_invert.get_active(); }
void set_invert(bool i) { check_invert.set_active(i); }
-
- void refresh_tool_options(); //to refresh the toolbox
+
+ void refresh_tool_options(); //to refresh the toolbox
//events
Smach::event_result event_stop_handler(const Smach::event& x);
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 make_circle(const Point& p1, const Point& p2);
-
+
}; // END of class StateGradient_Context
/* === M E T H O D S ======================================================= */
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);
set_falloff(atoi(value.c_str()));
else
set_falloff(2);
-
+
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
-
+
if(settings.get_value("circle.feather",value))
set_feather(atof(value.c_str()));
else
set_feather(0);
-
+
if(settings.get_value("circle.invert",value) && value != "0")
set_invert(true);
else
void
StateCircle_Context::save_settings()
-{
+{
settings.set_value("circle.id",get_id());
settings.set_value("circle.fallofftype",strprintf("%d",get_falloff()));
settings.set_value("circle.blend",strprintf("%d",get_blend()));
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.
{
// 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);
-
+
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);
}
{
no_egress_on_selection_change=false;
// Set up the tool options dialog
- //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(*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);
enum_falloff.set_param_desc(ParamDesc("falloff")
.add_enum_value(CIRCLE_SQRT,"sqrt",_("Square Root"))
.add_enum_value(CIRCLE_SIGMOND,"sigmond",_("Sigmond"))
.add_enum_value(CIRCLE_COSINE,"cosine",_("Cosine")));
-
+
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")));
-
+
load_settings();
//feather stuff
options_table.attach(spin_feather, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
options_table.attach(enum_falloff, 0, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
options_table.attach(enum_blend, 0, 2, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
+
//invert flag
options_table.attach(check_invert, 0, 2, 6, 7, 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()->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();
-
+
// Connect a signal
//get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateCircle_Context::on_user_click));
get_canvas_view()->work_area->set_cursor(Gdk::CROSSHAIR);
// 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();
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)
const synfig::TransformStack& transform(get_canvas_view()->get_curr_transform_stack());
const Point p1(transform.unperform(_p1));
const Point p2(transform.unperform(_p2));
-
+
if(get_falloff() >= 0 && get_falloff() < CIRCLE_NUM_FALLOFF)
{
-
+
layer=get_canvas_interface()->add_layer_to("circle",canvas,depth);
-
+
layer->set_param("pos",p1);
get_canvas_interface()->signal_layer_param_changed()(layer,"pos");
-
+
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");
-
+
layer->set_param("blend_method",get_blend());
get_canvas_interface()->signal_layer_param_changed()(layer,"blend_method");
-
+
layer->set_description(get_id());
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
get_canvas_interface()->get_selection_manager()->set_selected_layer(layer);
no_egress_on_selection_change=false;
}
-
+
reset();
increment_id();
}
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);
if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_DRAG && event.button==BUTTON_LEFT)
{
point2_duck->set_point(point_holder-get_work_area()->snap_point_to_grid(event.pos));
- get_work_area()->queue_draw();
+ get_work_area()->queue_draw();
return Smach::RESULT_ACCEPT;
}
}; // END of class StateCircle
extern StateCircle state_circle;
-
+
}; // END of namespace studio
/* === E N D =============================================================== */
{
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;
-
+
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 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);
Gtk::CheckButton checkbutton_auto_connect;
Gtk::CheckButton checkbutton_region_only;
Gtk::Button button_fill_last_stroke;
-
+
//pressure spinner and such
Gtk::Adjustment adj_min_pressure;
Gtk::SpinButton spin_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 :)
bool get_region_only_flag()const { return checkbutton_region_only.get_active(); }
void set_region_only_flag(bool x) { return checkbutton_region_only.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();
-
+
Smach::event_result event_stop_handler(const Smach::event& x);
Smach::event_result event_refresh_handler(const Smach::event& x);
Smach::event_result process_stroke(StrokeData stroke_data, WidthData width_data, bool region_flag=false);
bool process_queue();
-
+
StateDraw_Context(CanvasView* canvas_view);
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();
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));
void
StateDraw_Context::load_settings()
-{
+{
String value;
if(settings.get_value("draw.pressure_width",value) && value=="0")
set_region_only_flag(true);
else
set_region_only_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());
Real n = atof(value.c_str());
set_feather(n);
}else
- set_feather(0);
-
+ 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
void
StateDraw_Context::save_settings()
-{
+{
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_connect",get_auto_connect_flag()?"1":"0");
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.lthreshold",strprintf("%f",get_lthres()));
settings.set_value("draw.localize",get_local_error_flag()?"1":"0");
}
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),
+ adj_localthres(20,1,100000,0.1,1),
check_localerror(_("LocalError"))
-
+
{
synfig::info("STATE SKETCH: entering state");
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(*manage(new Gtk::Label(_("Draw Tool"))), 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
options_table.attach(checkbutton_pressure_width, 0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- options_table.attach(checkbutton_auto_loop, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- options_table.attach(checkbutton_auto_connect, 0, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- options_table.attach(checkbutton_region_only, 0, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
+ options_table.attach(checkbutton_auto_loop, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(checkbutton_auto_connect, 0, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(checkbutton_region_only, 0, 2, 4, 5, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
options_table.attach(check_min_pressure, 0, 2, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
options_table.attach(spin_min_pressure, 0, 2, 6, 7, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- options_table.attach(*manage(new Gtk::Label(_("Feather"))), 0, 1, 7, 8, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(*manage(new Gtk::Label(_("Feather"))), 0, 1, 7, 8, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
options_table.attach(spin_feather, 1, 2, 7, 8, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
- options_table.attach(check_localerror, 0, 2, 8, 9, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- options_table.attach(*manage(new Gtk::Label(_("Smooth"))), 0, 1, 9, 10, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+
+ options_table.attach(check_localerror, 0, 2, 8, 9, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(*manage(new Gtk::Label(_("Smooth"))), 0, 1, 9, 10, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
options_table.attach(spin_globalthres, 1, 2, 9, 10, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- //options_table.attach(button_fill_last_stroke, 0, 2, 10, 11, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
+ //options_table.attach(button_fill_last_stroke, 0, 2, 10, 11, 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()->allow_layer_clicks=false;
// Turn off duck clicking
get_work_area()->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();
-
+
// Hide the time bar
get_canvas_view()->hide_timebar();
-
+
// Connect a signal
//get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateDraw_Context::on_user_click));
get_canvas_view()->work_area->set_cursor(Gdk::PENCIL);
App::toolbox->refresh();
-
+
refresh_ducks();
}
spin_globalthres.set_value(adj_globalthres.get_value());
spin_globalthres.set_increments(0.01,.1);
}
-
+
spin_globalthres.update();
}
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")
App::dialog_tool_options->clear();
get_work_area()->set_type_mask(old_duckmask);
-
+
get_canvas_view()->work_area->reset_cursor();
// Restore layer clicking
// 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()->get_smach().push_state(&state_stroke);
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;
}
}
{
int &i;
DepthCounter(int &i):i(i) { i++; }
- ~DepthCounter() { 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_foreground_color());
-
+
if(nested==0)
{
DirtyTrap dirty_trap(get_work_area());
process_queue();
return result;
}
-
+
stroke_queue.push_back(pair<StrokeData,WidthData>(event.stroke_data,event.width_data));
- return Smach::RESULT_ACCEPT;
+ return Smach::RESULT_ACCEPT;
}
bool
{
// 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);
*iter=1.0;
}
}
-
+
//get_work_area()->add_stroke(event.stroke_data,synfigapp::Main::get_foreground_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.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 then the same point
if(get_auto_loop_flag())
if(bline.size()>2&&(bline.front().get_vertex()-bline.back().get_vertex()).mag()<=radius)
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
// 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 width(bline.front().get_width()+width);
width=width<=1?width:1;
bline.front().set_width(width);
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()
bline_point.get_tangent2()+bline_point.get_vertex()
) -new_vertex
);
-
+
bline_point.set_vertex(new_vertex);
-
+
trans_bline.push_back(bline_point);
}
value_node=ValueNode_BLine::create(synfig::ValueBase(trans_bline,loop_bline_flag));
bool extend_start=false,extend_finish=false,complete_loop=false;
bool extend_start_join_same=false,extend_start_join_different=false,extend_finish_join_same=false,extend_finish_join_different=false;
int start_duck_index,finish_duck_index;
-
+
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));
-
+
synfigapp::ValueDesc start_duck_value_desc,finish_duck_value_desc;
ValueNode_BLine::Handle start_duck_value_node_bline=NULL,finish_duck_value_node_bline=NULL;
// 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
return result;
}
}
-
+
// 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();
}
-
+
//int number(synfig::UniqueID().get_uid());
-
+
synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
+
if(get_region_only_flag())
layer=get_canvas_interface()->add_layer_to("region",canvas,depth);
else
layer=get_canvas_interface()->add_layer_to("outline",canvas,depth);
-
+
if(get_feather())
{
layer->set_param("feather",get_feather());
assert(layer);
//layer->set_description(strprintf("Stroke %d",number));
//get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
-
-
+
+
+
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)))
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"));
get_canvas_view()->get_selection_manager()->set_selected_layer(layer);
//refresh_ducks();
}
-
+
last_stroke=value_node;
return Smach::RESULT_ACCEPT;
}
{
// Create the action group
synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Define Region"));
-
+
std::list<synfigapp::ValueDesc> vertex_list;
-
+
// First we need to come up with a rough list of
// BLinePoints that we are going to be using to
- // define our region.
+ // 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;
+ 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__);
+ 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;
}
}
}
-
+
if(vertex_list.size()<=2)
{
synfig::info(__FILE__":%d: Vertex list too small to make region.",__LINE__);
- return Smach::RESULT_OK;
+ return Smach::RESULT_OK;
}
assert(vertex_list.back().is_valid());
-
+
// Remove any duplicates
{
}
-
+
// Now we need to clean the list of vertices up
// a bit. This includes inserting missing vertices
// and removing extraneous ones.
// any updates are performed, we will
// change it back to false.
done=true;
-
+
std::list<synfigapp::ValueDesc>::iterator prev,iter,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
-
+
for(;iter!=vertex_list.end();prev=iter,iter=next++)
{
synfigapp::ValueDesc value_prev(*prev);
synfigapp::ValueDesc value_desc(*iter);
synfigapp::ValueDesc value_next((next==vertex_list.end())?vertex_list.front():*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());
done=false;
break;
}
- }
+ }
*/
-
+
// Remove duplicate vertices
if(value_prev.get_value_node()==value_desc.get_value_node()
|| value_desc.get_value_node()==value_next.get_value_node())
done=false;
break;
}
-
+
if(value_desc.parent_is_value_node() && value_next.parent_is_value_node())
if(value_desc.get_parent_value_node()==value_next.get_parent_value_node() && (next!=vertex_list.end()))
{
break;
}
}
-
+
// Ensure that connections
// between blines are properly
// connected
//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((vertex.get_vertex()-vertex_next.get_vertex()).mag_squared()<radius*radius)
{
DEBUGPOINT();
*iter=synfigapp::ValueDesc(get_canvas(),value_node->get_id());
vertex_list.erase(next);
done=false;
- break;
+ break;
}
else
{
DEBUGPOINT();
bool positive_trend(value_desc.get_index()>value_prev.get_index());
-
+
if(!positive_trend && value_desc.get_index()>0)
{
DEBUGPOINT();
vertex_list.insert(next,synfigapp::ValueDesc(value_desc.get_parent_value_node(),value_desc.get_index()-1));
done=false;
- break;
+ break;
}
if(positive_trend && value_desc.get_index()<LinkableValueNode::Handle::cast_static(value_desc.get_value_node())->link_count()-1)
{
DEBUGPOINT();
vertex_list.insert(next,synfigapp::ValueDesc(value_desc.get_parent_value_node(),value_desc.get_index()+1));
done=false;
- break;
+ break;
}
}
-
+
}
}
}
if(vertex_list.size()<=2)
{
synfig::info(__FILE__":%d: Vertex list too small to make region.",__LINE__);
- return Smach::RESULT_OK;
+ return Smach::RESULT_OK;
}
-
+
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.
+ // 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_bline=ValueNode_BLine::Handle::cast_dynamic(trivial_case_value_node);
}
-
+
// If we aren't the trivial case,
// then go ahead and create the new
// BLine value node
{
value_node_bline=ValueNode_BLine::create();
- std::list<synfigapp::ValueDesc>::iterator iter;
+ 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()));
+ 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);
+ 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);
assert(layer);
layer->set_param("color",synfigapp::Main::get_background_color());
get_canvas_interface()->signal_layer_param_changed()(layer,"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("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)))
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"));
}
get_canvas_view()->get_selection_manager()->set_selected_layer(layer);
}
-
+
return Smach::RESULT_ACCEPT;
}
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();
+
+ get_work_area()->queue_draw();
*/
}
{
// 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("value_node_dynamic_list_loop"));
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("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;
ValueNode_Composite::Handle composite(ValueNode_Composite::create(*iter));
synfigapp::Action::Handle action(synfigapp::Action::create("value_node_dynamic_list_insert"));
-
+
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("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;
synfigapp::Action::Handle action(synfigapp::Action::create("value_node_dynamic_list_loop"));
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("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;
ValueNode_Composite::Handle composite(ValueNode_Composite::create(*iter));
synfigapp::Action::Handle action(synfigapp::Action::create("value_node_dynamic_list_insert"));
-
+
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("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;
StateDraw_Context::reverse_bline(std::list<synfig::BLinePoint> &bline)
{
int i;
-
+
std::list<synfig::BLinePoint>::iterator iter,eiter;
iter=bline.begin();
eiter=bline.end();
{
if(!last_stroke)
return;
-
+
synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Fill Stroke"));
Layer::Handle layer;
-
- get_canvas_interface()->auto_export(last_stroke);
+
+ get_canvas_interface()->auto_export(last_stroke);
synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
+
layer=get_canvas_interface()->add_layer("region");
assert(layer);
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("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("segment_list")))
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"));
}; // END of class StateDraw
extern StateDraw state_draw;
-
+
}; // END of namespace studio
/* === E N D =============================================================== */
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);
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()
{
{
synfig::info("Enterted Eyedrop State");
canvas_view->work_area->set_cursor(Gdk::Cursor(Gdk::CROSSHAIR));
-
+
App::toolbox->refresh();
}
/* === C L A S S E S & S T R U C T S ======================================= */
-namespace studio {
-
+namespace studio {
+
class StateEyedrop_Context;
class StateEyedrop : public Smach::state<StateEyedrop_Context>
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);
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()
{
{
synfig::info("Enterted Fill State");
canvas_view->work_area->set_cursor(Gdk::CROSSHAIR);
-
+
App::toolbox->refresh();
}
return Smach::RESULT_ACCEPT;
}
-
+
//synfigapp::Action::Handle action(synfigapp::Action::create("value_desc_set"));
synfigapp::ValueDesc value_desc(event.layer,"color");
}
/*
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("value_desc",value_desc);
action->set_param("time",get_canvas_interface()->get_time());
- //action->set_param("layer",event.layer);
+ //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_foreground_color())))
synfig::error("LayerParamConnect didn't like \"foreground_color\"");
-
+
if(!get_canvas_interface()->get_instance()->perform_action(action))
{
get_canvas_view()->get_ui_interface()->warning(_("Unable to set layer color"));
/* === C L A S S E S & S T R U C T S ======================================= */
-namespace studio {
-
+namespace studio {
+
class StateFill_Context;
class StateFill : public Smach::state<StateFill_Context>
{
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;
Widget_Enum enum_blend;
-
+
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); }
-
+
int get_blend()const { return enum_blend.get_value(); }
void set_blend(int x) { return enum_blend.set_value(x); }
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 no_egress_on_selection_change;
Smach::event_result event_layer_selection_changed_handler(const Smach::event& x)
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);
-
+
if(settings.get_value("gradient.blend",value))
set_blend(atoi(value.c_str()));
else
void
StateGradient_Context::save_settings()
-{
+{
settings.set_value("gradient.id",get_id().c_str());
settings.set_value("gradient.type",strprintf("%d",get_type()));
settings.set_value("gradient.blend",strprintf("%d",get_blend()));
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.
{
// 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);
-
+
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);
}
{
no_egress_on_selection_change=false;
// 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(*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")
.add_enum_value(GRADIENT_RADIAL,"radial",_("Radial"))
.add_enum_value(GRADIENT_CONICAL,"conical",_("Conical"))
.add_enum_value(GRADIENT_SPIRAL,"spiral",_("Spiral")));
-
+
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")));
-
+
load_settings();
options_table.attach(enum_type, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
get_work_area()->allow_layer_clicks=false;
get_canvas_view()->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();
-
+
// Hide the time bar
//get_canvas_view()->hide_timebar();
-
+
// Connect a signal
//get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateGradient_Context::on_user_click));
// 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();
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)
switch(get_type())
{
case GRADIENT_INTERPOLATION_LINEAR:
-
+
layer=get_canvas_interface()->add_layer_to("linear_gradient",canvas,depth);
layer->set_param("p1",p1);
get_canvas_interface()->signal_layer_param_changed()(layer,"p1");
default:
return;
}
-
+
layer->set_param("blend_method",get_blend());
get_canvas_interface()->signal_layer_param_changed()(layer,"blend_method");
-
+
layer->set_description(get_id());
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
-
+
no_egress_on_selection_change=true;
get_canvas_interface()->get_selection_manager()->clear_selected_layers();
get_canvas_interface()->get_selection_manager()->set_selected_layer(layer);
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);
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);
+ get_work_area()->add_duck(point2_duck);
handle<Duckmatic::Bezier> bezier(new Duckmatic::Bezier());
bezier->p1=bezier->c1=duck;
if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_DRAG && event.button==BUTTON_LEFT)
{
point2_duck->set_point(get_work_area()->snap_point_to_grid(event.pos));
- get_work_area()->queue_draw();
+ get_work_area()->queue_draw();
return Smach::RESULT_ACCEPT;
}
StateGradient_Context::refresh_ducks()
{
get_work_area()->clear_ducks();
- get_work_area()->queue_draw();
+ get_work_area()->queue_draw();
}
class studio::StateNormal_Context : public sigc::trackable
{
CanvasView *canvas_view;
-
+
CanvasView* get_canvas_view() { return canvas_view; }
Canvas::Handle get_canvas() { return canvas_view->get_canvas(); }
WorkArea* get_work_area() { return canvas_view->get_work_area(); }
etl::handle<synfigapp::CanvasInterface> get_canvas_interface() { return canvas_view->canvas_interface(); }
-
+
public:
StateNormal_Context(CanvasView *canvas_view);
~StateNormal_Context();
-
+
Smach::event_result event_stop_handler(const Smach::event& x);
Smach::event_result event_refresh_handler(const Smach::event& x);
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));
-}
+ 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()
{
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());
{
synfig::info("STATE NORMAL: Received layer click Event with an empty layer.");
}
-
+
switch(event.button)
{
case BUTTON_LEFT:
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();
-
+
DEBUGPOINT();
if(dialog.run()==0)
return;
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.
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("value_desc_connect");
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"));
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("waypoint_set_smart"));
if(!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("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;
}
-
+
}
}
*/
//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(
}
Gtk::Menu *menu=manage(new Gtk::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);
/* === C L A S S E S & S T R U C T S ======================================= */
-namespace studio {
-
+namespace studio {
+
class StateNormal_Context;
class StateNormal : public Smach::state<StateNormal_Context>
{
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 refresh_ducks();
-
+
Gtk::Table options_table;
Gtk::Entry entry_id;
Gtk::Button button_make;
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();
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))
void
StatePolygon_Context::save_settings()
-{
+{
settings.set_value("polygon.id",get_id().c_str());
}
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.
{
// 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);
-
+
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);
}
{
no_egress_on_selection_change=false;
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(*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(button_make, 0, 2, 4, 5, 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();
// Turn off layer clicking
get_work_area()->allow_layer_clicks=false;
-
+
// clear out the ducks
get_work_area()->clear_ducks();
-
+
// Refresh the work area
get_work_area()->queue_draw();
get_canvas_view()->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();
-
+
// Hide the time bar
get_canvas_view()->hide_timebar();
-
+
// Connect a signal
//get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StatePolygon_Context::on_user_click));
// 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();
//throw Smach::egress_exception();
reset();
return Smach::RESULT_ACCEPT;
-
+
}
Smach::event_result
{
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");
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)
{
synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("New Polygon"));
synfigapp::PushMode push_mode(get_canvas_interface(),synfigapp::MODE_NORMAL);
-
+
Layer::Handle layer(get_canvas_interface()->add_layer_to("polygon",canvas,depth));
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))
{
get_canvas_view()->get_ui_interface()->error("Unable to set layer parameter");
return;
}
-
+
{
synfigapp::Action::Handle action(synfigapp::Action::create("value_desc_convert"));
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("canvas",get_canvas());
+ action->set_param("canvas_interface",get_canvas_interface());
+ action->set_param("value_desc",value_desc);
action->set_param("type","dynamic_list");
if(!get_canvas_interface()->get_instance()->perform_action(action))
{
get_canvas_view()->get_ui_interface()->error("Unable to execute action \"value_desc_convert\"");
return;
}
- }
+ }
no_egress_on_selection_change=true;
get_canvas_interface()->get_selection_manager()->clear_selected_layers();
get_canvas_interface()->get_selection_manager()->set_selected_layer(layer);
polygon_point_list.push_back(get_work_area()->snap_point_to_grid(event.pos));
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;
}
}
StatePolygon_Context::refresh_ducks()
{
get_work_area()->clear_ducks();
-
+
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);
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)
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);
+ get_work_area()->add_duck(duck);
bezier->p2=bezier->c2=duck;
- get_work_area()->add_bezier(bezier);
+ get_work_area()->add_bezier(bezier);
}
- get_work_area()->queue_draw();
+ get_work_area()->queue_draw();
}
{
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::SpinButton spin_expand;
-
+
Gtk::CheckButton check_invert;
-
+
public:
synfig::String get_id()const { return entry_id.get_text(); }
Real get_expand()const { return adj_expand.get_value(); }
void set_expand(Real f) { adj_expand.set_value(f); }
-
+
bool get_invert()const { return check_invert.get_active(); }
void set_invert(bool i) { check_invert.set_active(i); }
-
- void refresh_tool_options(); //to refresh the toolbox
+
+ void refresh_tool_options(); //to refresh the toolbox
//events
Smach::event_result event_stop_handler(const Smach::event& x);
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 make_rectangle(const Point& p1, const Point& p2);
-
+
}; // END of class StateGradient_Context
/* === M E T H O D S ======================================================= */
void
StateRectangle_Context::load_settings()
-{
+{
String value;
-
+
//parse the arguments yargh!
if(settings.get_value("rectangle.id",value))
set_id(value);
set_expand(atof(value.c_str()));
else
set_expand(0);
-
+
if(settings.get_value("rectangle.invert",value) && value != "0")
set_invert(true);
else
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.invert",get_invert()?"1":"0");
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.
{
// 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);
-
+
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);
}
{
no_egress_on_selection_change=false;
load_settings();
-
+
// Set up the tool options dialog
- //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(*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);
//expand stuff
options_table.attach(*manage(new Gtk::Label(_("Expansion:"))), 0, 1, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
options_table.attach(spin_expand, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
+
//invert flag
options_table.attach(check_invert, 1, 2, 4, 5, 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()->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();
-
+
// Connect a signal
//get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateRectangle_Context::on_user_click));
// 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();
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)
const synfig::TransformStack& transform(get_canvas_view()->get_curr_transform_stack());
const Point p1(transform.unperform(_p1));
const Point p2(transform.unperform(_p2));
-
+
//set all the parameters
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");
-
+
//name
layer->set_description(get_id());
get_canvas_interface()->signal_layer_new_description()(layer,layer->get_description());
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);
if(event.key==EVENT_WORKAREA_MOUSE_BUTTON_DRAG && event.button==BUTTON_LEFT)
{
point2_duck->set_point(get_work_area()->snap_point_to_grid(event.pos));
- get_work_area()->queue_draw();
+ get_work_area()->queue_draw();
return Smach::RESULT_ACCEPT;
}
}; // END of class StateRectangle
extern StateRectangle state_rectangle;
-
+
}; // END of namespace studio
/* === E N D =============================================================== */
Real original_mag;
std::vector<synfig::Vector> positions;
-
-
+
+
bool bad_drag;
bool move_only;
-
+
public:
etl::handle<CanvasView> canvas_view_;
bool use_magnitude;
class studio::StateRotate_Context : public sigc::trackable
{
etl::handle<CanvasView> canvas_view_;
-
+
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_refresh_tool_options(const Smach::event& x);
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
Smach::state<StateRotate_Context>("rotate")
{
insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateRotate_Context::event_refresh_tool_options));
-}
+}
StateRotate::~StateRotate()
{
void
StateRotate_Context::load_settings()
-{
+{
String value;
if(settings.get_value("rotate.scale",value) && value=="0")
void
StateRotate_Context::save_settings()
-{
+{
settings.set_value("rotate.scale",get_scale_flag()?"1":"0");
}
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(*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()->allow_layer_clicks=true;
get_work_area()->set_duck_dragger(duck_dragger_);
const DuckList selected_ducks(duckmatic->get_selected_ducks());
DuckList::const_iterator iter;
-
+
/*
if(duckmatic->get_selected_ducks().size()<2)
{
}
*/
bad_drag=false;
-
+
drag_offset=duckmatic->find_duck(offset)->get_trans_point();
//snap=drag_offset-duckmatic->snap_point_to_grid(drag_offset);
else
move_only=false;
-
+
synfig::Vector vect(offset-center);
original_angle=Angle::tan(vect[1],vect[0]);
original_mag=vect.mag();
{
if(bad_drag)
return;
-
+
//std::set<etl::handle<Duck> >::iterator iter;
synfig::Vector vect(duckmatic->snap_point_to_grid(vector)-center+snap);
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];
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+=center;
(*iter)->set_trans_point(p);
}
-
+
last_rotate=vect;
//snap=Vector(0,0);
}
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();
std::vector<synfig::Vector> positions;
bool move_only;
-
+
bool bad_drag;
public:
bool lock_aspect;
class studio::StateScale_Context : public sigc::trackable
{
etl::handle<CanvasView> canvas_view_;
-
+
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(); }
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
Smach::state<StateScale_Context>("scale")
{
insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateScale_Context::event_refresh_tool_options));
-}
+}
StateScale::~StateScale()
{
void
StateScale_Context::load_settings()
-{
+{
String value;
if(settings.get_value("scale.lock_aspect",value) && value=="0")
void
StateScale_Context::save_settings()
-{
+{
settings.set_value("scale.lock_aspect",get_aspect_lock_flag()?"1":"0");
}
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(*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()->allow_layer_clicks=true;
get_work_area()->set_duck_dragger(duck_dragger_);
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);
move_only=true;
else
move_only=false;
-
+
center=(vmin+vmax)*0.5;
}
if(bad_drag)
return;
-
+
//std::set<etl::handle<Duck> >::iterator iter;
synfig::Vector vect(duckmatic->snap_point_to_grid(vector)-center);
last_scale=vect;
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]=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];
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+=center;
(*iter)->set_trans_point(p);
}
-
+
last_scale=vect;
//snap=Vector(0,0);
}
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();
bool prev_table_status;
bool prev_workarea_layer_status_;
-
+
Gtk::Table options_table;
Gtk::Button button_clear_sketch;
Gtk::Button button_undo_stroke;
void load_sketch();
void undo_stroke();
void toggle_show_sketch();
-
+
public:
Smach::event_result event_stop_handler(const Smach::event& x);
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
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));
-}
+ 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()
{
StateSketch_Context::save_sketch()
{
synfig::String filename(basename(get_canvas()->get_file_name())+".sketch");
-
+
while(App::dialog_save_file(_("Save Sketch"), filename))
{
// If the filename still has wildcards, then we should
StateSketch_Context::load_sketch()
{
synfig::String filename(basename(get_canvas()->get_file_name())+".sketch");
-
+
while(App::dialog_open_file(_("Load Sketch"), filename))
{
// If the filename still has wildcards, then we should
App::ui_manager()->add_ui_from_string(ui_info);
-
+
checkbutton_show_sketch.set_active(get_work_area()->get_show_persistant_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.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()->allow_layer_clicks=false;
// Turn off duck clicking
get_work_area()->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();
-
+
// Hide the time bar
//get_canvas_view()->hide_timebar();
-
+
// Connect a signal
//get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateSketch_Context::on_user_click));
get_canvas_view()->work_area->reset_cursor();
App::dialog_tool_options->clear();
-
+
// Restore layer clicking
get_work_area()->allow_layer_clicks=prev_workarea_layer_status_;
// 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::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->set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-sketch")));
/*
App::dialog_tool_options->add_button(
get_canvas_view()->get_smach().push_state(&state_stroke);
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;
}
}
const EventStroke& event(*reinterpret_cast<const EventStroke*>(&x));
assert(event.stroke_data);
-
+
get_work_area()->add_persistant_stroke(event.stroke_data,synfigapp::Main::get_foreground_color());
return Smach::RESULT_ACCEPT;
}; // END of class StateSketch
extern StateSketch state_sketch;
-
+
}; // END of namespace studio
/* === E N D =============================================================== */
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);
void duck_drag(Duckmatic* duckmatic, const synfig::Vector& vector);
void set_radius(float x) { radius=x; }
- float get_radius()const { return radius; }
+ float get_radius()const { return radius; }
};
class studio::StateSmoothMove_Context : public sigc::trackable
{
etl::handle<CanvasView> canvas_view_;
-
+
//Duckmatic::Push duckmatic_push;
-
+
synfigapp::Settings& settings;
etl::handle<DuckDrag_SmoothMove> duck_dragger_;
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);
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
Smach::state<StateSmoothMove_Context>("smooth_move")
{
insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateSmoothMove_Context::event_refresh_tool_options));
-}
+}
StateSmoothMove::~StateSmoothMove()
{
void
StateSmoothMove_Context::load_settings()
-{
+{
String value;
if(settings.get_value("smooth_move.radius",value))
void
StateSmoothMove_Context::save_settings()
-{
+{
settings.set_value("smooth_move.radius",strprintf("%f",get_radius()));
}
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(*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()->allow_layer_clicks=true;
get_work_area()->set_duck_dragger(duck_dragger_);
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;
-
+
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;
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]);
}
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]);
}
-
+
last_translate_=vect;
//snap=Vector(0,0);
}
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)
{
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;
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
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()
{
get_work_area()->add_stroke(stroke_data, synfigapp::Main::get_foreground_color());
- synfig::info("Now Scribbling...");
+ synfig::info("Now Scribbling...");
}
StateStroke_Context::~StateStroke_Context()
{
duckmatic_push.restore();
-
+
App::toolbox->refresh();
- synfig::info("No longer scribbling");
+ synfig::info("No longer scribbling");
// Send the stroke data to whatever previously called this state.
if(stroke_data->size()>=2)
modifier=event.modifier;
throw Smach::pop_exception();
}
-
+
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;
}
}
{
stroke_data->push_back(event.pos);
width_data->push_back(event.pressure);
- get_work_area()->queue_draw();
+ get_work_area()->queue_draw();
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;
}
}
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)
{
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::Entry entry_id; //what to name the layer
-
+
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
+
+ void refresh_tool_options(); //to refresh the toolbox
//events
Smach::event_result event_stop_handler(const Smach::event& x);
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 StateGradient_Context
/* === M E T H O D S ======================================================= */
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 true
if(settings.get_value("width.relative",value) && value == "0")
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");
old_duckmask(get_work_area()->get_type_mask()),
settings(synfigapp::Main::get_selected_input_device()->settings()),
-
+
adj_delta(6,0,1,0.001,0.01),
spin_delta(adj_delta,0.01,3),
-
+
adj_radius(0,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);
+ //options_table.attach(*manage(new Gtk::Label(_("Width 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);
//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()->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();
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()->allow_duck_clicks = false;
get_work_area()->set_type_mask((Duck::Type)((int)Duck::TYPE_WIDTH + (int)Duck::TYPE_RADIUS));
// 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();
-
+
// Connect a signal
//get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateWidth_Context::on_user_click));
StateWidth_Context::~StateWidth_Context()
{
save_settings();
-
+
//remove ducks if need be
if(added)
{
get_work_area()->erase_duck(closestpoint);
added = false;
}
-
+
// Restore Duck clicking
get_work_area()->allow_duck_clicks = prev_workarea_duck_clicking;
// Restore the mouse pointer
get_work_area()->reset_cursor();
-
+
// Restore duck masking
get_work_area()->set_type_mask(old_duckmask);
// 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();
return Smach::RESULT_ACCEPT;
}
-void
+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 = (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)
{
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;
StateWidth_Context::event_mouse_handler(const Smach::event& x)
{
const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
-
- //handle ze click
+
+ //handle ze click
if( (event.key == EVENT_WORKAREA_MOUSE_BUTTON_DOWN || event.key == EVENT_WORKAREA_MOUSE_BUTTON_DRAG)
&& event.button == BUTTON_LEFT )
{
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]
-
+ //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(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"));
+ synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Sketch Width"));
for(; i != changetable.end(); ++i)
{
//for each duck modify IT!!!
{
Action::Handle action(Action::create("value_desc_set"));
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("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();
return Smach::RESULT_ERROR;
}
}
- }
-
+ }
+
changetable.clear();
-
+
get_work_area()->queue_draw();
-
+
return Smach::RESULT_ACCEPT;
}
}; // END of class StateWidth
extern StateWidth state_width;
-
+
}; // END of namespace studio
/* === E N D =============================================================== */
{
etl::handle<CanvasView> canvas_view_;
CanvasView::IsWorking is_working;
-
+
Point p1,p2;
-
+
bool prev_workarea_layer_status_;
-
+
//Toolbox settings
synfigapp::Settings& settings;
-
+
//Toolbox display
Gtk::Table options_table;
-
+
public:
- void refresh_tool_options(); //to refresh the toolbox
+ void refresh_tool_options(); //to refresh the toolbox
//events
Smach::event_result event_stop_handler(const Smach::event& x);
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 zoom(const Point& p1, const Point& p2);
-
+
}; // END of class StateGradient_Context
/* === M E T H O D S ======================================================= */
//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));
insert(event_def(EVENT_REFRESH_TOOL_OPTIONS,&StateZoom_Context::event_refresh_tool_options));
-}
+}
StateZoom::~StateZoom()
{
void
StateZoom_Context::load_settings()
-{
+{
String value;
-
+
//parse the arguments yargh!
/*if(settings.get_value("circle.feather",value))
set_feather(atof(value.c_str()));
else
- set_feather(0);*/
+ set_feather(0);*/
}
void
settings(synfigapp::Main::get_selected_input_device()->settings())
{
// Set up the tool options dialog
- //options_table.attach(*manage(new Gtk::Label(_("Zoom Tool"))), 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
+ //options_table.attach(*manage(new Gtk::Label(_("Zoom Tool"))), 0, 2, 0, 1, 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()->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();
-
+
// Connect a signal
//get_work_area()->signal_user_click().connect(sigc::mem_fun(*this,&studio::StateZoom_Context::on_user_click));
get_canvas_view()->work_area->set_cursor(Gdk::CROSSHAIR);
// 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();
if(x.key==EVENT_WORKAREA_BOX)
{
const EventBox& event(*reinterpret_cast<const EventBox*>(&x));
-
+
if(event.button==BUTTON_LEFT)
{
//respond to event box...
-
-
+
+
//Center the new position at the center of the box
-
+
//OH MY GOD HACK - the space is -1* and offset (by the value of the center of the canvas)...
Point newpos;
{
const Point realcenter = (get_work_area()->get_window_tl() + get_work_area()->get_window_br())/2;
newpos = -(evcenter - realcenter) + get_work_area()->get_focus_point();
}
-
+
//The zoom will be whatever the required factor to convert current box size to desired box size
Point tl = get_work_area()->get_window_tl();
Point br = get_work_area()->get_window_br();
-
+
Vector span = br - tl;
Vector v = event.p2 - event.p1;
-
+
//get the minimum zoom as long as it's greater than 1...
v[0] = abs(v[0])/abs(span[0]);
v[1] = abs(v[1])/abs(span[1]);
-
+
float zdiv = max(v[0],v[1]);
if(zdiv < 1 && zdiv > 0) //must be zoomable
{
- get_work_area()->set_focus_point(newpos);
+ get_work_area()->set_focus_point(newpos);
get_work_area()->set_zoom(get_work_area()->get_zoom()/zdiv);
}
-
+
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()->set_focus_point(evpos + v);
get_work_area()->set_zoom(get_work_area()->get_zoom()*ZOOMFACTOR);
}
-
+
return Smach::RESULT_ACCEPT;
}
}
StateManager::add_state(const Smach::state_base *state)
{
String name(state->get_name());
-
+
Glib::RefPtr<Gtk::Action> action(
Gtk::Action::create(
"state-"+name,
);
/*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(
"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);
{
private:
Glib::RefPtr<Gtk::ActionGroup> state_group;
-
+
guint merge_id;
std::vector<guint> merge_id_list;
StateManager();
~StateManager();
-
+
void add_state(const Smach::state_base *state);
Glib::RefPtr<Gtk::ActionGroup> get_action_group();
}
instance->safe_close();
-
+
//assert(instance.unique());
}
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("Layers, Children , Params",sigc::ptr_fun(_create_stock_dialog2)));
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)));
+ sigc::ptr_fun(&studio::App::new_instance)));
filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::OPEN,
- sigc::ptr_fun(&studio::App::dialog_open)));
+ 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(&studio::App::dialog_not_implemented)));
filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::CLOSE,
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::SeparatorElem());
filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID(Gtk::Stock::QUIT),
- sigc::ptr_fun(studio::App::quit)));
-
+ sigc::ptr_fun(studio::App::quit)));
+
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_not_implemented)));
- helpmenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem());
+ sigc::ptr_fun(studio::App::dialog_not_implemented)));
+ 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)));
-
+ 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");
TOOLBOX_BUTTON(button_redo,"gtk-redo","Redo");
ADD_TOOLBOX_BUTTON(button_about,"synfig-about","About Synfig Studio");
ADD_TOOLBOX_BUTTON(button_color,"synfig-color","Color Dialog");
-
+
TOOLBOX_BUTTON(button_rotoscope_bline,"synfig-rotoscope_bline",_("Old Rotoscope BLine"));
TOOLBOX_BUTTON(button_rotoscope_polygon,"synfig-rotoscope_polygon",_("Rotoscope Polygon"));
TOOLBOX_BUTTON(button_eyedrop,"synfig-eyedrop",_("Eyedrop Tool"));
TOOLBOX_BUTTON(button_rotoscope,"synfig-rotoscope_bline",_("Rotoscope 2"));
-
+
button_about->signal_clicked().connect(sigc::ptr_fun(studio::App::dialog_about));
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->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->attach(*handle_tools, 0, 1, 3, 4, Gtk::FILL|Gtk::EXPAND,Gtk::EXPAND|Gtk::FILL, 0, 0);
table1->attach(*handle_defaults, 0, 1, 4, 5, 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_resizable(false);
-
+
App::signal_instance_selected().connect(
sigc::hide(
sigc::mem_fun(*this,&studio::Toolbox::update_undo_redo)
);
button_undo->set_sensitive(false);
- button_redo->set_sensitive(false);
+ button_redo->set_sensitive(false);
button_rotoscope_bline->set_sensitive(false);
button_rotoscope->set_sensitive(false);
- button_rotoscope_polygon->set_sensitive(false);
- button_eyedrop->set_sensitive(false);
+ button_rotoscope_polygon->set_sensitive(false);
+ button_eyedrop->set_sensitive(false);
std::list<Gtk::TargetEntry> listTargets;
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));
}
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)
{
return;
}
-
+
if(state_button_map.count(statename))
{
state_button_map[statename]->clicked();
if(changing_state_)
return;
changing_state_=true;
-
+
try
{
etl::handle<studio::CanvasView> canvas_view(studio::App::get_selected_canvas_view());
{
if(state->get_name()==String("normal"))
{
- canvas_view->get_smach().egress();
+ canvas_view->get_smach().egress();
}
else
{
changing_state_=false;
throw;
}
-
+
changing_state_=false;
}
assert(state);
String name=state->get_name();
-
+
Gtk::ToggleButton* button;
button=manage(new class Gtk::ToggleButton());
icon->show();
button->show();
-
-
+
+
int row=state_button_map.size()/4;
int col=state_button_map.size()%4;
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());
+ 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 rotoscope buttons
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);
}
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;
// Check to see if the file is already on the list.
// If it is, then remove it from the list
recent_files_menu->items().push_back(Gtk::Menu_Helpers::MenuElem(basename(*iter),
sigc::hide_return(sigc::bind(sigc::ptr_fun(&App::open),*iter))
));
-
+
// HACK
show();
}
{
// 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()));
{
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);
+
+ synfig::info("Attempting to open "+filename);
if(App::open(filename))
success=true;
else
class Dockable;
class StateManager;
-
+
class Toolbox : public Gtk::Window
{
friend class studio::StateManager;
-
+
DialogSettings dialog_settings;
Gtk::Tooltips tooltips;
Gtk::Button *button_rotoscope;
Gtk::Button *button_rotoscope_bline;
Gtk::Button *button_rotoscope_polygon;
-
+
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_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 add_state(const Smach::state_base *state);
-
+
void dockable_registered(Dockable* x);
-
+
Toolbox();
virtual ~Toolbox();
-
+
};
}; // END of namespace studio
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();
if(h)
{
- return h->get_local_name();
+ return h->get_local_name();
}else return String();
}
return i;
}
}
-
+
return list.end();
}
ValueBaseLink::list_type::iterator ValueBaseLink::findlink(ValueNode::Handle x)
return i;
}
}
-
+
return list.end();
}
void ValueBaseLink::add(ValueNode::Handle v)
{
list_type::iterator i = findlink(v);
-
+
if(i != list.end())
{
list.push_back(v);
void ValueBaseLink::remove(ValueNode::Handle v)
{
list_type::iterator i = findlink(v);
-
+
if(i != list.end())
{
if(i != list.end()-1)
*i = list.back();
}
list.pop_back();
- }
+ }
}
//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
+
+ //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;
virtual void remove(synfig::ValueNode::Handle v);
};
-
+
}; // END of namespace studio
/* === E N D =============================================================== */
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)
{
catch(std::runtime_error x)
{
App::dialog_error_blocking(_("Error:Exception Thrown"),x.what());
- set_value_(canvas);
+ set_value_(canvas);
}
catch(...)
{
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();
{
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));
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);
-
+ 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);
-
+ 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;
// In this case we have a solid color to use
Gdk::Color gdk_c1(colorconv_synfig2gdk(color));
- gc->set_rgb_fg_color(gdk_c1);
+ 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"));
return true;
}
break;
-
+
default:
break;
}
//Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
const int h(get_height());
- const int w(get_width());
-
+ const int w(get_width());
+
render_color_to_window(get_window(),Gdk::Rectangle(0,0,w,h),color);
return true;
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_secondary_;
sigc::signal<void>& signal_activate() { return signal_activate_; }
sigc::signal<void>& signal_clicked() { return signal_activate_; }
sigc::signal<void>& signal_secondary() { return signal_secondary_; }
-
+
void set_value(const synfig::Color &data);
const synfig::Color &get_value();
Widget_Color();
bool on_event(GdkEvent *event);
}; // END of class Widget_Color
-
+
}; // END of namespace studio
/* === E N D =============================================================== */
slider_color_TYPE_SAT,
slider_color_TYPE_A,
};
-
+
slider_color_func color_func(jump_table[int(type)]);
-
+
float amount;
switch(type)
{
}
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);
const Color c2(Color::blend(color,bg2,1.0).clamped());
assert(c1.is_valid());
assert(c2.is_valid());
-
+
gushort r1;
gushort g1;
gushort b1;
gushort r2;
gushort g2;
gushort b2;
-
+
if(use_colorspace_gamma() && (type<TYPE_U))
{
r1=(256*App::gamma.r_F32_to_U8(gamma_out(c1.get_r())));
g2=(256*App::gamma.g_F32_to_U8(c2.get_g()));
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);
- get_window()->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), 1, height/2);
-
+ get_window()->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), 1, height/2);
+
gdk_c.set_rgb(r2,g2,b2);
gc->set_rgb_fg_color(gdk_c);
get_window()->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y()+height/2, 1, height/2);
{
gdk_c.set_rgb(r2,g2,b2);
gc->set_rgb_fg_color(gdk_c);
- get_window()->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), 1, height/2);
-
+ get_window()->draw_rectangle(gc, true, ca.get_x()+i, ca.get_y(), 1, height/2);
+
gdk_c.set_rgb(r1,g1,b1);
gc->set_rgb_fg_color(gdk_c);
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,
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"));
case GDK_BUTTON_RELEASE:
signal_activated_();
return true;
-
+
case GDK_MOTION_NOTIFY:
// adjust_color(type,color_,pos);
signal_slider_moved_(type,pos);
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);
color=Color(0,0,0,0);
set_size_request(150,-1);
- hold_signals=true;
+ 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_ROW(1,A,_("Alpha"));
ATTACH_SPIN_BUTTON(1,A);
}
-
+
#undef SLIDER_ROW
-#undef ATTACH_SPIN_BUTTON
-
+#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));
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(type==ColorSlider::TYPE_B && color.get_b()<0)clamp_=false;
*/
clamp_=false;
-
+
set_value(color);
assert(color.is_valid());
}
{
if(hold_signals)
return;
-
+
const Color color(get_value_raw());
assert(color.is_valid());
slider_R->set_color(color);
}
color.set_a(A_adjustment.get_value()/100);
assert(color.is_valid());
-
+
return color;
}
}
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;
}
TYPE_HUE,
TYPE_SAT,
TYPE_A,
-
+
TYPE_END
};
-
+
private:
sigc::signal<void,Type,float> signal_slider_moved_;
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_;
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::Adjustment G_adjustment;
Gtk::Adjustment B_adjustment;
Gtk::Adjustment A_adjustment;
-
+
synfig::Color color;
Gtk::Notebook* notebook;
protected:
-
+
void on_value_changed();
public:
void on_slider_moved(ColorSlider::Type type, float amount);
//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);
Widget_ColorEdit();
~Widget_ColorEdit();
}; // END of class Widget_ColorEdit
-
+
}; // END of namespace studio
/* === E N D =============================================================== */
else
set_history(0);
- set_selected_instance_(x);
+ set_selected_instance_(x);
}
void
{
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> >(
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
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();
{
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));
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);
-
+ 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);
-
+ 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;
// In this case we have a solid color to use
Gdk::Color gdk_c1(colorconv_synfig2gdk(color));
- gc->set_rgb_fg_color(gdk_c1);
+ 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"));
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="tsplit";
channels.back().color=Gdk::Color("#ff00ff");
-
+
channels.push_back(Channel());
channels.back().name="t1.x";
channels.back().color=Gdk::Color("#ff0000");
throw synfig::Exception::BadType("Bad type for curves");
}
}
-
+
void clear_all_values()
{
DEBUGPOINT();
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.
default:
return 0;
}
-
+
return -channels[chan].values[time];
}
};
)
);
//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()
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)
{
}
return true;
-
+
/* switch(event->type)
{
case GDK_BUTTON_PRESS:
return true;
}
break;
-
+
default:
break;
}
Widget_Curves::redraw(GdkEventExpose*bleh)
{
const int h(get_height());
- const int w(get_width());
+ const int w(get_width());
get_window()->clear();
-
+
if(!time_adjustment_ || !range_adjustment_ || !h || !w)
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 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];
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);
+
+ 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;
}
Gtk::Adjustment* time_adjustment_;
Gtk::Adjustment* range_adjustment_;
-
+
std::list<CurveStruct> curve_list_;
-
+
public:
Widget_Curves();
bool on_event(GdkEvent *event);
}; // END of class Widget_Curves
-
+
}; // END of namespace studio
/* === E N D =============================================================== */
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());
+ 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
+ else
{
RendDesc rend_desc;
pixelsize=synfigapp::Main::get_bline_width().get(Distance::SYSTEM_PIXELS,rend_desc);
/*
gc->set_rgb_fg_color(colorconv_synfig2gdk(synfigapp::Main::get_background_color()));
- gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+ gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
get_window()->draw_rectangle(
gc,
true, // Fill?
w,h //w,h
);
*/
-
+
// Draw in the circle
gc->set_rgb_fg_color(colorconv_synfig2gdk(synfigapp::Main::get_foreground_color()));
gc->set_function(Gdk::COPY);
round_to_int(pixelsize+0.6),
0,
360*64
- );
-
+ );
+
return true;
}
{
// 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 w(get_width());
+
switch(event->type)
{
case GDK_MOTION_NOTIFY:
if(event->button.button==1) // Left click
{
Distance dist(synfigapp::Main::get_bline_width());
-
+
if(y<h/2) // increase BLine size
{
dist+=DEFAULT_INCREMENT;
case GDK_SCROLL:
{
Distance dist(synfigapp::Main::get_bline_width());
-
+
if(event->scroll.direction==GDK_SCROLL_UP)
{
dist+=DEFAULT_INCREMENT;
default:
break;
}
-
+
return false;
}
{
//set_size_request(48,48+GRADIENT_HEIGHT+16);
//set_size_request(48,-1);
-
+
{
Gtk::Table* subtable(manage(new Gtk::Table()));
-
+
// Foreground Color
widget_fg_color=manage(new Widget_Color());
widget_fg_color->show();
widget_fg_color->signal_clicked().connect(sigc::mem_fun(*this,&Widget_Defaults::on_fg_color_clicked));
subtable->attach(*widget_fg_color, 0, 2, 0, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
tooltips_.set_tip(*widget_fg_color,_("Foreground Color"));
-
+
// Background Color
widget_bg_color=manage(new Widget_Color());
widget_bg_color->show();
tooltips_.set_tip(*widget_bg_color,_("Background Color"));
Gtk::Image* icon;
-
+
// Swap button
Gtk::Button* button_swap(manage(new Gtk::Button()));
button_swap->show();
subtable->attach(*button_reset, 0,1, 2, 3, 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);
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_foreground_color());
}
*/
}
-
+
Widget_Defaults::~Widget_Defaults()
{
}
Glib::RefPtr<Gdk::GC> gc(Gdk::GC::create(get_window()));
const int h(get_height());
- const int w(get_width());
+ 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_background_color());
render_color_to_window(get_window(),Gdk::Rectangle(0,0,size/4*3-1,size/4*3-1),synfigapp::Main::get_foreground_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_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);
const int y(static_cast<int>(event->button.y));
const int h(get_height());
- const int w(get_width());
+ const int w(get_width());
const int size=std::min(h-GRADIENT_HEIGHT,w);
switch(event->type)
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;
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;
default:
break;
}
-
+
return false;
}
*/
class Widget_Color;
class Widget_Distance;
class Widget_Enum;
-
+
class Widget_Defaults : public Gtk::Table
{
Widget_Brush *widget_brush;
Widget_Enum *widget_blend_method;
Widget_Enum *widget_interpolation;
Gtk::HScale *widget_opacity;
-
+
void fg_color_refresh();
void bg_color_refresh();
void gradient_refresh();
void bline_width_refresh();
void interpolation_refresh();
-
+
void on_bline_width_changed();
void on_fg_color_clicked();
void on_bg_color_clicked();
void on_opacity_changed();
Gtk::Tooltips tooltips_;
-
+
public:
-
+
Widget_Defaults();
-
+
~Widget_Defaults();
// bool redraw(GdkEventExpose*bleh=NULL);
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();
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,
name=iter->local_name;
enum_menu->items().push_front(Gtk::Menu_Helpers::MenuElem(name));
-
- set_menu(*enum_menu);
+
+ set_menu(*enum_menu);
}
void
Widget_Enum::set_value(int data)
{
value=data;
-
+
refresh();
-
+
set_history(0);
}
{
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();
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);
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);
-
+ 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);
{
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);
-
+ 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);
add_events(Gdk::BUTTON1_MOTION_MASK);
}
-
+
Widget_Gradient::~Widget_Gradient()
{
}
{
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_)
show_selected=true;
}
}
-
+
// we do this so that we can be sure that
// the selected marker is shown on top
if(show_selected)
CONTROL_HEIGHT
);
}
-
+
return true;
}
Widget_Gradient::popup_menu(float x)
{
Gtk::Menu* menu(manage(new Gtk::Menu()));
-
+
menu->items().clear();
menu->items().push_back(
)
);
}
-
+
menu->popup(0,0);
}
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)
{
Gradient::iterator iter(gradient_.find(selected_cpoint));
-
+
if(event->button.state&GDK_SHIFT_MASK)
{
float begin(-100000000),end(100000000);
{
end=after->pos;
}
-
+
if(pos>end)
pos=end;
if(pos<begin)
pos=begin;
-
- iter->pos=pos;
+
+ iter->pos=pos;
}
else
{
iter->pos=pos;
gradient_.sort();
}
-
+
// signal_value_changed_();
changed_=true;
queue_draw();
break;
}
}
-
+
return false;
}
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 popup_menu(float x);
- void insert_cpoint(float x);
+ void insert_cpoint(float x);
+
+ void remove_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_; }
-
+ 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);
/* === M E T H O D S ======================================================= */
/* === E N T R Y P O I N T ================================================= */
-
+
studio::Widget_Sound::Widget_Sound()
{
}
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();
+ adj_timescale->changed(); adj_timescale->value_changed();
}else
if(t > upper)
{
//set the profile
audioprof = p;
-
+
if(!audioprof)
{
clear();
return false;
}
-
+
return true;
}
}
bool studio::Widget_Sound::on_expose_event(GdkEventExpose *heh)
-{
- if(!get_window()) return false;
+{
+ 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");
+ 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)
+ 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
+ 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",
+
+ /*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)
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;
}
{
//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
//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);
}
/* === C L A S S E S & S T R U C T S ======================================= */
namespace studio {
-
+
class AudioProfile;
class AudioContainer;
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: //interface
void draw();
-
+
void clear();
};
if(abs(newtime-time_)>=0.001)
{
time_=newtime;
- refresh_text();
+ refresh_text();
signal_value_changed()();
}
}
Widget_Time::on_event(GdkEvent* event)
{
const Time scroll_amount(0.25);
-
+
switch(event->type)
{
case GDK_SCROLL:
default:
break;
}
-
+
return Gtk::Entry::on_event(event);
}
Widget_Time::on_focus_out_event(GdkEventFocus* event)
{
refresh_value();
- refresh_text();
+ refresh_text();
return Gtk::Entry::on_focus_out_event(event);
}
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);
{
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
Gdk::Color color;
std::vector<Gdk::Point> points;
-
+
/*- BEFORE ------------------------------------- */
color=get_interp_color(tp.get_before());
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);
+ window->draw_lines(gc,points);
break;
case INTERPOLATION_CONSTANT:
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);
+ window->draw_lines(gc,points);
break;
case INTERPOLATION_UNDEFINED: default:
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);
+ window->draw_lines(gc,points);
break;
}
-
+
/*- AFTER -------------------------------------- */
color=get_interp_color(tp.get_after());
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);
+ window->draw_lines(gc,points);
break;
case INTERPOLATION_CONSTANT:
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);
+ window->draw_lines(gc,points);
break;
case INTERPOLATION_UNDEFINED: default:
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);
+ window->draw_lines(gc,points);
break;
}
dragscroll(false)
{
set_size_request(-1,fullheight);
-
+
// click scroll zoom
- add_events( Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK
+ add_events( Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK
| Gdk::BUTTON_MOTION_MASK | Gdk::SCROLL_MASK );
-
+
set_time_adjustment(&adj_default);
//update_times();
}
//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));
+ time_other_change = x->signal_changed().connect(sigc::mem_fun(*this,&Widget_Timeslider::queue_draw));
//invalidated = true;
//refresh();
}
if(fps != d)
{
fps = d;
-
+
//update everything since we need to redraw already
//invalidated = true;
//refresh();
}
}*/
-void Widget_Timeslider::refresh()
+void Widget_Timeslider::refresh()
{
}
-/*
+/*
{
if(invalidated)
{
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);
+
+ 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();
-
+ //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);
-
+
+ window->draw_rectangle(gc,true,0,0,w,h);
+
const double EPSILON = 1e-6;
if(!adj_timescale || w == 0) return true;
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"));
+ gc->set_rgb_fg_color(Gdk::Color("#333333"));
//draw these lines... (always 5 between) maybe 6?
const int subdiv = 4;
//1h 45 30 20 10 5
//..., 3m, 2m, 1m30s, 1m, 30s, 20s, 10s, 5s, 3s, 2s, 1s, 0.5s
//frames... (how???)
- double ranges[] =
+ double ranges[] =
{ 1.0/fps,subdiv/fps,0.25,0.5, 1, 2, 3, 5, 10, 20, 30, 60, 90, 120, 180, 300, 600, 1200, 1800, 2700, 3600 };
//{ 3600, 2700, 1800, 1200, 600, 300, 180, 120, 90, 60, 30, 20, 10, 5, 3, 2, 1, 0.5 };
const int ranges_size = sizeof(ranges)/sizeof(double);
-
+
double lowerrange = dtdp*75, upperrange = dtdp*150;
double midrange = (lowerrange + upperrange)/2;
-
+
//find most ideal scale
double scale = ranges[0];
{
double *val = binary_find(ranges, ranges+ranges_size, midrange);
double *after = val+1;
-
+
if(val >= ranges+ranges_size)
{
val = ranges+ranges_size-1;
}
-
+
if(after >= ranges+ranges_size)
{
after = ranges+ranges_size-1;
}
-
+
scale = *val;
-
+
double diff = abs(scale - midrange), diff2 = abs(*after - midrange);
if(diff2 < diff)
scale = *after;
}
-
- //synfig::info("Range found: (l %.2lf,u %.2lf - m %.2lf) -> %.2lf",lowerrange,upperrange,midrange,scale);
-
- //search around this area to get the right one
-
-
+
+ //synfig::info("Range found: (l %.2lf,u %.2lf - m %.2lf) -> %.2lf",lowerrange,upperrange,midrange,scale);
+
+ //search around this area to get the right one
+
+
//get first valid line and it's position in pixel space
double time = 0;
double pixel = 0;
-
+
int sdindex = 0;
double subr = scale / subdiv;
-
+
//get it's 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...
-
+
//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
+
+ //draw big
if(sdindex == 0)
{
window->draw_line(gc,xpx,0,xpx,heightbig);
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);
window->draw_layout(gc,xpx+2,heightsmall,layout);
}else
{
- window->draw_line(gc,xpx,0,xpx,heightsmall);
+ 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)
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)
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);
lastx = curx;
//lasty = cury;
}
-
- return true;
+
+ 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)
{
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();
-
+ //update_times();
+
//figure out if we should center ourselves on the current time
bool center = false;
{
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;
}
-
- default:
+
+ 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)
{
{
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)
{
{
start = adj_bounds->get_lower();
}
-
+
if(end > adj_bounds->get_upper())
{
- 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();
}
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",
+
+ /*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:
{
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;
}
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.)
+ 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)
*/
//HACK - I should not have to see this...
Gtk::Adjustment *adj_bounds;
-
+
//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
void set_global_fps(float d);
//accessors for the time adjustment
- Gtk::Adjustment &get_time_adjustment() const {return *adj_timescale;}
+ 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;}
+ 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 =============================================================== */
angle_adjustment(0,-2000000000,2000000000,1,1,1)
{
set_no_show_all();
-
+
label=manage(new class Gtk::Label("Unknown Datatype"));
pack_start(*label);
label->show();
angle_widget=manage(new class Gtk::SpinButton(angle_adjustment,15,2));
pack_start(*angle_widget);
- bool_widget=manage(new class Gtk::CheckButton());
+ bool_widget=manage(new class Gtk::CheckButton());
pack_start(*bool_widget);
//color_widget=manage(new class Gtk::ColorSelection());
string_widget=manage(new class Gtk::Entry());
pack_start(*string_widget);
-
+
canvas_widget=manage(new class Widget_CanvasChooser());
pack_start(*canvas_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));
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(
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);
filename_widget->hide();
time_widget->hide();
distance_widget->hide();
-
+
value=data;
try{
switch(value.get_type())
{
value=enum_widget->get_value();
}
-
+
break;
case ValueBase::TYPE_BOOL:
value=bool_widget->get_active();
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;
*/
}
return value;
}
-
+
void
Widget_ValueBase::on_grab_focus()
{
enum_widget->grab_focus();
}
-
+
break;
case ValueBase::TYPE_BOOL:
bool_widget->grab_focus();
return distance_widget->signal_activate();
else
return real_widget->signal_activate();
-
+
break;
case ValueBase::TYPE_TIME:
return time_widget->signal_activate();
return integer_widget->signal_activate();
else
return enum_widget->signal_activate();
-
+
break;
case ValueBase::TYPE_BOOL:
return string_widget->signal_activate();
class Widget_Vector;
class Widget_Time;
class Widget_Distance;
-
+
class Widget_ValueBase : public Gtk::HBox
{
Gtk::Label *label;
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_;
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; }
y_adjustment(0,-100000000,100000000,0.05,0.05,0.05)
{
Gtk::Label *label;
-
+
label=manage(new class Gtk::Label("X:"));
label->set_alignment(0, 0.5);
label->show();
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));
}
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);
namespace studio {
class Widget_Distance;
-
+
class Widget_Vector : public Gtk::HBox
{
Gtk::SpinButton* spinbutton_x;
Widget_Distance* distance_x;
Widget_Distance* distance_y;
-
+
Gtk::Adjustment x_adjustment;
Gtk::Adjustment y_adjustment;
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 set_digits(int x);
Widget_Vector();
~Widget_Vector();
-
+
protected:
void show_all_vfunc();
}; // END of class Widget_Vector
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));
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>"));
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);
{
canvas=x;
assert(canvas);
-
+
time_widget->set_fps(canvas->rend_desc().get_frame_rate());
value_widget->set_canvas(canvas);
}
time_widget->set_fps(canvas->rend_desc().get_frame_rate());
waypoint=x;
-
+
#warning This really needs to be fixed to support value node waypoints!
if(waypoint.is_static())
{
value_widget->hide();
value_node_label->show();
}
-
+
time_widget->set_value(waypoint.get_time());
before->set_history((int)waypoint.get_before());
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
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));
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(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(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(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(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(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(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();
{
if(updating)
return;
-
+
waypoint_model.set_before((Waypoint::Interpolation)before->get_history());
waypoint_model.set_after((Waypoint::Interpolation)after->get_history());
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());
{
waypoint_model=x;
updating=true;
-
+
before->set_history((int)waypoint_model.get_before());
after->set_history((int)waypoint_model.get_after());
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();
}
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::CheckButton checkbutton_temporal_tension;
void on_change();
-
+
public:
Widget_WaypointModel();
void set_waypoint_model(synfig::Waypoint::Model &x);
int twindow_start, twindow_width, twindow_height, twindow_pad;
int refresh_id;
-
+
bool onionskin;
bool onion_first_tile;
int onion_layers;
void set_onion_skin(bool x)
{
onionskin=x;
-
+
Time time(rend_desc().get_time_start());
-
+
onion_skin_queue.push_back(time);
//onion_skin_queue.push_back(time-1);
//onion_skin_queue.push_back(time+1);
-
+
try
{
onion_skin_queue.push_back(
}
catch(...)
{ }
-
+
try
{
onion_skin_queue.push_back(
}
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()),
set_canvas(workarea->get_canvas());
set_quality(workarea->get_quality());
}
-
+
~WorkAreaTarget()
{
workarea->queue_draw();
workarea->get_w()!=w
|| workarea->get_h()!=h
) workarea->set_wh(w,h,4);
-
+
workarea->full_frame=false;
desc=*newdesc;
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();
}
else
return 0;
-
+
return onion_skin_queue.size()+1;
}
{
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();
return total_tiles()-curr_tile+1;
}
-
+
virtual bool start_frame(synfig::ProgressCallback *cb)
{
synfig::Mutex::Lock lock(mutex);
//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));
return false;
Glib::RefPtr<Gdk::Pixbuf> pixbuf;
-
+
pixbuf=Gdk::Pixbuf::create_from_data(
buffer, // pointer to the data
Gdk::COLORSPACE_RGB, // the colorspace
surface.get_h(), // height
surface.get_w()*synfig::channels(pf), // stride (pitch)
sigc::ptr_fun(&WorkAreaTarget::free_buff)
- );
+ );
if(low_res)
{
Gdk::INTERP_NEAREST
);
}
-
+
if(!onionskin || onion_first_tile || !workarea->tile_book[index].first)
- {
+ {
workarea->tile_book[index].first=pixbuf;
}
else
255/(onion_layers-onion_skin_queue.size()+1) //int overall_alpha
);
}
-
+
//if(index%2)
- workarea->queue_draw();
+ workarea->queue_draw();
assert(workarea->tile_book[index].first);
return true;
}
int twindow_start, twindow_width, twindow_height, twindow_pad;
int refresh_id;
-
+
bool onionskin;
bool onion_first_tile;
int onion_layers;
void set_onion_skin(bool x)
{
onionskin=x;
-
+
Time time(rend_desc().get_time_start());
-
+
onion_skin_queue.push_back(time);
//onion_skin_queue.push_back(time-1);
//onion_skin_queue.push_back(time+1);
if(!onionskin)
return;
-
+
try
{
onion_skin_queue.push_back(
}
catch(...)
{ }
-
+
try
{
onion_skin_queue.push_back(
}
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()),
set_canvas(workarea->get_canvas());
set_quality(workarea->get_quality());
}
-
+
~WorkAreaTarget_Full()
{
}
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;
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 0;
return onion_skin_queue.size()+1;
}
-
+
virtual bool start_frame(synfig::ProgressCallback *cb)
{
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));
}
Glib::RefPtr<Gdk::Pixbuf> pixbuf;
-
+
pixbuf=Gdk::Pixbuf::create_from_data(
buffer, // pointer to the data
Gdk::COLORSPACE_RGB, // the colorspace
surface.get_h(), // height
surface.get_w()*synfig::channels(pf), // stride (pitch)
sigc::ptr_fun(&WorkAreaTarget::free_buff)
- );
+ );
if(low_res)
{
Gdk::INTERP_NEAREST
);
}
-
+
int index=0;
-
+
if(!onionskin || onion_first_tile || !workarea->tile_book[index].first)
- {
+ {
workarea->tile_book[index].first=pixbuf;
}
else
255/(onion_layers-onion_skin_queue.size()+1) //int overall_alpha
);
}
-
- workarea->queue_draw();
+
+ workarea->queue_draw();
assert(workarea->tile_book[index].first);
}
};
show_grid(false),
tile_w(128),
tile_h(128)
-{
+{
show_guides=true;
curr_input_device=0;
full_frame=false;
render_idle_func_id=0;
zoom=prev_zoom=1.0;
quality=10;
- rendering=false;
+ rendering=false;
canceled_=false;
low_resolution=true;
pw=0.001;
queued=false;
dirty_trap_enabled=false;
solid_lines=true;
-
+
dirty_trap_queued=0;
meta_data_lock=false;
// 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->modify_bg(Gtk::STATE_SELECTED,Gdk::Color("#00ff00"));
*/
//drawing_frame->set_state(Gtk::STATE_NORMAL);
-
+
drawing_frame->show();
-
+
attach(*drawing_frame, 1, 3+RULER_FIX, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
Gtk::IconSize iconsize=Gtk::IconSize::from_name("synfig-small_icon");
menubutton->signal_pressed().connect(sigc::mem_fun(*this, &WorkArea::popup_menu));
attach(*menubutton, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
-
+
Gtk::VScrollbar *vscrollbar1 = manage(new class Gtk::VScrollbar(*get_scrolly_adjustment()));
Gtk::HScrollbar *hscrollbar1 = manage(new class Gtk::HScrollbar(*get_scrollx_adjustment()));
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));
set_focus_point(Point(0,0));
- load_meta_data();
+ load_meta_data();
// Load sketch
{
String data(canvas->get_meta_data("sketch"));
}
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())
canvas_interface->set_meta_data("guide_y",data);
}
-
+
if(get_sketch_filename().size())
{
if(dirname(canvas->get_file_name())==dirname(get_sketch_filename()))
if(meta_data_lock)
return;
meta_data_lock=true;
-
+
String data;
data=canvas->get_meta_data("grid_size");
float gx(get_grid_size()[0]),gy(get_grid_size()[1]);
String::iterator iter(find(data.begin(),data.end(),' '));
- String tmp(data.begin(),iter);
-
+ String tmp(data.begin(),iter);
+
if(!tmp.empty())
gx=stratof(tmp);
-
+
if(iter==data.end())
tmp.clear();
else
if(!tmp.empty())
gy=stratof(tmp);
-
+
set_grid_size(Vector(gx,gy));
}
else
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);
+ 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);
+ String guide(data.begin(),iter);
if(!guide.empty())
get_guide_list_y().push_back(stratof(guide));
-
+
if(iter==data.end())
data.clear();
else
queue_draw();
}
-void
+void
WorkArea::disable_grid()
{
show_grid=false;
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);
+ get_scrolly_adjustment()->set_value(adjusted[1]*y_factor);
}
synfig::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;
-
+
return synfig::Point(get_scrollx_adjustment()->get_value()*x_factor, get_scrolly_adjustment()->get_value()*y_factor);
}
}
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;
refresh_dimension_info();
tile_book.clear();
-
+
return true;
}
return false;
Real multiplier(1.0);
-
+
if(Gdk::ModifierType(event->state)&GDK_SHIFT_MASK)
multiplier=10.0;
-
+
Vector nudge;
switch(event->keyval)
{
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 {
+ try {
start_duck_drag(get_selected_duck()->get_trans_point());
translate_selected_ducks(get_selected_duck()->get_trans_point()+nudge*multiplier);
end_duck_drag();
set_grid_snap(grid_snap_holder);
set_guide_snap(guide_snap_holder);
-
+
return true;
}
float pressure(0);
bool is_mouse(false);
Gdk::ModifierType modifier(Gdk::ModifierType(0));
-
+
drawing_area->grab_focus();
-
+
// Handle input stuff
if(
event->any.type==GDK_MOTION_NOTIFY ||
device=event->button.device;
modifier=Gdk::ModifierType(event->button.state);
}
-
+
// Make sure we recognise the device
if(curr_input_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
//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)
//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;
+ // button_pressed=0;
}
}
// GDK mouse scrolling events
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)
{
clicked_duck=0;
}
//else
// clear_selected_ducks();
-
-
-
+
+
+
selected_bezier=find_bezier(mouse_pos,radius,&bezier_click_pos);
if(duck && duck->get_editable())
{
}
// I commented out this section because
// it was causing issues when rotoscoping.
-// At the moment, we don't need it, so
+// At the moment, we don't need it, so
// this was the easiest way to fix the problem.
/*
else
{
// Check for a guide click
GuideList::iterator iter;
-
+
iter=find_guide_x(mouse_pos,radius);
if(iter==get_guide_list_x().end())
{
{
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)
{
bezier->signal_user_click(2)(bezier_click_pos);
return true;
}
- else
+ else
if(layer)
{
- if(canvas_view->get_smach().process_event(EventLayerClick(layer,BUTTON_RIGHT,mouse_pos))==Smach::RESULT_OK)
+ 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));
+ 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)
{
last_event_time=event->motion.time;
signal_cursor_moved_();
-
+
// Guide/Duck hilights 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;
}
}
-
+
if(dragging==DRAG_DUCK)
{
if(canvas_view->get_cancel_status())
}
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)
}
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;
if(!drag_did_anything)
{
//etl::handle<Duck> duck=find_duck(mouse_pos,radius);
-
+
if(modifier&GDK_SHIFT_MASK)
{
//synfig::info("DUCK_DRAG_RELEASE: SHIFT-MASK ON!");
clear_selected_ducks();
select_duck(clicked_duck);
}
- }
+ }
if(clicked_duck)clicked_duck->signal_user_click(0)();
}
else
ret=true;
}
-
+
if(dragging==DRAG_BOX)
- {
+ {
dragging=DRAG_NONE;
if((drag_point-mouse_pos).mag()>radius/2.0f)
{
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)
+ if(canvas_view->get_smach().process_event(EventLayerClick(layer,BUTTON_LEFT,mouse_pos,modifier))==Smach::RESULT_OK)
signal_layer_selected_(layer);
ret=true;
}
}
}
}
-
+
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;
if(modifier&GDK_CONTROL_MASK)
{
-
+
// The zoom is performed while preserving the pointer
// position as a fixed point (similarly to Xara Xtreme and
// Inkscape).
}
}
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
x=event->button.x;
y=event->button.y;
}
-
+
if(isnan(y) || isnan(x))
- return false;
-
+ 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)
{
canvasheight=rend_desc.get_br()[1]-rend_desc.get_tl()[1];
pw=canvaswidth/w;
- ph=canvasheight/h;
+ ph=canvasheight/h;
scrollx_adjustment.set_page_increment(abs(get_grid_size()[0]));
scrollx_adjustment.set_step_increment(abs(pw));
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);
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);
-
+
const int width_in_tiles(w/tile_w+(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++)
{
F func;
public:
handle2ptr_t(const F &func):func(func) { };
-
+
R operator()(typename etl::handle<T> x) { return func(*x); }
};
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;
);
}
}
-
-
+
+
// Calculate the window coordinates of the top-left
// corner of the canvas.
//const synfig::Vector::value_type
//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(canvas_interface->get_mode()&synfigapp::MODE_ANIMATE)
{
/*gc->set_rgb_fg_color(Gdk::Color("#FF0000"));
- gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
+ gc->set_line_attributes(1,Gdk::LINE_SOLID,Gdk::CAP_BUTT,Gdk::JOIN_MITER);
drawing_area->get_window()->draw_rectangle(
gc,
false, // Fill?
- previous_focus=get_focus_point();
+ previous_focus=get_focus_point();
return true;
}
// 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.
+ // go ahead and de-queue it.
if(render_idle_func_id)
{
- g_source_remove(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);
-
+
// Setup the description parameters
- desc.set_antialias(1);
+ desc.set_antialias(1);
desc.set_time(cur_time);
-
+
set_rend_desc(desc);
// Create the render target
handle<Target> target;
-
+
if(w*h>(low_resolution?480*270:480*270/2))
{
handle<WorkAreaTarget> trgt(new class WorkAreaTarget(this,w,h));
trgt->set_onion_skin(get_onion_skin());
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.
rendering=true;
cb->task("Rendering...");
rendering=true;
-
+
return true;
}
-void
+void
studio::WorkArea::async_update_finished()
{
synfig::ProgressCallback *cb=get_canvas_view()->get_ui_interface().get();
if(!async_renderer)
return;
-
+
// If we completed successfuly, then
// we aren't dirty anymore
if(async_renderer->has_success())
// 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)
{
}
if(!is_visible())return false;
- get_canvas()->set_time(get_time());
+ 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.
+ // go ahead and de-queue it.
if(render_idle_func_id)
{
- g_source_remove(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();
-
+
bool ret=false;
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_antialias(1);
desc.set_time(cur_time);
//desc.set_wh(w,h);
-
+
set_rend_desc(desc);
// Create the render target
// 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()));
target->render(cb);
-
+
if(!ret && !get_canvas_view()->get_cancel_status() && dirty)
{
rendering=false;
}
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);
+ 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 successfuly, then
// we aren't dirty anymore
if(ret)
refreshes+=5;
if(!is_visible())return;
- get_canvas()->set_time(get_time());
+ get_canvas()->set_time(get_time());
get_canvas_view()->get_smach().process_event(EVENT_REFRESH_DUCKS);
signal_rendering()();
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);
return;
const int
- dx(round_to_int(old_x)-round_to_int(new_x)),
+ 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);
/*drawing_area->queue_draw_area(
*/
//async_renderer=0;
}
-
+
if(dirty_trap_enabled)
{
dirty_trap_queued++;
return;
}
-
+
int queue_time=50;
-
+
if(rendering)
queue_time+=250;
-
+
if(queued==false)
{
DirtyTrap::DirtyTrap(WorkArea *work_area):work_area(work_area)
{
work_area->dirty_trap_enabled=true;
-
+
work_area->dirty_trap_queued=0;
}
typedef etl::loose_handle<T_> first_argument_type;
typedef etl::loose_handle<T_> second_argument_type;
typedef bool result_type;
-
+
}
};
*/
friend class WorkAreaTarget_Full;
friend class DirtyTrap;
friend class WorkAreaRenderer;
-
+
/*
-- ** -- P U B L I C T Y P E S ---------------------------------------------
*/
-
+
public:
void insert_renderer(const etl::handle<WorkAreaRenderer> &x);
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)
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;
bool show_guides;
bool low_resolution;
-
+
bool meta_data_lock;
- //! This flag is set if the entire frame is rendered rather than using tiles
+ //! 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;
synfig::Point last_focus_point;
bool canceled_;
-
+
int quality;
bool dirty_trap_enabled;
-
+
int dirty_trap_queued;
-
-
+
+
bool onion_skin;
-
+
etl::loose_handle<synfig::ValueNode> selected_value_node_;
int get_tile_w()const { return tile_w; }
int get_tile_h()const { return tile_h; }
-
+
bool solid_lines;
bool rendering;
bool dirty;
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; }
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; }
void set_quality(int x);
-
+
int get_w()const { return w; }
int get_h()const { return h; }
//! ??
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;
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; }
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);
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 -------------------------------------
*/
{
work_area_=x;
}
-
+
void
WorkAreaRenderer::render_vfunc(
const Glib::RefPtr<Gdk::Drawable>& window,
int
WorkAreaRenderer::get_h()const
{ return get_work_area()->get_h(); }
-
+
float
WorkAreaRenderer::get_pw()const
{ return get_work_area()->get_pw(); }
namespace studio {
class WorkArea;
-
+
class WorkAreaRenderer : public etl::shared_object, public sigc::trackable
{
public:
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;
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
Gtk::Tooltips tooltips;
Gtk::IconSize iconsize;
-
+
public:
Gtk::Button *zoom_in;
Gtk::Button *zoom_out;
be.get_param_vocab=x::get_param_vocab; \
be.is_candidate=x::is_candidate; \
}
-
+
Action::Main::Main()
{
book_=new synfigapp::Action::Book();
-
+
ADD_ACTION(Action::LayerRemove);
ADD_ACTION(Action::LayerMove);
ADD_ACTION(Action::LayerRaise);
ADD_ACTION(Action::LayerEncapsulate);
ADD_ACTION(Action::LayerDuplicate);
ADD_ACTION(Action::LayerSetDesc);
-
- ADD_ACTION(Action::ValueNodeConstSet);
- ADD_ACTION(Action::ValueNodeAdd);
- ADD_ACTION(Action::ValueNodeReplace);
+
+ ADD_ACTION(Action::ValueNodeConstSet);
+ ADD_ACTION(Action::ValueNodeAdd);
+ ADD_ACTION(Action::ValueNodeReplace);
ADD_ACTION(Action::ValueNodeLinkConnect);
ADD_ACTION(Action::ValueNodeLinkDisconnect);
ADD_ACTION(Action::ValueNodeDynamicListInsert);
ADD_ACTION(Action::ValueNodeDynamicListRotateOrder);
ADD_ACTION(Action::ValueNodeRename);
ADD_ACTION(Action::ValueNodeRemove);
-
+
ADD_ACTION(Action::ValueDescSet);
ADD_ACTION(Action::ValueDescExport);
ADD_ACTION(Action::ValueDescConvert);
ADD_ACTION(Action::GradientSet);
ADD_ACTION(Action::ColorSet);
-
+
ADD_ACTION(Action::TimepointsMove);
ADD_ACTION(Action::TimepointsCopy);
ADD_ACTION(Action::TimepointsDelete);
Action::Main::~Main()
{
delete book_;
-
+
}
{
if(!book().count(name))
return 0; //! \todo perhaps we should throw something instead?
- return book()[name].factory();
+ return book()[name].factory();
}
Action::compile_candidate_list(const ParamList& param_list, Category category)
{
Action::CandidateList ret;
-
+
Book::const_iterator iter;
//synfig::info("param_list.size()=%d",param_list.size());
}
}
}
-
+
return ret;
}
Action::Base::set_param_list(const ParamList ¶m_list)
{
ParamList::const_iterator iter;
-
+
for(iter=param_list.begin();iter!=param_list.end();++iter)
set_param(iter->first,iter->second);
}
Super::perform()
{
set_dirty(false);
-
+
prepare();
ActionList::const_iterator iter;
Action::CanvasSpecific::get_param_vocab()
{
ParamVocab ret;
-
+
ret.push_back(ParamDesc("canvas",Param::TYPE_CANVAS)
.set_local_name(_("Canvas"))
.set_desc(_("Selected Canvas"))
.set_desc(_("Canvas Interface"))
.set_optional(true)
);
-
+
return ret;
}
if(!param.get_canvas())
return false;
set_canvas(param.get_canvas());
-
+
return true;
}
if(name=="canvas_interface" && param.get_type()==Param::TYPE_CANVASINTERFACE)
set_canvas_interface(param.get_canvas_interface());
if(!get_canvas())
set_canvas(get_canvas_interface()->get_canvas());
-
+
return true;
}
if(name=="edit_mode" && param.get_type()==Param::TYPE_EDITMODE)
{
set_edit_mode(param.get_edit_mode());
-
+
return true;
}
{
if(mode_!=MODE_UNDEFINED)
return mode_;
-
+
if(get_canvas_interface())
return get_canvas_interface()->get_mode();
-
+
return MODE_NORMAL;
}
class Instance;
class Main;
-
-namespace Action {
+
+namespace Action {
class System;
-
+
//! Exception class, thrown when redoing or undoing an action
class Error
synfig::String desc_;
public:
-
+
Error(Type type, const char *format, ...):
type_(type)
{
type_(type)
{
}
-
+
Type get_type()const { return type_; }
synfig::String get_desc()const { return desc_; }
-
+
}; // END of class Action::Error
class Param;
CATEGORY_OTHER =(1<<12),
CATEGORY_DRAG =(1<<24),
-
+
CATEGORY_HIDDEN =(1<<31),
CATEGORY_ALL =(~0)-(1<<31) //!< All categories (EXCEPT HIDDEN)
}; // END of enum Category
** - Factory for creating this action from a ParamList
**
*/
-class Base : public etl::shared_object
+class Base : public etl::shared_object
{
protected:
Base() { }
-
+
public:
virtual ~Base() { };
//! This function will throw an Action::Error() on failure
virtual void perform()=0;
-
+
virtual bool set_param(const synfig::String& name, const Param &) { return false; }
virtual bool is_ready()const=0;
-
+
virtual synfig::String get_name()const =0;
virtual synfig::String get_local_name()const { return get_name(); }
void set_param_list(const ParamList &);
-
+
}; // END of class Action::Base
typedef Action::Base* (*Factory)();
}; // END of class Action::Undoable
//! Action base class for canvas-specific actions
-class CanvasSpecific
+class CanvasSpecific
{
private:
bool is_dirty_;
CanvasSpecific():is_dirty_(true), mode_(MODE_UNDEFINED) { }
virtual ~CanvasSpecific() { };
-
-
+
+
public:
void set_canvas(synfig::Canvas::Handle x) { canvas_=x; }
EditMode get_edit_mode()const;
void set_edit_mode(EditMode x) { mode_=x; }
-
+
bool is_dirty()const { return is_dirty_; }
void set_dirty(bool x=true) { is_dirty_=x; }
-
+
}; // END of class Action::Undoable
typedef std::list< etl::handle<Action::Undoable> > ActionList;
virtual void prepare()=0;
void clear() { action_list().clear(); }
-
+
bool first_time()const { return action_list_.empty(); }
-
+
void add_action(etl::handle<Undoable> action);
void add_action_front(etl::handle<Undoable> action);
Category category;
Factory factory;
CandidateChecker is_candidate;
- GetParamVocab get_param_vocab;
-
+ GetParamVocab get_param_vocab;
+
bool operator<(const BookEntry &rhs)const { return priority<rhs.priority; }
}; // END of struct BookEntry
Action::candidate_check(const ParamVocab& param_vocab, const ParamList& param_list)
{
ParamVocab::const_iterator iter;
-
+
for(iter=param_vocab.begin();iter!=param_vocab.end();++iter)
{
int n(param_list.count(iter->get_name()));
if(iter->get_user_supplied() || iter->get_optional())
continue;
-
+
if(n==0)
return false;
if(n==1 && iter->get_requires_multiple())
return false;
if(n>1 && !iter->get_supports_multiple())
return false;
-
+
if(iter->get_type()!=param_list.find(iter->get_name())->second.get_type())
return false;
}
}
Param::Param(const etl::handle<synfigapp::CanvasInterface>& x):
-
+
type_(TYPE_CANVASINTERFACE)
{
_ParamCounter::counter++;
/*
Param::Param(synfigapp::CanvasInterface* x):
-
+
type_(TYPE_CANVASINTERFACE)
{
_ParamCounter::counter++;
*/
Param::Param(const etl::loose_handle<synfigapp::CanvasInterface>& x):
-
+
type_(TYPE_CANVASINTERFACE)
{
_ParamCounter::counter++;
data.canvas_interface.get()=x;
}
-Param::Param(const synfig::Canvas::Handle& x):
+Param::Param(const synfig::Canvas::Handle& x):
type_(TYPE_CANVAS)
{
_ParamCounter::counter++;
data.canvas.get()=x;
}
-Param::Param(const synfig::Canvas::LooseHandle& x):
+Param::Param(const synfig::Canvas::LooseHandle& x):
type_(TYPE_CANVAS)
{
_ParamCounter::counter++;
}
Param::Param(const synfig::Layer::Handle& x):
-
+
type_(TYPE_LAYER)
{
_ParamCounter::counter++;
}
Param::Param(const synfig::Layer::LooseHandle& x):
-
+
type_(TYPE_LAYER)
{
_ParamCounter::counter++;
}
Param::Param(const synfig::ValueNode::Handle& x):
-
+
type_(TYPE_VALUENODE)
{
_ParamCounter::counter++;
}
Param::Param(const synfig::ValueNode::LooseHandle& x):
-
+
type_(TYPE_VALUENODE)
{
_ParamCounter::counter++;
}
Param::Param(const synfig::ValueBase& x):
-
+
type_(TYPE_VALUE)
{
_ParamCounter::counter++;
data.value.get()=x;
}
-Param::Param(const synfig::RendDesc& x):
+Param::Param(const synfig::RendDesc& x):
type_(TYPE_RENDDESC)
{
_ParamCounter::counter++;
}
Param::Param(const synfig::Activepoint& x):
-
+
type_(TYPE_ACTIVEPOINT)
{
_ParamCounter::counter++;
data.activepoint.get()=x;
}
-Param::Param(const synfig::Waypoint& x):
+Param::Param(const synfig::Waypoint& x):
type_(TYPE_WAYPOINT)
{
_ParamCounter::counter++;
data.waypoint.get()=x;
}
-Param::Param(const synfig::Waypoint::Model& x):
+Param::Param(const synfig::Waypoint::Model& x):
type_(TYPE_WAYPOINTMODEL)
{
_ParamCounter::counter++;
}
Param::Param(const synfig::Keyframe& x):
-
+
type_(TYPE_KEYFRAME)
{
_ParamCounter::counter++;
}
Param::Param(const synfigapp::ValueDesc& x):
-
+
type_(TYPE_VALUEDESC)
{
_ParamCounter::counter++;
}
Param::Param(const synfig::Real& x):
-
+
type_(TYPE_REAL)
{
_ParamCounter::counter++;
}
Param::Param(const bool& x):
-
+
type_(TYPE_BOOL)
{
_ParamCounter::counter++;
{
clear();
type_=rhs.type_;
-
+
switch(type_)
{
case TYPE_ACTIVEPOINT:
namespace synfigapp {
class CanvasInterface;
-
-namespace Action {
+
+namespace Action {
//! Action Parameter
class Param
TYPE_CANVASINTERFACE,
TYPE_EDITMODE,
TYPE_RENDDESC,
-
+
TYPE_END
};
private:
synfig::Real real;
bool b;
EditMode edit_mode;
-
+
} data;
public:
Param(const synfig::ValueBase& x);
~Param();
-
+
Param& operator=(const Param& rhs);
-
+
void clear();
-
+
const synfig::Canvas::LooseHandle& get_canvas()const { assert(type_==TYPE_CANVAS); return data.canvas.get(); }
const etl::loose_handle<synfigapp::CanvasInterface>& get_canvas_interface()const { assert(type_==TYPE_CANVASINTERFACE); return data.canvas_interface.get(); }
const synfig::Layer::LooseHandle& get_layer()const { assert(type_==TYPE_LAYER); return data.layer.get(); }
requires_multiple_(false),
optional_(false)
{ }
-
+
const synfig::String& get_name()const { return name_; }
const synfig::String& get_desc()const { return desc_; }
const synfig::String& get_mutual_exclusion()const { return mutual_exclusion_; }
Action::System::perform_action(handle<Action::Base> action)
{
handle<UIInterface> uim(get_ui_interface());
-
+
assert(action);
-
+
if(!action->is_ready())
{
uim->error(action->get_name()+": "+_("Action is not ready."));
return false;
- }
-
+ }
+
most_recent_action_=action;
-
+
static bool inuse=false;
if(inuse) return false;
inuse=true;
try {
-
+
assert(action);
-
+
Action::CanvasSpecific* canvas_specific(dynamic_cast<Action::CanvasSpecific*>(action.get()));
-
+
if(canvas_specific && canvas_specific->get_canvas())
{
handle<CanvasInterface> canvas_interface=static_cast<Instance*>(this)->find_canvas_interface(canvas_specific->get_canvas());
}
handle<Action::Undoable> undoable_action=handle<Action::Undoable>::cast_dynamic(action);
-
+
// If we cannot undo this action, make sure
// that the user knows this.
if(!undoable_action)
if(err.get_type()!=Action::Error::TYPE_UNABLE)
{
if(err.get_desc().empty())
- uim->error(action->get_name()+": "+strprintf("%d",err.get_type()));
+ uim->error(action->get_name()+": "+strprintf("%d",err.get_type()));
else
- uim->error(action->get_name()+": "+err.get_desc());
+ uim->error(action->get_name()+": "+err.get_desc());
}
// If action failed for whatever reason, just return false and do
uim->task(action->get_name()+' '+_("Failed"));
inuse=false;
- uim->error(action->get_name()+": "+err.what());
+ uim->error(action->get_name()+": "+err.what());
// If action failed for whatever reason, just return false and do
// not add the action onto the list
// Clear the redo stack
if(clear_redo_stack_on_new_action_)
- clear_redo_stack();
+ clear_redo_stack();
if(!group_stack_.empty())
group_stack_.front()->inc_depth();
else
inc_action_count();
-
+
// Push this action onto the action list if we can undo it
if(undoable_action)
{
// If necessary, signal the change in status of undo
if(undo_action_stack_.empty()) signal_undo_status_(true);
-
+
// Add it to the list
undo_action_stack_.push_front(undoable_action);
if(group_stack_.empty())
signal_new_action()(undoable_action);
}
-
+
inuse=false;
uim->task(action->get_name()+' '+_("Successful"));
{
handle<Action::Undoable> action(undo_action_stack().front());
most_recent_action_=action;
-
+
try { if(action->is_active()) action->undo(); }
catch(Action::Error err)
{
if(err.get_type()!=Action::Error::TYPE_UNABLE)
{
if(err.get_desc().empty())
- uim->error(action->get_name()+_(" (Undo): ")+strprintf("%d",err.get_type()));
+ uim->error(action->get_name()+_(" (Undo): ")+strprintf("%d",err.get_type()));
else
- uim->error(action->get_name()+_(" (Undo): ")+err.get_desc());
+ uim->error(action->get_name()+_(" (Undo): ")+err.get_desc());
}
return false;
}
inuse=false;
-
+
// If the action has "dirtied" the preview, signal it.
if(0)if(action->is_active() && canvas_specific && canvas_specific->is_dirty())
{
if(err.get_type()!=Action::Error::TYPE_UNABLE)
{
if(err.get_desc().empty())
- uim->error(action->get_name()+_(" (Redo): ")+strprintf("%d",err.get_type()));
+ uim->error(action->get_name()+_(" (Redo): ")+strprintf("%d",err.get_type()));
else
- uim->error(action->get_name()+_(" (Redo): ")+err.get_desc());
+ uim->error(action->get_name()+_(" (Redo): ")+err.get_desc());
}
return false;
signal_undo_status_(false);
signal_undo_stack_cleared_();
}
-
+
void
Action::System::clear_redo_stack()
{
{
Stack::iterator iter;
int failed=false;
-
+
if(action->is_active()==x)
return true;
Action::CanvasSpecific* canvas_specific(dynamic_cast<Action::CanvasSpecific*>(action.get()));
handle<UIInterface> uim=new ConfidentUIInterface();
-
+
iter=find(undo_action_stack_.begin(),undo_action_stack_.end(),action);
if(iter!=undo_action_stack_.end())
{
{
return false;
}
- }
+ }
if(!undo_(uim))
{
return false;
}
-
+
action->set_active(x);
if(redo_(get_ui_interface()))
action->set_active(!x);
failed=true;
}
-
-
+
+
while(undo_action_stack_.front()!=cur_pos)
{
if(!redo_(uim))
Action::PassiveGrouper::~PassiveGrouper()
{
assert(instance_->group_stack_.front()==this);
-
+
// Remove this group from the group stack
instance_->group_stack_.pop_front();
else
{
Action::CanvasSpecific* canvas_specific(dynamic_cast<Action::CanvasSpecific*>(action.get()));
-
+
if(0)if(canvas_specific && canvas_specific->is_dirty() && canvas_specific->get_canvas_interface())
{
if(instance_->group_stack_.empty())
- request_redraw(canvas_specific->get_canvas_interface());
+ request_redraw(canvas_specific->get_canvas_interface());
}
}
if(depth_>0)
{
group=new Action::Group(name_);
-
+
for(int i=0;i<depth_;i++)
// for(;depth_;depth_--)
{
handle<Action::Undoable> action(instance_->undo_action_stack_.front());
Action::CanvasSpecific* canvas_specific(dynamic_cast<Action::CanvasSpecific*>(action.get()));
-
+
if(0)if(canvas_specific && canvas_specific->is_dirty())
{
group->set_dirty(true);
group->set_canvas(canvas_specific->get_canvas());
group->set_canvas_interface(canvas_specific->get_canvas_interface());
}
-
+
// Copy the action from the undo stack to the group
group->add_action_front(action);
-
+
// Remove the action from the undo stack
instance_->undo_action_stack_.pop_front();
}
-
+
// Push the group onto the stack
instance_->undo_action_stack_.push_front(group);
-
+
if(0)if(group->is_dirty())
request_redraw(group->get_canvas_interface());
// group->get_canvas_interface()->signal_dirty_preview()();
-
+
if(instance_->group_stack_.empty())
{
instance_->inc_action_count();
else
instance_->group_stack_.front()->inc_depth();
}
-
+
if(0)if(redraw_requested_)
{
if(instance_->group_stack_.empty())
// Cancel any groupers that may be on top of us first
//while(instance_->group_stack_.front()!=this)
// instance_->group_stack_.front()->cancel();
-
+
synfig::warning("Cancel depth: %d",depth_);
-
+
while(depth_)
if(!instance_->undo())
{
error=true;
break;
}
-
+
if(error)
instance_->get_ui_interface()->error(_("State restore failure"));
else
namespace synfigapp {
class CanvasInterface;
-
+
namespace Action {
-
-
-
+
+
+
class System;
//! Passive action grouping class
void set_name(const synfig::String &x) { name_=x; }
etl::loose_handle<System> get_instance() { return instance_; }
-
+
void request_redraw(etl::handle<CanvasInterface>);
-
+
void cancel();
-
+
void inc_depth() { depth_++; }
void dec_depth() { depth_--; }
}; // END of class Action::PassiveGrouper
typedef std::list< etl::handle<Action::Undoable> > Stack;
-
+
class System : public etl::shared_object, public sigc::trackable
{
friend class PassiveGrouper;
-
+
/*
-- ** -- P U B L I C T Y P E S ---------------------------------------------
*/
*/
public:
-
+
/*
-- ** -- P R I V A T E D A T A ---------------------------------------------
*/
sigc::signal<void> signal_undo_;
sigc::signal<void> signal_redo_;
sigc::signal<void,etl::handle<Action::Undoable> > signal_action_status_changed_;
-
+
mutable sigc::signal<void,bool> signal_unsaved_status_changed_;
//! If this is non-zero, then the changes have not yet been saved.
etl::handle<UIInterface> ui_interface_;
bool clear_redo_stack_on_new_action_;
-
+
/*
-- ** -- P R I V A T E M E T H O D S ---------------------------------------
*/
const etl::handle<Action::Base>& get_most_recent_action() { return most_recent_action_; }
bool get_clear_redo_stack_on_new_action()const { return clear_redo_stack_on_new_action_; }
-
+
void set_clear_redo_stack_on_new_action(bool x) { clear_redo_stack_on_new_action_=x; }
bool perform_action(etl::handle<Action::Base> action);
//! Redoes the last undone action
bool redo();
-
- //! Clears the undo stack.
+
+ //! Clears the undo stack.
void clear_undo_stack();
-
- //! Clears the redo stack.
+
+ //! Clears the redo stack.
void clear_redo_stack();
-
+
//! Increments the action counter
/*! \note You should not have to call this under normal circumstances.
** \see dec_action_count(), reset_action_count(), get_action_count() */
void set_ui_interface(const etl::handle<UIInterface> &uim) { assert(uim); ui_interface_=uim; }
void unset_ui_interface() { ui_interface_=new DefaultUIInterface(); }
- const etl::handle<UIInterface> &get_ui_interface() { return ui_interface_; }
+ const etl::handle<UIInterface> &get_ui_interface() { return ui_interface_; }
/*
-- ** -- S I G N A L I N T E R F A C E S -----------------------------------
Action::ActivepointAdd::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
.set_local_name(_("ValueDesc"))
);
if(name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
{
ValueDesc value_desc(param.get_value_desc());
-
+
if(!value_desc.parent_is_value_node())
return false;
-
+
value_node=ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node());
-
+
if(!value_node)
return false;
-
+
index=value_desc.get_index();
-
+
if(time_set)
calc_activepoint();
-
+
return true;
}
if(name=="activepoint" && param.get_type()==Param::TYPE_ACTIVEPOINT && !time_set)
{
activepoint=param.get_activepoint();
-
+
return true;
}
if(name=="time" && param.get_type()==Param::TYPE_TIME && activepoint.get_time()==Time::begin()-1)
if(value_node)
calc_activepoint();
-
+
return true;
}
return Action::CanvasSpecific::is_ready();
}
-// This function is called if a time is specified, but not
+// This function is called if a time is specified, but not
// a activepoint. In this case, we need to calculate the value
// of the activepoint
void
Action::ActivepointAdd::calc_activepoint()
-{
+{
const Time time(activepoint.get_time());
activepoint.set_state(value_node->list[index].status_at_time(time));
activepoint.set_priority(0);
-
+
// In this case, nothing is really changing, so there will be
// no need to redraw the window
set_dirty(false);
void
Action::ActivepointAdd::perform()
-{
+{
try { value_node->list[index].find(activepoint.get_time()); throw Error(_("A Activepoint already exists at this point in time"));}
- catch(synfig::Exception::NotFound) { }
+ catch(synfig::Exception::NotFound) { }
try { if(value_node->list[index].find(activepoint)!=value_node->list[index].timing_info.end()) throw Error(_("This activepoint is already in the ValueNode"));}
- catch(synfig::Exception::NotFound) { }
-
+ catch(synfig::Exception::NotFound) { }
+
value_node->list[index].add(activepoint);
value_node->changed();
-
+
/*if(get_canvas_interface())
{
get_canvas_interface()->signal_value_node_changed()(value_node);
Action::ActivepointRemove::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
.set_local_name(_("ValueDesc"))
);
if(name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
{
ValueDesc value_desc(param.get_value_desc());
-
+
if(!value_desc.parent_is_value_node())
return false;
-
+
value_node=ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node());
-
+
if(!value_node)
return false;
-
+
index=value_desc.get_index();
-
+
return true;
}
if(name=="activepoint" && param.get_type()==Param::TYPE_ACTIVEPOINT)
{
activepoint=param.get_activepoint();
-
+
return true;
}
void
Action::ActivepointRemove::perform()
-{
+{
ValueNode_DynamicList::ListEntry::ActivepointList::iterator iter;
-
+
try { iter=value_node->list[index].find(activepoint); }
catch(synfig::Exception::NotFound)
{
throw Error(_("Unable to find activepoint"));
- }
+ }
value_node->list[index].erase(activepoint);
value_node->changed();
-
+
/*
// Signal that a layer has been inserted
if(get_canvas_interface())
Action::ActivepointRemove::undo()
{
try { value_node->list[index].find(activepoint.get_time()); throw Error(_("A Activepoint already exists at this point in time"));}
- catch(synfig::Exception::NotFound) { }
+ catch(synfig::Exception::NotFound) { }
try { if(value_node->list[index].find(activepoint)!=value_node->list[index].timing_info.end()) throw Error(_("This activepoint is already in the ValueNode"));}
- catch(synfig::Exception::NotFound) { }
-
+ catch(synfig::Exception::NotFound) { }
+
value_node->list[index].add(activepoint);
value_node->changed();
/*
Action::ActivepointSet::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
.set_local_name(_("ValueDesc"))
);
if(name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
{
ValueDesc value_desc(param.get_value_desc());
-
+
if(!value_desc.parent_is_value_node())
return false;
-
+
value_node=ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node());
-
+
if(!value_node)
return false;
-
+
index=value_desc.get_index();
-
+
return true;
}
if(name=="activepoint" && param.get_type()==Param::TYPE_ACTIVEPOINT)
{
//NOTE: there is no duplication checking at the moment
activepoints.push_back(param.get_activepoint());
-
+
return true;
}
void
Action::ActivepointSet::perform()
-{
+{
typedef ValueNode_DynamicList::ListEntry::ActivepointList AList;
AList::iterator iter;
-#if 1
+#if 1
vector<AList::iterator> iters;
- vector<Activepoint>::iterator i = activepoints.begin(), end = activepoints.end();
-
+ vector<Activepoint>::iterator i = activepoints.begin(), end = activepoints.end();
+
for(; i != end; ++i)
{
try { iters.push_back(value_node->list[index].find(*i)); }
throw Error(_("Unable to find activepoint"));
}
}
-
+
//check to see which valuenodes are going to override because of the time...
ValueNode_DynamicList::ListEntry::findresult timeiter;
-
+
for(i = activepoints.begin(); i != end; ++i)
{
timeiter = value_node->list[index].find_time(i->get_time());
-
+
bool candelete = timeiter.second;
-
+
//we only want to track overwrites (not activepoints that are also being modified)
if(candelete)
{
}
}
}
-
+
//if we can still delete it after checking, record it, and then remove them all later
if(candelete)
{
overwritten_activepoints.push_back(a);
}
}
-
+
//overwrite all the valuenodes we're supposed to set
{
i = activepoints.begin();
**ii = *i; //set the point to the corresponding point in the normal waypoint list
}
}
-
+
//remove all the points we're supposed to be overwritting
{
vector<Activepoint>::iterator oi = overwritten_activepoints.begin(),
}
}
-#else
+#else
try { iter=value_node->list[index].find(activepoint); }
catch(synfig::Exception::NotFound)
{
throw Error(_("Unable to find activepoint"));
- }
+ }
//find the value at the old time before we replace it
ValueNode_DynamicList::ListEntry::findresult timeiter;
timeiter = value_node->list[index].find_time(activepoint.get_time());
-
+
//we only want to track overwrites (not inplace modifications)
if(timeiter.second && activepoint.get_uid() == timeiter.first->get_uid())
{
timeiter.second = false;
}
-
+
old_activepoint=*iter;
*iter=activepoint;
-
+
if(timeiter.second)
{
synfig::info("Erasing the found activepoint");
time_overwrite = true;
overwritten_ap = *timeiter.first;
-
+
value_node->list[index].erase(overwritten_ap);
}
-
+
#endif
-
+
value_node->list[index].timing_info.sort();
-
+
// Signal that a valuenode has been changed
value_node->changed();
}
{
ValueNode_DynamicList::ListEntry::ActivepointList::iterator iter;
-#if 1
- vector<Activepoint>::iterator i = old_activepoints.begin(), end = old_activepoints.end();
-
+#if 1
+ vector<Activepoint>::iterator i = old_activepoints.begin(), end = old_activepoints.end();
+
for(; i != end; ++i)
{
try { iter = value_node->list[index].find(*i); }
{
throw Error(_("Unable to find activepoint"));
}
-
+
//overwrite with old one
*iter = *i;
}
-
+
//add back in all the points that we removed before...
{
vector<Activepoint>::iterator oi = overwritten_activepoints.begin(),
}
}
-#else
+#else
try { iter=value_node->list[index].find(activepoint); }
catch(synfig::Exception::NotFound)
{
throw Error(_("Unable to find activepoint"));
- }
+ }
*iter=old_activepoint;
-
+
if(time_overwrite)
{
value_node->list[index].add(overwritten_ap);
}
#endif
-
+
value_node->list[index].timing_info.sort();
-
+
// Signal that a valuenode has been changed
value_node->changed();
}
synfig::ValueNode_DynamicList::Handle value_node;
int index;
-
+
std::vector<synfig::Activepoint> activepoints;
- std::vector<synfig::Activepoint> old_activepoints;
+ std::vector<synfig::Activepoint> old_activepoints;
std::vector<synfig::Activepoint> overwritten_activepoints;
Action::ActivepointSetOff::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
.set_local_name(_("ValueDesc"))
);
.set_local_name(_("Time"))
.set_optional()
);
-
+
return ret;
}
ValueDesc value_desc(x.find("value_desc")->second.get_value_desc());
if(!value_desc.parent_is_value_node() || !ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node()))
return false;
-
+
// We are only a candidate if this canvas is animated.
Canvas::Handle canvas(x.find("canvas")->second.get_canvas());
if(canvas->rend_desc().get_time_start()==canvas->rend_desc().get_time_end())
return false;
-
+
// We need either a activepoint or a time.
if(x.count("activepoint") || x.count("time"))
return true;
if(name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
{
value_desc=param.get_value_desc();
-
+
if(!value_desc.parent_is_value_node())
return false;
-
+
value_node=ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node());
-
+
if(!value_node)
return false;
-
+
index=value_desc.get_index();
-
+
if(time_set)
calc_activepoint();
-
+
return true;
}
if(name=="activepoint" && param.get_type()==Param::TYPE_ACTIVEPOINT && !time_set)
{
activepoint=param.get_activepoint();
-
+
return true;
}
if(name=="time" && param.get_type()==Param::TYPE_TIME && activepoint.get_time()==Time::begin()-1)
if(value_node)
calc_activepoint();
-
+
return true;
}
if(activepoint.get_time()==(Time::begin()-1))
synfig::error("Missing activepoint");
-
+
if(!value_node || activepoint.get_time()==(Time::begin()-1))
return false;
return Action::CanvasSpecific::is_ready();
}
-// This function is called if a time is specified, but not
+// This function is called if a time is specified, but not
// a activepoint. In this case, we need to calculate the value
// of the activepoint
void
Action::ActivepointSetOff::calc_activepoint()
-{
+{
const Time time(activepoint.get_time());
-
+
try { activepoint=*value_node->list[index].find(time); }
catch(...)
{
activepoint.set_state(false);
Action::Handle action(ActivepointSetSmart::create());
-
+
action->set_param("edit_mode",get_edit_mode());
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
throw Error(Error::TYPE_NOTREADY);
add_action_front(action);
-
+
}
Action::ActivepointSetOn::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
.set_local_name(_("ValueDesc"))
);
.set_local_name(_("Time"))
.set_optional()
);
-
+
return ret;
}
if(name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
{
value_desc=param.get_value_desc();
-
+
if(!value_desc.parent_is_value_node())
return false;
-
+
value_node=ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node());
-
+
if(!value_node)
return false;
-
+
index=value_desc.get_index();
-
+
if(time_set)
calc_activepoint();
-
+
return true;
}
if(name=="activepoint" && param.get_type()==Param::TYPE_ACTIVEPOINT && !time_set)
{
activepoint=param.get_activepoint();
-
+
return true;
}
if(name=="time" && param.get_type()==Param::TYPE_TIME && activepoint.get_time()==Time::begin()-1)
if(value_node)
calc_activepoint();
-
+
return true;
}
if(activepoint.get_time()==(Time::begin()-1))
synfig::error("Missing activepoint");
-
+
if(!value_node || activepoint.get_time()==(Time::begin()-1))
return false;
return Action::CanvasSpecific::is_ready();
}
-// This function is called if a time is specified, but not
+// This function is called if a time is specified, but not
// a activepoint. In this case, we need to calculate the value
// of the activepoint
void
Action::ActivepointSetOn::calc_activepoint()
-{
+{
const Time time(activepoint.get_time());
-
+
try { activepoint=*value_node->list[index].find(time); }
catch(...)
{
activepoint.set_state(true);
Action::Handle action(ActivepointSetSmart::create());
-
+
action->set_param("edit_mode",get_edit_mode());
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
throw Error(Error::TYPE_NOTREADY);
add_action_front(action);
-
+
}
Action::ActivepointSetSmart::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
.set_local_name(_("ValueDesc"))
);
.set_desc(_("Time where activepoint is to be added"))
.set_optional()
);
-
+
return ret;
}
if(name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
{
value_desc=param.get_value_desc();
-
+
if(!value_desc.parent_is_value_node())
return false;
-
+
value_node=ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node());
-
+
if(!value_node)
return false;
-
+
index=value_desc.get_index();
-
+
if(time_set)
calc_activepoint();
-
+
return true;
}
if(name=="activepoint" && param.get_type()==Param::TYPE_ACTIVEPOINT && !time_set)
{
activepoint=param.get_activepoint();
-
+
return true;
}
if(name=="time" && param.get_type()==Param::TYPE_TIME && activepoint.get_time()==Time::begin()-1)
if(value_node)
calc_activepoint();
-
+
return true;
}
if(activepoint.get_time()==(Time::begin()-1))
synfig::error("Missing activepoint");
-
+
if(!value_node || activepoint.get_time()==(Time::begin()-1))
return false;
return Action::CanvasSpecific::is_ready();
}
-// This function is called if a time is specified, but not
+// This function is called if a time is specified, but not
// a activepoint. In this case, we need to calculate the value
// of the activepoint
void
Action::ActivepointSetSmart::calc_activepoint()
-{
+{
/*
const Time time(activepoint.get_time());
activepoint.set_state(value_node->list[index].status_at_time(time));
void
Action::ActivepointSetSmart::enclose_activepoint(const synfig::Activepoint& activepoint)
{
- times.insert(activepoint.get_time());
+ times.insert(activepoint.get_time());
if(get_edit_mode()&MODE_ANIMATE_PAST) try
{
if(times.count(keyframe.get_time()))
throw int();
else
- times.insert(keyframe.get_time());
-
+ times.insert(keyframe.get_time());
+
try { value_node->list[index].find(keyframe.get_time()); }
catch(synfig::Exception::NotFound)
{
Action::Handle action(ActivepointAdd::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_desc",value_desc);
-
+
if(!value_node->list[index].timing_info.empty())
- {
+ {
action->set_param("time",keyframe.get_time());
}
else
{
synfig::Activepoint tmp;
-
+
tmp.set_state(true);
tmp.set_time(keyframe.get_time());
action->set_param("activepoint",tmp);
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action_front(action);
- }
+ }
}
catch(int) { }
catch(synfig::Exception::NotFound) { }
if(times.count(keyframe.get_time()))
throw int();
else
- times.insert(keyframe.get_time());
-
+ times.insert(keyframe.get_time());
+
try { value_node->list[index].find(keyframe.get_time()); }
catch(synfig::Exception::NotFound)
{
Action::Handle action(ActivepointAdd::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_desc",value_desc);
-
+
if(!value_node->list[index].timing_info.empty())
- {
+ {
action->set_param("time",keyframe.get_time());
}
else
{
synfig::Activepoint tmp;
-
+
tmp.set_state(true);
tmp.set_time(keyframe.get_time());
action->set_param("activepoint",tmp);
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action_front(action);
- }
+ }
}
catch(int) { }
catch(synfig::Exception::NotFound) { }
{
clear();
times.clear();
-
+
// First, we need to to add any activepoints necessary to
// maintain the integrity of the keyframes.
enclose_activepoint(activepoint);
-
+
try
{
if(value_node->list[index].find(activepoint)==value_node->list[index].timing_info.end())
throw int();
-
+
// Then, lets try to replace the old activepoint, if it exists
enclose_activepoint(*value_node->list[index].find(activepoint));
Action::Handle action(ActivepointSet::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_desc",value_desc);
action->set_param("activepoint",activepoint);
-
+
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action_front(action);
-
+
return;
}
catch(int){}
activepoint.mimic(*value_node->list[index].find(activepoint.get_time()));
enclose_activepoint(*value_node->list[index].find(activepoint.get_time()));
-
+
Action::Handle action(ActivepointSet::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_desc",value_desc);
action->set_param("activepoint",activepoint);
-
+
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action_front(action);
-
+
return;
}
catch(int){}
catch(Exception::NotFound){}
-
+
try
{
// At this point we know that the old activepoint doesn't exist,
// so we need to create it.
Action::Handle action(ActivepointAdd::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_desc",value_desc);
action->set_param("activepoint",activepoint);
-
+
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action_front(action);
-
+
return;
}
catch(int){}
catch(Exception::NotFound){}
-
+
throw Error(_("Unable to determine how to procede. This is a bug."));
}
Action::ActivepointSimpleAdd::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
.set_local_name(_("Destination ValueNode (Animated)"))
);
if(name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
{
ValueDesc value_desc(param.get_value_desc());
-
+
if(!value_desc.parent_is_value_node())
return false;
-
+
value_node=ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node());
-
+
if(!value_node)
return false;
-
+
index=value_desc.get_index();
-
+
return true;
}
if(name=="activepoint" && param.get_type()==Param::TYPE_ACTIVEPOINT)
{
activepoint = param.get_activepoint();
-
+
return true;
}
void
Action::ActivepointSimpleAdd::perform()
-{
+{
//remove any pretenders that lie at our destination
ValueNode_DynamicList::ListEntry::findresult iter = value_node->list[index]
.find_time(activepoint.get_time());
-
+
time_overwrite = false;
if(iter.second)
{
time_overwrite = true;
value_node->list[index].erase(overwritten_ap);
}
-
+
//add the value node in since it's safe
value_node->list[index].add(activepoint);
-
+
//sort them...
value_node->list[index].timing_info.sort();
-
+
// Signal that a valuenode has been changed
value_node->changed();
}
{
//remove our old version...
ValueNode_DynamicList::ListEntry::findresult iter = value_node->list[index].find_uid(activepoint);
-
+
if(!iter.second)
{
throw Error(_("The activepoint to remove no longer exists"));
}
-
+
//remove the offending value
value_node->list[index].erase(*iter.first); //could also just use waypoint
-
+
if(time_overwrite)
{
- value_node->list[index].add(overwritten_ap);
+ value_node->list[index].add(overwritten_ap);
}
-
+
//sort them...
value_node->list[index].timing_info.sort();
-
+
// Signal that a valuenode has been changed
value_node->changed();
}
public CanvasSpecific
{
private:
-
+
synfig::ValueNode_DynamicList::Handle value_node;
int index;
-
+
synfig::Activepoint activepoint;
bool time_overwrite;
Action::BLinePointTangentMerge::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE)
.set_local_name(_("ValueNode of BLinePoint"))
);
ret.push_back(ParamDesc("time",Param::TYPE_TIME)
.set_local_name(_("Time"))
);
-
+
return ret;
}
if(name=="value_node" && param.get_type()==Param::TYPE_VALUENODE)
{
value_node=value_node.cast_dynamic(param.get_value_node());
-
+
return (bool)(value_node);
}
if(name=="time" && param.get_type()==Param::TYPE_TIME)
{
time=param.get_time();
-
+
return true;
}
if(time==(Time::begin()-1))
synfig::error("Missing time");
-
+
if(!value_node || time==(Time::begin()-1))
return false;
return Action::CanvasSpecific::is_ready();
clear();
Action::Handle action;
-
+
{
action=Action::create("value_desc_set");
if(!action)
throw Error(_("Couldn't find action \"value_desc_set\""));
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_desc",ValueDesc(value_node,3));
action->set_param("time",time);
action->set_param("new_value",synfig::ValueBase(false));
-
+
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action(action);
}
{
action=Action::create("value_desc_set");
if(!action)
throw Error(_("Couldn't find action \"value_desc_set\""));
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_desc",ValueDesc(value_node,5));
action->set_param("time",time);
action->set_param("new_value",(*value_node->get_link("t1"))(time));
-
+
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action(action);
}
-
+
}
Action::BLinePointTangentSplit::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE)
.set_local_name(_("ValueNode of BLinePoint"))
);
ret.push_back(ParamDesc("time",Param::TYPE_TIME)
.set_local_name(_("Time"))
);
-
+
return ret;
}
if(name=="value_node" && param.get_type()==Param::TYPE_VALUENODE)
{
value_node=value_node.cast_dynamic(param.get_value_node());
-
+
return (bool)(value_node);
}
if(name=="time" && param.get_type()==Param::TYPE_TIME)
{
time=param.get_time();
-
+
return true;
}
if(time==(Time::begin()-1))
synfig::error("Missing time");
-
+
if(!value_node || time==(Time::begin()-1))
return false;
return Action::CanvasSpecific::is_ready();
clear();
Action::Handle action;
-
+
{
action=Action::create("value_desc_set");
if(!action)
throw Error(_("Couldn't find action \"value_desc_set\""));
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_desc",ValueDesc(value_node,3));
action->set_param("time",time);
action->set_param("new_value",synfig::ValueBase(true));
-
+
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action(action);
}
{
action=Action::create("value_desc_set");
if(!action)
throw Error(_("Couldn't find action \"value_desc_set\""));
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_desc",ValueDesc(value_node,5));
action->set_param("time",time);
action->set_param("new_value",(*value_node->get_link("t1"))(time));
-
+
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action(action);
}
-
+
}
Action::CanvasAdd::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("src",Param::TYPE_CANVAS)
.set_local_name(_("New Canvas"))
.set_optional()
.set_desc(_("The name that you want this canvas to be"))
.set_user_supplied()
);
-
+
return ret;
}
if(name=="src" && param.get_type()==Param::TYPE_CANVAS)
{
new_canvas=param.get_canvas();
-
+
return true;
}
if(name=="id" && param.get_type()==Param::TYPE_STRING)
{
id=param.get_string();
-
+
return true;
}
get_canvas()->remove_child_canvas(new_canvas);
if(inline_parent)
- new_canvas->set_inline(inline_parent);
-
+ new_canvas->set_inline(inline_parent);
+
if(get_canvas_interface())
{
get_canvas_interface()->signal_canvas_removed()(new_canvas);
Action::CanvasRemove::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
return ret;
}
// We cannot remove the root canvas.
if(canvas->is_root())
return false;
-
+
return true;
}
return false;
if(get_canvas()->is_inline())
throw Error(_("You cannot remove an inline canvas!"));
-
+
parent_canvas=get_canvas()->parent();
canvas_id=get_canvas()->get_id();
-
+
assert(parent_canvas);
-
+
parent_canvas->remove_child_canvas(get_canvas());
-
+
if(get_canvas_interface())
{
get_canvas_interface()->signal_canvas_removed()(get_canvas());
Action::CanvasRendDescSet::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("rend_desc",Param::TYPE_RENDDESC)
.set_local_name(_("RendDesc"))
);
-
+
return ret;
}
if(name=="rend_desc" && param.get_type()==Param::TYPE_RENDDESC)
{
new_rend_desc=param.get_rend_desc();
-
+
return true;
}
old_rend_desc=get_canvas()->rend_desc();
get_canvas()->rend_desc()=new_rend_desc;
-
+
if(get_canvas_interface())
{
get_canvas_interface()->signal_rend_desc_changed()();
Action::CanvasRendDescSet::undo()
{
get_canvas()->rend_desc()=old_rend_desc;
-
+
if(get_canvas_interface())
{
get_canvas_interface()->signal_rend_desc_changed()();
Action::ColorSet::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
.set_local_name(_("ValueDesc"))
);
.set_local_name(_("Time"))
.set_optional()
);
-
+
return ret;
}
{
// Grab the value_desc
value_desc=param.get_value_desc();
-
+
// Grab the current color
color=synfigapp::Main::get_foreground_color();
-
+
return value_desc.get_value_type()==ValueBase::TYPE_COLOR;
}
if(name=="time" && param.get_type()==Param::TYPE_TIME)
{
time=param.get_time();
-
+
return true;
}
Action::ColorSet::prepare()
{
clear();
-
+
Action::Handle action;
action=Action::create("value_desc_set");
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_desc",value_desc);
action->set_param("new_value",ValueBase(color));
action->set_param("time",time);
-
+
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
Action::EditModeSet::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("edit_mode",Param::TYPE_EDITMODE)
.set_local_name(_("New Edit Mode"))
);
-
+
return ret;
}
if(name=="edit_mode" && param.get_type()==Param::TYPE_EDITMODE)
{
set_edit_mode(param.get_edit_mode());
-
+
return true;
}
*/
-
+
return Action::CanvasSpecific::set_param(name,param);
}
return;
get_canvas_interface()->mode_=get_edit_mode();
-
+
get_canvas_interface()->signal_mode_changed_(get_edit_mode());
}
return;
get_canvas_interface()->mode_=old_edit_mode;
-
+
get_canvas_interface()->signal_mode_changed_(old_edit_mode);
}
Action::GradientSet::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
.set_local_name(_("ValueDesc"))
);
.set_local_name(_("Time"))
.set_optional()
);
-
+
return ret;
}
{
// Grab the value_desc
value_desc=param.get_value_desc();
-
+
// Grab the current gradient
gradient=synfigapp::Main::get_gradient();
-
+
return value_desc.get_value_type()==ValueBase::TYPE_GRADIENT;
}
if(name=="time" && param.get_type()==Param::TYPE_TIME)
{
time=param.get_time();
-
+
return true;
}
Action::GradientSet::prepare()
{
clear();
-
+
Action::Handle action;
action=Action::create("value_desc_set");
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_desc",value_desc);
action->set_param("new_value",ValueBase(gradient));
action->set_param("time",time);
-
+
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
Action::GroupAddLayers::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("layer",Param::TYPE_LAYER)
.set_local_name(_("Layer"))
.set_desc(_("Layer to be added to group"))
.set_desc(_("Name of the Group to add the Layers to"))
.set_user_supplied()
);
-
+
return ret;
}
std::pair<synfig::Layer::Handle,String> layer_pair;
layer_pair.first=param.get_layer();
layer_list.push_back(layer_pair);
-
+
return true;
}
if(name=="group" && param.get_type()==Param::TYPE_STRING)
{
group=param.get_string();
-
+
return true;
}
{
Layer::Handle layer(iter->first);
iter->second=layer->get_group();
-
+
layer->add_to_group(group);
}
}
for(iter=layer_list.begin();iter!=layer_list.end();++iter)
{
Layer::Handle layer(iter->first);
-
+
layer->remove_from_group(group);
-
+
layer->add_to_group(iter->second);
}
}
// List contains the layers and their previous groups
std::list<std::pair<synfig::Layer::Handle,synfig::String> > layer_list;
-
+
// The name of the new group
synfig::String group;
Action::GroupRemove::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("group",Param::TYPE_STRING)
.set_local_name(_("Group"))
.set_desc(_("Name of the Group to remove"))
);
-
+
return ret;
}
if(name=="group" && param.get_type()==Param::TYPE_STRING)
{
group=param.get_string();
-
+
return true;
}
Action::GroupRemove::perform()
{
layer_list=get_canvas()->get_layers_in_group(group);
-
+
std::set<synfig::Layer::Handle>::iterator iter;
for(iter=layer_list.begin();iter!=layer_list.end();++iter)
{
// List contains the layers
std::set<synfig::Layer::Handle> layer_list;
-
+
// The name of the group to remove
synfig::String group;
Action::GroupRemoveLayers::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("layer",Param::TYPE_LAYER)
.set_local_name(_("Layer"))
.set_desc(_("Layer to be added to group"))
.set_desc(_("Name of the Group to add the Layers to"))
.set_user_supplied()
);
-
+
return ret;
}
std::pair<synfig::Layer::Handle,String> layer_pair;
layer_pair.first=param.get_layer();
layer_list.push_back(layer_pair);
-
+
return true;
}
if(name=="group" && param.get_type()==Param::TYPE_STRING)
{
group=param.get_string();
-
+
return true;
}
{
Layer::Handle layer(iter->first);
iter->second=layer->get_group();
-
+
layer->remove_from_group(group);
}
}
for(iter=layer_list.begin();iter!=layer_list.end();++iter)
{
Layer::Handle layer(iter->first);
-
+
layer->add_to_group(iter->second);
}
}
// List contains the layers and their previous groups
std::list<std::pair<synfig::Layer::Handle,synfig::String> > layer_list;
-
+
// The name of the new group
synfig::String group;
Action::GroupRename::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("group",Param::TYPE_STRING)
.set_local_name(_("Old Group"))
.set_desc(_("Name of the Group to rename"))
.set_local_name(_("New Group"))
.set_desc(_("New name for group"))
);
-
+
return ret;
}
if(name=="group" && param.get_type()==Param::TYPE_STRING)
{
old_group_name=param.get_string();
-
+
return true;
}
if(name=="new_group" && param.get_type()==Param::TYPE_STRING)
{
new_group_name=param.get_string();
-
+
return true;
}
// List contains the layers
std::set<synfig::Layer::Handle> layer_list;
-
+
// The name of the group to remove
synfig::String old_group_name;
Action::KeyframeAdd::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("keyframe",Param::TYPE_KEYFRAME)
.set_local_name(_("New Keyframe"))
.set_desc(_("Keyframe to be added"))
{
if(!candidate_check(get_param_vocab(),x))
return false;
-
+
return true;
}
if(name=="keyframe" && param.get_type()==Param::TYPE_KEYFRAME)
{
keyframe=param.get_keyframe();
-
+
return true;
}
void
Action::KeyframeAdd::perform()
-{
+{
try { get_canvas()->keyframe_list().find(keyframe.get_time()); throw Error(_("A Keyframe already exists at this point in time"));}
- catch(synfig::Exception::NotFound) { }
+ catch(synfig::Exception::NotFound) { }
try { get_canvas()->keyframe_list().find(keyframe); throw Error(_("This keyframe is already in the ValueNode"));}
- catch(synfig::Exception::NotFound) { }
-
+ catch(synfig::Exception::NotFound) { }
+
get_canvas()->keyframe_list().add(keyframe);
-
+
if(get_canvas_interface())
{
get_canvas_interface()->signal_keyframe_added()(keyframe);
}
else synfig::warning("CanvasInterface not set on action");
- get_canvas()->keyframe_list().erase(keyframe);
+ get_canvas()->keyframe_list().erase(keyframe);
}
Action::KeyframeDuplicate::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("keyframe",Param::TYPE_KEYFRAME)
.set_local_name(_("Keyframe"))
.set_desc(_("Keyframe to be duplicated"))
{
keyframe=param.get_keyframe();
new_keyframe.set_description(keyframe.get_description()+_(" (Duplicate)"));
-
+
return true;
}
if(name=="time" && param.get_type()==Param::TYPE_TIME)
{
new_keyframe.set_time(param.get_time());
-
+
return true;
}
catch(synfig::Exception::NotFound)
{
throw Error(_("Unable to find the given keyframe"));
- }
+ }
try { if(get_canvas()->keyframe_list().find(new_time)!=get_canvas()->keyframe_list().end()) throw Error(_("A Keyframe already exists at this point in time"));}
- catch(...) { }
+ catch(...) { }
- // If the times are different, then we
+ // If the times are different, then we
// will need to romp through the valuenodes
// and add actions to update their values.
if(new_time!=old_time)
void
Action::KeyframeDuplicate::process_value_desc(const synfigapp::ValueDesc& value_desc)
-{
+{
const synfig::Time old_time=keyframe.get_time();
const synfig::Time new_time=new_keyframe.get_time();
if(value_desc.is_value_node())
{
ValueNode::Handle value_node(value_desc.get_value_node());
-
+
// If we are a dynamic list, then we need to update the ActivePoints
if(ValueNode_DynamicList::Handle::cast_dynamic(value_node))
{
ValueNode_DynamicList::Handle value_node_dynamic(ValueNode_DynamicList::Handle::cast_dynamic(value_node));
int i;
-
+
for(i=0;i<value_node_dynamic->link_count();i++)
{
synfigapp::ValueDesc value_desc(value_node_dynamic,i);
activepoint.set_time(new_time);
Action::Handle action(ActivepointSetSmart::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_desc",value_desc);
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
- add_action_front(action);
+
+ add_action_front(action);
}
}
else if(ValueNode_Animated::Handle::cast_dynamic(value_node))
ValueNode_Animated::Handle value_node_animated(ValueNode_Animated::Handle::cast_dynamic(value_node));
Waypoint waypoint(value_node_animated->new_waypoint_at_time(old_time));
waypoint.set_time(new_time);
-
+
Action::Handle action(WaypointSetSmart::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_node",ValueNode::Handle(value_node_animated));
action->set_param("waypoint",waypoint);
-
+
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
- add_action_front(action);
+
+ add_action_front(action);
}
}
}
Action::KeyframeDuplicate::perform()
{
try { get_canvas()->keyframe_list().find(new_keyframe.get_time()); throw Error(_("A Keyframe already exists at this point in time"));}
- catch(synfig::Exception::NotFound) { }
+ catch(synfig::Exception::NotFound) { }
try { get_canvas()->keyframe_list().find(new_keyframe); throw Error(_("This keyframe is already in the ValueNode"));}
- catch(synfig::Exception::NotFound) { }
+ catch(synfig::Exception::NotFound) { }
Action::Super::perform();
-
+
get_canvas()->keyframe_list().add(new_keyframe);
-
+
if(get_canvas_interface())
{
get_canvas_interface()->signal_keyframe_added()(new_keyframe);
Action::KeyframeDuplicate::undo()
{
Action::Super::undo();
-
+
if(get_canvas_interface())
{
get_canvas_interface()->signal_keyframe_removed()(new_keyframe);
}
else synfig::warning("CanvasInterface not set on action");
- get_canvas()->keyframe_list().erase(new_keyframe);
+ get_canvas()->keyframe_list().erase(new_keyframe);
}
Action::KeyframeRemove::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("keyframe",Param::TYPE_KEYFRAME)
.set_local_name(_("Keyframe"))
.set_desc(_("Keyframe to be removed"))
if(name=="keyframe" && param.get_type()==Param::TYPE_KEYFRAME)
{
keyframe=param.get_keyframe();
-
+
return true;
}
catch(synfig::Exception::NotFound)
{
throw Error(_("Unable to find the given keyframe"));
- }
+ }
+
-
{
std::vector<synfigapp::ValueDesc> value_desc_list;
get_canvas_interface()->find_important_value_descs(value_desc_list);
void
Action::KeyframeRemove::process_value_desc(const synfigapp::ValueDesc& value_desc)
-{
+{
const synfig::Time time(keyframe.get_time());
if(value_desc.is_value_node())
{
ValueNode::Handle value_node(value_desc.get_value_node());
-
+
// If we are a dynamic list, then we need to update the ActivePoints
if(ValueNode_DynamicList::Handle::cast_dynamic(value_node))
{
synfigapp::ValueDesc value_desc(value_node_dynamic,i);
Action::Handle action(ActivepointRemove::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_desc",value_desc);
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
- add_action_front(action);
+
+ add_action_front(action);
}
catch(...)
{
Waypoint waypoint;
waypoint=*value_node_animated->find(time);
assert(waypoint.get_time()==time);
-
+
Action::Handle action(WaypointRemove::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_node",ValueNode::Handle(value_node_animated));
action->set_param("waypoint",waypoint);
-
+
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
- add_action_front(action);
+
+ add_action_front(action);
}
catch(...)
{
Action::KeyframeRemove::perform()
{
Action::Super::perform();
-
+
if(get_canvas_interface())
{
get_canvas_interface()->signal_keyframe_removed()(keyframe);
}
else synfig::warning("CanvasInterface not set on action");
- get_canvas()->keyframe_list().erase(keyframe);
+ get_canvas()->keyframe_list().erase(keyframe);
}
void
Action::KeyframeRemove::undo()
{
try { get_canvas()->keyframe_list().find(keyframe.get_time()); throw Error(_("A Keyframe already exists at this point in time"));}
- catch(synfig::Exception::NotFound) { }
+ catch(synfig::Exception::NotFound) { }
try { get_canvas()->keyframe_list().find(keyframe); throw Error(_("This keyframe is already in the ValueNode"));}
- catch(synfig::Exception::NotFound) { }
+ catch(synfig::Exception::NotFound) { }
Action::Super::undo();
-
+
get_canvas()->keyframe_list().add(keyframe);
-
+
if(get_canvas_interface())
{
get_canvas_interface()->signal_keyframe_added()(keyframe);
Action::KeyframeSet::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("keyframe",Param::TYPE_KEYFRAME)
.set_local_name(_("New Keyframe"))
.set_desc(_("Keyframe to be added"))
keyframe=param.get_keyframe();
synfig::info("KeyframeSet::set_param():new_time: %s",keyframe.get_time().get_string().c_str());
synfig::info("KeyframeSet::set_param():get_keyframe(): %s",param.get_keyframe().get_time().get_string().c_str());
-
+
return true;
}
{
clear();
guid_set.clear();
-
-
-
-
+
+
+
+
//synfig::info("new_time: %s",new_time.get_string().c_str());
//synfig::info("old_time: %s",old_time.get_string().c_str());
-
+
try { if(get_canvas()->keyframe_list().find(new_time)!=get_canvas()->keyframe_list().end()) throw Error(_("A Keyframe already exists at this point in time"));}
- catch(...) { }
+ catch(...) { }
- // If the times are different, then we
+ // If the times are different, then we
// will need to romp through the valuenodes
// and add actions to update their values.
if(new_time!=old_time)
{
ValueNode_DynamicList::Handle value_node(ValueNode_DynamicList::Handle::cast_static(value_desc.get_parent_value_node()));
ValueNode_DynamicList::ListEntry& list_entry(value_node->list[value_desc.get_index()]);
-
+
std::vector<Activepoint*> selected;
std::vector<Activepoint*>::iterator iter;
-
+
if(list_entry.find(old_begin,old_end,selected))
{
// check to make sure this operation is OK
}
catch(Exception::NotFound) { }
}
-
+
int ret(0);
while(!selected.empty())
{
if(selected.back()->get_time()!=old_2_new(selected.back()->get_time()))
{
Action::Handle action(Action::create("activepoint_set"));
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_desc",value_desc);
-
+
Activepoint activepoint(*selected.back());
activepoint.set_time(old_2_new(selected.back()->get_time()));
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
- add_action_front(action);
+
+ add_action_front(action);
ret++;
}
Action::KeyframeSet::scale_waypoints(const synfigapp::ValueDesc& value_desc,const Time& old_begin,const Time& old_end,const Time& new_begin,const Time& new_end)
{
ValueNode_Animated::Handle value_node(ValueNode_Animated::Handle::cast_static(value_desc.get_value_node()));
-
+
std::vector<Waypoint*> selected;
std::vector<Waypoint*>::iterator iter;
-
+
if(value_node->find(old_begin,old_end,selected))
{
// check to make sure this operation is OK
}
catch(Exception::NotFound) { }
}
-
+
int ret(0);
while(!selected.empty())
{
if(selected.back()->get_time()!=old_2_new(selected.back()->get_time()))
{
Action::Handle action(Action::create("waypoint_set"));
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_node",ValueNode::Handle::cast_static(value_node));
-
+
Waypoint waypoint(*selected.back());
waypoint.set_time(old_2_new(selected.back()->get_time()));
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
- add_action_front(action);
+
+ add_action_front(action);
ret++;
}
void
Action::KeyframeSet::process_value_desc(const synfigapp::ValueDesc& value_desc)
-{
+{
if(value_desc.is_value_node())
- {
+ {
ValueNode::Handle value_node(value_desc.get_value_node());
//if(guid_set.count(value_node->get_guid()))
scale_activepoints(value_desc,old_time,keyframe_next,new_time,keyframe_next);
}
//else
- {
+ {
Action::Handle action(ActivepointSetSmart::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_desc",value_desc);
-
+
Activepoint activepoint;
try
{
activepoint.set_priority(0);
}
action->set_param("activepoint",activepoint);
-
+
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action_front(action);
}
}
//else
{
ValueNode_Animated::Handle value_node_animated(ValueNode_Animated::Handle::cast_dynamic(value_node));
-
+
Action::Handle action(WaypointSetSmart::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_node",ValueNode::Handle(value_node_animated));
-
+
Waypoint waypoint;
try
{
waypoint.set_value((*value_node_animated)(old_time));
}
action->set_param("waypoint",waypoint);
-
+
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action_front(action);
}
}
old_time=get_canvas()->keyframe_list().find(keyframe)->get_time();
new_time=keyframe.get_time();
-
+
try { get_canvas()->keyframe_list().find(keyframe);}
catch(synfig::Exception::NotFound)
{
throw Error(_("Unable to find the given keyframe"));
- }
-
+ }
+
// Check for colisions
if(old_time!=new_time)
{
old_keyframe=*get_canvas()->keyframe_list().find(keyframe);
*get_canvas()->keyframe_list().find(keyframe)=keyframe;
-
+
get_canvas()->keyframe_list().sync();
try{
get_canvas()->keyframe_list().sync();
throw;
}
-
+
// Signal that a layer has been inserted
if(get_canvas_interface())
{
*get_canvas()->keyframe_list().find(old_keyframe)=old_keyframe;
get_canvas()->keyframe_list().sync();
-
+
// Signal that a layer has been inserted
if(get_canvas_interface())
{
synfig::Time new_time;
synfig::Time keyframe_prev,keyframe_next;
-
+
std::set<synfig::GUID> guid_set;
void process_value_desc(const synfigapp::ValueDesc& value_desc);
-
+
int scale_activepoints(const synfigapp::ValueDesc& value_desc,const synfig::Time& old_begin,const synfig::Time& old_end,const synfig::Time& new_begin,const synfig::Time& new_end);
int scale_waypoints(const synfigapp::ValueDesc& value_desc,const synfig::Time& old_begin,const synfig::Time& old_end,const synfig::Time& new_begin,const synfig::Time& new_end);
Action::KeyframeSetDelta::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("keyframe",Param::TYPE_KEYFRAME)
.set_local_name(_("Keyframe"))
);
value_desc_list.clear();
get_canvas_interface()->find_important_value_descs(value_desc_list);
-
+
Time time(get_canvas()->keyframe_list().find(keyframe)->get_time());
-
+
std::vector<synfigapp::ValueDesc>::iterator iter;
DEBUGPOINT();
for(iter=value_desc_list.begin();iter!=value_desc_list.end();++iter)
ValueNode_Animated::Handle value_node(
ValueNode_Animated::Handle::cast_dynamic(value_desc.get_value_node())
);
-
+
if(!value_node)
continue;
-
+
try{
value_node->find(time);
// if we got to this point, then we know that
}
}
Action::Handle action(Action::create("waypoint_set_smart"));
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_node",ValueNode::Handle::cast_static(value_node));
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
- add_action(action);
+
+ add_action(action);
}
}
if(!delta)
return;
Action::Super::perform();
-
+
// Time location(keyframe.get_time());
- Time location(get_canvas()->keyframe_list().find(keyframe)->get_time());
+ Time location(get_canvas()->keyframe_list().find(keyframe)->get_time());
Time delta(delta);
-
+
get_canvas()->keyframe_list().insert_time(location,delta);
std::vector<synfigapp::ValueDesc>::iterator iter;
{
if(!delta)
return;
-
+
// Time location(keyframe.get_time());
- Time location(get_canvas()->keyframe_list().find(keyframe)->get_time());
+ Time location(get_canvas()->keyframe_list().find(keyframe)->get_time());
Time delta(-delta);
-
+
get_canvas()->keyframe_list().insert_time(location,delta);
std::vector<synfigapp::ValueDesc>::iterator iter;
std::vector<synfigapp::ValueDesc> value_desc_list;
void process_value_desc(const synfigapp::ValueDesc& value_desc);
-
+
int scale_activepoints(const synfigapp::ValueDesc& value_desc,const synfig::Time& old_begin,const synfig::Time& old_end,const synfig::Time& new_begin,const synfig::Time& new_end);
int scale_waypoints(const synfigapp::ValueDesc& value_desc,const synfig::Time& old_begin,const synfig::Time& old_end,const synfig::Time& new_begin,const synfig::Time& new_end);
Action::KeyframeWaypointSet::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("keyframe",Param::TYPE_KEYFRAME)
.set_local_name(_("Keyframe"))
);
if(name=="keyframe" && param.get_type()==Param::TYPE_KEYFRAME)
{
keyframe=param.get_keyframe();
-
+
return true;
}
if(name=="model" && param.get_type()==Param::TYPE_WAYPOINTMODEL)
{
waypoint_model=param.get_waypoint_model();
-
+
return true;
}
catch(synfig::Exception::NotFound)
{
throw Error(_("Unable to find the given keyframe"));
- }
+ }
{
std::vector<synfigapp::ValueDesc> value_desc_list;
void
Action::KeyframeWaypointSet::process_value_desc(const synfigapp::ValueDesc& value_desc)
-{
+{
if(value_desc.is_value_node())
{
ValueNode_Animated::Handle value_node(ValueNode_Animated::Handle::cast_dynamic(value_desc.get_value_node()));
-
+
if(value_node)
- {
+ {
Action::Handle action(WaypointSetSmart::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_node",ValueNode::Handle(value_node));
-
+
Waypoint waypoint;
try
{
waypoint.set_value((*value_node)(keyframe.get_time()));
}
waypoint.apply_model(waypoint_model);
-
+
action->set_param("waypoint",waypoint);
-
+
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
- add_action_front(action);
+
+ add_action_front(action);
}
}
}
/* === M A C R O S ========================================================= */
#define ACTION_INIT2(class) \
Action::Base* class::create() { return new class(); } \
- synfig::String class::get_name()const { return name__; }
+ synfig::String class::get_name()const { return name__; }
ACTION_INIT2(Action::LayerActivate);
ACTION_SET_NAME(Action::LayerActivate,"layer_activate");
Action::LayerActivate::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("layer",Param::TYPE_LAYER)
.set_local_name(_("Layer"))
);
.set_local_name(_("New Status"))
.set_desc(_("The new status of the layer"))
);
-
+
return ret;
}
if(name=="layer" && param.get_type()==Param::TYPE_LAYER)
{
layer=param.get_layer();
-
+
return true;
}
if(name=="new_status" && param.get_type()==Param::TYPE_BOOL)
{
new_status=param.get_bool();
-
+
return true;
}
Action::LayerActivate::perform()
{
Canvas::Handle subcanvas(layer->get_canvas());
-
+
// Find the iterator for the layer
Canvas::iterator iter=find(subcanvas->begin(),subcanvas->end(),layer);
-
+
// If we couldn't find the layer in the canvas, then bail
if(*iter!=layer)
throw Error(_("This layer doesn't exist anymore."));
//if(get_canvas()!=subcanvas && !subcanvas->is_inline())
//if(get_canvas()->get_root()!=subcanvas->get_root())
// throw Error(_("This layer doesn't belong to this composition"));
-
+
old_status=layer->active();
-
+
// If we are changing the status to what it already is,
// the go ahead and return
if(new_status==old_status)
}
else
set_dirty();
-
+
if(new_status)
layer->enable();
else
layer->enable();
else
layer->disable();
-
+
if(get_canvas_interface())
{
get_canvas_interface()->signal_layer_status_changed()(layer,old_status);
Action::LayerAdd::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("new",Param::TYPE_LAYER)
.set_local_name(_("New Layer"))
.set_desc(_("Layer to be added"))
);
-
+
return ret;
}
if(name=="new" && param.get_type()==Param::TYPE_LAYER)
{
layer=param.get_layer();
-
+
return true;
}
{
// Set the layer's canvas
layer->set_canvas(get_canvas());
-
+
// Push the layer onto the front of the canvas
- get_canvas()->push_front(layer);
+ get_canvas()->push_front(layer);
// Mark ourselves as dirty if necessary
//set_dirty(layer->active());
-
+
// Signal that a layer has been inserted
if(get_canvas_interface())
{
{
// Find the iterator for the layer
Canvas::iterator iter=find(get_canvas()->begin(),get_canvas()->end(),layer);
-
+
// If we couldn't find the layer in the canvas, then bail
if(*iter!=layer)
throw Error(_("This layer doesn't exist anymore."));
-
+
// Remove the layer from the canvas
get_canvas()->erase(iter);
// Mark ourselves as dirty if necessary
//set_dirty(layer->active());
-
+
// Signal that a layer has been inserted
if(get_canvas_interface())
{
Action::LayerDuplicate::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("layer",Param::TYPE_LAYER)
.set_local_name(_("Layer"))
.set_desc(_("Layer to be duplicated"))
.set_supports_multiple()
);
-
+
return ret;
}
if(name=="layer" && param.get_type()==Param::TYPE_LAYER)
{
layers.push_back(param.get_layer());
-
+
return true;
}
{
if(!first_time())
return;
-
+
std::list<synfig::Layer::Handle>::const_iterator iter;
-
+
for(iter=layers.begin();iter!=layers.end();++iter)
{
Layer::Handle layer(*iter);
-
+
Canvas::Handle subcanvas(layer->get_canvas());
-
+
// Find the iterator for the layer
Canvas::iterator iter=find(subcanvas->begin(),subcanvas->end(),layer);
-
+
// If we couldn't find the layer in the canvas, then bail
if(*iter!=layer)
throw Error(_("This layer doesn't exist anymore."));
-
+
// If the subcanvas isn't the same as the canvas,
// then it had better be an inline canvas. If not,
// bail
if(get_canvas()!=subcanvas && !subcanvas->is_inline())
throw Error(_("This layer doesn't belong to this canvas anymore"));
-
+
Layer::Handle new_layer(layer->clone(guid));
-
+
{
Action::Handle action(Action::create("layer_move"));
-
+
action->set_param("canvas",subcanvas);
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("layer",new_layer);
action->set_param("new_index",layers.front()->get_depth());
-
+
add_action_front(action);
}
{
Action::Handle action(Action::create("layer_add"));
-
+
action->set_param("canvas",subcanvas);
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("new",new_layer);
-
+
add_action_front(action);
}
}
Action::LayerEncapsulate::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("layer",Param::TYPE_LAYER)
.set_local_name(_("Layer"))
.set_desc(_("Layer to be encapsulated"))
.set_supports_multiple()
);
-
+
return ret;
}
if(name=="layer" && param.get_type()==Param::TYPE_LAYER)
{
layers.push_back(param.get_layer());
-
+
return true;
}
{
std::list<synfig::Layer::Handle>::const_iterator iter;
int lowest_depth(0x7fffffff);
-
+
for(iter=layers.begin();iter!=layers.end();++iter)
{
int depth((*iter)->get_depth());
if(layers.empty())
throw Error("No layers to encapsulate");
-
+
// First create the new canvas and layer
if(!child_canvas)
child_canvas=Canvas::create_inline(get_canvas());
-
+
Layer::Handle new_layer(Layer::create("PasteCanvas"));
-
+
new_layer->set_param("canvas",child_canvas);
-
+
int target_depth(lowest_depth());
-
+
// Add the layer
{
Action::Handle action(LayerAdd::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("new",new_layer);
-
+
add_action(action);
- }
-
+ }
+
// Move the layer
{
Action::Handle action(Action::create("layer_move"));
-
+
assert(action);
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("layer",new_layer);
action->set_param("new_index",target_depth);
-
+
add_action(action);
- }
-
+ }
+
std::list<synfig::Layer::Handle>::reverse_iterator iter;
-
+
for(iter=layers.rbegin();iter!=layers.rend();++iter)
{
Layer::Handle layer(*iter);
-
+
Canvas::Handle subcanvas(layer->get_canvas());
-
+
// Find the iterator for the layer
Canvas::iterator iter=find(subcanvas->begin(),subcanvas->end(),layer);
-
+
// If we couldn't find the layer in the canvas, then bail
if(*iter!=layer)
throw Error(_("This layer doesn't exist anymore."));
-
+
if(!subcanvas)
throw Error(_("This layer doesn't have a parent canvas"));
if(get_canvas()!=subcanvas)
throw Error(_("get_canvas()!=subcanvas"));
-
+
// Remove the layer from the old canvas
{
Action::Handle action(LayerRemove::create());
-
+
action->set_param("canvas",subcanvas);
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("layer",layer);
-
+
add_action(action);
}
// Add the layer to the new canvas
{
Action::Handle action(LayerAdd::create());
-
+
action->set_param("canvas",child_canvas);
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("new",layer);
-
+
add_action(action);
}
}
Action::LayerLower::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("layer",Param::TYPE_LAYER)
.set_local_name(_("Layer"))
.set_desc(_("Layer to be lowered"))
.set_supports_multiple()
);
-
+
return ret;
}
{
if(!candidate_check(get_param_vocab(),x))
return false;
-
+
Layer::Handle layer(x.find("layer")->second.get_layer());
//synfig::info("layer->get_depth()= %d ; layer->get_canvas()->size()=%d ;",layer->get_depth(),layer->get_canvas()->size());
if(layer->get_depth()+1>=layer->get_canvas()->size())
if(name=="layer" && param.get_type()==Param::TYPE_LAYER)
{
layers.push_back(param.get_layer());
-
+
return true;
}
std::list<synfig::Layer::Handle>::const_iterator iter;
clear();
-
+
for(iter=layers.begin();iter!=layers.end();++iter)
{
Layer::Handle layer(*iter);
-
+
Canvas::Handle subcanvas(layer->get_canvas());
-
+
// Find the iterator for the layer
Canvas::iterator iter=find(subcanvas->begin(),subcanvas->end(),layer);
-
+
// If we couldn't find the layer in the canvas, then bail
if(*iter!=layer)
throw Error(_("This layer doesn't exist anymore."));
-
+
// If the subcanvas isn't the same as the canvas,
// then it had better be an inline canvas. If not,
// bail
//if(get_canvas()!=subcanvas && !subcanvas->is_inline())
// throw Error(_("This layer doesn't belong to this canvas anymore"));
-
+
int new_index=iter-subcanvas->begin();
-
+
new_index++;
-
+
// If this lowers the layer past the bottom then don't bother
if(new_index==subcanvas->size())
continue;
-
+
Action::Handle layer_move(LayerMove::create());
-
+
layer_move->set_param("canvas",get_canvas());
layer_move->set_param("canvas_interface",get_canvas_interface());
layer_move->set_param("layer",layer);
layer_move->set_param("new_index",new_index);
-
+
add_action_front(layer_move);
}
}
Action::LayerMove::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("layer",Param::TYPE_LAYER)
.set_local_name(_("Layer"))
.set_desc(_("Layer to be moved"))
.set_desc(_("The canvas the layer is to be moved to"))
.set_optional()
);
-
+
return ret;
}
{
layer=param.get_layer();
-
+
return true;
}
if(name=="new_index" && param.get_type()==Param::TYPE_INTEGER)
{
new_index=param.get_integer();
-
+
return true;
}
if(name=="dest_canvas" && param.get_type()==Param::TYPE_CANVAS)
{
dest_canvas=param.get_canvas();
-
+
return true;
}
void
Action::LayerMove::perform()
-{
+{
synfig::info(__FILE__":%d: layer->count()=%d",__LINE__,layer.count());
Canvas::Handle subcanvas(layer->get_canvas());
src_canvas=subcanvas;
if(!dest_canvas)
dest_canvas=subcanvas;
-
+
// Find the iterator for the layer
Canvas::iterator iter=find(src_canvas->begin(),src_canvas->end(),layer);
-
+
// If we couldn't find the layer in the canvas, then bail
if(*iter!=layer)
throw Error(_("This layer doesn't exist anymore."));
//if(get_canvas()!=subcanvas && !subcanvas->is_inline())
if(get_canvas()->get_root()!=dest_canvas->get_root() || get_canvas()->get_root()!=src_canvas->get_root())
throw Error(_("You cannot directly move layers across compositions"));
-
+
old_index=iter-src_canvas->begin();
int depth;
-
+
if(new_index<0)
depth=dest_canvas->size()+new_index+1;
else
depth=new_index;
-
+
set_dirty(layer->active());
synfig::info(__FILE__":%d: layer->count()=%d",__LINE__,layer.count());
// If we were to move it to where it is
if(old_index==depth && src_canvas==dest_canvas)
return;
-
+
if(depth>dest_canvas->size())
depth=dest_canvas->size();
if(depth<0)
depth=0;
-
+
src_canvas->erase(iter);
-
- dest_canvas->insert(dest_canvas->begin()+depth,layer);
+
+ dest_canvas->insert(dest_canvas->begin()+depth,layer);
layer->set_canvas(dest_canvas);
-
+
layer->changed();
dest_canvas->changed(); if(dest_canvas!=src_canvas) src_canvas->changed();
-
+
synfig::info(__FILE__":%d: layer->count()=%d",__LINE__,layer.count());
-
+
if(get_canvas_interface())
{
if(src_canvas==dest_canvas)
{
// Find the iterator for the layer
Canvas::iterator iter=find(dest_canvas->begin(),dest_canvas->end(),layer);
-
+
// If we couldn't find the layer in the canvas, then bail
if(*iter!=layer || (get_canvas()!=dest_canvas && !dest_canvas->is_inline()))
throw Error(_("This layer doesn't exist anymore."));
-
+
// If we were to move it to where it is
if(old_index==new_index && src_canvas==dest_canvas)
return;
set_dirty(layer->active());
dest_canvas->erase(iter);
-
+
src_canvas->insert(src_canvas->begin()+old_index,layer);
layer->set_canvas(src_canvas);
layer->changed();
dest_canvas->changed(); if(dest_canvas!=src_canvas) src_canvas->changed();
-
+
// Execute any signals
if(get_canvas_interface())
{
else
{
get_canvas_interface()->signal_layer_moved()(layer,old_index,src_canvas);
- //get_canvas_interface()->signal_layer_removed()(layer);
+ //get_canvas_interface()->signal_layer_removed()(layer);
//get_canvas_interface()->signal_layer_inserted()(layer,old_index);
}
}
Action::LayerParamConnect::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("layer",Param::TYPE_LAYER)
.set_local_name(_("Layer"))
);
ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE)
.set_local_name(_("ValueNode"))
);
-
+
return ret;
}
if(name=="layer" && param.get_type()==Param::TYPE_LAYER)
{
layer=param.get_layer();
-
+
return true;
}
if(name=="value_node" && param.get_type()==Param::TYPE_VALUENODE)
{
value_node=param.get_value_node();
-
+
return true;
}
if(name=="param" && param.get_type()==Param::TYPE_STRING)
{
param_name=param.get_string();
-
+
return true;
}
synfig::warning("Action::LayerParamConnect: Missing \"value_node\"");
if(param_name.empty())
synfig::warning("Action::LayerParamConnect: Missing \"param\"");
-
+
if(!layer || !value_node || param_name.empty())
return false;
return Action::CanvasSpecific::is_ready();
old_value=layer->get_param(param_name);
if(!old_value.is_valid())
- throw Error(_("Layer did not recognise parameter name"));
+ throw Error(_("Layer did not recognise parameter name"));
if(!layer->set_param(param_name,(*value_node)(0)))
throw Error(_("Bad connection"));
-
+
layer->connect_dynamic_param(param_name,value_node);
layer->changed();
layer->disconnect_dynamic_param(param_name);
layer->set_param(param_name,old_value);
}
-
+
layer->changed();
if(old_value_node)
old_value_node->changed();
else
set_dirty(false);
*/
-
+
if(get_canvas_interface())
{
get_canvas_interface()->signal_layer_param_changed()(layer,param_name);
Action::LayerParamDisconnect::LayerParamDisconnect():
time(0)
{
-
+
}
Action::ParamVocab
Action::LayerParamDisconnect::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("layer",Param::TYPE_LAYER)
.set_local_name(_("Layer"))
);
.set_local_name(_("Time"))
.set_optional()
);
-
+
return ret;
}
if(name=="layer" && param.get_type()==Param::TYPE_LAYER)
{
layer=param.get_layer();
-
+
return true;
}
if(name=="param" && param.get_type()==Param::TYPE_STRING)
{
param_name=param.get_string();
-
+
return true;
}
if(name=="time" && param.get_type()==Param::TYPE_TIME)
{
time=param.get_time();
-
+
return true;
}
old_value_node=layer->dynamic_param_list().find(param_name)->second;
layer->disconnect_dynamic_param(param_name);
-
+
if(new_value_node || ValueNode_DynamicList::Handle::cast_dynamic(old_value_node))
{
if(!new_value_node)
}
else
layer->set_param(param_name,(*old_value_node)(time));
-
+
layer->changed();
old_value_node->changed();
set_dirty(false);
-
+
if(get_canvas_interface())
{
get_canvas_interface()->signal_layer_param_changed()(layer,param_name);
Action::LayerParamDisconnect::undo()
{
layer->connect_dynamic_param(param_name,old_value_node);
-
+
/* if(layer->active() && get_canvas()->get_time()!=time)
set_dirty(true);
else
Action::LayerParamSet::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("layer",Param::TYPE_LAYER)
.set_local_name(_("Layer"))
);
ret.push_back(ParamDesc("new_value",Param::TYPE_VALUE)
.set_local_name(_("ValueBase"))
);
-
+
return ret;
}
if(name=="layer" && param.get_type()==Param::TYPE_LAYER)
{
layer=param.get_layer();
-
+
return true;
}
if(name=="new_value" && param.get_type()==Param::TYPE_VALUE)
{
new_value=param.get_value();
-
+
return true;
}
if(name=="param" && param.get_type()==Param::TYPE_STRING)
{
param_name=param.get_string();
-
+
return true;
}
throw Error(_("ValueNode attached to Parameter."));
old_value=layer->get_param(param_name);
-
+
if(!layer->set_param(param_name,new_value))
throw Error(_("Layer did not accept parameter."));
set_dirty(false);
*/
layer->changed();
-
+
// Signal that a layer has been inserted
if(get_canvas_interface())
{
else
set_dirty(false);
*/
-
+
layer->changed();
-
+
// Signal that a layer has been inserted
if(get_canvas_interface())
{
Action::LayerRaise::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("layer",Param::TYPE_LAYER)
.set_local_name(_("Layer"))
.set_desc(_("Layer to be raised"))
.set_supports_multiple()
);
-
+
return ret;
}
if(name=="layer" && param.get_type()==Param::TYPE_LAYER)
{
layers.push_back(param.get_layer());
-
+
return true;
}
std::list<synfig::Layer::Handle>::reverse_iterator iter;
clear();
-
+
for(iter=layers.rbegin();!(iter==layers.rend());++iter)
{
Layer::Handle layer(*iter);
-
+
Canvas::Handle subcanvas(layer->get_canvas());
-
+
// Find the iterator for the layer
Canvas::iterator iter=find(subcanvas->begin(),subcanvas->end(),layer);
-
+
// If we couldn't find the layer in the canvas, then bail
if(*iter!=layer)
throw Error(_("This layer doesn't exist anymore."));
-
+
// If the subcanvas isn't the same as the canvas,
// then it had better be an inline canvas. If not,
// bail
//if(get_canvas()!=subcanvas && !subcanvas->is_inline())
// throw Error(_("This layer doesn't belong to this canvas anymore"));
-
+
int new_index=iter-subcanvas->begin();
-
+
if(new_index==0)
continue;
-
+
new_index--;
-
+
Action::Handle layer_move(LayerMove::create());
-
+
layer_move->set_param("canvas",get_canvas());
layer_move->set_param("canvas_interface",get_canvas_interface());
layer_move->set_param("layer",layer);
layer_move->set_param("new_index",new_index);
-
+
add_action_front(layer_move);
}
}
Action::LayerRemove::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("layer",Param::TYPE_LAYER)
.set_local_name(_("Layer"))
.set_desc(_("Layer to be deleted"))
.set_supports_multiple()
);
-
+
return ret;
}
std::pair<synfig::Layer::Handle,int> layer_pair;
layer_pair.first=param.get_layer();
layer_list.push_back(layer_pair);
-
+
return true;
}
// Find the iterator for the layer
Canvas::iterator iter2=find(subcanvas->begin(),subcanvas->end(),layer);
-
+
// If we couldn't find the layer in the canvas, then bail
if(*iter2!=layer)
{
** before we go throwing shit around */
throw Error(_("This layer doesn't exist anymore."));
}
-
+
// If the subcanvas isn't the same as the canvas,
// then it had better be an inline canvas. If not,
// bail
** before we go throwing shit around */
throw Error(_("This layer doesn't belong to this canvas anymore"));
}
-
+
set_canvas(subcanvas);
-
+
// Calculate the depth that the layer was at (For the undo)
iter->second=layer->get_depth();
-
+
// Mark ourselves as dirty if necessary
set_dirty(layer->active());
-
+
// Remove the layer from the canvas
subcanvas->erase(iter2);
-
+
// Signal that a layer has been removed
if(get_canvas_interface())
get_canvas_interface()->signal_layer_removed()(layer);
{
std::list<std::pair<synfig::Layer::Handle,int> >::reverse_iterator iter;
for(iter=layer_list.rbegin();iter!=layer_list.rend();++iter)
- {
+ {
Layer::Handle layer(iter->first);
int& depth(iter->second);
-
+
// Set the layer's canvas
layer->set_canvas(get_canvas());
-
+
// Make sure that the depth is valid
if(get_canvas()->size()<depth)
depth=get_canvas()->size();
-
+
// Mark ourselves as dirty if necessary
set_dirty(layer->active());
-
+
// Insert the layer into the canvas at the desired depth
- get_canvas()->insert(get_canvas()->begin()+depth,layer);
-
+ get_canvas()->insert(get_canvas()->begin()+depth,layer);
+
// Signal that a layer has been inserted
if(get_canvas_interface())
get_canvas_interface()->signal_layer_inserted()(layer,depth);
private:
std::list<std::pair<synfig::Layer::Handle,int> > layer_list;
-
+
//synfig::Layer::Handle layer;
//int depth;
Action::LayerSetDesc::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("layer",Param::TYPE_LAYER)
.set_local_name(_("Layer"))
.set_desc(_("Layer to be moved"))
.set_local_name(_("Enter a new description for this layer"))
.set_user_supplied()
);
-
+
return ret;
}
if(name=="layer" && param.get_type()==Param::TYPE_LAYER)
{
layer=param.get_layer();
-
+
return true;
}
if(name=="new_description" && param.get_type()==Param::TYPE_STRING)
{
new_description=param.get_string();
-
+
return true;
}
Action::TimepointsCopy::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("addlayer",Param::TYPE_VALUE)
.set_local_name(_("New Selected Layer"))
.set_desc(_("A layer to add to our selected list"))
.set_supports_multiple()
.set_optional()
);
-
+
ret.push_back(ParamDesc("addcanvas",Param::TYPE_CANVAS)
.set_local_name(_("New Selected Canvas"))
.set_desc(_("A canvas to add to our selected list"))
.set_supports_multiple()
.set_optional()
);
-
+
ret.push_back(ParamDesc("addvaluedesc",Param::TYPE_VALUEDESC)
.set_local_name(_("New Selected ValueBase"))
.set_desc(_("A valuenode's description to add to our selected list"))
.set_supports_multiple()
.set_optional()
);
-
+
ret.push_back(ParamDesc("addtime",Param::TYPE_TIME)
.set_local_name(_("New Selected Time Point"))
.set_desc(_("A time point to add to our selected list"))
.set_supports_multiple()
);
-
+
ret.push_back(ParamDesc("deltatime",Param::TYPE_TIME)
.set_local_name(_("Time adjustment"))
.set_desc(_("The amount of time to adjust all the selected points"))
bool
Action::TimepointsCopy::is_candidate(const ParamList &x)
{
- if(!candidate_check(get_param_vocab(),x))
+ if(!candidate_check(get_param_vocab(),x))
return false;
-
- if( x.find("addlayer") == x.end() &&
- x.find("addcanvas") == x.end() &&
+
+ if( x.find("addlayer") == x.end() &&
+ x.find("addcanvas") == x.end() &&
x.find("addvaluedesc") == x.end())
return false;
return true;
//add a layer to the list
sel_layers.push_back(param.get_layer());
//synfig::info("action got layer");
-
+
return true;
}
-
+
if(name=="addcanvas" && param.get_type()==Param::TYPE_CANVAS)
{
//add a layer to the list
sel_canvases.push_back(param.get_canvas());
//synfig::info("action got canvas");
-
+
return true;
}
-
+
if(name=="addvaluedesc" && param.get_type()==Param::TYPE_VALUEDESC)
{
//add a layer to the list
sel_values.push_back(param.get_value_desc());
//synfig::info("action got valuedesc");
-
+
return true;
}
-
+
if(name=="addtime" && param.get_type()==Param::TYPE_TIME)
{
//add a layer to the list
sel_times.insert(param.get_time());
//synfig::info("action got time");
-
+
return true;
}
-
+
if(name=="deltatime" && param.get_type()==Param::TYPE_TIME)
{
timedelta = param.get_time();
//synfig::info("action got time to move");
-
+
return true;
}
Action::TimepointsCopy::prepare()
{
clear();
-
+
//synfig::info("Preparing TimepointsCopy by %f secs",(float)timemove);
-
+
if(sel_times.empty()) return;
-
+
//all our lists should be set correctly...
//build our sub-action list
- // and yes we do need to store it temporarily so we don't duplicate
+ // and yes we do need to store it temporarily so we don't duplicate
// an operation on a specific valuenode, etc....
timepoints_ref match;
-
+
Time fps = get_canvas()->rend_desc().get_frame_rate();
-
+
//std::vector<synfig::Layer::Handle>
//synfig::info("Layers %d", sel_layers.size());
{
std::vector<synfig::Layer::Handle>::iterator i = sel_layers.begin(),
end = sel_layers.end();
-
+
for(; i != end; ++i)
{
//synfig::info("Recurse through a layer");
recurse_layer(*i,sel_times,match);
}
}
-
+
//std::vector<synfig::Canvas::Handle> sel_canvases;
//synfig::info("Canvases %d", sel_canvases.size());
{
std::vector<synfig::Canvas::Handle>::iterator i = sel_canvases.begin(),
end = sel_canvases.end();
-
+
for(; i != end; ++i)
{
//synfig::info("Recurse through a canvas");
recurse_canvas(*i,sel_times,match);
}
}
-
+
//std::vector<synfigapp::ValueDesc>
//synfig::info("ValueBasedescs %d", sel_values.size());
{
std::vector<synfigapp::ValueDesc>::iterator i = sel_values.begin(),
end = sel_values.end();
-
+
for(; i != end; ++i)
{
//synfig::info("Recurse through a valuedesc");
recurse_valuedesc(*i,sel_times,match);
}
}
-
+
//synfig::info("built list of waypoints/activepoints to modify");
- //synfig::info("\t There are %d waypoint sets and %d activepointsets",
+ //synfig::info("\t There are %d waypoint sets and %d activepointsets",
// match.waypointbiglist.size(), match.actpointbiglist.size());
//process the hell out of em...
{
{
//iterate through each waypoint for this specific valuenode
std::set<synfig::Waypoint>::const_iterator j = i->waypoints.begin(),
- end = i->waypoints.end();
+ end = i->waypoints.end();
for(; j != end; ++j)
{
Action::Handle action(WaypointSimpleAdd::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_node",ValueNode::Handle(i->val));
-
+
//synfig::info("add waypoint mod...");
//NOTE: We may want to store the old time for undoing the action...
Waypoint neww;
Waypoint w = *j;
w.set_time((w.get_time() + timedelta).round(fps));
w.mimic(neww); //make sure the new waypoint has a new id
-
+
action->set_param("waypoint",w);
-
+
//run the action now that we've added everything
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action_front(action);
}
}
for(; j != jend; ++j)
{
Action::Handle action(ActivepointSimpleAdd::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_desc",i->val);
-
+
//NOTE: We may want to store the old time for undoing the action...
Activepoint newa;
Activepoint a = *j;
a.set_time((a.get_time() + timedelta).round(fps));
a.mimic(newa); //make sure the new activepoint has a new id
-
+
action->set_param("activepoint",a);
-
+
assert(action->is_ready());
if(!action->is_ready())
{
throw Error(Error::TYPE_NOTREADY);
}
-
+
add_action_front(action);
}
}
public Super
{
private:
-
+
//process all the value descriptions that are selected (or are in subselections)
std::vector<synfig::Layer::Handle> sel_layers;
std::vector<synfig::Canvas::Handle> sel_canvases;
std::vector<synfigapp::ValueDesc> sel_values;
std::set<synfig::Time> sel_times;
-
+
synfig::Time timedelta;
public:
Action::TimepointsDelete::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("addlayer",Param::TYPE_VALUE)
.set_local_name(_("New Selected Layer"))
.set_desc(_("A layer to add to our selected list"))
.set_supports_multiple()
.set_optional()
);
-
+
ret.push_back(ParamDesc("addcanvas",Param::TYPE_CANVAS)
.set_local_name(_("New Selected Canvas"))
.set_desc(_("A canvas to add to our selected list"))
.set_supports_multiple()
.set_optional()
);
-
+
ret.push_back(ParamDesc("addvaluedesc",Param::TYPE_VALUEDESC)
.set_local_name(_("New Selected ValueBase"))
.set_desc(_("A valuenode's description to add to our selected list"))
.set_supports_multiple()
.set_optional()
);
-
+
ret.push_back(ParamDesc("addtime",Param::TYPE_TIME)
.set_local_name(_("New Selected Time Point"))
.set_desc(_("A time point to add to our selected list"))
.set_supports_multiple()
);
-
+
return ret;
}
bool
Action::TimepointsDelete::is_candidate(const ParamList &x)
{
- if(!candidate_check(get_param_vocab(),x))
+ if(!candidate_check(get_param_vocab(),x))
return false;
-
- if( x.find("addlayer") == x.end() &&
- x.find("addcanvas") == x.end() &&
+
+ if( x.find("addlayer") == x.end() &&
+ x.find("addcanvas") == x.end() &&
x.find("addvaluedesc") == x.end())
return false;
return true;
{
//add a layer to the list
sel_layers.push_back(param.get_layer());
-
+
return true;
}
-
+
if(name=="addcanvas" && param.get_type()==Param::TYPE_CANVAS)
{
//add a layer to the list
sel_canvases.push_back(param.get_canvas());
-
+
return true;
}
-
+
if(name=="addvaluedesc" && param.get_type()==Param::TYPE_VALUEDESC)
{
//add a layer to the list
sel_values.push_back(param.get_value_desc());
-
+
return true;
}
-
+
if(name=="addtime" && param.get_type()==Param::TYPE_TIME)
{
//add a layer to the list
sel_times.insert(param.get_time());
-
+
return true;
}
Action::TimepointsDelete::prepare()
{
clear();
-
+
if(sel_times.empty()) return;
-
+
//all our lists should be set correctly...
//build our sub-action list
- // and yes we do need to store it temporarily so we don't duplicate
+ // and yes we do need to store it temporarily so we don't duplicate
// an operation on a specific valuenode, etc....
timepoints_ref match;
-
+
Time fps = get_canvas()->rend_desc().get_frame_rate();
-
+
//std::vector<synfig::Layer::Handle>
//synfig::info("Layers %d", sel_layers.size());
{
std::vector<synfig::Layer::Handle>::iterator i = sel_layers.begin(),
end = sel_layers.end();
-
+
for(; i != end; ++i)
{
//synfig::info("Recurse through a layer");
recurse_layer(*i,sel_times,match);
}
}
-
+
//std::vector<synfig::Canvas::Handle> sel_canvases;
//synfig::info("Canvases %d", sel_canvases.size());
{
std::vector<synfig::Canvas::Handle>::iterator i = sel_canvases.begin(),
end = sel_canvases.end();
-
+
for(; i != end; ++i)
{
//synfig::info("Recurse through a canvas");
recurse_canvas(*i,sel_times,match);
}
}
-
+
//std::vector<synfigapp::ValueDesc>
//synfig::info("ValueBasedescs %d", sel_values.size());
{
std::vector<synfigapp::ValueDesc>::iterator i = sel_values.begin(),
end = sel_values.end();
-
+
for(; i != end; ++i)
{
//synfig::info("Recurse through a valuedesc");
recurse_valuedesc(*i,sel_times,match);
}
}
-
+
//process the hell out of em...
{
//must build from both lists
{
//iterate through each waypoint for this specific valuenode
std::set<synfig::Waypoint>::const_iterator j = i->waypoints.begin(),
- end = i->waypoints.end();
+ end = i->waypoints.end();
for(; j != end; ++j)
{
Action::Handle action(WaypointRemove::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_node",ValueNode::Handle(i->val));
action->set_param("waypoint",*j);
-
+
//run the action now that we've added everything
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action_front(action);
}
}
for(; j != jend; ++j)
{
Action::Handle action(ActivepointRemove::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_desc",i->val);
action->set_param("activepoint",*j);
-
+
//run the action now that everything should be in order
assert(action->is_ready());
if(!action->is_ready())
{
throw Error(Error::TYPE_NOTREADY);
}
-
+
add_action_front(action);
}
}
public Super
{
private:
-
+
//process all the value descriptions that are selected (or are in subselections)
std::vector<synfig::Layer::Handle> sel_layers;
std::vector<synfig::Canvas::Handle> sel_canvases;
Action::TimepointsMove::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("addlayer",Param::TYPE_VALUE)
.set_local_name(_("New Selected Layer"))
.set_desc(_("A layer to add to our selected list"))
.set_supports_multiple()
.set_optional()
);
-
+
ret.push_back(ParamDesc("addcanvas",Param::TYPE_CANVAS)
.set_local_name(_("New Selected Canvas"))
.set_desc(_("A canvas to add to our selected list"))
.set_supports_multiple()
.set_optional()
);
-
+
ret.push_back(ParamDesc("addvaluedesc",Param::TYPE_VALUEDESC)
.set_local_name(_("New Selected ValueBase"))
.set_desc(_("A valuenode's description to add to our selected list"))
.set_supports_multiple()
.set_optional()
);
-
+
ret.push_back(ParamDesc("addtime",Param::TYPE_TIME)
.set_local_name(_("New Selected Time Point"))
.set_desc(_("A time point to add to our selected list"))
.set_supports_multiple()
);
-
+
ret.push_back(ParamDesc("deltatime",Param::TYPE_TIME)
.set_local_name(_("Time adjustment"))
.set_desc(_("The amount of time to adjust all the selected points"))
bool
Action::TimepointsMove::is_candidate(const ParamList &x)
{
- if(!candidate_check(get_param_vocab(),x))
+ if(!candidate_check(get_param_vocab(),x))
return false;
-
- if( x.find("addlayer") == x.end() &&
- x.find("addcanvas") == x.end() &&
+
+ if( x.find("addlayer") == x.end() &&
+ x.find("addcanvas") == x.end() &&
x.find("addvaluedesc") == x.end())
return false;
return true;
//add a layer to the list
sel_layers.push_back(param.get_layer());
//synfig::info("action got layer");
-
+
return true;
}
-
+
if(name=="addcanvas" && param.get_type()==Param::TYPE_CANVAS)
{
//add a layer to the list
sel_canvases.push_back(param.get_canvas());
//synfig::info("action got canvas");
-
+
return true;
}
-
+
if(name=="addvaluedesc" && param.get_type()==Param::TYPE_VALUEDESC)
{
//add a layer to the list
sel_values.push_back(param.get_value_desc());
//synfig::info("action got valuedesc");
-
+
return true;
}
-
+
if(name=="addtime" && param.get_type()==Param::TYPE_TIME)
{
//add a layer to the list
sel_times.insert(param.get_time());
//synfig::info("action got time");
-
+
return true;
}
-
+
if(name=="deltatime" && param.get_type()==Param::TYPE_TIME)
{
timemove = param.get_time();
//synfig::info("action got time to move");
-
+
return true;
}
Action::TimepointsMove::prepare()
{
clear();
-
+
//synfig::info("Preparing TimepointsMove by %f secs",(float)timemove);
-
+
if(sel_times.empty()) return;
-
+
//all our lists should be set correctly...
-
+
/*{
std::set<synfig::Time>::iterator i = sel_times.begin(), end = sel_times.end();
-
+
for(; i != end; ++i)
{
synfig::info("Time %f", (float)*i);
- }
+ }
}*/
//build our sub-action list
- // and yes we do need to store it temporarily so we don't duplicate
+ // and yes we do need to store it temporarily so we don't duplicate
// an operation on a specific valuenode, etc....
timepoints_ref match;
-
+
Time fps = get_canvas()->rend_desc().get_frame_rate();
-
+
//std::vector<synfig::Layer::Handle>
//synfig::info("Layers %d", sel_layers.size());
{
std::vector<synfig::Layer::Handle>::iterator i = sel_layers.begin(),
end = sel_layers.end();
-
+
for(; i != end; ++i)
{
//synfig::info("Recurse through a layer");
recurse_layer(*i,sel_times,match);
}
}
-
+
//std::vector<synfig::Canvas::Handle> sel_canvases;
//synfig::info("Canvases %d", sel_canvases.size());
{
std::vector<synfig::Canvas::Handle>::iterator i = sel_canvases.begin(),
end = sel_canvases.end();
-
+
for(; i != end; ++i)
{
//synfig::info("Recurse through a canvas");
recurse_canvas(*i,sel_times,match);
}
}
-
+
//std::vector<synfigapp::ValueDesc>
//synfig::info("ValueBasedescs %d", sel_values.size());
{
std::vector<synfigapp::ValueDesc>::iterator i = sel_values.begin(),
end = sel_values.end();
-
+
for(; i != end; ++i)
{
//synfig::info("Recurse through a valuedesc");
recurse_valuedesc(*i,sel_times,match);
}
}
-
+
//synfig::info("built list of waypoints/activepoints to modify");
- //synfig::info("\t There are %d waypoint sets and %d activepointsets",
+ //synfig::info("\t There are %d waypoint sets and %d activepointsets",
// match.waypointbiglist.size(), match.actpointbiglist.size());
//process the hell out of em...
{
for(; i != end; ++i)
{
Action::Handle action(WaypointSet::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_node",ValueNode::Handle(i->val));
-
+
//iterate through each waypoint for this specific valuenode
std::set<synfig::Waypoint>::const_iterator j = i->waypoints.begin(),
- end = i->waypoints.end();
+ end = i->waypoints.end();
for(; j != end; ++j)
- {
+ {
//synfig::info("add waypoint mod...");
//NOTE: We may want to store the old time for undoing the action...
Waypoint w = *j;
w.set_time((w.get_time() + timemove).round(fps));
action->set_param("waypoint",w);
}
-
+
//run the action now that we've added everything
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action_front(action);
}
}
for(; i != end; ++i)
{
Action::Handle action(ActivepointSet::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_desc",i->val);
-
+
//iterate through each activepoint for this specific valuenode
std::set<synfig::Activepoint>::const_iterator j = i->activepoints.begin(),
jend = i->activepoints.end();
for(; j != jend; ++j)
{
//synfig::info("add activepoint mod...");
-
+
//NOTE: We may want to store the old time for undoing the action...
Activepoint a = *j;
a.set_time((a.get_time() + timemove).round(fps));
action->set_param("activepoint",a);
}
-
+
assert(action->is_ready());
if(!action->is_ready())
{
throw Error(Error::TYPE_NOTREADY);
}
-
+
add_action_front(action);
}
}
public Super
{
private:
-
+
//process all the value descriptions that are selected (or are in subselections)
std::vector<synfig::Layer::Handle> sel_layers;
std::vector<synfig::Canvas::Handle> sel_canvases;
std::vector<synfigapp::ValueDesc> sel_values;
std::set<synfig::Time> sel_times;
-
+
synfig::Time timemove;
public:
Action::ValueDescConnect::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("dest",Param::TYPE_VALUEDESC)
.set_local_name(_("Destination ValueDesc"))
);
.set_mutual_exclusion("src")
.set_user_supplied()
);
-
+
return ret;
}
{
ValueDesc value_desc=x.find("dest")->second.get_value_desc();
ValueNode::Handle value_node=x.find("src")->second.get_value_node();
- if(value_desc.get_value_type()==value_node->get_type())
+ if(value_desc.get_value_type()==value_node->get_type())
return true;
}
return true;
if(name=="dest" && param.get_type()==Param::TYPE_VALUEDESC)
{
value_desc=param.get_value_desc();
-
+
return true;
}
if(name=="src" && param.get_type()==Param::TYPE_VALUENODE)
{
value_node=param.get_value_node();
-
+
return true;
}
{
value_node=param.get_canvas()->find_value_node(value_node_name);
}
-
+
if(name=="src_name" && param.get_type()==Param::TYPE_STRING)
{
value_node_name=param.get_string();
-
+
if(get_canvas())
{
value_node=get_canvas()->find_value_node(value_node_name);
if(!value_node)
return false;
}
-
+
return true;
}
-
+
return Action::CanvasSpecific::set_param(name,param);
}
clear();
if(value_desc.parent_is_canvas())
- {
+ {
ValueNode::Handle dest_value_node;
dest_value_node=value_desc.get_value_node();
Action::Handle action(ValueNodeReplace::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("src",value_node);
action->set_param("dest",value_desc.get_value_node());
-
+
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action_front(action);
- return;
+ return;
}
else
if(value_desc.parent_is_linkable_value_node())
{
Action::Handle action(ValueNodeLinkConnect::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("parent_value_node",value_desc.get_parent_value_node());
action->set_param("value_node", value_node);
action->set_param("index",value_desc.get_index());
-
+
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action_front(action);
- return;
+ return;
}
else
if(value_desc.parent_is_layer_param())
{
Action::Handle action(LayerParamConnect::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("layer",value_desc.get_layer());
action->set_param("param",value_desc.get_param_name());
action->set_param("value_node",value_node);
-
- assert(action->is_ready());
+
+ assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action_front(action);
- return;
+ return;
}
-
- throw Error(_("ValueDesc is not recognised or supported."));
+
+ throw Error(_("ValueDesc is not recognised or supported."));
}
Action::ValueDescConvert::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
.set_local_name(_("ValueDesc"))
);
.set_local_name(_("Type"))
.set_desc(_("The type of ValueNode that you want to be converted to"))
);
-
+
return ret;
}
if(name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
{
value_desc=param.get_value_desc();
-
+
return true;
}
if(name=="type" && param.get_type()==Param::TYPE_STRING)
{
type=param.get_string();
-
+
return true;
}
clear();
ValueBase value;
-
+
if(value_desc.is_const())
value=value_desc.get_value();
else if(value_desc.is_value_node())
value=(*value_desc.get_value_node())(0);
else
throw Error(_("Unable to decipher ValueDesc (Bug?)"));
-
+
ValueNode::Handle src_value_node(LinkableValueNode::create(type,value));
if(!src_value_node)
throw Error(_("Unable to create new value node"));
-
+
ValueNode::Handle dest_value_node;
dest_value_node=value_desc.get_value_node();
Action::Handle action(ValueDescConnect::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("src",src_value_node);
add_action_front(action);
/*
- return;
+ return;
+
-
if(value_desc.parent_is_canvas())
- {
+ {
ValueNode::Handle dest_value_node;
dest_value_node=value_desc.get_value_node();
Action::Handle action(ValueNodeReplace::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("src",src_value_node);
action->set_param("dest",dest_value_node);
-
+
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action_front(action);
- return;
+ return;
}
else
if(value_desc.parent_is_linkable_value_node())
{
Action::Handle action(ValueNodeLinkConnect::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("parent_value_node",value_desc.get_parent_value_node());
action->set_param("value_node", src_value_node);
action->set_param("index",value_desc.get_index());
-
+
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action_front(action);
- return;
+ return;
}
else
if(value_desc.parent_is_layer_param())
{
Action::Handle action(LayerParamConnect::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("layer",value_desc.get_layer());
action->set_param("param",value_desc.get_param_name());
action->set_param("value_node",src_value_node);
-
- assert(action->is_ready());
+
+ assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action_front(action);
- return;
+ return;
}
-
-
-
- throw Error(_("ValueDesc is not recognised or supported."));
+
+
+
+ throw Error(_("ValueDesc is not recognised or supported."));
*/
}
Action::ValueDescDisconnect::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
.set_local_name(_("ValueDesc"))
);
.set_local_name(_("Time"))
.set_optional()
);
-
+
return ret;
}
if(name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
{
value_desc=param.get_value_desc();
-
+
return true;
}
if(name=="time" && param.get_type()==Param::TYPE_TIME)
{
time=param.get_time();
-
+
return true;
}
clear();
if(value_desc.parent_is_canvas())
- {
+ {
ValueNode::Handle src_value_node;
src_value_node=ValueNode_Const::create((*value_desc.get_value_node())(time));
Action::Handle action(ValueNodeReplace::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("src",src_value_node);
action->set_param("dest",value_desc.get_value_node());
-
+
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action_front(action);
- return;
+ return;
}
else
if(value_desc.parent_is_linkable_value_node())
{
Action::Handle action(ValueNodeLinkDisconnect::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("parent_value_node",value_desc.get_parent_value_node());
action->set_param("index",value_desc.get_index());
action->set_param("time",time);
-
+
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action_front(action);
- return;
+ return;
}
else
if(value_desc.parent_is_layer_param())
{
Action::Handle action(LayerParamDisconnect::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("layer",value_desc.get_layer());
action->set_param("param",value_desc.get_param_name());
action->set_param("time",time);
-
- assert(action->is_ready());
+
+ assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action_front(action);
- return;
+ return;
}
-
- throw Error(_("ValueDesc is not recognised or supported."));
+
+ throw Error(_("ValueDesc is not recognised or supported."));
}
Action::ValueDescExport::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
.set_local_name(_("ValueDesc"))
);
.set_desc(_("The name that you want this value to be exported as"))
.set_user_supplied()
);
-
+
return ret;
}
return false;
return true;
}
- return false;
+ return false;
}
bool
if(param_name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
{
value_desc=param.get_value_desc();
-
+
return true;
}
if(param_name=="name" && param.get_type()==Param::TYPE_STRING)
{
name=param.get_string();
-
+
return true;
}
if(!value_desc.is_const())
throw Error(_("Can only export Canvas when used as constant parameter"));
Canvas::Handle canvas(value_desc.get_value().get(Canvas::Handle()));
-
+
Action::Handle action(CanvasAdd::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("src",canvas);
action->set_param("id",name);
-
- assert(action->is_ready());
+
+ assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
- add_action_front(action);
-
+
+ add_action_front(action);
+
return;
}
-
+
if(value_desc.is_value_node())
{
if(value_desc.get_value_node()->is_exported())
{
if(!value_desc.parent_is_layer_param())
throw Error(_("Unable to export parameter. (Bug?)"));
-
+
value_node=ValueNode_Const::create(value_desc.get_value());
-
+
Action::Handle action(LayerParamConnect::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("layer",value_desc.get_layer());
action->set_param("param",value_desc.get_param_name());
action->set_param("value_node",value_node);
-
- assert(action->is_ready());
+
+ assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
- add_action_front(action);
+
+ add_action_front(action);
}
-
+
Action::Handle action(ValueNodeAdd::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("new",value_node);
action->set_param("name",name);
- assert(action->is_ready());
+ assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
Action::ValueDescLink::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
.set_local_name(_("ValueDesc to link"))
.set_requires_multiple()
);
-
+
return ret;
}
time=param.get_time();
return true;
}
-
+
if(name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
{
ValueDesc value_desc(param.get_value_desc());
-
+
if(value_desc.is_value_node() && value_desc.get_value_node()->is_exported())
{
if(link_value_node==value_desc.get_value_node())
return true;
-
+
if(link_value_node && link_value_node->is_exported())
{
poison=true;
return false;
}
-
+
link_value_node=value_desc.get_value_node();
}
else if(value_desc.is_value_node())
{
link_value_node=value_desc.get_value_node();
}
-
+
/*
// Use the one that was most recently changed
else if(link_value_node->get_time_last_changed()<value_desc.get_value_node()->get_time_last_changed())
*/
}
-
+
if(value_desc_list.size() && value_desc.get_value_type()!=value_desc_list.front().get_value_type())
{
// Everything must be of the same type
{
if(poison || value_desc_list.empty())
throw Error(Error::TYPE_NOTREADY);
-
+
clear();
if(!link_value_node)
{
ValueDesc& value_desc(value_desc_list.front());
-
+
link_value_node=ValueNode_Const::create(value_desc.get_value(time));
-
+
Action::Handle action(Action::create("value_desc_connect"));
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("src",link_value_node);
action->set_param("dest",value_desc);
-
- assert(action->is_ready());
+
+ assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
- add_action_front(action);
+
+ add_action_front(action);
}
/*
if(!link_value_node->is_exported())
{
Action::Handle action(Action::create("value_node_add"));
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("new",link_value_node);
action->set_param("name",strprintf(_("Unnamed%08d"),synfig::UniqueID().get_uid()));
-
- assert(action->is_ready());
+
+ assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action_front(action);
}
*/
-
+
std::list<ValueDesc>::iterator iter;
for(iter=value_desc_list.begin();iter!=value_desc_list.end();++iter)
{
ValueDesc& value_desc(*iter);
-
+
if(value_desc.is_value_node() && value_desc.get_value_node()==link_value_node)
continue;
Action::Handle action(Action::create("value_desc_connect"));
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("src",link_value_node);
action->set_param("dest",value_desc);
-
- assert(action->is_ready());
+
+ assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
- add_action_front(action);
+
+ add_action_front(action);
}
}
/* === M A C R O S ========================================================= */
#define ACTION_INIT2(class) \
Action::Base* class::create() { return new class(); } \
- synfig::String class::get_name()const { return name__; }
+ synfig::String class::get_name()const { return name__; }
ACTION_INIT2(Action::ValueDescSet);
ACTION_SET_NAME(Action::ValueDescSet,"value_desc_set");
Action::ValueDescSet::get_local_name()const
{
String name("ValueDesc");
-
+
if(!value_desc)
{
}
{
synfig::LinkableValueNode::Handle value_node(synfig::LinkableValueNode::Handle::cast_reinterpret(value_desc.get_parent_value_node()));
name=value_node->link_local_name(value_desc.get_index());
-
+
synfig::Node* node;
for(node=value_node.get();!node->parent_set.empty() && !dynamic_cast<Layer*>(node);node=*node->parent_set.begin());
Layer::Handle parent_layer(dynamic_cast<Layer*>(node));
Action::ValueDescSet::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
.set_local_name(_("ValueDesc"))
);
.set_local_name(_("Time"))
.set_optional()
);
-
+
return ret;
}
if(name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
{
value_desc=param.get_value_desc();
-
+
return true;
}
if(name=="new_value" && param.get_type()==Param::TYPE_VALUE)
{
value=param.get_value();
-
+
return true;
}
if(name=="time" && param.get_type()==Param::TYPE_TIME)
{
time=param.get_time();
-
+
return true;
}
DEBUGPOINT();
ValueNode_Composite::Handle parent_value_node;
parent_value_node=parent_value_node.cast_dynamic(value_desc.get_parent_value_node());
-
+
assert(parent_value_node);
-
+
Action::Handle action(Action::create("value_desc_set"));
-
+
if(!action)
throw Error(_("Unable to find action value_desc_set (bug)"));
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("time",time);
action->set_param("new_value",value);
action->set_param("value_desc",ValueDesc(parent_value_node,5));
-
+
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
- add_action(action);
+
+ add_action(action);
}
// If we are a reference value node, then
if(!action)
throw Error(_("Unable to find action value_desc_set (bug)"));
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("time",time);
action->set_param("new_value",value);
action->set_param("value_desc",reference_value_desc);
-
+
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
- add_action(action);
-
+ add_action(action);
+
return;
}
-
+
// If we are a composite value node, then
// we need to distribute the changes to the
// individual parts
break;
}
default:
- throw Error("Bad type for composite (%s)",ValueBase::type_name(value.get_type()).c_str());
+ throw Error("Bad type for composite (%s)",ValueBase::type_name(value.get_type()).c_str());
break;
}
-
+
for(int i=0;i<n_components;i++)
{
ValueDesc component_value_desc(ValueNode_Composite::Handle::cast_dynamic(value_desc.get_value_node()),i);
Action::Handle action(Action::create("value_desc_set"));
-
+
if(!action)
throw Error(_("Unable to find action value_desc_set (bug)"));
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("time",time);
action->set_param("new_value",components[i]);
action->set_param("value_desc",component_value_desc);
-
+
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
- add_action(action);
+
+ add_action(action);
}
-
+
return;
}
-
+
// If we are a RADIAL composite value node, then
// we need to distribute the changes to the
// individual parts
n_components=4;
break;
default:
- throw Error("Bad type for radial composite (%s)",ValueBase::type_name(value.get_type()).c_str());
+ throw Error("Bad type for radial composite (%s)",ValueBase::type_name(value.get_type()).c_str());
break;
}
for(int i=0;i<n_components;i++)
ValueDesc component_value_desc(ValueNode_RadialComposite::Handle::cast_dynamic(value_desc.get_value_node()),i);
Action::Handle action(Action::create("value_desc_set"));
-
+
if(!action)
throw Error(_("Unable to find action value_desc_set (bug)"));
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("time",time);
action->set_param("new_value",components[i]);
action->set_param("value_desc",component_value_desc);
-
+
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
- add_action(action);
+
+ add_action(action);
}
-
+
return;
}
{
ValueNode_Composite::Handle parent_value_node;
parent_value_node=parent_value_node.cast_dynamic(value_desc.get_parent_value_node());
-
+
assert(parent_value_node);
-
+
Action::Handle action(Action::create("value_desc_set"));
-
+
if(!action)
throw Error(_("Unable to find action value_desc_set (bug)"));
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("time",time);
action->set_param("new_value",(*parent_value_node->get_link(4))(time));
action->set_param("value_desc",ValueDesc(parent_value_node,5));
-
+
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
- add_action(action);
+
+ add_action(action);
}
/* DEBUGPOINT();
}
}
}
-*/
+*/
+
-
// If we are in animate editing mode
if(get_edit_mode()&MODE_ANIMATE)
{
value=ValueNode_Const::Handle::cast_dynamic(value_desc.get_value_node())->get_value();
else
value=value_desc.get_value();
-
+
if(!value_node)value_node=ValueNode_Animated::create(value,time);
//if(!value_node)value_node=ValueNode_Animated::create(value.get_type());
-
+
Action::Handle action;
-
+
if(!value_desc.is_value_node())
{
action=(ValueDescConnect::create());
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(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
DEBUGPOINT();
add_action_front(action);
}
{
value_node=value_node.cast_dynamic(value_desc.get_value_node());
}
-
+
DEBUGPOINT();
if(!value_node)
- throw Error(_("Direct manipulation of this ValueNode type is not yet supported"));
-
+ throw Error(_("Direct manipulation of this ValueNode type is not yet supported"));
+
Action::Handle action(WaypointSetSmart::create());
-
+
//Waypoint waypoint(value,time);
-
+
Waypoint waypoint(value_node->new_waypoint_at_time(time));
waypoint.set_value(value);
-
+
waypoint.set_before(synfigapp::Main::get_interpolation());
waypoint.set_after(synfigapp::Main::get_interpolation());
-
+
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("waypoint",waypoint);
-
+
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
DEBUGPOINT();
add_action(action);
-
+
return;
}
else
if(ValueNode_Const::Handle::cast_dynamic(value_desc.get_value_node()))
{
Action::Handle action(ValueNodeConstSet::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_node",value_desc.get_value_node());
action->set_param("new_value",value);
-
+
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action_front(action);
return;
}
else
if(ValueNode_Animated::Handle::cast_dynamic(value_desc.get_value_node()))
- throw Error(_("You must be in Animate-Editing-Mode to directly manipulate this value"));
+ throw Error(_("You must be in Animate-Editing-Mode to directly manipulate this value"));
else
- throw Error(_("Direct manipulation of this ValueNode type is not yet supported"));
+ throw Error(_("Direct manipulation of this ValueNode type is not yet supported"));
}
else
if(value_desc.parent_is_layer_param() && !value_desc.is_value_node())
{
Action::Handle layer_param_set(LayerParamSet::create());
-
+
layer_param_set->set_param("canvas",get_canvas());
layer_param_set->set_param("canvas_interface",get_canvas_interface());
layer_param_set->set_param("layer",value_desc.get_layer());
layer_param_set->set_param("param",value_desc.get_param_name());
layer_param_set->set_param("new_value",value);
-
+
if(!layer_param_set->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action_front(layer_param_set);
return;
}
Action::ValueNodeAdd::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("new",Param::TYPE_VALUENODE)
.set_local_name(_("New ValueNode"))
.set_desc(_("ValueNode to be added"))
ret.push_back(ParamDesc("name",Param::TYPE_STRING)
.set_local_name(_("Name"))
);
-
+
return ret;
}
if(param_name=="new" && param.get_type()==Param::TYPE_VALUENODE)
{
value_node=param.get_value_node();
-
+
return true;
}
if(param_name=="name" && param.get_type()==Param::TYPE_STRING)
{
name=param.get_string();
-
+
return true;
}
{
throw Error(_("Parameter appears to already be exported"));
}
-
+
try
{
get_canvas()->add_value_node(value_node,name);
}
set_dirty(false);
-
+
// Signal that a layer has been inserted
if(get_canvas_interface())
{
}
set_dirty(false);
-
+
// Signal that a layer has been inserted
if(get_canvas_interface())
{
Action::ValueNodeConstSet::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE)
.set_local_name(_("ValueNode_Const"))
);
ret.push_back(ParamDesc("new_value",Param::TYPE_VALUE)
.set_local_name(_("ValueBase"))
);
-
+
return ret;
}
if(name=="value_node" && param.get_type()==Param::TYPE_VALUENODE)
{
value_node=ValueNode_Const::Handle::cast_dynamic(param.get_value_node());
-
+
return (bool)value_node;
}
if(name=="new_value" && param.get_type()==Param::TYPE_VALUE)
{
new_value=param.get_value();
-
+
return true;
}
Action::ValueNodeConstSet::perform()
{
//set_dirty(true);
-
+
old_value=value_node->get_value();
- value_node->set_value(new_value);
-
+ value_node->set_value(new_value);
+
// Signal that a layer has been inserted
/*if(get_canvas_interface())
{
{
//set_dirty(true);
- value_node->set_value(old_value);
-
+ value_node->set_value(old_value);
+
// Signal that a layer has been inserted
/*if(get_canvas_interface())
{
Action::ValueNodeDynamicListInsert::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
.set_local_name(_("ValueDesc"))
);
if(name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
{
ValueDesc value_desc(param.get_value_desc());
-
+
if(!value_desc.parent_is_value_node())
return false;
-
+
value_node=ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node());
-
+
if(!value_node)
return false;
list_entry=value_node->create_list_entry(index,time,origin);
if(item)
list_entry.value_node=item;
-
+
assert(list_entry.value_node.rcount()==1);
-
+
return true;
}
if(name=="time" && param.get_type()==Param::TYPE_TIME)
{
time=param.get_time();
-
+
return true;
}
if(name=="item" && param.get_type()==Param::TYPE_VALUENODE)
item=param.get_value_node();
if(item)
list_entry.value_node=item;
-
+
return true;
}
if(name=="origin" && param.get_type()==Param::TYPE_REAL)
{
origin=param.get_real();
-
+
return true;
}
void
Action::ValueNodeDynamicListInsert::perform()
-{
+{
if(index>value_node->link_count())
index=value_node->link_count();
-
+
value_node->add(list_entry,index);
assert(list_entry.value_node.rcount()>=2);
-
+
// Signal that a layer has been inserted
value_node->changed();
/*_if(get_canvas_interface())
assert(list_entry.value_node.rcount()>=2);
value_node->erase((value_node->list.begin()+index)->value_node);
assert(list_entry.value_node.rcount()>=1);
-
+
// Signal that a layer has been inserted
value_node->changed();
/*_if(get_canvas_interface())
Action::ValueNodeDynamicListInsertSmart::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
.set_local_name(_("ValueDesc"))
);
if(name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
{
ValueDesc value_desc(param.get_value_desc());
-
+
if(!value_desc.parent_is_value_node())
return false;
-
+
value_node=ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node());
-
+
if(!value_node)
return false;
index=value_desc.get_index();
-
+
return true;
}
if(name=="time" && param.get_type()==Param::TYPE_TIME)
{
time=param.get_time();
-
+
return true;
}
if(name=="origin" && param.get_type()==Param::TYPE_REAL)
{
origin=param.get_real();
-
+
return true;
}
void
Action::ValueNodeDynamicListInsertSmart::prepare()
-{
+{
//clear();
// HACK
if(!first_time())
return;
-
+
// If we are in animate editing mode
if(get_edit_mode()&MODE_ANIMATE)
{
synfig::info("ValueNodeDynamicListInsertSmart: value_node->list.size()=%d",value_node->list.size());
if(value_node->list.size()<=index && index>0)
synfig::info("ValueNodeDynamicListInsertSmart: value_node->list[index-1].status_at_time(time)=%d",value_node->list[index-1].status_at_time(time));
-
+
if(value_node->list.size()>=index && index>0 && !value_node->list[index-1].status_at_time(time))
{
// Ok, we do not have to create a new
- // entry in the dynamic list after all.
+ // entry in the dynamic list after all.
// However, we do need to set the
// position and tangent of this point.
ValueNode_DynamicList::ListEntry list_entry(value_node->create_list_entry(index,time,origin));
ValueBase value((*list_entry.value_node)(time));
index--;
-
+
ValueDesc item_value_desc(value_node,index);
Action::Handle action(Action::create("value_desc_set"));
-
+
if(!action)
throw Error(_("Unable to find action value_desc_set (bug)"));
-
+
action->set_param("edit_mode",get_edit_mode());
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("time",time);
action->set_param("new_value",value);
action->set_param("value_desc",ValueDesc(value_node,index));
-
+
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
- add_action(action);
+
+ add_action(action);
}
else
{
// Ok, not a big deal, we just need to
// add a new item
Action::Handle action(Action::create("value_node_dynamic_list_insert"));
-
+
if(!action)
throw Error(_("Unable to find action (bug)"));
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("time",time);
action->set_param("origin",origin);
action->set_param("value_desc",ValueDesc(value_node,index));
-
+
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action(action);
-
+
action=Action::create("activepoint_set_off");
-
+
if(!action)
throw Error(_("Unable to find action \"activepoint_set_off\""));
-
+
action->set_param("edit_mode",MODE_ANIMATE);
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("time",Time::begin());
action->set_param("origin",origin);
action->set_param("value_desc",ValueDesc(value_node,index));
-
+
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action(action);
}
-
+
// Now we set the activepoint up and then we'll be done
Action::Handle action(Action::create("activepoint_set_on"));
if(!action)
throw Error(_("Unable to find action \"activepoint_set_on\""));
-
+
action->set_param("edit_mode",get_edit_mode());
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("time",time);
action->set_param("origin",origin);
action->set_param("value_desc",ValueDesc(value_node,index));
-
+
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
if(!action)
throw Error(_("Unable to find action (bug)"));
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("time",time);
action->set_param("origin",origin);
action->set_param("value_desc",ValueDesc(value_node,index));
-
+
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
- add_action(action);
+ add_action(action);
}
}
Action::ValueNodeDynamicListLoop::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE)
.set_local_name(_("ValueNode"))
);
}
if(!value_node && name=="value_node" && param.get_type()==Param::TYPE_VALUENODE)
- {
+ {
value_node=ValueNode_DynamicList::Handle::cast_dynamic(param.get_value_node());
-
+
if(!value_node)
return false;
void
Action::ValueNodeDynamicListLoop::perform()
-{
+{
old_loop_value=value_node->get_loop();
-
+
if(old_loop_value==true)
{
set_dirty(false);
}
set_dirty(true);
value_node->set_loop(true);
-
+
value_node->changed();
/*_if(get_canvas_interface())
{
}
set_dirty(true);
value_node->set_loop(old_loop_value);
-
+
value_node->changed();
/*_if(get_canvas_interface())
{
Action::ValueNodeDynamicListRemove::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
.set_local_name(_("ValueDesc"))
);
if(name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
{
ValueDesc value_desc(param.get_value_desc());
-
+
if(!value_desc.parent_is_value_node())
return false;
-
+
value_node=ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node());
-
+
if(!value_node)
return false;
-
+
index=value_desc.get_index();
-
+
return true;
}
-
+
return Action::CanvasSpecific::set_param(name,param);
}
void
Action::ValueNodeDynamicListRemove::perform()
-{
+{
if(index>=value_node->link_count())
index=value_node->link_count()-1;
list_entry=value_node->list[index];
value_node->erase((value_node->list.begin()+index)->value_node);
-
+
// Signal that a layer has been inserted
value_node->changed();
/*_if(get_canvas_interface())
Action::ValueNodeDynamicListRemove::undo()
{
value_node->add(list_entry,index);
-
+
// Signal that a layer has been inserted
value_node->changed();
/*_if(get_canvas_interface())
Action::ValueNodeDynamicListRemoveSmart::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
.set_local_name(_("ValueDesc"))
);
if(name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
{
ValueDesc value_desc(param.get_value_desc());
-
+
if(!value_desc.parent_is_value_node())
return false;
-
+
value_node=ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node());
-
+
if(!value_node)
return false;
index=value_desc.get_index();
-
+
return true;
}
if(name=="time" && param.get_type()==Param::TYPE_TIME)
{
time=param.get_time();
-
+
return true;
}
if(name=="origin" && param.get_type()==Param::TYPE_REAL)
{
origin=param.get_real();
-
+
return true;
}
void
Action::ValueNodeDynamicListRemoveSmart::prepare()
-{
+{
clear();
-
+
// If we are in animate editing mode
if(get_edit_mode()&MODE_ANIMATE)
{
if(!action)
throw Error(_("Unable to find action (bug)"));
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("time",time);
action->set_param("origin",origin);
action->set_param("value_desc",ValueDesc(value_node,index));
-
+
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
if(!action)
throw Error(_("Unable to find action (bug)"));
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("time",time);
action->set_param("origin",origin);
action->set_param("value_desc",ValueDesc(value_node,index));
-
+
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
Action::ValueNodeDynamicListRotateOrder::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
.set_local_name(_("ValueDesc"))
);
if(name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
{
ValueDesc value_desc(param.get_value_desc());
-
+
if(!value_desc.parent_is_value_node())
return false;
-
+
value_node=ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node());
-
+
if(!value_node)
return false;
Action::ValueNodeDynamicListRotateOrder::prepare()
{
clear();
-
+
for(int i(0);i<(value_node->link_count()-index)%value_node->link_count();++i)
{
ValueDesc value_desc(value_node,value_node->link_count()-1-i);
Action::Handle action(Action::create("value_node_dynamic_list_remove"));
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_desc",ValueDesc(value_node,value_node->link_count()-1));
-
+
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action(action);
-
-
+
+
action=Action::create("value_node_dynamic_list_insert");
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_desc",ValueDesc(value_node,0));
action->set_param("item",child);
-
+
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action(action);
-
-
-
+
+
+
}
}
Action::ValueNodeDynamicListUnLoop::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE)
.set_local_name(_("ValueNode"))
);
}
if(!value_node && name=="value_node" && param.get_type()==Param::TYPE_VALUENODE)
- {
+ {
value_node=ValueNode_DynamicList::Handle::cast_dynamic(param.get_value_node());
-
+
if(!value_node)
return false;
void
Action::ValueNodeDynamicListUnLoop::perform()
-{
+{
old_loop_value=value_node->get_loop();
-
+
if(old_loop_value==false)
{
set_dirty(false);
set_dirty(true);
value_node->set_loop(false);
-
+
value_node->changed();
/*_if(get_canvas_interface())
{
set_dirty(true);
value_node->set_loop(old_loop_value);
-
+
value_node->changed();
/*_if(get_canvas_interface())
{
Action::ValueNodeLinkConnect::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("parent_value_node",Param::TYPE_VALUENODE)
.set_local_name(_("Parent ValueNode"))
);
if(name=="parent_value_node" && param.get_type()==Param::TYPE_VALUENODE)
{
parent_value_node=LinkableValueNode::Handle::cast_dynamic(param.get_value_node());
-
+
return static_cast<bool>(parent_value_node);
}
if(name=="value_node" && param.get_type()==Param::TYPE_VALUENODE)
{
new_value_node=param.get_value_node();
-
+
return true;
}
if(name=="index" && param.get_type()==Param::TYPE_INTEGER)
{
index=param.get_integer();
-
+
return true;
}
Action::ValueNodeLinkConnect::perform()
{
if(parent_value_node->link_count()<=index)
- throw Error(_("Bad index, too big. LinkCount=%d, Index=%d"),parent_value_node->link_count(),index);
-
+ throw Error(_("Bad index, too big. LinkCount=%d, Index=%d"),parent_value_node->link_count(),index);
+
old_value_node=parent_value_node->get_link(index);
if(!parent_value_node->set_link(index,new_value_node))
throw Error(_("Parent would not accept link"));
-
+
/*set_dirty(true);
-
+
if(get_canvas_interface())
{
get_canvas_interface()->signal_value_node_changed()(parent_value_node);
Action::ValueNodeLinkConnect::undo()
{
if(parent_value_node->link_count()<=index)
- throw Error(_("Bad index, too big. LinkCount=%d, Index=%d"),parent_value_node->link_count(),index);
-
+ throw Error(_("Bad index, too big. LinkCount=%d, Index=%d"),parent_value_node->link_count(),index);
+
if(!parent_value_node->set_link(index,old_value_node))
throw Error(_("Parent would not accept old link"));
-
+
/*set_dirty(true);
-
+
if(get_canvas_interface())
{
get_canvas_interface()->signal_value_node_changed()(parent_value_node);
Action::ValueNodeLinkDisconnect::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("parent_value_node",Param::TYPE_VALUENODE)
.set_local_name(_("Parent ValueNode"))
);
if(name=="parent_value_node" && param.get_type()==Param::TYPE_VALUENODE)
{
parent_value_node=LinkableValueNode::Handle::cast_dynamic(param.get_value_node());
-
+
return static_cast<bool>(parent_value_node);
}
if(name=="index" && param.get_type()==Param::TYPE_INTEGER)
{
index=param.get_integer();
-
+
return true;
}
if(name=="time" && param.get_type()==Param::TYPE_TIME)
{
time=param.get_time();
-
+
return true;
}
Action::ValueNodeLinkDisconnect::perform()
{
if(parent_value_node->link_count()<=index)
- throw Error(_("Bad index, too big. LinkCount=%d, Index=%d"),parent_value_node->link_count(),index);
-
+ throw Error(_("Bad index, too big. LinkCount=%d, Index=%d"),parent_value_node->link_count(),index);
+
old_value_node=parent_value_node->get_link(index);
if(!parent_value_node->set_link(index,ValueNode_Const::create((*old_value_node)(time))))
throw Error(_("Parent would not accept link"));
-
+
/*
if(get_canvas()->get_time()!=time)
set_dirty(true);
else
set_dirty(false);
-
+
if(get_canvas_interface())
{
get_canvas_interface()->signal_value_node_changed()(parent_value_node);
Action::ValueNodeLinkDisconnect::undo()
{
if(parent_value_node->link_count()<=index)
- throw Error(_("Bad index, too big. LinkCount=%d, Index=%d"),parent_value_node->link_count(),index);
-
+ throw Error(_("Bad index, too big. LinkCount=%d, Index=%d"),parent_value_node->link_count(),index);
+
if(!parent_value_node->set_link(index,old_value_node))
throw Error(_("Parent would not accept old link"));
-
+
/*if(get_canvas()->get_time()!=time)
set_dirty(true);
else
set_dirty(false);
-
+
if(get_canvas_interface())
{
get_canvas_interface()->signal_value_node_changed()(parent_value_node);
Action::ValueNodeRemove::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE)
.set_local_name(_("ValueNode"))
);
-
+
return ret;
}
if(name=="value_node" && param.get_type()==Param::TYPE_VALUENODE)
{
value_node=param.get_value_node();
-
+
if(value_node && !value_node->is_exported())
{
synfig::error("Action::ValueNodeRemove::set_param(): ValueBase node not exported!");
value_node=0;
}
-
+
return (bool)value_node;
}
void
Action::ValueNodeRemove::perform()
-{
+{
// if(value_node->rcount()!=1)
// throw Error(_("ValueNode is still being used by something"));
{
get_canvas_interface()->signal_value_node_deleted()(value_node);
}
-
+
//throw Error(_("Not yet implemented"));
/*
assert(value_node->is_exported());
if(get_canvas()->value_node_list().count(new_name))
throw Error(_("A ValueNode with this ID already exists in this canvas"));
-
+
old_name=value_node->get_id();
- value_node->set_id(new_name);
-
+ value_node->set_id(new_name);
+
if(get_canvas_interface())
{
get_canvas_interface()->signal_value_node_changed()(value_node);
{
get_canvas_interface()->signal_value_node_added()(value_node);
}
-
+
//throw Error(_("Not yet implemented"));
/*
assert(value_node->is_exported());
if(get_canvas()->value_node_list().count(old_name))
throw Error(_("A ValueNode with the old ID already exists in this canvas (BUG)"));
-
- value_node->set_id(old_name);
-
+
+ value_node->set_id(old_name);
+
if(get_canvas_interface())
{
get_canvas_interface()->signal_value_node_changed()(value_node);
Action::ValueNodeRename::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE)
.set_local_name(_("ValueNode_Const"))
);
.set_desc(_("The new name of the ValueNode"))
.set_user_supplied()
);
-
+
return ret;
}
if(name=="value_node" && param.get_type()==Param::TYPE_VALUENODE)
{
value_node=param.get_value_node();
-
+
if(value_node && !value_node->is_exported())
{
synfig::error("Action::ValueNodeRename::set_param(): ValueBase node not exported!");
value_node=0;
}
-
+
return (bool)value_node;
}
if(name=="name" && param.get_type()==Param::TYPE_STRING)
{
new_name=param.get_string();
-
+
return true;
}
void
Action::ValueNodeRename::perform()
-{
+{
assert(value_node->is_exported());
if(get_canvas()->value_node_list().count(new_name))
throw Error(_("A ValueNode with this ID already exists in this canvas"));
-
+
old_name=value_node->get_id();
- value_node->set_id(new_name);
-
+ value_node->set_id(new_name);
+
if(get_canvas_interface())
{
get_canvas_interface()->signal_value_node_changed()(value_node);
if(get_canvas()->value_node_list().count(old_name))
throw Error(_("A ValueNode with the old ID already exists in this canvas (BUG)"));
-
- value_node->set_id(old_name);
-
+
+ value_node->set_id(old_name);
+
if(get_canvas_interface())
{
get_canvas_interface()->signal_value_node_changed()(value_node);
GUID old_b(b->get_guid());
b->set_guid(GUID());
-
+
a->set_guid(old_b);
b->set_guid(old_a);
}
Action::ValueNodeReplace::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("dest",Param::TYPE_VALUENODE)
.set_local_name(_("Destination ValueNode"))
.set_desc(_("ValueNode to replaced"))
.set_local_name(_("Source ValueNode"))
.set_desc(_("ValueNode that will replace the destination"))
);
-
+
return ret;
}
if(name=="dest" && param.get_type()==Param::TYPE_VALUENODE)
{
dest_value_node=param.get_value_node();
-
+
return true;
}
if(name=="src" && param.get_type()==Param::TYPE_VALUENODE)
{
src_value_node=param.get_value_node();
-
+
return true;
}
if(dest_value_node->get_type() != src_value_node->get_type())
throw Error(_("You cannot replace ValueNodes with different types!"));
-
+
is_undoable=true;
-
+
if(!src_value_node->is_exported())
{
src_value_node->set_id(dest_value_node->get_id());
src_value_node->set_parent_canvas(dest_value_node->get_parent_canvas());
ValueNode::RHandle value_node(src_value_node);
-
+
if(!value_node.runique() && value_node.rcount()>1)
is_undoable=false; // !!!
}
else
is_undoable=false; // !!!
-
+
if(!is_undoable)
synfig::warning("ValueNodeReplace: Circumstances make undoing this action impossible at the current time. :(");
-
+
ValueNode::RHandle value_node(dest_value_node);
-
+
if(value_node.runique() || value_node.rcount()<=1)
throw Error(_("Nothing to replace."));
-
+
int replacements;
-
+
replacements=value_node->replace(src_value_node);
assert(replacements);
if(!replacements)
throw Error(_("Action Failure. This is a bug. Please report it."));
swap_guid(dest_value_node,src_value_node);
-
+
//src_value_node->parent_set.swap(dest_value_node->parent_set);
-
+
// Signal that a layer has been inserted
if(get_canvas_interface())
{
get_canvas_interface()->signal_value_node_replaced()(dest_value_node,src_value_node);
}
else synfig::warning("CanvasInterface not set on action");
-
+
}
void
{
if(!is_undoable)
throw Error(_("This action cannot be undone under these circumstances."));
-
+
set_dirty(true);
if(dest_value_node == src_value_node)
if(dest_value_node->get_type() != src_value_node->get_type())
throw Error(_("You cannot replace ValueNodes with different types!"));
-
+
ValueNode::RHandle value_node(src_value_node);
-
+
if(value_node.runique() || value_node.rcount()<=1)
throw Error(_("Nothing to replace."));
-
+
int replacements;
-
+
replacements=value_node->replace(dest_value_node);
assert(replacements);
if(!replacements)
swap_guid(dest_value_node,src_value_node);
//src_value_node->parent_set.swap(dest_value_node->parent_set);
-
+
synfig::info(get_name()+_(": (Undo) ")+strprintf("Replaced %d ValueNode instances",replacements));
src_value_node->set_id(String());
src_value_node->set_parent_canvas(0);
-
+
// Signal that a layer has been inserted
if(get_canvas_interface())
{
get_canvas_interface()->signal_value_node_replaced()(src_value_node,dest_value_node);
}
else synfig::warning("CanvasInterface not set on action");
-
+
}
Action::WaypointAdd::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE)
.set_local_name(_("Destination ValueNode (Animated)"))
);
value_node=ValueNode_Animated::Handle::cast_dynamic(param.get_value_node());
if(time_set)
calc_waypoint();
-
+
return static_cast<bool>(value_node);
}
if(name=="waypoint" && param.get_type()==Param::TYPE_WAYPOINT && !time_set)
{
waypoint=param.get_waypoint();
-
+
return true;
}
if(name=="time" && param.get_type()==Param::TYPE_TIME && waypoint.get_time()==Time::begin()-1)
if(value_node)
calc_waypoint();
-
+
return true;
}
return Action::CanvasSpecific::is_ready();
}
-// This function is called if a time is specified, but not
+// This function is called if a time is specified, but not
// a waypoint. In this case, we need to calculate the value
// of the waypoint
void
Action::WaypointAdd::calc_waypoint()
-{
+{
Time time=waypoint.get_time();
Waypoint original(waypoint);
- waypoint=value_node->new_waypoint_at_time(time);
+ waypoint=value_node->new_waypoint_at_time(time);
waypoint.mimic(original);
waypoint.set_before(synfigapp::Main::get_interpolation());
waypoint.set_after(synfigapp::Main::get_interpolation());
/*
ValueNode_Animated::WaypointList &waypoint_list(value_node->waypoint_list());
ValueNode_Animated::WaypointList::iterator iter;
-
+
if(waypoint_list.empty())
{
waypoint.set_value((*value_node)(time));
}
ValueNode_Animated::WaypointList::iterator closest=waypoint_list.begin();
-
+
for(iter=waypoint_list.begin();iter!=waypoint_list.end();++iter)
{
const Real dist(abs(iter->get_time()-time));
void
Action::WaypointAdd::perform()
-{
+{
try { value_node->find(waypoint.get_time()); throw Error(_("A Waypoint already exists at this point in time (%s)"),waypoint.get_time().get_string().c_str());}
- catch(synfig::Exception::NotFound) { }
+ catch(synfig::Exception::NotFound) { }
try { if(value_node->find(waypoint)!=value_node->waypoint_list().end()) throw Error(_("This waypoint is already in the ValueNode"));}
- catch(synfig::Exception::NotFound) { }
-
+ catch(synfig::Exception::NotFound) { }
+
value_node->add(waypoint);
-
+
value_node->changed();
/*_if(get_canvas_interface())
{
Action::WaypointAdd::undo()
{
value_node->erase(waypoint);
-
+
value_node->changed();
/*_if(get_canvas_interface())
{
private:
synfig::Waypoint waypoint;
-
+
bool time_overwrite;
synfig::Waypoint overwritten_wp;
Action::WaypointRemove::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE)
.set_local_name(_("ValueNode (Animated)"))
);
if(name=="value_node" && param.get_type()==Param::TYPE_VALUENODE)
{
value_node=ValueNode_Animated::Handle::cast_dynamic(param.get_value_node());
-
+
return static_cast<bool>(value_node);
}
if(name=="waypoint" && param.get_type()==Param::TYPE_WAYPOINT)
{
waypoint=param.get_waypoint();
-
+
return true;
}
void
Action::WaypointRemove::perform()
-{
+{
WaypointList::iterator iter(value_node->find(waypoint));
if((UniqueID)*iter!=(UniqueID)waypoint)
if(iter->get_time()!=waypoint.get_time())
throw Error(_("Time mismatch iter=%s, waypoint=%s"),iter->get_time().get_string().c_str(),waypoint.get_time().get_string().c_str());
-
+
waypoint=*iter;
-
+
value_node->erase(waypoint);
// In this case, we need to convert this to a
if(!value_node_ref)
throw Error(_("Unable to create ValueNode_Reference"));
}
-
+
value_node->replace(value_node_ref);
value_node->waypoint_list().clear();
-
+
if(get_canvas_interface())
{
get_canvas_interface()->signal_value_node_replaced()(value_node,value_node_ref);
{
if(value_node->waypoint_list().size()!=0)
throw Error(_("This animated value node should be empty, but for some reason it isn't. This is a bug. (1)"));
-
+
value_node_ref->replace(value_node);
-
+
waypoint.set_value_node(value_node_ref);
-
+
if(get_canvas_interface())
get_canvas_interface()->signal_value_node_replaced()(value_node_ref,value_node);
if(value_node->waypoint_list().size()!=0)
{
try { value_node->find(waypoint.get_time()); throw Error(_("A Waypoint already exists at this point in time"));}
- catch(synfig::Exception::NotFound) { }
-
+ catch(synfig::Exception::NotFound) { }
+
try { if(value_node->find(waypoint)!=value_node->waypoint_list().end()) throw Error(_("This waypoint is already in the ValueNode"));}
- catch(synfig::Exception::NotFound) { }
+ catch(synfig::Exception::NotFound) { }
}
-
+
value_node->add(waypoint);
-
+
/*_if(get_canvas_interface())
{
get_canvas_interface()->signal_value_node_changed()(value_node);
Action::WaypointSet::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE)
.set_local_name(_("Destination ValueNode (Animated)"))
);
if(name=="value_node" && param.get_type()==Param::TYPE_VALUENODE)
{
value_node=ValueNode_Animated::Handle::cast_dynamic(param.get_value_node());
-
+
return static_cast<bool>(value_node);
}
if(name=="waypoint" && param.get_type()==Param::TYPE_WAYPOINT)
{
//NOTE: at the moment there is no error checking for multiple sets!!!
waypoints.push_back(param.get_waypoint());
-
+
return true;
}
void
Action::WaypointSet::perform()
-{
+{
WaypointList::iterator iter;
-#if 1
+#if 1
vector<WaypointList::iterator> iters;
- vector<Waypoint>::iterator i = waypoints.begin(), end = waypoints.end();
-
+ vector<Waypoint>::iterator i = waypoints.begin(), end = waypoints.end();
+
for(; i != end; ++i)
{
try { iters.push_back(value_node->find(*i)); }
throw Error(_("Unable to find waypoint"));
}
}
-
+
//check to see which valuenodes are going to override because of the time...
ValueNode_Animated::findresult timeiter;
-
+
for(i = waypoints.begin(); i != end; ++i)
{
timeiter = value_node->find_time(i->get_time());
-
+
bool candelete = timeiter.second;
-
+
//we only want to track overwrites (not waypoints that are also being modified)
if(candelete)
{
}
}
}
-
+
//if we can still delete it after checking, record it, and then remove them all later
if(candelete)
{
overwritten_waypoints.push_back(w);
}
}
-
+
//overwrite all the valuenodes we're supposed to set
{
i = waypoints.begin();
**ii = *i; //set the point to the corresponding point in the normal waypoint list
}
}
-
+
//remove all the points we're supposed to be overwritting
{
vector<Waypoint>::iterator oi = overwritten_waypoints.begin(),
//find the value at the old time before we replace it
ValueNode_Animated::findresult timeiter;
timeiter = value_node->find_time(waypoint.get_time());
-
+
//we only want to track overwrites (not inplace modifications)
if(timeiter.second && waypoint.get_uid() == timeiter.first->get_uid())
{
- timeiter.second = false;
+ timeiter.second = false;
}
-
+
//copy and overwrite
old_waypoint=*iter;
*iter=waypoint;
-
+
//if we've found a unique one then we need to erase it, but store it first
if(timeiter.second)
{
time_overwrite = true;
overwritten_wp = *timeiter.first;
-
+
value_node->erase(overwritten_wp);
}
#endif
-
+
// Signal that a valuenode has been changed
value_node->changed();
}
Action::WaypointSet::undo()
{
WaypointList::iterator iter;
-
+
#if 1
- vector<Waypoint>::iterator i = old_waypoints.begin(), end = old_waypoints.end();
-
+ vector<Waypoint>::iterator i = old_waypoints.begin(), end = old_waypoints.end();
+
for(; i != end; ++i)
{
try { iter = value_node->find(*i); }
{
throw Error(_("Unable to find waypoint"));
}
-
+
//overwrite with old one
*iter = *i;
}
-
+
//add back in all the points that we removed before...
{
vector<Waypoint>::iterator oi = overwritten_waypoints.begin(),
catch(synfig::Exception::NotFound)
{
throw Error(_("Unable to find waypoint"));
- }
+ }
*iter=old_waypoint;
-
+
if(time_overwrite)
{
value_node->add(overwritten_wp);
}
#endif
-
+
// Signal that a valuenode has been changed
value_node->changed();
}
public CanvasSpecific
{
private:
-
+
synfig::ValueNode_Animated::Handle value_node;
-
+
std::vector<synfig::Waypoint> waypoints;
- std::vector<synfig::Waypoint> old_waypoints;
+ std::vector<synfig::Waypoint> old_waypoints;
std::vector<synfig::Waypoint> overwritten_waypoints;
Action::WaypointSetSmart::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE)
.set_local_name(_("Destination ValueNode (Animated)"))
);
.set_desc(_("Time where waypoint is to be added"))
.set_optional()
);
-
+
return ret;
}
DEBUGPOINT();
if(time_set)
calc_waypoint();
-
+
return static_cast<bool>(value_node);
}
if(name=="waypoint" && param.get_type()==Param::TYPE_WAYPOINT && !time_set)
{
waypoint=param.get_waypoint();
DEBUGPOINT();
-
+
return true;
}
if(value_node)
calc_waypoint();
DEBUGPOINT();
-
+
return true;
}
calc_waypoint();
waypoint.apply_model(param.get_waypoint_model());
-
+
return true;
}
if(waypoint.get_time()==(Time::begin()-1))
synfig::error("Missing waypoint");
-
+
if(!value_node || waypoint.get_time()==(Time::begin()-1))
return false;
return Action::CanvasSpecific::is_ready();
}
-// This function is called if a time is specified, but not
+// This function is called if a time is specified, but not
// a waypoint. In this case, we need to calculate the value
// of the waypoint
void
Action::WaypointSetSmart::calc_waypoint()
{
DEBUGPOINT();
- Time time=waypoint.get_time();
+ Time time=waypoint.get_time();
try
{
// Trivial case, we are sitting on a waypoint
}
catch(...)
{
- waypoint=value_node->new_waypoint_at_time(time);
+ waypoint=value_node->new_waypoint_at_time(time);
waypoint.set_before(synfigapp::Main::get_interpolation());
waypoint.set_after(synfigapp::Main::get_interpolation());
}
Time time=waypoint.get_time();
ValueNode_Animated::WaypointList &waypoint_list(value_node->waypoint_list());
ValueNode_Animated::WaypointList::iterator iter;
-
+
if(waypoint_list.empty())
{
waypoint.set_value((*value_node)(time));
}
ValueNode_Animated::WaypointList::iterator closest=waypoint_list.begin();
-
+
for(iter=waypoint_list.begin();iter!=waypoint_list.end();++iter)
{
const Real dist(abs(iter->get_time()-time));
void
Action::WaypointSetSmart::enclose_waypoint(const synfig::Waypoint& waypoint)
{
- times.insert(waypoint.get_time());
-
+ times.insert(waypoint.get_time());
+
try {
times.insert(value_node->find(waypoint)->get_time());
// synfig::info(__FILE__":%d: value_node->find(waypoint)->get_time()=%s",__LINE__,value_node->find(waypoint)->get_time().get_string().c_str());
// DEBUGPOINT();
}catch (...) { }
-
+
// DEBUGPOINT();
// First we need to to add any waypoints necessary to
- // maintain the integrity of the keyframes.
+ // maintain the integrity of the keyframes.
if(get_edit_mode()&MODE_ANIMATE_PAST) try
{
Time curr_time(waypoint.get_time());
-
+
//while(value_node->waypoint_list().front().get_time()<=curr_time)
{
// Try to find prev keyframe
// synfig::info(__FILE__":%d: prev_keyframe->time=%s",__LINE__,keyframe.get_time().get_string().c_str());
// synfig::info(__FILE__":%d: waypoint->time=%s",__LINE__,waypoint.get_time().get_string().c_str());
-
+
// DEBUGPOINT();
if(times.count(keyframe.get_time()))
{
throw int();
}
- times.insert(keyframe.get_time());
+ times.insert(keyframe.get_time());
// DEBUGPOINT();
try
{
catch(synfig::Exception::NotFound)
{
Action::Handle action(WaypointAdd::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_node",ValueNode::Handle(value_node));
-
+
if(!value_node->waypoint_list().empty())
- {
+ {
action->set_param("time",keyframe.get_time());
}
else
{
synfig::Waypoint tmp;
-
+
tmp.set_value(waypoint.get_value());
tmp.set_time(keyframe.get_time());
action->set_param("waypoint",tmp);
}
-
+
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action(action);
- }
- }
+ }
+ }
}
catch(Error x) { throw x; }
catch(synfig::Exception::NotFound) { DEBUGPOINT(); }
if(get_edit_mode()&MODE_ANIMATE_FUTURE)try
{
Time curr_time(waypoint.get_time());
-
+
//while(value_node->waypoint_list().back().get_time()>=curr_time)
{
-
+
//DEBUGPOINT();
// Try to find next keyframe
//synfig::info("FUTURE waypoint.get_time()=%s",waypoint.get_time().get_string().c_str());
Keyframe keyframe(*get_canvas()->keyframe_list().find_next(curr_time));
//synfig::info("FUTURE keyframe.get_time()=%s",keyframe.get_time().get_string().c_str());
curr_time=keyframe.get_time();
-
+
//DEBUGPOINT();
if(times.count(keyframe.get_time())|| waypoint.get_time().is_equal(keyframe.get_time()))
throw int();
else
- times.insert(keyframe.get_time());
+ times.insert(keyframe.get_time());
//DEBUGPOINT();
-
+
try
{
value_node->find(keyframe.get_time());
synfig::info(__FILE__":%d: time=%s",__LINE__,keyframe.get_time().get_string().c_str());
synfig::info(__FILE__":%d: waypointtime=%s",__LINE__,value_node->find(keyframe.get_time())->get_time().get_string().c_str());
-
+
}
catch(synfig::Exception::NotFound)
{
Action::Handle action(WaypointAdd::create());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",get_canvas_interface());
action->set_param("value_node",ValueNode::Handle(value_node));
-
+
if(!value_node->waypoint_list().empty())
- {
+ {
action->set_param("time",keyframe.get_time());
}
else
{
synfig::Waypoint tmp;
-
+
tmp.set_value(waypoint.get_value());
tmp.set_time(keyframe.get_time());
action->set_param("waypoint",tmp);
}
-
+
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action(action);
}
}
//DEBUGPOINT();
clear();
times.clear();
-
+
// First we need to to add any waypoints necessary to
- // maintain the integrity of the keyframes.
+ // maintain the integrity of the keyframes.
enclose_waypoint(waypoint);
try
//synfig::info("WaypointSetSmart: Move/Update?");
// Lets try to replace the old waypoint, if it exists
WaypointList::iterator iter(value_node->find(waypoint));
-
+
if(iter == value_node->waypoint_list().end())
throw int();
-
+
enclose_waypoint(*iter);
Action::Handle action(WaypointSet::create());
-
+
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("waypoint",waypoint);
-
+
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action(action);
-
+
return;
}
catch(synfig::Exception::NotFound){ } catch(int){ }
//DEBUGPOINT();
// Check to see if a waypoint exists at this point in time
WaypointList::iterator iter=value_node->find(waypoint.get_time());
-
+
waypoint.mimic(*iter);
enclose_waypoint(*iter);
-
+
Action::Handle action(WaypointSet::create());
-
+
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("waypoint",waypoint);
-
+
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action(action);
-
+
return;
}
catch(synfig::Exception::NotFound){ } catch(int){ }
-
+
try
{
//synfig::info("WaypointSetSmart: Add?");
// At this point we know that the old waypoint doesn't exist,
// so we need to create it.
Action::Handle action(WaypointAdd::create());
-
+
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("waypoint",waypoint);
-
+
assert(action->is_ready());
if(!action->is_ready())
throw Error(Error::TYPE_NOTREADY);
-
+
add_action(action);
-
+
return;
}
catch(synfig::Exception::NotFound){ } catch(int){ }
- throw Error(_("Unable to determine how to procede. This is a bug."));
+ throw Error(_("Unable to determine how to procede. This is a bug."));
}
Action::WaypointSimpleAdd::get_param_vocab()
{
ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
-
+
ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE)
.set_local_name(_("Destination ValueNode (Animated)"))
);
if(name=="value_node" && param.get_type()==Param::TYPE_VALUENODE)
{
value_node=ValueNode_Animated::Handle::cast_dynamic(param.get_value_node());
-
+
return static_cast<bool>(value_node);
}
if(name=="waypoint" && param.get_type()==Param::TYPE_WAYPOINT)
{
waypoint = param.get_waypoint();
-
+
return true;
}
void
Action::WaypointSimpleAdd::perform()
-{
+{
//remove any pretenders that lie at our destination
ValueNode_Animated::findresult iter = value_node->find_time(waypoint.get_time());
-
+
time_overwrite = false;
if(iter.second)
{
overwritten_wp = *iter.first;
time_overwrite = true;
}
-
+
//add the value node in since it's safe
value_node->add(waypoint);
-
+
// Signal that a valuenode has been changed
value_node->changed();
}
{
//remove our old version...
ValueNode_Animated::findresult iter = value_node->find_uid(waypoint);
-
+
if(!iter.second)
{
throw Error(_("The waypoint to remove no longer exists"));
}
-
+
//remove the offending value
value_node->erase(*iter.first); //could also just use waypoint
-
+
if(time_overwrite)
{
- value_node->add(overwritten_wp);
+ value_node->add(overwritten_wp);
}
-
+
// Signal that a valuenode has been changed
value_node->changed();
}
public CanvasSpecific
{
private:
-
+
synfig::ValueNode_Animated::Handle value_node;
-
+
synfig::Waypoint waypoint;
bool time_overwrite;
{
/*
Lj(x) = PI_i!=j (x - xi) / PI_i!=j (xj - xi)
-
+
so Lj'(x) = SUM_k PI_i!=j|k (x - xi) / PI_i!=j (xj - xi)
*/
-
+
unsigned int i,j,k,i0,i1;
-
+
Real Lpj,mult,div,tj;
Real tval = t[indexval];
-
- //sum k
+
+ //sum k
for(j=0;j<npoints;++j)
{
Lpj = 0;
div = 1;
tj = t[j];
-
+
for(k=0;k<npoints;++k)
{
if(k != j) //because there is no summand for k == j, since that term is missing from the original equation
mult *= tval - t[i];
}
}
-
+
Lpj += mult; //add into the summation
-
+
//since the ks follow the exact patern we need for the divisor (use that too)
div *= tj - t[k];
}
}
-
+
//get the actual coefficient
Lpj /= div;
-
+
//add it in to the equation
df += f[j]*Lpj;
}
else if(right - left < 3)
{
synfig::Vector v = f[left+1] - f[left];
-
+
//set both to the one we want
*(synfig::Vector*)out = v;
out += dfstride;
ThreePointdt(*(synfig::Vector*)out,f[left+0], f[left+1], f[left+2], -1);
current += 1;
out += dfstride;
-
+
for(;current < right-1; current++, out += dfstride)
{
ThreePointdt(*(synfig::Vector*)out,f[current-1], f[current], f[current+1], 0);
ThreePointdt(*(synfig::Vector*)out,f[right-3], f[right-2], f[right-1], 1);
current++;
out += dfstride;
-
+
}else //can use 5 point
{
//left 2 then middle bunch then right two
//may want to use 3 point for inner edge ones
-
+
FivePointdt(*(synfig::Vector*)out,f[left+0], f[left+1], f[left+2], f[left+3], f[left+4], -2);
out += dfstride;
FivePointdt(*(synfig::Vector*)out,f[left+1], f[left+2], f[left+3], f[left+4], f[left+5], -1);
out += dfstride;
current += 2;
-
+
for(;current < right-2; current++, out += dfstride)
{
FivePointdt(*(synfig::Vector*)out,f[current-2], f[current-1], f[current], f[current+1], f[current+2], 0);
FivePointdt(*(synfig::Vector*)out,f[right-5], f[right-4], f[right-3], f[right-2], f[right-1], 1);
out += dfstride;
- FivePointdt(*(synfig::Vector*)out,f[right-6], f[right-5], f[right-4], f[right-3], f[right-2], 2);
+ FivePointdt(*(synfig::Vector*)out,f[right-6], f[right-5], f[right-4], f[right-3], f[right-2], 2);
out += dfstride;
current += 2;
}
}
-void GetSimpleDerivatives(const std::vector<synfig::Point> &f, int left, int right,
+void GetSimpleDerivatives(const std::vector<synfig::Point> &f, int left, int right,
std::vector<synfig::Point> &df, int outleft,
const std::vector<synfig::Real> &di)
{
int i1,i2,i;
int offset = 2; //df = 1/2 (f[i+o]-f[i-o])
-
+
assert((int)df.size() >= right-left+outleft); //must be big enough
-
+
for(i = left; i < right; ++i)
{
//right now indices (figure out distance later)
i1 = std::max(left,i-offset);
i2 = std::max(left,i+offset);
-
+
df[outleft++] = (f[i2] - f[i1])*0.5f;
}
}
Real CurveError(const synfig::Point *pts, unsigned int n, std::vector<synfig::Point> &work, int left, int right)
{
if(right-left < 2) return -1;
-
+
int i,j;
-
+
//get distances to each point
Real d,dtemp,dsum;
//synfig::Vector v,vt;
//synfig::Point p1,p2;
synfig::Point pi;
std::vector<synfig::Point>::const_iterator it;//,end = work.begin()+right;
-
+
//unsigned int size = work.size();
-
+
//for each line, get distance
d = 0; //starts at 0
for(i = 0; i < (int)n; ++i)
- {
+ {
pi = pts[i];
-
+
dsum = FLT_MAX;
-
+
it = work.begin()+left;
//p2 = *it++; //put it at left+1
for(j = left/*+1*/; j < right; ++j,++it)
{
/*p1 = p2;
p2 = *it;
-
- v = p2 - p1;
+
+ v = p2 - p1;
vt = pi - p1;
-
+
dtemp = v.mag_squared() > 1e-12 ? (vt*v)/v.mag_squared() : 0; //get the projected time value for the current line
-
- //get distance to line segment with the time value clamped 0-1
+
+ //get distance to line segment with the time value clamped 0-1
if(dtemp >= 1) //use p+v
{
- vt += v; //makes it pp - (p+v)
+ vt += v; //makes it pp - (p+v)
}else if(dtemp > 0) //use vt-proj
{
vt -= v*dtemp; // vt - proj_v(vt) //must normalize the projection vector to work
}
-
+
//else use p
dtemp = vt.mag_squared();*/
-
- dtemp = (pi - *it).mag_squared();
+
+ dtemp = (pi - *it).mag_squared();
if(dtemp < dsum)
dsum = dtemp;
}
-
+
//accumulate the points' min distance from the curve
d += sqrt(dsum);
}
-
+
return d;
}
{
if(inds.size() < 2)
return 0;
-
+
etl::hermite<Point> curve;
int ntess = 0;
-
+
std::vector<cpindex>::const_iterator j = inds.begin(),j2, end = inds.end();
-
+
unsigned int ibase = inds[0].curind;
-
+
j2 = j++;
for(; j != end; j2 = j++)
{
unsigned int n = j->curind - j2->curind + 1; //thats the number of points in the span
unsigned int k, kend, i0, i3;
//so reset the right chunk
-
+
Real t, dt = 1/(Real)(n*2-2); //assuming that they own only n points
-
+
//start at first intermediate
t = 0;
- i0 = j2->curind; i3 = j->curind;
+ i0 = j2->curind; i3 = j->curind;
k = (i0-ibase)*2; //start on first intermediary point (2x+1)
kend = (i3-ibase)*2; //last point to set (not intermediary)
-
+
//build hermite curve, it's easier
curve.p1() = f[i0];
curve.p2() = f[i3];
curve.t1() = df[i0]*(df[i0].mag_squared() > 1e-4 ? j2->tangentscale/df[i0].mag() : j2->tangentscale);
curve.t2() = df[i3]*(df[i3].mag_squared() > 1e-4 ? j->tangentscale/df[i3].mag() : j->tangentscale);
curve.sync();
-
+
//MUST include the end point (since we are ignoring left one)
for(; k < kend; ++k, t += dt)
{
work[k] = curve(t);
}
-
+
work[k] = curve(1); //k == kend, t == 1 -> c(t) == p2
++ntess;
}
}
-
+
return ntess;
}
width = 0;
};
-void
+void
synfigapp::BLineConverter::clear()
{
f.clear();
void
synfigapp::BLineConverter::operator () (std::list<synfig::BLinePoint> &out, const std::list<synfig::Point> &in,const std::list<synfig::Real> &in_w)
-{
+{
//Profiling information
/*etl::clock::value_type initialprocess=0, curveval=0, breakeval=0, disteval=0;
etl::clock::value_type preproceval=0, tesseval=0, erroreval=0, spliteval=0;
return;
clear();
-
+
//removing digitization error harder than expected
-
+
//intended to fix little pen errors caused by the way people draw (tiny juts in opposite direction)
//Different solutions
// Average at both end points (will probably eliminate many points at each end of the samples)
// Average after the break points are found (weird points would still affect the curve)
// Just always get rid of breaks at the beginning and end if they are a certain distance apart
// This is will be current approach so all we do now is try to remove duplicate points
-
+
//remove duplicate points - very bad for fitting
-
+
//timer.reset();
-
+
{
std::list<synfig::Point>::const_iterator i = in.begin(), end = in.end();
std::list<synfig::Real>::const_iterator iw = in_w.begin();
synfig::Point c;
-
+
if(in.size() == in_w.size())
{
for(;i != end; ++i,++iw)
- {
+ {
//eliminate duplicate points
if(*i != c)
{
}else
{
for(;i != end; ++i)
- {
+ {
//eliminate duplicate points
if(*i != c)
{
}
}
//initialprocess = timer();
-
+
if(f.size()<=6)
return;
-
+
//get curvature information
//timer.reset();
-
+
{
int i,i0,i1;
synfig::Vector v1,v2;
-
+
cvt.resize(f.size());
-
+
cvt.front() = 1;
cvt.back() = 1;
-
+
for(i = 1; i < (int)f.size()-1; ++i)
{
i0 = std::max(0,i - 2);
i1 = std::min((int)(f.size()-1),i + 2);
-
+
v1 = f[i] - f[i0];
v2 = f[i1] - f[i];
-
+
cvt[i] = (v1*v2)/(v1.mag()*v2.mag());
}
}
-
+
//curveval = timer();
//synfig::info("calculated curvature");
-
+
//find corner points and interpolate inside those
//timer.reset();
- {
+ {
//break at sharp derivative points
//TODO tolerance should be set based upon digitization resolution (length dependent index selection)
Real tol = 0; //break tolerance, for the cosine of the change in angle (really high curvature or something)
Real fixdistsq = 4*width*width; //the distance to ignore breaks at the end points (for fixing stuff)
unsigned int i = 0;
-
+
int maxi = -1, last=0;
Real minc = 1;
-
+
brk.push_back(0);
-
+
for(i = 1; i < cvt.size()-1; ++i)
- {
+ {
//insert if too sharp (we need to break the tangents to insert onto the break list)
-
+
if(cvt[i] < tol)
{
if(cvt[i] < minc)
{
if(maxi >= last + 8)
{
- //synfig::info("break: %d-%d",maxi+1,cvt.size());
+ //synfig::info("break: %d-%d",maxi+1,cvt.size());
brk.push_back(maxi);
last = maxi;
}
minc = 1;
}
}
-
+
brk.push_back(i);
-
+
//postprocess for breaks too close to eachother
Real d = 0;
Point p = f[brk.front()];
-
+
//first set
for(i = 1; i < brk.size()-1; ++i) //do not want to include end point...
{
d = (f[brk[i]] - p).mag_squared();
- if(d > fixdistsq) break; //don't want to group breaks if we ever get over the dist...
+ if(d > fixdistsq) break; //don't want to group breaks if we ever get over the dist...
}
//want to erase all points before...
if(i != 1)
- brk.erase(brk.begin(),brk.begin()+i-1);
-
+ brk.erase(brk.begin(),brk.begin()+i-1);
+
//end set
p = f[brk.back()];
for(i = brk.size()-2; i > 0; --i) //start at one in from the end
}
//breakeval = timer();
//synfig::info("found break points: %d",brk.size());
-
+
//get the distance calculation of the entire curve (for tangent scaling)
//timer.reset();
{
synfig::Point p1,p2;
-
+
p1=p2=f[0];
-
+
di.resize(f.size()); d_i.resize(f.size());
Real d = 0;
for(unsigned int i = 0; i < f.size();)
{
d += (d_i[i] = (p2-p1).mag());
di[i] = d;
-
+
p1=p2;
p2=f[++i];
}
}
//disteval = timer();
//synfig::info("calculated distance");
-
+
//now break at every point - calculate new derivatives each time
-
+
//TODO
//must be sure that the break points are 3 or more apart
//then must also store the breaks which are not smooth, etc.
//and figure out tangents between there
-
+
//for each pair of break points (as long as they are far enough apart) recursively subdivide stuff
//ignore the detected intermediate points
{
unsigned int i0=0,i3=0,is=0;
int i=0,j=0;
-
+
bool done = false;
-
+
Real errortol = smoothness*pixelwidth; //???? what the hell should this value be
-
+
BLinePoint a;
synfig::Vector v;
-
+
//intemp = f; //don't want to smooth out the corners
-
+
bool breaktan = false, setwidth;
a.set_split_tangent_flag(false);
//a.set_width(width);
a.set_width(1.0f);
-
+
setwidth = (f.size() == f_w.size());
-
+
for(j = 0; j < (int)brk.size() - 1; ++j)
{
//for b[j] to b[j+1] subdivide and stuff
i0 = brk[j];
i3 = brk[j+1];
-
+
unsigned int size = i3-i0+1; //must include the end points
-
+
//new derivatives
//timer.reset();
ftemp.assign(f.begin()+i0, f.begin()+i3+1);
for(i=0;i<20;++i)
gaussian_blur_3(ftemp.begin(),ftemp.end(),false);
-
+
df.resize(size);
GetFirstDerivatives(ftemp,0,size,(char*)&df[0],sizeof(df[0]));
- //GetSimpleDerivatives(ftemp,0,size,df,0,di);
+ //GetSimpleDerivatives(ftemp,0,size,df,0,di);
//< don't have to worry about indexing stuff as it is all being taken car of right now
//preproceval += timer();
//numpre++;
-
+
work.resize(size*2-1); //guarantee that all points will be tesselated correctly (one point inbetween every 2 adjacent points)
-
+
//if size of work is size*2-1, the step size should be 1/(size*2 - 2)
//Real step = 1/(Real)(size*2 - 1);
-
+
//start off with break points as indices
curind.clear();
curind.push_back(cpindex(i0,di[i3]-di[i0],0)); //0 error because no curve on the left
curind.push_back(cpindex(i3,di[i3]-di[i0],-1)); //error needs to be reevaluated
done = false; //we want to loop
-
+
unsigned int dcount = 0;
-
- //while there are still enough points between us, and the error is too high subdivide (and invalidate neighbors that share tangents)
+
+ //while there are still enough points between us, and the error is too high subdivide (and invalidate neighbors that share tangents)
while(!done)
- {
+ {
//tesselate all curves with invalid error values
work[0] = f[i0];
-
+
//timer.reset();
/*numtess += */tesselate_curves(curind,f,df,work);
//tesseval += timer();
-
+
//now get all error values
//timer.reset();
for(i = 1; i < (int)curind.size(); ++i)
int size = curind[i].curind - curind[i-1].curind + 1;
curind[i].error = CurveError(&f[curind[i-1].curind], size,
work,(curind[i-1].curind - i0)*2,(curind[i].curind - i0)*2+1);
-
+
/*if(curind[i].error > 1.0e5)
{
synfig::info("Holy crap %d-%d error %f",curind[i-1].curind,curind[i].curind,curind[i].error);
}
}
//erroreval += timer();
-
+
//assume we're done
done = true;
-
+
//check each error to see if it's too big, if so, then subdivide etc.
int indsize = (int)curind.size();
Real maxrelerror = 0;
int maxi = -1;//, numpoints;
-
+
//timer.reset();
//get the maximum error and split there
for(i = 1; i < indsize; ++i)
{
//numpoints = curind[i].curind - curind[i-1].curind + 1;
-
+
if(curind[i].error > maxrelerror && curind[i].curind - curind[i-1].curind > 2) //only accept if it's valid
{
maxrelerror = curind[i].error;
maxi = i;
}
}
-
+
//split if error is too great
if(maxrelerror > errortol)
{
unsigned int ibase = curind[maxi-1].curind, itop = curind[maxi].curind,
ibreak = (ibase + itop)/2;
Real scale, scale2;
-
+
assert(ibreak < f.size());
-
+
//synfig::info("Split %d -%d- %d, error: %f", ibase,ibreak,itop,maxrelerror);
-
+
if(ibase != itop)
{
//invalidate current error of the changed tangents and add an extra segment
curind[maxi].error = -1;
curind[maxi-1].error = -1;
if(maxi+1 < indsize) curind[maxi+1].error = -1; //if there is a curve segment beyond this it will be effected as well
-
+
scale = di[itop] - di[ibreak];
scale2 = maxi+1 < indsize ? di[curind[maxi+1].curind] - di[itop] : scale; //to the right valid?
curind[maxi].tangentscale = std::min(scale, scale2);
-
+
scale = di[ibreak] - di[ibase];
scale2 = maxi >= 2 ? di[ibase] - di[curind[maxi-2].curind] : scale; // to the left valid -2 ?
curind[maxi-1].tangentscale = std::min(scale, scale2);
-
+
scale = std::min(di[ibreak] - di[ibase], di[itop] - di[ibreak]);
-
+
curind.insert(curind.begin()+maxi,cpindex(ibreak, scale, -1));
//curind.push_back(cpindex(ibreak, scale, -1));
//std::sort(curind.begin(), curind.end());
-
+
done = false;
//numsplit++;
}
}
//spliteval += timer();
-
+
dcount++;
}
-
- //insert the last point too (just set tangent for now
+
+ //insert the last point too (just set tangent for now
is = curind[0].curind;
-
- //first point inherits current tangent status
+
+ //first point inherits current tangent status
v = df[is - i0];
if(v.mag_squared() > EPSILON)
v *= (curind[0].tangentscale/v.mag());
-
+
if(!breaktan)
a.set_tangent(v);
else a.set_tangent2(v);
-
+
a.set_vertex(f[is]);
if(setwidth)a.set_width(f_w[is]);
-
+
out.push_back(a);
a.set_split_tangent_flag(false); //won't need to break anymore
breaktan = false;
-
+
for(i = 1; i < (int)curind.size()-1; ++i)
{
is = curind[i].curind;
-
+
//first point inherits current tangent status
v = df[is-i0];
if(v.mag_squared() > EPSILON)
v *= (curind[i].tangentscale/v.mag());
-
+
a.set_tangent(v); // always inside, so guaranteed to be smooth
a.set_vertex(f[is]);
if(setwidth)a.set_width(f_w[is]);
-
+
out.push_back(a);
}
-
+
//set the last point's data
is = curind.back().curind; //should already be this
-
+
v = df[is-i0];
if(v.mag_squared() > EPSILON)
v *= (curind.back().tangentscale/v.mag());
-
+
a.set_tangent1(v);
a.set_split_tangent_flag(true);
breaktan = true;
-
+
//will get the vertex and tangent 2 from next round
}
-
+
a.set_vertex(f[i3]);
a.set_split_tangent_flag(false);
if(setwidth)
a.set_width(f_w[i3]);
out.push_back(a);
-
+
/*etl::clock::value_type totaltime = total(),
misctime = totaltime - initialprocess - curveval - breakeval - disteval
- preproceval - tesseval - erroreval - spliteval;
-
+
synfig::info(
"Curve Convert Profile:\n"
"\tInitial Preprocess: %f\n"
numpre,preproceval,numtess,tesseval,numerror,erroreval,numsplit,spliteval,
in.size(),out.size(),
totaltime,misctime);*/
-
+
return;
}
}
{
std::list<synfig::BLinePoint>::iterator i = bline.begin(),
end = bline.end();
-
+
for(i = bline.begin(); i != end; ++i)
{
if(i->get_width() < min_pressure)
/* === C L A S S E S & S T R U C T S ======================================= */
namespace synfigapp {
-
+
class BLineConverter
{
public:
int curind;
synfig::Real tangentscale;
synfig::Real error; //negative error will indicate invalid;
-
- cpindex(int ci, synfig::Real s=0, synfig::Real e=-1)
- :curind(ci), tangentscale(s), error(e)
+
+ cpindex(int ci, synfig::Real s=0, synfig::Real e=-1)
+ :curind(ci), tangentscale(s), error(e)
{}
-
+
cpindex(const cpindex & o)
- :curind(o.curind), tangentscale(o.tangentscale), error(o.error)
+ :curind(o.curind), tangentscale(o.tangentscale), error(o.error)
{}
-
+
const cpindex & operator = (const cpindex & rhs)
{
curind = rhs.curind;
error = rhs.error;
return *this;
}
-
+
bool operator < (const cpindex &rhs) const
{
- return curind < rhs.curind;
+ return curind < rhs.curind;
}
-
+
//point is obviously in[curind]
//tangent scale will get reset to the smallest (or something else depending on experimentation)
};
//temporary point storage for vector calc
std::vector<synfig::Point> ftemp;
-
- std::vector<synfig::Vector> df; //the derivative cache
+
+ std::vector<synfig::Vector> df; //the derivative cache
std::vector<synfig::Real> cvt; //the curvature cache
-
+
std::vector<int> brk; //the break point cache
-
+
std::vector<synfig::Real> di, //cumulative distance
d_i; //distance between adjacent segments
-
+
std::vector<synfig::Point> work; //the working point cache for the entire curve
std::vector<cpindex> curind;
-
+
//function parameters
void clear();
static void EnforceMinWidth(std::list<synfig::BLinePoint> &bline, synfig::Real min_pressure);
void operator ()(std::list<synfig::BLinePoint> &out, const std::list<synfig::Point> &in,const std::list<synfig::Real> &in_w);
};
-
+
}; // END of namespace synfigapp
/* === E N D =============================================================== */
if(cur_time_.is_equal(x))
return;
cur_time_=x;
-
+
signal_time_changed()();
signal_dirty_preview()();
}
-
+
synfig::Time
CanvasInterface::get_time()const
{
return cur_time_;
}
-void
+void
CanvasInterface::refresh_current_values()
{
get_canvas()->set_time(cur_time_);
Action::Handle action(Action::EditModeSet::create());
assert(action);
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
action->set_param("edit_mode",x);
-
+
if(!action->is_ready())
{
get_ui_interface()->error(_("Action Not Ready, unable to change mode"));
assert(0);
return;
}
-
+
if(!get_instance()->perform_action(action))
- get_ui_interface()->error(_("Unable to change mode"));
+ get_ui_interface()->error(_("Unable to change mode"));
// mode_=x;
// signal_mode_changed_(x);
synfigapp::Action::PassiveGrouper group(get_instance().get(),_("Add Layer To"));
Layer::Handle layer(Layer::create(name));
-
+
assert(layer);
-
+
if(!layer)
return 0;
}
layer->set_canvas(canvas);
-
+
// Apply some defaults
if(layer->set_param("fg",synfigapp::Main::get_foreground_color()))
layer->set_param("bg",synfigapp::Main::get_background_color());
for(iter=paramlist.begin();iter!=paramlist.end();++iter)
{
ValueNode::Handle value_node;
-
+
if(iter->second.get_type()==ValueBase::TYPE_LIST)
value_node=LinkableValueNode::create("dynamic_list",iter->second);
else if(LinkableValueNode::check_type("composite",iter->second.get_type()) &&
(iter->second.get_type()!=ValueBase::TYPE_COLOR && iter->second.get_type()!=ValueBase::TYPE_VECTOR)
)
value_node=LinkableValueNode::create("composite",iter->second);
-
+
if(value_node)
layer->connect_dynamic_param(iter->first,value_node);
}
assert(action);
if(!action)
return 0;
-
+
action->set_param("canvas",canvas);
action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
action->set_param("new",layer);
-
+
if(!action->is_ready())
{
- get_ui_interface()->error(_("Action Not Ready"));
+ get_ui_interface()->error(_("Action Not Ready"));
return 0;
}
-
+
if(!get_instance()->perform_action(action))
{
- get_ui_interface()->error(_("Action Failed."));
+ get_ui_interface()->error(_("Action Failed."));
return 0;
}
if(depth>0)
{
Action::Handle action(Action::create("layer_move"));
-
+
assert(action);
if(!action)
return 0;
-
+
action->set_param("canvas",canvas);
action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
action->set_param("layer",layer);
action->set_param("new_index",depth);
-
+
if(!action->is_ready())
{
- get_ui_interface()->error(_("Move Action Not Ready"));
+ get_ui_interface()->error(_("Move Action Not Ready"));
return 0;
}
-
+
if(!get_instance()->perform_action(action))
{
- get_ui_interface()->error(_("Move Action Failed."));
+ get_ui_interface()->error(_("Move Action Failed."));
return 0;
}
- }
-
-
+ }
+
+
return layer;
}
assert(action);
if(!action)
return 0;
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
action->set_param("value_desc",value_desc);
action->set_param("type",type);
-
+
if(!action->is_ready())
{
- get_ui_interface()->error(_("Action Not Ready"));
+ get_ui_interface()->error(_("Action Not Ready"));
return 0;
}
-
+
if(get_instance()->perform_action(action))
return true;
-
- get_ui_interface()->error(_("Action Failed."));
+
+ get_ui_interface()->error(_("Action Failed."));
return false;
}
get_ui_interface()->error(_("Empty name!"));
return false;
}
-
+
Action::Handle action(Action::ValueNodeAdd::create());
assert(action);
if(!action)
return 0;
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
action->set_param("new",value_node);
action->set_param("name",name);
-
+
if(!action->is_ready())
{
- get_ui_interface()->error(_("Action Not Ready"));
+ get_ui_interface()->error(_("Action Not Ready"));
return 0;
}
-
+
if(get_instance()->perform_action(action))
return true;
-
- get_ui_interface()->error(_("Action Failed."));
+
+ get_ui_interface()->error(_("Action Failed."));
return false;
}
if(value_desc.parent_is_value_node())
param_list.add("parent_value_node",value_desc.get_parent_value_node());
-
+
if(value_desc.is_value_node())
param_list.add("value_node",value_desc.get_value_node());
-
+
if(value_desc.is_const())
param_list.add("value",value_desc.get_value());
param_list.add("dest",value_desc);
param_list.add("src",children_list.front().get_value_node());
}
- }
+ }
return param_list;
}
param_list.add("value_desc",*iter);
if(iter->is_value_node())
{
- param_list.add("value_node",iter->get_value_node());
+ param_list.add("value_node",iter->get_value_node());
}
}
assert(action);
if(!action)
return;
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
action->set_param("rend_desc",rend_desc);
-
+
if(!get_instance()->perform_action(action))
- get_ui_interface()->error(_("Action Failed."));
+ get_ui_interface()->error(_("Action Failed."));
}
bool
CanvasInterface::import(const synfig::String &filename, bool copy)
{
Action::PassiveGrouper group(get_instance().get(),_("Import Image"));
-
+
synfig::info("Attempting to import "+filename);
// If this is a SIF file, then we need to do things slightly differently
if(ext=="sif" || ext=="sifz")try
{
-
+
Canvas::Handle outside_canvas(synfig::open_canvas(filename));
if(!outside_canvas)
throw String(_("Unable to open this composition"));
get_ui_interface()->error(_("Uncaught exception when attempting\nto open this composition -- ")+filename);
return false;
}
-
-
-
+
+
+
if(!Importer::book().count(ext))
{
get_ui_interface()->error(_("I don't know how to open images of this type -- ")+ext);
layer->set_description(basename(filename));
signal_layer_new_description()(layer,filename);
-
- return true;
+
+ return true;
}
catch(...)
{
assert(action);
if(!action)
return;
-
+
waypoint.make_unique();
waypoint.set_time(get_time());
ValueNode::Handle value_node(value_desc.get_value_node());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
action->set_param("waypoint",waypoint);
action->set_param("time",get_time());
action->set_param("value_node",value_node);
-
+
if(!get_instance()->perform_action(action))
- get_ui_interface()->error(_("Action Failed."));
+ get_ui_interface()->error(_("Action Failed."));
}
void
assert(action);
if(!action)
return;
-
+
ValueNode::Handle value_node(value_desc.get_value_node());
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
action->set_param("waypoint",waypoint);
action->set_param("value_node",value_node);
-
+
if(!get_instance()->perform_action(action))
- get_ui_interface()->error(_("Action Failed."));
+ get_ui_interface()->error(_("Action Failed."));
}
assert(action);
if(!action)
return;
-
+
String name(strprintf(_("Unnamed%08d"),synfig::UniqueID().get_uid()));
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
action->set_param("new",value_node);
action->set_param("name",name);
-
+
if(!get_instance()->perform_action(action))
- get_ui_interface()->error(_("Action Failed."));
+ get_ui_interface()->error(_("Action Failed."));
*/
}
void
CanvasInterface::auto_export(const ValueDesc& value_desc)
-{
+{
// THIS FUNCTION IS DEPRECATED, AND IS NOW A STUB.
-#if 0
+#if 0
// Check to see if we are already exported.
if(value_desc.is_exported())
return;
assert(action);
if(!action)
return;
-
+
String name(strprintf(_("Unnamed%08d"),synfig::UniqueID().get_uid()));
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
action->set_param("value_desc",value_desc);
action->set_param("name",name);
-
+
if(!get_instance()->perform_action(action))
- get_ui_interface()->error(_("Action Failed."));
+ get_ui_interface()->error(_("Action Failed."));
#endif
}
// If this isn't really a change, then don't bother
if(new_value==value_desc.get_value(get_time()))
return true;
-
+
// If this change needs to take place elsewhere, then so be it.
if(value_desc.get_canvas() && value_desc.get_canvas()->get_root()!=get_canvas()->get_root())do
{
etl::handle<Instance> instance;
instance=find_instance(value_desc.get_canvas()->get_root());
-
+
if(instance)
return instance->find_canvas_interface(value_desc.get_canvas())->change_value(value_desc,new_value);
else
{
- get_ui_interface()->error(_("The value you are trying to edit is in a composition\nwhich doesn't seem to be open. Open that composition and you\nshould be able to edit this value as normal."));
+ get_ui_interface()->error(_("The value you are trying to edit is in a composition\nwhich doesn't seem to be open. Open that composition and you\nshould be able to edit this value as normal."));
return false;
}
}while(0);
else
{ synfig::warning("Can't get canvas from value desc...?"); }
#endif
-
+
synfigapp::Action::Handle action(synfigapp::Action::create("value_desc_set"));
if(!action)
{
return false;
}
-
+
action->set_param("canvas",get_canvas());
action->set_param("canvas_interface",etl::loose_handle<CanvasInterface>(this));
action->set_param("time",get_time());
return ret;
ret+=CanvasInterface::find_important_value_descs(canvas,out,guid_set);
}
-
+
if(value_desc.is_value_node())
{
ValueNode::Handle value_node(value_desc.get_value_node());
if(guid_set.count(value_node->get_guid()))
return ret;
guid_set.insert(value_node->get_guid());
-
+
if(LinkableValueNode::Handle::cast_dynamic(value_node))
{
if(ValueNode_DynamicList::Handle::cast_dynamic(value_node))
ret++;
}
}
-
+
return ret;
}
if(!canvas->is_inline())
{
ValueNodeList::const_iterator iter;
-
+
for(
iter=canvas->value_node_list().begin();
iter!=canvas->value_node_list().end();
}
Canvas::const_iterator iter;
-
+
for(iter=canvas->begin();iter!=canvas->end();++iter)
{
Layer::Handle layer(*iter);
-
+
Layer::DynamicParamList::const_iterator iter;
for(
iter=layer->dynamic_param_list().begin();
if(value.is_valid())
ret+=_process_value_desc(ValueDesc(layer,"canvas"),out,guid_set);
}
-
+
return ret;
}
{
if(!time)
return;
-
+
float fps(get_canvas()->rend_desc().get_frame_rate());
if(time>=synfig::Time::end())
set_time(get_canvas()->rend_desc().get_time_end());
return;
}
-
+
Time newtime(get_time()+time);
newtime=newtime.round(fps);
namespace synfigapp {
-namespace Action { class ParamList; class Param; class EditModeSet; };
+namespace Action { class ParamList; class Param; class EditModeSet; };
class Instance;
class ValueDesc;
-
+
class CanvasInterface : public etl::shared_object, public sigc::trackable
{
friend class Instance;
friend class Action::EditModeSet;
-
+
public:
typedef EditMode Mode;
sigc::signal<void,synfig::Layer::Handle,synfig::String> signal_layer_new_description_;
sigc::signal<void,synfig::Canvas::Handle> signal_canvas_added_;
sigc::signal<void,synfig::Canvas::Handle> signal_canvas_removed_;
-
+
sigc::signal<void,synfig::ValueNode::Handle> signal_value_node_added_;
sigc::signal<void,synfig::ValueNode::Handle> signal_value_node_deleted_;
sigc::signal<void,synfig::ValueNode::Handle> signal_value_node_changed_;
//! Signal called when layer is raised.
sigc::signal<void,synfig::Layer::Handle>& signal_layer_raised() { return signal_layer_raised_; }
-
+
//! Signal called when layer is lowered.
sigc::signal<void,synfig::Layer::Handle>& signal_layer_lowered() { return signal_layer_lowered_; }
-
+
//! Signal called when layer has been inserted at a given position.
sigc::signal<void,synfig::Layer::Handle,int>& signal_layer_inserted() { return signal_layer_inserted_; }
//! Changes the current SelectionManager object
void set_selection_manager(const etl::handle<SelectionManager> &sm) { selection_manager_=sm; }
-
+
//! Disables the selection manager
void unset_selection_manager() { selection_manager_=new NullSelectionManager(); }
-
+
//! Returns a handle to the current SelectionManager
- const etl::handle<SelectionManager> &get_selection_manager()const { return selection_manager_; }
+ const etl::handle<SelectionManager> &get_selection_manager()const { return selection_manager_; }
//! Changes the current UIInterface object
void set_ui_interface(const etl::handle<UIInterface> &uim) { ui_interface_=uim; }
//! Disables the UIInterface
void unset_ui_interface() { ui_interface_=new DefaultUIInterface(); }
-
+
//! Returns a handle to the current UIInterface
- const etl::handle<UIInterface> &get_ui_interface() { return ui_interface_; }
+ const etl::handle<UIInterface> &get_ui_interface() { return ui_interface_; }
//! Returns the Canvas associated with this interface
etl::handle<synfig::Canvas> get_canvas()const { return canvas_; }
//! Changes the ID of the canvas. Undoable.
bool set_id(const synfig::String &x);
-
+
//! Convience function to retrieve the name of the canvas
synfig::String get_name()const { return get_canvas()->get_name(); }
//! Sets the current time
void set_time(synfig::Time x);
-
+
//! Retrieves the current time
synfig::Time get_time()const;
-
+
//! Changes the current time to the next keyframe
void jump_to_next_keyframe();
//! Changes the current time to the next keyframe
void jump_to_prev_keyframe();
-
+
void seek_frame(int frames);
void seek_time(synfig::Time time);
-
+
//! \writeme
void refresh_current_values();
-
+
//! Sets the current editing mode
/*! \see Mode */
void set_mode(Mode x);
void set_rend_desc(const synfig::RendDesc &rend_desc);
bool import(const synfig::String &filename, bool copy=false);
-
-
+
+
void waypoint_duplicate(synfigapp::ValueDesc value_desc,synfig::Waypoint waypoint);
void waypoint_remove(synfigapp::ValueDesc value_desc,synfig::Waypoint waypoint);
PushMode(etl::loose_handle<CanvasInterface> c, CanvasInterface::Mode mode):
canvas_interface_(c.get()), old_mode_(canvas_interface_->get_mode())
{ canvas_interface_->set_mode(mode); }
-
+
~PushMode() { canvas_interface_->set_mode(old_mode_); }
}; // END of class PushMode
CVSInfo::set_file_name(const synfig::String& file_name)
{
file_name_=file_name;
-
+
std::ifstream file((dirname(file_name_)+"/CVS/Root").c_str());
if(file)
#ifdef _DEBUG
synfig::info("in_sandbox() = %d",in_sandbox());
#endif
-
+
if(!in_sandbox_)
return;
-
+
std::ifstream file((dirname(file_name_)+"/CVS/Entries").c_str());
while(file)
{
in_repository_=true;
String::size_type s,f;
-
+
// Grab the version
s=line.find('/',1);
assert(s!=String::npos);
f=line.find('/',s+1);
assert(f!=String::npos);
cvs_version_=String(line,s,f-s);
-
+
// Grab the time
#ifdef HAVE_STRPTIME
s=f+1;
strptime(String(line,s,f-s).c_str(),"%c",&time_struct);
original_timestamp_=mktime(&time_struct);
#endif
-
+
if(
system(strprintf(
"cd '%s' && cvs status '%s' | grep -q -e 'Needs Patch'",
synfig::info("UPDATE_AVAILABLE=FALSE");
update_available_=false;
}
-
-
+
+
#ifdef _DEBUG
synfig::info("in_repository() = %d",in_repository());
synfig::info("get_cvs_version() = %s",get_cvs_version().c_str());
synfig::info("get_current_timestamp() = %s",ctime(&t));
synfig::info("get_cvs_root() = %s",get_cvs_root().c_str());
synfig::info("get_cvs_module() = %s",get_cvs_module().c_str());
-#endif
+#endif
return;
}
}
{
if(!in_sandbox_)
return synfig::String();
-
+
std::ifstream file((dirname(file_name_)+"/CVS/Root").c_str());
if(file)
throw int();
return;
}
-
+
synfig::String command(strprintf("cd '%s' && %s add -m '%s' '%s'",dirname(file_name_).c_str(),cvs_command.c_str(),fix_msg(message).c_str(),basename(file_name_).c_str()));
-
+
int ret(system(command.c_str()));
-
+
calc_repository_info();
switch(ret)
break;
}
}
-
+
void
CVSInfo::cvs_update()
{
throw int();
return;
}
-
+
synfig::String command(strprintf("cd '%s' && %s update '%s'",dirname(file_name_).c_str(),cvs_command.c_str(),basename(file_name_).c_str()));
-
+
int ret(system(command.c_str()));
calc_repository_info();
-
+
switch(ret)
{
case 0:
break;
}
}
-
+
void
CVSInfo::cvs_commit(const synfig::String& message)
{
throw int();
return;
}
-
+
synfig::String command(strprintf("cd '%s' && %s commit -m '%s' '%s'",dirname(file_name_).c_str(),cvs_command.c_str(),fix_msg(message).c_str(),basename(file_name_).c_str()));
-
+
int ret(system(command.c_str()));
calc_repository_info();
-
+
switch(ret)
{
case 0:
bool in_sandbox_;
bool in_repository_;
bool update_available_;
-
+
synfig::String cvs_version_;
time_t original_timestamp_;
-
-
+
+
public:
void calc_repository_info();
-
+
CVSInfo(const synfig::String& file_name);
CVSInfo();
~CVSInfo();
//! Returns TRUE if \a file_name is in a sandbox
bool in_sandbox()const;
-
+
//! Returns TRUE if \a file_name is in the repository
bool in_repository()const;
//! Returns the CVS version string
const synfig::String& get_cvs_version()const;
-
+
//! Returns the unix timestamp of the repository file
const time_t &get_original_timestamp()const;
//! Returns the name of the module
synfig::String get_cvs_module()const;
-
+
// WRITE OPERATIONS -------------------------------------------------
-
+
void cvs_add(const synfig::String& message=synfig::String());
-
+
void cvs_update();
-
+
void cvs_commit(const synfig::String& message=synfig::String());
}; // END of class CVSInfo
-
+
}; // END of namespace synfigapp
/* === E N D =============================================================== */
/* === C L A S S E S & S T R U C T S ======================================= */
namespace synfigapp {
-
+
/*! \enum EditMode
** \brief \writeme
*/
public:
DeviceSettings(InputDevice* input_device):
input_device(input_device) { }
-
+
virtual bool get_value(const synfig::String& key, synfig::String& value)const
{
return true;
}
-
+
return Settings::get_value(key, value);
}
-
+
virtual bool set_value(const synfig::String& key,const synfig::String& value)
{
DEBUGPOINT();
input_device->set_foreground_color(synfig::Color(r,g,b,a));
return true;
}
-
+
return Settings::set_value(key, value);
}
-
+
virtual KeyList get_key_list()const
{
KeyList ret(Settings::get_key_list());
state_="normal";
break;
}
-
+
device_settings=new DeviceSettings(this);
Main::settings().add_domain(device_settings,"input_device."+id_);
}
InputDevice::~InputDevice()
{
- Main::settings().remove_domain("input_device."+id_);
+ Main::settings().remove_domain("input_device."+id_);
delete device_settings;
}
namespace synfigapp {
class Settings;
-
+
class InputDevice : public etl::shared_object
{
public:
};
typedef etl::handle<InputDevice> Handle;
-
+
private:
synfig::String id_;
Type type_;
synfig::String state_;
synfig::Color foreground_color_;
synfig::Color background_color_;
- synfig::Distance bline_width_;
+ synfig::Distance bline_width_;
synfig::Real opacity_;
synfig::Color::BlendMethod blend_method_;
const synfig::Real& get_opacity()const { return opacity_; }
const synfig::Color::BlendMethod& get_blend_method()const { return blend_method_; }
Type get_type()const { return type_; }
-
+
void set_state(const synfig::String& x) { state_=x; }
void set_foreground_color(const synfig::Color& x) { foreground_color_=x; }
void set_background_color(const synfig::Color& x) { background_color_=x; }
void set_blend_method(const synfig::Color::BlendMethod& x) { blend_method_=x; }
void set_opacity(const synfig::Real& x) { opacity_=x; }
void set_type(Type x) { type_=x; }
-
+
Settings& settings();
const Settings& settings()const;
}; // END of class InputDevice
assert(canvas->is_root());
unset_selection_manager();
-
+
instance_map_[canvas]=this;
} // END of synfigapp::Instance::Instance()
return 0;
while(canvas->is_inline())
canvas=canvas->parent();
-
+
CanvasInterfaceList::iterator iter;
for(iter=canvas_interface_list().begin();iter!=canvas_interface_list().end();iter++)
bool ret;
String old_file_name(get_file_name());
-
+
set_file_name(file_name);
ret=save_canvas(file_name,canvas_);
*/
public:
-
+
/*
-- ** -- P R I V A T E D A T A ---------------------------------------------
*/
sigc::signal<void> signal_filename_changed_;
sigc::signal<void> signal_saved_;
etl::handle<SelectionManager> selection_manager_;
-
+
protected:
Instance(etl::handle<synfig::Canvas>);
void set_selection_manager(const etl::handle<SelectionManager> &sm) { assert(sm); selection_manager_=sm; }
void unset_selection_manager() { selection_manager_=new NullSelectionManager(); }
- const etl::handle<SelectionManager> &get_selection_manager() { return selection_manager_; }
+ const etl::handle<SelectionManager> &get_selection_manager() { return selection_manager_; }
void set_file_name(const synfig::String &name);
public:
-
+
public: // Constructor interfaces
static etl::handle<Instance> create(etl::handle<synfig::Canvas> canvas);
synfigapp_ref_count_.reset();
ref_count_=synfigapp_ref_count_;
-
+
// Add initialization after this point
action_main=new synfigapp::Action::Main();
settings_.construct();
-
+
signal_foreground_color_changed_.construct();
signal_background_color_changed_.construct();
signal_gradient_changed_.construct();
signal_opacity_changed_.construct();
signal_blend_method_changed_.construct();
signal_interpolation_changed_.construct();
-
+
set_foreground_color(Color::black());
set_background_color(Color::white());
set_gradient_default_colors();
if(!synfigapp_ref_count_.unique())
return;
synfigapp_ref_count_.detach();
-
+
// Add deinitialization after this point
- delete action_main;
-
+ delete action_main;
+
selected_input_device_=0;
input_devices_.clear();
-
+
settings_.destruct();
signal_foreground_color_changed_.destruct();
signal_background_color_changed_.destruct();
if(interpolation_!=x)
{
interpolation_=x;
-
+
signal_interpolation_changed();
}
}
if(x!=bline_width_)
{
bline_width_=x;
-
+
if(selected_input_device_)
selected_input_device_->set_bline_width(x);
-
+
signal_bline_width_changed()();
}
}
synfigapp::Main::select_input_device(InputDevice::Handle input_device)
{
assert(input_device);
-
+
synfig::info("Input device changed to \"%s\"",input_device->get_id().c_str());
-
+
selected_input_device_=input_device;
- set_bline_width(input_device->get_bline_width());
+ set_bline_width(input_device->get_bline_width());
set_foreground_color(input_device->get_foreground_color());
- set_opacity(input_device->get_opacity());
- set_blend_method(input_device->get_blend_method());
-
+ set_opacity(input_device->get_opacity());
+ set_blend_method(input_device->get_blend_method());
+
return true;
}
InputDevice::Handle
synfigapp::Main::get_selected_input_device()
{
- return selected_input_device_;
+ return selected_input_device_;
}
void
};
namespace synfigapp {
-
+
/*! \class synfigapp::Main
** \brief \writeme
**
~Main();
const etl::reference_counter& ref_count()const { return ref_count_; }
-
+
static const synfig::Color& get_foreground_color();
static const synfig::Color& get_background_color();
static const synfig::Gradient& get_gradient();
static void set_interpolation(synfig::Waypoint::Interpolation x);
- static void set_bline_width(synfig::Distance x);
+ static void set_bline_width(synfig::Distance x);
static void set_foreground_color(synfig::Color color);
static void set_background_color(synfig::Color color);
static void set_gradient(synfig::Gradient gradient);
static void set_gradient_default_colors();
- static void color_swap();
+ static void color_swap();
static synfig::Color::BlendMethod get_blend_method();
static const synfig::Real& get_opacity();
static sigc::signal<void>& signal_blend_method_changed();
static sigc::signal<void>& signal_opacity_changed();
static sigc::signal<void>& signal_interpolation_changed();
-
+
// Input Device stuff
static InputDevice::Handle add_input_device(const synfig::String id_, InputDevice::Type type_=InputDevice::TYPE_MOUSE);
static InputDevice::Handle find_input_device(const synfig::String id_);
static void set_state(synfig::String state);
static Settings& settings();
-
- // Signal interfaces
+
+ // Signal interfaces
static sigc::signal<void>& signal_foreground_color_changed();
static sigc::signal<void>& signal_background_color_changed();
static sigc::signal<void>& signal_gradient_changed();
//! Returns a list of the currently selected layers.
virtual LayerList get_selected_layers()const=0;
-
+
//! Returns the first layer selected or an empty handle if none are selected.
virtual synfig::Layer::Handle get_selected_layer()const=0;
-
+
//! Sets which layers should be selected
virtual void set_selected_layers(const LayerList &layer_list)=0;
//! Returns a list of the currently selected childrens.
virtual ChildrenList get_selected_children()const=0;
-
+
//! Returns the first children selected or an empty handle if none are selected.
virtual ChildrenList::value_type get_selected_child()const=0;
-
+
//! Sets which childrens should be selected
virtual void set_selected_children(const ChildrenList &children_list)=0;
//! Returns a list of the currently selected layer parameters.
virtual LayerParamList get_selected_layer_parameters()const=0;
-
+
//! Returns the first layer parameter selected or an empty handle if none are selected.
virtual LayerParam get_selected_layer_parameter()const=0;
-
+
//! Sets which layer parameters should be selected
virtual void set_selected_layer_parameters(const LayerParamList &layer_param_list)=0;
if(key.size()>iter->first.size() && String(key.begin(),key.begin()+iter->first.size())==iter->first)
{
synfig::String key_(key.begin()+iter->first.size()+1,key.end());
-
+
// If the domain has it, then we have got a hit
if(iter->second->get_value(key_,value))
return true;
value=simple_value_map.find(key)->second;
return true;
}
-
+
// key not found
return false;
}
if(key.size()>iter->first.size() && String(key.begin(),key.begin()+iter->first.size())==iter->first)
{
synfig::String key_(key.begin()+iter->first.size()+1,key.end());
-
+
return iter->second->set_value(key_,value);
}
}
key_list.push_back(iter->first+'.'+*key_iter);
}
}
-
+
// Get keys from the simple variables
{
ValueBaseMap::const_iterator iter;
// Sort the keys
key_list.sort();
-
+
return key_list;
}
Settings::save_to_file(const synfig::String& filename)const
{
synfig::String tmp_filename(filename+".TMP");
-
+
try
{
std::ofstream file(tmp_filename.c_str());
if(!file)return false;
-
+
KeyList key_list(get_key_list());
-
+
// Save the keys
{
KeyList::const_iterator iter;
file<<*iter<<'='<<get_value(*iter)<<endl;
}
}
-
+
if(!file)
return false;
}catch(...) { return false; }
-
+
#ifdef _WIN32
char old_file[80]="sif.XXXXXXXX";
mktemp(old_file);
- rename(filename.c_str(),old_file);
+ rename(filename.c_str(),old_file);
if(rename(tmp_filename.c_str(),filename.c_str())!=0)
{
rename(old_file,tmp_filename.c_str());
if(rename(tmp_filename.c_str(),filename.c_str())!=0)
return false;
#endif
-
+
return true;
}
continue;
std::string key(line.begin(),equal);
std::string value(equal+1,line.end());
-
+
//synfig::info("Settings::load_from_file(): Trying Key \"%s\" with a value of \"%s\".",key.c_str(),value.c_str());
try{
if(!set_value(key,value))
class Settings
{
public:
-
+
typedef std::list<synfig::String> KeyList;
typedef std::map<synfig::String,synfig::String> ValueBaseMap;
typedef std::map<synfig::String,Settings*> DomainMap;
-
+
private:
ValueBaseMap simple_value_map;
{
ValueBaseTimeInfo vt;
vt.val = v;
-
+
waytracker::iterator i = waypointbiglist.find(vt);
-
+
if(i != waypointbiglist.end())
{
i->waypoints.insert(w);
{
ActiveTimeInfo vt;
vt.val = v;
-
+
acttracker::iterator i = actpointbiglist.find(vt);
-
+
if(i != actpointbiglist.end())
{
i->activepoints.insert(a);
}
//recursion functions
-void synfigapp::recurse_canvas(synfig::Canvas::Handle h, const std::set<Time> &tlist,
+void synfigapp::recurse_canvas(synfig::Canvas::Handle h, const std::set<Time> &tlist,
timepoints_ref &vals)
{
-
+
//synfig::info("Canvas...\n Recurse through layers");
// iterate through the layers
}
}
-void synfigapp::recurse_layer(synfig::Layer::Handle h, const std::set<Time> &tlist,
+void synfigapp::recurse_layer(synfig::Layer::Handle h, const std::set<Time> &tlist,
timepoints_ref &vals)
{
// iterate through the layers
//check for special case of paste canvas
etl::handle<synfig::Layer_PasteCanvas> p = etl::handle<synfig::Layer_PasteCanvas>::cast_dynamic(h);
-
+
//synfig::info("Layer...");
-
+
if(p)
{
//synfig::info("We are a paste canvas so go into that");
//recurse into the canvas
const synfig::Node::time_set &tset = p->get_sub_canvas()->get_times();
-
+
if(check_intersect(tset.begin(),tset.end(),tlist.begin(),tlist.end()))
{
//we have to offset the times so it won't wreck havoc if the canvas is imported more than once...
// and so we get correct results when offsets are present
- std::set<Time> tlistoff;
+ std::set<Time> tlistoff;
std::set<Time>::iterator i = tlist.begin(), end = tlist.end();
for(; i != end; ++i)
{
tlistoff.insert(*i - p->get_time_offset());
}
-
+
recurse_canvas(p->get_sub_canvas(),tlist,vals);
}
}
for(; i != end; ++i)
{
const synfig::Node::time_set &tset = i->second->get_times();
-
+
if(check_intersect(tset.begin(),tset.end(),tlist.begin(),tlist.end()))
{
recurse_valuedesc(ValueDesc(h,i->first),tlist,vals);
static bool sorted(IT i,IT end, const CMP &cmp = CMP())
{
if(i == end) return true;
-
+
for(IT last = i++; i != end; last = i++)
{
if(!cmp(*last,*i))
return false;
}
-
+
return true;
}
-void synfigapp::recurse_valuedesc(synfigapp::ValueDesc h, const std::set<Time> &tlist,
+void synfigapp::recurse_valuedesc(synfigapp::ValueDesc h, const std::set<Time> &tlist,
timepoints_ref &vals)
{
//special cases for Animated, DynamicList, and Linkable
-
+
//synfig::info("ValueBasenode... %p, %s", h.get_value_node().get(),typeid(*h.get_value_node()).name());
-
-
+
+
//animated case
{
synfig::ValueNode_Animated::Handle p = synfig::ValueNode_Animated::Handle::cast_dynamic(h.get_value_node());
-
+
if(p)
{
//loop through and determine which waypoint we will need to reference
const synfig::WaypointList &w = p->waypoint_list();
-
+
synfig::WaypointList::const_iterator i = w.begin(),
end = w.end();
-
+
std::set<Time>::const_iterator j = tlist.begin(),
jend = tlist.end();
- for(; i != end && j != jend;)
+ for(; i != end && j != jend;)
{
//synfig::info("tpair t(%.3f) = %.3f", (float)*j, (float)(i->get_time()));
-
+
if(j->is_equal(i->get_time()))
{
vals.insert(p,*i);
++i,++j;
- }else if(*i < *j)
+ }else if(*i < *j)
{
++i;
}else ++j;
return;
}
}
-
+
//parent dynamiclist case - just for active points for that object...
if(h.parent_is_value_node())
{
- synfig::ValueNode_DynamicList::Handle p = synfig::ValueNode_DynamicList::Handle::cast_dynamic(h.get_parent_value_node());
-
+ synfig::ValueNode_DynamicList::Handle p = synfig::ValueNode_DynamicList::Handle::cast_dynamic(h.get_parent_value_node());
+
if(p)
{
int index = h.get_index();
-
+
//check all the active points in each list...
const synfig::ActivepointList &a = p->list[index].timing_info;
-
+
//synfig::info("Our parent = dynamic list, searching in %d activepts",a.size());
-
+
std::set<Time>::const_iterator i = tlist.begin(),
end = tlist.end();
-
+
synfig::ActivepointList::const_iterator j = a.begin(),
jend = a.end();
-
+
for(; j != jend && i != end;)
{
double it = *i;
double jt = j->get_time();
double diff = (double)(it - jt);
-
- //synfig::info("\ttpair match(%.4lg) - %.4lg (diff = %lg",it,jt,diff);
-
+
+ //synfig::info("\ttpair match(%.4lg) - %.4lg (diff = %lg",it,jt,diff);
+
//
if(abs(diff) < (double)Time::epsilon())
{
//synfig::info("\tActivepoint to add being referenced (%x,%s,%.4lg)",
// (int)j->get_uid(),j->state?"true":"false", (double)j->time);
vals.insert(ValueDesc(p,index),*j);
- ++i,++j;
+ ++i,++j;
}else if(it < jt)
{
++i;
//synfig::info("\tIncrementing time");
}
- else
+ else
{
++j;
//synfig::info("\tIncrementing actpt");
}
}
}
-
+
//dynamiclist case - we must still make sure that we read from the list entries the time values
// because just the linked valuenodes will not do that
{
synfig::ValueNode_DynamicList::Handle p = synfig::ValueNode_DynamicList::Handle::cast_dynamic(h.get_value_node());
-
+
if(p)
{
//synfig::info("Process dynamic list valuenode");
int index = 0;
-
- std::vector<synfig::ValueNode_DynamicList::ListEntry>::const_iterator
+
+ std::vector<synfig::ValueNode_DynamicList::ListEntry>::const_iterator
i = p->list.begin(),
end = p->list.end();
-
+
for(; i != end; ++i, ++index)
{
const Node::time_set &tset = i->get_times();
-
+
if(check_intersect(tset.begin(),tset.end(),tlist.begin(),tlist.end()))
{
recurse_valuedesc(ValueDesc(p,index),tlist,vals);
return;
}
}
-
+
//the linkable case...
{
etl::handle<synfig::LinkableValueNode> p = etl::handle<synfig::LinkableValueNode>::cast_dynamic(h.get_value_node());
-
+
if(p)
{
//synfig::info("Process Linkable ValueBasenode");
int i = 0, size = p->link_count();
-
+
for(; i < size; ++i)
{
ValueNode::Handle v = p->get_link(i);
const Node::time_set &tset = v->get_times();
-
+
if(check_intersect(tset.begin(),tset.end(),tlist.begin(),tlist.end()))
{
recurse_valuedesc(ValueDesc(p,i),tlist,vals);
{
synfig::ValueNode_Animated::Handle val;
mutable std::set<synfig::Waypoint> waypoints;
-
+
bool operator<(const ValueBaseTimeInfo &rhs) const
{
return val < rhs.val;
bool operator()(const synfig::Activepoint &lhs, const synfig::Activepoint &rhs) const
{
return lhs.time < rhs.time;
- }
+ }
};
-
+
synfigapp::ValueDesc val;
-
+
typedef std::set<synfig::Activepoint,actcmp> set;
-
+
mutable set activepoints;
-
+
bool operator<(const ActiveTimeInfo &rhs) const
{
- return val.get_parent_value_node() == rhs.val.get_parent_value_node() ?
- val.get_index() < rhs.val.get_index() :
+ return val.get_parent_value_node() == rhs.val.get_parent_value_node() ?
+ val.get_index() < rhs.val.get_index() :
val.get_parent_value_node() < rhs.val.get_parent_value_node();
}
};
struct timepoints_ref
{
- typedef std::set<ValueBaseTimeInfo> waytracker;
+ typedef std::set<ValueBaseTimeInfo> waytracker;
typedef std::set<ActiveTimeInfo> acttracker;
-
+
waytracker waypointbiglist;
- acttracker actpointbiglist;
-
- void insert(synfig::ValueNode_Animated::Handle v, synfig::Waypoint w);
+ acttracker actpointbiglist;
+
+ void insert(synfig::ValueNode_Animated::Handle v, synfig::Waypoint w);
void insert(synfigapp::ValueDesc v, synfig::Activepoint a);
};
template < typename I1, typename I2 >
bool check_intersect(I1 b1, I1 end1, I2 b2, I2 end2)
{
- if(b1 == end1 || b2 == end2)
+ if(b1 == end1 || b2 == end2)
return false;
-
+
for(; b1 != end1 && b2 != end2;)
{
if(*b1 < *b2) ++b1;
return false;
}
-//pointer kind of a hack, gets the accurate times from a value desc
+//pointer kind of a hack, gets the accurate times from a value desc
// (deals with dynamic list member correctly... i.e. gathers activepoints)
const synfig::Node::time_set *get_times_from_vdesc(const synfigapp::ValueDesc &v);
//get's the closest time inside the set
-bool get_closest_time(const synfig::Node::time_set &tset, const synfig::Time &t,
+bool get_closest_time(const synfig::Node::time_set &tset, const synfig::Time &t,
const synfig::Time &range, synfig::Time &out);
//recursion functions based on time restrictions (can be expanded later)...
//builds a list of relevant waypoints and activepoints inside the timepoints_ref structure
void recurse_valuedesc(synfigapp::ValueDesc valdesc, const std::set<synfig::Time> &tlist,
timepoints_ref &vals);
-void recurse_layer(synfig::Layer::Handle layer, const std::set<synfig::Time> &tlist,
+void recurse_layer(synfig::Layer::Handle layer, const std::set<synfig::Time> &tlist,
timepoints_ref &vals);
-void recurse_canvas(synfig::Canvas::Handle canvas, const std::set<synfig::Time> &tlist,
+void recurse_canvas(synfig::Canvas::Handle canvas, const std::set<synfig::Time> &tlist,
timepoints_ref &vals);
return RESPONSE_OK;
}
}
-
+
bool
ConsoleUIInterface::task(const std::string &task)
{
virtual Response yes_no(const std::string &title, const std::string &message,Response dflt=RESPONSE_YES)=0;
virtual Response yes_no_cancel(const std::string &title, const std::string &message,Response dflt=RESPONSE_YES)=0;
virtual Response ok_cancel(const std::string &title, const std::string &message,Response dflt=RESPONSE_OK)=0;
-};
+};
class DefaultUIInterface : public UIInterface
{
{ return dflt; }
Response ok_cancel(const std::string &title, const std::string &message,Response dflt)
{ return dflt; }
-
+
bool task(const std::string &task)
{ return true; }
bool error(const std::string &task)
{ return true; }
bool amount_complete(int current, int total)
{ return true; }
-};
+};
class ConfidentUIInterface : public UIInterface
{
{ return RESPONSE_YES; }
Response ok_cancel(const std::string &title, const std::string &message,Response dflt)
{ return RESPONSE_OK; }
-
+
bool task(const std::string &task)
{ return true; }
bool error(const std::string &task)
{ return true; }
bool amount_complete(int current, int total)
{ return true; }
-};
+};
class ConsoleUIInterface : public UIInterface
{
Response yes_no(const std::string &title, const std::string &message,Response dflt);
Response yes_no_cancel(const std::string &title, const std::string &message,Response dflt);
Response ok_cancel(const std::string &title, const std::string &message,Response dflt);
-
+
bool task(const std::string &task);
bool error(const std::string &task);
bool warning(const std::string &task);
bool amount_complete(int current, int total);
-};
+};
}; // END of namespace synfigapp
// Info for Layer parent
synfig::Layer::Handle layer;
synfig::String name;
-
+
// Info for ValueNode parent
synfig::ValueNode::Handle parent_value_node;
int index;
// Info for exported ValueNode
synfig::Canvas::Handle canvas;
-
+
public:
bool operator==(const ValueDesc &rhs)const
{
return !operator==(rhs);
}
-
+
ValueDesc(synfig::Layer::Handle layer,const synfig::String& param_name):
layer(layer),
name(param_name) { }
bool parent_is_linkable_value_node()const { return parent_is_value_node() && index>=0; }
bool parent_is_value_node_const()const { return parent_is_value_node() && index==-1; }
bool parent_is_canvas()const { return (bool)canvas; }
-
+
bool is_value_node()const { return parent_is_value_node() || parent_is_canvas() || (parent_is_layer_param() && (bool)layer->dynamic_param_list().count(name)); }
bool is_const()const { return (parent_is_layer_param() && !layer->dynamic_param_list().count(name)) || parent_is_value_node_const(); }
-
+
synfig::Layer::Handle get_layer()const { assert(parent_is_layer_param()); return layer; }
const synfig::String& get_param_name()const { assert(parent_is_layer_param()); return name; }
-
+
synfig::ValueNode::Handle get_parent_value_node()const { assert(parent_is_value_node()); return parent_value_node; }
int get_index()const { assert(parent_is_linkable_value_node()); return index; }
-
+
const synfig::String& get_value_node_id()const { assert(parent_is_canvas()); return name; }
synfig::Canvas::Handle get_canvas()const
return parent_value_node->get_root_canvas();
return 0;
}
-
+
synfig::ValueNode::Handle
get_value_node()const
{
if(parent_is_layer_param() && layer)
return layer->get_param(name);
return synfig::ValueBase();
- }
+ }
synfig::ValueBase::Type
get_value_type()const
return value_node->get_type();
return get_value().get_type();
}
-
+
bool
is_exported()const
{
/* === C L A S S E S & S T R U C T S ======================================= */
namespace studio {
-
+
}; // END of namespace studio
/* === E N D =============================================================== */