/
Live.vue.ts
132 lines (106 loc) · 3.51 KB
/
Live.vue.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import Vue from 'vue';
import { Component } from 'vue-property-decorator';
import SceneSelector from 'components/SceneSelector.vue';
import Mixer from 'components/Mixer.vue';
import { UserService } from 'services/user';
import { Inject } from 'services/core/injector';
import Display from 'components/shared/Display.vue';
import { CustomizationService } from 'services/customization';
import VTooltip from 'v-tooltip';
import { $t, I18nService } from 'services/i18n';
import { NavigationService } from 'services/navigation';
import ResizeBar from 'components/shared/ResizeBar.vue';
import { WindowsService } from 'services/windows';
import electron from 'electron';
import BrowserView from 'components/shared/BrowserView';
Vue.use(VTooltip);
VTooltip.options.defaultContainer = '#mainWrapper';
@Component({
components: {
SceneSelector,
Mixer,
Display,
ResizeBar,
BrowserView,
},
})
export default class Live extends Vue {
@Inject() userService: UserService;
@Inject() customizationService: CustomizationService;
@Inject() i18nService: I18nService;
@Inject() navigationService: NavigationService;
@Inject() windowsService: WindowsService;
enablePreviewTooltip = $t('Enable the preview stream');
disablePreviewTooltip = $t('Disable the preview stream, can help with CPU');
maxHeight: number = null;
mounted() {
this.handleWindowResize();
window.addEventListener('resize', this.handleWindowResize);
}
destroyed() {
window.removeEventListener('resize', this.handleWindowResize);
}
handleWindowResize() {
this.maxHeight = this.$root.$el.getBoundingClientRect().height - 400;
const clampedHeight = Math.min(this.height, this.maxHeight);
if (clampedHeight !== this.height) this.height = clampedHeight;
}
onBrowserViewReady(view: Electron.BrowserView) {
if (view.isDestroyed()) return;
electron.ipcRenderer.send('webContents-preventPopup', view.webContents.id);
view.webContents.on('new-window', (e, url) => {
const match = url.match(/dashboard\/([^\/^\?]*)/);
if (match && match[1] === 'recent-events') {
this.popout();
} else if (match) {
this.navigationService.navigate('Dashboard', {
subPage: match[1],
});
} else {
electron.remote.shell.openExternal(url);
}
});
}
popout() {
this.userService.popoutRecentEvents();
}
get previewEnabled() {
return (
this.customizationService.state.livePreviewEnabled &&
!this.performanceModeEnabled &&
!this.windowsService.state.main.hideStyleBlockers
);
}
get performanceModeEnabled() {
return this.customizationService.state.performanceMode;
}
set previewEnabled(value: boolean) {
this.customizationService.setLivePreviewEnabled(value);
}
get recenteventsUrl() {
return this.userService.recentEventsUrl();
}
get height() {
return this.customizationService.state.bottomdockSize;
}
set height(value) {
this.customizationService.setSettings({ bottomdockSize: value });
}
get displayWidth() {
// 29 pixels is roughly the size of the title control label
return (16 / 9) * (this.height - 29);
}
get minHeight() {
return 50;
}
get sleepingKevin() {
const mode = this.customizationService.isDarkTheme ? 'night' : 'day';
return require(`../../../media/images/sleeping-kevin-${mode}.png`);
}
onResizeStartHandler() {
this.windowsService.updateStyleBlockers('main', true);
}
onResizeStopHandler() {
this.windowsService.updateStyleBlockers('main', false);
}
}