Quellcode durchsuchen

Added some UI improvements to the IDE and performed some minor refactoring.

Stan Hebben vor 6 Jahren
Ursprung
Commit
5248b0747b
73 geänderte Dateien mit 1026 neuen und 230 gelöschten Zeilen
  1. 1
    2
      DrawableGui/src/main/java/org/openzen/drawablegui/DButton.java
  2. 1
    1
      DrawableGui/src/main/java/org/openzen/drawablegui/DCanvas.java
  3. 10
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/DPath.java
  4. 1
    1
      DrawableGui/src/main/java/org/openzen/drawablegui/DUIWindow.java
  5. 1
    2
      DrawableGui/src/main/java/org/openzen/drawablegui/border/DCustomWindowBorder.java
  6. 2
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/border/DEmptyBorder.java
  7. 81
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/border/DSideBorder.java
  8. 8
    1
      DrawableGui/src/main/java/org/openzen/drawablegui/layout/DHorizontalLayout.java
  9. 1
    1
      DrawableGui/src/main/java/org/openzen/drawablegui/layout/DHorizontalLayoutStyle.java
  10. 10
    2
      DrawableGui/src/main/java/org/openzen/drawablegui/layout/DSideLayout.java
  11. 20
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/layout/DSideLayoutStyle.java
  12. 49
    19
      DrawableGui/src/main/java/org/openzen/drawablegui/layout/DVerticalLayout.java
  13. 10
    1
      DrawableGui/src/main/java/org/openzen/drawablegui/layout/DVerticalLayoutStyle.java
  14. 30
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/live/InverseLiveBool.java
  15. 3
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/live/SimpleLiveInt.java
  16. 3
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/live/SimpleLiveObject.java
  17. 3
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/live/SimpleLiveString.java
  18. 5
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/style/DEmptyStyleDefinition.java
  19. 39
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/style/DMargin.java
  20. 20
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/style/DMarginElement.java
  21. 2
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/style/DPxDimension.java
  22. 1
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/style/DShadow.java
  23. 8
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/style/DSimpleStylesheet.java
  24. 2
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/style/DStyleDefinition.java
  25. 4
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/style/DStyleElement.java
  26. 5
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/style/DStylesheetBuilder.java
  27. 7
    2
      DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingCanvas.java
  28. 22
    3
      DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingDialog.java
  29. 6
    5
      DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingGraphicsContext.java
  30. 23
    3
      DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingInlineWindow.java
  31. 3
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingRoot.java
  32. 24
    3
      DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingWindow.java
  33. 36
    4
      IDE/src/main/java/org/openzen/zenscript/ide/Main.java
  34. 25
    0
      IDE/src/main/java/org/openzen/zenscript/ide/codemodel/IDECodeSpace.java
  35. 2
    0
      IDE/src/main/java/org/openzen/zenscript/ide/host/DevelopmentHost.java
  36. 26
    0
      IDE/src/main/java/org/openzen/zenscript/ide/host/IDEPropertyDirectory.java
  37. 16
    0
      IDE/src/main/java/org/openzen/zenscript/ide/host/IDEPropertyStore.java
  38. 2
    1
      IDE/src/main/java/org/openzen/zenscript/ide/host/IDESourceFile.java
  39. 57
    0
      IDE/src/main/java/org/openzen/zenscript/ide/host/local/FilePropertyStore.java
  40. 60
    0
      IDE/src/main/java/org/openzen/zenscript/ide/host/local/JSONPropertyDirectory.java
  41. 1
    1
      IDE/src/main/java/org/openzen/zenscript/ide/host/local/LocalPackage.java
  42. 7
    0
      IDE/src/main/java/org/openzen/zenscript/ide/host/local/LocalProjectDevelopmentHost.java
  43. 7
    2
      IDE/src/main/java/org/openzen/zenscript/ide/host/local/LocalSourceFile.java
  44. 0
    32
      IDE/src/main/java/org/openzen/zenscript/ide/ui/IDEWindow.java
  45. 4
    5
      IDE/src/main/java/org/openzen/zenscript/ide/ui/dialog/CreatePackageDialog.java
  46. 4
    4
      IDE/src/main/java/org/openzen/zenscript/ide/ui/dialog/CreateSourceFileDialog.java
  47. 1
    2
      IDE/src/main/java/org/openzen/zenscript/ide/ui/icons/AddBoxIcon.java
  48. 1
    2
      IDE/src/main/java/org/openzen/zenscript/ide/ui/icons/BuildIcon.java
  49. 1
    2
      IDE/src/main/java/org/openzen/zenscript/ide/ui/icons/PlayIcon.java
  50. 1
    2
      IDE/src/main/java/org/openzen/zenscript/ide/ui/icons/SettingsIcon.java
  51. 1
    2
      IDE/src/main/java/org/openzen/zenscript/ide/ui/icons/ShadedSaveIcon.java
  52. 4
    8
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/IconButtonControl.java
  53. 7
    0
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/TabbedView.java
  54. 6
    2
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/TabbedViewComponent.java
  55. 40
    7
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/TabbedViewTab.java
  56. 8
    0
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/TabbedViewTabStyle.java
  57. 11
    61
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/WindowView.java
  58. 1
    4
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/aspectbar/AspectBarSelectorButton.java
  59. 8
    1
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/aspectbar/AspectBarStyle.java
  60. 8
    9
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/aspectbar/AspectBarView.java
  61. 11
    2
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/SourceEditor.java
  62. 23
    0
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/output/BasicOutputSpan.java
  63. 23
    0
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/output/ErrorOutputSpan.java
  64. 26
    0
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/output/OutputLine.java
  65. 14
    0
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/output/OutputSpan.java
  66. 20
    0
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/output/OutputView.java
  67. 2
    2
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/project/LibraryTreeNode.java
  68. 3
    3
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/project/ModuleTreeNode.java
  69. 8
    9
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/project/PackageTreeNode.java
  70. 132
    0
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/project/ProjectBrowser.java
  71. 5
    6
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/project/ProjectTreeNode.java
  72. 3
    4
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/project/RootTreeNode.java
  73. 6
    7
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/project/SourceFileTreeNode.java

+ 1
- 2
DrawableGui/src/main/java/org/openzen/drawablegui/DButton.java Datei anzeigen

@@ -91,8 +91,7 @@ public class DButton implements DComponent {
91 91
 		}
92 92
 		
93 93
 		DPath shape = DPath.roundedRectangle(bounds.x, bounds.y, bounds.width, bounds.height, 2 * context.getScale());
94
-		canvas.shadowPath(shape, DTransform2D.IDENTITY, shadow);
95
-		canvas.fillPath(shape, DTransform2D.IDENTITY, backgroundColor);
94
+		canvas.shadowPath(shape, DTransform2D.IDENTITY, backgroundColor, shadow);
96 95
 		canvas.drawText(style.font, style.textColor, bounds.x + style.paddingLeft, bounds.y + style.paddingTop + fontMetrics.getAscent(), label.getValue());
97 96
 	}
98 97
 

+ 1
- 1
DrawableGui/src/main/java/org/openzen/drawablegui/DCanvas.java Datei anzeigen

