mirror of
https://github.com/overte-org/overte.git
synced 2025-04-07 22:33:04 +02:00
Merge pull request #9595 from hyperlogic/bug-fix/tablet-ui-bugfixes
tablet-ui: Bug fixes
This commit is contained in:
commit
bac5bd5c0e
6 changed files with 54 additions and 6 deletions
|
@ -540,6 +540,9 @@ Q_GUI_EXPORT void qt_gl_set_global_share_context(QOpenGLContext *context);
|
|||
|
||||
Setting::Handle<int> sessionRunTime{ "sessionRunTime", 0 };
|
||||
|
||||
const float DEFAULT_HMD_TABLET_SCALE_PERCENT = 100.0f;
|
||||
const float DEFAULT_DESKTOP_TABLET_SCALE_PERCENT = 75.0f;
|
||||
|
||||
Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bool runServer, QString runServerPathOption) :
|
||||
QApplication(argc, argv),
|
||||
_shouldRunServer(runServer),
|
||||
|
@ -557,6 +560,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
_mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)),
|
||||
_previousScriptLocation("LastScriptLocation", DESKTOP_LOCATION),
|
||||
_fieldOfView("fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES),
|
||||
_hmdTabletScale("hmdTabletScale", DEFAULT_HMD_TABLET_SCALE_PERCENT),
|
||||
_desktopTabletScale("desktopTabletScale", DEFAULT_DESKTOP_TABLET_SCALE_PERCENT),
|
||||
_constrainToolbarPosition("toolbar/constrainToolbarToCenterX", true),
|
||||
_scaleMirror(1.0f),
|
||||
_rotateMirror(0.0f),
|
||||
|
@ -2318,6 +2323,14 @@ void Application::setFieldOfView(float fov) {
|
|||
}
|
||||
}
|
||||
|
||||
void Application::setHMDTabletScale(float hmdTabletScale) {
|
||||
_hmdTabletScale.set(hmdTabletScale);
|
||||
}
|
||||
|
||||
void Application::setDesktopTabletScale(float desktopTabletScale) {
|
||||
_desktopTabletScale.set(desktopTabletScale);
|
||||
}
|
||||
|
||||
void Application::setSettingConstrainToolbarPosition(bool setting) {
|
||||
_constrainToolbarPosition.set(setting);
|
||||
DependencyManager::get<OffscreenUi>()->setConstrainToolbarToCenterX(setting);
|
||||
|
|
|
@ -208,6 +208,11 @@ public:
|
|||
float getFieldOfView() { return _fieldOfView.get(); }
|
||||
void setFieldOfView(float fov);
|
||||
|
||||
float getHMDTabletScale() { return _hmdTabletScale.get(); }
|
||||
void setHMDTabletScale(float hmdTabletScale);
|
||||
float getDesktopTabletScale() { return _desktopTabletScale.get(); }
|
||||
void setDesktopTabletScale(float desktopTabletScale);
|
||||
|
||||
float getSettingConstrainToolbarPosition() { return _constrainToolbarPosition.get(); }
|
||||
void setSettingConstrainToolbarPosition(bool setting);
|
||||
|
||||
|
@ -539,6 +544,8 @@ private:
|
|||
|
||||
Setting::Handle<QString> _previousScriptLocation;
|
||||
Setting::Handle<float> _fieldOfView;
|
||||
Setting::Handle<float> _hmdTabletScale;
|
||||
Setting::Handle<float> _desktopTabletScale;
|
||||
Setting::Handle<bool> _constrainToolbarPosition;
|
||||
|
||||
float _scaleMirror;
|
||||
|
|
|
@ -70,10 +70,27 @@ void setupPreferences() {
|
|||
}
|
||||
|
||||
// UI
|
||||
static const QString UI_CATEGORY { "UI" };
|
||||
{
|
||||
auto getter = []()->bool { return qApp->getSettingConstrainToolbarPosition(); };
|
||||
auto setter = [](bool value) { qApp->setSettingConstrainToolbarPosition(value); };
|
||||
preferences->addPreference(new CheckPreference("UI", "Constrain Toolbar Position to Horizontal Center", getter, setter));
|
||||
preferences->addPreference(new CheckPreference(UI_CATEGORY, "Constrain Toolbar Position to Horizontal Center", getter, setter));
|
||||
}
|
||||
{
|
||||
auto getter = []()->float { return qApp->getHMDTabletScale(); };
|
||||
auto setter = [](float value) { qApp->setHMDTabletScale(value); };
|
||||
auto preference = new SpinnerPreference(UI_CATEGORY, "HMD Tablet Scale %", getter, setter);
|
||||
preference->setMin(20);
|
||||
preference->setMax(500);
|
||||
preferences->addPreference(preference);
|
||||
}
|
||||
{
|
||||
auto getter = []()->float { return qApp->getDesktopTabletScale(); };
|
||||
auto setter = [](float value) { qApp->setDesktopTabletScale(value); };
|
||||
auto preference = new SpinnerPreference(UI_CATEGORY, "Desktop Tablet Scale %", getter, setter);
|
||||
preference->setMin(20);
|
||||
preference->setMax(500);
|
||||
preferences->addPreference(preference);
|
||||
}
|
||||
|
||||
// Snapshots
|
||||
|
|
|
@ -2568,7 +2568,7 @@ function MyController(hand) {
|
|||
};
|
||||
|
||||
this.maybeScale = function(props) {
|
||||
if (!objectScalingEnabled) {
|
||||
if (!objectScalingEnabled || this.isTablet(this.grabbedEntity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,12 @@ WebTablet = function (url, width, dpi, hand, clientOnly) {
|
|||
var tabletScaleFactor = this.width / TABLET_NATURAL_DIMENSIONS.x;
|
||||
this.height = TABLET_NATURAL_DIMENSIONS.y * tabletScaleFactor;
|
||||
this.depth = TABLET_NATURAL_DIMENSIONS.z * tabletScaleFactor;
|
||||
this.dpi = dpi || DEFAULT_DPI;
|
||||
|
||||
if (dpi) {
|
||||
this.dpi = dpi;
|
||||
} else {
|
||||
this.dpi = DEFAULT_DPI * (DEFAULT_WIDTH / this.width);
|
||||
}
|
||||
|
||||
var tabletProperties = {
|
||||
name: "WebTablet Tablet",
|
||||
|
@ -252,12 +257,14 @@ WebTablet.prototype.geometryChanged = function (geometry) {
|
|||
// calclulate the appropriate position of the tablet in world space, such that it fits in the center of the screen.
|
||||
// with a bit of padding on the top and bottom.
|
||||
WebTablet.prototype.calculateWorldAttitudeRelativeToCamera = function () {
|
||||
var DEFAULT_DESKTOP_TABLET_SCALE = 75;
|
||||
var DESKTOP_TABLET_SCALE = Settings.getValue("desktopTabletScale") || DEFAULT_DESKTOP_TABLET_SCALE;
|
||||
var fov = (Settings.getValue('fieldOfView') || DEFAULT_VERTICAL_FIELD_OF_VIEW) * (Math.PI / 180);
|
||||
var MAX_PADDING_FACTOR = 2.2;
|
||||
var PADDING_FACTOR = Math.min(Window.innerHeight / TABLET_TEXTURE_RESOLUTION.y, MAX_PADDING_FACTOR);
|
||||
var TABLET_HEIGHT = (TABLET_TEXTURE_RESOLUTION.y / this.dpi) * INCHES_TO_METERS;
|
||||
var WEB_ENTITY_Z_OFFSET = (this.depth / 2);
|
||||
var dist = (PADDING_FACTOR * TABLET_HEIGHT) / (2 * Math.tan(fov / 2)) - WEB_ENTITY_Z_OFFSET;
|
||||
var dist = (PADDING_FACTOR * TABLET_HEIGHT) / (2 * Math.tan(fov / 2) * (DESKTOP_TABLET_SCALE / 100)) - WEB_ENTITY_Z_OFFSET;
|
||||
return {
|
||||
position: Vec3.sum(Camera.position, Vec3.multiply(dist, Quat.getFront(Camera.orientation))),
|
||||
rotation: Quat.multiply(Camera.orientation, ROT_Y_180)
|
||||
|
@ -359,7 +366,7 @@ WebTablet.prototype.getPosition = function () {
|
|||
|
||||
WebTablet.prototype.mousePressEvent = function (event) {
|
||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||
var entityPickResults = Entities.findRayIntersection(pickRay, true); // non-accurate picking
|
||||
var entityPickResults = Entities.findRayIntersection(pickRay, true, [this.tabletEntityID]); // non-accurate picking
|
||||
if (entityPickResults.intersects && entityPickResults.entityID === this.tabletEntityID) {
|
||||
var overlayPickResults = Overlays.findRayIntersection(pickRay);
|
||||
if (overlayPickResults.intersects && overlayPickResults.overlayID === HMD.homeButtonID) {
|
||||
|
|
|
@ -24,7 +24,11 @@
|
|||
function showTabletUI() {
|
||||
tabletShown = true;
|
||||
print("show tablet-ui");
|
||||
UIWebTablet = new WebTablet("qml/hifi/tablet/TabletRoot.qml", null, null, activeHand, true);
|
||||
|
||||
var DEFAULT_WIDTH = 0.4375;
|
||||
var DEFAULT_HMD_TABLET_SCALE = 100;
|
||||
var HMD_TABLET_SCALE = Settings.getValue("hmdTabletScale") || DEFAULT_HMD_TABLET_SCALE;
|
||||
UIWebTablet = new WebTablet("qml/hifi/tablet/TabletRoot.qml", DEFAULT_WIDTH * (HMD_TABLET_SCALE / 100), null, activeHand, true);
|
||||
UIWebTablet.register();
|
||||
HMD.tabletID = UIWebTablet.tabletEntityID;
|
||||
HMD.homeButtonID = UIWebTablet.homeButtonEntity;
|
||||
|
|
Loading…
Reference in a new issue