Components now can be clicked
[Mograsim.git] / LogicUI / src / era / mi / components / gui / BasicGUIComponent.java
index f7e7d37..54384b9 100644 (file)
@@ -3,6 +3,7 @@ package era.mi.components.gui;
 import era.mi.logic.wires.WireArray;
 import net.haspamelodica.swt.helper.gcs.GeneralGC;
 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
+import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
 
 public interface BasicGUIComponent
 {
@@ -10,6 +11,18 @@ public interface BasicGUIComponent
         * Render this component to the given gc, at coordinates (0, 0).
         */
        public void render(GeneralGC gc);
+       /**
+        * Returns the bounds of this component.
+        * Used for calculating which component is clicked.
+        */
+       public Rectangle getBounds();
+       /**
+        * Called when this component is clicked. Relative coordinates of the click are given.
+        */
+       public default boolean clicked(double x, double y)
+       {
+               return false;
+       }
 
        //TODO this code will be replaced by code in BasicComponent.
        /**