@@ -0,0 +1,52 @@ | |||||
/*******************************************************************************/ | |||||
/* Copyright (C) 2008 Jonathan Moore Liles */ | |||||
/* */ | |||||
/* This program is free software; you can redistribute it and/or modify it */ | |||||
/* under the terms of the GNU General Public License as published by the */ | |||||
/* Free Software Foundation; either version 2 of the License, or (at your */ | |||||
/* option) any later version. */ | |||||
/* */ | |||||
/* This program is distributed in the hope that it will be useful, but WITHOUT */ | |||||
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ | |||||
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */ | |||||
/* more details. */ | |||||
/* */ | |||||
/* You should have received a copy of the GNU General Public License along */ | |||||
/* with This program; see the file COPYING. If not,write to the Free Software */ | |||||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |||||
/*******************************************************************************/ | |||||
static const char *event_names[] = | |||||
{ | |||||
"FL_NO_EVENT", | |||||
"FL_PUSH", | |||||
"FL_RELEASE", | |||||
"FL_ENTER", | |||||
"FL_LEAVE", | |||||
"FL_DRAG", | |||||
"FL_FOCUS", | |||||
"FL_UNFOCUS", | |||||
"FL_KEYDOWN", | |||||
"FL_KEYUP", | |||||
"FL_CLOSE", | |||||
"FL_MOVE", | |||||
"FL_SHORTCUT", | |||||
"FL_DEACTIVATE", | |||||
"FL_ACTIVATE", | |||||
"FL_HIDE", | |||||
"FL_SHOW", | |||||
"FL_PASTE", | |||||
"FL_SELECTIONCLEAR", | |||||
"FL_MOUSEWHEEL", | |||||
"FL_DND_ENTER", | |||||
"FL_DND_DRAG", | |||||
"FL_DND_LEAVE", | |||||
"FL_DND_RELEASE", | |||||
}; | |||||
const char * | |||||
event_name ( int m ) | |||||
{ | |||||
return event_names[ m ]; | |||||
} |
@@ -0,0 +1,20 @@ | |||||
/*******************************************************************************/ | |||||
/* Copyright (C) 2008 Jonathan Moore Liles */ | |||||
/* */ | |||||
/* This program is free software; you can redistribute it and/or modify it */ | |||||
/* under the terms of the GNU General Public License as published by the */ | |||||
/* Free Software Foundation; either version 2 of the License, or (at your */ | |||||
/* option) any later version. */ | |||||
/* */ | |||||
/* This program is distributed in the hope that it will be useful, but WITHOUT */ | |||||
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ | |||||
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */ | |||||
/* more details. */ | |||||
/* */ | |||||
/* You should have received a copy of the GNU General Public License along */ | |||||
/* with This program; see the file COPYING. If not,write to the Free Software */ | |||||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |||||
/*******************************************************************************/ | |||||
const char *event_name ( int m ); |
@@ -0,0 +1,37 @@ | |||||
/*******************************************************************************/ | |||||
/* Copyright (C) 2008 Jonathan Moore Liles */ | |||||
/* */ | |||||
/* This program is free software; you can redistribute it and/or modify it */ | |||||
/* under the terms of the GNU General Public License as published by the */ | |||||
/* Free Software Foundation; either version 2 of the License, or (at your */ | |||||
/* option) any later version. */ | |||||
/* */ | |||||
/* This program is distributed in the hope that it will be useful, but WITHOUT */ | |||||
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ | |||||
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */ | |||||
/* more details. */ | |||||
/* */ | |||||
/* You should have received a copy of the GNU General Public License along */ | |||||
/* with This program; see the file COPYING. If not,write to the Free Software */ | |||||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |||||
/*******************************************************************************/ | |||||
/* Fl::test_shortcut() is broken for use in FL_PUSH handlers etc, | |||||
* because it relies on Fl::event_text(), which isn't cleared as it | |||||
* should be--and there's no official way to clear it. Therefore, we | |||||
* provide a test_press() function instead, which, unlike | |||||
* test_shortcut(), does not treat a missing FL_SHIFT as "don't care". */ | |||||
#include <FL/Fl.H> | |||||
int | |||||
test_press ( unsigned long e ) | |||||
{ | |||||
((char *)Fl::event_text())[0] = '\0'; | |||||
if ( ! ( e & FL_SHIFT ) ) | |||||
return Fl::test_shortcut( e ) && ! Fl::event_shift(); | |||||
else | |||||
return Fl::test_shortcut( e ); | |||||
} |
@@ -0,0 +1,20 @@ | |||||
/*******************************************************************************/ | |||||
/* Copyright (C) 2008 Jonathan Moore Liles */ | |||||
/* */ | |||||
/* This program is free software; you can redistribute it and/or modify it */ | |||||
/* under the terms of the GNU General Public License as published by the */ | |||||
/* Free Software Foundation; either version 2 of the License, or (at your */ | |||||
/* option) any later version. */ | |||||
/* */ | |||||
/* This program is distributed in the hope that it will be useful, but WITHOUT */ | |||||
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ | |||||
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */ | |||||
/* more details. */ | |||||
/* */ | |||||
/* You should have received a copy of the GNU General Public License along */ | |||||
/* with This program; see the file COPYING. If not,write to the Free Software */ | |||||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |||||
/*******************************************************************************/ | |||||
int test_press ( unsigned long e ); |
@@ -90,22 +90,26 @@ Annotation_Region::draw ( void ) | |||||
} | } | ||||
#include "FL/Fl_Text_Edit_Window.H" | #include "FL/Fl_Text_Edit_Window.H" | ||||
#include "FL/test_press.H" | |||||
int | int | ||||
Annotation_Region::handle ( int m ) | Annotation_Region::handle ( int m ) | ||||
{ | { | ||||
Logger _log( this ); | Logger _log( this ); | ||||
if ( m == FL_PUSH && Fl::test_shortcut( FL_BUTTON3 ) && ! Fl::event_shift() ) | |||||
if ( m == FL_PUSH ) | |||||
{ | { | ||||
char *s = fl_text_edit( "Annotation text:", "&Save", name() ); | |||||
if ( test_press( FL_BUTTON3 ) ) | |||||
{ | |||||
char *s = fl_text_edit( "Annotation text:", "&Save", name() ); | |||||
if ( s ) | |||||
name( s ); | |||||
if ( s ) | |||||
name( s ); | |||||
free( s ); | |||||
free( s ); | |||||
return 0; | |||||
return 0; | |||||
} | |||||
} | } | ||||
int r = Sequence_Region::handle( m ); | int r = Sequence_Region::handle( m ); | ||||
@@ -193,6 +193,7 @@ Audio_Region::source_name ( void ) const | |||||
} | } | ||||
#include <FL/fl_show_colormap.H> | #include <FL/fl_show_colormap.H> | ||||
#include "FL/test_press.H" | |||||
int | int | ||||
Audio_Region::handle ( int m ) | Audio_Region::handle ( int m ) | ||||
@@ -244,7 +245,7 @@ Audio_Region::handle ( int m ) | |||||
case FL_PUSH: | case FL_PUSH: | ||||
{ | { | ||||
/* splitting */ | /* splitting */ | ||||
if ( Fl::test_shortcut( FL_BUTTON2 | FL_SHIFT ) ) | |||||
if ( test_press( FL_BUTTON2 | FL_SHIFT ) ) | |||||
{ | { | ||||
/* split */ | /* split */ | ||||
if ( ! copied ) | if ( ! copied ) | ||||
@@ -272,13 +273,13 @@ Audio_Region::handle ( int m ) | |||||
/* for panning */ | /* for panning */ | ||||
os = _r->offset; | os = _r->offset; | ||||
if ( Fl::test_shortcut( FL_BUTTON2 | FL_CTRL ) && ! Fl::event_shift() ) | |||||
if ( test_press( FL_BUTTON2 | FL_CTRL ) ) | |||||
{ | { | ||||
normalize(); | normalize(); | ||||
redraw(); | redraw(); | ||||
return 1; | return 1; | ||||
} | } | ||||
else if ( Fl::test_shortcut( FL_BUTTON3 ) && ! Fl::event_shift() ) | |||||
else if ( test_press( FL_BUTTON3 ) ) | |||||
{ | { | ||||
/* context menu */ | /* context menu */ | ||||
@@ -344,7 +345,7 @@ Audio_Region::handle ( int m ) | |||||
_log.hold(); | _log.hold(); | ||||
} | } | ||||
if ( Fl::test_shortcut( FL_BUTTON1 | FL_SHIFT | FL_CTRL ) ) | |||||
if ( test_press( FL_BUTTON1 | FL_SHIFT | FL_CTRL ) ) | |||||
{ | { | ||||
/* panning */ | /* panning */ | ||||
int d = (ox + X) - x(); | int d = (ox + X) - x(); | ||||
@@ -273,17 +273,29 @@ Sequence::snap ( Sequence_Widget *r ) | |||||
r->start( f ); | r->start( f ); | ||||
} | } | ||||
#include "FL/event_name.H" | |||||
int | int | ||||
Sequence::handle ( int m ) | Sequence::handle ( int m ) | ||||
{ | { | ||||
/* if ( m != FL_NO_EVENT ) */ | |||||
/* DMESSAGE( "%s", event_name( m ) ); */ | |||||
switch ( m ) | switch ( m ) | ||||
{ | { | ||||
case FL_NO_EVENT: | |||||
/* garbage from overlay window */ | |||||
return 0; | |||||
case FL_FOCUS: | case FL_FOCUS: | ||||
case FL_UNFOCUS: | case FL_UNFOCUS: | ||||
Fl_Widget::handle( m ); | |||||
redraw(); | |||||
return 1; | return 1; | ||||
case FL_LEAVE: | case FL_LEAVE: | ||||
// DMESSAGE( "leave" ); | // DMESSAGE( "leave" ); | ||||
fl_cursor( FL_CURSOR_DEFAULT ); | fl_cursor( FL_CURSOR_DEFAULT ); | ||||
Fl_Widget::handle( m ); | |||||
return 1; | return 1; | ||||
case FL_DND_DRAG: | case FL_DND_DRAG: | ||||
return 1; | return 1; | ||||
@@ -306,6 +318,8 @@ Sequence::handle ( int m ) | |||||
if ( ! event_widget() ) | if ( ! event_widget() ) | ||||
fl_cursor( cursor() ); | fl_cursor( cursor() ); | ||||
Fl_Widget::handle( m ); | |||||
return 1; | return 1; | ||||
case FL_DND_ENTER: | case FL_DND_ENTER: | ||||
case FL_DND_LEAVE: | case FL_DND_LEAVE: | ||||
@@ -319,29 +333,41 @@ Sequence::handle ( int m ) | |||||
{ | { | ||||
if ( Sequence_Widget::belowmouse() ) | if ( Sequence_Widget::belowmouse() ) | ||||
Sequence_Widget::belowmouse()->handle( FL_LEAVE ); | Sequence_Widget::belowmouse()->handle( FL_LEAVE ); | ||||
Sequence_Widget::belowmouse( r ); | Sequence_Widget::belowmouse( r ); | ||||
if ( r ) | if ( r ) | ||||
r->handle( FL_ENTER ); | r->handle( FL_ENTER ); | ||||
} | } | ||||
return 0; | |||||
return 1; | |||||
} | } | ||||
default: | default: | ||||
{ | { | ||||
Sequence_Widget *r = Sequence_Widget::pushed() ? Sequence_Widget::pushed() : event_widget(); | Sequence_Widget *r = Sequence_Widget::pushed() ? Sequence_Widget::pushed() : event_widget(); | ||||
/* if ( this == Fl::focus() ) */ | |||||
/* DMESSAGE( "Sequence widget = %p", r ); */ | |||||
if ( r ) | if ( r ) | ||||
{ | { | ||||
int retval = r->dispatch( m ); | int retval = r->dispatch( m ); | ||||
/* DMESSAGE( "retval = %d", retval ); */ | |||||
if ( m == FL_PUSH ) | |||||
take_focus(); | |||||
if ( retval ) | if ( retval ) | ||||
{ | { | ||||
if ( m == FL_PUSH ) | if ( m == FL_PUSH ) | ||||
{ | { | ||||
take_focus(); | |||||
if ( Sequence_Widget::pushed() ) | |||||
Sequence_Widget::pushed()->handle( FL_UNFOCUS ); | |||||
Sequence_Widget::pushed( r ); | Sequence_Widget::pushed( r ); | ||||
r->handle( FL_FOCUS ); | |||||
} | } | ||||
else if ( m == FL_RELEASE ) | else if ( m == FL_RELEASE ) | ||||
Sequence_Widget::pushed( NULL ); | Sequence_Widget::pushed( NULL ); | ||||
@@ -368,7 +394,10 @@ Sequence::handle ( int m ) | |||||
Loggable::block_end(); | Loggable::block_end(); | ||||
return retval; | |||||
if ( m == FL_PUSH ) | |||||
return 1; | |||||
else | |||||
return retval; | |||||
} | } | ||||
else | else | ||||
return Fl_Widget::handle( m ); | return Fl_Widget::handle( m ); | ||||
@@ -103,6 +103,9 @@ public: | |||||
void remove_selected ( void ); | void remove_selected ( void ); | ||||
Fl_Color color ( void ) const { return this == Fl::focus() ? fl_color_average( FL_FOREGROUND_COLOR, Fl_Widget::color(), 0.24f ) : Fl_Widget::color(); } | |||||
void color ( Fl_Color v ) { Fl_Widget::color( v ); } | |||||
const std::list <Sequence_Widget *> widgets ( void ) const { return _widgets; } | const std::list <Sequence_Widget *> widgets ( void ) const { return _widgets; } | ||||
void queue_delete ( Sequence_Widget *r ) | void queue_delete ( Sequence_Widget *r ) | ||||
@@ -127,7 +127,7 @@ Sequence_Region::trim ( enum trim_e t, int X ) | |||||
} | } | ||||
} | } | ||||
#include "FL/test_press.H" | |||||
int | int | ||||
Sequence_Region::handle ( int m ) | Sequence_Region::handle ( int m ) | ||||
@@ -168,7 +168,7 @@ Sequence_Region::handle ( int m ) | |||||
fl_cursor( FL_CURSOR_WE ); | fl_cursor( FL_CURSOR_WE ); | ||||
return 1; | return 1; | ||||
} | } | ||||
else if ( Fl::test_shortcut( FL_BUTTON2 ) && ! Fl::event_shift() ) | |||||
else if ( test_press( FL_BUTTON2 ) ) | |||||
{ | { | ||||
if ( Sequence_Widget::current() == this ) | if ( Sequence_Widget::current() == this ) | ||||
{ | { | ||||
@@ -181,7 +181,7 @@ Sequence_Region::handle ( int m ) | |||||
redraw(); | redraw(); | ||||
return 1; | return 1; | ||||
} | } | ||||
else if ( Fl::test_shortcut( FL_CTRL + FL_BUTTON1 ) && ! Fl::event_shift() ) | |||||
else if ( test_press( FL_CTRL + FL_BUTTON1 ) ) | |||||
{ | { | ||||
/* duplication */ | /* duplication */ | ||||
fl_cursor( FL_CURSOR_MOVE ); | fl_cursor( FL_CURSOR_MOVE ); | ||||
@@ -233,7 +233,7 @@ Sequence_Region::handle ( int m ) | |||||
return 1; | return 1; | ||||
} | } | ||||
} | } | ||||
else if ( Fl::test_shortcut( FL_BUTTON1 ) && ! Fl::event_shift() && ! selected() ) | |||||
else if ( test_press( FL_BUTTON1 ) && ! selected() ) | |||||
{ | { | ||||
/* track jumping */ | /* track jumping */ | ||||
if ( Y > y() + h() || Y < y() ) | if ( Y > y() + h() || Y < y() ) | ||||
@@ -279,6 +279,8 @@ Sequence_Widget::draw_box ( void ) | |||||
} | } | ||||
#include "FL/test_press.H" | |||||
/* base hanlde just does basic dragging */ | /* base hanlde just does basic dragging */ | ||||
int | int | ||||
Sequence_Widget::handle ( int m ) | Sequence_Widget::handle ( int m ) | ||||
@@ -288,7 +290,6 @@ Sequence_Widget::handle ( int m ) | |||||
Logger _log( this ); | Logger _log( this ); | ||||
switch ( m ) | switch ( m ) | ||||
{ | { | ||||
case FL_ENTER: | case FL_ENTER: | ||||
@@ -301,13 +302,13 @@ Sequence_Widget::handle ( int m ) | |||||
case FL_PUSH: | case FL_PUSH: | ||||
{ | { | ||||
/* deletion */ | /* deletion */ | ||||
if ( Fl::test_shortcut( FL_CTRL + FL_BUTTON3 ) && ! Fl::event_shift() ) | |||||
if ( test_press( FL_BUTTON3 + FL_CTRL ) ) | |||||
{ | { | ||||
redraw(); | redraw(); | ||||
sequence()->queue_delete( this ); | sequence()->queue_delete( this ); | ||||
return 1; | return 1; | ||||
} | } | ||||
else if ( Fl::test_shortcut( FL_BUTTON1 ) && ! Fl::event_shift() ) | |||||
else if ( test_press( FL_BUTTON1 ) || test_press( FL_BUTTON1 + FL_CTRL ) ) | |||||
{ | { | ||||
fl_cursor( FL_CURSOR_MOVE ); | fl_cursor( FL_CURSOR_MOVE ); | ||||
@@ -318,6 +319,7 @@ Sequence_Widget::handle ( int m ) | |||||
return 0; | return 0; | ||||
} | } | ||||
case FL_RELEASE: | case FL_RELEASE: | ||||
if ( _drag ) | if ( _drag ) | ||||
{ | { | ||||
end_drag(); | end_drag(); | ||||
@@ -329,17 +331,16 @@ Sequence_Widget::handle ( int m ) | |||||
return 1; | return 1; | ||||
case FL_DRAG: | case FL_DRAG: | ||||
{ | { | ||||
Fl::event_key( 0 ); | |||||
if ( ! _drag ) | if ( ! _drag ) | ||||
{ | { | ||||
begin_drag ( Drag( x() - X, y() - Y, x_to_offset( X ) ) ); | begin_drag ( Drag( x() - X, y() - Y, x_to_offset( X ) ) ); | ||||
_log.hold(); | _log.hold(); | ||||
} | } | ||||
if ( ( Fl::test_shortcut( FL_BUTTON1 + FL_CTRL ) || | |||||
Fl::test_shortcut( FL_BUTTON1 ) ) && ! Fl::event_shift() ) | |||||
else if ( test_press( FL_BUTTON1 ) || test_press( FL_BUTTON1 + FL_CTRL ) ) | |||||
{ | { | ||||
// fl_cursor( FL_CURSOR_MOVE ); | |||||
redraw(); | redraw(); | ||||
const nframes_t of = timeline->x_to_offset( X ); | const nframes_t of = timeline->x_to_offset( X ); | ||||
@@ -382,7 +383,10 @@ Sequence_Widget::handle ( int m ) | |||||
return 1; | return 1; | ||||
} | } | ||||
else | else | ||||
{ | |||||
DMESSAGE( "unknown" ); | |||||
return 0; | return 0; | ||||
} | |||||
} | } | ||||
default: | default: | ||||
return 0; | return 0; | ||||
@@ -947,6 +947,8 @@ Timeline::track_under ( int Y ) | |||||
return NULL; | return NULL; | ||||
} | } | ||||
#include "FL/event_name.H" | |||||
#include "FL/test_press.H" | |||||
int | int | ||||
Timeline::handle ( int m ) | Timeline::handle ( int m ) | ||||
@@ -954,6 +956,12 @@ Timeline::handle ( int m ) | |||||
static Drag *drag = NULL; | static Drag *drag = NULL; | ||||
static bool range = false; | static bool range = false; | ||||
/* if ( m != FL_NO_EVENT ) */ | |||||
/* DMESSAGE( "%s", event_name( m ) ); */ | |||||
int r = Fl_Overlay_Window::handle( m ); | |||||
switch ( m ) | switch ( m ) | ||||
{ | { | ||||
case FL_FOCUS: | case FL_FOCUS: | ||||
@@ -993,19 +1001,20 @@ Timeline::handle ( int m ) | |||||
/* keep scrollbar from eating these. */ | /* keep scrollbar from eating these. */ | ||||
return 0; | return 0; | ||||
default: | default: | ||||
return Fl_Overlay_Window::handle( m ); | |||||
return r; | |||||
} | } | ||||
return 0; | return 0; | ||||
} | } | ||||
default: | default: | ||||
{ | { | ||||
if ( m == FL_PUSH && this != Fl::focus() ) | |||||
take_focus(); | |||||
/* if ( m == FL_PUSH ) */ | |||||
/* take_focus(); */ | |||||
//Fl::focus( this ); | //Fl::focus( this ); | ||||
int r = Fl_Overlay_Window::handle( m ); | |||||
/* r = Fl_Overlay_Window::handle( m ); */ | |||||
if ( m != FL_RELEASE && r ) | if ( m != FL_RELEASE && r ) | ||||
return r; | return r; | ||||
@@ -1017,7 +1026,7 @@ Timeline::handle ( int m ) | |||||
{ | { | ||||
case FL_PUSH: | case FL_PUSH: | ||||
{ | { | ||||
if ( Fl::test_shortcut( FL_BUTTON1 ) && ! Fl::event_shift() ) | |||||
if ( test_press( FL_BUTTON1 ) ) | |||||
{ | { | ||||
assert( ! drag ); | assert( ! drag ); | ||||
@@ -1027,7 +1036,7 @@ Timeline::handle ( int m ) | |||||
return 1; | return 1; | ||||
} | } | ||||
else if ( Fl::test_shortcut( FL_BUTTON3 ) && ! Fl::event_shift() ) | |||||
else if ( test_press( FL_BUTTON3 ) ) | |||||
{ | { | ||||
const Fl_Menu_Item *r = menu->menu()->popup( X, Y, "Timeline" ); | const Fl_Menu_Item *r = menu->menu()->popup( X, Y, "Timeline" ); | ||||
if ( r ) | if ( r ) | ||||
@@ -470,9 +470,16 @@ Track::draw ( void ) | |||||
Fl_Group::draw(); | Fl_Group::draw(); | ||||
} | } | ||||
#include "FL/event_name.H" | |||||
#include "FL/test_press.H" | |||||
int | int | ||||
Track::handle ( int m ) | Track::handle ( int m ) | ||||
{ | { | ||||
/* if ( m != FL_NO_EVENT ) */ | |||||
/* DMESSAGE( "%s", event_name( m ) ); */ | |||||
switch ( m ) | switch ( m ) | ||||
{ | { | ||||
case FL_MOUSEWHEEL: | case FL_MOUSEWHEEL: | ||||
@@ -493,6 +500,8 @@ Track::handle ( int m ) | |||||
} | } | ||||
case FL_PUSH: | case FL_PUSH: | ||||
{ | { | ||||
Fl::event_key( 0 ); | |||||
Logger log( this ); | Logger log( this ); | ||||
int X = Fl::event_x(); | int X = Fl::event_x(); | ||||
@@ -501,7 +510,7 @@ Track::handle ( int m ) | |||||
if ( Fl_Group::handle( m ) ) | if ( Fl_Group::handle( m ) ) | ||||
return 1; | return 1; | ||||
if ( Fl::test_shortcut( FL_BUTTON3 ) && ! Fl::event_shift() && X < Track::width() ) | |||||
if ( test_press( FL_BUTTON3 ) && X < Track::width() ) | |||||
{ | { | ||||
int c = output.size(); | int c = output.size(); | ||||