Skip to content

Commit

Permalink
Merge pull request #1189 from frankrousseau/master
Browse files Browse the repository at this point in the history
[Player] Various improvements
  • Loading branch information
frankrousseau authored Sep 18, 2023
2 parents 01973d8 + 30b262a commit 44c4015
Show file tree
Hide file tree
Showing 7 changed files with 222 additions and 48 deletions.
27 changes: 19 additions & 8 deletions src/components/mixins/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const annotationMixin = {
data() {
return {
fabricCanvas: null,
fabricCanvasComparison: null,
lastAnnotationTime: '',
additions: [],
deletions: [],
Expand Down Expand Up @@ -468,9 +469,15 @@ export const annotationMixin = {
* Load an annotation directly to the canvas by adding all its object
* one by one to the canvas.
*/
loadSingleAnnotation(annotation) {
loadSingleAnnotation(annotation, canvas = null) {
annotation.drawing.objects.forEach(obj => {
this.addObjectToCanvas(annotation, obj)
this.addObjectToCanvas(annotation, obj, canvas)
})
},

loadSingleAnnotationComparison(annotation) {
annotation.drawing.objects.forEach(obj => {
this.addObjectToCanvas(annotation, obj, this.fabricCanvasComparison)
})
},

Expand All @@ -490,9 +497,10 @@ export const annotationMixin = {
*
* @returns: the build object.
*/
addObjectToCanvas(annotation, obj) {
addObjectToCanvas(annotation, obj, canvas = null) {
if (!obj) return
if (this.getObjectById(obj.id)) return
if (this.getObjectById(obj.id) && !canvas) return
if (!canvas) canvas = this.fabricCanvas
let path, text
let scaleMultiplierX = 1
let scaleMultiplierY = 1
Expand Down Expand Up @@ -535,9 +543,9 @@ export const annotationMixin = {
if (obj.type === 'path') {
let strokeMultiplier = 1
if (obj.canvasWidth) {
strokeMultiplier = canvasWidth / this.fabricCanvas.width
strokeMultiplier = canvasWidth / canvas.width
}
if (this.fabricCanvas.width < 420) strokeMultiplier /= 2
if (canvas.width < 420) strokeMultiplier /= 2
path = new fabric.Path(obj.path, {
...base
})
Expand All @@ -558,7 +566,7 @@ export const annotationMixin = {
mtr: !this.isCurrentUserArtist
})
this.$options.silentAnnnotation = true
this.fabricCanvas.add(path)
canvas.add(path)
this.$options.silentAnnnotation = false
} else if (obj.type === 'i-text' || obj.type === 'text') {
text = new fabric.IText(obj.text, {
Expand Down Expand Up @@ -587,7 +595,7 @@ export const annotationMixin = {
mtr: false
})
this.$options.silentAnnnotation = true
this.fabricCanvas.add(text)
canvas.add(text)
this.$options.silentAnnnotation = false
}
return path || text
Expand Down Expand Up @@ -1016,6 +1024,9 @@ export const annotationMixin = {
if (this.fabricCanvas) {
this.fabricCanvas.clear()
}
if (this.fabricCanvasComparison) {
this.fabricCanvasComparison.clear()
}
},

/*
Expand Down
4 changes: 1 addition & 3 deletions src/components/mixins/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -855,9 +855,7 @@ export const playerMixin = {
onMaxDurationUpdate(duration) {
if (duration) {
duration = floorToFrame(duration, this.fps)
const isChromium = !!window.chrome
const change = isChromium ? this.frameDuration : 0
this.maxDurationRaw = duration + change
this.maxDurationRaw = duration
this.maxDuration = this.formatTime(duration)
this.resetHandles()
} else {
Expand Down
26 changes: 0 additions & 26 deletions src/components/pages/playlists/PlaylistPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -465,19 +465,6 @@
icon="music"
@click="isWaveformDisplayed = !isWaveformDisplayed"
/>

<!--button-simple
class="button playlist-button flexrow-item"
@click="onPreviousFrameClicked"
:title="$t('playlists.actions.previous_frame')"
icon="left"
/>
<button-simple
class="button playlist-button flexrow-item"
@click="onNextFrameClicked"
:title="$t('playlists.actions.next_frame')"
icon="right"
/-->
</div>

<div class="separator"></div>
Expand Down Expand Up @@ -574,19 +561,6 @@
"
>
<div class="separator" v-if="isCurrentUserManager && tempMode"></div>
<!--button-simple
class="playlist-button flexrow-item"
icon="undo"
:title="$t('playlists.actions.annotation_undo')"
@click="undoLastAction"
/>
<button-simple
class="playlist-button flexrow-item"
:title="$t('playlists.actions.annotation_redo')"
icon="redo"
@click="redoLastAction"
/-->
<button-simple
@click="isAnnotationsDisplayed = !isAnnotationsDisplayed"
:class="{
Expand Down
Loading

0 comments on commit 44c4015

Please sign in to comment.