FLTK logo

Re: is it safe to sort 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.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: is it safe to sort children? Michael Sweet Mar 27, 2007  
 
Stan wrote:
At runtime, I'm stuffing a grid of widgets into an Fl_Scroll.
My program structure demands that the grid is generated
in column-major order, but I'd like a row-major tab order
when I'm done.

I implemented this by using insert() to add each component at its
(currently) correct position.  When the grid is large, this is
rather slow.  Performance is obviously much better if I add()
each component, then sort the Fl_Scroll's array of children
when I'm all done.  It seems to work, but I'm wondering if it's
safe to do.

It's safe enough as long as you don't call Fl::check() or Fl::wait()
while doing so (which could lead to some strange event processing).

Just make sure to only sort if you have more than 1 widget - Fl_Group
uses a plain widget pointer for the 1 child case (optimization).

--
______________________________________________________________________
Michael Sweet, Easy Software Products           mike at easysw dot com
Internet Printing and Document Software          http://www.easysw.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'.