Mixer: Improve the mousewheel behavior of Fl_Arc_Dial and add Fl_Value_SliderX.
You can now hold down the ctrl key for more precision.
This commit is contained in:
parent
9f751ed858
commit
65d4293665
|
@ -24,6 +24,7 @@
|
||||||
#include <Fl/Fl.H>
|
#include <Fl/Fl.H>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
Fl_Arc_Dial::handle ( int m )
|
Fl_Arc_Dial::handle ( int m )
|
||||||
|
@ -37,14 +38,31 @@ Fl_Arc_Dial::handle ( int m )
|
||||||
if ( this != Fl::belowmouse() )
|
if ( this != Fl::belowmouse() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int d = Fl::event_dy();
|
int steps = 16;
|
||||||
|
|
||||||
double v = increment( value(), d );
|
if ( Fl::event_ctrl() )
|
||||||
|
steps = 128;
|
||||||
|
|
||||||
if ( v < minimum() )
|
float step = fabs( maximum() - minimum() ) / (float)steps;
|
||||||
v = minimum();
|
|
||||||
else if ( v > maximum() )
|
float d = ((float)Fl::event_dy()) * step;
|
||||||
v = maximum();
|
|
||||||
|
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 );
|
value( v );
|
||||||
do_callback();
|
do_callback();
|
||||||
|
|
|
@ -0,0 +1,88 @@
|
||||||
|
|
||||||
|
/*******************************************************************************/
|
||||||
|
/* Copyright (C) 2009 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. */
|
||||||
|
/*******************************************************************************/
|
||||||
|
|
||||||
|
/* just like an Fl_Value_Slider, except that it responds to mousewheel events */
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <FL/Fl_Value_Slider.H>
|
||||||
|
#include <FL/Fl.H>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
class Fl_Value_SliderX : public Fl_Value_Slider
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Fl_Value_SliderX ( int X, int Y, int W, int H, const char *L = 0 )
|
||||||
|
: Fl_Value_Slider( X, Y, W, H, L )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
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 );
|
||||||
|
}
|
||||||
|
};
|
|
@ -20,7 +20,7 @@
|
||||||
#include "Controller_Module.H"
|
#include "Controller_Module.H"
|
||||||
|
|
||||||
#include <FL/Fl.H>
|
#include <FL/Fl.H>
|
||||||
#include <FL/Fl_Value_Slider.H>
|
#include "FL/Fl_Value_SliderX.H"
|
||||||
#include <FL/Fl_Box.H>
|
#include <FL/Fl_Box.H>
|
||||||
#include <FL/Fl_Counter.H>
|
#include <FL/Fl_Counter.H>
|
||||||
#include "FL/Fl_Arc_Dial.H"
|
#include "FL/Fl_Arc_Dial.H"
|
||||||
|
@ -151,7 +151,7 @@ Controller_Module::connect_to ( Port *p )
|
||||||
}
|
}
|
||||||
else if ( p->hints.type == Module::Port::Hints::LOGARITHMIC )
|
else if ( p->hints.type == Module::Port::Hints::LOGARITHMIC )
|
||||||
{
|
{
|
||||||
Fl_Value_Slider *o = new Fl_Value_Slider(0, 0, 30, 250, p->name() );
|
Fl_Value_SliderX *o = new Fl_Value_SliderX(0, 0, 30, 250, p->name() );
|
||||||
control = o;
|
control = o;
|
||||||
w = o;
|
w = o;
|
||||||
|
|
||||||
|
@ -160,7 +160,6 @@ Controller_Module::connect_to ( Port *p )
|
||||||
o->selection_color((Fl_Color)1);
|
o->selection_color((Fl_Color)1);
|
||||||
o->minimum(1.5);
|
o->minimum(1.5);
|
||||||
o->maximum(0);
|
o->maximum(0);
|
||||||
o->step(0.01);
|
|
||||||
o->value(1);
|
o->value(1);
|
||||||
o->textsize(14);
|
o->textsize(14);
|
||||||
|
|
||||||
|
@ -192,7 +191,6 @@ Controller_Module::connect_to ( Port *p )
|
||||||
o->color( fl_darker( fl_darker( FL_GRAY ) ) );
|
o->color( fl_darker( fl_darker( FL_GRAY ) ) );
|
||||||
o->selection_color( FL_WHITE );
|
o->selection_color( FL_WHITE );
|
||||||
o->value( p->control_value() );
|
o->value( p->control_value() );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,8 @@ public:
|
||||||
|
|
||||||
const char *name ( void ) const { return "Controller"; }
|
const char *name ( void ) const { return "Controller"; }
|
||||||
|
|
||||||
int can_support_inputs ( int n ) { return 0; }
|
int can_support_inputs ( int ) { return 0; }
|
||||||
bool configure_inputs ( int n ) { return false; }
|
bool configure_inputs ( int ) { return false; }
|
||||||
|
|
||||||
void pad ( bool v ) { _pad = v; }
|
void pad ( bool v ) { _pad = v; }
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include <FL/fl_draw.H>
|
#include <FL/fl_draw.H>
|
||||||
#include <FL/Fl_Pack.H>
|
#include <FL/Fl_Pack.H>
|
||||||
#include <FL/Fl_Value_Slider.H>
|
#include "FL/Fl_Value_SliderX.H"
|
||||||
#include <FL/Fl_Box.H>
|
#include <FL/Fl_Box.H>
|
||||||
#include <FL/Fl_Counter.H>
|
#include <FL/Fl_Counter.H>
|
||||||
#include "FL/Fl_Arc_Dial.H"
|
#include "FL/Fl_Arc_Dial.H"
|
||||||
|
@ -35,6 +35,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <util/debug.h>
|
#include <util/debug.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -172,10 +173,11 @@ Module_Parameter_Editor::make_controls ( void )
|
||||||
o->selection_color( FL_WHITE );
|
o->selection_color( FL_WHITE );
|
||||||
o->value( p->control_value() );
|
o->value( p->control_value() );
|
||||||
|
|
||||||
|
// o->step( fabs( ( o->maximum() - o->minimum() ) ) / 32.0f );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Fl_Value_Slider *o = new Fl_Value_Slider( 0, 0, 120, 24, p->name() );
|
Fl_Value_SliderX *o = new Fl_Value_SliderX( 0, 0, 120, 24, p->name() );
|
||||||
w = o;
|
w = o;
|
||||||
|
|
||||||
if ( mode_choice->value() == 1 )
|
if ( mode_choice->value() == 1 )
|
||||||
|
@ -198,6 +200,7 @@ Module_Parameter_Editor::make_controls ( void )
|
||||||
o->minimum( p->hints.maximum );
|
o->minimum( p->hints.maximum );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// o->step( fabs( ( o->maximum() - o->minimum() ) ) / 32.0f );
|
||||||
o->slider( FL_THIN_UP_BOX );
|
o->slider( FL_THIN_UP_BOX );
|
||||||
o->color( fl_darker( fl_darker( FL_GRAY ) ) );
|
o->color( fl_darker( fl_darker( FL_GRAY ) ) );
|
||||||
o->selection_color( FL_WHITE );
|
o->selection_color( FL_WHITE );
|
||||||
|
|
Loading…
Reference in New Issue