2006-07-23 08:03:19 -04:00
/*
2019-08-02 17:26:43 -04: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 08:03:19 -04:00
# ifndef __ardour_midi_streamview_h__
# define __ardour_midi_streamview_h__
# include <list>
# include <cmath>
2009-02-25 13:26:51 -05:00
# include "ardour/location.h"
2006-07-23 08:03:19 -04:00
# include "enums.h"
# include "streamview.h"
2007-08-04 00:18:34 -04:00
# include "time_axis_view_item.h"
# include "route_time_axis.h"
2006-07-23 08:03:19 -04:00
namespace Gdk {
class Color ;
}
namespace ARDOUR {
class Crossfade ;
2012-05-23 22:54:10 -04:00
class MidiModel ;
2006-07-23 08:03:19 -04:00
class MidiRegion ;
2012-05-23 22:54:10 -04:00
class Route ;
2006-07-23 08:03:19 -04:00
class Source ;
2012-05-23 22:54:10 -04:00
struct PeakData ;
2006-07-23 08:03:19 -04:00
}
2013-04-04 00:32:52 -04:00
namespace ArdourCanvas {
class LineSet ;
}
2006-07-23 08:03:19 -04:00
class PublicEditor ;
class Selectable ;
class MidiTimeAxisView ;
class MidiRegionView ;
class RegionSelection ;
class CrossfadeView ;
class Selection ;
class MidiStreamView : public StreamView
{
2017-07-01 15:11:14 -04:00
public :
2009-07-09 13:58:13 -04:00
MidiStreamView ( MidiTimeAxisView & ) ;
2006-07-23 08:03:19 -04:00
~ MidiStreamView ( ) ;
2009-05-12 13:03:42 -04:00
void get_inverted_selectables ( Selection & , std : : list < Selectable * > & results ) ;
2020-04-16 14:16:45 -04:00
void get_regions_with_selected_data ( RegionSelection & ) ;
2006-07-23 08:03:19 -04:00
2007-07-14 21:56:11 -04:00
enum VisibleNoteRange {
FullRange ,
ContentsRange
} ;
2008-01-13 12:45:17 -05:00
Gtk : : Adjustment note_range_adjustment ;
2014-06-22 11:41:05 -04:00
ArdourCanvas : : Container * midi_underlay_group ;
2008-01-13 12:45:17 -05:00
2007-08-06 02:09:41 -04:00
void set_note_range ( VisibleNoteRange r ) ;
2007-07-14 21:56:11 -04:00
2008-09-22 22:40:29 -04:00
inline uint8_t lowest_note ( ) const { return _lowest_note ; }
inline uint8_t highest_note ( ) const { return _highest_note ; }
2009-10-14 12:10:01 -04:00
2008-09-22 22:40:29 -04:00
void update_note_range ( uint8_t note_num ) ;
2009-10-14 12:10:01 -04:00
2017-01-29 09:02:07 -05:00
void set_layer_display ( LayerDisplay ) ;
2017-07-01 15:11:14 -04: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 16:42:22 -04:00
void redisplay_track ( ) ;
2009-10-14 12:10:01 -04:00
2017-07-01 15:11:14 -04:00
inline double contents_height ( ) const {
return ( child_height ( ) - TimeAxisViewItem : : NAME_HIGHLIGHT_SIZE - 2 ) ;
}
2009-10-14 12:10:01 -04:00
2017-07-01 15:11:14 -04:00
inline double note_to_y ( uint8_t note ) const {
return contents_height ( ) - ( note + 1 - lowest_note ( ) ) * note_height ( ) + 1 ;
}
2009-10-14 12:10:01 -04:00
2011-03-07 12:17:11 -05:00
uint8_t y_to_note ( double y ) const ;
2009-10-14 12:10:01 -04:00
2017-07-01 15:11:14 -04:00
inline double note_height ( ) const {
return contents_height ( ) / ( double ) contents_note_range ( ) ;
}
2009-10-14 12:10:01 -04:00
2017-07-01 15:11:14 -04:00
inline uint8_t contents_note_range ( ) const {
return highest_note ( ) - lowest_note ( ) + 1 ;
}
2009-10-14 12:10:01 -04:00
2008-01-13 12:45:17 -05:00
sigc : : signal < void > NoteRangeChanged ;
2007-07-05 03:02:24 -04:00
2009-06-08 15:28:51 -04:00
RegionView * create_region_view ( boost : : shared_ptr < ARDOUR : : Region > , bool , bool ) ;
2020-10-19 14:37:54 -04:00
bool paste ( Temporal : : timepos_t const & pos , const Selection & selection , PasteContext & ctx ) ;
2014-12-16 14:37:40 -05:00
2010-10-08 10:54:16 -04:00
void apply_note_range ( uint8_t lowest , uint8_t highest , bool to_region_views ) ;
2011-04-16 09:31:27 -04:00
void suspend_updates ( ) ;
void resume_updates ( ) ;
2017-07-01 15:11:14 -04:00
protected :
2006-07-23 08:03:19 -04:00
void setup_rec_box ( ) ;
2010-10-08 10:54:16 -04:00
void update_rec_box ( ) ;
2008-09-22 22:40:29 -04:00
2017-07-01 15:11:14 -04:00
private :
2014-12-17 18:40:38 -05:00
2008-09-22 22:40:29 -04:00
RegionView * add_region_view_internal (
2017-07-01 15:11:14 -04:00
boost : : shared_ptr < ARDOUR : : Region > ,
bool wait_for_waves ,
bool recording = false ) ;
2008-09-22 22:40:29 -04:00
void display_region ( MidiRegionView * region_view , bool load_model ) ;
2010-04-21 16:42:22 -04:00
void display_track ( boost : : shared_ptr < ARDOUR : : Track > tr ) ;
2009-10-14 12:10:01 -04:00
2008-09-19 15:32:10 -04:00
void update_contents_height ( ) ;
2010-06-24 15:46:28 -04:00
2008-01-13 12:45:17 -05:00
void draw_note_lines ( ) ;
2008-09-22 22:40:29 -04:00
bool update_data_note_range ( uint8_t min , uint8_t max ) ;
2009-02-15 14:44:27 -05:00
void update_contents_metrics ( boost : : shared_ptr < ARDOUR : : Region > r ) ;
2006-07-23 08:03:19 -04:00
2007-06-15 18:08:27 -04:00
void color_handler ( ) ;
2007-07-05 03:02:24 -04:00
2008-01-13 12:45:17 -05:00
void note_range_adjustment_changed ( ) ;
2011-04-16 09:31:27 -04:00
void apply_note_range_to_regions ( ) ;
2008-01-13 12:45:17 -05:00
2008-09-22 22:40:29 -04:00
bool _range_dirty ;
2008-01-13 12:45:17 -05:00
double _range_sum_cache ;
2008-09-22 22:40:29 -04: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 15:39:01 -04:00
ArdourCanvas : : LineSet * _note_lines ;
2011-04-16 09:31:27 -04:00
/** true if updates to the note lines and regions are currently suspended */
bool _updates_suspended ;
2006-07-23 08:03:19 -04:00
} ;
# endif /* __ardour_midi_streamview_h__ */