13
0

note range for midi * views API cleanup

This commit is contained in:
Paul Davis 2024-02-09 13:03:24 -07:00
parent 9d8ddd814c
commit 7899829a5e
8 changed files with 19 additions and 16 deletions

View File

@ -693,3 +693,9 @@ MidiRegionView::select_self_uniquely ()
{
_editing_context.set_selected_midi_region_view (*this);
}
void
MidiRegionView::set_visibility_note_range (MidiViewBackground::VisibleNoteRange vnr, bool from_selection)
{
dynamic_cast<MidiTimeAxisView*>(&trackview)->set_visibility_note_range (vnr, from_selection);
}

View File

@ -131,6 +131,8 @@ public:
void select_self_uniquely ();
void begin_drag_edit (std::string const & why);
void set_visibility_note_range (MidiViewBackground::VisibleNoteRange, bool);
protected:
void reset_width_dependent_items (double pixel_width);
void parameter_changed (std::string const & p);

View File

@ -746,12 +746,12 @@ MidiTimeAxisView::append_extra_display_menu_items ()
range_items.push_back (
MenuElem (_("Show Full Range"),
sigc::bind (sigc::mem_fun(*this, &MidiTimeAxisView::set_note_range),
sigc::bind (sigc::mem_fun(*this, &MidiTimeAxisView::set_visibility_note_range),
MidiStreamView::FullRange, true)));
range_items.push_back (
MenuElem (_("Fit Contents"),
sigc::bind (sigc::mem_fun(*this, &MidiTimeAxisView::set_note_range),
sigc::bind (sigc::mem_fun(*this, &MidiTimeAxisView::set_visibility_note_range),
MidiStreamView::ContentsRange, true)));
items.push_back (MenuElem (_("Note Range"), *range_menu));
@ -1326,11 +1326,11 @@ MidiTimeAxisView::set_color_mode (ColorMode mode, bool force, bool redisplay, bo
}
void
MidiTimeAxisView::set_note_range (MidiStreamView::VisibleNoteRange range, bool apply_to_selection)
MidiTimeAxisView::set_visibility_note_range (MidiStreamView::VisibleNoteRange range, bool apply_to_selection)
{
if (apply_to_selection) {
_editor.get_selection().tracks.foreach_midi_time_axis (
boost::bind (&MidiTimeAxisView::set_note_range, _1, range, false));
boost::bind (&MidiTimeAxisView::set_visibility_note_range, _1, range, false));
} else {
if (!_ignore_signals) {
midi_view()->set_note_visibility_range_style (range);

View File

@ -113,7 +113,7 @@ public:
void get_per_region_note_selection (std::list<std::pair<PBD::ID, std::set<std::shared_ptr<Evoral::Note<Temporal::Beats> > > > >&);
void use_midnam_info ();
void set_note_range (MidiStreamView::VisibleNoteRange range, bool apply_to_selection = false);
void set_visibility_note_range (MidiStreamView::VisibleNoteRange range, bool apply_to_selection = false);
protected:
void start_step_editing ();

View File

@ -300,6 +300,7 @@ class MidiView : public virtual sigc::trackable
void show_list_editor ();
void set_note_range (uint8_t low, uint8_t high);
virtual void set_visibility_note_range (MidiViewBackground::VisibleNoteRange, bool) {};
typedef std::set<NoteBase*> Selection;
Selection const & selection () const {

View File

@ -652,7 +652,7 @@ PianoRollHeader::on_button_press_event (GdkEventButton* ev)
if (ev->type == GDK_2BUTTON_PRESS) {
MidiTimeAxisView* mtv = dynamic_cast<MidiTimeAxisView*>(&_view.trackview());
if (mtv) {
mtv->set_note_range (MidiStreamView::ContentsRange, false);
mtv->set_visibility_note_range (MidiStreamView::ContentsRange, false);
}
return true;
}

View File

@ -253,13 +253,12 @@ PianoRollHeader::get_path (int note, double x[], double y[]) const
{
double y_pos = floor(_view.midi_context().note_to_y(note));
double note_height;
_raw_note_height = floor(_view.midi_context().note_to_y(note - 1)) - y_pos;
double width = get().width() - 1.0f;
if (note == 0) {
note_height = floor(_view.midi_context().contents_height()) - y_pos;
} else {
note_height = _raw_note_height <= 3 ? _raw_note_height : _raw_note_height - 1.f;
note_height = _view.midi_context().note_height() <= 3 ? _view.midi_context().note_height() : _view.midi_context().note_height() - 1.f;
}
x[0] = _scroomer_size;
@ -647,7 +646,7 @@ PianoRollHeader::motion_handler (GdkEventMotion* ev)
case TOP:
real_val_at_pointer = real_val_at_pointer <= _saved_top_val? _adj.get_value() + _adj.get_page_size() : real_val_at_pointer;
real_val_at_pointer = min(127.0, real_val_at_pointer);
if (_note_height >= UIConfiguration::instance().get_max_note_height()){
if (_view.midi_context().note_height() >= UIConfiguration::instance().get_max_note_height()){
_saved_top_val = min(_adj.get_value() + _adj.get_page_size (), 127.0);
} else {
_saved_top_val = 0.0;
@ -659,7 +658,7 @@ PianoRollHeader::motion_handler (GdkEventMotion* ev)
case BOTTOM:
real_val_at_pointer = max(0.0, real_val_at_pointer);
real_val_at_pointer = real_val_at_pointer >= _saved_bottom_val? _adj.get_value() : real_val_at_pointer;
if (_note_height >= UIConfiguration::instance().get_max_note_height()){
if (_view.midi_context().note_height() >= UIConfiguration::instance().get_max_note_height()){
_saved_bottom_val = _adj.get_value();
} else {
_saved_bottom_val = 127.0;
@ -719,7 +718,7 @@ PianoRollHeader::button_press_handler (GdkEventButton* ev)
if (ev->button == 1 && ev->x <= _scroomer_size){
if (ev->type == GDK_2BUTTON_PRESS) {
// _view.set_note_range (MidiStreamView::ContentsRange, false);
_view.set_note_range (MidiStreamView::ContentsRange, false);
return true;
}
@ -858,7 +857,6 @@ PianoRollHeader::leave_handler (GdkEventCrossing*)
void
PianoRollHeader::note_range_changed ()
{
_note_height = floor (_view.midi_context().note_height ()) + 0.5f;
redraw ();
}

View File

@ -122,7 +122,6 @@ private:
double _old_y;
double _fract;
double _fract_top;
mutable double _raw_note_height;
double _min_page_size;
enum scr_pos {TOP, BOTTOM, MOVE, NONE};
scr_pos _scroomer_state;
@ -132,9 +131,6 @@ private:
mutable bool _mini_map_display;
bool entered;
double _note_height;
double _old_av_note_height;
bool show_scroomer () const;
ArdourCanvas::Rect _alloc;