FLTK logo

[fltk.coredev] RFC: Fl_Group option with relative coords for children

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.coredev  ]
 
Previous Message ]New Message | Reply ]Next Message ]

RFC: Fl_Group option with relative coords for children Greg Ercolano Nov 26, 2020  
 
Now that we have the ability to apply transformations to fltk drawing (I think?),
would it make sense to add a method to Fl_Group, e.g. relative(bool) that allows child widgets
to be positioned relative to the upper/left corner of the group rather than the parent window?
Much like the way one can use subwindows now, but without the window-related overhead that can entail.

Seems like it'd be easy for the draw() code to do something like:

void Fl_Group::draw() {
  // Relative positioning of children? translate coord space to our x()/y()
  if ( relative() ) fl_translate(x(), y());
  // Draw the children
  [..]
  // Undo transform..
  if ( relative() ) fl_translate(-x(), -y());   // basically 'pop' the old transforms
}

I think event x/y positions could be translated too by adjusting x/y events
on entry to the Fl_Group::handle() method, and undoing them on exit.

Might involve mods to FLTK's core to support event delivery for focus widgets though,
since those get a first shot at events and bypass the widget handle() hierarchy by directing
events directly at the focus widget first. For that to work, FLTK's core event delivery would
have to walk the widget hierarchy looking for Fl_Groups with this relative() flag on, so it can
calculate an offset for the events.

Anyway, just a thought -- I'm not sure this would work and haven't tried any tests, just curious
if this sounds plausible/useful, or is just an unwanted can of worms or a malformed idea..

-- 
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/9bbd26c1-b7ae-c0d0-6c3c-7ca1726f1675%40seriss.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'.