Skip to content

Commit

Permalink
[viewer] Match icon colour to labels
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiashienzsch committed Oct 24, 2023
1 parent c6c859e commit a1d9e5a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 20 deletions.
36 changes: 19 additions & 17 deletions tools/jml-viewer/Application/MenuBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ auto MenuBar::getMenuForIndex(int menuIndex, juce::String const& /*menuName*/) -
{
using IDs = CommandIDs;

auto* cmd = &_commands;
auto const index = static_cast<MenuIndex>(menuIndex);
auto* cmd = &_commands;
auto const index = static_cast<MenuIndex>(menuIndex);
auto const iconColor = getLookAndFeel().findColour(juce::PopupMenu::textColourId);
auto const icon = [iconColor](auto const* name) { return getIcon(name, iconColor); };

if (index == MenuIndex::File) {
auto files = juce::PopupMenu{};
Expand All @@ -45,36 +47,36 @@ auto MenuBar::getMenuForIndex(int menuIndex, juce::String const& /*menuName*/) -
files.addItem("Clear", [] { getApplicationSettings().clearRecentFiles(); });

auto menu = juce::PopupMenu{};
menu.addCommandItem(cmd, IDs::open, "Open", getIcon("launch_black_48dp_svg"));
menu.addCommandItem(cmd, IDs::reload, "Reload", getIcon("autorenew_black_48dp_svg"));
menu.addSubMenu("Recent Files", files, true, getIcon("restore_black_48dp_svg"));
menu.addCommandItem(cmd, IDs::open, "Open", icon("launch_black_48dp_svg"));
menu.addCommandItem(cmd, IDs::reload, "Reload", icon("autorenew_black_48dp_svg"));
menu.addSubMenu("Recent Files", files, true, icon("restore_black_48dp_svg"));
menu.addSeparator();
menu.addCommandItem(cmd, IDs::save, "Save", getIcon("save_black_48dp_svg"));
menu.addCommandItem(cmd, IDs::saveAs, "Save As", getIcon("save_as_black_48dp_svg"));
menu.addCommandItem(cmd, IDs::save, "Save", icon("save_black_48dp_svg"));
menu.addCommandItem(cmd, IDs::saveAs, "Save As", icon("save_as_black_48dp_svg"));
menu.addSeparator();
menu.addCommandItem(cmd, IDs::settings, "Settings", getIcon("settings_black_48dp_svg"));
menu.addCommandItem(cmd, IDs::settings, "Settings", icon("settings_black_48dp_svg"));
menu.addSeparator();
menu.addCommandItem(cmd, IDs::quit, "Quit", getIcon("close_black_48dp_svg"));
menu.addCommandItem(cmd, IDs::quit, "Quit", icon("close_black_48dp_svg"));
return menu;
}

if (index == MenuIndex::Edit) {
auto menu = juce::PopupMenu{};
menu.addCommandItem(cmd, IDs::undo, "Undo", getIcon("undo_black_48dp_svg"));
menu.addCommandItem(cmd, IDs::redo, "Redo", getIcon("redo_black_48dp_svg"));
menu.addCommandItem(cmd, IDs::undo, "Undo", icon("undo_black_48dp_svg"));
menu.addCommandItem(cmd, IDs::redo, "Redo", icon("redo_black_48dp_svg"));
menu.addSeparator();
menu.addCommandItem(cmd, IDs::cut, "Cut", getIcon("content_cut_black_48dp_svg"));
menu.addCommandItem(cmd, IDs::copy, "Copy", getIcon("content_copy_black_48dp_svg"));
menu.addCommandItem(cmd, IDs::paste, "Paste", getIcon("content_paste_black_48dp_svg"));
menu.addCommandItem(cmd, IDs::cut, "Cut", icon("content_cut_black_48dp_svg"));
menu.addCommandItem(cmd, IDs::copy, "Copy", icon("content_copy_black_48dp_svg"));
menu.addCommandItem(cmd, IDs::paste, "Paste", icon("content_paste_black_48dp_svg"));
menu.addSeparator();
menu.addCommandItem(cmd, IDs::selectAll, "Select All", getIcon("select_all_black_48dp_svg"));
menu.addCommandItem(cmd, IDs::deselectAll, "Deselect", getIcon("deselect_black_48dp_svg"));
menu.addCommandItem(cmd, IDs::selectAll, "Select All", icon("select_all_black_48dp_svg"));
menu.addCommandItem(cmd, IDs::deselectAll, "Deselect", icon("deselect_black_48dp_svg"));
return menu;
}

if (index == MenuIndex::Help) {
auto menu = juce::PopupMenu{};
menu.addCommandItem(cmd, IDs::about, "About", getIcon("info_black_48dp_svg"));
menu.addCommandItem(cmd, IDs::about, "About", icon("info_black_48dp_svg"));
return menu;
}

Expand Down
9 changes: 6 additions & 3 deletions tools/jml-viewer/Viewer/ScriptPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,13 @@ auto MultiScriptPanel::paint(juce::Graphics& g) -> void

auto area = getLocalBounds().reduced(proportionOfWidth(0.25F), proportionOfHeight(0.25F));

auto const iconArea = area.removeFromTop(area.proportionOfHeight(0.5));
auto const text = juce::String{R"(Drop lua script or go to File -> Open)"};
auto const iconColor = getLookAndFeel().findColour(juce::PopupMenu::textColourId);
auto const iconArea = area.removeFromTop(area.proportionOfHeight(0.5));
auto const text = juce::String{R"(Drop lua script or go to File -> Open)"};

_openIcon->drawWithin(g, iconArea.toFloat(), juce::RectanglePlacement::centred, 1.0);
auto icon = _openIcon->createCopy();
icon->replaceColour(juce::Colours::black, iconColor);
icon->drawWithin(g, iconArea.toFloat(), juce::RectanglePlacement::centred, 1.0);
g.setColour(getSchemeDefaultTextColour());
g.setFont(32.0F);
g.drawText(text, area, juce::Justification::centred, false);
Expand Down
7 changes: 7 additions & 0 deletions tools/jml_tools/graphics/Drawable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,11 @@ auto getIcon(char const* name) -> std::unique_ptr<juce::Drawable>
return svg;
}

auto getIcon(char const* name, juce::Colour colour) -> std::unique_ptr<juce::Drawable>
{
auto icon = getIcon(name);
icon->replaceColour(juce::Colours::black, colour);
return icon;
}

} // namespace jml
1 change: 1 addition & 0 deletions tools/jml_tools/graphics/Drawable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
namespace jml {

[[nodiscard]] auto getIcon(char const* name) -> std::unique_ptr<juce::Drawable>;
[[nodiscard]] auto getIcon(char const* name, juce::Colour colour) -> std::unique_ptr<juce::Drawable>;

} // namespace jml

0 comments on commit a1d9e5a

Please sign in to comment.