From ec8ad6118e59572f350e1650d4e1d1fd665c671d Mon Sep 17 00:00:00 2001 From: j-james Date: Sun, 27 Nov 2022 03:34:42 -0800 Subject: Begin implementation of the layout engine --- src/main/model/layout/DocumentLayout.java | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/main/model/layout/DocumentLayout.java (limited to 'src/main/model/layout/DocumentLayout.java') diff --git a/src/main/model/layout/DocumentLayout.java b/src/main/model/layout/DocumentLayout.java new file mode 100644 index 0000000..84f58f2 --- /dev/null +++ b/src/main/model/layout/DocumentLayout.java @@ -0,0 +1,25 @@ +package model.layout; + +import java.awt.*; + +public class DocumentLayout extends Layout { + + /* + * INCREDIBLY UNSAFE - but this is actually fine with our code design + * We only reference the node / parent layout from the child layout, + * and so as we aren't referencing them here it (should) be fine + */ + public DocumentLayout() { + super(null, null); + } + + public void layout() { + this.setLocation(new Point(0, 0)); + this.setDimension(new Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT)); + + for (Layout child : this.getChildren()) { + child.layout(); + this.setHeight(this.getHeight() + child.getHeight()); + } + } +} -- cgit v1.2.3-70-g09d2