[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Renaissance: bad layout with dynamic title
From: |
Nicola Pero |
Subject: |
Re: Renaissance: bad layout with dynamic title |
Date: |
Sat, 29 Mar 2008 08:21:18 +0000 |
Hi Michael,
I thought I'd take advantage of Renaissance's
key-value coding support to program the title dynamically:
<gsmarkup>
<objects>
<vbox id="view">
<button id="mainCheckbox" title="#NSOwner.dictionaryName"
type="switch"/>
</vbox>
</objects>
<connectors>
<outlet source="#NSOwner" target="#view" key="view"/>
<outlet source="#NSOwner" target="#mainCheckbox"
key="mainCheckbox"/>
</connectors>
</gsmarkup>
But when I run the program, all of my checkboxes show up as just the
checkbox, no title.
Yes - the title gets set when the connections are done, which is
after all objects
have been created, autosized and put in place. So I'd expect that
the title does
get changed, but the button's size is still the same as the one it
had before the
title was set - the new title would then fall outside the frame and
be clipped,
so you don't see it. ;-)
You can easily confirm it by hardcoding the width of the button:
<button ... width="200" />
and you should see now the title appearing ;-)
I've tried many variations on this theme. I've tried setting the
title to
a placeholder, then dynamically updating the title in code (result:
everything is sized for the original title), I've tried calling
sizeToFitContent on the vbox and the button (result: no change),
removing
and re-adding the button to its superview (result: no change), I've
tried
using an hbox (no change), an NSBox (naked checkbox in the middle of a
reasonably wide box), and nothing seems to get the result I want.
It seems like the layout is getting somehow baked into the view
hierarchy
early on, and I need to prod it into updating but I don't know how
to do
that.
Yes - you would need to redo the layout "bottom-to-top". I have various
unfinished experiments with designing a good API for that.
But you can already do it programmatically using the stable API for
autolayout
and the boxes.
Here's how you can do it:
[* change the button title]
* call -sizeToFitContent on the button
* get the new button's size
* call -setMinimumSize:forView: on the vbox to tell it that the
button has a new minimum size
* call -sizeToFitContent on the vbox
I added on Renaissance's subversion trunk the worked out code as an
example - you find it
in Examples/Special/AutoLayoutUpdate. :-)
Hope that helps
Thanks