Mixer: Make slider types optional too.

This commit is contained in:
Jonathan Moore Liles 2012-03-02 18:02:23 -08:00
parent ccc93d2388
commit df0a9c4267
7 changed files with 173 additions and 69 deletions

View File

@ -27,7 +27,7 @@
#include <math.h>
#include <algorithm>
int Fl_Arc_Dial::_default_knob_style = Fl_Arc_Dial::PLASTIC_DIAL;
int Fl_Arc_Dial::_default_style = Fl_Arc_Dial::PLASTIC_DIAL;
/** This simple box is suitable for use with knob-type widgets. It
* comprises a border with shadow, and a cap with glare-lines akin

View File

@ -25,7 +25,7 @@
class Fl_Arc_Dial : public Fl_Dial
{
static int _default_knob_style;
static int _default_style;
int _scaleticks;
@ -48,7 +48,7 @@ public:
type ( void ) const
{
if ( Fl_Dial::type() == DEFAULT )
return Fl_Arc_Dial::_default_knob_style;
return Fl_Arc_Dial::_default_style;
else
return Fl_Dial::type();
}
@ -58,7 +58,7 @@ public:
Fl_Dial::type( n );
}
static void default_knob_style ( int n ) { Fl_Arc_Dial::_default_knob_style = n; }
static void default_style ( int n ) { Fl_Arc_Dial::_default_style = n; }
enum
{

108
FL/Fl_Value_SliderX.C Normal file
View File

@ -0,0 +1,108 @@
/*******************************************************************************/
/* Copyright (C) 2012 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 "Fl_Value_SliderX.H"
int Fl_Value_SliderX::_default_style = NICE_SLIDER;
void
Fl_Value_SliderX::draw ( void )
{
switch ( _default_style )
{
case NICE_SLIDER:
{
if ( FL_HORIZONTAL == _type )
Fl_Value_Slider::type( FL_HOR_NICE_SLIDER );
else
Fl_Value_Slider::type( FL_VERT_NICE_SLIDER );
break;
}
case FILL_SLIDER:
{
if ( FL_HORIZONTAL == _type )
Fl_Value_Slider::type( FL_HOR_FILL_SLIDER );
else
Fl_Value_Slider::type( FL_VERT_FILL_SLIDER );
break;
}
case SIMPLE_SLIDER:
{
if ( FL_HORIZONTAL == _type )
Fl_Value_Slider::type( FL_HOR_SLIDER );
else
Fl_Value_Slider::type( FL_VERT_SLIDER );
break;
}
}
Fl_Value_Slider::draw();
}
int
Fl_Value_SliderX::handle ( int m )
{
/* Fl_Value_Slider and friends should really handle mousewheel, but they don't in FTLK1 */
switch ( m )
{
case FL_MOUSEWHEEL:
{
if ( this != Fl::belowmouse() )
return 0;
int steps = 16;
if ( Fl::event_ctrl() )
steps = 128;
float step = fabs( maximum() - minimum() ) / (float)steps;
float d = ((float)Fl::event_dy()) * step;
double v = value() + d;
if ( maximum() > minimum() )
{
if ( v < minimum() )
v = minimum();
else if ( v > maximum() )
v = maximum();
}
else
{
if ( v > minimum() )
v = minimum();
else if ( v < maximum() )
v = maximum();
}
value( v );
do_callback();
return 1;
}
}
return Fl_Value_Slider::handle( m );
}

View File

