import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
import net.mograsim.logic.model.editor.ui.EditorGUI;
+import net.mograsim.preferences.Preferences;
public class EditorUserInput
{
gui.logicCanvas.addListener(SWT.MouseDown, e ->
{
Point clicked = editor.gui.logicCanvas.canvasToWorldCoords(e.x, e.y);
- switch (e.button)
- {
- case 1:
+ if (e.button == Preferences.current().getInt("net.mograsim.logic.model.button.action"))
editor.handleManager.click(clicked, e.stateMask);
- break;
- default:
- // don't react
- }
-
});
gui.logicCanvas.addMouseMoveListener(e ->
import net.mograsim.logic.model.editor.Editor;
import net.mograsim.logic.model.editor.SaveLoadManager;
import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
+import net.mograsim.preferences.Preferences;
public class EditorGUI
{
setupBottomToolBar(innerComp);
ZoomableCanvasUserInput userInput = new ZoomableCanvasUserInput(logicCanvas);
- userInput.buttonDrag = 3;
- userInput.buttonZoom = 2;
+ userInput.buttonDrag = Preferences.current().getInt("net.mograsim.logic.model.button.drag");
+ userInput.buttonZoom = Preferences.current().getInt("net.mograsim.logic.model.button.zoom");
userInput.enableUserInput();
new ZoomableCanvasOverlay(logicCanvas, null).enableScale();
}
private void mouseDown(Event e)
{
- if (e.button == 1)
+ if (e.button == Preferences.current().getInt("net.mograsim.logic.model.button.action"))
{
Point click = canvasToWorldCoords(e.x, e.y);
for (ModelComponent component : model.getComponentsByName().values())
import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasOverlay;
import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasUserInput;
import net.mograsim.logic.model.model.LogicModel;
+import net.mograsim.preferences.Preferences;
/**
* Standalone simulation visualizer graphical user interface.
ui = new LogicUICanvas(shell, SWT.NONE, model);
ZoomableCanvasUserInput userInput = new ZoomableCanvasUserInput(ui);
- userInput.buttonDrag = 3;
- userInput.buttonZoom = 2;
+ userInput.buttonDrag = Preferences.current().getInt("net.mograsim.logic.model.button.drag");
+ userInput.buttonZoom = Preferences.current().getInt("net.mograsim.logic.model.button.zoom");
userInput.enableUserInput();
new ZoomableCanvasOverlay(ui, null).enableScale();
}
addField(new BooleanFieldEditor("net.mograsim.logic.model.debug.openhlsshell", "Open the debug HLS shell", parent));
addField(new IntegerFieldEditor("net.mograsim.logic.model.debug.hlsshelldepth",
"Depth of components to list in the debug HLS shell", parent));
+ IntegerFieldEditor editor;
+ editor = new IntegerFieldEditor("net.mograsim.logic.model.button.action", "Mouse button for actions", parent);
+ editor.setValidRange(1, 5);
+ addField(editor);
+ editor = new IntegerFieldEditor("net.mograsim.logic.model.button.drag", "Mouse button for dragging", parent);
+ editor.setValidRange(1, 5);
+ addField(editor);
+ editor = new IntegerFieldEditor("net.mograsim.logic.model.button.zoom", "Mouse button for zooming", parent);
+ editor.setValidRange(1, 5);
+ addField(editor);
// TODO add other preferences
}
}
\ No newline at end of file
import net.mograsim.plugin.tables.DisplaySettings;
import net.mograsim.plugin.tables.mi.ActiveInstructionPreviewContentProvider;
import net.mograsim.plugin.tables.mi.InstructionTable;
+import net.mograsim.preferences.Preferences;
//TODO what if we open multiple editors?
//TODO actually save / load register and latch states
machine = machineOptional.get();
canvas = new LogicUICanvas(canvasParent, SWT.NONE, machine.getModel());
ZoomableCanvasUserInput userInput = new ZoomableCanvasUserInput(canvas);
- userInput.buttonDrag = 3;
- userInput.buttonZoom = 2;
+ userInput.buttonDrag = Preferences.current().getInt("net.mograsim.logic.model.button.drag");
+ userInput.buttonZoom = Preferences.current().getInt("net.mograsim.logic.model.button.zoom");
userInput.enableUserInput();
if (zoom > 0)
{
{
case "net.mograsim.logic.model.debug.hlsshelldepth":
return 0;
+ case "net.mograsim.logic.model.button.action":
+ return 1;
+ case "net.mograsim.logic.model.button.drag":
+ return 3;
+ case "net.mograsim.logic.model.button.zoom":
+ return 2;
default:
throw new IllegalArgumentException("Unknown int preference name: " + name);
}