mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-09 15:15:41 +01:00
use MouseCursors::invalid_cursor() to replace null cursor; redefine various cursors to meet PRD or get closer to them.
This includes the use of a null cursor to indicate "use parent window's cursor" - see comments in mouse_cursors.{cc,h} for more detail.
This commit is contained in:
parent
5d4146ff7f
commit
bf9981e143
6 changed files with 74 additions and 63 deletions
|
|
@ -352,7 +352,7 @@ Editor::Editor ()
|
|||
clicked_routeview = 0;
|
||||
clicked_control_point = 0;
|
||||
last_update_frame = 0;
|
||||
pre_press_cursor = 0;
|
||||
pre_press_cursor = _cursors->invalid_cursor ();
|
||||
_drags = new DragManager (this);
|
||||
lock_dialog = 0;
|
||||
ruler_dialog = 0;
|
||||
|
|
|
|||
|
|
@ -434,7 +434,7 @@ Editor::reset_controls_layout_height (int32_t h)
|
|||
bool
|
||||
Editor::track_canvas_map_handler (GdkEventAny* /*ev*/)
|
||||
{
|
||||
if (current_canvas_cursor) {
|
||||
if (!MouseCursors::is_invalid (current_canvas_cursor)) {
|
||||
set_canvas_cursor (current_canvas_cursor);
|
||||
}
|
||||
return false;
|
||||
|
|
@ -1082,15 +1082,19 @@ Editor::set_canvas_cursor (Gdk::Cursor* cursor, bool save)
|
|||
|
||||
Glib::RefPtr<Gdk::Window> win = _track_canvas->get_window();
|
||||
|
||||
if (win && cursor) {
|
||||
win->set_cursor (*cursor);
|
||||
}
|
||||
if (win && !MouseCursors::is_invalid (cursor)) {
|
||||
if (cursor) {
|
||||
win->set_cursor (*cursor);
|
||||
} else {
|
||||
win->set_cursor ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Editor::push_canvas_cursor (Gdk::Cursor* cursor)
|
||||
{
|
||||
if (cursor) {
|
||||
if (!MouseCursors::is_invalid (cursor)) {
|
||||
_cursor_stack.push (cursor);
|
||||
set_canvas_cursor (cursor, false);
|
||||
}
|
||||
|
|
@ -1179,7 +1183,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:
|
||||
|
|
@ -1259,7 +1263,7 @@ Editor::which_mode_cursor () const
|
|||
Gdk::Cursor*
|
||||
Editor::which_track_cursor () const
|
||||
{
|
||||
Gdk::Cursor* cursor = 0;
|
||||
Gdk::Cursor* cursor = _cursors->invalid_cursor();
|
||||
|
||||
assert (mouse_mode == MouseObject || get_smart_mode());
|
||||
|
||||
|
|
@ -1287,11 +1291,11 @@ Editor::reset_canvas_cursor ()
|
|||
|
||||
Gdk::Cursor* cursor = which_mode_cursor ();
|
||||
|
||||
if (!cursor) {
|
||||
if (MouseCursors::is_invalid (cursor)) {
|
||||
cursor = which_grabber_cursor ();
|
||||
}
|
||||
|
||||
if (cursor) {
|
||||
if (!MouseCursors::is_invalid (cursor)) {
|
||||
set_canvas_cursor (cursor);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1302,7 +1306,7 @@ Editor::reset_canvas_cursor ()
|
|||
void
|
||||
Editor::choose_canvas_cursor_on_entry (GdkEventCrossing* /*event*/, ItemType type)
|
||||
{
|
||||
Gdk::Cursor* cursor = 0;
|
||||
Gdk::Cursor* cursor = _cursors->invalid_cursor ();
|
||||
|
||||
if (_drags->active()) {
|
||||
return;
|
||||
|
|
@ -1383,13 +1387,13 @@ Editor::choose_canvas_cursor_on_entry (GdkEventCrossing* /*event*/, ItemType typ
|
|||
case CrossfadeViewItem:
|
||||
cursor = _cursors->cross_hair;
|
||||
break;
|
||||
case SelectionItem:
|
||||
cursor = which_grabber_cursor();
|
||||
break;
|
||||
case SelectionItem:
|
||||
cursor = which_grabber_cursor();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
} else if (mouse_mode == MouseGain) {
|
||||
|
||||
/* ControlPointItem is not really specific to region gain mode
|
||||
|
|
@ -1408,16 +1412,16 @@ Editor::choose_canvas_cursor_on_entry (GdkEventCrossing* /*event*/, ItemType typ
|
|||
break;
|
||||
}
|
||||
|
||||
} else if (mouse_mode == MouseRange) {
|
||||
} else if (mouse_mode == MouseRange) {
|
||||
|
||||
switch (type) {
|
||||
case SelectionItem:
|
||||
cursor = which_grabber_cursor();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
switch (type) {
|
||||
case SelectionItem:
|
||||
cursor = _cursors->all_direction_move;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
/* These items use the timebar cursor at all times */
|
||||
|
|
@ -1429,7 +1433,7 @@ Editor::choose_canvas_cursor_on_entry (GdkEventCrossing* /*event*/, ItemType typ
|
|||
cursor = _cursors->timebar;
|
||||
break;
|
||||
|
||||
/* These items use the grabber cursor at all times */
|
||||
/* These items use the grabber cursor at all times */
|
||||
case MeterMarkerItem:
|
||||
case TempoMarkerItem:
|
||||
case MeterBarItem:
|
||||
|
|
@ -1440,13 +1444,13 @@ Editor::choose_canvas_cursor_on_entry (GdkEventCrossing* /*event*/, ItemType typ
|
|||
case CdMarkerBarItem:
|
||||
case VideoBarItem:
|
||||
case DropZoneItem:
|
||||
cursor = which_grabber_cursor();
|
||||
break;
|
||||
cursor = which_grabber_cursor();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (cursor) {
|
||||
if (!MouseCursors::is_invalid (cursor)) {
|
||||
set_canvas_cursor (cursor, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1441,9 +1441,9 @@ Editor::button_release_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemT
|
|||
framepos_t where = canvas_event_sample (event);
|
||||
AutomationTimeAxisView* atv = 0;
|
||||
|
||||
if (pre_press_cursor) {
|
||||
if (!MouseCursors::is_invalid (pre_press_cursor)) {
|
||||
set_canvas_cursor (pre_press_cursor);
|
||||
pre_press_cursor = 0;
|
||||
pre_press_cursor = _cursors->invalid_cursor();
|
||||
}
|
||||
|
||||
/* no action if we're recording */
|
||||
|
|
|
|||
|
|
@ -110,8 +110,8 @@ MidiRegionView::MidiRegionView (ArdourCanvas::Container *parent, RouteTimeAxisVi
|
|||
, _no_sound_notes (false)
|
||||
, _last_event_x (0)
|
||||
, _last_event_y (0)
|
||||
, pre_enter_cursor (0)
|
||||
, pre_press_cursor (0)
|
||||
, pre_enter_cursor (MouseCursors::invalid_cursor())
|
||||
, pre_press_cursor (MouseCursors::invalid_cursor())
|
||||
, _note_player (0)
|
||||
{
|
||||
CANVAS_DEBUG_NAME (_note_group, string_compose ("note group for %1", get_item_name()));
|
||||
|
|
@ -147,8 +147,8 @@ MidiRegionView::MidiRegionView (ArdourCanvas::Container *parent, RouteTimeAxisVi
|
|||
, _no_sound_notes (false)
|
||||
, _last_event_x (0)
|
||||
, _last_event_y (0)
|
||||
, pre_enter_cursor (0)
|
||||
, pre_press_cursor (0)
|
||||
, pre_enter_cursor (MouseCursors::invalid_cursor())
|
||||
, pre_press_cursor (MouseCursors::invalid_cursor())
|
||||
, _note_player (0)
|
||||
{
|
||||
CANVAS_DEBUG_NAME (_note_group, string_compose ("note group for %1", get_item_name()));
|
||||
|
|
@ -193,8 +193,8 @@ MidiRegionView::MidiRegionView (const MidiRegionView& other)
|
|||
, _no_sound_notes (false)
|
||||
, _last_event_x (0)
|
||||
, _last_event_y (0)
|
||||
, pre_enter_cursor (0)
|
||||
, pre_press_cursor (0)
|
||||
, pre_enter_cursor (MouseCursors::invalid_cursor())
|
||||
, pre_press_cursor (MouseCursors::invalid_cursor())
|
||||
, _note_player (0)
|
||||
{
|
||||
init (false);
|
||||
|
|
@ -221,8 +221,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_press_cursor (0)
|
||||
, pre_enter_cursor (MouseCursors::invalid_cursor())
|
||||
, pre_press_cursor (MouseCursors::invalid_cursor())
|
||||
, _note_player (0)
|
||||
{
|
||||
init (true);
|
||||
|
|
@ -411,9 +411,9 @@ MidiRegionView::leave_notify (GdkEventCrossing*)
|
|||
trackview.editor().verbose_cursor()->hide ();
|
||||
remove_ghost_note ();
|
||||
|
||||
if (pre_enter_cursor) {
|
||||
if (!MouseCursors::is_invalid (pre_enter_cursor)) {
|
||||
Editor* editor = dynamic_cast<Editor *> (&trackview.editor());
|
||||
editor->set_canvas_cursor(pre_enter_cursor);
|
||||
editor->set_canvas_cursor (pre_enter_cursor);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -482,9 +482,9 @@ MidiRegionView::button_release (GdkEventButton* ev)
|
|||
|
||||
PublicEditor& editor = trackview.editor ();
|
||||
|
||||
if (pre_press_cursor) {
|
||||
if (!MouseCursors::is_invalid (pre_press_cursor)) {
|
||||
dynamic_cast<Editor*>(&editor)->set_canvas_cursor (pre_press_cursor, false);
|
||||
pre_press_cursor = 0;
|
||||
pre_press_cursor = MouseCursors::invalid_cursor();
|
||||
}
|
||||
|
||||
switch (_mouse_state) {
|
||||
|
|
@ -3130,9 +3130,9 @@ MidiRegionView::note_left (NoteBase*)
|
|||
|
||||
editor->verbose_cursor()->hide ();
|
||||
|
||||
if (pre_enter_cursor) {
|
||||
if (!MouseCursors::is_invalid (pre_enter_cursor)) {
|
||||
editor->set_canvas_cursor (pre_enter_cursor);
|
||||
pre_enter_cursor = 0;
|
||||
pre_enter_cursor = MouseCursors::invalid_cursor();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -112,6 +112,8 @@ MouseCursors::drop_all ()
|
|||
delete move; move = 0;
|
||||
delete expand_left_right; expand_left_right = 0;
|
||||
delete expand_up_down; expand_up_down = 0;
|
||||
|
||||
/* no need to drop _invalid */
|
||||
}
|
||||
|
||||
Gdk::Cursor*
|
||||
|
|
@ -145,20 +147,35 @@ MouseCursors::set_cursor_set (const std::string& name)
|
|||
sets should come with a hotspot info file.
|
||||
*/
|
||||
|
||||
/* using a null GdkCursor* in a call to gdk_window_set_cursor()
|
||||
causes the GdkWindow to use the cursor of the parent window.
|
||||
|
||||
Since we never set the cursor for the top level window(s),
|
||||
this will be default cursor on a given platform.
|
||||
|
||||
Obviously, if this was used with deeply nested windows
|
||||
some of which have non-default cursors and some don't,
|
||||
this might fail, but in reality we use it only in cases
|
||||
of single nesting or non-non-default cursors.
|
||||
*/
|
||||
|
||||
#define DEFAULT_PLATFORM_CURSOR (Gdk::Cursor*) 0
|
||||
|
||||
zoom_in = make_cursor ("zoom_in_cursor", 10, 5);
|
||||
zoom_out = make_cursor ("zoom_out_cursor", 5, 5);
|
||||
scissors = make_cursor ("scissors", 5, 0);
|
||||
grabber = make_cursor ("grabber", 5, 0);
|
||||
all_direction_move = new Cursor (FLEUR);
|
||||
grabber = DEFAULT_PLATFORM_CURSOR;
|
||||
grabber_edit_point = DEFAULT_PLATFORM_CURSOR;
|
||||
grabber_note = make_cursor ("grabber_note", 5, 10);
|
||||
grabber_edit_point = make_cursor ("grabber_edit_point", 5, 4);
|
||||
left_side_trim = make_cursor ("trim_left_cursor", 5, 11);
|
||||
anchored_left_side_trim = make_cursor ("anchored_trim_left_cursor", 5, 11);
|
||||
right_side_trim = make_cursor ("trim_right_cursor", 23, 11);
|
||||
anchored_right_side_trim = make_cursor ("anchored_trim_right_cursor", 23, 11);
|
||||
left_side_trim_right_only = make_cursor ("trim_left_cursor_right_only", 5, 11);
|
||||
right_side_trim_left_only = make_cursor ("trim_right_cursor_left_only", 23, 11);
|
||||
fade_in = make_cursor ("fade_in_cursor", 0, 0);
|
||||
fade_out = make_cursor ("fade_out_cursor", 29, 0);
|
||||
fade_in = new Cursor(LEFT_PTR);
|
||||
fade_out = new Cursor(LEFT_PTR);
|
||||
resize_left = make_cursor ("resize_left_cursor", 3, 10);
|
||||
resize_top_left = make_cursor ("resize_top_left_cursor", 3, 3);
|
||||
resize_top = make_cursor ("resize_top_cursor", 10, 3);
|
||||
|
|
@ -170,7 +187,7 @@ MouseCursors::set_cursor_set (const std::string& name)
|
|||
move = make_cursor ("move_cursor", 11, 11);
|
||||
expand_left_right = make_cursor ("expand_left_right_cursor", 11, 4);
|
||||
expand_up_down = make_cursor ("expand_up_down_cursor", 4, 11);
|
||||
selector = make_cursor ("i_beam_cursor", 4, 11);
|
||||
selector = new Cursor (XTERM); /* odd but this is actually an I-Beam */
|
||||
|
||||
Gdk::Color fbg ("#ffffff");
|
||||
Gdk::Color ffg ("#000000");
|
||||
|
|
@ -198,20 +215,10 @@ MouseCursors::set_cursor_set (const std::string& name)
|
|||
trimmer = new Cursor (SB_H_DOUBLE_ARROW);
|
||||
time_fx = new Cursor (SIZING);
|
||||
wait = new Cursor (WATCH);
|
||||
timebar = new Cursor(LEFT_PTR);
|
||||
timebar = DEFAULT_PLATFORM_CURSOR;
|
||||
midi_pencil = new Cursor (PENCIL);
|
||||
midi_select = new Cursor (CENTER_PTR);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ public:
|
|||
Gdk::Cursor* fade_in;
|
||||
Gdk::Cursor* fade_out;
|
||||
Gdk::Cursor* selector;
|
||||
Gdk::Cursor* all_direction_move;
|
||||
Gdk::Cursor* grabber;
|
||||
Gdk::Cursor* grabber_note;
|
||||
Gdk::Cursor* grabber_edit_point;
|
||||
|
|
@ -76,19 +77,18 @@ public:
|
|||
/* 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
|
||||
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; }
|
||||
static Gdk::Cursor* invalid_cursor() { return (Gdk::Cursor*) 0xfeedface; }
|
||||
static bool is_invalid (Gdk::Cursor* c) { return c == invalid_cursor(); }
|
||||
|
||||
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__ */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue