add bluray support, add dialog close fixes, scale fix
[goodguy/history.git] / cinelerra-5.0 / cinelerra / tipwindow.C
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 #include "bcdisplayinfo.h"
23 #include "bcsignals.h"
24 #include "clip.h"
25 #include "keys.h"
26 #include "language.h"
27 #include "mainsession.h"
28 #include "mwindow.h"
29 #include "preferences.h"
30 #include "theme.h"
31 #include "tipwindow.h"
32
33
34
35 // Table of tips of the day
36 static const char *tips[] = 
37 {
38         _("Shift-click on a curve keyframe to snap it to the neighboring values."),
39
40         _("When configuring slow effects, disable playback for the track.  After configuring it,\n"
41         "re-enable playback to process a single frame."),
42
43         _("Ctrl + any transport command causes playback to only cover\n"
44         "the region defined by the in/out points."),
45
46         _("Shift + clicking a patch causes all other patches except the\n"
47         "selected one to toggle."),
48
49         _("Clicking on a patch and dragging across other tracks causes\n"
50         "the other patches to match the first one."),
51
52         _("Shift + clicking on an effect boundary causes dragging to affect\n"
53         "just the one effect."),
54
55         _("Load multiple files by clicking on one file and shift + clicking on\n"
56         "another file.  Ctrl + clicking toggles individual files."),
57
58         _("Ctrl + left clicking on the time bar cycles forward a time format.\n"
59         "Ctrl + middle clicking on the time bar cycles backward a time format."),
60
61         _("Use the +/- keys in the Compositor window to zoom in and out.\n"),
62
63         _("Pressing Alt while clicking in the cropping window causes translation of\n"
64         "all 4 points.\n"),
65
66         _("Pressing Tab over a track toggles the Record status.\n"
67         "Pressing Shift-Tab over a track toggles the Record status of all the other tracks.\n"),
68
69         _("Audio->Map 1:1 maps each recordable audio track to a different channel.\n"
70         "Map 5.1:1 maps 6 recordable AC3 tracks to 2 channels.\n"),
71
72         _("Alt + left moves to the previous edit handle.\n"
73         "Alt + right moves to the next edit handle.\n"),
74
75         _("Settings->typeless keyframes allows keyframes from any track to be pasted on either\n"
76         "audio or video tracks.\n")
77 };
78
79 static int total_tips = sizeof(tips) / sizeof(char*);
80
81
82
83
84 TipWindow::TipWindow(MWindow *mwindow)
85  : BC_DialogThread()
86 {
87         this->mwindow = mwindow;
88 }
89
90 TipWindow::~TipWindow()
91 {
92         close_window();
93 }
94
95 void TipWindow::handle_close_event(int result)
96 {
97         gui = 0;
98 }
99
100 BC_Window* TipWindow::new_gui()
101 {
102         BC_DisplayInfo display_info;
103         int x = display_info.get_abs_cursor_x();
104         int y = display_info.get_abs_cursor_y();
105         TipWindowGUI *gui = this->gui = new TipWindowGUI(mwindow, 
106                 this,
107                 x,
108                 y);
109         gui->create_objects();
110         return gui;
111 }
112
113 char* TipWindow::get_current_tip()
114 {
115         CLAMP(mwindow->session->current_tip, 0, total_tips - 1);
116         char *result = _(tips[mwindow->session->current_tip]);
117         mwindow->session->current_tip++;
118         if(mwindow->session->current_tip >= total_tips)
119                 mwindow->session->current_tip = 0;
120         mwindow->save_defaults();
121         return result;
122 }
123
124 void TipWindow::next_tip()
125 {
126         gui->tip_text->update(get_current_tip());
127 }
128
129 void TipWindow::prev_tip()
130 {
131         for(int i = 0; i < 2; i++)
132         {
133                 mwindow->session->current_tip--;
134                 if(mwindow->session->current_tip < 0)
135                         mwindow->session->current_tip = total_tips - 1;
136         }
137
138         gui->tip_text->update(get_current_tip());
139 }
140
141
142
143
144
145
146 TipWindowGUI::TipWindowGUI(MWindow *mwindow, 
147         TipWindow *thread,
148         int x,
149         int y)
150  : BC_Window(_(PROGRAM_NAME ": Tip of the day"),
151         x,
152         y,
153         640,
154         100,
155         640,
156         100,
157         0,
158         0,
159         1)
160 {
161         this->mwindow = mwindow;
162         this->thread = thread;
163 }
164
165 void TipWindowGUI::create_objects()
166 {
167         int x = 10, y = 10;
168 SET_TRACE
169         add_subwindow(tip_text = new BC_Title(x, y, thread->get_current_tip()));
170         y = get_h() - 30;
171 SET_TRACE
172         BC_CheckBox *checkbox; 
173         add_subwindow(checkbox = new TipDisable(mwindow, this, x, y));
174 SET_TRACE
175         BC_Button *button;
176         y = get_h() - TipClose::calculate_h(mwindow) - 10;
177         x = get_w() - TipClose::calculate_w(mwindow) - 10;
178         add_subwindow(button = new TipClose(mwindow, this, x, y));
179 SET_TRACE
180         x -= TipNext::calculate_w(mwindow) + 10;
181         add_subwindow(button = new TipNext(mwindow, this, x, y));
182 SET_TRACE
183         x -= TipPrev::calculate_w(mwindow) + 10;
184         add_subwindow(button = new TipPrev(mwindow, this, x, y));
185 SET_TRACE
186         x += button->get_w() + 10;
187
188         show_window();
189         raise_window();
190 }
191
192 int TipWindowGUI::keypress_event()
193 {
194         switch(get_keypress())
195         {
196                 case RETURN:
197                 case ESC:
198                 case 'w':
199                         set_done(0);
200                         break;
201         }
202         return 0;
203 }
204
205
206
207
208
209
210
211 TipDisable::TipDisable(MWindow *mwindow, TipWindowGUI *gui, int x, int y)
212  : BC_CheckBox(x, 
213         y, 
214         mwindow->preferences->use_tipwindow, 
215         _("Show tip of the day."))
216 {
217         this->mwindow = mwindow;
218         this->gui = gui;
219 }
220
221 int TipDisable::handle_event()
222 {
223         mwindow->preferences->use_tipwindow = get_value();
224         return 1;
225 }
226
227
228
229 TipNext::TipNext(MWindow *mwindow, TipWindowGUI *gui, int x, int y)
230  : BC_Button(x, 
231         y, 
232         mwindow->theme->get_image_set("next_tip"))
233 {
234         this->mwindow = mwindow;
235         this->gui = gui;
236         set_tooltip(_("Next tip"));
237 }
238 int TipNext::handle_event()
239 {
240         gui->thread->next_tip();
241         return 1;
242 }
243
244 int TipNext::calculate_w(MWindow *mwindow)
245 {
246         return mwindow->theme->get_image_set("next_tip")[0]->get_w();
247 }
248
249
250
251
252
253
254 TipPrev::TipPrev(MWindow *mwindow, TipWindowGUI *gui, int x, int y)
255  : BC_Button(x, y, mwindow->theme->get_image_set("prev_tip"))
256 {
257         this->mwindow = mwindow;
258         this->gui = gui;
259         set_tooltip(_("Previous tip"));
260 }
261
262 int TipPrev::handle_event()
263 {
264         gui->thread->prev_tip();
265         return 1;
266 }
267 int TipPrev::calculate_w(MWindow *mwindow)
268 {
269         return mwindow->theme->get_image_set("prev_tip")[0]->get_w();
270 }
271
272
273
274
275
276
277
278
279
280 TipClose::TipClose(MWindow *mwindow, TipWindowGUI *gui, int x, int y)
281  : BC_Button(x, y, mwindow->theme->get_image_set("close_tip"))
282 {
283         this->mwindow = mwindow;
284         this->gui = gui;
285         set_tooltip(_("Close"));
286 }
287
288 int TipClose::handle_event()
289 {
290         gui->set_done(0);
291         return 1;
292 }
293
294 int TipClose::calculate_w(MWindow *mwindow)
295 {
296         return mwindow->theme->get_image_set("close_tip")[0]->get_w();
297 }
298 int TipClose::calculate_h(MWindow *mwindow)
299 {
300         return mwindow->theme->get_image_set("close_tip")[0]->get_h();
301 }
302
303
304