Skip to content

Commit 67b856f

Browse files
esaruohoSEVA77claude
committed
Add toolbar enhancements for v3-dev (rebase of PR pfalstad#162/pfalstad#212)
Port SEVA77 toolbar enhancements to v3-dev architecture: Toolbar.java: - Add toolbar separators between button groups for visual clarity - Add file operation buttons (New, Open, Save As) to toolbar - Add + symbol to Save As icon for visual distinction from Save - Add Centre Circuit button to toolbar - Handle Electron vs browser Save As command differences Menus.java: - Add Show Mode checkbox to Options menu (persisted to storage) UIManager.java: - Draw mouse mode info on canvas when Show Mode is enabled - Shift developer mode text down to avoid overlap with mode display Original PR by SEVA77, remapped to v3-dev split architecture. Co-Authored-By: SEVA77 <CEBA1996@outlook.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7cf753f commit 67b856f

3 files changed

Lines changed: 32 additions & 4 deletions

File tree

src/com/lushprojects/circuitjs1/client/Menus.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public class Menus {
6161
CheckboxMenuItem noEditCheckItem;
6262
CheckboxMenuItem mouseWheelEditCheckItem;
6363
CheckboxMenuItem toolbarCheckItem;
64+
CheckboxMenuItem mouseModeCheckItem;
6465
MenuBar elmMenuBar;
6566
MenuItem elmEditMenuItem;
6667
MenuItem elmCutMenuItem;
@@ -215,12 +216,18 @@ public void init() {
215216
sim.setToolbar();
216217
}
217218
}));
219+
m.addItem(mouseModeCheckItem = new CheckboxMenuItem(Locale.LS("Show Mode"),
220+
new Command() { public void execute(){
221+
sim.setOptionInStorage("showMouseMode", mouseModeCheckItem.getState());
222+
}
223+
}));
224+
mouseModeCheckItem.setState(sim.getOptionFromStorage("showMouseMode", true));
218225
m.addItem(crossHairCheckItem = new CheckboxMenuItem(Locale.LS("Show Cursor Cross Hairs"),
219226
new Command() { public void execute(){
220227
sim.setOptionInStorage("crossHair", crossHairCheckItem.getState());
221228
}
222229
}));
223-
230+
224231
m.addItem(euroResistorCheckItem = new CheckboxMenuItem(Locale.LS("European Resistors")));
225232
m.addItem(euroGatesCheckItem = new CheckboxMenuItem(Locale.LS("IEC Gates")));
226233
m.addItem(printableCheckItem = new CheckboxMenuItem(Locale.LS("White Background")));

src/com/lushprojects/circuitjs1/client/Toolbar.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class Toolbar extends FlowPanel {
2121
private Label modeLabel;
2222
private HashMap<String, Label> highlightableButtons = new HashMap<>();
2323
private Label activeButton; // Currently active button
24+
private String SEPARATOR = "<div style=\"height:30px;width:0;border-left:2px solid grey;\"></div>";
2425

2526
Label resistorButton;
2627

@@ -35,18 +36,32 @@ public Toolbar() {
3536
style.setDisplay(Style.Display.FLEX);
3637
style.setProperty("alignItems", "center");
3738

39+
add(createIconButton("doc-new", "New Blank Circuit", new MyCommand("file", "newblankcircuit")));
40+
add(createIconButton("folder", "Open File...", new MyCommand("file", "importfromlocalfile")));
41+
if (CirSim.isElectron()) {
42+
// Additional conditions are required: "Save" should not be available always.
43+
//add(createIconButton("floppy", "Save", new MyCommand("file", "save")));
44+
add(createIconButton("floppy", "Save As...", new MyCommand("file", "saveas")));
45+
} else {
46+
add(createIconButton("floppy", "Save As...", new MyCommand("file", "exportaslocalfile")));
47+
}
48+
add(new HTML("<sup style=\"margin-left:-12px;\"><strong>+</strong></sup>")); // add symbol to "Save As" icon for the visual difference
49+
add(new HTML(SEPARATOR));
3850
add(createIconButton("ccw", "Undo", new MyCommand("edit", "undo")));
3951
add(createIconButton("cw", "Redo", new MyCommand("edit", "redo")));
52+
add(new HTML(SEPARATOR));
4053
add(createIconButton("scissors", "Cut", new MyCommand("edit", "cut")));
4154
add(createIconButton("copy", "Copy", new MyCommand("edit", "copy")));
4255
add(createIconButton("paste", "Paste", new MyCommand("edit", "paste")));
4356
add(createIconButton("clone", "Duplicate", new MyCommand("edit", "duplicate")));
57+
add(new HTML(SEPARATOR));
4458
add(createIconButton("search", "Find Component...", new MyCommand("edit", "search")));
45-
59+
add(new HTML(SEPARATOR));
60+
add(createIconButton("target", "Centre Circuit", new MyCommand("edit", "centrecircuit")));
4661
add(createIconButton("zoom-11", "Zoom 100%", new MyCommand("zoom", "zoom100")));
4762
add(createIconButton("zoom-in", "Zoom In", new MyCommand("zoom", "zoomin")));
4863
add(createIconButton("zoom-out", "Zoom Out", new MyCommand("zoom", "zoomout")));
49-
64+
add(new HTML(SEPARATOR));
5065
add(createIconButton(wireIcon, "WireElm"));
5166
add(resistorButton = createIconButton(resistorIcon, "ResistorElm"));
5267
add(createIconButton(groundIcon, "GroundElm"));

src/com/lushprojects/circuitjs1/client/UIManager.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ public void updateCircuit() {
732732
perfmon.stopContext(); // updateCircuit
733733

734734
if (app.developerMode) {
735-
int height = 15;
735+
int height = 45;
736736
int increment = 15;
737737
g.drawString("Framerate: " + CircuitElm.showFormat.format(framerate), 10, height);
738738
g.drawString("Steprate: " + CircuitElm.showFormat.format(steprate), 10, height += increment);
@@ -749,6 +749,12 @@ public void updateCircuit() {
749749
}
750750
}
751751

752+
// Add info about mouse mode in graphics
753+
if (menus.mouseModeCheckItem.getState()){
754+
if (menus.printableCheckItem.getState()) g.setColor(Color.black);
755+
g.drawString(Locale.LS("Mode: ") + app.classToLabelMap.get(mouseModeStr), 10, 29);
756+
}
757+
752758
app.jsInterface.callUpdateHook();
753759
}
754760

0 commit comments

Comments
 (0)