allow use of null pointer as a valid cursor (implies using cursor of parent window)

This commit is contained in:
Paul Davis 2015-01-23 15:15:29 -05:00
parent fe08965d91
commit 90c1e0ffd2
4 changed files with 34 additions and 15 deletions

View File

@ -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);

View File

@ -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());

View File

@ -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);
}
}

View File

@ -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__ */