r668: Configure.in and autogen.sh cleanup based on ideas by giskard.
[cinelerra_cv.git] / cinelerra / tipwindow.C
blobab19a7b178a3168abb523b0ae0b16735b92715ea
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         "When configuring slow effects, disable playback for the track.  After configuring it,\n"
17         "re-enable playback to process a single frame.",
19         "Ctrl + any transport command causes playback to only cover\n"
20         "the region defined by the in/out points.",
22         "Shift + clicking a patch causes all other patches except the\n"
23         "selected one to toggle.",
25         "Clicking on a patch and dragging across other tracks causes\n"
26         "the other patches to match the first one.",
28         "Shift + clicking on an effect boundary causes dragging to affect\n"
29         "just the one effect.",
31         "Load multiple files by clicking on one file and shift + clicking on\n"
32         "another file.  Ctrl + clicking toggles individual files.",
34         "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         "Use the +/- keys in the Compositor window to zoom in and out.\n",
39         "Pressing Alt while clicking in the cropping window causes translation of\n"
40         "all 4 points.\n",
42         "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"
46 static int total_tips = sizeof(tips) / sizeof(char*);
51 TipWindow::TipWindow(MWindow *mwindow)
52  : BC_DialogThread()
54         this->mwindow = mwindow;
57 BC_Window* TipWindow::new_gui()
59         BC_DisplayInfo display_info;
60         int x = display_info.get_abs_cursor_x();
61         int y = display_info.get_abs_cursor_y();
62         TipWindowGUI *gui = this->gui = new TipWindowGUI(mwindow, 
63                 this,
64                 x,
65                 y);
66         gui->create_objects();
67         return gui;
70 char* TipWindow::get_current_tip()
72         CLAMP(mwindow->session->current_tip, 0, total_tips - 1);
73         char *result = tips[mwindow->session->current_tip];
74         mwindow->session->current_tip++;
75         if(mwindow->session->current_tip >= total_tips)
76                 mwindow->session->current_tip = 0;
77         mwindow->save_defaults();
78         return result;
81 void TipWindow::next_tip()
83         gui->tip_text->update(get_current_tip());
86 void TipWindow::prev_tip()
88         for(int i = 0; i < 2; i++)
89         {
90                 mwindow->session->current_tip--;
91                 if(mwindow->session->current_tip < 0)
92                         mwindow->session->current_tip = total_tips - 1;
93         }
95         gui->tip_text->update(get_current_tip());
103 TipWindowGUI::TipWindowGUI(MWindow *mwindow, 
104         TipWindow *thread,
105         int x,
106         int y)
107  : BC_Window(PROGRAM_NAME ": Tip of the day",
108         x,
109         y,
110         640,
111         100,
112         640,
113         100,
114         0,
115         0,
116         1)
118         this->mwindow = mwindow;
119         this->thread = thread;
122 void TipWindowGUI::create_objects()
124         int x = 10, y = 10;
125 SET_TRACE
126         add_subwindow(tip_text = new BC_Title(x, y, thread->get_current_tip()));
127         y = get_h() - 30;
128 SET_TRACE
129         BC_CheckBox *checkbox; 
130         add_subwindow(checkbox = new TipDisable(mwindow, this, x, y));
131 SET_TRACE
132         BC_Button *button;
133         y = get_h() - TipClose::calculate_h(mwindow) - 10;
134         x = get_w() - TipClose::calculate_w(mwindow) - 10;
135         add_subwindow(button = new TipClose(mwindow, this, x, y));
136 SET_TRACE
137         x -= TipNext::calculate_w(mwindow) + 10;
138         add_subwindow(button = new TipNext(mwindow, this, x, y));
139 SET_TRACE
140         x -= TipPrev::calculate_w(mwindow) + 10;
141         add_subwindow(button = new TipPrev(mwindow, this, x, y));
142 SET_TRACE
143         x += button->get_w() + 10;
145         show_window();
146         raise_window();
149 int TipWindowGUI::keypress_event()
151         switch(get_keypress())
152         {
153                 case RETURN:
154                 case ESC:
155                 case 'w':
156                         set_done(0);
157                         break;
158         }
159         return 0;
168 TipDisable::TipDisable(MWindow *mwindow, TipWindowGUI *gui, int x, int y)
169  : BC_CheckBox(x, 
170         y, 
171         mwindow->preferences->use_tipwindow, 
172         _("Show tip of the day."))
174         this->mwindow = mwindow;
175         this->gui = gui;
178 int TipDisable::handle_event()
180         mwindow->preferences->use_tipwindow = get_value();
181         return 1;
186 TipNext::TipNext(MWindow *mwindow, TipWindowGUI *gui, int x, int y)
187  : BC_Button(x, 
188         y, 
189         mwindow->theme->get_image_set("next_tip"))
191         this->mwindow = mwindow;
192         this->gui = gui;
193         set_tooltip(_("Next tip"));
195 int TipNext::handle_event()
197         gui->thread->next_tip();
198         return 1;
201 int TipNext::calculate_w(MWindow *mwindow)
203         return mwindow->theme->get_image_set("next_tip")[0]->get_w();
211 TipPrev::TipPrev(MWindow *mwindow, TipWindowGUI *gui, int x, int y)
212  : BC_Button(x, y, mwindow->theme->get_image_set("prev_tip"))
214         this->mwindow = mwindow;
215         this->gui = gui;
216         set_tooltip(_("Previous tip"));
219 int TipPrev::handle_event()
221         gui->thread->prev_tip();
222         return 1;
224 int TipPrev::calculate_w(MWindow *mwindow)
226         return mwindow->theme->get_image_set("prev_tip")[0]->get_w();
237 TipClose::TipClose(MWindow *mwindow, TipWindowGUI *gui, int x, int y)
238  : BC_Button(x, y, mwindow->theme->get_image_set("close_tip"))
240         this->mwindow = mwindow;
241         this->gui = gui;
242         set_tooltip(_("Close"));
245 int TipClose::handle_event()
247         gui->set_done(0);
248         return 1;
251 int TipClose::calculate_w(MWindow *mwindow)
253         return mwindow->theme->get_image_set("close_tip")[0]->get_w();
255 int TipClose::calculate_h(MWindow *mwindow)
257         return mwindow->theme->get_image_set("close_tip")[0]->get_h();