<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Why I Say &#8216;NO&#8217; to Autoresizing</title>
	<atom:link href="http://katidev.com/blog/2008/02/12/why-i-say-no-to-autoresizing/feed/" rel="self" type="application/rss+xml" />
	<link>http://katidev.com/blog/2008/02/12/why-i-say-no-to-autoresizing/</link>
	<description>Developing Interfaces with Cocoa</description>
	<pubDate>Fri, 21 Nov 2008 16:31:53 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
		<item>
		<title>By: Andy Lee</title>
		<link>http://katidev.com/blog/2008/02/12/why-i-say-no-to-autoresizing/#comment-182</link>
		<dc:creator>Andy Lee</dc:creator>
		<pubDate>Wed, 30 Apr 2008 19:58:02 +0000</pubDate>
		<guid isPermaLink="false">http://katidev.com/blog/?p=5#comment-182</guid>
		<description>twobyte wrote:

&#62;&#62;&#62;
In the “View Programming Guide” you quoted is written:

Important: Several cautions apply to autoresizing. For autoresizing to work correctly, the subview being autoresized must lie completely within its superview’s frame.
&#60;&#60;&#60;

I could be imagining things, but I *think* the "drifting subview" problem has been observed even when a generous minimum size has been specified for the enclosing view.  The only way to avoid the problem completely is never to have more than one spring in a given direction (horizontal or vertical) for a given view.  Roundoff errors occur when autoresizing tries to distribute a given number of pixels between two "springy" areas, based on some ratio.  If there is only one spring, there is no ratio to compute; you just take the number of pixels left over after subtracting the sizes of the struts.

