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

View File

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

View File

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

View File

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

View File

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

View File

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