2006-07-23 12:03:19 +00:00
/*
2019-08-02 23:26:43 +02:00
* Copyright ( C ) 2006 - 2014 David Robillard < d @ drobilla . net >
* Copyright ( C ) 2007 Doug McLain < doug @ nostar . net >
* Copyright ( C ) 2008 - 2017 Paul Davis < paul @ linuxaudiosystems . com >
* Copyright ( C ) 2009 - 2012 Carl Hetherington < carl @ carlh . net >
* Copyright ( C ) 2016 - 2017 Robin Gareus < robin @ gareus . org >
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License along
* with this program ; if not , write to the Free Software Foundation , Inc . ,
* 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 USA .
*/
2006-07-23 12:03:19 +00:00
# ifndef __ardour_midi_streamview_h__
# define __ardour_midi_streamview_h__
# include <list>
# include <cmath>
2009-02-25 18:26:51 +00:00
# include "ardour/location.h"
2006-07-23 12:03:19 +00:00
# include "enums.h"
# include "streamview.h"
2007-08-04 04:18:34 +00:00
# include "time_axis_view_item.h"
# include "route_time_axis.h"
2006-07-23 12:03:19 +00:00
namespace Gdk {
class Color ;
}
namespace ARDOUR {
class Crossfade ;
2012-05-24 02:54:10 +00:00
class MidiModel ;
2006-07-23 12:03:19 +00:00
class MidiRegion ;
2012-05-24 02:54:10 +00:00
class Route ;
2006-07-23 12:03:19 +00:00
class Source ;
2012-05-24 02:54:10 +00:00
struct PeakData ;
2006-07-23 12:03:19 +00:00
}
2013-04-04 00:32:52 -04:00
namespace ArdourCanvas {
class LineSet ;
}
2006-07-23 12:03:19 +00:00
class PublicEditor ;
class Selectable ;
class MidiTimeAxisView ;
class MidiRegionView ;
class RegionSelection ;
class CrossfadeView ;
class Selection ;
class MidiStreamView : public StreamView
{
2017-07-01 21:11:14 +02:00
public :
2009-07-09 17:58:13 +00:00
MidiStreamView ( MidiTimeAxisView & ) ;
2006-07-23 12:03:19 +00:00
~ MidiStreamView ( ) ;
2009-05-12 17:03:42 +00:00
void get_inverted_selectables ( Selection & , std : : list < Selectable * > & results ) ;
2020-04-16 12:16:45 -06:00
void get_regions_with_selected_data ( RegionSelection & ) ;
2006-07-23 12:03:19 +00:00
2007-07-15 01:56:11 +00:00
enum VisibleNoteRange {
FullRange ,
ContentsRange
} ;
2008-01-13 17:45:17 +00:00
Gtk : : Adjustment note_range_adjustment ;
2007-08-06 06:09:41 +00:00
void set_note_range ( VisibleNoteRange r ) ;
2007-07-15 01:56:11 +00:00
2008-09-23 02:40:29 +00:00
inline uint8_t lowest_note ( ) const { return _lowest_note ; }
inline uint8_t highest_note ( ) const { return _highest_note ; }
2009-10-14 16:10:01 +00:00
2008-09-23 02:40:29 +00:00
void update_note_range ( uint8_t note_num ) ;
2009-10-14 16:10:01 +00:00
2017-01-29 15:02:07 +01:00
void set_layer_display ( LayerDisplay ) ;
2017-07-01 21:11:14 +02:00
//bool can_change_layer_display() const { return false; } // revert this change for now. Although stacked view is weirdly implemented wrt the "scroomer", it is still necessary to be able to manage layered regions.
2010-04-21 20:42:22 +00:00
void redisplay_track ( ) ;
2009-10-14 16:10:01 +00:00
2017-07-01 21:11:14 +02:00
inline double contents_height ( ) const {
return ( child_height ( ) - TimeAxisViewItem : : NAME_HIGHLIGHT_SIZE - 2 ) ;
}
2009-10-14 16:10:01 +00:00
2017-07-01 21:11:14 +02:00
inline double note_to_y ( uint8_t note ) const {
return contents_height ( ) - ( note + 1 - lowest_note ( ) ) * note_height ( ) + 1 ;
}
2009-10-14 16:10:01 +00:00
2011-03-07 17:17:11 +00:00
uint8_t y_to_note ( double y ) const ;
2009-10-14 16:10:01 +00:00
2017-07-01 21:11:14 +02:00
inline double note_height ( ) const {
return contents_height ( ) / ( double ) contents_note_range ( ) ;
}
2009-10-14 16:10:01 +00:00
2017-07-01 21:11:14 +02:00
inline uint8_t contents_note_range ( ) const {
return highest_note ( ) - lowest_note ( ) + 1 ;
}
2009-10-14 16:10:01 +00:00
2008-01-13 17:45:17 +00:00
sigc : : signal < void > NoteRangeChanged ;
2007-07-05 07:02:24 +00:00
2023-02-16 16:33:28 -07:00
RegionView * create_region_view ( std : : shared_ptr < ARDOUR : : Region > , bool , bool ) ;
2009-06-08 19:28:51 +00:00
2020-10-19 12:37:54 -06:00
bool paste ( Temporal : : timepos_t const & pos , const Selection & selection , PasteContext & ctx ) ;
2014-12-16 14:37:40 -05:00
2010-10-08 14:54:16 +00:00
void apply_note_range ( uint8_t lowest , uint8_t highest , bool to_region_views ) ;
2011-04-16 13:31:27 +00:00
void suspend_updates ( ) ;
void resume_updates ( ) ;
2022-12-09 01:36:15 +01:00
ArdourCanvas : : Container * midi_underlay ( ) const { return _midi_underlay ; }
ArdourCanvas : : Container * region_canvas ( ) const { return _region_group ; }
2023-02-05 11:36:24 -07:00
void parameter_changed ( std : : string const & ) ;
2017-07-01 21:11:14 +02:00
protected :
2006-07-23 12:03:19 +00:00
void setup_rec_box ( ) ;
2010-10-08 14:54:16 +00:00
void update_rec_box ( ) ;
2008-09-23 02:40:29 +00:00
2022-12-09 01:36:15 +01:00
ArdourCanvas : : Container * _midi_underlay ;
ArdourCanvas : : Container * _region_group ;
2017-07-01 21:11:14 +02:00
private :
2014-12-17 18:40:38 -05:00
2008-09-23 02:40:29 +00:00
RegionView * add_region_view_internal (
2023-02-16 16:33:28 -07:00
std : : shared_ptr < ARDOUR : : Region > ,
2017-07-01 21:11:14 +02:00
bool wait_for_waves ,
bool recording = false ) ;
2008-09-23 02:40:29 +00:00
void display_region ( MidiRegionView * region_view , bool load_model ) ;
2023-02-16 16:33:28 -07:00
void display_track ( std : : shared_ptr < ARDOUR : : Track > tr ) ;
2009-10-14 16:10:01 +00:00
2008-09-19 19:32:10 +00:00
void update_contents_height ( ) ;
2010-06-24 19:46:28 +00:00
2008-01-13 17:45:17 +00:00
void draw_note_lines ( ) ;
2008-09-23 02:40:29 +00:00
bool update_data_note_range ( uint8_t min , uint8_t max ) ;
2023-02-16 16:33:28 -07:00
void update_contents_metrics ( std : : shared_ptr < ARDOUR : : Region > r ) ;
2006-07-23 12:03:19 +00:00
2007-06-15 22:08:27 +00:00
void color_handler ( ) ;
2007-07-05 07:02:24 +00:00
2008-01-13 17:45:17 +00:00
void note_range_adjustment_changed ( ) ;
2011-04-16 13:31:27 +00:00
void apply_note_range_to_regions ( ) ;
2008-01-13 17:45:17 +00:00
2008-09-23 02:40:29 +00:00
bool _range_dirty ;
2008-01-13 17:45:17 +00:00
double _range_sum_cache ;
2008-09-23 02:40:29 +00:00
uint8_t _lowest_note ; ///< currently visible
uint8_t _highest_note ; ///< currently visible
uint8_t _data_note_min ; ///< in data
uint8_t _data_note_max ; ///< in data
2008-09-24 19:39:01 +00:00
ArdourCanvas : : LineSet * _note_lines ;
2011-04-16 13:31:27 +00:00
/** true if updates to the note lines and regions are currently suspended */
bool _updates_suspended ;
2006-07-23 12:03:19 +00:00
} ;
# endif /* __ardour_midi_streamview_h__ */