You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ma...@apache.org on 2013/10/05 01:03:17 UTC
[11/15] git commit: [flex-sdk] [refs/heads/develop] -
https://issues.apache.org/jira/browse/FLEX-33777 Dagrid for mobile - clean up
code to prepare integration with SDK (continued) renamed class DensityUtil2
to MobileGridUtil
https://issues.apache.org/jira/browse/FLEX-33777 Dagrid for mobile
- clean up code to prepare integration with SDK (continued)
renamed class DensityUtil2 to MobileGridUtil
Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/908829a5
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/908829a5
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/908829a5
Branch: refs/heads/develop
Commit: 908829a5184c42ecea79de9ae5e3136c271bcec2
Parents: b2fb601
Author: mamsellem <ma...@systar.com>
Authored: Fri Oct 4 01:37:03 2013 +0200
Committer: mamsellem <ma...@systar.com>
Committed: Fri Oct 4 01:37:03 2013 +0200
----------------------------------------------------------------------
.../src/spark/layouts/MobileGridLayout.as | 4 +-
.../src/spark/utils/MobileGridUtil.as | 80 ++++++++++++++++++++
2 files changed, 82 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/908829a5/frameworks/projects/experimental_mobile/src/spark/layouts/MobileGridLayout.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/layouts/MobileGridLayout.as b/frameworks/projects/experimental_mobile/src/spark/layouts/MobileGridLayout.as
index 8149dfe..a5901d8 100644
--- a/frameworks/projects/experimental_mobile/src/spark/layouts/MobileGridLayout.as
+++ b/frameworks/projects/experimental_mobile/src/spark/layouts/MobileGridLayout.as
@@ -4,7 +4,7 @@ import mx.core.mx_internal;
import spark.components.MobileGrid;
import spark.components.supportClasses.MobileGridColumn;
-import spark.utils.DensityUtil2;
+import spark.utils.MobileGridUtil;
use namespace mx_internal;
@@ -66,7 +66,7 @@ public class MobileGridLayout extends VerticalLayout
else
{
colWidth = isNaN(col.width) ? 100 : col.width;
- colActualWidth = DensityUtil2.dpiScale(colWidth);
+ colActualWidth = MobileGridUtil.dpiScale(colWidth);
col.actualWidth = colActualWidth; // can immediately set actual width
totalFixedWidths += colActualWidth;
}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/908829a5/frameworks/projects/experimental_mobile/src/spark/utils/MobileGridUtil.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/experimental_mobile/src/spark/utils/MobileGridUtil.as b/frameworks/projects/experimental_mobile/src/spark/utils/MobileGridUtil.as
new file mode 100644
index 0000000..41a8344
--- /dev/null
+++ b/frameworks/projects/experimental_mobile/src/spark/utils/MobileGridUtil.as
@@ -0,0 +1,80 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package spark.utils
+{
+
+import mx.core.DPIClassification;
+import mx.core.FlexGlobals;
+import mx.managers.SystemManager;
+
+import spark.components.Application;
+
+//TODO merge with spark.utils.DensityUtil
+
+/**
+ * @private
+ * Utility class for MobileGrid
+ *
+ * @langversion 3.0
+ * @playerversion AIR 3.8
+ * @productversion Flex 4.11
+
+ */
+
+
+public class MobileGridUtil
+{
+
+ private static var _setApplicationDPI:Number = 0;
+
+ /** returns the actual value for a value authored for <code>sourceDPI</code>, taking into account any dpi scaling.
+ * <ul>
+ * <li> If Application.applicationDPI has been set, which means dpi scaling factor is already applied, return the original value.</li>
+ * <li> If Application.applicationDPI has not been set, then return scaled value runTimeDPI / sourceDPI </li>
+ * </li>
+ * @param sourceDPI
+ * @return scaled value
+ */
+ public static function dpiScale(value:Number, sourceDPI:Number = DPIClassification.DPI_160):Number
+ {
+ var appDPI:Number = getSetApplicationDPI();
+ if (isNaN(appDPI))
+ {
+ var runDPI:Number = FlexGlobals.topLevelApplication.runtimeDPI;
+ return value * runDPI / sourceDPI;
+ }
+ else
+ return value; // already scaled
+ }
+
+ /**
+ * returns the applicationDPI that was explicitly set in top level application , or NaN if none */
+ private static function getSetApplicationDPI():Number
+ {
+ if (_setApplicationDPI == 0)
+ {
+ var application:Application = FlexGlobals.topLevelApplication as Application;
+ var sm:SystemManager = application ? application.systemManager as SystemManager : null;
+ _setApplicationDPI = sm ? sm.info()["applicationDPI"] : NaN;
+ }
+ return _setApplicationDPI;
+ }
+
+}
+}