~ubuntu-branches/ubuntu/precise/plib/precise

« back to all changes in this revision

Viewing changes to src/pui/puBiSlider.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Philipp Frauenfelder
  • Date: 2004-08-26 23:31:16 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040826233116-vqusvk3ytn6lq3rl
Tags: 1.8.3-2
* Corrected C++ syntax in ssgAux/ssgaSky.h. Thanks to
  neuro.harald AT surfeu.at for the patch. Closes: #260355
* Build-Depends on libx11-dev, libxmu-dev instead of xlibs-dev
* Removed build depends on g++, libc6.
* Changed (build) depends on libgl-dev to xlibmesa-gl-dev | libgl-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
     PLIB - A Suite of Portable Game Libraries
3
 
     Copyright (C) 2001  Steve Baker
4
 
 
 
3
     Copyright (C) 1998,2002  Steve Baker
 
4
 
5
5
     This library is free software; you can redistribute it and/or
6
6
     modify it under the terms of the GNU Library General Public
7
7
     License as published by the Free Software Foundation; either
8
8
     version 2 of the License, or (at your option) any later version.
9
 
 
 
9
 
10
10
     This library is distributed in the hope that it will be useful,
11
11
     but WITHOUT ANY WARRANTY; without even the implied warranty of
12
12
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
13
     Library General Public License for more details.
14
 
 
 
14
 
15
15
     You should have received a copy of the GNU Library General Public
16
 
     License along with this library; if not, write to the Free
 
16
     License along with this library; if not, write to the Free Software
17
17
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18
 
 
 
18
 
19
19
     For further information visit http://plib.sourceforge.net
20
20
 
21
 
     $Id: puBiSlider.cxx,v 1.11 2001/06/19 02:42:18 sjbaker Exp $
 
21
     $Id: puBiSlider.cxx,v 1.22 2002/09/02 06:05:45 sjbaker Exp $
22
22
*/
23
23
 
 
24
 
24
25
#include "puLocal.h"
25
26
 
 
27
UL_RTTI_DEF1(puBiSlider,puSlider)
 
28
 
 
29
 
26
30
void puBiSlider::draw ( int dx, int dy )
27
31
{
28
32
  if ( !visible || ( window != puGetWindow () ) ) return ;
29
33
 
30
34
  // Draw the slider box itself
31
35
 
32
 
  abox . draw ( dx, dy,
33
 
                (style==PUSTYLE_BEVELLED||
34
 
                 style==PUSTYLE_SHADED) ? -PUSTYLE_BOXED : -style,
35
 
                colour, FALSE ) ;
 
36
  if ( ( style == PUSTYLE_BEVELLED ) ||
 
37
       ( style == PUSTYLE_SHADED ) )
 
38
    abox.draw ( dx, dy, -PUSTYLE_BOXED, colour, FALSE, 2 ) ;
 
39
  else
 
40
    abox.draw ( dx, dy, -style, colour, FALSE, border_thickness ) ;
36
41
 
37
42
  if ( r_cb )
38
43
    r_cb ( this, dx, dy, render_data ) ;
48
53
      val = 1.0f ;
49
54
 
50
55
    char str_value[10] ;
51
 
    sprintf (str_value, "%d", getCurrentMax() ) ;
 
56
    sprintf (str_value, "%g", getCurrentMax() ) ;
52
57
 
53
 
    draw_slider_box ( dx, dy, val, str_value ) ;
 
58
    draw_slider_box ( dx, dy, abox, val, str_value ) ;
54
59
 
55
60
    // Draw the current_min slider and label it
56
61
 
59
64
    else
60
65
      val = 0.0f ;
61
66
 
62
 
    sprintf (str_value, "%d", getCurrentMin() ) ;
63
 
 
64
 
    draw_slider_box ( dx, dy, val, str_value ) ;
65
 
 
66
 
    // If greyed out then halve the opacity when drawing the label and legend
67
 
 
68
 
    if ( active )
69
 
      glColor4fv ( colour [ PUCOL_LEGEND ] ) ;
70
 
    else
71
 
      glColor4f ( colour [ PUCOL_LEGEND ][0],
72
 
                  colour [ PUCOL_LEGEND ][1],
73
 
                  colour [ PUCOL_LEGEND ][2],
74
 
                  colour [ PUCOL_LEGEND ][3] / 2.0f ) ; // 50% more transparent
75
 
 
76
 
    int xx = ( abox.max[0] - abox.min[0] - puGetStringWidth(legendFont,legend) ) / 2 ;
77
 
    int yy = ( abox.max[1] - abox.min[1] - puGetStringHeight(legendFont) ) / 2 ;
78
 
 
79
 
    puDrawString ( legendFont, legend,
80
 
                    dx + abox.min[0] + xx,
81
 
                    dy + abox.min[1] + yy ) ;
 
67
    sprintf (str_value, "%g", getCurrentMin() ) ;
 
68
 
 
69
    draw_slider_box ( dx, dy, abox, val, str_value ) ;
 
70
 
 
71
    draw_legend ( dx, dy ) ;
82
72
  }
83
73
 
84
74
  draw_label ( dx, dy ) ;
121
111
 
122
112
    next_value = (next_value < 0.0f) ? 0.0f : (next_value > 1.0) ? 1.0f : next_value ;
123
113
 
124
 
    int new_value = getMinValue() + (int)( next_value * ( getMaxValue() - getMinValue() ) + 0.5 ) ;
 
114
    float new_value = getMinValue() + next_value * ( getMaxValue() - getMinValue() ) ;
125
115
 
126
116
    if ( ( getActiveButton() == 0 ) || ( updown == PU_DOWN ) )  // No currently-active slider, set whichever is closest
127
117
    {
128
118
      if ( (new_value-getCurrentMin()) < (getCurrentMax()-new_value) ) // Closest to current_min
129
119
      {
130
 
        setCurrentMin ( new_value ) ;
 
120
        setCurrentMin ( checkStep(new_value) ) ;
131
121
        setActiveButton ( 1 ) ;
132
122
      }
133
123
      else  // Closest to current_max
134
124
      {
135
 
        setCurrentMax ( new_value ) ;
 
125
        setCurrentMax ( checkStep(new_value) ) ;
136
126
        setActiveButton ( 2 ) ;
137
127
      }
138
128
    }
139
129
    else if ( getActiveButton() == 1 )  // Currently moving current_min
140
130
    {
141
 
      setCurrentMin ( new_value ) ;
 
131
      setCurrentMin ( checkStep(new_value) ) ;
142
132
      if ( getCurrentMax() < getCurrentMin() ) setCurrentMax ( getCurrentMin() ) ;
143
133
    }
144
134
    else if ( getActiveButton() == 2 )  // Currently moving current_max
145
135
    {
146
 
      setCurrentMax ( new_value ) ;
 
136
      setCurrentMax ( checkStep(new_value) ) ;
147
137
      if ( getCurrentMax() < getCurrentMin() ) setCurrentMin ( getCurrentMax() ) ;
148
138
    }
149
139
 
159
149
        }
160
150
        break ;
161
151
 
162
 
      case PUSLIDER_DELTA :
 
152
      case PUSLIDER_DELTA :/* Deprecated! */
163
153
        if ( fabs ( last_cb_value - next_value ) >= cb_delta )
164
154
        {
165
155
          last_cb_value = next_value ;