Changeset 35641 for main


Ignore:
Timestamp:
2021-10-20T11:49:36+13:00 (3 years ago)
Author:
cstephen
Message:

Add shadow word representation.
Show absolute time boundaries, rather than selected words time boundaries.
Cleanup

Location:
main/trunk/model-interfaces-dev/atea/korero-maori-asr/src
Files:
2 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/components/WordTimingSelector.vue

    r35633 r35641  
    55
    66    <div class="words-container" v-width="onWordsContainerWidthChanged">
     7        <div class="shadow-word" v-for="word in shadowWords" :key="word.id" :style="{ left: `${word.left}px`, width: `${word.length}px` }"
     8            :class="{ 'shadow-hoisted': shouldHoist(word) }">
     9            <span>{{ word.word }}</span>
     10        </div>
     11
    712        <div class="word" v-for="word in mySurroundingWords" :key="word.id" :style="{ left: `${word.left}px`, width: `${word.length}px` }"
    813            :class="{ 'hoisted': shouldHoist(word) }">
     
    6772}
    6873
     74.shadow-word {
     75    @extend .word;
     76
     77    opacity: 0.7;
     78    color: #BBB;
     79    background-color: #DDD;
     80    border: 1px solid #AAA;
     81}
     82
     83.hoisted {
     84    top: -100%;
     85    background-color: var(--highlighted-word-bg);
     86}
     87
     88.shadow-hoisted {
     89    @extend .hoisted;
     90
     91    background-color: #DDD;
     92}
     93
    6994.word-attachment-container {
    7095    position: absolute;
     
    92117    }
    93118}
    94 
    95 .hoisted {
    96     top: -100%;
    97     background-color: var(--highlighted-word-bg);
    98 }
    99119</style>
    100120
     
    104124
    105125class Word {
    106     constructor(word, startTime, endTime, left, length) {
    107         this.id = Util.generateUuid();
     126    constructor(id, word, startTime, endTime, left, length) {
     127        this.id = id;
    108128        this.word = word;
    109129        this.startTime = startTime;
     
    131151            canAdjustWordStartTime: false,
    132152            canAdjustWordEndTime: false,
    133             wordsContainerWidth: 0
     153            wordsContainerWidth: 0,
     154            shadowWords: []
    134155        }
    135156    },
     
    147168            }
    148169
     170            if (this.wordIndex === 0) {
     171                return Util.formatSecondsTimeString(0, false, 2);
     172            }
     173
    149174            return Util.formatSecondsTimeString(this.surroundingWords[0].startTime, false, 2);
    150175        },
     
    152177            if (this.surroundingWords.length === 0) {
    153178                return 0;
     179            }
     180
     181            if (this.wordIndex === this.surroundingWords.length - 1) {
     182                return Util.formatSecondsTimeString(this.$store.getters.transcriptionPlaybackLength(this.transcriptionID), false, 2);
    154183            }
    155184
     
    222251        }
    223252    },
     253    watch: {
     254        /**
     255         * Watches for changes to the myWord computed property.
     256         * Updates the shadow words.
     257         * @param {Word} newValue The new word.
     258         * @param {Word} oldValue The old word.
     259         */
     260        myWord(newValue, oldValue) {
     261            if (newValue.id === oldValue.id && this.shadowWords.length > 0) {
     262                console.log(`New: ${newValue.id} | Old: ${oldValue.id}`);
     263                return;
     264            }
     265
     266            console.log("Updating");
     267            this.shadowWords = [];
     268            for (const word of this.mySurroundingWords) {
     269                this.shadowWords.push(word);
     270            }
     271        }
     272    },
    224273    methods: {
    225274        onWordsContainerWidthChanged(newValue) {
     
    232281            return time * this.scalingFactor - this.wordLeftOffsetPx;
    233282        },
     283        /**
     284         * Converts a {@link TWord} to a {@link Word}.
     285         * @param {TWord} word The word to convert.
     286         */
    234287        convertWord(word) {
    235288            const left = this.timeToPosition(word.startTime);
    236289            const length = (word.endTime - word.startTime) * this.scalingFactor;
    237290
    238             return new Word(word.word, word.startTime, word.endTime, left, length);
     291            return new Word(word.id, word.word, word.startTime, word.endTime, left, length);
    239292        },
    240293        shouldHoist(word) {
    241             return word === this.myWord;
     294            return word.id === this.myWord.id;
    242295        },
    243296
  • main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/styles/theme.scss

    r35508 r35641  
    1616    --monospace-font: 1rem 'Roboto Mono', sans-serif;
    1717    --page-bg-color: #f7f4f0;
    18     --highlighted-word-bg: rgba(255, 255, 0, 0.4);
     18    --highlighted-word-bg: rgb(255, 255, 100);
    1919
    2020    --primary-bg-color-l1: 196, 36, 44;
Note: See TracChangeset for help on using the changeset viewer.