flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <aha...@adobe.com>
Subject Re: git commit: [flex-sdk] [refs/heads/develop] - FLEX-24257 Fixed measured width of date field as it may vary month by month based on format.
Date Tue, 18 Jun 2013 13:53:53 GMT
Hi Justin,

Thanks for looking into it.  Seems like a reasonable approach, but one
concern is that adding a loop in measure may affect performance.  I'm
thinking of the DataGrid with lots of DateFields in the renderers.
Imagine a file system datagrid with creation, modification and
last-accessed date columns.

Do you have time to build a static cache based on
fontSize/fontstyle/fontweight.  There might be code in
EmbeddedFontRegistry you can borrow?

FWIW, another approach would be a "typicalDate" property so folks can
offer up the pattern that will reserve enough space for them, but I think
loop-and-cache is more "automatic".

-Alex

On 6/18/13 4:00 AM, "jmclean@apache.org" <jmclean@apache.org> wrote:

>Updated Branches:
>  refs/heads/develop 965ec7616 -> 04b8b35ca
>
>
>FLEX-24257 Fixed measured width of date field as it may vary month by
>month based on format.
>
>
>Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
>Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/04b8b35c
>Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/04b8b35c
>Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/04b8b35c
>
>Branch: refs/heads/develop
>Commit: 04b8b35ca28eb74323032ce3835944e6064a8902
>Parents: 965ec76
>Author: Justin Mclean <jmclean@apache.org>
>Authored: Tue Jun 18 20:58:45 2013 +1000
>Committer: Justin Mclean <jmclean@apache.org>
>Committed: Tue Jun 18 20:58:45 2013 +1000
>
>----------------------------------------------------------------------
> .../projects/mx/src/mx/controls/DateField.as     | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>----------------------------------------------------------------------
>
>
>http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/04b8b35c/frameworks/p
>rojects/mx/src/mx/controls/DateField.as
>----------------------------------------------------------------------
>diff --git a/frameworks/projects/mx/src/mx/controls/DateField.as
>b/frameworks/projects/mx/src/mx/controls/DateField.as
>index 9c65abc..e78074b 100644
>--- a/frameworks/projects/mx/src/mx/controls/DateField.as
>+++ b/frameworks/projects/mx/src/mx/controls/DateField.as
>@@ -2203,11 +2203,22 @@ public class DateField extends ComboBase
>         var buttonWidth:Number =
>downArrowButton.getExplicitOrMeasuredWidth();
>         var buttonHeight:Number =
>downArrowButton.getExplicitOrMeasuredHeight();
> 
>-        var bigDate:Date = new Date(2004, 12, 31);
>-        var txt:String = (_labelFunction != null) ?
>_labelFunction(bigDate) :
>-                            dateToString(bigDate, formatString);
>+        var bigDate:Date;
>+        var txt:String;
>+		var textWidth:Number;
>+		var maxWidth:Number = 0;
>+		
>+		// Width may vary based on date format
>+		for (var month:int = 0; month < 12; month++) {
>+			bigDate = new Date(2000, month, 28); // day 28 exist in all months
>+			txt = (_labelFunction != null) ? _labelFunction(bigDate) :
>dateToString(bigDate, formatString);
>+			textWidth = measureText(txt).width;
>+			if (textWidth > maxWidth) {
>+				maxWidth = textWidth;
>+			}
>+		}
> 
>-        measuredMinWidth = measuredWidth = measureText(txt).width + 8 +
>2 + buttonWidth;
>+        measuredMinWidth = measuredWidth = maxWidth + 8 + 2 +
>buttonWidth;
>         measuredMinWidth = measuredWidth += getStyle("paddingLeft") +
>getStyle("paddingRight");
>         measuredMinHeight = measuredHeight =
>textInput.getExplicitOrMeasuredHeight();
>     }
>


Mime
View raw message