Mixer: Fix receiving of direct OSC messages.
[nondaw.git] / FL / Fl_Value_SliderX.C
blobf7583fee7177dfa8c1ff0410c41037aa125a1d88
2 /*******************************************************************************/
3 /* Copyright (C) 2012 Jonathan Moore Liles                                     */
4 /*                                                                             */
5 /* This program is free software; you can redistribute it and/or modify it     */
6 /* under the terms of the GNU General Public License as published by the       */
7 /* Free Software Foundation; either version 2 of the License, or (at your      */
8 /* option) any later version.                                                  */
9 /*                                                                             */
10 /* This program is distributed in the hope that it will be useful, but WITHOUT */
11 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       */
12 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for   */
13 /* more details.                                                               */
14 /*                                                                             */
15 /* You should have received a copy of the GNU General Public License along     */
16 /* with This program; see the file COPYING.  If not,write to the Free Software */
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
18 /*******************************************************************************/
21 #include "Fl_Value_SliderX.H"
23 int Fl_Value_SliderX::_default_style = NICE_SLIDER;
25 void
26 Fl_Value_SliderX::draw ( void )
28     switch ( _default_style )
29     {
30         case NICE_SLIDER:
31         {
32             if ( FL_HORIZONTAL == _type )
33                 Fl_Value_Slider::type( FL_HOR_NICE_SLIDER );
34             else
35                 Fl_Value_Slider::type( FL_VERT_NICE_SLIDER );
36             break;
37         }
38         case FILL_SLIDER:
39         {
40             if ( FL_HORIZONTAL == _type )
41                 Fl_Value_Slider::type( FL_HOR_FILL_SLIDER );
42             else
43                 Fl_Value_Slider::type( FL_VERT_FILL_SLIDER );
44             break;
45         }
46         case SIMPLE_SLIDER:
47         {
48             if ( FL_HORIZONTAL == _type )
49                 Fl_Value_Slider::type( FL_HOR_SLIDER );
50             else
51                 Fl_Value_Slider::type( FL_VERT_SLIDER );
52             break;
53         }
54     }
56     Fl_Value_Slider::draw();
60 int
61 Fl_Value_SliderX::handle ( int m )
64     /* Fl_Value_Slider and friends should really handle mousewheel, but they don't in FTLK1 */
67     switch ( m )
68     {
69         case FL_MOUSEWHEEL:
70         {
71             if ( this != Fl::belowmouse() )
72                 return 0;
74             int steps = 16;
76             if ( Fl::event_ctrl() )
77                 steps = 128;
79             float step = fabs( maximum() - minimum() ) / (float)steps;
81             float d = ((float)Fl::event_dy()) * step;
83             double v = value() + d;
85             if ( maximum() > minimum() )
86             {
87                 if ( v < minimum() )
88                     v = minimum();
89                 else if ( v > maximum() )
90                     v = maximum();
91             }
92             else
93             {
94                 if ( v > minimum() )
95                     v = minimum();
96                 else if ( v < maximum() )
97                     v = maximum();
98             }
100             value( v );
101             do_callback();
103             return 1;
104         }
105     }
107     return Fl_Value_Slider::handle( m );