/*******************************************************************************/ /* 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 #include #include #include "Waveform.H" #include extern Fl_Color velocity_colors[]; Waveform::Waveform ( int X, int Y, int W, int H, const char *L=0 ) : Fl_Widget( X, Y, W, H, L ) { } #if 0 void Waveform::buble_draw ( void ) { int inc = 10; for ( tick_t x = 0; x < w() && x < _end; ++x ) { float v1 = _peaks[ _start + (x * inc) ] / (float)127; int lh1 = (float)(h() / 2) * fabs( v1 ); int ly1 = (h() / 2) - (lh1 / 2); fl_color( selection_color() ); fl_color( velocity_colors[ 127 - (int)(127 * fabs( v1 )) ] ); fl_pie( x, y() + ly1, inc, lh1, 0, 360 ); fl_color( fl_darker( selection_color() ) ); fl_arc( x, y() + ly1, inc, lh1, 0, 360 ); } } #endif int Waveform::handle ( int m ) { if ( m == FL_PUSH ) { switch ( Fl::event_button() ) { case 1: _start += 100; _end += 100; redraw(); break; case 3: _start -= 100; _end -= 100; redraw(); break; default: return 0; } return 1; } return 0; } void Waveform::draw ( void ) { fl_push_clip( x(), y(), w(), h() ); draw_box( FL_PLASTIC_UP_BOX, x(), y(), w(), h(), color() ); fl_push_matrix(); fl_color( selection_color() ); int j; float scale = 1; j = 0; for ( tick_t x = 0; x < w() && x < _end; ++x ) { float lo = _peaks[ _start + j++ ] * scale; float hi = _peaks[ _start + j++ ] * scale; int mid = y() + (h() / 2); int rx = this->x() + x; fl_line( rx, mid + (h() * lo), rx, mid + (h() * hi) ); } fl_color( fl_darker( fl_darker( selection_color() ) ) ); fl_begin_line(); j = 0; for ( tick_t x = 0; x < w() && x < _end; ++x ) { float v = _peaks[ _start + j ] * scale; j += 2; fl_vertex( this->x() + x, y() + (h() / 2) + ((float)h() * v )); } fl_end_line(); fl_begin_line(); j = 1; for ( tick_t x = 0; x < w() && x < _end; ++x ) { float v = _peaks[ _start + j ] * scale; j += 2; fl_vertex( this->x() + x, y() + (h() / 2) + ((float)h() * v )); } fl_end_line(); fl_pop_matrix(); fl_pop_clip(); } #if 0 void Waveform::draw ( void ) { fl_push_clip( x(), y(), w(), h() ); draw_box( FL_PLASTIC_UP_BOX, x(), y(), w(), h(), color() ); fl_push_matrix(); int inc = 1; int j = 0; for ( tick_t x = 0; x < w() && x < _end; ++x ) { float lo = _peaks[ _start + j++ ]; float hi = _peaks[ _start + j++ ]; int mid = y() + (h() / 2); int rx = this->x() + x; fl_color( selection_color() ); fl_line( rx, mid + (h() * lo), rx, mid + (h() * hi) ); } fl_pop_matrix(); } #endif