11<script lang="ts">
22import {
33 computed , defineComponent , ref , PropType , Ref ,
4+ watch ,
45} from ' vue' ;
56import { AttributeShortcut , ButtonShortcut } from ' vue-media-annotator/use/AttributeTypes' ;
67import usedShortcuts from ' dive-common/use/usedShortcuts' ;
@@ -36,6 +37,8 @@ export default defineComponent({
3637 const selectedShortcutButton: Ref <ButtonShortcut | undefined > = ref (undefined );
3738 const isSegment = ref (false );
3839 const segmentEditable = ref (false );
40+ const segmentSize = ref (0.01 );
41+ const segmentSizeType: Ref <' frames' | ' seconds' | ' percent' > = ref (' percent' );
3942 const copy = ref (props .value );
4043 const awaitingKeyPress = ref (false );
4144 const shortcutError: Ref <{description: string ; type: ' System' | ' Custom' }| null > = ref (null );
@@ -81,6 +84,8 @@ export default defineComponent({
8184 editShortcutDialog .value = true ;
8285 isSegment .value = shortcut .segment || false ;
8386 segmentEditable .value = ! shortcut .segment ? false : shortcut .segmentEditable || false ;
87+ segmentSize .value = shortcut .segmentSize || 0.01 ;
88+ segmentSizeType .value = shortcut .segmentSizeType || ' percent' ;
8489 };
8590
8691 const cancel = () => {
@@ -93,6 +98,8 @@ export default defineComponent({
9398 selectedShortcutKey .value = ' ' ;
9499 isSegment .value = false ;
95100 segmentEditable .value = false ;
101+ segmentSize .value = 0.01 ;
102+ segmentSizeType .value = ' percent' ;
96103 };
97104 const save = () => {
98105 editShortcutDialog .value = false ;
@@ -105,6 +112,8 @@ export default defineComponent({
105112 button: selectedShortcutButton .value ,
106113 segment: isSegment .value || undefined ,
107114 segmentEditable: isSegment .value ? (segmentEditable .value || undefined ) : undefined ,
115+ segmentSize: isSegment .value ? segmentSize .value : undefined ,
116+ segmentSizeType: isSegment .value ? segmentSizeType .value : undefined ,
108117 };
109118 selectedShortcutButton .value = undefined ;
110119 emit (' input' , copy .value );
@@ -202,6 +211,18 @@ export default defineComponent({
202211 window .document .addEventListener (' keydown' , handleKeyDown );
203212 };
204213
214+ watch (segmentSizeType , (newVal ) => {
215+ if (newVal === ' percent' && segmentSize .value > 1 ) {
216+ segmentSize .value = 0.01 ;
217+ }
218+ if ((newVal === ' frames' || newVal === ' seconds' ) && segmentSize .value < 1 ) {
219+ segmentSize .value = 1 ;
220+ }
221+ if (newVal === ' percent' && segmentSize .value >= 1 ) {
222+ segmentSize .value = 0.99 ;
223+ }
224+ });
225+
205226 const selectedDisplayKey = computed (() => {
206227 let base = ' ' ;
207228 if (selectedShortcutModifiers .value .length ) {
@@ -219,6 +240,8 @@ export default defineComponent({
219240 selectedShortcutButton ,
220241 isSegment ,
221242 segmentEditable ,
243+ segmentSize ,
244+ segmentSizeType ,
222245 shortcutTypes ,
223246 selectedDisplayKey ,
224247 awaitingKeyPress ,
@@ -405,7 +428,22 @@ awaitingKeyPress
405428 <span >Allows for editing of an entire segment</span >
406429 </v-tooltip >
407430 </v-row >
408-
431+ <v-row v-if =" isSegment" >
432+ <v-text-field
433+ v-model.number =" segmentSize"
434+ type =" number"
435+ :step =" segmentSizeType === 'percent' ? 0.01 : 1"
436+ :max =" segmentSizeType === 'percent' ? 1 : undefined"
437+ :min =" segmentSizeType === 'percent' ? 0.01 : 1"
438+ label =" Segment Size"
439+ class =" mr-4"
440+ />
441+ <v-select
442+ v-model =" segmentSizeType"
443+ :items =" ['frames', 'seconds', 'percent']"
444+ label =" Segment Size Type"
445+ />
446+ </v-row >
409447 <button-shortcut-editor
410448 v-model =" selectedShortcutButton"
411449 />
0 commit comments