Skip to content

Commit

Permalink
Add firmware update warning
Browse files Browse the repository at this point in the history
  • Loading branch information
xioTechnologies authored Sep 5, 2024
1 parent 6020a1c commit 1f3af33
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion x-IMU3-GUI/Source/Dialogs/AboutDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void AboutDialog::resized()
logo.setBounds(bounds);
bounds.removeFromTop(margin);

applicationVersionUpdateLabel.setBounds(downloadsButton.getRight(), downloadsButton.getY(), 200, downloadsButton.getHeight());
applicationVersionUpdateLabel.setBounds(juce::Rectangle<int>::leftTopRightBottom(downloadsButton.getRight(), downloadsButton.getY(), bounds.getRight(), downloadsButton.getBottom()));
}

void AboutDialog::mouseUp(const juce::MouseEvent& mouseEvent)
Expand Down
4 changes: 2 additions & 2 deletions x-IMU3-GUI/Source/Dialogs/Dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ int Dialog::getMinimumWidth() const
int Dialog::calculateHeight(const int numberOfRows) const
{
// This "adjust" fixes a bug that the dialog height doesn't adjust after changing the title bar height
static constexpr int adjust = titleBarHeight - 26; // 26 is juce default title bar height,
return margin + (numberOfRows + 1) * (UILayout::textComponentHeight + margin) + adjust;
static constexpr int adjust = + titleBarHeight - 26; // 26 is juce default title bar height,
return margin + (numberOfRows + 1) * (UILayout::textComponentHeight + margin) + adjust + margin;
}

void Dialog::setOkButton(const bool valid, const juce::String& buttonText)
Expand Down
2 changes: 1 addition & 1 deletion x-IMU3-GUI/Source/Dialogs/SendNoteCommandDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void SendNoteCommandDialog::resized()
{
Dialog::resized();

auto bounds = getContentBounds();
auto bounds = getContentBounds().removeFromTop(UILayout::textComponentHeight);
label.setBounds(bounds.removeFromLeft(columnWidth));
value.setBounds(bounds);
}
Expand Down
6 changes: 5 additions & 1 deletion x-IMU3-GUI/Source/Dialogs/UpdateFirmwareDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
#include "UpdateFirmwareDialog.h"
#include "UpdatingFirmwareDialog.h"

UpdateFirmwareDialog::UpdateFirmwareDialog() : Dialog(BinaryData::tools_svg, "Update Firmware", "Update")
UpdateFirmwareDialog::UpdateFirmwareDialog() : Dialog(BinaryData::tools_svg, "Update Firmware", "Update", "Cancel", &warningIcon, iconButtonWidth)
{
addAndMakeVisible(deviceLabel);
addAndMakeVisible(deviceValue);
addAndMakeVisible(hexFileLabel);
addAndMakeVisible(hexFileSelector);
addAndMakeVisible(warningIcon);
addAndMakeVisible(warningLabel);

const auto hexFile = ApplicationSettings::getDirectory().getChildFile(Firmware::hexFile);
hexFile.replaceWithData(Firmware::memoryBlock.getData(), Firmware::memoryBlock.getSize());
Expand Down Expand Up @@ -38,6 +40,8 @@ void UpdateFirmwareDialog::resized()
auto hexFileRow = bounds.removeFromTop(UILayout::textComponentHeight);
hexFileLabel.setBounds(hexFileRow.removeFromLeft(columnWidth));
hexFileSelector.setBounds(hexFileRow);

warningLabel.setBounds(juce::Rectangle<int>::leftTopRightBottom(warningIcon.getRight(), warningIcon.getY(), bounds.getRight(), warningIcon.getBottom()));
}

std::unique_ptr<ximu3::ConnectionInfo> UpdateFirmwareDialog::getConnectionInfo() const
Expand Down
4 changes: 4 additions & 0 deletions x-IMU3-GUI/Source/Dialogs/UpdateFirmwareDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "Widgets/CustomComboBox.h"
#include "Widgets/CustomTextEditor.h"
#include "Widgets/FileSelector.h"
#include "Widgets/Icon.h"
#include "Widgets/IconButton.h"
#include "Widgets/SimpleLabel.h"
#include "Ximu3.hpp"
Expand Down Expand Up @@ -80,5 +81,8 @@ class UpdateFirmwareDialog : public Dialog
SimpleLabel hexFileLabel { "Hex File:" };
FileSelector hexFileSelector { "Select Firmware File", ".hex" };

Icon warningIcon { BinaryData::warning_white_svg, "", 0.7f };
SimpleLabel warningLabel { "Updating firmware will restore default settings" };

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(UpdateFirmwareDialog)
};

0 comments on commit 1f3af33

Please sign in to comment.