@@ -727,7 +727,7 @@ void CustomLookAndFeel::drawMenuBarBackground (Graphics& g, int width, int heigh
727727
728728 if (menuBar.getName ().equalsIgnoreCase (" MainMenu" ))
729729 {
730- g.setColour (findColour (ThemeColours::defaultText));
730+ g.setColour (findColour (ThemeColours::defaultText). withAlpha (menuBar. isEnabled () ? 1 . 0f : 0 . 5f ) );
731731 String ver = " v" + String (ProjectInfo::versionString);
732732 g.setFont (getCommonMenuFont ());
733733 int verStrWidth = GlyphArrangement::getStringWidthInt (getCommonMenuFont (), ver);
@@ -960,7 +960,7 @@ class CustomDocumentWindowButton : public Button
960960
961961 void paintButton (Graphics& g, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override
962962 {
963- auto pathColour = findColour (ThemeColours::controlPanelText);
963+ auto pathColour = findColour (ThemeColours::controlPanelText). withAlpha ( isEnabled () ? 1 . 0f : 0 . 5f ) ;
964964
965965 // g.fillAll (background);
966966
@@ -1117,6 +1117,110 @@ void CustomLookAndFeel::drawDocumentWindowTitleBar (DocumentWindow& window, Grap
11171117 g.drawText (window.getName (), textX, 0 , textW, h, Justification::centredLeft, true );
11181118}
11191119
1120+ // ==================================================================
1121+ // ALERT WINDOW METHODS :
1122+ // ==================================================================
1123+
1124+ AlertWindow* CustomLookAndFeel::createAlertWindow (const String& title,
1125+ const String& message,
1126+ const String& button1,
1127+ const String& button2,
1128+ const String& button3,
1129+ MessageBoxIconType iconType,
1130+ int numButtons,
1131+ Component* associatedComponent)
1132+ {
1133+ auto boundsOffset = 20 ;
1134+
1135+ auto * aw = LookAndFeel_V2::createAlertWindow (title, message, button1, button2, button3, iconType, numButtons, associatedComponent);
1136+
1137+ auto bounds = aw->getBounds ();
1138+ bounds = bounds.withSizeKeepingCentre (bounds.getWidth () + boundsOffset, bounds.getHeight () + boundsOffset);
1139+ aw->setBounds (bounds);
1140+
1141+ for (auto * child : aw->getChildren ())
1142+ if (auto * button = dynamic_cast <TextButton*> (child))
1143+ button->setBounds (button->getBounds () + Point<int > (10 , 10 ));
1144+
1145+ return aw;
1146+ }
1147+
1148+ void CustomLookAndFeel::drawAlertBox (Graphics& g, AlertWindow& alert, const Rectangle<int >& textArea, TextLayout& textLayout)
1149+ {
1150+ auto cornerSize = 0 .0f ;
1151+
1152+ g.setColour (alert.findColour (AlertWindow::outlineColourId));
1153+ g.drawRoundedRectangle (alert.getLocalBounds ().toFloat (), cornerSize, 2 .0f );
1154+
1155+ auto bounds = alert.getLocalBounds ().reduced (1 );
1156+ g.reduceClipRegion (bounds);
1157+
1158+ g.setColour (alert.findColour (AlertWindow::backgroundColourId));
1159+ g.fillRoundedRectangle (bounds.toFloat (), cornerSize);
1160+
1161+ auto iconSpaceUsed = 0 ;
1162+
1163+ auto iconWidth = 50 ;
1164+ auto iconSize = jmin (iconWidth, bounds.getHeight ());
1165+
1166+ if (alert.containsAnyExtraComponents () || alert.getNumButtons () > 2 )
1167+ iconSize = jmin (iconSize, textArea.getHeight () + 50 );
1168+
1169+ juce::Rectangle<int > iconRect (10 , 30 , iconSize, iconSize);
1170+
1171+ if (alert.getAlertType () != MessageBoxIconType::NoIcon)
1172+ {
1173+ Path icon;
1174+ char character;
1175+ Colour colour;
1176+
1177+ if (alert.getAlertType () == MessageBoxIconType::WarningIcon)
1178+ {
1179+ character = ' !' ;
1180+
1181+ icon.addTriangle ((float ) iconRect.getX () + (float ) iconRect.getWidth () * 0 .5f ,
1182+ (float ) iconRect.getY (),
1183+ static_cast <float > (iconRect.getRight ()),
1184+ static_cast <float > (iconRect.getBottom ()),
1185+ static_cast <float > (iconRect.getX ()),
1186+ static_cast <float > (iconRect.getBottom ()));
1187+
1188+ icon = icon.createPathWithRoundedCorners (5 .0f );
1189+ colour = findColour (ProcessorColour::SOURCE_COLOUR);
1190+ }
1191+ else
1192+ {
1193+ colour = findColour (ProcessorColour::FILTER_COLOUR);
1194+ character = alert.getAlertType () == MessageBoxIconType::InfoIcon ? ' i' : ' ?' ;
1195+
1196+ icon.addEllipse (iconRect.toFloat ());
1197+ }
1198+
1199+ GlyphArrangement ga;
1200+ ga.addFittedText (withDefaultMetrics (FontOptions { (float ) iconRect.getHeight () * 0 .9f , Font::bold }),
1201+ String::charToString ((juce_wchar) (uint8) character),
1202+ static_cast <float > (iconRect.getX ()),
1203+ static_cast <float > (iconRect.getY ()),
1204+ static_cast <float > (iconRect.getWidth ()),
1205+ static_cast <float > (iconRect.getHeight ()),
1206+ Justification::centred,
1207+ 1 );
1208+
1209+ g.setColour (Colour (colour));
1210+ g.fillPath (icon);
1211+
1212+ g.setColour (Colours::white);
1213+ ga.draw (g);
1214+
1215+ iconSpaceUsed = iconWidth + 20 ;
1216+ }
1217+
1218+ juce::Rectangle<int > alertBounds (bounds.getX () + iconSpaceUsed, 30 , bounds.getWidth () - iconSpaceUsed, bounds.getHeight () - getAlertWindowButtonHeight () - 50 );
1219+
1220+ g.setColour (alert.findColour (AlertWindow::textColourId));
1221+ textLayout.draw (g, alertBounds.toFloat ());
1222+ }
1223+
11201224int CustomLookAndFeel::getAlertWindowButtonHeight () { return 30 ; }
11211225Font CustomLookAndFeel::getAlertWindowTitleFont () { return FontOptions { " Inter" , " Bold" , 20 .f }; }
11221226Font CustomLookAndFeel::getAlertWindowMessageFont () { return FontOptions { " Inter" , " Medium" , 18 .f }; }
0 commit comments