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
23 #include "bcsignals.h"
26 #include "edlsession.h"
27 #include "gwindowgui.h"
30 #include "mainsession.h"
32 #include "mwindowgui.h"
34 #include "trackcanvas.h"
40 GWindowGUI::GWindowGUI(MWindow *mwindow, int w, int h)
41 : BC_Window(_(PROGRAM_NAME ": Overlays"),
42 mwindow->session->gwindow_x, mwindow->session->gwindow_y,
45 this->mwindow = mwindow;
48 const char *GWindowGUI::other_text[NON_AUTOMATION_TOTAL] =
56 const char *GWindowGUI::auto_text[AUTOMATION_TOTAL] =
72 int GWindowGUI::auto_colors[AUTOMATION_TOTAL] =
89 static toggleinfo toggle_order[] =
91 {0, NON_AUTOMATION_ASSETS},
92 {0, NON_AUTOMATION_TITLES},
93 {0, NON_AUTOMATION_TRANSITIONS},
94 {0, NON_AUTOMATION_PLUGIN_AUTOS},
98 {1, AUTOMATION_SPEED},
99 {1, AUTOMATION_CAMERA_X},
100 {1, AUTOMATION_CAMERA_Y},
101 {1, AUTOMATION_CAMERA_Z},
102 {1, AUTOMATION_PROJECTOR_X},
103 {1, AUTOMATION_PROJECTOR_Y},
104 {1, AUTOMATION_PROJECTOR_Z},
105 {1, AUTOMATION_MODE},
107 {1, AUTOMATION_MASK},
110 void GWindowGUI::calculate_extents(BC_WindowBase *gui, int *w, int *h)
112 int temp1, temp2, temp3, temp4, temp5, temp6, temp7;
113 int current_w, current_h;
117 for( int i=0; i<(int)(sizeof(toggle_order)/sizeof(toggle_order[0])); ++i ) {
118 toggleinfo *tp = &toggle_order[i];
119 int isauto = tp->isauto, ref = tp->ref;
121 *h += get_resources()->bar_data->get_h() + 5;
124 BC_Toggle::calculate_extents(gui,
125 BC_WindowBase::get_resources()->checkbox_images,
126 0, &temp1, ¤t_w, ¤t_h,
127 &temp2, &temp3, &temp4, &temp5, &temp6, &temp7,
128 _(isauto ? auto_text[ref] : other_text[ref]),
130 *w = MAX(current_w, *w);
140 void GWindowGUI::create_objects()
143 lock_window("GWindowGUI::create_objects 1");
145 for( int i=0; i<(int)(sizeof(toggle_order)/sizeof(toggle_order[0])); ++i ) {
146 toggleinfo *tp = &toggle_order[i];
149 BC_Bar *bar = new BC_Bar(x,y,get_w()-x-10);
152 y += bar->get_h() + 5;
155 toggles[i] = new GWindowToggle(mwindow, this, x, y, *tp);
156 add_tool(toggles[i]);
159 case AUTOMATION_MODE: vframe = mwindow->theme->modekeyframe_data; break;
160 case AUTOMATION_PAN: vframe = mwindow->theme->pankeyframe_data; break;
161 case AUTOMATION_MASK: vframe = mwindow->theme->maskkeyframe_data; break;
164 draw_vframe(vframe, get_w()-vframe->get_w()-10, y);
165 y += toggles[i]->get_h() + 5;
170 void GWindowGUI::update_mwindow()
173 mwindow->gui->mainmenu->update_toggles(1);
174 lock_window("GWindowGUI::update_mwindow");
177 void GWindowGUI::update_toggles(int use_lock)
179 if(use_lock) lock_window("GWindowGUI::update_toggles");
181 for( int i=0; i<(int)(sizeof(toggle_order)/sizeof(toggle_order[0])); ++i ) {
182 if( toggles[i] ) toggles[i]->update();
185 if(use_lock) unlock_window();
188 int GWindowGUI::translation_event()
190 mwindow->session->gwindow_x = get_x();
191 mwindow->session->gwindow_y = get_y();
195 int GWindowGUI::close_event()
198 mwindow->session->show_gwindow = 0;
201 mwindow->gui->lock_window("GWindowGUI::close_event");
202 mwindow->gui->mainmenu->show_gwindow->set_checked(0);
203 mwindow->gui->unlock_window();
205 lock_window("GWindowGUI::close_event");
206 mwindow->save_defaults();
210 int GWindowGUI::keypress_event()
212 switch(get_keypress()) {
226 GWindowToggle::GWindowToggle(MWindow *mwindow,
227 GWindowGUI *gui, int x, int y, toggleinfo toggleinf)
228 : BC_CheckBox(x, y, *get_main_value(mwindow, toggleinf),
229 _((toggleinf.isauto ?
230 GWindowGUI::auto_text[toggleinf.ref] :
231 GWindowGUI::other_text[toggleinf.ref])),
233 !toggleinf.isauto ? -1 : GWindowGUI::auto_colors[toggleinf.ref])
235 this->mwindow = mwindow;
237 this->toggleinf = toggleinf;
240 int GWindowToggle::handle_event()
242 *get_main_value(mwindow, toggleinf) = get_value();
243 gui->update_mwindow();
246 // Update stuff in MWindow
248 mwindow->gui->lock_window("GWindowToggle::handle_event");
251 mwindow->gui->draw_overlays(1);
255 switch(toggleinf.ref)
257 case NON_AUTOMATION_ASSETS:
258 case NON_AUTOMATION_TITLES:
259 mwindow->gui->update(1, 1, 0, 0, 1, 0, 0);
262 case NON_AUTOMATION_TRANSITIONS:
263 case NON_AUTOMATION_PLUGIN_AUTOS:
264 mwindow->gui->draw_overlays(1);
269 mwindow->gui->unlock_window();
270 lock_window("GWindowToggle::handle_event");
275 int* GWindowToggle::get_main_value(MWindow *mwindow, toggleinfo toggleinf)
277 if( toggleinf.isauto )
278 return &mwindow->edl->session->auto_conf->autos[toggleinf.ref];
280 switch(toggleinf.ref) {
281 case NON_AUTOMATION_ASSETS: return &mwindow->edl->session->show_assets;
282 case NON_AUTOMATION_TITLES: return &mwindow->edl->session->show_titles;
283 case NON_AUTOMATION_TRANSITIONS: return &mwindow->edl->session->auto_conf->transitions;
284 case NON_AUTOMATION_PLUGIN_AUTOS: return &mwindow->edl->session->auto_conf->plugins;
289 void GWindowToggle::update()
291 int *vp = get_main_value(mwindow, toggleinf);