You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by Greg Brown <gk...@mac.com> on 2009/10/12 17:53:18 UTC

Re: svn commit: r824385

FYI, this change fixes a minor layout issue in TerraFormSkin - the flag was meant to be bottom-aligned with the baseline, but it was actually top-aligned, which produced some strange results.  :-)

I fixed the bug, but the alignment still looked a bit odd, so I reverted to the previous layout behavior of always vertically centering the flag on the field. However, it would be nice to attempt to support some sort of baseline alignment here if we can. The main problem is that images don't have baselines.

One solution would be to add a baseline property to Image. ImageViewSkin would use this property to determine its own baseline, which could then be used by TerraFormSkin to align the flag to the field's baseline.


On Monday, October 12, 2009, at 11:30AM, <gb...@apache.org> wrote:
>Author: gbrown
>Date: Mon Oct 12 15:30:09 2009
>New Revision: 824385
>
>URL: http://svn.apache.org/viewvc?rev=824385&view=rev
>Log:
>Fix flag alignment bug in TerraFormSkin (restore previous behavior that always centers the flag).
>
>
>Modified:
>    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFormSkin.java
>
>Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFormSkin.java
>URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFormSkin.java?rev=824385&r1=824384&r2=824385&view=diff
>==============================================================================
>--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFormSkin.java (original)
>+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/terra/TerraFormSkin.java Mon Oct 12 15:30:09 2009
>@@ -292,6 +292,7 @@
>                     if (alignToBaseline) {
>                         int labelBaseLine = label.getBaseline(label.getWidth());
>                         int fieldBaseLine = field.getBaseline(fieldSize.width);
>+
>                         if (labelBaseLine != -1 && fieldBaseLine != -1) {
>                             int baseline = Math.max(labelBaseLine, fieldBaseLine);
>                             int belowBaseline = Math.max(fieldSize.height - fieldBaseLine,
>@@ -299,8 +300,6 @@
>                             rowHeight = baseline + belowBaseline;
>                             labelY = rowY + (baseline - labelBaseLine);
>                             fieldY = rowY + (baseline - fieldBaseLine);
>-                            // make the bottom of the flag line up with baseline
>-                            flagImageY = rowY + (flagImageView.getHeight() - baseline);
>                         } else {
>                             // if they don't both have baselines, default to
>                             // non-baseline behaviour
>@@ -308,8 +307,10 @@
>                                 FLAG_IMAGE_SIZE));
>                             fieldY = rowY;
>                             labelY = rowY;
>-                            flagImageY = rowY + (rowHeight - flagImageView.getHeight()) / 2;
>                         }
>+
>+                        // Vertically center the flag on the row
>+                        flagImageY = rowY + (rowHeight - flagImageView.getHeight()) / 2;
>                     } else {
>                         rowHeight = Math.max(label.getHeight(), Math.max(field.getHeight(),
>                             FLAG_IMAGE_SIZE));
>
>
>
>