Skip to content

Commit

Permalink
Add more information to About dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
xioTechnologies authored Oct 17, 2024
1 parent ad29a61 commit 0c266f7
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 30 deletions.
7 changes: 6 additions & 1 deletion x-IMU3-GUI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ if (APPLE)
target_sources(x-IMU3-GUI PRIVATE Source/UIUtilsMac.mm)
endif ()

string(TIMESTAMP BUILD_DATE UTC)
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD OUTPUT_VARIABLE COMMIT_SHA OUTPUT_STRIP_TRAILING_WHITESPACE)

target_compile_definitions(x-IMU3-GUI
PRIVATE
JUCE_WEB_BROWSER=0
Expand All @@ -61,7 +64,9 @@ target_compile_definitions(x-IMU3-GUI
JUCE_APPLICATION_VERSION_STRING="$<TARGET_PROPERTY:x-IMU3-GUI,JUCE_VERSION>"
JUCE_OPENGL3=1
GLM_FORCE_SILENT_WARNINGS
GLM_FORCE_SIZE_T_LENGTH) # Resolves signed conversion warning on Ubuntu
GLM_FORCE_SIZE_T_LENGTH # Resolves signed conversion warning on Ubuntu
BUILD_DATE="${BUILD_DATE}"
COMMIT_SHA="${COMMIT_SHA}")

FILE(GLOB_RECURSE FONT_FILES "Fonts/*.*")
FILE(GLOB_RECURSE IMAGE_FILES "Images/*.*")
Expand Down
51 changes: 28 additions & 23 deletions x-IMU3-GUI/Source/Dialogs/AboutDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,31 @@
AboutDialog::AboutDialog(const juce::String& latestVersion) : Dialog(BinaryData::xio_icon_svg, "About", "Close", "", &downloadsButton, iconButtonWidth)
{
addAndMakeVisible(logo);
addAndMakeVisible(applicationVersionLabel);
addAndMakeVisible(applicationVersionValue);
addAndMakeVisible(expectedFirmwareVersionLabel);
addAndMakeVisible(expectedFirmwareVersionValue);
for (auto& row : rows)
{
addAndMakeVisible(row.first);
addAndMakeVisible(row.second);
}
addAndMakeVisible(downloadsButton);

logo.setMouseCursor(juce::MouseCursor::PointingHandCursor);
logo.addMouseListener(this, true);

if (latestVersion.isNotEmpty())
{
addAndMakeVisible(applicationVersionUpdateLabel);
addAndMakeVisible(versionUpdateLabel);
if (latestVersion != ("v" + juce::JUCEApplication::getInstance()->getApplicationVersion()))
{
applicationVersionUpdateLabel.setInterceptsMouseClicks(true, true);
applicationVersionUpdateLabel.addMouseListener(this, true);
applicationVersionUpdateLabel.setMouseCursor(juce::MouseCursor::PointingHandCursor);
applicationVersionUpdateLabel.setText("x-IMU3 GUI " + latestVersion + " available");
applicationVersionUpdateLabel.setColour(juce::Label::textColourId, UIColours::update);
versionUpdateLabel.setInterceptsMouseClicks(true, true);
versionUpdateLabel.addMouseListener(this, true);
versionUpdateLabel.setMouseCursor(juce::MouseCursor::PointingHandCursor);
versionUpdateLabel.setText(latestVersion + " available");
versionUpdateLabel.setColour(juce::Label::textColourId, UIColours::update);
}
else
{
applicationVersionUpdateLabel.setText("No updates available");
applicationVersionUpdateLabel.setColour(juce::Label::textColourId, juce::Colours::grey);
versionUpdateLabel.setText("No updates available");
versionUpdateLabel.setColour(juce::Label::textColourId, juce::Colours::grey);
}
}

Expand All @@ -35,7 +36,7 @@ AboutDialog::AboutDialog(const juce::String& latestVersion) : Dialog(BinaryData:
juce::URL("https://x-io.co.uk/x-imu3/#downloads").launchInDefaultBrowser();
};

setSize(375, 235);
setSize(375, 325);
}

void AboutDialog::resized()
Expand All @@ -44,17 +45,21 @@ void AboutDialog::resized()

auto bounds = getContentBounds();

expectedFirmwareVersionLabel.setBounds(bounds.removeFromBottom(UILayout::textComponentHeight).reduced(75, 0));
expectedFirmwareVersionValue.setBounds(expectedFirmwareVersionLabel.getBounds());
applicationVersionLabel.setBounds(bounds.removeFromBottom(UILayout::textComponentHeight).reduced(75, 0));
applicationVersionValue.setBounds(applicationVersionLabel.getBounds());

