synfigapp::Settings& settings;
- sigc::connection keypress_connect;
- sigc::connection keyrelease_connect;
-
etl::handle<DuckDrag_Combo> duck_dragger_;
Gtk::Table options_table;
- Gtk::CheckButton checkbutton_rotate;
- Gtk::CheckButton checkbutton_scale;
- Gtk::CheckButton checkbutton_constrain;
-
public:
- bool get_rotate_flag()const { return checkbutton_rotate.get_active(); }
- void set_rotate_flag(bool x) { checkbutton_rotate.set_active(x); refresh_rotate_flag(); }
- void refresh_rotate_flag() { if(duck_dragger_)duck_dragger_->rotate=get_rotate_flag(); }
+ bool get_rotate_flag()const { if(duck_dragger_) return duck_dragger_->rotate; else return false; }
+ void set_rotate_flag(bool x) { if(duck_dragger_ && x!=duck_dragger_->rotate) duck_dragger_->rotate=x; }
- bool get_scale_flag()const { return checkbutton_scale.get_active(); }
- void set_scale_flag(bool x) { checkbutton_scale.set_active(x); refresh_scale_flag(); }
- void refresh_scale_flag() { if(duck_dragger_)duck_dragger_->scale=get_scale_flag(); }
+ bool get_scale_flag()const { if(duck_dragger_) return duck_dragger_->scale; else return false; }
+ void set_scale_flag(bool x) { if(duck_dragger_ && x!=duck_dragger_->scale) duck_dragger_->scale=x; }
+
+ bool get_constrain_flag()const { if(duck_dragger_) return duck_dragger_->constrain; else return false; }
+ void set_constrain_flag(bool x) { if(duck_dragger_ && x!=duck_dragger_->constrain) duck_dragger_->constrain=x; }
- bool get_constrain_flag()const { return checkbutton_constrain.get_active(); }
- void set_constrain_flag(bool x) { checkbutton_constrain.set_active(x); refresh_constrain_flag(); }
- void refresh_constrain_flag() { if(duck_dragger_)duck_dragger_->constrain=get_constrain_flag(); }
void refresh_cursor();
StateNormal_Context(CanvasView* canvas_view);
void load_settings();
void save_settings();
- bool key_pressed(GdkEventKey *event);
- bool key_released(GdkEventKey *event);
-
Smach::event_result event_stop_handler(const Smach::event& x);
Smach::event_result event_refresh_handler(const Smach::event& x);
Smach::event_result event_refresh_ducks_handler(const Smach::event& x);
Smach::event_result event_redo_handler(const Smach::event& x);
Smach::event_result event_mouse_button_down_handler(const Smach::event& x);
Smach::event_result event_multiple_ducks_clicked_handler(const Smach::event& x);
+ Smach::event_result event_mouse_motion_handler(const Smach::event& x);
Smach::event_result event_refresh_tool_options(const Smach::event& x);
void refresh_tool_options();
Smach::event_result event_layer_click(const Smach::event& x);
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_MOUSE_MOTION, &StateNormal_Context::event_mouse_motion_handler));
+ insert(event_def(EVENT_WORKAREA_MOUSE_BUTTON_DRAG, &StateNormal_Context::event_mouse_motion_handler));
insert(event_def(EVENT_WORKAREA_LAYER_CLICKED,&StateNormal_Context::event_layer_click));
}
StateNormal_Context::StateNormal_Context(CanvasView* canvas_view):
canvas_view_(canvas_view),
settings(synfigapp::Main::get_selected_input_device()->settings()),
- duck_dragger_(new DuckDrag_Combo()),
- checkbutton_rotate(_("Rotate (Ctrl)")),
- checkbutton_scale(_("Scale (Alt)")),
- checkbutton_constrain(_("Constrain (Shift)"))
+ duck_dragger_(new DuckDrag_Combo())
{
duck_dragger_->canvas_view_=get_canvas_view();
// Set up the tool options dialog
options_table.attach(*manage(new Gtk::Label(_("Transform Tool"))), 0, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- options_table.attach(checkbutton_rotate, 0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- options_table.attach(checkbutton_scale, 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
- options_table.attach(checkbutton_constrain, 0, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-
- checkbutton_rotate.signal_toggled().connect(sigc::mem_fun(*this,&StateNormal_Context::refresh_rotate_flag));
- checkbutton_scale.signal_toggled().connect(sigc::mem_fun(*this,&StateNormal_Context::refresh_scale_flag));
- checkbutton_constrain.signal_toggled().connect(sigc::mem_fun(*this,&StateNormal_Context::refresh_constrain_flag));
-
+ options_table.attach(*manage(new Gtk::Label(_("Ctrl to rotate"), Gtk::ALIGN_LEFT)), 0, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(*manage(new Gtk::Label(_("Alt to scale"), Gtk::ALIGN_LEFT)), 0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
+ options_table.attach(*manage(new Gtk::Label(_("Shift to constrain"), Gtk::ALIGN_LEFT)), 0, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
options_table.show_all();
refresh_tool_options();
get_work_area()->set_allow_layer_clicks(true);
get_work_area()->set_duck_dragger(duck_dragger_);
- keypress_connect=get_work_area()->signal_key_press_event().connect(sigc::mem_fun(*this,&StateNormal_Context::key_pressed),false);
- keyrelease_connect=get_work_area()->signal_key_release_event().connect(sigc::mem_fun(*this,&StateNormal_Context::key_released),false);
-
//these will segfault
// get_work_area()->set_cursor(Gdk::CROSSHAIR);
// get_work_area()->reset_cursor();
App::toolbox->refresh();
load_settings();
- refresh_scale_flag();
-}
-
-bool
-StateNormal_Context::key_pressed(GdkEventKey *event)
-{
- switch(event->keyval)
- {
- case GDK_Control_L:
- case GDK_Control_R:
- set_rotate_flag(true);
- break;
- case GDK_Alt_L:
- case GDK_Alt_R:
- set_scale_flag(true);
- break;
- case GDK_Shift_L:
- case GDK_Shift_R:
- set_constrain_flag(true);
- break;
- default:
- break;
- }
- refresh_cursor();
- return false; //Pass on the event to other handlers, just in case
-}
-
-bool
-StateNormal_Context::key_released(GdkEventKey *event)
-{
- switch(event->keyval)
- {
- case GDK_Control_L:
- case GDK_Control_R:
- set_rotate_flag(false);
- break;
- case GDK_Alt_L:
- case GDK_Alt_R:
- set_scale_flag(false);
- break;
- case GDK_Shift_L:
- case GDK_Shift_R:
- set_constrain_flag(false);
- break;
- default:
- break;
- }
- refresh_cursor();
- return false; //Pass on the event to other handlers
}
void
get_work_area()->clear_duck_dragger();
get_work_area()->reset_cursor();
- keypress_connect.disconnect();
- keyrelease_connect.disconnect();
-
App::dialog_tool_options->clear();
App::toolbox->refresh();
}
Smach::event_result
+StateNormal_Context::event_mouse_motion_handler(const Smach::event& x)
+{
+ // synfig::info("STATE NORMAL: Received mouse button down Event");
+
+ const EventMouse& event(*reinterpret_cast<const EventMouse*>(&x));
+
+ set_rotate_flag(event.modifier&GDK_CONTROL_MASK);
+ set_scale_flag(event.modifier&GDK_MOD1_MASK);
+ set_constrain_flag(event.modifier&GDK_SHIFT_MASK);
+
+ return Smach::RESULT_OK;
+}
+
+Smach::event_result
StateNormal_Context::event_layer_click(const Smach::event& x)
{
const EventLayerClick& event(*reinterpret_cast<const EventLayerClick*>(&x));