Stretch mode fixes

This commit is contained in:
Tamius Han 2019-02-19 21:10:49 +01:00
parent 4eba239da9
commit a0f1a27271
11 changed files with 46 additions and 37 deletions

View File

@ -107,14 +107,14 @@
</template> </template>
<script> <script>
import StretchMode from '../enums/stretch.enum'; import Stretch from '../enums/stretch.enum';
import KeyboardShortcutParser from '../js/KeyboardShortcutParser'; import KeyboardShortcutParser from '../js/KeyboardShortcutParser';
export default { export default {
data () { data () {
return { return {
StretchMode: StretchMode Stretch: Stretch
} }
}, },
created () { created () {

View File

@ -46,13 +46,13 @@
</template> </template>
<script> <script>
import StretchMode from '../enums/stretch.enum'; import Stretch from '../enums/stretch.enum';
import KeyboardShortcutParser from '../js/KeyboardShortcutParser' import KeyboardShortcutParser from '../js/KeyboardShortcutParser'
export default { export default {
data () { data () {
return { return {
StretchMode: StretchMode Stretch: Stretch
} }
}, },
created () { created () {

View File

@ -5,8 +5,8 @@ const _prod = false;
var Debug = { var Debug = {
performanceMetrics: true, // should not be affected by debug.debug in order to allow benchmarking of the impact logging in console has performanceMetrics: true, // should not be affected by debug.debug in order to allow benchmarking of the impact logging in console has
init: true, init: true,
// debug: true, debug: true,
debug: false, // debug: false,
// keyboard: true, // keyboard: true,
debugResizer: true, debugResizer: true,
debugArDetect: true, debugArDetect: true,

View File

@ -301,12 +301,10 @@ class Settings {
} }
canStartAutoAr(site) { canStartAutoAr(site) {
console.log("SITE:", site)
if (!site) { if (!site) {
site = window.location.host; site = window.location.host;
if (!site) { if (!site) {
console.log("site should be window.location.host")
return false; return false;
} }
} }
@ -369,7 +367,7 @@ class Settings {
} }
getDefaultStretchMode(site) { getDefaultStretchMode(site) {
if (site && this.active.sites[site] && this.active.sites[site].stretch !== StretchMode.Default) { if (site && this.active.sites[site] && this.active.sites[site].stretch !== Stretch.Default) {
return this.active.sites[site].stretch; return this.active.sites[site].stretch;
} }

View File

@ -5,6 +5,8 @@ import RescanReason from './enums/RescanReason';
if(Debug.debug) if(Debug.debug)
console.log("Loading: PageInfo.js"); console.log("Loading: PageInfo.js");
class PageInfo { class PageInfo {
constructor(comms, settings, extensionMode){ constructor(comms, settings, extensionMode){
this.hasVideos = false; this.hasVideos = false;

View File

@ -4,7 +4,7 @@ import Stretcher from './Stretcher';
import Zoom from './Zoom'; import Zoom from './Zoom';
import PlayerData from '../video-data/PlayerData'; import PlayerData from '../video-data/PlayerData';
import ExtensionMode from '../../../common/enums/extension-mode.enum'; import ExtensionMode from '../../../common/enums/extension-mode.enum';
import StretchMode from '../../../common/enums/stretch.enum'; import Stretch from '../../../common/enums/stretch.enum';
import VideoAlignment from '../../../common/enums/video-alignment.enum'; import VideoAlignment from '../../../common/enums/video-alignment.enum';
if(Debug.debug) if(Debug.debug)
@ -39,7 +39,7 @@ class Resizer {
// this.lastAr = this.settings.getDefaultAr(); // this is the aspect ratio we start with // this.lastAr = this.settings.getDefaultAr(); // this is the aspect ratio we start with
this.lastAr = {type: 'original'}; this.lastAr = {type: 'original'};
this.videoAlignment = this.settings.getDefaultVideoAlignment(); // this is initial video alignment this.videoAlignment = this.settings.getDefaultVideoAlignment(window.location.hostname); // this is initial video alignment
this.destroyed = false; this.destroyed = false;
this.resizerId = (Math.random(99)*100).toFixed(0); this.resizerId = (Math.random(99)*100).toFixed(0);
@ -109,7 +109,7 @@ class Resizer {
// // pause AR on basic stretch, unpause when using other mdoes // // pause AR on basic stretch, unpause when using other mdoes
// fir sine reason unpause doesn't unpause. investigate that later // fir sine reason unpause doesn't unpause. investigate that later
try { try {
if (this.stretcher.mode === StretchMode.Basic) { if (this.stretcher.mode === Stretch.Basic) {
this.conf.arDetector.pause(); this.conf.arDetector.pause();
} else { } else {
if (this.lastAr.type === 'auto') { if (this.lastAr.type === 'auto') {
@ -121,7 +121,7 @@ class Resizer {
} }
// do stretch thingy // do stretch thingy
if (this.stretcher.mode === StretchMode.NoStretch || this.stretcher.mode === StretchMode.Conditional){ if (this.stretcher.mode === Stretch.NoStretch || this.stretcher.mode === Stretch.Conditional){
var stretchFactors = this.scaler.calculateCrop(ar); var stretchFactors = this.scaler.calculateCrop(ar);
if(! stretchFactors || stretchFactors.error){ if(! stretchFactors || stretchFactors.error){
@ -133,20 +133,20 @@ class Resizer {
} }
return; return;
} }
if(this.stretcher.mode === StretchMode.Conditional){ if(this.stretcher.mode === Stretch.Conditional){
this.stretcher.applyConditionalStretch(stretchFactors, ar); this.stretcher.applyConditionalStretch(stretchFactors, ar);
} }
if (Debug.debug) { if (Debug.debug) {
console.log("[Resizer::setAr] Processed stretch factors for ", this.stretcher.mode === StretchMode.NoStretch ? 'stretch-free crop.' : 'crop with conditional stretch.', 'Stretch factors are:', stretchFactors); console.log("[Resizer::setAr] Processed stretch factors for ", this.stretcher.mode === Stretch.NoStretch ? 'stretch-free crop.' : 'crop with conditional stretch.', 'Stretch factors are:', stretchFactors);
} }
} else if (this.stretcher.mode === StretchMode.Hybrid) { } else if (this.stretcher.mode === Stretch.Hybrid) {
var stretchFactors = this.stretcher.calculateStretch(ar); var stretchFactors = this.stretcher.calculateStretch(ar);
if (Debug.debug) { if (Debug.debug) {
console.log('[Resizer::setAr] Processed stretch factors for hybrid stretch/crop. Stretch factors are:', stretchFactors); console.log('[Resizer::setAr] Processed stretch factors for hybrid stretch/crop. Stretch factors are:', stretchFactors);
} }
} else if (this.stretcher.mode === StretchMode.Basic) { } else if (this.stretcher.mode === Stretch.Basic) {
var stretchFactors = this.stretcher.calculateBasicStretch(); var stretchFactors = this.stretcher.calculateBasicStretch();
if (Debug.debug) { if (Debug.debug) {
console.log('[Resizer::setAr] Processed stretch factors for basic stretch. Stretch factors are:', stretchFactors); console.log('[Resizer::setAr] Processed stretch factors for basic stretch. Stretch factors are:', stretchFactors);
@ -179,7 +179,7 @@ class Resizer {
} }
setStretchMode(stretchMode){ setStretchMode(stretchMode){
this.stretcher.mode = stretchMode; this.stretcher.setStretchMode(stretchMode);
this.restore(); this.restore();
} }
@ -190,7 +190,7 @@ class Resizer {
return; return;
} }
// dont allow weird floats // dont allow weird floats
this.videoAlignment = 'center'; this.videoAlignment = VideoAlignment.Center;
const player = this.conf.player.element; const player = this.conf.player.element;
@ -337,7 +337,7 @@ class Resizer {
} }
resetStretch(){ resetStretch(){
this.stretcher.mode = StretchMode.NoStretch; this.stretcher.setStretchMode(Stretch.NoStretch);
this.restore(); this.restore();
} }

View File

@ -1,4 +1,5 @@
import Debug from '../../conf/Debug'; import Debug from '../../conf/Debug';
import Stretch from '../../../common/enums/stretch.enum';
// računa vrednosti za transform-scale (x, y) // računa vrednosti za transform-scale (x, y)
// transform: scale(x,y) se uporablja za raztegovanje videa, ne pa za približevanje // transform: scale(x,y) se uporablja za raztegovanje videa, ne pa za približevanje
@ -13,7 +14,15 @@ class Stretcher {
constructor(videoData) { constructor(videoData) {
this.conf = videoData; this.conf = videoData;
this.settings = videoData.settings; this.settings = videoData.settings;
this.mode = this.settings.getDefaultStretchMode(); this.mode = this.settings.getDefaultStretchMode(window.location.hostname);
}
setStretchMode(stretchMode) {
if (stretchMode === Stretch.Default) {
this.mode = this.settings.getDefaultStretchMode(window.location.hostname);
} else {
this.mode = stretchMode;
}
} }
applyConditionalStretch(stretchFactors, actualAr){ applyConditionalStretch(stretchFactors, actualAr){

View File

@ -99,7 +99,7 @@
</template> </template>
<script> <script>
import StretchMode from '../../common/enums/stretch.enum'; import Stretch from '../../common/enums/stretch.enum';
import KeyboardShortcutParser from '../../common/js/KeyboardShortcutParser'; import KeyboardShortcutParser from '../../common/js/KeyboardShortcutParser';
import CommandChain from './command-builder/command-chain'; import CommandChain from './command-builder/command-chain';
import CommandAddEdit from './command-builder/command-add-edit'; import CommandAddEdit from './command-builder/command-add-edit';
@ -111,7 +111,7 @@ export default {
}, },
data () { data () {
return { return {
StretchMode: StretchMode, Stretch: Stretch,
action: { action: {
name: 'New action', name: 'New action',
label: 'New action', label: 'New action',

View File

@ -78,12 +78,12 @@
<script> <script>
import ActionList from '../../../ext/conf/ActionList'; import ActionList from '../../../ext/conf/ActionList';
import StretchMode from '../../../common/enums/stretch.enum'; import Stretch from '../../../common/enums/stretch.enum';
export default { export default {
data () { data () {
return { return {
StretchMode: StretchMode, Stretch: Stretch,
ActionList: ActionList, ActionList: ActionList,
selectedAction: this.action ? action.action : undefined, selectedAction: this.action ? action.action : undefined,
selectedArgument: this.action ? { selectedArgument: this.action ? {

View File

@ -81,7 +81,7 @@
<script> <script>
import Button from '../../common/components/button'; import Button from '../../common/components/button';
import StretchMode from '../../common/enums/stretch.enum'; import Stretch from '../../common/enums/stretch.enum';
import ActionAlt from '../../common/components/action-alt'; import ActionAlt from '../../common/components/action-alt';
export default { export default {
@ -91,7 +91,7 @@ export default {
}, },
data () { data () {
return { return {
StretchMode: StretchMode, Stretch: Stretch,
tableVisibility: { tableVisibility: {
crop: true, crop: true,
} }

View File

@ -75,20 +75,20 @@
</div> </div>
<div class="flex flex-row button-box"> <div class="flex flex-row button-box">
<Button label="Don't stretch" <Button label="Don't stretch"
:selected="settings.active.sites['@global'].stretch === StretchMode.NoStretch" :selected="settings.active.sites['@global'].stretch === Stretch.NoStretch"
@click.native="setDefaultStretchingMode(StretchMode.NoStretch)"> @click.native="setDefaultStretchingMode(Stretch.NoStretch)">
</Button> </Button>
<Button label="Basic stretch" <Button label="Basic stretch"
:selected="settings.active.sites['@global'].stretch === StretchMode.Basic" :selected="settings.active.sites['@global'].stretch === Stretch.Basic"
@click.native="setDefaultStretchingMode(StretchMode.Basic)"> @click.native="setDefaultStretchingMode(Stretch.Basic)">
</Button> </Button>
<Button label="Hybrid stretch" <Button label="Hybrid stretch"
:selected="settings.active.sites['@global'].stretch === StretchMode.Hybrid" :selected="settings.active.sites['@global'].stretch === Stretch.Hybrid"
@click.native="setDefaultStretchingMode(StretchMode.Hybrid)"> @click.native="setDefaultStretchingMode(Stretch.Hybrid)">
</Button> </Button>
<Button label="Thin borders only" <Button label="Thin borders only"
:selected="settings.active.sites['@global'].stretch === StretchMode.Conditional" :selected="settings.active.sites['@global'].stretch === Stretch.Conditional"
@click.native="setDefaultStretchingMode(StretchMode.Conditional)" @click.native="setDefaultStretchingMode(Stretch.Conditional)"
> >
</Button> </Button>
</div> </div>
@ -129,7 +129,7 @@
<script> <script>
import Button from '../common/components/button'; import Button from '../common/components/button';
import StretchMode from '../common/enums/stretch.enum'; import Stretch from '../common/enums/stretch.enum';
import ExtensionMode from '../common/enums/extension-mode.enum'; import ExtensionMode from '../common/enums/extension-mode.enum';
import VideoAlignment from '../common/enums/video-alignment.enum'; import VideoAlignment from '../common/enums/video-alignment.enum';
@ -142,7 +142,7 @@ export default {
}, },
data () { data () {
return { return {
StretchMode: StretchMode, Stretch: Stretch,
ExtensionMode: ExtensionMode, ExtensionMode: ExtensionMode,
VideoAlignment: VideoAlignment, VideoAlignment: VideoAlignment,
stretchThreshold: 0, stretchThreshold: 0,