refactored IDE sprite bar

pull/95/head
jmoenig 2020-04-29 17:54:13 +02:00
rodzic 140335c885
commit 0645d87fdd
1 zmienionych plików z 19 dodań i 31 usunięć

Wyświetl plik

@ -1308,22 +1308,20 @@ IDE_Morph.prototype.createSpriteBar = function () {
button = new ToggleButtonMorph( button = new ToggleButtonMorph(
colors, colors,
myself, // the IDE is the target myself, // the IDE is the target
function () { () => {
if (myself.currentSprite instanceof SpriteMorph) { if (myself.currentSprite instanceof SpriteMorph) {
myself.currentSprite.rotationStyle = rotationStyle; myself.currentSprite.rotationStyle = rotationStyle;
myself.currentSprite.changed(); myself.currentSprite.changed();
myself.currentSprite.fixLayout(); myself.currentSprite.fixLayout();
myself.currentSprite.rerender(); myself.currentSprite.rerender();
} }
rotationStyleButtons.forEach(function (each) { rotationStyleButtons.forEach(each =>
each.refresh(); each.refresh()
}); );
}, },
symbols[rotationStyle], // label symbols[rotationStyle], // label
function () { // query () => myself.currentSprite instanceof SpriteMorph // query
return myself.currentSprite instanceof SpriteMorph && myself.currentSprite.rotationStyle === rotationStyle,
&& myself.currentSprite.rotationStyle === rotationStyle;
},
null, // environment null, // environment
localize(labels[rotationStyle]) localize(labels[rotationStyle])
); );
@ -1395,14 +1393,10 @@ IDE_Morph.prototype.createSpriteBar = function () {
padlock = new ToggleMorph( padlock = new ToggleMorph(
'checkbox', 'checkbox',
null, null,
function () { () => this.currentSprite.isDraggable =
myself.currentSprite.isDraggable = !this.currentSprite.isDraggable,
!myself.currentSprite.isDraggable;
},
localize('draggable'), localize('draggable'),
function () { () => this.currentSprite.isDraggable
return myself.currentSprite.isDraggable;
}
); );
padlock.label.isBold = false; padlock.label.isBold = false;
padlock.label.setColor(this.buttonLabelColor); padlock.label.setColor(this.buttonLabelColor);
@ -1428,7 +1422,7 @@ IDE_Morph.prototype.createSpriteBar = function () {
tabBar.tabTo = function (tabString) { tabBar.tabTo = function (tabString) {
var active; var active;
myself.currentTab = tabString; myself.currentTab = tabString;
this.children.forEach(function (each) { this.children.forEach(each => {
each.refresh(); each.refresh();
if (each.state) {active = each; } if (each.state) {active = each; }
}); });
@ -1440,11 +1434,9 @@ IDE_Morph.prototype.createSpriteBar = function () {
tab = new TabMorph( tab = new TabMorph(
tabColors, tabColors,
null, // target null, // target
function () {tabBar.tabTo('scripts'); }, () => tabBar.tabTo('scripts'),
localize('Scripts'), // label localize('Scripts'), // label
function () { // query () => this.currentTab === 'scripts' // query
return myself.currentTab === 'scripts';
}
); );
tab.padding = 3; tab.padding = 3;
tab.corner = tabCorner; tab.corner = tabCorner;
@ -1458,13 +1450,11 @@ IDE_Morph.prototype.createSpriteBar = function () {
tab = new TabMorph( tab = new TabMorph(
tabColors, tabColors,
null, // target null, // target
function () {tabBar.tabTo('costumes'); }, () => tabBar.tabTo('costumes'),
localize(this.currentSprite instanceof SpriteMorph ? localize(this.currentSprite instanceof SpriteMorph ?
'Costumes' : 'Backgrounds' 'Costumes' : 'Backgrounds'
), ),
function () { // query () => this.currentTab === 'costumes' // query
return myself.currentTab === 'costumes';
}
); );
tab.padding = 3; tab.padding = 3;
tab.corner = tabCorner; tab.corner = tabCorner;
@ -1478,11 +1468,9 @@ IDE_Morph.prototype.createSpriteBar = function () {
tab = new TabMorph( tab = new TabMorph(
tabColors, tabColors,
null, // target null, // target
function () {tabBar.tabTo('sounds'); }, () => tabBar.tabTo('sounds'),
localize('Sounds'), // label localize('Sounds'), // label
function () { // query () => this.currentTab === 'sounds' // query
return myself.currentTab === 'sounds';
}
); );
tab.padding = 3; tab.padding = 3;
tab.corner = tabCorner; tab.corner = tabCorner;
@ -1494,9 +1482,9 @@ IDE_Morph.prototype.createSpriteBar = function () {
tabBar.add(tab); tabBar.add(tab);
tabBar.fixLayout(); tabBar.fixLayout();
tabBar.children.forEach(function (each) { tabBar.children.forEach(each =>
each.refresh(); each.refresh()
}); );
this.spriteBar.tabBar = tabBar; this.spriteBar.tabBar = tabBar;
this.spriteBar.add(this.spriteBar.tabBar); this.spriteBar.add(this.spriteBar.tabBar);