Only allow LV2 touch events for control inputs
[ardour.git] / gtk2_ardour / tempo_dialog.h
1 /*
2     Copyright (C) 2000-2007 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __ardour_gtk_tempo_dialog_h__
21 #define __ardour_gtk_tempo_dialog_h__
22
23 #include <gtkmm/entry.h>
24 #include <gtkmm/frame.h>
25 #include <gtkmm/box.h>
26 #include <gtkmm/button.h>
27 #include <gtkmm/label.h>
28 #include <gtkmm/table.h>
29 #include <gtkmm/entry.h>
30 #include <gtkmm/spinbutton.h>
31 #include <gtkmm/comboboxtext.h>
32
33 #include "ardour/types.h"
34 #include "ardour/tempo.h"
35
36 #include "ardour_dialog.h"
37
38 class TempoDialog : public ArdourDialog
39 {
40 public:
41         TempoDialog (ARDOUR::TempoMap&, samplepos_t, const std::string & action);
42         TempoDialog (ARDOUR::TempoMap&, ARDOUR::TempoSection&, const std::string & action);
43
44         double get_bpm ();
45         double get_end_bpm ();
46         double get_note_type ();
47         bool   get_bbt_time (Timecode::BBT_Time&);
48         ARDOUR::TempoSection::Type get_tempo_type ();
49         ARDOUR::PositionLockStyle get_lock_style ();
50
51 private:
52         void init (const Timecode::BBT_Time& start, double bpm, double end_bpm, double note_type, ARDOUR::TempoSection::Type type, bool movable, ARDOUR::PositionLockStyle style);
53         bool is_user_input_valid() const;
54         void bpm_changed ();
55         bool bpm_button_press (GdkEventButton* );
56         bool bpm_button_release (GdkEventButton* );
57         bool entry_key_release (GdkEventKey* );
58         void pulse_change ();
59         void tempo_type_change ();
60         void lock_style_change ();
61         bool tap_tempo_key_press (GdkEventKey*);
62         bool tap_tempo_button_press (GdkEventButton*);
63         bool tap_tempo_focus_out (GdkEventFocus* );
64
65         void tap_tempo ();
66
67         typedef std::map<std::string,float> NoteTypes;
68         NoteTypes note_types;
69
70         typedef std::map<std::string, ARDOUR::TempoSection::Type> TempoTypes;
71         TempoTypes tempo_types;
72
73         typedef std::map<std::string, ARDOUR::PositionLockStyle> LockStyles;
74         LockStyles lock_styles;
75
76         bool tapped;      // whether the tap-tempo button has been clicked
77         double sum_x, sum_xx, sum_xy, sum_y;
78         double tap_count;
79         double last_t;
80         gint64 first_t;
81
82         ARDOUR::TempoMap* _map;
83         ARDOUR::TempoSection* _section;
84
85         Gtk::ComboBoxText pulse_selector;
86         Gtk::Adjustment   bpm_adjustment;
87         Gtk::SpinButton   bpm_spinner;
88         Gtk::Adjustment   end_bpm_adjustment;
89         Gtk::SpinButton   end_bpm_spinner;
90         Gtk::Label   _end_bpm_label;
91         Gtk::Entry   when_bar_entry;
92         Gtk::Entry   when_beat_entry;
93         Gtk::Label   when_bar_label;
94         Gtk::Label   when_beat_label;
95         Gtk::Label   pulse_selector_label;
96         Gtk::Button  tap_tempo_button;
97         Gtk::ComboBoxText tempo_type;
98         Gtk::ComboBoxText lock_style;
99 };
100
101 class MeterDialog : public ArdourDialog
102 {
103 public:
104
105         MeterDialog (ARDOUR::TempoMap&, samplepos_t, const std::string & action);
106         MeterDialog (ARDOUR::TempoMap&, ARDOUR::MeterSection&, const std::string & action);
107
108         double get_bpb ();
109         double get_note_type ();
110         ARDOUR::PositionLockStyle get_lock_style ();
111         bool   get_bbt_time (Timecode::BBT_Time&);
112
113 private:
114         void init (const Timecode::BBT_Time&, double, double, bool, ARDOUR::PositionLockStyle style);
115         bool is_user_input_valid() const;
116         bool entry_key_press (GdkEventKey* );
117         bool entry_key_release (GdkEventKey* );
118         void note_type_change ();
119         void lock_style_change ();
120
121         typedef std::map<std::string,float> NoteTypes;
122         NoteTypes note_types;
123
124         typedef std::map<std::string, ARDOUR::PositionLockStyle> LockStyles;
125         LockStyles lock_styles;
126
127         Gtk::Entry   bpb_entry;
128         Gtk::ComboBoxText note_type;
129         Gtk::ComboBoxText lock_style;
130         std::vector<std::string> strings;
131         Gtk::Button  ok_button;
132         Gtk::Button  cancel_button;
133         Gtk::Entry   when_bar_entry;
134 };
135
136 #endif /* __ardour_gtk_tempo_dialog_h__ */