From a71ba1cbba93f62160c1f15144a4840629c7e43e Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Tue, 12 Feb 2008 15:25:11 -0600 Subject: [PATCH] Use double-buffered visual for main_window, but keep canvas widget single-buffered by placing it inside a subwindow --- TODO | 1 - gui/ui.fl | 151 ++++++++++++++++++++++++++++++------------------------ 2 files changed, 83 insertions(+), 69 deletions(-) diff --git a/TODO b/TODO index 77d9c50..81fe333 100644 --- a/TODO +++ b/TODO @@ -5,7 +5,6 @@ ; General -* show playback progress on playlist. * per phrase tempo setting? Perhaps a percentage of global tempo? * add channel field to event list widget (but channel bits in pattern event lists are currently meaningless.) diff --git a/gui/ui.fl b/gui/ui.fl index 265949f..5de6347 100644 --- a/gui/ui.fl +++ b/gui/ui.fl @@ -150,7 +150,7 @@ if ( Fl::event() == FL_SHORTCUT && Fl::event_key() == FL_Escape ) if ( maybe_save_song() ) quit();} open - xywh {694 168 869 801} type Single box PLASTIC_UP_BOX color 37 resizable xclass non size_range {869 801 0 0} visible + xywh {694 168 869 801} type Double box PLASTIC_UP_BOX color 37 resizable xclass non size_range {869 801 0 0} visible } { Fl_Menu_Bar menu_bar {open xywh {0 0 869 30} color 37 @@ -563,7 +563,7 @@ o->maximum( phrase::phrases() );} code0 {\#include "draw.H"} code1 {o->set_canvas( pattern_c );} code2 {\#include "input.H"} - code3 {o->box( FL_NO_BOX );} + code3 {// o->box( FL_NO_BOX );} class O_Canvas } Fl_Group {} {open @@ -955,7 +955,7 @@ else } } } - Fl_Output status {selected + Fl_Output status { xywh {0 776 869 25} box UP_BOX color 32 labeltype NO_LABEL textcolor 55 } } @@ -1278,19 +1278,70 @@ ie.run();} {} } } -decl {\#include } {public +Function {shortcut_handler( int e )} {return_type int +} { + code {if ( e != FL_SHORTCUT ) + return 0; + + +// this is for mainwindow shortcuts only, ignore all other windows. +if ( Fl::first_window() != ui->main_window ) + return 0; + +int processed = 0; + +// shortcuts that don't fit anywhere else (widgets that don't take shortcuts, etc.) + +\#define KEY(key) ((Fl::test_shortcut( (key) ))) + + processed = 1; + if KEY( FL_ALT + 's' ) + { + ui->tabs->value( ui->sequence_tab ); + ui->tabs->do_callback(); + } + else + if KEY( FL_ALT + 'a' ) + { + ui->tabs->value( ui->phrase_tab ); + ui->tabs->do_callback(); + } + else + if KEY( FL_ALT + 'p' ) + { + ui->tabs->value( ui->pattern_tab ); + ui->tabs->do_callback(); + } + else + if KEY( FL_ALT + 'c' ) + ui->pattern_channel_spinner->take_focus(); + else + if KEY( FL_ALT + 'o' ) + ui->pattern_port_spinner->take_focus(); + else + if KEY( FL_ALT + 'i' ) + ui->mapping_menu->take_focus(); + else + processed = 0; + +return processed;} {} } -class O_Canvas {: {public Fl_Widget} +decl {\#include } {public +} + +class O_Canvas {open : {public Fl_Single_Window} } { decl {Canvas *_c;} {} decl {bool _border_drawn;} {} decl {uint _flags;} {} - Function {O_Canvas( int X, int Y, int W, int H, const char*L=0) : Fl_Widget(X,Y,W,H,L)} {open + Function {O_Canvas( int X, int Y, int W, int H, const char*L=0) : Fl_Single_Window(X,Y,W,H,L)} {open } { code {_c = NULL; _border_drawn = false; -_flags = 0;} {} +_flags = 0; + +end();} {} } Function {handle( int m )} {open return_type int } { @@ -1308,6 +1359,9 @@ if ( m == FL_PUSH ) take_focus(); +if ( Fl_Window::handle( m ) ) + return 1; + // Ignore events unless we have the focus. if ( this != Fl::focus() ) return 0; @@ -1325,13 +1379,14 @@ return p;} {} } Function {resize( int x, int y, int w, int h )} {open } { - code {if ( _c ) + code {Fl_Window::resize( x, y, w, h ); + +if ( _c ) { DEBUG( "Resizing canvas." ); - _c->resize( x + 1, y + 1, w - 1, h - 1 ); + _c->resize( 0 + 1, 0 + 1, w - 1, h - 1 ); } -Fl_Widget::resize( x, y, w, h ); // Fl_Window::resize( x, y, w, h );} {} } @@ -1339,8 +1394,8 @@ Fl_Widget::resize( x, y, w, h ); } { code {draw_border(); -if ( ! takesevents() ) - return; +//if ( ! takesevents() ) +// return; if ( _c ) { @@ -1357,9 +1412,16 @@ if ( _c ) printf("\\n"); */ - + if ( damage() & FL_DAMAGE_EXPOSE ) + { + draw_box( FL_FLAT_BOX, 0, 0, w(), h(), canvas_background_color ); + _c->redraw(); + return; + } + if ( damage() & (FL_DAMAGE_ALL | FL_DAMAGE_USER2) ) { + draw_box( FL_FLAT_BOX, 0, 0, w(), h(), canvas_background_color ); _c->redraw(); } @@ -1378,15 +1440,18 @@ if ( _c ) else if ( damage() & FL_DAMAGE_ALL ) { + draw_box( FL_FLAT_BOX, 0, 0, w(), h(), canvas_background_color ); _border_drawn = false; draw_border(); _c->redraw(); + } } else { WARNING( "No canvas set for widget." ); -}} {} +}} {selected + } } Function {set_canvas( Canvas *c )} {open } { @@ -1405,7 +1470,7 @@ _c->signal_settings_change.connect( sigc::ptr_fun( &UI::update_canvas_widgets ) } Function {clear( void )} {open return_type void } { - code {parent()->parent()->damage( FL_DAMAGE_ALL, x(), y(), w(), h() ); + code {// parent()->parent()->damage( FL_DAMAGE_ALL, x(), y(), w(), h() ); damage( FL_DAMAGE_USER2 ); _flags |= FL_DAMAGE_USER2;} {} @@ -1433,63 +1498,14 @@ else fl_color( FL_BLACK ); fl_line_style( FL_DASH ); -fl_rect( x(), y(), w(), h() ); +fl_rect( 0, 0, w(), h() ); fl_line_style( FL_SOLID ); _border_drawn = true;} {} } } -Function {shortcut_handler( int e )} {open return_type int -} { - code {if ( e != FL_SHORTCUT ) - return 0; - - -// this is for mainwindow shortcuts only, ignore all other windows. -if ( Fl::first_window() != ui->main_window ) - return 0; - -int processed = 0; - -// shortcuts that don't fit anywhere else (widgets that don't take shortcuts, etc.) - -\#define KEY(key) ((Fl::test_shortcut( (key) ))) - - processed = 1; - if KEY( FL_ALT + 's' ) - { - ui->tabs->value( ui->sequence_tab ); - ui->tabs->do_callback(); - } - else - if KEY( FL_ALT + 'a' ) - { - ui->tabs->value( ui->phrase_tab ); - ui->tabs->do_callback(); - } - else - if KEY( FL_ALT + 'p' ) - { - ui->tabs->value( ui->pattern_tab ); - ui->tabs->do_callback(); - } - else - if KEY( FL_ALT + 'c' ) - ui->pattern_channel_spinner->take_focus(); - else - if KEY( FL_ALT + 'o' ) - ui->pattern_port_spinner->take_focus(); - else - if KEY( FL_ALT + 'i' ) - ui->mapping_menu->take_focus(); - else - processed = 0; - -return processed;} {} -} - -class Trigger {open : {public Fl_Dial} +class Trigger {: {public Fl_Dial} } { Function {Trigger( int X, int Y, int W, int H, const char *L = 0 ) : Fl_Dial( X, Y, W, H, L )} {open } {} @@ -1558,8 +1574,7 @@ return r;} {} } } -class Instrument_Editor {open -} { +class Instrument_Editor {} { Function {Instrument_Editor()} {open return_type void } { code {make_window();} {}