Mixer: Try to fix some weirdness with Controller Module knob display.
This commit is contained in:
parent
9f6a2fd022
commit
044414c4c2
129
FL/Fl_Arc_Dial.C
129
FL/Fl_Arc_Dial.C
|
@ -72,8 +72,6 @@ burnished_oval_box ( int x, int y, int w, int h, Fl_Color c )
|
||||||
void
|
void
|
||||||
Fl_Arc_Dial::draw_box ( void )
|
Fl_Arc_Dial::draw_box ( void )
|
||||||
{
|
{
|
||||||
if ( type() == ARC_DIAL )
|
|
||||||
fl_draw_box( FL_ROUNDED_BOX, x(), y(), w(), h(), color() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -121,44 +119,45 @@ Fl_Arc_Dial::handle ( int m )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Fl_Dial::handle( m );
|
int X, Y, S;
|
||||||
|
|
||||||
|
get_knob_dimensions ( &X, &Y, &S );
|
||||||
|
|
||||||
|
return Fl_Dial::handle( m, X, Y, S, S );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Fl_Arc_Dial::draw ( void )
|
Fl_Arc_Dial::draw ( void )
|
||||||
{
|
{
|
||||||
int X = x();
|
int X, Y, S;
|
||||||
int Y = y();
|
|
||||||
int W = w();
|
get_knob_dimensions ( &X, &Y, &S);
|
||||||
int H = h();
|
|
||||||
|
|
||||||
draw_box();
|
draw_box();
|
||||||
draw_label();
|
draw_label();
|
||||||
|
|
||||||
X += Fl::box_dx(box());
|
|
||||||
Y += Fl::box_dy(box());
|
|
||||||
W -= Fl::box_dw(box());
|
|
||||||
H -= Fl::box_dh(box());
|
|
||||||
|
|
||||||
double angle = ( angle2() - angle1() ) * ( value() - minimum()) / ( maximum() - minimum() ) + angle1();
|
double angle = ( angle2() - angle1() ) * ( value() - minimum()) / ( maximum() - minimum() ) + angle1();
|
||||||
|
|
||||||
|
|
||||||
X += W / 8;
|
|
||||||
Y += H / 8;
|
|
||||||
W -= W / 4;
|
|
||||||
H -= H / 4;
|
|
||||||
|
|
||||||
if ( type() == ARC_DIAL )
|
if ( type() == ARC_DIAL )
|
||||||
{
|
{
|
||||||
fl_line_style( FL_SOLID, W / 6 );
|
/* fl_line_style( FL_SOLID, 0 ); */
|
||||||
|
if ( type() == ARC_DIAL )
|
||||||
|
fl_draw_box( FL_ROUNDED_BOX, X, Y, S, S, color() );
|
||||||
|
|
||||||
|
/* shrink a bit */
|
||||||
|
X += S / 8.0;
|
||||||
|
Y += S / 8.0;
|
||||||
|
S -= S / 4;
|
||||||
|
|
||||||
|
fl_line_style( FL_SOLID, S / 6 );
|
||||||
|
|
||||||
/* background arc */
|
/* background arc */
|
||||||
fl_color( fl_darker( color() ) );
|
fl_color( fl_darker( color() ) );
|
||||||
fl_arc( X, Y, W, H, 270 - angle1(), 270 - angle2() );
|
fl_arc( X, Y, S, S, 270 - angle1(), 270 - angle2() );
|
||||||
|
|
||||||
/* foreground arc */
|
/* foreground arc */
|
||||||
fl_color( selection_color() );
|
fl_color( selection_color() );
|
||||||
fl_arc( X, Y, W, H, 270 - angle1(), 270 - angle );
|
fl_arc( X, Y, S, S, 270 - angle1(), 270 - angle );
|
||||||
|
|
||||||
fl_line_style( FL_SOLID, 0 );
|
fl_line_style( FL_SOLID, 0 );
|
||||||
|
|
||||||
|
@ -166,52 +165,33 @@ Fl_Arc_Dial::draw ( void )
|
||||||
}
|
}
|
||||||
else if ( type() == PLASTIC_DIAL || type() == BURNISHED_DIAL )
|
else if ( type() == PLASTIC_DIAL || type() == BURNISHED_DIAL )
|
||||||
{
|
{
|
||||||
// fl_color( fl_color_average( FL_RED, selection_color(), ( value() - minimum() ) / ( maximum() - minimum() ) ) );
|
|
||||||
draw_knob();
|
draw_knob();
|
||||||
|
|
||||||
fl_line_style( FL_SOLID, W / 6 );
|
draw_cursor( X, Y, S);
|
||||||
fl_color( fl_contrast( selection_color(), FL_BACKGROUND_COLOR ) );
|
|
||||||
|
|
||||||
const int d = 6;
|
|
||||||
|
|
||||||
/* account for edge conditions */
|
|
||||||
angle = angle < angle1() + d ? angle1() + d : angle;
|
|
||||||
angle = angle > angle2() - d ? angle2() - d : angle;
|
|
||||||
|
|
||||||
fl_arc( X + 5, Y + 5 , W - 10, H - 10, 270 - (angle - d), 270 - (angle + d) );
|
|
||||||
|
|
||||||
fl_line_style( FL_SOLID, 0 );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Some strange bug in FLTK prevents us from always been able to draw text
|
||||||
|
* here, so don't even try for now. */
|
||||||
|
/* char s[10]; */
|
||||||
|
|
||||||
|
/* fl_font( FL_HELVETICA, 8 ); */
|
||||||
|
|
||||||
char s[10];
|
/* snprintf( s, sizeof( s ), "%.1f", value() ); */
|
||||||
|
|
||||||
fl_font( FL_HELVETICA, 8 );
|
|
||||||
|
|
||||||
snprintf( s, sizeof( s ), "%.1f", value() );
|
|
||||||
if ( type() == ARC_DIAL )
|
|
||||||
fl_draw( s, X, Y, W, H, FL_ALIGN_BOTTOM );
|
|
||||||
else
|
|
||||||
if ( type() == PLASTIC_DIAL )
|
|
||||||
{
|
|
||||||
fl_draw( s, x(), y(), w(), H, FL_ALIGN_BOTTOM );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
/* /\* fl_rectf( X, Y + S, S, 14, FL_BACKGROUND2_COLOR ); *\/ */
|
||||||
|
/* fl_color( FL_WHITE ); */
|
||||||
|
/* fl_draw( s, X, Y + S, S, 14, FL_ALIGN_CENTER ); */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Fl_Arc_Dial::draw_knob ( void )
|
Fl_Arc_Dial::get_knob_dimensions ( int *X, int *Y, int *S )
|
||||||
{
|
{
|
||||||
int ox, oy, ww, hh, side;
|
int ox, oy, ww, hh, side;
|
||||||
ox = x();
|
ox = x();
|
||||||
oy = y();
|
oy = y();
|
||||||
ww = w();
|
ww = w();
|
||||||
hh = h();
|
hh = h();
|
||||||
draw_label();
|
|
||||||
fl_clip(ox, oy, ww, hh);
|
|
||||||
if (ww > hh)
|
if (ww > hh)
|
||||||
{
|
{
|
||||||
side = hh;
|
side = hh;
|
||||||
|
@ -224,6 +204,52 @@ Fl_Arc_Dial::draw_knob ( void )
|
||||||
}
|
}
|
||||||
side = w() > h() ? hh : ww;
|
side = w() > h() ? hh : ww;
|
||||||
|
|
||||||
|
*X = ox;
|
||||||
|
*Y = oy;
|
||||||
|
*S = side;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Fl_Arc_Dial::draw_cursor ( int ox, int oy, int side )
|
||||||
|
{
|
||||||
|
double angle;
|
||||||
|
|
||||||
|
// fl_color(fl_color_average(FL_BACKGROUND_COLOR, FL_BLACK, .7f));
|
||||||
|
|
||||||
|
angle = ( angle2() - angle1() ) * ( value() - minimum()) / ( maximum() - minimum() ) + angle1();
|
||||||
|
|
||||||
|
fl_color( fl_contrast( selection_color(), FL_BACKGROUND_COLOR ) );
|
||||||
|
|
||||||
|
fl_line_style( FL_SOLID, side / 8 );
|
||||||
|
|
||||||
|
const int d = 6;
|
||||||
|
|
||||||
|
/* account for edge conditions */
|
||||||
|
angle = angle < angle1() + d ? angle1() + d : angle;
|
||||||
|
angle = angle > angle2() - d ? angle2() - d : angle;
|
||||||
|
|
||||||
|
ox += side / 4;
|
||||||
|
oy += side / 4;
|
||||||
|
side -= side / 2;
|
||||||
|
|
||||||
|
fl_arc( ox, oy, side, side, 270 - (angle - d), 270 - (angle + d) );
|
||||||
|
|
||||||
|
fl_line_style( FL_SOLID, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Fl_Arc_Dial::draw_knob ( void )
|
||||||
|
{
|
||||||
|
int ox, oy, ww, hh, side;
|
||||||
|
|
||||||
|
get_knob_dimensions ( &ox, &oy, &side );
|
||||||
|
|
||||||
|
ww = w();
|
||||||
|
hh = h();
|
||||||
|
draw_label();
|
||||||
|
fl_clip(ox, oy, ww, hh);
|
||||||
|
|
||||||
|
|
||||||
// background
|
// background
|
||||||
/* fl_color(FL_BACKGROUND_COLOR); */
|
/* fl_color(FL_BACKGROUND_COLOR); */
|
||||||
/* fl_rectf(ox, oy, side, side); */
|
/* fl_rectf(ox, oy, side, side); */
|
||||||
|
@ -231,7 +257,6 @@ Fl_Arc_Dial::draw_knob ( void )
|
||||||
/* scale color */
|
/* scale color */
|
||||||
fl_color(fl_color_average(color(), FL_BACKGROUND2_COLOR, .6));
|
fl_color(fl_color_average(color(), FL_BACKGROUND2_COLOR, .6));
|
||||||
|
|
||||||
|
|
||||||
fl_pie(ox + 1, oy + 3, side - 2, side - 12, 0, 360);
|
fl_pie(ox + 1, oy + 3, side - 2, side - 12, 0, 360);
|
||||||
// scale
|
// scale
|
||||||
draw_scale(ox, oy, side);
|
draw_scale(ox, oy, side);
|
||||||
|
|
|
@ -33,6 +33,7 @@ class Fl_Arc_Dial : public Fl_Dial
|
||||||
void draw_scale ( int ox, int oy, int side );
|
void draw_scale ( int ox, int oy, int side );
|
||||||
void draw_cursor ( int ox, int oy, int sidei );
|
void draw_cursor ( int ox, int oy, int sidei );
|
||||||
|
|
||||||
|
void get_knob_dimensions ( int *X, int *Y, int *S );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -75,6 +76,7 @@ public:
|
||||||
_scaleticks = 12;
|
_scaleticks = 12;
|
||||||
|
|
||||||
box( FL_NO_BOX );
|
box( FL_NO_BOX );
|
||||||
|
type( DEFAULT );
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -82,7 +82,10 @@ public:
|
||||||
|
|
||||||
void dolayout ( void )
|
void dolayout ( void )
|
||||||
{
|
{
|
||||||
size( w(), layout( w() ) );
|
int new_h = layout( w() );
|
||||||
|
|
||||||
|
if ( new_h != h() )
|
||||||
|
size( w(), new_h );
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -113,6 +116,9 @@ public:
|
||||||
X = 0;
|
X = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* avoid bothering the control with lots of resize() calls */
|
||||||
|
if ( ! ( o->x() == x() + X &&
|
||||||
|
o->y() == y() + Y ) )
|
||||||
o->position( x() + X, y() + Y );
|
o->position( x() + X, y() + Y );
|
||||||
|
|
||||||
X += o->w() + _hspacing;
|
X += o->w() + _hspacing;
|
||||||
|
|
|
@ -141,13 +141,14 @@ Chain::Chain ( ) : Fl_Group( 0, 0, 100, 100, "")
|
||||||
o->labeltype( FL_NO_LABEL );
|
o->labeltype( FL_NO_LABEL );
|
||||||
o->hide();
|
o->hide();
|
||||||
{ Fl_Scroll *o = new Fl_Scroll( X, Y, W, H );
|
{ Fl_Scroll *o = new Fl_Scroll( X, Y, W, H );
|
||||||
// o->color( FL_BACKGROUND_COLOR );
|
o->color( FL_BACKGROUND_COLOR );
|
||||||
o->box( FL_NO_BOX );
|
o->box( FL_NO_BOX );
|
||||||
o->type( Fl_Scroll::VERTICAL );
|
o->type( Fl_Scroll::VERTICAL );
|
||||||
{ Fl_Flowpack *o = controls_pack = new Fl_Flowpack( X, Y, W, H );
|
{ Fl_Flowpack *o = controls_pack = new Fl_Flowpack( X, Y, W, H );
|
||||||
|
o->type( FL_VERTICAL );
|
||||||
o->hspacing( 10 );
|
o->hspacing( 10 );
|
||||||
o->vspacing( 10 );
|
o->vspacing( 10 );
|
||||||
// o->box( FL_FLAT_BOX );
|
o->box( FL_NO_BOX );
|
||||||
// o->color( FL_RED );
|
// o->color( FL_RED );
|
||||||
o->end();
|
o->end();
|
||||||
Fl_Group::current()->resizable( o );
|
Fl_Group::current()->resizable( o );
|
||||||
|
@ -159,7 +160,6 @@ Chain::Chain ( ) : Fl_Group( 0, 0, 100, 100, "")
|
||||||
o->hide();
|
o->hide();
|
||||||
Fl_Group::current()->resizable( o );
|
Fl_Group::current()->resizable( o );
|
||||||
}
|
}
|
||||||
|
|
||||||
end();
|
end();
|
||||||
|
|
||||||
log_create();
|
log_create();
|
||||||
|
|
|
@ -361,7 +361,7 @@ Controller_Module::connect_to ( Port *p )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
{ Fl_Arc_Dial *o = new Fl_Arc_Dial( 0, 0, 40, 40, p->name() );
|
{ Fl_Arc_Dial *o = new Fl_Arc_Dial( 0, 0, 50, 50, p->name() );
|
||||||
w = o;
|
w = o;
|
||||||
control = o;
|
control = o;
|
||||||
|
|
||||||
|
@ -402,10 +402,8 @@ Controller_Module::connect_to ( Port *p )
|
||||||
w->resize( x(), y(), this->w(), h() );
|
w->resize( x(), y(), this->w(), h() );
|
||||||
add( w );
|
add( w );
|
||||||
resizable( w );
|
resizable( w );
|
||||||
/* init_sizes(); */
|
// init_sizes();
|
||||||
}
|
}
|
||||||
|
|
||||||
// create OSC port
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue