Skip to content

Commit

Permalink
Make Heavy dialog and other dialogs more consistent in style, added h…
Browse files Browse the repository at this point in the history
…elp button to heavy dialog
  • Loading branch information
timothyschoen committed Oct 4, 2023
1 parent 99ee10b commit 20b5900
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 30 deletions.
Binary file modified Resources/Fonts/IconFont.ttf
Binary file not shown.
1 change: 1 addition & 0 deletions Source/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ struct Icons {
inline static const String History = "X";
inline static const String Protection = "Y";
inline static const String DevTools = "{";
inline static const String Help = "\\";

inline static const String SavePatch = "Z";
inline static const String ClosePatch = "[";
Expand Down
6 changes: 3 additions & 3 deletions Source/Dialogs/Deken.h
Original file line number Diff line number Diff line change
Expand Up @@ -527,10 +527,10 @@ class Deken : public Component
g.setColour(findColour(PlugDataColour::panelBackgroundColourId));
g.fillRoundedRectangle(getLocalBounds().toFloat(), Corners::windowCornerRadius);

auto bounds = getLocalBounds().removeFromTop(40).toFloat();
auto titlebarBounds = getLocalBounds().removeFromTop(40).toFloat();

Path p;
p.addRoundedRectangle(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight(), Corners::largeCornerRadius, Corners::largeCornerRadius, true, true, false, false);
p.addRoundedRectangle(titlebarBounds.getX(), titlebarBounds.getY(), titlebarBounds.getWidth(), titlebarBounds.getHeight(), Corners::largeCornerRadius, Corners::largeCornerRadius, true, true, false, false);

g.setColour(findColour(PlugDataColour::toolbarBackgroundColourId));
g.fillPath(p);
Expand All @@ -550,7 +550,7 @@ class Deken : public Component
Fonts::drawFittedText(g, "Type to search for objects or libraries", 30, 40, getWidth() - 60, 30, findColour(PlugDataColour::panelTextColourId).withAlpha(0.5f), 1, 0.9f, 14);
}

g.setColour(findColour(PlugDataColour::outlineColourId));
g.setColour(findColour(PlugDataColour::toolbarOutlineColourId));
g.drawLine(0, 40, getWidth(), 40);
g.drawLine(0, 70, getWidth(), 70);
}
Expand Down
10 changes: 6 additions & 4 deletions Source/Dialogs/ObjectBrowserDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -832,11 +832,13 @@ class ObjectBrowserDialog : public Component {
g.setColour(findColour(PlugDataColour::panelBackgroundColourId));
g.fillRoundedRectangle(getLocalBounds().reduced(1).toFloat(), Corners::windowCornerRadius);

g.setColour(findColour(PlugDataColour::toolbarBackgroundColourId));
auto titlebarBounds = getLocalBounds().removeFromTop(40);

Path p;
p.addRoundedRectangle(titlebarBounds.getX(), titlebarBounds.getY(), titlebarBounds.getWidth(), titlebarBounds.getHeight(), Corners::largeCornerRadius, Corners::largeCornerRadius, true, true, false, false);

auto toolbarBounds = Rectangle<float>(1, 1, getWidth() - 2, 40);
g.fillRoundedRectangle(toolbarBounds, Corners::windowCornerRadius);
g.fillRect(toolbarBounds.withTrimmedTop(15.0f));
g.setColour(findColour(PlugDataColour::toolbarBackgroundColourId));
g.fillPath(p);

g.setColour(findColour(PlugDataColour::toolbarOutlineColourId));
g.drawHorizontalLine(40, 0.0f, getWidth());
Expand Down
12 changes: 6 additions & 6 deletions Source/Dialogs/ObjectReferenceDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,6 @@ class ObjectReferenceDialog : public Component {
setVisible(false);
};

backButton.setColour(TextButton::buttonColourId, Colours::transparentBlack);
backButton.setColour(TextButton::buttonOnColourId, Colours::transparentBlack);
backButton.getProperties().set("Style", "LargeIcon");

addAndMakeVisible(objectInfoPanel);
Expand All @@ -237,11 +235,13 @@ class ObjectReferenceDialog : public Component {
g.setColour(findColour(PlugDataColour::panelBackgroundColourId));
g.fillRoundedRectangle(getLocalBounds().reduced(1).toFloat(), Corners::windowCornerRadius);

g.setColour(findColour(PlugDataColour::toolbarBackgroundColourId));
auto titlebarBounds = getLocalBounds().removeFromTop(40).toFloat();

Path p;
p.addRoundedRectangle(titlebarBounds.getX(), titlebarBounds.getY(), titlebarBounds.getWidth(), titlebarBounds.getHeight(), Corners::largeCornerRadius, Corners::largeCornerRadius, true, true, false, false);

auto toolbarBounds = Rectangle<float>(1, 1, getWidth() - 2, 40);
g.fillRoundedRectangle(toolbarBounds, Corners::windowCornerRadius);
g.fillRect(toolbarBounds.withTrimmedTop(15.0f));
g.setColour(findColour(PlugDataColour::toolbarBackgroundColourId));
g.fillPath(p);

g.setColour(findColour(PlugDataColour::toolbarOutlineColourId));
g.drawHorizontalLine(40, 0.0f, getWidth());
Expand Down
4 changes: 2 additions & 2 deletions Source/Dialogs/PatchStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -664,11 +664,11 @@ struct PatchStorage : public Component
if (input.getText().isEmpty()) {
Fonts::drawFittedText(g, "Type to search for patches", 30, 40, getWidth() - 60, 30, findColour(PlugDataColour::panelTextColourId).withAlpha(0.5f), 1, 0.9f, 14);
}
g.setColour(findColour(PlugDataColour::outlineColourId));
g.setColour(findColour(PlugDataColour::toolbarOutlineColourId));
g.drawLine(0, 70, getWidth(), 70);
}

g.setColour(findColour(PlugDataColour::outlineColourId));
g.setColour(findColour(PlugDataColour::toolbarOutlineColourId));
g.drawLine(0, 40, getWidth(), 40);
}

