@@ -67,7 +67,11 @@ export class Indicator {
67
67
68
68
this . border_radius = number_entry (
69
69
_ ( "Active Border Radius" ) ,
70
- ext . settings . active_hint_border_radius ( ) ,
70
+ {
71
+ value : ext . settings . active_hint_border_radius ( ) ,
72
+ min : 5 ,
73
+ max : 30
74
+ } ,
71
75
( value ) => {
72
76
ext . settings . set_active_hint_border_radius ( value ) ;
73
77
}
@@ -203,15 +207,19 @@ function shortcuts(menu: any): any {
203
207
return item ;
204
208
}
205
209
206
- function clamp ( input : number ) : number {
207
- return Math . min ( Math . max ( 0 , input ) , 128 ) ;
210
+ function clamp ( input : number , min = 0 , max = 128 ) : number {
211
+ return Math . min ( Math . max ( min , input ) , max ) ;
208
212
}
209
213
210
214
function number_entry (
211
215
label : string ,
212
- value : number ,
216
+ valueOrOptions : number | { value : number , min : number , max : number } ,
213
217
callback : ( a : number ) => void ,
214
218
) : any {
219
+ let value = valueOrOptions , min : number , max : number ;
220
+ if ( typeof valueOrOptions !== 'number' )
221
+ ( { value, min, max } = valueOrOptions ) ;
222
+
215
223
const entry = new St . Entry ( {
216
224
text : String ( value ) ,
217
225
input_purpose : Clutter . InputContentPurpose . NUMBER ,
@@ -234,9 +242,9 @@ function number_entry(
234
242
symbol == 65293 // enter key
235
243
? parse_number ( text . text )
236
244
: symbol == 65361 // left key
237
- ? clamp ( parse_number ( text . text ) - 1 )
245
+ ? clamp ( parse_number ( text . text ) - 1 , min , max )
238
246
: symbol == 65363 // right key
239
- ? clamp ( parse_number ( text . text ) + 1 )
247
+ ? clamp ( parse_number ( text . text ) + 1 , min , max )
240
248
: null ;
241
249
242
250
if ( number !== null ) {
@@ -250,12 +258,12 @@ function number_entry(
250
258
251
259
entry . set_primary_icon ( create_icon ( 'value-decrease' ) )
252
260
entry . connect ( 'primary-icon-clicked' , ( ) => {
253
- text . set_text ( String ( clamp ( parseInt ( text . get_text ( ) ) - 1 ) ) )
261
+ text . set_text ( String ( clamp ( parseInt ( text . get_text ( ) ) - 1 , min , max ) ) )
254
262
} )
255
263
256
264
entry . set_secondary_icon ( create_icon ( 'value-increase' ) )
257
265
entry . connect ( 'secondary-icon-clicked' , ( ) => {
258
- text . set_text ( String ( clamp ( parseInt ( text . get_text ( ) ) + 1 ) ) )
266
+ text . set_text ( String ( clamp ( parseInt ( text . get_text ( ) ) + 1 , min , max ) ) )
259
267
} )
260
268
261
269
text . connect ( 'text-changed' , ( ) => {
0 commit comments