Activate a number of entries in the menu.

pull/3/head
Jonathan Moore Liles 2008-04-23 15:43:17 -05:00
parent e97435d3e7
commit 2dd18e842f
5 changed files with 153 additions and 46 deletions

View File

@ -34,6 +34,28 @@ class Scalebar : public Fl_Scrollbar
double _zoom_min;
double _zoom_max;
void constrain ( void )
{
if ( _zoom > _zoom_max )
_zoom = _zoom_max;
else
if ( _zoom < _zoom_min )
_zoom = _zoom_min;
}
void maybe_do_callback ( int z )
{
if ( z != _zoom )
{
_zoom_changed = true;
do_callback();
_zoom_changed = false;
slider_size( w() / maximum() );
}
}
public:
Scalebar ( int X, int Y, int W, int H ) : Fl_Scrollbar ( X, Y, W, H )
@ -48,10 +70,13 @@ public:
bool zoom_changed ( void ) const { return _zoom_changed; }
double zoom ( void ) const { return _zoom; }
void zoom ( double v ) { _zoom = v; }
void zoom ( double v ) { _zoom = v; }
double value ( void ) const { return Fl_Slider::value(); }
void zoom_range ( double zmin, double zmax ) { _zoom_min = zmin; _zoom_max = zmax; }
void zoom_out ( void ) { int z = _zoom; _zoom *= 2; constrain(); maybe_do_callback( z ); }
void zoom_in ( void ) {int z = _zoom; _zoom /= 2; constrain(); maybe_do_callback( z ); }
int
handle ( int m )
{
@ -73,20 +98,9 @@ public:
while ( d-- )
_zoom *= 2;
if ( _zoom > _zoom_max )
_zoom = _zoom_max;
else
if ( _zoom < _zoom_min )
_zoom = _zoom_min;
constrain();
if ( z != _zoom )
{
_zoom_changed = true;
do_callback();
_zoom_changed = false;
slider_size( w() / maximum() );
}
maybe_do_callback( z );
return 1;
}

View File

@ -170,6 +170,8 @@ Sequence::draw ( void )
Rectangle b( (*r)->x(), o->y(), (o->x() + o->w()) - (*r)->x(), o->h() );
/* draw overlapping waveforms in X-ray style. */
bool t = Waveform::fill;
Waveform::fill = false;
/* Fl_Color oc = o->color(); */
@ -186,7 +188,7 @@ Sequence::draw ( void )
fl_pop_clip();
Waveform::fill = true;
Waveform::fill = t;
/* o->color( oc ); */

View File

