Commit 50a1371f authored by hsun1316's avatar hsun1316 Committed by Evan W. Patton

Add menu option to hide workspace controls

parent 4241d37c
...@@ -44,6 +44,8 @@ Blockly.Msg.en.switch_language_to_english = { ...@@ -44,6 +44,8 @@ Blockly.Msg.en.switch_language_to_english = {
Blockly.Msg.UNDO = 'Undo'; Blockly.Msg.UNDO = 'Undo';
Blockly.Msg.REDO = 'Redo'; Blockly.Msg.REDO = 'Redo';
Blockly.Msg.CLEAN_UP = 'Clean up Blocks'; 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.DUPLICATE_BLOCK = 'Duplicate';
Blockly.Msg.REMOVE_COMMENT = 'Remove Comment'; Blockly.Msg.REMOVE_COMMENT = 'Remove Comment';
Blockly.Msg.ADD_COMMENT = 'Add Comment'; Blockly.Msg.ADD_COMMENT = 'Add Comment';
......
...@@ -63,6 +63,12 @@ Blockly.WorkspaceSvg.prototype.blocksNeedingRendering = null; ...@@ -63,6 +63,12 @@ Blockly.WorkspaceSvg.prototype.blocksNeedingRendering = null;
*/ */
Blockly.WorkspaceSvg.prototype.latestClick = { x: 0, y: 0 }; 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. * Wrap the onMouseClick_ event to handle additional behaviors.
*/ */
...@@ -568,6 +574,19 @@ Blockly.WorkspaceSvg.prototype.customContextMenu = function(menuOptions) { ...@@ -568,6 +574,19 @@ Blockly.WorkspaceSvg.prototype.customContextMenu = function(menuOptions) {
}; };
menuOptions.splice(3, 0, exportOption); 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. // Arrange blocks in row order.
var arrangeOptionH = {enabled: (Blockly.workspace_arranged_position !== Blockly.BLKS_HORIZONTAL)}; var arrangeOptionH = {enabled: (Blockly.workspace_arranged_position !== Blockly.BLKS_HORIZONTAL)};
arrangeOptionH.text = Blockly.Msg.ARRANGE_H; arrangeOptionH.text = Blockly.Msg.ARRANGE_H;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment