incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [2/13] wp7 commit: metaviewport tag content attribute user-scalable yes|no is observed.
Date Sat, 28 Apr 2012 00:26:43 GMT
metaviewport tag content attribute user-scalable yes|no is observed.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/commit/d6bd4ced
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/tree/d6bd4ced
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/diff/d6bd4ced

Branch: refs/heads/master
Commit: d6bd4cedbbb7014b697387f33a4c93c4b8f4a4a3
Parents: fa9fff9
Author: Jesse MacFadyen <purplecabbage@gmail.com>
Authored: Fri Apr 27 17:22:47 2012 -0700
Committer: Jesse MacFadyen <purplecabbage@gmail.com>
Committed: Fri Apr 27 17:22:47 2012 -0700

----------------------------------------------------------------------
 framework/Cordova/BrowserMouseHelper.cs |  105 +++++++++++---------------
 framework/CordovaView.xaml.cs           |    2 +-
 2 files changed, 44 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/d6bd4ced/framework/Cordova/BrowserMouseHelper.cs
----------------------------------------------------------------------
diff --git a/framework/Cordova/BrowserMouseHelper.cs b/framework/Cordova/BrowserMouseHelper.cs
index 4a23d41..65fc825 100644
--- a/framework/Cordova/BrowserMouseHelper.cs
+++ b/framework/Cordova/BrowserMouseHelper.cs
@@ -62,17 +62,15 @@ namespace WP7CordovaClassLib
         /// the WebBrowser control;
         /// </summary>
         public bool ScrollDisabled { get; set; }
-        public bool ZoomDisabled { get; set; }
-
-        private bool isScaling = false;
 
         private bool userScalable = true;
         private double maxScale = 2.0;
         private double minScale = 0.5;
         protected Border border;
