Browse Source

Changes Fl_Dial to use XForms defaults for angles

-Carl


git-svn-id: file:///fltk/svn/fltk/trunk@397 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
branch-1.0
Carl E. Thompson 27 years ago
parent
commit
f7e1ff7742
  1. 10
      documentation/Fl_Dial.html
  2. 14
      src/Fl_Dial.cxx
  3. 6
      test/valuators.fl

10
documentation/Fl_Dial.html

@ -34,12 +34,12 @@ and label string. The default type is <TT>FL_NORMAL_DIAL</TT>.
Destroys the valuator. Destroys the valuator.
<H4><A name=Fl_Dial.angles>void Fl_Dial::angles(short a, short b)</A></H4> <H4><A name=Fl_Dial.angles>void Fl_Dial::angles(short a, short b)</A></H4>
Sets the angles used for the minimum and maximum values. By default Sets the angles used for the minimum and maximum values. By default
these are 225 and 135, respectively. (0 degrees is straight up and the these are 0 and 360, respectively. (0 degrees is straight down and the
angles progress clockwise.) The angles specified should be greater than angles progress clockwise.) The angles specified should be greater than
or equal to 0 and less than 360. The progress of the dial always starts at or equal to 0 and less than or equal to 360. The progress of the dial always
the minimum angle and progresses clockwise to the maximum angle. Currently, starts at the minimum angle and progresses clockwise to the maximum angle.
counter-clockwise progression is not supported (but user code can always Currently, counter-clockwise progression is not supported (but user code can
use 1/value()). always use 1/value()).
<H4><A name=Fl_Dial.type>type(uchar)</A></H4> <H4><A name=Fl_Dial.type>type(uchar)</A></H4>
Sets the type of the dial to: Sets the type of the dial to:
<UL> <UL>

14
src/Fl_Dial.cxx

@ -1,5 +1,5 @@
// //
// "$Id: Fl_Dial.cxx,v 1.10 1999/03/09 07:51:10 bill Exp $" // "$Id: Fl_Dial.cxx,v 1.11 1999/03/10 00:13:52 carl Exp $"
// //
// Circular dial widget for the Fast Light Tool Kit (FLTK). // Circular dial widget for the Fast Light Tool Kit (FLTK).
// //
@ -50,9 +50,9 @@ void Fl_Dial::draw(int x, int y, int w, int h) {
int foo = (box() > _FL_ROUND_UP_BOX && Fl::box_dx(box())); int foo = (box() > _FL_ROUND_UP_BOX && Fl::box_dx(box()));
if (foo) {x--; y--; w+=2; h+=2;} if (foo) {x--; y--; w+=2; h+=2;}
fl_color(color()); fl_color(color());
fl_pie(x, y, w-1, h-1, 90-a1, 360+90-angle); fl_pie(x, y, w-1, h-1, 270-a1, 360+270-angle);
fl_color(selection_color()); fl_color(selection_color());
fl_pie(x, y, w-1, h-1, 90-angle, 90-a1); fl_pie(x, y, w-1, h-1, 270-angle, 270-a1);
if (foo) { if (foo) {
fl_color(FL_BLACK); fl_color(FL_BLACK);
fl_arc(x, y, w, h, 0, 360); fl_arc(x, y, w, h, 0, 360);
@ -72,7 +72,7 @@ void Fl_Dial::draw(int x, int y, int w, int h) {
fl_begin_line(); fl_vertex(0, 0); fl_vertex(.5, 0); fl_end_line(); fl_begin_line(); fl_vertex(0, 0); fl_vertex(.5, 0); fl_end_line();
} }
*/ */
fl_rotate(225-angle); fl_rotate(45-angle);
fl_color(selection_color()); fl_color(selection_color());
if (type() == FL_LINE_DIAL) { if (type() == FL_LINE_DIAL) {
fl_begin_polygon(); fl_begin_polygon();
@ -114,7 +114,7 @@ int Fl_Dial::handle(int event, int x, int y, int w, int h) {
int my = Fl::event_y()-y-h/2; int my = Fl::event_y()-y-h/2;
if (!mx && !my) return 1; if (!mx && !my) return 1;
angle = atan2((float)-my, (float)-mx) + M_PI; angle = atan2((float)-my, (float)-mx) + M_PI;
angle = (angle*360) / (2*M_PI) + 90; angle = (angle*360) / (2*M_PI) + 270;
while (angle < oldangle-180) angle += 360; while (angle < oldangle-180) angle += 360;
while (angle > oldangle+180) angle -= 360; while (angle > oldangle+180) angle -= 360;
if (angle <= a1) { if (angle <= a1) {
@ -143,9 +143,9 @@ Fl_Dial::Fl_Dial(int x, int y, int w, int h, const char* l)
: Fl_Valuator(x, y, w, h, l) { : Fl_Valuator(x, y, w, h, l) {
box(FL_OVAL_BOX); box(FL_OVAL_BOX);
selection_color(FL_INACTIVE_COLOR); // was 37 selection_color(FL_INACTIVE_COLOR); // was 37
angles(225,135); angles(0,360);
} }
// //
// End of "$Id: Fl_Dial.cxx,v 1.10 1999/03/09 07:51:10 bill Exp $". // End of "$Id: Fl_Dial.cxx,v 1.11 1999/03/10 00:13:52 carl Exp $".
// //

6
test/valuators.fl

@ -133,20 +133,22 @@ fflush(stdout);}
callback {printf("%g \\r",o->value()); callback {printf("%g \\r",o->value());
fflush(stdout);} selected fflush(stdout);} selected
xywh {315 280 65 65} color 10 selection_color 1 labelsize 8 xywh {315 280 65 65} color 10 selection_color 1 labelsize 8
code0 {o->angles(180,135);} code0 {o->angles(0,315);}
} }
Fl_Dial {} { Fl_Dial {} {
label FL_LINE_DIAL label FL_LINE_DIAL
callback {printf("%g \\r",o->value()); callback {printf("%g \\r",o->value());
fflush(stdout);} fflush(stdout);}
xywh {395 280 65 65} type Line color 10 selection_color 1 labelsize 8 xywh {395 280 65 65} type Line color 10 selection_color 1 labelsize 8
code0 {o->angles(0,360);} code1 {o->value(0.5);}
} }
Fl_Dial {} { Fl_Dial {} {
label FL_FILL_DIAL label FL_FILL_DIAL
callback {printf("%g \\r",o->value()); callback {printf("%g \\r",o->value());
fflush(stdout);} fflush(stdout);}
xywh {475 280 65 65} type Fill color 10 selection_color 1 labelsize 8 xywh {475 280 65 65} type Fill color 10 selection_color 1 labelsize 8
code0 {o->angles(45,315);}
code1 {o->value(1.0);}
} }
Fl_Box {} { Fl_Box {} {
label Fl_Roller label Fl_Roller

Loading…
Cancel
Save