r1037: Check for OpenGL 2.0 libraries in /usr/X11R6/lib64/libGL.so.1,
[cinelerra_cv.git] / cinelerra / tipwindow.C
blobc12e26501e2bac30c89acac9fe14bd6b037da268
1 #include "bcdisplayinfo.h"
2 #include "bcsignals.h"
3 #include "keys.h"
4 #include "language.h"
5 #include "mainsession.h"
6 #include "mwindow.h"
7 #include "preferences.h"
8 #include "theme.h"
9 #include "tipwindow.h"
13 // Table of tips of the day
14 static char *tips[] = 
16         N_("When configuring slow effects, disable playback for the track.  After configuring it,\n"
17         "re-enable playback to process a single frame."),
19         N_("Ctrl + any transport command causes playback to only cover\n"
20         "the region defined by the in/out points."),
22         N_("Shift + clicking a patch causes all other patches except the\n"
23         "selected one to toggle."),
25         N_("Clicking on a patch and dragging across other tracks causes\n"
26         "the other patches to match the first one."),
28         N_("Shift + clicking on an effect boundary causes dragging to affect\n"
29         "just the one effect."),
31         N_("Load multiple files by clicking on one file and shift + clicking on\n"
32         "another file.  Ctrl + clicking toggles individual files."),
34         N_("Ctrl + left clicking on the time bar cycles forward a time format.\n"
35         "Ctrl + middle clicking on the time bar cycles backward a time format."),
37         N_("Use the +/- keys in the Compositor window to zoom in and out.\n"),
39         N_("Pressing Alt while clicking in the cropping window causes translation of\n"
40         "all 4 points.\n"),
42         N_("Pressing Tab over a track toggles the Record status.\n"
43         "Pressing Shift-Tab over a track toggles the Record status of all the other tracks.\n"),
45         N_("Audio->Map 1:1 maps each recordable audio track to a different channel.\n"
46         "Map 5.1:1 maps 6 recordable AC3 tracks to 2 channels.\n"),
48         N_("Alt + left moves to the previous edit handle.\n"
49         "Alt + right moves to the next edit handle.\n")
52 static int total_tips = sizeof(tips) / sizeof(char*);
57 TipWindow::TipWindow(MWindow *mwindow)
58  : BC_DialogThread()
60         this->mwindow = mwindow;
63 BC_Window* TipWindow::new_gui()
65         BC_DisplayInfo display_info;
66         int x = display_info.get_abs_cursor_x();
67         int y = display_info.get_abs_cursor_y();
68         TipWindowGUI *gui = this->gui = new TipWindowGUI(mwindow, 
69                 this,
70                 x,
71                 y);
72         gui->create_objects();
73         return gui;
76 char* TipWindow::get_current_tip()
78         CLAMP(mwindow->session->current_tip, 0, total_tips - 1);
79         char *result = _(tips[mwindow->session->current_tip]);
80         mwindow->session->current_tip++;
81         if(mwindow->session->current_tip >= total_tips)
82                 mwindow->session->current_tip = 0;
83         mwindow->save_defaults();
84         return result;
87 void TipWindow::next_tip()
89         gui->tip_text->update(get_current_tip());
92 void TipWindow::prev_tip()
94         for(int i = 0; i < 2; i++)
95         {
96                 mwindow->session->current_tip--;
97                 if(mwindow->session->current_tip < 0)
98                         mwindow->session->current_tip = total_tips - 1;
99         }
101         gui->tip_text->update(get_current_tip());
109 TipWindowGUI::TipWindowGUI(MWindow *mwindow, 
110         TipWindow *thread,
111         int x,
112         int y)
113  : BC_Window(PROGRAM_NAME ": Tip of the day",
114         x,
115         y,
116         640,
117         100,
118         640,
119         100,
120         0,
121         0,
122         1)
124         this->mwindow = mwindow;
125         this->thread = thread;
128 void TipWindowGUI::create_objects()
130         int x = 10, y = 10;
131 SET_TRACE
132         add_subwindow(tip_text = new BC_Title(x, y, thread->get_current_tip()));
133         y = get_h() - 30;
134 SET_TRACE
135         BC_CheckBox *checkbox; 
136         add_subwindow(checkbox = new TipDisable(mwindow, this, x, y));
137 SET_TRACE
138         BC_Button *button;
139         y = get_h() - TipClose::calculate_h(mwindow) - 10;
140         x = get_w() - TipClose::calculate_w(mwindow) - 10;
141         add_subwindow(button = new TipClose(mwindow, this, x, y));
142 SET_TRACE
143         x -= TipNext::calculate_w(mwindow) + 10;
144         add_subwindow(button = new TipNext(mwindow, this, x, y));
145 SET_TRACE
146         x -= TipPrev::calculate_w(mwindow) + 10;
147         add_subwindow(button = new TipPrev(mwindow, this, x, y));
148 SET_TRACE
149         x += button->get_w() + 10;
151         show_window();
152         raise_window();
155 int TipWindowGUI::keypress_event()
157         switch(get_keypress())
158         {
159                 case RETURN:
160                 case ESC:
161                 case 'w':
162                         set_done(0);
163                         break;
164         }
165         return 0;
174 TipDisable::TipDisable(MWindow *mwindow, TipWindowGUI *gui, int x, int y)
175  : BC_CheckBox(x, 
176         y, 
177         mwindow->preferences->use_tipwindow, 
178         _("Show tip of the day."))
180         this->mwindow = mwindow;
181         this->gui = gui;
184 int TipDisable::handle_event()
186         mwindow->preferences->use_tipwindow = get_value();
187         return 1;
192 TipNext::TipNext(MWindow *mwindow, TipWindowGUI *gui, int x, int y)
193  : BC_Button(x, 
194         y, 
195         mwindow->theme->get_image_set("next_tip"))
197         this->mwindow = mwindow;
198         this->gui = gui;
199         set_tooltip(_("Next tip"));
201 int TipNext::handle_event()
203         gui->thread->next_tip();
204         return 1;
207 int TipNext::calculate_w(MWindow *mwindow)
209         return mwindow->theme->get_image_set("next_tip")[0]->get_w();
217 TipPrev::TipPrev(MWindow *mwindow, TipWindowGUI *gui, int x, int y)
218  : BC_Button(x, y, mwindow->theme->get_image_set("prev_tip"))
220         this->mwindow = mwindow;
221         this->gui = gui;
222         set_tooltip(_("Previous tip"));
225 int TipPrev::handle_event()
227         gui->thread->prev_tip();
228         return 1;
230 int TipPrev::calculate_w(MWindow *mwindow)
232         return mwindow->theme->get_image_set("prev_tip")[0]->get_w();
243 TipClose::TipClose(MWindow *mwindow, TipWindowGUI *gui, int x, int y)
244  : BC_Button(x, y, mwindow->theme->get_image_set("close_tip"))
246         this->mwindow = mwindow;
247         this->gui = gui;
248         set_tooltip(_("Close"));
251 int TipClose::handle_event()
253         gui->set_done(0);
254         return 1;
257 int TipClose::calculate_w(MWindow *mwindow)
259         return mwindow->theme->get_image_set("close_tip")[0]->get_w();
261 int TipClose::calculate_h(MWindow *mwindow)
263         return mwindow->theme->get_image_set("close_tip")[0]->get_h();