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"
29 #include "mainsession.h"
31 #include "mwindowgui.h"
32 #include "trackcanvas.h"
38 GWindowGUI::GWindowGUI(MWindow *mwindow,
41 : BC_Window(PROGRAM_NAME ": Overlays",
42 mwindow->session->gwindow_x,
43 mwindow->session->gwindow_y,
52 this->mwindow = mwindow;
57 static const char *other_text[OTHER_TOGGLES] =
65 static const char *auto_text[AUTOMATION_TOTAL] =
81 void GWindowGUI::calculate_extents(BC_WindowBase *gui, int *w, int *h)
83 int temp1, temp2, temp3, temp4, temp5, temp6, temp7;
84 int current_w, current_h;
87 for(int i = 0; i < OTHER_TOGGLES; i++)
89 BC_Toggle::calculate_extents(gui,
90 BC_WindowBase::get_resources()->checkbox_images,
103 *w = MAX(current_w, *w);
107 for(int i = 0; i < AUTOMATION_TOTAL; i++)
109 BC_Toggle::calculate_extents(gui,
110 BC_WindowBase::get_resources()->checkbox_images,
123 *w = MAX(current_w, *w);
132 void GWindowGUI::create_objects()
135 lock_window("GWindowGUI::create_objects 1");
138 for(int i = 0; i < OTHER_TOGGLES; i++)
140 add_tool(other[i] = new GWindowToggle(mwindow,
147 y += other[i]->get_h() + 5;
150 for(int i = 0; i < AUTOMATION_TOTAL; i++)
152 add_tool(auto_toggle[i] = new GWindowToggle(mwindow,
159 y += auto_toggle[i]->get_h() + 5;
164 void GWindowGUI::update_mwindow()
167 mwindow->gui->mainmenu->update_toggles(1);
168 lock_window("GWindowGUI::update_mwindow");
171 void GWindowGUI::update_toggles(int use_lock)
173 if(use_lock) lock_window("GWindowGUI::update_toggles");
175 for(int i = 0; i < OTHER_TOGGLES; i++)
180 for(int i = 0; i < AUTOMATION_TOTAL; i++)
182 auto_toggle[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 int GWindowGUI::cursor_motion_event()
228 //int cursor_x = get_relative_cursor_x();
229 int cursor_y = get_relative_cursor_y();
230 //int update_gui = 0;
237 for(int i = 0; i < MAX(OTHER_TOGGLES, AUTOMATION_TOTAL); i++)
239 if(i < OTHER_TOGGLES)
241 if(cursor_y >= other[i]->get_y() &&
242 cursor_y < other[i]->get_y() + other[i]->get_h())
244 other[i]->BC_Toggle::update(new_status);
249 if(i < AUTOMATION_TOTAL)
251 if(cursor_y >= auto_toggle[i]->get_y() &&
252 cursor_y < auto_toggle[i]->get_y() + auto_toggle[i]->get_h())
254 auto_toggle[i]->BC_Toggle::update(new_status);
272 GWindowToggle::GWindowToggle(MWindow *mwindow,
281 *get_main_value(mwindow, subscript, other),
284 this->mwindow = mwindow;
286 this->subscript = subscript;
292 int GWindowToggle::button_press_event()
294 if(is_event_win() && get_buttonpress() == 1)
296 //printf("GWindowToggle::button_press_event %d %d\n", __LINE__, get_value());
297 set_status(BC_Toggle::TOGGLE_DOWN);
299 BC_Toggle::update(!get_value());
300 gui->drag_operation = 1;
301 gui->new_status = get_value();
302 //printf("GWindowToggle::button_press_event %d %d\n", __LINE__, get_value());
309 int GWindowToggle::button_release_event()
311 int result = BC_Toggle::button_release_event();
312 gui->drag_operation = 0;
319 int GWindowToggle::handle_event()
321 *get_main_value(mwindow, subscript, other) = get_value();
322 gui->update_mwindow();
325 // Update stuff in MWindow
327 mwindow->gui->lock_window("GWindowToggle::handle_event");
330 mwindow->gui->draw_overlays(1);
338 mwindow->gui->update(1,
349 mwindow->gui->draw_overlays(1);
354 mwindow->gui->unlock_window();
355 lock_window("GWindowToggle::handle_event");
360 int *GWindowToggle::get_main_value(MWindow *mwindow, int subscript, int other)
364 return &mwindow->edl->session->auto_conf->autos[subscript];
371 return &mwindow->edl->session->show_assets;
374 return &mwindow->edl->session->show_titles;
377 return &mwindow->edl->session->auto_conf->transitions;
380 return &mwindow->edl->session->auto_conf->plugins;
387 void GWindowToggle::update()
389 set_value(*get_main_value(mwindow, subscript, other));