4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
22 #include "bcdisplayinfo.h"
23 #include "bcsignals.h"
27 #include "mainsession.h"
29 #include "preferences.h"
31 #include "tipwindow.h"
35 // Table of tips of the day
36 static const char *tips[] =
38 N_("Shift-click on a curve keyframe to snap it to the neighboring values."),
40 N_("When configuring slow effects, disable playback for the track. After configuring it,\n"
41 "re-enable playback to process a single frame."),
43 N_("Ctrl + any transport command causes playback to only cover\n"
44 "the region defined by the in/out points."),
46 N_("Shift + clicking a patch causes all other patches except the\n"
47 "selected one to toggle."),
49 N_("Clicking on a patch and dragging across other tracks causes\n"
50 "the other patches to match the first one."),
52 N_("Shift + clicking on an effect boundary causes dragging to affect\n"
53 "just the one effect."),
55 N_("Load multiple files by clicking on one file and shift + clicking on\n"
56 "another file. Ctrl + clicking toggles individual files."),
58 N_("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."),
61 N_("Use the +/- keys in the Compositor window to zoom in and out.\n"),
63 N_("Pressing Alt while clicking in the cropping window causes translation of\n"
66 N_("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"),
69 N_("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"),
72 N_("Alt + left moves to the previous edit handle.\n"
73 "Alt + right moves to the next edit handle.\n"),
75 N_("Settings->typeless keyframes allows keyframes from any track to be pasted on either\n"
76 "audio or video tracks.\n")
79 static int total_tips = sizeof(tips) / sizeof(char*);
84 TipWindow::TipWindow(MWindow *mwindow)
87 this->mwindow = mwindow;
90 void TipWindow::handle_close_event(int result)
95 BC_Window* TipWindow::new_gui()
97 BC_DisplayInfo display_info;
98 int x = display_info.get_abs_cursor_x();
99 int y = display_info.get_abs_cursor_y();
100 TipWindowGUI *gui = this->gui = new TipWindowGUI(mwindow,
104 gui->create_objects();
108 char* TipWindow::get_current_tip()
110 CLAMP(mwindow->session->current_tip, 0, total_tips - 1);
111 char *result = _(tips[mwindow->session->current_tip]);
112 mwindow->session->current_tip++;
113 if(mwindow->session->current_tip >= total_tips)
114 mwindow->session->current_tip = 0;
115 mwindow->save_defaults();
119 void TipWindow::next_tip()
121 gui->tip_text->update(get_current_tip());
124 void TipWindow::prev_tip()
126 for(int i = 0; i < 2; i++)
128 mwindow->session->current_tip--;
129 if(mwindow->session->current_tip < 0)
130 mwindow->session->current_tip = total_tips - 1;
133 gui->tip_text->update(get_current_tip());
141 TipWindowGUI::TipWindowGUI(MWindow *mwindow,
145 : BC_Window(PROGRAM_NAME ": Tip of the day",
156 this->mwindow = mwindow;
157 this->thread = thread;
160 void TipWindowGUI::create_objects()
164 add_subwindow(tip_text = new BC_Title(x, y, thread->get_current_tip()));
167 BC_CheckBox *checkbox;
168 add_subwindow(checkbox = new TipDisable(mwindow, this, x, y));
171 y = get_h() - TipClose::calculate_h(mwindow) - 10;
172 x = get_w() - TipClose::calculate_w(mwindow) - 10;
173 add_subwindow(button = new TipClose(mwindow, this, x, y));
175 x -= TipNext::calculate_w(mwindow) + 10;
176 add_subwindow(button = new TipNext(mwindow, this, x, y));
178 x -= TipPrev::calculate_w(mwindow) + 10;
179 add_subwindow(button = new TipPrev(mwindow, this, x, y));
181 x += button->get_w() + 10;
187 int TipWindowGUI::keypress_event()
189 switch(get_keypress())
206 TipDisable::TipDisable(MWindow *mwindow, TipWindowGUI *gui, int x, int y)
209 mwindow->preferences->use_tipwindow,
210 _("Show tip of the day."))
212 this->mwindow = mwindow;
216 int TipDisable::handle_event()
218 mwindow->preferences->use_tipwindow = get_value();
224 TipNext::TipNext(MWindow *mwindow, TipWindowGUI *gui, int x, int y)
227 mwindow->theme->get_image_set("next_tip"))
229 this->mwindow = mwindow;
231 set_tooltip(_("Next tip"));
233 int TipNext::handle_event()
235 gui->thread->next_tip();
239 int TipNext::calculate_w(MWindow *mwindow)
241 return mwindow->theme->get_image_set("next_tip")[0]->get_w();
249 TipPrev::TipPrev(MWindow *mwindow, TipWindowGUI *gui, int x, int y)
250 : BC_Button(x, y, mwindow->theme->get_image_set("prev_tip"))
252 this->mwindow = mwindow;
254 set_tooltip(_("Previous tip"));
257 int TipPrev::handle_event()
259 gui->thread->prev_tip();
262 int TipPrev::calculate_w(MWindow *mwindow)
264 return mwindow->theme->get_image_set("prev_tip")[0]->get_w();
275 TipClose::TipClose(MWindow *mwindow, TipWindowGUI *gui, int x, int y)
276 : BC_Button(x, y, mwindow->theme->get_image_set("close_tip"))
278 this->mwindow = mwindow;
280 set_tooltip(_("Close"));
283 int TipClose::handle_event()
289 int TipClose::calculate_w(MWindow *mwindow)
291 return mwindow->theme->get_image_set("close_tip")[0]->get_w();
293 int TipClose::calculate_h(MWindow *mwindow)
295 return mwindow->theme->get_image_set("close_tip")[0]->get_h();