From 421dc838b6ac0b0c734bf7dd935eb8e2b35e1aba Mon Sep 17 00:00:00 2001 From: Alexander Lobas Date: Fri, 1 Apr 2016 12:46:36 +0300 Subject: [PATCH] IDEA-153807 Welcome screen notifications --- .../src/ide/notification/errorEvents.png | Bin 0 -> 241 bytes .../src/ide/notification/errorEvents@2x.png | Bin 0 -> 425 bytes .../icons/src/ide/notification/infoEvents.png | Bin 0 -> 241 bytes .../src/ide/notification/infoEvents@2x.png | Bin 0 -> 425 bytes .../icons/src/ide/notification/noEvents.png | Bin 0 -> 308 bytes .../src/ide/notification/noEvents@2x.png | Bin 0 -> 606 bytes .../src/ide/notification/warningEvents.png | Bin 0 -> 241 bytes .../src/ide/notification/warningEvents@2x.png | Bin 0 -> 425 bytes .../ide/actions/ActivateToolWindowAction.java | 2 +- .../impl/IdeNotificationArea.java | 48 ++++++++++++------ .../src/META-INF/PlatformExtensions.xml | 2 +- .../util/src/com/intellij/icons/AllIcons.java | 4 ++ 12 files changed, 39 insertions(+), 17 deletions(-) create mode 100644 platform/icons/src/ide/notification/errorEvents.png create mode 100644 platform/icons/src/ide/notification/errorEvents@2x.png create mode 100644 platform/icons/src/ide/notification/infoEvents.png create mode 100644 platform/icons/src/ide/notification/infoEvents@2x.png create mode 100644 platform/icons/src/ide/notification/noEvents.png create mode 100644 platform/icons/src/ide/notification/noEvents@2x.png create mode 100644 platform/icons/src/ide/notification/warningEvents.png create mode 100644 platform/icons/src/ide/notification/warningEvents@2x.png diff --git a/platform/icons/src/ide/notification/errorEvents.png b/platform/icons/src/ide/notification/errorEvents.png new file mode 100644 index 0000000000000000000000000000000000000000..8fe04b8971c0acb0e9dc0b7f82de9450bf5976ba GIT binary patch literal 241 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`J3L(+Ln>}1{|KIXs-Z=)@rG=N zIOE4yg@3F^%NHie1(+7to|yHt@rQuGfAt1_$E%AZ7O);!-*JKG@cIQ+2iOXjKiUeJ z95y%+eMfjY4kRe{+rDB*zS1jhTC1`pUzG{}oce3%%dKWB-F0C(cWiupWezb9Pu z@N@drFlRzS1Y-xkaOMGXg=a424AW-XOfH+T-Tt2XQq?3nM& oJHulYqrn-rBNrX^@El=hXjhmN`PruL9ncR9p00i_>zopr0OX!rIsgCw literal 0 HcmV?d00001 diff --git a/platform/icons/src/ide/notification/errorEvents@2x.png b/platform/icons/src/ide/notification/errorEvents@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..7450904c5d576a8e42b47e6540f9416891998697 GIT binary patch literal 425 zcmV;a0apHrP)#OHzdH4y)T;@40ykX$ZQEm7tYQosbnQ9yhgi2sv_k3;n`k?R0U zAihe5#pw7d)GVSMzzoFIK>V8umc#IGsF}=!9Ka65o2Y0pI^G1e1FHi-uG>gM%VBsU za!4RMpq37n!*D&i1GJ&piCzu>*`i9EP{R9H0!ue+R$;|3G$w98fU;mcwub z$N{?s&;h$Z4tP3%4tNT3z>fiRz>k4;!1sZUg8KuV2-gjCHcSIKKn+?b(A)BFKrAwl zMez*ex3GZ0ImSI6~qbU@ZXHb_7%XGVNYvduKK{2&ms5o(mO0C5kEaz-I3 z&2k4SHOo=*J-Ho|6I60Q7pV?F@0#U86VU}|cMOzue**C<||qUIN4)k-BNB^l|_)2IYSbAf61w{V;I=$6-kw Tsd7aH00000NkvXXu0mjfS6Ziz literal 0 HcmV?d00001 diff --git a/platform/icons/src/ide/notification/infoEvents.png b/platform/icons/src/ide/notification/infoEvents.png new file mode 100644 index 0000000000000000000000000000000000000000..3ce39c8359594aef447b7388a25537da89cd9b93 GIT binary patch literal 241 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`J3L(+Ln>}1Ygk2`YiN;dydm2m z&iFA_;UDYK@`Xuq0j34ECuTiu{2?IlU%i3f@#-Rp1*}KbcU<5(ynaE|0k#6>kG4W4 zhYe0d-%()ZIsp`BRbciDN;sf7f$_ek!2|Xa4e}xqA0`Ir&skz3z@2!pVm{B=?+F(@ z{G5I@%$bl7!PvnsoO!@p;hBp$!?c+;6OAtCEBxa+Qr_@GeU@U}4W0w-str2?JLWs{ o&hS{pXmEz@$VG=eJV)3WT#h70p7#OHzdH4y)T;@40ykX$ZQEm7tYQosbnQ9yhgi2sv_k3;n`k?R0U zAihe5#pw7d)GVSMzzoFIK>V8umc#IGsF}=!9Ka65o2Y0pI^G1e1FHi-uG>gM%VBsU za!4RMpq37n!*D&i1GJ&piCzu>*`i9EP{R9H0!ue+R$;|3G$w98fU;mcwub z$N{?s&;h$Z4tP3%4tNT3z>fiRz>k4;!1sZUg8KuV2-gjCHcSIKKn+?b(A)BFKrAwl zMez*ex3GZ0ImSI6~qbU@ZXHb_7%XGVNYvduKK{2&ms5o(mO0C5kEaz-I3 z&2k4SHOo=*J-Ho|6I60Q7pV?F@0#U86VU}|cMOzue**C<||qUIN4)k-BNB^l|_)2IYSbAf61w{V;I=SfGUt Tqg;NK00000NkvXXu0mjfuqUS$ literal 0 HcmV?d00001 diff --git a/platform/icons/src/ide/notification/noEvents.png b/platform/icons/src/ide/notification/noEvents.png new file mode 100644 index 0000000000000000000000000000000000000000..0cbeeed2a9fb06c34dfa092a44763238593f49fc GIT binary patch literal 308 zcmV-40n7f0P)wp6 zO@8TZbI!TF=iVyIvXqAb73hNvH?sMz%9wYKH#rRxSV9x>5TiWbEg6&c7bw6EI{q0x ze4)fR%y|}&88%>kN%S+hte8BsU=$$PHI!T#%%H4MKyv0XxIk2+Km@KbxM~(i!0DeQ zlqA<};!v}RZFd{D0k^RZYY2M}lEbetek2!R4_W_F&cGBF(10A98|MT`#>xG}T~MEn zYR&UA-Qf%?I6#m8#h7s_NYhf#rzUi`yn=QAkPo5OXGyI`&*d+0000AHiWS4W3e`}xy9BBb>!7>PfDv%9QNjCd}9CM@1J7TQ34S2yQcx8Z7 z&;tSvmMg$Hr;PE+nBJcZ_(6n|-oPaAIS@ASF~%EXMyL_ffVf-dz-v(V2Vs*s#{8g$ zHYZMiD;>@^Q$pAYP*BWtyMjSqla>sWq?Xf^rrOZYQI5 zir<4AGaZj>>A1`V@k%Wn57;h9^0b0PD(9r{O0tcAEXfr8jJa*bi#0d}OmnBoq!ZBX zuqgei1{iiyme+q#miKC9xtC8QziUAsXo(SPQJwqWUQG5JUP=}~x)x`G{Zmd2m{+qQ zZlXh8$K>cfgG;avRwcnu>>PA*NgLRA{1*f9Qfge~&iDpY)~$BifLgjPKC!txOEwJX sMjE+!@3d=Lp)CXEHLaOPaz^!k0%{+Ppmw@TiU0rr07*qoM6N<$g63ii^8f$< literal 0 HcmV?d00001 diff --git a/platform/icons/src/ide/notification/warningEvents.png b/platform/icons/src/ide/notification/warningEvents.png new file mode 100644 index 0000000000000000000000000000000000000000..7a26967479337954b405db0bfd553043fc01167f GIT binary patch literal 241 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`J3L(+Ln>}1|0vezW8^eu+Gs7H z&-7@w!yoRh_fAJ`7GyoBnqYdG`J@IGLBRIQTH zmN;Si4o5bT2|!_P2evs&4m1QSFz*XaIKV%F(O$#gf%4Kg3(rgiu|tbK+DXoOe{j*n zIW1opEfo)LU=om5yVQ{HaHcblLC3gKDRtR>hd-hn?-@S&n>g>;Albn0%}}T;VBaof nFfoKVVFqu<;>HTe4t|DxF_$B!TMNDd`hmgI)z4*}Q$iB}Q&Ltd literal 0 HcmV?d00001 diff --git a/platform/icons/src/ide/notification/warningEvents@2x.png b/platform/icons/src/ide/notification/warningEvents@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..acd4f27c739e3e78b55b70936554914ad8c48bd8 GIT binary patch literal 425 zcmV;a0apHrP)azU-ZjgGCZY?_?ieWR{siJzKzs&>SA!}TJPx={i35nm z+620CrnGhdEb8K*K1O%IB6>Ig*&!}Kyab3pB6ZVL>E!@q49fo=Ks*_U`(fe$AWuy! TPyzjq00000NkvXXu0mjfuj#Fr literal 0 HcmV?d00001 diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ActivateToolWindowAction.java b/platform/platform-impl/src/com/intellij/ide/actions/ActivateToolWindowAction.java index 8a6b478b2a0d..4dfa4e525c1c 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/ActivateToolWindowAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/ActivateToolWindowAction.java @@ -97,7 +97,7 @@ public class ActivateToolWindowAction extends DumbAwareAction { presentation.setDescription(IdeBundle.message("action.activate.tool.window", title)); Icon icon = toolWindow.getIcon(); if (EventLog.LOG_TOOL_WINDOW_ID.equals(myToolWindowId)) { - icon = AllIcons.Ide.Info_notifications; + icon = AllIcons.Ide.Notification.InfoEvents; } presentation.setIcon(icon == null ? null : new SizedIcon(icon, icon.getIconHeight(), icon.getIconHeight())); } diff --git a/platform/platform-impl/src/com/intellij/notification/impl/IdeNotificationArea.java b/platform/platform-impl/src/com/intellij/notification/impl/IdeNotificationArea.java index 7c4b5efa078d..021646b39ba6 100644 --- a/platform/platform-impl/src/com/intellij/notification/impl/IdeNotificationArea.java +++ b/platform/platform-impl/src/com/intellij/notification/impl/IdeNotificationArea.java @@ -26,13 +26,13 @@ import com.intellij.notification.NotificationType; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.wm.CustomStatusBarWidget; import com.intellij.openapi.wm.IconLikeCustomStatusBarWidget; import com.intellij.openapi.wm.StatusBar; import com.intellij.openapi.wm.ToolWindow; import com.intellij.ui.ClickListener; import com.intellij.ui.LayeredIcon; -import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -91,7 +91,7 @@ public class IdeNotificationArea extends JLabel implements CustomStatusBarWidget @Nullable private Project getProject() { - return CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext((Component) myStatusBar)); + return CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext((Component)myStatusBar)); } @NotNull @@ -126,10 +126,14 @@ public class IdeNotificationArea extends JLabel implements CustomStatusBarWidget private LayeredIcon createIconWithNotificationCount(ArrayList notifications) { LayeredIcon icon = new LayeredIcon(2); - Icon statusIcon = getPendingNotificationsIcon(AllIcons.Ide.Notifications, getMaximumType(notifications)); + NotificationType type = getMaximumType(notifications); + Icon statusIcon = getPendingNotificationsIcon(AllIcons.Ide.Notification.NoEvents, type); icon.setIcon(statusIcon, 0); - if (notifications.size() > 0) { - icon.setIcon(new TextIcon(this, String.valueOf(notifications.size())), 1, statusIcon.getIconWidth() - 2, 0); + int size = notifications.size(); + if (size > 0) { + //noinspection UseJBColor + Color textColor = type == NotificationType.ERROR ? Color.white : Color.black; + icon.setIcon(new TextIcon(this, size < 10 ? String.valueOf(size) : "9+", textColor), 1); } return icon; } @@ -142,9 +146,12 @@ public class IdeNotificationArea extends JLabel implements CustomStatusBarWidget private static Icon getPendingNotificationsIcon(Icon defIcon, final NotificationType maximumType) { if (maximumType != null) { switch (maximumType) { - case WARNING: return AllIcons.Ide.Warning_notifications; - case ERROR: return AllIcons.Ide.Error_notifications; - case INFORMATION: return AllIcons.Ide.Info_notifications; + case WARNING: + return AllIcons.Ide.Notification.WarningEvents; + case ERROR: + return AllIcons.Ide.Notification.ErrorEvents; + case INFORMATION: + return AllIcons.Ide.Notification.InfoEvents; } } return defIcon; @@ -172,12 +179,14 @@ public class IdeNotificationArea extends JLabel implements CustomStatusBarWidget private static class TextIcon implements Icon { private final String myStr; private final JComponent myComponent; + private final Color myTextColor; private final int myWidth; - public TextIcon(JComponent component, @NotNull String str) { + public TextIcon(JComponent component, @NotNull String str, @NotNull Color textColor) { myStr = str; myComponent = component; - myWidth = myComponent.getFontMetrics(calcFont()).stringWidth(myStr) + 1; + myTextColor = textColor; + myWidth = myComponent.getFontMetrics(calcFont()).stringWidth(myStr); } @Override @@ -209,9 +218,14 @@ public class IdeNotificationArea extends JLabel implements CustomStatusBarWidget Font originalFont = g.getFont(); Color originalColor = g.getColor(); g.setFont(calcFont()); - y += getIconHeight() - g.getFontMetrics().getDescent(); - g.setColor(UIUtil.getLabelForeground()); + x += (getIconWidth() - myWidth) / 2; + y += getIconHeight() / 2 + g.getFontMetrics().getDescent(); + if (!SystemInfo.isLinux && myStr.length() > 1) { + x++; + } + + g.setColor(myTextColor); g.drawString(myStr, x, y); g.setFont(originalFont); @@ -219,17 +233,21 @@ public class IdeNotificationArea extends JLabel implements CustomStatusBarWidget } private Font calcFont() { - return myComponent.getFont().deriveFont(Font.BOLD).deriveFont((float) getIconHeight() * 3 / 5); + float size = (float)getIconHeight() * 3 / 5; + if (myStr.length() > 1) { + size--; + } + return myComponent.getFont().deriveFont(size); } @Override public int getIconWidth() { - return myWidth; + return AllIcons.Ide.Notification.NoEvents.getIconWidth(); } @Override public int getIconHeight() { - return AllIcons.Ide.Notifications.getIconHeight(); + return AllIcons.Ide.Notification.NoEvents.getIconHeight(); } } } diff --git a/platform/platform-resources/src/META-INF/PlatformExtensions.xml b/platform/platform-resources/src/META-INF/PlatformExtensions.xml index 44e4a5f7dde2..d18f378ebb69 100644 --- a/platform/platform-resources/src/META-INF/PlatformExtensions.xml +++ b/platform/platform-resources/src/META-INF/PlatformExtensions.xml @@ -355,7 +355,7 @@