update push button / toggle button label colors when fixing layout

pull/95/head
jmoenig 2020-02-26 10:57:21 +01:00
rodzic ca6e43be86
commit 43bf03efa5
5 zmienionych plików z 28 dodań i 7 usunięć

Wyświetl plik

@ -8,7 +8,6 @@
<script type="text/javascript" src="src/symbols.js?version=2020-02-10"></script>
<script type="text/javascript" src="src/widgets.js?version=2020-01-03"></script>
<script type="text/javascript" src="src/blocks.js?version=2020-02-11"></script>
<script type="text/javascript" src="src/threads.js?version=2019-12-19"></script>
<script type="text/javascript" src="src/objects.js?version=2020-01-28"></script>
<script type="text/javascript" src="src/gui.js?version=2020-01-28"></script>

Wyświetl plik

@ -13484,6 +13484,8 @@ ScriptFocusMorph.prototype.reactToKeyEvent = function (key) {
}
};
/*
// register examples with the World demo menu
// comment out to shave off a millisecond loading speed ;-)
@ -13556,3 +13558,4 @@ ScriptFocusMorph.prototype.reactToKeyEvent = function (key) {
]
]);
})();
*/

Wyświetl plik

@ -1178,7 +1178,7 @@
/*global window, HTMLCanvasElement, FileReader, Audio, FileList, Map*/
var morphicVersion = '2020-February-20';
var morphicVersion = '2020-February-26';
var modules = {}; // keep track of additional loaded modules
var useBlurredShadows = true;
@ -8401,7 +8401,7 @@ StringMorph.prototype.font = function () {
this.fontStyle;
};
StringMorph.prototype.fixLayout = function () {
StringMorph.prototype.fixLayout = function (justMe) {
// determine my extent depending on my current settings
var width,
shadowOffset = this.shadowOffset || new Point(),
@ -8421,7 +8421,7 @@ StringMorph.prototype.fixLayout = function () {
);
// notify my parent of layout change
if (this.parent) {
if (!justMe && this.parent) {
if (this.parent.fixLayout) {
this.parent.fixLayout();
}

Wyświetl plik

@ -163,7 +163,8 @@ SymbolMorph.prototype.toString = function () {
this.constructor.toString().split(' ')[1].split('(')[0]) +
': "' +
this.name +
'"';
'" ' +
this.bounds;
};
// SymbolMorph zebra coloring:
@ -1819,6 +1820,7 @@ SymbolMorph.prototype.renderSymbolList = function (ctx, color) {
ctx.fillRect(0, 0, w, h);
};
/*
// register examples with the World demo menu
// comment out to shave off a millisecond loading speed ;-)
@ -1841,3 +1843,4 @@ SymbolMorph.prototype.renderSymbolList = function (ctx, color) {
])
]);
})();
*/

Wyświetl plik

@ -183,6 +183,7 @@ PushButtonMorph.prototype.init = function (
PushButtonMorph.prototype.fixLayout = function () {
// make sure I at least encompass my label
if (this.label !== null) {
this.updateLabelColors();
var padding = this.padding * 2 + this.outline * 2 + this.edge * 2;
this.bounds.setWidth(
Math.max(this.label.width(), this.labelMinExtent.x) + padding
@ -466,6 +467,18 @@ PushButtonMorph.prototype.createLabel = function () {
this.add(this.label);
};
PushButtonMorph.prototype.updateLabelColors = function () {
var shading = !MorphicPreferences.isFlat || this.is3D;
if (this.label) {
this.label.color = this.labelColor;
if (shading) {
this.label.shadowOffset = this.labelShadowOffset;
this.label.shadowColor = this.labelShadowColor;
}
this.label.fixLayout(true); // just me
}
};
// PushButtonMorph states
PushButtonMorph.prototype.disable = function () {
@ -658,8 +671,11 @@ ToggleButtonMorph.prototype.refresh = function () {
ToggleButtonMorph.prototype.fixLayout = function () {
if (this.label !== null) {
var lw = Math.max(this.label.width(), this.labelMinExtent.x),
padding = this.padding * 2 + this.outline * 2 + this.edge * 2;
var padding = this.padding * 2 + this.outline * 2 + this.edge * 2,
lw;
this.updateLabelColors();
lw = Math.max(this.label.width(), this.labelMinExtent.x);
this.bounds.setWidth(this.minWidth ?
Math.max(this.minWidth, lw) + padding
: lw + padding