Implemented SubmodelComponent.clicked(); removed obsolete TODOs
[Mograsim.git] / net.mograsim.logic.ui / src / net / mograsim / logic / ui / model / components / SubmodelComponent.java
index 27699bd..be9b854 100644 (file)
@@ -205,13 +205,12 @@ public abstract class SubmodelComponent extends GUIComponent
        @Override
        public boolean clicked(double x, double y)
        {
-               // TODO
                double scaledX = (x - getBounds().x) / submodelScale;
                double scaledY = (y - getBounds().y) / submodelScale;
-               double roundedScaledX = Math.round(scaledX / 5 * 2) * 5 / 2.;
-               double roundedScaledY = Math.round(scaledY / 5 * 2) * 5 / 2.;
-               System.out.println(scaledX + "|" + scaledY + ", rounded " + roundedScaledX + "|" + roundedScaledY);
-               return true;
+               for (GUIComponent component : submodel.getComponents())
+                       if (component.getBounds().contains(scaledX, scaledY) && component.clicked(scaledX, scaledY))
+                               return true;
+               return false;
        }
 
        /**
@@ -257,7 +256,7 @@ public abstract class SubmodelComponent extends GUIComponent
                        GUIComponent component = componentIt.next();
                        InnerComponentParams inner = new InnerComponentParams();
                        comps[i] = inner;
-                       inner.logicWidth = component.getPins().iterator().next().logicWidth; // TODO This could be done a little more elegantly
+                       inner.params = component.getInstantiationParameters();
                        Rectangle bounds = component.getBounds();
                        inner.pos = new Point(bounds.x, bounds.y);
                        inner.type = component.getIdentifier();