Esempio n. 1
0
void
Controller_Module::connect_to ( Port *p )
{
    control_output[0].connect_to( p );

    clear();

    Fl_Widget *w;

    if ( p->hints.type == Module::Port::Hints::BOOLEAN )
    {
        Fl_Light_Button *o = new Fl_Light_Button( 0, 0, 40, 40, p->name() );
        w = o;
        o->value( p->control_value() );

        _type = TOGGLE;

        /* FIXME: hack */
        control = (Fl_Valuator*)o;
    }
    else if ( p->hints.type == Module::Port::Hints::INTEGER )
    {

        Fl_Counter *o = new Fl_Counter(0, 0, 58, 24, p->name() );
        control = o;
        w = o;

        o->type(1);
        o->step(1);

        if ( p->hints.ranged )
        {
            o->minimum( p->hints.minimum );
            o->maximum( p->hints.maximum );
        }

        _type = SPINNER;

        o->value( p->control_value() );
    }
    else if ( p->hints.type == Module::Port::Hints::LOGARITHMIC )
    {
        Fl_Value_SliderX *o = new Fl_Value_SliderX(0, 0, 30, 250, p->name() );
        control = o;
        w = o;

        o->type(4);
        o->color( FL_DARK1 );
        o->selection_color( fl_color_average( FL_GRAY, FL_CYAN, 0.5 ) );
        o->minimum(1.5);
        o->maximum(0);
        o->value(1);
        o->textsize(9);

        if ( p->hints.ranged )
        {
            o->minimum( p->hints.maximum );
            o->maximum( p->hints.minimum );
        }

        o->value( p->control_value() );

        _type = SLIDER;
    }
    else
    {
        { Fl_DialX *o = new Fl_DialX( 0, 0, 50, 50, p->name() );
            w = o;
            control = o;

            if ( p->hints.ranged )
            {
                DMESSAGE( "Min: %f, max: %f", p->hints.minimum, p->hints.maximum );
                o->minimum( p->hints.minimum );
                o->maximum( p->hints.maximum );
            }
            
            o->color( fl_darker( FL_GRAY ) );
            o->selection_color( FL_WHITE );
            o->value( p->control_value() );
        }

        _type = KNOB;
    }

    control_value = p->control_value();

    w->set_visible_focus();
    w->align(FL_ALIGN_TOP);
    w->labelsize( 10 );
    w->callback( cb_handle, this );

    if ( _pad )
    {
        Fl_Labelpad_Group *flg = new Fl_Labelpad_Group( w );
        flg->set_visible_focus();
        size( flg->w(), flg->h() );
        flg->position( x(), y() );
        add( flg );
    }
    else
    {
        /* HACK: hide label */
        w->labeltype( FL_NO_LABEL );
        w->resize( x(), y(), this->w(), h() );
        add( w );
        resizable( w );
//       init_sizes();
    }
}
Esempio n. 2
0
void
Controller_Module::connect_to ( Port *p )
{
    control_output[0].connect_to( p );

    clear();

    Fl_Widget *w;

    if ( p->hints.type == Module::Port::Hints::BOOLEAN )
    {
        Fl_Button *o = new Fl_Button( 0, 0, 40, 40, p->name() );
        w = o;
        o->type( FL_TOGGLE_BUTTON );
        o->value( p->control_value() );
        o->selection_color( fl_color_average( FL_GRAY, FL_CYAN, 0.5 ) );

        _type = TOGGLE;

        /* FIXME: hack */
        control = (Fl_Valuator*)o;
    }
    else if ( p->hints.type == Module::Port::Hints::INTEGER )
    {

        Fl_Counter *o = new Fl_Counter(0, 0, 58, 24, p->name() );
        control = o;
        w = o;

        o->type(1);
        o->step(1);

        if ( p->hints.ranged )
        {
            o->minimum( p->hints.minimum );
            o->maximum( p->hints.maximum );
        }

        _type = SPINNER;

        o->value( p->control_value() );
    }
    //  else if ( p->hints.type == Module::Port::Hints::LOGARITHMIC )
    else
    {
        Fl_Value_SliderX *o = new Fl_Value_SliderX(0, 0, 30, 250, p->name() );
        control = o;
        w = o;

        if ( ! _horizontal )
        {
            o->size( 30, 250 );
            o->type(FL_VERT_NICE_SLIDER);
        }
        else
        {
            o->size(250,20);
            o->type(FL_HOR_NICE_SLIDER);
        }

//        o->type(4);
        o->color( FL_BACKGROUND2_COLOR );
        o->selection_color( fl_color_average( FL_GRAY, FL_CYAN, 0.5 ) );
        o->minimum(1.5);
        o->maximum(0);
        o->value(1);
//        o->textsize(9);

        if ( p->hints.ranged )
        {
            if ( ! _horizontal )
            {
                o->minimum( p->hints.maximum );
                o->maximum( p->hints.minimum );
            }
            else
            {
                o->minimum( p->hints.minimum );
                o->maximum( p->hints.maximum );
            }
        }

        o->precision(2);

        o->value( p->control_value() );

        _type = SLIDER;
    }
    /* else */
    /* { */
    /*     { Fl_DialX *o = new Fl_DialX( 0, 0, 50, 50, p->name() ); */
    /*         w = o; */
    /*         control = o; */

    /*         if ( p->hints.ranged ) */
    /*         { */
    /*             DMESSAGE( "Min: %f, max: %f", p->hints.minimum, p->hints.maximum ); */
    /*             o->minimum( p->hints.minimum ); */
    /*             o->maximum( p->hints.maximum ); */
    /*         } */
            
    /*         o->color( fl_darker( FL_GRAY ) ); */
    /*         o->selection_color( FL_WHITE ); */
    /*         o->value( p->control_value() ); */
    /*     } */

    /*     _type = KNOB; */
    /* } */

    control_value = p->control_value();

    w->clear_visible_focus();
    w->align(FL_ALIGN_TOP);
    w->labelsize( 10 );
    w->callback( cb_handle, this );

    if ( _pad )
    {
        Fl_Labelpad_Group *flg = new Fl_Labelpad_Group( w );
        flg->set_visible_focus();
        size( flg->w(), flg->h() );
        flg->position( x(), y() );
        add( flg );
        resizable(flg);
//        init_sizes();
    }
    else
    {
        /* HACK: hide label */
        if ( _type == TOGGLE )
        {
            w->align( FL_ALIGN_INSIDE );
        }
        else
        {
            w->labeltype( FL_NO_LABEL );
        }
        w->resize( x(), y(), this->w(), h() );
        add( w );
        resizable( w );
        init_sizes();
    }
}