Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Redesign the picture-in-picture window
Browse files Browse the repository at this point in the history
  • Loading branch information
robintown committed Dec 20, 2022
1 parent 42cc3ca commit 633c26d
Show file tree
Hide file tree
Showing 23 changed files with 471 additions and 220 deletions.
1 change: 1 addition & 0 deletions res/css/_components.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
@import "./components/views/location/_ZoomButtons.pcss";
@import "./components/views/messages/_MBeaconBody.pcss";
@import "./components/views/messages/shared/_MediaProcessingError.pcss";
@import "./components/views/pips/_WidgetPip.pcss";
@import "./components/views/settings/devices/_DeviceDetailHeading.pcss";
@import "./components/views/settings/devices/_DeviceDetails.pcss";
@import "./components/views/settings/devices/_DeviceExpandDetailsButton.pcss";
Expand Down
71 changes: 71 additions & 0 deletions res/css/components/views/pips/_WidgetPip.pcss
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
Copyright 2022 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

.mx_WidgetPip {
position: fixed;
left: 0;
top: 0;
/* Display above the widget element */
z-index: 102;
}

.mx_WidgetPip_content {
width: 320px;
height: 220px;
border-radius: 8px;
contain: paint;
color: $call-primary-content;
cursor: pointer;
}

.mx_WidgetPip_header,
.mx_WidgetPip_footer {
position: absolute;
left: 0;
height: 60px;
width: 100%;
box-sizing: border-box;
}

.mx_WidgetPip_header {
top: 0;
padding: $spacing-12;
display: flex;
font-size: $font-12px;
font-weight: $font-semi-bold;
background: linear-gradient(rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0));
}

.mx_WidgetPip_backButton {
height: $spacing-24;
display: flex;
align-items: center;
gap: $spacing-12;

> .mx_Icon {
color: $call-light-quaternary-content;
padding: 0;
}
}

.mx_WidgetPip_footer {
bottom: 0;
padding: $spacing-12 $spacing-8;
display: flex;
justify-content: flex-end;
align-items: flex-end;
background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.9));
}
2 changes: 1 addition & 1 deletion res/css/views/messages/_LegacyCallEvent.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ limitations under the License.
&.mx_LegacyCallEvent_rejected,
&.mx_LegacyCallEvent_noAnswer {
.mx_LegacyCallEvent_type_icon::before {
mask-image: url("$(res)/img/voip/declined-voice.svg");
mask-image: url("$(res)/img/element-icons/call/hangup.svg");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion res/css/views/rooms/_AppsDrawer.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

$MiniAppTileHeight: 200px;
$MiniAppTileHeight: 220px;
/* TODO this should be 300px but that's too large */
$MinWidth: 240px;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ limitations under the License.
background-color: $alert;

&::before {
mask-image: url("$(res)/img/voip/call-view/hangup.svg");
mask-image: url("$(res)/img/element-icons/call/hangup.svg");
background-color: white; /* Same on both themes */
}
}
Expand Down
24 changes: 12 additions & 12 deletions res/css/views/voip/_CallView.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ limitations under the License.
height: 100%;
border: none;
border-radius: inherit;
background-color: $call-lobby-background;
background-color: $call-background;
}

/* While the lobby is shown, the widget needs to stay loaded but hidden in the background */
Expand All @@ -44,8 +44,8 @@ limitations under the License.
min-height: 0;
flex-grow: 1;
padding: $spacing-12;
color: $call-lobby-primary-content;
background-color: $call-lobby-background;
color: $call-primary-content;
background-color: $call-background;
border-radius: 8px;

display: flex;
Expand All @@ -59,7 +59,7 @@ limitations under the License.
margin: $spacing-8 auto 0;

.mx_FacePile_faces .mx_BaseAvatar_image {
border-color: $call-lobby-background;
border-color: $call-background;
}
}

Expand All @@ -68,7 +68,7 @@ limitations under the License.
width: 100%;
max-width: 800px;
aspect-ratio: 1.5;
background-color: $call-lobby-system;
background-color: $call-system;

border-radius: 20px;
overflow: hidden;
Expand Down Expand Up @@ -106,7 +106,7 @@ limitations under the License.
left: 0;
right: 0;

background-color: rgba($call-lobby-background, 0.9);
background-color: rgba($call-background, 0.9);

display: flex;
justify-content: center;
Expand All @@ -122,7 +122,7 @@ limitations under the License.
width: $size;
height: $size;

background-color: $call-lobby-system;
background-color: $call-system;
border-radius: calc($size / 2);

&::before {
Expand All @@ -131,7 +131,7 @@ limitations under the License.
mask-repeat: no-repeat;
mask-size: 20px;
mask-position: center;
background-color: $call-lobby-primary-content;
background-color: $call-primary-content;
height: 100%;
width: 100%;
}
Expand All @@ -154,7 +154,7 @@ limitations under the License.
width: $size;
height: $size;

background-color: $call-lobby-system;
background-color: $call-system;
border-radius: calc($size / 2);

&::before {
Expand All @@ -163,7 +163,7 @@ limitations under the License.
mask-image: url("$(res)/img/feather-customised/chevron-down.svg");
mask-size: $size;
mask-position: center;
background-color: $call-lobby-primary-content;
background-color: $call-primary-content;
height: 100%;
width: 100%;
}
Expand All @@ -172,10 +172,10 @@ limitations under the License.
&.mx_CallView_deviceButtonWrapper_muted {
.mx_CallView_deviceButton,
.mx_CallView_deviceListButton {
background-color: $call-lobby-primary-content;
background-color: $call-primary-content;

&::before {
background-color: $call-lobby-system;
background-color: $call-system;
}
}

Expand Down
2 changes: 1 addition & 1 deletion res/css/views/voip/_LegacyCallPreview.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ limitations under the License.
border-radius: 8px;
overflow: hidden;
}
}
}
3 changes: 2 additions & 1 deletion res/img/element-icons/call/hangup.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions res/img/voip/call-view/hangup.svg

