Skip to content

Commit 2bfbd22

Browse files
committed
Add update indicator icon in PluginInstaller
1 parent 7f1924d commit 2bfbd22

1 file changed

Lines changed: 37 additions & 22 deletions

File tree

Source/UI/PluginInstaller.cpp

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -583,10 +583,20 @@ const Path& getRemoveIconPath()
583583

584584
const Path& getDocsIconPath()
585585
{
586-
static const auto path = createSvgPath ({ "M14 3v4a1 1 0 0 0 1 1h4",
587-
"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2",
588-
"M11 14h1v4h1",
589-
"M12 11h.01" });
586+
static const auto path = createSvgPath ({ "M4 8h16",
587+
"M12.5 20h-6.5a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v7",
588+
"M8 4v4",
589+
"M16 22l5 -5",
590+
"M21 21.5v-4.5h-4.5" });
591+
592+
return path;
593+
}
594+
595+
const Path& getUpdateIndicatorPath()
596+
{
597+
static const auto path = createSvgPath ({ "M16 12l-4 -4l-4 4",
598+
"M12 16v-8",
599+
"M12 3c7.2 0 9 1.8 9 9c0 7.2 -1.8 9 -9 9c-7.2 0 -9 -1.8 -9 -9c0 -7.2 1.8 -9 9 -9" });
590600

591601
return path;
592602
}
@@ -633,10 +643,10 @@ class PluginIconButton : public Button
633643
outline = outline.withAlpha (0.42f);
634644

635645
g.setColour (background);
636-
g.fillRoundedRectangle (bounds, 6.0f);
646+
g.fillRoundedRectangle (bounds, 4.0f);
637647

638648
g.setColour (outline);
639-
g.drawRoundedRectangle (bounds, 6.0f, 1.0f);
649+
g.drawRoundedRectangle (bounds, 4.0f, 1.0f);
640650

641651
auto iconBounds = bounds.reduced (7.0f);
642652
const auto& iconPath = icon == IconType::install ? getInstallIconPath()
@@ -683,7 +693,6 @@ class PluginVersionCell : public Component
683693
versionMenu.setSelectedId (selectedIndex + 1, dontSendNotification);
684694

685695
versionMenu.setEnabled (! pluginInfo.versions.isEmpty());
686-
versionMenu.setTooltip (selectedVersion);
687696
}
688697

689698
void resized() override
@@ -778,11 +787,11 @@ PluginInstallerComponent::PluginInstallerComponent()
778787
addAndMakeVisible (installedButton.get());
779788

