[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [XForms] Looking for simple example
From: |
jon |
Subject: |
Re: [XForms] Looking for simple example |
Date: |
Sat, 08 Nov 2014 03:44:48 +0000 |
On Sat, 2014-11-08 at 01:00 +0100, Jens Thoms Toerring wrote:
> Hi Jon,
>
> On Fri, Nov 07, 2014 at 02:43:24PM +0000, jon wrote:
> > I have never used xforms before and am looking for a simple example.
> >
> > I need to write a front end for a mixer, what I need is a moderately
> > large number of slider controls.
> >
> > In an ideal world I would like an array of slider controls, with only
> > one handler. Is this possible, if so can anyone point me at an example
> > structured like this.
>
> This sgouldn't pose a problem. Any number of objects can be
> set up to invoke the same callback ("handler") function. As
> you may have already noticed, setting a callback function
> for an object with fl_set_object_callback() takes three
> arguments: first the pointer to the object, then the func-
> tion pointer and, finally, a long integer number. Both the
> (pointer to the) object and the number from the tird argu-
> ment are going to be passed to the callback function.
>
> If you use a different number for each of your sliders when
> setting its callback function you should easily be able to
> distinguish within the callback function for which one of
> them it was invoked. So the same calback function, when
> written appropriately, should be able to deal with being
> called for lots of different objects!
>
> If you have an array of sliders then one way to deal with
> it might be to call fl_set_object_callback() on each of
> them with, for example, the index into the array of sliders
> as the third argument (assuming that that array pf sliders
> is a global variable). When the callback function is called
> then its first argument is the (pointer to the) slider object
> itself and the second one is that index.
>
> There's also another way to skin the cat if that won't do:
> the callback function receives, as its first argument, the
> address of the object it was invoked for. And each object
> structure has three user-definable fields (copied directly
> from "forms.h":
>
> void * u_vdata; /* anything the user likes */
> char * u_cdata; /* anything the user likes */
> long u_ldata; /* anything the user likes */
>
> So, if the mechanism of setting a (long int) number when
> setting the callback function doesn't suit your needs, using
> one of those members of the FL_OBJECT structure should allow
> you to distinguish which objects the handler (callback func-
> tion) was invoked for and what to do.
>
> I don't know if this helps you (it's not an example, but I
> don't have one at the moment). If not, please don't hesitate
> to ask for more infornations/examples.
>
> Best regards, Jens
Fantastic reply, everything I needed all in one go :-)
I have been working with it for about a day now, I am starting to get
the hang of it.
I opted for the number passed to a common callback as this is all I need
at the moment, the controls are all the same type and scale so this
works well.
I like the fdesign editor, at first glance it does not look very
powerful but after a few hours getting used to it I managed to design a
quite complex form.
Many thanks,
Jon
- [XForms] Looking for simple example, jon, 2014/11/07
- Re: [XForms] Looking for simple example, Jens Thoms Toerring, 2014/11/07
- Re: [XForms] Looking for simple example,
jon <=
- Re: [XForms] Looking for simple example, Jens Thoms Toerring, 2014/11/08
- Re: [XForms] Looking for simple example, jon, 2014/11/08
- Re: [XForms] Looking for simple example, Jens Thoms Toerring, 2014/11/08
- Re: [XForms] Looking for simple example, jon, 2014/11/08
- Re: [XForms] Looking for simple example, Jens Thoms Toerring, 2014/11/09
- Re: [XForms] Looking for simple example, jon, 2014/11/09
- Re: [XForms] Looking for simple example, jon, 2014/11/11
- Re: [XForms] Looking for simple example, Jens Thoms Toerring, 2014/11/11
- Re: [XForms] Looking for simple example, jon, 2014/11/15
- Re: [XForms] Looking for simple example, jon, 2014/11/08