summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2015-01-23 15:15:29 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2015-01-23 15:19:36 -0500
commit90c1e0ffd284f0383073a63c5b2b83208c4f49d9 (patch)
tree594647be1eeb1fe60708d513d788bf823061b9c9 /gtk2_ardour
parentfe08965d91b9dd8a71604118e4d967d624e87f03 (diff)
allow use of null pointer as a valid cursor (implies using cursor of parent window)
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/editor_canvas.cc10
-rw-r--r--gtk2_ardour/editor_drag.cc21
-rw-r--r--gtk2_ardour/mouse_cursors.cc7
-rw-r--r--gtk2_ardour/mouse_cursors.h11
4 files changed, 34 insertions, 15 deletions
diff --git a/gtk2_ardour/editor_canvas.cc b/gtk2_ardour/editor_canvas.cc
index 611d5ac054..4a5378f145 100644
--- a/gtk2_ardour/editor_canvas.cc
+++ b/gtk2_ardour/editor_canvas.cc
@@ -1012,7 +1012,7 @@ Editor::set_canvas_cursor (Gdk::Cursor* cursor)
{
Glib::RefPtr<Gdk::Window> win = _track_canvas->get_window();
- if (win && cursor) {
+ if (win && !_cursors->is_invalid (cursor)) {
win->set_cursor (*cursor);
}
}
@@ -1020,7 +1020,7 @@ Editor::set_canvas_cursor (Gdk::Cursor* cursor)
size_t
Editor::push_canvas_cursor (Gdk::Cursor* cursor)
{
- if (cursor) {
+ if (!_cursors->is_invalid (cursor)) {
_cursor_stack.push_back (cursor);
set_canvas_cursor (cursor);
}
@@ -1095,7 +1095,7 @@ Editor::which_trim_cursor (bool left) const
Gdk::Cursor*
Editor::which_mode_cursor () const
{
- Gdk::Cursor* mode_cursor = 0;
+ Gdk::Cursor* mode_cursor = _cursors->invalid_cursor ();
switch (mouse_mode) {
case MouseRange:
@@ -1161,7 +1161,7 @@ Editor::which_mode_cursor () const
Gdk::Cursor*
Editor::which_track_cursor () const
{
- Gdk::Cursor* cursor = 0;
+ Gdk::Cursor* cursor = _cursors->invalid_cursor();
switch (_join_object_range_state) {
case JOIN_OBJECT_RANGE_NONE:
@@ -1332,7 +1332,7 @@ Editor::choose_canvas_cursor_on_entry (ItemType type)
Gdk::Cursor* cursor = which_canvas_cursor(type);
- if (cursor) {
+ if (!_cursors->is_invalid (cursor)) {
// Push a new enter context
const EnterContext ctx = { type, CursorContext::create(*this, cursor) };
_enter_stack.push_back(ctx);
diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc
index 17fe93139a..9d97f132fc 100644
--- a/gtk2_ardour/editor_drag.cc
+++ b/gtk2_ardour/editor_drag.cc
@@ -234,11 +234,13 @@ Drag::swap_grab (ArdourCanvas::Item* new_item, Gdk::Cursor* cursor, uint32_t /*t
_item->ungrab ();
_item = new_item;
- if (cursor == 0) {
- _item->grab ();
+ if (!_cursor_ctx) {
+ _cursor_ctx = CursorContext::create (*_editor, cursor);
} else {
- _item->grab ();
+ _cursor_ctx->change (cursor);
}
+
+ _item->grab ();
}
void
@@ -271,12 +273,11 @@ Drag::start_grab (GdkEvent* event, Gdk::Cursor *cursor)
_last_pointer_y = _grab_y;
- if (cursor == 0) {
- _item->grab ();
- } else {
+ _item->grab ();
+
+ if (!_editor->cursors()->is_invalid (cursor)) {
/* CAIROCANVAS need a variant here that passes *cursor */
- _item->grab ();
- _cursor_ctx = CursorContext::create(*_editor, cursor);
+ _cursor_ctx = CursorContext::create (*_editor, cursor);
}
if (_editor->session() && _editor->session()->transport_rolling()) {
@@ -4151,7 +4152,7 @@ SelectionDrag::start_grab (GdkEvent* event, Gdk::Cursor*)
return;
}
- Gdk::Cursor* cursor = 0;
+ Gdk::Cursor* cursor = _editor->cursors()->invalid_cursor();
switch (_operation) {
case CreateSelection:
@@ -4489,7 +4490,7 @@ RangeMarkerBarDrag::start_grab (GdkEvent* event, Gdk::Cursor *)
return;
}
- Gdk::Cursor* cursor = 0;
+ Gdk::Cursor* cursor = _editor->cursors()->invalid_cursor();
if (!_editor->temp_location) {
_editor->temp_location = new Location (*_editor->session());
diff --git a/gtk2_ardour/mouse_cursors.cc b/gtk2_ardour/mouse_cursors.cc
index d735ed6c64..93bba191f8 100644
--- a/gtk2_ardour/mouse_cursors.cc
+++ b/gtk2_ardour/mouse_cursors.cc
@@ -211,4 +211,11 @@ MouseCursors::set_cursor_set (const std::string& name)
midi_resize = new Cursor (SIZING);
midi_erase = new Cursor (DRAPED_BOX);
up_down = new Cursor (SB_V_DOUBLE_ARROW);
+
+ {
+ char pix[4] = { 0, 0, 0, 0 };
+ RefPtr<Bitmap> bits = Bitmap::create (pix, 2, 2);
+ Color c;
+ _invalid = new Cursor (bits, bits, c, c, 0, 0);
+ }
}
diff --git a/gtk2_ardour/mouse_cursors.h b/gtk2_ardour/mouse_cursors.h
index 6c5c94b5e9..756b2657d9 100644
--- a/gtk2_ardour/mouse_cursors.h
+++ b/gtk2_ardour/mouse_cursors.h
@@ -73,11 +73,22 @@ public:
Gdk::Cursor* expand_left_right;
Gdk::Cursor* expand_up_down;
+ /* This cursor is not intended to be used directly, it just
+ serves as an out-of-bounds value when we need to indicate
+ "no cursor". NULL/0 doesn't work for this, because it
+ is actually a valid value for a Gdk::Cursor - it indicates
+ "use the parent window's cursor"
+ */
+
+ bool is_invalid (Gdk::Cursor* c) const { return c == _invalid; }
+ Gdk::Cursor* invalid_cursor() const { return _invalid; }
+
private:
std::string _cursor_set;
void drop_all ();
Gdk::Cursor* make_cursor (const char* name, int hotspot_x = 0, int hotspot_y = 0);
+ Gdk::Cursor* _invalid;
};
#endif /* __gtk2_ardour_mouse_cursors__ */