mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-08-28 22:10:31 -04:00
Lay out trashcan and zoom controls more flexibly.
This commit is contained in:
parent
7568015c8c
commit
f9d47bd39e
3 changed files with 31 additions and 19 deletions
|
@ -67,14 +67,14 @@ Blockly.Trashcan.prototype.LID_HEIGHT_ = 15;
|
|||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
Blockly.Trashcan.prototype.MARGIN_BOTTOM_ = 35;
|
||||
Blockly.Trashcan.prototype.MARGIN_BOTTOM_ = 20;
|
||||
|
||||
/**
|
||||
* Distance between trashcan and right edge of workspace.
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
Blockly.Trashcan.prototype.MARGIN_SIDE_ = 35;
|
||||
Blockly.Trashcan.prototype.MARGIN_SIDE_ = 20;
|
||||
|
||||
/**
|
||||
* Extent of hotspot on all sides beyond the size of the image.
|
||||
|
@ -185,9 +185,13 @@ Blockly.Trashcan.prototype.createDom = function() {
|
|||
|
||||
/**
|
||||
* Initialize the trash can.
|
||||
* @param {number} bottom Distance from workspace bottom to bottom of trashcan.
|
||||
* @return {number} Distance from workspace bottom to the top of trashcan.
|
||||
*/
|
||||
Blockly.Trashcan.prototype.init = function() {
|
||||
Blockly.Trashcan.prototype.init = function(bottom) {
|
||||
this.bottom_ = this.MARGIN_BOTTOM_ + bottom;
|
||||
this.setOpen_(false);
|
||||
return this.bottom_ + this.BODY_HEIGHT_ + this.LID_HEIGHT_;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -214,13 +218,13 @@ Blockly.Trashcan.prototype.position = function() {
|
|||
return;
|
||||
}
|
||||
if (this.workspace_.RTL) {
|
||||
this.left_ = this.MARGIN_SIDE_;
|
||||
this.left_ = this.MARGIN_SIDE_ + Blockly.Scrollbar.scrollbarThickness;
|
||||
} else {
|
||||
this.left_ = metrics.viewWidth + metrics.absoluteLeft -
|
||||
this.WIDTH_ - this.MARGIN_SIDE_;
|
||||
this.WIDTH_ - this.MARGIN_SIDE_ - Blockly.Scrollbar.scrollbarThickness;
|
||||
}
|
||||
this.top_ = metrics.viewHeight + metrics.absoluteTop -
|
||||
(this.BODY_HEIGHT_ + this.LID_HEIGHT_) - this.MARGIN_BOTTOM_;
|
||||
(this.BODY_HEIGHT_ + this.LID_HEIGHT_) - this.bottom_;
|
||||
this.svgGroup_.setAttribute('transform',
|
||||
'translate(' + this.left_ + ',' + this.top_ + ')');
|
||||
};
|
||||
|
|
|
@ -162,11 +162,12 @@ Blockly.WorkspaceSvg.prototype.createDom = function(opt_backgroundClass) {
|
|||
{'class': 'blocklyBlockCanvas'}, this.svgGroup_, this);
|
||||
this.svgBubbleCanvas_ = Blockly.createSvgElement('g',
|
||||
{'class': 'blocklyBubbleCanvas'}, this.svgGroup_, this);
|
||||
var bottom = Blockly.Scrollbar.scrollbarThickness;
|
||||
if (this.options.hasTrashcan) {
|
||||
this.addTrashcan_();
|
||||
bottom = this.addTrashcan_(bottom);
|
||||
}
|
||||
if (this.options.zoomOptions && this.options.zoomOptions.controls) {
|
||||
this.addZoomControls_();
|
||||
bottom = this.addZoomControls_(bottom);
|
||||
}
|
||||
Blockly.bindEvent_(this.svgGroup_, 'mousedown', this, this.onMouseDown_);
|
||||
var thisWorkspace = this;
|
||||
|
@ -231,26 +232,30 @@ Blockly.WorkspaceSvg.prototype.dispose = function() {
|
|||
|
||||
/**
|
||||
* Add a trashcan.
|
||||
* @param {number} bottom Distance from workspace bottom to bottom of trashcan.
|
||||
* @return {number} Distance from workspace bottom to the top of trashcan.
|
||||
* @private
|
||||
*/
|
||||
Blockly.WorkspaceSvg.prototype.addTrashcan_ = function() {
|
||||
Blockly.WorkspaceSvg.prototype.addTrashcan_ = function(bottom) {
|
||||
/** @type {Blockly.Trashcan} */
|
||||
this.trashcan = new Blockly.Trashcan(this);
|
||||
var svgTrashcan = this.trashcan.createDom();
|
||||
this.svgGroup_.insertBefore(svgTrashcan, this.svgBlockCanvas_);
|
||||
this.trashcan.init();
|
||||
return this.trashcan.init(bottom);
|
||||
};
|
||||
|
||||
/**
|
||||
* Add zoom controls.
|
||||
* @param {number} bottom Distance from workspace bottom to bottom of controls.
|
||||
* @return {number} Distance from workspace bottom to the top of controls.
|
||||
* @private
|
||||
*/
|
||||
Blockly.WorkspaceSvg.prototype.addZoomControls_ = function() {
|
||||
Blockly.WorkspaceSvg.prototype.addZoomControls_ = function(bottom) {
|
||||
/** @type {Blockly.ZoomControls} */
|
||||
this.zoomControls_ = new Blockly.ZoomControls(this);
|
||||
var svgZoomControls = this.zoomControls_.createDom();
|
||||
this.svgGroup_.appendChild(svgZoomControls);
|
||||
this.zoomControls_.init();
|
||||
return this.zoomControls_.init(bottom);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -57,14 +57,14 @@ Blockly.ZoomControls.prototype.HEIGHT_ = 110;
|
|||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
Blockly.ZoomControls.prototype.MARGIN_BOTTOM_ = 100;
|
||||
Blockly.ZoomControls.prototype.MARGIN_BOTTOM_ = 20;
|
||||
|
||||
/**
|
||||
* Distance between zoom controls and right edge of workspace.
|
||||
* @type {number}
|
||||
* @private
|
||||
*/
|
||||
Blockly.ZoomControls.prototype.MARGIN_SIDE_ = 35;
|
||||
Blockly.ZoomControls.prototype.MARGIN_SIDE_ = 20;
|
||||
|
||||
/**
|
||||
* The SVG group containing the zoom controls.
|
||||
|
@ -175,9 +175,12 @@ Blockly.ZoomControls.prototype.createDom = function() {
|
|||
|
||||
/**
|
||||
* Initialize the zoom controls.
|
||||
* @param {number} bottom Distance from workspace bottom to bottom of controls.
|
||||
* @return {number} Distance from workspace bottom to the top of controls.
|
||||
*/
|
||||
Blockly.ZoomControls.prototype.init = function() {
|
||||
// Initialize some stuff... (animations?)
|
||||
Blockly.ZoomControls.prototype.init = function(bottom) {
|
||||
this.bottom_ = this.MARGIN_BOTTOM_ + bottom;
|
||||
return this.bottom_ + this.HEIGHT_;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -202,13 +205,13 @@ Blockly.ZoomControls.prototype.position = function() {
|
|||
return;
|
||||
}
|
||||
if (this.workspace_.RTL) {
|
||||
this.left_ = this.MARGIN_SIDE_;
|
||||
this.left_ = this.MARGIN_SIDE_ + Blockly.Scrollbar.scrollbarThickness;
|
||||
} else {
|
||||
this.left_ = metrics.viewWidth + metrics.absoluteLeft -
|
||||
this.WIDTH_ - this.MARGIN_SIDE_;
|
||||
this.WIDTH_ - this.MARGIN_SIDE_ - Blockly.Scrollbar.scrollbarThickness;
|
||||
}
|
||||
this.top_ = metrics.viewHeight + metrics.absoluteTop -
|
||||
this.HEIGHT_ - this.MARGIN_BOTTOM_;
|
||||
this.HEIGHT_ - this.bottom_;
|
||||
this.svgGroup_.setAttribute('transform',
|
||||
'translate(' + this.left_ + ',' + this.top_ + ')');
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue