Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/colours.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const Colours = {
valueReportBackground: "#FFFFFF",
valueReportBorder: "#AAAAAA",
contextualMenuHover: "rgba(77, 151, 255, .25)",
menuHover: "rgba(0, 0, 0, .2)",
};

/**
Expand Down
27 changes: 13 additions & 14 deletions src/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -702,16 +702,16 @@ const styles = `
}

.blocklyAngleCenterPoint {
stroke: #fff;
stroke: var(--colour-text);
stroke-width: 1;
fill: #fff;
fill: var(--colour-text);
}

.blocklyAngleDragHandle {
stroke: #fff;
stroke: var(--colour-text);
stroke-width: 5;
stroke-opacity: 0.25;
fill: #fff;
fill: var(--colour-text);
cursor: pointer;
}

Expand All @@ -720,18 +720,18 @@ const styles = `
}

.blocklyAngleMarks {
stroke: #fff;
stroke: var(--colour-text);
stroke-width: 1;
stroke-opacity: 0.5;
}

.blocklyAngleGauge {
fill: #fff;
fill: var(--colour-text);
fill-opacity: 0.20;
}

.blocklyAngleLine {
stroke: #fff;
stroke: var(--colour-text);
stroke-width: 1;
stroke-linecap: round;
pointer-events: none;
Expand Down Expand Up @@ -1011,12 +1011,12 @@ const styles = `
z-index: 20000; /* Arbitrary, but some apps depend on it... */
}