bounds.removeFromBottom(margin);
bounds.removeFromTop(10);
logo.setBounds(bounds);
bounds.removeFromTop(margin);
logo.setBounds(bounds.removeFromTop(100));
bounds.removeFromTop(margin);

const auto labelWidth = std::accumulate(rows.begin(), rows.end(), 0, [&] (auto width, const auto& pair) { return std::max(width, juce::GlyphArrangement::getStringWidthInt(UIFonts::getDefaultFont(), pair.first->getText())); });
const auto valueWidth = std::accumulate(rows.begin(), rows.end(), 0, [&] (auto width, const auto& pair) { return std::max(width, juce::GlyphArrangement::getStringWidthInt(UIFonts::getDefaultFont(), pair.second->getText())); });
bounds = bounds.withSizeKeepingCentre(labelWidth + 25 + valueWidth, bounds.getHeight());
for (auto it = rows.rbegin(); it != rows.rend(); it++)
{
auto row = bounds.removeFromBottom(UILayout::textComponentHeight);
it->first->setBounds(row.removeFromLeft(labelWidth));
it->second->setBounds(row.removeFromRight(valueWidth));
}

applicationVersionUpdateLabel.setBounds(downloadsButton.getRight(), downloadsButton.getY(), (int) std::ceil(applicationVersionUpdateLabel.getTextWidth()), downloadsButton.getHeight());
versionUpdateLabel.setBounds(downloadsButton.getRight(), downloadsButton.getY(), (int) std::ceil(versionUpdateLabel.getTextWidth()), downloadsButton.getHeight());
}

void AboutDialog::mouseUp(const juce::MouseEvent& mouseEvent)
Expand All @@ -63,7 +68,7 @@ void AboutDialog::mouseUp(const juce::MouseEvent& mouseEvent)
{
juce::URL(logoUrl).launchInDefaultBrowser();
}
else if (mouseEvent.eventComponent == &applicationVersionUpdateLabel)
else if (mouseEvent.eventComponent == &versionUpdateLabel)
{
downloadsButton.triggerClick();
}
Expand Down
31 changes: 25 additions & 6 deletions x-IMU3-GUI/Source/Dialogs/AboutDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,31 @@ class AboutDialog : public Dialog

Icon logo { BinaryData::xio_logo_svg, logoUrl };

SimpleLabel applicationVersionLabel { "x-IMU3 GUI Version:" };
SimpleLabel applicationVersionValue { "v" + juce::JUCEApplication::getInstance()->getApplicationVersion(), UIFonts::getDefaultFont(), juce::Justification::centredRight };
SimpleLabel expectedFirmwareVersionLabel { "Expected Firmware:" };
SimpleLabel expectedFirmwareVersionValue { Firmware::version, UIFonts::getDefaultFont(), juce::Justification::centredRight };

SimpleLabel applicationVersionUpdateLabel { "", UIFonts::getDefaultFont(), juce::Justification::centredLeft };
SimpleLabel versionLabel { "Version:" };
SimpleLabel versionValue { "v" + juce::JUCEApplication::getInstance()->getApplicationVersion(), UIFonts::getDefaultFont(), juce::Justification::centredLeft };

SimpleLabel buildDateLabel { "Build Date:" };
SimpleLabel buildDateValue { juce::String(BUILD_DATE), UIFonts::getDefaultFont(), juce::Justification::centredLeft };

SimpleLabel configurationLabel { "Configuration:" };
#if JUCE_DEBUG
SimpleLabel configurationValue { "Debug", UIFonts::getDefaultFont(), juce::Justification::centredLeft };
#else
SimpleLabel configurationValue { "Release", UIFonts::getDefaultFont(), juce::Justification::centredLeft };
#endif

SimpleLabel commitShaLabel { "Commit SHA:" };
SimpleLabel commitShaValue { juce::String(COMMIT_SHA).isEmpty() ? "N/A" : juce::String(COMMIT_SHA), UIFonts::getDefaultFont(), juce::Justification::centredLeft };

const std::vector<std::pair<SimpleLabel*, SimpleLabel*>> rows
{
{ &versionLabel, &versionValue },
{ &buildDateLabel, &buildDateValue },
{ &configurationLabel, &configurationValue },
{ &commitShaLabel, &commitShaValue },
};

SimpleLabel versionUpdateLabel { "", UIFonts::getDefaultFont(), juce::Justification::centredLeft };

IconButton downloadsButton { BinaryData::download_svg, "x-IMU3 Downloads" };

Expand Down

0 comments on commit 0c266f7

Please sign in to comment.