make MouseCursors invalid cursor API be static; use to initialize default cursor value in Drag API; use C API to set canvas cursor
This commit is contained in:
@@ -1013,7 +1013,14 @@ Editor::set_canvas_cursor (Gdk::Cursor* cursor)
|
||||
Glib::RefPtr<Gdk::Window> win = _track_canvas->get_window();
|
||||
|
||||
if (win && !_cursors->is_invalid (cursor)) {
|
||||
win->set_cursor (*cursor);
|
||||
/* glibmm 2.4 doesn't allow null cursor pointer because it uses
|
||||
a Gdk::Cursor& as the argument to Gdk::Window::set_cursor().
|
||||
But a null pointer just means "use parent window cursor",
|
||||
and so should be allowed. Gtkmm 3.x has fixed this API.
|
||||
|
||||
For now, drop down and use C API
|
||||
*/
|
||||
gdk_window_set_cursor (win->gobj(), cursor ? cursor->gobj() : 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1095,7 +1102,7 @@ Editor::which_trim_cursor (bool left) const
|
||||
Gdk::Cursor*
|
||||
Editor::which_mode_cursor () const
|
||||
{
|
||||
Gdk::Cursor* mode_cursor = _cursors->invalid_cursor ();
|
||||
Gdk::Cursor* mode_cursor = MouseCursors::invalid_cursor ();
|
||||
|
||||
switch (mouse_mode) {
|
||||
case MouseRange:
|
||||
@@ -1161,7 +1168,7 @@ Editor::which_mode_cursor () const
|
||||
Gdk::Cursor*
|
||||
Editor::which_track_cursor () const
|
||||
{
|
||||
Gdk::Cursor* cursor = _cursors->invalid_cursor();
|
||||
Gdk::Cursor* cursor = MouseCursors::invalid_cursor();
|
||||
|
||||
switch (_join_object_range_state) {
|
||||
case JOIN_OBJECT_RANGE_NONE:
|
||||
|
||||
@@ -4152,7 +4152,7 @@ SelectionDrag::start_grab (GdkEvent* event, Gdk::Cursor*)
|
||||
return;
|
||||
}
|
||||
|
||||
Gdk::Cursor* cursor = _editor->cursors()->invalid_cursor();
|
||||
Gdk::Cursor* cursor = MouseCursors::invalid_cursor();
|
||||
|
||||
switch (_operation) {
|
||||
case CreateSelection:
|
||||
@@ -4490,7 +4490,7 @@ RangeMarkerBarDrag::start_grab (GdkEvent* event, Gdk::Cursor *)
|
||||
return;
|
||||
}
|
||||
|
||||
Gdk::Cursor* cursor = _editor->cursors()->invalid_cursor();
|
||||
Gdk::Cursor* cursor = MouseCursors::invalid_cursor();
|
||||
|
||||
if (!_editor->temp_location) {
|
||||
_editor->temp_location = new Location (*_editor->session());
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include "cursor_context.h"
|
||||
#include "editor_items.h"
|
||||
#include "mouse_cursors.h"
|
||||
|
||||
namespace ARDOUR {
|
||||
class Location;
|
||||
@@ -58,8 +59,8 @@ public:
|
||||
|
||||
void abort ();
|
||||
void add (Drag *);
|
||||
void set (Drag *, GdkEvent *, Gdk::Cursor* c = 0);
|
||||
void start_grab (GdkEvent *, Gdk::Cursor* c = 0);
|
||||
void set (Drag *, GdkEvent *, Gdk::Cursor* c = MouseCursors::invalid_cursor());
|
||||
void start_grab (GdkEvent *, Gdk::Cursor* c = MouseCursors::invalid_cursor());
|
||||
bool end_grab (GdkEvent *);
|
||||
bool have_item (ArdourCanvas::Item *) const;
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
|
||||
using namespace ARDOUR_UI_UTILS;
|
||||
|
||||
Gdk::Cursor* MouseCursors::_invalid = 0;
|
||||
|
||||
MouseCursors::MouseCursors ()
|
||||
: cross_hair (0)
|
||||
, scissors (0)
|
||||
@@ -211,11 +213,13 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MouseCursors::create_invalid()
|
||||
{
|
||||
char pix[4] = { 0, 0, 0, 0 };
|
||||
Glib::RefPtr<Gdk::Bitmap> bits = Gdk::Bitmap::create (pix, 2, 2);
|
||||
Gdk::Color c;
|
||||
_invalid = new Gdk::Cursor (bits, bits, c, c, 0, 0);
|
||||
}
|
||||
|
||||
@@ -80,15 +80,16 @@ public:
|
||||
"use the parent window's cursor"
|
||||
*/
|
||||
|
||||
bool is_invalid (Gdk::Cursor* c) const { return c == _invalid; }
|
||||
Gdk::Cursor* invalid_cursor() const { return _invalid; }
|
||||
static bool is_invalid (Gdk::Cursor* c) { if (!_invalid) { create_invalid(); } return c == _invalid; }
|
||||
static Gdk::Cursor* invalid_cursor() { if (!_invalid) { create_invalid(); } 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;
|
||||
static Gdk::Cursor* _invalid;
|
||||
static void create_invalid ();
|
||||
};
|
||||
|
||||
#endif /* __gtk2_ardour_mouse_cursors__ */
|
||||
|
||||
Reference in New Issue
Block a user