org.symbian.tools.wrttools.previewer/preview/script/emulator.js
author Eugene Ostroukhov <eugeneo@symbian.org>
Thu, 01 Jul 2010 15:01:44 -0700
changeset 412 72448215f517
parent 407 c7c8bde493b1
child 423 742a5cb59f9a
permissions -rw-r--r--
Bug 2785 - Orientation and Resolution Controls Placements
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
402
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     1
/**
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     2
 * Copyright (c) 2009-2010 Symbian Foundation and/or its subsidiary(-ies). All
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     3
 * rights reserved. This component and the accompanying materials are made
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     4
 * available under the terms of the License "Eclipse Public License v1.0" which
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     5
 * accompanies this distribution, and is available at the URL
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     6
 * "http://www.eclipse.org/legal/epl-v10.html".
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     7
 * 
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     8
 * Initial Contributors: Nokia Corporation - initial contribution.
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     9
 * 
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    10
 * Contributors:
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    11
 * 
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    12
 * Description:
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    13
 * 
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    14
 */
403
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    15
var ORIENTATIONS = {
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    16
	DisplayRightUp : "DisplayRightUp",
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    17
	DisplayLeftUp : "DisplayLeftUp",
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    18
	DisplayUp : "DisplayUp",
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    19
	DisplayDown : "DisplayDown",
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    20
	DisplayUpwards : "DisplayUpwards",
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    21
	DisplayDownwards : "DisplayDownwards"
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    22
};
412
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
    23
