Changes Fl_Dial to use XForms defaults for angles

-Carl


git-svn-id: file:///fltk/svn/fltk/trunk@397 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Carl E. Thompson 1999-03-10 00:13:52 +00:00
parent 72d1391dbb
commit f7e1ff7742
3 changed files with 16 additions and 14 deletions

View File

@ -34,12 +34,12 @@ and label string. The default type is <TT>FL_NORMAL_DIAL</TT>.
Destroys the valuator.
<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
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
or equal to 0 and less than 360. The progress of the dial always starts at
the minimum angle and progresses clockwise to the maximum angle. Currently,
counter-clockwise progression is not supported (but user code can always
use 1/value()).
or equal to 0 and less than or equal to 360. The progress of the dial always
starts at the minimum angle and progresses clockwise to the maximum angle.
Currently, counter-clockwise progression is not supported (but user code can
always use 1/value()).
<H4><A name=Fl_Dial.type>type(uchar)</A></H4>
Sets the type of the dial to:
<UL>

View File

@ -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).
//
@ -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()));
if (foo) {x--; y--; w+=2; h+=2;}
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_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) {
fl_color(FL_BLACK);
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_rotate(225-angle);
fl_rotate(45-angle);
fl_color(selection_color());
if (type() == FL_LINE_DIAL) {
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;
if (!mx && !my) return 1;
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;
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) {
box(FL_OVAL_BOX);
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 $".
//

View File

@ -133,20 +133,22 @@ fflush(stdout);}
callback {printf("%g \\r",o->value());
fflush(stdout);} selected
xywh {315 280 65 65} color 10 selection_color 1 labelsize 8
code0 {o->angles(180,135);}
code0 {o->angles(0,315);}
}
Fl_Dial {} {
label FL_LINE_DIAL
callback {printf("%g \\r",o->value());
fflush(stdout);}
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 {} {
label FL_FILL_DIAL
callback {printf("%g \\r",o->value());
fflush(stdout);}
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 {} {
label Fl_Roller