@ -6,18 +6,27 @@ decl {const float STATUS_UPDATE_FREQ = 0.5f;} {}
decl {\#include "Timeline.H"} {}
decl {\#include "Engine.H"} {selected
}
decl {\#include "Engine.H"} {}
decl {\#include "Transport.H"} {}
decl {\#include "Clock.H"} {public
}
decl {\#include "Waveform.H" // for options} {}
decl {\#include "Control_Sequence.H" // for options} {}
decl {\#include <FL/Fl.H>} {}
class TLE {open
} {
decl {static void menubar_cb ( void *v )} {}
decl {void menubar_cb ( void )} {}
Function {menu_picked_value( const Fl_Menu_ *m )} {open return_type {static int}
} {
code {return m->menu()[ m->value() ].flags & FL_MENU_VALUE;} {}
}
Function {TLE()} {open
} {
code {make_window();
@ -35,12 +44,12 @@ Fl::add_timeout( STATUS_UPDATE_FREQ, update_cb, this );} {}
} {
Fl_Window main_window {
label {Non-DAW - Timeline} open
xywh {549 146 1024 768} type Double resizable xclass {Non-DAW} visible
xywh {483 100 1024 768} type Double resizable xclass {Non-DAW} visible
} {
Fl_Group {} {open
xywh {0 0 1024 25}
} {}
Fl_Menu_Bar {} {
Fl_Menu_Bar menubar {open
xywh {0 0 1024 25}
} {
Submenu {} {
@ -74,6 +83,7 @@ Fl::add_timeout( STATUS_UPDATE_FREQ, update_cb, this );} {}
}
MenuItem {} {
label {&Quit}
callback {exit( 0 );}
xywh {40 40 40 25} shortcut 0x40071
}
}
@ -96,23 +106,27 @@ Fl::add_timeout( STATUS_UPDATE_FREQ, update_cb, this );} {}
} {
MenuItem {} {
label Home
xywh {0 0 40 25}
callback {transport->locate( 0 );}
xywh {0 0 40 25} shortcut 0xff50
}
MenuItem {} {
label End
xywh {10 10 40 25}
callback {transport->locate( timeline->length() );}
xywh {10 10 40 25} shortcut 0xff57
}
MenuItem {} {
label Stop
xywh {20 20 40 25}
callback {transport->stop();}
xywh {20 20 40 25} shortcut 0x50073
}
MenuItem {} {
label Play
xywh {30 30 40 25}
callback {transport->start();}
xywh {30 30 40 25} shortcut 0x50070
}
MenuItem {} {
label Record
xywh {40 40 40 25}
xywh {40 40 40 25} shortcut 0x50072
}
}
Submenu {} {
@ -120,25 +134,38 @@ Fl::add_timeout( STATUS_UPDATE_FREQ, update_cb, this );} {}
xywh {0 0 74 25}
} {
Submenu {} {
label Zoom open
label {&Zoom} open
xywh {0 0 74 25}
} {
MenuItem {} {
label Fit
xywh {10 10 40 25}
}
MenuItem {} {
label {1 sec.}
xywh {10 10 40 25}
}
MenuItem {} {
label {1 min.}
label {&In}
callback {timeline->zoom_in();}
xywh {20 20 40 25}
}
MenuItem {} {
label {1 hour.}
label {&Out}
callback {timeline->zoom_out();}
xywh {30 30 40 25}
}
MenuItem {} {
label {&Fit}
xywh {10 10 40 25} divider
}
MenuItem {} {
label {1 sec.}
callback {timeline->zoom( 1 );}
xywh {10 10 40 25} shortcut 0x31
}
MenuItem {} {
label {1 min.}
callback {timeline->zoom( 60 );}
xywh {20 20 40 25} shortcut 0x32
}
MenuItem {} {
label {1 hour.}
callback {timeline->zoom( 60 * 60 );}
xywh {30 30 40 25} shortcut 0x33
}
}
}
Submenu {} {
@ -146,74 +173,112 @@ Fl::add_timeout( STATUS_UPDATE_FREQ, update_cb, this );} {}
xywh {0 0 74 25} divider
} {
Submenu {} {
label Display open
label {&Display} open
xywh {0 0 74 25}
} {
MenuItem {} {
label item
xywh {0 0 40 25}
}
Submenu {} {
label Region open
label {&Waveforms} open
xywh {0 0 74 25}
} {
MenuItem {} {
label {Filled waveforms}
label Fill
callback {Waveform::fill = menu_picked_value( o );
timeline->redraw();}
xywh {10 10 40 25} type Toggle value 1
}
MenuItem {} {
label {Colorful waveforms}
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 );
timeline->redraw();}
xywh {20 20 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
}
}
Submenu {} {
label {Control Sequence} open
label {&Control Sequence} open
xywh {0 0 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 );
timeline->redraw();}
xywh {30 30 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
}
}
Submenu {} {
label Style open
label {&Style} open
xywh {0 0 74 25}
} {
MenuItem {} {
label Default
callback {Fl::scheme( "plastic" );}
xywh {0 0 40 25} type Radio value 1
}
MenuItem {} {
label Flat
callback {Fl::scheme( "gtk+" );}
xywh {10 10 40 25} type Radio
}
}
Submenu {} {
label Colors open
label {C&olors} open selected
xywh {0 0 74 25}
} {
MenuItem {} {
label System
callback {Fl::get_system_colors();
Fl::scheme( Fl::scheme() );}
xywh {0 0 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( 255, 255, 255 );
Fl::background( 172, 172, 172 );
Fl::foreground( 0, 0, 0 );
Fl::scheme( Fl::scheme() );}
xywh {20 20 40 25} type Radio
}
}

View File

@ -823,6 +823,29 @@ Timeline::handle ( int m )
}
void
Timeline::zoom_in ( void )
{
hscroll->zoom_in();
}
void
Timeline::zoom_out ( void )
{
hscroll->zoom_out();
}
/** zoom the display to show /secs/ seconds per screen */
void
Timeline::zoom ( float secs )
{
const int sw = w() - vscroll->w() - Track::width();
/* FIXME: we actually need to set this in the scalebar */
_fpp = (int)((secs * _sample_rate) / sw);
redraw();
}
Track *
Timeline::track_by_name ( const char *name )

View File

@ -158,6 +158,9 @@ public:
int total_input_buffer_percent ( void );
int total_output_buffer_percent ( void );
void zoom ( float secs );
void zoom_in ( void );
void zoom_out ( void );
private: