Re: [LAD] Fwd: Re: How can an LV2 plugin UI get the value of a control port from the plugin?

From: Harry van Haaren <harryhaaren@email-addr-hidden>
Date: Mon Oct 20 2014 - 18:39:54 EEST

On Mon, Oct 20, 2014 at 12:26 PM, Philippe Coatmeur <philcm@email-addr-hidden> wrote:
>
> Now for the direct questions:
>
> - Is it a proper NTK widget class declaration, that would expose a
> value() method?
> - Are those proper NTK widget class instances?
>
> You must derive from an NTK widget in order for it to work properly. See
(pseudo) code:

// derive from slider, to provide
// - value() : to get the current value
// - value(float newVal) : to set a new value
// - redraw() will cause the widget to get repainted at the next
opportunity.
class MyWidget : public Fl_Slider
{
  public:
MyWidget( int, int, int, int, const char* ) :
Fl_Slider( ... blah blah ... )
{
// set default value:
value( 0.5 );
}

void draw()
{
// draw stuff based on value() here
line_to( 0, width * value() );
}

// note: there's no *explicit* value() function here, it's inherited from
Fl_Slider.
};

class NtkLv2UI
{
  public:
NtkLv2UI()
{
wid = new MyWidget( 10, 10, 200, 25 );
}
MyWidget wid;
};

NtkLv2UI::port_event()
{
  if ( portNumber == VOLUME )
  {
     wid->value( portValue );
     wid->redraw();
  }
}

Hope that clears things up somewhat, -Harry

PS: Hermann, FLTK / NTK will delete child instances when a window is
deleted. The window itself should be deleted though!

-- 
http://www.openavproductions.com

_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Mon Oct 20 20:15:04 2014

This archive was generated by hypermail 2.1.8 : Mon Oct 20 2014 - 20:15:04 EEST