FLTK logo

[fltk.general] Re: Which origin does FLTK draw function use ? Widget or Window?

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Which origin does FLTK draw function use ? Widget or Window? Ian MacArthur May 25, 2021  
 

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...)

 

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/659168c7-b80f-4f86-a66c-65ea2b698b4en%40googlegroups.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.