Skip to content

Commit

Permalink
remove all trace of cursor stacks; canvas cursor is always "just set"
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldavisthefirst committed Dec 8, 2024
1 parent 5b112e4 commit 98c9c03
Show file tree
Hide file tree
Showing 22 changed files with 55 additions and 306 deletions.
8 changes: 0 additions & 8 deletions MSVCardour3/Ardour3.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -459,10 +459,6 @@
RelativePath="..\gtk2_ardour\control_slave_ui.cc"
>
</File>
<File
RelativePath="..\gtk2_ardour\cursor_context.cc"
>
</File>
<File
RelativePath="..\gtk2_ardour\curvetest.cc"
>
Expand Down Expand Up @@ -1641,10 +1637,6 @@
RelativePath="..\gtk2_ardour\crossfade_edit.h"
>
</File>
<File
RelativePath="..\gtk2_ardour\cursor_context.h"
>
</File>
<File
RelativePath="..\gtk2_ardour\debug.h"
>
Expand Down
6 changes: 0 additions & 6 deletions gtk2_ardour/cue_editor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,6 @@ CueEditor::instant_save()
{
}

EditingContext::EnterContext*
CueEditor::get_enter_context(ItemType type)
{
return nullptr;
}

void
CueEditor::begin_selection_op_history ()
{
Expand Down
7 changes: 0 additions & 7 deletions gtk2_ardour/cue_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,6 @@ class CueEditor : public EditingContext, public PBD::HistoryOwner, public sigc::

void instant_save();

/** Get the topmost enter context for the given item type.
*
* This is used to change the cursor associated with a given enter context,
* which may not be on the top of the stack.
*/
EnterContext* get_enter_context(ItemType type);

void begin_selection_op_history ();
void begin_reversible_selection_op (std::string cmd_name);
void commit_reversible_selection_op ();
Expand Down
62 changes: 0 additions & 62 deletions gtk2_ardour/cursor_context.cc

This file was deleted.

73 changes: 0 additions & 73 deletions gtk2_ardour/cursor_context.h

This file was deleted.

64 changes: 9 additions & 55 deletions gtk2_ardour/editing_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2065,8 +2065,13 @@ EditingContext::set_horizontal_position (double p)
Gdk::Cursor*
EditingContext::get_canvas_cursor () const
{
/* The top of the cursor stack is always the currently visible cursor. */
return _cursor_stack.back();
Glib::RefPtr<Gdk::Window> win = get_canvas_viewport()->get_window();

if (win) {
return _cursors->from_gdk_cursor (gdk_window_get_cursor (win->gobj()));
}

return nullptr;
}

void
Expand All @@ -2087,36 +2092,6 @@ EditingContext::set_canvas_cursor (Gdk::Cursor* cursor)
}
}

size_t
EditingContext::push_canvas_cursor (Gdk::Cursor* cursor)
{
if (!_cursors->is_invalid (cursor)) {
_cursor_stack.push_back (cursor);
set_canvas_cursor (cursor);
}
return _cursor_stack.size() - 1;
}

void
EditingContext::pop_canvas_cursor ()
{
while (true) {
if (_cursor_stack.size() <= 1) {
set_canvas_cursor (nullptr);
return;
}

_cursor_stack.pop_back();
if (!_cursor_stack.empty()) {
/* Popped to an existing cursor, we're done. Otherwise, the
context that created this cursor has been destroyed, so we need
to skip to the next down the stack. */
set_canvas_cursor (_cursor_stack.back());
return;
}
}
}

void
EditingContext::pack_draw_box ()
{
Expand Down Expand Up @@ -2763,39 +2738,18 @@ EditingContext::reset_point_selection ()
}
}

EditingContext::EnterContext*
EditingContext::get_enter_context(ItemType type)
{
for (ssize_t i = _enter_stack.size() - 1; i >= 0; --i) {
if (_enter_stack[i].item_type == type) {
return &_enter_stack[i];
}
}
return NULL;
}


void
EditingContext::choose_canvas_cursor_on_entry (ItemType type)
{
if (_drags->active()) {
return;
}

Gdk::Cursor* cursor = which_canvas_cursor(type);
Gdk::Cursor* cursor = which_canvas_cursor (type);

if (!_cursors->is_invalid (cursor)) {
// Push a new enter context
const EnterContext ctx = { type, CursorContext::create(*this, cursor) };
_enter_stack.push_back(ctx);
}
}

