13
0

adjust relationship between VerboseCursor and Editor to use EditingContext

This commit is contained in:
Paul Davis 2023-11-18 18:40:50 -07:00
parent 8bbe117e6b
commit b4e592a469
6 changed files with 19 additions and 18 deletions

View File

@ -31,6 +31,7 @@
#include "midi_region_view.h"
#include "selection.h"
#include "selection_memento.h"
#include "verbose_cursor.h"
#include "pbd/i18n.h"
@ -91,6 +92,8 @@ EditingContext::EditingContext ()
, _verbose_cursor (nullptr)
{
grid_type_strings = I18N (_grid_type_strings);
_verbose_cursor = new VerboseCursor (*this);
}
EditingContext::~EditingContext()

View File

@ -255,6 +255,8 @@ public:
ArdourCanvas::Rectangle* rubberband_rect;
virtual ArdourCanvas::Container* get_noscroll_group() const = 0;
protected:
Glib::RefPtr<Gtk::ActionGroup> _midi_actions;
@ -339,7 +341,6 @@ public:
MouseCursors* _cursors;
friend class VerboseCursor;
VerboseCursor* _verbose_cursor;
};

View File

@ -855,8 +855,6 @@ private:
bool within_track_canvas;
friend class VerboseCursor;
RegionPeakCursor* _region_peak_cursor;
void parameter_changed (std::string);

View File

@ -112,7 +112,6 @@ Editor::initialize_canvas ()
CANVAS_DEBUG_NAME (cursor_scroll_group, "canvas cursor scroll");
_track_canvas->add_scroller (*cg);
_verbose_cursor = new VerboseCursor (this);
_region_peak_cursor = new RegionPeakCursor (get_noscroll_group ());
/*a group to hold global rects like punch/loop indicators */

View File

@ -30,7 +30,7 @@
#include "canvas/tracking_text.h"
#include "audio_clock.h"
#include "editor.h"
#include "editing_context.h"
#include "editor_drag.h"
#include "main_clock.h"
#include "verbose_cursor.h"
@ -43,10 +43,10 @@ using namespace std;
using namespace ARDOUR;
using namespace Temporal;
VerboseCursor::VerboseCursor (Editor* editor)
VerboseCursor::VerboseCursor (EditingContext& editor)
: _editor (editor)
{
_canvas_item = new ArdourCanvas::TrackingText (_editor->get_noscroll_group());
_canvas_item = new ArdourCanvas::TrackingText (_editor.get_noscroll_group());
CANVAS_DEBUG_NAME (_canvas_item, "verbose canvas cursor");
_canvas_item->set_font_description (Pango::FontDescription (UIConfiguration::instance().get_LargerBoldFont()));
color_handler ();
@ -103,7 +103,7 @@ VerboseCursor::set_time (samplepos_t sample)
Timecode::Time timecode;
Temporal::BBT_Time bbt;
if (_editor->_session == 0) {
if (_editor.session() == 0) {
return;
}
@ -118,16 +118,16 @@ VerboseCursor::set_time (samplepos_t sample)
break;
case AudioClock::Timecode:
_editor->_session->timecode_time (sample, timecode);
_editor.session()->timecode_time (sample, timecode);
snprintf (buf, sizeof (buf), "%s", Timecode::timecode_format_time (timecode).c_str());
break;
case AudioClock::MinSec:
AudioClock::print_minsec (sample, buf, sizeof (buf), _editor->_session->sample_rate());
AudioClock::print_minsec (sample, buf, sizeof (buf), _editor.session()->sample_rate());
break;
case AudioClock::Seconds:
snprintf (buf, sizeof(buf), "%.1f", sample / (float)_editor->_session->sample_rate());
snprintf (buf, sizeof(buf), "%.1f", sample / (float)_editor.session()->sample_rate());
break;
default:
@ -147,7 +147,7 @@ VerboseCursor::set_duration (samplepos_t start, samplepos_t end)
Temporal::BBT_Time ebbt;
Meter const & meter_at_start (TempoMap::use()->metric_at (timepos_t (start)).meter());
if (_editor->_session == 0) {
if (_editor.session() == 0) {
return;
}
@ -191,16 +191,16 @@ VerboseCursor::set_duration (samplepos_t start, samplepos_t end)
}
case AudioClock::Timecode:
_editor->_session->timecode_duration (end - start, timecode);
_editor.session()->timecode_duration (end - start, timecode);
snprintf (buf, sizeof (buf), "%s", Timecode::timecode_format_time (timecode).c_str());
break;
case AudioClock::MinSec:
AudioClock::print_minsec (end - start, buf, sizeof (buf), _editor->_session->sample_rate());
AudioClock::print_minsec (end - start, buf, sizeof (buf), _editor.session()->sample_rate());
break;
case AudioClock::Seconds:
snprintf (buf, sizeof(buf), "%.1f", (end - start) / (float)_editor->_session->sample_rate());
snprintf (buf, sizeof(buf), "%.1f", (end - start) / (float)_editor.session()->sample_rate());
break;
default:

View File

@ -23,7 +23,7 @@
#include "ardour/types.h"
#include "canvas/canvas.h"
class Editor;
class EditingContext;
namespace ArdourCanvas {
class TrackingText;
@ -32,7 +32,7 @@ namespace ArdourCanvas {
class VerboseCursor
{
public:
VerboseCursor (Editor *);
VerboseCursor (EditingContext&);
ArdourCanvas::Item* canvas_item () const;
bool visible () const;
@ -46,7 +46,7 @@ public:
void hide ();
private:
Editor* _editor;
EditingContext& _editor;
ArdourCanvas::TrackingText* _canvas_item;
void color_handler ();