At least that's my theory; I haven't experimented with this stuff in a while.</description>
		<content:encoded><![CDATA[<p>twobyte wrote:</p>
<p>&gt;&gt;&gt;<br />
In the “View Programming Guide” you quoted is written:</p>
<p>Important: Several cautions apply to autoresizing. For autoresizing to work correctly, the subview being autoresized must lie completely within its superview’s frame.<br />
&lt;&lt;&lt;</p>
<p>I could be imagining things, but I *think* the &#8220;drifting subview&#8221; problem has been observed even when a generous minimum size has been specified for the enclosing view.  The only way to avoid the problem completely is never to have more than one spring in a given direction (horizontal or vertical) for a given view.  Roundoff errors occur when autoresizing tries to distribute a given number of pixels between two &#8220;springy&#8221; areas, based on some ratio.  If there is only one spring, there is no ratio to compute; you just take the number of pixels left over after subtracting the sizes of the struts.</p>
<p>At least that&#8217;s my theory; I haven&#8217;t experimented with this stuff in a while.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andy Lee</title>
		<link>http://katidev.com/blog/2008/02/12/why-i-say-no-to-autoresizing/#comment-181</link>
		<dc:creator>Andy Lee</dc:creator>
		<pubDate>Wed, 30 Apr 2008 19:44:59 +0000</pubDate>
		<guid isPermaLink="false">http://katidev.com/blog/?p=5#comment-181</guid>
		<description>Cathy, I think you are right in your update that the problem is in how the changes are computed, but I don't think it's a notification lag.  I think it's simply what you referred to earlier -- that views don't cache their margins and proportions -- along with roundoff error.

It looks like views compute their new size by trying to preserve the margins and/or proportions from their *previous* size and position rather than their *original* size and position -- what Dirk referred to as the use of real-time coordinates.

I think the problem is that when a margin gets close to 0, something causes it to be rounded to 0.  I'm not sure if floating point rounding errors would be large enough to make this happen.  I've wondered whether autoresizing explicitly rounds some coordinates to integers; I think I even tested this theory once with some NSLogs, but if so it was long ago.  In any case, once a margin becomes 0, it tends to stay that way, because 0 always scales to 0.  The only way to force it to become non-zero again is (in your example) to make the outer view smaller than the inner view.  The inner view's fixed size will be preserved, because struts apparently have higher precedence than springs.  This would explain the lopsidedness that follows.  The views have totally forgotten that one was centered inside the other; they are preserving whatever margin proportions you created at the moment you forced the stuck edges to separate.

As for the "sticking" only happening sometimes -- I think in your experiments when you're dragging to resize, it's a matter of chance whether you hit the exact size that's going to make a margin 0 at the exact time that a resizing event occurs.  I think the "sticking" is more likely to happen if you're dragging slowly enough for resize events to happen at almost every pixel that you move.  For example, imagine you have the inner view with just a one-pixel margin all around, and then ever so carefully shrink the window by exactly two pixels.

Anyway, I'm not sure I'm saying a whole lot that's new -- Dirk was getting at some of the same points -- but I've been meaning to comment on this post for ages, because it's an interesting problem.  One of these days I'll check out the more sophisticated capabilities of CALayer.</description>
		<content:encoded><![CDATA[<p>Cathy, I think you are right in your update that the problem is in how the changes are computed, but I don&#8217;t think it&#8217;s a notification lag.  I think it&#8217;s simply what you referred to earlier &#8212; that views don&#8217;t cache their margins and proportions &#8212; along with roundoff error.</p>
<p>It looks like views compute their new size by trying to preserve the margins and/or proportions from their *previous* size and position rather than their *original* size and position &#8212; what Dirk referred to as the use of real-time coordinates.</p>
<p>I think the problem is that when a margin gets close to 0, something causes it to be rounded to 0.  I&#8217;m not sure if floating point rounding errors would be large enough to make this happen.  I&#8217;ve wondered whether autoresizing explicitly rounds some coordinates to integers; I think I even tested this theory once with some NSLogs, but if so it was long ago.  In any case, once a margin becomes 0, it tends to stay that way, because 0 always scales to 0.  The only way to force it to become non-zero again is (in your example) to make the outer view smaller than the inner view.  The inner view&#8217;s fixed size will be preserved, because struts apparently have higher precedence than springs.  This would explain the lopsidedness that follows.  The views have totally forgotten that one was centered inside the other; they are preserving whatever margin proportions you created at the moment you forced the stuck edges to separate.</p>
<p>As for the &#8220;sticking&#8221; only happening sometimes &#8212; I think in your experiments when you&#8217;re dragging to resize, it&#8217;s a matter of chance whether you hit the exact size that&#8217;s going to make a margin 0 at the exact time that a resizing event occurs.  I think the &#8220;sticking&#8221; is more likely to happen if you&#8217;re dragging slowly enough for resize events to happen at almost every pixel that you move.  For example, imagine you have the inner view with just a one-pixel margin all around, and then ever so carefully shrink the window by exactly two pixels.</p>
<p>Anyway, I&#8217;m not sure I&#8217;m saying a whole lot that&#8217;s new &#8212; Dirk was getting at some of the same points &#8212; but I&#8217;ve been meaning to comment on this post for ages, because it&#8217;s an interesting problem.  One of these days I&#8217;ll check out the more sophisticated capabilities of CALayer.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alan Shouls</title>
		<link>http://katidev.com/blog/2008/02/12/why-i-say-no-to-autoresizing/#comment-174</link>
		<dc:creator>Alan Shouls</dc:creator>
		<pubDate>Sun, 20 Apr 2008 15:10:07 +0000</pubDate>
		<guid isPermaLink="false">http://katidev.com/blog/?p=5#comment-174</guid>
		<description>Hi Kati,

Like Jense I’ve never thought of the splitters snapping shut as a design flaw. Comming from a non-cocoa environment where we didn't have this problem I put time into getting our splitters to snap - the issue is that if you have, say, a list of icons with labels there is not that much point in having a splitter 4px running the width of the window. It would be less than 1/2 an icon. As a user I find this messy and not useful. As I remember when implementing the snapping behavior I was working on 10.3 &#38; 10.4 and looked quite carefully at the Finder. As I remember they implemented the snapping at the point where you would otherwise get less than an icon. I think they got it right - when you move the splitter want to see more, or less. To me the extremes are as much as possible, nothing or the minimum that is useful.

For the avoidance of doubt, I think that the Auto Resizing behaviour *should* behave properly.</description>
		<content:encoded><![CDATA[<p>Hi Kati,</p>
<p>Like Jense I’ve never thought of the splitters snapping shut as a design flaw. Comming from a non-cocoa environment where we didn&#8217;t have this problem I put time into getting our splitters to snap - the issue is that if you have, say, a list of icons with labels there is not that much point in having a splitter 4px running the width of the window. It would be less than 1/2 an icon. As a user I find this messy and not useful. As I remember when implementing the snapping behavior I was working on 10.3 &amp; 10.4 and looked quite carefully at the Finder. As I remember they implemented the snapping at the point where you would otherwise get less than an icon. I think they got it right - when you move the splitter want to see more, or less. To me the extremes are as much as possible, nothing or the minimum that is useful.</p>
<p>For the avoidance of doubt, I think that the Auto Resizing behaviour *should* behave properly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cathy</title>
		<link>http://katidev.com/blog/2008/02/12/why-i-say-no-to-autoresizing/#comment-108</link>
		<dc:creator>Cathy</dc:creator>
		<pubDate>Tue, 25 Mar 2008 01:55:01 +0000</pubDate>
		<guid isPermaLink="false">http://katidev.com/blog/?p=5#comment-108</guid>
		<description>twobyte:

once a split view is in the picture, views don't lie completely within their super view's frame.  most modern apps are based around a single window with a split view design.  and usually there are more split views inside those split views.  that kind of restriction is compeltely not realistic! : )</description>
		<content:encoded><![CDATA[<p>twobyte:</p>
<p>once a split view is in the picture, views don&#8217;t lie completely within their super view&#8217;s frame.  most modern apps are based around a single window with a split view design.  and usually there are more split views inside those split views.  that kind of restriction is compeltely not realistic! : )</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: twobyte</title>
		<link>http://katidev.com/blog/2008/02/12/why-i-say-no-to-autoresizing/#comment-103</link>
		<dc:creator>twobyte</dc:creator>
		<pubDate>Tue, 25 Mar 2008 00:35:26 +0000</pubDate>
		<guid isPermaLink="false">http://katidev.com/blog/?p=5#comment-103</guid>
		<description>To address you problem, the "View programming guide" you quoted says:

A subclass can override resizeSubviewsWithOldSize: or resizeWithOldSuperviewSize: to customize the autoresizing behavior for a view.</description>
		<content:encoded><![CDATA[<p>To address you problem, the &#8220;View programming guide&#8221; you quoted says:</p>
<p>A subclass can override resizeSubviewsWithOldSize: or resizeWithOldSuperviewSize: to customize the autoresizing behavior for a view.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: twobyte</title>
		<link>http://katidev.com/blog/2008/02/12/why-i-say-no-to-autoresizing/#comment-102</link>
		<dc:creator>twobyte</dc:creator>
		<pubDate>Tue, 25 Mar 2008 00:33:24 +0000</pubDate>
		<guid isPermaLink="false">http://katidev.com/blog/?p=5#comment-102</guid>
		<description>In the "View Programming Guide" you quoted is written:

Important: Several cautions apply to autoresizing. For autoresizing to work correctly, the subview being autoresized must lie completely within its superview’s frame.</description>
		<content:encoded><![CDATA[<p>In the &#8220;View Programming Guide&#8221; you quoted is written:</p>
<p>Important: Several cautions apply to autoresizing. For autoresizing to work correctly, the subview being autoresized must lie completely within its superview’s frame.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cathy</title>
		<link>http://katidev.com/blog/2008/02/12/why-i-say-no-to-autoresizing/#comment-16</link>
		<dc:creator>Cathy</dc:creator>
		<pubDate>Sat, 16 Feb 2008 04:07:40 +0000</pubDate>
		<guid isPermaLink="false">http://katidev.com/blog/?p=5#comment-16</guid>
		<description>I think springs-and-struts are awesome.  It's one of my favorite interfaces ever, just wish the effect would not be so buggy.  

As far as the split view thing goes, my opinion certainly has alot to do with my personal preferences.  I absolutely hate it when i can't resize a window as much as i want, even though I completely understand that for some layouts, there absoultely needs to be a min size of the window or else buttons and things will be drawn ontop of each other or they'll be out of the view.  Same for split views.  I want to drag back and forth as much as I want.  I'm fidgety that way, I like to play with the interfaces.  When I can't and there's no obvious layout reason why, first I think it's broken, then when it finally snaps, I get annoyed.  But that's Just me. :)

One problem is the way people do it.  Dirk Stoop pointed this out to me and I think it makes a difference.  If you're going to stop people from dragging any further, change the cursur icon from the left/right or up/down icons to ones that show only one direction.  Then it's more obvious that you can't go any further and you'll stop trying to pull it.  If you're going to snap it, change the cursur back to the arrow right away, don't wait for the mouse up.  Details like that help the user understand what's going on.  It's nice to let them know they're no longer in control.  

These situations might also be the right time for a little animation to help clear things up.  The snapping is so jarring.</description>
		<content:encoded><![CDATA[<p>I think springs-and-struts are awesome.  It&#8217;s one of my favorite interfaces ever, just wish the effect would not be so buggy.  </p>
<p>As far as the split view thing goes, my opinion certainly has alot to do with my personal preferences.  I absolutely hate it when i can&#8217;t resize a window as much as i want, even though I completely understand that for some layouts, there absoultely needs to be a min size of the window or else buttons and things will be drawn ontop of each other or they&#8217;ll be out of the view.  Same for split views.  I want to drag back and forth as much as I want.  I&#8217;m fidgety that way, I like to play with the interfaces.  When I can&#8217;t and there&#8217;s no obvious layout reason why, first I think it&#8217;s broken, then when it finally snaps, I get annoyed.  But that&#8217;s Just me. <img src='http://katidev.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>One problem is the way people do it.  Dirk Stoop pointed this out to me and I think it makes a difference.  If you&#8217;re going to stop people from dragging any further, change the cursur icon from the left/right or up/down icons to ones that show only one direction.  Then it&#8217;s more obvious that you can&#8217;t go any further and you&#8217;ll stop trying to pull it.  If you&#8217;re going to snap it, change the cursur back to the arrow right away, don&#8217;t wait for the mouse up.  Details like that help the user understand what&#8217;s going on.  It&#8217;s nice to let them know they&#8217;re no longer in control.  </p>
<p>These situations might also be the right time for a little animation to help clear things up.  The snapping is so jarring.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jens Alfke</title>
		<link>http://katidev.com/blog/2008/02/12/why-i-say-no-to-autoresizing/#comment-15</link>
		<dc:creator>Jens Alfke</dc:creator>
		<pubDate>Sat, 16 Feb 2008 03:47:31 +0000</pubDate>
		<guid isPermaLink="false">http://katidev.com/blog/?p=5#comment-15</guid>
		<description>Funny, I've never thought of the splitters snapping shut as a design flaw. I actually really like this mechanism: it's similar to design programs that snap the object you're dragging to the edge or center of the page. If I'm dragging a splitter way over to the side, it's because I either want to make that pane "as narrow as possible" (but still useable), or I want to hide it entirely. I don't want a uselessly narrow little pane that isn't even wide enough to show its UI components. So the splitter gives me one or the other. I can quickly drag the slider over and know that I'll hide the pane entirely, not be left with a 10-pixel-wide pane or something like that.

(Springs-and-struts can be a pain, but every other layout mechanism I've experienced is much worse. Have you ever used Java's LayoutManagers? I vividly remember building a simple inspector window in Swing that took me two whole days of messing with the dreaded GridBagLayoutManager, which I could have built in ten minutes with IB.)</description>
		<content:encoded><![CDATA[<p>Funny, I&#8217;ve never thought of the splitters snapping shut as a design flaw. I actually really like this mechanism: it&#8217;s similar to design programs that snap the object you&#8217;re dragging to the edge or center of the page. If I&#8217;m dragging a splitter way over to the side, it&#8217;s because I either want to make that pane &#8220;as narrow as possible&#8221; (but still useable), or I want to hide it entirely. I don&#8217;t want a uselessly narrow little pane that isn&#8217;t even wide enough to show its UI components. So the splitter gives me one or the other. I can quickly drag the slider over and know that I&#8217;ll hide the pane entirely, not be left with a 10-pixel-wide pane or something like that.</p>
<p>(Springs-and-struts can be a pain, but every other layout mechanism I&#8217;ve experienced is much worse. Have you ever used Java&#8217;s LayoutManagers? I vividly remember building a simple inspector window in Swing that took me two whole days of messing with the dreaded GridBagLayoutManager, which I could have built in ten minutes with IB.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Cathy</title>
		<link>http://katidev.com/blog/2008/02/12/why-i-say-no-to-autoresizing/#comment-12</link>
		<dc:creator>Cathy</dc:creator>
		<pubDate>Sat, 16 Feb 2008 02:43:12 +0000</pubDate>
		<guid isPermaLink="false">http://katidev.com/blog/?p=5#comment-12</guid>
		<description>Yes, thank you for the tip. 

rdar://problem/5742732</description>
		<content:encoded><![CDATA[<p>Yes, thank you for the tip. </p>
<p>rdar://problem/5742732</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Hosey</title>
		<link>http://katidev.com/blog/2008/02/12/why-i-say-no-to-autoresizing/#comment-11</link>
		<dc:creator>Peter Hosey</dc:creator>
		<pubDate>Sat, 16 Feb 2008 02:37:16 +0000</pubDate>
		<guid isPermaLink="false">http://katidev.com/blog/?p=5#comment-11</guid>
		<description>Good to know that you're not simply abandoning resizing entirely. The autoresizing code sounds like something that would be good to post for others' use, if that's possible.

By the way, whenever you mention that you've filed a Radar bug, you should link to it for the benefit of any Apple employees who should run across your post. The syntax is rdar://problem/######.</description>
		<content:encoded><![CDATA[<p>Good to know that you&#8217;re not simply abandoning resizing entirely. The autoresizing code sounds like something that would be good to post for others&#8217; use, if that&#8217;s possible.</p>
<p>By the way, whenever you mention that you&#8217;ve filed a Radar bug, you should link to it for the benefit of any Apple employees who should run across your post. The syntax is rdar://problem/######.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 1.063 seconds -->
