use event bus

This commit is contained in:
Tamius Han 2021-11-13 00:51:59 +01:00
parent 15a89583a2
commit 484db037c0
8 changed files with 98 additions and 73 deletions

View File

@ -47,7 +47,7 @@
<div class="content flex flex-column"> <div class="content flex flex-column">
<!-- autodetection warning --> <!-- autodetection warning -->
<div class="warning-area"> <div v-if="ultrawidify?.videoData?.hasDrm" class="warning-area">
<div class="warning-box"> <div class="warning-box">
<div> <div>
<mdicon name="alert" :size="42" /> <mdicon name="alert" :size="42" />
@ -64,7 +64,7 @@
<template v-if="settingsInitialized"> <template v-if="settingsInitialized">
<VideoSettings <VideoSettings
:settings="settings" :settings="settings"
:eventBus="eventBus" :eventBus="ultrawidify.eventBus"
></VideoSettings> ></VideoSettings>
<!-- <ResizerDebugPanel :debugData="debugData"> <!-- <ResizerDebugPanel :debugData="debugData">
</ResizerDebugPanel> --> </ResizerDebugPanel> -->

View File

@ -68,84 +68,90 @@ import VideoAlignmentType from '../../common/enums/VideoAlignmentType.enum';
export default { export default {
props: [
'eventBus'
],
data() { data() {
return { return {
VideoAlignment: VideoAlignmentType VideoAlignment: VideoAlignmentType
} }
}, },
methods: { methods: {
align() { align(alignmentX, alignmentY) {
console.warn('sending set alignment:', {x: alignmentX, y: alignmentY});
this.eventBus.send('set-alignment', {x: alignmentX, y: alignmentY})
} }
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss">
.alignment-box { .uw-ultrawidify-container-root {
aspect-ratio: 1; .alignment-box {
width: 100%; aspect-ratio: 1;
min-width: 40px; width: 100%;
max-width: 80px; min-width: 40px;
max-width: 80px;
display: flex;
flex-direction: column;
.row {
flex: 0 0 33%;
display: flex; display: flex;
flex-direction: row; flex-direction: column;
}
.col { .row {
flex: 0 0 33%; flex: 0 0 33%;
display: flex; display: flex;
flex-direction: row;
.alignment-ui {
width: 50%;
height: 50%;
} }
align-items: center; .col {
justify-content: center; flex: 0 0 33%;
&.top { display: flex;
align-items: flex-start;
.alignment-ui { .alignment-ui {
border-top: 3px solid #fff; width: 50%;
height: 50%;
} }
}
&.bottom {
align-items: flex-end;
.alignment-ui { align-items: center;
border-bottom: 3px solid #fff; justify-content: center;
&.top {
align-items: flex-start;
.alignment-ui {
border-top: 3px solid #fff;
}
} }
} &.bottom {
&.left { align-items: flex-end;
justify-content: flex-start;
.alignment-ui { .alignment-ui {
border-left: 3px solid #fff; border-bottom: 3px solid #fff;
}
} }
} &.left {
&.right { justify-content: flex-start;
justify-content: flex-end;
.alignment-ui { .alignment-ui {
border-right: 3px solid #fff; border-left: 3px solid #fff;
}
} }
} &.right {
justify-content: flex-end;
&.center.ycenter { .alignment-ui {
border-right: 3px solid #fff;
}
}
.alignment-ui { &.center.ycenter {
width: 25%;
height: 25%; .alignment-ui {
background-color: #fff; width: 25%;
height: 25%;
background-color: #fff;
}
} }
} }
} }

View File

@ -120,7 +120,9 @@
</div> </div>
<div class="flex flex-row"> <div class="flex flex-row">
<alignment-options-control-component> <alignment-options-control-component
:eventBus="eventBus"
>
</alignment-options-control-component> </alignment-options-control-component>
</div> </div>
@ -167,7 +169,7 @@ export default {
'settings', 'settings',
'frame', 'frame',
'cropModePersistence', 'cropModePersistence',
'eventBus' 'eventBus',
], ],
created() { created() {
this.exec = new ExecAction(this.settings, window.location.hostname); this.exec = new ExecAction(this.settings, window.location.hostname);
@ -238,24 +240,35 @@ export default {
} }
</script> </script>
<style lang="scss">
.uw-ultrawidify-container-root {
all: revert;
* {
all: revert;
}
}
</style>
<style lang="scss" src="../../res/css/flex.scss" scoped></style> <style lang="scss" src="../../res/css/flex.scss" scoped></style>
<style lang="scss" src="../res-common/panels.scss" scoped></style> <style lang="scss" src="../res-common/panels.scss" scoped></style>
<style lang="scss" src="../res-common/common.scss" scoped></style> <style lang="scss" src="../res-common/common.scss" scoped></style>
<style lang="scss" scoped> <style lang="scss" scoped>
.b3 { .uw-ultrawidify-container-root {
width: 9rem; .b3 {
padding-left: 0.33rem; width: 9rem;
padding-right: 0.33rem; padding-left: 0.33rem;
padding-right: 0.33rem;
}
.input-slider {
width: 480px;
}
.warning-lite {
padding-right: 16px;
padding-bottom: 16px;
padding-top: 8px;
}
} }
.input-slider {
width: 480px;
}
.warning-lite {
padding-right: 16px;
padding-bottom: 16px;
padding-top: 8px;
}
</style> </style>

View File

@ -24,7 +24,7 @@ class PlayerNotificationUi extends UI {
PlayerNotificationUi.getStoreConfig(), PlayerNotificationUi.getStoreConfig(),
PlayerNotificationUi.getUiConfig(playerElement), PlayerNotificationUi.getUiConfig(playerElement),
PlayerNotificationUi.getCommsConfig(), PlayerNotificationUi.getCommsConfig(),
eventBus { eventBus }
); );
this.settings = settings; this.settings = settings;

View File

@ -20,13 +20,14 @@ class PlayerUi extends UI {
playerElement, playerElement,
settings, settings,
eventBus, eventBus,
videoData
) { ) {
super( super(
'ultrawidifyUi', 'ultrawidifyUi',
PlayerUi.getStoreConfig(), PlayerUi.getStoreConfig(),
PlayerUi.getUiConfig(playerElement), PlayerUi.getUiConfig(playerElement),
PlayerUi.getCommsConfig(), PlayerUi.getCommsConfig(),
eventBus { eventBus, videoData }
); );
this.settings = settings; this.settings = settings;

View File

@ -14,13 +14,13 @@ class UI {
storeConfig, storeConfig,
uiConfig, // {component, parentElement?} uiConfig, // {component, parentElement?}
commsConfig, commsConfig,
eventBus ultrawidify, // or, at least, videoData instance + event bus
) { ) {
this.interfaceId = interfaceId; this.interfaceId = interfaceId;
this.commsConfig = commsConfig; this.commsConfig = commsConfig;
this.storeConfig = storeConfig; this.storeConfig = storeConfig;
this.uiConfig = uiConfig; this.uiConfig = uiConfig;
this.eventBus = eventBus; this.ultrawidify = ultrawidify;
this.init(); this.init();
} }
@ -71,12 +71,12 @@ class UI {
app.mixin({ app.mixin({
data() { data() {
return { return {
eventBus: options.eventBus ultrawidify: options.ultrawidify
} }
} }
}) })
} }
}, {eventBus: this.eventBus}); }, {ultrawidify: this.ultrawidify});
if (this.vuexStore) { if (this.vuexStore) {
app.use(this.vuexStore); app.use(this.vuexStore);

View File

@ -95,7 +95,7 @@ class PlayerData {
this.element = this.getPlayer(); this.element = this.getPlayer();
this.notificationService = new PlayerNotificationUi(this.element, this.settings, this.eventBus); this.notificationService = new PlayerNotificationUi(this.element, this.settings, this.eventBus);
this.ui = new PlayerUi(this.element, this.settings, this.eventBus); this.ui = new PlayerUi(this.element, this.settings, this.eventBus, this.videoData);
this.ui.init(); this.ui.init();
this.dimensions = undefined; this.dimensions = undefined;

View File

@ -591,6 +591,8 @@ class Resizer {
const {realVideoWidth, realVideoHeight, marginX, marginY} = this.computeVideoDisplayedDimensions(); const {realVideoWidth, realVideoHeight, marginX, marginY} = this.computeVideoDisplayedDimensions();
const {postZoomVideoDimensions, displayedVideoDimensions, crop} = this.computeCroppedAreas(stretchFactors);
// correct any remaining element size discrepencies (applicable only to certain crop strategies!) // correct any remaining element size discrepencies (applicable only to certain crop strategies!)
// NOTE: it's possible that we might also need to apply a similar measure for CropPillarbox strategy // NOTE: it's possible that we might also need to apply a similar measure for CropPillarbox strategy
// (but we'll wait for bug reports before doing so). // (but we'll wait for bug reports before doing so).
@ -605,6 +607,9 @@ class Resizer {
stretchFactors.yFactor *= autoHeightCompensationFactor; stretchFactors.yFactor *= autoHeightCompensationFactor;
} }
const offsetWidth = this.conf.video.offsetWidth;
const offsetHeight = this.conf.video.offsetHeight;
const wdiff = this.conf.player.dimensions.width - realVideoWidth; const wdiff = this.conf.player.dimensions.width - realVideoWidth;
const hdiff = this.conf.player.dimensions.height - realVideoHeight; const hdiff = this.conf.player.dimensions.height - realVideoHeight;