#2458 Toolbar.prefSize() in Javascript

SlimerDude Thu 10 Sep 2015

When calculating the preferred width of a Toolbar (in Javascript) it currently just takes the width of the widest child. Which is fine if you only have one button!

So this patch adds up the preferred width of all the children.

diff -r a77e9070251b src/fwt/js/ToolBarPeer.js
--- a/src/fwt/js/ToolBarPeer.js	Fri Sep 04 09:11:51 2015 -0400
+++ b/src/fwt/js/ToolBarPeer.js	Thu Sep 10 21:25:06 2015 +0100
@@ -32,7 +32,7 @@
   {
     var kid  = kids.get(i);
     var pref = kid.peer.prefSize(kid);
-    pw = Math.max(pw, pref.m_w);
+    pw += pref.m_w + 4;
     ph = Math.max(ph, pref.m_h);
   }
   return fan.gfx.Size.make(pw+14, ph+14);  // add padding/border

The extra + 4 comes from relayout() which lays out the kids with:

x += pref.m_w + 4;

andy Mon 21 Sep 2015

Login or Signup to reply.