Ardour  9.7-250-g422e6c7d80
midi_view_background.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2014 David Robillard <d@drobilla.net>
3  * Copyright (C) 2007 Doug McLain <doug@nostar.net>
4  * Copyright (C) 2008-2017 Paul Davis <paul@linuxaudiosystems.com>
5  * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
6  * Copyright (C) 2016-2017 Robin Gareus <robin@gareus.org>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 
23 #ifndef __gtk2_ardour_midi_view_background_h__
24 #define __gtk2_ardour_midi_view_background_h__
25 
26 #include <cstdint>
27 
28 #include <ytkmm/adjustment.h>
29 
30 #include "pbd/signals.h"
31 
32 #include "ardour/types.h"
33 
34 #include "gtkmm2ext/colors.h"
35 
36 #include "view_background.h"
37 
38 namespace ARDOUR {
39  class InstrumentInfo;
40  class MidiTrack;
41 }
42 
43 namespace ArdourCanvas {
44  class Item;
45  class RectSet;
46 }
47 
48 namespace Gtk {
49  class Menu;
50  class MenuItem;
51  class CheckMenuItem;
52 }
53 
54 class EditingContext;
55 
62 class MidiViewBackground : public virtual ViewBackground
63 {
64  public:
67 
69 
72  mvb.NoteRangeChanged.block ();
73  }
74 
76  mvb.NoteRangeChanged.unblock ();
77  mvb.NoteRangeChanged(); /* EMIT SIGNAL */
78  }
79 
81  };
82 
86  UserRange
87  };
88 
89  virtual std::shared_ptr<ARDOUR::MidiTrack> midi_track() const = 0;
90 
93  sigc::signal<void> NoteModeChanged;
94 
97 
100 
101  inline uint8_t lowest_note() const { return _lowest_note; }
102  inline uint8_t highest_note() const { return _highest_note; }
103 
104  void maybe_extend_note_range (uint8_t note_num);
105 
106  double note_height() const;
107  int note_to_y (uint8_t note) const;
108  uint8_t y_to_note (int y) const;
109  bool note_visible(uint8_t note) const;
110 
111  uint8_t contents_note_range() const {
112  return highest_note() - lowest_note() + 1;
113  }
114 
115  sigc::signal<void> NoteRangeChanged;
116 
117  bool apply_note_range (uint8_t lowest, uint8_t highest, bool to_children);
118  bool maybe_apply_note_range (uint8_t lowest, uint8_t highest, bool to_children);
119 
120  bool scroll (GdkEventScroll* ev);
121 
123  virtual int y_position () const { return 0; }
124 
125  virtual uint8_t get_preferred_midi_channel () const = 0;
126  virtual void set_note_highlight (uint8_t) = 0;
127  virtual void record_layer_check (std::shared_ptr<ARDOUR::Region>, samplepos_t) = 0;
128 
129  virtual void set_size (int w, int h) {}
131 
133 
134  void get_note_positions (std::vector<int>& numbers, std::vector<double>& pos, std::vector<double>& heights) const;
135 
137 
138  sigc::signal<void,bool> NoteVisibilityShouldChange;
139 
140  bool update_data_note_range (uint8_t min, uint8_t max);
141  uint8_t highest_data_note() const { return _data_note_max; }
142  uint8_t lowest_data_note() const { return _data_note_min; }
143 
147 
150 
151  protected:
155  uint8_t _lowest_note;
156  uint8_t _highest_note;
157  uint8_t _data_note_min;
158  uint8_t _data_note_max;
166 
167  void color_handler ();
168  void parameter_changed (std::string const &);
171  virtual void apply_note_range_to_children () = 0;
172  virtual bool updates_suspended() const { return false; }
173 
176 };
177 
178 
179 #endif /* __gtk2_ardour_midi_view_background_h__ */
Gtk::MenuItem * kep_menu_hack
ArdourCanvas::RectSet * _note_lines
ARDOUR::ColorMode _color_mode
uint8_t y_to_note(int y) const
void set_note_visibility_range_style(VisibleNoteRange r)
void set_color_mode(ARDOUR::ColorMode)
void update_contents_height()
bool maybe_apply_note_range(uint8_t lowest, uint8_t highest, bool to_children)
void sync_data_and_visual_range()
ARDOUR::NoteMode note_mode() const
void property_change(PBD::PropertyChange const &)
virtual void apply_note_range_to_children()=0
void toggle_key_enforcement_policy(ARDOUR::KeyEnforcementPolicy kepb, Gtk::CheckMenuItem *item)
sigc::signal< void > NoteModeChanged
VisibleNoteRange _visibility_note_range
bool note_visible(uint8_t note) const
void connect_property_changes()
void disconnect_property_changes()
virtual std::shared_ptr< ARDOUR::MidiTrack > midi_track() const =0
PBD::ScopedConnection track_property_connection
uint8_t lowest_note() const
virtual bool updates_suspended() const
uint8_t _data_note_min
in data
virtual void set_size(int w, int h)
void maybe_extend_note_range(uint8_t note_num)
bool apply_note_range(uint8_t lowest, uint8_t highest, bool to_children)
void get_note_positions(std::vector< int > &numbers, std::vector< double > &pos, std::vector< double > &heights) const
double note_height() const
VisibleNoteRange visibility_range_style() const
void set_note_mode(ARDOUR::NoteMode nm)
Gtk::Adjustment note_range_adjustment
uint8_t contents_note_range() const
void note_range_adjustment_changed()
PBD::Signal< void()> HeightChanged
ARDOUR::ColorMode color_mode() const
bool update_data_note_range(uint8_t min, uint8_t max)
bool scroll(GdkEventScroll *ev)
MidiViewBackground(ArdourCanvas::Item *parent, EditingContext &ec)
uint8_t _highest_note
currently visible
uint8_t highest_data_note() const
virtual ARDOUR::InstrumentInfo * instrument_info() const =0
int note_to_y(uint8_t note) const
Gtk::Menu * build_key_enforcement_menu()
ARDOUR::NoteMode _note_mode
uint8_t _data_note_max
in data
uint8_t lowest_data_note() const
virtual uint8_t get_preferred_midi_channel() const =0
sigc::signal< void > NoteRangeChanged
sigc::signal< void, bool > NoteVisibilityShouldChange
EditingContext & editing_context() const
EditingContext & _editing_context
virtual void record_layer_check(std::shared_ptr< ARDOUR::Region >, samplepos_t)=0
uint8_t highest_note() const
virtual void set_note_highlight(uint8_t)=0
void parameter_changed(std::string const &)
uint8_t _lowest_note
currently visible
virtual int y_position() const
Temporal::samplepos_t samplepos_t
Definition: ardour_ui.h:182