void draw() { fl_push_clip(0, 0, w(), h()); fl_color(FL_DARK3); fl_rectf(0, 0, w(), h()); fl_push_matrix(); // if (args[6]) { fl_translate(w()/2.0f, h()/2.0f); fl_rotate(args[6]); fl_translate(-w()/2.0f, -h()/2.0f); //} fl_arc(args[0],args[1],args[2],args[3],args[4],args[5]); fl_closepath(); fl_arc(120,120,40,40,0,-360); fl_ellipse(20,20,args[2],args[3]); // hardware circle fl_color(FL_WHITE); fl_fill_stroke(FL_RED); fl_pop_matrix(); fl_pop_clip(); }
void Fl_DialX::draw ( void ) { int X,Y,S; { int ox, oy, ww, hh, side; ox = x(); oy = y(); ww = w(); hh = h(); if (ww > hh) { side = hh; ox = ox + (ww - side) / 2; } else { side = ww; oy = oy + (hh - side) / 2; } side = w() > h() ? hh : ww; X = ox; Y = oy; S = side; } draw_box(); draw_label(); double angle = ( angle2() - angle1() ) * ( value() - minimum()) / ( maximum() - minimum() ) + angle1(); fl_draw_box( box(), X, Y, S, S, color() ); /* shrink a bit */ int OX = x(); int OY = y(); X += S / 8; Y += S / 8; int OS = S; S -= S / 4; fl_line_style( FL_SOLID, S / 12 ); /* background arc */ fl_color( fl_darker( color() ) ); fl_arc( X, Y, S, S, 270 - angle1(), 270 - angle2() ); /* foreground arc */ fl_color( selection_color() ); fl_arc( X, Y, S, S, 270 - angle1(), 270 - angle ); fl_line_style( FL_SOLID, 0 ); if ( active_r() ) { int W = OS; int H = OS; fl_push_matrix(); fl_translate(OX+W/2, OY+H/2); fl_scale(W, H); fl_rotate(310+angle); fl_color( fl_color_add_alpha( FL_WHITE, 127 )); fl_begin_polygon(); fl_circle(-0.26, 0.26, 0.12); fl_end_polygon(); fl_color( FL_WHITE ); fl_begin_polygon(); fl_circle(-0.26, 0.26, 0.06); fl_end_polygon(); fl_pop_matrix(); } fl_color( fl_contrast( labelcolor(), color() ) ); if ( Fl::belowmouse() == this ) { char s[10]; fl_font( FL_HELVETICA, 10 ); snprintf( s, sizeof( s ), "%.1f", value() ); fl_color( FL_FOREGROUND_COLOR ); fl_draw( s, X, Y, S, S, FL_ALIGN_CENTER ); } }
FL_EXPORT_C(void,flc_rotate)(double d){ fl_rotate(d); }
void Panner::draw ( void ) { draw_box(); // draw_box( FL_FLAT_BOX, x(), y(), w(), h(), FL_BLACK ); draw_label(); if ( _bypassed ) { fl_color( 0 ); fl_font( FL_HELVETICA, 12 ); fl_draw( "(bypass)", x(), y(), w(), h(), FL_ALIGN_CENTER ); return; } int tw, th, tx, ty; bbox( tx, ty, tw, th ); fl_push_clip( tx, ty, tw, th ); fl_color( FL_RED ); const int b = 10; tx += b; ty += b; tw -= b * 2; th -= b * 2; /* draw perimeter */ { Fl_Color c1, c2; int iter; if ( Fl::belowmouse() == this ) { iter = 12; c1 = fl_darker( FL_RED ); c2 = FL_GRAY; } else { iter = 6; c1 = FL_GRAY; c2 = FL_BLACK; } Fl_Color c = c1; for ( int i = iter; i--; ) { fl_color( c ); fl_arc( tx + (i * (tw / iter)) / 2, ty + (i * (th / iter)) / 2, tw - (i * (tw / iter)), th - (i * ( th / iter )), 0, 360 ); c = fl_color_average( c1, c2, (float)i / iter); } } /* fl_color( FL_WHITE ); */ /* fl_arc( tx, ty, tw, th, 0, 360 ); */ if ( _configs[ _outs ][0] >= 0 ) { for ( int i = _outs; i--; ) { int a = _configs[ _outs ][ i ]; Point p( 1.2f, (float)a ); float px, py; p.axes( &px, &py ); fl_push_matrix(); const int bx = tx + ((tw / 2) * px + (tw / 2)); const int by = ty + ((th / 2) * py + (th / 2)); fl_translate( bx, by ); fl_scale( 5, 5 ); a = 90 - a; fl_rotate( a ); draw_speaker( FL_WHITE ); fl_rotate( -a ); fl_pop_matrix(); } } /* ensure that points are drawn *inside* the circle */ for ( int i = _ins; i--; ) { Point *p = &_points[ i ]; Fl_Color c = (Fl_Color)(10 + i); int px, py, pw, ph; point_bbox( p, &px, &py, &pw, &ph ); /* draw point */ if ( p != drag ) fl_color( c ); else fl_color( FL_WHITE ); fl_pie( px, py, pw, ph, 0, 360 ); /* draw echo */ fl_color( c = fl_darker( c ) ); fl_arc( px - 5, py - 5, pw + 10, ph + 10, 0, 360 ); if ( Fl::belowmouse() == this ) { fl_color( c = fl_darker( c ) ); fl_arc( px - 10, py - 10, pw + 20, ph + 20, 0, 360 ); fl_color( c = fl_darker( c ) ); fl_arc( px - 30, py - 30, pw + 60, ph + 60, 0, 360 ); } /* draw number */ char pat[4]; snprintf( pat, 4, "%d", i + 1 ); fl_color( FL_BLACK ); fl_font( FL_HELVETICA, ph + 2 ); fl_draw( pat, px + 1, py + 1, pw - 1, ph - 1, FL_ALIGN_CENTER ); /* draw line */ /* fl_color( FL_WHITE ); */ /* fl_line( bx + pw() / 2, by + ph() / 2, tx + (tw / 2), ty + (th / 2) ); */ } fl_pop_clip(); }
void WidgetPDial::draw() { #ifdef NTK_GUI box( FL_NO_BOX ); Fl_Dial::draw(); return; #else const int cx = x(), cy = y(), sx = w(), sy = h(); const double a1 = angle1(), a2 = angle2(); const double val = (value() - minimum()) / (maximum() - minimum()); // even radius produces less artifacts if no antialiasing is avail const int rad = (sx > sy ? sy : sx) &~1; /* clears the button background */ pdialcolor(160, 160, 160); fl_pie(cx - 2, cy - 2, rad + 4, rad + 4, 0, 360); /* dark outline */ fl_color(60, 60, 60); fl_pie(cx - 1, cy - 1, rad + 2, rad + 2, 0, 360); /* Draws the button faceplate, min/max */ pdialcolor(110, 110, 115); fl_pie(cx, cy, rad, rad, 270 - a2, 270 - a1); /* knob center */ if (rad > 8) { pdialcolor(140, 140, 145); fl_pie(cx + 4, cy + 4, rad - 8, rad - 8, 0, 360); } /* value circle */ double a = -(a2 - a1) * val - a1; fl_line_style(0, 2, 0); pdialcolor(0, 200, 0); fl_arc(cx + 1, cy + 1, rad - 2, rad - 2, a - 90, a1 - 180); fl_line_style(0); /* draw value line */ int ll = rad/4; if (ll < 2) ll = 2; fl_push_matrix(); fl_translate(cx + rad / 2, cy + rad / 2); fl_rotate(a - 90.0f); fl_translate(rad / 2, 0); fl_begin_polygon(); pdialcolor(0, 0, 0); fl_vertex(-ll, 0); fl_vertex(0, 0); fl_end_polygon(); fl_pop_matrix(); #endif }
void Fl_Dial::draw() { int X = 0; int Y = 0; int W = w(); int H = h(); if (!(type() == FILL && box() == FL_OVAL_BOX)) { if (damage()&FL_DAMAGE_ALL) draw_box(); box()->inset(X,Y,W,H); } Fl_Color fillcolor = selection_color(); Fl_Color linecolor = highlight_color(); if (!active_r()) { fillcolor = fl_inactive(fillcolor); linecolor = fl_inactive(linecolor); } double angle = (a2-a1)*(value()-minimum())/(maximum()-minimum()) + a1; if (type() == FILL) { if (damage()&FL_DAMAGE_EXPOSE && box() == FL_OVAL_BOX) { fl_push_clip(0, 0, w(), h()); parent()->draw_group_box(); fl_pop_clip(); } fl_color(color()); fl_pie(X, Y, W-1, H-1, 270-a1, angle > a1 ? 360+270-angle : 270-360-angle); fl_color(fillcolor); fl_pie(X, Y, W-1, H-1, 270-angle, 270-a1); if (box() == FL_OVAL_BOX) { fl_ellipse(X, Y, W-1, H-1); fl_color(linecolor); fl_stroke(); } } else { if (!(damage()&FL_DAMAGE_ALL)) { fl_ellipse(X+1, Y+1, W-2, H-2); fl_color(color()); fl_fill(); } fl_push_matrix(); fl_translate(X+W/2-.5, Y+H/2-.5); fl_scale(W-1, H-1); fl_rotate(45-angle); if (type() == LINE) { fl_vertex(0.0, 0.0); fl_vertex(-0.04, 0.0); fl_vertex(-0.25, 0.25); fl_vertex(0.0, 0.04); } else { fl_circle(-0.20, 0.20, 0.07); } fl_color(fillcolor); fl_fill_stroke(linecolor); fl_pop_matrix(); } if (focused()) { fl_ellipse(X+2, Y+2, W-5, H-5); fl_color(linecolor); fl_line_style(FL_DASH); fl_stroke(); fl_line_style(0); } }
void Fl_Gauge::draw(void) { int X = x(); int Y = y(); int W = w(); int H = h(); draw_box(); X += Fl::box_dx(box()); Y += Fl::box_dy(box()); W -= Fl::box_dw(box()); H -= Fl::box_dh(box()); double frac = (value() - minimum()) / (maximum() - minimum()); double angle = (angle2() - angle1()) * frac + angle1(); float cx = X + W/2.0f; float cy = Y + H/2.0f; float d = (float)((W < H)? W : H); double num_major_ticks = (maximum() - minimum()) / major_step_size; double num_minor_ticks = (maximum() - minimum()) / minor_step_size; double minor_angle = (angle2() - angle1()) / num_minor_ticks; double major_angle = (angle2() - angle1()) / num_major_ticks; int i; fl_color(FL_WHITE); fl_line_style(FL_SOLID, 1); /* minor ticks */ fl_push_matrix(); fl_color(FL_WHITE); fl_translate(cx, cy); fl_scale(d, d); fl_rotate(-angle1()); for (i = 0; i <= num_minor_ticks; i++) { fl_begin_line(); fl_vertex(0, 0.40); fl_vertex(0, 0.45); fl_end_line(); fl_rotate(-minor_angle); } fl_pop_matrix(); /* major ticks */ fl_push_matrix(); fl_color(FL_WHITE); fl_line_style(FL_SOLID, 3); fl_translate(cx, cy); fl_scale(d, d); fl_rotate(-angle1()); for (i = 0; i <= num_major_ticks; i++) { fl_begin_line(); fl_vertex(0, 0.40); fl_vertex(0, 0.47); fl_end_line(); fl_rotate(-major_angle); } fl_pop_matrix(); /* tick labels */ char buf[128]; fl_color(FL_WHITE); for (i = 0; i <= num_major_ticks; i++) { snprintf(buf, sizeof(buf), "%.0lf", minimum() + i * major_step_size); double angle = 360.0 + -angle1() - 90 - i * major_angle; double rad = angle * M_PI/180.0; int width = 0; int height = 0; fl_measure(buf, width, height); if (width < 1) { width = 9; } if (height < 1) { height = 16; } double radius = d / 3; double x = cx + radius * cos(rad); double y = cy - radius * sin(rad); if (rad < M_PI/2.0 || rad > 3 * M_PI/2.0) { x = cx + (radius - width/2.0) * cos(rad); } x -= width/2.0; fl_draw(buf, x, y + height/2.0); } fl_push_matrix(); fl_translate(cx, cy); fl_scale(d, d); fl_color(FL_WHITE); fl_rotate(-angle); /* arrow */ fl_begin_polygon(); fl_vertex(-0.02, 0.03); fl_vertex(-0.02, 0.35); fl_vertex( 0.00, 0.37); fl_vertex( 0.02, 0.35); fl_vertex( 0.02, 0.03); fl_end_polygon(); /* border */ fl_begin_loop(); fl_circle(0.0, 0.0, 0.48); fl_end_loop(); fl_pop_matrix(); fl_color(FL_GRAY); fl_pie(cx - d * 0.05, cy - d * 0.05, d * 0.1, d * 0.1, 0, 360.0); fl_color(FL_BLACK); fl_pie(cx - d * 0.025, cy - d * 0.025, d * 0.05, d * 0.05, 0, 360.0); draw_label(); }