On Tuesday, 25 May 2021 at 07:31:02 UTC+1 fmeg... wrote:
Is this the default behavior ? i thought that the draw function uses the widgets 0,0 and not the window. do i need to explicitly call the x() and y() in the custom draw() function and apply transforms and/or offsets to correct this ?
Yes, all fltk drawing (in the 1.x series) is Window Relative, not Widget Relative.
The adjustment I usually use is, at the start of my draw() methods, do:
int xo = x();
int yo = y();
The add (xo, yo) to the root of any integer drawing I do.
I think, if you use fluid to generate a derived widget, you can also ask it to do that offsetting for you.
Or you can use the transform based drawing methods of course, which are handy for more complex scenes but can be slower than the basic integer methods, of course.
Greg as a nice demo of an Aircraft Altimeter widget here:
http://www.seriss.com/people/erco/fltk/#Altimeter
Which I think embraces these issues (though TBH it is probably more elaborate than you really needs, since Greg was attempting to illustrate some more "advanced" techniques with that demo...)