.blocklyDropDownDiv .blocklyMenu .blocklyMenuItem:hover {
background: var(--colour-menuHover);
.blocklyDropDownDiv .blocklyMenu .blocklyMenuItem.blocklyMenuItemHighlight {
background-color: var(--colour-menuHover);
}

.blocklyWidgetDiv .blocklyMenu .blocklyMenuItem:hover {
background: var(--colour-contextualMenuHover);
.blocklyWidgetDiv .blocklyMenu .blocklyMenuItem.blocklyMenuItemHighlight {
background-color: var(--colour-contextualMenuHover);
}

.blocklyWidgetDiv .blocklyMenu .blocklyMenuItemDisabled.blocklyMenuItem:hover {
Expand Down Expand Up @@ -1168,13 +1168,12 @@ const styles = `
color: #4c97ff;
}
.blocklyDropDownDiv .blocklyMenuItem {
color: #fff;
font-weight: bold;
min-height: 32px;
padding: 4px 7em 4px 28px;
}
.high-contrast-theme.blocklyDropDownDiv .blocklyMenuItem {
color: #000;
.scratch-renderer.blocklyDropDownDiv .blocklyMenuItem .blocklyMenuItemContent {
color: var(--colour-text);
}
.blocklyToolboxSelected .blocklyTreeLabel {
color: var(--colour-toolboxText);
Expand Down
65 changes: 38 additions & 27 deletions src/fields/field_matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class FieldMatrix extends Blockly.Field<string> {
this.arrow_.setAttributeNS(
"http://www.w3.org/1999/xlink",
"xlink:href",
Blockly.getMainWorkspace().options.pathToMedia + "dropdown-arrow.svg"
this.getConstants().FIELD_DROPDOWN_SVG_ARROW_DATAURI
);
this.arrow_.style.cursor = "default";
}
Expand All @@ -238,6 +238,25 @@ class FieldMatrix extends Blockly.Field<string> {
* Show the drop-down menu for editing this field.
*/
showEditor_() {
const sourceBlock = this.getSourceBlock() as Blockly.BlockSvg;
Blockly.DropDownDiv.setColour(
sourceBlock.getColour(),
sourceBlock.getColourTertiary()
);

const style = sourceBlock.style;
if (sourceBlock.isShadow()) {
this.originalStyle = sourceBlock.getStyleName();
sourceBlock.setStyle(`${this.originalStyle}_selected`);
} else if (this.borderRect_) {
this.borderRect_.setAttribute(
"fill",
"colourQuaternary" in style
? `${style.colourQuaternary}`
: style.colourTertiary
);
}

const div = Blockly.DropDownDiv.getContentDiv();
// Build the SVG DOM.
const matrixSize =
Expand Down Expand Up @@ -286,23 +305,19 @@ class FieldMatrix extends Blockly.Field<string> {
// Button to clear matrix
const clearButtonDiv = document.createElement("div");
clearButtonDiv.className = "scratchMatrixButtonDiv";
const sourceBlock = this.getSourceBlock() as Blockly.BlockSvg;

const clearButton = this.createButton_(sourceBlock.getColourSecondary());
clearButtonDiv.appendChild(clearButton);
// Button to fill matrix
const fillButtonDiv = document.createElement("div");
fillButtonDiv.className = "scratchMatrixButtonDiv";
const fillButton = this.createButton_("#FFFFFF");
const fillButton = this.createButton_("var(--colour-text)");
fillButtonDiv.appendChild(fillButton);

buttonDiv.appendChild(clearButtonDiv);
buttonDiv.appendChild(fillButtonDiv);
div.appendChild(buttonDiv);

Blockly.DropDownDiv.setColour(
sourceBlock.getColour(),
sourceBlock.getColourTertiary()
);
Blockly.DropDownDiv.showPositionedByBlock(
this,
sourceBlock,
Expand All @@ -328,19 +343,6 @@ class FieldMatrix extends Blockly.Field<string> {
this.fillMatrix_
);

const style = sourceBlock.style;
if (sourceBlock.isShadow()) {
this.originalStyle = sourceBlock.getStyleName();
sourceBlock.setStyle(`${this.originalStyle}_selected`);
} else if (this.borderRect_) {
this.borderRect_.setAttribute(
"fill",
"colourQuaternary" in style
? `${style.colourQuaternary}`
: style.colourTertiary
);
}

// Update the matrix for the current value
this.updateMatrix_();
}
Expand All @@ -350,6 +352,7 @@ class FieldMatrix extends Blockly.Field<string> {
if (sourceBlock.isShadow()) {
sourceBlock.setStyle(this.originalStyle);
}
this.updateMatrix_();
}

/**
Expand Down Expand Up @@ -400,12 +403,16 @@ class FieldMatrix extends Blockly.Field<string> {
this.fillMatrixNode_(
this.ledButtons_,
i,
sourceBlock.getColourTertiary()
);
this.fillMatrixNode_(
this.ledThumbNodes_,
i,
sourceBlock.getColourSecondary()
);
this.fillMatrixNode_(this.ledThumbNodes_, i, sourceBlock.getColour());
} else {
this.fillMatrixNode_(this.ledButtons_, i, "#FFFFFF");
this.fillMatrixNode_(this.ledThumbNodes_, i, "#FFFFFF");
this.fillMatrixNode_(this.ledButtons_, i, "var(--colour-text)");
this.fillMatrixNode_(this.ledThumbNodes_, i, "var(--colour-text)");
}
}
}
Expand Down Expand Up @@ -505,10 +512,14 @@ class FieldMatrix extends Blockly.Field<string> {
* Unbind mouse move event and clear the paint style.
*/
onMouseUp() {
Blockly.browserEvents.unbind(this.matrixMoveWrapper_);
this.matrixMoveWrapper_ = null;
Blockly.browserEvents.unbind(this.matrixReleaseWrapper_);
this.matrixReleaseWrapper_ = null;
if (this.matrixMoveWrapper_) {
Blockly.browserEvents.unbind(this.matrixMoveWrapper_);
this.matrixMoveWrapper_ = null;
}
if (this.matrixReleaseWrapper_) {
Blockly.browserEvents.unbind(this.matrixReleaseWrapper_);
this.matrixReleaseWrapper_ = null;
}
this.paintStyle_ = null;
}

Expand Down