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

Commit 6e6a26f

Browse files
authored
Merge pull request #5710 from SimonBrandner/resizable-call-view
Resizable CallView
2 parents fa53b1c + 202ead4 commit 6e6a26f

File tree

8 files changed

+104
-36
lines changed

8 files changed

+104
-36
lines changed

res/css/_components.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@
250250
@import "./views/voice_messages/_Waveform.scss";
251251
@import "./views/voip/_CallContainer.scss";
252252
@import "./views/voip/_CallView.scss";
253+
@import "./views/voip/_CallViewForRoom.scss";
253254
@import "./views/voip/_DialPad.scss";
254255
@import "./views/voip/_DialPadContextMenu.scss";
255256
@import "./views/voip/_DialPadModal.scss";

res/css/views/voip/_CallView.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@ limitations under the License.
2727
.mx_CallView_large {
2828
padding-bottom: 10px;
2929
margin: 5px 5px 5px 18px;
30+
display: flex;
31+
flex-direction: column;
32+
flex: 1;
3033

3134
.mx_CallView_voice {
32-
height: 360px;
35+
flex: 1;
3336
}
3437
}
3538

@@ -104,6 +107,7 @@ limitations under the License.
104107

105108
.mx_CallView_video {
106109
width: 100%;
110+
height: 100%;
107111
position: relative;
108112
z-index: 30;
109113
border-radius: 8px;
@@ -177,6 +181,7 @@ limitations under the License.
177181
flex-direction: row;
178182
align-items: center;
179183
justify-content: left;
184+
flex-shrink: 0;
180185
}
181186

