mirror of
https://github.com/scratchfoundation/scratch-flash.git
synced 2024-12-04 21:21:06 -05:00
Fixed display of numbers in list watchers
Numbers are now rounded to three decimal places like they are in variable watchers.
This commit is contained in:
parent
b858d029dc
commit
ab09998c46
2 changed files with 11 additions and 7 deletions
|
@ -417,7 +417,7 @@ public class ListWatcher extends Sprite {
|
|||
var cellW:int = cellPane.width - cellX - 1;
|
||||
var nextY:int = 0;
|
||||
for (var i:int = firstVisibleIndex; i < contents.length; i++) {
|
||||
var s:String = contents[i];
|
||||
var s:String = Watcher.formatValue(contents[i]);
|
||||
if (limitedView && (s.length > 8)) s = s.slice(0, 8) + '...';
|
||||
var cell:ListCell = allocateCell(s, cellW);
|
||||
cell.x = cellX;
|
||||
|
|
|
@ -40,8 +40,16 @@ import flash.display.*;
|
|||
|
||||
public class Watcher extends Sprite implements DragClient {
|
||||
|
||||
private static const precision:Number = 1000;
|
||||
public static function formatValue(value:*):String {
|
||||
if (value is Number && Math.abs(value) > 0.001) {
|
||||
// show at most N digits after the decimal point
|
||||
value = Math.round(value * precision) / precision;
|
||||
}
|
||||
return '' + value;
|
||||
}
|
||||
|
||||
private const format:TextFormat = new TextFormat(CSS.font, 11, 0, true);
|
||||
private const precision:Number = 1000;
|
||||
|
||||
private const NORMAL_MODE:int = 1;
|
||||
private const LARGE_MODE:int = 2;
|
||||
|
@ -188,11 +196,7 @@ public class Watcher extends Sprite implements DragClient {
|
|||
}
|
||||
|
||||
private function showValue(value:*):void {
|
||||
if ((value is Number) && (Math.abs(value) > 0.001)) {
|
||||
// show at most N digits after the decimal point
|
||||
value = Math.round(value * precision) / precision;
|
||||
}
|
||||
readout.setContents(value.toString());
|
||||
readout.setContents(formatValue(value));
|
||||
fixLayout();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue