Cleanup menu generation.
This commit is contained in:
parent
c98016d5e4
commit
f0a973d652
|
@ -49,8 +49,6 @@ Fl_Boxtype Audio_Region::_box = FL_UP_BOX;
|
||||||
|
|
||||||
Fl_Color Audio_Region::_selection_color = FL_MAGENTA;
|
Fl_Color Audio_Region::_selection_color = FL_MAGENTA;
|
||||||
|
|
||||||
Fl_Menu_Button *Audio_Region::_menu = NULL;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static Fl_Color fl_invert_color ( Fl_Color c )
|
static Fl_Color fl_invert_color ( Fl_Color c )
|
||||||
|
@ -252,38 +250,39 @@ Audio_Region::menu_cb ( const Fl_Menu_ *m )
|
||||||
#include "FL/test_press.H"
|
#include "FL/test_press.H"
|
||||||
|
|
||||||
/** build the context menu for this region */
|
/** build the context menu for this region */
|
||||||
void
|
Fl_Menu_Button &
|
||||||
Audio_Region::update_menu ( void )
|
Audio_Region::menu ( void )
|
||||||
{
|
{
|
||||||
if ( ! Audio_Region::_menu )
|
static Fl_Menu_Button m( 0, 0, 0, 0, "Region" );
|
||||||
Audio_Region::_menu = new Fl_Menu_Button( 0, 0, 0, 0, "Region" );
|
|
||||||
|
|
||||||
Fade::fade_type_e it = _fade_in.type;
|
Fade::fade_type_e it = _fade_in.type;
|
||||||
Fade::fade_type_e ot = _fade_out.type;
|
Fade::fade_type_e ot = _fade_out.type;
|
||||||
|
|
||||||
Fl_Menu_Item items[] =
|
Fl_Menu_Item items[] =
|
||||||
{
|
{
|
||||||
{ "Fade", 0, &Audio_Region::menu_cb, this, FL_SUBMENU },
|
{ "Fade", 0, &Audio_Region::menu_cb, 0, FL_SUBMENU },
|
||||||
{ "In", 0, &Audio_Region::menu_cb, this, FL_SUBMENU },
|
{ "In", 0, &Audio_Region::menu_cb, 0, FL_SUBMENU },
|
||||||
{ "Linear", 0, &Audio_Region::menu_cb, this, FL_MENU_RADIO | ( it == Fade::Linear ? FL_MENU_VALUE : 0 ) },
|
{ "Linear", 0, &Audio_Region::menu_cb, 0, FL_MENU_RADIO | ( it == Fade::Linear ? FL_MENU_VALUE : 0 ) },
|
||||||
{ "Sigmoid", 0, &Audio_Region::menu_cb, this, FL_MENU_RADIO | ( it == Fade::Sigmoid ? FL_MENU_VALUE : 0 ) },
|
{ "Sigmoid", 0, &Audio_Region::menu_cb, 0, FL_MENU_RADIO | ( it == Fade::Sigmoid ? FL_MENU_VALUE : 0 ) },
|
||||||
{ "Logarithmic", 0, &Audio_Region::menu_cb, this, FL_MENU_RADIO | ( it == Fade::Logarithmic ? FL_MENU_VALUE : 0 ) },
|
{ "Logarithmic", 0, &Audio_Region::menu_cb, 0, FL_MENU_RADIO | ( it == Fade::Logarithmic ? FL_MENU_VALUE : 0 ) },
|
||||||
{ "Parabolic", 0, &Audio_Region::menu_cb, this, FL_MENU_RADIO | ( it == Fade::Parabolic ? FL_MENU_VALUE : 0 ) },
|
{ "Parabolic", 0, &Audio_Region::menu_cb, 0, FL_MENU_RADIO | ( it == Fade::Parabolic ? FL_MENU_VALUE : 0 ) },
|
||||||
{ 0 },
|
{ 0 },
|
||||||
{ "Out", 0, &Audio_Region::menu_cb, this, FL_SUBMENU },
|
{ "Out", 0, &Audio_Region::menu_cb, 0, FL_SUBMENU },
|
||||||
{ "Linear", 0, &Audio_Region::menu_cb, this, FL_MENU_RADIO | ( ot == Fade::Linear ? FL_MENU_VALUE : 0 ) },
|
{ "Linear", 0, &Audio_Region::menu_cb, 0, FL_MENU_RADIO | ( ot == Fade::Linear ? FL_MENU_VALUE : 0 ) },
|
||||||
{ "Sigmoid", 0, &Audio_Region::menu_cb, this, FL_MENU_RADIO | ( ot == Fade::Sigmoid ? FL_MENU_VALUE : 0 ) },
|
{ "Sigmoid", 0, &Audio_Region::menu_cb, 0, FL_MENU_RADIO | ( ot == Fade::Sigmoid ? FL_MENU_VALUE : 0 ) },
|
||||||
{ "Logarothmic", 0, &Audio_Region::menu_cb, this, FL_MENU_RADIO | ( ot == Fade::Logarithmic ? FL_MENU_VALUE : 0 ) },
|
{ "Logarothmic", 0, &Audio_Region::menu_cb, 0, FL_MENU_RADIO | ( ot == Fade::Logarithmic ? FL_MENU_VALUE : 0 ) },
|
||||||
{ "Parabolic", 0, &Audio_Region::menu_cb, this, FL_MENU_RADIO | ( ot == Fade::Parabolic ? FL_MENU_VALUE : 0 ) },
|
{ "Parabolic", 0, &Audio_Region::menu_cb, 0, FL_MENU_RADIO | ( ot == Fade::Parabolic ? FL_MENU_VALUE : 0 ) },
|
||||||
{ 0 },
|
{ 0 },
|
||||||
{ 0 },
|
{ 0 },
|
||||||
{ "Color", 0, &Audio_Region::menu_cb, this, inherit_track_color ? FL_MENU_INACTIVE : 0 },
|
{ "Color", 0, &Audio_Region::menu_cb, 0, inherit_track_color ? FL_MENU_INACTIVE : 0 },
|
||||||
{ "Fade in to mouse", FL_F + 3, &Audio_Region::menu_cb, this },
|
{ "Fade in to mouse", FL_F + 3, &Audio_Region::menu_cb, 0 },
|
||||||
{ "Fade out to mouse", FL_F + 4, &Audio_Region::menu_cb, this },
|
{ "Fade out to mouse", FL_F + 4, &Audio_Region::menu_cb, 0 },
|
||||||
{ 0 },
|
{ 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
_menu->copy( items );
|
m.copy( items, (void*)this );
|
||||||
|
|
||||||
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "FL/menu_popup.H"
|
#include "FL/menu_popup.H"
|
||||||
|
@ -307,15 +306,9 @@ Audio_Region::handle ( int m )
|
||||||
case FL_UNFOCUS:
|
case FL_UNFOCUS:
|
||||||
return 1;
|
return 1;
|
||||||
case FL_KEYBOARD:
|
case FL_KEYBOARD:
|
||||||
if ( selected() )
|
return menu().test_shortcut() != 0;
|
||||||
/* make sure the user_data fields of menu point to this object */
|
|
||||||
update_menu();
|
|
||||||
return _menu->test_shortcut() != 0;
|
|
||||||
case FL_ENTER:
|
case FL_ENTER:
|
||||||
{
|
|
||||||
update_menu();
|
|
||||||
return Sequence_Region::handle( m );
|
return Sequence_Region::handle( m );
|
||||||
}
|
|
||||||
case FL_LEAVE:
|
case FL_LEAVE:
|
||||||
return Sequence_Region::handle( m );
|
return Sequence_Region::handle( m );
|
||||||
case FL_PUSH:
|
case FL_PUSH:
|
||||||
|
@ -358,10 +351,7 @@ Audio_Region::handle ( int m )
|
||||||
else if ( test_press( FL_BUTTON3 ) )
|
else if ( test_press( FL_BUTTON3 ) )
|
||||||
{
|
{
|
||||||
/* context menu */
|
/* context menu */
|
||||||
|
menu_popup( &menu() );
|
||||||
update_menu();
|
|
||||||
|
|
||||||
menu_popup( _menu );
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,9 +102,7 @@ private:
|
||||||
|
|
||||||
friend class Track; /* for _clip */
|
friend class Track; /* for _clip */
|
||||||
|
|
||||||
static Fl_Menu_Button *_menu;
|
Fl_Menu_Button & menu ( void );
|
||||||
|
|
||||||
void update_menu ( void );
|
|
||||||
static void peaks_pending_cb ( void *v );
|
static void peaks_pending_cb ( void *v );
|
||||||
void peaks_pending_cb ( Peaks_Redraw_Request *r );
|
void peaks_pending_cb ( Peaks_Redraw_Request *r );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue