From aee2e46d8ff4a3edf6189668aaee7b24437322c7 Mon Sep 17 00:00:00 2001 From: Vincenzo Sicurella Date: Sun, 4 Aug 2024 02:56:38 -0400 Subject: [PATCH] move firmware label to MainComponent (wip) --- Source/Main.cpp | 5 +++++ Source/MainComponent.cpp | 20 ++++++++++++++++--- Source/MainComponent.h | 4 +++- .../ui/keyboard_component.cpp | 4 ---- .../ui/keyboard_component.h | 2 -- 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/Source/Main.cpp b/Source/Main.cpp index c7c7263..0c13632 100644 --- a/Source/Main.cpp +++ b/Source/Main.cpp @@ -105,6 +105,11 @@ void TerpstraSysExApplication::shutdown() savePropertiesFile(); + // juce::String stateStr =state.toString(); + // auto lines = juce::StringArray::fromLines(stateStr); + // for (auto line : lines) + // DBG(line); + if (state.firmwareUpdateCompleted()) FirmwareTransfer::exitLibSsh2(); diff --git a/Source/MainComponent.cpp b/Source/MainComponent.cpp index a283f52..5705ac8 100644 --- a/Source/MainComponent.cpp +++ b/Source/MainComponent.cpp @@ -116,6 +116,11 @@ MainContentComponent::MainContentComponent(const LumatoneEditorState& stateIn, j lblAppVersion->setColour(Label::ColourIds::textColourId, Colour(0xff777777)); addAndMakeVisible(lblAppVersion.get()); + lblFirmwareVersion = std::make_unique("lblFirmwareVersion", ""); + lblFirmwareVersion->setFont(getAppFonts().getFont(LumatoneEditorFont::FranklinGothic)); + lblFirmwareVersion->setColour(Label::ColourIds::textColourId, juce::Colour(0xff777777)); + addAndMakeVisible(lblFirmwareVersion.get()); + addStatusListener(this); @@ -508,9 +513,9 @@ void MainContentComponent::resized() allKeysOverview->setBounds(contentMargin, midiAreaHeight, contentWidth, controlsLabelYPos - midiAreaHeight); int btnHeight = roundToInt(getHeight() * fileButtonH); - int btnMargin = roundToInt(getWidth() * saveloadMarginW); + int btnMargin = roundToInt(contentWidth * saveLoadMarginW); int saveLoadWidth = roundToInt(getWidth() * saveLoadW); - int btnY = allKeysOverview->getY() - roundToInt(getHeight() * btnYFromImageTop); + int btnY = allKeysOverview->getY() - (allKeysOverview->getHeight() * btnYFromImageTop); int halfWidthX = roundToInt(getWidth() * 0.5f); @@ -539,7 +544,11 @@ void MainContentComponent::resized() resizeLabelWithHeight(lblAppVersion.get(), roundToInt(lblAppName->getHeight() * 0.75f)); lblAppVersion->setTopLeftPosition(lblAppName->getRight(), lblAppName->getBottom() - lblAppVersion->getHeight()); + + // resizeLabelWithHeight(lblFirmwareVersion.get(), btnHeight * 0.6f); + lblFirmwareVersion->setBounds(allKeysOverview->getX(), allKeysOverview->getBottom(), btnHeight * 0.6f, contentWidth); } + void MainContentComponent::resizeEditSectionTabs() { int sectionTabsMargin = proportionOfWidth(sectionTabsMarginW); @@ -580,8 +589,13 @@ void MainContentComponent::handleStatePropertyChange(juce::ValueTree stateIn, co { updateDeveloperMode(); } - if (property == LumatoneApplicationProperty::NumKeySelected) + else if (property == LumatoneApplicationProperty::NumKeySelected) { lblSelectedKeys->setText(stateIn[property].toString() + " Keys Selected", juce::NotificationType::dontSendNotification); } + else if (property == LumatoneStateProperty::LastConnectedFirmwareVersion) + { + auto string = juce::String("Firmware version: " + getFirmwareVersion().toDisplayString()); + lblFirmwareVersion->setText(string, juce::NotificationType::sendNotification); + } } diff --git a/Source/MainComponent.h b/Source/MainComponent.h index bf13d84..107d953 100644 --- a/Source/MainComponent.h +++ b/Source/MainComponent.h @@ -115,6 +115,8 @@ class MainContentComponent : public juce::Component std::unique_ptr lblAppName; std::unique_ptr lblAppVersion; + std::unique_ptr lblFirmwareVersion; + // Buffer for copy/paste of sub board data std::unique_ptr copiedSubBoardData; @@ -161,7 +163,7 @@ class MainContentComponent : public juce::Component const float btnYFromImageTop = 0.02; const float saveLoadW = 0.08f; - const float saveloadMarginW = 0.0034f; + const float saveLoadMarginW = 0.0034f; const float popupWidth = 0.4f; diff --git a/Source/lumatone_editor_library/ui/keyboard_component.cpp b/Source/lumatone_editor_library/ui/keyboard_component.cpp index 837a14a..cf4e1f3 100644 --- a/Source/lumatone_editor_library/ui/keyboard_component.cpp +++ b/Source/lumatone_editor_library/ui/keyboard_component.cpp @@ -83,10 +83,6 @@ void LumatoneKeyboardComponent::resized() octaveLineY = lumatoneBounds.getBottom() + juce::roundToInt(getHeight() * octaveLineYRatio); - // int btnHeight = juce::roundToInt(getHeight() * saveLoadH); - //resizeLabelWithHeight(lblFirmwareVersion.get(), btnHeight * 0.6f); - // lblFirmwareVersion->setTopLeftPosition(lumatoneBounds.getX(), lumatoneBounds.getY() - btnHeight * 0.6f); - keyWidth = juce::roundToInt(lumatoneBounds.getWidth() * keyW); keyHeight = juce::roundToInt(lumatoneBounds.getHeight() * keyH); diff --git a/Source/lumatone_editor_library/ui/keyboard_component.h b/Source/lumatone_editor_library/ui/keyboard_component.h index 8298627..33a2979 100644 --- a/Source/lumatone_editor_library/ui/keyboard_component.h +++ b/Source/lumatone_editor_library/ui/keyboard_component.h @@ -183,8 +183,6 @@ class LumatoneKeyboardComponent : public juce::Component, juce::Array lastKeySelection; - // std::unique_ptr lblFirmwareVersion; - //============================================================================== // UI Data