do most of the work related to adding new anchored trim cursors (but debugging/analys...
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 13 Jun 2014 21:15:23 +0000 (17:15 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 13 Jun 2014 22:43:53 +0000 (18:43 -0400)
gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_canvas.cc
gtk2_ardour/editor_drag.cc
gtk2_ardour/mouse_cursors.cc
gtk2_ardour/mouse_cursors.h
gtk2_ardour/utils.cc

index f3195daec271359348670b7499687ff7a565ddc4..e892fbcaa19d9ca521837e7cd981926cc6fd8022 100644 (file)
@@ -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());
        }
 }
index a7a7224e61e437a93a970a1aedfbcdb89cc0323c..9e78181dcf5b1973e6ab68326e747f5cc86c0202 100644 (file)
@@ -23,6 +23,7 @@
 #include <list>
 #include <map>
 #include <set>
+#include <stack>
 #include <string>
 #include <sys/time.h>
 #include <cmath>
@@ -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<ARDOUR::Trimmable>);
        void set_current_movable (boost::shared_ptr<ARDOUR::Movable>);
 
@@ -696,6 +701,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        Gtk::VBox           global_vpacker;
        Gtk::VBox           vpacker;
 
+       std::stack<Gdk::Cursor*> _cursor_stack;
        Gdk::Cursor*          current_canvas_cursor;
        Gdk::Cursor* which_grabber_cursor ();
        void set_canvas_cursor ();
index f962cb4ff75975c38ae745275558f84a6be6658d..12f119c71170beac9702ef6304f1545f38d91a07 100644 (file)
@@ -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*)
 {
index 10a4a88c77641e5a0356f37721f4ac24109176b2..f6f05925deab0c4394274cb3dfd90b9abf4f5566 100644 (file)
@@ -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<set<boost::shared_ptr<Playlist> >::iterator,bool> insert_result;
        frameoffset_t frame_delta = 0;
 
+       cerr << "trim drag @ " << this << " motion\n";
+
        if (tv && tv->is_track()) {
                speed = tv->track()->speed();
        }
index 56a2eafac80cabafd976fb6560d9af88af1b1028..0aab5423472d51c80ea36745ff6c50a4ac214285 100644 (file)
@@ -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<Pixbuf> p (::get_icon ("anchored_trim_left_cursor", _cursor_set));
+               anchored_left_side_trim = new Cursor (Display::get_default(), p, 5, 11);
+       }
+
        {
                RefPtr<Pixbuf> p (::get_icon ("trim_right_cursor", _cursor_set));
                right_side_trim = new Cursor (Display::get_default(), p, 23, 11);
        }
 
+       {
+               RefPtr<Pixbuf> p (::get_icon ("anchored_trim_right_cursor", _cursor_set));
+               anchored_right_side_trim = new Cursor (Display::get_default(), p, 23, 11);
+       }
+
        {
                RefPtr<Pixbuf> p (::get_icon ("trim_left_cursor_right_only", _cursor_set));
                left_side_trim_right_only = new Cursor (Display::get_default(), p, 5, 11);
index a6b54b62a57572b11d4f972ff742dbea2b5c233a..30eca6acb87ada57e3fc5a571cd235d2139f1e7a 100644 (file)
@@ -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;
index 8ded1a2f8177c962afc8c7b774f9243f6142e898..facbe92db53990a4d0139dd544a2150c70cc7c7f 100644 (file)
@@ -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);
        }