mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 23:05:04 +01:00
make undo/redo action sensitivity work with multiple EditingContexts
This commit is contained in:
parent
911ad78c06
commit
86ecca8c76
5 changed files with 50 additions and 26 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
#include "cue_editor.h"
|
#include "cue_editor.h"
|
||||||
#include "editor_drag.h"
|
#include "editor_drag.h"
|
||||||
|
#include "gui_thread.h"
|
||||||
|
|
||||||
#include "pbd/i18n.h"
|
#include "pbd/i18n.h"
|
||||||
|
|
||||||
|
|
@ -7,6 +8,7 @@ CueEditor::CueEditor (std::string const & name)
|
||||||
: EditingContext (name)
|
: EditingContext (name)
|
||||||
, HistoryOwner (X_("cue-editor"))
|
, HistoryOwner (X_("cue-editor"))
|
||||||
{
|
{
|
||||||
|
_history.Changed.connect (history_connection, invalidator (*this), boost::bind (&CueEditor::history_changed, this), gui_context());
|
||||||
}
|
}
|
||||||
|
|
||||||
CueEditor::~CueEditor ()
|
CueEditor::~CueEditor ()
|
||||||
|
|
@ -239,3 +241,9 @@ CueEditor::do_redo (uint32_t n)
|
||||||
_history.redo (n);
|
_history.redo (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CueEditor::history_changed ()
|
||||||
|
{
|
||||||
|
update_undo_redo_actions (_history);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
#include "editing.h"
|
#include "editing.h"
|
||||||
#include "editing_context.h"
|
#include "editing_context.h"
|
||||||
|
|
||||||
class CueEditor : public EditingContext, public PBD::HistoryOwner
|
class CueEditor : public EditingContext, public PBD::HistoryOwner, public sigc::trackable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CueEditor (std::string const & name);
|
CueEditor (std::string const & name);
|
||||||
|
|
@ -67,6 +67,8 @@ class CueEditor : public EditingContext, public PBD::HistoryOwner
|
||||||
void redo_selection_op ();
|
void redo_selection_op ();
|
||||||
|
|
||||||
PBD::HistoryOwner& history() { return *this; }
|
PBD::HistoryOwner& history() { return *this; }
|
||||||
|
void history_changed ();
|
||||||
|
PBD::ScopedConnection history_connection;
|
||||||
|
|
||||||
void add_command (PBD::Command * cmd) { HistoryOwner::add_command (cmd); }
|
void add_command (PBD::Command * cmd) { HistoryOwner::add_command (cmd); }
|
||||||
void begin_reversible_command (std::string cmd_name) { HistoryOwner::begin_reversible_command (cmd_name); }
|
void begin_reversible_command (std::string cmd_name) { HistoryOwner::begin_reversible_command (cmd_name); }
|
||||||
|
|
|
||||||
|
|
@ -1992,13 +1992,18 @@ EditingContext::current_editing_context()
|
||||||
void
|
void
|
||||||
EditingContext::push_editing_context (EditingContext* ec)
|
EditingContext::push_editing_context (EditingContext* ec)
|
||||||
{
|
{
|
||||||
|
assert (ec);
|
||||||
ec_stack.push (ec);
|
ec_stack.push (ec);
|
||||||
|
ec->history_changed ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
EditingContext::pop_editing_context ()
|
EditingContext::pop_editing_context ()
|
||||||
{
|
{
|
||||||
ec_stack.pop ();
|
ec_stack.pop ();
|
||||||
|
if (!ec_stack.empty()) {
|
||||||
|
ec_stack.top()->history_changed ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
|
|
@ -2490,3 +2495,30 @@ EditingContext::radio_reg_sens (RefPtr<ActionGroup> action_group, RadioAction::G
|
||||||
ActionManager::session_sensitive_actions.push_back (act);
|
ActionManager::session_sensitive_actions.push_back (act);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
EditingContext::update_undo_redo_actions (PBD::UndoHistory const & history)
|
||||||
|
{
|
||||||
|
string label;
|
||||||
|
|
||||||
|
if (undo_action) {
|
||||||
|
if (history.undo_depth() == 0) {
|
||||||
|
label = S_("Command|Undo");
|
||||||
|
undo_action->set_sensitive(false);
|
||||||
|
} else {
|
||||||
|
label = string_compose(S_("Command|Undo (%1)"), history.next_undo());
|
||||||
|
undo_action->set_sensitive(true);
|
||||||
|
}
|
||||||
|
undo_action->property_label() = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (redo_action) {
|
||||||
|
if (history.redo_depth() == 0) {
|
||||||
|
label = _("Redo");
|
||||||
|
redo_action->set_sensitive (false);
|
||||||
|
} else {
|
||||||
|
label = string_compose(_("Redo (%1)"), history.next_redo());
|
||||||
|
redo_action->set_sensitive (true);
|
||||||
|
}
|
||||||
|
redo_action->property_label() = label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ class SelectionMemento;
|
||||||
|
|
||||||
class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider
|
class EditingContext : public ARDOUR::SessionHandlePtr, public AxisViewProvider
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** Context for mouse entry (stored in a stack). */
|
/** Context for mouse entry (stored in a stack). */
|
||||||
struct EnterContext {
|
struct EnterContext {
|
||||||
ItemType item_type;
|
ItemType item_type;
|
||||||
|
|
@ -398,6 +398,9 @@ public:
|
||||||
*/
|
*/
|
||||||
void redo (uint32_t n = 1) { do_redo (n); }
|
void redo (uint32_t n = 1) { do_redo (n); }
|
||||||
|
|
||||||
|
virtual void history_changed() = 0;
|
||||||
|
static void update_undo_redo_actions (PBD::UndoHistory const &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string _name;
|
std::string _name;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1319,9 +1319,10 @@ Editor::set_session (Session *t)
|
||||||
_session->locations()->removed.connect (_session_connections, invalidator (*this), boost::bind (&Editor::location_gone, this, _1), gui_context());
|
_session->locations()->removed.connect (_session_connections, invalidator (*this), boost::bind (&Editor::location_gone, this, _1), gui_context());
|
||||||
_session->locations()->changed.connect (_session_connections, invalidator (*this), boost::bind (&Editor::refresh_location_display, this), gui_context());
|
_session->locations()->changed.connect (_session_connections, invalidator (*this), boost::bind (&Editor::refresh_location_display, this), gui_context());
|
||||||
_session->auto_loop_location_changed.connect (_session_connections, invalidator (*this), boost::bind (&Editor::loop_location_changed, this, _1), gui_context ());
|
_session->auto_loop_location_changed.connect (_session_connections, invalidator (*this), boost::bind (&Editor::loop_location_changed, this, _1), gui_context ());
|
||||||
_session->history().Changed.connect (_session_connections, invalidator (*this), boost::bind (&Editor::history_changed, this), gui_context());
|
|
||||||
Location::flags_changed.connect (_session_connections, invalidator (*this), boost::bind (&Editor::update_section_rects, this), gui_context ());
|
Location::flags_changed.connect (_session_connections, invalidator (*this), boost::bind (&Editor::update_section_rects, this), gui_context ());
|
||||||
|
|
||||||
|
_session->history().Changed.connect (_session_connections, invalidator (*this), boost::bind (&Editor::history_changed, this), gui_context());
|
||||||
|
|
||||||
_playhead_cursor->track_canvas_item().reparent ((ArdourCanvas::Item*) get_cursor_scroll_group());
|
_playhead_cursor->track_canvas_item().reparent ((ArdourCanvas::Item*) get_cursor_scroll_group());
|
||||||
_playhead_cursor->show ();
|
_playhead_cursor->show ();
|
||||||
|
|
||||||
|
|
@ -3063,29 +3064,7 @@ Editor::history_changed ()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string label;
|
update_undo_redo_actions (_session->undo_redo());
|
||||||
|
|
||||||
if (undo_action) {
|
|
||||||
if (_session->undo_depth() == 0) {
|
|
||||||
label = S_("Command|Undo");
|
|
||||||
undo_action->set_sensitive(false);
|
|
||||||
} else {
|
|
||||||
label = string_compose(S_("Command|Undo (%1)"), _session->next_undo());
|
|
||||||
undo_action->set_sensitive(true);
|
|
||||||
}
|
|
||||||
undo_action->property_label() = label;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (redo_action) {
|
|
||||||
if (_session->redo_depth() == 0) {
|
|
||||||
label = _("Redo");
|
|
||||||
redo_action->set_sensitive (false);
|
|
||||||
} else {
|
|
||||||
label = string_compose(_("Redo (%1)"), _session->next_redo());
|
|
||||||
redo_action->set_sensitive (true);
|
|
||||||
}
|
|
||||||
redo_action->property_label() = label;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue