Replace scrollbar with scalebar and ditch zoom slider.
This commit is contained in:
parent
71a4692f2d
commit
ef305848c9
|
@ -0,0 +1,70 @@
|
||||||
|
|
||||||
|
/*******************************************************************************/
|
||||||
|
/* 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
|
||||||
|
|
||||||
|
#include <FL/Fl.H>
|
||||||
|
#include <FL/Fl_Scrollbar.H>
|
||||||
|
#include <FL/Fl_Slider.H>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
class Scalebar : public Fl_Scrollbar
|
||||||
|
{
|
||||||
|
double _zoom;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Scalebar ( int X, int Y, int W, int H ) : Fl_Scrollbar ( X, Y, W, H )
|
||||||
|
{
|
||||||
|
_zoom = 1.0f;
|
||||||
|
|
||||||
|
step( 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
double zoom ( void ) const { return _zoom; }
|
||||||
|
double value ( void ) const { return Fl_Slider::value(); }
|
||||||
|
|
||||||
|
int
|
||||||
|
handle ( int m )
|
||||||
|
{
|
||||||
|
switch ( m )
|
||||||
|
{
|
||||||
|
case FL_MOUSEWHEEL:
|
||||||
|
{
|
||||||
|
int d = Fl::event_dy();
|
||||||
|
|
||||||
|
if ( d < 0 )
|
||||||
|
while ( d++ )
|
||||||
|
_zoom /= 2;
|
||||||
|
else
|
||||||
|
while ( d-- )
|
||||||
|
_zoom *= 2;
|
||||||
|
|
||||||
|
do_callback();
|
||||||
|
|
||||||
|
slider_size( w() / maximum() );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return Fl_Scrollbar::handle( m );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
|
@ -76,6 +76,8 @@ struct Timeline {
|
||||||
|
|
||||||
nframes_t xoffset;
|
nframes_t xoffset;
|
||||||
|
|
||||||
|
nframes_t length;
|
||||||
|
|
||||||
int _beats_per_bar;
|
int _beats_per_bar;
|
||||||
float _beats_per_minute;
|
float _beats_per_minute;
|
||||||
|
|
||||||
|
|
54
main.C
54
main.C
|
@ -22,11 +22,14 @@
|
||||||
#include <FL/Fl_Window.H>
|
#include <FL/Fl_Window.H>
|
||||||
#include <FL/Fl_Double_Window.H>
|
#include <FL/Fl_Double_Window.H>
|
||||||
#include <FL/Fl_Scroll.H>
|
#include <FL/Fl_Scroll.H>
|
||||||
#include <FL/Fl_Scrollbar.H>
|
// #include <FL/Fl_Scrollbar.H>
|
||||||
#include <FL/Fl_Pack.H>
|
#include <FL/Fl_Pack.H>
|
||||||
#include <FL/Fl_Group.H>
|
#include <FL/Fl_Group.H>
|
||||||
#include <FL/Fl_Slider.H>
|
#include <FL/Fl_Slider.H>
|
||||||
|
|
||||||
|
|
||||||
|
#include "Scalebar.H"
|
||||||
|
|
||||||
// #include "Waveform.H"
|
// #include "Waveform.H"
|
||||||
#include "Region.H"
|
#include "Region.H"
|
||||||
|
|
||||||
|
@ -45,34 +48,22 @@
|
||||||
|
|
||||||
Timeline timeline;
|
Timeline timeline;
|
||||||
|
|
||||||
void
|
|
||||||
cb_zoom ( Fl_Widget *w, void *v )
|
|
||||||
{
|
|
||||||
timeline.fpp = ((Fl_Slider*)w)->value();
|
|
||||||
|
|
||||||
|
|
||||||
/* for ( int i = timeline.tracks->children(); i-- ; ) */
|
|
||||||
/* { */
|
|
||||||
/* Fl_Group *track = (Fl_Group*)timeline.tracks->child( i ); */
|
|
||||||
/* for ( int j = track->children(); j-- ; ) */
|
|
||||||
/* ((Region*)(track->child( j )))->resize(); */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
|
|
||||||
timeline.scroll->redraw();
|
|
||||||
|
|
||||||
if ( timeline.fpp < FRAMES_PER_PEAK )
|
|
||||||
w->selection_color( FL_RED );
|
|
||||||
else
|
|
||||||
w->selection_color( FL_GRAY );
|
|
||||||
|
|
||||||
printf( "%f\n", timeline.fpp );
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
cb_scroll ( Fl_Widget *w, void *v )
|
cb_scroll ( Fl_Widget *w, void *v )
|
||||||
{
|
{
|
||||||
timeline.xoffset = timeline.x_to_ts( ((Fl_Slider*)w)->value() );
|
Scalebar *sb = (Scalebar*)w;
|
||||||
|
|
||||||
|
timeline.fpp = sb->zoom() * 256;
|
||||||
|
timeline.fpp = max( min( timeline.fpp, 4096.0f ), (float)2 );
|
||||||
|
|
||||||
|
int maxx = timeline.ts_to_x( timeline.length );
|
||||||
|
sb->range( 0, maxx );
|
||||||
|
// sb->value( sb->value(), maxx
|
||||||
|
// sb->slider_size( sb->w() / maxx );
|
||||||
|
// ((Fl_Scrollbar*)sb)->value( sb->value(), 60, 10, maxx );
|
||||||
|
|
||||||
|
timeline.xoffset = timeline.x_to_ts( sb->value() );
|
||||||
// timeline.tracks->redraw();
|
// timeline.tracks->redraw();
|
||||||
timeline.scroll->redraw();
|
timeline.scroll->redraw();
|
||||||
|
|
||||||
|
@ -101,10 +92,11 @@ main ( int argc, char **argv )
|
||||||
|
|
||||||
Fl_Double_Window *main_window = new Fl_Double_Window( 0, 0, 800, 600 );
|
Fl_Double_Window *main_window = new Fl_Double_Window( 0, 0, 800, 600 );
|
||||||
|
|
||||||
timeline.scroll = new Fl_Scroll( 0, 24, 800, 600 - (24 * 2) );
|
timeline.scroll = new Fl_Scroll( 0, 0, 800, 600 - 24 );
|
||||||
timeline.scroll->type( Fl_Scroll::VERTICAL );
|
timeline.scroll->type( Fl_Scroll::VERTICAL );
|
||||||
timeline.fpp = 256;
|
timeline.fpp = 256;
|
||||||
timeline._beats_per_minute = 120;
|
timeline._beats_per_minute = 120;
|
||||||
|
timeline.length = 48000 * 60 * 2;
|
||||||
|
|
||||||
|
|
||||||
timeline.beats_per_minute( 0, 120 );
|
timeline.beats_per_minute( 0, 120 );
|
||||||
|
@ -181,17 +173,9 @@ main ( int argc, char **argv )
|
||||||
timeline.tracks->end();
|
timeline.tracks->end();
|
||||||
timeline.scroll->end();
|
timeline.scroll->end();
|
||||||
|
|
||||||
Fl_Slider *zoom_slider = new Fl_Slider( 0, 0, 800, 24 );
|
timeline.scrollbar = new Scalebar( 0, 600 - 24, 800, 24 );
|
||||||
zoom_slider->type( FL_HOR_SLIDER );
|
|
||||||
zoom_slider->callback( cb_zoom, 0 );
|
|
||||||
zoom_slider->range( 2, 4096 );
|
|
||||||
zoom_slider->step( 1 );
|
|
||||||
zoom_slider->value( 256 );
|
|
||||||
|
|
||||||
timeline.scrollbar = new Fl_Scrollbar( 0, 600 - 24, 800, 24 );
|
|
||||||
timeline.scrollbar->range( 0, 48000 * 2 );
|
timeline.scrollbar->range( 0, 48000 * 2 );
|
||||||
timeline.scrollbar->type( 1 );
|
timeline.scrollbar->type( 1 );
|
||||||
timeline.scrollbar->step( 1 );
|
|
||||||
timeline.scrollbar->callback( cb_scroll, 0 );
|
timeline.scrollbar->callback( cb_scroll, 0 );
|
||||||
|
|
||||||
main_window->end();
|
main_window->end();
|
||||||
|
|
Loading…
Reference in New Issue