From bc4705c2d2fee027ddc8a6a3d93782b00ac97d80 Mon Sep 17 00:00:00 2001 From: JannisX11 Date: Tue, 8 Mar 2022 19:23:30 +0100 Subject: [PATCH] Improve layout on mobile Fix issues with panel arranging --- css/dialogs.css | 8 +++----- css/window.css | 10 +++++++++- js/interface/keyboard.js | 7 +------ js/interface/panels.js | 17 ++++++++++++----- js/texturing/color.js | 2 +- js/util.js | 9 +++++++++ 6 files changed, 35 insertions(+), 18 deletions(-) diff --git a/css/dialogs.css b/css/dialogs.css index 4f9e9a5..fa49c5e 100644 --- a/css/dialogs.css +++ b/css/dialogs.css @@ -1241,6 +1241,9 @@ height: 42px; box-shadow: 0 0 5px rgba(0, 0, 0, 0.5); } + body.is_mobile #action_selector { + top: 26px; + } #action_selector > input { width: calc(100% - 38px); height: 42px; @@ -1326,11 +1329,6 @@ top: 4px; left: 49px; } - @media (max-device-width: 640px) { - dialog#action_selector { - top: 26px; - } - } /* Edit History */ #edit_history_list ul { diff --git a/css/window.css b/css/window.css index 20cdd96..f598456 100644 --- a/css/window.css +++ b/css/window.css @@ -85,6 +85,10 @@ #status_bar { grid-area: status_bar; } + #top_slot, + #bottom_slot { + background-color: var(--color-ui); + } .single_canvas_wrapper { height: 100%; width: 100%; @@ -307,7 +311,7 @@ } body.is_mobile.is_landscape #work_screen { grid-template-columns: auto 48px !important; - grid-template-rows: auto minmax(100px, 5000px) 26px !important; + grid-template-rows: auto minmax(200px, 5000px) 26px !important; grid-template-areas: "toolbar panel_selector" "center panel_selector" @@ -320,6 +324,10 @@ body.is_mobile #main_toolbar { display: block; } + body.is_mobile.is_landscape #main_toolbar { + display: flex; + height: fit-content; + } body.is_mobile #main_toolbar > * { display: block; } diff --git a/js/interface/keyboard.js b/js/interface/keyboard.js index 35821cb..6362317 100644 --- a/js/interface/keyboard.js +++ b/js/interface/keyboard.js @@ -301,12 +301,7 @@ Keybinds.loadKeymap = function(id, from_start_screen = false) { return true; } Keybinds.no_overlap = function(k1, k2) { - if (typeof k1.condition !== 'object' || typeof k2.condition !== 'object') return false; - if (k1.condition.modes && k2.condition.modes && k1.condition.modes.overlap(k2.condition.modes) == 0) return true; - if (k1.condition.tools && k2.condition.tools && k1.condition.tools.overlap(k2.condition.tools) == 0) return true; - if (k1.condition.formats && k2.condition.formats && k1.condition.formats.overlap(k2.condition.formats) == 0) return true; - if (k1.condition.features && k2.condition.features && k1.condition.features.overlap(k2.condition.features) == 0) return true; - return false; + return Condition.mutuallyExclusive(k1.condition, k2.condition); } function updateKeybindConflicts() { for (var key in Keybinds.structure) { diff --git a/js/interface/panels.js b/js/interface/panels.js index f631308..3094b8b 100644 --- a/js/interface/panels.js +++ b/js/interface/panels.js @@ -374,20 +374,25 @@ class Panel { } else { $(ref_panel.node).after(this.node); } + Interface.data[slot].remove(this.id); + Interface.data[slot].splice(Interface.data[slot].indexOf(ref_panel.id) + (before ? 0 : 1), 0, this.id); } else { document.getElementById(slot).append(this.node); + Interface.data[slot].push(this.id); } } else if (slot == 'top') { let top_panel = Interface.getTopPanel(); - if (top_panel && top_panel !== this) top_panel.moveTo(top_panel.previous_slot); - + if (top_panel && top_panel !== this && !Condition.mutuallyExclusive(this.condition, top_panel.condition)) { + top_panel.moveTo(top_panel.previous_slot); + } document.getElementById('top_slot').append(this.node); } else if (slot == 'bottom') { let bottom_panel = Interface.getBottomPanel(); - if (bottom_panel && bottom_panel !== this) bottom_panel.moveTo(bottom_panel.previous_slot); - + if (bottom_panel && bottom_panel !== this && !Condition.mutuallyExclusive(this.condition, bottom_panel.condition)) { + bottom_panel.moveTo(bottom_panel.previous_slot); + } document.getElementById('bottom_slot').append(this.node); } else if (slot == 'float') { @@ -525,7 +530,9 @@ function updateSidebarOrder() { Interface.data[bar].forEach(panel_id => { let panel = Panels[panel_id]; - if (panel) bar_node.append(panel.node); + if (panel && panel.slot == bar) { + bar_node.append(panel.node); + } }); }) } diff --git a/js/texturing/color.js b/js/texturing/color.js index 749c11a..99039f6 100644 --- a/js/texturing/color.js +++ b/js/texturing/color.js @@ -59,7 +59,7 @@ Interface.definePanels(() => { ColorPanel = new Panel('color', { icon: 'palette', - condition: () => Modes.id === 'paint', + condition: {modes: ['paint']}, default_position: { slot: 'right_bar', float_position: [0, 0], diff --git a/js/util.js b/js/util.js index 6f9dfe1..a9ac4aa 100644 --- a/js/util.js +++ b/js/util.js @@ -50,6 +50,15 @@ const Condition = function(condition, context) { return !!condition } } +Condition.mutuallyExclusive = function(a, b) { + if (typeof a !== 'object' || typeof b !== 'object') return false; + if (a.modes && b.modes && a.modes.overlap(b.modes) == 0) return true; + if (a.tools && b.tools && a.tools.overlap(b.tools) == 0) return true; + if (a.formats && b.formats && a.formats.overlap(b.formats) == 0) return true; + if (a.features && b.features && a.features.overlap(b.features) == 0) return true; + return false; +} + class oneLiner { constructor(data) { if (data !== undefined) {