Expand Down
12 changes: 7 additions & 5 deletions Source/Dialogs/SettingsDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,13 @@ class SettingsDialog : public Component {
g.setColour(findColour(PlugDataColour::panelBackgroundColourId));
g.fillRoundedRectangle(getLocalBounds().reduced(1).toFloat(), Corners::windowCornerRadius);

g.setColour(findColour(PlugDataColour::toolbarBackgroundColourId));
auto titlebarBounds = getLocalBounds().removeFromTop(toolbarHeight).toFloat();

Path p;
p.addRoundedRectangle(titlebarBounds.getX(), titlebarBounds.getY(), titlebarBounds.getWidth(), titlebarBounds.getHeight(), Corners::largeCornerRadius, Corners::largeCornerRadius, true, true, false, false);

auto toolbarBounds = Rectangle<float>(1, 1, getWidth() - 2, toolbarHeight);
g.fillRoundedRectangle(toolbarBounds, Corners::windowCornerRadius);
g.fillRect(toolbarBounds.withTrimmedTop(15.0f));
g.setColour(findColour(PlugDataColour::toolbarBackgroundColourId));
g.fillPath(p);

g.setColour(findColour(PlugDataColour::toolbarOutlineColourId));
g.drawHorizontalLine(toolbarHeight, 0.0f, getWidth());
Expand All @@ -168,7 +170,7 @@ class SettingsDialog : public Component {
AudioProcessor* processor;
ComponentBoundsConstrainer constrainer;

static constexpr int toolbarHeight = 42;
static constexpr int toolbarHeight = 40;

static inline std::atomic<int> lastPanel = 0;
int currentPanel;
Expand Down
1 change: 1 addition & 0 deletions Source/Heavy/DaisyExporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class DaisyExporter : public ExporterBase {
exportButton.setVisible(false);
addAndMakeVisible(flashButton);

flashButton.setColour(TextButton::buttonColourId, findColour(PlugDataColour::panelBackgroundColourId));
flashButton.setColour(TextButton::textColourOnId, findColour(TextButton::textColourOffId));

exportTypeValue.addListener(this);
Expand Down
2 changes: 2 additions & 0 deletions Source/Heavy/ExporterBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ struct ExporterBase : public Component
, editor(pluginEditor)
{
addAndMakeVisible(exportButton);

exportButton.setColour(TextButton::buttonColourId, findColour(PlugDataColour::panelBackgroundColourId));
exportButton.setColour(TextButton::textColourOnId, findColour(TextButton::textColourOffId));

Array<PropertiesPanel::Property*> properties;
Expand Down
50 changes: 43 additions & 7 deletions Source/Heavy/HeavyExportDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ExporterSettingsPanel : public Component
{
auto listboxBounds = getLocalBounds().removeFromLeft(listBoxWidth);

g.setColour(findColour(PlugDataColour::outlineColourId));
g.setColour(findColour(PlugDataColour::toolbarOutlineColourId));
g.drawLine(Line<float>(listboxBounds.getTopRight().toFloat(), listboxBounds.getBottomRight().toFloat()));
}

Expand Down Expand Up @@ -145,18 +145,31 @@ HeavyExportDialog::HeavyExportDialog(Dialog* dialog)
: exportingView(new ExportingProgressView())
, exporterPanel(new ExporterSettingsPanel(dynamic_cast<PluginEditor*>(dialog->parentComponent), exportingView.get()))
, installer(new ToolchainInstaller(dynamic_cast<PluginEditor*>(dialog->parentComponent)))
, infoButton(new TextButton(Icons::Help))
{

hasToolchain = Toolchain::dir.exists();

// Create integer versions by removing the dots
// Compare latest version on github to the currently installed version
auto const latestVersion = URL("https://raw.githubusercontent.com/plugdata-team/plugdata-heavy-toolchain/main/VERSION").readEntireTextStream().trim().removeCharacters(".").getIntValue();


// Don't do this relative to toolchain variable, that won't work on Windows
auto const versionFile = ProjectInfo::appDataDir.getChildFile("Toolchain").getChildFile("VERSION");
auto const installedVersion = versionFile.loadFileAsString().trim().removeCharacters(".").getIntValue();


// Create integer versions by removing the dots
// Compare latest version on github to the currently installed version
int latestVersion;
try {
auto compatTable = JSON::parse(URL("https://raw.githubusercontent.com/plugdata-team/plugdata-heavy-toolchain/main/COMPATIBILITY").readEntireTextStream());
// Get latest version

latestVersion = compatTable.getDynamicObject()->getProperty(String(ProjectInfo::versionString).upToFirstOccurrenceOf("-", false, false)).toString().removeCharacters(".").getIntValue();
}
// Network error, JSON error or empty version string somehow
catch (...) {
latestVersion = installedVersion;
return;
}

if (hasToolchain && latestVersion > installedVersion) {
installer->needsUpdate = true;
hasToolchain = false;
Expand All @@ -168,6 +181,12 @@ HeavyExportDialog::HeavyExportDialog(Dialog* dialog)

exportingView->setAlwaysOnTop(true);

infoButton->getProperties().set("Style", "LargeIcon");
infoButton->onClick = [](){
URL("https://wasted-audio.github.io/hvcc/docs/01.introduction.html#what-is-heavy").launchInDefaultBrowser();
};
addAndMakeVisible(*infoButton);

installer->toolchainInstalledCallback = [this]() {
hasToolchain = true;
exporterPanel->setVisible(true);
Expand All @@ -191,12 +210,29 @@ void HeavyExportDialog::paint(Graphics& g)
{
g.setColour(findColour(PlugDataColour::panelBackgroundColourId));
g.fillRoundedRectangle(getLocalBounds().toFloat(), Corners::windowCornerRadius);

auto titlebarBounds = getLocalBounds().removeFromTop(40);

Path p;
p.addRoundedRectangle(titlebarBounds.getX(), titlebarBounds.getY(), titlebarBounds.getWidth(), titlebarBounds.getHeight(), Corners::largeCornerRadius, Corners::largeCornerRadius, true, true, false, false);

g.setColour(findColour(PlugDataColour::toolbarBackgroundColourId));
g.fillPath(p);

Fonts::drawStyledText(g, "Compiler", Rectangle<float>(0.0f, 4.0f, getWidth(), 32.0f), findColour(PlugDataColour::panelTextColourId), Semibold, 15, Justification::centred);
}

void HeavyExportDialog::paintOverChildren(Graphics& g)
{
g.setColour(findColour(PlugDataColour::toolbarOutlineColourId));
g.drawHorizontalLine(40, 0.0f, getWidth());
}

void HeavyExportDialog::resized()
{
auto b = getLocalBounds();
auto b = getLocalBounds().withTrimmedTop(40);
exporterPanel->setBounds(b);
installer->setBounds(b);
exportingView->setBounds(b);
infoButton->setBounds(Rectangle<int>(40, 40));
}
4 changes: 3 additions & 1 deletion Source/Heavy/HeavyExportDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ class HeavyExportDialog : public Component {
std::unique_ptr<ExportingProgressView> exportingView;
std::unique_ptr<ToolchainInstaller> installer;
std::unique_ptr<ExporterSettingsPanel> exporterPanel;

std::unique_ptr<TextButton> infoButton;

public:
explicit HeavyExportDialog(Dialog* dialog);

~HeavyExportDialog() override;

void paint(Graphics& g) override;
void paintOverChildren(Graphics& g) override;

void resized() override;
};
4 changes: 2 additions & 2 deletions Source/Heavy/Toolchain.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ struct ToolchainInstaller : public Component
float downloadBarBgHeight = 11.0f;
float downloadBarHeight = downloadBarBgHeight - 3.0f;

auto downloadBarBg = Rectangle<float>(90.0f, 300.0f - (downloadBarBgHeight * 0.5), width, downloadBarBgHeight);
auto downloadBar = Rectangle<float>(91.5f, 300.0f - (downloadBarHeight * 0.5), progress, downloadBarHeight);
auto downloadBarBg = Rectangle<float>(90.0f, 250.0f - (downloadBarBgHeight * 0.5), width, downloadBarBgHeight);
auto downloadBar = Rectangle<float>(91.5f, 250.0f - (downloadBarHeight * 0.5), progress, downloadBarHeight);

g.setColour(findColour(PlugDataColour::panelTextColourId));
PlugDataLook::fillSmoothedRectangle(g, downloadBarBg, Corners::defaultCornerRadius);
Expand Down

0 comments on commit 20b5900

Please sign in to comment.