@@ -21,6 +21,7 @@ class MPLCanvasModel extends widgets.DOMWidgetModel {
21
21
toolbar : null ,
22
22
toolbar_visible : true ,
23
23
toolbar_position : 'horizontal' ,
24
+ resizable : true ,
24
25
_width : 0 ,
25
26
_height : 0 ,
26
27
_figure_label : 'Figure' ,
@@ -51,6 +52,11 @@ class MPLCanvasModel extends widgets.DOMWidgetModel {
51
52
this . _init_image ( ) ;
52
53
53
54
this . on ( 'msg:custom' , this . on_comm_message . bind ( this ) ) ;
55
+ this . on ( 'change:resizable' , ( ) => {
56
+ this . _for_each_view ( function ( view ) {
57
+ view . update_canvas ( ) ;
58
+ } )
59
+ } ) ;
54
60
55
61
this . send_initialization_message ( ) ;
56
62
}
@@ -421,26 +427,28 @@ class MPLCanvasView extends widgets.DOMWidgetView {
421
427
}
422
428
423
429
// Draw resize handle
424
- this . top_context . save ( ) ;
430
+ if ( this . model . get ( 'resizable' ) ) {
431
+ this . top_context . save ( ) ;
425
432
426
- var gradient = this . top_context . createLinearGradient (
427
- this . top_canvas . width - this . resize_handle_size / 3 , this . top_canvas . height - this . resize_handle_size / 3 ,
428
- this . top_canvas . width - this . resize_handle_size / 4 , this . top_canvas . height - this . resize_handle_size / 4
429
- ) ;
430
- gradient . addColorStop ( 0 , 'rgba(0, 0, 0, 0)' ) ;
431
- gradient . addColorStop ( 1 , 'rgba(0, 0, 0, 255)' ) ;
433
+ var gradient = this . top_context . createLinearGradient (
434
+ this . top_canvas . width - this . resize_handle_size / 3 , this . top_canvas . height - this . resize_handle_size / 3 ,
435
+ this . top_canvas . width - this . resize_handle_size / 4 , this . top_canvas . height - this . resize_handle_size / 4
436
+ ) ;
437
+ gradient . addColorStop ( 0 , 'rgba(0, 0, 0, 0)' ) ;
438
+ gradient . addColorStop ( 1 , 'rgba(0, 0, 0, 255)' ) ;
432
439
433
- this . top_context . fillStyle = gradient ;
440
+ this . top_context . fillStyle = gradient ;
434
441
435
- this . top_context . globalAlpha = 0.3 ;
436
- this . top_context . beginPath ( ) ;
437
- this . top_context . moveTo ( this . top_canvas . width , this . top_canvas . height ) ;
438
- this . top_context . lineTo ( this . top_canvas . width , this . top_canvas . height - this . resize_handle_size ) ;
439
- this . top_context . lineTo ( this . top_canvas . width - this . resize_handle_size , this . top_canvas . height ) ;
440
- this . top_context . closePath ( ) ;
441
- this . top_context . fill ( ) ;
442
+ this . top_context . globalAlpha = 0.3 ;
443
+ this . top_context . beginPath ( ) ;
444
+ this . top_context . moveTo ( this . top_canvas . width , this . top_canvas . height ) ;
445
+ this . top_context . lineTo ( this . top_canvas . width , this . top_canvas . height - this . resize_handle_size ) ;
446
+ this . top_context . lineTo ( this . top_canvas . width - this . resize_handle_size , this . top_canvas . height ) ;
447
+ this . top_context . closePath ( ) ;
448
+ this . top_context . fill ( ) ;
442
449
443
- this . top_context . restore ( ) ;
450
+ this . top_context . restore ( ) ;
451
+ }
444
452
}
445
453
446
454
_update_cursor ( ) {
@@ -492,7 +500,8 @@ class MPLCanvasView extends widgets.DOMWidgetView {
492
500
if ( name === 'button_press' ) {
493
501
// If clicking on the resize handle
494
502
if ( canvas_pos . x >= this . top_canvas . width - this . resize_handle_size &&
495
- canvas_pos . y >= this . top_canvas . height - this . resize_handle_size ) {
503
+ canvas_pos . y >= this . top_canvas . height - this . resize_handle_size &&
504
+ this . model . get ( 'resizable' ) ) {
496
505
this . resizing = true ;
497
506
return ;
498
507
} else {
0 commit comments