mirror of
https://github.com/overte-org/overte.git
synced 2025-04-07 12:53:44 +02:00
add setLandscape call to tablet
This commit is contained in:
parent
36ad3af48e
commit
c62b07d26f
5 changed files with 47 additions and 14 deletions
|
@ -270,6 +270,11 @@ void Web3DOverlay::render(RenderArgs* args) {
|
|||
}
|
||||
}
|
||||
|
||||
if (_mayNeedResize) {
|
||||
_mayNeedResize = false;
|
||||
_webSurface->resize(QSize(_resolution.x, _resolution.y));
|
||||
}
|
||||
|
||||
vec2 halfSize = getSize() / 2.0f;
|
||||
vec4 color(toGlm(getColor()), getAlpha());
|
||||
|
||||
|
@ -491,6 +496,8 @@ void Web3DOverlay::setProperties(const QVariantMap& properties) {
|
|||
_inputMode = Touch;
|
||||
}
|
||||
}
|
||||
|
||||
_mayNeedResize = true;
|
||||
}
|
||||
|
||||
QVariant Web3DOverlay::getProperty(const QString& property) {
|
||||
|
|
|
@ -87,6 +87,8 @@ private:
|
|||
uint8_t _desiredMaxFPS { 10 };
|
||||
uint8_t _currentMaxFPS { 0 };
|
||||
|
||||
bool _mayNeedResize { false };
|
||||
|
||||
QMetaObject::Connection _mousePressConnection;
|
||||
QMetaObject::Connection _mouseReleaseConnection;
|
||||
QMetaObject::Connection _mouseMoveConnection;
|
||||
|
|
|
@ -63,7 +63,7 @@ signals:
|
|||
* @returns {Signal}
|
||||
*/
|
||||
void tabletNotification();
|
||||
|
||||
|
||||
private:
|
||||
void processMenuEvents(QObject* object, const QKeyEvent* event);
|
||||
void processTabletEvents(QObject* object, const QKeyEvent* event);
|
||||
|
@ -85,6 +85,7 @@ class TabletProxy : public QObject {
|
|||
Q_OBJECT
|
||||
Q_PROPERTY(QString name READ getName)
|
||||
Q_PROPERTY(bool toolbarMode READ getToolbarMode WRITE setToolbarMode)
|
||||
Q_PROPERTY(bool landscape READ getLandscape WRITE setLandscape)
|
||||
public:
|
||||
TabletProxy(QString name);
|
||||
|
||||
|
@ -173,6 +174,14 @@ public:
|
|||
*/
|
||||
Q_INVOKABLE bool onHomeScreen();
|
||||
|
||||
/**jsdoc
|
||||
* set tablet into our out of landscape mode
|
||||
* @function TabletProxy#setLandscape
|
||||
* @param landscape {bool} true for landscape, false for portrait
|
||||
*/
|
||||
Q_INVOKABLE void setLandscape(bool landscape) { _landscape = landscape; }
|
||||
Q_INVOKABLE bool getLandscape() { return _landscape; }
|
||||
|
||||
QQuickItem* getTabletRoot() const { return _qmlTabletRoot; }
|
||||
|
||||
QObject* getTabletSurface();
|
||||
|
@ -216,7 +225,7 @@ protected:
|
|||
void removeButtonsFromToolbar();
|
||||
|
||||
bool _initialScreen { false };
|
||||
QVariant _initialPath { "" };
|
||||
QVariant _initialPath { "" };
|
||||
QString _name;
|
||||
std::mutex _mutex;
|
||||
std::vector<QSharedPointer<TabletButtonProxy>> _tabletButtonProxies;
|
||||
|
@ -227,6 +236,7 @@ protected:
|
|||
|
||||
enum class State { Uninitialized, Home, Web, Menu, QML };
|
||||
State _state { State::Uninitialized };
|
||||
bool _landscape { false };
|
||||
};
|
||||
|
||||
/**jsdoc
|
||||
|
|
|
@ -113,6 +113,14 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location) {
|
|||
this.dpi = DEFAULT_DPI * (DEFAULT_WIDTH / this.width);
|
||||
}
|
||||
|
||||
this.getDimensions = function() {
|
||||
if (this.landscape) {
|
||||
return { x: this.width * 2, y: this.height, z: this.depth };
|
||||
} else {
|
||||
return { x: this.width, y: this.height, z: this.depth };
|
||||
}
|
||||
};
|
||||
|
||||
var modelURL = LOCAL_TABLET_MODEL_PATH;
|
||||
var tabletProperties = {
|
||||
name: "WebTablet Tablet",
|
||||
|
@ -123,18 +131,10 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location) {
|
|||
userData: JSON.stringify({
|
||||
"grabbableKey": {"grabbable": true}
|
||||
}),
|
||||
dimensions: {x: this.width, y: this.height, z: this.depth},
|
||||
dimensions: this.getDimensions(),
|
||||
parentID: AVATAR_SELF_ID
|
||||
};
|
||||
|
||||
this.getDimensions = function() {
|
||||
if (this.landscape) {
|
||||
return { x: this.width * 2, y: this.height, z: this.depth };
|
||||
} else {
|
||||
return { x: this.width, y: this.height, z: this.depth };
|
||||
}
|
||||
};
|
||||
|
||||
this.getTabletTextureResolution = function() {
|
||||
if (this.landscape) {
|
||||
return { x: TABLET_TEXTURE_RESOLUTION.x * 2, y: TABLET_TEXTURE_RESOLUTION.y };
|
||||
|
@ -215,7 +215,9 @@ WebTablet = function (url, width, dpi, hand, clientOnly, location) {
|
|||
}
|
||||
this.landscape = newLandscapeValue;
|
||||
Overlays.editOverlay(this.tabletEntityID, { dimensions: this.getDimensions() });
|
||||
Overlays.editOverlay(this.webOverlayID, { resolution: this.getTabletTextureResolution() });
|
||||
Overlays.editOverlay(this.webOverlayID, {
|
||||
resolution: this.getTabletTextureResolution()
|
||||
});
|
||||
};
|
||||
|
||||
this.state = "idle";
|
||||
|
@ -508,6 +510,7 @@ WebTablet.prototype.mousePressEvent = function (event) {
|
|||
tablet.gotoHomeScreen();
|
||||
this.setHomeButtonTexture();
|
||||
}
|
||||
Messages.sendLocalMessage("home", this.homeButtonID);
|
||||
}
|
||||
} else if (!HMD.active && (!overlayPickResults.intersects || overlayPickResults.overlayID !== this.webOverlayID)) {
|
||||
this.dragging = true;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
MyAvatar, Menu */
|
||||
|
||||
(function() { // BEGIN LOCAL_SCOPE
|
||||
var _this = this;
|
||||
var tabletShown = false;
|
||||
var tabletRezzed = false;
|
||||
var activeHand = null;
|
||||
|
@ -159,6 +160,7 @@
|
|||
|
||||
// close the WebTablet if it we go into toolbar mode.
|
||||
var toolbarMode = Tablet.getTablet("com.highfidelity.interface.tablet.system").toolbarMode;
|
||||
var landscape = Tablet.getTablet("com.highfidelity.interface.tablet.system").landscape;
|
||||
|
||||
if (tabletShown && toolbarMode) {
|
||||
closeTabletUI();
|
||||
|
@ -176,6 +178,9 @@
|
|||
}
|
||||
|
||||
updateTabletWidthFromSettings();
|
||||
if (UIWebTablet) {
|
||||
UIWebTablet.setLandscape(landscape);
|
||||
}
|
||||
|
||||
if (validCheckTime - now > MSECS_PER_SEC) {
|
||||
validCheckTime = now;
|
||||
|
@ -218,14 +223,20 @@
|
|||
|
||||
}
|
||||
|
||||
function toggleHand(channel, hand, senderUUID, localOnly) {
|
||||
function handleMessage(channel, hand, senderUUID, localOnly) {
|
||||
if (channel === "toggleHand") {
|
||||
activeHand = JSON.parse(hand);
|
||||
}
|
||||
if (channel === "home") {
|
||||
if (UIWebTablet) {
|
||||
Tablet.getTablet("com.highfidelity.interface.tablet.system").landscape = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Messages.subscribe("toggleHand");
|
||||
Messages.messageReceived.connect(toggleHand);
|
||||
Messages.subscribe("home");
|
||||
Messages.messageReceived.connect(handleMessage);
|
||||
|
||||
Script.setInterval(updateShowTablet, 100);
|
||||
|
||||
|
|
Loading…
Reference in a new issue