added scene-setting to hide/show category names in the unified palette

snap7
jmoenig 2021-10-12 11:04:27 +02:00
rodzic 67fe3a767d
commit b854c65ebd
5 zmienionych plików z 27 dodań i 6 usunięć

Wyświetl plik

@ -41,6 +41,7 @@
### 2021-10-12
* scenes, store: store single palette setting per project (for making extensions)
* gui, scenes, objects: added scene-setting to hide/show category names in the unified palette
### 2021-10-11
* objects: sort order of blocks in custom categories alphabetically in the unified palette

Wyświetl plik

@ -18,9 +18,9 @@
<script src="src/widgets.js?version=2021-07-21"></script>
<script src="src/blocks.js?version=2021-10-07"></script>
<script src="src/threads.js?version=2021-10-06"></script>
<script src="src/objects.js?version=2021-10-11"></script>
<script src="src/objects.js?version=2021-10-12"></script>
<script src="src/scenes.js?version=2021-10-12"></script>
<script src="src/gui.js?version=2021-09-30"></script>
<script src="src/gui.js?version=2021-10-12"></script>
<script src="src/paint.js?version=2021-07-05"></script>
<script src="src/lists.js?version=2021-07-19"></script>
<script src="src/byob.js?version=2021-10-07"></script>

Wyświetl plik

@ -85,7 +85,7 @@ Animation, BoxMorph, BlockDialogMorph, RingMorph, Project, ZERO, BLACK*/
// Global stuff ////////////////////////////////////////////////////////
modules.gui = '2021-September-30';
modules.gui = '2021-October-12';
// Declarations
@ -4148,6 +4148,15 @@ IDE_Morph.prototype.settingsMenu = function () {
'check to show all blocks in a single palette',
false
);
if (this.scene.unifiedPalette) {
addPreference(
'Show categories',
() => this.toggleCategoryNames(),
this.scene.unifiedPalette,
'uncheck to hide\ncategory names\nin the palette',
'check to show\ncategory names\nin the palette'
);
}
addPreference(
'Persist linked sublist IDs',
() => StageMorph.prototype.enableSublistIDs =
@ -6244,6 +6253,13 @@ IDE_Morph.prototype.setUnifiedPalette = function (bool) {
return true;
};
IDE_Morph.prototype.toggleCategoryNames = function () {
this.scene.showCategories = !this.scene.showCategories;
this.flushBlocksCache();
this.refreshPalette();
};
IDE_Morph.prototype.setPaletteWidth = function (newWidth) {
var msecs = this.isAnimating ? 100 : 0,
world = this.world();

Wyświetl plik

@ -87,7 +87,7 @@ BlockVisibilityDialogMorph*/
/*jshint esversion: 6*/
modules.objects = '2021-October-11';
modules.objects = '2021-October-12';
var SpriteMorph;
var StageMorph;
@ -2989,6 +2989,7 @@ SpriteMorph.prototype.palette = function (category) {
SpriteMorph.prototype.freshPalette = function (category) {
var myself = this,
palette = new ScrollFrameMorph(null, null, this.sliderColor),
showCategories,
unit = SyntaxElementMorph.prototype.fontSize,
x = 0,
y = 5,
@ -3075,12 +3076,14 @@ SpriteMorph.prototype.freshPalette = function (category) {
if (category === 'unified') {
// In a Unified Palette custom blocks appear following each category,
// but there is only 1 make a block button (at the end).
showCategories = this.parentThatIsA(IDE_Morph).scene.showCategories;
blocks = SpriteMorph.prototype.allCategories().reduce(
(blocks, category) => {
let header = [ this.categoryText(category), '-' ],
let header = [this.categoryText(category), '-' ],
primitives = this.getPrimitiveTemplates(category),
customs = this.customBlockTemplatesForCategory(category),
showHeader = !['lists', 'other'].includes(category) &&
showHeader = showCategories &&
!['lists', 'other'].includes(category) &&
(primitives.some(item =>
item instanceof BlockMorph) || customs.length);

Wyświetl plik

@ -119,6 +119,7 @@ function Scene(aStageMorph) {
this.stage = aStageMorph || new StageMorph(this.globalVariables);
this.hasUnsavedEdits = false;
this.unifiedPalette = false;
this.showCategories = true;
// cached IDE state
this.sprites = new List();