Update menubar entires to reflect session state.

This commit is contained in:
Jonathan Moore Liles 2008-05-05 23:33:41 -05:00
parent 2881479cc2
commit 31e40639d2
4 changed files with 62 additions and 29 deletions

View File

@ -33,6 +33,7 @@ session state belongs to Timeline and other classes. */
#include "debug.h" #include "debug.h"
char Session::_name[256]; char Session::_name[256];
bool Session::_is_open = false;
void void
Session::set_name ( const char *name ) Session::set_name ( const char *name )
@ -60,6 +61,8 @@ bool
Session::close ( void ) Session::close ( void )
{ {
Loggable::close(); Loggable::close();
_is_open = false;
} }
bool bool
@ -84,6 +87,8 @@ Session::open ( const char *name )
set_name( name ); set_name( name );
_is_open = true;
return true; return true;
} }

View File

@ -23,6 +23,7 @@ const char user_template_dir[] = "~/.non-daw/templates";
class Session class Session
{ {
static bool _is_open;
static char _name[256]; static char _name[256];
public: public:
@ -32,6 +33,7 @@ public:
static void set_name ( const char *name ); static void set_name ( const char *name );
static bool close ( void ); static bool close ( void );
static bool open ( const char *name ); static bool open ( const char *name );
static bool open ( void ) { return _is_open; }
static bool create ( const char *name, const char *template_name ); static bool create ( const char *name, const char *template_name );
}; };

View File

@ -76,6 +76,14 @@ free( path );
code {Fl_Menu_ *o = menubar; code {Fl_Menu_ *o = menubar;
Track::capture_format = o->menu()[ o->value() ].label();} {} Track::capture_format = o->menu()[ o->value() ].label();} {}
}
Function {run()} {open
} {
code {update_menu();
main_window->show();
Fl::run();} {}
} }
Function {TLE()} {open Function {TLE()} {open
} { } {
@ -119,7 +127,7 @@ free( path );} {}
} { } {
Fl_Window main_window { Fl_Window main_window {
label {Non-DAW - Timeline} open 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 Fl_Menu_Bar menubar {open
xywh {0 0 1024 25} xywh {0 0 1024 25}
@ -134,13 +142,11 @@ free( path );} {}
} }
MenuItem {} { MenuItem {} {
label {&New} label {&New}
callback {if ( new_session_chooser() ) callback {new_session_chooser();
{
transport->activate();
timeline->activate();
}
main_window->redraw();} selected update_menu();
main_window->redraw();}
xywh {0 0 40 25} xywh {0 0 40 25}
} }
MenuItem {} { MenuItem {} {
@ -148,20 +154,15 @@ main_window->redraw();} selected
callback {const char *name = fl_dir_chooser( "Open Session", NULL, NULL ); callback {const char *name = fl_dir_chooser( "Open Session", NULL, NULL );
Session::close(); Session::close();
timeline->deactivate();
transport->deactivate();
if ( ! Session::open( name ) ) if ( ! Session::open( name ) )
{ {
fl_alert( "Could not open \\"%s\\" as a Non-DAW session!", 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. // we are in a somewhar ambiguous state now with no session open.
return;
} }
timeline->activate(); update_menu();}
transport->activate();}
xywh {10 10 40 25} xywh {10 10 40 25}
} }
MenuItem {} { MenuItem {} {
@ -175,7 +176,7 @@ Loggable::compact();}
xywh {20 20 40 25} xywh {20 20 40 25}
} }
Submenu {} { Submenu {} {
label Export open label {&Export} open
xywh {0 0 74 25} deactivate xywh {0 0 74 25} deactivate
} { } {
MenuItem {} { 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<Fl_Menu_Item*>(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} Function {update_progress( Fl_Progress *p, char *s, float v )} {open private return_type {static void}
} { } {
code {p->value( v ); code {p->value( v );
@ -663,7 +691,7 @@ class New_Session_Dialog {open
} { } {
code {make_window();} {} code {make_window();} {}
} }
Function {run()} {open return_type {const char *} Function {run()} {open return_type void
} { } {
code {_window->show(); 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; code {New_Session_Dialog nsd;
return nsd.run();} {} nsd.run();} {}
} }

View File

@ -86,16 +86,16 @@ int
main ( int argc, char **argv ) main ( int argc, char **argv )
{ {
/* welcome to C++ */ /* 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_Point );
LOG_REGISTER_CREATE( Annotation_Region ); 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_Sequence ); 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(); init_boxtypes();
@ -124,7 +124,5 @@ main ( int argc, char **argv )
MESSAGE( "Starting GUI" ); MESSAGE( "Starting GUI" );
// tle.main_window->show( argc, argv ); // tle.main_window->show( argc, argv );
tle.main_window->show(); tle.run();
Fl::run();
} }