full fullscreen and zoom to fit

pull/68/head
Michael Aschauer 2018-10-22 12:35:17 +02:00
rodzic ccf38caec3
commit d2f76901bb
2 zmienionych plików z 60 dodań i 38 usunięć

Wyświetl plik

@ -16,6 +16,8 @@ IDE_Morph.prototype.init = function(isAutoFill) {
'Embroidery tools' 'Embroidery tools'
); );
// this.isAnimating = false; // this.isAnimating = false;
this.paletteWidth = 250; // initially same as logo width
//MorphicPreferences.globalFontFamily = 'Sans, Helvetica, Arial';
this.cloud = new BeetleCloud('/api'); this.cloud = new BeetleCloud('/api');
}; };
@ -149,6 +151,7 @@ StageHandleMorph.prototype.init = function (target) {
this.isDraggable = false; this.isDraggable = false;
this.noticesTransparentClick = true; this.noticesTransparentClick = true;
this.setExtent(new Point(12, 50)); this.setExtent(new Point(12, 50));
}; };
IDE_Morph.prototype.origSetStageExtent = IDE_Morph.prototype.setStageExtent; IDE_Morph.prototype.origSetStageExtent = IDE_Morph.prototype.setStageExtent;
@ -222,7 +225,7 @@ IDE_Morph.prototype.createControlBar = function () {
} }
this.controlBar = new Morph(); this.controlBar = new Morph();
this.controlBar.color = this.frameColor; //this.controlBar.color = this.frameColor;
this.controlBar.color = new Color(250, 250, 250); this.controlBar.color = new Color(250, 250, 250);
this.controlBar.setHeight(this.logo.height()); // height is fixed this.controlBar.setHeight(this.logo.height()); // height is fixed
this.controlBar.mouseClickLeft = function () { this.controlBar.mouseClickLeft = function () {
@ -596,7 +599,7 @@ IDE_Morph.prototype.toggleAppMode = function (appMode) {
this.controlBar.steppingButton, this.controlBar.steppingButton,
//this.controlBar.largeStageSizeButton, //this.controlBar.largeStageSizeButton,
this.spriteEditor, this.spriteEditor,
//this.paletteHandle, this.paletteHandle,
this.stageHandle, this.stageHandle,
this.palette, this.palette,
this.statusDisplay, this.statusDisplay,
@ -617,9 +620,12 @@ IDE_Morph.prototype.toggleAppMode = function (appMode) {
morph.hide(); morph.hide();
} }
}); });
this.stage.add(this.controlBar);
this.controlBar.alpha = 0;
} else { } else {
this.setColor(this.backgroundColor); this.controlBar.setColor(this.controlBar.color);
this.controlBar.setColor(this.frameColor); this.add(this.controlBar);
elements.forEach(function (e) { elements.forEach(function (e) {
e.show(); e.show();
}); });
@ -916,14 +922,14 @@ IDE_Morph.prototype.createStatusDisplay = function () {
elements.push(zoomOutButton); elements.push(zoomOutButton);
var resetCameraButton = new PushButtonMorph( var fitScreenButton = new PushButtonMorph(
null, null,
function () { stage.camera.reset(); }, function () { stage.camera.fitScene(); },
'Reset View' 'Zoom to Fit'
); );
resetCameraButton.columns = 4; elements.push(fitScreenButton);
resetCameraButton.newColumn = 2; fitScreenButton.columns = 4;
elements.push(resetCameraButton); fitScreenButton.newColumn = 2;
var toggleTurboButton = new ToggleMorph( var toggleTurboButton = new ToggleMorph(
'checkbox', 'checkbox',
@ -951,9 +957,17 @@ IDE_Morph.prototype.createStatusDisplay = function () {
function () { function () {
return !stage.turtleShepherd.isMetric(); return !stage.turtleShepherd.isMetric();
}); });
toggleUnitButton.newLines = 3; toggleUnitButton.newLines = 2;
elements.push(toggleUnitButton); elements.push(toggleUnitButton);
var resetCameraButton = new PushButtonMorph(
null,
function () { stage.camera.reset(); },
'Reset View'
);
elements.push(resetCameraButton);
resetCameraButton.newLines = 3;
var downloadSVGButton = new PushButtonMorph( var downloadSVGButton = new PushButtonMorph(
null, null,
function () { myself.downloadSVG(); }, function () { myself.downloadSVG(); },
@ -1016,7 +1030,7 @@ IDE_Morph.prototype.fixLayout = function (situation) {
// categories // categories
this.categories.setLeft(this.logo.left()); this.categories.setLeft(this.logo.left());
this.categories.setTop(this.logo.bottom()); this.categories.setTop(this.logo.bottom()+1);
this.categories.setWidth(this.paletteWidth); this.categories.setWidth(this.paletteWidth);
} }
@ -1029,11 +1043,13 @@ IDE_Morph.prototype.fixLayout = function (situation) {
if (situation !== 'refreshPalette') { if (situation !== 'refreshPalette') {
// stage // stage
if (this.isAppMode) { if (this.isAppMode) {
this.stage.setScale(Math.floor(Math.min( this.stage.setScale(this.width() / this.stage.dimensions.x);
(this.width() - padding * 2) / this.stage.dimensions.x, //this.stage.setScale(3);
(this.height() - this.controlBar.height() * 2 - padding * 2) /
this.stage.dimensions.y ) * 10) / 10);
this.stage.setCenter(this.center()); this.stage.setCenter(this.center());
//this.stage.setTop(this.controlBar.bottom());
//this.stage.setLeft(0);
this.controlBar.setTop(0);
this.controlBar.setRight(this.width() - padding);
} else { } else {
this.stage.setScale(this.isSmallStage ? this.stageRatio : 1); this.stage.setScale(this.isSmallStage ? this.stageRatio : 1);
this.stage.setTop(this.logo.bottom() + padding); this.stage.setTop(this.logo.bottom() + padding);
@ -2262,9 +2278,6 @@ DialogBoxMorph.prototype.informWithLink = function (
}; };
IDE_Morph.prototype.toggleStageSize = function (isSmall, forcedRatio) {
};
ProjectDialogMorph.prototype.installCloudProjectList = function (pl) { ProjectDialogMorph.prototype.installCloudProjectList = function (pl) {
var myself = this; var myself = this;

Wyświetl plik

@ -130,7 +130,7 @@ SpriteMorph.prototype.addStitch = function(x1, y1, x2, y2) {
//console.log(w, x2, y2); //console.log(w, x2, y2);
//console.log(this.cache); //console.log(this.cache);
} }
this.reRender();
this.lastJumped = false; this.lastJumped = false;
}; };
@ -152,6 +152,7 @@ SpriteMorph.prototype.addJumpLine = function(x1, y1, x2, y2) {
stage.myJumpLines.add(line); stage.myJumpLines.add(line);
this.lastJumped = true; this.lastJumped = true;
this.reRender();
}; };
SpriteMorph.prototype.addStitchPoint = function(x2, y2) { SpriteMorph.prototype.addStitchPoint = function(x2, y2) {
@ -188,6 +189,8 @@ SpriteMorph.prototype.addStitchPoint = function(x2, y2) {
line.visible = stage.renderer.showingStitchPoints; line.visible = stage.renderer.showingStitchPoints;
stage.myStitchPoints.add(line); stage.myStitchPoints.add(line);
this.reRender();
}; };
SpriteMorph.prototype.addDensityPoint = function(x1, y1) { SpriteMorph.prototype.addDensityPoint = function(x1, y1) {
@ -212,6 +215,7 @@ SpriteMorph.prototype.addDensityPoint = function(x1, y1) {
circle.translateZ(0.03); circle.translateZ(0.03);
circle.visible = true; circle.visible = true;
stage.myDensityPoints.add(circle); stage.myDensityPoints.add(circle);
this.reRender();
}; };
@ -579,7 +583,7 @@ SpriteMorph.prototype.clear = function () {
}; };
SpriteMorph.prototype.reRender = function () { SpriteMorph.prototype.reRender = function () {
this.parentThatIsA(StageMorph).renderer.changed = true ;
//this.hide(); //this.hide();
this.changed(); this.changed();
}; };
@ -941,7 +945,6 @@ StageMorph.prototype.initCamera = function () {
this.zoomFactor = 1.7; this.zoomFactor = 1.7;
this.applyZoom(); this.applyZoom();
this.position.set(0,0,10); this.position.set(0,0,10);
//myself.controls.rotateLeft(radians(90));
} else { } else {
this.position.set(0,0,10); this.position.set(0,0,10);
} }
@ -957,13 +960,15 @@ StageMorph.prototype.initCamera = function () {
center = boundingSphere.center, center = boundingSphere.center,
distance = boundingSphere.radius; distance = boundingSphere.radius;
this.reset(); var width = Math.max(myself.width(), 480),
height = Math.max(myself.height(), 360);
this.position.set(center.x, center.y, center.z); this.zoomFactor = Math.max(width / distance, height / distance);
this.translateZ(distance * 1.2); this.applyZoom();
this.position.set(center.x, center.y, 10);
myself.controls.center.set(center.x, center.y, 10);
myself.controls.center.set(center.x, center.y, center.z);
myself.controls.dollyOut(1.2);
myself.controls.update(); myself.controls.update();
myself.reRender(); myself.reRender();
}; };
@ -1041,12 +1046,16 @@ StageMorph.prototype.rotateTurtle = function(h) {
StageMorph.prototype.originalStep = StageMorph.prototype.step; StageMorph.prototype.originalStep = StageMorph.prototype.step;
StageMorph.prototype.step = function () { StageMorph.prototype.step = function () {
this.originalStep(); this.originalStep();
if (!(this.isFastTracked && this.threads.processes.length)) { if (!(this.isFastTracked && this.threads.processes.length)) {
this.renderCycle(); this.renderCycle();
} else if (this.stepcounter % 12 == 0) { } else {
if (this.stepcounter % 12 == 0) {
this.renderCycle(); this.renderCycle();
}
}; };
this.stepcounter++; this.stepcounter++;
}; };