Begin handlig region events again.
This commit is contained in:
parent
69aee9de79
commit
900c49aeae
193
Region.C
193
Region.C
|
@ -122,86 +122,85 @@ Region::Region ( Clip *c )
|
|||
/* } */
|
||||
|
||||
int
|
||||
Region::handle ( int m ) { return 0; }
|
||||
Region::handle ( int m )
|
||||
{
|
||||
|
||||
/* { */
|
||||
static int ox, oy;
|
||||
static enum trim_e trimming;
|
||||
|
||||
/* /\* if ( Fl_Widget::handle( m ) ) *\/ */
|
||||
/* /\* return 1; *\/ */
|
||||
static bool copied = false;
|
||||
static nframes_t os;
|
||||
|
||||
/* static int ox, oy; */
|
||||
/* static enum trim_e trimming; */
|
||||
int X = Fl::event_x();
|
||||
int Y = Fl::event_y();
|
||||
|
||||
/* static bool copied = false; */
|
||||
/* static nframes_t os; */
|
||||
switch ( m )
|
||||
{
|
||||
case FL_PUSH:
|
||||
{
|
||||
|
||||
/* int X = Fl::event_x(); */
|
||||
/* int Y = Fl::event_y(); */
|
||||
if ( Fl::event_state() & FL_SHIFT &&
|
||||
! ( Fl::event_state() & FL_CTRL ))
|
||||
{
|
||||
switch ( Fl::event_button() )
|
||||
{
|
||||
|
||||
/* switch ( m ) */
|
||||
/* { */
|
||||
/* case FL_PUSH: */
|
||||
/* { */
|
||||
|
||||
/* if ( Fl::event_state() & FL_SHIFT && */
|
||||
/* ! ( Fl::event_state() & FL_CTRL )) */
|
||||
/* { */
|
||||
/* switch ( Fl::event_button() ) */
|
||||
/* { */
|
||||
/* case 1: */
|
||||
/* trim( trimming = LEFT, X ); */
|
||||
/* break; */
|
||||
/* case 3: */
|
||||
/* trim( trimming = RIGHT, X ); */
|
||||
/* break; */
|
||||
/* default: */
|
||||
/* return 0; */
|
||||
/* } */
|
||||
/* fl_cursor( FL_CURSOR_WE ); */
|
||||
/* return 1; */
|
||||
/* } */
|
||||
/* else */
|
||||
/* { */
|
||||
/* ox = x() - X; */
|
||||
/* oy = y() - Y; */
|
||||
|
||||
/* if ( Fl::event_state() && FL_CTRL ) */
|
||||
/* { */
|
||||
/* os = _start; */
|
||||
/* // Fl::local_grab( this ); */
|
||||
/* } */
|
||||
default:
|
||||
return 0;
|
||||
|
||||
}
|
||||
fl_cursor( FL_CURSOR_WE );
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ox = x() - X;
|
||||
oy = y() - Y;
|
||||
|
||||
if ( Fl::event_state() && FL_CTRL )
|
||||
{
|
||||
os = _start;
|
||||
// Fl::local_grab( this );
|
||||
}
|
||||
|
||||
/* if ( Fl::event_button() == 2 ) */
|
||||
/* normalize(); */
|
||||
|
||||
|
||||
/* return 1; */
|
||||
/* } */
|
||||
/* return 0; */
|
||||
/* break; */
|
||||
/* } */
|
||||
/* case FL_RELEASE: */
|
||||
/* fl_cursor( FL_CURSOR_DEFAULT ); */
|
||||
/* copied = false; */
|
||||
/* trimming = NO; */
|
||||
/* // Fl::release(); */
|
||||
/* return 1; */
|
||||
/* case FL_DRAG: */
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
case FL_RELEASE:
|
||||
fl_cursor( FL_CURSOR_DEFAULT );
|
||||
copied = false;
|
||||
trimming = NO;
|
||||
// Fl::release();
|
||||
return 1;
|
||||
case FL_DRAG:
|
||||
|
||||
/* if ( Fl::event_state() & FL_SHIFT && */
|
||||
/* Fl::event_state() & FL_CTRL ) */
|
||||
/* { */
|
||||
/* int d = (ox + X) - x(); */
|
||||
/* long td = timeline.x_to_ts( d ); */
|
||||
if ( Fl::event_state() & FL_SHIFT &&
|
||||
Fl::event_state() & FL_CTRL )
|
||||
{
|
||||
int d = (ox + X) - x();
|
||||
long td = timeline.x_to_ts( d );
|
||||
|
||||
/* if ( td > 0 && os < td ) */
|
||||
/* _start = 0; */
|
||||
/* else */
|
||||
/* _start = os - td; */
|
||||
if ( td > 0 && os < td )
|
||||
_start = 0;
|
||||
else
|
||||
_start = os - td;
|
||||
|
||||
/* redraw(); */
|
||||
/* return 1; */
|
||||
/* } */
|
||||
// redraw();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* if ( Fl::event_state() & FL_SHIFT ) */
|
||||
/* if ( trimming ) */
|
||||
|
@ -212,44 +211,46 @@ Region::handle ( int m ) { return 0; }
|
|||
/* else */
|
||||
/* return 0; */
|
||||
|
||||
/* if ( Fl::event_state() & FL_CTRL ) */
|
||||
/* { */
|
||||
/* if ( ! copied ) */
|
||||
/* { */
|
||||
/* _track->add( new Region( *this ) ); */
|
||||
/* copied = true; */
|
||||
/* return 1; */
|
||||
/* } */
|
||||
/* } */
|
||||
if ( Fl::event_state() & FL_CTRL )
|
||||
{
|
||||
if ( ! copied )
|
||||
{
|
||||
_track->add( new Region( *this ) );
|
||||
copied = true;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* if ( ox + X >= _track->x() ) */
|
||||
/* { */
|
||||
/* int nx = ox + X; */
|
||||
if ( ox + X >= _track->x() )
|
||||
{
|
||||
int nx = ox + X;
|
||||
|
||||
/* // nx = _track->snap( this, nx ); */
|
||||
// nx = _track->snap( this, nx );
|
||||
|
||||
/* // _offset = timeline.x_to_ts( nx ); */
|
||||
// _offset = timeline.x_to_ts( nx );
|
||||
|
||||
/* position( nx, y() ); */
|
||||
// position( nx, y() );
|
||||
|
||||
/* _track->snap( this ); */
|
||||
/* } */
|
||||
_offset = timeline.x_to_ts( nx ) + timeline.xoffset;
|
||||
|
||||
/* if ( Y > y() + h() ) */
|
||||
/* { */
|
||||
/* if ( _track->next() ) */
|
||||
/* _track->next()->add( this ); */
|
||||
/* } */
|
||||
/* else */
|
||||
/* if ( Y < y() ) */
|
||||
/* { */
|
||||
/* if ( _track->prev() ) */
|
||||
/* _track->prev()->add( this ); */
|
||||
/* } */
|
||||
// _track->snap( this );
|
||||
}
|
||||
|
||||
/* parent()->redraw(); */
|
||||
if ( Y > y() + h() )
|
||||
{
|
||||
if ( _track->next() )
|
||||
_track->next()->add( this );
|
||||
}
|
||||
else
|
||||
if ( Y < y() )
|
||||
{
|
||||
if ( _track->prev() )
|
||||
_track->prev()->add( this );
|
||||
}
|
||||
|
||||
/* fl_cursor( FL_CURSOR_MOVE ); */
|
||||
_track->redraw();
|
||||
|
||||
fl_cursor( FL_CURSOR_MOVE );
|
||||
|
||||
/* if ( X >= timeline.scroll->x() + timeline.scroll->w() || */
|
||||
/* X <= timeline.scroll->x() ) */
|
||||
|
@ -269,14 +270,14 @@ Region::handle ( int m ) { return 0; }
|
|||
/* timeline.scroll->position( pos, timeline.scroll->yposition() ); */
|
||||
/* } */
|
||||
|
||||
/* // _offset = timeline.x_to_ts( x() ); */
|
||||
// _offset = timeline.x_to_ts( x() );
|
||||
|
||||
/* return 1; */
|
||||
/* default: */
|
||||
/* return 0; */
|
||||
/* break; */
|
||||
/* } */
|
||||
/* } */
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** must be called whenever zoom is adjusted */
|
||||
|
|
10
Region.H
10
Region.H
|
@ -19,11 +19,13 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
class Track;
|
||||
// class Track;
|
||||
|
||||
// #include "Waveform.H"
|
||||
|
||||
#include "Clip.H"
|
||||
#include "Track.H"
|
||||
#include "Timeline.H"
|
||||
|
||||
class Region
|
||||
{
|
||||
|
@ -47,6 +49,10 @@ public:
|
|||
Region ( const Region & rhs );
|
||||
Region ( Clip *c );
|
||||
|
||||
int y ( void ) { return _track->y(); }
|
||||
int h ( void ) { return _track->h(); }
|
||||
int x ( void ) { return timeline.ts_to_x( _offset ) - timeline.xoffset; }
|
||||
|
||||
int handle ( int m );
|
||||
void draw ( int X, int Y, int W, int H );
|
||||
void resize ( void );
|
||||
|
@ -57,5 +63,7 @@ public:
|
|||
nframes_t offset ( void ) const { return _offset; }
|
||||
void offset ( nframes_t o ) { _offset = o; }
|
||||
|
||||
nframes_t length ( void ) const { return _end - _start; }
|
||||
|
||||
void end ( nframes_t v ) { _end = v; }
|
||||
};
|
||||
|
|
31
Track.C
31
Track.C
|
@ -20,6 +20,8 @@
|
|||
#include "Track.H"
|
||||
#include "Timeline.H"
|
||||
|
||||
#include "Region.H"
|
||||
|
||||
void
|
||||
Track::draw ( void )
|
||||
{
|
||||
|
@ -36,6 +38,24 @@ Track::remove_region ( Region *r )
|
|||
_regions.remove( r );
|
||||
}
|
||||
|
||||
|
||||
Region *
|
||||
Track::event_region ( void )
|
||||
{
|
||||
// FIXME: doesn't handle overlap!
|
||||
|
||||
for ( list <Region *>::iterator r = _regions.begin(); r != _regions.end(); r++ )
|
||||
{
|
||||
int X = timeline.ts_to_x( (*r)->offset() ) - timeline.xoffset;
|
||||
int W = timeline.ts_to_x( (*r)->length() );
|
||||
|
||||
if ( Fl::event_x() > X && Fl::event_x() < X + W )
|
||||
return (*r);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
Track::add ( Region *r )
|
||||
{
|
||||
|
@ -146,7 +166,16 @@ Track::handle ( int m )
|
|||
|
||||
return 1;
|
||||
}
|
||||
case FL_MOVE:
|
||||
/* these aren't used, so don't bother doing lookups for them */
|
||||
return 1;
|
||||
default:
|
||||
return Fl_Group::handle( m );
|
||||
{
|
||||
Region *r = event_region();
|
||||
if ( r )
|
||||
return r->handle( m );
|
||||
else
|
||||
return Fl_Group::handle( m );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
7
Track.H
7
Track.H
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include <FL/Fl_Group.H>
|
||||
#include <FL/Fl.H>
|
||||
#include "Region.H"
|
||||
// #include "Region.H"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -31,6 +31,8 @@
|
|||
#include <list>
|
||||
using std::list;
|
||||
|
||||
class Region;
|
||||
|
||||
class Track : public Fl_Group
|
||||
{
|
||||
Track *_next;
|
||||
|
@ -40,6 +42,8 @@ class Track : public Fl_Group
|
|||
|
||||
char *_name;
|
||||
|
||||
Region *event_region ( void );
|
||||
|
||||
public:
|
||||
|
||||
Track ( int X, int Y, int W, int H ) : Fl_Group( X, Y, W, H )
|
||||
|
@ -56,6 +60,7 @@ public:
|
|||
void prev ( Track *t ) { _prev = t; }
|
||||
void next ( Track *t ) { _next = t; }
|
||||
|
||||
|
||||
void draw ( void );
|
||||
void remove_region ( Region *r );
|
||||
void add ( Region *r );
|
||||
|
|
Loading…
Reference in New Issue