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>
<script>
import StretchMode from '../enums/stretch.enum';
import Stretch from '../enums/stretch.enum';
import KeyboardShortcutParser from '../js/KeyboardShortcutParser';
export default {
data () {
return {
StretchMode: StretchMode
Stretch: Stretch
}
},
created () {

View File

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

View File

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

View File

@ -301,12 +301,10 @@ class Settings {
}
canStartAutoAr(site) {
console.log("SITE:", site)
if (!site) {
site = window.location.host;
if (!site) {
console.log("site should be window.location.host")
return false;
}
}
@ -369,7 +367,7 @@ class Settings {
}
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;
}

View File

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

View File

@ -4,7 +4,7 @@ import Stretcher from './Stretcher';
import Zoom from './Zoom';
import PlayerData from '../video-data/PlayerData';
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';
if(Debug.debug)
@ -39,7 +39,7 @@ class Resizer {
// this.lastAr = this.settings.getDefaultAr(); // this is the aspect ratio we start with
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.resizerId = (Math.random(99)*100).toFixed(0);
@ -109,7 +109,7 @@ class Resizer {
// // pause AR on basic stretch, unpause when using other mdoes
// fir sine reason unpause doesn't unpause. investigate that later
try {
if (this.stretcher.mode === StretchMode.Basic) {
if (this.stretcher.mode === Stretch.Basic) {
this.conf.arDetector.pause();
} else {
if (this.lastAr.type === 'auto') {
@ -121,7 +121,7 @@ class Resizer {
}
// 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);
if(! stretchFactors || stretchFactors.error){
@ -133,20 +133,20 @@ class Resizer {
}
return;
}
if(this.stretcher.mode === StretchMode.Conditional){
if(this.stretcher.mode === Stretch.Conditional){
this.stretcher.applyConditionalStretch(stretchFactors, ar);
}
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);
if (Debug.debug) {
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();
if (Debug.debug) {
console.log('[Resizer::setAr] Processed stretch factors for basic stretch. Stretch factors are:', stretchFactors);
@ -179,7 +179,7 @@ class Resizer {
}
setStretchMode(stretchMode){
this.stretcher.mode = stretchMode;
this.stretcher.setStretchMode(stretchMode);
this.restore();
}
@ -190,7 +190,7 @@ class Resizer {
return;
}
// dont allow weird floats
this.videoAlignment = 'center';
this.videoAlignment = VideoAlignment.Center;
const player = this.conf.player.element;
@ -337,7 +337,7 @@ class Resizer {
}
resetStretch(){
this.stretcher.mode = StretchMode.NoStretch;
this.stretcher.setStretchMode(Stretch.NoStretch);
this.restore();
}

View File

@ -1,4 +1,5 @@
import Debug from '../../conf/Debug';
import Stretch from '../../../common/enums/stretch.enum';
// računa vrednosti za transform-scale (x, y)
// transform: scale(x,y) se uporablja za raztegovanje videa, ne pa za približevanje
@ -13,7 +14,15 @@ class Stretcher {
constructor(videoData) {
this.conf = videoData;
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){

View File

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

View File

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

View File

@ -81,7 +81,7 @@
<script>
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';
export default {
@ -91,7 +91,7 @@ export default {
},
data () {
return {
StretchMode: StretchMode,
Stretch: Stretch,
tableVisibility: {
crop: true,
}

View File

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