void
EditingContext::update_all_enter_cursors ()
{
for (auto & ec : _enter_stack) {
ec.cursor_ctx->change(which_canvas_cursor (ec.item_type));
set_canvas_cursor (cursor);
}
}

Expand Down
28 changes: 2 additions & 26 deletions gtk2_ardour/editing_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ class SelectableOwner;
class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider
{
public:
/** Context for mouse entry (stored in a stack). */
struct EnterContext {
ItemType item_type;
std::shared_ptr<CursorContext> cursor_ctx;
};

EditingContext (std::string const &);
~EditingContext ();

Expand Down Expand Up @@ -348,9 +342,6 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider
/** Push the appropriate enter/cursor context on item entry. */
void choose_canvas_cursor_on_entry (ItemType);

/** Update all enter cursors based on current settings. */
void update_all_enter_cursors ();

virtual Gdk::Cursor* get_canvas_cursor () const;
static MouseCursors const* cursors () {
return _cursors;
Expand Down Expand Up @@ -399,23 +390,13 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider
virtual ArdourCanvas::GtkCanvasViewport* get_canvas_viewport() const = 0;
virtual ArdourCanvas::GtkCanvas* get_canvas() const = 0;

virtual size_t push_canvas_cursor (Gdk::Cursor*);
virtual void pop_canvas_cursor ();

virtual void mouse_mode_toggled (Editing::MouseMode) = 0;

bool on_velocity_scroll_event (GdkEventScroll*);
void pre_render ();

void select_automation_line (GdkEventButton*, ArdourCanvas::Item*, ARDOUR::SelectionOperation);

/** Get the topmost enter context for the given item type.
*
* This is used to change the cursor associated with a given enter context,
* which may not be on the top of the stack.
*/
virtual EnterContext* get_enter_context(ItemType type);

virtual Gdk::Cursor* which_track_cursor () const = 0;
virtual Gdk::Cursor* which_mode_cursor () const = 0;
virtual Gdk::Cursor* which_trim_cursor (bool left_side) const = 0;
Expand All @@ -437,17 +418,14 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider
static EditingContext* current_editing_context();
static void switch_editing_context(EditingContext*);

virtual void set_canvas_cursor (Gdk::Cursor*);

protected:
std::string _name;

static Glib::RefPtr<Gtk::ActionGroup> _midi_actions;
static Glib::RefPtr<Gtk::ActionGroup> _common_actions;

/* Cursor stuff. Do not use directly, use via CursorContext. */
friend class CursorContext;
std::vector<Gdk::Cursor*> _cursor_stack;
virtual void set_canvas_cursor (Gdk::Cursor*);

Editing::GridType pre_internal_grid_type;
Editing::SnapMode pre_internal_snap_mode;
Editing::GridType internal_grid_type;
Expand Down Expand Up @@ -712,8 +690,6 @@ class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider

virtual void set_entered_track (TimeAxisView*) {};

std::vector<EnterContext> _enter_stack;

PBD::ScopedConnection escape_connection;
virtual void escape () {}

Expand Down
9 changes: 1 addition & 8 deletions gtk2_ardour/editor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,7 @@ Editor::Editor ()

_group_tabs->signal_scroll_event().connect (sigc::mem_fun(*this, &Editor::control_layout_scroll), false);

/* Push default cursor to ever-present bottom of cursor stack. */
push_canvas_cursor (nullptr);
set_canvas_cursor (nullptr);

ArdourCanvas::GtkCanvas* time_pad = manage (new ArdourCanvas::GtkCanvas ());

Expand Down Expand Up @@ -2095,8 +2094,6 @@ Editor::set_edit_point_preference (EditPoint ep, bool force)
edit_point_selector.set_text (str);
}

update_all_enter_cursors();

if (!force && !changed) {
return;
}
Expand Down Expand Up @@ -5673,11 +5670,7 @@ Editor::ui_parameter_changed (string parameter)
EditingContext::ui_parameter_changed (parameter);

if (parameter == "icon-set") {
while (!_cursor_stack.empty()) {
_cursor_stack.pop_back();
}
_cursors->set_cursor_set (UIConfiguration::instance().get_icon_set());
_cursor_stack.push_back(nullptr);
content_right_pane.set_drag_cursor (*PublicEditor::instance().cursors()->expand_left_right);
editor_summary_pane.set_drag_cursor (*_cursors->expand_up_down);

Expand Down
Loading

0 comments on commit 98c9c03

Please sign in to comment.