Skip to content

Commit

Permalink
update "About Kiwi" window
Browse files Browse the repository at this point in the history
  • Loading branch information
eliottparis committed Jan 28, 2019
1 parent 3a896c7 commit f9ea581
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 30 deletions.
118 changes: 88 additions & 30 deletions Client/Source/KiwiApp_Application/KiwiApp_AboutWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,62 +42,120 @@ namespace kiwi
getContentComponent()->setSize(400, 380);
}

// ================================================================================ //
// LINK LIST //
// ================================================================================ //

LinkList::LinkList(juce::String header, std::vector<Link> links)
: m_header("header", std::move(header))
, m_links(std::move(links))
{
addAndMakeVisible(m_header);
m_header.setColour(juce::Label::ColourIds::textColourId, juce::Colours::black);

for(auto& link: m_links)
{
addAndMakeVisible(link.link);
link.link.setColour(juce::HyperlinkButton::ColourIds::textColourId, juce::Colours::black.withAlpha(0.8f));

addAndMakeVisible(link.description);
link.description.setColour(juce::Label::ColourIds::textColourId, juce::Colours::black);
}
}

void LinkList::resized()
{
auto bounds = getLocalBounds();
m_header.setBounds(bounds.removeFromTop(22));
bounds.reduce(10, 0);
for(auto& link: m_links)
{
const auto link_bounds = bounds.removeFromTop(20);
link.link.setBounds(link_bounds);
link.link.changeWidthToFitText();
link.description.setBounds(link_bounds.withLeft(link.link.getRight()));
}
}

// ================================================================================ //
// ABOUT WINDOW CONTENT //
// ================================================================================ //

AboutWindow::Content::Content() :
m_kiwi_app_image(juce::ImageCache::getFromMemory(binary_data::images::kiwi_icon_png,
AboutWindow::Content::Content()
: m_kiwi_app_image(juce::ImageCache::getFromMemory(binary_data::images::kiwi_icon_png,
binary_data::images::kiwi_icon_png_size))
, m_authors_links("Developers:", {
{"Eliott Paris", juce::URL("https://github.com/eliottparis")},
{"Pierre Guillot", juce::URL("https://github.com/pierreguillot")},
{"Jean Millot", juce::URL("https://github.com/jean-millot")},
})
, m_credits_links("Credits: ", {
{"Juce", juce::URL("https://github.com/WeAreROLI/JUCE"), juce::CharPointer_UTF8("- © Roli")},
{"Flip", juce::URL("http://developer.irisate.com/"), juce::CharPointer_UTF8("- © irisate")},
{"Beast", juce::URL("https://github.com/boostorg/Beast/"), juce::CharPointer_UTF8("- boost")},
{"concurrentqueue", juce::URL("https://github.com/cameron314/concurrentqueue"), juce::CharPointer_UTF8("- Cameron Desrochers")},
{"json", juce::URL("https://github.com/nlohmann/json"), juce::CharPointer_UTF8("- Niels Lohmann")},
{"Faust", juce::URL("https://github.com/grame-cncm/faust"), juce::CharPointer_UTF8("- GRAME")},
{"Icons", juce::URL("https://www.flaticon.com/"), juce::CharPointer_UTF8("- by Freepik")}
})
{
addAndMakeVisible(m_authors_links);
addAndMakeVisible(m_credits_links);

setSize(400, 380);
}

void AboutWindow::Content::resized()
{
auto bounds = getLocalBounds().reduced(5, 0);
bounds.removeFromTop(70); // header
bounds.removeFromTop(30); // text
m_authors_links.setBounds(bounds.removeFromTop(90));
m_credits_links.setBounds(bounds);
}

void AboutWindow::Content::paint(juce::Graphics& g)
{
const auto bounds = getLocalBounds();

g.fillAll(juce::Colours::whitesmoke);

float img_size = 50;
int padding = 10;
auto bounds = getLocalBounds();

auto header_bounds = bounds.removeFromTop(70);

g.setColour(juce::Colour::fromRGB(88, 88, 90));
const auto header_bounds = bounds.withBottom(img_size + padding * 2);
g.fillRect(header_bounds);

const auto padding = 10;

header_bounds.reduce(padding, padding);

g.drawImage(m_kiwi_app_image,
juce::Rectangle<float>(getWidth() - img_size - padding, padding, img_size, img_size),
header_bounds.removeFromRight(header_bounds.getHeight()).toFloat(),
juce::RectanglePlacement::centred, false);

g.setColour(juce::Colours::lightgrey);
g.fillRect(bounds);

#if JUCE_DEBUG
const auto app_version = KiwiApp::use().getApplicationVersion() + " (debug)";
#else
const auto app_version = KiwiApp::use().getApplicationVersion();
#endif

const auto model_version = model::DataModel::use().version();
const auto compile_date = juce::Time::getCompilationDate().toString(true, false);
const auto compilation_date = juce::Time::getCompilationDate().toString(true, false);

g.setColour(juce::Colours::whitesmoke);

const auto info_text =
"- Kiwi app version: " + app_version + '\n'
+ "- Kiwi model version: " + model_version + '\n'
+ "- Compilation date: " + compile_date;
const auto header =
"App version: " + app_version + '\n'
+ "model version: " + model_version + '\n'
+ "Build date: " + compilation_date;

g.drawFittedText(info_text, header_bounds.withLeft(padding), juce::Justification::centredLeft, 5);
g.drawFittedText(header, header_bounds, juce::Justification::centredLeft, 5);

g.setColour(juce::Colours::black);

std::string licence_text = std::string("Kiwi © CICM - ANR MUSICOLL 2016-2018.\n\n");

licence_text += "Authors:\n";
licence_text += "- Eliott Paris\n";
licence_text += "- Pierre Guillot\n";
licence_text += "- Jean Millot\n";
licence_text += "\n";

licence_text += "Credits:\n";
licence_text += "- Application icons are designed by Freepik and distributed by Flaticon\n";

g.drawFittedText(licence_text,
bounds.withTop(header_bounds.getBottom()).reduced(padding),
juce::Justification::topLeft, 100);
g.drawFittedText(juce::CharPointer_UTF8 ("Kiwi © CICM ANR MUSICOLL - 2016-2018.\n\n"),
bounds.reduced(padding),
juce::Justification::topLeft, 1);
}
}
44 changes: 44 additions & 0 deletions Client/Source/KiwiApp_Application/KiwiApp_AboutWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,43 @@ namespace kiwi

};

//! @brief A list of HyperlinkButtons with optional description.
class LinkList : public juce::Component
{
public: // methods

struct Link {
Link(juce::String text, juce::URL url, juce::String _description = "")
: link(text, url)
, description("description", _description)
{}

Link(Link const& rhs)
: link(rhs.link.getButtonText(), rhs.link.getURL())
, description("description", rhs.description.getText())
{}

Link(Link&&) = default;

juce::HyperlinkButton link = {};
juce::Label description = {};
};

//! @brief Constructor.
LinkList(juce::String header, std::vector<Link> links);

//! @brief Destructor.
~LinkList() = default;

//! @brief juce::Component
void resized() override;

private: // variables

juce::Label m_header = {};
std::vector<Link> m_links;
};

class AboutWindow::Content : public juce::Component
{
public: // methods
Expand All @@ -64,8 +101,15 @@ namespace kiwi
//! @brief juce::Component
void paint(juce::Graphics& g) override;

//! @brief juce::Component
void resized() override;

private: // variables

juce::Image m_kiwi_app_image;
LinkList m_authors_links;
LinkList m_credits_links;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Content)
};
}

0 comments on commit f9ea581

Please sign in to comment.