@ -27,9 +27,25 @@
class Fl_Value_SliderX : public Fl_Value_Slider
{
static int _default_style;
int _type;
public:
enum
{
NICE_SLIDER,
SIMPLE_SLIDER,
FILL_SLIDER
};
static void default_style ( int n ) { Fl_Value_SliderX::_default_style = n; }
int type ( void ) const { return _type; }
void type ( int v ) { _type = v; }
Fl_Value_SliderX ( int X, int Y, int W, int H, const char *L = 0 )
: Fl_Value_Slider( X, Y, W, H, L )
{
@ -37,52 +53,6 @@ public:
virtual ~Fl_Value_SliderX() { }
virtual int handle ( int m )
{
/* Fl_Value_Slider and friends should really handle mousewheel, but they don't in FTLK1 */
switch ( m )
{
case FL_MOUSEWHEEL:
{
if ( this != Fl::belowmouse() )
return 0;
int steps = 16;
if ( Fl::event_ctrl() )
steps = 128;
float step = fabs( maximum() - minimum() ) / (float)steps;
float d = ((float)Fl::event_dy()) * step;
double v = value() + d;
if ( maximum() > minimum() )
{
if ( v < minimum() )
v = minimum();
else if ( v > maximum() )
v = maximum();
}
else
{
if ( v > minimum() )
v = minimum();
else if ( v < maximum() )
v = maximum();
}
value( v );
do_callback();
return 1;
}
}
return Fl_Value_Slider::handle( m );
}
virtual int handle ( int m );
virtual void draw ( void );
};

View File

@ -43,6 +43,7 @@
#include <unistd.h>
#include <sys/types.h>
#include "FL/Fl_Value_SliderX.H"
#include "FL/color_scheme.H"
#include "OSC/Endpoint.H"
#include <lo/lo.h>
@ -156,6 +157,18 @@ Mixer::sm_active ( bool b )
}
}
void
Mixer::redraw_windows ( void )
{
window()->redraw();
if ( Fl::first_window() )
for ( Fl_Window *w = Fl::first_window(); ( w = Fl::next_window( w ) ); )
w->redraw();
}
void Mixer::cb_menu(Fl_Widget* o) {
Fl_Menu_Bar *menu = (Fl_Menu_Bar*)o;
@ -284,24 +297,33 @@ void Mixer::cb_menu(Fl_Widget* o) {
}
else if (! strcmp( picked, "&Options/&Display/&Knobs/&Burnished") )
{
Fl_Arc_Dial::default_knob_style( Fl_Arc_Dial::BURNISHED_DIAL );
if ( Fl::first_window() )
for ( Fl_Window *w = Fl::first_window(); ( w = Fl::next_window( w ) ); )
w->redraw();
Fl_Arc_Dial::default_style( Fl_Arc_Dial::BURNISHED_DIAL );
redraw_windows();
}
else if (! strcmp( picked, "&Options/&Display/&Knobs/&Arc") )
{
Fl_Arc_Dial::default_knob_style( Fl_Arc_Dial::ARC_DIAL );
if ( Fl::first_window() )
for ( Fl_Window *w = Fl::first_window(); ( w = Fl::next_window( w ) ); )
w->redraw();
Fl_Arc_Dial::default_style( Fl_Arc_Dial::ARC_DIAL );
redraw_windows();
}
else if (! strcmp( picked, "&Options/&Display/&Knobs/&Plastic") )
{
Fl_Arc_Dial::default_knob_style( Fl_Arc_Dial::PLASTIC_DIAL );
if ( Fl::first_window() )
for ( Fl_Window *w = Fl::first_window(); ( w = Fl::next_window( w ) ); )
w->redraw();
Fl_Arc_Dial::default_style( Fl_Arc_Dial::PLASTIC_DIAL );
redraw_windows();
}
else if (! strcmp( picked, "&Options/&Display/&Sliders/&Nice") )
{
Fl_Value_SliderX::default_style( Fl_Value_SliderX::NICE_SLIDER );
redraw_windows();
}
else if (! strcmp( picked, "&Options/&Display/&Sliders/&Fill") )
{
Fl_Value_SliderX::default_style( Fl_Value_SliderX::FILL_SLIDER );
redraw_windows();
}
else if (! strcmp( picked, "&Options/&Display/&Sliders/&Simple") )
{
Fl_Value_SliderX::default_style( Fl_Value_SliderX::SIMPLE_SLIDER );
redraw_windows();
}
else if ( ! strcmp( picked, "&Help/&About" ) )
{
@ -374,6 +396,9 @@ Mixer::Mixer ( int X, int Y, int W, int H, const char *L ) :
o->add( "_&Options/&Display/&Knobs/&Arc", 0, 0, 0, FL_MENU_RADIO );
o->add( "_&Options/&Display/&Knobs/&Burnished", 0, 0, 0, FL_MENU_RADIO );
o->add( "_&Options/&Display/&Knobs/&Plastic", 0, 0, 0, FL_MENU_RADIO | FL_MENU_VALUE );
o->add( "_&Options/&Display/&Sliders/&Nice", 0, 0, 0, FL_MENU_RADIO | FL_MENU_VALUE );
o->add( "_&Options/&Display/&Sliders/&Fill", 0, 0, 0, FL_MENU_RADIO );
o->add( "_&Options/&Display/&Sliders/&Simple", 0, 0, 0, FL_MENU_RADIO );
o->add( "_&Options/&Display/&Colors/&System", 0, 0, 0, FL_MENU_RADIO );
o->add( "&Help/&Manual" );
o->add( "&Help/&About" );

View File

@ -66,6 +66,8 @@ private:
void save_options ( void );
void update_menu ( void );
void redraw_windows ( void );
protected:
int handle ( int m );

View File

@ -217,8 +217,7 @@ Module_Parameter_Editor::make_controls ( void )
if ( mode_choice->value() == 1 )
{
// o->type( FL_HORIZONTAL );
o->type( FL_HOR_NICE_SLIDER );
o->type( FL_HORIZONTAL );
o->size( 120, 36 );
if ( p->hints.ranged )
@ -229,8 +228,7 @@ Module_Parameter_Editor::make_controls ( void )
}
else
{
// o->type( FL_VERTICAL );
o->type(FL_VERT_NICE_SLIDER);
o->type( FL_VERTICAL );
o->size( 36, 120 );
/* have to reverse the meaning of these to get the
@ -240,8 +238,9 @@ Module_Parameter_Editor::make_controls ( void )
}
o->slider( FL_UP_BOX );
// o->color( FL_BACKGROUND2_COLOR );
o->color( FL_BACKGROUND2_COLOR );
o->selection_color( FL_GRAY );
o->selection_color( FL_WHITE );
o->value( p->control_value() );
}