inter-view tweaks, add clip preview, fix for dupl proxy vicon refs, fix track drag...
[goodguy/cinelerra.git] / cinelerra-5.1 / guicast / bcpot.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef BCPOT_H
23 #define BCPOT_H
24
25 #include "bcpixmap.h"
26 #include "vframe.inc"
27 #include "bcsubwindow.h"
28
29 #define POT_UP 0
30 #define POT_HIGH 1
31 #define POT_DN 2
32 #define POT_STATES 3
33
34 class BC_FPot;
35 class BC_IPot;
36 class BC_QPot;
37 class BC_PercentagePot;
38
39 class BC_Pot : public BC_SubWindow
40 {
41 public:
42         BC_Pot(int x, int y, VFrame **data);
43         virtual ~BC_Pot();
44
45         friend class BC_FPot;
46         friend class BC_IPot;
47         friend class BC_QPot;
48         friend class BC_PercentagePot;
49
50
51         static int calculate_h();
52         static int calculate_w();
53         int initialize();
54         virtual float get_percentage() { return 0; };
55         virtual int percentage_to_value(float percentage) { return 0; };
56         virtual int handle_event() { return 0; };
57         virtual const char* get_caption() { return ""; };
58         virtual int increase_value() { return 0; };
59         virtual int decrease_value() { return 0; };
60         void set_use_caption(int value);
61         void enable();
62         void disable();
63
64
65         int reposition_window(int x, int y);
66         int repeat_event(int64_t repeat_id);
67         int cursor_enter_event();
68         int cursor_leave_event();
69         int button_press_event();
70         virtual int button_release_event();
71         int cursor_motion_event();
72         int keypress_event();
73
74 private:
75         int set_data(VFrame **data);
76         int draw(int flush);
77         float percentage_to_angle(float percentage);
78         float angle_to_percentage(float angle);
79         int angle_to_coords(int &x1, int &y1, int &x2, int &y2, float angle);
80         float coords_to_angle(int x2, int y2);
81         void show_value_tooltip();
82
83         VFrame **data;
84         BC_Pixmap *images[POT_STATES];
85         char caption[BCTEXTLEN];
86         int status;
87         int64_t keypress_tooltip_timer;
88         float angle_offset;
89         float start_cursor_angle;
90         float start_needle_angle;
91         float prev_angle, angle_correction;
92         int use_caption;
93         int enabled;
94 };
95
96 class BC_FPot : public BC_Pot
97 {
98 public:
99         BC_FPot(int x,
100                 int y,
101                 float value,
102                 float minvalue,
103                 float maxvalue,
104                 VFrame **data = 0);
105         ~BC_FPot();
106
107         const char* get_caption();
108         int increase_value();
109         int decrease_value();
110         float get_percentage();
111         float get_value();
112         int percentage_to_value(float percentage);
113         void update(float value);
114         void update(float value, float minvalue, float maxvalue);
115         void set_precision(float value);
116
117 private:
118         float value, minvalue, maxvalue;
119         float precision;
120 };
121
122 class BC_IPot : public BC_Pot
123 {
124 public:
125         BC_IPot(int x,
126                 int y,
127                 int64_t value,
128                 int64_t minvalue,
129                 int64_t maxvalue,
130                 VFrame **data = 0);
131         ~BC_IPot();
132
133         const char* get_caption();
134         int increase_value();
135         int decrease_value();
136         float get_percentage();
137         int percentage_to_value(float percentage);
138         int64_t get_value();
139         void update(int64_t value);
140         void update(int64_t value, int64_t minvalue, int64_t maxvalue);
141
142 private:
143         int64_t value, minvalue, maxvalue;
144 };
145
146 class BC_QPot : public BC_Pot
147 {
148 public:
149         BC_QPot(int x,
150                 int y,
151                 int64_t value,      // Units of frequencies
152                 VFrame **data = 0);
153         ~BC_QPot();
154
155         const char* get_caption();
156         int increase_value();
157         int decrease_value();
158         float get_percentage();
159         int percentage_to_value(float percentage);
160 // Units of frequencies
161         int64_t get_value();
162 // Units of frequencies
163         void update(int64_t value);
164
165 private:
166 // Units of frequency index
167         int64_t value, minvalue, maxvalue;
168 };
169
170 class BC_PercentagePot : public BC_Pot
171 {
172 public:
173         BC_PercentagePot(int x,
174                 int y,
175                 float value,
176                 float minvalue,
177                 float maxvalue,
178                 VFrame **data = 0);
179         ~BC_PercentagePot();
180
181         const char* get_caption();
182         int increase_value();
183         int decrease_value();
184         float get_percentage();
185         float get_value();
186         int percentage_to_value(float percentage);
187         void update(float value);
188
189 private:
190         float value, minvalue, maxvalue;
191 };
192
193 #endif