From b3a3be6e553dbaf49a376fda7ff88b93c5042572 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Tue, 15 Apr 2008 06:44:03 -0500 Subject: [PATCH] Add context popup menu for regions to set fade-in/out curve. --- Timeline/Region.C | 55 +++++++++++++++++++++++++++++++++++++++-------- Timeline/Region.H | 2 +- Timeline/main.C | 1 - 3 files changed, 47 insertions(+), 11 deletions(-) diff --git a/Timeline/Region.C b/Timeline/Region.C index 2c668c7..207f244 100644 --- a/Timeline/Region.C +++ b/Timeline/Region.C @@ -27,7 +27,7 @@ #include #include #include - +#include #include #include @@ -256,15 +256,15 @@ Region::handle ( int m ) printf( "setting fade in length to %lu\n", _fade_in.length ); } else - if ( Fl::event_key() == FL_F + 4 ) - { - long offset = length() - x_to_offset( X ); + if ( Fl::event_key() == FL_F + 4 ) + { + long offset = length() - x_to_offset( X ); - if ( offset > 0 ) - _fade_out.length = offset; + if ( offset > 0 ) + _fade_out.length = offset; - printf( "setting fade out length to %lu\n", _fade_in.length ); - } + printf( "setting fade out length to %lu\n", _fade_in.length ); + } redraw(); @@ -342,11 +342,48 @@ Region::handle ( int m ) redraw(); goto changed; } - if ( Fl::event_button1() && Fl::event_ctrl() ) + else if ( Fl::event_button1() && Fl::event_ctrl() ) { /* duplication */ return 1; } + else if ( Fl::event_button3() ) + { + /* context menu */ + + Fade::fade_type_e it = _fade_in.type; + Fade::fade_type_e ot = _fade_out.type; + + Fl_Menu_Item menu[] = + { + { "Fade", 0, 0, 0, FL_SUBMENU }, + { "In", 0, 0, 0, FL_SUBMENU }, + { "Linear", 0, 0, 0, FL_MENU_RADIO | ( it == Fade::Linear ? FL_MENU_VALUE : 0 ) }, + { "Sigmoid", 0, 0, 0, FL_MENU_RADIO | ( it == Fade::Sigmoid ? FL_MENU_VALUE : 0 ) }, + { "Logarithmic", 0, 0, 0, FL_MENU_RADIO | ( it == Fade::Logarithmic ? FL_MENU_VALUE : 0 ) }, + { "Parabolic", 0, 0, 0, FL_MENU_RADIO | ( it == Fade::Parabolic ? FL_MENU_VALUE : 0 ) }, + { 0 }, + { "Out", 0, 0, 0, FL_SUBMENU }, + { "Linear", 0, 0, 0, FL_MENU_RADIO | ( ot == Fade::Linear ? FL_MENU_VALUE : 0 ) }, + { "Sigmoid", 0, 0, 0, FL_MENU_RADIO | ( ot == Fade::Sigmoid ? FL_MENU_VALUE : 0 ) }, + { "Logarothmic", 0, 0, 0, FL_MENU_RADIO | ( ot == Fade::Logarithmic ? FL_MENU_VALUE : 0 ) }, + { "Parabolic", 0, 0, 0, FL_MENU_RADIO | ( ot == Fade::Parabolic ? FL_MENU_VALUE : 0 ) }, + { 0 }, + { 0 }, + { 0 }, + }; + + const Fl_Menu_Item *r = menu->popup( X, Y, "Region" ); + + if ( r ) + { + if ( r > &menu[1] && r < &menu[6] ) + _fade_in.type = (Fade::fade_type_e)(int)(r - &menu[2]); + else if ( r > &menu[7] && r < &menu[12] ) + _fade_out.type = (Fade::fade_type_e)(int)(r - &menu[8]); + } + + } else return Track_Widget::handle( m ); } diff --git a/Timeline/Region.H b/Timeline/Region.H index 2ae828f..dc96d3d 100644 --- a/Timeline/Region.H +++ b/Timeline/Region.H @@ -41,7 +41,7 @@ public: struct Fade { - enum fade_type_e { Linear, Sigmoid, Logarithmic, Parabolic }; + enum fade_type_e { Linear = 0, Sigmoid, Logarithmic, Parabolic }; enum fade_dir_e { In, Out }; fade_type_e type; diff --git a/Timeline/main.C b/Timeline/main.C index 872f740..9c439dc 100644 --- a/Timeline/main.C +++ b/Timeline/main.C @@ -72,7 +72,6 @@ main ( int argc, char **argv ) Fl::scheme( "plastic" ); // Fl::scheme( "gtk+" ); - Loggable::open( "history" ); /* welcome to C++ */ Loggable::register_create( "Region", &Region::create );