From 11c201e8826a9dcdcbf86680997950547ef5660c Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Sun, 29 Oct 2017 11:29:40 +0000 Subject: [PATCH] [client] Finish refacotring the brush indicator with weird ellipse stuff :P --- Nibriboard/ClientFiles/BoardWindow.js | 4 ++-- Nibriboard/ClientFiles/BrushIndicator.js | 9 +++++---- Nibriboard/ClientFiles/Interface.js | 2 ++ Nibriboard/ClientFiles/Nibri.css | 19 ++++++------------- Nibriboard/ClientFiles/Pencil.js | 2 +- Nibriboard/lib/GlidingSquirrel | 2 +- 6 files changed, 17 insertions(+), 21 deletions(-) diff --git a/Nibriboard/ClientFiles/BoardWindow.js b/Nibriboard/ClientFiles/BoardWindow.js index bff5379..9cfddbf 100644 --- a/Nibriboard/ClientFiles/BoardWindow.js +++ b/Nibriboard/ClientFiles/BoardWindow.js @@ -103,10 +103,10 @@ class BoardWindow extends EventEmitter this.interface.seekColour("forwards"); }).bind(this)); this.keyboard.on("keyup-up", (function(event) { - this.interface.updateBrushWidth(this.interface.currentBrushWidth + 2, true); + this.interface.updateBrushWidth(this.interface.brushIndicator.width + 2, true); }).bind(this)); this.keyboard.on("keyup-down", (function(event) { - this.interface.updateBrushWidth(this.interface.currentBrushWidth - 2, true); + this.interface.updateBrushWidth(this.interface.brushIndicator.width - 2, true); }).bind(this)); this.keyboard.on("keyup-c", (function(event) { this.chunkCache.showRenderedChunks = !this.chunkCache.showRenderedChunks; diff --git a/Nibriboard/ClientFiles/BrushIndicator.js b/Nibriboard/ClientFiles/BrushIndicator.js index 108add2..6980ddf 100644 --- a/Nibriboard/ClientFiles/BrushIndicator.js +++ b/Nibriboard/ClientFiles/BrushIndicator.js @@ -7,6 +7,8 @@ class BrushIndicator this.canvas = canvas; this.context = canvas.getContext("2d"); + this.canvas.height = this.canvas.width = 48; + this.width = 10; this.colour = "red"; } @@ -19,11 +21,10 @@ class BrushIndicator ); this.context.beginPath(); - this.context.arc( + this.context.ellipse( this.canvas.width / 2, this.canvas.height / 2, - this.width / 2, - 0, Math.PI * 2, - false + this.width / 3, this.width / 3, + 0, 0, Math.PI * 2, false ); this.context.fillStyle = this.colour; this.context.fill(); diff --git a/Nibriboard/ClientFiles/Interface.js b/Nibriboard/ClientFiles/Interface.js index 6c68cef..f216f55 100644 --- a/Nibriboard/ClientFiles/Interface.js +++ b/Nibriboard/ClientFiles/Interface.js @@ -2,6 +2,8 @@ window.EventEmitter = require("event-emitter-es6"); +import BrushIndicator from './BrushIndicator.js'; + class Interface extends EventEmitter { constructor(inBoardWindow, inSidebar, inDebugDisplay) diff --git a/Nibriboard/ClientFiles/Nibri.css b/Nibriboard/ClientFiles/Nibri.css index cf8f49b..72201b4 100644 --- a/Nibriboard/ClientFiles/Nibri.css +++ b/Nibriboard/ClientFiles/Nibri.css @@ -74,22 +74,15 @@ hr .brush-settings { - display: flex; flex-direction: column; + display: flex; flex-direction: row; min-height: 5em; } -.brush-preview-display -{ - flex: 1; -} - -.brush-indicator -{ - position: relative; - top: 50%; left: 50%; transform: translate(-50%, -50%); - - margin: 1em 0 0 0; - border-radius: 50%; +.brush-indicator { flex: 0; } +.brush-width-controls +{ + flex: 3; + margin-top: 2em; } .tool-selector diff --git a/Nibriboard/ClientFiles/Pencil.js b/Nibriboard/ClientFiles/Pencil.js index d33d925..5fb3e53 100644 --- a/Nibriboard/ClientFiles/Pencil.js +++ b/Nibriboard/ClientFiles/Pencil.js @@ -70,7 +70,7 @@ class Pencil }).bind(this)) // Look up the initial line with in the interface - this.currentLineWidth = inInterface.currentBrushWidth; + this.currentLineWidth = inInterface.brushIndicator.width; // Listen for future updates fromt he interface inInterface.on("brushwidthchange", (function(event) { this.currentLineWidth = event.newWidth; diff --git a/Nibriboard/lib/GlidingSquirrel b/Nibriboard/lib/GlidingSquirrel index 62f67e9..1e7878c 160000 --- a/Nibriboard/lib/GlidingSquirrel +++ b/Nibriboard/lib/GlidingSquirrel @@ -1 +1 @@ -Subproject commit 62f67e924c652d84956ed2bbf87588fd5ae963a9 +Subproject commit 1e7878c76032ab87bbf2829c8be2f43ff85f5660