# HG changeset patch # User Eugene Ostroukhov # Date 1278021704 25200 # Node ID 72448215f5179e5fec2e7224c64ae8ff08ca15f4 # Parent 07412dc8e169bfca00a8a08930f87cb23d99a995 Bug 2785 - Orientation and Resolution Controls Placements diff -r 07412dc8e169 -r 72448215f517 org.symbian.tools.wrttools.previewer/preview/css/style.css --- a/org.symbian.tools.wrttools.previewer/preview/css/style.css Thu Jul 01 09:57:41 2010 -0700 +++ b/org.symbian.tools.wrttools.previewer/preview/css/style.css Thu Jul 01 15:01:44 2010 -0700 @@ -729,4 +729,17 @@ margin-right: 15px; text-align: center; width: 6ex; -} \ No newline at end of file +} + +.button-clockwise { + background: url("../images/rotate-buttons.png") !important; +} + +.button-cclockwise { + background: url("../images/rotate-buttons.png") !important; + background-attachment: scroll !important; + background-position: 16px 0 !important; +} + + + diff -r 07412dc8e169 -r 72448215f517 org.symbian.tools.wrttools.previewer/preview/images/rotate-buttons.png Binary file org.symbian.tools.wrttools.previewer/preview/images/rotate-buttons.png has changed diff -r 07412dc8e169 -r 72448215f517 org.symbian.tools.wrttools.previewer/preview/images/rotate-left.png Binary file org.symbian.tools.wrttools.previewer/preview/images/rotate-left.png has changed diff -r 07412dc8e169 -r 72448215f517 org.symbian.tools.wrttools.previewer/preview/images/rotate-right.png Binary file org.symbian.tools.wrttools.previewer/preview/images/rotate-right.png has changed diff -r 07412dc8e169 -r 72448215f517 org.symbian.tools.wrttools.previewer/preview/script/accelerometer.js --- a/org.symbian.tools.wrttools.previewer/preview/script/accelerometer.js Thu Jul 01 09:57:41 2010 -0700 +++ b/org.symbian.tools.wrttools.previewer/preview/script/accelerometer.js Thu Jul 01 15:01:44 2010 -0700 @@ -14,7 +14,7 @@ setupListeners("zaxis", "zleft", "zright", updateAngleZ, this.angleZ); window.setTimeout(function() { - control.paint(); + control.paint(true); }, 50); function setupListeners(inputId, leftArrow, rightArrow, fn, initial) { @@ -99,7 +99,7 @@ var r = 62; - var xy = (this.angleX - 180) * Math.PI / 180; + var xy = (180 - this.angleX) * Math.PI / 180; var yz = (this.angleY - 180) * Math.PI / 180; var xz = (180 - this.angleZ) * Math.PI / 180 + Math.PI / 2; diff -r 07412dc8e169 -r 72448215f517 org.symbian.tools.wrttools.previewer/preview/script/emulator.js --- a/org.symbian.tools.wrttools.previewer/preview/script/emulator.js Thu Jul 01 09:57:41 2010 -0700 +++ b/org.symbian.tools.wrttools.previewer/preview/script/emulator.js Thu Jul 01 15:01:44 2010 -0700 @@ -20,6 +20,10 @@ DisplayUpwards : "DisplayUpwards", DisplayDownwards : "DisplayDownwards" }; +var MODES = { + portrait : "portrait", + landscape : "landscape" +}; function Emulator() { this.child = false; @@ -84,7 +88,7 @@ if (orientation != this.orientation) { this.orientation = orientation; - NOKIA.helper.setPreference("__SYM_DEVICE_ORIENTATION", orientation); + NOKIA.helper.setPreference(EmulatorPreferences.ORIENTATION, orientation); NOKIA.emulator.render(); } @@ -96,12 +100,38 @@ Emulator.prototype.setAccelerationValues = function(x, y, z) { window.setTimeout(function() { - NOKIA.emulator.accelerationChanged(x, y, z); - NOKIA.rotationSupport.setAngles(x * 90, y * 90, - z * 90); + NOKIA.rotationSupport.setAngles(x * 90, y * 90, z * 90); }, 5); }; +Emulator.prototype.showOrientationAngles = function(orientation) { + switch (orientation) { + case ORIENTATIONS.DisplayUp: + this.setAccelerationValues(0, 0, 0); + break; + case ORIENTATIONS.DisplayDown: + this.setAccelerationValues(2, 0, 0); + break; + case ORIENTATIONS.DisplayRightUp: + this.setAccelerationValues(-1, 0, 0); + break; + case ORIENTATIONS.DisplayLeftUp: + this.setAccelerationValues(1, 0, 0); + break; + case ORIENTATIONS.DisplayUpwards: + this.setAccelerationValues(NOKIA.mode == 'portrait' ? 0 : 1, 0, 1); + break; + case ORIENTATIONS.DisplayDownwards: + this.setAccelerationValues(NOKIA.mode == 'portrait' ? 0 : 1, 0, -1); + break; + } + this.orientation = orientation; + NOKIA.helper.setPreference(EmulatorPreferences.ORIENTATION, orientation); + window.setTimeout(function() { + NOKIA.emulator.render(); + }, 50); +}; + Emulator.prototype.load = function() { if (this.loaded) return false; @@ -116,29 +146,10 @@ if (mode != null) NOKIA.mode = mode; - var orientation = NOKIA.helper.getPreference("__SYM_DEVICE_ORIENTATION"); + var orientation = NOKIA.helper.getPreference(EmulatorPreferences.ORIENTATION); if (orientation != null) { this.orientation = orientation; - switch (orientation) { - case ORIENTATIONS.DisplayUp: - this.setAccelerationValues(0, 0, 0); - break; - case ORIENTATIONS.DisplayDown: - this.setAccelerationValues(2, 0, 0); - break; - case ORIENTATIONS.DisplayRightUp: - this.setAccelerationValues(1, 0, 0); - break; - case ORIENTATIONS.DisplayLeftUp: - this.setAccelerationValues(-1, 0, 0); - break; - case ORIENTATIONS.DisplayUpwards: - this.setAccelerationValues(NOKIA.mode == 'portrait' ? 0 : 1, 0, 1); - break; - case ORIENTATIONS.DisplayDownwards: - this.setAccelerationValues(NOKIA.mode == 'portrait' ? 0 : 1, 0, -1); - break; - } + this.showOrientationAngles(orientation); } // SAVE the device DATA @@ -299,6 +310,58 @@ }); }; +Emulator.prototype.turn = function(direction) { + var newOrientation = ORIENTATIONS.DisplayUp; + if (direction > 0) { // Clockwise + switch (this.orientation) { + case ORIENTATIONS.DisplayUp: + newOrientation = ORIENTATIONS.DisplayLeftUp; + break; + case ORIENTATIONS.DisplayLeftUp: + newOrientation = ORIENTATIONS.DisplayDown; + break; + case ORIENTATIONS.DisplayDown: + newOrientation = ORIENTATIONS.DisplayRightUp; + break; + case ORIENTATIONS.DisplayRightUp: + newOrientation = ORIENTATIONS.DisplayUp; + break; + default: + if (this.mode == MODES.portrait) { + newOrientation = ORIENTATIONS.DisplayRightUp; + } else { + newOrientation = ORIENTATIONS.DisplayUp; + } + break; + } + } else { + switch (this.orientation) { + case ORIENTATIONS.DisplayUp: + newOrientation = ORIENTATIONS.DisplayRightUp; + break; + case ORIENTATIONS.DisplayLeftUp: + newOrientation = ORIENTATIONS.DisplayUp; + break; + case ORIENTATIONS.DisplayDown: + newOrientation = ORIENTATIONS.DisplayLeftUp; + break; + case ORIENTATIONS.DisplayRightUp: + newOrientation = ORIENTATIONS.DisplayDown; + break; + default: + if (this.mode == MODES.portrait) { + newOrientation = ORIENTATIONS.DisplayRightUp; + } else { + newOrientation = ORIENTATIONS.DisplayUp; + } + break; + } + } + this.orientation = newOrientation; + this.showOrientationAngles(newOrientation); + this.render(); +}; + function EmulatorState(x, y, z, orientation) { this.XAxis = x; this.YAxis = y; diff -r 07412dc8e169 -r 72448215f517 org.symbian.tools.wrttools.previewer/preview/script/helper.js --- a/org.symbian.tools.wrttools.previewer/preview/script/helper.js Thu Jul 01 09:57:41 2010 -0700 +++ b/org.symbian.tools.wrttools.previewer/preview/script/helper.js Thu Jul 01 15:01:44 2010 -0700 @@ -306,6 +306,19 @@ $(".tabs-bottom .ui-tabs-nav, .tabs-bottom .ui-tabs-nav > *").removeClass( "ui-corner-all ui-corner-top").addClass("ui-corner-bottom"); + $("#clockwise").button( { + icons : { + primary : "button-clockwise" + }, + text : null + }).click(function() {NOKIA.emulator.turn(1);}); + $("#cclockwise").button( { + icons : { + primary : "button-cclockwise" + }, + text : null + }).click(function() {NOKIA.emulator.turn(-1);}); + $("#xleft").button( { icons : { primary : 'ui-icon-triangle-1-w' diff -r 07412dc8e169 -r 72448215f517 org.symbian.tools.wrttools.previewer/preview/script/nokia.js --- a/org.symbian.tools.wrttools.previewer/preview/script/nokia.js Thu Jul 01 09:57:41 2010 -0700 +++ b/org.symbian.tools.wrttools.previewer/preview/script/nokia.js Thu Jul 01 15:01:44 2010 -0700 @@ -174,5 +174,6 @@ window.onresize = NOKIA.layout.render; var EmulatorPreferences = { - SELECTED_TAB:"__SYM_SELECTED_CONTROLS_TAB" + SELECTED_TAB: "__SYM_SELECTED_CONTROLS_TAB", + ORIENTATION: "__SYM_DEVICE_ORIENTATION" }; diff -r 07412dc8e169 -r 72448215f517 org.symbian.tools.wrttools.previewer/preview/wrt_preview.html --- a/org.symbian.tools.wrttools.previewer/preview/wrt_preview.html Thu Jul 01 09:57:41 2010 -0700 +++ b/org.symbian.tools.wrttools.previewer/preview/wrt_preview.html Thu Jul 01 15:01:44 2010 -0700 @@ -99,12 +99,14 @@ Screen Resolution: +
 
+
 
@@ -112,9 +114,9 @@ No canvas available -
-
-
+
 
 
+
 
 
+