From f733f2680c94fad910ce9686aa2645bc90ebc160 Mon Sep 17 00:00:00 2001 From: "jamiewalch@chromium.org" Date: Wed, 14 May 2014 06:10:16 +0000 Subject: Implement apps v2 custom window frame. The default apps v2 container is pretty basic. We want to provide something that looks prettier and also implements some functionality specific to our use-case: * When connected to a host, a disconnect icon is added to the window controls (it's therefore no longer needed in the tool-bar). * When connected to a host, maximize == full-screen. * In full-screen mode, the window controls are still accessible, but are auto-hidden near the top-left corner (but not obscuring it, since it's often a hot-spot on the server). * For touch-screen devices with no concept of hover, clicking the "stub" will also reveal the controls. There should be no change to the v1 UX, but I don't plan on landing this CL before the M36 branch point, just in case. BUG=134213 Review URL: https://codereview.chromium.org/265393005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270342 0039d316-1c4b-4281-b951-d872f2087c98 --- remoting/remoting.gyp | 1 + remoting/remoting_webapp_files.gypi | 8 ++ remoting/resources/drag.webp | Bin 0 -> 148 bytes remoting/resources/icon_close.webp | Bin 0 -> 410 bytes remoting/resources/icon_disconnect.webp | Bin 0 -> 360 bytes remoting/resources/icon_maximize_restore.webp | Bin 0 -> 350 bytes remoting/resources/icon_minimize.webp | Bin 0 -> 176 bytes remoting/resources/remoting_strings.grd | 17 ++- remoting/webapp/background.js | 3 +- remoting/webapp/client_session.js | 86 ++++++++----- remoting/webapp/event_handlers.js | 6 + remoting/webapp/fullscreen_v2.js | 2 + remoting/webapp/html/template_main.html | 92 +++++++------- remoting/webapp/html/toolbar.html | 12 +- remoting/webapp/html/window_frame.html | 29 +++++ remoting/webapp/js_proto/chrome_proto.js | 1 + remoting/webapp/main.css | 4 +- remoting/webapp/remoting.js | 2 + remoting/webapp/toolbar.css | 2 +- remoting/webapp/window_frame.css | 174 +++++++++++++++++++++++++ remoting/webapp/window_frame.js | 175 ++++++++++++++++++++++++++ 21 files changed, 533 insertions(+), 81 deletions(-) create mode 100644 remoting/resources/drag.webp create mode 100644 remoting/resources/icon_close.webp create mode 100644 remoting/resources/icon_disconnect.webp create mode 100644 remoting/resources/icon_maximize_restore.webp create mode 100644 remoting/resources/icon_minimize.webp create mode 100644 remoting/webapp/html/window_frame.html create mode 100644 remoting/webapp/window_frame.css create mode 100644 remoting/webapp/window_frame.js diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp index 128ce31..0e2ffc8 100644 --- a/remoting/remoting.gyp +++ b/remoting/remoting.gyp @@ -206,6 +206,7 @@ 'webapp/manifest.json.jinja2', 'webapp/paired_client_manager.js', 'webapp/remoting.js', + 'webapp/window_frame.js', ], }, 'actions': [ diff --git a/remoting/remoting_webapp_files.gypi b/remoting/remoting_webapp_files.gypi index fca8cbe..ba94d40 100644 --- a/remoting/remoting_webapp_files.gypi +++ b/remoting/remoting_webapp_files.gypi @@ -90,6 +90,7 @@ 'webapp/menu_button.js', 'webapp/ui_mode.js', 'webapp/toolbar.js', + 'webapp/window_frame.js', ], # UI files for controlling the local machine as a host. 'remoting_webapp_js_ui_host_control_files': [ @@ -169,10 +170,15 @@ 'remoting_webapp_resource_files': [ 'resources/disclosure_arrow_down.webp', 'resources/disclosure_arrow_right.webp', + 'resources/drag.webp', 'resources/host_setup_instructions.webp', + 'resources/icon_close.webp', 'resources/icon_cross.webp', + 'resources/icon_disconnect.webp', 'resources/icon_help.webp', 'resources/icon_host.webp', + 'resources/icon_maximize_restore.webp', + 'resources/icon_minimize.webp', 'resources/icon_pencil.webp', 'resources/icon_warning.webp', 'resources/infographic_my_computers.webp', @@ -188,6 +194,7 @@ 'webapp/scale-to-fit.webp', 'webapp/spinner.gif', 'webapp/toolbar.css', + 'webapp/window_frame.css', ], 'remoting_webapp_files': [ @@ -225,6 +232,7 @@ 'webapp/html/ui_header.html', 'webapp/html/ui_it2me.html', 'webapp/html/ui_me2me.html', + 'webapp/html/window_frame.html', ], }, diff --git a/remoting/resources/drag.webp b/remoting/resources/drag.webp new file mode 100644 index 0000000..e93f0ef Binary files /dev/null and b/remoting/resources/drag.webp differ diff --git a/remoting/resources/icon_close.webp b/remoting/resources/icon_close.webp new file mode 100644 index 0000000..65ee17c Binary files /dev/null and b/remoting/resources/icon_close.webp differ diff --git a/remoting/resources/icon_disconnect.webp b/remoting/resources/icon_disconnect.webp new file mode 100644 index 0000000..ac23d83 Binary files /dev/null and b/remoting/resources/icon_disconnect.webp differ diff --git a/remoting/resources/icon_maximize_restore.webp b/remoting/resources/icon_maximize_restore.webp new file mode 100644 index 0000000..a91c1cc Binary files /dev/null and b/remoting/resources/icon_maximize_restore.webp differ diff --git a/remoting/resources/icon_minimize.webp b/remoting/resources/icon_minimize.webp new file mode 100644 index 0000000..a21cad0 Binary files /dev/null and b/remoting/resources/icon_minimize.webp differ diff --git a/remoting/resources/remoting_strings.grd b/remoting/resources/remoting_strings.grd index b9d8bc2..2161914 100644 --- a/remoting/resources/remoting_strings.grd +++ b/remoting/resources/remoting_strings.grd @@ -552,9 +552,24 @@ For information about privacy, please see the Google Privacy Policy (http://goo. waiting for connection… - + Full screen + + Exit full screen + + + Close window + + + Maximize window + + + Minimize window + + + Restore window + Get started diff --git a/remoting/webapp/background.js b/remoting/webapp/background.js index 118b7e57..1976b91 100644 --- a/remoting/webapp/background.js +++ b/remoting/webapp/background.js @@ -8,7 +8,8 @@ var kNewWindowId = 'new-window'; function createWindow() { chrome.app.window.create('main.html', { 'width': 800, - 'height': 600 + 'height': 600, + 'frame': 'none' }); }; diff --git a/remoting/webapp/client_session.js b/remoting/webapp/client_session.js index 7b0d80e..23c8814 100644 --- a/remoting/webapp/client_session.js +++ b/remoting/webapp/client_session.js @@ -176,28 +176,29 @@ remoting.ClientSession.prototype.updateScrollbarVisibility = function() { if (!this.shrinkToFit_) { // Determine whether or not horizontal or vertical scrollbars are // required, taking into account their width. - needsVerticalScroll = window.innerHeight < this.plugin_.desktopHeight; - needsHorizontalScroll = window.innerWidth < this.plugin_.desktopWidth; + var clientArea = this.getClientArea_(); + needsVerticalScroll = clientArea.height < this.plugin_.desktopHeight; + needsHorizontalScroll = clientArea.width < this.plugin_.desktopWidth; var kScrollBarWidth = 16; if (needsHorizontalScroll && !needsVerticalScroll) { needsVerticalScroll = - window.innerHeight - kScrollBarWidth < this.plugin_.desktopHeight; + clientArea.height - kScrollBarWidth < this.plugin_.desktopHeight; } else if (!needsHorizontalScroll && needsVerticalScroll) { needsHorizontalScroll = - window.innerWidth - kScrollBarWidth < this.plugin_.desktopWidth; + clientArea.width - kScrollBarWidth < this.plugin_.desktopWidth; } } - var htmlNode = /** @type {HTMLElement} */ (document.documentElement); + var scroller = document.getElementById('scroller'); if (needsHorizontalScroll) { - htmlNode.classList.remove('no-horizontal-scroll'); + scroller.classList.remove('no-horizontal-scroll'); } else { - htmlNode.classList.add('no-horizontal-scroll'); + scroller.classList.add('no-horizontal-scroll'); } if (needsVerticalScroll) { - htmlNode.classList.remove('no-vertical-scroll'); + scroller.classList.remove('no-vertical-scroll'); } else { - htmlNode.classList.add('no-vertical-scroll'); + scroller.classList.add('no-vertical-scroll'); } }; @@ -568,6 +569,9 @@ remoting.ClientSession.prototype.removePlugin = function() { function() { remoting.fullscreen.removeListener(listener); }); + if (remoting.windowFrame) { + remoting.windowFrame.setConnected(false); + } // Remove mediasource-rendering class from video-contained - this will also // hide the