Commit 7dd09e91 authored by Christian Winter's avatar Christian Winter

wip

parent 3d393ef3
......@@ -128,19 +128,19 @@
</colgroup>
<tr title="Left of the rendered image">
<td>Left</td>
<td><input id="artBoundsLeft" type="number" value="0" onchange="Preferences.artBounds.left = +value; Renderer.redraw();"></td>
<td><input id="artBoundsLeft" type="number" value="0" onchange="Preferences.artBounds.left = +value; Application.redrawAllViews();"></td>
</tr>
<tr title="Top of the rendered image">
<td>Top</td>
<td><input id="artBoundsTop" type="number" value="0" onchange="Preferences.artBounds.top = +value; Renderer.redraw();"></td>
<td><input id="artBoundsTop" type="number" value="0" onchange="Preferences.artBounds.top = +value; Application.redrawAllViews();"></td>
</tr>
<tr title="Width of the rendered image">
<td>Width</td>
<td><input id="artBoundsWidth" type="number" min="1" value="1" onchange="Preferences.artBounds.width = +value; Renderer.redraw();"></td>
<td><input id="artBoundsWidth" type="number" min="1" value="1" onchange="Preferences.artBounds.width = +value; Application.redrawAllViews();"></td>
</tr>
<tr title="Height of the rendered image">
<td>Height</td>
<td><input id="artBoundsHeight" type="number" min="1" value="1" onchange="Preferences.artBounds.height = +value; Renderer.redraw();"></td>
<td><input id="artBoundsHeight" type="number" min="1" value="1" onchange="Preferences.artBounds.height = +value; Application.redrawAllViews();"></td>
</tr>
<tr title="Scale of the rendered image">
<td>Scale factor</td>
......
......@@ -5,10 +5,11 @@
this.currentState; // Drawing, EditingPrefab
this.currentView = null;
this.views = [];
this.views.push(new View());
this.views.push(new View());
this.currentView = this.views[this.views.length - 1];
this.initializeClasses();
......@@ -18,8 +19,6 @@
window.addEventListener('resize', evt => this.layoutGUI(evt), false);
GUI.genereateGridSettings();
Logic.start();
//Renderer.setContext(this.currentView.context);
......@@ -27,6 +26,7 @@
}
initializeClasses() {
GridManager.init();
GUI.init();
Preferences.init();
......@@ -38,7 +38,6 @@
RenderManager.init();
Selection.init();
GridManager.init();
ActionHistory.init();
PrefabManager.init();
......@@ -74,13 +73,18 @@
}
setView(view) {
this.currentView = view;
if (view == null)
return;
}
redraw() {
if (this.currentView)
this.currentView.deactivate();
this.currentView = view;
this.currentView.activate();
}
redrawAllViews() {
for (let view of this.views)
view.renderer.redraw();
}
}
\ No newline at end of file
......@@ -17,7 +17,7 @@ class LineManipulator {
}
Selection.data.lines = [];
Selection.data.lines = newLines;
Renderer.redraw();
Application.redrawAllViews();
}
static rotateSelectionBy(degrees, rotationCenter) {
......@@ -38,7 +38,7 @@ class LineManipulator {
instance.transform.rotation += degrees;
}
Renderer.redraw();
Application.redrawAllViews();
}
static rotatePositionByAngle(position, rotationCenter, degrees) {
......@@ -85,7 +85,7 @@ class LineManipulator {
}
}
Renderer.redraw();
Application.redrawAllViews();
}
static scalePoint(position, center, scaleVector) {
......@@ -97,7 +97,7 @@ class LineManipulator {
.subtractVector(center)
.multiplyVector(scaleVector)
.addVector(center);
//Renderer.redraw();
//Application.redrawAllViews();
}
static growSelection() {
......
......@@ -36,7 +36,7 @@
this.addPrefab(newPrefab);
GUI.buildPrefabUI();
Renderer.redraw();
Application.redrawAllViews();
}
static editPrefab(id) {
......@@ -101,7 +101,7 @@
}
Utilities.deleteArrayEntry(this.prefabs, this.prefabs[id]);
GUI.buildPrefabUI();
Renderer.redraw();
Application.redrawAllViews();
}
static _endPreviousPrefabEditIfExisting() {
......
......@@ -98,13 +98,13 @@
Preferences.init();
window.location.reload();
Renderer.redraw();
Application.redrawAllViews();
}
static setQualitySetting(quality) {
this.qualitySetting = quality;
Renderer.setQualitySetting(this.qualitySetting);
Renderer.redraw();
Application.redrawAllViews();
}
static adjustRenderGuideLayers(value) {
......
......@@ -65,7 +65,7 @@ Utilities = new class {
for (let i = 0; i < selPoints.length; ++i)
selPoints[i].position = GridManager.grid.getNearestPointFor(selPoints[i].position);
Renderer.redraw();
Application.redrawAllViews();
}
distancePointToLine(position, line) {
......@@ -86,7 +86,7 @@ Utilities = new class {
for (let line of selLines) {
Utilities.cutLines(line, File.currentLayer.lines, false);
}
Renderer.redraw();
Application.redrawAllViews();
}
cutLines(cutter, lines, useDrawnLineAsRealLine) {
......@@ -186,7 +186,7 @@ Utilities = new class {
for (let ending of endings)
ending.position = center.copy();
Renderer.redraw();
Application.redrawAllViews();
}
// TODO make it possible to pass in, position as Vector2 and rotate as angle
......@@ -280,7 +280,7 @@ Utilities = new class {
Selection.clearSelection();
Selection.data = newSelData;
File.updateStats();
Renderer.redraw();
Application.redrawAllViews();
}
makeCircle(center, radius, segments, overshoot) {
......@@ -303,7 +303,7 @@ Utilities = new class {
}
File.updateStats();
Renderer.redraw();
Application.redrawAllViews();
}
measure() {
......
......@@ -49,14 +49,12 @@
mouseEnter(e) {
//console.log(this._getMousePos(e));
this.canvas.style.background = 'green';
Application.setView(this);
}
mouseExit(e) {
//console.log(this._getMousePos(e));
this.canvas.style.background = 'grey';
Application.setView(null);
}
......@@ -67,4 +65,12 @@
e.clientY - rect.top
);
}
activate() {
this.canvas.style.background = 'green';
}
deactivate() {
this.canvas.style.background = 'grey';
}
}
\ No newline at end of file
......@@ -46,7 +46,7 @@
if (state) {
this.undoneStates.push(this.currentState);
this.setState(state);
Renderer.redraw();
Application.redrawAllViews();
}
}
......@@ -56,7 +56,7 @@
if (state) {
this.states.push(this.currentState);
this.setState(state);
Renderer.redraw();
Application.redrawAllViews();
}
}
}
......@@ -97,13 +97,13 @@ class ActionHistory {
static undo() {
this.popAction();
Renderer.redraw();
Application.redrawAllViews();
}
static redo() {
var action = this.undoneActions.pop();
if (action)
this.pushAction(action, true);
Renderer.redraw();
Application.redrawAllViews();
}
}
\ No newline at end of file
......@@ -40,7 +40,7 @@
this.layers[id] = layer1;
GUI.objectHierarchyChanged();
Renderer.redraw();
Application.redrawAllViews();
}
static moveLayerUp(id) {
......@@ -54,7 +54,7 @@
this.layers[id] = layer1;
GUI.objectHierarchyChanged();
Renderer.redraw();
Application.redrawAllViews();
}
static deleteLayerWithID(id) {
......@@ -68,7 +68,7 @@
Utilities.deleteArrayEntry(this.layers, this.layers[id]);
GUI.objectHierarchyChanged();
Renderer.redraw();
Application.redrawAllViews();
}
static selectLayerWithID(id) {
......@@ -82,7 +82,8 @@
this.layers[id].visible = true;
GUI.objectHierarchyChanged();
Renderer.redraw();
// WIP
//Application.redrawAllViews();
}
static toggleVisibilityOfLayerWithID(id) {
......@@ -96,12 +97,12 @@
}
GUI.objectHierarchyChanged();
Renderer.redraw();
Application.redrawAllViews();
}
static toggleRenderableOfLayerWithID(id) {
this.layers[id].hideInRenderPreview= !this.layers[id].hideInRenderPreview;
GUI.objectHierarchyChanged();
Renderer.redraw();
Application.redrawAllViews();
}
static selectNextVisibleLayer(id) {
......
......@@ -142,7 +142,7 @@
}
if (redraw)
Renderer.redraw();
Application.redrawAllViews();
}
selectLinked() {
......@@ -162,7 +162,7 @@
if (i == maxIterations)
GUI.notify("Max Iteration Depth reached!");
Renderer.redraw();
Application.redrawAllViews();
}
copy() {
......
......@@ -7,6 +7,9 @@
this.triGrid = new TriangleGrid();
this.polarGrid = new PolarGrid();
waitingForStart.push(this);
}
static start() {
this.updateGrid();
}
......@@ -35,6 +38,7 @@
GUI.gridTypeSelection.value = Preferences.gridType;
GUI.genereateGridSettings();
Renderer.redraw();
// wip
//Application.redrawAllViews();
}
}
\ No newline at end of file
......@@ -8,7 +8,7 @@
case Key.Space:
if (Logic.currentState instanceof IdleState) {
Logic.setState(new MeasureState());
Renderer.redraw();
Application.redrawAllViews();
}
break;
case Key.G:
......@@ -17,7 +17,7 @@
LineManipulator.resetPosition();
else
Logic.setState(new MoveLinesState());
Renderer.redraw();
Application.redrawAllViews();
}
break;
case Key.R:
......@@ -30,7 +30,7 @@
LineManipulator.resetRotation();
else
Logic.setState(new RotateState());
Renderer.redraw();
Application.redrawAllViews();
}
break;
......@@ -41,7 +41,7 @@
LineManipulator.resetScale();
else
Logic.setState(new ScaleState());
Renderer.redraw();
Application.redrawAllViews();
}
break;
......@@ -65,7 +65,7 @@
if (!Logic.isPreviewing()) {
Logic.isRenderPreviewing = true;
Renderer.setQualitySetting("quality");
Renderer.redraw();
Application.redrawAllViews();
}
break;
......@@ -80,7 +80,7 @@
case Key.Control:
MouseHandler.updateCurrentPosition();
Renderer.redraw();
Application.redrawAllViews();
break;
case Key.E:
Utilities.extrudeSelection();
......@@ -99,7 +99,7 @@
if (Logic.isPreviewing()) {
Logic.isRenderPreviewing = false;
Renderer.setQualitySetting(Preferences.qualitySetting);
Renderer.redraw();
Application.redrawAllViews();
}
break;
......@@ -107,7 +107,7 @@
if (Logic.currentState instanceof DrawingState) {
if (drawPolyLine) {
Logic.currentState.cancel();
Renderer.redraw();
Application.redrawAllViews();
}
}
drawPolyLine = false;
......@@ -126,7 +126,7 @@
case Key.Control:
MouseHandler.updateCurrentPosition();
Renderer.redraw();
Application.redrawAllViews();
break;
}
}
......
......@@ -47,7 +47,8 @@ class Input {
if (!MouseHandler.canvasFocused) {
if (e.keyCode == Key.Enter) {
canvas.focus();
Application.currentView.canvas.focus();
Application.redrawAllViews();
}
}
......@@ -99,6 +100,6 @@ class Input {
}
}
Input.downKeys = [];
Renderer.redraw();
Application.redrawAllViews();
}
}
\ No newline at end of file
......@@ -60,7 +60,7 @@ class MouseHandler {
//GUI.writeToStats("Application.currentView.camera.canvasOffset", Application.currentView.camera.canvasOffset.toString());
this.oldPosScreenSpace = newPosScreenSpace;
Renderer.redraw();
Application.redrawAllViews();
}
static adjustMouseDownButtonBools(e, state) {
......@@ -104,7 +104,7 @@ class MouseHandler {
}
else if (Logic.currentState instanceof BrushSelectionState) {
Logic.currentState.update();
Renderer.redraw();
Application.redrawAllViews();
}
else if (Logic.currentState instanceof ContinousDrawingState) {
Logic.currentState.oldPos = Logic.shouldSnap() ? currentPosition.copy() : mousePosition.copy();
......@@ -221,7 +221,7 @@ class MouseHandler {
Logic.currentState.mouseDown(2);
}
Renderer.redraw();
Application.redrawAllViews();
}
else if (e.button == 1) // MMB
{
......@@ -230,7 +230,7 @@ class MouseHandler {
}
else if (Logic.currentState instanceof BrushSelectionState) {
Logic.currentState.update();
Renderer.redraw();
Application.redrawAllViews();
}
else if (e.ctrlKey) {
Logic.setState(new ZoomState());
......@@ -347,7 +347,7 @@ class MouseHandler {
Logic.currentState.execute();
Logic.setState(new IdleState());
Renderer.redraw();
Application.redrawAllViews();
}
else if (Logic.currentState instanceof BoxSelectionState) // end box selection initialized with RMB
{
......@@ -398,7 +398,7 @@ class MouseHandler {
this.mouseMove(e);
}
Renderer.redraw();
Application.redrawAllViews();
e.preventDefault();
}
......
......@@ -20,7 +20,7 @@
if (keepCenter)
this.popCameraCenter();
Renderer.redraw();
Application.redrawAllViews();
}
zoomBy(delta, keepCenter) {
......@@ -31,7 +31,7 @@
if (keepCenter)
this.popCameraCenter();
Renderer.redraw();
Application.redrawAllViews();
}
setZoom(val, keepCenter) {
......@@ -43,7 +43,7 @@
if (keepCenter)
this.popCameraCenter();
Renderer.redraw();
Application.redrawAllViews();
GUI.writeToStats("Zoom", (this.zoom * 100).toFixed(2) + " %");
}
......@@ -79,7 +79,7 @@
getVisibleBounds() {
return new Bounds(
this.screenSpaceToCanvasSpace(new Vector2(0, 0)),
this.screenSpaceToCanvasSpace(new Vector2(Renderer.currentContext.canvas.width, Renderer.currentContext.canvas.height))
this.screenSpaceToCanvasSpace(new Vector2(this.view.canvas.width, this.view.canvas.height))
);
}
......@@ -87,9 +87,9 @@
pivot = Vector2.zero;
this.setZoom(1, false);
this.canvasOffset = (new Vector2(canvas.width * 0.5, canvas.height * 0.5));
this.canvasOffset = (new Vector2(this.view.canvas.width * 0.5, this.view.canvas.height * 0.5));
Renderer.redraw();
this.view.renderer.redraw();
}
}
\ No newline at end of file
......@@ -70,6 +70,8 @@
this.updateDevModeToggle();
this.updateRenderGuideLayers();
this.updateOnlyTransformPrefabInstancePositionToggle();
this.genereateGridSettings();
}
static genereateGridSettings() {
......@@ -107,7 +109,7 @@
input.setAttribute("min", "1");
input.setAttribute("max", "100");
input.setAttribute("value", GridManager.grid.width);
input.setAttribute("onchange", "GridManager.grid.width = +value; Renderer.redraw();");
input.setAttribute("onchange", "GridManager.grid.width = +value; Application.redrawAllViews();");
td.appendChild(input);
// Height
......@@ -126,7 +128,7 @@
input.setAttribute("min", "1");
input.setAttribute("max", "100");
input.setAttribute("value", GridManager.grid.height);
input.setAttribute("onchange", "GridManager.grid.height = +value; Renderer.redraw();");
input.setAttribute("onchange", "GridManager.grid.height = +value; Application.redrawAllViews();");
td.appendChild(input);
// Big grid
......@@ -144,7 +146,7 @@
input.setAttribute("type", "number");
input.setAttribute("min", "0");
input.setAttribute("value", GridManager.grid.bigGridNumber);
input.setAttribute("onchange", "GridManager.grid.bigGridNumber= +value; Renderer.redraw();");
input.setAttribute("onchange", "GridManager.grid.bigGridNumber= +value; Application.redrawAllViews();");
td.appendChild(input);
}
else if (Preferences.gridType == 1) {
......@@ -163,7 +165,7 @@
input.setAttribute("type", "number");
input.setAttribute("min", "1");
input.setAttribute("value", GridManager.grid.width);
input.setAttribute("onchange", "GridManager.grid.width = +value; Renderer.redraw()");
input.setAttribute("onchange", "GridManager.grid.width = +value; Application.redrawAllViews()");
td.appendChild(input);
tr = document.createElement("tr");
......@@ -180,7 +182,7 @@
input.setAttribute("type", "number");
input.setAttribute("min", "1");
input.setAttribute("value", GridManager.grid.height);
input.setAttribute("onchange", "GridManager.grid.height = +value; Renderer.redraw()");
input.setAttribute("onchange", "GridManager.grid.height = +value; Application.redrawAllViews()");
td.appendChild(input);
......@@ -195,7 +197,7 @@
input = document.createElement("input");
input.setAttribute("type", "button");
input.setAttribute("onclick", "GridManager.grid.uniformHeight(); GUI.genereateGridSettings(); Renderer.redraw()");
input.setAttribute("onclick", "GridManager.grid.uniformHeight(); GUI.genereateGridSettings(); Application.redrawAllViews()");
input.value = "Uniform Height";
td.appendChild(input);
......@@ -207,7 +209,7 @@
input = document.createElement("input");
input.setAttribute("type", "button");
input.setAttribute("onclick", "GridManager.grid.swapXAndY = !GridManager.grid.swapXAndY; Renderer.redraw()");
input.setAttribute("onclick", "GridManager.grid.swapXAndY = !GridManager.grid.swapXAndY; Application.redrawAllViews()");
input.value = "Swap X and Y";
td.appendChild(input);
}
......@@ -228,7 +230,7 @@
input.setAttribute("type", "number");
input.setAttribute("min", "1");
input.setAttribute("value", GridManager.grid.width);
input.setAttribute("onchange", "GridManager.grid.width = +value; Renderer.redraw()");
input.setAttribute("onchange", "GridManager.grid.width = +value; Application.redrawAllViews()");
td.appendChild(input);
// height
......@@ -246,7 +248,7 @@
input.setAttribute("type", "number");
input.setAttribute("min", "1");
input.setAttribute("value", GridManager.grid.height);
input.setAttribute("onchange", "GridManager.grid.height = +value; Renderer.redraw()");
input.setAttribute("onchange", "GridManager.grid.height = +value; Application.redrawAllViews()");
td.appendChild(input);
// radius
......@@ -264,7 +266,7 @@
input.setAttribute("type", "number");
input.setAttribute("min", "1");
input.setAttribute("value", GridManager.grid.radius);
input.setAttribute("onchange", "GridManager.grid.radius= +value; Renderer.redraw()");
input.setAttribute("onchange", "GridManager.grid.radius= +value; Application.redrawAllViews()");
td.appendChild(input);
// segments
......@@ -282,7 +284,7 @@
input.setAttribute("type", "number");
input.setAttribute("min", "1");
input.setAttribute("value", GridManager.grid.segments);
input.setAttribute("onchange", "GridManager.grid.segments = +value; Renderer.redraw()");
input.setAttribute("onchange", "GridManager.grid.segments = +value; Application.redrawAllViews()");
td.appendChild(input);
// angleOffset
......@@ -300,7 +302,7 @@
input.setAttribute("type", "number");
//input.setAttribute("min", "1");
input.setAttribute("value", GridManager.grid.angleOffset);
input.setAttribute("onchange", "GridManager.grid.angleOffset= +value; Renderer.redraw()");
input.setAttribute("onchange", "GridManager.grid.angleOffset= +value; Application.redrawAllViews()");
td.appendChild(input);
......@@ -341,7 +343,7 @@
input.setAttribute("type", "number");
//input.setAttribute("min", "1");
input.setAttribute("value", GridManager.grid.positionOffset.x);
input.setAttribute("onchange", "GridManager.grid.positionOffset.x = +value; Renderer.redraw()");
input.setAttribute("onchange", "GridManager.grid.positionOffset.x = +value; Application.redrawAllViews()");
td.appendChild(input);
// posOffsetY
......@@ -359,7 +361,7 @@
input.setAttribute("type", "number");
//input.setAttribute("min", "1");
input.setAttribute("value", GridManager.grid.positionOffset.y);
input.setAttribute("onchange", "GridManager.grid.positionOffset.y = +value; Renderer.redraw()");
input.setAttribute("onchange", "GridManager.grid.positionOffset.y = +value; Application.redrawAllViews()");
td.appendChild(input);
}
}
......@@ -682,7 +684,7 @@
GridManager.grid.positionOffset = Vector2.zero;
GUI.genereateGridSettings();
Renderer.redraw();
Application.redrawAllViews();
}
// Toggles
......@@ -715,7 +717,8 @@
this.lineHandlesToggle.removeAttribute("class");
}
Renderer.redraw();
// WIP
//Application.redrawAllViews();
}
static updateCutLinesToggle() {
if (Preferences.cutLines) {
......@@ -738,7 +741,8 @@
this.use2DCursorToggle.setAttribute("class", "pressed");
else
this.use2DCursorToggle.removeAttribute("class");
Renderer.redraw()
// wip
//Application.redrawAllViews()
}
// vertices and edge selection
......@@ -773,7 +777,7 @@
this.mirrorXToggle.setAttribute("class", "pressed");
else
this.mirrorXToggle.removeAttribute("class");
Renderer.redraw();
Application.redrawAllViews();
}
static mirrorYTogglePressed() {
......@@ -785,7 +789,7 @@
this.mirrorYToggle.setAttribute("class", "pressed");
else
this.mirrorYToggle.removeAttribute("class");
Renderer.redraw();
Application.redrawAllViews();
}
// dev mode toggle
......
......@@ -138,7 +138,7 @@ class Logic {
this.currentState = state;
this.currentState.enter();
Renderer.redraw();
Application.redrawAllViews();
if (Preferences.developerMode) {
;//console.log(this.previousState + " --> " + this.currentState);
GUI.writeToStats("currentState", state.toString());
......@@ -152,7 +152,7 @@ class Logic {
if (state)
text = state.toString();
GUI.writeToStats("waitingState", text);
Renderer.redraw();
Application.redrawAllViews();
}
static setBacklogState(state) {
......@@ -176,7 +176,7 @@ class Logic {
static toggleGridVisiblity(senderButton) {
Preferences.showGrid = !Preferences.showGrid;
senderButton.innerHTML = Preferences.showGrid ? "Hide grid" : "Show grid";