X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=LogicUI%2Fsrc%2Fera%2Fmi%2Fgui%2Fmodel%2Fcomponents%2FGUIComponent.java;h=e266afbf6eee065506e4ef3290e4f6cc5eb60b77;hb=c1a22b1d26c98afab4d5666e77ef870fd5d54396;hp=7f4107d76f701f599be61da521f56da3a0de24b5;hpb=85c006b0d58883da85a057f33aff189a2cecbcf9;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) {