Skip to content

Commit 255e38b

Browse files
Merge pull request #463 from CommonWealthRobotics/kh/darkmode
Kh/darkmode
2 parents 06f5399 + d9728a7 commit 255e38b

File tree

5 files changed

+105
-5
lines changed

5 files changed

+105
-5
lines changed

src/main/java/com/neuronrobotics/bowlerstudio/BowlerStudio.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,9 @@ public void open(URI toOpe) {
291291
ScriptingEngine.cloneRepo(myAssets, null);
292292
layoutFile = AssetFactory.loadFile("layout/default.css");
293293
}
294+
if((Boolean)ConfigurationDatabase.get("BowlerStudioUI", "DarkMode",true)) {
295+
layoutFile = AssetFactory.loadFile("layout/darkmode.css");
296+
}
294297
// SplashManager.setIcon(AssetFactory.loadAsset("BowlerStudioTrayIcon.png"));
295298
renderSplashFrame(50, "DL'ing Tutorials...");
296299
// load tutorials repo

src/main/java/com/neuronrobotics/bowlerstudio/BowlerStudioController.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import eu.mihosoft.vrl.v3d.Vector3d;
3131
import eu.mihosoft.vrl.v3d.Vertex;
3232
import eu.mihosoft.vrl.v3d.ext.org.poly2tri.PolygonUtil;
33+
import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase;
3334
import javafx.application.Platform;
3435
import javafx.scene.Node;
3536
import javafx.scene.control.Tab;
@@ -417,7 +418,7 @@ public static void setCsg(List<CSG> toadd, File source) {
417418
if (toadd != null)
418419
for (CSG c : toadd) {
419420
if (c != null)
420-
BowlerStudio.runLater(() -> CreatureLab3dController.getEngine().addObject(c, source));
421+
BowlerStudio.runLater(() -> CreatureLab3dController.getEngine().addObject(c, source,c.getColor().getOpacity(), CSGDatabase.getInstance()));
421422
}
422423
});
423424
}
@@ -482,7 +483,7 @@ public static void setSelectedAffine(Affine af) {
482483
public static void addCsg(CSG toadd, File source) {
483484
BowlerStudio.runLater(() -> {
484485
if (toadd != null)
485-
CreatureLab3dController.getEngine().addObject(toadd, source);
486+
CreatureLab3dController.getEngine().addObject(toadd, source, toadd.getColor().getOpacity(),CSGDatabase.getInstance());
486487

487488
});
488489
}

src/main/java/com/neuronrobotics/bowlerstudio/CreatureLab3dController.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,11 @@ private void setupUi() {
172172
getEngine() .getSubScene().heightProperty().bind(viewContainer.heightProperty());
173173
});
174174
BowlerStudio.runLater(() -> {
175-
jfx3dControls.getChildren().add(getEngine().getControlsBox(AssetFactory.loadIcon("Home-Camera.png"),
175+
Group controlsBox = getEngine().getControlsBox(AssetFactory.loadIcon("Home-Camera.png"),
176176
AssetFactory.loadIcon("Generate-Cad.png"),
177177
AssetFactory.loadIcon("Clear-Screen.png")
178-
));
178+
);
179+
jfx3dControls.getChildren().add(controlsBox);
179180
viewContainer.getChildren().add(getEngine() .getSubScene());
180181
AnchorPane.setTopAnchor(getEngine() .getSubScene(), 0.0);
181182
AnchorPane.setRightAnchor(getEngine() .getSubScene(), 0.0);

src/main/java/com/neuronrobotics/bowlerstudio/tabs/LocalFileScriptTab.java

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,21 @@
1818

1919
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
2020
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
21+
import org.fife.ui.rsyntaxtextarea.Theme;
2122
import org.fife.ui.rtextarea.RTextScrollPane;
2223

2324
import javax.swing.AbstractAction;
25+
import javax.swing.JButton;
26+
import javax.swing.JPanel;
27+
import javax.swing.JScrollBar;
28+
import javax.swing.JScrollPane;
2429
import javax.swing.KeyStroke;
2530
import javax.swing.SwingUtilities;
2631
import javax.swing.event.CaretEvent;
2732
import javax.swing.event.CaretListener;
2833
import javax.swing.event.DocumentEvent;
2934
import javax.swing.event.DocumentListener;
35+
import javax.swing.plaf.basic.BasicScrollBarUI;
3036
import javax.swing.text.BadLocationException;
3137
import javax.swing.text.DefaultHighlighter;
3238
import javax.swing.text.Highlighter;
@@ -40,6 +46,7 @@
4046

4147
import com.neuronrobotics.bowlerstudio.BowlerStudio;
4248
import com.neuronrobotics.bowlerstudio.IssueReportingExceptionHandler;
49+
import com.neuronrobotics.bowlerstudio.assets.ConfigurationDatabase;
4350
import com.neuronrobotics.bowlerstudio.scripting.IScriptEventListener;
4451
import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine;
4552
import com.neuronrobotics.bowlerstudio.scripting.ScriptingFileWidget;
@@ -201,6 +208,7 @@ public LocalFileScriptTab(File file) throws IOException {
201208
textArea.setSyntaxEditingStyle(type);
202209
textArea.setCodeFoldingEnabled(true);
203210

211+
204212
textArea.getDocument().addDocumentListener(new DocumentListener() {
205213

206214
@Override
@@ -307,7 +315,94 @@ public void mouseClicked(MouseEvent e) {
307315
});
308316

309317
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+
}
310328

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+
}
311406
swingNode = new javafx.embed.swing.SwingNode();
312407

313408
KeyStroke keystroke_s = KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_DOWN_MASK);

0 commit comments

Comments
 (0)