@@ -55,6 +55,9 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({
5555
5656 that . update_toolbar_position ( ) ;
5757
58+ that . update_header_visible ( ) ;
59+ that . update_toolbar_visible ( ) ;
60+
5861 that . model_events ( ) ;
5962
6063 that . send_initialization_message ( ) ;
@@ -80,12 +83,10 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({
8083
8184 update_header_visible : function ( ) {
8285 this . header . style . display = this . model . get ( 'header_visible' ) ? '' : 'none' ;
83- this . request_resize ( ) ;
8486 } ,
8587
8688 update_toolbar_visible : function ( ) {
8789 this . toolbar_view . el . style . display = this . model . get ( 'toolbar_visible' ) ? '' : 'none' ;
88- this . request_resize ( ) ;
8990 } ,
9091
9192 update_toolbar_position : function ( ) {
@@ -117,8 +118,6 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({
117118 this . el . appendChild ( this . toolbar_view . el ) ;
118119 }
119120 }
120-
121- this . request_resize ( ) ;
122121 } ,
123122
124123 clear : function ( ) {
@@ -227,60 +226,6 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({
227226 this . figure . appendChild ( this . footer ) ;
228227 } ,
229228
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-
284229 _resize_canvas : function ( width , height ) {
285230 // Keep the size of the canvas, and rubber band canvas in sync.
286231 this . canvas . setAttribute ( 'width' , width * this . ratio ) ;
@@ -292,13 +237,6 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({
292237
293238 this . canvas_div . style . width = width + 'px' ;
294239 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' ;
302240 } ,
303241
304242 send_message : function ( type , message = { } ) {
@@ -431,17 +369,6 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({
431369 }
432370 } ,
433371
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-
445372 mouse_event : function ( name ) {
446373 var that = this ;
447374 var last_update = 0 ;
0 commit comments