no editing inside subcircuit

This commit is contained in:
Paul Falstad
2026-03-01 11:38:34 -08:00
parent a83e05960f
commit 45f92ed413
6 changed files with 23 additions and 12 deletions

View File

@@ -2,7 +2,12 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/Java [1.8.301.09]"/>
<classpathentry kind="con" path="com.gwtplugins.gwt.eclipse.core.GWT_CONTAINER/GWT 2.8.1"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/Java [1.8.401.10]"/>
<classpathentry kind="con" path="com.gwtplugins.gwt.eclipse.core.GWT_CONTAINER"/>
<classpathentry kind="src" path=".apt_generated">
<attributes>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="war/WEB-INF/classes"/>
</classpath>

View File

@@ -1,3 +1,4 @@
//gwtVersion_/Users/pf/Projects/gwt-sdk/gwt-2.11.0=2.11.0
eclipse.preferences.version=1
entryPointModules=
filesCopiedToWebInfLib=gwt-servlet.jar

View File

@@ -11,6 +11,7 @@ org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.processAnnotations=enabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647

View File

@@ -18,7 +18,7 @@ public class CommandManager {
public void menuPerformed(String menu, String item) {
PopupPanel contextPanel = app.ui.contextPanel;
if ((menu=="edit" || menu=="main" || menu=="scopes") && app.menus.noEditCheckItem.getState()) {
if ((menu=="edit" || menu=="main" || menu=="scopes") && app.ui.isReadOnly()) {
Window.alert(Locale.LS("Editing disabled. Re-enable from the Options menu."));
return;
}

View File

@@ -245,7 +245,7 @@ public class MouseManager implements MouseDownHandler, MouseMoveHandler, MouseUp
case MODE_SELECT:
if (mouseElm == null)
selectArea(gx, gy, e.isShiftKeyDown());
else if (!sim.menus.noEditCheckItem.getState()) {
else if (!ui.isReadOnly()) {
// wait short delay before dragging. This is to fix problem where switches were accidentally getting
// dragged when tapped on mobile devices
if (System.currentTimeMillis()-mouseDownTime < 150)
@@ -653,7 +653,7 @@ public class MouseManager implements MouseDownHandler, MouseMoveHandler, MouseUp
@SuppressWarnings("deprecation")
void doPopupMenu() {
if (sim.menus.noEditCheckItem.getState() || sim.dialogIsShowing())
if (ui.isReadOnly() || sim.dialogIsShowing())
return;
menuElm = mouseElm;
sim.scopeManager.menuScope=-1;
@@ -775,7 +775,7 @@ public class MouseManager implements MouseDownHandler, MouseMoveHandler, MouseUp
public void onDoubleClick(DoubleClickEvent e){
e.preventDefault();
// if (!didSwitch && mouseElm != null)
if (mouseElm != null && !(mouseElm instanceof SwitchElm) && !sim.menus.noEditCheckItem.getState())
if (mouseElm != null && !(mouseElm instanceof SwitchElm) && !ui.isReadOnly())
sim.commands.doEdit(mouseElm);
}
@@ -838,12 +838,12 @@ public class MouseManager implements MouseDownHandler, MouseMoveHandler, MouseUp
tempMouseMode = MODE_DRAG_ALL;
if (sim.menus.noEditCheckItem.getState())
if (ui.isReadOnly())
tempMouseMode = MODE_SELECT;
if (!(sim.dialogIsShowing()) && ((sim.scopeManager.scopeSelected != -1 && sim.scopeManager.scopes[sim.scopeManager.scopeSelected].cursorInSettingsWheel()) ||
( sim.scopeManager.scopeSelected == -1 && mouseElm instanceof ScopeElm && ((ScopeElm)mouseElm).elmScope.cursorInSettingsWheel()))){
if (sim.menus.noEditCheckItem.getState())
if (ui.isReadOnly())
return;
Scope s;
if (sim.scopeManager.scopeSelected != -1)
@@ -866,7 +866,7 @@ public class MouseManager implements MouseDownHandler, MouseMoveHandler, MouseUp
}
// IES - Grab resize handles in select mode if they are far enough apart and you are on top of them
if (tempMouseMode == MODE_SELECT && mouseElm!=null && !sim.menus.noEditCheckItem.getState() &&
if (tempMouseMode == MODE_SELECT && mouseElm!=null && !ui.isReadOnly() &&
mouseElm.getHandleGrabbedClose(gx, gy, POSTGRABSQ, MINPOSTGRABSIZE) >=0 &&
!anySelectedButMouse())
tempMouseMode = MODE_DRAG_POST;
@@ -979,7 +979,7 @@ public class MouseManager implements MouseDownHandler, MouseMoveHandler, MouseUp
// so we don't accidentally edit a resistor value while zooming
boolean zoomOnly = System.currentTimeMillis() < zoomTime+1000;
if (sim.menus.noEditCheckItem.getState() || !sim.menus.mouseWheelEditCheckItem.getState())
if (ui.isReadOnly() || !sim.menus.mouseWheelEditCheckItem.getState())
zoomOnly = true;
if (!zoomOnly)

View File

@@ -585,7 +585,7 @@ public class UIManager {
g.context.setLineCap(LineCap.ROUND);
if (menus.noEditCheckItem.getState())
if (isReadOnly())
g.drawLock(20, 30);
g.setColor(Color.white);
@@ -798,6 +798,10 @@ public class UIManager {
}
}
boolean isReadOnly() {
return menus.noEditCheckItem.getState() || !subcircuitStack.isEmpty();
}
void enableItems() {
}
@@ -942,7 +946,7 @@ public class UIManager {
}
}
if (menus.noEditCheckItem.getState())
if (isReadOnly())
return;
if ((t & Event.ONKEYDOWN)!=0) {