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