On 27.10.2011 06:55, Jim Jozwiak wrote:
> Here is an excerpt from my nutrition program which contains two horizontal 
> packs within a vertical pack within a double window.
>
> If you compile it with "fltk-config --compile main.cc" it works perfectly.
>
> But if you compile a second time changing the resize_yes variable at the 
> beginning of the main function to true so that all packs are resizable to the 
> groups themselves, everything in the second horizontal pack fails to work.  
> The light buttons go dead and the tooltips do not show.
>
> I am running slackware 13.37 with kernel 2.6.37.6 on a 686 with gcc 4.5.2 and 
> X.Org X Server 1.9.5.  My fltk version is fltk-1.3.x-r9143.
>
> Any ideas?

Yes - well, it's complicated. I played around with your test
program for a while, and it's confusing.

First point: It's not only the second pack that shows these
strange effects, but it depends on where you click first. If
you click first on the (round) button, then the buttons in
the 2nd pack seem to be dead, and there are no tooltips, as
you described. However, if you resize the window only for a
small bit, then all buttons and tooltips are operative again.
If you *click* on one of the buttons in the second pack, then
the upper (round) button is inactive.

This is clearly a symptom of some shifting/positioning of the
widgets while resizing, and the reason is that Fl_Pack is really
a problematic widget. It has the feature that it resizes itself
to surround all widgets - and to make it worse, this is done in
the draw() method (not in resize() or something else). An additional
feature is that the contained widgets are allowed to resize themselves
when (while) *they* are drawn - and this would be the case for nested
Fl_Pack's.

Now, what does "resizable" mean usually? A widget (let's say a group
here) can be resized, and then it will resize its children to fit
the new sizes. This is exactly the opposite way around than Fl_Pack
is designed to do.

Okay, bringing it to the point:
  - nesting Fl_Pack's is bad (difficult to do correctly)
  - making Fl_Pack's resizable is bad (contradicting designs)
  - nesting resizable Fl_Pack's ... is even worse.

This is not an official statement, but my current understanding of
the situation and the existing code. Maybe it can be "fixed", but
maybe not...

My assumption: although it is not documented, it appears to me that
both nesting Fl_Pack's and making them resizable might not be doable,
at least not together and with the current code base. FLTK 2 has
introduced another method (layout()) that should help to improve the
code, but this is not something we can use in FLTK 1.3. Maybe this will
be available in FLTK 3 - but this will affect user code.

Nevertheless I did some (quick and dirty) tests with adding init_sizes()
and a resize() method to Fl_Pack to see if I can fix the behavior.
I succeeded in a way that the "dead widget" effect was fixed, but there
were other bad side effects like widgets "jumping" from one place to
another when clicked. This is something that would have to be
investigated further. There is a plan to refactor the code anyway, but
this might not happen before the next major release (3.0) or maybe 1.4.

Anyway, I agree with Ian that you can probably get what you want by
replacing your Fl_Pack widgets with Fl_Group widgets, with the only
additional "cost" that you must do more of the layout calculation
yourself. I can't tell if your layout is so dynamic that it can't be
done this way, so this would be something you should tell us. As Ian
wrote, Fl_Group's resizing works so that the widgets are repositioned
relative to each other, so that resizing looks smooth. If this is all
you want to achieve, then this might be a better way to go than to
fight with Fl_Pack's special resizing problems. Note that I don't
recommend this as a workaround, but really as a better approach, since
Fl_Group's resizing and Fl_Pack's design are so different.

Could you please tell us, why you used Fl_Pack in the first place?
Why did you not use Fl_Group, what did you want to achieve?

Albrecht
_______________________________________________
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to