Better screen zoom that makes use of the full width of the simulator. (#471)

This commit is contained in:
Sam El-Husseini
2018-04-09 16:21:41 -07:00
committed by GitHub
parent a433988929
commit ac1380ec92
7 changed files with 118 additions and 49 deletions

View File

@ -15,14 +15,15 @@ namespace pxsim.visuals {
private static LIGHT_BLACK_COLOR = '#6a6a6a';
constructor(port: number) {
super(EV3_SVG, "board", NodeType.Brick, port);
protected btnids: string[] = [];
constructor(xml: string, prefix: string, port: number) {
super(xml, prefix, NodeType.Brick, port);
}
protected buildDomCore() {
// Setup buttons
const btnids = ["btn_up", "btn_enter", "btn_down", "btn_right", "btn_left", "btn_back"];
this.buttons = btnids.map(n => this.content.getElementById(this.normalizeId(n)) as SVGElement);
this.buttons = this.btnids.map(n => this.content.getElementById(this.normalizeId(n)) as SVGElement);
this.buttons.forEach(b => svg.addClass(b, "sim-button"));
this.light = this.content.getElementById(this.normalizeId(BrickView.EV3_LIGHT_ID)) as SVGElement;

View File

@ -0,0 +1,24 @@
/// <reference path="./moduleView.ts" />
namespace pxsim.visuals {
export class BrickViewLandscape extends BrickView implements LayoutElement {
constructor(port: number) {
super(EV3_LANDSCAPE_SVG, "board-land", port);
this.btnids = ["btn_up", "btn_enter", "btn_down", "btn_right", "btn_left"];
}
protected updateDimensions(width: number, height: number) {
if (this.content) {
const currentWidth = this.getInnerWidth();
const currentHeight = this.getInnerHeight();
const newHeight = currentHeight / currentWidth * width;
const newWidth = currentWidth / currentHeight * height;
this.content.setAttribute('width', `${height > width ? width : newWidth}`);
this.content.setAttribute('height', `${height > width ? newHeight : height}`);
}
}
}
}

View File

@ -0,0 +1,13 @@
/// <reference path="./moduleView.ts" />
namespace pxsim.visuals {
export class BrickViewPortrait extends BrickView implements LayoutElement {
constructor(port: number) {
super(EV3_SVG, "board", port);
this.btnids = ["btn_up", "btn_enter", "btn_down", "btn_right", "btn_left", "btn_back"];
}
}
}