|
18 | 18 |
|
19 | 19 | import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; |
20 | 20 | import org.fife.ui.rsyntaxtextarea.SyntaxConstants; |
| 21 | +import org.fife.ui.rsyntaxtextarea.Theme; |
21 | 22 | import org.fife.ui.rtextarea.RTextScrollPane; |
22 | 23 |
|
23 | 24 | import javax.swing.AbstractAction; |
| 25 | +import javax.swing.JButton; |
| 26 | +import javax.swing.JPanel; |
| 27 | +import javax.swing.JScrollBar; |
| 28 | +import javax.swing.JScrollPane; |
24 | 29 | import javax.swing.KeyStroke; |
25 | 30 | import javax.swing.SwingUtilities; |
26 | 31 | import javax.swing.event.CaretEvent; |
27 | 32 | import javax.swing.event.CaretListener; |
28 | 33 | import javax.swing.event.DocumentEvent; |
29 | 34 | import javax.swing.event.DocumentListener; |
| 35 | +import javax.swing.plaf.basic.BasicScrollBarUI; |
30 | 36 | import javax.swing.text.BadLocationException; |
31 | 37 | import javax.swing.text.DefaultHighlighter; |
32 | 38 | import javax.swing.text.Highlighter; |
|
40 | 46 |
|
41 | 47 | import com.neuronrobotics.bowlerstudio.BowlerStudio; |
42 | 48 | import com.neuronrobotics.bowlerstudio.IssueReportingExceptionHandler; |
| 49 | +import com.neuronrobotics.bowlerstudio.assets.ConfigurationDatabase; |
43 | 50 | import com.neuronrobotics.bowlerstudio.scripting.IScriptEventListener; |
44 | 51 | import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine; |
45 | 52 | import com.neuronrobotics.bowlerstudio.scripting.ScriptingFileWidget; |
@@ -201,6 +208,7 @@ public LocalFileScriptTab(File file) throws IOException { |
201 | 208 | textArea.setSyntaxEditingStyle(type); |
202 | 209 | textArea.setCodeFoldingEnabled(true); |
203 | 210 |
|
| 211 | + |
204 | 212 | textArea.getDocument().addDocumentListener(new DocumentListener() { |
205 | 213 |
|
206 | 214 | @Override |
@@ -307,7 +315,94 @@ public void mouseClicked(MouseEvent e) { |
307 | 315 | }); |
308 | 316 |
|
309 | 317 | spscrollPane = new RTextScrollPane(textArea); |
| 318 | + Boolean dark = (Boolean)ConfigurationDatabase.get("BowlerStudioUI", "DarkMode",true); |
| 319 | + if (dark) { |
| 320 | + // Apply a dark theme |
| 321 | + try { |
| 322 | + Theme theme = Theme |
| 323 | + .load(getClass().getResourceAsStream("/org/fife/ui/rsyntaxtextarea/themes/dark.xml")); |
| 324 | + theme.apply(textArea); |
| 325 | + } catch (IOException ioe) { |
| 326 | + ioe.printStackTrace(); |
| 327 | + } |
310 | 328 |
|
| 329 | + // Set the viewport background (content area) |
| 330 | + spscrollPane.getViewport().setBackground(new Color(0x5a6ec4)); // even lighter blue |
| 331 | + |
| 332 | + |
| 333 | + // Set viewport background |
| 334 | + spscrollPane.getViewport().setBackground(new Color(0x5a6ec4)); // even lighter blue |
| 335 | + |
| 336 | + // Style vertical scrollbar |
| 337 | + JScrollBar vertical = spscrollPane.getVerticalScrollBar(); |
| 338 | + vertical.setUI(new BasicScrollBarUI() { |
| 339 | + @Override |
| 340 | + protected void configureScrollBarColors() { |
| 341 | + this.trackColor = new Color(0x5a6ec4); // even lighter blue |
| 342 | + this.thumbColor = new Color(0x263d8c); // logo blue |
| 343 | + this.thumbDarkShadowColor = new Color(0x263d8c); |
| 344 | + this.thumbHighlightColor = new Color(0x263d8c); |
| 345 | + this.thumbLightShadowColor = new Color(0x263d8c); |
| 346 | + } |
| 347 | + |
| 348 | + @Override |
| 349 | + protected JButton createDecreaseButton(int orientation) { |
| 350 | + JButton button = super.createDecreaseButton(orientation); |
| 351 | + button.setBackground(new Color(0xf2c83d)); // yellow |
| 352 | + return button; |
| 353 | + } |
| 354 | + |
| 355 | + @Override |
| 356 | + protected JButton createIncreaseButton(int orientation) { |
| 357 | + JButton button = super.createIncreaseButton(orientation); |
| 358 | + button.setBackground(new Color(0xf2c83d)); // yellow |
| 359 | + return button; |
| 360 | + } |
| 361 | + }); |
| 362 | + |
| 363 | + // Style horizontal scrollbar similarly |
| 364 | + JScrollBar horizontal = spscrollPane.getHorizontalScrollBar(); |
| 365 | + horizontal.setUI(new BasicScrollBarUI() { |
| 366 | + @Override |
| 367 | + protected void configureScrollBarColors() { |
| 368 | + this.trackColor = new Color(0x5a6ec4); |
| 369 | + this.thumbColor = new Color(0x263d8c); |
| 370 | + this.thumbDarkShadowColor = new Color(0x263d8c); |
| 371 | + this.thumbHighlightColor = new Color(0x263d8c); |
| 372 | + this.thumbLightShadowColor = new Color(0x263d8c); |
| 373 | + } |
| 374 | + |
| 375 | + @Override |
| 376 | + protected JButton createDecreaseButton(int orientation) { |
| 377 | + JButton button = super.createDecreaseButton(orientation); |
| 378 | + button.setBackground(new Color(0xf2c83d)); |
| 379 | + return button; |
| 380 | + } |
| 381 | + |
| 382 | + @Override |
| 383 | + protected JButton createIncreaseButton(int orientation) { |
| 384 | + JButton button = super.createIncreaseButton(orientation); |
| 385 | + button.setBackground(new Color(0xf2c83d)); |
| 386 | + return button; |
| 387 | + } |
| 388 | + }); |
| 389 | + // Set the corners where scrollbars meet |
| 390 | + JPanel lowerRight = new JPanel(); |
| 391 | + lowerRight.setBackground(new Color(0x5a6ec4)); // even lighter blue |
| 392 | + spscrollPane.setCorner(JScrollPane.LOWER_RIGHT_CORNER, lowerRight); |
| 393 | + |
| 394 | + JPanel lowerLeft = new JPanel(); |
| 395 | + lowerLeft.setBackground(new Color(0x5a6ec4)); |
| 396 | + spscrollPane.setCorner(JScrollPane.LOWER_LEFT_CORNER, lowerLeft); |
| 397 | + |
| 398 | + JPanel upperRight = new JPanel(); |
| 399 | + upperRight.setBackground(new Color(0x5a6ec4)); |
| 400 | + spscrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, upperRight); |
| 401 | + |
| 402 | + JPanel upperLeft = new JPanel(); |
| 403 | + upperLeft.setBackground(new Color(0x5a6ec4)); |
| 404 | + spscrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, upperLeft); |
| 405 | + } |
311 | 406 | swingNode = new javafx.embed.swing.SwingNode(); |
312 | 407 |
|
313 | 408 | KeyStroke keystroke_s = KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_DOWN_MASK); |
|
0 commit comments