Updating zoom mouse cursor on modifier press. Fixes #274.
authorCarl Hetherington <carl@carlh.net>
Tue, 21 Sep 2010 14:22:13 +0000 (14:22 +0000)
committerCarl Hetherington <carl@carlh.net>
Tue, 21 Sep 2010 14:22:13 +0000 (14:22 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@7820 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/editor_canvas.cc
gtk2_ardour/editor_canvas_events.cc
gtk2_ardour/editor_drag.cc
gtk2_ardour/editor_drag.h
gtk2_ardour/editor_mouse.cc
gtk2_ardour/editor_xpms

index 4d3ecb80c8926d21e0f9a4142ee769f92f525c33..65130dc6de12e136f849359e93558cfe4e21c3f5 100644 (file)
@@ -220,7 +220,8 @@ Gdk::Cursor* Editor::fade_out_cursor = 0;
 Gdk::Cursor* Editor::grabber_cursor = 0;
 Gdk::Cursor* Editor::grabber_note_cursor = 0;
 Gdk::Cursor* Editor::grabber_edit_point_cursor = 0;
-Gdk::Cursor* Editor::zoom_cursor = 0;
+Gdk::Cursor* Editor::zoom_in_cursor = 0;
+Gdk::Cursor* Editor::zoom_out_cursor = 0;
 Gdk::Cursor* Editor::time_fx_cursor = 0;
 Gdk::Cursor* Editor::fader_cursor = 0;
 Gdk::Cursor* Editor::speaker_cursor = 0;
@@ -1195,16 +1196,16 @@ Editor::build_cursors ()
 {
        using namespace Gdk;
 
-       Gdk::Color mbg ("#000000" ); /* Black */
-       Gdk::Color mfg ("#0000ff" ); /* Blue. */
-
        {
-               RefPtr<Bitmap> source, mask;
-               source = Bitmap::create (mag_bits, mag_width, mag_height);
-               mask = Bitmap::create (magmask_bits, mag_width, mag_height);
-               zoom_cursor = new Gdk::Cursor (source, mask, mfg, mbg, mag_x_hot, mag_y_hot);
+               Glib::RefPtr<Gdk::Pixbuf> zoom_in_cursor_pixbuf (::get_icon ("zoom_in_cursor"));
+               zoom_in_cursor = new Gdk::Cursor (Gdk::Display::get_default(), zoom_in_cursor_pixbuf, 5, 5);
        }
 
+       {
+               Glib::RefPtr<Gdk::Pixbuf> zoom_out_cursor_pixbuf (::get_icon ("zoom_out_cursor"));
+               zoom_out_cursor = new Gdk::Cursor (Gdk::Display::get_default(), zoom_out_cursor_pixbuf, 5, 5);
+       }
+       
        Gdk::Color fbg ("#ffffff" );
        Gdk::Color ffg  ("#000000" );
 
index 9e5e065ecd9be491d31760e9262f2d6e730b3f3b..01bc7a09e7238548bf8ff4faf0a969e2c171b53f 100644 (file)
@@ -462,7 +462,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        static Gdk::Cursor* grabber_cursor;
        static Gdk::Cursor* grabber_note_cursor;
        static Gdk::Cursor* grabber_edit_point_cursor;
-       static Gdk::Cursor* zoom_cursor;
+       static Gdk::Cursor* zoom_in_cursor;
+       static Gdk::Cursor* zoom_out_cursor;
        static Gdk::Cursor* time_fx_cursor;
        static Gdk::Cursor* fader_cursor;
        static Gdk::Cursor* speaker_cursor;
@@ -1408,6 +1409,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
        void track_canvas_allocate (Gtk::Allocation alloc);
        bool track_canvas_size_allocated ();
        bool track_canvas_drag_motion (Glib::RefPtr<Gdk::DragContext> const &, int, int, guint);
+       bool track_canvas_key_press (GdkEventKey *);
+       bool track_canvas_key_release (GdkEventKey *);
 
        void set_playhead_cursor ();
 
index 5989cb7c926a8cdd20e7bb768fb4350189bd32f7..705e7efa3bcd08f7352c6a79d9139af4911cf5c5 100644 (file)
@@ -46,6 +46,7 @@
 #include "editor_group_tabs.h"
 #include "editor_routes.h"
 #include "editor_summary.h"
+#include "keyboard.h"
 
 #include "i18n.h"
 
@@ -282,9 +283,11 @@ Editor::initialize_canvas ()
        track_canvas->signal_button_press_event().connect (sigc::mem_fun (*this, &Editor::track_canvas_button_press_event));
        track_canvas->signal_button_release_event().connect (sigc::mem_fun (*this, &Editor::track_canvas_button_release_event));
        track_canvas->signal_drag_motion().connect (sigc::mem_fun (*this, &Editor::track_canvas_drag_motion));
+       track_canvas->signal_key_press_event().connect (sigc::mem_fun (*this, &Editor::track_canvas_key_press));
+       track_canvas->signal_key_release_event().connect (sigc::mem_fun (*this, &Editor::track_canvas_key_release));
 
        track_canvas->set_name ("EditorMainCanvas");
-       track_canvas->add_events (Gdk::POINTER_MOTION_HINT_MASK|Gdk::SCROLL_MASK);
+       track_canvas->add_events (Gdk::POINTER_MOTION_HINT_MASK | Gdk::SCROLL_MASK | Gdk::KEY_PRESS_MASK | Gdk::KEY_RELEASE_MASK);
        track_canvas->signal_leave_notify_event().connect (sigc::mem_fun(*this, &Editor::left_track_canvas));
        track_canvas->signal_enter_notify_event().connect (sigc::mem_fun(*this, &Editor::entered_track_canvas));
        track_canvas->set_flags (CAN_FOCUS);
@@ -914,3 +917,24 @@ Editor::horizontal_position () const
 {
        return frame_to_unit (leftmost_frame);
 }
+
+bool
+Editor::track_canvas_key_press (GdkEventKey* event)
+{
+       /* XXX: event does not report the modifier key pressed down, AFAICS, so use the Keyboard object instead */
+       if (mouse_mode == Editing::MouseZoom && Keyboard::the_keyboard().key_is_down (GDK_Control_L)) {
+               track_canvas->get_window()->set_cursor (*zoom_out_cursor);
+       }
+
+       return false;
+}
+
+bool
+Editor::track_canvas_key_release (GdkEventKey* event)
+{
+       if (mouse_mode == Editing::MouseZoom && !Keyboard::the_keyboard().key_is_down (GDK_Control_L)) {
+               track_canvas->get_window()->set_cursor (*zoom_in_cursor);
+       }
+
+       return false;
+}
index d25492287d60b7ddc17dfc6b19d3267cefbe906f..2fabce80b46265ed7f5eff61189d61f7c364a82b 100644 (file)
@@ -294,7 +294,7 @@ Editor::canvas_stream_view_event (GdkEvent *event, ArdourCanvas::Item* item, Rou
        case GDK_LEAVE_NOTIFY:
                set_entered_track (0);
                break;
-
+               
        default:
                break;
        }
index 0463061f19bd637792aacec725c48c90845186a9..61d137cb98ca62825c54fcce81535967df00cf6b 100644 (file)
@@ -3561,6 +3561,7 @@ RangeMarkerBarDrag::update_item (Location* location)
 
 MouseZoomDrag::MouseZoomDrag (Editor* e, ArdourCanvas::Item* i)
        : Drag (e, i)
+       , _zoom_out (false)
 {
        DEBUG_TRACE (DEBUG::Drags, "New MouseZoomDrag\n");
 }
@@ -3568,7 +3569,14 @@ MouseZoomDrag::MouseZoomDrag (Editor* e, ArdourCanvas::Item* i)
 void
 MouseZoomDrag::start_grab (GdkEvent* event, Gdk::Cursor *)
 {
-       Drag::start_grab (event, _editor->zoom_cursor);
+       if (Keyboard::the_keyboard().key_is_down (GDK_Control_L)) {
+               Drag::start_grab (event, _editor->zoom_out_cursor);
+               _zoom_out = true;
+       } else {
+               Drag::start_grab (event, _editor->zoom_in_cursor);
+               _zoom_out = false;
+       }
+               
        _editor->show_verbose_time_cursor (adjusted_current_frame (event), 10);
 }
 
@@ -3617,11 +3625,7 @@ MouseZoomDrag::finished (GdkEvent* event, bool movement_occurred)
                        _editor->temporal_zoom_by_frame (last_pointer_frame(), grab_frame(), "mouse zoom");
                }
        } else {
-               _editor->temporal_zoom_to_frame (false, grab_frame());
-               /*
-               temporal_zoom_step (false);
-               center_screen (grab_frame());
-               */
+               _editor->temporal_zoom_to_frame (_zoom_out, grab_frame());
        }
 
        _editor->zoom_rect->hide();
index 4e8a703c2d31b158ebdf3ee28759dbdc92ae0dcf..a0281fc4276574dd15e71291bbf71f3ff91340f5 100644 (file)
@@ -807,6 +807,9 @@ public:
        void motion (GdkEvent *, bool);
        void finished (GdkEvent *, bool);
        void aborted ();
+
+private:
+       bool _zoom_out;
 };
 
 /** Drag of a range of automation data, changing value but not position */
index a3eef66d72d1fb146bcfe160465d6b9c5ea6d81d..d33db07e88aad5f3a6e05c23aeb885aded92c7a1 100644 (file)
@@ -242,7 +242,7 @@ Editor::set_canvas_cursor ()
                        break;
 
                case MouseZoom:
-                       current_canvas_cursor = zoom_cursor;
+                       current_canvas_cursor = zoom_in_cursor;
                        break;
 
                case MouseTimeFX:
@@ -1595,7 +1595,7 @@ Editor::enter_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemType item_
                                cursor = selector_cursor;
                                break;
                        case MouseZoom:
-                               cursor = zoom_cursor;
+                               cursor = zoom_in_cursor;
                                break;
                        default:
                                cursor = cross_hair_cursor;
index 95a51a82137f7004de4825dd894cda255566b72c..cb4a044cfd5437f387cf1e802566df3fd5096dd4 100644 (file)
@@ -1,18 +1,3 @@
-/* Created with The GIMP */
-#define mag_width 16
-#define mag_height 16
-#define mag_x_hot 9
-#define mag_y_hot 5
-static const gchar mag_bits[] = {
-   0x7f, 0xe0, 0x3f, 0xc0, 0x1f, 0x8f, 0x8f, 0x9f, 0xcf, 0x3f, 0xcf, 0x3f,
-   0xcf, 0x3f, 0xcf, 0x3f, 0x8f, 0x1f, 0x1f, 0x8f, 0x0f, 0xc0, 0x47, 0xe0,
-   0xe3, 0xff, 0xf1, 0xff, 0xf8, 0xff, 0xfc, 0xff };
-
-static const gchar magmask_bits[] = {
-   0x80, 0x1f, 0xc0, 0x3f, 0xe0, 0x70, 0x70, 0x66, 0x30, 0xc6, 0xb0, 0xdf,
-   0xb0, 0xdf, 0x30, 0xc6, 0x70, 0xe6, 0xe0, 0x70, 0xf0, 0x3f, 0xb8, 0x1f,
-   0x1c, 0x00, 0x0e, 0x00, 0x07, 0x00, 0x03, 0x00 };
-
 /* Created with The GIMP */
 #define fader_cursor_width 25
 #define fader_cursor_height 25