mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 23:05:04 +01:00
tempo bar and BBT ruler in MIDI cue editor
This commit is contained in:
parent
a523551228
commit
10244c0360
5 changed files with 36 additions and 13 deletions
|
|
@ -47,13 +47,13 @@ using namespace Gtkmm2ext;
|
||||||
using namespace Temporal;
|
using namespace Temporal;
|
||||||
|
|
||||||
MidiCueEditor::MidiCueEditor()
|
MidiCueEditor::MidiCueEditor()
|
||||||
: vertical_adjustment (0.0, 0.0, 10.0, 400.0)
|
: timebar_height (15.)
|
||||||
|
, n_timebars (2)
|
||||||
|
, vertical_adjustment (0.0, 0.0, 10.0, 400.0)
|
||||||
, horizontal_adjustment (0.0, 0.0, 1e16)
|
, horizontal_adjustment (0.0, 0.0, 1e16)
|
||||||
, view (nullptr)
|
, view (nullptr)
|
||||||
, mouse_mode (Editing::MouseDraw)
|
, mouse_mode (Editing::MouseDraw)
|
||||||
, bbt_metric (*this)
|
, bbt_metric (*this)
|
||||||
, timebar_height (15.)
|
|
||||||
, n_timebars (1)
|
|
||||||
{
|
{
|
||||||
build_canvas ();
|
build_canvas ();
|
||||||
|
|
||||||
|
|
@ -121,17 +121,24 @@ MidiCueEditor::build_canvas ()
|
||||||
rubberband_rect->set_fill_color (UIConfiguration::instance().color_mod ("rubber band rect", "selection rect"));
|
rubberband_rect->set_fill_color (UIConfiguration::instance().color_mod ("rubber band rect", "selection rect"));
|
||||||
CANVAS_DEBUG_NAME (rubberband_rect, X_("cue rubberband rect"));
|
CANVAS_DEBUG_NAME (rubberband_rect, X_("cue rubberband rect"));
|
||||||
|
|
||||||
|
tempo_bar = new ArdourCanvas::Rectangle (time_line_group, ArdourCanvas::Rect (0.0, 0.0, ArdourCanvas::COORD_MAX, timebar_height));
|
||||||
|
CANVAS_DEBUG_NAME (tempo_bar, "Tempo Bar");
|
||||||
|
tempo_bar->set_fill(true);
|
||||||
|
tempo_bar->set_outline(false);
|
||||||
|
tempo_bar->set_outline_what(ArdourCanvas::Rectangle::BOTTOM);
|
||||||
|
// tempo_bar->set_fill_color (UIConfiguration::instance().color_mod ("tempo bar", "marker bar"));
|
||||||
|
tempo_bar->set_fill_color (0xff0000ff);
|
||||||
|
|
||||||
Pango::FontDescription font (UIConfiguration::instance().get_SmallerFont());
|
Pango::FontDescription font (UIConfiguration::instance().get_SmallerFont());
|
||||||
Pango::FontDescription larger_font (UIConfiguration::instance().get_SmallBoldFont());
|
Pango::FontDescription larger_font (UIConfiguration::instance().get_SmallBoldFont());
|
||||||
bbt_ruler = new ArdourCanvas::Ruler (time_line_group, &bbt_metric, ArdourCanvas::Rect (0, 0, ArdourCanvas::COORD_MAX, timebar_height));
|
bbt_ruler = new ArdourCanvas::Ruler (time_line_group, &bbt_metric, ArdourCanvas::Rect (0, timebar_height, ArdourCanvas::COORD_MAX, timebar_height * 2));
|
||||||
bbt_ruler->set_font_description (font);
|
bbt_ruler->set_font_description (font);
|
||||||
bbt_ruler->set_second_font_description (larger_font);
|
bbt_ruler->set_second_font_description (larger_font);
|
||||||
Gtkmm2ext::Color base = UIConfiguration::instance().color ("ruler base");
|
Gtkmm2ext::Color base = UIConfiguration::instance().color ("ruler base");
|
||||||
Gtkmm2ext::Color text = UIConfiguration::instance().color ("ruler text");
|
Gtkmm2ext::Color text = UIConfiguration::instance().color ("ruler text");
|
||||||
bbt_ruler->set_fill_color (base);
|
bbt_ruler->set_fill_color (base);
|
||||||
bbt_ruler->set_outline_color (text);
|
bbt_ruler->set_outline_color (text);
|
||||||
CANVAS_DEBUG_NAME (bbt_ruler, "bbt ruler");
|
CANVAS_DEBUG_NAME (bbt_ruler, "cue bbt ruler");
|
||||||
|
|
||||||
data_group = new ArdourCanvas::Container (hv_scroll_group);
|
data_group = new ArdourCanvas::Container (hv_scroll_group);
|
||||||
data_group->move (ArdourCanvas::Duple (0., timebar_height * n_timebars));
|
data_group->move (ArdourCanvas::Duple (0., timebar_height * n_timebars));
|
||||||
|
|
@ -176,10 +183,15 @@ MidiCueEditor::canvas_enter_leave (GdkEventCrossing* ev)
|
||||||
void
|
void
|
||||||
MidiCueEditor::canvas_allocate (Gtk::Allocation alloc)
|
MidiCueEditor::canvas_allocate (Gtk::Allocation alloc)
|
||||||
{
|
{
|
||||||
|
_visible_canvas_width = alloc.get_width();
|
||||||
|
_visible_canvas_height = alloc.get_height();
|
||||||
|
|
||||||
bg->set_size (alloc.get_width(), alloc.get_height());
|
bg->set_size (alloc.get_width(), alloc.get_height());
|
||||||
|
std::cerr << "bg is " << bg->width() << std::endl;
|
||||||
|
|
||||||
if (view) {
|
if (view) {
|
||||||
view->set_size (alloc.get_width(), alloc.get_height() - (timebar_height * n_timebars));
|
ArdourCanvas::Rect r (0., timebar_height * n_timebars, ArdourCanvas::COORD_MAX, alloc.get_height() - (timebar_height * n_timebars));
|
||||||
|
view->set_size (r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -231,7 +243,11 @@ MidiCueEditor::reset_zoom (samplecnt_t spp)
|
||||||
view->set_samples_per_pixel (spp);
|
view->set_samples_per_pixel (spp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cerr << "RZ @ " << spp << " cps " << current_page_samples() << " vcw " << _visible_canvas_width << std::endl;
|
||||||
|
|
||||||
bbt_ruler->set_range (0, current_page_samples());
|
bbt_ruler->set_range (0, current_page_samples());
|
||||||
|
compute_bbt_ruler_scale (0, current_page_samples());
|
||||||
|
bbt_metric.units_per_pixel = spp;
|
||||||
}
|
}
|
||||||
|
|
||||||
samplecnt_t
|
samplecnt_t
|
||||||
|
|
@ -315,6 +331,8 @@ MidiCueEditor::set_region (std::shared_ptr<ARDOUR::MidiTrack> t, std::shared_ptr
|
||||||
double width = bg->width();
|
double width = bg->width();
|
||||||
samplecnt_t samples = duration.samples();
|
samplecnt_t samples = duration.samples();
|
||||||
|
|
||||||
|
std::cerr << "region is " << samples << " long\n";
|
||||||
|
|
||||||
samplecnt_t spp = floor (samples / width);
|
samplecnt_t spp = floor (samples / width);
|
||||||
reset_zoom (spp);
|
reset_zoom (spp);
|
||||||
}
|
}
|
||||||
|
|
@ -502,6 +520,8 @@ edit_last_mark_label (std::vector<ArdourCanvas::Ruler::Mark>& marks, const std::
|
||||||
void
|
void
|
||||||
MidiCueEditor::metric_get_bbt (std::vector<ArdourCanvas::Ruler::Mark>& marks, samplepos_t leftmost, samplepos_t rightmost, gint /*maxchars*/)
|
MidiCueEditor::metric_get_bbt (std::vector<ArdourCanvas::Ruler::Mark>& marks, samplepos_t leftmost, samplepos_t rightmost, gint /*maxchars*/)
|
||||||
{
|
{
|
||||||
|
std::cerr << "MCE:mgb s = " << _session << std::endl;
|
||||||
|
|
||||||
if (_session == 0) {
|
if (_session == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,9 @@ class MidiCueEditor : public CueEditor
|
||||||
Editing::MouseMode current_mouse_mode () const;
|
Editing::MouseMode current_mouse_mode () const;
|
||||||
bool internal_editing() const;
|
bool internal_editing() const;
|
||||||
|
|
||||||
|
double timebar_height;
|
||||||
|
size_t n_timebars;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Temporal::timepos_t snap_to_grid (Temporal::timepos_t const & start,
|
Temporal::timepos_t snap_to_grid (Temporal::timepos_t const & start,
|
||||||
Temporal::RoundMode direction,
|
Temporal::RoundMode direction,
|
||||||
|
|
@ -122,6 +125,7 @@ class MidiCueEditor : public CueEditor
|
||||||
ArdourCanvas::Container* data_group;
|
ArdourCanvas::Container* data_group;
|
||||||
ArdourCanvas::Container* time_line_group;
|
ArdourCanvas::Container* time_line_group;
|
||||||
ArdourCanvas::Ruler* bbt_ruler;
|
ArdourCanvas::Ruler* bbt_ruler;
|
||||||
|
ArdourCanvas::Rectangle* tempo_bar;
|
||||||
|
|
||||||
ArdourCanvas::Rectangle* transport_loop_range_rect;
|
ArdourCanvas::Rectangle* transport_loop_range_rect;
|
||||||
|
|
||||||
|
|
@ -153,8 +157,6 @@ class MidiCueEditor : public CueEditor
|
||||||
};
|
};
|
||||||
|
|
||||||
BBTMetric bbt_metric;
|
BBTMetric bbt_metric;
|
||||||
double timebar_height;
|
|
||||||
size_t n_timebars;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -408,8 +408,6 @@ MidiView::button_press (GdkEventButton* ev)
|
||||||
bool
|
bool
|
||||||
MidiView::button_release (GdkEventButton* ev)
|
MidiView::button_release (GdkEventButton* ev)
|
||||||
{
|
{
|
||||||
std::cerr << "ho1\n";
|
|
||||||
|
|
||||||
double event_x, event_y;
|
double event_x, event_y;
|
||||||
|
|
||||||
if (ev->button != 1) {
|
if (ev->button != 1) {
|
||||||
|
|
@ -450,11 +448,9 @@ MidiView::button_release (GdkEventButton* ev)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AddDragging:
|
case AddDragging:
|
||||||
std::cerr << "AD\n";
|
|
||||||
/* Don't a ghost note when we added a note - wait until motion to avoid visual confusion.
|
/* Don't a ghost note when we added a note - wait until motion to avoid visual confusion.
|
||||||
we don't want one when we were drag-selecting either. */
|
we don't want one when we were drag-selecting either. */
|
||||||
case SelectRectDragging:
|
case SelectRectDragging:
|
||||||
std::cerr << "SRD\n";
|
|
||||||
_editing_context.drags()->end_grab ((GdkEvent *) ev);
|
_editing_context.drags()->end_grab ((GdkEvent *) ev);
|
||||||
_mouse_state = None;
|
_mouse_state = None;
|
||||||
break;
|
break;
|
||||||
|
|
@ -602,7 +598,11 @@ MidiView::scroll (GdkEventScroll* ev)
|
||||||
set_note_range (min (127, _midi_context.lowest_note() - step), max (0, _midi_context.highest_note() - step));
|
set_note_range (min (127, _midi_context.lowest_note() - step), max (0, _midi_context.highest_note() - step));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
case GDK_SCROLL_LEFT:
|
||||||
|
break;
|
||||||
|
case GDK_SCROLL_RIGHT:
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -533,7 +533,6 @@ GtkCanvas::re_enter ()
|
||||||
DEBUG_TRACE (PBD::DEBUG::CanvasEnterLeave, "re-enter canvas by request\n");
|
DEBUG_TRACE (PBD::DEBUG::CanvasEnterLeave, "re-enter canvas by request\n");
|
||||||
_current_item = 0;
|
_current_item = 0;
|
||||||
pick_current_item (0);
|
pick_current_item (0);
|
||||||
PBD::stacktrace (std::cerr, 20);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Construct a GtkCanvas */
|
/** Construct a GtkCanvas */
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,8 @@ Ruler::set_second_font_description (Pango::FontDescription fd)
|
||||||
void
|
void
|
||||||
Ruler::render (Rect const & area, Cairo::RefPtr<Cairo::Context> cr) const
|
Ruler::render (Rect const & area, Cairo::RefPtr<Cairo::Context> cr) const
|
||||||
{
|
{
|
||||||
|
std::cerr << whoami() << " ruler render " << _lower << " .. " << _upper << "\n";
|
||||||
|
|
||||||
if (_lower == _upper) {
|
if (_lower == _upper) {
|
||||||
/* nothing to draw */
|
/* nothing to draw */
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue