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

Harry van Haaren harryhaaren at gmail.com
Mon Oct 20 15:39:54 UTC 2014


On Mon, Oct 20, 2014 at 12:26 PM, Philippe Coatmeur <philcm at gnu.org> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxaudio.org/pipermail/linux-audio-dev/attachments/20141020/7d62be24/attachment.html>


More information about the Linux-audio-dev mailing list