added "L" short cut to insert last inserted component again.

This commit is contained in:
hneemann 2017-06-05 10:09:23 +02:00
parent 9781bed640
commit 65abe0c1c3
5 changed files with 28 additions and 1 deletions

View File

@ -21,6 +21,7 @@ public class InsertHistory implements LibraryListener {
private final ElementLibrary library;
private final ArrayList<WrapperAction> wrappers;
private int mainTime;
private InsertAction lastInsertAction;
/**
* Creates a new instance
@ -42,6 +43,7 @@ public class InsertHistory implements LibraryListener {
* @param action the action
*/
public void add(InsertAction action) {
lastInsertAction = action;
if (!contains(action)) {
WrapperAction wrapper = new WrapperAction(action, bar.getComponentCount());
wrappers.add(wrapper);
@ -82,6 +84,12 @@ public class InsertHistory implements LibraryListener {
return false;
}
/**
* @return the last insert action
*/
public InsertAction getLastInsertAction() {
return lastInsertAction;
}
@Override
public void libraryChanged(LibraryNode node) {

View File

@ -246,6 +246,15 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
}
}.setToolTip(Lang.get("menu_help_elements_tt")).createJMenuItem());
new ToolTipAction("insertLast") {
@Override
public void actionPerformed(ActionEvent actionEvent) {
InsertAction lastInsertAction = insertHistory.getLastInsertAction();
if (lastInsertAction != null)
lastInsertAction.actionPerformed(actionEvent);
}
}.setAccelerator("L").enableAcceleratorIn(circuitComponent);
enableClockShortcut();
setPreferredSize(Screen.getInstance().scale(new Dimension(1024, 768)));

View File

@ -636,6 +636,9 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
} catch (AWTException e) {
e.printStackTrace();
}
} else {
mouseInsertElement.updateMousePos(getPosVector(point.x, point.y));
repaintNeeded();
}
}
@ -1173,11 +1176,15 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
@Override
void moved(MouseEvent e) {
updateMousePos(getPosVector(e));
}
void updateMousePos(Vector pos) {
if (delta == null) {
GraphicMinMax minMax = element.getMinMax(false);
delta = element.getPos().sub(minMax.getMax());
}
element.setPos(raster(getPosVector(e).add(delta)));
element.setPos(raster(pos.add(delta)));
repaint();
}
@ -1210,6 +1217,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
public void escapePressed() {
mouseNormal.activate();
}
}
private final class MouseControllerMoveElement extends MouseController {

View File

@ -242,6 +242,7 @@
<shortcut key="STRG-C">Kopieren der selektierten Elemente in die Zwischenablage.</shortcut>
<shortcut key="STRG-V">Einfügen der Elemente aus der Zwischenablage.</shortcut>
<shortcut key="R">Beim Einfügen rotieren der Elemente.</shortcut>
<shortcut key="L">Letztes eingefügtes Element noch einmal einfügen.</shortcut>
<shortcut key="STRG-S">Speichern der Schaltung.</shortcut>
<shortcut key="STRG-Z">Letzte Änderung zurücknehmen.</shortcut>
<shortcut key="STRG-Y">Zurückgenommene Änderung erneut anwenden.</shortcut>

View File

@ -231,6 +231,7 @@
<shortcut key="CTRL-C">Copys the selected components to the clipboard.</shortcut>
<shortcut key="CTRL-V">Inserts the comonents from 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="CTRL-S">Save the circuit.</shortcut>
<shortcut key="CTRL-Z">Undo last modification.</shortcut>
<shortcut key="CTRL-Y">Redo the last undone modification.</shortcut>