Ardour  9.0-pre0-582-g084a23a80d
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 
56  void update_note (GhostEvent* gev) { update_ghost_event (gev); }
57  void update_hit (GhostEvent* gev) { update_ghost_event (gev); }
58 
59  virtual void remove_note (NoteBase*) = 0;
61  void clear ();
62 
63  void set_colors ();
65 
66  int y_position_to_velocity (double y) const;
67 
68  void set_selected (bool);
69 
70  bool line_draw_motion (ArdourCanvas::Duple const & d, ArdourCanvas::Rectangle const & r, double last_x);
71  bool line_extended (ArdourCanvas::Duple const & from, ArdourCanvas::Duple const & to, ArdourCanvas::Rectangle const & r, double last_x);
72 
73  void start_line_drag ();
74  void end_line_drag (bool did_change);
75 
77  MidiView& midi_view() const { return view; }
78 
79  protected:
80  virtual bool lollevent (GdkEvent*, GhostEvent*) = 0;
81 
89  bool dragging;
93  bool selected;
94  GhostEvent::EventList::iterator _optimization_iterator;
95 
96  virtual bool base_event (GdkEvent*) = 0;
98  void lollis_close_to_x (int x, double distance, std::vector<GhostEvent*>& events);
99  void lollis_between (int x0, int x1, std::vector<GhostEvent*>& events);
102 };
103 
std::unordered_map< std::shared_ptr< NoteType >, GhostEvent * > EventList
Definition: ghost_event.h:32
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 *)
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 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)
virtual ~VelocityDisplay()
uint32_t Color
Definition: colors.h:33