var MODES = {
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
    24
	portrait : "portrait",
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
    25
	landscape : "landscape"
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
    26
};
403
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    27
402
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    28
function Emulator() {
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    29
	this.child = false;
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    30
	this.accelerationCallback = false;
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    31
	this.iconFile = 'preview/images/default-Icon.png';
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    32
	this.loaded = false;
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    33
	this.FORCE = 62;
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    34
	this.state = new EmulatorState(0, this.FORCE, 0, true);
403
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    35
	this.orientation = ORIENTATIONS.DisplayUp;
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    36
	this.modeForced = false;
402
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    37
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    38
	this.plist = {
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    39
		DisplayName : '',
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    40
		Identifier : '',
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    41
		MainHTML : '',
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    42
		AllowNetworkAccess : "false",
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    43
		Version : '',
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    44
		MiniViewEnabled : "false",
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    45
		is_browserReady : false
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    46
	};
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    47
};
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    48
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    49
Emulator.prototype.setAccelerationCallback = function(acceleration) {
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    50
	this.accelerationCallback = acceleration;
403
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    51
	this.accelerationCallback(this.state.XAxis, this.state.YAxis,
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    52
			this.state.ZAxis, this.orientation);
402
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    53
};
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    54
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    55
function orientationFromAcceleration(x, y, z) {
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    56
	var orientation = NOKIA.emulator.orientation;
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    57
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    58
	var xangle = Math.asin(x) * 180 / Math.PI;
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    59
	if (xangle > 55) {
403
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    60
		orientation = ORIENTATIONS.DisplayRightUp;
402
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    61
	} else if (xangle < -55) {
403
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    62
		orientation = ORIENTATIONS.DisplayLeftUp;
402
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    63
	}
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    64
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    65
	var yangle = Math.asin(y) * 180 / Math.PI;
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    66
	if (yangle > 55) {
403
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    67
		orientation = ORIENTATIONS.DisplayUp;
402
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    68
	} else if (yangle < -55) {
403
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    69
		orientation = ORIENTATIONS.DisplayDown;
402
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    70
	}
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    71
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    72
	var zangle = Math.asin(z) * 180 / Math.PI;
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    73
	if (zangle > 75) {
403
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    74
		orientation = ORIENTATIONS.DisplayUpwards;
402
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    75
	} else if (zangle < -75) {
403
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    76
		orientation = ORIENTATIONS.DisplayDownwards;
402
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    77
	}
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    78
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    79
	return orientation;
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    80
}
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    81
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    82
Emulator.prototype.accelerationChanged = function(x, y, z) {
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    83
	this.state.XAxis = x * this.FORCE;
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    84
	this.state.YAxis = y * this.FORCE;
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    85
	this.state.ZAxis = z * this.FORCE;
403
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    86
402
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    87
	var orientation = orientationFromAcceleration(x, y, z);
403
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    88
402
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    89
	if (orientation != this.orientation) {
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    90
		this.orientation = orientation;
412
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
    91
		NOKIA.helper.setPreference(EmulatorPreferences.ORIENTATION, orientation);
403
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    92
		NOKIA.emulator.render();
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    93
	}
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    94
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    95
	if (this.accelerationCallback) {
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    96
		this.accelerationCallback(this.state.XAxis, this.state.YAxis,
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    97
				this.state.ZAxis, this.orientation);
402
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    98
	}
403
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
    99
};
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   100
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   101
Emulator.prototype.setAccelerationValues = function(x, y, z) {
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   102
	window.setTimeout(function() {
412
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   103
		NOKIA.rotationSupport.setAngles(x * 90, y * 90, z * 90);
403
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   104
	}, 5);
402
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   105
};
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   106
412
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   107
Emulator.prototype.showOrientationAngles = function(orientation) {
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   108
	switch (orientation) {
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   109
	case ORIENTATIONS.DisplayUp:
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   110
		this.setAccelerationValues(0, 0, 0);
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   111
		break;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   112
	case ORIENTATIONS.DisplayDown:
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   113
		this.setAccelerationValues(2, 0, 0);
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   114
		break;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   115
	case ORIENTATIONS.DisplayRightUp:
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   116
		this.setAccelerationValues(-1, 0, 0);
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   117
		break;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   118
	case ORIENTATIONS.DisplayLeftUp:
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   119
		this.setAccelerationValues(1, 0, 0);
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   120
		break;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   121
	case ORIENTATIONS.DisplayUpwards:
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   122
		this.setAccelerationValues(NOKIA.mode == 'portrait' ? 0 : 1, 0, 1);
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   123
		break;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   124
	case ORIENTATIONS.DisplayDownwards:
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   125
		this.setAccelerationValues(NOKIA.mode == 'portrait' ? 0 : 1, 0, -1);
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   126
		break;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   127
	}
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   128
	this.orientation = orientation;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   129
	NOKIA.helper.setPreference(EmulatorPreferences.ORIENTATION, orientation);
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   130
	window.setTimeout(function() {
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   131
		NOKIA.emulator.render();
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   132
	}, 50);
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   133
};
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   134
402
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   135
Emulator.prototype.load = function() {
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   136
	if (this.loaded)
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   137
		return false;
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   138
	NOKIA.layout._console_minimized = (NOKIA.helper
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   139
			.getPreference('__SYM_NOKIA_CONSOLE_OPEN') != "true");
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   140
	// load the saved device Info
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   141
	var device = NOKIA.helper.getPreference('__SYM_NOKIA_EMULATOR_DEVICE');
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   142
	NOKIA.currentDevice = device || NOKIA.currentDevice;
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   143
407
c7c8bde493b1 Orientation controls were updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 403
diff changeset
   144
	// load the saved device mode
c7c8bde493b1 Orientation controls were updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 403
diff changeset
   145
	var mode = NOKIA.helper.getPreference('__SYM_NOKIA_EMULATOR_DEVICE_MODE');
c7c8bde493b1 Orientation controls were updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 403
diff changeset
   146
	if (mode != null)
c7c8bde493b1 Orientation controls were updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 403
diff changeset
   147
		NOKIA.mode = mode;
c7c8bde493b1 Orientation controls were updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 403
diff changeset
   148
412
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   149
	var orientation = NOKIA.helper.getPreference(EmulatorPreferences.ORIENTATION);
403
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   150
	if (orientation != null) {
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   151
		this.orientation = orientation;
412
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   152
		this.showOrientationAngles(orientation);
403
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   153
	}
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   154
402
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   155
	// SAVE the device DATA
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   156
	NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_DEVICE',
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   157
			NOKIA.currentDevice);
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   158
	NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_DEVICE_MODE', NOKIA.mode);
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   159
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   160
	this.loaded = true;
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   161
};
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   162
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   163
Emulator.prototype.render = function() {
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   164
	this.load();
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   165
	// Selecting Resoltion
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   166
	var resOptions = $("#resOptions")[0];
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   167
	for ( var i = 0; i < NOKIA.resolution.length; i++) {
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   168
		if (NOKIA.resolution[i] == NOKIA.currentDevice) {
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   169
			resOptions.options[i].selected = true;
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   170
			break;
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   171
		}
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   172
	}
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   173
403
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   174
	var deg = 0;
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   175
	switch (NOKIA.emulator.orientation) {
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   176
	case ORIENTATIONS.DisplayUp:
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   177
		deg = 0;
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   178
		break;
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   179
	case ORIENTATIONS.DisplayDown:
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   180
		deg = 180;
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   181
		break;
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   182
	case ORIENTATIONS.DisplayRightUp:
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   183
		deg = -90;
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   184
		break;
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   185
	case ORIENTATIONS.DisplayLeftUp:
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   186
		deg = 90;
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   187
		break;
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   188
	default:
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   189
		if (NOKIA.mode == 'portrait') {
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   190
			deg = 0;
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   191
		} else {
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   192
			deg = -90;
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   193
		}
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   194
		break;
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   195
	}
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   196
	if (this.orientationSupports() && !this.modeForced) {
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   197
		if (deg == 0) {
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   198
			NOKIA.mode = 'portrait';
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   199
		} else if (deg == -90) {
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   200
			NOKIA.mode = 'landscape';
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   201
		}
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   202
	}
407
c7c8bde493b1 Orientation controls were updated
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 403
diff changeset
   203
	NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_DEVICE_MODE', NOKIA.mode);
403
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   204
402
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   205
	if (!NOKIA.emulator.orientationSupports())
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   206
		NOKIA.mode = NOKIA.deviceList[NOKIA.currentDevice]['default'];
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   207
403
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   208
	this.setStyle();
402
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   209
403
ba20dd5983c7 Acceleration and orientation sensors support
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 402
diff changeset
   210
	var or = (NOKIA.mode == 'portrait') ? deg : (deg + 90);
402
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   211
	var val = "rotate(" + or + "deg)";
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   212
	$("#DeviceDisplayLayout").css("-moz-transform", val);
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   213
	$("#DeviceDisplayLayout").css("-webkit-transform", val);
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   214
};
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   215
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   216
Emulator.prototype.setMode = function(mode) {
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   217
	NOKIA.mode = mode;
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   218
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   219
	// SAVE the device DATA
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   220
	NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_DEVICE_MODE', NOKIA.mode);
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   221
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   222
	NOKIA.emulator.render();
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   223
};
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   224
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   225
Emulator.prototype.orientationSupports = function() {
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   226
	return NOKIA.deviceList[NOKIA.currentDevice]['orientation'];
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   227
};
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   228
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   229
Emulator.prototype.setStyle = function() {
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   230
	if (!NOKIA.helper.checkDependencies()) {
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   231
		setTimeout(NOKIA.emulator.setStyle, 1000);
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   232
	}
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   233
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   234
	var deviceProperties = NOKIA.deviceList[NOKIA.currentDevice][NOKIA.mode];
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   235
	var style = deviceProperties['style'];
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   236
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   237
	// Apply Style and propertis to Device layers
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   238
	$("#DeviceDisplayLayout").css(style['layout']);
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   239
	$('#DisplayArea').css(style['display']);
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   240
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   241
	NOKIA.emulator.setWidgetStyle();
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   242
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   243
	$('#SoftKeysArea').css( {
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   244
		'width' : style['menu']['width'] + 'px',
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   245
		'height' : style['menu']['height'] + 'px',
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   246
		'float' : style['menu']['float']
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   247
	});
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   248
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   249
	$('#SoftKeysArea > ul > li').css('width',
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   250
			parseInt(style['menu']['width'] / 2) - 10);
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   251
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   252
	NOKIA.emulator.setMenuItemsStyle();
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   253
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   254
	$('#SoftKeys').css(style['softkeys']);
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   255
	// $('#SoftKeys > a > img').css(style['softkeysImg']);
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   256
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   257
	NOKIA.menu.createSFKArea();
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   258
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   259
	$("#DeviceDisplayLayout").show();
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   260
	$("#InspectorTab").show();
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   261
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   262
	if (/chrome/.test(navigator.userAgent.toLowerCase())) {
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   263
		$("#InspectorBtn").show();
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   264
	}
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   265
	if (/mac/.test(navigator.userAgent.toLowerCase())) {
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   266
		$("#MacShortcut").show();
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   267
	} else {
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   268
		$("#UniversalShortcut").show();
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   269
	}
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   270
},
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   271
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   272
Emulator.prototype.setWidgetStyle = function() {
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   273
	var style = NOKIA.deviceList[NOKIA.currentDevice][NOKIA.mode]['style'];
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   274
	var height;
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   275
	if (NOKIA.menu.softkeys_visibility || NOKIA.menu.is_softkeys_visible)
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   276
		height = parseInt(style['widget']['height'] - style['menu']['height']);
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   277
	else
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   278
		height = style['widget']['height'];
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   279
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   280
	$('#WidgetArea').css( {
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   281
		'width' : style['widget']['width'] + 'px',
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   282
		'height' : height + 'px',
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   283
		'float' : style['widget']['float']
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   284
	});
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   285
};
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   286
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   287
Emulator.prototype.setMenuItemsStyle = function() {
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   288
	var style = NOKIA.deviceList[NOKIA.currentDevice][NOKIA.mode]['style'];
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   289
	var count = 1;
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   290
	try {
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   291
		if (NOKIA.emulator.child.menu) {
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   292
			count = parseInt(NOKIA.helper
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   293
					.getElementsLengthInObject(NOKIA.emulator.child.menu.items)) + 1;
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   294
		}
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   295
	} catch (e) {
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   296
		count = 1;
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   297
	}
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   298
	var height = parseInt(count * style['menu']['optionKeysheight']) + 10;
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   299
	var top = parseInt(style['widget']['height'] - height);
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   300
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   301
	$('#MenuItemsArea').css(
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   302
			{
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   303
				'width' : style['widget']['width'] + 'px',
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   304
				'height' : height + 'px',
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   305
				'marginTop' : '-2px',
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   306
				'top' : (style['widget']['height'] - height
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   307
						- style['menu']['height'] + 2)
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   308
						+ 'px',
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   309
				'position' : 'relative'
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   310
			});
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   311
};
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   312
412
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   313
Emulator.prototype.turn = function(direction) {
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   314
	var newOrientation = ORIENTATIONS.DisplayUp;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   315
	if (direction > 0) { // Clockwise
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   316
		switch (this.orientation) {
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   317
		case ORIENTATIONS.DisplayUp:
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   318
			newOrientation = ORIENTATIONS.DisplayLeftUp;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   319
			break;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   320
		case ORIENTATIONS.DisplayLeftUp:
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   321
			newOrientation = ORIENTATIONS.DisplayDown;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   322
			break;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   323
		case ORIENTATIONS.DisplayDown:
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   324
			newOrientation = ORIENTATIONS.DisplayRightUp;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   325
			break;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   326
		case ORIENTATIONS.DisplayRightUp:
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   327
			newOrientation = ORIENTATIONS.DisplayUp;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   328
			break;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   329
		default:
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   330
			if (this.mode == MODES.portrait) {
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   331
				newOrientation = ORIENTATIONS.DisplayRightUp;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   332
			} else {
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   333
				newOrientation = ORIENTATIONS.DisplayUp;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   334
			}
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   335
			break;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   336
		}
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   337
	} else {
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   338
		switch (this.orientation) {
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   339
		case ORIENTATIONS.DisplayUp:
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   340
			newOrientation = ORIENTATIONS.DisplayRightUp;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   341
			break;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   342
		case ORIENTATIONS.DisplayLeftUp:
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   343
			newOrientation = ORIENTATIONS.DisplayUp;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   344
			break;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   345
		case ORIENTATIONS.DisplayDown:
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   346
			newOrientation = ORIENTATIONS.DisplayLeftUp;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   347
			break;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   348
		case ORIENTATIONS.DisplayRightUp:
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   349
			newOrientation = ORIENTATIONS.DisplayDown;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   350
			break;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   351
		default:
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   352
			if (this.mode == MODES.portrait) {
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   353
				newOrientation = ORIENTATIONS.DisplayRightUp;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   354
			} else {
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   355
				newOrientation = ORIENTATIONS.DisplayUp;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   356
			}
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   357
			break;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   358
		}
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   359
	}
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   360
	this.orientation = newOrientation;
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   361
	this.showOrientationAngles(newOrientation);
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   362
	this.render();
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   363
};
72448215f517 Bug 2785 - Orientation and Resolution Controls Placements
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 407
diff changeset
   364
402
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   365
function EmulatorState(x, y, z, orientation) {
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   366
	this.XAxis = x;
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   367
	this.YAxis = y;
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   368
	this.ZAxis = z;
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   369
	this.portrait = orientation;
f943a50b6689 Acceleration and orientation - initial cut
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
   370
}