@@ -52,7 +52,7 @@ public interface DCanvas {
52 52
 	 * @param transform
53 53
 	 * @param shadow
54 54
 	 */
55
-	void shadowPath(DPath path, DTransform2D transform, DShadow shadow);
55
+	void shadowPath(DPath path, DTransform2D transform, int color, DShadow shadow);
56 56
 	
57 57
 	/**
58 58
 	 * Fills a rectangle.

+ 10
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/DPath.java Datei anzeigen

@@ -10,6 +10,13 @@ package org.openzen.drawablegui;
10 10
  * @author Hoofdgebruiker
11 11
  */
12 12
 public interface DPath {
13
+	public static DPath line(float x1, float y1, float x2, float y2) {
14
+		return tracer -> {
15
+			tracer.moveTo(x1, y1);
16
+			tracer.lineTo(x2, y2);
17
+		};
18
+	}
19
+	
13 20
 	public static DPath circle(float x, float y, float radius) {
14 21
 		// see http://spencermortensen.com/articles/bezier-circle/
15 22
 		return tracer -> {
@@ -45,6 +52,9 @@ public interface DPath {
45 52
 	}
46 53
 	
47 54
 	public static DPath roundedRectangle(float x, float y, float width, float height, float radius) {
55
+		if (radius < 0.01f)
56
+			return rectangle(x, y, width, height);
57
+		
48 58
 		return tracer -> {
49 59
 			float c = radius - radius * 0.551915024494f;
50 60
 			tracer.moveTo(x + width - radius, y + height);

+ 1
- 1
DrawableGui/src/main/java/org/openzen/drawablegui/DUIWindow.java Datei anzeigen

@@ -13,7 +13,7 @@ import org.openzen.drawablegui.live.LiveObject;
13 13
  * @author Hoofdgebruiker
14 14
  */
15 15
 public interface DUIWindow {
16
-	DIRectangle getWindowBounds();
16
+	LiveObject<DIRectangle> getWindowBounds();
17 17
 	
18 18
 	DUIContext getContext();
19 19
 	

+ 1
- 2
DrawableGui/src/main/java/org/openzen/drawablegui/border/DCustomWindowBorder.java Datei anzeigen

@@ -120,8 +120,7 @@ public class DCustomWindowBorder implements DComponent {
120 120
 					|| canvasBounds.y < bounds.y + spacing
121 121
 					|| canvasBounds.x + canvasBounds.width > bounds.x + bounds.width - spacing
122 122
 					|| canvasBounds.y + canvasBounds.height > bounds.y + bounds.height - spacing) {
123
-				canvas.shadowPath(border, DTransform2D.IDENTITY, style.shadow);
124
-				canvas.fillPath(border, DTransform2D.IDENTITY, style.backgroundColor);
123
+				canvas.shadowPath(border, DTransform2D.IDENTITY, style.backgroundColor, style.shadow);
125 124
 				canvas.strokePath(
126 125
 						border,
127 126
 						DTransform2D.IDENTITY,

+ 2
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/border/DEmptyBorder.java Datei anzeigen

@@ -7,6 +7,7 @@ package org.openzen.drawablegui.border;
7 7
 
8 8
 import org.openzen.drawablegui.DCanvas;
9 9
 import org.openzen.drawablegui.DIRectangle;
10
+import org.openzen.drawablegui.style.DBorderElement;
10 11
 
11 12
 /**
12 13
  *
@@ -14,6 +15,7 @@ import org.openzen.drawablegui.DIRectangle;
14 15
  */
15 16
 public class DEmptyBorder implements DBorder {
16 17
 	public static final DEmptyBorder INSTANCE = new DEmptyBorder();
18
+	public static final DBorderElement ELEMENT = context -> INSTANCE;
17 19
 	
18 20
 	private DEmptyBorder() {}
19 21
 	

+ 81
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/border/DSideBorder.java Datei anzeigen

@@ -0,0 +1,81 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.drawablegui.border;
7
+
8
+import org.openzen.drawablegui.DCanvas;
9
+import org.openzen.drawablegui.DIRectangle;
10
+import org.openzen.drawablegui.DPath;
11
+import org.openzen.drawablegui.DTransform2D;
12
+
13
+/**
14
+ *
15
+ * @author Hoofdgebruiker
16
+ */
17
+public class DSideBorder implements DBorder {
18
+	public final int leftWidth;
19
+	public final int leftColor;
20
+	public final int topWidth;
21
+	public final int topColor;
22
+	public final int rightWidth;
23
+	public final int rightColor;
24
+	public final int bottomWidth;
25
+	public final int bottomColor;
26
+	
27
+	public DSideBorder(
28
+			int leftWidth, int leftColor,
29
+			int topWidth, int topColor,
30
+			int rightWidth, int rightColor,
31
+			int bottomWidth, int bottomColor) {
32
+		this.leftWidth = leftWidth;
33
+		this.leftColor = leftColor;
34
+		this.topWidth = topWidth;
35
+		this.topColor = topColor;
36
+		this.rightWidth = rightWidth;
37
+		this.rightColor = rightColor;
38
+		this.bottomWidth = bottomWidth;
39
+		this.bottomColor = bottomColor;
40
+	}
41
+
42
+	@Override
43
+	public void paint(DCanvas canvas, DIRectangle bounds) {
44
+		if (leftWidth > 0) {
45
+			int x = bounds.x;
46
+			canvas.strokePath(DPath.line(x, bounds.y, x, bounds.y + bounds.height), DTransform2D.IDENTITY, topColor, topWidth);
47
+		}
48
+		if (topWidth > 0) {
49
+			int y = bounds.y;
50
+			canvas.strokePath(DPath.line(bounds.x, y, bounds.x + bounds.width, y), DTransform2D.IDENTITY, topColor, topWidth);
51
+		}
52
+		if (rightWidth > 0) {
53
+			int x = bounds.x + bounds.width - rightWidth;
54
+			canvas.strokePath(DPath.line(x, bounds.y, x, bounds.y + bounds.height), DTransform2D.IDENTITY, topColor, topWidth);
55
+		}
56
+		if (bottomWidth > 0) {
57
+			int y = bounds.y + bounds.height - bottomWidth;
58
+			canvas.strokePath(DPath.line(bounds.x, y, bounds.x + bounds.width, y), DTransform2D.IDENTITY, topColor, topWidth);
59
+		}
60
+	}
61
+
62
+	@Override
63
+	public int getPaddingLeft() {
64
+		return leftWidth;
65
+	}
66
+
67
+	@Override
68
+	public int getPaddingRight() {
69
+		return rightWidth;
70
+	}
71
+
72
+	@Override
73
+	public int getPaddingTop() {
74
+		return topWidth;
75
+	}
76
+
77
+	@Override
78
+	public int getPaddingBottom() {
79
+		return bottomWidth;
80
+	}
81
+}

DrawableGui/src/main/java/org/openzen/drawablegui/DHorizontalLayout.java → DrawableGui/src/main/java/org/openzen/drawablegui/layout/DHorizontalLayout.java Datei anzeigen

@@ -3,10 +3,16 @@
3 3
  * To change this template file, choose Tools | Templates
4 4
  * and open the template in the editor.
5 5
  */
6
-package org.openzen.drawablegui;
6
+package org.openzen.drawablegui.layout;
7 7
 
8 8
 import java.util.function.Consumer;
9 9
 import java.util.function.Predicate;
10
+import org.openzen.drawablegui.BaseComponentGroup;
11
+import org.openzen.drawablegui.DCanvas;
12
+import org.openzen.drawablegui.DComponent;
13
+import org.openzen.drawablegui.DIRectangle;
14
+import org.openzen.drawablegui.DSizing;
15
+import org.openzen.drawablegui.DUIContext;
10 16
 import org.openzen.drawablegui.listeners.ListenerHandle;
11 17
 import org.openzen.drawablegui.live.LiveObject;
12 18
 import org.openzen.drawablegui.live.MutableLiveObject;
@@ -99,6 +105,7 @@ public class DHorizontalLayout extends BaseComponentGroup {
99 105
 	@Override
100 106
 	public void paint(DCanvas canvas) {
101 107
 		canvas.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height, style.backgroundColor);
108
+		style.border.paint(canvas, bounds);
102 109
 		for (Element element : components) {
103 110
 			element.component.paint(canvas);
104 111
 		}

DrawableGui/src/main/java/org/openzen/drawablegui/DHorizontalLayoutStyle.java → DrawableGui/src/main/java/org/openzen/drawablegui/layout/DHorizontalLayoutStyle.java Datei anzeigen

@@ -3,7 +3,7 @@
3 3
  * To change this template file, choose Tools | Templates
4 4
  * and open the template in the editor.
5 5
  */
6
-package org.openzen.drawablegui;
6
+package org.openzen.drawablegui.layout;
7 7
 
8 8
 import org.openzen.drawablegui.border.DBorder;
9 9
 import org.openzen.drawablegui.border.DPaddedBorder;

DrawableGui/src/main/java/org/openzen/drawablegui/DSideLayout.java → DrawableGui/src/main/java/org/openzen/drawablegui/layout/DSideLayout.java Datei anzeigen

@@ -3,17 +3,22 @@
3 3
  * To change this template file, choose Tools | Templates
4 4
  * and open the template in the editor.
5 5
  */
6
-package org.openzen.drawablegui;
6
+package org.openzen.drawablegui.layout;
7 7
 
8 8
 import java.io.Closeable;
9 9
 import java.util.ArrayList;
10 10
 import java.util.List;
11 11
 import java.util.function.Consumer;
12 12
 import java.util.function.Predicate;
13
+import org.openzen.drawablegui.BaseComponentGroup;
14
+import org.openzen.drawablegui.DCanvas;
15
+import org.openzen.drawablegui.DComponent;
16
+import org.openzen.drawablegui.DIRectangle;
17
+import org.openzen.drawablegui.DSizing;
18
+import org.openzen.drawablegui.DUIContext;
13 19
 import org.openzen.drawablegui.listeners.ListenerHandle;
14 20
 import org.openzen.drawablegui.live.LiveObject;
15 21
 import org.openzen.drawablegui.live.MutableLiveObject;
16
-import org.openzen.drawablegui.live.SimpleLiveObject;
17 22
 import org.openzen.drawablegui.style.DStyleClass;
18 23
 import org.openzen.drawablegui.style.DStylePath;
19 24
 
@@ -30,6 +35,7 @@ public class DSideLayout extends BaseComponentGroup {
30 35
 	
31 36
 	private DStylePath path;
32 37
 	private DUIContext context;
38
+	private DSideLayoutStyle style;
33 39
 	private DIRectangle bounds;
34 40
 	
35 41
 	public DSideLayout(DStyleClass styleClass, DComponent main) {
@@ -61,6 +67,7 @@ public class DSideLayout extends BaseComponentGroup {
61 67
 	public void setContext(DStylePath parent, DUIContext context) {
62 68
 		this.context = context;
63 69
 		this.path = parent.getChild("sidelayout", styleClass);
70
+		style = new DSideLayoutStyle(context.getStylesheets().get(context, path));
64 71
 		
65 72
 		main.setContext(path, context);
66 73
 		for (SideComponent side : sides)
@@ -169,6 +176,7 @@ public class DSideLayout extends BaseComponentGroup {
169 176
 
170 177
 	@Override
171 178
 	public void paint(DCanvas canvas) {
179
+		canvas.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height, style.backgroundColor);
172 180
 		main.paint(canvas);
173 181
 		
174 182
 		for (SideComponent component : sides)

+ 20
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/layout/DSideLayoutStyle.java Datei anzeigen

@@ -0,0 +1,20 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.drawablegui.layout;
7
+
8
+import org.openzen.drawablegui.style.DStyleDefinition;
9
+
10
+/**
11
+ *
12
+ * @author Hoofdgebruiker
13
+ */
14
+public class DSideLayoutStyle {
15
+	public final int backgroundColor;
16
+	
17
+	public DSideLayoutStyle(DStyleDefinition style) {
18
+		backgroundColor = style.getColor("backgroundColor", 0);
19
+	}
20
+}

DrawableGui/src/main/java/org/openzen/drawablegui/DVerticalLayout.java → DrawableGui/src/main/java/org/openzen/drawablegui/layout/DVerticalLayout.java Datei anzeigen

@@ -3,14 +3,21 @@
3 3
  * To change this template file, choose Tools | Templates
4 4
  * and open the template in the editor.
5 5
  */
6
-package org.openzen.drawablegui;
6
+package org.openzen.drawablegui.layout;
7 7
 
8 8
 import java.util.function.Consumer;
9 9
 import java.util.function.Predicate;
10
+import org.openzen.drawablegui.BaseComponentGroup;
11
+import org.openzen.drawablegui.DCanvas;
12
+import org.openzen.drawablegui.DComponent;
13
+import org.openzen.drawablegui.DIRectangle;
14
+import org.openzen.drawablegui.DPath;
15
+import org.openzen.drawablegui.DSizing;
16
+import org.openzen.drawablegui.DTransform2D;
17
+import org.openzen.drawablegui.DUIContext;
10 18
 import org.openzen.drawablegui.listeners.ListenerHandle;
11 19
 import org.openzen.drawablegui.live.LiveObject;
12 20
 import org.openzen.drawablegui.live.MutableLiveObject;
13
-import org.openzen.drawablegui.live.SimpleLiveObject;
14 21
 import org.openzen.drawablegui.style.DStyleClass;
15 22
 import org.openzen.drawablegui.style.DStylePath;
16 23
 
@@ -30,6 +37,7 @@ public class DVerticalLayout extends BaseComponentGroup {
30 37
 	private DIRectangle bounds;
31 38
 	private float totalGrow;
32 39
 	private float totalShrink;
40
+	private DPath shape;
33 41
 	
34 42
 	public DVerticalLayout(DStyleClass styleClass, Alignment alignment, Element... components) {
35 43
 		this.styleClass = styleClass;
@@ -92,12 +100,18 @@ public class DVerticalLayout extends BaseComponentGroup {
92 100
 	@Override
93 101
 	public void setBounds(DIRectangle bounds) {
94 102
 		this.bounds = bounds;
103
+		shape = DPath.roundedRectangle(
104
+				bounds.x + style.margin.left,
105
+				bounds.y + style.margin.top,
106
+				bounds.width - style.margin.getHorizontal(),
107
+				bounds.height - style.margin.getVertical(),
108
+				style.cornerRadius);
95 109
 		layout();
96 110
 	}
97 111
 
98 112
 	@Override
99 113
 	public void paint(DCanvas canvas) {
100
-		canvas.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height, style.backgroundColor);
114
+		canvas.shadowPath(shape, DTransform2D.IDENTITY, style.backgroundColor, style.shadow);
101 115
 		for (Element element : components) {
102 116
 			element.component.paint(canvas);
103 117
 		}
@@ -155,13 +169,31 @@ public class DVerticalLayout extends BaseComponentGroup {
155 169
 		}
156 170
 	}
157 171
 	
158
-	private void layoutShrinked() {
172
+	private int getInnerWidth() {
173
+		return bounds.width - style.margin.getHorizontal() - style.border.getPaddingHorizontal();
174
+	}
175
+	
176
+	private int getInnerHeight() {
177
+		return bounds.height - style.margin.getVertical() - style.border.getPaddingVertical();
178
+	}
179
+	
180
+	private int getPreferredInnerWidth() {
181
+		DSizing myPreferences = sizing.getValue();
182
+		return myPreferences.preferredWidth - style.margin.getHorizontal() - style.border.getPaddingHorizontal();
183
+	}
184
+	
185
+	private int getPreferredInnerHeight() {
159 186
 		DSizing myPreferences = sizing.getValue();
187
+		return myPreferences.preferredHeight - style.margin.getVertical() - style.border.getPaddingVertical();
188
+	}
189
+	
190
+	private void layoutShrinked() {
160 191
 		if (totalShrink == 0) {
161 192
 			// now what?
162 193
 			// shrink proportionally, we have to shrink...
163
-			float scale = (float)(bounds.height - (components.length - 1) * style.spacing) / (myPreferences.preferredHeight - (components.length - 1) * style.spacing);
164
-			int y = 0;
194
+			float availableHeight = getInnerHeight() - (components.length - 1) * style.spacing;
195
+			float scale = (float)(availableHeight) / (getPreferredInnerHeight() - (components.length - 1) * style.spacing);
196
+			int y = bounds.y + style.margin.top + style.border.getPaddingTop();
165 197
 			
166 198
 			for (int i = 0; i < components.length; i++) {
167 199
 				Element element = components[i];
@@ -173,7 +205,7 @@ public class DVerticalLayout extends BaseComponentGroup {
173 205
 				y = idealY;
174 206
 			}
175 207
 		} else {
176
-			int delta = bounds.height - myPreferences.preferredHeight;
208
+			int delta = getInnerHeight() - getPreferredInnerHeight();
177 209
 			float deltaScaled = delta / totalShrink;
178 210
 			int y = bounds.y;
179 211
 			for (Element element : components) {
@@ -189,11 +221,9 @@ public class DVerticalLayout extends BaseComponentGroup {
189 221
 	
190 222
 	private void layoutGrown() {
191 223
 		// resize according to grow values
192
-		DSizing myPreferences = sizing.getValue();
193
-		
194 224
 		if (totalGrow == 0) {
195
-			int deltaY = (int)(myPreferences.preferredHeight - bounds.height);
196
-			int y = bounds.y + (int)(deltaY * alignment.align);
225
+			int deltaY = getPreferredInnerHeight() - getInnerHeight();
226
+			int y = bounds.y + style.margin.top + style.border.getPaddingTop() + (int)(deltaY * alignment.align);
197 227
 			for (Element element : components) {
198 228
 				DSizing preferences = element.component.getSizing().getValue();
199 229
 				int newY = y + preferences.preferredHeight;
@@ -201,9 +231,9 @@ public class DVerticalLayout extends BaseComponentGroup {
201 231
 				y = newY;
202 232
 			}
203 233
 		} else {
204
-			int delta = bounds.width - myPreferences.preferredWidth;
234
+			int delta = getPreferredInnerHeight() - getInnerHeight();
205 235
 			float deltaScaled = delta / totalGrow;
206
-			int y = bounds.y;
236
+			int y = bounds.y + style.margin.top + style.border.getPaddingTop();
207 237
 			for (Element element : components) {
208 238
 				DSizing preferences = element.component.getSizing().getValue();
209 239
 				float scaledSize = preferences.preferredHeight + deltaScaled * element.grow;
@@ -221,21 +251,21 @@ public class DVerticalLayout extends BaseComponentGroup {
221 251
 		int width;
222 252
 		switch (element.alignment) {
223 253
 			case LEFT:
224
-				width = Math.min(preferences.preferredWidth, bounds.width - style.border.getPaddingHorizontal());
225
-				x = bounds.x + style.border.getPaddingLeft();
254
+				width = Math.min(preferences.preferredWidth, bounds.width - style.border.getPaddingHorizontal() - style.margin.getHorizontal());
255
+				x = bounds.x + style.margin.left + style.border.getPaddingLeft();
226 256
 				break;
227 257
 			case CENTER:
228 258
 				width = Math.min(preferences.preferredWidth, bounds.width - style.border.getPaddingHorizontal());
229
-				x = bounds.x + style.border.getPaddingLeft() + (bounds.width - style.border.getPaddingHorizontal() - width) / 2;
259
+				x = bounds.x + style.margin.left + style.border.getPaddingLeft() + (bounds.width - style.border.getPaddingHorizontal() - width) / 2;
230 260
 				break;
231 261
 			case RIGHT:
232 262
 				width = Math.min(preferences.preferredWidth, bounds.width - style.border.getPaddingHorizontal());
233
-				x = bounds.x + bounds.width - style.border.getPaddingLeft() - width;
263
+				x = bounds.x + bounds.width - style.margin.right - style.border.getPaddingRight() - width;
234 264
 				break;
235 265
 			case STRETCH:
236 266
 			default:
237
-				width = bounds.width - style.border.getPaddingHorizontal();
238
-				x = bounds.x + style.border.getPaddingLeft();
267
+				width = bounds.width - style.border.getPaddingHorizontal() - style.margin.getHorizontal();
268
+				x = bounds.x + style.margin.left + style.border.getPaddingLeft();
239 269
 				break;
240 270
 		}
241 271
 		element.component.setBounds(new DIRectangle(x, y, width, height));

DrawableGui/src/main/java/org/openzen/drawablegui/DVerticalLayoutStyle.java → DrawableGui/src/main/java/org/openzen/drawablegui/layout/DVerticalLayoutStyle.java Datei anzeigen

@@ -3,11 +3,14 @@
3 3
  * To change this template file, choose Tools | Templates
4 4
  * and open the template in the editor.
5 5
  */
6
-package org.openzen.drawablegui;
6
+package org.openzen.drawablegui.layout;
7 7
 
8 8
 import org.openzen.drawablegui.border.DBorder;
9 9
 import org.openzen.drawablegui.border.DPaddedBorder;
10 10
 import org.openzen.drawablegui.style.DDpDimension;
11
+import org.openzen.drawablegui.style.DMargin;
12
+import org.openzen.drawablegui.style.DPxDimension;
13
+import org.openzen.drawablegui.style.DShadow;
11 14
 import org.openzen.drawablegui.style.DStyleDefinition;
12 15
 
13 16
 /**
@@ -18,10 +21,16 @@ public class DVerticalLayoutStyle {
18 21
 	public final int spacing;
19 22
 	public final DBorder border;
20 23
 	public final int backgroundColor;
24
+	public final DMargin margin;
25
+	public final int cornerRadius;
26
+	public final DShadow shadow;
21 27
 	
22 28
 	public DVerticalLayoutStyle(DStyleDefinition style) {
23 29
 		spacing = style.getDimension("spacing", new DDpDimension(8));
24 30
 		border = style.getBorder("border", context -> new DPaddedBorder(context.dp(8)));
25 31
 		backgroundColor = style.getColor("backgroundColor", 0);
32
+		margin = style.getMargin("margin", DMargin.EMPTY_ELEMENT);
33
+		cornerRadius = style.getDimension("cornerRadius", DPxDimension.ZERO);
34
+		shadow = style.getShadow("shadow", DShadow.NONE_ELEMENT);
26 35
 	}
27 36
 }

+ 30
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/live/InverseLiveBool.java Datei anzeigen

@@ -0,0 +1,30 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.drawablegui.live;
7
+
8
+import org.openzen.drawablegui.listeners.ListenerHandle;
9
+
10
+/**
11
+ *
12
+ * @author Hoofdgebruiker
13
+ */
14
+public class InverseLiveBool implements LiveBool {
15
+	private final LiveBool source;
16
+	
17
+	public InverseLiveBool(LiveBool source) {
18
+		this.source = source;
19
+	}
20
+
21
+	@Override
22
+	public boolean getValue() {
23
+		return !source.getValue();
24
+	}
25
+
26
+	@Override
27
+	public ListenerHandle<Listener> addListener(Listener listener) {
28
+		return source.addListener((oldValue, newValue) -> listener.onChanged(!oldValue, !newValue));
29
+	}
30
+}

+ 3
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/live/SimpleLiveInt.java Datei anzeigen

@@ -23,6 +23,9 @@ public class SimpleLiveInt implements LiveInt {
23 23
 
24 24
 	@Override
25 25
 	public void setValue(int value) {
26
+		if (value == this.value)
27
+			return;
28
+		
26 29
 		int oldValue = this.value;
27 30
 		this.value = value;
28 31
 		listeners.accept(listener -> listener.onChanged(oldValue, value));

+ 3
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/live/SimpleLiveObject.java Datei anzeigen

@@ -27,6 +27,9 @@ public class SimpleLiveObject<T> implements MutableLiveObject<T> {
27 27
 	
28 28
 	@Override
29 29
 	public void setValue(T value) {
30
+		if (value == this.value)
31
+			return;
32
+		
30 33
 		T oldValue = this.value;
31 34
 		this.value = value;
32 35
 		listeners.accept(listener -> listener.onUpdated(oldValue, value));

+ 3
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/live/SimpleLiveString.java Datei anzeigen

@@ -33,6 +33,9 @@ public class SimpleLiveString implements MutableLiveString {
33 33
 
34 34
 	@Override
35 35
 	public void setValue(String value) {
36
+		if (value.equals(this.value))
37
+			return;
38
+		
36 39
 		String oldValue = this.value;
37 40
 		this.value = value;
38 41
 		listeners.accept(listener -> listener.onChanged(oldValue, value));

+ 5
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/style/DEmptyStyleDefinition.java Datei anzeigen

@@ -49,4 +49,9 @@ public class DEmptyStyleDefinition implements DStyleDefinition {
49 49
 	public DBorder getBorder(String name, DBorderElement defaultValue) {
50 50
 		return defaultValue.eval(context);
51 51
 	}
52
+	
53
+	@Override
54
+	public DMargin getMargin(String name, DMarginElement defaultValue) {
55
+		return defaultValue.eval(context);
56
+	}
52 57
 }

+ 39
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/style/DMargin.java Datei anzeigen

@@ -0,0 +1,39 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.drawablegui.style;
7
+
8
+/**
9
+ *
10
+ * @author Hoofdgebruiker
11
+ */
12
+public class DMargin {
13
+	public static final DMargin EMPTY = new DMargin(0);
14
+	public static final DMarginElement EMPTY_ELEMENT = context -> EMPTY;
15
+	
16
+	public final int left;
17
+	public final int right;
18
+	public final int top;
19
+	public final int bottom;
20
+	
21
+	public DMargin(int left, int right, int top, int bottom) {
22
+		this.left = left;
23
+		this.right = right;
24
+		this.top = top;
25
+		this.bottom = bottom;
26
+	}
27
+	
28
+	public DMargin(int amount) {
29
+		this(amount, amount, amount, amount);
30
+	}
31
+	
32
+	public int getVertical() {
33
+		return top + bottom;
34
+	}
35
+	
36
+	public int getHorizontal() {
37
+		return left + right;
38
+	}
39
+}

+ 20
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/style/DMarginElement.java Datei anzeigen

@@ -0,0 +1,20 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.drawablegui.style;
7
+
8
+import org.openzen.drawablegui.DUIContext;
9
+
10
+/**
11
+ *
12
+ * @author Hoofdgebruiker
13
+ */
14
+public interface DMarginElement extends DStyleElement {
15
+	DMargin eval(DUIContext context);
16
+	
17
+	default DMarginElement asMargin() {
18
+		return this;
19
+	}
20
+}

+ 2
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/style/DPxDimension.java Datei anzeigen

@@ -12,6 +12,8 @@ import org.openzen.drawablegui.DUIContext;
12 12
  * @author Hoofdgebruiker
13 13
  */
14 14
 public class DPxDimension implements DDimension {
15
+	public static final DPxDimension ZERO = new DPxDimension(0);
16
+	
15 17
 	private final float pixels;
16 18
 	
17 19
 	public DPxDimension(float pixels) {

+ 1
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/style/DShadow.java Datei anzeigen

@@ -11,6 +11,7 @@ package org.openzen.drawablegui.style;
11 11
  */
12 12
 public class DShadow {
13 13
 	public static final DShadow NONE = new DShadow(0, 0, 0, 0);
14
+	public static final DShadowElement NONE_ELEMENT = context -> NONE;
14 15
 	
15 16
 	public final int color;
16 17
 	public final float offsetX;

+ 8
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/style/DSimpleStylesheet.java Datei anzeigen

@@ -80,5 +80,13 @@ public class DSimpleStylesheet implements DStylesheet {
80 80
 			
81 81
 			return elements.get(name).asBorder().eval(context);
82 82
 		}
83
+		
84
+		@Override
85
+		public DMargin getMargin(String name, DMarginElement defaultValue) {
86
+			if (!elements.containsKey(name))
87
+				return defaultValue.eval(context);
88
+			
89
+			return elements.get(name).asMargin().eval(context);
90
+		}
83 91
 	}
84 92
 }

+ 2
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/style/DStyleDefinition.java Datei anzeigen

@@ -24,4 +24,6 @@ public interface DStyleDefinition {
24 24
 	public DFont getFont(String name, DFontElement defaultValue);
25 25
 	
26 26
 	public DBorder getBorder(String name, DBorderElement defaultValue);
27
+	
28
+	public DMargin getMargin(String name, DMarginElement defaultValue);
27 29
 }

+ 4
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/style/DStyleElement.java Datei anzeigen

@@ -31,6 +31,10 @@ public interface DStyleElement {
31 31
 		throw new RuntimeException("Not a border!");
32 32
 	}
33 33
 	
34
+	default DMarginElement asMargin() {
35
+		throw new RuntimeException("Not a margin!");
36
+	}
37
+	
34 38
 	default DShadowElement asShadow() {
35 39
 		throw new RuntimeException("Not a shadow!");
36 40
 	}

+ 5
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/style/DStylesheetBuilder.java Datei anzeigen

@@ -50,6 +50,11 @@ public class DStylesheetBuilder {
50 50
 		return this;
51 51
 	}
52 52
 	
53
+	public DStylesheetBuilder marginDp(String name, float value) {
54
+		elements.put(name, (DMarginElement)context -> new DMargin(context.dp(value)));
55
+		return this;
56
+	}
57
+	
53 58
 	public DStylesheet build() {
54 59
 		return new DSimpleStylesheet(elements);
55 60
 	}

+ 7
- 2
DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingCanvas.java Datei anzeigen

@@ -118,12 +118,15 @@ public class SwingCanvas implements DCanvas {
118 118
 	}
119 119
 
120 120
 	@Override
121
-	public void shadowPath(DPath path, DTransform2D transform, DShadow shadow) {
122
-		if (shadow.color == 0)
121
+	public void shadowPath(DPath path, DTransform2D transform, int color, DShadow shadow) {
122
+		if (shadow.color == 0) {
123
+			fillPath(path, transform, color);
123 124
 			return;
125
+		}
124 126
 		
125 127
 		if (shadow.radius == 0) {
126 128
 			fillPath(path, transform, shadow.color);
129
+			fillPath(path, transform, color);
127 130
 			return;
128 131
 		}
129 132
 		
@@ -143,6 +146,8 @@ public class SwingCanvas implements DCanvas {
143 146
 		image = getGaussianBlurFilter((int)Math.ceil(shadow.radius), true).filter(image, null);
144 147
 		image = getGaussianBlurFilter((int)Math.ceil(shadow.radius), false).filter(image, null);
145 148
 		g.drawImage(image, bounds.x - offset, bounds.y - offset, null);
149
+		
150
+		fillPath(path, transform, color);
146 151
 	}
147 152
 
148 153
 	@Override

+ 22
- 3
DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingDialog.java Datei anzeigen

@@ -7,6 +7,8 @@ package org.openzen.drawablegui.swing;
7 7
 
8 8
 import java.awt.BorderLayout;
9 9
 import java.awt.Color;
10
+import java.awt.event.ComponentAdapter;
11
+import java.awt.event.ComponentEvent;
10 12
 import java.awt.event.WindowEvent;
11 13
 import java.awt.event.WindowListener;
12 14
 import java.awt.event.WindowStateListener;
@@ -20,6 +22,7 @@ import org.openzen.drawablegui.DUIWindow;
20 22
 import org.openzen.drawablegui.border.DCustomWindowBorder;
21 23
 import org.openzen.drawablegui.live.LiveBool;
22 24
 import org.openzen.drawablegui.live.LiveObject;
25
+import org.openzen.drawablegui.live.MutableLiveObject;
23 26
 import org.openzen.drawablegui.live.SimpleLiveBool;
24 27
 import org.openzen.drawablegui.live.SimpleLiveObject;
25 28
 import org.openzen.drawablegui.style.DStyleClass;
@@ -33,6 +36,7 @@ public final class SwingDialog extends JDialog implements WindowListener, Window
33 36
 	private final boolean noTitleBar;
34 37
 	private final SimpleLiveObject<State> state = new SimpleLiveObject<>(State.NORMAL);
35 38
 	private final SimpleLiveBool active = new SimpleLiveBool(true);
39
+	private final MutableLiveObject<DIRectangle> bounds = new SimpleLiveObject<>(DIRectangle.EMPTY);
36 40
 	
37 41
 	public SwingDialog(SwingWindow owner, String title, DComponent root, boolean noTitleBar) {
38 42
 		super(owner, title);
@@ -46,6 +50,17 @@ public final class SwingDialog extends JDialog implements WindowListener, Window
46 50
 		
47 51
 		addWindowListener(this);
48 52
 		addWindowStateListener(this);
53
+		addComponentListener(new ComponentAdapter() {
54
+			@Override
55
+			public void componentMoved(ComponentEvent componentEvent) {
56
+				updateBounds();
57
+			}
58
+			
59
+			@Override
60
+			public void componentResized(ComponentEvent componentEvent) {
61
+				updateBounds();
62
+			}
63
+		});
49 64
 		
50 65
 		getContentPane().add(swingComponent = new SwingRoot(root), BorderLayout.CENTER);
51 66
 		swingComponent.setWindow(this);
@@ -76,8 +91,8 @@ public final class SwingDialog extends JDialog implements WindowListener, Window
76 91
 	}
77 92
 
78 93
 	@Override
79
-	public DIRectangle getWindowBounds() {
80
-		return new DIRectangle(getX(), getY(), getWidth(), getHeight());
94
+	public LiveObject<DIRectangle> getWindowBounds() {
95
+		return bounds;
81 96
 	}
82 97
 
83 98
 	@Override
@@ -135,7 +150,7 @@ public final class SwingDialog extends JDialog implements WindowListener, Window
135 150
 
136 151
 	@Override
137 152
 	public void windowOpened(WindowEvent e) {
138
-		
153
+		updateBounds();
139 154
 	}
140 155
 
141 156
 	@Override
@@ -173,6 +188,10 @@ public final class SwingDialog extends JDialog implements WindowListener, Window
173 188
 		state.setValue(getStateFromWindowState());
174 189
 	}
175 190
 	
191
+	private void updateBounds() {
192
+		bounds.setValue(new DIRectangle(getX(), getY(), getWidth(), getHeight()));
193
+	}
194
+	
176 195
 	private State getStateFromWindowState() {
177 196
 		/*switch (ge()) {
178 197
 			case NORMAL:

+ 6
- 5
DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingGraphicsContext.java Datei anzeigen

@@ -150,15 +150,18 @@ public class SwingGraphicsContext implements DUIContext {
150 150
 
151 151
 	@Override
152 152
 	public DUIWindow openDialog(int x, int y, DAnchor anchor, String title, DComponent root) {
153
-		SwingDialog window = new SwingDialog((SwingWindow)this.window, title, root, false);
153
+		SwingWindow swingWindow = (SwingWindow)this.window;
154
+		SwingDialog window = new SwingDialog(swingWindow, title, root, false);
154 155
 		SwingGraphicsContext windowContext = new SwingGraphicsContext(stylesheets, scale, textScale, window.swingComponent);
155 156
 		windowContext.setWindow(window);
156 157
 		windowContext.graphics = this.graphics; // help a little...
157 158
 		
159
+		Point rootLocation = swingWindow.swingComponent.getLocationOnScreen();
160
+		
158 161
 		root.setContext(DStylePathRoot.INSTANCE, windowContext);
159 162
 		DSizing dimension = root.getSizing().getValue();
160
-		int tx = (int)(x - anchor.alignX * dimension.preferredWidth);
161
-		int ty = (int)(y - anchor.alignY * dimension.preferredHeight);
163
+		int tx = (int)(x + rootLocation.x - anchor.alignX * dimension.preferredWidth);
164
+		int ty = (int)(y + rootLocation.y - anchor.alignY * dimension.preferredHeight);
162 165
 		
163 166
 		window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
164 167
 		window.swingComponent.setPreferredSize(new Dimension(dimension.preferredWidth, dimension.preferredHeight));
@@ -183,7 +186,6 @@ public class SwingGraphicsContext implements DUIContext {
183 186
 		
184 187
 		int tx = (int)(x + rootLocation.x - anchor.alignX * dimension.preferredWidth);
185 188
 		int ty = (int)(y + rootLocation.y - anchor.alignY * dimension.preferredHeight);
186
-		System.out.println("Position: " + tx + ", " + ty);
187 189
 		
188 190
 		window.swingComponent.setPreferredSize(new Dimension(dimension.preferredWidth, dimension.preferredHeight));
189 191
 		window.setLocation(tx, ty);
@@ -191,7 +193,6 @@ public class SwingGraphicsContext implements DUIContext {
191 193
 		window.setVisible(true);
192 194
 		window.swingComponent.repaint();
193 195
 		
194
-		System.out.println("Window size: " + window.getWidth() + " x " + window.getHeight());
195 196
 		return window;
196 197
 	}
197 198
 	

+ 23
- 3
DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingInlineWindow.java Datei anzeigen

@@ -6,6 +6,8 @@
6 6
 package org.openzen.drawablegui.swing;
7 7
 
8 8
 import java.awt.BorderLayout;
9
+import java.awt.event.ComponentAdapter;
10
+import java.awt.event.ComponentEvent;
9 11
 import java.awt.event.WindowEvent;
10 12
 import java.awt.event.WindowListener;
11 13
 import java.awt.event.WindowStateListener;
@@ -17,7 +19,9 @@ import org.openzen.drawablegui.DUIWindow;
17 19
 import org.openzen.drawablegui.live.ImmutableLiveObject;
18 20
 import org.openzen.drawablegui.live.LiveBool;
19 21
 import org.openzen.drawablegui.live.LiveObject;
22
+import org.openzen.drawablegui.live.MutableLiveObject;
20 23
 import org.openzen.drawablegui.live.SimpleLiveBool;
24
+import org.openzen.drawablegui.live.SimpleLiveObject;
21 25
 
22 26
 /**
23 27
  *
@@ -27,6 +31,7 @@ public final class SwingInlineWindow extends JWindow implements WindowListener,
27 31
 	public final SwingRoot swingComponent;
28 32
 	private final LiveObject<State> state = new ImmutableLiveObject<>(State.NORMAL);
29 33
 	private final SimpleLiveBool active = new SimpleLiveBool(true);
34
+	private final MutableLiveObject<DIRectangle> bounds = new SimpleLiveObject<>(DIRectangle.EMPTY);
30 35
 	
31 36
 	public SwingInlineWindow(SwingWindow owner, String title, DComponent root) {
32 37
 		super(owner);
@@ -37,6 +42,17 @@ public final class SwingInlineWindow extends JWindow implements WindowListener,
37 42
 		getContentPane().add(swingComponent = new SwingRoot(root), BorderLayout.CENTER);
38 43
 		swingComponent.setWindow(this);
39 44
 		swingComponent.requestFocusInWindow();
45
+		addComponentListener(new ComponentAdapter() {
46
+			@Override
47
+			public void componentMoved(ComponentEvent componentEvent) {
48
+				updateBounds();
49
+			}
50
+			
51
+			@Override
52
+			public void componentResized(ComponentEvent componentEvent) {
53
+				updateBounds();
54
+			}
55
+		});
40 56
 	}
41 57
 	
42 58
 	@Override
@@ -45,8 +61,8 @@ public final class SwingInlineWindow extends JWindow implements WindowListener,
45 61
 	}
46 62
 
47 63
 	@Override
48
-	public DIRectangle getWindowBounds() {
49
-		return new DIRectangle(getX(), getY(), getWidth(), getHeight());
64
+	public LiveObject<DIRectangle> getWindowBounds() {
65
+		return bounds;
50 66
 	}
51 67
 
52 68
 	@Override
@@ -96,7 +112,7 @@ public final class SwingInlineWindow extends JWindow implements WindowListener,
96 112
 
97 113
 	@Override
98 114
 	public void windowOpened(WindowEvent e) {
99
-		
115
+		updateBounds();
100 116
 	}
101 117
 
102 118
 	@Override
@@ -133,4 +149,8 @@ public final class SwingInlineWindow extends JWindow implements WindowListener,
133 149
 	public void windowStateChanged(WindowEvent e) {
134 150
 		
135 151
 	}
152
+	
153
+	private void updateBounds() {
154
+		bounds.setValue(new DIRectangle(getX(), getY(), getWidth(), getHeight()));
155
+	}
136 156
 }

+ 3
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingRoot.java Datei anzeigen

@@ -87,6 +87,9 @@ public final class SwingRoot extends Component implements ComponentListener, Mou
87 87
 
88 88
 	@Override
89 89
 	public void componentResized(ComponentEvent e) {
90
+		if (firstPaint)
91
+			return;
92
+		
90 93
 		component.setBounds(new DIRectangle(0, 0,
91 94
 				e.getComponent().getWidth(),
92 95
 				e.getComponent().getHeight()));

+ 24
- 3
DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingWindow.java Datei anzeigen

@@ -7,6 +7,8 @@ package org.openzen.drawablegui.swing;
7 7
 
8 8
 import java.awt.BorderLayout;
9 9
 import java.awt.Color;
10
+import java.awt.event.ComponentAdapter;
11
+import java.awt.event.ComponentEvent;
10 12
 import java.awt.event.WindowEvent;
11 13
 import java.awt.event.WindowListener;
12 14
 import java.awt.event.WindowStateListener;
@@ -19,6 +21,7 @@ import org.openzen.drawablegui.DUIWindow;
19 21
 import org.openzen.drawablegui.border.DCustomWindowBorder;
20 22
 import org.openzen.drawablegui.live.LiveBool;
21 23
 import org.openzen.drawablegui.live.LiveObject;
24
+import org.openzen.drawablegui.live.MutableLiveObject;
22 25
 import org.openzen.drawablegui.live.SimpleLiveBool;
23 26
 import org.openzen.drawablegui.live.SimpleLiveObject;
24 27
 import org.openzen.drawablegui.style.DStyleClass;
@@ -32,6 +35,7 @@ public final class SwingWindow extends JFrame implements WindowListener, WindowS
32 35
 	private final boolean noTitleBar;
33 36
 	private final SimpleLiveObject<State> state = new SimpleLiveObject<>(State.NORMAL);
34 37
 	private final SimpleLiveBool active = new SimpleLiveBool(true);
38
+	private final MutableLiveObject<DIRectangle> bounds = new SimpleLiveObject<>(DIRectangle.EMPTY);
35 39
 	
36 40
 	public SwingWindow(String title, DComponent root, boolean noTitleBar) {
37 41
 		super(title);
@@ -45,10 +49,22 @@ public final class SwingWindow extends JFrame implements WindowListener, WindowS
45 49
 		
46 50
 		addWindowListener(this);
47 51
 		addWindowStateListener(this);
52
+		addComponentListener(new ComponentAdapter() {
53
+			@Override
54
+			public void componentMoved(ComponentEvent componentEvent) {
55
+				updateBounds();
56
+			}
57
+			
58
+			@Override
59
+			public void componentResized(ComponentEvent componentEvent) {
60
+				updateBounds();
61
+			}
62
+		});
48 63
 		
49 64
 		getContentPane().add(swingComponent = new SwingRoot(root), BorderLayout.CENTER);
50 65
 		swingComponent.setWindow(this);
51 66
 		swingComponent.requestFocusInWindow();
67
+		
52 68
 	}
53 69
 	
54 70
 	@Override
@@ -57,8 +73,8 @@ public final class SwingWindow extends JFrame implements WindowListener, WindowS
57 73
 	}
58 74
 
59 75
 	@Override
60
-	public DIRectangle getWindowBounds() {
61
-		return new DIRectangle(getX(), getY(), getWidth(), getHeight());
76
+	public LiveObject<DIRectangle> getWindowBounds() {
77
+		return bounds;
62 78
 	}
63 79
 
64 80
 	@Override
@@ -116,7 +132,7 @@ public final class SwingWindow extends JFrame implements WindowListener, WindowS
116 132
 
117 133
 	@Override
118 134
 	public void windowOpened(WindowEvent e) {
119
-		
135
+		updateBounds();
120 136
 	}
121 137
 
122 138
 	@Override
@@ -154,6 +170,11 @@ public final class SwingWindow extends JFrame implements WindowListener, WindowS
154 170
 		state.setValue(getStateFromWindowState());
155 171
 	}
156 172
 	
173
+	private void updateBounds() {
174
+		state.setValue(getStateFromWindowState());
175
+		bounds.setValue(new DIRectangle(getX(), getY(), getWidth(), getHeight()));
176
+	}
177
+	
157 178
 	private State getStateFromWindowState() {
158 179
 		switch (getExtendedState()) {
159 180
 			case NORMAL:

+ 36
- 4
IDE/src/main/java/org/openzen/zenscript/ide/Main.java Datei anzeigen

@@ -4,12 +4,15 @@ import java.io.File;
4 4
 import java.io.IOException;
5 5
 import java.util.Arrays;
6 6
 import javax.swing.JFrame;
7
+import org.openzen.drawablegui.DUIWindow;
7 8
 import org.openzen.zenscript.ide.host.DevelopmentHost;
8 9
 import org.openzen.zenscript.ide.host.local.LocalProjectDevelopmentHost;
9 10
 import org.openzen.drawablegui.swing.SwingWindow;
10 11
 import org.openzen.zenscript.compiler.CompilationUnit;
11 12
 import org.openzen.zenscript.constructor.ModuleLoader;
12 13
 import org.openzen.zenscript.constructor.Project;
14
+import org.openzen.zenscript.ide.host.IDEPropertyDirectory;
15
+import org.openzen.zenscript.ide.host.IDEPropertyStore;
13 16
 import org.openzen.zenscript.ide.ui.IDEWindow;
14 17
 import org.openzen.zenscript.ide.ui.view.WindowView;
15 18
 
@@ -26,15 +29,44 @@ public class Main {
26 29
 		Project project = new Project(loader, directory);
27 30
 		
28 31
 		DevelopmentHost host = new LocalProjectDevelopmentHost(project);
29
-		
30
-		int pixelPerInch = java.awt.Toolkit.getDefaultToolkit().getScreenResolution();
32
+		open(host);
33
+    }
34
+	
35
+	private static void open(DevelopmentHost host) {
36
+		IDEPropertyStore properties = host.getPropertyStore();
31 37
 		
32 38
 		IDEWindow window = new IDEWindow(host);
33 39
 		WindowView root = new WindowView(window, host);
34 40
 		
41
+		IDEPropertyDirectory uiState = properties.getRoot().getSubdirectory("uiState");
42
+		
43
+		int pixelPerInch = java.awt.Toolkit.getDefaultToolkit().getScreenResolution();
35 44
 		SwingWindow swingWindow = new SwingWindow("ZenCode IDE - " + host.getName(), root, false);
36
-		swingWindow.setSize(800 * pixelPerInch / 96, 600 * pixelPerInch / 96);
45
+		swingWindow.setSize(
46
+				uiState.getInt("width", 800 * pixelPerInch / 96),
47
+				uiState.getInt("height", 600 * pixelPerInch / 96));
48
+		swingWindow.setLocation(
49
+				uiState.getInt("x", 0),
50
+				uiState.getInt("y", 0));
37 51
 		swingWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
52
+		swingWindow.setExtendedState(uiState.getBool("maximized", false) ? JFrame.MAXIMIZED_BOTH : JFrame.NORMAL);
38 53
 		swingWindow.setVisible(true);
39
-    }
54
+		
55
+		swingWindow.getWindowBounds().addListener((oldBounds, newBounds) -> {
56
+			if (swingWindow.getWindowState().getValue() == DUIWindow.State.NORMAL) {
57
+				uiState.setInt("x", newBounds.x);
58
+				uiState.setInt("y", newBounds.y);
59
+				uiState.setInt("width", newBounds.width);
60
+				uiState.setInt("height", newBounds.height);
61
+				properties.save();
62
+			}
63
+		});
64
+		swingWindow.getWindowState().addListener((oldState, newState) -> {
65
+			boolean isMaximized = newState == DUIWindow.State.MAXIMIZED;
66
+			if (isMaximized != uiState.getBool("maximized", false)) {
67
+				uiState.setBool("maximized", isMaximized);
68
+				properties.save();
69
+			}
70
+		});
71
+	}
40 72
 }

+ 25
- 0
IDE/src/main/java/org/openzen/zenscript/ide/codemodel/IDECodeSpace.java Datei anzeigen

@@ -0,0 +1,25 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.ide.codemodel;
7
+
8
+import org.openzen.zenscript.ide.host.DevelopmentHost;
9
+import org.openzen.zenscript.ide.host.IDESourceFile;
10
+
11
+/**
12
+ *
13
+ * @author Hoofdgebruiker
14
+ */
15
+public class IDECodeSpace {
16
+	private final DevelopmentHost host;
17
+	
18
+	public IDECodeSpace(DevelopmentHost host) {
19
+		this.host = host;
20
+	}
21
+	
22
+	public void onSaved(IDESourceFile file) {
23
+		
24
+	}
25
+}

+ 2
- 0
IDE/src/main/java/org/openzen/zenscript/ide/host/DevelopmentHost.java Datei anzeigen

@@ -14,6 +14,8 @@ import org.openzen.drawablegui.live.LiveList;
14 14
 public interface DevelopmentHost {
15 15
 	public String getName();
16 16
 	
17
+	public IDEPropertyStore getPropertyStore();
18
+	
17 19
 	public LiveList<IDEModule> getModules();
18 20
 	
19 21
 	public LiveList<IDELibrary> getLibraries();

+ 26
- 0
IDE/src/main/java/org/openzen/zenscript/ide/host/IDEPropertyDirectory.java Datei anzeigen

@@ -0,0 +1,26 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.ide.host;
7
+
8
+/**
9
+ *
10
+ * @author Hoofdgebruiker
11
+ */
12
+public interface IDEPropertyDirectory {
13
+	public boolean getBool(String name, boolean defaultValue);
14
+	
15
+	public void setBool(String name, boolean value);
16
+	
17
+	public int getInt(String name, int defaultValue);
18
+	
19
+	public void setInt(String name, int value);
20
+	
21
+	public String getString(String name, String defaultValue);
22
+	
23
+	public void setString(String name, String value);
24
+	
25
+	public IDEPropertyDirectory getSubdirectory(String name);
26
+}

+ 16
- 0
IDE/src/main/java/org/openzen/zenscript/ide/host/IDEPropertyStore.java Datei anzeigen

@@ -0,0 +1,16 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.ide.host;
7
+
8
+/**
9
+ *
10
+ * @author Hoofdgebruiker
11
+ */
12
+public interface IDEPropertyStore {
13
+	IDEPropertyDirectory getRoot();
14
+	
15
+	void save();
16
+}

+ 2
- 1
IDE/src/main/java/org/openzen/zenscript/ide/host/IDESourceFile.java Datei anzeigen

@@ -7,13 +7,14 @@ package org.openzen.zenscript.ide.host;
7 7
 
8 8
 import java.io.IOException;
9 9
 import java.io.Reader;
10
+import org.openzen.drawablegui.live.LiveString;
10 11
 
11 12
 /**
12 13
  *
13 14
  * @author Hoofdgebruiker
14 15
  */
15 16
 public interface IDESourceFile {
16
-	public String getName();
17
+	public LiveString getName();
17 18
 	
18 19
 	public Reader read() throws IOException;
19 20
 	

+ 57
- 0
IDE/src/main/java/org/openzen/zenscript/ide/host/local/FilePropertyStore.java Datei anzeigen

@@ -0,0 +1,57 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.ide.host.local;
7
+
8
+import java.io.BufferedInputStream;
9
+import java.io.File;
10
+import java.io.FileInputStream;
11
+import java.io.FileOutputStream;
12
+import java.io.IOException;
13
+import java.io.InputStreamReader;
14
+import java.io.OutputStreamWriter;
15
+import java.nio.charset.StandardCharsets;
16
+import org.json.JSONObject;
17
+import org.json.JSONTokener;
18
+import org.openzen.zenscript.ide.host.IDEPropertyDirectory;
19
+import org.openzen.zenscript.ide.host.IDEPropertyStore;
20
+
21
+/**
22
+ *
23
+ * @author Hoofdgebruiker
24
+ */
25
+public class FilePropertyStore implements IDEPropertyStore {
26
+	private final File file;
27
+	private JSONObject data;
28
+	
29
+	public FilePropertyStore(File file) {
30
+		this.file = file;
31
+		
32
+		if (!file.exists()) {
33
+			data = new JSONObject();
34
+			save();
35
+		} else {
36
+			try (InputStreamReader input = new InputStreamReader(new BufferedInputStream(new FileInputStream(file)), StandardCharsets.UTF_8)) {
37
+				data = new JSONObject(new JSONTokener(input));
38
+			} catch (IOException ex) {
39
+				data = new JSONObject();
40
+			}
41
+		}
42
+	}
43
+	
44
+	@Override
45
+	public IDEPropertyDirectory getRoot() {
46
+		return new JSONPropertyDirectory(data);
47
+	}
48
+	
49
+	@Override
50
+	public void save() {
51
+		try (OutputStreamWriter output = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)) {
52
+			output.write(data.toString(2));
53
+		} catch (IOException ex) {
54
+			ex.printStackTrace();
55
+		}
56
+	}
57
+}

+ 60
- 0
IDE/src/main/java/org/openzen/zenscript/ide/host/local/JSONPropertyDirectory.java Datei anzeigen

@@ -0,0 +1,60 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.ide.host.local;
7
+
8
+import org.json.JSONObject;
9
+import org.openzen.zenscript.ide.host.IDEPropertyDirectory;
10
+
11
+/**
12
+ *
13
+ * @author Hoofdgebruiker
14
+ */
15
+public class JSONPropertyDirectory implements IDEPropertyDirectory {
16
+	private final JSONObject data;
17
+	
18
+	public JSONPropertyDirectory(JSONObject data) {
19
+		this.data = data;
20
+	}
21
+	
22
+	@Override
23
+	public boolean getBool(String name, boolean defaultValue) {
24
+		return data.optBoolean(name, defaultValue);
25
+	}
26
+	
27
+	@Override
28
+	public void setBool(String name, boolean value) {
29
+		data.put(name, value);
30
+	}
31
+	
32
+	@Override
33
+	public int getInt(String name, int defaultValue) {
34
+		return data.optInt(name, defaultValue);
35
+	}
36
+	
37
+	@Override
38
+	public void setInt(String name, int value) {
39
+		data.put(name, value);
40
+	}
41
+
42
+	@Override
43
+	public String getString(String name, String defaultValue) {
44
+		return data.optString(name, defaultValue);
45
+	}
46
+	
47
+	@Override
48
+	public void setString(String name, String value) {
49
+		data.put(name, value);
50
+	}
51
+
52
+	@Override
53
+	public IDEPropertyDirectory getSubdirectory(String name) {
54
+		if (!data.has(name)) {
55
+			data.put(name, new JSONObject());
56
+		}
57
+		
58
+		return new JSONPropertyDirectory(data.getJSONObject(name));
59
+	}
60
+}

+ 1
- 1
IDE/src/main/java/org/openzen/zenscript/ide/host/local/LocalPackage.java Datei anzeigen

@@ -48,7 +48,7 @@ public class LocalPackage implements IDEPackage {
48 48
 		}
49 49
 		
50 50
 		subPackagesSorted = new SortedLiveList<>(subPackages, (a, b) -> a.getName().compareTo(b.getName()));
51
-		sourceFilesSorted = new SortedLiveList<>(sourceFiles, (a, b) -> a.getName().compareTo(b.getName()));
51
+		sourceFilesSorted = new SortedLiveList<>(sourceFiles, (a, b) -> a.getName().getValue().compareTo(b.getName().getValue()));
52 52
 	}
53 53
 	
54 54
 	@Override

+ 7
- 0
IDE/src/main/java/org/openzen/zenscript/ide/host/local/LocalProjectDevelopmentHost.java Datei anzeigen

@@ -5,6 +5,7 @@
5 5
  */
6 6
 package org.openzen.zenscript.ide.host.local;
7 7
 
8
+import java.io.File;
8 9
 import org.openzen.drawablegui.live.LiveArrayList;
9 10
 import org.openzen.drawablegui.live.LiveList;
10 11
 import org.openzen.drawablegui.live.MutableLiveList;
@@ -15,6 +16,7 @@ import org.openzen.zenscript.compiler.Target;
15 16
 import org.openzen.zenscript.ide.host.DevelopmentHost;
16 17
 import org.openzen.zenscript.ide.host.IDEModule;
17 18
 import org.openzen.zenscript.ide.host.IDELibrary;
19
+import org.openzen.zenscript.ide.host.IDEPropertyStore;
18 20
 import org.openzen.zenscript.ide.host.IDETarget;
19 21
 
20 22
 /**
@@ -47,6 +49,11 @@ public class LocalProjectDevelopmentHost implements DevelopmentHost {
47 49
 	public String getName() {
48 50
 		return project.name;
49 51
 	}
52
+	
53
+	@Override
54
+	public IDEPropertyStore getPropertyStore() {
55
+		return new FilePropertyStore(new File(project.directory, "ide.json"));
56
+	}
50 57
 
51 58
 	@Override
52 59
 	public LiveList<IDEModule> getModules() {

+ 7
- 2
IDE/src/main/java/org/openzen/zenscript/ide/host/local/LocalSourceFile.java Datei anzeigen

@@ -15,6 +15,9 @@ import java.io.OutputStreamWriter;
15 15
 import java.io.Reader;
16 16
 import java.io.Writer;
17 17
 import java.nio.charset.StandardCharsets;
18
+import org.openzen.drawablegui.live.LiveString;
19
+import org.openzen.drawablegui.live.MutableLiveString;
20
+import org.openzen.drawablegui.live.SimpleLiveString;
18 21
 import org.openzen.zenscript.constructor.module.SourceFile;
19 22
 import org.openzen.zenscript.ide.host.IDESourceFile;
20 23
 
@@ -24,14 +27,16 @@ import org.openzen.zenscript.ide.host.IDESourceFile;
24 27
  */
25 28
 public class LocalSourceFile implements IDESourceFile {
26 29
 	private final SourceFile file;
30
+	private final MutableLiveString name;
27 31
 	
28 32
 	public LocalSourceFile(SourceFile file) {
29 33
 		this.file = file;
34
+		this.name = new SimpleLiveString(file.name);
30 35
 	}
31 36
 
32 37
 	@Override
33
-	public String getName() {
34
-		return file.name;
38
+	public LiveString getName() {
39
+		return name;
35 40
 	}
36 41
 
37 42
 	@Override

+ 0
- 32
IDE/src/main/java/org/openzen/zenscript/ide/ui/IDEWindow.java Datei anzeigen

@@ -6,19 +6,10 @@
6 6
 package org.openzen.zenscript.ide.ui;
7 7
 
8 8
 import org.openzen.drawablegui.live.ImmutableLiveString;
9
-import org.openzen.drawablegui.live.LiveBool;
10
-import org.openzen.drawablegui.live.LivePredicateBool;
11
-import org.openzen.drawablegui.live.MutableLiveObject;
12
-import org.openzen.drawablegui.live.SimpleLiveObject;
13 9
 import org.openzen.drawablegui.style.DStyleClass;
14 10
 import org.openzen.zenscript.ide.host.DevelopmentHost;
15
-import org.openzen.zenscript.ide.host.IDEModule;
16
-import org.openzen.zenscript.ide.host.IDEPackage;
17 11
 import org.openzen.zenscript.ide.host.IDESourceFile;
18 12
 import org.openzen.zenscript.ide.host.IDETarget;
19
-import org.openzen.zenscript.ide.ui.dialog.CreatePackageDialog;
20
-import org.openzen.zenscript.ide.ui.dialog.CreateSourceFileDialog;
21
-import org.openzen.zenscript.ide.ui.icons.AddBoxIcon;
22 13
 import org.openzen.zenscript.ide.ui.icons.BuildIcon;
23 14
 import org.openzen.zenscript.ide.ui.icons.PlayIcon;
24 15
 import org.openzen.zenscript.ide.ui.icons.SettingsIcon;
@@ -38,11 +29,6 @@ public class IDEWindow {
38 29
 	
39 30
 	public IDEAspectToolbar projectToolbar;
40 31
 	
41
-	public final MutableLiveObject<IDEModule> contextModule = new SimpleLiveObject<>(null);
42
-	public final MutableLiveObject<IDEPackage> contextPackage = new SimpleLiveObject<>(null);
43
-	public final MutableLiveObject<IDESourceFile> contextFile = new SimpleLiveObject<>(null);
44
-	public final LiveBool addContentDisabled = new LivePredicateBool(contextPackage, pkg -> pkg == null);
45
-	
46 32
 	public IDEWindow(DevelopmentHost host) {
47 33
 		this.host = host;
48 34
 		
@@ -84,22 +70,4 @@ public class IDEWindow {
84 70
 		}));
85 71
 		aspectBar.toolbars.add(projectToolbar);
86 72
 	}
87
-	
88
-	public void setContextModule(IDEModule module) {
89
-		contextModule.setValue(module);
90
-		contextPackage.setValue(module.getRootPackage());
91
-		contextFile.setValue(null);
92
-	}
93
-	
94
-	public void setContextPackage(IDEModule module, IDEPackage pkg) {
95
-		contextModule.setValue(module);
96
-		contextPackage.setValue(pkg);
97
-		contextFile.setValue(null);
98
-	}
99
-	
100
-	public void setContextFile(IDESourceFile file) {
101
-		contextModule.setValue(null);
102
-		contextPackage.setValue(null);
103
-		contextFile.setValue(file);
104
-	}
105 73
 }

+ 4
- 5
IDE/src/main/java/org/openzen/zenscript/ide/ui/dialog/CreatePackageDialog.java Datei anzeigen

@@ -8,12 +8,12 @@ package org.openzen.zenscript.ide.ui.dialog;
8 8
 import org.openzen.drawablegui.DAnchor;
9 9
 import org.openzen.drawablegui.DButton;
10 10
 import org.openzen.drawablegui.DComponent;
11
-import org.openzen.drawablegui.DHorizontalLayout;
11
+import org.openzen.drawablegui.layout.DHorizontalLayout;
12 12
 import org.openzen.drawablegui.DIRectangle;
13 13
 import org.openzen.drawablegui.DInputField;
14 14
 import org.openzen.drawablegui.DLabel;
15 15
 import org.openzen.drawablegui.DUIWindow;
16
-import org.openzen.drawablegui.DVerticalLayout;
16
+import org.openzen.drawablegui.layout.DVerticalLayout;
17 17
 import org.openzen.drawablegui.form.DForm;
18 18
 import org.openzen.drawablegui.form.DFormComponent;
19 19
 import org.openzen.drawablegui.live.ImmutableLiveBool;
@@ -23,7 +23,6 @@ import org.openzen.drawablegui.style.DDpDimension;
23 23
 import org.openzen.drawablegui.style.DStyleClass;
24 24
 import org.openzen.zenscript.ide.host.IDEModule;
25 25
 import org.openzen.zenscript.ide.host.IDEPackage;
26
-import org.openzen.zenscript.ide.ui.IDEWindow;
27 26
 
28 27
 /**
29 28
  *
@@ -71,8 +70,8 @@ public class CreatePackageDialog {
71 70
 	}
72 71
 	
73 72
 	public void open(DUIWindow parent) {
74
-		DIRectangle rectangle = parent.getWindowBounds();
75
-		window = parent.getContext().openDialog(rectangle.getCenterX(), rectangle.getCenterY(), DAnchor.MIDDLE_LEFT, "Create package", root);
73
+		DIRectangle rectangle = parent.getWindowBounds().getValue();
74
+		window = parent.getContext().openDialog(rectangle.width / 2, rectangle.height / 2, DAnchor.MIDDLE_CENTER, "Create package", root);
76 75
 		window.focus(input);
77 76
 	}
78 77
 	

+ 4
- 4
IDE/src/main/java/org/openzen/zenscript/ide/ui/dialog/CreateSourceFileDialog.java Datei anzeigen

@@ -8,12 +8,12 @@ package org.openzen.zenscript.ide.ui.dialog;
8 8
 import org.openzen.drawablegui.DAnchor;
9 9
 import org.openzen.drawablegui.DButton;
10 10
 import org.openzen.drawablegui.DComponent;
11
-import org.openzen.drawablegui.DHorizontalLayout;
11
+import org.openzen.drawablegui.layout.DHorizontalLayout;
12 12
 import org.openzen.drawablegui.DIRectangle;
13 13
 import org.openzen.drawablegui.DInputField;
14 14
 import org.openzen.drawablegui.DLabel;
15 15
 import org.openzen.drawablegui.DUIWindow;
16
-import org.openzen.drawablegui.DVerticalLayout;
16
+import org.openzen.drawablegui.layout.DVerticalLayout;
17 17
 import org.openzen.drawablegui.form.DForm;
18 18
 import org.openzen.drawablegui.form.DFormComponent;
19 19
 import org.openzen.drawablegui.live.ImmutableLiveBool;
@@ -74,8 +74,8 @@ public class CreateSourceFileDialog {
74 74
 	}
75 75
 	
76 76
 	public void open(DUIWindow parent) {
77
-		DIRectangle rectangle = parent.getWindowBounds();
78
-		window = parent.getContext().openDialog(rectangle.getCenterX(), rectangle.getCenterY(), DAnchor.MIDDLE_LEFT, "Create source file", root);
77
+		DIRectangle rectangle = parent.getWindowBounds().getValue();
78
+		window = parent.getContext().openDialog(rectangle.getCenterX(), rectangle.getCenterY(), DAnchor.MIDDLE_CENTER, "Create source file", root);
79 79
 		window.focus(input);
80 80
 	}
81 81
 	

+ 1
- 2
IDE/src/main/java/org/openzen/zenscript/ide/ui/icons/AddBoxIcon.java Datei anzeigen

@@ -49,8 +49,7 @@ public class AddBoxIcon implements DColorableIcon {
49 49
 	
50 50
 	@Override
51 51
 	public void draw(DCanvas canvas, DTransform2D transform, int color) {
52
-		canvas.shadowPath(PATH, transform, new DShadow(0xFF999999, 0, 1, 6));
53
-		canvas.fillPath(PATH, transform, color);
52
+		canvas.shadowPath(PATH, transform, color, new DShadow(0xFF999999, 0, 1, 6));
54 53
 	}
55 54
 
56 55
 	@Override

+ 1
- 2
IDE/src/main/java/org/openzen/zenscript/ide/ui/icons/BuildIcon.java Datei anzeigen

@@ -36,8 +36,7 @@ public class BuildIcon implements DColorableIcon {
36 36
 	
37 37
 	@Override
38 38
 	public void draw(DCanvas canvas, DTransform2D transform, int color) {
39
-		canvas.shadowPath(PATH, transform, new DShadow(0xFFCCCCCC, 0, 1, 4));
40
-		canvas.fillPath(PATH, transform, color);
39
+		canvas.shadowPath(PATH, transform, color, new DShadow(0xFFCCCCCC, 0, 1, 4));
41 40
 	}
42 41
 
43 42
 	@Override

+ 1
- 2
IDE/src/main/java/org/openzen/zenscript/ide/ui/icons/PlayIcon.java Datei anzeigen

@@ -26,8 +26,7 @@ public class PlayIcon implements DColorableIcon {
26 26
 	
27 27
 	@Override
28 28
 	public void draw(DCanvas canvas, DTransform2D transform, int color) {
29
-		canvas.shadowPath(PATH, transform, new DShadow(0xFFCCCCCC, 0, 1, 4));
30
-		canvas.fillPath(PATH, transform, color);
29
+		canvas.shadowPath(PATH, transform, color, new DShadow(0xFFCCCCCC, 0, 1, 4));
31 30
 	}
32 31
 
33 32
 	@Override

+ 1
- 2
IDE/src/main/java/org/openzen/zenscript/ide/ui/icons/SettingsIcon.java Datei anzeigen

@@ -68,8 +68,7 @@ public class SettingsIcon implements DColorableIcon {
68 68
 	
69 69
 	@Override
70 70
 	public void draw(DCanvas canvas, DTransform2D transform, int color) {
71
-		canvas.shadowPath(PATH, transform, new DShadow(0xFF888888, 0, 1, 4));
72
-		canvas.fillPath(PATH, transform, color);
71
+		canvas.shadowPath(PATH, transform, color, new DShadow(0xFF888888, 0, 1, 4));
73 72
 	}
74 73
 
75 74
 	@Override

+ 1
- 2
IDE/src/main/java/org/openzen/zenscript/ide/ui/icons/ShadedSaveIcon.java Datei anzeigen

@@ -45,8 +45,7 @@ public class ShadedSaveIcon implements DColorableIcon {
45 45
 	
46 46
 	@Override
47 47
 	public void draw(DCanvas canvas, DTransform2D transform, int color) {
48
-		canvas.shadowPath(PATH, transform, new DShadow(0xFFCCCCCC, 0, 1, 4));
49
-		canvas.fillPath(PATH, transform, color);
48
+		canvas.shadowPath(PATH, transform, color, new DShadow(0xFFCCCCCC, 0, 1, 4));
50 49
 	}
51 50
 
52 51
 	@Override

+ 4
- 8
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/IconButtonControl.java Datei anzeigen

@@ -109,17 +109,13 @@ public class IconButtonControl implements DComponent {
109 109
 	@Override
110 110
 	public void paint(DCanvas canvas) {
111 111
 		if (disabled.getValue()) {
112
-			canvas.shadowPath(shape, DTransform2D.IDENTITY, style.shadowDisabled);
113
-			canvas.fillPath(shape, DTransform2D.IDENTITY, style.colorDisabled);
112
+			canvas.shadowPath(shape, DTransform2D.IDENTITY, style.colorDisabled, style.shadowDisabled);
114 113
 		} else if (press) {
115
-			canvas.shadowPath(shape, DTransform2D.IDENTITY, style.shadowPress);
116
-			canvas.fillPath(shape, DTransform2D.IDENTITY, style.colorPress);
114
+			canvas.shadowPath(shape, DTransform2D.IDENTITY, style.colorPress, style.shadowPress);
117 115
 		} else if (hover) {
118
-			canvas.shadowPath(shape, DTransform2D.IDENTITY, style.shadowHover);
119
-			canvas.fillPath(shape, DTransform2D.IDENTITY, style.colorHover);
116
+			canvas.shadowPath(shape, DTransform2D.IDENTITY, style.colorHover, style.shadowHover);
120 117
 		} else {
121
-			canvas.shadowPath(shape, DTransform2D.IDENTITY, style.shadowNormal);
122
-			canvas.fillPath(shape, DTransform2D.IDENTITY, style.colorNormal);
118
+			canvas.shadowPath(shape, DTransform2D.IDENTITY, style.colorNormal, style.shadowNormal);
123 119
 		}
124 120
 		
125 121
 		DDrawable icon = disabled.getValue() ? iconDisabled : this.icon;

+ 7
- 0
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/TabbedView.java Datei anzeigen

@@ -5,6 +5,8 @@
5 5
  */
6 6
 package org.openzen.zenscript.ide.ui.view;
7 7
 
8
+import java.util.HashMap;
9
+import java.util.Map;
8 10
 import java.util.function.Consumer;
9 11
 import java.util.function.Predicate;
10 12
 import org.openzen.drawablegui.BaseComponentGroup;
@@ -14,6 +16,7 @@ import org.openzen.drawablegui.DSizing;
14 16
 import org.openzen.drawablegui.DFontMetrics;
15 17
 import org.openzen.drawablegui.DIRectangle;
16 18
 import org.openzen.drawablegui.DUIContext;
19
+import org.openzen.drawablegui.listeners.ListenerHandle;
17 20
 import org.openzen.drawablegui.live.LiveArrayList;
18 21
 import org.openzen.drawablegui.live.LiveList;
19 22
 import org.openzen.drawablegui.live.LiveMappedList;
@@ -34,6 +37,8 @@ public class TabbedView extends BaseComponentGroup {
34 37
 	private final MutableLiveObject<DSizing> sizing = DSizing.create();
35 38
 	public final MutableLiveObject<TabbedViewComponent> currentTab = new SimpleLiveObject<>(null);
36 39
 	
40
+	private final Map<TabbedViewTab, ListenerHandle<LiveObject.Listener<DSizing>>> tabSizeListeners = new HashMap<>();
41
+	
37 42
 	private DUIContext context;
38 43
 	private DStylePath path;
39 44
 	private DIRectangle bounds;
@@ -45,6 +50,8 @@ public class TabbedView extends BaseComponentGroup {
45 50
 		TabbedViewTab result = new TabbedViewTab(this, currentTab, tab);
46 51
 		if (context != null)
47 52
 			result.setContext(path, context);
53
+		
54
+		tabSizeListeners.put(result, result.getSizing().addListener((oldSize, newSize) -> layoutTabs()));
48 55
 		return result;
49 56
 	});
50 57
 	

+ 6
- 2
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/TabbedViewComponent.java Datei anzeigen

@@ -7,19 +7,23 @@ package org.openzen.zenscript.ide.ui.view;
7 7
 
8 8
 import org.openzen.drawablegui.DComponent;
9 9
 import org.openzen.drawablegui.DDrawable;
10
+import org.openzen.drawablegui.live.LiveBool;
11
+import org.openzen.drawablegui.live.LiveString;
10 12
 
11 13
 /**
12 14
  *
13 15
  * @author Hoofdgebruiker
14 16
  */
15 17
 public class TabbedViewComponent {
16
-	public final String title;
18
+	public final LiveString title;
17 19
 	public final DDrawable icon;
18 20
 	public final DComponent content;
21
+	public final LiveBool updated;
19 22
 	
20
-	public TabbedViewComponent(String title, DDrawable icon, DComponent content) {
23
+	public TabbedViewComponent(LiveString title, DDrawable icon, DComponent content, LiveBool updated) {
21 24
 		this.title = title;
22 25
 		this.icon = icon;
23 26
 		this.content = content;
27
+		this.updated = updated;
24 28
 	}
25 29
 }

+ 40
- 7
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/TabbedViewTab.java Datei anzeigen

@@ -14,7 +14,10 @@ import org.openzen.drawablegui.DMouseEvent;
14 14
 import org.openzen.drawablegui.DPath;
15 15
 import org.openzen.drawablegui.DTransform2D;
16 16
 import org.openzen.drawablegui.DUIContext;
17
+import org.openzen.drawablegui.listeners.ListenerHandle;
18
+import org.openzen.drawablegui.live.LiveBool;
17 19
 import org.openzen.drawablegui.live.LiveObject;
20
+import org.openzen.drawablegui.live.LiveString;
18 21
 import org.openzen.drawablegui.live.MutableLiveObject;
19 22
 import org.openzen.drawablegui.style.DStyleClass;
20 23
 import org.openzen.drawablegui.style.DStylePath;
@@ -37,6 +40,9 @@ public class TabbedViewTab implements DComponent {
37 40
 	private int textWidth;
38 41
 	private DIRectangle bounds;
39 42
 	
43
+	private final ListenerHandle<LiveString.Listener> titleListener;
44
+	private final ListenerHandle<LiveBool.Listener> updatedListener;
45
+	
40 46
 	private boolean hover;
41 47
 	private boolean press;
42 48
 	
@@ -45,6 +51,9 @@ public class TabbedViewTab implements DComponent {
45 51
 		this.currentTab = currentTab;
46 52
 		this.tab = tab;
47 53
 		this.closeButton = new TabbedViewTabClose(this);
54
+		
55
+		titleListener = tab.title.addListener((oldValue, newValue) -> calculateSizing());
56
+		updatedListener = tab.updated.addListener((oldValue, newValue) -> calculateSizing());
48 57
 	}
49 58
 	
50 59
 	public void closeTab() {
@@ -59,11 +68,22 @@ public class TabbedViewTab implements DComponent {
59 68
 		fontMetrics = context.getFontMetrics(style.tabFont);
60 69
 		closeButton.setContext(path, context);
61 70
 		
62
-		textWidth = fontMetrics.getWidth(tab.title);
63
-		sizing.setValue(new DSizing(
64
-				style.paddingLeft + textWidth + style.paddingRight
71
+		calculateSizing();
72
+	}
73
+	
74
+	private void calculateSizing() {
75
+		textWidth = fontMetrics.getWidth(tab.title.getValue());
76
+		
77
+		int width = style.paddingLeft + textWidth + style.paddingRight
65 78
 						+ style.closeIconPadding
66
-						+ closeButton.getSizing().getValue().preferredWidth,
79
+						+ closeButton.getSizing().getValue().preferredWidth;
80
+		
81
+		if (tab.updated.getValue()) {
82
+			width += style.updatedDiameter + style.updatedPadding;
83
+		}
84
+		
85
+		sizing.setValue(new DSizing(
86
+				width,
67 87
 				style.paddingTop + fontMetrics.getAscent() + fontMetrics.getDescent()
68 88
 						+ style.paddingBottom));
69 89
 	}
@@ -99,6 +119,9 @@ public class TabbedViewTab implements DComponent {
99 119
 	public void paint(DCanvas canvas) {
100 120
 		int width = style.paddingLeft + textWidth + style.paddingRight
101 121
 				+ closeButton.getSizing().getValue().preferredWidth + style.closeIconPadding;
122
+		
123
+		if (tab.updated.getValue())
124
+			width += style.updatedDiameter + style.updatedPadding;
102 125
 
103 126
 		int color = style.tabColorNormal;
104 127
 		if (currentTab.getValue() == tab)
@@ -110,15 +133,25 @@ public class TabbedViewTab implements DComponent {
110 133
 
111 134
 		canvas.fillRectangle(bounds.x, bounds.y, width, bounds.height, color);
112 135
 		canvas.strokePath(DPath.rectangle(bounds.x, bounds.y, width, bounds.height), DTransform2D.IDENTITY, style.borderColor, style.borderWidth);
113
-
114
-		canvas.drawText(style.tabFont, style.tabFontColor, bounds.x + style.paddingLeft, bounds.y + style.paddingTop + fontMetrics.getAscent(), tab.title);
136
+		
137
+		canvas.drawText(style.tabFont, style.tabFontColor, bounds.x + style.paddingLeft, bounds.y + style.paddingTop + fontMetrics.getAscent(), tab.title.getValue());
138
+		
139
+		if (tab.updated.getValue()) {
140
+			canvas.fillPath(
141
+					DPath.circle(
142
+						bounds.x + bounds.width - style.paddingRight - closeButton.getBounds().width - style.closeIconPadding - style.updatedDiameter / 2,
143
+						bounds.y + style.paddingTop + ((bounds.height - style.paddingTop - style.paddingBottom) / 2), style.updatedDiameter / 2),
144
+					DTransform2D.IDENTITY,
145
+					style.updatedColor);
146
+		}
115 147
 		
116 148
 		closeButton.paint(canvas);
117 149
 	}
118 150
 
119 151
 	@Override
120 152
 	public void close() {
121
-		
153
+		titleListener.close();
154
+		updatedListener.close();
122 155
 	}
123 156
 	
124 157
 	@Override

+ 8
- 0
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/TabbedViewTabStyle.java Datei anzeigen

@@ -35,6 +35,10 @@ public class TabbedViewTabStyle {
35 35
 	public final int closeIconSize;
36 36
 	public final int closeIconPadding;
37 37
 	
38
+	public final int updatedDiameter;
39
+	public final int updatedPadding;
40
+	public final int updatedColor;
41
+	
38 42
 	public TabbedViewTabStyle(DStyleDefinition style) {
39 43
 		tabFont = style.getFont("tabFont", context -> new DFont(DFontFamily.UI, false, false, false, (int)(12 * context.getScale())));
40 44
 		tabFontColor = style.getColor("tabFontColor", 0xFF000000);
@@ -54,5 +58,9 @@ public class TabbedViewTabStyle {
54 58
 		
55 59
 		closeIconSize = style.getDimension("closeIconSize", new DDpDimension(16));
56 60
 		closeIconPadding = style.getDimension("closeIconPadding", new DDpDimension(6));
61
+		
62
+		updatedDiameter = style.getDimension("updatedDiameter", new DDpDimension(6));
63
+		updatedPadding = style.getDimension("updatedPadding", new DDpDimension(8));
64
+		updatedColor = style.getColor("updatedColor", 0xFF000000);
57 65
 	}
58 66
 }

+ 11
- 61
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/WindowView.java Datei anzeigen

@@ -5,30 +5,20 @@
5 5
  */
6 6
 package org.openzen.zenscript.ide.ui.view;
7 7
 
8
-import org.openzen.drawablegui.DSizing;
9 8
 import org.openzen.drawablegui.DEmptyView;
10
-import org.openzen.drawablegui.DHorizontalLayout;
11 9
 import org.openzen.drawablegui.scroll.DScrollPane;
12
-import org.openzen.drawablegui.DSideLayout;
13
-import org.openzen.drawablegui.DVerticalLayout;
14
-import org.openzen.drawablegui.border.DEmptyBorder;
15
-import org.openzen.drawablegui.live.ImmutableLiveString;
10
+import org.openzen.drawablegui.layout.DSideLayout;
16 11
 import org.openzen.drawablegui.live.LiveString;
17 12
 import org.openzen.drawablegui.live.SimpleLiveString;
18 13
 import org.openzen.drawablegui.style.DStyleClass;
19 14
 import org.openzen.drawablegui.style.DStylesheetBuilder;
20
-import org.openzen.drawablegui.tree.DTreeView;
21
-import org.openzen.drawablegui.tree.DTreeViewStyle;
22 15
 import org.openzen.zenscript.ide.host.DevelopmentHost;
23 16
 import org.openzen.zenscript.ide.host.IDESourceFile;
24 17
 import org.openzen.zenscript.ide.ui.IDEDockWindow;
25 18
 import org.openzen.zenscript.ide.ui.IDEWindow;
26
-import org.openzen.zenscript.ide.ui.dialog.CreatePackageDialog;
27
-import org.openzen.zenscript.ide.ui.dialog.CreateSourceFileDialog;
28
-import org.openzen.zenscript.ide.ui.icons.AddBoxIcon;
29 19
 import org.openzen.zenscript.ide.ui.view.aspectbar.AspectBarView;
30 20
 import org.openzen.zenscript.ide.ui.view.editor.SourceEditor;
31
-import org.openzen.zenscript.ide.ui.view.project.RootTreeNode;
21
+import org.openzen.zenscript.ide.ui.view.project.ProjectBrowser;
32 22
 
33 23
 /**
34 24
  *
@@ -38,60 +28,18 @@ public final class WindowView extends DSideLayout {
38 28
 	private final IDEWindow window;
39 29
 	private final TabbedView tabs;
40 30
 	public final LiveString status = new SimpleLiveString("IDE initialized");
31
+	private final ProjectBrowser projectBrowser;
41 32
 	
42 33
 	public WindowView(IDEWindow window, DevelopmentHost host) {
43
-		super(DStyleClass.EMPTY, DEmptyView.INSTANCE);
34
+		super(DStyleClass.inline(
35
+				new DStylesheetBuilder().color("backgroundColor", 0xFFEEEEEE).build()),
36
+				DEmptyView.INSTANCE);
44 37
 		this.window = window;
45 38
 		
46
-		DStyleClass minimalButtonPadding = DStyleClass.inline(new DStylesheetBuilder()
47
-				.dimensionDp("margin", 3)
48
-				.dimensionDp("padding", 0)
49
-				.build());
50
-		
51
-		IconButtonControl addPackageButton = new IconButtonControl(
52
-				minimalButtonPadding,
53
-				AddBoxIcon.BLUE,
54
-				AddBoxIcon.GRAY,
55
-				window.addContentDisabled,
56
-				new ImmutableLiveString("Create package"),
57
-				e -> {
58
-					CreatePackageDialog dialog = new CreatePackageDialog(window.contextModule.getValue(), window.contextPackage.getValue());
59
-					dialog.open(e.window);
60
-				});
61
-		IconButtonControl addFileButton = new IconButtonControl(
62
-				minimalButtonPadding,
63
-				AddBoxIcon.ORANGE,
64
-				AddBoxIcon.GRAY,
65
-				window.addContentDisabled,
66
-				new ImmutableLiveString("Create source file"),
67
-				e -> {
68
-					CreateSourceFileDialog dialog = new CreateSourceFileDialog(window, window.contextModule.getValue(), window.contextPackage.getValue());
69
-					dialog.open(e.window);
70
-				});
71
-		
72
-		DHorizontalLayout toolbar = new DHorizontalLayout(
73
-				DStyleClass.inline(new DStylesheetBuilder()
74
-						.border("border", context -> DEmptyBorder.INSTANCE)
75
-						.dimensionPx("spacing", 0)
76
-						.color("backgroundColor", 0xFFFFFFFF)
77
-						.build()),
78
-				DHorizontalLayout.Alignment.LEFT,
79
-				new DHorizontalLayout.Element(addPackageButton, 0, 0, DHorizontalLayout.ElementAlignment.TOP),
80
-				new DHorizontalLayout.Element(addFileButton, 0, 0, DHorizontalLayout.ElementAlignment.TOP));
81
-		DTreeView projectTree = new DTreeView(DTreeViewStyle.DEFAULT, new RootTreeNode(window, host), false);
82
-		projectTree.getSizing().setValue(new DSizing(500, 500));
83
-		
84
-		DVerticalLayout projectView = new DVerticalLayout(
85
-				DStyleClass.inline(new DStylesheetBuilder()
86
-						.border("border", context -> DEmptyBorder.INSTANCE)
87
-						.dimensionPx("spacing", 0)
88
-						.build()),
89
-				DVerticalLayout.Alignment.TOP,
90
-				new DVerticalLayout.Element(toolbar, 0, 0, DVerticalLayout.ElementAlignment.STRETCH),
91
-				new DVerticalLayout.Element(new DScrollPane(DStyleClass.forId("projectView"), projectTree), 1, 1, DVerticalLayout.ElementAlignment.STRETCH));
39
+		projectBrowser = new ProjectBrowser(window, host);
92 40
 		
93 41
 		setMain(tabs = new TabbedView(DStyleClass.EMPTY));
94
-		add(Side.LEFT,projectView);
42
+		add(Side.LEFT, projectBrowser.view);
95 43
 		add(Side.BOTTOM, new StatusBarView(DStyleClass.EMPTY, status));
96 44
 		add(Side.TOP, new AspectBarView(DStyleClass.EMPTY, window.aspectBar));
97 45
 		
@@ -101,10 +49,12 @@ public final class WindowView extends DSideLayout {
101 49
 	private class DockWindowListener implements IDEDockWindow.Listener {
102 50
 		@Override
103 51
 		public void onOpen(IDESourceFile sourceFile) {
52
+			SourceEditor editor = new SourceEditor(DStyleClass.EMPTY, window, sourceFile);
104 53
 			TabbedViewComponent tab = new TabbedViewComponent(
105 54
 					sourceFile.getName(),
106 55
 					null,
107
-					new DScrollPane(DStyleClass.EMPTY, new SourceEditor(DStyleClass.EMPTY, window, sourceFile)));
56
+					new DScrollPane(DStyleClass.EMPTY, editor),
57
+					editor.isUpdated());
108 58
 			tabs.tabs.add(tab);
109 59
 			tabs.currentTab.setValue(tab);
110 60
 		}

+ 1
- 4
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/aspectbar/AspectBarSelectorButton.java Datei anzeigen

@@ -110,11 +110,8 @@ public class AspectBarSelectorButton implements DComponent {
110 110
 		canvas.shadowPath(
111 111
 					shape,
112 112
 					DTransform2D.translate(bounds.x, bounds.y),
113
+					color,
113 114
 					shadow);
114
-		canvas.fillPath(
115
-				shape,
116
-				DTransform2D.translate(bounds.x, bounds.y),
117
-				color);
118 115
 		icon.draw(canvas, DTransform2D.scaleAndTranslate(
119 116
 				bounds.x + (style.width - icon.getNominalWidth() * context.getScale()) / 2,
120 117
 				bounds.y + (style.height - icon.getNominalHeight() * context.getScale()) / 2,

+ 8
- 1
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/aspectbar/AspectBarStyle.java Datei anzeigen

@@ -21,7 +21,9 @@ public class AspectBarStyle {
21 21
 	public final int aspectSelectorToToolbarSpacing;
22 22
 	public final int aspectSelectorBottomSize;
23 23
 	public final int backgroundColor;
24
+	public final int backgroundColorBottom;
24 25
 	public final int foregroundColor;
26
+	public final int marginBottom;
25 27
 	
26 28
 	public final int aspectSelectorButtonSpacing;
27 29
 	public final int toolbarTitleToControlsSpacing;
@@ -29,6 +31,7 @@ public class AspectBarStyle {
29 31
 	public final DShadow aspectBarShadow;
30 32
 	public final int aspectBarPaddingTop;
31 33
 	
34
+	public final int controlHeight;
32 35
 	public final int controlPaddingTop;
33 36
 	public final int controlPaddingBottom;
34 37
 	
@@ -40,19 +43,21 @@ public class AspectBarStyle {
40 43
 	public final DShadow windowControlShadow;
41 44
 	
42 45
 	public AspectBarStyle(DStyleDefinition style) {
43
-		height = style.getDimension("height", new DDpDimension(38));
44 46
 		aspectSelectorPaddingLeft = style.getDimension("aspectSelectorPaddingLeft", new DDpDimension(4));
45 47
 		aspectSelectorToToolbarSpacing = style.getDimension("aspectSelectorToToolbarSpacing", new DDpDimension(16));
46 48
 		toolbarTitleToControlsSpacing = style.getDimension("toolbarTitleToControlsSpacing", new DDpDimension(8));
47 49
 		aspectSelectorBottomSize = style.getDimension("aspectSelectorBottomSize", new DDpDimension(4));
48 50
 		backgroundColor = style.getColor("backgroundColor", 0xFFCCCCCC); // 0xFFF0F0F0
51
+		backgroundColorBottom = style.getColor("backgroundColorBottom", 0xFFEEEEEE);
49 52
 		foregroundColor = style.getColor("foregroundColor", 0xFFFFFFFF);
53
+		marginBottom = style.getDimension("marginBottom", new DDpDimension(2));
50 54
 		
51 55
 		aspectSelectorButtonSpacing = style.getDimension("aspectSelectorButtonSpacing", new DDpDimension(4));
52 56
 		
53 57
 		aspectBarShadow = style.getShadow("aspectBarShadow", context -> new DShadow(0xFF888888, 0, 0.5f * context.getScale(), 2 * context.getScale()));
54 58
 		aspectBarPaddingTop = style.getDimension("aspectBarPaddingTop", new DDpDimension(4));
55 59
 		
60
+		controlHeight = style.getDimension("controlHeight", new DDpDimension(28));
56 61
 		controlPaddingTop = style.getDimension("controlPaddingTop", new DDpDimension(2));
57 62
 		controlPaddingBottom = style.getDimension("controlPaddingBottom", new DDpDimension(2));
58 63
 		
@@ -63,5 +68,7 @@ public class AspectBarStyle {
63 68
 		windowControlSpacingBottom = style.getDimension("windowControlSpacingBottom", new DDpDimension(4));
64 69
 		//windowControlShadow = style.getShadow("windowControlShadow", context -> DShadow.NONE);
65 70
 		windowControlShadow = style.getShadow("windowControlShadow", context -> new DShadow(0x80888888, 0, 0, 2 * context.getScale()));
71
+		
72
+		height = aspectBarPaddingTop + controlPaddingTop + controlHeight + controlPaddingBottom + marginBottom;
66 73
 	}
67 74
 }

+ 8
- 9
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/aspectbar/AspectBarView.java Datei anzeigen

@@ -153,6 +153,7 @@ public class AspectBarView extends BaseComponentGroup {
153 153
 	public void paint(DCanvas canvas) {
154 154
 		canvas.pushBounds(bounds);
155 155
 		canvas.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height, style.backgroundColor);
156
+		canvas.fillRectangle(bounds.x, bounds.y + bounds.height - style.marginBottom, bounds.width, style.marginBottom, style.backgroundColorBottom);
156 157
 		
157 158
 		for (DComponent button : selectorButtons) {
158 159
 			if (button.getBounds() == null)
@@ -164,11 +165,8 @@ public class AspectBarView extends BaseComponentGroup {
164 165
 		canvas.shadowPath(
165 166
 				aspectBarShape,
166 167
 				DTransform2D.IDENTITY,
168
+				style.foregroundColor,
167 169
 				style.aspectBarShadow);
168
-		canvas.fillPath(
169
-				aspectBarShape,
170
-				DTransform2D.IDENTITY,
171
-				style.foregroundColor);
172 170
 		
173 171
 		if (aspectBar.active.getValue() != null) {
174 172
 			int y = bounds.y
@@ -191,7 +189,7 @@ public class AspectBarView extends BaseComponentGroup {
191 189
 		}
192 190
 		
193 191
 		if (showWindowControls) {
194
-			canvas.shadowPath(windowControlsShape, DTransform2D.IDENTITY, style.windowControlShadow);
192
+			canvas.shadowPath(windowControlsShape, DTransform2D.IDENTITY, style.backgroundColor, style.windowControlShadow);
195 193
 			minimize.paint(canvas);
196 194
 			maximizeRestore.paint(canvas);
197 195
 			close.paint(canvas);
@@ -251,7 +249,7 @@ public class AspectBarView extends BaseComponentGroup {
251 249
 		for (DComponent component : selectorButtons) {
252 250
 			int width = component.getSizing().getValue().preferredWidth;
253 251
 			int height = component.getSizing().getValue().preferredHeight;
254
-			int y = bounds.y + (bounds.height - style.aspectSelectorBottomSize - height) / 2;
252
+			int y = bounds.y + (bounds.height - style.marginBottom - style.aspectSelectorBottomSize - height) / 2;
255 253
 			component.setBounds(new DIRectangle(x, y, width, height));
256 254
 			
257 255
 			x += width + style.aspectSelectorButtonSpacing;
@@ -327,7 +325,8 @@ public class AspectBarView extends BaseComponentGroup {
327 325
 		int toX = aspectSelectorEndX;
328 326
 		
329 327
 		aspectBarShape = tracer -> {
330
-			int baseY = bounds.y + bounds.height - style.aspectSelectorBottomSize;
328
+			int height = bounds.height - style.marginBottom;
329
+			int baseY = bounds.y + height - style.aspectSelectorBottomSize;
331 330
 			int barBaseX = toX + style.aspectSelectorToToolbarSpacing;
332 331
 			int barBaseY = bounds.y + style.aspectBarPaddingTop;
333 332
 			
@@ -355,8 +354,8 @@ public class AspectBarView extends BaseComponentGroup {
355 354
 				tracer.lineTo(bounds.x + bounds.width, bounds.y + style.aspectBarPaddingTop);
356 355
 			}
357 356
 			
358
-			tracer.lineTo(bounds.x + bounds.width, bounds.y + bounds.height);
359
-			tracer.lineTo(bounds.x, bounds.y + bounds.height);
357
+			tracer.lineTo(bounds.x + bounds.width, bounds.y + height);
358
+			tracer.lineTo(bounds.x, bounds.y + height);
360 359
 			tracer.close();
361 360
 		};
362 361
 		

+ 11
- 2
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/SourceEditor.java Datei anzeigen

@@ -29,6 +29,8 @@ import org.openzen.zenscript.lexer.ZSTokenParser;
29 29
 import org.openzen.zenscript.lexer.ZSTokenType;
30 30
 import org.openzen.drawablegui.DUIContext;
31 31
 import org.openzen.drawablegui.live.ImmutableLiveString;
32
+import org.openzen.drawablegui.live.InverseLiveBool;
33
+import org.openzen.drawablegui.live.LiveBool;
32 34
 import org.openzen.drawablegui.live.MutableLiveObject;
33 35
 import org.openzen.drawablegui.live.SimpleLiveBool;
34 36
 import org.openzen.drawablegui.style.DStyleClass;
@@ -75,19 +77,22 @@ public class SourceEditor implements DComponent {
75 77
 	private final IDEWindow window;
76 78
 	private final IDEAspectToolbar editToolbar = new IDEAspectToolbar(0, ShadedCodeIcon.BLUE, "Edit", "Source code editor");
77 79
 	
80
+	private final LiveBool updated;
81
+	
78 82
 	public SourceEditor(DStyleClass styleClass, IDEWindow window, IDESourceFile sourceFile) {
79 83
 		this.styleClass = styleClass;
80 84
 		this.window = window;
81 85
 		this.sourceFile = sourceFile;
82 86
 		
83
-		tokens = new TokenModel(sourceFile.getName(), tab.length());
87
+		tokens = new TokenModel(sourceFile.getName().getValue(), tab.length());
84 88
 		tokenListener = tokens.addListener(new TokenListener());
85 89
 		
86 90
 		editToolbar.controls.add(() -> new IconButtonControl(DStyleClass.EMPTY, ShadedSaveIcon.PURPLE, SaveIcon.GREY, unchanged, new ImmutableLiveString("Save file"), e -> save()));
91
+		updated = new InverseLiveBool(unchanged);
87 92
 		
88 93
 		try {
89 94
 			TokenParser<ZSToken, ZSTokenType> parser = ZSTokenParser.createRaw(
90
-					sourceFile.getName(),
95
+					sourceFile.getName().getValue(),
91 96
 					new ReaderCharReader(sourceFile.read()),
92 97
 					tab.length());
93 98
 			tokens.set(parser);
@@ -96,6 +101,10 @@ public class SourceEditor implements DComponent {
96 101
 		}
97 102
 	}
98 103
 	
104
+	public LiveBool isUpdated() {
105
+		return updated;
106
+	}
107
+	
99 108
 	@Override
100 109
 	public void onMounted() {
101 110
 		window.aspectBar.toolbars.add(editToolbar);

+ 23
- 0
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/output/BasicOutputSpan.java Datei anzeigen

@@ -0,0 +1,23 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.ide.ui.view.output;
7
+
8
+/**
9
+ *
10
+ * @author Hoofdgebruiker
11
+ */
12
+public class BasicOutputSpan implements OutputSpan {
13
+	private final String value;
14
+	
15
+	public BasicOutputSpan(String value) {
16
+		this.value = value;
17
+	}
18
+	
19
+	@Override
20
+	public String toString() {
21
+		return value;
22
+	}
23
+}

+ 23
- 0
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/output/ErrorOutputSpan.java Datei anzeigen

@@ -0,0 +1,23 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.ide.ui.view.output;
7
+
8
+/**
9
+ *
10
+ * @author Hoofdgebruiker
11
+ */
12
+public class ErrorOutputSpan implements OutputSpan {
13
+	private final String value;
14
+	
15
+	public ErrorOutputSpan(String value) {
16
+		this.value = value;
17
+	}
18
+	
19
+	@Override
20
+	public String toString() {
21
+		return value;
22
+	}
23
+}

+ 26
- 0
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/output/OutputLine.java Datei anzeigen

@@ -0,0 +1,26 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.ide.ui.view.output;
7
+
8
+/**
9
+ *
10
+ * @author Hoofdgebruiker
11
+ */
12
+public class OutputLine {
13
+	public final OutputSpan[] spans;
14
+	
15
+	public OutputLine(OutputSpan[] spans) {
16
+		this.spans = spans;
17
+	}
18
+	
19
+	@Override
20
+	public String toString() {
21
+		StringBuilder result = new StringBuilder();
22
+		for (OutputSpan span : spans)
23
+			result.append(span.toString());
24
+		return result.toString();
25
+	}
26
+}

+ 14
- 0
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/output/OutputSpan.java Datei anzeigen

@@ -0,0 +1,14 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.ide.ui.view.output;
7
+
8
+/**
9
+ *
10
+ * @author Hoofdgebruiker
11
+ */
12
+public interface OutputSpan {
13
+	
14
+}

+ 20
- 0
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/output/OutputView.java Datei anzeigen

@@ -0,0 +1,20 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.ide.ui.view.output;
7
+
8
+import org.openzen.drawablegui.live.LiveList;
9
+
10
+/**
11
+ *
12
+ * @author Hoofdgebruiker
13
+ */
14
+public class OutputView {
15
+	public final LiveList<OutputLine> lines;
16
+	
17
+	public OutputView(LiveList<OutputLine> lines) {
18
+		this.lines = lines;
19
+	}
20
+}

+ 2
- 2
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/project/LibraryTreeNode.java Datei anzeigen

@@ -20,10 +20,10 @@ public class LibraryTreeNode extends ProjectOverviewNode {
20 20
 	private final IDELibrary library;
21 21
 	private final LiveList<ProjectOverviewNode> modules;
22 22
 	
23
-	public LibraryTreeNode(IDEWindow window, IDELibrary library) {
23
+	public LibraryTreeNode(ProjectBrowser browser, IDELibrary library) {
24 24
 		this.library = library;
25 25
 		
26
-		modules = new LiveMappedList<>(library.getModules(), module -> new ModuleTreeNode(window, module));
26
+		modules = new LiveMappedList<>(library.getModules(), module -> new ModuleTreeNode(browser, module));
27 27
 	}
28 28
 	
29 29
 	@Override

+ 3
- 3
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/project/ModuleTreeNode.java Datei anzeigen

@@ -16,8 +16,8 @@ import org.openzen.zenscript.ide.ui.icons.ModuleIcon;
16 16
  * @author Hoofdgebruiker
17 17
  */
18 18
 public class ModuleTreeNode extends PackageTreeNode {
19
-	public ModuleTreeNode(IDEWindow window, IDEModule module) {
20
-		super(window, module.getRootPackage());
19
+	public ModuleTreeNode(ProjectBrowser projectBrowser, IDEModule module) {
20
+		super(projectBrowser, module.getRootPackage());
21 21
 		
22 22
 		init(module);
23 23
 	}
@@ -39,7 +39,7 @@ public class ModuleTreeNode extends PackageTreeNode {
39 39
 	
40 40
 	@Override
41 41
 	public void onMouseClick(DMouseEvent e) {
42
-		window.setContextModule(module);
42
+		browser.setContextModule(module);
43 43
 	}
44 44
 
45 45
 	@Override

+ 8
- 9
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/project/PackageTreeNode.java Datei anzeigen

@@ -12,7 +12,6 @@ import org.openzen.drawablegui.live.LiveList;
12 12
 import org.openzen.drawablegui.live.LiveMappedList;
13 13
 import org.openzen.zenscript.ide.host.IDEModule;
14 14
 import org.openzen.zenscript.ide.host.IDEPackage;
15
-import org.openzen.zenscript.ide.ui.IDEWindow;
16 15
 import org.openzen.zenscript.ide.ui.icons.FolderIcon;
17 16
 
18 17
 /**
@@ -20,18 +19,18 @@ import org.openzen.zenscript.ide.ui.icons.FolderIcon;
20 19
  * @author Hoofdgebruiker
21 20
  */
22 21
 public class PackageTreeNode extends ProjectOverviewNode {
23
-	protected final IDEWindow window;
22
+	protected final ProjectBrowser browser;
24 23
 	protected IDEModule module;
25 24
 	private final IDEPackage pkg;
26 25
 	private LiveList<ProjectOverviewNode> contents;
27 26
 	
28
-	public PackageTreeNode(IDEWindow window, IDEPackage pkg) {
29
-		this.window = window;
27
+	public PackageTreeNode(ProjectBrowser browser, IDEPackage pkg) {
28
+		this.browser = browser;
30 29
 		this.pkg = pkg;
31 30
 	}
32 31
 	
33
-	public PackageTreeNode(IDEWindow window, IDEModule module, IDEPackage pkg) {
34
-		this.window = window;
32
+	public PackageTreeNode(ProjectBrowser browser, IDEModule module, IDEPackage pkg) {
33
+		this.browser = browser;
35 34
 		this.module = module;
36 35
 		this.pkg = pkg;
37 36
 		
@@ -41,8 +40,8 @@ public class PackageTreeNode extends ProjectOverviewNode {
41 40
 	protected final void init(IDEModule module) {
42 41
 		this.module = module;
43 42
 		contents = new LiveConcatList<>(
44
-				new LiveMappedList<>(pkg.getSubPackages(), sub -> new PackageTreeNode(window, module, sub)),
45
-				new LiveMappedList<>(pkg.getSourceFiles(), source -> new SourceFileTreeNode(window, source))
43
+				new LiveMappedList<>(pkg.getSubPackages(), sub -> new PackageTreeNode(browser, module, sub)),
44
+				new LiveMappedList<>(pkg.getSourceFiles(), source -> new SourceFileTreeNode(browser, source))
46 45
 		);
47 46
 	}
48 47
 	
@@ -78,6 +77,6 @@ public class PackageTreeNode extends ProjectOverviewNode {
78 77
 	
79 78
 	@Override
80 79
 	public void onMouseClick(DMouseEvent e) {
81
-		window.setContextPackage(module, pkg);
80
+		browser.setContextPackage(module, pkg);
82 81
 	}
83 82
 }

+ 132
- 0
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/project/ProjectBrowser.java Datei anzeigen

@@ -0,0 +1,132 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.ide.ui.view.project;
7
+
8
+import org.openzen.drawablegui.DComponent;
9
+import org.openzen.drawablegui.layout.DHorizontalLayout;
10
+import org.openzen.drawablegui.DSizing;
11
+import org.openzen.drawablegui.layout.DVerticalLayout;
12
+import org.openzen.drawablegui.border.DEmptyBorder;
13
+import org.openzen.drawablegui.border.DPaddedBorder;
14
+import org.openzen.drawablegui.live.ImmutableLiveString;
15
+import org.openzen.drawablegui.live.LiveBool;
16
+import org.openzen.drawablegui.live.LivePredicateBool;
17
+import org.openzen.drawablegui.live.MutableLiveObject;
18
+import org.openzen.drawablegui.live.SimpleLiveObject;
19
+import org.openzen.drawablegui.scroll.DScrollPane;
20
+import org.openzen.drawablegui.style.DShadow;
21
+import org.openzen.drawablegui.style.DStyleClass;
22
+import org.openzen.drawablegui.style.DStylesheetBuilder;
23
+import org.openzen.drawablegui.tree.DTreeView;
24
+import org.openzen.drawablegui.tree.DTreeViewStyle;
25
+import org.openzen.zenscript.ide.host.DevelopmentHost;
26
+import org.openzen.zenscript.ide.host.IDEModule;
27
+import org.openzen.zenscript.ide.host.IDEPackage;
28
+import org.openzen.zenscript.ide.host.IDESourceFile;
29
+import org.openzen.zenscript.ide.ui.IDEWindow;
30
+import org.openzen.zenscript.ide.ui.dialog.CreatePackageDialog;
31
+import org.openzen.zenscript.ide.ui.dialog.CreateSourceFileDialog;
32
+import org.openzen.zenscript.ide.ui.icons.AddBoxIcon;
33
+import org.openzen.zenscript.ide.ui.view.IconButtonControl;
34
+
35
+/**
36
+ *
37
+ * @author Hoofdgebruiker
38
+ */
39
+public class ProjectBrowser {
40
+	public final IDEWindow window;
41
+	public final DComponent view;
42
+	
43
+	public final MutableLiveObject<IDEModule> contextModule = new SimpleLiveObject<>(null);
44
+	public final MutableLiveObject<IDEPackage> contextPackage = new SimpleLiveObject<>(null);
45
+	public final MutableLiveObject<IDESourceFile> contextFile = new SimpleLiveObject<>(null);
46
+	public final LiveBool addContentDisabled = new LivePredicateBool(contextPackage, pkg -> pkg == null);
47
+	
48
+	public ProjectBrowser(IDEWindow window, DevelopmentHost host) {
49
+		this.window = window;
50
+		
51
+		DStyleClass minimalButtonPadding = DStyleClass.inline(new DStylesheetBuilder()
52
+				.dimensionDp("margin", 3)
53
+				.dimensionDp("padding", 0)
54
+				.build());
55
+		
56
+		IconButtonControl addPackageButton = new IconButtonControl(
57
+				minimalButtonPadding,
58
+				AddBoxIcon.BLUE,
59
+				AddBoxIcon.GRAY,
60
+				addContentDisabled,
61
+				new ImmutableLiveString("Create package"),
62
+				e -> {
63
+					CreatePackageDialog dialog = new CreatePackageDialog(contextModule.getValue(), contextPackage.getValue());
64
+					dialog.open(e.window);
65
+				});
66
+		IconButtonControl addFileButton = new IconButtonControl(
67
+				minimalButtonPadding,
68
+				AddBoxIcon.ORANGE,
69
+				AddBoxIcon.GRAY,
70
+				addContentDisabled,
71
+				new ImmutableLiveString("Create source file"),
72
+				e -> {
73
+					CreateSourceFileDialog dialog = new CreateSourceFileDialog(window, contextModule.getValue(), contextPackage.getValue());
74
+					dialog.open(e.window);
75
+				});
76
+		
77
+		DHorizontalLayout toolbar = new DHorizontalLayout(
78
+				DStyleClass.inline(new DStylesheetBuilder()
79
+						.border("border", context -> new DPaddedBorder(0, context.dp(2), 0, 0))
80
+						.dimensionPx("spacing", 0)
81
+						.build()),
82
+				DHorizontalLayout.Alignment.LEFT,
83
+				new DHorizontalLayout.Element(addPackageButton, 0, 0, DHorizontalLayout.ElementAlignment.TOP),
84
+				new DHorizontalLayout.Element(addFileButton, 0, 0, DHorizontalLayout.ElementAlignment.TOP));
85
+		DTreeView projectTree = new DTreeView(
86
+				DTreeViewStyle.DEFAULT,
87
+				new RootTreeNode(this, host), false);
88
+		projectTree.getSizing().setValue(new DSizing(500, 500));
89
+		
90
+		view = new DVerticalLayout(
91
+				DStyleClass.inline(new DStylesheetBuilder()
92
+						.border("border", DEmptyBorder.ELEMENT)
93
+						.dimensionPx("spacing", 0)
94
+						.marginDp("margin", 3)
95
+						.dimensionDp("cornerRadius", 2)
96
+						.color("backgroundColor", 0xFFFFFFFF)
97
+						.shadow("shadow", context -> new DShadow(0xFF888888, 0, 0.5f * context.getScale(), 3 * context.getScale()))
98
+						.build()),
99
+				DVerticalLayout.Alignment.TOP,
100
+				new DVerticalLayout.Element(toolbar, 0, 0, DVerticalLayout.ElementAlignment.STRETCH),
101
+				new DVerticalLayout.Element(new DScrollPane(DStyleClass.forId("projectView"), projectTree), 1, 1, DVerticalLayout.ElementAlignment.STRETCH));
102
+	}
103
+	
104
+	public void setContextModule(IDEModule module) {
105
+		contextModule.setValue(module);
106
+		contextPackage.setValue(module.getRootPackage());
107
+		contextFile.setValue(null);
108
+	}
109
+	
110
+	public void setContextPackage(IDEModule module, IDEPackage pkg) {
111
+		contextModule.setValue(module);
112
+		contextPackage.setValue(pkg);
113
+		contextFile.setValue(null);
114
+	}
115
+	
116
+	public void setContextFile(IDESourceFile file) {
117
+		contextModule.setValue(null);
118
+		contextPackage.setValue(null);
119
+		contextFile.setValue(file);
120
+	}
121
+	
122
+	public void setContextProject() {
123
+		contextModule.setValue(null);
124
+		contextPackage.setValue(null);
125
+		contextFile.setValue(null);
126
+		window.aspectBar.active.setValue(window.projectToolbar);
127
+	}
128
+	
129
+	public void open(IDESourceFile file) {
130
+		window.open(file);
131
+	}
132
+}

+ 5
- 6
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/project/ProjectTreeNode.java Datei anzeigen

@@ -10,7 +10,6 @@ import org.openzen.drawablegui.DMouseEvent;
10 10
 import org.openzen.drawablegui.live.LiveList;
11 11
 import org.openzen.drawablegui.live.LiveMappedList;
12 12
 import org.openzen.zenscript.ide.host.DevelopmentHost;
13
-import org.openzen.zenscript.ide.ui.IDEWindow;
14 13
 import org.openzen.zenscript.ide.ui.icons.ProjectIcon;
15 14
 
16 15
 /**
@@ -18,15 +17,15 @@ import org.openzen.zenscript.ide.ui.icons.ProjectIcon;
18 17
  * @author Hoofdgebruiker
19 18
  */
20 19
 public class ProjectTreeNode extends ProjectOverviewNode {
21
-	private final IDEWindow window;
20
+	private final ProjectBrowser browser;
22 21
 	private final DevelopmentHost host;
23 22
 	private final LiveList<ProjectOverviewNode> modules;
24 23
 	
25
-	public ProjectTreeNode(IDEWindow window, DevelopmentHost host) {
26
-		this.window = window;
24
+	public ProjectTreeNode(ProjectBrowser browser, DevelopmentHost host) {
25
+		this.browser = browser;
27 26
 		this.host = host;
28 27
 		
29
-		modules = new LiveMappedList<>(host.getModules(), module -> new ModuleTreeNode(window, module));
28
+		modules = new LiveMappedList<>(host.getModules(), module -> new ModuleTreeNode(browser, module));
30 29
 	}
31 30
 	
32 31
 	@Override
@@ -61,6 +60,6 @@ public class ProjectTreeNode extends ProjectOverviewNode {
61 60
 	
62 61
 	@Override
63 62
 	public void onMouseClick(DMouseEvent e) {
64
-		window.aspectBar.active.setValue(window.projectToolbar);
63
+		browser.setContextProject();
65 64
 	}
66 65
 }

+ 3
- 4
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/project/RootTreeNode.java Datei anzeigen

@@ -10,7 +10,6 @@ import org.openzen.drawablegui.live.LiveList;
10 10
 import org.openzen.drawablegui.live.LiveMappedList;
11 11
 import org.openzen.drawablegui.live.LivePrefixedList;
12 12
 import org.openzen.zenscript.ide.host.DevelopmentHost;
13
-import org.openzen.zenscript.ide.ui.IDEWindow;
14 13
 import org.openzen.zenscript.ide.ui.icons.ProjectIcon;
15 14
 
16 15
 /**
@@ -21,12 +20,12 @@ public class RootTreeNode extends ProjectOverviewNode {
21 20
 	private final DevelopmentHost host;
22 21
 	private final LiveList<ProjectOverviewNode> children;
23 22
 	
24
-	public RootTreeNode(IDEWindow window, DevelopmentHost host) {
23
+	public RootTreeNode(ProjectBrowser browser, DevelopmentHost host) {
25 24
 		this.host = host;
26 25
 		
27 26
 		children = new LivePrefixedList<>(
28
-				new ProjectTreeNode(window, host),
29
-				new LiveMappedList<>(host.getLibraries(), library -> new LibraryTreeNode(window, library)));
27
+				new ProjectTreeNode(browser, host),
28
+				new LiveMappedList<>(host.getLibraries(), library -> new LibraryTreeNode(browser, library)));
30 29
 	}
31 30
 	
32 31
 	@Override

+ 6
- 7
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/project/SourceFileTreeNode.java Datei anzeigen

@@ -10,7 +10,6 @@ import org.openzen.drawablegui.DMouseEvent;
10 10
 import org.openzen.drawablegui.live.LiveEmptyList;
11 11
 import org.openzen.drawablegui.live.LiveList;
12 12
 import org.openzen.zenscript.ide.host.IDESourceFile;
13
-import org.openzen.zenscript.ide.ui.IDEWindow;
14 13
 import org.openzen.zenscript.ide.ui.icons.CodeIcon;
15 14
 
16 15
 /**
@@ -18,11 +17,11 @@ import org.openzen.zenscript.ide.ui.icons.CodeIcon;
18 17
  * @author Hoofdgebruiker
19 18
  */
20 19
 public class SourceFileTreeNode extends ProjectOverviewNode {
21
-	private final IDEWindow window;
20
+	private final ProjectBrowser browser;
22 21
 	private final IDESourceFile sourceFile;
23 22
 	
24
-	public SourceFileTreeNode(IDEWindow window, IDESourceFile sourceFile) {
25
-		this.window = window;
23
+	public SourceFileTreeNode(ProjectBrowser browser, IDESourceFile sourceFile) {
24
+		this.browser = browser;
26 25
 		this.sourceFile = sourceFile;
27 26
 	}
28 27
 	
@@ -43,7 +42,7 @@ public class SourceFileTreeNode extends ProjectOverviewNode {
43 42
 
44 43
 	@Override
45 44
 	public String getTitle() {
46
-		return sourceFile.getName();
45
+		return sourceFile.getName().getValue(); // TODO: live strings for node names
47 46
 	}
48 47
 
49 48
 	@Override
@@ -58,9 +57,9 @@ public class SourceFileTreeNode extends ProjectOverviewNode {
58 57
 	
59 58
 	@Override
60 59
 	public void onMouseClick(DMouseEvent e) {
61
-		window.setContextFile(sourceFile);
60
+		browser.setContextFile(sourceFile);
62 61
 		if (e.isDoubleClick()) {
63
-			window.open(sourceFile);
62
+			browser.open(sourceFile);
64 63
 		}
65 64
 	}
66 65
 }

Laden…
Abbrechen
Speichern