mirror of
https://github.com/google/blockly.git
synced 2026-01-13 20:07:08 +01:00
Fix bugs with apply colour (#3483)
This commit is contained in:
@@ -972,10 +972,6 @@ Blockly.BlockSvg.prototype.dispose = function(healStack, animate) {
|
||||
* @package
|
||||
*/
|
||||
Blockly.BlockSvg.prototype.applyColour = function() {
|
||||
if (!this.rendered) {
|
||||
// Non-rendered blocks don't have colour.
|
||||
return;
|
||||
}
|
||||
this.pathObject.applyColour(this);
|
||||
|
||||
var icons = this.getIcons();
|
||||
|
||||
@@ -673,10 +673,34 @@ Blockly.Field.prototype.getSize = function() {
|
||||
* @package
|
||||
*/
|
||||
Blockly.Field.prototype.getScaledBBox = function() {
|
||||
var bBox = this.borderRect_.getBBox();
|
||||
var xy = this.getAbsoluteXY_();
|
||||
var scaledWidth = bBox.width * this.sourceBlock_.workspace.scale;
|
||||
var scaledHeight = bBox.height * this.sourceBlock_.workspace.scale;
|
||||
if (!this.borderRect_) {
|
||||
// Browsers are inconsistent in what they return for a bounding box.
|
||||
// - Webkit / Blink: fill-box / object bounding box
|
||||
// - Gecko / Triden / EdgeHTML: stroke-box
|
||||
var bBox = this.sourceBlock_.getHeightWidth();
|
||||
var scale = this.sourceBlock_.workspace.scale;
|
||||
var xy = this.getAbsoluteXY_();
|
||||
var scaledWidth = bBox.width * scale;
|
||||
var scaledHeight = bBox.height * scale;
|
||||
|
||||
if (Blockly.utils.userAgent.GECKO) {
|
||||
xy.x += 1.5 * scale;
|
||||
xy.y += 1.5 * scale;
|
||||
scaledWidth += 1 * scale;
|
||||
scaledHeight += 1 * scale;
|
||||
} else {
|
||||
if (!Blockly.utils.userAgent.EDGE && !Blockly.utils.userAgent.IE) {
|
||||
xy.x -= 0.5 * scale;
|
||||
xy.y -= 0.5 * scale;
|
||||
}
|
||||
scaledWidth += 1 * scale;
|
||||
scaledHeight += 1 * scale;
|
||||
}
|
||||
} else {
|
||||
var xy = this.borderRect_.getBoundingClientRect();
|
||||
var scaledWidth = xy.width;
|
||||
var scaledHeight = xy.height;
|
||||
}
|
||||
return {
|
||||
top: xy.y,
|
||||
bottom: xy.y + scaledHeight,
|
||||
|
||||
@@ -199,7 +199,9 @@ Blockly.FieldColour.prototype.initView = function() {
|
||||
*/
|
||||
Blockly.FieldColour.prototype.applyColour = function() {
|
||||
if (!this.constants_.FIELD_COLOUR_FULL_BLOCK) {
|
||||
this.borderRect_.style.fill = this.getValue();
|
||||
if (this.borderRect_) {
|
||||
this.borderRect_.style.fill = this.getValue();
|
||||
}
|
||||
} else {
|
||||
this.sourceBlock_.pathObject.svgPath.setAttribute('fill', this.getValue());
|
||||
this.sourceBlock_.pathObject.svgPath.setAttribute('stroke', '#fff');
|
||||
|
||||
@@ -635,44 +635,4 @@ Blockly.FieldTextInput.prototype.getValueFromEditorText_ = function(text) {
|
||||
return text;
|
||||
};
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
Blockly.FieldTextInput.prototype.getScaledBBox = function() {
|
||||
if (!this.borderRect_) {
|
||||
// Browsers are inconsistent in what they return for a bounding box.
|
||||
// - Webkit / Blink: fill-box / object bounding box
|
||||
// - Gecko / Triden / EdgeHTML: stroke-box
|
||||
var bBox = this.sourceBlock_.getHeightWidth();
|
||||
var scale = this.sourceBlock_.workspace.scale;
|
||||
var xy = this.getAbsoluteXY_();
|
||||
var scaledWidth = bBox.width * scale;
|
||||
var scaledHeight = bBox.height * scale;
|
||||
|
||||
if (Blockly.utils.userAgent.GECKO) {
|
||||
xy.x += 1.5 * scale;
|
||||
xy.y += 1.5 * scale;
|
||||
scaledWidth += 1 * scale;
|
||||
scaledHeight += 1 * scale;
|
||||
} else {
|
||||
if (!Blockly.utils.userAgent.EDGE && !Blockly.utils.userAgent.IE) {
|
||||
xy.x -= 0.5 * scale;
|
||||
xy.y -= 0.5 * scale;
|
||||
}
|
||||
scaledWidth += 1 * scale;
|
||||
scaledHeight += 1 * scale;
|
||||
}
|
||||
} else {
|
||||
var xy = this.borderRect_.getBoundingClientRect();
|
||||
var scaledWidth = xy.width;
|
||||
var scaledHeight = xy.height;
|
||||
}
|
||||
return {
|
||||
top: xy.y,
|
||||
bottom: xy.y + scaledHeight,
|
||||
left: xy.x,
|
||||
right: xy.x + scaledWidth
|
||||
};
|
||||
};
|
||||
|
||||
Blockly.fieldRegistry.register('field_input', Blockly.FieldTextInput);
|
||||
|
||||
Reference in New Issue
Block a user