From 7c4ea855a838c2668fc0fffbaa1b297f5752b097 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 25 Mar 2015 14:50:25 -0700 Subject: [PATCH] Limit height of users window per screen space available --- examples/users.js | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/examples/users.js b/examples/users.js index 22fe89389f..18404340c5 100644 --- a/examples/users.js +++ b/examples/users.js @@ -54,6 +54,8 @@ var usersWindow = (function () { isVisible = true, viewportHeight, + isMirrorDisplay = false, + isFullscreenMirror = false, HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/", RADIO_BUTTON_SVG = HIFI_PUBLIC_BUCKET + "images/radio-button.svg", @@ -62,10 +64,21 @@ var usersWindow = (function () { radioButtonDiameter; function calculateWindowHeight() { + var AUDIO_METER_HEIGHT = 52, + MIRROR_HEIGHT = 220, + maxWindowHeight; + // Reserve 5 lines for window heading plus visibility heading and controls // Subtract windowLineSpacing for both end of user list and end of controls windowHeight = (linesOfUsers.length > 0 ? linesOfUsers.length + 5 : 5) * windowLineHeight - 2 * windowLineSpacing + VISIBILITY_SPACER_2D + 2 * WINDOW_MARGIN_2D; + + // Limit to height of window minus VU meter and mirror if displayed + maxWindowHeight = viewportHeight - AUDIO_METER_HEIGHT; + if (isMirrorDisplay && !isFullscreenMirror) { + maxWindowHeight -= MIRROR_HEIGHT; + } + windowHeight = Math.min(windowHeight, maxWindowHeight); } function updateOverlayPositions() { @@ -295,10 +308,20 @@ var usersWindow = (function () { } function onScriptUpdate() { - var oldViewportHeight = viewportHeight; + var oldViewportHeight = viewportHeight, + oldIsMirrorDisplay = isMirrorDisplay, + oldIsFullscreenMirror = isFullscreenMirror, + MIRROR_MENU_ITEM = "Mirror", + FULLSCREEN_MIRROR_MENU_ITEM = "Fullscreen Mirror"; viewportHeight = Controller.getViewportDimensions().y; - if (viewportHeight !== oldViewportHeight) { + isMirrorDisplay = Menu.isOptionChecked(MIRROR_MENU_ITEM); + isFullscreenMirror = Menu.isOptionChecked(FULLSCREEN_MIRROR_MENU_ITEM); + + if (viewportHeight !== oldViewportHeight + || isMirrorDisplay !== oldIsMirrorDisplay + || isFullscreenMirror !== oldIsFullscreenMirror) { + calculateWindowHeight(); updateOverlayPositions(); } }