Better screen zoom that makes use of the full width of the simulator. (#471)
This commit is contained in:
24
sim/visuals/nodes/brickViewLandscape.ts
Normal file
24
sim/visuals/nodes/brickViewLandscape.ts
Normal 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}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user