Ardour  9.0-pre0-1320-gf48fe3f740
prh_base.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2025 David Robillard <d@drobilla.net>
3  * Copyright (C) 2010-2012 Paul Davis <paul@linuxaudiosystems.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #pragma once
21 
22 #include <pangomm/layout.h>
23 #include <glibmm/refptr.h>
24 
25 #include "ardour/types.h"
26 
27 #include "canvas/rectangle.h"
28 
29 #include <ytkmm/adjustment.h>
30 
31 namespace Gdk {
32  class Window;
33 }
34 
35 namespace ARDOUR {
36  class MidiTrack;
37 }
38 
39 class MidiView;
40 class MidiViewBackground;
41 class EditingContext;
42 
43 class PianoRollHeaderBase : virtual public sigc::trackable {
44  public:
46  virtual ~PianoRollHeaderBase() {}
47 
48  void render (ArdourCanvas::Rect const & self, ArdourCanvas::Rect const & area, Cairo::RefPtr<Cairo::Context>) const;
49 
50  virtual void instrument_info_change ();
51 
53  void set_note_highlight (uint8_t note);
54 
55  sigc::signal<void,uint8_t> SetNoteSelection;
56  sigc::signal<void,uint8_t> AddNoteSelection;
57  sigc::signal<void,uint8_t> ToggleNoteSelection;
58  sigc::signal<void,uint8_t> ExtendNoteSelection;
59 
60  void set_view (MidiView*);
61 
62  virtual void redraw () = 0;
63  virtual void redraw (double x, double y, double w, double h) = 0;
64  virtual double height() const = 0;
65  virtual double width() const = 0;
66  virtual double event_y_to_y (double evy) const = 0;
67  virtual void draw_transform (double& x, double& y) const = 0;
68  virtual void event_transform (double& x, double& y) const = 0;
69  virtual void _queue_resize () = 0;
70  virtual void do_grab() = 0;
71  virtual void do_ungrab() = 0;
72  virtual Glib::RefPtr<Gdk::Window> cursor_window() = 0;
73  virtual std::shared_ptr<ARDOUR::MidiTrack> midi_track() = 0;
74 
75  protected:
79 
80  uint8_t _event[3];
81 
82  mutable Glib::RefPtr<Pango::Layout> _layout;
83  mutable Glib::RefPtr<Pango::Layout> _big_c_layout;
84  mutable Glib::RefPtr<Pango::Layout> _midnam_layout;
85  mutable Pango::FontDescription _font_descript;
86  Pango::FontDescription _font_descript_big_c;
87  mutable Pango::FontDescription _font_descript_midnam;
88  bool _active_notes[128];
90  uint8_t _clicked_note;
91  double _grab_y;
92  bool _dragging;
93  mutable double _scroomer_size;
95  double _old_y;
96  double _fract;
97  double _fract_top;
99  enum scr_pos {TOP, BOTTOM, MOVE, NONE};
104  mutable bool _mini_map_display;
105  bool entered;
106 
107  // void on_size_request(Gtk::Requisition*);
108 
109  struct NoteName {
110  std::string name;
112  };
115 
116  void set_min_page_size (double page_size);
117  void render_scroomer (Cairo::RefPtr<Cairo::Context>) const;
119 
127 
128  enum ItemType {
136  WHITE_DGA
137  };
138 
139  void invalidate_note_range (int lowest, int highest);
140  void send_note_on (uint8_t note);
141  void send_note_off (uint8_t note);
142  void reset_clicked_note (uint8_t, bool invalidate = true);
143  bool show_scroomer () const;
144  void alloc_layouts (Glib::RefPtr<Pango::Context>);
146 };
bool button_press_handler(GdkEventButton *)
bool leave_handler(GdkEventCrossing *)
Pango::FontDescription _font_descript
Definition: prh_base.h:85
bool _active_notes[128]
Definition: prh_base.h:88
Pango::FontDescription _font_descript_big_c
Definition: prh_base.h:86
sigc::signal< void, uint8_t > ToggleNoteSelection
Definition: prh_base.h:57
Gtk::Adjustment & _adj
Definition: prh_base.h:77
uint8_t _clicked_note
Definition: prh_base.h:90
double _saved_top_val
Definition: prh_base.h:102
bool show_scroomer() const
virtual double width() const =0
virtual double height() const =0
virtual void redraw(double x, double y, double w, double h)=0
void set_min_page_size(double page_size)
void send_note_off(uint8_t note)
scr_pos _scroomer_state
Definition: prh_base.h:100
virtual void redraw()=0
double _scroomer_size
Definition: prh_base.h:93
Pango::FontDescription _font_descript_midnam
Definition: prh_base.h:87
PianoRollHeaderBase(MidiViewBackground &)
bool enter_handler(GdkEventCrossing *)
bool motion_handler(GdkEventMotion *)
bool scroll_handler(GdkEventScroll *)
virtual void draw_transform(double &x, double &y) const =0
void alloc_layouts(Glib::RefPtr< Pango::Context >)
bool button_release_handler(GdkEventButton *)
virtual void do_grab()=0
MidiViewBackground & _midi_context
Definition: prh_base.h:76
void invalidate_note_range(int lowest, int highest)
uint8_t _highlighted_note
Definition: prh_base.h:89
scr_pos _scroomer_button_state
Definition: prh_base.h:101
virtual void _queue_resize()=0
void set_cursor(Gdk::Cursor *)
Glib::RefPtr< Pango::Layout > _layout
Definition: prh_base.h:82
virtual void instrument_info_change()
double _saved_bottom_val
Definition: prh_base.h:103
virtual void do_ungrab()=0
void reset_clicked_note(uint8_t, bool invalidate=true)
virtual ~PianoRollHeaderBase()
Definition: prh_base.h:46
Glib::RefPtr< Pango::Layout > _big_c_layout
Definition: prh_base.h:83
Glib::RefPtr< Pango::Layout > _midnam_layout
Definition: prh_base.h:84
MidiView * _view
Definition: prh_base.h:78
void set_view(MidiView *)
bool event_handler(GdkEvent *)
sigc::signal< void, uint8_t > SetNoteSelection
Definition: prh_base.h:55
virtual void event_transform(double &x, double &y) const =0
void send_note_on(uint8_t note)
NoteName note_names[128]
Definition: prh_base.h:113
NoteName get_note_name(int note)
uint8_t _event[3]
Definition: prh_base.h:80
void set_note_highlight(uint8_t note)
sigc::signal< void, uint8_t > AddNoteSelection
Definition: prh_base.h:56
void render(ArdourCanvas::Rect const &self, ArdourCanvas::Rect const &area, Cairo::RefPtr< Cairo::Context >) const
virtual double event_y_to_y(double evy) const =0
void render_scroomer(Cairo::RefPtr< Cairo::Context >) const
double _min_page_size
Definition: prh_base.h:98
virtual Glib::RefPtr< Gdk::Window > cursor_window()=0
virtual std::shared_ptr< ARDOUR::MidiTrack > midi_track()=0
sigc::signal< void, uint8_t > ExtendNoteSelection
Definition: prh_base.h:58
Definition: Window.h:41