Introduced mini-buttons to the GUIManualSwitch to flip single bits
[Mograsim.git] / net.mograsim.logic.model / src / net / mograsim / logic / model / model / wires / WireCrossPoint.java
index f7150a2..5751596 100644 (file)
@@ -10,6 +10,7 @@ import net.mograsim.logic.core.types.BitVectorFormatter;
 import net.mograsim.logic.core.wires.Wire.ReadEnd;
 import net.mograsim.logic.model.model.ViewModelModifiable;
 import net.mograsim.logic.model.model.components.GUIComponent;
+import net.mograsim.logic.model.serializing.IdentifierGetter;
 import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
 import net.mograsim.preferences.ColorDefinition;
 import net.mograsim.preferences.ColorManager;
@@ -28,6 +29,10 @@ public class WireCrossPoint extends GUIComponent
        private static final int CIRCLE_RADIUS = 1;
        private static final int CIRCLE_DIAM = CIRCLE_RADIUS * 2;
 
+       /**
+        * The logical width of this cross point.
+        */
+       public final int logicWidth;
        /**
         * The (single) pin of this cross point.
         */
@@ -52,10 +57,11 @@ public class WireCrossPoint extends GUIComponent
        public WireCrossPoint(ViewModelModifiable model, int logicWidth, String name)
        {
                super(model, name);
-               logicObs = (i) -> requestRedraw();
+               this.logicWidth = logicWidth;
+               logicObs = (i) -> model.requestRedraw();
 
                setSize(CIRCLE_DIAM, CIRCLE_DIAM);
-               addPin(this.pin = new Pin(this, "", logicWidth, CIRCLE_RADIUS, CIRCLE_RADIUS));
+               addPin(this.pin = new Pin(this, "", logicWidth, PinUsage.TRISTATE, CIRCLE_RADIUS, CIRCLE_RADIUS));
        }
 
        // pins
@@ -115,9 +121,9 @@ public class WireCrossPoint extends GUIComponent
        // serializing
 
        @Override
-       public JsonElement getParamsForSerializing()
+       public JsonElement getParamsForSerializing(IdentifierGetter idGetter)
        {
-               return new JsonPrimitive(pin.logicWidth);
+               return new JsonPrimitive(logicWidth);
        }
 
        static