@@ -55,6 +55,9 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({
55
55
56
56
that . update_toolbar_position ( ) ;
57
57
58
+ that . update_header_visible ( ) ;
59
+ that . update_toolbar_visible ( ) ;
60
+
58
61
that . model_events ( ) ;
59
62
60
63
that . send_initialization_message ( ) ;
@@ -80,12 +83,10 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({
80
83
81
84
update_header_visible : function ( ) {
82
85
this . header . style . display = this . model . get ( 'header_visible' ) ? '' : 'none' ;
83
- this . request_resize ( ) ;
84
86
} ,
85
87
86
88
update_toolbar_visible : function ( ) {
87
89
this . toolbar_view . el . style . display = this . model . get ( 'toolbar_visible' ) ? '' : 'none' ;
88
- this . request_resize ( ) ;
89
90
} ,
90
91
91
92
update_toolbar_position : function ( ) {
@@ -117,8 +118,6 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({
117
118
this . el . appendChild ( this . toolbar_view . el ) ;
118
119
}
119
120
}
120
-
121
- this . request_resize ( ) ;
122
121
} ,
123
122
124
123
clear : function ( ) {
@@ -227,60 +226,6 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({
227
226
this . figure . appendChild ( this . footer ) ;
228
227
} ,
229
228
230
- _calculate_decorations_size : function ( ) {
231
- // Calculate the size of the decorations on the figure.
232
- var decorations_width = 0 ;
233
- var decorations_height = 0 ;
234
-
235
- // Toolbar size
236
- var toolbar_position = this . model . get ( 'toolbar_position' ) ;
237
- if ( toolbar_position == 'top' || toolbar_position == 'bottom' ) {
238
- decorations_height += utils . get_full_size ( this . toolbar_view . el ) . height ;
239
- } else {
240
- decorations_width += utils . get_full_size ( this . toolbar_view . el ) . width ;
241
- }
242
-
243
- // Label sizes
244
- decorations_height += utils . get_full_size ( this . header ) . height ;
245
- decorations_height += utils . get_full_size ( this . footer ) . height ;
246
-
247
- // Margins on the canvas
248
- var canvas_div_margins = utils . get_margin_size ( this . canvas_div ) ;
249
- decorations_width += canvas_div_margins . width ;
250
- decorations_height += canvas_div_margins . height ;
251
-
252
- // Margins on the figure div
253
- var figure_margins = utils . get_margin_size ( this . figure ) ;
254
- decorations_width += figure_margins . width ;
255
- decorations_height += figure_margins . height ;
256
-
257
- return {
258
- width : decorations_width ,
259
- height : decorations_height
260
- } ;
261
- } ,
262
-
263
- request_resize : function ( ) {
264
- // Ensure that the image already exists. We ignore the first calls to resize
265
- // because we want the widget to first adapt to the figure size set in
266
- // matplotlib.
267
- if ( ! this . image . src ) {
268
- return ;
269
- }
270
-
271
- // Using the given widget size, figure out how big the canvas should be.
272
- var decorations_size = this . _calculate_decorations_size ( ) ;
273
-
274
- var new_canvas_width = this . el . clientWidth - decorations_size . width ;
275
- var new_canvas_height = this . el . clientHeight - decorations_size . height ;
276
-
277
- // Ensure that the canvas size is a positive number.
278
- new_canvas_width = new_canvas_width < 1 ? 1 : new_canvas_width ;
279
- new_canvas_height = new_canvas_height < 1 ? 1 : new_canvas_height ;
280
-
281
- this . send_message ( 'resize' , { 'width' : new_canvas_width , 'height' : new_canvas_height } ) ;
282
- } ,
283
-
284
229
_resize_canvas : function ( width , height ) {
285
230
// Keep the size of the canvas, and rubber band canvas in sync.
286
231
this . canvas . setAttribute ( 'width' , width * this . ratio ) ;
@@ -292,13 +237,6 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({
292
237
293
238
this . canvas_div . style . width = width + 'px' ;
294
239
this . canvas_div . style . height = height + 'px' ;
295
-
296
- // Figure out the widget size.
297
- var decorations_size = this . _calculate_decorations_size ( ) ;
298
-
299
- // Reset the widget size to adapt to this figure.
300
- this . el . style . width = width + decorations_size . width + 'px' ;
301
- this . el . style . height = height + decorations_size . height + 'px' ;
302
240
} ,
303
241
304
242
send_message : function ( type , message = { } ) {
@@ -431,17 +369,6 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({
431
369
}
432
370
} ,
433
371
434
- processPhosphorMessage : function ( msg ) {
435
- MPLCanvasView . __super__ . processPhosphorMessage . apply ( this , arguments ) ;
436
-
437
- switch ( msg . type ) {
438
- case 'resize' :
439
- this . request_resize ( ) ;
440
- break ;
441
- }
442
- } ,
443
-
444
-
445
372
mouse_event : function ( name ) {
446
373
var that = this ;
447
374
var last_update = 0 ;
0 commit comments