From 1382c3db57f4b4e66e7714086f1ad858ce476701 Mon Sep 17 00:00:00 2001
From: Max <m.giller.dev@gmail.com>
Date: Fri, 5 Nov 2021 18:07:57 +0100
Subject: [PATCH] Made settings button right aligned and toggable

---
 editor/css/editor.css           | 4 ++++
 editor/js/toolbar.js            | 7 ++++++-
 editor/js/tools/settingstool.js | 2 +-
 editor/js/tools/tool.js         | 3 ++-
 4 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/editor/css/editor.css b/editor/css/editor.css
index 61852b2..c677e85 100644
--- a/editor/css/editor.css
+++ b/editor/css/editor.css
@@ -52,3 +52,7 @@ div#ks-editor img.preview-image {
     max-width: 5rem;
     height: auto;
 }
+
+div#ks-editor #toolbar-settings {
+    float: right;
+}
diff --git a/editor/js/toolbar.js b/editor/js/toolbar.js
index a4b93c2..795628b 100644
--- a/editor/js/toolbar.js
+++ b/editor/js/toolbar.js
@@ -64,7 +64,12 @@ export default class Toolbar {
             "",
             tool,
             (e) => {
-                state.setTool(e.data);
+                var sameTool = state.tool === tool;
+                if (sameTool && tool.toggleBehaviour) {
+                    state.setTool(state.previousTool);
+                } else {
+                    state.setTool(e.data);
+                }
             }
         );
     }
diff --git a/editor/js/tools/settingstool.js b/editor/js/tools/settingstool.js
index 0812a27..ca217e5 100644
--- a/editor/js/tools/settingstool.js
+++ b/editor/js/tools/settingstool.js
@@ -9,7 +9,7 @@ import Tool from "./tool";
 
 export default class SettingsTool extends Tool {
     constructor(key) {
-        super("Settings", "settings", key, new SettingsMenu());
+        super("Settings", "settings", key, new SettingsMenu(), true);
     }
 
     onMenuChange(key, value) {
diff --git a/editor/js/tools/tool.js b/editor/js/tools/tool.js
index 63ab117..31ee19a 100644
--- a/editor/js/tools/tool.js
+++ b/editor/js/tools/tool.js
@@ -1,10 +1,11 @@
 export default class Tool {
-    constructor(name, icon, key, menu) {
+    constructor(name, icon, key, menu, toggleBehaviour = false) {
         this.name = name;
         this.icon = icon;
         this.key = key;
         this.warnings = false;
         this.menu = menu;
+        this.toggleBehaviour = toggleBehaviour;
 
         if (this.menu !== undefined) {
             this.menu.loadTool(this);
-- 
GitLab