|
25 | 25 | package com.github.strangelookingnerd;
|
26 | 26 |
|
27 | 27 | import com.intellij.openapi.progress.util.ColorProgressBar;
|
28 |
| -import com.intellij.ui.Gray; |
29 |
| -import com.intellij.ui.JBColor; |
30 | 28 | import com.intellij.ui.scale.JBUIScale;
|
31 | 29 | import com.intellij.util.ui.JBInsets;
|
| 30 | +import com.intellij.util.ui.JBUI; |
32 | 31 | import com.intellij.util.ui.UIUtilities;
|
33 | 32 |
|
34 | 33 | import javax.swing.ImageIcon;
|
|
57 | 56 | */
|
58 | 57 | public class PedroProgressBarUI extends BasicProgressBarUI {
|
59 | 58 |
|
60 |
| - private static final Color TRACK_COLOR = JBColor.namedColor("ProgressBar.trackColor", |
61 |
| - new JBColor(Gray.xC4, Gray.x55)); |
62 |
| - private static final Color PROGRESS_COLOR = JBColor.namedColor("ProgressBar.progressColor", |
63 |
| - new JBColor(Gray.x80, Gray.xA0)); |
64 |
| - private static final Color INDETERMINATE_START_COLOR = JBColor.namedColor("ProgressBar.indeterminateStartColor", |
65 |
| - new JBColor(Gray.xC4, Gray.x69)); |
66 |
| - private static final Color INDETERMINATE_END_COLOR = JBColor.namedColor("ProgressBar.indeterminateEndColor", |
67 |
| - new JBColor(Gray.x80, Gray.x83)); |
68 |
| - |
69 |
| - private static final Color FAILED_COLOR = JBColor.namedColor("ProgressBar.failedColor", |
70 |
| - new JBColor(0xd64f4f, 0xe74848)); |
71 |
| - private static final Color FAILED_END_COLOR = JBColor.namedColor("ProgressBar.failedEndColor", |
72 |
| - new JBColor(0xfb8f89, 0xf4a2a0)); |
73 |
| - private static final Color PASSED_COLOR = JBColor.namedColor("ProgressBar.passedColor", |
74 |
| - new JBColor(0x34b171, 0x008f50)); |
75 |
| - private static final Color PASSED_END_COLOR = JBColor.namedColor("ProgressBar.passedEndColor", |
76 |
| - new JBColor(0x7ee8a5, 0x5dc48f)); |
77 |
| - private static final Color WARNING_COLOR = JBColor.namedColor("ProgressBar.warningColor", |
78 |
| - new JBColor(0xF0A732, 0xD9A343)); |
79 |
| - private static final Color WARNING_END_COLOR = JBColor.namedColor("ProgressBar.warningEndColor", |
80 |
| - new JBColor(0xEAD2A1, 0xEAD2A1)); |
81 |
| - |
82 | 59 | private static final int CYCLE_TIME_DEFAULT = 800;
|
83 | 60 | private static final int REPAINT_INTERVAL_DEFAULT = 50;
|
84 | 61 |
|
@@ -114,25 +91,24 @@ protected void paintIndeterminate(Graphics graphics, JComponent component) {
|
114 | 91 | JBInsets.removeFrom(r, i);
|
115 | 92 | int orientation = progressBar.getOrientation();
|
116 | 93 |
|
117 |
| - // Use foreground color as a reference, don't use it directly. This is done for compatibility reason. |
118 |
| - // Colors are hardcoded in UI delegates by design. If more colors are needed contact designers. |
119 | 94 | Color startColor;
|
120 | 95 | Color endColor;
|
121 | 96 | Color foreground = progressBar.getForeground();
|
122 |
| - if (foreground == ColorProgressBar.RED) { |
123 |
| - startColor = FAILED_COLOR; |
124 |
| - endColor = FAILED_END_COLOR; |
125 |
| - } else if (foreground == ColorProgressBar.GREEN) { |
126 |
| - startColor = PASSED_COLOR; |
127 |
| - endColor = PASSED_END_COLOR; |
128 |
| - } else if (foreground == ColorProgressBar.YELLOW) { |
129 |
| - startColor = WARNING_COLOR; |
130 |
| - endColor = WARNING_END_COLOR; |
| 97 | + Object statusProperty = progressBar.getClientProperty(JBUI.CurrentTheme.ProgressBar.statusKey()); |
| 98 | + if (JBUI.CurrentTheme.ProgressBar.failedStatusValue().equals(statusProperty) || foreground == ColorProgressBar.RED) { |
| 99 | + startColor = JBUI.CurrentTheme.ProgressBar.FAILED; |
| 100 | + endColor = JBUI.CurrentTheme.ProgressBar.FAILED_END; |
| 101 | + } else if (JBUI.CurrentTheme.ProgressBar.passedStatusValue().equals(statusProperty) || foreground == ColorProgressBar.GREEN) { |
| 102 | + startColor = JBUI.CurrentTheme.ProgressBar.PASSED; |
| 103 | + endColor = JBUI.CurrentTheme.ProgressBar.PASSED_END; |
| 104 | + } else if (JBUI.CurrentTheme.ProgressBar.warningStatusValue().equals(statusProperty) || foreground == ColorProgressBar.YELLOW) { |
| 105 | + startColor = JBUI.CurrentTheme.ProgressBar.WARNING; |
| 106 | + endColor = JBUI.CurrentTheme.ProgressBar.WARNING_END; |
131 | 107 | } else {
|
132 | 108 | startColor = progressBar.getClientProperty("ProgressBar.indeterminateStartColor") instanceof Color color ?
|
133 |
| - color : INDETERMINATE_START_COLOR; |
| 109 | + color : JBUI.CurrentTheme.ProgressBar.INDETERMINATE_START; |
134 | 110 | endColor = progressBar.getClientProperty("ProgressBar.indeterminateEndColor") instanceof Color color ?
|
135 |
| - color : INDETERMINATE_END_COLOR; |
| 111 | + color : JBUI.CurrentTheme.ProgressBar.INDETERMINATE_END; |
136 | 112 | }
|
137 | 113 |
|
138 | 114 | Shape shape;
|
@@ -207,20 +183,19 @@ protected void paintDeterminate(Graphics graphics, JComponent component) {
|
207 | 183 | fullShape = getShapedRect(xOffset, r.y, pWidth, r.height, pWidth);
|
208 | 184 | coloredShape = getShapedRect(xOffset, r.y, pWidth, amountFull, pWidth);
|
209 | 185 | }
|
210 |
| - graphics2D.setColor(TRACK_COLOR); |
| 186 | + graphics2D.setColor(JBUI.CurrentTheme.ProgressBar.TRACK); |
211 | 187 | graphics2D.fill(fullShape);
|
212 | 188 |
|
213 |
| - // Use foreground color as a reference, don't use it directly. This is done for compatibility reason. |
214 |
| - // Colors are hardcoded in UI delegates by design. If more colors are needed contact designers. |
215 | 189 | Color foreground = progressBar.getForeground();
|
216 |
| - if (foreground == ColorProgressBar.RED) { |
217 |
| - graphics2D.setColor(FAILED_COLOR); |
218 |
| - } else if (foreground == ColorProgressBar.GREEN) { |
219 |
| - graphics2D.setColor(PASSED_COLOR); |
220 |
| - } else if (foreground == ColorProgressBar.YELLOW) { |
221 |
| - graphics2D.setColor(WARNING_COLOR); |
| 190 | + Object statusProperty = progressBar.getClientProperty(JBUI.CurrentTheme.ProgressBar.statusKey()); |
| 191 | + if (JBUI.CurrentTheme.ProgressBar.failedStatusValue().equals(statusProperty) || foreground == ColorProgressBar.RED) { |
| 192 | + graphics.setColor(JBUI.CurrentTheme.ProgressBar.FAILED); |
| 193 | + } else if (JBUI.CurrentTheme.ProgressBar.passedStatusValue().equals(statusProperty) || foreground == ColorProgressBar.GREEN) { |
| 194 | + graphics.setColor(JBUI.CurrentTheme.ProgressBar.PASSED); |
| 195 | + } else if (JBUI.CurrentTheme.ProgressBar.warningStatusValue().equals(statusProperty) || foreground == ColorProgressBar.YELLOW) { |
| 196 | + graphics.setColor(JBUI.CurrentTheme.ProgressBar.WARNING); |
222 | 197 | } else {
|
223 |
| - graphics2D.setColor(PROGRESS_COLOR); |
| 198 | + graphics2D.setColor(JBUI.CurrentTheme.ProgressBar.PROGRESS); |
224 | 199 | }
|
225 | 200 | graphics2D.fill(coloredShape);
|
226 | 201 |
|
|
0 commit comments