Skip to content

Commit

Permalink
feat: add quaternary color for selected dropdowns
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy O'Neill committed Mar 2, 2023
1 parent 69baac5 commit ffcd546
Show file tree
Hide file tree
Showing 23 changed files with 180 additions and 67 deletions.
15 changes: 10 additions & 5 deletions blocks_common/math.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ Blockly.Blocks['math_number'] = {
"outputShape": Blockly.OUTPUT_SHAPE_ROUND,
"colour": Blockly.Colours.textField,
"colourSecondary": Blockly.Colours.textField,
"colourTertiary": Blockly.Colours.textField
"colourTertiary": Blockly.Colours.textField,
"colourQuaternary": Blockly.Colours.textField
});
}
};
Expand All @@ -75,7 +76,8 @@ Blockly.Blocks['math_integer'] = {
"outputShape": Blockly.OUTPUT_SHAPE_ROUND,
"colour": Blockly.Colours.textField,
"colourSecondary": Blockly.Colours.textField,
"colourTertiary": Blockly.Colours.textField
"colourTertiary": Blockly.Colours.textField,
"colourQuaternary": Blockly.Colours.textField
});
}
};
Expand All @@ -100,7 +102,8 @@ Blockly.Blocks['math_whole_number'] = {
"outputShape": Blockly.OUTPUT_SHAPE_ROUND,
"colour": Blockly.Colours.textField,
"colourSecondary": Blockly.Colours.textField,
"colourTertiary": Blockly.Colours.textField
"colourTertiary": Blockly.Colours.textField,
"colourQuaternary": Blockly.Colours.textField
});
}
};
Expand All @@ -124,7 +127,8 @@ Blockly.Blocks['math_positive_number'] = {
"outputShape": Blockly.OUTPUT_SHAPE_ROUND,
"colour": Blockly.Colours.textField,
"colourSecondary": Blockly.Colours.textField,
"colourTertiary": Blockly.Colours.textField
"colourTertiary": Blockly.Colours.textField,
"colourQuaternary": Blockly.Colours.textField
});
}
};
Expand All @@ -148,7 +152,8 @@ Blockly.Blocks['math_angle'] = {
"outputShape": Blockly.OUTPUT_SHAPE_ROUND,
"colour": Blockly.Colours.textField,
"colourSecondary": Blockly.Colours.textField,
"colourTertiary": Blockly.Colours.textField
"colourTertiary": Blockly.Colours.textField,
"colourQuaternary": Blockly.Colours.textField
});
}
};
3 changes: 2 additions & 1 deletion blocks_common/note.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ Blockly.Blocks['note'] = {
"output": "Number",
"colour": Blockly.Colours.textField,
"colourSecondary": Blockly.Colours.textField,
"colourTertiary": Blockly.Colours.textField
"colourTertiary": Blockly.Colours.textField,
"colourQuaternary": Blockly.Colours.textField
});
}
};
3 changes: 2 additions & 1 deletion blocks_common/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ Blockly.Blocks['text'] = {
"outputShape": Blockly.OUTPUT_SHAPE_ROUND,
"colour": Blockly.Colours.textField,
"colourSecondary": Blockly.Colours.textField,
"colourTertiary": Blockly.Colours.textField
"colourTertiary": Blockly.Colours.textField,
"colourQuaternary": Blockly.Colours.textField
});
}
};
15 changes: 10 additions & 5 deletions blocks_horizontal/control.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ Blockly.Blocks['control_repeat'] = {
"category": Blockly.Categories.control,
"colour": Blockly.Colours.control.primary,
"colourSecondary": Blockly.Colours.control.secondary,
"colourTertiary": Blockly.Colours.control.tertiary
"colourTertiary": Blockly.Colours.control.tertiary,
"colourQuaternary": Blockly.Colours.control.quaternary
});
}
};
Expand Down Expand Up @@ -99,7 +100,8 @@ Blockly.Blocks['control_forever'] = {
"category": Blockly.Categories.control,
"colour": Blockly.Colours.control.primary,
"colourSecondary": Blockly.Colours.control.secondary,
"colourTertiary": Blockly.Colours.control.tertiary
"colourTertiary": Blockly.Colours.control.tertiary,
"colourQuaternary": Blockly.Colours.control.quaternary
});
}
};
Expand Down Expand Up @@ -139,7 +141,8 @@ Blockly.Blocks['control_repeat'] = {
"category": Blockly.Categories.control,
"colour": Blockly.Colours.control.primary,
"colourSecondary": Blockly.Colours.control.secondary,
"colourTertiary": Blockly.Colours.control.tertiary
"colourTertiary": Blockly.Colours.control.tertiary,
"colourQuaternary": Blockly.Colours.control.quaternary
});
}
};
Expand Down Expand Up @@ -167,7 +170,8 @@ Blockly.Blocks['control_stop'] = {
"category": Blockly.Categories.control,
"colour": Blockly.Colours.control.primary,
"colourSecondary": Blockly.Colours.control.secondary,
"colourTertiary": Blockly.Colours.control.tertiary
"colourTertiary": Blockly.Colours.control.tertiary,
"colourQuaternary": Blockly.Colours.control.quaternary
});
}
};
Expand Down Expand Up @@ -201,7 +205,8 @@ Blockly.Blocks['control_wait'] = {
"category": Blockly.Categories.control,
"colour": Blockly.Colours.control.primary,
"colourSecondary": Blockly.Colours.control.secondary,
"colourTertiary": Blockly.Colours.control.tertiary
"colourTertiary": Blockly.Colours.control.tertiary,
"colourQuaternary": Blockly.Colours.control.quaternary
});
}
};
15 changes: 10 additions & 5 deletions blocks_horizontal/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ Blockly.Blocks['event_whenflagclicked'] = {
"category": Blockly.Categories.event,
"colour": Blockly.Colours.event.primary,
"colourSecondary": Blockly.Colours.event.secondary,
"colourTertiary": Blockly.Colours.event.tertiary
"colourTertiary": Blockly.Colours.event.tertiary,
"colourQuaternary": Blockly.Colours.event.quaternary
});
}
};
Expand Down Expand Up @@ -84,7 +85,8 @@ Blockly.Blocks['dropdown_whenbroadcast'] = {
this.setOutput(true);
this.setColour(Blockly.Colours.event.primary,
Blockly.Colours.event.secondary,
Blockly.Colours.event.tertiary
Blockly.Colours.event.tertiary,
Blockly.Colours.event.quaternary
);
}
};
Expand Down Expand Up @@ -116,7 +118,8 @@ Blockly.Blocks['event_whenbroadcastreceived'] = {
"category": Blockly.Categories.event,
"colour": Blockly.Colours.event.primary,
"colourSecondary": Blockly.Colours.event.secondary,
"colourTertiary": Blockly.Colours.event.tertiary
"colourTertiary": Blockly.Colours.event.tertiary,
"colourQuaternary": Blockly.Colours.event.quaternary
});
}
};
Expand Down Expand Up @@ -146,7 +149,8 @@ Blockly.Blocks['dropdown_broadcast'] = {
this.setOutput(true);
this.setColour(Blockly.Colours.event.primary,
Blockly.Colours.event.secondary,
Blockly.Colours.event.tertiary
Blockly.Colours.event.tertiary,
Blockly.Colours.event.quaternary
);
}
};
Expand Down Expand Up @@ -179,7 +183,8 @@ Blockly.Blocks['event_broadcast'] = {
"category": Blockly.Categories.event,
"colour": Blockly.Colours.event.primary,
"colourSecondary": Blockly.Colours.event.secondary,
"colourTertiary": Blockly.Colours.event.tertiary
"colourTertiary": Blockly.Colours.event.tertiary,
"colourQuaternary": Blockly.Colours.event.quaternary
});
}
};
27 changes: 18 additions & 9 deletions blocks_horizontal/wedo.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ Blockly.Blocks['dropdown_wedo_setcolor'] = {
this.setOutput(true);
this.setColour(Blockly.Colours.looks.primary,
Blockly.Colours.looks.secondary,
Blockly.Colours.looks.tertiary
Blockly.Colours.looks.tertiary,
Blockly.Colours.looks.quaternary
);
}
};
Expand Down Expand Up @@ -94,7 +95,8 @@ Blockly.Blocks['wedo_setcolor'] = {
"category": Blockly.Categories.looks,
"colour": Blockly.Colours.looks.primary,
"colourSecondary": Blockly.Colours.looks.secondary,
"colourTertiary": Blockly.Colours.looks.tertiary
"colourTertiary": Blockly.Colours.looks.tertiary,
"colourQuaternary": Blockly.Colours.looks.quaternary
});
}
};
Expand Down Expand Up @@ -128,7 +130,8 @@ Blockly.Blocks['wedo_motorclockwise'] = {
"category": Blockly.Categories.motion,
"colour": Blockly.Colours.motion.primary,
"colourSecondary": Blockly.Colours.motion.secondary,
"colourTertiary": Blockly.Colours.motion.tertiary
"colourTertiary": Blockly.Colours.motion.tertiary,
"colourQuaternary": Blockly.Colours.motion.quaternary
});
}
};
Expand Down Expand Up @@ -162,7 +165,8 @@ Blockly.Blocks['wedo_motorcounterclockwise'] = {
"category": Blockly.Categories.motion,
"colour": Blockly.Colours.motion.primary,
"colourSecondary": Blockly.Colours.motion.secondary,
"colourTertiary": Blockly.Colours.motion.tertiary
"colourTertiary": Blockly.Colours.motion.tertiary,
"colourQuaternary": Blockly.Colours.motion.quaternary
});
}
};
Expand All @@ -186,7 +190,8 @@ Blockly.Blocks['dropdown_wedo_motorspeed'] = {
this.setOutput(true);
this.setColour(Blockly.Colours.motion.primary,
Blockly.Colours.motion.secondary,
Blockly.Colours.motion.tertiary
Blockly.Colours.motion.tertiary,
Blockly.Colours.motion.quaternary
);
}
};
Expand Down Expand Up @@ -219,7 +224,8 @@ Blockly.Blocks['wedo_motorspeed'] = {
"category": Blockly.Categories.motion,
"colour": Blockly.Colours.motion.primary,
"colourSecondary": Blockly.Colours.motion.secondary,
"colourTertiary": Blockly.Colours.motion.tertiary
"colourTertiary": Blockly.Colours.motion.tertiary,
"colourQuaternary": Blockly.Colours.motion.quaternary
});
}
};
Expand Down Expand Up @@ -250,7 +256,8 @@ Blockly.Blocks['dropdown_wedo_whentilt'] = {
this.setOutput(true);
this.setColour(Blockly.Colours.event.primary,
Blockly.Colours.event.secondary,
Blockly.Colours.event.tertiary
Blockly.Colours.event.tertiary,
Blockly.Colours.event.quaternary
);
}
};
Expand Down Expand Up @@ -282,7 +289,8 @@ Blockly.Blocks['wedo_whentilt'] = {
"category": Blockly.Categories.event,
"colour": Blockly.Colours.event.primary,
"colourSecondary": Blockly.Colours.event.secondary,
"colourTertiary": Blockly.Colours.event.tertiary
"colourTertiary": Blockly.Colours.event.tertiary,
"colourQuaternary": Blockly.Colours.event.quaternary
});
}
};
Expand Down Expand Up @@ -310,7 +318,8 @@ Blockly.Blocks['wedo_whendistanceclose'] = {
"category": Blockly.Categories.event,
"colour": Blockly.Colours.event.primary,
"colourSecondary": Blockly.Colours.event.secondary,
"colourTertiary": Blockly.Colours.event.tertiary
"colourTertiary": Blockly.Colours.event.tertiary,
"colourQuaternary": Blockly.Colours.event.quaternary
});
}
};
3 changes: 2 additions & 1 deletion blocks_vertical/control.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ Blockly.Blocks['control_stop'] = {
this.setCategory(Blockly.Categories.control);
this.setColour(Blockly.Colours.control.primary,
Blockly.Colours.control.secondary,
Blockly.Colours.control.tertiary
Blockly.Colours.control.tertiary,
Blockly.Colours.control.quaternary
);
this.setPreviousStatement(true);
},
Expand Down
8 changes: 2 additions & 6 deletions blocks_vertical/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ Blockly.Blocks['data_showvariable'] = {
"previousStatement": null,
"nextStatement": null,
"category": Blockly.Categories.data,
"colour": Blockly.Colours.data.primary,
"colourSecondary": Blockly.Colours.data.secondary,
"colourTertiary": Blockly.Colours.data.tertiary
"extensions": ["colours_data"]
});
}
};
Expand All @@ -142,9 +140,7 @@ Blockly.Blocks['data_hidevariable'] = {
"previousStatement": null,
"nextStatement": null,
"category": Blockly.Categories.data,
"colour": Blockly.Colours.data.primary,
"colourSecondary": Blockly.Colours.data.secondary,
"colourTertiary": Blockly.Colours.data.tertiary
"extensions": ["colours_data"]
});
}
};
Expand Down
1 change: 1 addition & 0 deletions blocks_vertical/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ Blockly.Blocks['event_broadcast_menu'] = {
"colour": Blockly.Colours.event.secondary,
"colourSecondary": Blockly.Colours.event.secondary,
"colourTertiary": Blockly.Colours.event.tertiary,
"colourQuaternary": Blockly.Colours.event.quaternary,
"extensions": ["output_string"]
});
}
Expand Down
2 changes: 2 additions & 0 deletions blocks_vertical/looks.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ Blockly.Blocks['looks_costume'] = {
"colour": Blockly.Colours.looks.secondary,
"colourSecondary": Blockly.Colours.looks.secondary,
"colourTertiary": Blockly.Colours.looks.tertiary,
"colourQuaternary": Blockly.Colours.looks.quaternary,
"extensions": ["output_string"]
});
}
Expand Down Expand Up @@ -447,6 +448,7 @@ Blockly.Blocks['looks_backdrops'] = {
"colour": Blockly.Colours.looks.secondary,
"colourSecondary": Blockly.Colours.looks.secondary,
"colourTertiary": Blockly.Colours.looks.tertiary,
"colourQuaternary": Blockly.Colours.looks.quaternary,
"extensions": ["output_string"]
});
}
Expand Down
3 changes: 3 additions & 0 deletions blocks_vertical/motion.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ Blockly.Blocks['motion_pointtowards_menu'] = {
"colour": Blockly.Colours.motion.secondary,
"colourSecondary": Blockly.Colours.motion.secondary,
"colourTertiary": Blockly.Colours.motion.tertiary,
"colourQuaternary": Blockly.Colours.motion.quaternary,
"extensions": ["output_string"]
});
}
Expand Down Expand Up @@ -187,6 +188,7 @@ Blockly.Blocks['motion_goto_menu'] = {
"colour": Blockly.Colours.motion.secondary,
"colourSecondary": Blockly.Colours.motion.secondary,
"colourTertiary": Blockly.Colours.motion.tertiary,
"colourQuaternary": Blockly.Colours.motion.quaternary,
"extensions": ["output_string"]
});
}
Expand Down Expand Up @@ -285,6 +287,7 @@ Blockly.Blocks['motion_glideto_menu'] = {
"colour": Blockly.Colours.motion.secondary,
"colourSecondary": Blockly.Colours.motion.secondary,
"colourTertiary": Blockly.Colours.motion.tertiary,
"colourQuaternary": Blockly.Colours.motion.quaternary,
"extensions": ["output_string"]
});
}
Expand Down
2 changes: 2 additions & 0 deletions blocks_vertical/procedures.js
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,7 @@ Blockly.Blocks['argument_editor_boolean'] = {
"colour": Blockly.Colours.textField,
"colourSecondary": Blockly.Colours.textField,
"colourTertiary": Blockly.Colours.textField,
"colourQuaternary": Blockly.Colours.textField,
"extensions": ["output_boolean"]
});
},
Expand All @@ -963,6 +964,7 @@ Blockly.Blocks['argument_editor_string_number'] = {
"colour": Blockly.Colours.textField,
"colourSecondary": Blockly.Colours.textField,
"colourTertiary": Blockly.Colours.textField,
"colourQuaternary": Blockly.Colours.textField,
"extensions": ["output_number", "output_string"]
});
},
Expand Down
1 change: 1 addition & 0 deletions blocks_vertical/sound.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Blockly.Blocks['sound_sounds_menu'] = {
"colour": Blockly.Colours.sounds.secondary,
"colourSecondary": Blockly.Colours.sounds.secondary,
"colourTertiary": Blockly.Colours.sounds.tertiary,
"colourQuaternary": Blockly.Colours.sounds.quaternary,
"extensions": ["output_string"]
});
}
Expand Down
13 changes: 7 additions & 6 deletions blocks_vertical/vertical_extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,26 @@ goog.require('Blockly.constants');

/**
* Helper function that generates an extension based on a category name.
* The generated function will set primary, secondary, and tertiary colours
* based on the category name.
* The generated function will set primary, secondary, tertiary, and quaternary
* colours based on the category name.
* @param {String} category The name of the category to set colours for.
* @return {function} An extension function that sets colours based on the given
* category.
*/
Blockly.ScratchBlocks.VerticalExtensions.colourHelper = function(category) {
var colours = Blockly.Colours[category];
if (!(colours && colours.primary && colours.secondary && colours.tertiary)) {
if (!(colours && colours.primary && colours.secondary && colours.tertiary &&
colours.quaternary)) {
throw new Error('Could not find colours for category "' + category + '"');
}
/**
* Set the primary, secondary, and tertiary colours on this block for the
* given category.
* Set the primary, secondary, tertiary, and quaternary colours on this block for
* the given category.
* @this {Blockly.Block}
*/
return function() {
this.setColourFromRawValues_(colours.primary, colours.secondary,
colours.tertiary);
colours.tertiary, colours.quaternary);
};
};

Expand Down
Loading

0 comments on commit ffcd546

Please # to comment.