Skip to content

Commit 743d17d

Browse files
Adjust angle dropdown color to match parent block (#24)
Co-authored-by: Thomas Weber <[email protected]>
1 parent dbca9ec commit 743d17d

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

core/css.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,9 +788,7 @@ Blockly.Css.CONTENT = [
788788
'}',
789789

790790
'.blocklyAngleCircle {',
791-
'stroke: ' + Blockly.Colours.motion.tertiary + ';',
792791
'stroke-width: 1;',
793-
'fill: ' + Blockly.Colours.motion.secondary + ';',
794792
'}',
795793

796794
'.blocklyAngleCenterPoint {',

core/field_angle.js

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,22 @@ Blockly.FieldAngle.RADIUS = Blockly.FieldAngle.HALF
137137
Blockly.FieldAngle.CENTER_RADIUS = 2;
138138

139139
/**
140-
* Path to the arrow svg icon.
140+
* SVG path data for arrow icon.
141141
*/
142-
Blockly.FieldAngle.ARROW_SVG_PATH = 'icons/arrow.svg';
142+
Blockly.FieldAngle.ARROW_SVG_PATH_DATA =
143+
'M 0.0189 -1.3178' +
144+
' L -4.4901 -0.5663' +
145+
' C -4.7532 -0.5224 -4.9811 -0.2606 -4.9811 0.0156' +
146+
' C -4.9811 0.2836 -4.7613 0.5522 -4.4901 0.5974' +
147+
' L 0.0189 1.3489' +
148+
' L 0.0189 3.0185' +
149+
' C 0.0189 3.5625 0.3833 3.752 0.8327 3.4269' +
150+
' L 4.641 0.6721' +
151+
' C 5.0982 0.3414 5.0957 -0.1853 4.6527 -0.5168' +
152+
' L 0.821 -3.3842' +
153+
' C 0.3756 -3.7175 0.0189 -3.5381 0.0189 -2.9874' +
154+
' L 0.0189 -1.3178' +
155+
' Z';
143156

144157
/**
145158
* Clean up this FieldAngle, as well as the inherited FieldTextInput.
@@ -175,6 +188,7 @@ Blockly.FieldAngle.prototype.showEditor_ = function() {
175188
Blockly.DropDownDiv.clearContent();
176189
var div = Blockly.DropDownDiv.getContentDiv();
177190
// Build the SVG DOM.
191+
var parentBlock = this.sourceBlock_.parentBlock_;
178192
var svg = Blockly.utils.createSvgElement('svg', {
179193
'xmlns': 'http://www.w3.org/2000/svg',
180194
'xmlns:html': 'http://www.w3.org/1999/xhtml',
@@ -186,6 +200,8 @@ Blockly.FieldAngle.prototype.showEditor_ = function() {
186200
Blockly.utils.createSvgElement('circle', {
187201
'cx': Blockly.FieldAngle.HALF, 'cy': Blockly.FieldAngle.HALF,
188202
'r': Blockly.FieldAngle.RADIUS,
203+
'fill': parentBlock.getColourSecondary(),
204+
'stroke': parentBlock.getColourTertiary(),
189205
'class': 'blocklyAngleCircle'
190206
}, svg);
191207
this.gauge_ = Blockly.utils.createSvgElement('path',
@@ -231,24 +247,20 @@ Blockly.FieldAngle.prototype.showEditor_ = function() {
231247
'r': Blockly.FieldAngle.HANDLE_RADIUS,
232248
'class': 'blocklyAngleDragHandle'
233249
}, this.handle_);
234-
this.arrowSvg_ = Blockly.utils.createSvgElement('image',
250+
this.arrowSvg_ = Blockly.utils.createSvgElement('path',
235251
{
236252
'width': Blockly.FieldAngle.ARROW_WIDTH,
237253
'height': Blockly.FieldAngle.ARROW_WIDTH,
238254
'x': -Blockly.FieldAngle.ARROW_WIDTH / 2,
239255
'y': -Blockly.FieldAngle.ARROW_WIDTH / 2,
240-
'class': 'blocklyAngleDragArrow'
256+
'class': 'blocklyAngleDragArrow',
257+
'fill': parentBlock.getColour(),
258+
'd': Blockly.FieldAngle.ARROW_SVG_PATH_DATA
241259
},
242260
this.handle_);
243-
this.arrowSvg_.setAttributeNS(
244-
'http://www.w3.org/1999/xlink',
245-
'xlink:href',
246-
Blockly.mainWorkspace.options.pathToMedia + Blockly.FieldAngle.ARROW_SVG_PATH
247-
);
248-
249-
Blockly.DropDownDiv.setColour(this.sourceBlock_.parentBlock_.getColour(),
250-
this.sourceBlock_.getColourTertiary());
251-
Blockly.DropDownDiv.setCategory(this.sourceBlock_.parentBlock_.getCategory());
261+
262+
Blockly.DropDownDiv.setColour(parentBlock.getColour(), this.sourceBlock_.getColourTertiary());
263+
Blockly.DropDownDiv.setCategory(parentBlock.getCategory());
252264
Blockly.DropDownDiv.showPositionedByBlock(this, this.sourceBlock_);
253265

254266
this.mouseDownWrapper_ =

0 commit comments

Comments
 (0)