X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=LogicUI%2Fsrc%2Fera%2Fmi%2Fgui%2Fmodel%2Fcomponents%2FGUIComponent.java;h=e266afbf6eee065506e4ef3290e4f6cc5eb60b77;hb=8eb61f917f31b0cff935538606df04e1c610bdf9;hp=7f4107d76f701f599be61da521f56da3a0de24b5;hpb=4a6a0a2c85c1a16112efaf7ca6d2b5fba3c9b466;p=Mograsim.git diff --git a/LogicUI/src/era/mi/gui/model/components/GUIComponent.java b/LogicUI/src/era/mi/gui/model/components/GUIComponent.java index 7f4107d7..e266afbf 100644 --- a/LogicUI/src/era/mi/gui/model/components/GUIComponent.java +++ b/LogicUI/src/era/mi/gui/model/components/GUIComponent.java @@ -33,6 +33,14 @@ public abstract class GUIComponent this.componentMovedListeners = new ArrayList<>(); this.pinAddedListeners = new ArrayList<>(); this.pinRemovedListeners = new ArrayList<>(); + + model.componentCreated(this); + } + + public void destroy() + { + pins.forEach(p -> pinRemovedListeners.forEach(l -> l.accept(p))); + model.componentDestroyed(this); } public void moveTo(double x, double y) @@ -50,9 +58,9 @@ public abstract class GUIComponent return new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height); } - // TODO /** - * Called when this component is clicked. Relative coordinates of the click are given. Returns true if this component has to be redrawn. + * Called when this component is clicked. Absolute coordinates of the click are given. Returns true if this component consumed this + * click. */ public boolean clicked(double x, double y) {