Changeset 35608 for main/trunk


Ignore:
Timestamp:
2021-10-15T12:46:35+13:00 (3 years ago)
Author:
cstephen
Message:

Implement full support for word time editing

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

Legend:

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

    r35603 r35608  
    2020    </div>
    2121
    22     <word-timing-selector class="word-timing-selector" :surroundingWords="surroundingWords" :wordIndex="surroundingWordPrincipleIndex" @wordUpdated="onWordUpdated" v-if="enableEditing" />
     22    <word-timing-selector class="word-timing-selector" @wordUpdated="onWordUpdated" v-if="enableEditing"
     23        :surroundingWords="surroundingWords" :wordIndex="surroundingWordPrincipleIndex" />
    2324</div>
    2425</template>
  • main/trunk/model-interfaces-dev/atea/korero-maori-asr/src/components/WordTimingSelector.vue

    r35604 r35608  
    119119            canAdjustWordStartTime: false,
    120120            canAdjustWordEndTime: false,
    121             wordsContainerWidth: 0,
    122             isProduction: false
     121            wordsContainerWidth: 0
    123122        }
    124123    },
     
    168167                if (this.wordIndex !== 0) {
    169168                    length -= this.surroundingWords[0].startTime;
     169                }
     170
     171                // Gives 0.5s of time to play with while adjusting the last word.
     172                if (this.wordIndex === this.surroundingWords.length - 1) {
     173                    length += 0.5;
    170174                }
    171175
     
    225229            return word === this.myWord;
    226230        },
     231
    227232        onDocumentMouseMove(event) {
    228             if (this.isProduction) {
    229                 return;
    230             }
    231 
    232233            if (this.canAdjustWordStartTime) {
    233234                this.onMinHandleMouseMove(event);
     
    245246            }
    246247
    247             // const word = this.mySurroundingWords[this.wordIndex];
    248 
    249             // if (event.movementX < 0 && word.left + event.movementX < 0) {
    250             //     return;
    251             // }
    252 
    253             // if (event.movementX > 0 && word.left + event.movementX >= word.right()) {
    254             //     return;
    255             // }
    256 
    257             // word.left += event.movementX;
    258             // word.length -= event.movementX;
    259 
    260248            this.adjustWordStartTime(event.movementX);
    261249
     
    267255            }
    268256
    269             const word = this.myWord;
    270 
    271             const lastWord = this.mySurroundingWords[this.mySurroundingWords.length - 1];
    272 
    273             if (event.movementX > 0 && word.right() + event.movementX > lastWord.right()) {
    274                 return;
    275             }
    276 
    277             if (event.movementX < 0 && word.right() + event.movementX <= word.left) {
    278                 return;
    279             }
    280 
    281             word.length += event.movementX;
     257            this.adjustWordEndTime(event.movementX);
    282258
    283259            this.updateSurroundingWords();
     
    287263            this.canAdjustWordEndTime = false;
    288264        },
     265
    289266        adjustWordStartTime(amount) {
    290267            const word = this.myWord;
     
    324301            }
    325302            else {
    326                 if (word.left > (word.right() - this.scaleTime(0.1))) {
    327                     const diff = word.left - (word.right() - this.scaleTime(0.1)) // Will be positive
     303                const rightBoundary = word.right() - this.scaleTime(0.1);
     304                if (word.left > rightBoundary) {
     305                    const diff = word.left - rightBoundary // Will be positive
    328306                    word.left -= diff;
    329307                    word.length += diff;
     
    331309            }
    332310        },
     311        adjustWordEndTime(amount) {
     312            const word = this.myWord;
     313            word.length += amount;
     314
     315            if (amount > 0) {
     316                if (this.wordIndex === this.mySurroundingWords.length - 1) {
     317                    const rightBoundary = this.scaleTime(this.audioSnippetLength);
     318
     319                    if (word.right() < rightBoundary) {
     320                        return;
     321                    }
     322
     323                    const diff = word.right() - rightBoundary;
     324                    word.length -= diff;
     325                }
     326                else {
     327                    const nextWord = this.mySurroundingWords[this.wordIndex + 1];
     328
     329                    if (word.right() < nextWord.left) {
     330                        return;
     331                    }
     332
     333                    nextWord.left += amount;
     334                    nextWord.length -= amount;
     335
     336                    const rightBoundary = nextWord.right() - this.scaleTime(0.1);
     337
     338                    if (nextWord.left < rightBoundary) {
     339                        return;
     340                    }
     341
     342                    const diff = word.right() - rightBoundary;
     343                    word.length -= diff;
     344                    nextWord.left -= diff;
     345                    nextWord.length += diff;
     346                }
     347            }
     348            else {
     349                const leftBoundary = word.left + this.scaleTime(0.1);
     350                if (word.right() < leftBoundary) {
     351                    const diff = leftBoundary - word.right();
     352                    word.length += diff;
     353                }
     354            }
     355        },
     356
    333357        updateSurroundingWords() {
    334358            for (let i = 0; i < this.mySurroundingWords.length; i++) {
     
    344368        }
    345369    },
    346     beforeMount() {
    347         this.isProduction = process.env.NODE_ENV === "production";
    348     },
    349370    mounted() {
    350371        this.isMounted = true;
Note: See TracChangeset for help on using the changeset viewer.