diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index f3195daec2..e892fbcaa1 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -500,6 +500,7 @@ Editor::Editor () _cursors = new MouseCursors; _cursors->set_cursor_set (ARDOUR_UI::config()->get_icon_set()); + cerr << "Set cursor set to " << ARDOUR_UI::config()->get_icon_set() << endl; ArdourCanvas::GtkCanvas* time_pad = manage (new ArdourCanvas::GtkCanvas ()); @@ -5428,6 +5429,9 @@ void Editor::ui_parameter_changed (string parameter) { if (parameter == "icon-set") { + while (!_cursor_stack.empty()) { + _cursor_stack.pop(); + } _cursors->set_cursor_set (ARDOUR_UI::config()->get_icon_set()); } } diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index a7a7224e61..9e78181dcf 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -422,6 +423,10 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD Gdk::Cursor* get_canvas_cursor () const { return current_canvas_cursor; } void set_canvas_cursor (Gdk::Cursor*, bool save=false); + + void push_canvas_cursor (Gdk::Cursor*); + void pop_canvas_cursor (); + void set_current_trimmable (boost::shared_ptr); void set_current_movable (boost::shared_ptr); @@ -696,6 +701,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD Gtk::VBox global_vpacker; Gtk::VBox vpacker; + std::stack _cursor_stack; Gdk::Cursor* current_canvas_cursor; Gdk::Cursor* which_grabber_cursor (); void set_canvas_cursor (); diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc index f962cb4ff7..12f119c711 100644 --- a/gtk2_ardour/editor_canvas.cc +++ b/gtk2_ardour/editor_canvas.cc @@ -904,6 +904,25 @@ Editor::set_canvas_cursor (Gdk::Cursor* cursor, bool save) } } +void +Editor::push_canvas_cursor (Gdk::Cursor* cursor) +{ + if (cursor) { + _cursor_stack.push (cursor); + set_canvas_cursor (cursor, false); + } +} + +void +Editor::pop_canvas_cursor () +{ + if (!_cursor_stack.empty()) { + Gdk::Cursor* cursor = _cursor_stack.top (); + _cursor_stack.pop (); + set_canvas_cursor (cursor, false); + } +} + bool Editor::track_canvas_key_press (GdkEventKey*) { diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 10a4a88c77..f6f05925de 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -281,11 +281,10 @@ Drag::start_grab (GdkEvent* event, Gdk::Cursor *cursor) if (cursor == 0) { _item->grab (); - } else { /* CAIROCANVAS need a variant here that passes *cursor */ _item->grab (); - + _editor->push_canvas_cursor (cursor); } if (_editor->session() && _editor->session()->transport_rolling()) { @@ -322,6 +321,7 @@ Drag::end_grab (GdkEvent* event) finished (event, _move_threshold_passed); _editor->verbose_cursor()->hide (); + _editor->pop_canvas_cursor (); return _move_threshold_passed; } @@ -1932,6 +1932,8 @@ TrimDrag::start_grab (GdkEvent* event, Gdk::Cursor*) framepos_t const pf = adjusted_current_frame (event); + cerr << "Button state = " << hex << event->button.state << dec << endl; + if (Keyboard::modifier_state_equals (event->button.state, Keyboard::PrimaryModifier)) { /* Move the contents of the region around without changing the region bounds */ _operation = ContentsTrim; @@ -1941,11 +1943,22 @@ TrimDrag::start_grab (GdkEvent* event, Gdk::Cursor*) if (pf < (region_start + region_length/2)) { /* closer to front */ _operation = StartTrim; - Drag::start_grab (event, _editor->cursors()->left_side_trim); + + if (Keyboard::modifier_state_equals (event->button.state, Keyboard::TertiaryModifier)) { + cerr << "start anchored leftdrag\n"; + Drag::start_grab (event, _editor->cursors()->anchored_left_side_trim); + } else { + Drag::start_grab (event, _editor->cursors()->left_side_trim); + } } else { /* closer to end */ _operation = EndTrim; - Drag::start_grab (event, _editor->cursors()->right_side_trim); + if (Keyboard::modifier_state_equals (event->button.state, Keyboard::TertiaryModifier)) { + Drag::start_grab (event, _editor->cursors()->anchored_right_side_trim); + cerr << "start anchored right drag\n"; + } else { + Drag::start_grab (event, _editor->cursors()->right_side_trim); + } } } @@ -1984,6 +1997,8 @@ TrimDrag::motion (GdkEvent* event, bool first_move) pair >::iterator,bool> insert_result; frameoffset_t frame_delta = 0; + cerr << "trim drag @ " << this << " motion\n"; + if (tv && tv->is_track()) { speed = tv->track()->speed(); } diff --git a/gtk2_ardour/mouse_cursors.cc b/gtk2_ardour/mouse_cursors.cc index 56a2eafac8..0aab542347 100644 --- a/gtk2_ardour/mouse_cursors.cc +++ b/gtk2_ardour/mouse_cursors.cc @@ -26,7 +26,9 @@ MouseCursors::MouseCursors () : cross_hair (0) , trimmer (0) , right_side_trim (0) + , anchored_right_side_trim (0) , left_side_trim (0) + , anchored_left_side_trim (0) , right_side_trim_left_only (0) , left_side_trim_right_only (0) , fade_in (0) @@ -68,7 +70,9 @@ MouseCursors::drop_all () delete cross_hair; cross_hair = 0; delete trimmer; trimmer = 0; delete right_side_trim; right_side_trim = 0; + delete anchored_right_side_trim; anchored_right_side_trim = 0; delete left_side_trim; left_side_trim = 0; + delete anchored_left_side_trim; anchored_left_side_trim = 0; delete right_side_trim_left_only; right_side_trim_left_only = 0; delete left_side_trim_right_only; left_side_trim_right_only = 0; delete fade_in; fade_in = 0; @@ -174,11 +178,21 @@ MouseCursors::set_cursor_set (const std::string& name) left_side_trim = new Cursor (Display::get_default(), p, 5, 11); } + { + RefPtr p (::get_icon ("anchored_trim_left_cursor", _cursor_set)); + anchored_left_side_trim = new Cursor (Display::get_default(), p, 5, 11); + } + { RefPtr p (::get_icon ("trim_right_cursor", _cursor_set)); right_side_trim = new Cursor (Display::get_default(), p, 23, 11); } + { + RefPtr p (::get_icon ("anchored_trim_right_cursor", _cursor_set)); + anchored_right_side_trim = new Cursor (Display::get_default(), p, 23, 11); + } + { RefPtr p (::get_icon ("trim_left_cursor_right_only", _cursor_set)); left_side_trim_right_only = new Cursor (Display::get_default(), p, 5, 11); diff --git a/gtk2_ardour/mouse_cursors.h b/gtk2_ardour/mouse_cursors.h index a6b54b62a5..30eca6acb8 100644 --- a/gtk2_ardour/mouse_cursors.h +++ b/gtk2_ardour/mouse_cursors.h @@ -36,7 +36,9 @@ public: Gdk::Cursor* cross_hair; Gdk::Cursor* trimmer; Gdk::Cursor* right_side_trim; + Gdk::Cursor* anchored_right_side_trim; Gdk::Cursor* left_side_trim; + Gdk::Cursor* anchored_left_side_trim; Gdk::Cursor* right_side_trim_left_only; Gdk::Cursor* left_side_trim_right_only; Gdk::Cursor* fade_in; diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc index 8ded1a2f81..facbe92db5 100644 --- a/gtk2_ardour/utils.cc +++ b/gtk2_ardour/utils.cc @@ -698,10 +698,12 @@ get_icon_path (const char* cname, string icon_set) name += X_(".png"); Searchpath spath(ARDOUR::ardour_data_search_path()); - + if (!icon_set.empty() && icon_set != _("default")) { - string subdir = Glib::build_filename ("icons", icon_set); - spath.add_subdirectory_to_paths (subdir); + + /* add "icons/icon_set" but .. not allowed to add both of these at once */ + spath.add_subdirectory_to_paths ("icons"); + spath.add_subdirectory_to_paths (icon_set); find_file_in_search_path (spath, name, data_file_path); }