Clean up sequence widget class.
This commit is contained in:
parent
9335a97933
commit
d4535ab52e
|
@ -48,6 +48,35 @@ Sequence_Widget::Sequence_Widget ( )
|
|||
_color = FL_FOREGROUND_COLOR;
|
||||
}
|
||||
|
||||
/* careful with this, it doesn't journal */
|
||||
Sequence_Widget::Sequence_Widget ( const Sequence_Widget &rhs ) : Loggable( rhs )
|
||||
{
|
||||
_drag = NULL;
|
||||
|
||||
_sequence = rhs._sequence;
|
||||
|
||||
_range = rhs._range;
|
||||
_r = &_range;
|
||||
|
||||
_color = rhs._color;
|
||||
_box_color = rhs._box_color;
|
||||
};
|
||||
|
||||
const Sequence_Widget &
|
||||
Sequence_Widget::operator= ( const Sequence_Widget &rhs )
|
||||
{
|
||||
if ( this == &rhs )
|
||||
return *this;
|
||||
|
||||
_r = &_range;
|
||||
_range = rhs._range;
|
||||
_sequence = rhs._sequence;
|
||||
_box_color = rhs._box_color;
|
||||
_color = rhs._color;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Sequence_Widget::~Sequence_Widget ( )
|
||||
{
|
||||
redraw();
|
||||
|
@ -336,8 +365,7 @@ Sequence_Widget::handle ( int m )
|
|||
/* deletion */
|
||||
if ( test_press( FL_BUTTON3 + FL_CTRL ) )
|
||||
{
|
||||
redraw();
|
||||
sequence()->queue_delete( this );
|
||||
remove();
|
||||
return 1;
|
||||
}
|
||||
else if ( test_press( FL_BUTTON1 ) || test_press( FL_BUTTON1 + FL_CTRL ) )
|
||||
|
@ -450,3 +478,68 @@ Sequence_Widget::handle ( int m )
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**********/
|
||||
/* Public */
|
||||
/**********/
|
||||
|
||||
/** add this widget to the selection */
|
||||
void
|
||||
Sequence_Widget::select ( void )
|
||||
{
|
||||
if ( selected() )
|
||||
return;
|
||||
|
||||
_selection.push_back( this );
|
||||
_selection.sort( sort_func );
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
/** remove this widget from the selection */
|
||||
void
|
||||
Sequence_Widget::deselect ( void )
|
||||
{
|
||||
_selection.remove( this );
|
||||
redraw();
|
||||
}
|
||||
|
||||
bool
|
||||
Sequence_Widget::selected ( void ) const
|
||||
{
|
||||
return std::find( _selection.begin(), _selection.end(), this ) != _selection.end();
|
||||
}
|
||||
|
||||
/** remove this widget from its sequence */
|
||||
void
|
||||
Sequence_Widget::remove ( void )
|
||||
{
|
||||
redraw();
|
||||
sequence()->queue_delete( this );
|
||||
}
|
||||
|
||||
void
|
||||
Sequence_Widget::delete_selected ( void )
|
||||
{
|
||||
Loggable::block_start();
|
||||
|
||||
while ( _selection.size() )
|
||||
delete _selection.front();
|
||||
|
||||
Loggable::block_end();
|
||||
}
|
||||
|
||||
void
|
||||
Sequence_Widget::select_none ( void )
|
||||
{
|
||||
Loggable::block_start();
|
||||
|
||||
while ( _selection.size() )
|
||||
{
|
||||
_selection.front()->redraw();
|
||||
_selection.pop_front();
|
||||
}
|
||||
|
||||
Loggable::block_end();
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ struct Drag
|
|||
};
|
||||
|
||||
/* most common position description. /offset/ is only used by Regions,
|
||||
but it's more convenient to have it here */
|
||||
but it's more convenient to have it here */
|
||||
struct Range
|
||||
{
|
||||
nframes_t start; /* where on the timeline */
|
||||
|
@ -110,6 +110,12 @@ struct position_info
|
|||
BBT bbt;
|
||||
};
|
||||
|
||||
#define SEQUENCE_WIDGET_CLONE_FUNC(class) \
|
||||
virtual Sequence_Widget *clone ( void ) const \
|
||||
{ \
|
||||
return new class ( *this ); \
|
||||
}
|
||||
|
||||
|
||||
/* Base class for virtual widget on a track */
|
||||
class Sequence_Widget : public Loggable
|
||||
|
@ -144,114 +150,33 @@ protected:
|
|||
virtual void get ( Log_Entry &e ) const;
|
||||
virtual void set ( Log_Entry &e );
|
||||
|
||||
/* careful with this, it doesn't journal */
|
||||
Sequence_Widget ( const Sequence_Widget &rhs ) : Loggable( rhs )
|
||||
{
|
||||
_drag = NULL;
|
||||
|
||||
_sequence = rhs._sequence;
|
||||
|
||||
_range = rhs._range;
|
||||
_r = &_range;
|
||||
|
||||
_color = rhs._color;
|
||||
_box_color = rhs._box_color;
|
||||
};
|
||||
|
||||
Sequence_Widget ( const Sequence_Widget &rhs );
|
||||
Sequence_Widget ( );
|
||||
|
||||
const Sequence_Widget &
|
||||
operator= ( const Sequence_Widget &rhs );
|
||||
|
||||
public:
|
||||
|
||||
virtual ~Sequence_Widget ( );
|
||||
|
||||
const Sequence_Widget &
|
||||
operator= ( const Sequence_Widget &rhs )
|
||||
{
|
||||
if ( this == &rhs )
|
||||
return *this;
|
||||
|
||||
_r = &_range;
|
||||
_range = rhs._range;
|
||||
_sequence = rhs._sequence;
|
||||
_box_color = rhs._box_color;
|
||||
_color = rhs._color;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/* Sequence_Widget ( const Sequence_Widget &rhs ) */
|
||||
/* { */
|
||||
/* *this = rhs; */
|
||||
/* } */
|
||||
|
||||
#define SEQUENCE_WIDGET_CLONE_FUNC(class) \
|
||||
virtual Sequence_Widget *clone ( void ) const \
|
||||
{ \
|
||||
return new class ( *this ); \
|
||||
} \
|
||||
\
|
||||
// virtual Sequence_Widget *clone ( const Sequence_Widget *r ) = 0;
|
||||
virtual Sequence_Widget *clone ( void ) const = 0;
|
||||
|
||||
bool selected ( void ) const
|
||||
{
|
||||
return std::find( _selection.begin(), _selection.end(), this ) != _selection.end();
|
||||
}
|
||||
bool selected ( void ) const;
|
||||
void select ( void );
|
||||
void deselect ( void );
|
||||
void remove ( void );
|
||||
|
||||
void select ( void )
|
||||
{
|
||||
if ( selected() )
|
||||
return;
|
||||
|
||||
_selection.push_back( this );
|
||||
_selection.sort( sort_func );
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
||||
void deselect ( void )
|
||||
{
|
||||
_selection.remove( this );
|
||||
redraw();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
delete_selected ( void )
|
||||
{
|
||||
Loggable::block_start();
|
||||
|
||||
while ( _selection.size() )
|
||||
delete _selection.front();
|
||||
|
||||
Loggable::block_end();
|
||||
}
|
||||
|
||||
static void
|
||||
select_none ( void )
|
||||
{
|
||||
Loggable::block_start();
|
||||
|
||||
while ( _selection.size() )
|
||||
{
|
||||
_selection.front()->redraw();
|
||||
_selection.pop_front();
|
||||
}
|
||||
|
||||
Loggable::block_end();
|
||||
}
|
||||
static void delete_selected ( void );
|
||||
static void select_none ( void );
|
||||
|
||||
static Sequence_Widget *current ( void ) { return Sequence_Widget::_current; }
|
||||
|
||||
static Sequence_Widget *pushed ( void ) { return Sequence_Widget::_pushed; }
|
||||
static Sequence_Widget *belowmouse ( void ) { return Sequence_Widget::_belowmouse; }
|
||||
|
||||
static void pushed ( Sequence_Widget *w ) { Sequence_Widget::_pushed = w; }
|
||||
static void belowmouse ( Sequence_Widget *w ) { Sequence_Widget::_belowmouse = w; }
|
||||
|
||||
// static void pushed ( Sequence_Widget *w ) { Sequence_Widget::_pushed = w; }
|
||||
|
||||
void begin_drag ( const Drag &d );
|
||||
void end_drag ( void );
|
||||
|
||||
|
@ -322,9 +247,6 @@ public:
|
|||
|
||||
int active_r ( void ) const { return _sequence->active_r(); }
|
||||
|
||||
|
||||
|
||||
|
||||
/** returns true if widget /w/ begins and ends completely within the range of this widget */
|
||||
bool contains ( const Sequence_Widget *w ) const
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue