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,
42 : BC_Window(_(PROGRAM_NAME ": Overlays"),
43 mwindow->session->gwindow_x,
44 mwindow->session->gwindow_y,
53 this->mwindow = mwindow;
58 static const char *other_text[OTHER_TOGGLES] =
66 static const char *auto_text[AUTOMATION_TOTAL] =
82 void GWindowGUI::calculate_extents(BC_WindowBase *gui, int *w, int *h)
84 int temp1, temp2, temp3, temp4, temp5, temp6, temp7;
85 int current_w, current_h;
88 for(int i = 0; i < OTHER_TOGGLES; i++)
90 BC_Toggle::calculate_extents(gui,
91 BC_WindowBase::get_resources()->checkbox_images,
104 *w = MAX(current_w, *w);
108 for(int i = 0; i < AUTOMATION_TOTAL; i++)
110 BC_Toggle::calculate_extents(gui,
111 BC_WindowBase::get_resources()->checkbox_images,
124 *w = MAX(current_w, *w);
133 void GWindowGUI::create_objects()
136 lock_window("GWindowGUI::create_objects 1");
139 for(int i = 0; i < OTHER_TOGGLES; i++)
141 add_tool(other[i] = new GWindowToggle(mwindow,
148 y += other[i]->get_h() + 5;
151 for(int i = 0; i < AUTOMATION_TOTAL; i++)
153 add_tool(auto_toggle[i] = new GWindowToggle(mwindow,
160 y += auto_toggle[i]->get_h() + 5;
165 void GWindowGUI::update_mwindow()
168 mwindow->gui->mainmenu->update_toggles(1);
169 lock_window("GWindowGUI::update_mwindow");
172 void GWindowGUI::update_toggles(int use_lock)
174 if(use_lock) lock_window("GWindowGUI::update_toggles");
176 for(int i = 0; i < OTHER_TOGGLES; i++)
181 for(int i = 0; i < AUTOMATION_TOTAL; i++)
183 auto_toggle[i]->update();
186 if(use_lock) unlock_window();
189 int GWindowGUI::translation_event()
191 mwindow->session->gwindow_x = get_x();
192 mwindow->session->gwindow_y = get_y();
196 int GWindowGUI::close_event()
199 mwindow->session->show_gwindow = 0;
202 mwindow->gui->lock_window("GWindowGUI::close_event");
203 mwindow->gui->mainmenu->show_gwindow->set_checked(0);
204 mwindow->gui->unlock_window();
206 lock_window("GWindowGUI::close_event");
207 mwindow->save_defaults();
211 int GWindowGUI::keypress_event()
213 switch(get_keypress())
227 int GWindowGUI::cursor_motion_event()
229 //int cursor_x = get_relative_cursor_x();
230 int cursor_y = get_relative_cursor_y();
231 //int update_gui = 0;
238 for(int i = 0; i < MAX(OTHER_TOGGLES, AUTOMATION_TOTAL); i++)
240 if(i < OTHER_TOGGLES)
242 if(cursor_y >= other[i]->get_y() &&
243 cursor_y < other[i]->get_y() + other[i]->get_h())
245 other[i]->BC_Toggle::update(new_status);
250 if(i < AUTOMATION_TOTAL)
252 if(cursor_y >= auto_toggle[i]->get_y() &&
253 cursor_y < auto_toggle[i]->get_y() + auto_toggle[i]->get_h())
255 auto_toggle[i]->BC_Toggle::update(new_status);
273 GWindowToggle::GWindowToggle(MWindow *mwindow,
282 *get_main_value(mwindow, subscript, other),
285 this->mwindow = mwindow;
287 this->subscript = subscript;
293 int GWindowToggle::button_press_event()
295 if(is_event_win() && get_buttonpress() == 1)
297 //printf("GWindowToggle::button_press_event %d %d\n", __LINE__, get_value());
298 set_status(BC_Toggle::TOGGLE_DOWN);
300 BC_Toggle::update(!get_value());
301 gui->drag_operation = 1;
302 gui->new_status = get_value();
303 //printf("GWindowToggle::button_press_event %d %d\n", __LINE__, get_value());
310 int GWindowToggle::button_release_event()
312 int result = BC_Toggle::button_release_event();
313 gui->drag_operation = 0;
320 int GWindowToggle::handle_event()
322 *get_main_value(mwindow, subscript, other) = get_value();
323 gui->update_mwindow();
326 // Update stuff in MWindow
328 mwindow->gui->lock_window("GWindowToggle::handle_event");
331 mwindow->gui->draw_overlays(1);
339 mwindow->gui->update(1,
350 mwindow->gui->draw_overlays(1);
355 mwindow->gui->unlock_window();
356 lock_window("GWindowToggle::handle_event");
361 int *GWindowToggle::get_main_value(MWindow *mwindow, int subscript, int other)
365 return &mwindow->edl->session->auto_conf->autos[subscript];
372 return &mwindow->edl->session->show_assets;
375 return &mwindow->edl->session->show_titles;
378 return &mwindow->edl->session->auto_conf->transitions;
381 return &mwindow->edl->session->auto_conf->plugins;
388 void GWindowToggle::update()
390 set_value(*get_main_value(mwindow, subscript, other));