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

wip

parent 3d393ef3
...@@ -128,19 +128,19 @@ ...@@ -128,19 +128,19 @@
</colgroup> </colgroup>
<tr title="Left of the rendered image"> <tr title="Left of the rendered image">
<td>Left</td> <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>
<tr title="Top of the rendered image"> <tr title="Top of the rendered image">
<td>Top</td> <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>
<tr title="Width of the rendered image"> <tr title="Width of the rendered image">
<td>Width</td> <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>
<tr title="Height of the rendered image"> <tr title="Height of the rendered image">
<td>Height</td> <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>
<tr title="Scale of the rendered image"> <tr title="Scale of the rendered image">
<td>Scale factor</td> <td>Scale factor</td>
......
...@@ -5,10 +5,11 @@ ...@@ -5,10 +5,11 @@
this.currentState; // Drawing, EditingPrefab this.currentState; // Drawing, EditingPrefab
this.currentView = null;
this.views = []; this.views = [];
this.views.push(new View()); this.views.push(new View());
this.views.push(new View()); this.views.push(new View());
this.currentView = this.views[this.views.length - 1];
this.initializeClasses(); this.initializeClasses();
...@@ -18,8 +19,6 @@ ...@@ -18,8 +19,6 @@
window.addEventListener('resize', evt => this.layoutGUI(evt), false); window.addEventListener('resize', evt => this.layoutGUI(evt), false);
GUI.genereateGridSettings();
Logic.start(); Logic.start();
//Renderer.setContext(this.currentView.context); //Renderer.setContext(this.currentView.context);
...@@ -27,6 +26,7 @@ ...@@ -27,6 +26,7 @@
} }
initializeClasses() { initializeClasses() {
GridManager.init();
GUI.init(); GUI.init();
Preferences.init(); Preferences.init();
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
RenderManager.init(); RenderManager.init();
Selection.init(); Selection.init();
GridManager.init();
ActionHistory.init(); ActionHistory.init();
PrefabManager.init(); PrefabManager.init();
...@@ -74,13 +73,18 @@ ...@@ -74,13 +73,18 @@
} }
setView(view) { setView(view) {
this.currentView = view;
if (view == null) if (view == null)
return; 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 { ...@@ -17,7 +17,7 @@ class LineManipulator {
} }
Selection.data.lines = []; Selection.data.lines = [];
Selection.data.lines = newLines; Selection.data.lines = newLines;
Renderer.redraw(); Application.redrawAllViews();
} }
static rotateSelectionBy(degrees, rotationCenter) { static rotateSelectionBy(degrees, rotationCenter) {
...@@ -38,7 +38,7 @@ class LineManipulator { ...@@ -38,7 +38,7 @@ class LineManipulator {
instance.transform.rotation += degrees; instance.transform.rotation += degrees;
} }
Renderer.redraw(); Application.redrawAllViews();
} }
static rotatePositionByAngle(position, rotationCenter, degrees) { static rotatePositionByAngle(position, rotationCenter, degrees) {
...@@ -85,7 +85,7 @@ class LineManipulator { ...@@ -85,7 +85,7 @@ class LineManipulator {
} }
} }
Renderer.redraw(); Application.redrawAllViews();
} }
static scalePoint(position, center, scaleVector) { static scalePoint(position, center, scaleVector) {
...@@ -97,7 +97,7 @@ class LineManipulator { ...@@ -97,7 +97,7 @@ class LineManipulator {
.subtractVector(center) .subtractVector(center)
.multiplyVector(scaleVector) .multiplyVector(scaleVector)
.addVector(center); .addVector(center);
//Renderer.redraw(); //Application.redrawAllViews();
} }
static growSelection() { static growSelection() {
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
this.addPrefab(newPrefab); this.addPrefab(newPrefab);
GUI.buildPrefabUI(); GUI.buildPrefabUI();
Renderer.redraw(); Application.redrawAllViews();
} }
static editPrefab(id) { static editPrefab(id) {
...@@ -101,7 +101,7 @@ ...@@ -101,7 +101,7 @@
} }
Utilities.deleteArrayEntry(this.prefabs, this.prefabs[id]); Utilities.deleteArrayEntry(this.prefabs, this.prefabs[id]);
GUI.buildPrefabUI(); GUI.buildPrefabUI();
Renderer.redraw(); Application.redrawAllViews();
} }
static _endPreviousPrefabEditIfExisting() { static _endPreviousPrefabEditIfExisting() {
......
...@@ -98,13 +98,13 @@ ...@@ -98,13 +98,13 @@
Preferences.init(); Preferences.init();
window.location.reload(); window.location.reload();
Renderer.redraw(); Application.redrawAllViews();
} }
static setQualitySetting(quality) { static setQualitySetting(quality) {
this.qualitySetting = quality; this.qualitySetting = quality;
Renderer.setQualitySetting(this.qualitySetting); Renderer.setQualitySetting(this.qualitySetting);
Renderer.redraw(); Application.redrawAllViews();
} }
static adjustRenderGuideLayers(value) { static adjustRenderGuideLayers(value) {
......
...@@ -65,7 +65,7 @@ Utilities = new class { ...@@ -65,7 +65,7 @@ Utilities = new class {
for (let i = 0; i < selPoints.length; ++i) for (let i = 0; i < selPoints.length; ++i)
selPoints[i].position = GridManager.grid.getNearestPointFor(selPoints[i].position); selPoints[i].position = GridManager.grid.getNearestPointFor(selPoints[i].position);
Renderer.redraw(); Application.redrawAllViews();
} }
distancePointToLine(position, line) { distancePointToLine(position, line) {
...@@ -86,7 +86,7 @@ Utilities = new class { ...@@ -86,7 +86,7 @@ Utilities = new class {
for (let line of selLines) { for (let line of selLines) {
Utilities.cutLines(line, File.currentLayer.lines, false); Utilities.cutLines(line, File.currentLayer.lines, false);
} }
Renderer.redraw(); Application.redrawAllViews();
} }
cutLines(cutter, lines, useDrawnLineAsRealLine) { cutLines(cutter, lines, useDrawnLineAsRealLine) {
...@@ -186,7 +186,7 @@ Utilities = new class { ...@@ -186,7 +186,7 @@ Utilities = new class {
for (let ending of endings) for (let ending of endings)
ending.position = center.copy(); ending.position = center.copy();
Renderer.redraw(); Application.redrawAllViews();
} }
// TODO make it possible to pass in, position as Vector2 and rotate as angle // TODO make it possible to pass in, position as Vector2 and rotate as angle
...@@ -280,7 +280,7 @@ Utilities = new class { ...@@ -280,7 +280,7 @@ Utilities = new class {
Selection.clearSelection(); Selection.clearSelection();
Selection.data = newSelData; Selection.data = newSelData;
File.updateStats(); File.updateStats();
Renderer.redraw(); Application.redrawAllViews();
} }
makeCircle(center, radius, segments, overshoot) { makeCircle(center, radius, segments, overshoot) {
...@@ -303,7 +303,7 @@ Utilities = new class { ...@@ -303,7 +303,7 @@ Utilities = new class {
} }
File.updateStats(); File.updateStats();
Renderer.redraw(); Application.redrawAllViews();
} }
measure() { measure() {
......
...@@ -49,14 +49,12 @@ ...@@ -49,14 +49,12 @@
mouseEnter(e) { mouseEnter(e) {
//console.log(this._getMousePos(e)); //console.log(this._getMousePos(e));
this.canvas.style.background = 'green';
Application.setView(this); Application.setView(this);
} }
mouseExit(e) { mouseExit(e) {
//console.log(this._getMousePos(e)); //console.log(this._getMousePos(e));
this.canvas.style.background = 'grey';
Application.setView(null); Application.setView(null);
} }
...@@ -67,4 +65,12 @@ ...@@ -67,4 +65,12 @@
e.clientY - rect.top 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 @@ ...@@ -46,7 +46,7 @@
if (state) { if (state) {
this.undoneStates.push(this.currentState); this.undoneStates.push(this.currentState);
this.setState(state); this.setState(state);
Renderer.redraw(); Application.redrawAllViews();
} }
} }
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
if (state) { if (state) {
this.states.push(this.currentState); this.states.push(this.currentState);
this.setState(state); this.setState(state);
Renderer.redraw(); Application.redrawAllViews();
} }
} }
} }
...@@ -97,13 +97,13 @@ class ActionHistory { ...@@ -97,13 +97,13 @@ class ActionHistory {
static undo() { static undo() {
this.popAction(); this.popAction();
Renderer.redraw(); Application.redrawAllViews();
} }
static redo() { static redo() {
var action = this.undoneActions.pop(); var action = this.undoneActions.pop();
if (action) if (action)
this.pushAction(action, true); this.pushAction(action, true);
Renderer.redraw(); Application.redrawAllViews();
} }
} }
\ No newline at end of file
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
this.layers[id] = layer1; this.layers[id] = layer1;
GUI.objectHierarchyChanged(); GUI.objectHierarchyChanged();
Renderer.redraw(); Application.redrawAllViews();
} }
static moveLayerUp(id) { static moveLayerUp(id) {
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
this.layers[id] = layer1; this.layers[id] = layer1;
GUI.objectHierarchyChanged(); GUI.objectHierarchyChanged();
Renderer.redraw(); Application.redrawAllViews();
} }
static deleteLayerWithID(id) { static deleteLayerWithID(id) {
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
Utilities.deleteArrayEntry(this.layers, this.layers[id]); Utilities.deleteArrayEntry(this.layers, this.layers[id]);
GUI.objectHierarchyChanged(); GUI.objectHierarchyChanged();
Renderer.redraw(); Application.redrawAllViews();
} }
static selectLayerWithID(id) { static selectLayerWithID(id) {
...@@ -82,7 +82,8 @@ ...@@ -82,7 +82,8 @@
this.layers[id].visible = true; this.layers[id].visible = true;
GUI.objectHierarchyChanged(); GUI.objectHierarchyChanged();
Renderer.redraw(); // WIP
//Application.redrawAllViews();
} }
static toggleVisibilityOfLayerWithID(id) { static toggleVisibilityOfLayerWithID(id) {
...@@ -96,12 +97,12 @@ ...@@ -96,12 +97,12 @@
} }
GUI.objectHierarchyChanged(); GUI.objectHierarchyChanged();
Renderer.redraw(); Application.redrawAllViews();
} }
static toggleRenderableOfLayerWithID(id) { static toggleRenderableOfLayerWithID(id) {
this.layers[id].hideInRenderPreview= !this.layers[id].hideInRenderPreview; this.layers[id].hideInRenderPreview= !this.layers[id].hideInRenderPreview;
GUI.objectHierarchyChanged(); GUI.objectHierarchyChanged();
Renderer.redraw(); Application.redrawAllViews();
} }
static selectNextVisibleLayer(id) { static selectNextVisibleLayer(id) {
......
...@@ -142,7 +142,7 @@ ...@@ -142,7 +142,7 @@
} }
if (redraw) if (redraw)
Renderer.redraw(); Application.redrawAllViews();
} }
selectLinked() { selectLinked() {
...@@ -162,7 +162,7 @@ ...@@ -162,7 +162,7 @@
if (i == maxIterations) if (i == maxIterations)
GUI.notify("Max Iteration Depth reached!"); GUI.notify("Max Iteration Depth reached!");
Renderer.redraw(); Application.redrawAllViews();
} }
copy() { copy() {
......
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
this.triGrid = new TriangleGrid(); this.triGrid = new TriangleGrid();
this.polarGrid = new PolarGrid(); this.polarGrid = new PolarGrid();
waitingForStart.push(this);
}
static start() {
this.updateGrid(); this.updateGrid();
} }
...@@ -35,6 +38,7 @@ ...@@ -35,6 +38,7 @@
GUI.gridTypeSelection.value = Preferences.gridType; GUI.gridTypeSelection.value = Preferences.gridType;
GUI.genereateGridSettings(); GUI.genereateGridSettings();
Renderer.redraw(); // wip
//Application.redrawAllViews();
} }
} }
\ No newline at end of file
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
case Key.Space: case Key.Space:
if (Logic.currentState instanceof IdleState) { if (Logic.currentState instanceof IdleState) {
Logic.setState(new MeasureState()); Logic.setState(new MeasureState());
Renderer.redraw(); Application.redrawAllViews();
} }
break; break;
case Key.G: case Key.G:
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
LineManipulator.resetPosition(); LineManipulator.resetPosition();
else else
Logic.setState(new MoveLinesState()); Logic.setState(new MoveLinesState());
Renderer.redraw(); Application.redrawAllViews();
} }
break; break;
case Key.R: case Key.R:
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
LineManipulator.resetRotation(); LineManipulator.resetRotation();
else else
Logic.setState(new RotateState()); Logic.setState(new RotateState());
Renderer.redraw(); Application.redrawAllViews();
} }
break; break;
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
LineManipulator.resetScale(); LineManipulator.resetScale();
else else
Logic.setState(new ScaleState()); Logic.setState(new ScaleState());
Renderer.redraw(); Application.redrawAllViews();
} }
break; break;
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
if (!Logic.isPreviewing()) { if (!Logic.isPreviewing()) {
Logic.isRenderPreviewing = true; Logic.isRenderPreviewing = true;
Renderer.setQualitySetting("quality"); Renderer.setQualitySetting("quality");
Renderer.redraw(); Application.redrawAllViews();
} }
break; break;
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
case Key.Control: case Key.Control:
MouseHandler.updateCurrentPosition(); MouseHandler.updateCurrentPosition();
Renderer.redraw(); Application.redrawAllViews();
break; break;
case Key.E: case Key.E:
Utilities.extrudeSelection(); Utilities.extrudeSelection();
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
if (Logic.isPreviewing()) { if (Logic.isPreviewing()) {
Logic.isRenderPreviewing = false; Logic.isRenderPreviewing = false;
Renderer.setQualitySetting(Preferences.qualitySetting); Renderer.setQualitySetting(Preferences.qualitySetting);
Renderer.redraw(); Application.redrawAllViews();
} }
break; break;
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
if (Logic.currentState instanceof DrawingState) { if (Logic.currentState instanceof DrawingState) {
if (drawPolyLine) { if (drawPolyLine) {
Logic.currentState.cancel(); Logic.currentState.cancel();
Renderer.redraw(); Application.redrawAllViews();
} }
} }
drawPolyLine = false; drawPolyLine = false;
...@@ -126,7 +126,7 @@ ...@@ -126,7 +126,7 @@
case Key.Control: case Key.Control:
MouseHandler.updateCurrentPosition(); MouseHandler.updateCurrentPosition();
Renderer.redraw(); Application.redrawAllViews();
break; break;
} }
} }
......
...@@ -47,7 +47,8 @@ class Input { ...@@ -47,7 +47,8 @@ class Input {
if (!MouseHandler.canvasFocused) { if (!MouseHandler.canvasFocused) {
if (e.keyCode == Key.Enter) { if (e.keyCode == Key.Enter) {
canvas.focus(); Application.currentView.canvas.focus();
Application.redrawAllViews();
} }
} }
...@@ -99,6 +100,6 @@ class Input { ...@@ -99,6 +100,6 @@ class Input {
} }
} }
Input.downKeys = []; Input.downKeys = [];
Renderer.redraw(); Application.redrawAllViews();
} }
} }
\ No newline at end of file
...@@ -60,7 +60,7 @@ class MouseHandler { ...@@ -60,7 +60,7 @@ class MouseHandler {
//GUI.writeToStats("Application.currentView.camera.canvasOffset", Application.currentView.camera.canvasOffset.toString()); //GUI.writeToStats("Application.currentView.camera.canvasOffset", Application.currentView.camera.canvasOffset.toString());
this.oldPosScreenSpace = newPosScreenSpace; this.oldPosScreenSpace = newPosScreenSpace;
Renderer.redraw(); Application.redrawAllViews();
} }
static adjustMouseDownButtonBools(e, state) { static adjustMouseDownButtonBools(e, state) {
...@@ -104,7 +104,7 @@ class MouseHandler { ...@@ -104,7 +104,7 @@ class MouseHandler {
} }
else if (Logic.currentState instanceof BrushSelectionState) { else if (Logic.currentState instanceof BrushSelectionState) {
Logic.currentState.update(); Logic.currentState.update();
Renderer.redraw(); Application.redrawAllViews();
} }
else if (Logic.currentState instanceof ContinousDrawingState) { else if (Logic.currentState instanceof ContinousDrawingState) {
Logic.currentState.oldPos = Logic.shouldSnap() ? currentPosition.copy() : mousePosition.copy(); Logic.currentState.oldPos = Logic.shouldSnap() ? currentPosition.copy() : mousePosition.copy();
...@@ -221,7 +221,7 @@ class MouseHandler { ...@@ -221,7 +221,7 @@ class MouseHandler {
Logic.currentState.mouseDown(2); Logic.currentState.mouseDown(2);
} }
Renderer.redraw(); Application.redrawAllViews();
} }
else if (e.button == 1) // MMB else if (e.button == 1) // MMB
{ {
...@@ -230,7 +230,7 @@ class MouseHandler { ...@@ -230,7 +230,7 @@ class MouseHandler {
} }
else if (Logic.currentState instanceof BrushSelectionState) { else if (Logic.currentState instanceof BrushSelectionState) {
Logic.currentState.update(); Logic.currentState.update();
Renderer.redraw(); Application.redrawAllViews();
} }
else if (e.ctrlKey) { else if (e.ctrlKey) {
Logic.setState(new ZoomState()); Logic.setState(new ZoomState());
...@@ -347,7 +347,7 @@ class MouseHandler { ...@@ -347,7 +347,7 @@ class MouseHandler {
Logic.currentState.execute(); Logic.currentState.execute();
Logic.setState(new IdleState()); Logic.setState(new IdleState());
Renderer.redraw(); Application.redrawAllViews();
} }
else if (Logic.currentState instanceof BoxSelectionState) // end box selection initialized with RMB else if (Logic.currentState instanceof BoxSelectionState) // end box selection initialized with RMB
{ {
...@@ -398,7 +398,7 @@ class MouseHandler { ...@@ -398,7 +398,7 @@ class MouseHandler {
this.mouseMove(e); this.mouseMove(e);
} }