Skip to content
Permalink
Browse files

Add menu option to hide workspace controls

  • Loading branch information...
hsun1316 authored and ewpatton committed Mar 22, 2019
1 parent 4241d37 commit 50a1371fa64493dfcce8c1f39dad8daa73c16c7e
@@ -44,6 +44,8 @@ Blockly.Msg.en.switch_language_to_english = {
Blockly.Msg.UNDO = 'Undo';
Blockly.Msg.REDO = 'Redo';
Blockly.Msg.CLEAN_UP = 'Clean up Blocks';
Blockly.Msg.HIDE = 'Hide Workspace Controls';
Blockly.Msg.SHOW = 'Show Workspace Controls';
Blockly.Msg.DUPLICATE_BLOCK = 'Duplicate';
Blockly.Msg.REMOVE_COMMENT = 'Remove Comment';
Blockly.Msg.ADD_COMMENT = 'Add Comment';
@@ -63,6 +63,12 @@ Blockly.WorkspaceSvg.prototype.blocksNeedingRendering = null;
*/
Blockly.WorkspaceSvg.prototype.latestClick = { x: 0, y: 0 };

/**
* Whether the workspace elements are hidden
* @type {boolean}
*/
Blockly.WorkspaceSvg.prototype.chromeHidden = false;

/**
* Wrap the onMouseClick_ event to handle additional behaviors.
*/
@@ -568,6 +574,19 @@ Blockly.WorkspaceSvg.prototype.customContextMenu = function(menuOptions) {
};
menuOptions.splice(3, 0, exportOption);

//Show or hide workspace SVG elements backpack, zoom, and trashcan
var workspaceOption = {enabled: true};
workspaceOption.text = this.chromeHidden ? Blockly.Msg.SHOW : Blockly.Msg.HIDE;
var displayStyle = this.chromeHidden ? 'block' : 'none';
workspaceOption.callback= function() {
self.backpack_.svgGroup_.style.display=displayStyle;
self.trashcan.svgGroup_.style.display=displayStyle;
self.zoomControls_.svgGroup_.style.display=displayStyle;
self.warningIndicator_.svgGroup_.style.display=displayStyle;
self.chromeHidden = !self.chromeHidden;
};
menuOptions.push(workspaceOption);

// Arrange blocks in row order.
var arrangeOptionH = {enabled: (Blockly.workspace_arranged_position !== Blockly.BLKS_HORIZONTAL)};
arrangeOptionH.text = Blockly.Msg.ARRANGE_H;

0 comments on commit 50a1371

Please sign in to comment.
You can’t perform that action at this time.