Rearrange menus. Keep timeline menu in timeline class and share it with popup menu.

This commit is contained in:
Jonathan Moore Liles 2008-05-25 01:14:17 -05:00
parent 3d40848e52
commit 06a0518463
3 changed files with 250 additions and 205 deletions

View File

@ -82,19 +82,8 @@ class TLE {open
char *path;
asprintf( &path, "%s/%s", user_config_dir, options_filename );
((Fl_Menu_Settings*)menubar)->dump( menubar->find_item( "&Options" ), path );
free( path );
// save unjournaled state
// Loggable::save_unjournaled( state_filename );
if ( Project::open() )
{
// save project local options (Timeline menu)
((Fl_Menu_Settings*)menubar)->dump( menubar->find_item( "&Timeline" ), options_filename );
}} {}
((Fl_Menu_Settings*)menubar)->dump( menubar->find_item( "&Options/&Global" ), path );
free( path );} {}
}
Function {capture_format_cb( Fl_Widget *w, void *v )} {open private return_type {static void}
} {
@ -122,6 +111,13 @@ Fl::run();} {}
make_window();
{
Fl_Menu_Item *tl = (Fl_Menu_Item*)menubar->find_item( "&Timeline" );
tl->user_data( timeline->menu );
tl->flags = FL_SUBMENU_POINTER;
}
Fl::visible_focus( 0 );
Fl::get_system_colors();
@ -148,25 +144,25 @@ for ( std::list <const char *>::const_iterator f = formats.begin(); f != formats
// capture_format_menu->add( *f, FL_MENU_RADIO, 0, 0, 0 );
//;
char pat[256];
snprintf( pat, sizeof( pat ), "&Timeline/Capture Format/%s", *f );
snprintf( pat, sizeof( pat ), "&Options/&Project/&Timeline/Capture Format/%s", *f );
menubar->add( pat, 0, &TLE::capture_format_cb, this, FL_MENU_RADIO );
}
menubar->picked( menubar->find_item( "&Timeline/Capture Format/Wav 24" ) );
menubar->picked( menubar->find_item( "&Options/&Project/&Timeline/Capture Format/Wav 24" ) );
char *path;
asprintf( &path, "%s/options", user_config_dir );
((Fl_Menu_Settings*)menubar)->load( menubar->find_item( "&Options" ), path );
((Fl_Menu_Settings*)menubar)->load( menubar->find_item( "&Options/&Global" ), path );
free( path );} {}
}
Function {make_window()} {open
} {
Fl_Window main_window {
label Timeline open
xywh {254 185 1020 765} type Double resizable xclass Non_DAW visible
xywh {225 89 1020 765} type Double resizable xclass Non_DAW visible
} {
Fl_Menu_Bar menubar {open selected
xywh {0 0 1024 25}
@ -285,6 +281,10 @@ Loggable::compact();}
xywh {40 40 40 25} shortcut 0x10072
}
}
MenuItem {} {
label {&Timeline}
xywh {5 5 40 25}
}
Submenu {} {
label {&View} open
xywh {0 0 74 25}
@ -325,160 +325,120 @@ Loggable::compact();}
}
}
}
Submenu timeline_menu {
label {&Timeline} open
xywh {0 0 74 25}
} {
MenuItem {} {
label {&Follow Playhead}
callback {Timeline::follow_playhead = menu_picked_value( o );}
xywh {20 20 40 25} type Toggle value 1
}
MenuItem {} {
label {&Center Playhead}
callback {Timeline::center_playhead = menu_picked_value( o );}
xywh {30 30 40 25} type Toggle value 1
}
Submenu {} {
label {&Snap to} open
xywh {0 0 74 25}
} {
MenuItem {} {
label Bars
callback {Timeline::snap_to = Timeline::Bars;}
xywh {0 0 40 25} type Radio value 1
}
MenuItem {} {
label Beats
callback {Timeline::snap_to = Timeline::Beats;}
xywh {10 10 40 25} type Radio
}
MenuItem {} {
label Off
callback {Timeline::snap_to = Timeline::None;}
xywh {20 20 40 25} type Radio
}
}
MenuItem {} {
label {Magnetic snap}
callback {Timeline::snap_magnetic = menu_picked_value( o );}
xywh {10 10 40 25} type Toggle value 1
}
Submenu {} {
label {Capture Format} open
xywh {0 0 74 25}
} {}
}
Submenu {} {
label {&Options} open
xywh {0 0 74 25} divider
} {
Submenu {} {
label {&Display} open
label {&Global} open
xywh {0 0 74 25}
} {
Submenu {} {
label {&Timeline} open
xywh {0 0 74 25}
label {&Display} open
xywh {5 5 74 25}
} {
MenuItem {} {
label {&Measure lines}
callback {Timeline::draw_with_measure_lines = menu_picked_value( o );
Submenu {} {
label {&Timeline} open
xywh {5 5 74 25}
} {
MenuItem {} {
label {&Measure lines}
callback {Timeline::draw_with_measure_lines = menu_picked_value( o );
timeline->redraw();}
xywh {0 0 40 25} type Toggle value 1
xywh {5 5 40 25} type Toggle value 1
}
}
}
Submenu {} {
label {&Waveform} open
xywh {0 0 74 25}
} {
MenuItem {} {
label Fill
callback {Waveform::fill = menu_picked_value( o );
Submenu {} {
label {&Waveform} open
xywh {5 5 74 25}
} {
MenuItem {} {
label Fill
callback {Waveform::fill = menu_picked_value( o );
timeline->redraw();}
xywh {10 10 40 25} type Toggle value 1
}
MenuItem {} {
label Outline
callback {Waveform::outline = menu_picked_value( o );
xywh {15 15 40 25} type Toggle value 1
}
MenuItem {} {
label Outline
callback {Waveform::outline = menu_picked_value( o );
timeline->redraw();}
xywh {30 30 40 25} type Toggle value 1
}
MenuItem {} {
label {Vary color}
callback {Waveform::vary_color = menu_picked_value( o );
xywh {35 35 40 25} type Toggle value 1
}
MenuItem {} {
label {Vary color}
callback {Waveform::vary_color = menu_picked_value( o );
timeline->redraw();}
xywh {20 20 40 25} type Toggle value 1
xywh {25 25 40 25} type Toggle value 1
}
}
}
Submenu {} {
label {&Region} open
xywh {0 0 74 25}
} {
MenuItem {} {
label {Filled fades}
xywh {30 30 40 25} type Toggle value 1
}
MenuItem {} {
label {Inherit track color}
callback {Audio_Region::inherit_track_color = menu_picked_value( o );
Submenu {} {
label {&Region} open
xywh {5 5 74 25}
} {
MenuItem {} {
label {Filled fades}
xywh {35 35 40 25} type Toggle value 1
}
MenuItem {} {
label {Inherit track color}
callback {Audio_Region::inherit_track_color = menu_picked_value( o );
timeline->redraw();}
xywh {40 40 40 25} type Toggle value 1
xywh {45 45 40 25} type Toggle value 1
}
}
}
Submenu {} {
label {&Control Sequence} open
xywh {0 0 74 25}
} {
MenuItem {} {
label Polygon
callback {Control_Sequence::draw_with_polygon = menu_picked_value( o );
Submenu {} {
label {&Control Sequence} open
xywh {5 5 74 25}
} {
MenuItem {} {
label Polygon
callback {Control_Sequence::draw_with_polygon = menu_picked_value( o );
timeline->redraw();}
xywh {20 20 40 25} type Toggle value 1
}
MenuItem {} {
label Graded
callback {Control_Sequence::draw_with_gradient = menu_picked_value( o );
xywh {25 25 40 25} type Toggle value 1
}
MenuItem {} {
label Graded
callback {Control_Sequence::draw_with_gradient = menu_picked_value( o );
timeline->redraw();}
xywh {30 30 40 25} type Toggle value 1
}
MenuItem {} {
label Ruled
callback {Control_Sequence::draw_with_grid = menu_picked_value( o );
xywh {35 35 40 25} type Toggle value 1
}
MenuItem {} {
label Ruled
callback {Control_Sequence::draw_with_grid = menu_picked_value( o );
timeline->redraw();}
xywh {40 40 40 25} type Toggle value 1
xywh {45 45 40 25} type Toggle value 1
}
}
}
Submenu {} {
label {&Style} open
xywh {0 0 74 25}
} {
MenuItem {} {
label Default
callback {Fl::scheme( "plastic" );}
xywh {0 0 40 25} type Radio value 1
Submenu {} {
label {&Style} open
xywh {5 5 74 25}
} {
MenuItem {} {
label Default
callback {Fl::scheme( "plastic" );}
xywh {5 5 40 25} type Radio value 1
}
MenuItem {} {
label Flat
callback {Fl::scheme( "gtk+" );}
xywh {15 15 40 25} type Radio
}
}
MenuItem {} {
label Flat
callback {Fl::scheme( "gtk+" );}
xywh {10 10 40 25} type Radio
}
}
Submenu {} {
label {C&olors} open
xywh {0 0 74 25}
} {
MenuItem {} {
label System
callback {//Fl::get_system_colors();
Submenu {} {
label {C&olors} open
xywh {5 5 74 25}
} {
MenuItem {} {
label System
callback {//Fl::get_system_colors();
unsigned char r, g, b;
@ -495,28 +455,78 @@ Fl::get_color( system_colors[ 2 ], r, g, b );
Fl::background2( r, g, b );
Fl::scheme( Fl::scheme() );}
xywh {0 0 40 25} type Radio
}
MenuItem {} {
label Dark
callback {Fl::background2( 100, 100, 100 );
xywh {5 5 40 25} type Radio
}
MenuItem {} {
label Dark
callback {Fl::background2( 100, 100, 100 );
Fl::background( 50, 50, 50 );
Fl::foreground( 255, 255, 255 );
Fl::scheme( Fl::scheme() );}
xywh {10 10 40 25} type Radio value 1
}
MenuItem {} {
label Light
callback {Fl::background2( 192, 192, 192 );
xywh {15 15 40 25} type Radio value 1
}
MenuItem {} {
label Light
callback {Fl::background2( 192, 192, 192 );
Fl::background( 220, 220, 220 );
Fl::foreground( 0, 0, 0 );
Fl::scheme( Fl::scheme() );}
xywh {20 20 40 25} type Radio
xywh {25 25 40 25} type Radio
}
}
}
}
Submenu {} {
label {&Project} open
xywh {0 0 74 25}
} {
Submenu {} {
label {&Timeline} open
xywh {10 10 74 25}
} {
MenuItem {} {
label {&Follow Playhead}
callback {Timeline::follow_playhead = menu_picked_value( o );}
xywh {30 30 40 25} type Toggle value 1
}
MenuItem {} {
label {&Center Playhead}
callback {Timeline::center_playhead = menu_picked_value( o );}
xywh {40 40 40 25} type Toggle value 1
}
Submenu {} {
label {&Snap to} open
xywh {10 10 74 25}
} {
MenuItem {} {
label Bars
callback {Timeline::snap_to = Timeline::Bars;}
xywh {10 10 40 25} type Radio value 1
}
MenuItem {} {
label Beats
callback {Timeline::snap_to = Timeline::Beats;}
xywh {20 20 40 25} type Radio
}
MenuItem {} {
label Off
callback {Timeline::snap_to = Timeline::None;}
xywh {30 30 40 25} type Radio
}
}
MenuItem {} {
label {Magnetic snap}
callback {Timeline::snap_magnetic = menu_picked_value( o );}
xywh {20 20 40 25} type Toggle value 1
}
Submenu {} {
label {Capture Format} open
xywh {10 10 74 25}
} {}
}
}
}
Submenu {} {
label {&Help} open
@ -635,7 +645,7 @@ if ( ! Project::open() )
find_item( m, "&Project/&Compact" )->deactivate();
find_item( m, "&Project/&Info" )->deactivate();
find_item( m, "&Timeline" )->deactivate();
find_item( m, "&Options/&Project/&Timeline" )->deactivate();
timeline->deactivate();
transport->deactivate();
@ -646,7 +656,7 @@ else
find_item( m, "&Project/&Compact" )->activate();
find_item( m, "&Project/&Info" )->activate();
find_item( m, "&Timeline" )->activate();
find_item( m, "&Options/&Project/&Timeline" )->activate();
timeline->activate();
transport->activate();
@ -758,14 +768,14 @@ You should have received a copy of the GNU General Public License along with thi
code {if ( Project::open() )
{
// save project local options (Timeline menu)
((Fl_Menu_Settings*)menubar)->dump( menubar->find_item( "&Timeline" ), "options" );
((Fl_Menu_Settings*)menubar)->dump( menubar->find_item( "&Options/&Project" ), "options" );
}} {}
}
Function {load_timeline_settings()} {open
} {
code {if ( Project::open() )
{
((Fl_Menu_Settings*)menubar)->load( menubar->find_item( "&Timeline" ), "options" );
((Fl_Menu_Settings*)menubar)->load( menubar->find_item( "&Options/&Project" ), "options" );
}

View File

@ -140,6 +140,64 @@ Timeline::cb_scroll ( Fl_Widget *w )
}
}
#include <FL/Fl_Menu.H>
void
Timeline::menu_cb ( Fl_Widget *w, void *v )
{
((Timeline*)v)->menu_cb( w );
}
void
Timeline::menu_cb ( Fl_Widget *w )
{
Fl_Menu_ *m = static_cast<Fl_Menu_*>(w);
const char *picked = m->mvalue()->label();
/* m->item_pathname( picked, sizeof( picked ) ); */
DMESSAGE( "%s", picked );
if ( ! strcmp( picked, "Add Audio Track" ) )
{
/* FIXME: prompt for I/O config? */
Loggable::block_start();
/* add audio track */
char *name = get_unique_track_name( "Audio" );
Track *t = new Track( name );
Audio_Sequence *o = new Audio_Sequence( t );
add_track( t );
t->sequence( o );
Loggable::block_end();
}
else if ( ! strcmp( picked, "Tempo from range" ) )
{
if ( p1 != p2 )
{
if ( p1 > p2 )
{
nframes_t t = p2;
p2 = p1;
p1 = t;
}
beats_per_minute( p1, sample_rate() * 60 / (float)( p2 - p1 ) );
p2 = p1;
}
}
else
WARNING( "programming error: Unknown menu item" );
}
Timeline::Timeline ( int X, int Y, int W, int H, const char* L ) : Fl_Overlay_Window( X, Y, W, H, L )
{
@ -155,6 +213,13 @@ Timeline::Timeline ( int X, int Y, int W, int H, const char* L ) : Fl_Overlay_Wi
p1 = p2 = 0;
menu = new Fl_Menu;
/* menu->add( "Add Track", 0, 0, 0 ); */
menu->add( "Add Audio Track", 'a', &Timeline::menu_cb, this );
menu->add( "Tempo from range", 't', &Timeline::menu_cb, this );
{
Scalebar *o = new Scalebar( X, Y + H - 18, W - 18, 18 );
@ -324,8 +389,8 @@ nearest_line_cb ( nframes_t frame, const BBT &bbt, void *arg )
}
/** Set the value pointed to by /frame/ to the frame number of the of
the nearest measure line to /when/. Returns true if the new value of
*frame is valid, false otherwise. */
the nearest measure line to /when/. Returns true if the new value of
*frame is valid, false otherwise. */
bool
Timeline::nearest_line ( nframes_t when, nframes_t *frame ) const
{
@ -388,7 +453,7 @@ Timeline::update_tempomap ( void )
_tempomap.push_back( *i );
/* FIXME: shouldn't we ensure that time points always precede
tempo points at the same position? */
tempo points at the same position? */
_tempomap.sort( Sequence_Widget::sort_func );
}
@ -924,24 +989,6 @@ Timeline::handle ( int m )
redraw();
return 1;
}
case 't':
{
if ( p1 != p2 )
{
if ( p1 > p2 )
{
nframes_t t = p2;
p2 = p1;
p1 = t;
}
beats_per_minute( p1, sample_rate() * 60 / (float)( p2 - p1 ) );
p2 = p1;
}
return 1;
}
default:
return Fl_Overlay_Window::handle( m );
}
@ -981,36 +1028,20 @@ Timeline::handle ( int m )
}
else if ( Fl::test_shortcut( FL_BUTTON3 ) && ! Fl::event_shift() )
{
Fl_Menu_Item menu[] =
{
{ "Add Track", 0, 0, 0, FL_SUBMENU },
{ "Audio", 0, 0, 0 },
{ 0 },
{ 0 },
};
/* Fl_Menu_Item menu[] = */
/* { */
/* { "Add Track", 0, 0, 0, FL_SUBMENU }, */
/* { "Audio", 0, 0, 0 }, */
/* { 0 }, */
/* { 0 }, */
/* }; */
const Fl_Menu_Item *r = menu->popup( X, Y, "Timeline" );
if ( r == &menu[1] )
if ( r )
{
/* FIXME: prompt for I/O config? */
Loggable::block_start();
/* add audio track */
char *name = get_unique_track_name( "Audio" );
Track *t = new Track( name );
Audio_Sequence *o = new Audio_Sequence( t );
// new Control_Sequence( t );
add_track( t );
t->sequence( o );
Loggable::block_end();
((Fl_Menu_*)(menu))->value( r );
r->do_callback( (Fl_Widget*)menu );
}
}

View File

@ -36,6 +36,8 @@ class Fl_Pack;
class Fl_Scrollbar;
class Fl_Widget;
#include <FL/Fl_Menu.H>
class Timeline;
extern Timeline *timeline;
@ -92,10 +94,11 @@ class Timeline : public Fl_Overlay_Window, public RWLock
Scalebar *hscroll;
Fl_Scrollbar *vscroll;
void adjust_vscroll ( void );
static void cb_scroll ( Fl_Widget *w, void *v );
void cb_scroll ( Fl_Widget *w );
static void menu_cb ( Fl_Widget *w, void *v );
void menu_cb ( Fl_Widget *w );
int _fpp; /* frames per pixel, power of two */
nframes_t _length;
@ -127,6 +130,7 @@ public:
Time_Sequence *time_track;
Annotation_Sequence *ruler_track;
Fl_Menu *menu;
nframes_t xoffset;