mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-18 09:24:42 -04:00
Adds a [T] shortcut to insert a tunnel.
Shortcuts [+] and [-] are able to modify constants. See #380
This commit is contained in:
parent
9f39155577
commit
ce4ed8fb12
@ -515,8 +515,19 @@ public class Circuit implements Copyable<Circuit> {
|
||||
* @return the first element or null if there is no element at the given position
|
||||
*/
|
||||
public VisualElement getElementAt(Vector pos) {
|
||||
return getElementAt(pos, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the element at the given position
|
||||
*
|
||||
* @param pos the cursor position
|
||||
* @param includeText if true the label text is included in matching
|
||||
* @return the first element or null if there is no element at the given position
|
||||
*/
|
||||
public VisualElement getElementAt(Vector pos, boolean includeText) {
|
||||
for (VisualElement element : visualElements)
|
||||
if (element.matches(pos, false))
|
||||
if (element.matches(pos, includeText))
|
||||
return element;
|
||||
return null;
|
||||
}
|
||||
|
@ -5,11 +5,10 @@
|
||||
*/
|
||||
package de.neemann.digital.gui.components;
|
||||
|
||||
import de.neemann.digital.core.NodeException;
|
||||
import de.neemann.digital.core.ObservableValue;
|
||||
import de.neemann.digital.core.*;
|
||||
import de.neemann.digital.core.Observer;
|
||||
import de.neemann.digital.core.SyncAccess;
|
||||
import de.neemann.digital.core.element.*;
|
||||
import de.neemann.digital.core.io.Const;
|
||||
import de.neemann.digital.core.io.In;
|
||||
import de.neemann.digital.core.io.InValue;
|
||||
import de.neemann.digital.core.io.Out;
|
||||
@ -346,6 +345,18 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
||||
}
|
||||
}.setAcceleratorCTRLplus('D').enableAcceleratorIn(this);
|
||||
|
||||
new ToolTipAction("insertTunnel") {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
if (activeMouseController == mouseNormal) {
|
||||
VisualElement tunnel =
|
||||
new VisualElement(Tunnel.DESCRIPTION.getName())
|
||||
.setShapeFactory(shapeFactory);
|
||||
setPartToInsert(tunnel);
|
||||
}
|
||||
}
|
||||
}.setAccelerator("T").enableAcceleratorIn(this);
|
||||
|
||||
ToolTipAction plus = new PlusMinusAction(1).setAccelerator("PLUS").enableAcceleratorIn(this);
|
||||
getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD, 0), plus);
|
||||
|
||||
@ -1288,8 +1299,12 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
||||
mouseNormal.activate();
|
||||
|
||||
VisualElement ve = null;
|
||||
if (activeMouseController instanceof MouseControllerNormal)
|
||||
ve = getCircuit().getElementAt(getPosVector(lastMousePos.x, lastMousePos.y));
|
||||
if (activeMouseController instanceof MouseControllerNormal) {
|
||||
Vector pos = getPosVector(lastMousePos.x, lastMousePos.y);
|
||||
ve = getCircuit().getElementAt(pos);
|
||||
if (ve == null)
|
||||
ve = getCircuit().getElementAt(pos, true);
|
||||
}
|
||||
return ve;
|
||||
}
|
||||
|
||||
@ -1403,6 +1418,10 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
||||
int number = ve.getElementAttributes().get(Keys.INPUT_COUNT) + delta;
|
||||
if (number >= Keys.INPUT_COUNT.getMin() && number <= Keys.INPUT_COUNT.getMax())
|
||||
modify(new ModifyAttribute<>(ve, Keys.INPUT_COUNT, number));
|
||||
} else if (ve.equalsDescription(Const.DESCRIPTION)) {
|
||||
long v = ve.getElementAttributes().get(Keys.VALUE) + delta;
|
||||
v &= Bits.mask(ve.getElementAttributes().getBits());
|
||||
modify(new ModifyAttribute<>(ve, Keys.VALUE, v));
|
||||
}
|
||||
} catch (ElementNotFoundException e1) {
|
||||
// do nothing on error
|
||||
|
@ -657,6 +657,7 @@
|
||||
<shortcut key="STRG-D">Aktuelle Auswahl duplizieren ohne die Zwischenablage zu verändern.</shortcut>
|
||||
<shortcut key="R">Rotieren der Elemente beim Einfügen</shortcut>
|
||||
<shortcut key="L">Zuletzt eingefügtes Element noch einmal einfügen</shortcut>
|
||||
<shortcut key="T">Einfügen eines Tunnels</shortcut>
|
||||
<shortcut key="STRG-N">Neue Schaltung</shortcut>
|
||||
<shortcut key="STRG-O">Schaltung öffnen</shortcut>
|
||||
<shortcut key="STRG-S">Speichern der Schaltung</shortcut>
|
||||
@ -669,8 +670,12 @@
|
||||
<shortcut key="ESC">Abbrechen der aktuellen Aktion</shortcut>
|
||||
<shortcut key="Entfernen">Löschen der selektierten Elemente</shortcut>
|
||||
<shortcut key="Rückschritt">Löschen der selektierten Elemente</shortcut>
|
||||
<shortcut key="+">Erhöht die Anzahl der Eingänge in dem Element, auf welches die Maus zeigt.</shortcut>
|
||||
<shortcut key="-">Erniedrigt die Anzahl der Eingänge in dem Element, auf welches die Maus zeigt.</shortcut>
|
||||
<shortcut key="+">Erhöht die Anzahl der Eingänge in dem Element, auf welches die Maus zeigt. Bei Konstanten
|
||||
wird der Wert erhöht.
|
||||
</shortcut>
|
||||
<shortcut key="-">Erniedrigt die Anzahl der Eingänge in dem Element, auf welches die Maus zeigt. Bei
|
||||
Konstanten wird der Wert verringert.
|
||||
</shortcut>
|
||||
<shortcut key="STRG +">Vergrößern</shortcut>
|
||||
<shortcut key="STRG -">Verkleinern</shortcut>
|
||||
<shortcut key="F1">Einpassen</shortcut>
|
||||
|
@ -595,6 +595,7 @@
|
||||
<shortcut key="CTRL-D">Duplicate the current selection without modifying the clipboard.</shortcut>
|
||||
<shortcut key="R">While inserting this rotates the components.</shortcut>
|
||||
<shortcut key="L">Inserts the last inserted component again.</shortcut>
|
||||
<shortcut key="T">Inserts a new tunnel.</shortcut>
|
||||
<shortcut key="CTRL-N">New circuit.</shortcut>
|
||||
<shortcut key="CTRL-O">Open circuit.</shortcut>
|
||||
<shortcut key="CTRL-S">Save the circuit.</shortcut>
|
||||
@ -607,8 +608,12 @@
|
||||
<shortcut key="ESC">Abort the current action.</shortcut>
|
||||
<shortcut key="Del">Removes the selected components.</shortcut>
|
||||
<shortcut key="Backspace">Removes the selected components.</shortcut>
|
||||
<shortcut key="+">Increases the number of inputs at the component the mouse points to.</shortcut>
|
||||
<shortcut key="-">Decreases the number of inputs at the component the mouse points to.</shortcut>
|
||||
<shortcut key="+">Increases the number of inputs at the component the mouse points to. If it is used with
|
||||
constants, the value is increased.
|
||||
</shortcut>
|
||||
<shortcut key="-">Decreases the number of inputs at the component the mouse points to. If it is used with
|
||||
constants, the value is decreased.
|
||||
</shortcut>
|
||||
<shortcut key="CTRL +">Zoom In</shortcut>
|
||||
<shortcut key="CTRL -">Zoom Out</shortcut>
|
||||
<shortcut key="F1">Fit to size</shortcut>
|
||||
|
Loading…
x
Reference in New Issue
Block a user