From ac4ab25d8a4c1ffb6f17405b43f6bc0a463e8059 Mon Sep 17 00:00:00 2001 From: kovacsv Date: Tue, 14 Dec 2021 12:10:32 +0100 Subject: [PATCH] Move reset to default button to the bottom of the sidebar. --- website/o3dv/css/sidebar.css | 6 +++ website/o3dv/js/sidebarsettingspanel.js | 52 +++++++++++++++---------- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/website/o3dv/css/sidebar.css b/website/o3dv/css/sidebar.css index 7ab7083..4c003ab 100644 --- a/website/o3dv/css/sidebar.css +++ b/website/o3dv/css/sidebar.css @@ -58,6 +58,12 @@ div.ov_sidebar_content div.ov_sidebar_settings_content overflow: auto; } +div.ov_sidebar_content div.ov_sidebar_settings_sections +{ + margin-bottom: 10px; + overflow: auto; +} + div.ov_sidebar_content div.ov_sidebar_settings_row { margin: 5px 0px; diff --git a/website/o3dv/js/sidebarsettingspanel.js b/website/o3dv/js/sidebarsettingspanel.js index 6a10f85..38aceab 100644 --- a/website/o3dv/js/sidebarsettingspanel.js +++ b/website/o3dv/js/sidebarsettingspanel.js @@ -224,10 +224,17 @@ OV.SidebarSettingsPanel = class extends OV.SidebarPanel { super (parentDiv); this.settings = settings; - this.backgroundColorSection = new OV.SettingsColorSection (this.contentDiv); - this.defaultColorSection = new OV.SettingsColorSection (this.contentDiv); - this.edgeDisplaySection = new OV.SettingsEdgeDisplaySection (this.contentDiv); - this.themeSection = new OV.SettingsThemeSection (this.contentDiv); + + this.sectionsDiv = OV.AddDiv (this.contentDiv, 'ov_sidebar_settings_sections ov_thin_scrollbar'); + this.backgroundColorSection = new OV.SettingsColorSection (this.sectionsDiv); + this.defaultColorSection = new OV.SettingsColorSection (this.sectionsDiv); + this.edgeDisplaySection = new OV.SettingsEdgeDisplaySection (this.sectionsDiv); + this.themeSection = new OV.SettingsThemeSection (this.sectionsDiv); + + this.resetToDefaultsButton = OV.AddDiv (this.contentDiv, 'ov_button ov_sidebar_button outline', 'Reset to Default'); + this.resetToDefaultsButton.addEventListener ('click', () => { + this.ResetToDefaults (); + }); } GetName () @@ -298,7 +305,6 @@ OV.SidebarSettingsPanel = class extends OV.SidebarPanel } callbacks.onThemeChange (); }); - this.AddResetToDefaultsButton (); } UpdateSettings (hasDefaultMaterial) @@ -327,23 +333,29 @@ OV.SidebarSettingsPanel = class extends OV.SidebarPanel } } - AddResetToDefaultsButton () + ResetToDefaults () { let defaultSettings = new OV.Settings (); - let resetToDefaultsButton = OV.AddDiv (this.contentDiv, 'ov_button ov_sidebar_button outline', 'Reset to Default'); - resetToDefaultsButton.addEventListener ('click', () => { - this.settings.backgroundColor = defaultSettings.backgroundColor; - this.settings.defaultColor = defaultSettings.defaultColor; - this.settings.showEdges = defaultSettings.showEdges; - this.settings.edgeColor = defaultSettings.edgeColor; - this.settings.edgeThreshold = defaultSettings.edgeThreshold; - this.settings.themeId = defaultSettings.themeId; - this.backgroundColorSection.Update (defaultSettings.backgroundColor); - this.defaultColorSection.Update (defaultSettings.defaultColor); - this.edgeDisplaySection.Update (defaultSettings.showEdges, defaultSettings.edgeColor, defaultSettings.edgeThreshold); - this.themeSection.Update (defaultSettings.themeId); - this.callbacks.onThemeChange (); - }); + this.settings.backgroundColor = defaultSettings.backgroundColor; + this.settings.defaultColor = defaultSettings.defaultColor; + this.settings.showEdges = defaultSettings.showEdges; + this.settings.edgeColor = defaultSettings.edgeColor; + this.settings.edgeThreshold = defaultSettings.edgeThreshold; + this.settings.themeId = defaultSettings.themeId; + + this.backgroundColorSection.Update (defaultSettings.backgroundColor); + this.defaultColorSection.Update (defaultSettings.defaultColor); + this.edgeDisplaySection.Update (defaultSettings.showEdges, defaultSettings.edgeColor, defaultSettings.edgeThreshold); + this.themeSection.Update (defaultSettings.themeId); + this.callbacks.onThemeChange (); + } + + Resize () + { + let titleHeight = OV.GetDomElementOuterHeight (this.titleDiv); + let resetButtonHeight = OV.GetDomElementOuterHeight (this.resetToDefaultsButton); + let height = this.parentDiv.offsetHeight; + OV.SetDomElementOuterHeight (this.sectionsDiv, height - titleHeight - resetButtonHeight); } };