2008-04-18 22:18:07 +02:00
|
|
|
|
|
|
|
/*******************************************************************************/
|
|
|
|
/* 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. */
|
|
|
|
/*******************************************************************************/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2008-04-19 06:16:21 +02:00
|
|
|
#include "Sequence.H"
|
2008-05-05 00:32:08 +02:00
|
|
|
#include "Annotation_Point.H"
|
2008-05-05 04:05:20 +02:00
|
|
|
#include "Annotation_Region.H"
|
2008-04-18 22:18:07 +02:00
|
|
|
#include "Timeline.H"
|
|
|
|
|
2008-05-05 07:29:39 +02:00
|
|
|
#include "Track.H"
|
|
|
|
|
|
|
|
class Annotation_Sequence : public Sequence
|
2008-04-18 22:18:07 +02:00
|
|
|
{
|
|
|
|
|
2008-05-05 01:06:36 +02:00
|
|
|
protected:
|
|
|
|
|
|
|
|
virtual void get ( Log_Entry &e ) const
|
|
|
|
{
|
2008-05-07 17:28:57 +02:00
|
|
|
e.add( ":track", _track );
|
2008-05-05 01:06:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
set ( Log_Entry &e )
|
|
|
|
{
|
|
|
|
for ( int i = 0; i < e.size(); ++i )
|
|
|
|
{
|
|
|
|
const char *s, *v;
|
|
|
|
|
|
|
|
e.get( i, &s, &v );
|
|
|
|
|
2008-05-07 17:28:57 +02:00
|
|
|
if ( ! strcmp( ":track", s ) )
|
2008-05-05 01:06:36 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
sscanf( v, "%X", &i );
|
|
|
|
Track *t = (Track*)Loggable::find( i );
|
|
|
|
|
|
|
|
assert( t );
|
|
|
|
|
2008-05-05 07:29:39 +02:00
|
|
|
t->add( this );
|
2008-05-05 01:06:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-05 07:29:39 +02:00
|
|
|
Annotation_Sequence ( ) : Sequence ( 0 )
|
2008-05-05 01:06:36 +02:00
|
|
|
{
|
2012-12-11 06:47:44 +01:00
|
|
|
color( FL_DARK1 );
|
2008-05-05 01:06:36 +02:00
|
|
|
}
|
|
|
|
|
2008-04-18 22:18:07 +02:00
|
|
|
public:
|
|
|
|
|
2008-05-05 01:06:36 +02:00
|
|
|
|
|
|
|
LOG_CREATE_FUNC( Annotation_Sequence );
|
|
|
|
|
2008-05-02 13:42:50 +02:00
|
|
|
Fl_Cursor cursor ( void ) const { return FL_CURSOR_INSERT; }
|
|
|
|
|
2008-05-05 07:29:39 +02:00
|
|
|
Annotation_Sequence ( Track *track ) : Sequence( track )
|
2008-05-05 01:06:36 +02:00
|
|
|
{
|
2012-12-11 06:47:44 +01:00
|
|
|
color( FL_DARK1 );
|
2008-05-05 01:06:36 +02:00
|
|
|
|
|
|
|
log_create();
|
|
|
|
}
|
|
|
|
|
2012-12-11 06:47:44 +01:00
|
|
|
virtual ~Annotation_Sequence ( )
|
2008-05-05 01:06:36 +02:00
|
|
|
{
|
2008-06-06 06:14:00 +02:00
|
|
|
Loggable::block_start();
|
|
|
|
|
|
|
|
clear();
|
|
|
|
|
2008-05-05 01:06:36 +02:00
|
|
|
log_destroy();
|
2008-05-28 02:36:17 +02:00
|
|
|
|
|
|
|
track()->remove( this );
|
2008-06-06 06:14:00 +02:00
|
|
|
|
|
|
|
Loggable::block_end();
|
2008-05-05 01:06:36 +02:00
|
|
|
}
|
|
|
|
|
2008-04-26 13:58:50 +02:00
|
|
|
int handle ( int m )
|
|
|
|
{
|
|
|
|
|
|
|
|
if ( Sequence::handle( m ) )
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
switch ( m )
|
|
|
|
{
|
|
|
|
case FL_PUSH:
|
|
|
|
{
|
2012-12-11 07:58:18 +01:00
|
|
|
if ( Fl::event_x() < drawable_x() )
|
|
|
|
return 0;
|
|
|
|
|
2010-01-24 23:42:32 +01:00
|
|
|
Logger log( this );
|
|
|
|
|
2008-04-26 13:58:50 +02:00
|
|
|
if ( Fl::event_button1() )
|
|
|
|
{
|
2012-12-11 06:47:44 +01:00
|
|
|
add( new Annotation_Point( this, x_to_offset( Fl::event_x() - drawable_x() ), "mark" ) );
|
2008-04-26 13:58:50 +02:00
|
|
|
redraw();
|
|
|
|
}
|
2008-05-05 04:05:20 +02:00
|
|
|
if ( Fl::event_button3() && Fl::event_shift() )
|
|
|
|
{
|
2012-12-11 06:47:44 +01:00
|
|
|
Annotation_Region *r = new Annotation_Region( this, x_to_offset( Fl::event_x() - drawable_x() ), "mark" );
|
2008-05-05 04:05:20 +02:00
|
|
|
|
|
|
|
add( r );
|
|
|
|
|
|
|
|
Sequence_Widget::pushed( r );
|
|
|
|
|
|
|
|
r->handle( m );
|
|
|
|
|
|
|
|
redraw();
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
2010-01-24 23:42:32 +01:00
|
|
|
else if ( Fl::event_button3() && ! ( Fl::event_state() & ( FL_ALT | FL_SHIFT | FL_CTRL ) ) )
|
|
|
|
{
|
|
|
|
|
|
|
|
Fl_Menu_Item menu[] =
|
|
|
|
{
|
|
|
|
{ "Remove" },
|
|
|
|
{ 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
const Fl_Menu_Item *r = menu->popup( Fl::event_x(), Fl::event_y(), "Annotation Sequence" );
|
|
|
|
|
|
|
|
if ( r )
|
|
|
|
{
|
|
|
|
if ( r == &menu[ 0 ] )
|
|
|
|
{
|
|
|
|
Fl::delete_widget( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2008-04-26 13:58:50 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-04-18 22:18:07 +02:00
|
|
|
|
2008-04-26 13:58:50 +02:00
|
|
|
return 0;
|
2008-04-18 22:18:07 +02:00
|
|
|
}
|
|
|
|
};
|