182187
.mx_CallView_header_callType {
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
Copyright 2021 Šimon Brandner <[email protected]>
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
.mx_CallViewForRoom {
18+
overflow: hidden;
19+
20+
.mx_CallViewForRoom_ResizeWrapper {
21+
display: flex;
22+
margin-bottom: 8px;
23+
24+
&:hover .mx_CallViewForRoom_ResizeHandle {
25+
// Need to use important to override element style attributes
26+
// set by re-resizable
27+
width: 100% !important;
28+
29+
display: flex;
30+
justify-content: center;
31+
32+
&::after {
33+
content: '';
34+
margin-top: 3px;
35+
36+
border-radius: 4px;
37+
38+
height: 4px;
39+
width: 100%;
40+
max-width: 64px;
41+
42+
background-color: $primary-fg-color;
43+
}
44+
}
45+
}
46+
}

res/css/views/voip/_VideoFeed.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License.
1616

1717
.mx_VideoFeed_remote {
1818
width: 100%;
19-
max-height: 100%;
19+
height: 100%;
2020
background-color: #000;
2121
z-index: 50;
2222
}

src/components/views/rooms/AuxPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ export default class AuxPanel extends React.Component<IProps, IState> {
149149
const callView = (
150150
<CallViewForRoom
151151
roomId={this.props.room.roomId}
152-
onResize={this.props.onResize}
153152
maxVideoHeight={this.props.maxHeight}
153+
resizeNotifier={this.props.resizeNotifier}
154154
/>
155155
);
156156

src/components/views/voip/CallView.tsx

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ interface IProps {
4040
// Another ongoing call to display information about
4141
secondaryCall?: MatrixCall,
4242

43-
// maxHeight style attribute for the video panel
44-
maxVideoHeight?: number;
45-
4643
// a callback which is called when the content in the callview changes
4744
// in a way that is likely to cause a resize.
4845
onResize?: any;
@@ -96,9 +93,6 @@ function exitFullscreen() {
9693
const CONTROLS_HIDE_DELAY = 1000;
9794
// Height of the header duplicated from CSS because we need to subtract it from our max
9895
// height to get the max height of the video
99-
const HEADER_HEIGHT = 44;
100-
const BOTTOM_PADDING = 10;
101-
const BOTTOM_MARGIN_TOP_BOTTOM = 10; // top margin plus bottom margin
10296
const CONTEXT_MENU_VPADDING = 8; // How far the context menu sits above the button (px)
10397

10498
@replaceableComponent("views.voip.CallView")
@@ -548,20 +542,9 @@ export default class CallView extends React.Component<IProps, IState> {
548542
localVideoFeed = <VideoFeed type={VideoFeedType.Local} call={this.props.call} />;
549543
}
550544

551-
// if we're fullscreen, we don't want to set a maxHeight on the video element.
552-
const maxVideoHeight = getFullScreenElement() || !this.props.maxVideoHeight ? null : (
553-
this.props.maxVideoHeight - (HEADER_HEIGHT + BOTTOM_PADDING + BOTTOM_MARGIN_TOP_BOTTOM)
554-
);
555-
contentView = <div className={containerClasses}
556-
ref={this.contentRef} onMouseMove={this.onMouseMove}
557-
// Put the max height on here too because this div is ended up 4px larger than the content
558-
// and is causing it to scroll, and I am genuinely baffled as to why.
559-
style={{maxHeight: maxVideoHeight}}
560-
>
545+
contentView = <div className={containerClasses} ref={this.contentRef} onMouseMove={this.onMouseMove}>
561546
{onHoldBackground}
562-
<VideoFeed type={VideoFeedType.Remote} call={this.props.call} onResize={this.props.onResize}
563-
maxHeight={maxVideoHeight}
564-
/>
547+
<VideoFeed type={VideoFeedType.Remote} call={this.props.call} onResize={this.props.onResize} />
565548
{localVideoFeed}
566549
{holdTransferContent}
567550
{callControls}

src/components/views/voip/CallViewForRoom.tsx

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import React from 'react';
1919
import CallHandler from '../../../CallHandler';
2020
import CallView from './CallView';
2121
import dis from '../../../dispatcher/dispatcher';
22+
import {Resizable} from "re-resizable";
23+
import ResizeNotifier from "../../../utils/ResizeNotifier";
2224
import {replaceableComponent} from "../../../utils/replaceableComponent";
2325

2426
interface IProps {
@@ -28,9 +30,7 @@ interface IProps {
2830
// maxHeight style attribute for the video panel
2931
maxVideoHeight?: number;
3032

31-
// a callback which is called when the content in the callview changes
32-
// in a way that is likely to cause a resize.
33-
onResize?: any;
33+
resizeNotifier: ResizeNotifier,
3434
}
3535

3636
interface IState {
@@ -79,11 +79,50 @@ export default class CallViewForRoom extends React.Component<IProps, IState> {
7979
return call;
8080
}
8181

82+
private onResizeStart = () => {
83+
this.props.resizeNotifier.startResizing();
84+
};
85+
86+
private onResize = () => {
87+
this.props.resizeNotifier.notifyTimelineHeightChanged();
88+
};
89+
90+
private onResizeStop = () => {
91+
this.props.resizeNotifier.stopResizing();
92+
};
93+
8294
public render() {
8395
if (!this.state.call) return null;
84-
85-
return <CallView call={this.state.call} pipMode={false}
86-
onResize={this.props.onResize} maxVideoHeight={this.props.maxVideoHeight}
87-
/>;
96+
// We subtract 8 as it the margin-bottom of the mx_CallViewForRoom_ResizeWrapper
97+
const maxHeight = this.props.maxVideoHeight - 8;
98+
99+
return (
100+
<div className="mx_CallViewForRoom">
101+
<Resizable
102+
minHeight={380}
103+
maxHeight={maxHeight}
104+
enable={{
105+
top: false,
106+
right: false,
107+
bottom: true,
108+
left: false,
109+
topRight: false,
110+
bottomRight: false,
111+
bottomLeft: false,
112+
topLeft: false,
113+
}}
114+
onResizeStart={this.onResizeStart}
115+
onResize={this.onResize}
116+
onResizeStop={this.onResizeStop}
117+
className="mx_CallViewForRoom_ResizeWrapper"
118+
handleClasses={{bottom: "mx_CallViewForRoom_ResizeHandle"}}
119+
>
120+
<CallView
121+
call={this.state.call}
122+
pipMode={false}
123+
/>
124+
</Resizable>
125+
</div>
126+
);
88127
}
89128
}

src/components/views/voip/VideoFeed.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ interface IProps {
3030

3131
type: VideoFeedType,
3232

33-
// maxHeight style attribute for the video element
34-
maxHeight?: number,
35-
3633
// a callback which is called when the video element is resized
3734
// due to a change in video metadata
3835
onResize?: (e: Event) => void,
@@ -82,9 +79,6 @@ export default class VideoFeed extends React.Component<IProps> {
8279
),
8380
};
8481

85-
let videoStyle = {};
86-
if (this.props.maxHeight) videoStyle = { maxHeight: this.props.maxHeight };
87-
88-
return <video className={classnames(videoClasses)} ref={this.vid} style={videoStyle} />;
82+
return <video className={classnames(videoClasses)} ref={this.vid} />;
8983
}
9084
}

0 commit comments

Comments
 (0)