Ardour  9.0-pre0-822-g12e3bc5c20
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 "canvas/rectangle.h"
24 #include "canvas/poly_line.h"
25 
26 #include "gtkmm2ext/colors.h"
27 
28 #include "ghost_event.h"
29 
30 namespace ArdourCanvas {
31  class Container;
32  class Lollipop;
33  class Rectangle;
34 }
35 
36 class EditingContext;
37 class MidiViewBackground;
38 class MidiView;
39 class NoteBase;
40 
42 {
43  public:
45  virtual ~VelocityDisplay ();
46 
47  void hide ();
48  void show ();
49 
50  void redisplay();
52 
54 
57  void update_note (GhostEvent* gev) { update_ghost_event (gev); }
58  void update_hit (GhostEvent* gev) { update_ghost_event (gev); }
59 
60  virtual void remove_note (NoteBase*) = 0;
62  void clear ();
63 
64  void set_colors ();
65  void drag_lolli (ArdourCanvas::Lollipop* l, GdkEventMotion* ev);
66 
67  int y_position_to_velocity (double y) const;
68 
69  void set_sensitive (bool yn);
70  bool sensitive () const;
71 
72  void set_selected (bool);
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 
93  bool dragging;
97  bool selected;
98  GhostEvent::EventList::iterator _optimization_iterator;
99  bool _sensitive;
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:34
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 set_selected(bool)
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()
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()
VelocityDisplay(EditingContext &, MidiViewBackground &, MidiView &, ArdourCanvas::Rectangle &base_rect, ArdourCanvas::Container &, GhostEvent::EventList &el, Gtkmm2ext::Color oc)
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
ArdourCanvas::Container * lolli_container
bool line_draw_motion(ArdourCanvas::Duple const &d, ArdourCanvas::Rectangle const &r, double last_x)
void set_sensitive(bool yn)
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