@@ -3644,7 +3644,7 @@ JSROOT.define(['d3', 'painter'], (d3, jsrp) => {
36443644
36453645 /** @summary Add buttons for pad or canvas
36463646 * @private */
3647- RPadPainter . prototype . addPadButtons = function ( /* is_online */ ) {
3647+ RPadPainter . prototype . addPadButtons = function ( is_online ) {
36483648
36493649 this . addPadButton ( "camera" , "Create PNG" , this . iscan ? "CanvasSnapShot" : "PadSnapShot" , "Ctrl PrintScreen" ) ;
36503650
@@ -3655,6 +3655,12 @@ JSROOT.define(['d3', 'painter'], (d3, jsrp) => {
36553655
36563656 if ( add_enlarge || this . enlargeMain ( 'verify' ) )
36573657 this . addPadButton ( "circle" , "Enlarge canvas" , "enlargePad" ) ;
3658+
3659+ if ( is_online && this . brlayout ) {
3660+ this . addPadButton ( "diamand" , "Toggle Ged" , "ToggleGed" ) ;
3661+ this . addPadButton ( "three_circles" , "Toggle Status" , "ToggleStatus" ) ;
3662+ }
3663+
36583664 }
36593665
36603666 /** @summary Show pad buttons
@@ -4224,9 +4230,126 @@ JSROOT.define(['d3', 'painter'], (d3, jsrp) => {
42244230 }
42254231 }
42264232
4233+ /** @summary Handle pad button click event
4234+ * @private */
4235+ RCanvasPainter . prototype . clickPadButton = function ( funcname , evnt ) {
4236+ if ( funcname == "ToggleGed" ) return this . activateGed ( this , null , "toggle" ) ;
4237+ if ( funcname == "ToggleStatus" ) return this . activateStatusBar ( "toggle" ) ;
4238+ RPadPainter . prototype . clickPadButton . call ( this , funcname , evnt ) ;
4239+ }
4240+
42274241 /** @summary returns true when event status area exist for the canvas */
42284242 RCanvasPainter . prototype . hasEventStatus = function ( ) {
4229- return this . has_event_status ;
4243+ if ( this . testUI5 ( ) ) return false ;
4244+ return this . brlayout ? this . brlayout . hasStatus ( ) : false ;
4245+ }
4246+
4247+ /** @summary Show/toggle event status bar
4248+ * @private */
4249+ RCanvasPainter . prototype . activateStatusBar = function ( state ) {
4250+ if ( this . testUI5 ( ) ) return ;
4251+ if ( this . brlayout )
4252+ this . brlayout . createStatusLine ( 23 , state ) ;
4253+ this . processChanges ( "sbits" , this ) ;
4254+ }
4255+
4256+ /** @summary Returns true if GED is present on the canvas */
4257+ RCanvasPainter . prototype . hasGed = function ( ) {
4258+ if ( this . testUI5 ( ) ) return false ;
4259+ return this . brlayout ? this . brlayout . hasContent ( ) : false ;
4260+ }
4261+
4262+ /** @summary Function used to de-activate GED
4263+ * @private */
4264+ RCanvasPainter . prototype . removeGed = function ( ) {
4265+ if ( this . testUI5 ( ) ) return ;
4266+
4267+ this . registerForPadEvents ( null ) ;
4268+
4269+ if ( this . ged_view ) {
4270+ this . ged_view . getController ( ) . cleanupGed ( ) ;
4271+ this . ged_view . destroy ( ) ;
4272+ delete this . ged_view ;
4273+ }
4274+ if ( this . brlayout )
4275+ this . brlayout . deleteContent ( ) ;
4276+
4277+ this . processChanges ( "sbits" , this ) ;
4278+ }
4279+
4280+ /** @summary Function used to activate GED
4281+ * @returns {Promise } when GED is there
4282+ * @private */
4283+ RCanvasPainter . prototype . activateGed = function ( objpainter , kind , mode ) {
4284+ if ( this . testUI5 ( ) || ! this . brlayout )
4285+ return Promise . resolve ( false ) ;
4286+
4287+ if ( this . brlayout . hasContent ( ) ) {
4288+ if ( ( mode === "toggle" ) || ( mode === false ) ) {
4289+ this . removeGed ( ) ;
4290+ } else {
4291+ let pp = objpainter ? objpainter . getPadPainter ( ) : null ;
4292+ if ( pp ) pp . selectObjectPainter ( objpainter ) ;
4293+ }
4294+
4295+ return Promise . resolve ( true ) ;
4296+ }
4297+
4298+ if ( mode === false )
4299+ return Promise . resolve ( false ) ;
4300+
4301+ let btns = this . brlayout . createBrowserBtns ( ) ;
4302+
4303+ JSROOT . require ( 'interactive' ) . then ( inter => {
4304+
4305+ inter . ToolbarIcons . createSVG ( btns , inter . ToolbarIcons . diamand , 15 , "toggle fix-pos mode" )
4306+ . style ( "margin" , "3px" ) . on ( "click" , ( ) => this . brlayout . toggleKind ( 'fix' ) ) ;
4307+
4308+ inter . ToolbarIcons . createSVG ( btns , inter . ToolbarIcons . circle , 15 , "toggle float mode" )
4309+ . style ( "margin" , "3px" ) . on ( "click" , ( ) => this . brlayout . toggleKind ( 'float' ) ) ;
4310+
4311+ inter . ToolbarIcons . createSVG ( btns , inter . ToolbarIcons . cross , 15 , "delete GED" )
4312+ . style ( "margin" , "3px" ) . on ( "click" , ( ) => this . removeGed ( ) ) ;
4313+ } ) ;
4314+
4315+ // be aware, that jsroot_browser_hierarchy required for flexible layout that element use full browser area
4316+ this . brlayout . setBrowserContent ( "<div class='jsroot_browser_hierarchy' id='ged_placeholder'>Loading GED ...</div>" ) ;
4317+ this . brlayout . setBrowserTitle ( "GED" ) ;
4318+ this . brlayout . toggleBrowserKind ( kind || "float" ) ;
4319+
4320+ return new Promise ( resolveFunc => {
4321+
4322+ JSROOT . require ( 'openui5' ) . then ( ( ) => {
4323+
4324+ d3 . select ( "#ged_placeholder" ) . text ( "" ) ;
4325+
4326+ sap . ui . define ( [ "sap/ui/model/json/JSONModel" , "sap/ui/core/mvc/XMLView" ] , ( JSONModel , XMLView ) => {
4327+
4328+ let oModel = new JSONModel ( { handle : null } ) ;
4329+
4330+ XMLView . create ( {
4331+ viewName : "rootui5.canv.view.Ged"
4332+ } ) . then ( oGed => {
4333+
4334+ oGed . setModel ( oModel ) ;
4335+
4336+ oGed . placeAt ( "ged_placeholder" ) ;
4337+
4338+ this . ged_view = oGed ;
4339+
4340+ // TODO: should be moved into Ged controller - it must be able to detect canvas painter itself
4341+ this . registerForPadEvents ( oGed . getController ( ) . padEventsReceiver . bind ( oGed . getController ( ) ) ) ;
4342+
4343+ let pp = objpainter ? objpainter . getPadPainter ( ) : null ;
4344+ if ( pp ) pp . selectObjectPainter ( objpainter ) ;
4345+
4346+ this . processChanges ( "sbits" , this ) ;
4347+
4348+ resolveFunc ( true ) ;
4349+ } ) ;
4350+ } ) ;
4351+ } ) ;
4352+ } ) ;
42304353 }
42314354
42324355 /** @summary produce JSON for RCanvas, which can be used to display canvas once again
@@ -4236,7 +4359,6 @@ JSROOT.define(['d3', 'painter'], (d3, jsrp) => {
42364359 return "" ;
42374360 }
42384361
4239-
42404362 function drawRCanvas ( divid , can /*, opt */ ) {
42414363 let nocanvas = ! can ;
42424364 if ( nocanvas )
0 commit comments