Improve the way Sequence_Points are drawn.

pull/3/head
Jonathan Moore Liles 2008-04-30 23:24:20 -05:00
parent 2bec4b16f1
commit 8e791e2cd9
4 changed files with 132 additions and 41 deletions

View File

@ -11,6 +11,7 @@ SRCS= \
Timeline.C \
Track.C \
Sequence_Widget.C \
Sequence_Point.C \
Tempo_Point.C \
Time_Point.C \
Peaks.C \

109
Timeline/Sequence_Point.C Normal file
View File

@ -0,0 +1,109 @@
/*******************************************************************************/
/* 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. */
/*******************************************************************************/
#include "Sequence_Point.H"
void
Sequence_Point::get ( Log_Entry &e ) const
{
e.add( ":x", _r->offset );
e.add( ":t", _track );
}
void
Sequence_Point::set ( Log_Entry &e )
{
Sequence_Widget::set( e );
for ( int i = 0; i < e.size(); ++i )
{
const char *s, *v;
e.get( i, &s, &v );
if ( ! strcmp( ":x", s ) )
{
_track->sort();
}
}
}
static void
draw_marker ( Fl_Color c )
{
fl_color( c );
fl_begin_polygon();
#define vv(x,y) fl_vertex( x, y );
vv( 0.0, 0.0 );
vv( 0.0, 0.6 );
vv( 0.5, 1.0 );
vv( 1.0, 0.6 );
vv( 1.0, 0.0 );
vv( 0.0, 0.0 );
fl_end_polygon();
fl_color( fl_darker( c ) );
fl_begin_line();
vv( 0.0, 0.0 );
vv( 0.0, 0.6 );
vv( 0.5, 1.0 );
vv( 1.0, 0.6 );
vv( 1.0, 0.0 );
vv( 0.0, 0.0 );
fl_end_line();
}
void
Sequence_Point::draw_box ( void )
{
// Sequence_Widget::draw_box();
const int X = x() - (abs_w() >> 1);
// const int Y = y() + Fl::box_dy( box() );
const int Y = y();
fl_color( color() );
fl_push_matrix();
fl_translate( X, Y + ( h() >> 3 ) );
fl_scale( w(), h() - ( h() >> 3 ) );
draw_marker( color() );
fl_pop_matrix();
// fl_line( X, Y, X, Y + h() - Fl::box_dh( box() ) );
}
void
Sequence_Point::draw ( void )
{
// Sequence_Widget::draw();
draw_label( _label, align() );
}

View File

@ -28,45 +28,36 @@ protected:
char *_label;
virtual void get ( Log_Entry &e ) const
{
e.add( ":x", _r->offset );
e.add( ":t", _track );
}
virtual void set ( Log_Entry &e )
{
Sequence_Widget::set( e );
for ( int i = 0; i < e.size(); ++i )
{
const char *s, *v;
e.get( i, &s, &v );
if ( ! strcmp( ":x", s ) )
{
_track->sort();
}
}
}
void get ( Log_Entry &e ) const;
void set ( Log_Entry &e );
public:
Fl_Align align ( void ) const { return FL_ALIGN_RIGHT; }
virtual int abs_w ( void ) const { return 8; }
// virtual int abs_x ( void ) const { return Sequence_Widget::abs_x() - ( abs_w() >> 1 ); }
// virtual int x ( void ) const { return Sequence_Widget::line_x() - ( abs_w() >> 1 ); }
virtual int x ( void ) const
{
const int x = Sequence_Widget::x();
if ( x >= _track->x() + _track->w() )
return _track->x() + _track->w() + abs_w();
else
return x;
virtual int abs_w ( void ) const { return 10; }
/* FIXME: hack */
virtual int x ( void ) const { const int x = Sequence_Widget::x() - ( abs_w() >> 1 ); if ( x == _track->x() ) return x - 3; else return x; }
}
nframes_t length ( void ) const { return timeline->x_to_ts( abs_w() ); }
Sequence_Point ( )
{
_label = NULL;
color( FL_CYAN );
}
@ -74,19 +65,7 @@ public:
{
}
virtual void
draw ( void )
{
Sequence_Widget::draw();
virtual void draw_box ( void );
virtual void draw ( void );
const int x = Sequence_Widget::x();
const int y = this->y() + Fl::box_dy( box() );
fl_color( FL_WHITE );
fl_line( x, y, x, y + h() - Fl::box_dh( box() ) );
draw_label( _label, align() );
}
};

View File

@ -638,6 +638,8 @@ Timeline::draw ( void )
int dx = ts_to_x( _old_xposition ) - ts_to_x( xoffset );
int dy = _old_yposition - _yposition;
/* draw_child( *rulers ); */
if ( ! dy )
fl_scroll( rulers->x(), rulers->y(), rulers->w(), rulers->h(), dx, 0, draw_clip, this );