Commit ab9220f4 authored by Kuo Jen Wei's avatar Kuo Jen Wei Committed by Commit Bot

Fix CCA window/preview under square mode bugs.

This CL include following UI changes and bugfixes:
1. Fix CCA window size ratio to 16:9 under all modes.
2. Centered camera-mode icons on preview.
3. Fix bug measuring square mode preview in original video size bug
4. Fix w-letterbox-l not working bug.
5. Fix switch to/from square mode preview position jumping before ready.

Bug: 954672
Change-Id: I580e08db2fec3face310ca7cbf20a3edbfee6422
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1563132Reviewed-by: default avatarSheng-hao Tsao <shenghao@chromium.org>
Commit-Queue: Kuo Jen Wei <inker@chromium.org>
Auto-Submit: Kuo Jen Wei <inker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#653500}
parent b48e3356
...@@ -532,7 +532,7 @@ body:not(.w-letterbox).preview-vertical-dock #camera { ...@@ -532,7 +532,7 @@ body:not(.w-letterbox).preview-vertical-dock #camera {
position: relative; position: relative;
} }
body:.w-letterbox.w-letterbox-l #preview-wrapper { body.w-letterbox.w-letterbox-l #preview-wrapper {
left: 72px; left: 72px;
} }
...@@ -540,12 +540,12 @@ body:not(.w-letterbox).preview-vertical-dock #preview-wrapper { ...@@ -540,12 +540,12 @@ body:not(.w-letterbox).preview-vertical-dock #preview-wrapper {
bottom: calc((var(--bottom-line) + (var(--big-icon) / 2)) + 12px); bottom: calc((var(--bottom-line) + (var(--big-icon) / 2)) + 12px);
} }
body:not(.mode-switching).square-mode #preview-wrapper { body.square-preview #preview-wrapper {
height: 0; /* Calculate at runtime. */ height: 0; /* Calculate at runtime. */
width: 0; /* Calculate at runtime. */ width: 0; /* Calculate at runtime. */
} }
body:not(.mode-switching).square-mode #preview-video { body.square-preview #preview-video {
left: 0; /* Calculate at runtime. */ left: 0; /* Calculate at runtime. */
position: absolute; position: absolute;
top: 0; /* Calculate at runtime. */ top: 0; /* Calculate at runtime. */
......
...@@ -29,16 +29,16 @@ cca.views.camera.Layout = function() { ...@@ -29,16 +29,16 @@ cca.views.camera.Layout = function() {
* @type {CSSStyleDeclaration} * @type {CSSStyleDeclaration}
* @private * @private
*/ */
this.squareViewport_ = cca.views.camera.Layout.cssStyle_( this.squareViewport_ =
'body:not(.mode-switching).square-mode #preview-wrapper'); cca.views.camera.Layout.cssStyle_('body.square-preview #preview-wrapper');
/** /**
* CSS style of the video in square mode. * CSS style of the video in square mode.
* @type {CSSStyleDeclaration} * @type {CSSStyleDeclaration}
* @private * @private
*/ */
this.squareVideo_ = cca.views.camera.Layout.cssStyle_( this.squareVideo_ =
'body:not(.mode-switching).square-mode #preview-video'); cca.views.camera.Layout.cssStyle_('body.square-preview #preview-video');
// End of properties, seal the object. // End of properties, seal the object.
Object.seal(this); Object.seal(this);
...@@ -76,13 +76,17 @@ cca.views.camera.Layout.prototype.updatePreviewSize_ = function(fullWindow) { ...@@ -76,13 +76,17 @@ cca.views.camera.Layout.prototype.updatePreviewSize_ = function(fullWindow) {
// as they are not updated immediately. // as they are not updated immediately.
var video = document.querySelector('#preview-video'); var video = document.querySelector('#preview-video');
if (video.videoHeight) { if (video.videoHeight) {
var f = fullWindow ? Math.min : Math.max; var scale = cca.state.get('square-mode') ?
var scale = f(window.innerHeight / video.videoHeight, Math.min(window.innerHeight, window.innerWidth) /
window.innerWidth / video.videoWidth); Math.min(video.videoHeight, video.videoWidth) :
Math.min(
window.innerHeight / video.videoHeight,
window.innerWidth / video.videoWidth);
video.width = scale * video.videoWidth; video.width = scale * video.videoWidth;
video.height = scale * video.videoHeight; video.height = scale * video.videoHeight;
} }
var [viewportW, viewportH] = [video.width, video.height]; var [viewportW, viewportH] = [video.width, video.height];
cca.state.set('square-preview', cca.state.get('square-mode'));
if (cca.state.get('square-mode')) { if (cca.state.get('square-mode')) {
viewportW = viewportH = Math.min(video.width, video.height); viewportW = viewportH = Math.min(video.width, video.height);
this.squareVideo_.setProperty('left', `${(viewportW - video.width) / 2}px`); this.squareVideo_.setProperty('left', `${(viewportW - video.width) / 2}px`);
......
...@@ -219,9 +219,7 @@ cca.views.camera.Preview.prototype.onWindowResize_ = function(aspectRatio) { ...@@ -219,9 +219,7 @@ cca.views.camera.Preview.prototype.onWindowResize_ = function(aspectRatio) {
// TODO(yuli): Update min-width for resizing at portrait orientation. // TODO(yuli): Update min-width for resizing at portrait orientation.
var inner = chrome.app.window.current().innerBounds; var inner = chrome.app.window.current().innerBounds;
var innerW = inner.minWidth; var innerW = inner.minWidth;
var innerH = cca.state.get('square-mode') ? var innerH = Math.round(innerW * 9 / 16);
innerW :
Math.round(innerW / this.aspectRatio_);
// Limit window resizing capability by setting min-height. Don't limit // Limit window resizing capability by setting min-height. Don't limit
// max-height here as it may disable maximize/fullscreen capabilities. // max-height here as it may disable maximize/fullscreen capabilities.
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
data="../images/camera_focus_aim.svg" data="../images/camera_focus_aim.svg"
tabindex="-1" hidden></object> tabindex="-1" hidden></object>
</div> </div>
<div class="centered-overlay" id="camera-mode"></div>
</div> </div>
<div id="modes-group" class="buttons right-stripe"> <div id="modes-group" class="buttons right-stripe">
<label class="mode-item"> <label class="mode-item">
...@@ -129,7 +130,6 @@ ...@@ -129,7 +130,6 @@
<div class="centered-overlay"> <div class="centered-overlay">
<div id="timer-tick-msg"></div> <div id="timer-tick-msg"></div>
</div> </div>
<div class="centered-overlay" id="camera-mode"></div>
</div> </div>
<div id="settings"> <div id="settings">
<div class="menu"> <div class="menu">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment