Browse Source

Allow the user to add/edit tempo points.

tags/non-daw-v1.1.0
Jonathan Moore Liles 17 years ago
parent
commit
61f3d56611
4 changed files with 114 additions and 4 deletions
  1. +3
    -3
      Timeline/TLE.fl
  2. +79
    -0
      Timeline/Tempo_Point.C
  3. +3
    -1
      Timeline/Tempo_Point.H
  4. +29
    -0
      Timeline/Tempo_Sequence.H

+ 3
- 3
Timeline/TLE.fl View File

@@ -34,7 +34,7 @@ decl {\#include <FL/Fl.H>} {}
decl {extern char *user_config_dir;} {global
}

class TLE {open
class TLE {open selected
} {
decl {Fl_Color system_colors[3];} {public
}
@@ -114,7 +114,7 @@ free( path );} {}
label {Non-DAW - Timeline} open
xywh {577 94 1024 768} type Double resizable xclass {Non-DAW} visible
} {
Fl_Menu_Bar menubar {open
Fl_Menu_Bar menubar {
xywh {0 0 1024 25}
} {
Submenu {} {
@@ -158,7 +158,7 @@ Loggable::compact();}

printf( "dropped %d buffers\\n", engine->dropped() );

exit( 0 );} selected
exit( 0 );}
xywh {40 40 40 25} shortcut 0x40071
}
}


+ 79
- 0
Timeline/Tempo_Point.C View File

@@ -72,9 +72,18 @@ Tempo_Point::~Tempo_Point ( )
}



int
Tempo_Point::handle ( int m )
{
if ( m == FL_PUSH && Fl::event_button3() && ! ( Fl::event_state() & ( FL_ALT | FL_CTRL | FL_SHIFT ) ) )
{
float t = _tempo;
edit( &t );
tempo( t );
return 0;
}

int r = Sequence_Widget::handle( m );

if ( m == FL_RELEASE )
@@ -84,3 +93,73 @@ Tempo_Point::handle ( int m )
}
return r;
}


#include <FL/Fl_Float_Input.H>
#include <FL/Fl_Menu_Window.H>


class Tempo_Point_Editor : public Fl_Menu_Window
{

float *_tempo;
Fl_Float_Input *_fi;

bool _sucess;

public:

Tempo_Point_Editor ( int X, int Y, float *tempo ) : Fl_Menu_Window( X, Y, 75, 58, "Edit Tempo" )
{
_sucess = false;
_tempo = tempo;

set_modal();

Fl_Float_Input *fi = _fi = new Fl_Float_Input( 12, 0 + 24, 50, 24, "Tempo:" );
fi->align( FL_ALIGN_TOP );
fi->when( FL_WHEN_ENTER_KEY );
fi->callback( &Tempo_Point_Editor::enter_cb, (void*)this );

char pat[10];
snprintf( pat, sizeof( pat ), "%.1f", *tempo );

fi->value( pat );

end();

show();

while ( shown() )
Fl::wait();
}

static void
enter_cb ( Fl_Widget *w, void *v )
{
((Tempo_Point_Editor*)v)->enter_cb();
}

void
enter_cb ( void )
{
sscanf( _fi->value(), "%f", _tempo );
_sucess = true;
hide();
}

bool
sucess ( void )
{
return _sucess;
}
};


bool
Tempo_Point::edit ( float *tempo )
{
Tempo_Point_Editor ti( Fl::event_x(), Fl::event_y(), tempo );

return ti.sucess();
}

+ 3
- 1
Timeline/Tempo_Point.H View File

@@ -48,6 +48,8 @@ protected:

public:

static bool edit ( float *tempo );

LOG_CREATE_FUNC( Tempo_Point );

Tempo_Point ( nframes_t when, float bpm );
@@ -69,7 +71,7 @@ public:
float tempo ( void ) const
{ return _tempo; }
void tempo ( float v )
{ _tempo = v; }
{ if ( v != _tempo ) { _tempo = v; _make_label(); timeline->redraw(); } }

int handle ( int m );
};

+ 29
- 0
Timeline/Tempo_Sequence.H View File

@@ -69,4 +69,33 @@ public:
sort();
}

int
handle ( int m )
{
int r = Sequence::handle( m );

if ( r )
return r;

switch ( m )
{
case FL_PUSH:
if ( Fl::event_button1() )
{
static float t = 120.0f;

if ( Tempo_Point::edit( &t ) )
{
add( new Tempo_Point( timeline->x_to_offset( Fl::event_x() ), t ) );

timeline->redraw();
}
return 0;
}
default:
return 0;

}

}
};

Loading…
Cancel
Save