From 5cc65272a2bb1e863da1714e3dd76b8fc4cc2e8a Mon Sep 17 00:00:00 2001 From: Luca Bonora Date: Tue, 19 Jul 2022 10:42:35 +0200 Subject: [PATCH 1/3] Show frame duration in the properties --- src/js/Controller.js | 38 ++++++++++++++++++++++++++++++++++++++ src/js/view/Properties.js | 3 +++ 2 files changed, 41 insertions(+) diff --git a/src/js/Controller.js b/src/js/Controller.js index b14f7551..cae5723d 100644 --- a/src/js/Controller.js +++ b/src/js/Controller.js @@ -1273,6 +1273,44 @@ export class Controller extends EventEmitter { ); } + /** + * Get frame timeoutMS + transitionDuration from the first frame to the current frame. + * + * This method is used in the {@linkcode module:view/Properties.Properties|Properties} to calculate and show in the + * HTML fields the actual time duration for the selected frame. + * + * @returns {Array} The values of the property in the selected layers. + */ + getFrameDuration() { + const values = []; + const currentFrame = this.selection.currentFrame; + if (!currentFrame) { + return; + } + + let duration = 0; + for (let i = 0; i <= currentFrame.index ; i ++) { + const frame = this.presentation.frames[i]; + duration += frame['timeoutMs'] + frame['transitionDurationMs']; + } + if (values.indexOf(duration) < 0) { + const minutes = Math.floor(duration / 60000); + const seconds = ((duration % 60000) / 1000).toFixed(0); + let millis = (duration % 60000) / 1000; + if (millis > +seconds) { + millis = (duration % 60000) - (seconds * 1000); + } else { + millis = '000'; + } + const inMinutesAndSeconds = seconds == 60 ? + (minutes+1) + ":00" : + minutes + ":" + (seconds < 10 ? "0" : "") + seconds + ":" + millis + values.push('' + inMinutesAndSeconds); + } + + return values; + } + /** Get a property of the selected layers in the selected frames. * * This method is used in the {@linkcode module:view/Properties.Properties|Properties} view to assign getters diff --git a/src/js/view/Properties.js b/src/js/view/Properties.js index 5bc39388..0d7e3dc8 100644 --- a/src/js/view/Properties.js +++ b/src/js/view/Properties.js @@ -213,6 +213,9 @@ export class Properties extends VirtualDOMView { ]), this.renderNumberField("timeoutMs", timeoutMsDisabled, controller.getFrameProperty, controller.setFrameProperty, false, 0.1, 1000), + h("label", { for: "field-elapsedMs"}, _("Elapsed time")), + this.renderTextField("elapsedMs", true, controller.getFrameDuration, function () {}, false), + h("h1", _("Layer")), h("div.btn-group", [ From a67b4867efa2fa96b27fe43b37dc4031df592aa7 Mon Sep 17 00:00:00 2001 From: Luca Bonora Date: Tue, 19 Jul 2022 14:33:59 +0200 Subject: [PATCH 2/3] Fixed calculations --- src/js/Controller.js | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/js/Controller.js b/src/js/Controller.js index cae5723d..349de6e0 100644 --- a/src/js/Controller.js +++ b/src/js/Controller.js @@ -1282,33 +1282,35 @@ export class Controller extends EventEmitter { * @returns {Array} The values of the property in the selected layers. */ getFrameDuration() { - const values = []; const currentFrame = this.selection.currentFrame; if (!currentFrame) { - return; + return []; } let duration = 0; - for (let i = 0; i <= currentFrame.index ; i ++) { - const frame = this.presentation.frames[i]; - duration += frame['timeoutMs'] + frame['transitionDurationMs']; - } - if (values.indexOf(duration) < 0) { + if (currentFrame.index > 0) { + + for (let i = 0; i <= currentFrame.index - 1; i++) { + const frame = this.presentation.frames[i]; + duration += frame['timeoutMs'] + frame['transitionDurationMs']; + } const minutes = Math.floor(duration / 60000); - const seconds = ((duration % 60000) / 1000).toFixed(0); + const secondsString = ((duration % 60000) / 1000).toFixed(0); + const seconds = +secondsString; let millis = (duration % 60000) / 1000; - if (millis > +seconds) { - millis = (duration % 60000) - (seconds * 1000); + if (millis > seconds) { + millis = (duration % 60000) - (seconds * 1000); } else { - millis = '000'; + millis = '000'; } - const inMinutesAndSeconds = seconds == 60 ? - (minutes+1) + ":00" : - minutes + ":" + (seconds < 10 ? "0" : "") + seconds + ":" + millis - values.push('' + inMinutesAndSeconds); + const padding = seconds < 10 ? '0' : ''; + const inMinutesAndSeconds = seconds === 60 ? + (minutes + 1) + ':00' : + minutes + ':' + padding + seconds + ':' + millis; + return [ '' + inMinutesAndSeconds ]; + } else { + return [ '0:00:000' ]; } - - return values; } /** Get a property of the selected layers in the selected frames. From 1b56b58fe71308933c7aa3e74936d47d2c22d835 Mon Sep 17 00:00:00 2001 From: Luca Bonora Date: Tue, 19 Jul 2022 14:38:43 +0200 Subject: [PATCH 3/3] Translated elapsed time in Italian --- locales/it.po | 198 +++++++++++++++++++++++++------------------------- 1 file changed, 101 insertions(+), 97 deletions(-) diff --git a/locales/it.po b/locales/it.po index 11efa30e..f3b8a31f 100644 --- a/locales/it.po +++ b/locales/it.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: sozi\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-12-25 02:21:+0000\n" +"POT-Creation-Date: 2022-07-19 11:05:+0000\n" "PO-Revision-Date: 2022-05-28 13:18+0100\n" "Last-Translator: Albano Battistella \n" "Language-Team: Italian