This file was deleted.

4 changes: 0 additions & 4 deletions res/img/voip/declined-voice.svg

This file was deleted.

7 changes: 4 additions & 3 deletions res/themes/dark/css/_dark.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,10 @@ $call-view-content-background: $quinary-content;

$video-feed-secondary-background: $system;

$call-lobby-system: $system;
$call-lobby-background: $background;
$call-lobby-primary-content: $primary-content;
$call-system: $system;
$call-background: $background;
$call-primary-content: $primary-content;
$call-light-quaternary-content: #c1c6cd;
/* ******************** */

/* Location sharing */
Expand Down
7 changes: 4 additions & 3 deletions res/themes/legacy-dark/css/_legacy-dark.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ $call-view-content-background: $quinary-content;

$video-feed-secondary-background: $system;

$call-lobby-system: $system;
$call-lobby-background: $background;
$call-lobby-primary-content: $primary-content;
$call-system: $system;
$call-background: $background;
$call-primary-content: $primary-content;
$call-light-quaternary-content: #c1c6cd;

$roomlist-filter-active-bg-color: $panel-actions;
$roomlist-bg-color: $header-panel-bg-color;
Expand Down
7 changes: 4 additions & 3 deletions res/themes/legacy-light/css/_legacy-light.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,10 @@ $call-view-content-background: #21262c;
$video-feed-secondary-background: #394049; /* XXX: Color from dark theme */

/* All of these are from dark theme */
$call-lobby-system: #21262c;
$call-lobby-background: #15191e;
$call-lobby-primary-content: #ffffff;
$call-system: #21262c;
$call-background: #15191e;
$call-primary-content: #ffffff;
$call-light-quaternary-content: #c1c6cd;

$username-variant1-color: #368bd6;
$username-variant2-color: #ac3ba8;
Expand Down
8 changes: 5 additions & 3 deletions res/themes/light/css/_light.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,11 @@ $video-feed-secondary-background: #394049; /* XXX: Color from dark theme */
$voipcall-plinth-color: $system;

/* All of these are from dark theme */
$call-lobby-system: #21262c;
$call-lobby-background: #15191e;
$call-lobby-primary-content: #ffffff;
$call-system: #21262c;
$call-background: #15191e;
$call-primary-content: #ffffff;
/* This one is from light theme */
$call-light-quaternary-content: #c1c6cd;
/* ******************** */

/* One-off colors */
Expand Down
50 changes: 40 additions & 10 deletions src/components/structures/PictureInPictureDragger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,20 @@ export default class PictureInPictureDragger extends React.Component<IProps> {
private desiredTranslationY = UIStore.instance.windowHeight - PADDING.bottom - PIP_VIEW_HEIGHT;
private translationX = this.desiredTranslationX;
private translationY = this.desiredTranslationY;
private moving = false;
private scheduledUpdate = new MarkedExecution(
private mouseHeld = false;
private scheduledUpdate: MarkedExecution = new MarkedExecution(
() => this.animationCallback(),
() => requestAnimationFrame(() => this.scheduledUpdate.trigger()),
);

private _moving = false;
public get moving(): boolean {
return this._moving;
}
private set moving(value: boolean) {
this._moving = value;
}

public componentDidMount() {
document.addEventListener("mousemove", this.onMoving);
document.addEventListener("mouseup", this.onEndMoving);
Expand Down Expand Up @@ -179,26 +187,47 @@ export default class PictureInPictureDragger extends React.Component<IProps> {
event.preventDefault();
event.stopPropagation();

this.moving = true;
this.initX = event.pageX - this.desiredTranslationX;
this.initY = event.pageY - this.desiredTranslationY;
this.scheduledUpdate.mark();
this.mouseHeld = true;
};

private onMoving = (event: React.MouseEvent | MouseEvent) => {
if (!this.moving) return;
private onMoving = (event: MouseEvent) => {
if (!this.mouseHeld) return;

event.preventDefault();
event.stopPropagation();

if (!this.moving) {
this.moving = true;
this.initX = event.pageX - this.desiredTranslationX;
this.initY = event.pageY - this.desiredTranslationY;
this.scheduledUpdate.mark();
}

this.setTranslation(event.pageX - this.initX, event.pageY - this.initY);
};

private onEndMoving = () => {
this.moving = false;
private onEndMoving = (event: MouseEvent) => {
if (!this.mouseHeld) return;

event.preventDefault();
event.stopPropagation();

this.mouseHeld = false;
// Delaying this to the next event loop tick is necessary for click
// event cancellation to work
setImmediate(() => (this.moving = false));
this.snap(true);
};

private onClickCapture = (event: React.MouseEvent) => {
// To prevent mouse up events during dragging from being double-counted
// as clicks, we cancel clicks before they ever reach the target
if (this.moving) {
event.preventDefault();
event.stopPropagation();
}
};

public render() {
const style = {
transform: `translateX(${this.translationX}px) translateY(${this.translationY}px)`,
Expand All @@ -209,6 +238,7 @@ export default class PictureInPictureDragger extends React.Component<IProps> {
className={this.props.className}
style={style}
ref={this.callViewWrapper}
onClickCapture={this.onClickCapture}
onDoubleClick={this.props.onDoubleClick}
>
{this.props.children({
Expand Down
Loading

0 comments on commit 633c26d

Please sign in to comment.