summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2012-01-19 22:23:28 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2012-01-19 22:23:28 +0000
commitf758ed0f4123605235dc83c70d5fdef2e8aa8947 (patch)
tree26c2230c6d007f65ccb9fa3173bbab01e8a791ea
parentefab36a85e4a462716f2d7f4d0f12a12e45b4a75 (diff)
more fixups of various things including cursors when note editing. in particular, don't needlessly reset the cursor during a drag. note insertion with ctrl pressed now only works if in MouseObject mode.
git-svn-id: svn://localhost/ardour2/branches/3.0@11270 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/editor_canvas.cc5
-rw-r--r--gtk2_ardour/editor_drag.cc21
-rw-r--r--gtk2_ardour/editor_rulers.cc3
-rw-r--r--gtk2_ardour/midi_region_view.cc96
-rw-r--r--gtk2_ardour/midi_region_view.h3
-rw-r--r--gtk2_ardour/mouse_cursors.h5
6 files changed, 83 insertions, 50 deletions
diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc
index 3e2f423cd6..6da76503a7 100644
--- a/gtk2_ardour/editor_canvas.cc
+++ b/gtk2_ardour/editor_canvas.cc
@@ -917,6 +917,7 @@ Editor::horizontal_position () const
{
return frame_to_unit (leftmost_frame);
}
+
void
Editor::set_canvas_cursor (Gdk::Cursor* cursor, bool save)
{
@@ -924,7 +925,9 @@ Editor::set_canvas_cursor (Gdk::Cursor* cursor, bool save)
current_canvas_cursor = cursor;
}
- if (is_drawable()) {
+ Glib::RefPtr<Gdk::Window> win = track_canvas->get_window();
+
+ if (win) {
track_canvas->get_window()->set_cursor (*cursor);
}
}
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index 7d088d0684..25d1c878b8 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -205,19 +205,15 @@ Drag::swap_grab (ArdourCanvas::Item* new_item, Gdk::Cursor* cursor, uint32_t tim
_item = new_item;
if (cursor == 0) {
- cursor = _editor->which_grabber_cursor ();
+ _item->grab (Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK, time);
+ } else {
+ _item->grab (Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK, *cursor, time);
}
-
- _item->grab (Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK, *cursor, time);
}
void
Drag::start_grab (GdkEvent* event, Gdk::Cursor *cursor)
{
- if (cursor == 0) {
- cursor = _editor->which_grabber_cursor ();
- }
-
// if dragging with button2, the motion is x constrained, with Alt-button2 it is y constrained
if (Keyboard::is_button2_event (&event->button)) {
@@ -240,9 +236,14 @@ Drag::start_grab (GdkEvent* event, Gdk::Cursor *cursor)
_last_pointer_x = _grab_x;
_last_pointer_y = _grab_y;
- _item->grab (Gdk::POINTER_MOTION_MASK|Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK,
- *cursor,
- event->button.time);
+ if (cursor == 0) {
+ _item->grab (Gdk::POINTER_MOTION_MASK|Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK,
+ event->button.time);
+ } else {
+ _item->grab (Gdk::POINTER_MOTION_MASK|Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK,
+ *cursor,
+ event->button.time);
+ }
if (_editor->session() && _editor->session()->transport_rolling()) {
_was_rolling = true;
diff --git a/gtk2_ardour/editor_rulers.cc b/gtk2_ardour/editor_rulers.cc
index f11e584c18..82669b7ecc 100644
--- a/gtk2_ardour/editor_rulers.cc
+++ b/gtk2_ardour/editor_rulers.cc
@@ -32,7 +32,8 @@
#include "ardour/session.h"
#include "ardour/tempo.h"
#include "ardour/profile.h"
-#include <gtkmm2ext/gtk_ui.h>
+
+#include "gtkmm2ext/gtk_ui.h"
#include "editor.h"
#include "editing.h"
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc
index 125fd501c2..196f0f0960 100644
--- a/gtk2_ardour/midi_region_view.cc
+++ b/gtk2_ardour/midi_region_view.cc
@@ -24,7 +24,7 @@
#include <gtkmm.h>
-#include <gtkmm2ext/gtk_ui.h>
+#include "gtkmm2ext/gtk_ui.h"
#include <sigc++/signal.h>
@@ -63,6 +63,7 @@
#include "midi_streamview.h"
#include "midi_time_axis.h"
#include "midi_util.h"
+#include "mouse_cursors.h"
#include "note_player.h"
#include "public_editor.h"
#include "rgb_macros.h"
@@ -70,7 +71,6 @@
#include "simpleline.h"
#include "streamview.h"
#include "utils.h"
-#include "mouse_cursors.h"
#include "patch_change_dialog.h"
#include "verbose_cursor.h"
@@ -110,7 +110,8 @@ MidiRegionView::MidiRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &
, _no_sound_notes (false)
, _last_event_x (0)
, _last_event_y (0)
- , _pre_enter_cursor (0)
+ , pre_enter_cursor (0)
+ , pre_press_cursor (0)
{
_note_group->raise_to_top();
PublicEditor::DropDownKeys.connect (sigc::mem_fun (*this, &MidiRegionView::drop_down_keys));
@@ -146,7 +147,8 @@ MidiRegionView::MidiRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &
, _no_sound_notes (false)
, _last_event_x (0)
, _last_event_y (0)
- , _pre_enter_cursor (0)
+ , pre_enter_cursor (0)
+ , pre_press_cursor (0)
{
_note_group->raise_to_top();
PublicEditor::DropDownKeys.connect (sigc::mem_fun (*this, &MidiRegionView::drop_down_keys));
@@ -190,7 +192,8 @@ MidiRegionView::MidiRegionView (const MidiRegionView& other)
, _no_sound_notes (false)
, _last_event_x (0)
, _last_event_y (0)
- , _pre_enter_cursor (0)
+ , pre_enter_cursor (0)
+ , pre_press_cursor (0)
{
Gdk::Color c;
int r,g,b,a;
@@ -224,7 +227,8 @@ MidiRegionView::MidiRegionView (const MidiRegionView& other, boost::shared_ptr<M
, _no_sound_notes (false)
, _last_event_x (0)
, _last_event_y (0)
- , _pre_enter_cursor (0)
+ , pre_enter_cursor (0)
+ , pre_press_cursor (0)
{
Gdk::Color c;
int r,g,b,a;
@@ -429,11 +433,19 @@ MidiRegionView::button_press (GdkEventButton* ev)
return false;
}
- if (_mouse_state != SelectTouchDragging) {
+ Editor* editor = dynamic_cast<Editor *> (&trackview.editor());
+ MouseMode m = editor->current_mouse_mode();
+
+ if (m == MouseObject && Keyboard::modifier_state_contains (ev->state, Keyboard::insert_note_modifier())) {
+ pre_press_cursor = editor->get_canvas_cursor ();
+ editor->set_canvas_cursor (editor->cursors()->midi_pencil);
+ }
+ if (_mouse_state != SelectTouchDragging) {
+
_pressed_button = ev->button;
_mouse_state = Pressed;
-
+
return true;
}
@@ -459,6 +471,11 @@ MidiRegionView::button_release (GdkEventButton* ev)
PublicEditor& editor = trackview.editor ();
+ if (pre_press_cursor) {
+ dynamic_cast<Editor*>(&editor)->set_canvas_cursor (pre_press_cursor, false);
+ pre_press_cursor = 0;
+ }
+
switch (_mouse_state) {
case Pressed: // Clicked
@@ -538,21 +555,24 @@ MidiRegionView::motion (GdkEventMotion* ev)
{
PublicEditor& editor = trackview.editor ();
- if (!_ghost_note && editor.current_mouse_mode() != MouseDraw
- && Keyboard::modifier_state_contains (ev->state, Keyboard::insert_note_modifier())
- && _mouse_state != AddDragging) {
+ if (!_ghost_note && editor.current_mouse_mode() == MouseObject &&
+ Keyboard::modifier_state_contains (ev->state, Keyboard::insert_note_modifier()) &&
+ _mouse_state != AddDragging) {
create_ghost_note (ev->x, ev->y);
- } else if (_ghost_note && editor.current_mouse_mode() != MouseDraw
- && Keyboard::modifier_state_contains (ev->state, Keyboard::insert_note_modifier())) {
+
+ } else if (_ghost_note && editor.current_mouse_mode() == MouseObject &&
+ Keyboard::modifier_state_contains (ev->state, Keyboard::insert_note_modifier())) {
update_ghost_note (ev->x, ev->y);
- } else if (_ghost_note && editor.current_mouse_mode() != MouseDraw) {
- remove_ghost_note ();
+ } else if (_ghost_note && editor.current_mouse_mode() == MouseObject) {
+ remove_ghost_note ();
editor.verbose_cursor()->hide ();
+
} else if (_ghost_note && editor.current_mouse_mode() == MouseDraw) {
+
update_ghost_note (ev->x, ev->y);
}
@@ -565,23 +585,25 @@ MidiRegionView::motion (GdkEventMotion* ev)
switch (_mouse_state) {
case Pressed:
- if (_pressed_button == 1 && editor.current_mouse_mode() == MouseObject
- && !Keyboard::modifier_state_contains (ev->state, Keyboard::insert_note_modifier())) {
-
- editor.drags()->set (new MidiRubberbandSelectDrag (dynamic_cast<Editor *> (&editor), this), (GdkEvent *) ev);
- _mouse_state = SelectRectDragging;
- return true;
-
- } else if (editor.internal_editing()) {
-
- editor.drags()->set (new NoteCreateDrag (dynamic_cast<Editor *> (&editor), group, this), (GdkEvent *) ev);
- _mouse_state = AddDragging;
-
- remove_ghost_note ();
-
- editor.verbose_cursor()->hide ();
+ if (_pressed_button == 1) {
+
+ MouseMode m = editor.current_mouse_mode();
+
+ if (m == MouseDraw || (m == MouseObject && Keyboard::modifier_state_contains (ev->state, Keyboard::insert_note_modifier()))) {
+
+ editor.drags()->set (new NoteCreateDrag (dynamic_cast<Editor *> (&editor), group, this), (GdkEvent *) ev);
+ _mouse_state = AddDragging;
+ remove_ghost_note ();
+ editor.verbose_cursor()->hide ();
+ cerr << "starting note create drag\n";
- return true;
+ return true;
+ } else {
+
+ editor.drags()->set (new MidiRubberbandSelectDrag (dynamic_cast<Editor *> (&editor), this), (GdkEvent *) ev);
+ _mouse_state = SelectRectDragging;
+ return true;
+ }
}
return false;
@@ -2959,7 +2981,7 @@ MidiRegionView::note_entered(ArdourCanvas::CanvasNoteEvent* ev)
{
Editor* editor = dynamic_cast<Editor*>(&trackview.editor());
- _pre_enter_cursor = editor->get_canvas_cursor ();
+ pre_enter_cursor = editor->get_canvas_cursor ();
if (_mouse_state == SelectTouchDragging) {
note_selected (ev, true);
@@ -2979,9 +3001,9 @@ MidiRegionView::note_left (ArdourCanvas::CanvasNoteEvent*)
editor->verbose_cursor()->hide ();
- if (_pre_enter_cursor) {
- editor->set_canvas_cursor (_pre_enter_cursor);
- _pre_enter_cursor = 0;
+ if (pre_enter_cursor) {
+ editor->set_canvas_cursor (pre_enter_cursor);
+ pre_enter_cursor = 0;
}
}
@@ -3010,8 +3032,8 @@ MidiRegionView::note_mouse_position (float x_fraction, float /*y_fraction*/, boo
} else if (x_fraction >= 0.8 && x_fraction < 1.0) {
editor->set_canvas_cursor (editor->cursors()->right_side_trim);
} else {
- if (_pre_enter_cursor && can_set_cursor) {
- editor->set_canvas_cursor (_pre_enter_cursor);
+ if (pre_enter_cursor && can_set_cursor) {
+ editor->set_canvas_cursor (pre_enter_cursor);
}
}
}
diff --git a/gtk2_ardour/midi_region_view.h b/gtk2_ardour/midi_region_view.h
index 6e0a3b4a36..d1c1fb7c94 100644
--- a/gtk2_ardour/midi_region_view.h
+++ b/gtk2_ardour/midi_region_view.h
@@ -465,7 +465,8 @@ private:
PBD::ScopedConnection _mouse_mode_connection;
- Gdk::Cursor* _pre_enter_cursor;
+ Gdk::Cursor* pre_enter_cursor;
+ Gdk::Cursor* pre_press_cursor;
};
diff --git a/gtk2_ardour/mouse_cursors.h b/gtk2_ardour/mouse_cursors.h
index 55d5fd0c9d..bf93e1ad78 100644
--- a/gtk2_ardour/mouse_cursors.h
+++ b/gtk2_ardour/mouse_cursors.h
@@ -17,6 +17,9 @@
*/
+#ifndef __gtk2_ardour_mouse_cursors__
+#define __gtk2_ardour_mouse_cursors__
+
/** @file Handling of bitmaps to be used for mouse cursors.
*
* Held centrally by the Editor because some cursors are used in several places.
@@ -64,3 +67,5 @@ public:
Gdk::Cursor* expand_left_right;
Gdk::Cursor* expand_up_down;
};
+
+#endif /* __gtk2_ardour_mouse_cursors__ */