mirror of
https://github.com/overte-org/overte.git
synced 2025-04-16 12:51:15 +02:00
Tablet scale settings now take effect soon after they are changed.
This commit is contained in:
parent
2e29ff3114
commit
f5c3d41f2c
2 changed files with 63 additions and 8 deletions
|
@ -279,6 +279,38 @@ WebTablet.prototype.getOverlayObject = function () {
|
|||
return Overlays.getOverlayObject(this.webOverlayID);
|
||||
};
|
||||
|
||||
WebTablet.prototype.setWidth = function (width) {
|
||||
|
||||
// scale factor of natural tablet dimensions.
|
||||
this.width = width || DEFAULT_WIDTH;
|
||||
var tabletScaleFactor = this.width / TABLET_NATURAL_DIMENSIONS.x;
|
||||
this.height = TABLET_NATURAL_DIMENSIONS.y * tabletScaleFactor;
|
||||
this.depth = TABLET_NATURAL_DIMENSIONS.z * tabletScaleFactor;
|
||||
this.dpi = DEFAULT_DPI * (DEFAULT_WIDTH / this.width);
|
||||
|
||||
// update tablet model dimensions
|
||||
if (this.tabletIsOverlay) {
|
||||
Overlays.editOverlay(this.tabletEntityID, {dimensions: {x: this.width, y: this.height, z: this.depth}});
|
||||
} else {
|
||||
Entities.editEntity(this.tabletEntityID, {dimensions: {x: this.width, y: this.height, z: this.depth}});
|
||||
}
|
||||
|
||||
// update webOverlay
|
||||
var WEB_ENTITY_Z_OFFSET = (this.depth / 2);
|
||||
var WEB_ENTITY_Y_OFFSET = 0.004;
|
||||
Overlays.editOverlay(this.webOverlayID, {
|
||||
localPosition: { x: 0, y: WEB_ENTITY_Y_OFFSET, z: -WEB_ENTITY_Z_OFFSET },
|
||||
dpi: this.dpi
|
||||
});
|
||||
|
||||
// update homeButton
|
||||
var HOME_BUTTON_Y_OFFSET = (this.height / 2) - (this.height / 20);
|
||||
Overlays.editOverlay(this.homeButtonID, {
|
||||
localPosition: {x: -0.001, y: -HOME_BUTTON_Y_OFFSET, z: 0.0},
|
||||
dimensions: { x: 4 * tabletScaleFactor, y: 4 * tabletScaleFactor, z: 4 * tabletScaleFactor}
|
||||
});
|
||||
};
|
||||
|
||||
WebTablet.prototype.destroy = function () {
|
||||
Overlays.deleteOverlay(this.webOverlayID);
|
||||
if (this.tabletIsOverlay) {
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
var preMakeTime = Date.now();
|
||||
var validCheckTime = Date.now();
|
||||
var debugTablet = false;
|
||||
var tabletScalePercentage = 100.0;
|
||||
UIWebTablet = null;
|
||||
|
||||
Script.include("../libraries/WebTablet.js");
|
||||
|
@ -48,26 +49,45 @@
|
|||
return true;
|
||||
}
|
||||
|
||||
function getTabletScalePercentageFromSettings() {
|
||||
var toolbarMode = Tablet.getTablet("com.highfidelity.interface.tablet.system").toolbarMode;
|
||||
var tabletScalePercentage = DEFAULT_TABLET_SCALE;
|
||||
if (!toolbarMode) {
|
||||
if (HMD.active) {
|
||||
tabletScalePercentage = Settings.getValue("hmdTabletScale") || DEFAULT_TABLET_SCALE;
|
||||
} else {
|
||||
tabletScalePercentage = Settings.getValue("desktopTabletScale") || DEFAULT_TABLET_SCALE;
|
||||
}
|
||||
}
|
||||
return tabletScalePercentage;
|
||||
}
|
||||
|
||||
function updateTabletWidthFromSettings() {
|
||||
var newTabletScalePercentage = getTabletScalePercentageFromSettings();
|
||||
if (newTabletScalePercentage !== tabletScalePercentage && UIWebTablet) {
|
||||
tabletScalePercentage = newTabletScalePercentage;
|
||||
UIWebTablet.setWidth(DEFAULT_WIDTH * (tabletScalePercentage / 100));
|
||||
}
|
||||
}
|
||||
|
||||
function onHmdChanged() {
|
||||
updateTabletWidthFromSettings();
|
||||
}
|
||||
|
||||
function rezTablet() {
|
||||
if (debugTablet) {
|
||||
print("TABLET rezzing");
|
||||
}
|
||||
var toolbarMode = Tablet.getTablet("com.highfidelity.interface.tablet.system").toolbarMode;
|
||||
var TABLET_SCALE = DEFAULT_TABLET_SCALE;
|
||||
if (toolbarMode) {
|
||||
TABLET_SCALE = Settings.getValue("desktopTabletScale") || DEFAULT_TABLET_SCALE;
|
||||
} else {
|
||||
TABLET_SCALE = Settings.getValue("hmdTabletScale") || DEFAULT_TABLET_SCALE;
|
||||
}
|
||||
|
||||
tabletScalePercentage = getTabletScalePercentageFromSettings();
|
||||
UIWebTablet = new WebTablet("qml/hifi/tablet/TabletRoot.qml",
|
||||
DEFAULT_WIDTH * (TABLET_SCALE / 100),
|
||||
DEFAULT_WIDTH * (tabletScalePercentage / 100),
|
||||
null, activeHand, true);
|
||||
UIWebTablet.register();
|
||||
HMD.tabletID = UIWebTablet.tabletEntityID;
|
||||
HMD.homeButtonID = UIWebTablet.homeButtonID;
|
||||
HMD.tabletScreenID = UIWebTablet.webOverlayID;
|
||||
HMD.displayModeChanged.connect(onHmdChanged);
|
||||
|
||||
tabletRezzed = true;
|
||||
}
|
||||
|
@ -166,6 +186,8 @@
|
|||
tablet.updateAudioBar(currentMicLevel);
|
||||
}
|
||||
|
||||
updateTabletWidthFromSettings();
|
||||
|
||||
if (validCheckTime - now > MSECS_PER_SEC) {
|
||||
validCheckTime = now;
|
||||
if (tabletRezzed && UIWebTablet && !tabletIsValid()) {
|
||||
|
@ -180,6 +202,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
// check for change in tablet scale.
|
||||
|
||||
if (HMD.showTablet && !tabletShown && !toolbarMode) {
|
||||
UserActivityLogger.openedTablet(visibleToOthers);
|
||||
|
|
Loading…
Reference in a new issue