kopia lustrzana https://github.com/backface/turtlestitch
				
				
				
			update push button / toggle button label colors when fixing layout
							rodzic
							
								
									ca6e43be86
								
							
						
					
					
						commit
						43bf03efa5
					
				| 
						 | 
					@ -8,7 +8,6 @@
 | 
				
			||||||
        <script type="text/javascript" src="src/symbols.js?version=2020-02-10"></script>
 | 
					        <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/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/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/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/objects.js?version=2020-01-28"></script>
 | 
				
			||||||
        <script type="text/javascript" src="src/gui.js?version=2020-01-28"></script>
 | 
					        <script type="text/javascript" src="src/gui.js?version=2020-01-28"></script>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13484,6 +13484,8 @@ ScriptFocusMorph.prototype.reactToKeyEvent = function (key) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
// register examples with the World demo menu
 | 
					// register examples with the World demo menu
 | 
				
			||||||
// comment out to shave off a millisecond loading speed ;-)
 | 
					// comment out to shave off a millisecond loading speed ;-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13556,3 +13558,4 @@ ScriptFocusMorph.prototype.reactToKeyEvent = function (key) {
 | 
				
			||||||
        ]
 | 
					        ]
 | 
				
			||||||
    ]);
 | 
					    ]);
 | 
				
			||||||
})();
 | 
					})();
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1178,7 +1178,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*global window, HTMLCanvasElement, FileReader, Audio, FileList, Map*/
 | 
					/*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 modules = {}; // keep track of additional loaded modules
 | 
				
			||||||
var useBlurredShadows = true;
 | 
					var useBlurredShadows = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8401,7 +8401,7 @@ StringMorph.prototype.font = function () {
 | 
				
			||||||
        this.fontStyle;
 | 
					        this.fontStyle;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
StringMorph.prototype.fixLayout = function () {
 | 
					StringMorph.prototype.fixLayout = function (justMe) {
 | 
				
			||||||
    // determine my extent depending on my current settings
 | 
					    // determine my extent depending on my current settings
 | 
				
			||||||
    var width,
 | 
					    var width,
 | 
				
			||||||
        shadowOffset = this.shadowOffset || new Point(),
 | 
					        shadowOffset = this.shadowOffset || new Point(),
 | 
				
			||||||
| 
						 | 
					@ -8421,7 +8421,7 @@ StringMorph.prototype.fixLayout = function () {
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // notify my parent of layout change
 | 
					    // notify my parent of layout change
 | 
				
			||||||
    if (this.parent) {
 | 
					    if (!justMe && this.parent) {
 | 
				
			||||||
        if (this.parent.fixLayout) {
 | 
					        if (this.parent.fixLayout) {
 | 
				
			||||||
            this.parent.fixLayout();
 | 
					            this.parent.fixLayout();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -163,7 +163,8 @@ SymbolMorph.prototype.toString = function () {
 | 
				
			||||||
            this.constructor.toString().split(' ')[1].split('(')[0]) +
 | 
					            this.constructor.toString().split(' ')[1].split('(')[0]) +
 | 
				
			||||||
        ': "' +
 | 
					        ': "' +
 | 
				
			||||||
        this.name +
 | 
					        this.name +
 | 
				
			||||||
        '"';
 | 
					        '" ' +
 | 
				
			||||||
 | 
					        this.bounds;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// SymbolMorph zebra coloring:
 | 
					// SymbolMorph zebra coloring:
 | 
				
			||||||
| 
						 | 
					@ -1819,6 +1820,7 @@ SymbolMorph.prototype.renderSymbolList = function (ctx, color) {
 | 
				
			||||||
    ctx.fillRect(0, 0, w, h);
 | 
					    ctx.fillRect(0, 0, w, h);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
// register examples with the World demo menu
 | 
					// register examples with the World demo menu
 | 
				
			||||||
// comment out to shave off a millisecond loading speed ;-)
 | 
					// comment out to shave off a millisecond loading speed ;-)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1841,3 +1843,4 @@ SymbolMorph.prototype.renderSymbolList = function (ctx, color) {
 | 
				
			||||||
        ])
 | 
					        ])
 | 
				
			||||||
    ]);
 | 
					    ]);
 | 
				
			||||||
})();
 | 
					})();
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -183,6 +183,7 @@ PushButtonMorph.prototype.init = function (
 | 
				
			||||||
PushButtonMorph.prototype.fixLayout = function () {
 | 
					PushButtonMorph.prototype.fixLayout = function () {
 | 
				
			||||||
    // make sure I at least encompass my label
 | 
					    // make sure I at least encompass my label
 | 
				
			||||||
    if (this.label !== null) {
 | 
					    if (this.label !== null) {
 | 
				
			||||||
 | 
					        this.updateLabelColors();
 | 
				
			||||||
        var padding = this.padding * 2 + this.outline * 2 + this.edge * 2;
 | 
					        var padding = this.padding * 2 + this.outline * 2 + this.edge * 2;
 | 
				
			||||||
        this.bounds.setWidth(
 | 
					        this.bounds.setWidth(
 | 
				
			||||||
            Math.max(this.label.width(), this.labelMinExtent.x) + padding
 | 
					            Math.max(this.label.width(), this.labelMinExtent.x) + padding
 | 
				
			||||||
| 
						 | 
					@ -466,6 +467,18 @@ PushButtonMorph.prototype.createLabel = function () {
 | 
				
			||||||
    this.add(this.label);
 | 
					    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 states
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PushButtonMorph.prototype.disable = function () {
 | 
					PushButtonMorph.prototype.disable = function () {
 | 
				
			||||||
| 
						 | 
					@ -658,8 +671,11 @@ ToggleButtonMorph.prototype.refresh = function () {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ToggleButtonMorph.prototype.fixLayout = function () {
 | 
					ToggleButtonMorph.prototype.fixLayout = function () {
 | 
				
			||||||
    if (this.label !== null) {
 | 
					    if (this.label !== null) {
 | 
				
			||||||
        var lw = Math.max(this.label.width(), this.labelMinExtent.x),
 | 
					        var padding = this.padding * 2 + this.outline * 2 + this.edge * 2,
 | 
				
			||||||
            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 ?
 | 
					        this.bounds.setWidth(this.minWidth ?
 | 
				
			||||||
                Math.max(this.minWidth, lw) + padding
 | 
					                Math.max(this.minWidth, lw) + padding
 | 
				
			||||||
                    : lw + padding
 | 
					                    : lw + padding
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Ładowanie…
	
		Reference in New Issue