[Top][All Lists]

[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: Sun, 09 Nov 2014 15:07:08 +0000

On Sun, 2014-11-09 at 15:09 +0100, Jens Thoms Toerring wrote:
> Hi Jon,
> On Sun, Nov 09, 2014 at 03:01:11AM +0000, jon wrote:
> > The above code works fine, but I need a
> > timer in milliseconds not seconds.
> It does work with sub-second resolution - the 'delay' argument
> to fl_set_timer() is a double, so if you set it to 0.1 the
> timer should expire after 100 ms. If it doesn't then you've
> discovered a bug!
> > I found this example online, works fine as stand alone but does not seem
> > to work if I mix it into the xforms application.
> > 
> > http://www.informit.com/articles/article.aspx?p=23618&seqNum=14
> > 
> > It must be a common task but I don't seem to making it work, how do I
> > perform an action at 10Hz or better within an xforms application ?
> Well, a timer object should work... Here's an example program:

Useful example, thanks :-)  

> On my machine the time resultion achieved seems to be in the
> sub-millisecond range, which I would consider to be not too
> bad;-) Of course, such a high resolution isn't guaranteed,
> in a real program with lots of objects competing for CPU time
> it probably is going to be worse.
> > At the moment fl_do_forms() seems to block forever,
> That's what fl_for_forms() is meant to do: it only ever returns
> when there's an event from an object that does not have a call-
> back.
Ahh, I see !

>  Otherwise it's supposed never to return. That's like with
> all other GUI frameworks I know about - the event look never re-
> turns, XForms is different in that it allows the event loop
> (what you enter when calling fl_do_forms()) to stop once an
> event for an object without a callback is received.
It was the "missing callback" logic I had not understood. I was assuming
the exiting the control loop was triggered by some sort of flag. IE it
could be turned on and off and that I was missing a switch or parameter
somewhere to enable a behaviour change.

> > In places the examples do things like this:
> >         if ( fl_do_forms( ) == yes )
> > But I cant see what changes the behaviour of fl_fo_forms() so that it
> > returns control before the application ends ?
> In that example 'yes' is obviously an object without a callback.
> And when there's none fl_do_forms() returns. This is often used
> for the "Exit" or "Quit" button or similar. So the simple rule
> is that objects without a handler will make fl_do_forms() re-
> turn when triggered (e.g. when a button is clicked on or a
> timer expires etc.), while objects that have a callback don't.
> > i've read the
> > documentation and references online, it seems to contradict itself in
> > several places,
> Could you send me some pointers to such places? I'd be happy to
> improve the documentation!
To be fair the xcode.pdf I downloaded with the source package does not
contradict itself, I sometimes find older pages online that do not fully
agree, I will note them as I see them.  It may simply be that I have not
fully understood. I did not put as much time into understanding xforms
as would have been ideal.

> On Sun, Nov 09, 2014 at 04:41:59AM +0000, jon wrote:
> > I think I made it work, found fl_set_idle_callback() - that seems good
> > enough.
> Fine;-) Just be aware that idle callbacks can have a much worse
> time resolution than timer objects since the idle callback is
> really only invoked when there's time enough. So at what moment
> they get called can be rather random, which often is good enough,
> but not for all purposes.
I changed the code over to timers using your example.  The resolution
may be quite good, but now I now want to push for faster updates and I
cant seem to do it.  Timer values 0.1 work 0.01 is a little faster, but
not ten times as fast - values smaller seem not to make a difference ?

I don't know why I could not make it work with setitimer() - I could
make it work outside of the xforms code but the one I tried to merge it
in the timer handler never got executed, maybe it was finger trouble on
my part, I might have another go at that.

I am plotting some VU meters, seems to work well. I am using fl_line to
render bar graphs.

I have a couple of tasks remaining.  I want to turn scaling the window
off, I tried to do it like this (using bits from the pdf and google

FL_Coord w,h;
fl_winminsize(None, w, h);
fl_winmaxsize(None, w, h);

I assume I need some object reference for get_winsize?  If I hard code w
and h rather than trying to read it with fl_get_winsize then it seems to
work ok. 

My final task I have not tried yet is that I need to plot some pretty
displays of audio data. 

In fdesigner I placed on the form a number of pixmaps, in an ideal world
I would like to get a pointer to the raw pixel data - modify it (all
modern displays are either 16 bit 565 or 24 bit, so I can do this by
hand), then have xforms refresh or redraw the modified image (but not
re-load it from disk, I want it to evolve).  I don't understand enough
about how the xforms structures work to guess at extracting the pixel
buffer pointer (assuming it has one)? I assume I would also need to tell
xforms to re-draw the pixmap ?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]