Browse Source

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.
tags/non-daw-v1.1.0
Jonathan Moore Liles 14 years ago
parent
commit
65d4293665
5 changed files with 121 additions and 14 deletions
  1. +24
    -6
      FL/Fl_Arc_Dial.C
  2. +88
    -0
      FL/Fl_Value_SliderX.H
  3. +2
    -4
      Mixer/Controller_Module.C
  4. +2
    -2
      Mixer/Controller_Module.H
  5. +5
    -2
      Mixer/Module_Parameter_Editor.C

+ 24
- 6
FL/Fl_Arc_Dial.C View File

@@ -24,6 +24,7 @@
#include <Fl/Fl.H>
#include <string.h>
#include <stdio.h>
#include <math.h>

int
Fl_Arc_Dial::handle ( int m )
@@ -37,14 +38,31 @@ Fl_Arc_Dial::handle ( int m )
if ( this != Fl::belowmouse() )
return 0;

int d = Fl::event_dy();
int steps = 16;

double v = increment( value(), d );
if ( Fl::event_ctrl() )
steps = 128;

if ( v < minimum() )
v = minimum();
else if ( v > maximum() )
v = maximum();
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();


+ 88
- 0
FL/Fl_Value_SliderX.H View File

@@ -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 );
}
};

+ 2
- 4
Mixer/Controller_Module.C View File

@@ -20,7 +20,7 @@
#include "Controller_Module.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_Counter.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 )
{
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;
w = o;

@@ -160,7 +160,6 @@ Controller_Module::connect_to ( Port *p )
o->selection_color((Fl_Color)1);
o->minimum(1.5);
o->maximum(0);
o->step(0.01);
o->value(1);
o->textsize(14);

@@ -192,7 +191,6 @@ Controller_Module::connect_to ( Port *p )
o->color( fl_darker( fl_darker( FL_GRAY ) ) );
o->selection_color( FL_WHITE );
o->value( p->control_value() );

}

}


+ 2
- 2
Mixer/Controller_Module.H View File

@@ -47,8 +47,8 @@ public:

const char *name ( void ) const { return "Controller"; }

int can_support_inputs ( int n ) { return 0; }
bool configure_inputs ( int n ) { return false; }
int can_support_inputs ( int ) { return 0; }
bool configure_inputs ( int ) { return false; }

void pad ( bool v ) { _pad = v; }



+ 5
- 2
Mixer/Module_Parameter_Editor.C View File

@@ -19,7 +19,7 @@

#include <FL/fl_draw.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_Counter.H>
#include "FL/Fl_Arc_Dial.H"
@@ -35,6 +35,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <util/debug.h>
#include <math.h>


@@ -172,10 +173,11 @@ Module_Parameter_Editor::make_controls ( void )
o->selection_color( FL_WHITE );
o->value( p->control_value() );

// o->step( fabs( ( o->maximum() - o->minimum() ) ) / 32.0f );
}
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;

if ( mode_choice->value() == 1 )
@@ -198,6 +200,7 @@ Module_Parameter_Editor::make_controls ( void )
o->minimum( p->hints.maximum );
}

// o->step( fabs( ( o->maximum() - o->minimum() ) ) / 32.0f );
o->slider( FL_THIN_UP_BOX );
o->color( fl_darker( fl_darker( FL_GRAY ) ) );
o->selection_color( FL_WHITE );


Loading…
Cancel
Save