+        private bool firstMouseMove = false;
 
 
-        public BrowserMouseHelper(WebBrowser browser)
+        public BrowserMouseHelper(ref WebBrowser browser)
         {
             _browser = browser;
             browser.Loaded += new RoutedEventHandler(browser_Loaded);
@@ -86,7 +84,6 @@ namespace WP7CordovaClassLib
             var grid = VisualTreeHelper.GetChild(panZoom, 0);
             border = VisualTreeHelper.GetChild(grid, 0) as Border;
 
-
             if (border != null)
             {
                 border.ManipulationStarted += Border_ManipulationStarted;
@@ -142,10 +139,8 @@ namespace WP7CordovaClassLib
 
         void Browser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs
e)
         {
-
             ParseViewportMeta();
 
-
             try
             {
                 _browser.InvokeScript("execScript", MinifiedMouseScript);
@@ -154,7 +149,6 @@ namespace WP7CordovaClassLib
             {
                 Debug.WriteLine("BrowserHelper Failed to install mouse script in WebBrowser");
             }
-
         }
 
         bool InvokeSimulatedMouseEvent(string eventName, Point pos)
@@ -167,7 +161,6 @@ namespace WP7CordovaClassLib
                 {
                     return bCancelled;
                 }
-
             }
             catch (Exception)
             {
@@ -177,83 +170,91 @@ namespace WP7CordovaClassLib
             return bCancelled;
         }
 
+        #region Hold
+
         void Border_Hold(object sender, GestureEventArgs e)
         {
             Debug.WriteLine("Border_Hold");
             e.Handled = true;
         }
 
+        #endregion
+
+        #region DoubleTap
+
         void Border_DoubleTap(object sender, GestureEventArgs e)
         {
             Debug.WriteLine("Border_DoubleTap");
             e.Handled = true;
         }
 
-        void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
-        {
-            if (isScaling)
-                return;
+        #endregion
 
-            Debug.WriteLine("Border_MouseLeftButtonDown");
+        #region MouseEvents
 
+        void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+        {
             border.MouseMove += new MouseEventHandler(Border_MouseMove);
             border.MouseLeftButtonUp += new MouseButtonEventHandler(Border_MouseLeftButtonUp);
 
+            firstMouseMove = true;
+
             Point pos = e.GetPosition(_browser);
+            InvokeSimulatedMouseEvent("mousedown", pos);
+        }
 
-            bool bCancelled = InvokeSimulatedMouseEvent("mousedown", pos);
-            e.Handled = bCancelled;
-            ScrollDisabled = bCancelled;
+        void Border_MouseMove(object sender, MouseEventArgs e)
+        {
+            Point pos = e.GetPosition(_browser);
+            bool retVal = InvokeSimulatedMouseEvent("mousemove", pos);
+            // only the return value from the first mouse move event should be used to determine
if scrolling is prevented.
+            if (firstMouseMove)
+            {
+                ScrollDisabled = retVal;
+            }
         }
 
         void Border_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
         {
-            if (isScaling)
-                return;
-
-            Debug.WriteLine("Border_MouseLeftButtonUp");
-
             border.MouseMove -= new MouseEventHandler(Border_MouseMove);
             border.MouseLeftButtonUp -= new MouseButtonEventHandler(Border_MouseLeftButtonUp);
             Point pos = e.GetPosition(_browser);
-
-            bool bCancelled = InvokeSimulatedMouseEvent("mouseup", pos);
-            e.Handled = bCancelled;
+            e.Handled = InvokeSimulatedMouseEvent("mouseup", pos);
             ScrollDisabled = false;
         }
 
 
-        void Border_MouseMove(object sender, MouseEventArgs e)
-        {
-            if (isScaling)
-                return;
+        #endregion
 
-            Debug.WriteLine("Border_MouseMove");
-            Point pos = e.GetPosition(_browser);
-
-            bool bCancelled = InvokeSimulatedMouseEvent("mousemove", pos);
-            //ScrollDisabled = bCancelled;
-
-        }
+        #region ManipulationEvents
 
         void Border_ManipulationStarted(object sender, ManipulationStartedEventArgs e)
         {
-            Debug.WriteLine("Border_ManipulationStarted");
-
             if (ScrollDisabled)
             {
                 e.Handled = true;
                 e.Complete();
             }
-            else if (this.userScalable)
+        }
+
+        private void Border_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
+        {
+            // optionally suppress zoom
+            if ((ScrollDisabled || !userScalable) && (e.DeltaManipulation.Scale.X
!= 0.0 || e.DeltaManipulation.Scale.Y != 0.0))
+            {
+                e.Handled = true;
+                e.Complete();
+            }
+            // optionally suppress scrolling
+            if (ScrollDisabled && (e.DeltaManipulation.Translation.X != 0.0 || e.DeltaManipulation.Translation.Y
!= 0.0))
             {
-                isScaling = true;
+                e.Handled = true;
+                e.Complete();
             }
         }
 
         private void Border_ManipulationCompleted(object sender, ManipulationCompletedEventArgs
e)
         {
-            Debug.WriteLine("Border_ManipulationCompleted");
             // suppress zoom
             if (!userScalable && e.FinalVelocities != null)
             {
@@ -263,30 +264,10 @@ namespace WP7CordovaClassLib
                     e.Handled = true;
                 }
             }
-            this.isScaling = false;
         }
 
-        private void Border_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
-        {
-            Debug.WriteLine("Border_ManipulationDelta");
-            // optionally suppress zoom
-            if (isScaling)
-            {
-                return;
-            }
 
-            if (!userScalable && (e.DeltaManipulation.Scale.X != 0.0 || e.DeltaManipulation.Scale.Y
!= 0.0))
-            {
-                e.Handled = true;
-                e.Complete();
-            }
-            // optionally suppress scrolling
-            if (ScrollDisabled && (e.DeltaManipulation.Translation.X != 0.0 || e.DeltaManipulation.Translation.Y
!= 0.0) )
-            {
-                e.Handled = true;
-                e.Complete();
-            }
-        }
+        #endregion
 
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp7/blob/d6bd4ced/framework/CordovaView.xaml.cs
----------------------------------------------------------------------
diff --git a/framework/CordovaView.xaml.cs b/framework/CordovaView.xaml.cs
index 776bf23..86b3298 100644
--- a/framework/CordovaView.xaml.cs
+++ b/framework/CordovaView.xaml.cs
@@ -147,7 +147,7 @@ namespace WP7CordovaClassLib
 
             // initializes native execution logic
             this.nativeExecution = new NativeExecution(ref this.CordovaBrowser);
-            this.bmHelper = new BrowserMouseHelper(this.CordovaBrowser);
+            this.bmHelper = new BrowserMouseHelper(ref this.CordovaBrowser);
         }
 
         


Mime
View raw message