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