Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

gwindowgui.C

Go to the documentation of this file.
00001 #include "autoconf.h"
00002 #include "bcsignals.h"
00003 #include "clip.h"
00004 #include "edl.h"
00005 #include "edlsession.h"
00006 #include "gwindowgui.h"
00007 #include "mainmenu.h"
00008 #include "mainsession.h"
00009 #include "mwindow.h"
00010 #include "mwindowgui.h"
00011 #include "trackcanvas.h"
00012 
00013 
00014 
00015 
00016 
00017 GWindowGUI::GWindowGUI(MWindow *mwindow,
00018         int w,
00019         int h)
00020  : BC_Window(PROGRAM_NAME ": Overlays",
00021         mwindow->session->gwindow_x, 
00022     mwindow->session->gwindow_y, 
00023     w, 
00024     h,
00025     w,
00026     h,
00027     0,
00028     0,
00029     1)
00030 {
00031         this->mwindow = mwindow;
00032 }
00033 
00034 static char *other_text[OTHER_TOGGLES] =
00035 {
00036         "Assets",
00037         "Titles",
00038         "Transitions",
00039         "Plugin Autos"
00040 };
00041 
00042 static char *auto_text[] = 
00043 {
00044         "Mute",
00045         "Camera X",
00046         "Camera Y",
00047         "Camera Z",
00048         "Projector X",
00049         "Projector Y",
00050         "Projector Z",
00051         "Fade",
00052         "Pan",
00053         "Mode",
00054         "Mask",
00055         "Nudge"
00056 };
00057 
00058 void GWindowGUI::calculate_extents(BC_WindowBase *gui, int *w, int *h)
00059 {
00060         int temp1, temp2, temp3, temp4, temp5, temp6, temp7;
00061         int current_w, current_h;
00062         *w = 10;
00063         *h = 10;
00064         for(int i = 0; i < OTHER_TOGGLES; i++)
00065         {
00066                 BC_Toggle::calculate_extents(gui, 
00067                         BC_WindowBase::get_resources()->checkbox_images,
00068                         0,
00069                         &temp1,
00070                         &current_w,
00071                         &current_h,
00072                         &temp2,
00073                         &temp3,
00074                         &temp4,
00075                         &temp5, 
00076                         &temp6,
00077                         &temp7, 
00078                         other_text[i]);
00079                 *w = MAX(current_w, *w);
00080                 *h += current_h + 5;
00081         }
00082 
00083         for(int i = 0; i < AUTOMATION_TOTAL; i++)
00084         {
00085                 BC_Toggle::calculate_extents(gui, 
00086                         BC_WindowBase::get_resources()->checkbox_images,
00087                         0,
00088                         &temp1,
00089                         &current_w,
00090                         &current_h,
00091                         &temp2,
00092                         &temp3,
00093                         &temp4,
00094                         &temp5, 
00095                         &temp6,
00096                         &temp7, 
00097                         auto_text[i]);
00098                 *w = MAX(current_w, *w);
00099                 *h += current_h + 5;
00100         }
00101         *h += 10;
00102         *w += 20;
00103 }
00104 
00105 
00106 
00107 void GWindowGUI::create_objects()
00108 {
00109         int x = 10, y = 10;
00110 
00111 
00112         for(int i = 0; i < OTHER_TOGGLES; i++)
00113         {
00114                 add_tool(other[i] = new GWindowToggle(mwindow, 
00115                         this, 
00116                         x, 
00117                         y, 
00118                         -1,
00119                         i, 
00120                         other_text[i]));
00121                 y += other[i]->get_h() + 5;
00122         }
00123 
00124         for(int i = 0; i < AUTOMATION_TOTAL; i++)
00125         {
00126                 add_tool(auto_toggle[i] = new GWindowToggle(mwindow, 
00127                         this, 
00128                         x, 
00129                         y, 
00130                         i,
00131                         -1, 
00132                         auto_text[i]));
00133                 y += auto_toggle[i]->get_h() + 5;
00134         }
00135 }
00136 
00137 void GWindowGUI::update_mwindow()
00138 {
00139         unlock_window();
00140         mwindow->gui->mainmenu->update_toggles(1);
00141         lock_window("GWindowGUI::update_mwindow");
00142 }
00143 
00144 void GWindowGUI::update_toggles(int use_lock)
00145 {
00146         if(use_lock) lock_window("GWindowGUI::update_toggles");
00147 
00148         for(int i = 0; i < OTHER_TOGGLES; i++)
00149         {
00150                 other[i]->update();
00151         }
00152 
00153         for(int i = 0; i < AUTOMATION_TOTAL; i++)
00154         {
00155                 auto_toggle[i]->update();
00156         }
00157 
00158         if(use_lock) unlock_window();
00159 }
00160 
00161 int GWindowGUI::translation_event()
00162 {
00163         mwindow->session->gwindow_x = get_x();
00164         mwindow->session->gwindow_y = get_y();
00165         return 0;
00166 }
00167 
00168 int GWindowGUI::close_event()
00169 {
00170         hide_window();
00171         mwindow->session->show_gwindow = 0;
00172         unlock_window();
00173 
00174         mwindow->gui->lock_window("GWindowGUI::close_event");
00175         mwindow->gui->mainmenu->show_gwindow->set_checked(0);
00176         mwindow->gui->unlock_window();
00177 
00178         lock_window("GWindowGUI::close_event");
00179         mwindow->save_defaults();
00180         return 1;
00181 }
00182 
00183 int GWindowGUI::keypress_event()
00184 {
00185         switch(get_keypress())
00186         {
00187                 case 'w':
00188                 case 'W':
00189                         if(ctrl_down())
00190                         {
00191                                 close_event();
00192                                 return 1;
00193                         }
00194                         break;
00195         }
00196         return 0;
00197 }
00198 
00199 
00200 
00201 
00202 
00203 
00204 GWindowToggle::GWindowToggle(MWindow *mwindow, 
00205         GWindowGUI *gui, 
00206         int x, 
00207         int y, 
00208         int subscript, 
00209         int other,
00210         char *text)
00211  : BC_CheckBox(x, 
00212         y, 
00213         *get_main_value(mwindow, subscript, other), 
00214         text)
00215 {
00216         this->mwindow = mwindow;
00217         this->gui = gui;
00218         this->subscript = subscript;
00219         this->other = other;
00220 }
00221 
00222 int GWindowToggle::handle_event()
00223 {
00224         *get_main_value(mwindow, subscript, other) = get_value();
00225         gui->update_mwindow();
00226 
00227 
00228 // Update stuff in MWindow
00229         unlock_window();
00230         mwindow->gui->lock_window("GWindowToggle::handle_event");
00231         if(subscript >= 0)
00232         {
00233                 mwindow->gui->canvas->draw_overlays();
00234                 mwindow->gui->canvas->flash();
00235         }
00236         else
00237         {
00238                 switch(other)
00239                 {
00240                         case ASSETS:
00241                         case TITLES:
00242                                 mwindow->gui->update(1,
00243                                         1,
00244                                         0,
00245                                         0,
00246                                         1, 
00247                                         0,
00248                                         0);
00249                                 break;
00250 
00251                         case TRANSITIONS:
00252                         case PLUGIN_AUTOS:
00253                                 mwindow->gui->canvas->draw_overlays();
00254                                 mwindow->gui->canvas->flash();
00255                                 break;
00256                 }
00257         }
00258 
00259         mwindow->gui->unlock_window();
00260         lock_window("GWindowToggle::handle_event");
00261 
00262         return 1;
00263 }
00264 
00265 int* GWindowToggle::get_main_value(MWindow *mwindow, int subscript, int other)
00266 {
00267         if(subscript >= 0)
00268         {
00269                 return &mwindow->edl->session->auto_conf->autos[subscript];
00270         }
00271         else
00272         {
00273                 switch(other)
00274                 {
00275                         case ASSETS:
00276                                 return &mwindow->edl->session->show_assets;
00277                                 break;
00278                         case TITLES:
00279                                 return &mwindow->edl->session->show_titles;
00280                                 break;
00281                         case TRANSITIONS:
00282                                 return &mwindow->edl->session->auto_conf->transitions;
00283                                 break;
00284                         case PLUGIN_AUTOS:
00285                                 return &mwindow->edl->session->auto_conf->plugins;
00286                                 break;
00287                 }
00288         }
00289 }
00290 
00291 void GWindowToggle::update()
00292 {
00293         set_value(*get_main_value(mwindow, subscript, other));
00294 }
00295 
00296 
00297 

Generated on Sun Jan 8 13:38:56 2006 for Cinelerra-svn by  doxygen 1.4.4