Ardour  9.2-583-gd7d701abf5
velocity_display.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2014 David Robillard <d@drobilla.net>
3  * Copyright (C) 2009-2010 Carl Hetherington <carl@carlh.net>
4  * Copyright (C) 2009-2017 Paul Davis <paul@linuxaudiosystems.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #pragma once
22 
23 #include <sigc++/trackable.h>
24 
25 #include "canvas/rectangle.h"
26 #include "canvas/poly_line.h"
27 
28 #include "gtkmm2ext/colors.h"
29 
30 #include "ghost_event.h"
31 
32 namespace ArdourCanvas {
33  class Container;
34  class Lollipop;
35  class Rectangle;
36 }
37 
38 class EditingContext;
39 class MidiViewBackground;
40 class MidiView;
41 class NoteBase;
42 
43 class VelocityDisplay : virtual public sigc::trackable
44 {
45  public:
47  virtual ~VelocityDisplay ();
48 
49  void hide ();
50  void show ();
51 
52  void redisplay();
54 
56 
59  void update_note (GhostEvent* gev) { update_ghost_event (gev); }
60  void update_hit (GhostEvent* gev) { update_ghost_event (gev); }
61 
62  virtual void remove_note (NoteBase*) = 0;
64  void clear ();
65 
66  void set_colors ();
68 
69  int y_position_to_velocity (double y) const;
70 
71  void set_sensitive (bool yn);
72  bool sensitive () const;
73 
74  bool line_draw_motion (ArdourCanvas::Duple const & d, ArdourCanvas::Rectangle const & r, double last_x);
75  bool line_extended (ArdourCanvas::Duple const & from, ArdourCanvas::Duple const & to, ArdourCanvas::Rectangle const & r, double last_x);
76 
77  void start_line_drag ();
78  void end_line_drag (bool did_change);
79 
81  MidiView& midi_view() const { return view; }
82 
83  protected:
84  virtual bool lollevent (GdkEvent*, GhostEvent*) = 0;
85 
92  bool dragging;
96  bool selected;
97  GhostEvent::EventList::iterator _optimization_iterator;
98  bool _sensitive;
99  sigc::connection base_connection;
100 
101  virtual bool base_event (GdkEvent*) = 0;
103  void lollis_close_to_x (int x, double distance, std::vector<GhostEvent*>& events);
104  void lollis_between (int x0, int x1, std::vector<GhostEvent*>& events);
107 };
108 
std::unordered_map< std::shared_ptr< NoteType >, GhostEvent * > EventList
Definition: ghost_event.h:36
void set_size_and_position(GhostEvent &)
ArdourCanvas::Rectangle & base_item()
void update_ghost_event(GhostEvent *)
virtual bool lollevent(GdkEvent *, GhostEvent *)=0
void desensitize_lollis()
ArdourCanvas::Rectangle & base
void drag_lolli(ArdourCanvas::Lollipop *l, GdkEventMotion *ev)
void end_line_drag(bool did_change)
ArdourCanvas::PolyLine * dragging_line
void lollis_between(int x0, int x1, std::vector< GhostEvent * > &events)
void start_line_drag()
sigc::connection base_connection
virtual bool base_event(GdkEvent *)=0
bool line_extended(ArdourCanvas::Duple const &from, ArdourCanvas::Duple const &to, ArdourCanvas::Rectangle const &r, double last_x)
MidiView & midi_view() const
void sensitize_lollis()
void update_note(NoteBase *)
bool sensitive() const
virtual void remove_note(NoteBase *)=0
MidiViewBackground & bg
int y_position_to_velocity(double y) const
void add_note(NoteBase *)
void update_note(GhostEvent *gev)
GhostEvent::EventList & events
bool line_draw_motion(ArdourCanvas::Duple const &d, ArdourCanvas::Rectangle const &r, double last_x)
void set_sensitive(bool yn)
VelocityDisplay(EditingContext &, MidiViewBackground &, MidiView &, ArdourCanvas::Rectangle &base_rect, GhostEvent::EventList &el, Gtkmm2ext::Color oc)
void note_selected(NoteBase *)
EditingContext & editing_context
Gtkmm2ext::Color _outline
void lollis_close_to_x(int x, double distance, std::vector< GhostEvent * > &events)
GhostEvent::EventList::iterator _optimization_iterator
void update_hit(GhostEvent *gev)
void color_ghost_event(GhostEvent *)
virtual ~VelocityDisplay()
uint32_t Color
Definition: colors.h:33