From 31e40639d23be25cebbe3a1c1b5057c5801c2df8 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Mon, 5 May 2008 23:33:41 -0500 Subject: [PATCH] Update menubar entires to reflect session state. --- Timeline/Session.C | 5 ++++ Timeline/Session.H | 2 ++ Timeline/TLE.fl | 62 +++++++++++++++++++++++++++++++++------------- Timeline/main.C | 22 ++++++++-------- 4 files changed, 62 insertions(+), 29 deletions(-) diff --git a/Timeline/Session.C b/Timeline/Session.C index 848df14..9ad5db2 100644 --- a/Timeline/Session.C +++ b/Timeline/Session.C @@ -33,6 +33,7 @@ session state belongs to Timeline and other classes. */ #include "debug.h" char Session::_name[256]; +bool Session::_is_open = false; void Session::set_name ( const char *name ) @@ -60,6 +61,8 @@ bool Session::close ( void ) { Loggable::close(); + + _is_open = false; } bool @@ -84,6 +87,8 @@ Session::open ( const char *name ) set_name( name ); + _is_open = true; + return true; } diff --git a/Timeline/Session.H b/Timeline/Session.H index 27bd4ac..d361ef2 100644 --- a/Timeline/Session.H +++ b/Timeline/Session.H @@ -23,6 +23,7 @@ const char user_template_dir[] = "~/.non-daw/templates"; class Session { + static bool _is_open; static char _name[256]; public: @@ -32,6 +33,7 @@ public: static void set_name ( const char *name ); static bool close ( void ); static bool open ( const char *name ); + static bool open ( void ) { return _is_open; } static bool create ( const char *name, const char *template_name ); }; diff --git a/Timeline/TLE.fl b/Timeline/TLE.fl index 0c4ca21..1c0c706 100644 --- a/Timeline/TLE.fl +++ b/Timeline/TLE.fl @@ -76,6 +76,14 @@ free( path ); code {Fl_Menu_ *o = menubar; Track::capture_format = o->menu()[ o->value() ].label();} {} + } + Function {run()} {open + } { + code {update_menu(); + +main_window->show(); + +Fl::run();} {} } Function {TLE()} {open } { @@ -119,7 +127,7 @@ free( path );} {} } { Fl_Window main_window { label {Non-DAW - Timeline} open - xywh {257 179 1020 765} type Double resizable xclass {Non-DAW} visible + xywh {353 133 1020 765} type Double resizable xclass {Non-DAW} visible } { Fl_Menu_Bar menubar {open xywh {0 0 1024 25} @@ -134,13 +142,11 @@ free( path );} {} } MenuItem {} { label {&New} - callback {if ( new_session_chooser() ) -{ - transport->activate(); - timeline->activate(); -} + callback {new_session_chooser(); -main_window->redraw();} selected +update_menu(); + +main_window->redraw();} xywh {0 0 40 25} } MenuItem {} { @@ -148,20 +154,15 @@ main_window->redraw();} selected callback {const char *name = fl_dir_chooser( "Open Session", NULL, NULL ); Session::close(); -timeline->deactivate(); -transport->deactivate(); if ( ! Session::open( name ) ) { fl_alert( "Could not open \\"%s\\" as a Non-DAW session!", name ); // we are in a somewhar ambiguous state now with no session open. - - return; } -timeline->activate(); -transport->activate();} +update_menu();} xywh {10 10 40 25} } MenuItem {} { @@ -175,7 +176,7 @@ Loggable::compact();} xywh {20 20 40 25} } Submenu {} { - label Export open + label {&Export} open xywh {0 0 74 25} deactivate } { MenuItem {} { @@ -578,6 +579,33 @@ delete win;} } } } + Function {find_item( Fl_Menu_ *menu, const char *path )} {open selected return_type {static Fl_Menu_Item *} + } { + code {return const_cast(menu->find_item( path ));} {} + } + Function {update_menu()} {open + } { + code {Fl_Menu_Bar *m = menubar; + +if ( ! Session::open() ) +{ + find_item( m, "&Session/&Export" )->deactivate(); + find_item( m, "&Session/&Compact" )->deactivate(); + find_item( m, "&Session/&Info" )->deactivate(); + + timeline->deactivate(); + transport->deactivate(); +} +else +{ + find_item( m, "&Session/&Export" )->activate(); + find_item( m, "&Session/&Compact" )->activate(); + find_item( m, "&Session/&Info" )->activate(); + + timeline->activate(); + transport->activate(); +}} {} + } Function {update_progress( Fl_Progress *p, char *s, float v )} {open private return_type {static void} } { code {p->value( v ); @@ -663,7 +691,7 @@ class New_Session_Dialog {open } { code {make_window();} {} } - Function {run()} {open return_type {const char *} + Function {run()} {open return_type void } { code {_window->show(); @@ -736,9 +764,9 @@ while ( _window->shown() ) } } -Function {new_session_chooser()} {open C return_type {const char *} +Function {new_session_chooser()} {open C return_type void } { code {New_Session_Dialog nsd; -return nsd.run();} {} +nsd.run();} {} } diff --git a/Timeline/main.C b/Timeline/main.C index e70fb41..52abfd3 100644 --- a/Timeline/main.C +++ b/Timeline/main.C @@ -86,16 +86,16 @@ int main ( int argc, char **argv ) { /* welcome to C++ */ - LOG_REGISTER_CREATE( Audio_Region ); - LOG_REGISTER_CREATE( Time_Point ); - LOG_REGISTER_CREATE( Tempo_Point ); - LOG_REGISTER_CREATE( Annotation_Point ); - LOG_REGISTER_CREATE( Annotation_Region ); - LOG_REGISTER_CREATE( Control_Point ); - LOG_REGISTER_CREATE( Track ); - LOG_REGISTER_CREATE( Audio_Sequence ); - LOG_REGISTER_CREATE( Control_Sequence ); + LOG_REGISTER_CREATE( Annotation_Point ); + LOG_REGISTER_CREATE( Annotation_Region ); LOG_REGISTER_CREATE( Annotation_Sequence ); + LOG_REGISTER_CREATE( Audio_Region ); + LOG_REGISTER_CREATE( Audio_Sequence ); + LOG_REGISTER_CREATE( Control_Point ); + LOG_REGISTER_CREATE( Control_Sequence ); + LOG_REGISTER_CREATE( Tempo_Point ); + LOG_REGISTER_CREATE( Time_Point ); + LOG_REGISTER_CREATE( Track ); init_boxtypes(); @@ -124,7 +124,5 @@ main ( int argc, char **argv ) MESSAGE( "Starting GUI" ); // tle.main_window->show( argc, argv ); - tle.main_window->show(); - - Fl::run(); + tle.run(); }