From 12dce36e4b1b7ce0aba25ef698d262b588c8b53c Mon Sep 17 00:00:00 2001 From: Daniel Kirschten Date: Wed, 15 May 2019 11:48:24 +0200 Subject: [PATCH] Added getBounds() in BasicGUIComponent --- LogicUI/src/era/mi/components/gui/BasicGUIComponent.java | 6 ++++++ LogicUI/src/era/mi/components/gui/GUIAndGate.java | 6 ++++++ LogicUI/src/era/mi/components/gui/GUIMerger.java | 6 ++++++ LogicUI/src/era/mi/components/gui/GUIMux.java | 7 +++++++ LogicUI/src/era/mi/components/gui/GUINotGate.java | 6 ++++++ LogicUI/src/era/mi/components/gui/GUISplitter.java | 6 ++++++ 6 files changed, 37 insertions(+) diff --git a/LogicUI/src/era/mi/components/gui/BasicGUIComponent.java b/LogicUI/src/era/mi/components/gui/BasicGUIComponent.java index 8d263842..55929b9d 100644 --- a/LogicUI/src/era/mi/components/gui/BasicGUIComponent.java +++ b/LogicUI/src/era/mi/components/gui/BasicGUIComponent.java @@ -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,11 @@ 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(); //TODO this code will be replaced by code in BasicComponent. /** diff --git a/LogicUI/src/era/mi/components/gui/GUIAndGate.java b/LogicUI/src/era/mi/components/gui/GUIAndGate.java index 6b18afab..7f0749a9 100644 --- a/LogicUI/src/era/mi/components/gui/GUIAndGate.java +++ b/LogicUI/src/era/mi/components/gui/GUIAndGate.java @@ -10,6 +10,7 @@ import era.mi.logic.wires.WireArray; import net.haspamelodica.swt.helper.gcs.GeneralGC; import net.haspamelodica.swt.helper.swtobjectwrappers.Font; import net.haspamelodica.swt.helper.swtobjectwrappers.Point; +import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle; public class GUIAndGate extends AndGate implements BasicGUIComponent { @@ -44,6 +45,11 @@ public class GUIAndGate extends AndGate implements BasicGUIComponent this.wireArrayConnectionPoints = Collections.unmodifiableList(wireArrayConnectionPointsModifiable); } + @Override + public Rectangle getBounds() + { + return new Rectangle(0, 0, 20, height); + } @Override public void render(GeneralGC gc) { diff --git a/LogicUI/src/era/mi/components/gui/GUIMerger.java b/LogicUI/src/era/mi/components/gui/GUIMerger.java index 0abe968f..df5b5151 100644 --- a/LogicUI/src/era/mi/components/gui/GUIMerger.java +++ b/LogicUI/src/era/mi/components/gui/GUIMerger.java @@ -9,6 +9,7 @@ import era.mi.logic.components.Merger; 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 class GUIMerger extends Merger implements BasicGUIComponent { @@ -41,6 +42,11 @@ public class GUIMerger extends Merger implements BasicGUIComponent this.wireArrayConnectionPoints = Collections.unmodifiableList(wireArrayConnectionPointsModifiable); } + @Override + public Rectangle getBounds() + { + return new Rectangle(0, 0, 20, height); + } @Override public void render(GeneralGC gc) { diff --git a/LogicUI/src/era/mi/components/gui/GUIMux.java b/LogicUI/src/era/mi/components/gui/GUIMux.java index bf78b76a..19c16229 100644 --- a/LogicUI/src/era/mi/components/gui/GUIMux.java +++ b/LogicUI/src/era/mi/components/gui/GUIMux.java @@ -9,6 +9,7 @@ import era.mi.logic.components.Mux; 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 class GUIMux extends Mux implements BasicGUIComponent { @@ -45,6 +46,12 @@ public class GUIMux extends Mux implements BasicGUIComponent this.connectedWireArrays = Collections.unmodifiableList(connectedWireArraysModifiable); this.wireArrayConnectionPoints = Collections.unmodifiableList(wireArrayConnectionPointsModifiable); } + + @Override + public Rectangle getBounds() + { + return new Rectangle(0, 0, 20, height + 20); + } @Override public void render(GeneralGC gc) { diff --git a/LogicUI/src/era/mi/components/gui/GUINotGate.java b/LogicUI/src/era/mi/components/gui/GUINotGate.java index 7af9a4b4..6b8ee24c 100644 --- a/LogicUI/src/era/mi/components/gui/GUINotGate.java +++ b/LogicUI/src/era/mi/components/gui/GUINotGate.java @@ -9,6 +9,7 @@ import era.mi.logic.wires.WireArray; import net.haspamelodica.swt.helper.gcs.GeneralGC; import net.haspamelodica.swt.helper.swtobjectwrappers.Font; import net.haspamelodica.swt.helper.swtobjectwrappers.Point; +import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle; public class GUINotGate extends NotGate implements BasicGUIComponent { @@ -34,6 +35,11 @@ public class GUINotGate extends NotGate implements BasicGUIComponent this.wireArrayConnectionPoints = Collections.unmodifiableList(wireArrayConnectionPointsModifiable); } + @Override + public Rectangle getBounds() + { + return new Rectangle(0, 0, 20, 10); + } @Override public void render(GeneralGC gc) { diff --git a/LogicUI/src/era/mi/components/gui/GUISplitter.java b/LogicUI/src/era/mi/components/gui/GUISplitter.java index b8a67f21..c6aa2182 100644 --- a/LogicUI/src/era/mi/components/gui/GUISplitter.java +++ b/LogicUI/src/era/mi/components/gui/GUISplitter.java @@ -9,6 +9,7 @@ import era.mi.logic.components.Splitter; 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 class GUISplitter extends Splitter implements BasicGUIComponent { @@ -41,6 +42,11 @@ public class GUISplitter extends Splitter implements BasicGUIComponent this.wireArrayConnectionPoints = Collections.unmodifiableList(wireArrayConnectionPointsModifiable); } + @Override + public Rectangle getBounds() + { + return new Rectangle(0, 0, 20, height); + } @Override public void render(GeneralGC gc) { -- 2.17.1