From eced53e47ba39e2025331c5b029567e72441808d Mon Sep 17 00:00:00 2001 From: Anjal Doshi Date: Fri, 1 Nov 2024 17:29:02 -0700 Subject: [PATCH] Save/load console window bounds --- Source/UI/UIComponent.cpp | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/Source/UI/UIComponent.cpp b/Source/UI/UIComponent.cpp index 79421c5da..daf95aa5e 100755 --- a/Source/UI/UIComponent.cpp +++ b/Source/UI/UIComponent.cpp @@ -438,12 +438,11 @@ void UIComponent::openConsoleWindow() { if (consoleWindow == nullptr) { - consoleWindow = std::make_unique (nullptr, "Console"); + consoleWindow = std::make_unique (nullptr, "Open Ephys GUI Console"); consoleWindow->addListener (this); consoleWindow->setLookAndFeel (customLookAndFeel); consoleWindow->setBackgroundColour (findColour (ThemeColours::windowBackground)); - consoleWindow->setTitle ("Open Ephys GUI Console"); - consoleWindow->setSize (600, 800); + consoleWindow->setSize (700, 700); } if (consoleOpenInTab) @@ -1154,7 +1153,12 @@ void UIComponent::saveStateToXml (XmlElement* xml) XmlElement* uiComponentState = xml->createNewChildElement ("UICOMPONENT"); uiComponentState->setAttribute ("isProcessorListOpen", processorList->isOpen()); uiComponentState->setAttribute ("isEditorViewportOpen", showHideEditorViewportButton->getToggleState()); - uiComponentState->setAttribute ("consoleOpenState", consoleOpenInTab ? 1 : (consoleOpenInWindow ? 2 : 0)); + uiComponentState->setAttribute ("consoleOpenInWindow", consoleOpenInWindow); + + if (consoleOpenInWindow) + { + uiComponentState->setAttribute ("consoleWindowBounds", consoleWindow->getWindowStateAsString()); + } } void UIComponent::loadStateFromXml (XmlElement* xml) @@ -1171,28 +1175,12 @@ void UIComponent::loadStateFromXml (XmlElement* xml) showHideEditorViewportButton->setToggleState (isEditorViewportOpen, sendNotification); - int consoleOpenState = xmlNode->getIntAttribute ("consoleOpenState", -1); + bool consoleWindowState = xmlNode->getBoolAttribute ("consoleOpenInWindow"); - if (consoleOpenState == 1 || consoleOpenState == -1) - { - addConsoleTab(); - } - else if (consoleOpenState == 2) + if (consoleWindowState) { openConsoleWindow(); - } - else - { - if (consoleOpenInTab) - { - dataViewport->removeTab (2); - consoleOpenInTab = false; - } - - if (consoleOpenInWindow) - { - consoleWindow->closeButtonPressed(); - } + consoleWindow->restoreWindowStateFromString (xmlNode->getStringAttribute ("consoleWindowBounds")); } } } @@ -1209,7 +1197,7 @@ void UIComponent::setRecentlyUsedFilenames (const Array& filenames) void UIComponent::windowClosed (const String& windowName) { - if (windowName == "Console") + if (windowName == consoleWindow->getName()) { consoleOpenInWindow = false; }