From 4b8f294f4d9daff2f5bbf5ae6af84da1cf26f457 Mon Sep 17 00:00:00 2001 From: SEVA77 Date: Sat, 22 Jun 2024 08:00:49 -0400 Subject: [PATCH] Update patches --- patches/CirSim.patch | 336 ++++++++++++++++++++++---------- patches/HelpDialog.patch | 26 ++- patches/LicenseDialog.patch | 20 +- patches/ModDialog.patch | 375 ++++++++++++++++++++++++++++++++++++ patches/style.css.patch | 7 +- 5 files changed, 652 insertions(+), 112 deletions(-) create mode 100644 patches/ModDialog.patch diff --git a/patches/CirSim.patch b/patches/CirSim.patch index b7c2079..be04951 100644 --- a/patches/CirSim.patch +++ b/patches/CirSim.patch @@ -16,7 +16,7 @@ public class CirSim implements MouseDownHandler, MouseMoveHandler, MouseUpHandler, ClickHandler, DoubleClickHandler, ContextMenuHandler, NativePreviewHandler, -@@ -111,9 +113,16 @@ +@@ -111,10 +113,17 @@ Button runStopButton; Button dumpMatrixButton; MenuItem aboutItem; @@ -30,20 +30,23 @@ MenuItem importFromLocalFileItem, importFromTextItem, exportAsUrlItem, exportAsLocalFileItem, exportAsTextItem, printItem, recoverItem, saveFileItem; - MenuItem importFromDropboxItem; +- MenuItem undoItem, redoItem, cutItem, copyItem, pasteItem, selectAllItem, optionsItem; + //MenuItem importFromDropboxItem; - MenuItem undoItem, redoItem, cutItem, copyItem, pasteItem, selectAllItem, optionsItem; ++ MenuItem undoItem, redoItem, cutItem, copyItem, pasteItem, selectAllItem, optionsItem, modItem; MenuBar optionsMenuBar; CheckboxMenuItem dotsCheckItem; -@@ -248,6 +257,8 @@ + CheckboxMenuItem voltsCheckItem; +@@ -249,6 +258,9 @@ boolean hideInfoBox; int scopeColCount[]; static EditDialog editDialog, customLogicEditDialog, diodeModelEditDialog; + static HelpDialog helpDialog; + static LicenseDialog licenseDialog; ++ static ModDialog modDialog; static ScrollValuePopup scrollValuePopup; static Dialog dialogShowing; static AboutBox aboutBox; -@@ -264,6 +275,8 @@ +@@ -265,6 +277,8 @@ MenuBar menuBar; MenuBar fileMenuBar; VerticalPanel verticalPanel; @@ -52,33 +55,164 @@ CellPanel buttonPanel; private boolean mouseDragging; double scopeHeightFraction = 0.2; -@@ -272,7 +285,7 @@ +@@ -273,7 +287,10 @@ Vector mainMenuItemNames = new Vector(); LoadFile loadFileInput; - Frame iFrame; + Frame iFrame=null; ++ ++ static Button absResetBtn; ++ static Button absRunStopBtn; Canvas cv; Context2d cvcontext; -@@ -463,6 +476,16 @@ - fileMenuBar.addItem(menuItemWithShortcut("window", "New Window...", Locale.LS(ctrlMetaKey + "N"), - new MyCommand("file", "newwindow"))); - -+ fileMenuBar = new MenuBar(true); -+ fileMenuBar.addItem(iconMenuItem("popup", "New Window...", -+ new Command() { public void execute(){ -+ ScriptInjector.fromString("nw.Window.open('index.html', {}, function(new_win) {});") -+ .setRemoveTag(false) -+ .setWindow(ScriptInjector.TOP_WINDOW) -+ .inject(); +@@ -281,7 +298,7 @@ + // canvas width/height in px (before device pixel ratio scaling) + int canvasWidth, canvasHeight; + +- static final int MENUBARHEIGHT = 30; ++ static int MENUBARHEIGHT = 30; + static int VERTICALPANELWIDTH = 166; // default + static final int POSTGRABSQ = 25; + static final int MINPOSTGRABSIZE = 256; +@@ -303,6 +320,14 @@ + return window.devicePixelRatio; + }-*/; + ++ void redrawCanvasSize() { ++ layoutPanel.setWidgetSize(menuBar, MENUBARHEIGHT); ++ if (MENUBARHEIGHT<30) menuBar.addStyleName("modSmallMenuBar"); ++ else menuBar.removeStyleName("modSmallMenuBar"); ++ setCanvasSize(); ++ repaint(); ++ } ++ + void checkCanvasSize() { + if (cv.getCoordinateSpaceWidth() != (int) (canvasWidth * devicePixelRatio())) + setCanvasSize(); +@@ -360,6 +385,84 @@ + return $wnd.LZString.decompressFromEncodedURIComponent(dump); + }-*/; + ++ public static void executeJS(String js){ ++ ScriptInjector.fromString(js) ++ .setWindow(ScriptInjector.TOP_WINDOW) ++ .inject(); ++ } ++ ++ static native float getDefaultScale() /*-{ ++ $wnd.nw.Screen.Init(); ++ var dwidth = $wnd.nw.Screen.screens[0].bounds.width; ++ var defaultScale; ++ if (dwidth >= 1960) ++ defaultScale = 1.6; // 2-0.4 and etc. ++ else if (dwidth >= 1752 && dwidth < 1960) ++ defaultScale = 1.1; // -0.4 ++ else if (dwidth >= 1600 && dwidth < 1752) ++ defaultScale = 0.7; // -0.3 ++ else if (dwidth >= 1460 && dwidth < 1600) ++ defaultScale = 0.3; // -0.2 ++ else if (dwidth >= 1200 && dwidth < 1460) ++ defaultScale = -0.1; // -0.1 ++ else if (dwidth < 1200) ++ defaultScale = -0.3; ++ return defaultScale; ++ }-*/; ++ ++ void modSetDefault(){ ++ ++ Storage lstor = Storage.getLocalStorageIfSupported(); ++ if (lstor == null) return; ++ /* KEYS: ++ MOD_UIScale, MOD_TopMenuBar, MOD_absBtnTheme, MOD_absBtnIcon, ++ MOD_hideAbsBtns, MOD_showSidebaronStartup ++ */ ++ String MOD_UIScale=lstor.getItem("MOD_UIScale"); ++ String MOD_TopMenuBar=lstor.getItem("MOD_TopMenuBar"); ++ String MOD_absBtnTheme=lstor.getItem("MOD_absBtnTheme"); ++ String MOD_absBtnIcon=lstor.getItem("MOD_absBtnIcon"); ++ String MOD_hideAbsBtns=lstor.getItem("MOD_hideAbsBtns"); ++ String MOD_showSidebaronStartup=lstor.getItem("MOD_showSidebaronStartup"); ++ ++ if (MOD_UIScale==null){ ++ lstor.setItem("MOD_UIScale", Float.toString(getDefaultScale())); ++ executeJS("nw.Window.get().zoomLevel = "+getDefaultScale()); ++ } ++ else executeJS("nw.Window.get().zoomLevel = "+MOD_UIScale); ++ if (MOD_TopMenuBar==null) lstor.setItem("MOD_TopMenuBar","standart"); ++ else if (MOD_TopMenuBar=="small"){ ++ MENUBARHEIGHT = 20; ++ redrawCanvasSize(); ++ absRunStopBtn.removeStyleName("btn-top-pos"); ++ absResetBtn.removeStyleName("btn-top-pos"); ++ absRunStopBtn.addStyleName("btn-min-top-pos"); ++ absResetBtn.addStyleName("btn-min-top-pos"); ++ executeJS("setTrLabelPos(\"39px\")"); ++ } ++ if (MOD_absBtnTheme==null) lstor.setItem("MOD_absBtnTheme","default"); ++ else if (MOD_absBtnTheme=="classic"){ ++ absRunStopBtn.removeStyleName("modDefaultRunStopBtn"); ++ absRunStopBtn.addStyleName("gwt-Button"); ++ absRunStopBtn.addStyleName("modClassicButton"); ++ absResetBtn.removeStyleName("modDefaultResetBtn"); ++ absResetBtn.addStyleName("gwt-Button"); ++ absResetBtn.addStyleName("modClassicButton"); ++ } ++ if (MOD_absBtnIcon==null) lstor.setItem("MOD_absBtnIcon","stop"); ++ else if (MOD_absBtnIcon=="pause"){ ++ absRunStopBtn.getElement().setInnerHTML(""); ++ } ++ if (MOD_hideAbsBtns==null) lstor.setItem("MOD_hideAbsBtns","false"); ++ else if (MOD_hideAbsBtns=="true"){ ++ absRunStopBtn.setVisible(false); ++ absResetBtn.setVisible(false); ++ } ++ if (MOD_showSidebaronStartup==null) lstor.setItem("MOD_showSidebaronStartup","false"); ++ else if (MOD_showSidebaronStartup=="true") executeJS("document.getElementById(\"trigger\").checked = true"); ++ ++ } ++ + // Circuit applet; + + CirSim() { +@@ -457,13 +560,31 @@ + + shortcuts = new String[127]; + ++ RootLayoutPanel.get().add(absResetBtn = new Button("↺", ++ new ClickHandler() { ++ public void onClick(ClickEvent event) { ++ resetAction(); + } -+ })); ++ })); ++ ++ RootLayoutPanel.get().add(absRunStopBtn = new Button("", ++ new ClickHandler() { ++ public void onClick(ClickEvent event) { ++ setSimRunning(!simIsRunning()); ++ executeJS("SetBtnsStyle()"); ++ } ++ })); + ++ absResetBtn.setStyleName("btn-top-pos reset-btn reset-btn-pos modDefaultResetBtn"); ++ absRunStopBtn.setStyleName("btn-top-pos run-stop-btn run-stop-btn-pos modDefaultRunStopBtn"); ++ absResetBtn.getElement().setTitle("Reset"); ++ absRunStopBtn.getElement().setTitle("Run/Stop"); ++ + layoutPanel = new DockLayoutPanel(Unit.PX); + + fileMenuBar = new MenuBar(true); +- if (isElectron()) +- fileMenuBar.addItem(menuItemWithShortcut("window", "New Window...", Locale.LS(ctrlMetaKey + "N"), +- new MyCommand("file", "newwindow"))); +- ++ fileMenuBar.addItem(menuItemWithShortcut("window", "New Window...", Locale.LS(ctrlMetaKey + "N"), ++ new MyCommand("file", "newwindow"))); fileMenuBar.addItem(iconMenuItem("doc-new", "New Blank Circuit", new MyCommand("file", "newblankcircuit"))); importFromLocalFileItem = menuItemWithShortcut("folder", "Open File...", Locale.LS(ctrlMetaKey + "O"), new MyCommand("file","importfromlocalfile")); -@@ -470,8 +493,8 @@ +@@ -471,8 +592,8 @@ fileMenuBar.addItem(importFromLocalFileItem); importFromTextItem = iconMenuItem("doc-text", "Import From Text...", new MyCommand("file","importfromtext")); fileMenuBar.addItem(importFromTextItem); @@ -89,39 +223,14 @@ if (isElectron()) { saveFileItem = fileMenuBar.addItem(menuItemWithShortcut("floppy", "Save", Locale.LS(ctrlMetaKey + "S"), new MyCommand("file", "save"))); -@@ -496,22 +519,52 @@ - printItem = menuItemWithShortcut("print", "Print...", Locale.LS(ctrlMetaKey + "P"), new MyCommand("file","print")); - fileMenuBar.addItem(printItem); +@@ -500,20 +621,27 @@ fileMenuBar.addSeparator(); -+ /* -+ MenuBar fsub = new MenuBar(true); -+ fsub.setAutoOpen(true); -+ fsub.addItem(new MenuItem(LS("pfalstad"), -+ new Command() { public void execute(){ -+ ScriptInjector.fromString("open_webapp('http://www.falstad.com/circuit/circuitjs.html');") -+ .setWindow(ScriptInjector.TOP_WINDOW) -+ .inject(); -+ } -+ })); -+ fsub.addItem(new MenuItem(LS("isharp"), -+ new Command() { public void execute(){ -+ ScriptInjector.fromString("open_webapp('http://lushprojects.com/circuitjs/circuitjs.html');") -+ .setWindow(ScriptInjector.TOP_WINDOW) -+ .inject(); -+ } -+ })); -+ -+ fileMenuBar.addItem(LS("Open circuitjs1 from web"), fsub); -+ */ fileMenuBar.addItem(iconMenuItem("resize-full-alt", "Toggle Full Screen", new MyCommand("view", "fullscreen"))); fileMenuBar.addSeparator(); + fileMenuBar.addItem(iconMenuItem("exit", "Exit", + new Command() { public void execute(){ -+ ScriptInjector.fromString("close_app()") -+ .setWindow(ScriptInjector.TOP_WINDOW) -+ .inject(); -+ } -+ })); ++ executeJS("nw.Window.get().close(true)"); ++ }})); + /* aboutItem = iconMenuItem("info-circled", "About...", (Command)null); fileMenuBar.addItem(aboutItem); @@ -145,7 +254,7 @@ verticalPanel.getElement().addClassName("verticalPanel"); verticalPanel.getElement().setId("painel"); -@@ -521,6 +574,8 @@ +@@ -523,6 +651,8 @@ sidePanelCheckbox.setId("trigger"); sidePanelCheckboxLabel.setAttribute("for", "trigger" ); sidePanelCheckbox.addClassName("trigger"); @@ -154,38 +263,32 @@ Element topPanelCheckbox = DOM.createInputCheck(); Element topPanelCheckboxLabel = DOM.createLabel(); topPanelCheckbox.setId("toptrigger"); -@@ -563,9 +618,29 @@ +@@ -565,9 +695,9 @@ m.addItem(combineAllItem = iconMenuItem("object-group", "Combine All", new MyCommand("scopes", "combineAll"))); m.addItem(separateAllItem = iconMenuItem("object-ungroup", "Separate All", new MyCommand("scopes", "separateAll"))); menuBar.addItem(Locale.LS("Scopes"), m); - -+ /*m.addItem(fullscreenCheckItem = new CheckboxMenuItem(LS("Fullscreen Mode"), -+ new Command() { public void execute(){ -+ if (fullscreenCheckItem.getState()) { -+ ScriptInjector.fromString("nw.Window.get().enterFullscreen();") -+ .setRemoveTag(false) -+ .setWindow(ScriptInjector.TOP_WINDOW) -+ .inject(); -+ } -+ else { -+ ScriptInjector.fromString("nw.Window.get().leaveFullscreen();") -+ .setRemoveTag(false) -+ .setWindow(ScriptInjector.TOP_WINDOW) -+ .inject(); -+ }*/ -+ /* (new CheckboxAlignedMenuItem) -+ String fullscreenScript = "nw.Window.get().toggleFullscreen();"; -+ ScriptInjector.fromString(fullscreenScript).inject(); -+ */ -+ /* } -+ }));*/ optionsMenuBar = m = new MenuBar(true ); menuBar.addItem(Locale.LS("Options"), optionsMenuBar); + m.addItem(dotsCheckItem = new CheckboxMenuItem(Locale.LS("Show Current"))); dotsCheckItem.setState(true); m.addItem(voltsCheckItem = new CheckboxMenuItem(Locale.LS("Show Voltage"), -@@ -678,6 +753,7 @@ +@@ -646,6 +776,8 @@ + + m.addItem(new CheckboxAlignedMenuItem(Locale.LS("Shortcuts..."), new MyCommand("options", "shortcuts"))); + m.addItem(optionsItem = new CheckboxAlignedMenuItem(Locale.LS("Other Options..."), new MyCommand("options","other"))); ++ m.addItem(modItem = new CheckboxAlignedMenuItem("Modification Setup...", new MyCommand("options","modsetup"))); ++ modItem.addStyleName("modItem"); + if (isElectron()) + m.addItem(new CheckboxAlignedMenuItem(Locale.LS("Toggle Dev Tools"), new MyCommand("options","devtools"))); + +@@ -677,9 +809,12 @@ + return; + } + ++ modSetDefault(); ++ Window.addResizeHandler(new ResizeHandler() { public void onResize(ResizeEvent event) { repaint(); @@ -193,7 +296,7 @@ } }); -@@ -685,6 +761,7 @@ +@@ -687,6 +822,7 @@ setCanvasSize(); layoutPanel.add(cv); verticalPanel.add(buttonPanel); @@ -201,9 +304,9 @@ buttonPanel.add(resetButton = new Button(Locale.LS("Reset"))); resetButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { -@@ -706,40 +783,63 @@ - verticalPanel.add(dumpMatrixButton);// IES for debugging - */ +@@ -710,40 +846,63 @@ + */ + - if (LoadFile.isSupported()) + if (LoadFile.isSupported()){ @@ -270,7 +373,7 @@ setGrid(); elmList = new Vector(); -@@ -809,8 +909,8 @@ +@@ -813,8 +972,8 @@ if (stopMessage == null && startCircuitLink!=null) { readCircuit(""); getSetupList(false); @@ -281,7 +384,7 @@ } else { readCircuit(""); if (stopMessage == null && startCircuit != null) { -@@ -827,7 +927,7 @@ +@@ -831,7 +990,7 @@ enableUndoRedo(); enablePaste(); @@ -290,7 +393,7 @@ cv.addMouseDownHandler(this); cv.addMouseMoveHandler(this); cv.addMouseOutHandler(this); -@@ -1281,22 +1381,20 @@ +@@ -1291,22 +1450,20 @@ sb.addItem(mi); } @@ -317,7 +420,7 @@ } -@@ -1777,6 +1875,10 @@ +@@ -1787,6 +1944,10 @@ return getNthScopeElm(scopeMenuSelected-scopeCount).elmScope == s; } @@ -328,7 +431,7 @@ void setupScopes() { int i; -@@ -1810,7 +1912,9 @@ +@@ -1820,7 +1981,9 @@ int iw = infoWidth; if (colct <= 2) iw = iw*3/2; @@ -339,18 +442,22 @@ int marg = 10; if (w < marg*2) w = marg*2; -@@ -3226,6 +3330,10 @@ +@@ -3238,8 +3401,14 @@ Window.alert(Locale.LS("Editing disabled. Re-enable from the Options menu.")); return; } + if (item=="help") + helpDialog = new HelpDialog(); + if (item=="license") -+ licenseDialog = new LicenseDialog(); ++ licenseDialog = new LicenseDialog(); if (item=="about") aboutBox = new AboutBox(circuitjs1.versionString); ++ if (item=="modsetup") ++ modDialog = new ModDialog(); if (item=="importfromlocalfile") { -@@ -3245,9 +3353,9 @@ + pushUndo(); + if (isElectron()) +@@ -3257,9 +3426,9 @@ if (item=="importfromtext") { dialogShowing = new ImportFromTextDialog(this); } @@ -362,7 +469,7 @@ if (item=="exportasurl") { doExportAsUrl(); unsavedChanges = false; -@@ -3500,11 +3608,15 @@ +@@ -3517,11 +3686,15 @@ tempMouseMode = mouseMode; } if (item=="fullscreen") { @@ -380,7 +487,7 @@ } repaint(); -@@ -3775,6 +3887,37 @@ +@@ -3805,6 +3978,33 @@ currentMenuBar=new MenuBar(true); currentMenuBar.setAutoOpen(true); menuBar.addItem(Locale.LS("Circuits"), currentMenuBar); @@ -397,19 +504,15 @@ + aboutItem.setScheduledCommand(new MyCommand("file","about")); + h.addSeparator(); + h.addItem(aboutCircuitsItem = iconMenuItem("link", "About Circuits", -+ new Command() { public void execute(){ -+ ScriptInjector.fromString("nw.Shell.openExternal('https://www.falstad.com/circuit/e-index.html');") -+ .setRemoveTag(false) -+ .setWindow(ScriptInjector.TOP_WINDOW) -+ .inject(); ++ new Command() { ++ public void execute(){ ++ executeJS("nw.Shell.openExternal('https://www.falstad.com/circuit/e-index.html')"); + } + })); + h.addItem(aboutCircuitsPLItem = iconMenuItem("link", "About Circuits (Polish ver.)", -+ new Command() { public void execute(){ -+ ScriptInjector.fromString("nw.Shell.openExternal('https://www.falstad.com/circuit/polish/e-index.html');") -+ .setRemoveTag(false) -+ .setWindow(ScriptInjector.TOP_WINDOW) -+ .inject(); ++ new Command() { ++ public void execute(){ ++ executeJS("nw.Shell.openExternal('https://www.falstad.com/circuit/polish/e-index.html');"); + } + })); + @@ -418,7 +521,7 @@ stack[stackptr++] = currentMenuBar; int p; for (p = 0; p < len; ) { -@@ -3808,6 +3951,7 @@ +@@ -3838,6 +4038,7 @@ if (file.equals(startCircuit) && startLabel == null) { startLabel = title; titleLabel.setText(title); @@ -426,7 +529,7 @@ } if (first && startCircuit == null) { startCircuit = file; -@@ -3825,16 +3969,19 @@ +@@ -3855,16 +4056,19 @@ readCircuit(text.getBytes(), flags); if ((flags & RC_KEEP_TITLE) == 0) titleLabel.setText(null); @@ -446,7 +549,7 @@ } void readSetupFile(String str, String title) { -@@ -3844,6 +3991,7 @@ +@@ -3874,6 +4078,7 @@ loadFileFromURL(url); if (title != null) titleLabel.setText(title); @@ -454,18 +557,29 @@ unsavedChanges = false; } -@@ -5320,6 +5468,10 @@ +@@ -5350,6 +5555,12 @@ return true; if (aboutBox !=null && aboutBox.isShowing()) return true; + if (helpDialog !=null && helpDialog.isShowing()) + return true; + if (licenseDialog !=null && licenseDialog.isShowing()) ++ return true; ++ if (modDialog !=null && modDialog.isShowing()) + return true; return false; } -@@ -5607,16 +5759,13 @@ +@@ -5461,7 +5672,7 @@ + menuPerformed("key", "print"); + e.cancel(); + } +- if (code==KEY_N && isElectron()) { ++ if (code==KEY_N) { + menuPerformed("key", "newwindow"); + e.cancel(); + } +@@ -5637,16 +5848,13 @@ if (iFrame!=null) { int i=verticalPanel.getWidgetIndex(iFrame); verticalPanel.insert(w, i); @@ -484,14 +598,36 @@ } public static CircuitElm createCe(int tint, int x1, int y1, int x2, int y2, int f, StringTokenizer st) { -@@ -6440,7 +6589,9 @@ +@@ -6131,13 +6339,14 @@ + } + + native void printCanvas(CanvasElement cv) /*-{ +- var img = cv.toDataURL("image/png"); +- var win = window.open("", "print", "height=500,width=500,status=yes,location=no"); +- win.document.title = "Print Circuit"; +- win.document.open(); +- win.document.write(''); +- win.document.close(); +- setTimeout(function(){win.print();},1000); ++ var img = cv.toDataURL("image/png"); ++ var iframe = $doc.createElement("iframe"); ++ iframe.src = img; ++ iframe.style = "display:none"; ++ $doc.body.appendChild(iframe); ++ var contentWindow = iframe.contentWindow; ++ contentWindow.print(); ++ contentWindow.addEventListener('afterprint', function(){iframe.remove()}); + }-*/; + + void doDCAnalysis() { +@@ -6488,7 +6697,9 @@ getElements: $entry(function() { return that.@com.lushprojects.circuitjs1.client.CirSim::getJSElements()(); } ), getCircuitAsSVG: $entry(function() { return that.@com.lushprojects.circuitjs1.client.CirSim::doExportAsSVGFromAPI()(); } ), exportCircuit: $entry(function() { return that.@com.lushprojects.circuitjs1.client.CirSim::dumpCircuit()(); } ), - importCircuit: $entry(function(circuit, subcircuitsOnly) { return that.@com.lushprojects.circuitjs1.client.CirSim::importCircuitFromText(Ljava/lang/String;Z)(circuit, subcircuitsOnly); }) + importCircuit: $entry(function(circuit, subcircuitsOnly) { return that.@com.lushprojects.circuitjs1.client.CirSim::importCircuitFromText(Ljava/lang/String;Z)(circuit, subcircuitsOnly); }), + setupScopes: $entry(function() { return that.@com.lushprojects.circuitjs1.client.CirSim::setupScopes()(); } ), -+ resetAction: $entry(function() { return that.@com.lushprojects.circuitjs1.client.CirSim::resetAction()(); } ) ++ redrawCanvasSize: $entry(function() { return that.@com.lushprojects.circuitjs1.client.CirSim::redrawCanvasSize()(); } ) }; var hook = $wnd.oncircuitjsloaded; if (hook) diff --git a/patches/HelpDialog.patch b/patches/HelpDialog.patch index fe8cbde..767c3a3 100644 --- a/patches/HelpDialog.patch +++ b/patches/HelpDialog.patch @@ -2,7 +2,22 @@ +++ src/main/java/com/lushprojects/circuitjs1/client/HelpDialog.java @@ -0,0 +1,90 @@ +/* -+ Copyright (C) Usevalad Khatkevich ++ Copyright (C) Paul Falstad, Iain Sharp and Usevalad Khatkevich ++ ++ This file is part of CircuitJS1. ++ ++ CircuitJS1 is free software: you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation, either version 2 of the License, or ++ (at your option) any later version. ++ ++ CircuitJS1 is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with CircuitJS1. If not, see . +*/ + +package com.lushprojects.circuitjs1.client; @@ -28,7 +43,6 @@ + VerticalPanel vpPL; + VerticalPanel vpDE; + VerticalPanel vpDA; -+ CirSim sim; + + HelpDialog() { + super(); @@ -40,11 +54,11 @@ + vp.add(tp); + String tab1Title = "EN"; + String tab2Title = "RU"; -+ String tab3Title = "PL"; -+ String tab4Title = "DE"; -+ String tab5Title = "DA"; ++ //String tab3Title = "PL"; ++ //String tab4Title = "DE"; ++ //String tab5Title = "DA"; + -+ //create tabs ++ //create tabs + tp.add(vpEN = new VerticalPanel(), tab1Title); + vpEN.setWidth("500px"); + vpEN.add(new HTML("")); diff --git a/patches/LicenseDialog.patch b/patches/LicenseDialog.patch index cd7e476..b293037 100644 --- a/patches/LicenseDialog.patch +++ b/patches/LicenseDialog.patch @@ -1,8 +1,23 @@ --- /dev/null +++ src/main/java/com/lushprojects/circuitjs1/client/LicenseDialog.java -@@ -0,0 +1,41 @@ +@@ -0,0 +1,55 @@ +/* -+ Copyright (C) Usevalad Khatkevich ++ Copyright (C) Paul Falstad and Usevalad Khatkevich ++ ++ This file is part of CircuitJS1. ++ ++ CircuitJS1 is free software: you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation, either version 2 of the License, or ++ (at your option) any later version. ++ ++ CircuitJS1 is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with CircuitJS1. If not, see . +*/ + +package com.lushprojects.circuitjs1.client; @@ -19,7 +34,6 @@ + + VerticalPanel vp; + Button okButton; -+ CirSim sim; + + LicenseDialog() { + super(); diff --git a/patches/ModDialog.patch b/patches/ModDialog.patch new file mode 100644 index 0000000..74d8413 --- /dev/null +++ b/patches/ModDialog.patch @@ -0,0 +1,375 @@ +--- /dev/null ++++ src/main/java/com/lushprojects/circuitjs1/client/ModDialog.java +@@ -0,0 +1,372 @@ ++/* ++ Copyright (C) Paul Falstad and Usevalad Khatkevich ++ ++ This file is part of CircuitJS1. ++ ++ CircuitJS1 is free software: you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation, either version 2 of the License, or ++ (at your option) any later version. ++ ++ CircuitJS1 is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with CircuitJS1. If not, see . ++*/ ++ ++package com.lushprojects.circuitjs1.client; ++ ++import com.google.gwt.event.dom.client.ClickEvent; ++import com.google.gwt.event.dom.client.ClickHandler; ++import com.google.gwt.user.client.ui.DialogBox; ++import com.google.gwt.user.client.ui.VerticalPanel; ++import com.google.gwt.user.client.ui.HTML; ++import com.google.gwt.user.client.ui.Button; ++import com.lushprojects.circuitjs1.client.util.Locale; ++import com.google.gwt.user.client.ui.HorizontalPanel; ++import com.google.gwt.user.client.ui.HasHorizontalAlignment; ++import com.google.gwt.user.client.ui.HasVerticalAlignment; ++import com.google.gwt.user.client.ui.CheckBox; ++import com.google.gwt.storage.client.Storage; ++ ++public class ModDialog extends DialogBox { ++ ++ VerticalPanel vp; ++ Storage lstor = Storage.getLocalStorageIfSupported(); ++ ++ //for "UI scale:" ++ HorizontalPanel scaleButtons; ++ Button setScale100Button; ++ Button setDefaultScaleButton; ++ Button setScaleButton; ++ HTML scaleScrollbarElm; ++ native float getRealScale() /*-{ ++ return $wnd.nw.Window.get().zoomLevel; ++ }-*/; ++ String getScaleScrollbar(float value,int scale){ ++ return ""+scale+"%"; ++ } ++ ++ //for "Top menu bar:" ++ HorizontalPanel topMenuBarVars; ++ CheckBox setStandartTopMenu; ++ CheckBox setSmallTopMenu; ++ ++ //for "Start/Stop and Reset buttons:" ++ HorizontalPanel btnsPreview; ++ HTML previewText; ++ Button resetPrevBtn; ++ Button stopPrevBtn; ++ HorizontalPanel SRCheckBoxes; ++ VerticalPanel vp1; ++ CheckBox setDefaultSRBtns; ++ CheckBox setClassicSRBtns; ++ VerticalPanel vp2; ++ CheckBox setStopIcon; ++ CheckBox setPauseIcon; ++ VerticalPanel vp3; ++ CheckBox hideSRBtns; ++ native boolean CirSimIsRunning()/*-{ ++ return $wnd.CircuitJS1.isRunning(); ++ }-*/; ++ ++ //for "Other:" ++ CheckBox setShowSidebaronStartup; ++ ++ ++ Button closeButton; ++ ++ ModDialog() { ++ ++ super(); ++ vp = new VerticalPanel(); ++ setWidget(vp); ++ setText("Modification Setup"); ++ vp.setWidth("400px"); ++ ++ vp.add(new HTML("UI Scale:")); ++ vp.add(scaleScrollbarElm = new HTML(getScaleScrollbar(getRealScale(),(int)(getRealScale()*100+100)))); ++ vp.setCellHorizontalAlignment(scaleScrollbarElm, HasHorizontalAlignment.ALIGN_CENTER); ++ vp.add(scaleButtons = new HorizontalPanel()); ++ scaleButtons.setWidth("100%"); ++ scaleButtons.add(setScale100Button = new Button("100%", ++ new ClickHandler(){ ++ public void onClick(ClickEvent event) { ++ vp.remove(scaleScrollbarElm); ++ vp.insert(scaleScrollbarElm = new HTML(getScaleScrollbar(0,100)),1); ++ vp.setCellHorizontalAlignment(scaleScrollbarElm, HasHorizontalAlignment.ALIGN_CENTER); ++ CirSim.executeJS("setScaleUI()"); ++ lstor.setItem("MOD_UIScale", "0"); ++ } ++ })); ++ scaleButtons.add(setDefaultScaleButton = new Button("Default scale*", ++ new ClickHandler() { ++ public void onClick(ClickEvent event) { ++ vp.remove(scaleScrollbarElm); ++ vp.insert(scaleScrollbarElm = new HTML(getScaleScrollbar(CirSim.getDefaultScale(), ++ (int)(CirSim.getDefaultScale()*100+100))),1); ++ vp.setCellHorizontalAlignment(scaleScrollbarElm, HasHorizontalAlignment.ALIGN_CENTER); ++ CirSim.executeJS("setScaleUI()"); ++ lstor.setItem("MOD_UIScale", Float.toString(CirSim.getDefaultScale())); ++ } ++ })); ++ scaleButtons.add(setScaleButton = new Button("Set", ++ new ClickHandler() { ++ public void onClick(ClickEvent event) { ++ CirSim.executeJS("setScaleUI()"); ++ lstor.setItem("MOD_UIScale", Float.toString(getRealScale())); ++ } ++ })); ++ vp.add(new HTML("

* - the default UI scale for your monitor is set to "+ ++ (int)(CirSim.getDefaultScale()*100+100)+"%

")); ++ // Styling buttons: ++ setScaleButton.addStyleName("modButtons"); //.setHeight("20px"); ++ setScaleButton.addStyleName("modSetButtons"); ++ setScale100Button.addStyleName("modButtons"); ++ setDefaultScaleButton.addStyleName("modButtons"); ++ //remove "gwt-Button" style: ++ setScaleButton.removeStyleName("gwt-Button"); ++ setScale100Button.removeStyleName("gwt-Button"); ++ setDefaultScaleButton.removeStyleName("gwt-Button"); ++ scaleButtons.setCellHorizontalAlignment(setScale100Button, HasHorizontalAlignment.ALIGN_CENTER); ++ scaleButtons.setCellHorizontalAlignment(setDefaultScaleButton, HasHorizontalAlignment.ALIGN_CENTER); ++ scaleButtons.setCellHorizontalAlignment(setScaleButton, HasHorizontalAlignment.ALIGN_CENTER); ++ ++ vp.add(new HTML("
Top Menu Bar:")); ++ vp.add(topMenuBarVars = new HorizontalPanel()); ++ topMenuBarVars.setWidth("100%"); ++ topMenuBarVars.add(setStandartTopMenu = new CheckBox("Standart")); ++ topMenuBarVars.add(setSmallTopMenu = new CheckBox("Small")); ++ if (CirSim.MENUBARHEIGHT<30) setSmallTopMenu.setValue(true); ++ else setStandartTopMenu.setValue(true); ++ ++ setStandartTopMenu.addClickHandler(new ClickHandler() { ++ public void onClick(ClickEvent event) { ++ if (setSmallTopMenu.getValue()) { ++ CirSim.MENUBARHEIGHT = 30; ++ //CirSim.layoutPanel.setWidgetSize(menuBar, 30); ++ setSmallTopMenu.setValue(false); ++ setStandartTopMenu.setValue(true); ++ CirSim.executeJS("CircuitJS1.redrawCanvasSize()"); ++ lstor.setItem("MOD_TopMenuBar", "standart"); ++ CirSim.absRunStopBtn.removeStyleName("btn-min-top-pos"); ++ CirSim.absResetBtn.removeStyleName("btn-min-top-pos"); ++ CirSim.absRunStopBtn.addStyleName("btn-top-pos"); ++ CirSim.absResetBtn.addStyleName("btn-top-pos"); ++ CirSim.executeJS("setTrLabelPos(\"50px\")"); ++ } else { ++ setStandartTopMenu.setValue(true); ++ } ++ } ++ }); ++ ++ setSmallTopMenu.addClickHandler(new ClickHandler() { ++ public void onClick(ClickEvent event) { ++ if (setStandartTopMenu.getValue()) { ++ CirSim.MENUBARHEIGHT = 20; ++ //CirSim.layoutPanel.setWidgetSize(menuBar, 19); ++ setStandartTopMenu.setValue(false); ++ setSmallTopMenu.setValue(true); ++ CirSim.executeJS("CircuitJS1.redrawCanvasSize()"); ++ lstor.setItem("MOD_TopMenuBar", "small"); ++ CirSim.absRunStopBtn.removeStyleName("btn-top-pos"); ++ CirSim.absResetBtn.removeStyleName("btn-top-pos"); ++ CirSim.absRunStopBtn.addStyleName("btn-min-top-pos"); ++ CirSim.absResetBtn.addStyleName("btn-min-top-pos"); ++ CirSim.executeJS("setTrLabelPos(\"39px\")"); ++ } else { ++ setSmallTopMenu.setValue(true); ++ } ++ } ++ }); ++ ++ // Styling checkboxes: ++ topMenuBarVars.setCellHorizontalAlignment(setStandartTopMenu, HasHorizontalAlignment.ALIGN_CENTER); ++ topMenuBarVars.setCellHorizontalAlignment(setSmallTopMenu, HasHorizontalAlignment.ALIGN_CENTER); ++ ++ vp.add(new HTML("
Start/Stop and Reset Buttons:")); ++ vp.add(btnsPreview = new HorizontalPanel()); ++ btnsPreview.setWidth("100%"); ++ btnsPreview.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); ++ btnsPreview.add(previewText = new HTML("Preview:")); ++ btnsPreview.add(resetPrevBtn = new Button("↺")); ++ btnsPreview.add(stopPrevBtn = new Button("")); ++ if (lstor.getItem("MOD_absBtnIcon")=="pause") ++ stopPrevBtn.getElement().setInnerHTML(""); ++ btnsPreview.setCellHorizontalAlignment(previewText, HasHorizontalAlignment.ALIGN_RIGHT); ++ btnsPreview.setCellHorizontalAlignment(resetPrevBtn, HasHorizontalAlignment.ALIGN_RIGHT); ++ btnsPreview.setCellHorizontalAlignment(stopPrevBtn, HasHorizontalAlignment.ALIGN_LEFT); ++ ++ stopPrevBtn.setStyleName("run-stop-btn modPrevBtn"); ++ resetPrevBtn.setStyleName("reset-btn modPrevBtn"); ++ if (lstor.getItem("MOD_absBtnTheme")=="default"){ ++ stopPrevBtn.addStyleName("modDefaultRunStopBtn"); ++ resetPrevBtn.addStyleName("modDefaultResetBtn"); ++ } else { ++ stopPrevBtn.addStyleName("gwt-Button"); ++ resetPrevBtn.addStyleName("gwt-Button"); ++ } ++ ++ vp.add(SRCheckBoxes = new HorizontalPanel()); ++ SRCheckBoxes.setWidth("100%"); ++ SRCheckBoxes.add(vp1 = new VerticalPanel()); ++ SRCheckBoxes.add(vp2 = new VerticalPanel()); ++ SRCheckBoxes.add(vp3 = new VerticalPanel()); ++ vp3.setHeight("100%"); ++ SRCheckBoxes.setCellVerticalAlignment(vp3, HasVerticalAlignment.ALIGN_MIDDLE); ++ //SRCheckBoxes.setCellHorizontalAlignment(vp3, HasHorizontalAlignment.ALIGN_CENTER); ++ ++ vp1.add(new HTML("Theme:")); ++ vp1.add(setDefaultSRBtns = new CheckBox("Default")); ++ vp1.add(setClassicSRBtns = new CheckBox("Classic")); ++ ++ vp2.add(new HTML("Icon:")); ++ vp2.add(setStopIcon = new CheckBox("Stop")); ++ vp2.add(setPauseIcon = new CheckBox("Pause")); ++ ++ vp3.add(hideSRBtns = new CheckBox("HIDE BUTTONS!")); ++ ++ if (CirSim.absResetBtn.getElement().hasClassName("modDefaultResetBtn")) ++ setDefaultSRBtns.setValue(true); ++ else setClassicSRBtns.setValue(true); ++ ++ /*if (CirSim.absRunStopBtn.getElement().getInnerText() == "") ++ setStopIcon.setValue(true); ++ else setPauseIcon.setValue(true);*/ //try to get info from localstorage ++ ++ if (lstor.getItem("MOD_absBtnIcon")=="stop") setStopIcon.setValue(true); ++ else setPauseIcon.setValue(true); ++ ++ if (!CirSim.absRunStopBtn.isVisible()) hideSRBtns.setValue(true); ++ ++ setDefaultSRBtns.addClickHandler(new ClickHandler() { ++ public void onClick(ClickEvent event) { ++ if (setClassicSRBtns.getValue()) { ++ setClassicSRBtns.setValue(false); ++ setDefaultSRBtns.setValue(true); ++ //Buttons for preview: ++ stopPrevBtn.removeStyleName("gwt-Button"); ++ stopPrevBtn.addStyleName("modDefaultRunStopBtn"); ++ resetPrevBtn.removeStyleName("gwt-Button"); ++ resetPrevBtn.addStyleName("modDefaultResetBtn"); ++ //Absolute buttons: ++ CirSim.absRunStopBtn.removeStyleName("gwt-Button"); ++ CirSim.absRunStopBtn.removeStyleName("modClassicButton"); ++ CirSim.absRunStopBtn.addStyleName("modDefaultRunStopBtn"); ++ CirSim.absResetBtn.removeStyleName("gwt-Button"); ++ CirSim.absResetBtn.removeStyleName("modClassicButton"); ++ CirSim.absResetBtn.addStyleName("modDefaultResetBtn"); ++ //save: ++ lstor.setItem("MOD_absBtnTheme", "default"); ++ } else { ++ setDefaultSRBtns.setValue(true); ++ } ++ } ++ }); ++ setClassicSRBtns.addClickHandler(new ClickHandler() { ++ public void onClick(ClickEvent event) { ++ if (setDefaultSRBtns.getValue()) { ++ setDefaultSRBtns.setValue(false); ++ setClassicSRBtns.setValue(true); ++ //Buttons for preview: ++ stopPrevBtn.removeStyleName("modDefaultRunStopBtn"); ++ stopPrevBtn.addStyleName("gwt-Button"); ++ resetPrevBtn.removeStyleName("modDefaultResetBtn"); ++ resetPrevBtn.addStyleName("gwt-Button"); ++ //Absolute buttons: ++ CirSim.absRunStopBtn.removeStyleName("modDefaultRunStopBtn"); ++ CirSim.absRunStopBtn.addStyleName("gwt-Button"); ++ CirSim.absRunStopBtn.addStyleName("modClassicButton"); ++ CirSim.absResetBtn.removeStyleName("modDefaultResetBtn"); ++ CirSim.absResetBtn.addStyleName("gwt-Button"); ++ CirSim.absResetBtn.addStyleName("modClassicButton"); ++ //save: ++ lstor.setItem("MOD_absBtnTheme", "classic"); ++ } else { ++ setClassicSRBtns.setValue(true); ++ } ++ } ++ }); ++ setStopIcon.addClickHandler(new ClickHandler() { ++ public void onClick(ClickEvent event) { ++ if (setPauseIcon.getValue()) { ++ setPauseIcon.setValue(false); ++ setStopIcon.setValue(true); ++ stopPrevBtn.getElement().setInnerHTML(""); ++ if (CirSimIsRunning()) ++ CirSim.absRunStopBtn.getElement().setInnerHTML(""); ++ //save: ++ lstor.setItem("MOD_absBtnIcon", "stop"); ++ } else { ++ setStopIcon.setValue(true); ++ } ++ } ++ }); ++ setPauseIcon.addClickHandler(new ClickHandler() { ++ public void onClick(ClickEvent event) { ++ if (setStopIcon.getValue()) { ++ setStopIcon.setValue(false); ++ setPauseIcon.setValue(true); ++ stopPrevBtn.getElement().setInnerHTML(""); ++ if (CirSimIsRunning()) ++ CirSim.absRunStopBtn.getElement().setInnerHTML(""); ++ //save: ++ lstor.setItem("MOD_absBtnIcon", "pause"); ++ } else { ++ setPauseIcon.setValue(true); ++ } ++ } ++ }); ++ hideSRBtns.addClickHandler(new ClickHandler() { ++ public void onClick(ClickEvent event) { ++ if (hideSRBtns.getValue()){ ++ CirSim.absRunStopBtn.setVisible(false); ++ CirSim.absResetBtn.setVisible(false); ++ //save: ++ lstor.setItem("MOD_hideAbsBtns", "true"); ++ }else{ ++ CirSim.absRunStopBtn.setVisible(true); ++ CirSim.absResetBtn.setVisible(true); ++ //save: ++ lstor.setItem("MOD_hideAbsBtns", "false"); ++ } ++ } ++ }); ++ ++ vp.add(new HTML("
Other:")); ++ vp.add(setShowSidebaronStartup = new CheckBox("Show sidebar on startup")); ++ vp.setCellHorizontalAlignment(setShowSidebaronStartup, HasHorizontalAlignment.ALIGN_CENTER); ++ if (lstor.getItem("MOD_showSidebaronStartup")=="true") setShowSidebaronStartup.setValue(true); ++ setShowSidebaronStartup.addClickHandler(new ClickHandler() { ++ public void onClick(ClickEvent event) { ++ if (setShowSidebaronStartup.getValue()){ ++ lstor.setItem("MOD_showSidebaronStartup", "true"); ++ } else {lstor.setItem("MOD_showSidebaronStartup", "false");} ++ } ++ }); ++ vp.add(new HTML("
")); ++ ++ vp.add(closeButton = new Button("Close", ++ new ClickHandler() { ++ public void onClick(ClickEvent event) { ++ closeDialog(); ++ } ++ })); ++ vp.setCellHorizontalAlignment(closeButton, ++ HasHorizontalAlignment.ALIGN_CENTER); ++ ++ center(); ++ show(); ++ } ++ ++ protected void closeDialog() { ++ hide(); ++ } ++ ++} diff --git a/patches/style.css.patch b/patches/style.css.patch index 1af8f5d..02b8e97 100644 --- a/patches/style.css.patch +++ b/patches/style.css.patch @@ -1,6 +1,6 @@ ---- /dev/null +--- /dev/null +++ src/main/java/com/lushprojects/circuitjs1/public/style.css -@@ -1,123 +1,91 @@ +@@ -1,123 +1,92 @@ @charset "UTF-8"; -/*Hide all mobile elements when in desktop usage*/ @@ -54,6 +54,7 @@ + right: 0; + z-index: 1; + transition: right 1s; ++ cursor: pointer; +} +.triggerLabel:before { + content: "\25C0"; @@ -203,4 +204,4 @@ } -} +} -\ В конце файла нет новой строки +\ No newline at end of file