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"
33 #include "trackcanvas.h"
39 GWindowGUI::GWindowGUI(MWindow *mwindow, int w, int h)
40 : BC_Window(_(PROGRAM_NAME ": Overlays"),
41 mwindow->session->gwindow_x, mwindow->session->gwindow_y,
44 this->mwindow = mwindow;
47 static const char *other_text[NON_AUTOMATION_TOTAL] =
55 static const char *auto_text[AUTOMATION_TOTAL] =
72 static toggleinfo toggle_order[] =
74 {0, NON_AUTOMATION_ASSETS},
75 {0, NON_AUTOMATION_TITLES},
76 {0, NON_AUTOMATION_TRANSITIONS},
81 {0, NON_AUTOMATION_PLUGIN_AUTOS},
83 {1, AUTOMATION_SPEED},
84 {1, AUTOMATION_CAMERA_X},
85 {1, AUTOMATION_CAMERA_Y},
86 {1, AUTOMATION_CAMERA_Z},
87 {1, AUTOMATION_PROJECTOR_X},
88 {1, AUTOMATION_PROJECTOR_Y},
89 {1, AUTOMATION_PROJECTOR_Z},
92 void GWindowGUI::calculate_extents(BC_WindowBase *gui, int *w, int *h)
94 int temp1, temp2, temp3, temp4, temp5, temp6, temp7;
95 int current_w, current_h;
99 for(int i = 0; i < NON_AUTOMATION_TOTAL + AUTOMATION_TOTAL; i++)
101 BC_Toggle::calculate_extents(gui,
102 BC_WindowBase::get_resources()->checkbox_images,
103 0, &temp1, ¤t_w, ¤t_h,
104 &temp2, &temp3, &temp4, &temp5, &temp6, &temp7,
105 _(toggle_order[i].isauto ?
106 auto_text[toggle_order[i].ref] :
107 other_text[toggle_order[i].ref]), MEDIUMFONT);
108 *w = MAX(current_w, *w);
118 void GWindowGUI::create_objects()
121 lock_window("GWindowGUI::create_objects 1");
124 for(int i = 0; i < NON_AUTOMATION_TOTAL + AUTOMATION_TOTAL; i++)
126 add_tool(toggles[i] = new GWindowToggle(mwindow,
131 y += toggles[i]->get_h() + 5;
136 void GWindowGUI::update_mwindow()
139 mwindow->gui->mainmenu->update_toggles(1);
140 lock_window("GWindowGUI::update_mwindow");
143 void GWindowGUI::update_toggles(int use_lock)
145 if(use_lock) lock_window("GWindowGUI::update_toggles");
147 for(int i = 0; i < NON_AUTOMATION_TOTAL + AUTOMATION_TOTAL; i++)
149 toggles[i]->update();
152 if(use_lock) unlock_window();
155 int GWindowGUI::translation_event()
157 mwindow->session->gwindow_x = get_x();
158 mwindow->session->gwindow_y = get_y();
162 int GWindowGUI::close_event()
165 mwindow->session->show_gwindow = 0;
168 mwindow->gui->lock_window("GWindowGUI::close_event");
169 mwindow->gui->mainmenu->show_gwindow->set_checked(0);
170 mwindow->gui->unlock_window();
172 lock_window("GWindowGUI::close_event");
173 mwindow->save_defaults();
177 int GWindowGUI::keypress_event()
179 switch(get_keypress())
198 GWindowToggle::GWindowToggle(MWindow *mwindow,
199 GWindowGUI *gui, int x, int y, toggleinfo toggleinf)
200 : BC_CheckBox(x, y, *get_main_value(mwindow, toggleinf),
201 _((toggleinf.isauto ? auto_text[toggleinf.ref] : other_text[toggleinf.ref])))
203 this->mwindow = mwindow;
205 this->toggleinf = toggleinf;
208 int GWindowToggle::handle_event()
210 *get_main_value(mwindow, toggleinf) = get_value();
211 gui->update_mwindow();
214 // Update stuff in MWindow
216 mwindow->gui->lock_window("GWindowToggle::handle_event");
219 mwindow->gui->draw_overlays(1);
223 switch(toggleinf.ref)
225 case NON_AUTOMATION_ASSETS:
226 case NON_AUTOMATION_TITLES:
227 mwindow->gui->update(1, 1, 0, 0, 1, 0, 0);
230 case NON_AUTOMATION_TRANSITIONS:
231 case NON_AUTOMATION_PLUGIN_AUTOS:
232 mwindow->gui->draw_overlays(1);
237 mwindow->gui->unlock_window();
238 lock_window("GWindowToggle::handle_event");
243 int* GWindowToggle::get_main_value(MWindow *mwindow, toggleinfo toggleinf)
247 return &mwindow->edl->session->auto_conf->autos[toggleinf.ref];
251 switch(toggleinf.ref)
253 case NON_AUTOMATION_ASSETS:
254 return &mwindow->edl->session->show_assets;
255 case NON_AUTOMATION_TITLES:
256 return &mwindow->edl->session->show_titles;
257 case NON_AUTOMATION_TRANSITIONS:
258 return &mwindow->edl->session->auto_conf->transitions;
259 case NON_AUTOMATION_PLUGIN_AUTOS:
260 return &mwindow->edl->session->auto_conf->plugins;
266 void GWindowToggle::update()
268 set_value(*get_main_value(mwindow, toggleinf));