780789
updatesButton = std::make_unique<ShapeButton> ("Refresh Plugins",
781-
Colours::transparentBlack,
782-
Colours::transparentBlack,
783-
Colours::transparentBlack);
790+
Colours::transparentBlack,
791+
Colours::transparentBlack,
792+
Colours::transparentBlack);
784793
String reloadIconPath = "M19.933 13.041a8 8 0 1 1 -9.925 -8.788c3.899 -1 7.935 1.007 9.425 4.747 M20 4v5h-5";
785-
updatesButton->setShape (Drawable::parseSVGPath (reloadIconPath).createPathWithRoundedCorners(2.0f), true, true, false);
794+
updatesButton->setShape (Drawable::parseSVGPath (reloadIconPath).createPathWithRoundedCorners (2.0f), true, true, false);
786795
updatesButton->setOutline (findColour (ThemeColours::defaultText), 2.0f);
787796
updatesButton->setMouseCursor (MouseCursor::PointingHandCursor);
788797
updatesButton->setTooltip ("Refresh Plugins");
@@ -933,12 +942,6 @@ void PluginListBoxComponent::paintRowBackground (Graphics& g, int rowNumber, int
933942

934943
g.fillAll (background);
935944

936-
if (pluginInfo->hasUpdate)
937-
{
938-
g.setColour (Colours::green.withAlpha (0.8f));
939-
g.fillRect (0, 0, 4, height);
940-
}
941-
942945
g.setColour (findColour (ThemeColours::defaultText).withAlpha (0.08f));
943946
g.fillRect (0, height - 1, width, 1);
944947
}
@@ -956,7 +959,6 @@ void PluginListBoxComponent::paintCell (Graphics& g,
956959
if (pluginInfo == nullptr)
957960
return;
958961

959-
g.setColour (findColour (ThemeColours::defaultText));
960962
g.setFont (tableFont);
961963

962964
juce::Rectangle<int> textBounds (5, 0, width - 10, height);
@@ -966,7 +968,18 @@ void PluginListBoxComponent::paintCell (Graphics& g,
966968
{
967969
case displayNameColumn:
968970
g.setFont (headerFont);
971+
textBounds.removeFromLeft (5);
969972
text = pluginInfo->displayName;
973+
if (pluginInfo->hasUpdate)
974+
{
975+
auto nameWidth = GlyphArrangement::getStringWidthInt (Font (headerFont), pluginInfo->displayName);
976+
auto updateIndicatorBounds = Rectangle<int> (textBounds.getX() + nameWidth + 6, textBounds.getCentreY() - 7, 14, 14);
977+
auto transform = getUpdateIndicatorPath().getTransformToScaleToFit (updateIndicatorBounds.toFloat(), true);
978+
g.setColour (findColour (ThemeColours::widgetBackground));
979+
g.fillPath (getUpdateIndicatorPath(), transform);
980+
g.setColour (Colours::green);
981+
g.strokePath (getUpdateIndicatorPath(), PathStrokeType (1.5f, PathStrokeType::curved, PathStrokeType::rounded), transform);
982+
}
970983
break;
971984

972985
case typeColumn:
@@ -997,6 +1010,7 @@ void PluginListBoxComponent::paintCell (Graphics& g,
9971010
return;
9981011
}
9991012

1013+
g.setColour (findColour (ThemeColours::defaultText));
10001014
g.drawText (text.isNotEmpty() ? text : String ("-"), textBounds, Justification::centredLeft, true);
10011015
}
10021016

@@ -1060,7 +1074,7 @@ Component* PluginListBoxComponent::refreshComponentForCell (int rowNumber,
10601074
{
10611075
actionCell->update (getInstallActionLabel (*pluginInfo),
10621076
canInstallPlugin (*pluginInfo),
1063-
"Install the selected plugin version",
1077+
"",
10641078
[this, rowNumber]
10651079
{
10661080
installPluginForRow (rowNumber);
@@ -1070,7 +1084,7 @@ Component* PluginListBoxComponent::refreshComponentForCell (int rowNumber,
10701084
{
10711085
actionCell->update ("Remove",
10721086
pluginInfo->installedVersion.isNotEmpty(),
1073-
"Uninstall the currently installed version",
1087+
"",
10741088
[this, rowNumber]
10751089
{
10761090
uninstallPluginForRow (rowNumber);
@@ -1124,7 +1138,8 @@ int PluginListBoxComponent::getColumnAutoSizeWidth (int columnId)
11241138
auto maxWidth = GlyphArrangement::getStringWidthInt (Font (headerFont), pluginTable->getHeader().getColumnName (displayNameColumn));
11251139

11261140
for (const auto& pluginInfo : allPlugins)
1127-
maxWidth = jmax (maxWidth, GlyphArrangement::getStringWidthInt (Font (headerFont), pluginInfo.displayName));
1141+
maxWidth = jmax (maxWidth,
1142+
GlyphArrangement::getStringWidthInt (Font (headerFont), pluginInfo.displayName) + (pluginInfo.hasUpdate ? 20 : 0));
11281143

11291144
return maxWidth + 28;
11301145
}
@@ -1293,7 +1308,7 @@ void PluginListBoxComponent::setSelectedVersion (int rowNumber, const String& ve
12931308
if (auto* pluginInfo = getPluginForVisibleRow (rowNumber))
12941309
{
12951310
pluginInfo->selectedVersion = version;
1296-
pluginTable->repaintRow (rowNumber);
1311+
pluginTable->updateContent();
12971312
}
12981313
}
12991314

0 commit comments

Comments
 (0)