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