Skip to content

Commit 347e953

Browse files
gettinToastygettinToastyblackxored
authored
Refactor display rendering to handle its own style blocking (#5434)
* Port LiveDock Component * Fix import errors and tabs * Add to ReactComponentList * Fix strict nulls * Fix import error * Fix reactivity issues * Fix positioning and styling * Begin 1 to 1 port * Define variables and functions * Add missing classNames * Fix non-modal redlines * Add modals to react * Import components * Fix rendering bugs * Add misssing classes * Change scope of windowWidth * Remove props from main window * Move to native react rendering * Revert to Vue wrapper component * Fix stale style blockers * Add css aliases * Begin livedock restructure * Fix rendering livedock * Use Realm * Fix compilation error * Fix Livedock breaking render * Use realm props binding * fix: pass theme to `Loader` * chore: uncoment main rendering * fix(main): restore wrappers, should fix resizing behavior * Restores main wrappers from the original Vue component, some of these are needed to preserve layout, while also in some cases separating the styles from the rendered component, e.g. footer, sidebar, where styles would be merged weirdly. * `overflow: auto` is apparently required and that's what it seems to fix the cutoff at the bottom, combined with the above. * Cleanup needed. * Re-add ChatTabs * Fix index typing for customization service * Fix typing in Studio.tsx * Fix resizing problem * Fix css on resize bar * Fix footer clipping at small sizes * Fix livedock collapse * Refactor resizebar into main window * Get resize working * Refactor to add collapse * Fix dock resizing * Add perf optimizations * Add animation * Fix non-editor size weirdness * Fix chat disappearing * Fix strict nulls issue * Fix strict nulls again * Fix strict nulls last time pls * Address CR * Fix many tests * Fix skipOnboarding * Add timeout to skipOnboarding * Restore TestWidgets in Vue * Increase wait time for loader * Add additional await for titlebar to exist before attempting tests * Ignore ResizeObserver issue * Increase loadtime for skipOnboarding * Fix tests that restart * Refactor display rendering to handle its own style blocking * Remove identical type --------- Co-authored-by: gettinToasty <sbeyer@logitech.com> Co-authored-by: Adrian Perez <adrian@adrianperez.org>
1 parent 2e0232b commit 347e953

10 files changed

Lines changed: 30 additions & 41 deletions

File tree

app/components-react/editor/elements/RecordingPreview.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ import { useVuex } from 'components-react/hooks';
1111
const mins = { x: 0, y: 0 };
1212

1313
export function RecordingPreview() {
14-
const { WindowsService, StreamingService } = Services;
14+
const { StreamingService } = Services;
1515

1616
const containerRef = useRef<HTMLDivElement>(null);
1717

1818
const { renderElement } = useBaseElement(<RecPreview />, mins, containerRef.current);
1919

20-
const { hideStyleBlockers, selectiveRecording } = useVuex(() => ({
21-
hideStyleBlockers: WindowsService.state[Util.getCurrentUrlParams().windowId].hideStyleBlockers,
20+
const { selectiveRecording } = useVuex(() => ({
2221
selectiveRecording: StreamingService.state.selectiveRecording,
2322
}));
2423

@@ -34,7 +33,6 @@ export function RecordingPreview() {
3433

3534
function RecPreview() {
3635
if (!selectiveRecording) return <SelectiveRecordingMessage />;
37-
if (hideStyleBlockers) return <div />;
3836
return <Display renderingMode={ERenderingMode.OBS_RECORDING_RENDERING} />;
3937
}
4038

app/components-react/editor/elements/StreamPreview.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { useRef } from 'react';
22
import Display from 'components-react/shared/Display';
3-
import Util from 'services/utils';
43
import { ERenderingMode } from '../../../../obs-api';
54
import styles from './BaseElement.m.less';
65
import { $t } from 'services/i18n';
@@ -11,14 +10,13 @@ import { useVuex } from 'components-react/hooks';
1110
const mins = { x: 0, y: 0 };
1211

1312
export function StreamPreview() {
14-
const { WindowsService, StreamingService } = Services;
13+
const { StreamingService } = Services;
1514

1615
const containerRef = useRef<HTMLDivElement>(null);
1716

1817
const { renderElement } = useBaseElement(<StreamPreviewElement />, mins, containerRef.current);
1918

20-
const { hideStyleBlockers, selectiveRecording } = useVuex(() => ({
21-
hideStyleBlockers: WindowsService.state[Util.getCurrentUrlParams().windowId].hideStyleBlockers,
19+
const { selectiveRecording } = useVuex(() => ({
2220
selectiveRecording: StreamingService.state.selectiveRecording,
2321
}));
2422

@@ -34,7 +32,6 @@ export function StreamPreview() {
3432

3533
function StreamPreviewElement() {
3634
if (!selectiveRecording) return <SelectiveRecordingMessage />;
37-
if (hideStyleBlockers) return <div />;
3835
return <Display renderingMode={ERenderingMode.OBS_STREAMING_RENDERING} />;
3936
}
4037

app/components-react/root/StudioEditor.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export default function StudioEditor() {
3232
} = Services;
3333
const performanceMode = useRealmObject(CustomizationService.state).performanceMode;
3434
const v = useVuex(() => ({
35-
hideStyleBlockers: WindowsService.state.main.hideStyleBlockers,
3635
cursor: EditorService.state.cursor,
3736
studioMode: TransitionsService.state.studioMode,
3837
dualOutputMode: DualOutputService.views.dualOutputMode,
@@ -43,8 +42,7 @@ export default function StudioEditor() {
4342
activeSceneId: ScenesService.views.activeSceneId,
4443
isLoading: DualOutputService.views.isLoading,
4544
}));
46-
47-
const displayEnabled = !v.hideStyleBlockers && !performanceMode && !v.isLoading;
45+
const displayEnabled = !performanceMode && !v.isLoading;
4846
const placeholderRef = useRef<HTMLDivElement>(null);
4947
const studioModeRef = useRef<HTMLDivElement>(null);
5048
const [studioModeStacked, setStudioModeStacked] = useState(false);

app/components-react/shared/Display.tsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { Display as OBSDisplay } from '../../services/video';
55
import { TDisplayType } from 'services/settings-v2/video';
66
import uuid from 'uuid/v4';
77
import { useRealmObject } from 'components-react/hooks/realm';
8+
import Utils from 'services/utils';
9+
810
interface DisplayProps {
911
id?: string;
1012
sourceId?: string;
@@ -18,7 +20,8 @@ interface DisplayProps {
1820
}
1921

2022
export default function Display(props: DisplayProps) {
21-
const { CustomizationService, VideoSettingsService } = Services;
23+
const { CustomizationService, VideoSettingsService, WindowsService } = Services;
24+
const windowId = Utils.getWindowId();
2225

2326
const p = {
2427
paddingSize: 0,
@@ -34,6 +37,7 @@ export default function Display(props: DisplayProps) {
3437

3538
return {
3639
baseResolution: `${videoSettings?.baseWidth}x${videoSettings?.baseHeight}`,
40+
hideDisplay: WindowsService.state[windowId]?.hideStyleBlockers,
3741
};
3842
}, false);
3943

@@ -43,9 +47,21 @@ export default function Display(props: DisplayProps) {
4347
const displayEl = useRef<HTMLDivElement>(null);
4448

4549
useEffect(updateDisplay, [p.sourceId, paddingColor]);
46-
useEffect(refreshOutputRegion, [v.baseResolution]);
50+
useEffect(handleResize, [v.baseResolution]);
51+
useEffect(handleHideDisplay, [v.hideDisplay]);
52+
53+
function handleHideDisplay() {
54+
if (v.hideDisplay) {
55+
destroyDisplay();
56+
} else {
57+
createDisplay();
58+
if (obsDisplay.current) {
59+
obsDisplay.current.refreshOutputRegion();
60+
}
61+
}
62+
}
4763

48-
function refreshOutputRegion() {
64+
function handleResize() {
4965
if (!obsDisplay.current) return;
5066
const [width, height] = v.baseResolution.split('x');
5167
obsDisplay.current.resize(Number(width), Number(height));
@@ -55,7 +71,7 @@ export default function Display(props: DisplayProps) {
5571
p.clickHandler(event);
5672
}
5773

58-
async function createDisplay() {
74+
function createDisplay() {
5975
const displayId = uuid();
6076
obsDisplay.current = new OBSDisplay(displayId, {
6177
sourceId: p.sourceId,
@@ -64,7 +80,6 @@ export default function Display(props: DisplayProps) {
6480
renderingMode: p.renderingMode,
6581
type: p.type,
6682
});
67-
await refreshOutputRegion();
6883
obsDisplay.current.setShoulddrawUI(p.drawUI);
6984
obsDisplay.current.onOutputResize(region => p.onOutputResize(region));
7085
if (displayEl.current) obsDisplay.current.trackElement(displayEl.current);

app/components-react/windows/Projector.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ export default function Projector() {
1717

1818
const { sourceId, renderingMode } = useOneOffWindowParams();
1919
const windowId = useMemo(() => Util.getCurrentUrlParams().windowId, []);
20-
const { hideStyleBlockers, fullscreen } = useVuex(() => {
20+
const { fullscreen } = useVuex(() => {
2121
return {
22-
hideStyleBlockers: WindowsService.state[windowId].hideStyleBlockers,
2322
fullscreen: WindowsService.state[windowId].isFullScreen,
2423
};
2524
});
@@ -74,7 +73,7 @@ export default function Projector() {
7473
))}
7574
</div>
7675
</Scrollable>
77-
{!hideStyleBlockers && <Display sourceId={sourceId} renderingMode={renderingMode} />}
76+
<Display sourceId={sourceId} renderingMode={renderingMode} />
7877
</div>
7978
</ModalLayout>
8079
)}

app/components-react/windows/SourceProperties.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export default function SourceProperties() {
2626
const [properties, setProperties] = useState(() =>
2727
source ? source.getPropertiesFormData() : [],
2828
);
29-
const hideStyleBlockers = useVuex(() => WindowsService.state.child.hideStyleBlockers);
3029

3130
// close the window if the source has been deleted
3231
useSubscription(SourcesService.sourceRemoved, removedSource => {
@@ -62,12 +61,7 @@ export default function SourceProperties() {
6261
return (
6362
<ModalLayout
6463
scrollable
65-
fixedChild={
66-
source &&
67-
!hideStyleBlockers && (
68-
<Display sourceId={source.sourceId} style={{ position: 'relative' }} />
69-
)
70-
}
64+
fixedChild={source && <Display sourceId={source.sourceId} style={{ position: 'relative' }} />}
7165
>
7266
<ObsForm
7367
value={properties}

app/components/windows/SourceProperties.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66
:cancel-handler="cancel"
77
:fixedSectionHeight="200"
88
>
9-
<display
10-
slot="fixed"
11-
v-if="source && !hideStyleBlockers"
12-
:componentProps="{ sourceId: source.id }"
13-
/>
9+
<display slot="fixed" v-if="source" :componentProps="{ sourceId: source.id }" />
1410
<div slot="content" v-if="source">
1511
<component
1612
v-if="propertiesManagerUI"

app/components/windows/SourceProperties.vue.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ export default class SourceProperties extends Vue {
6161
this.sourceUpdatedSub.unsubscribe();
6262
}
6363

64-
get hideStyleBlockers() {
65-
return this.windowsService.state.child.hideStyleBlockers;
66-
}
67-
6864
get propertiesManagerUI() {
6965
if (this.source) return this.source.getPropertiesManagerUI();
7066
}

app/components/windows/WidgetEditor.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
>
4949
<div class="display">
5050
<display
51-
v-if="!animating && !hideStyleBlockers"
51+
v-if="!animating"
5252
:componentProps="{
5353
sourceId: widget.previewSourceId,
5454
clickHandler: e => createProjector(e),

app/components/windows/WidgetEditor.vue.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ export default class WidgetEditor extends TsxComponent<WidgetEditorProps> {
8181
animating = false;
8282
canShowEditor = false;
8383

84-
get hideStyleBlockers() {
85-
return this.windowsService.state.child.hideStyleBlockers;
86-
}
87-
8884
get loaded() {
8985
return !!this.settingsState.data;
9086
}

0 commit comments

Comments
 (0)