Browse Source

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

Stan Hebben 6 years ago
parent
commit
5248b0747b
73 changed files with 1026 additions and 230 deletions
  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 View File

91
 		}
91
 		}
92
 		
92
 		
93
 		DPath shape = DPath.roundedRectangle(bounds.x, bounds.y, bounds.width, bounds.height, 2 * context.getScale());
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
 		canvas.drawText(style.font, style.textColor, bounds.x + style.paddingLeft, bounds.y + style.paddingTop + fontMetrics.getAscent(), label.getValue());
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 View File

52
 	 * @param transform
52
 	 * @param transform
53
 	 * @param shadow
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
 	 * Fills a rectangle.
58
 	 * Fills a rectangle.

+ 10
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/DPath.java View File

10
  * @author Hoofdgebruiker
10
  * @author Hoofdgebruiker
11
  */
11
  */
12
 public interface DPath {
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
 	public static DPath circle(float x, float y, float radius) {
20
 	public static DPath circle(float x, float y, float radius) {
14
 		// see http://spencermortensen.com/articles/bezier-circle/
21
 		// see http://spencermortensen.com/articles/bezier-circle/
15
 		return tracer -> {
22
 		return tracer -> {
45
 	}
52
 	}
46
 	
53
 	
47
 	public static DPath roundedRectangle(float x, float y, float width, float height, float radius) {
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
 		return tracer -> {
58
 		return tracer -> {
49
 			float c = radius - radius * 0.551915024494f;
59
 			float c = radius - radius * 0.551915024494f;
50
 			tracer.moveTo(x + width - radius, y + height);
60
 			tracer.moveTo(x + width - radius, y + height);

+ 1
- 1
DrawableGui/src/main/java/org/openzen/drawablegui/DUIWindow.java View File

13
  * @author Hoofdgebruiker
13
  * @author Hoofdgebruiker
14
  */
14
  */
15
 public interface DUIWindow {
15
 public interface DUIWindow {
16
-	DIRectangle getWindowBounds();
16
+	LiveObject<DIRectangle> getWindowBounds();
17
 	
17
 	
18
 	DUIContext getContext();
18
 	DUIContext getContext();
19
 	
19
 	

+ 1
- 2
DrawableGui/src/main/java/org/openzen/drawablegui/border/DCustomWindowBorder.java View File

120
 					|| canvasBounds.y < bounds.y + spacing
120
 					|| canvasBounds.y < bounds.y + spacing
121
 					|| canvasBounds.x + canvasBounds.width > bounds.x + bounds.width - spacing
121
 					|| canvasBounds.x + canvasBounds.width > bounds.x + bounds.width - spacing
122
 					|| canvasBounds.y + canvasBounds.height > bounds.y + bounds.height - spacing) {
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
 				canvas.strokePath(
124
 				canvas.strokePath(
126
 						border,
125
 						border,
127
 						DTransform2D.IDENTITY,
126
 						DTransform2D.IDENTITY,

+ 2
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/border/DEmptyBorder.java View File

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

+ 81
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/border/DSideBorder.java View File

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 View File

3
  * To change this template file, choose Tools | Templates
3
  * To change this template file, choose Tools | Templates
4
  * and open the template in the editor.
4
  * and open the template in the editor.
5
  */
5
  */
6
-package org.openzen.drawablegui;
6
+package org.openzen.drawablegui.layout;
7
 
7
 
8
 import java.util.function.Consumer;
8
 import java.util.function.Consumer;
9
 import java.util.function.Predicate;
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
 import org.openzen.drawablegui.listeners.ListenerHandle;
16
 import org.openzen.drawablegui.listeners.ListenerHandle;
11
 import org.openzen.drawablegui.live.LiveObject;
17
 import org.openzen.drawablegui.live.LiveObject;
12
 import org.openzen.drawablegui.live.MutableLiveObject;
18
 import org.openzen.drawablegui.live.MutableLiveObject;
99
 	@Override
105
 	@Override
100
 	public void paint(DCanvas canvas) {
106
 	public void paint(DCanvas canvas) {
101
 		canvas.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height, style.backgroundColor);
107
 		canvas.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height, style.backgroundColor);
108
+		style.border.paint(canvas, bounds);
102
 		for (Element element : components) {
109
 		for (Element element : components) {
103
 			element.component.paint(canvas);
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 View File

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

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

+ 20
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/layout/DSideLayoutStyle.java View File

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 View File

3
  * To change this template file, choose Tools | Templates
3
  * To change this template file, choose Tools | Templates
4
  * and open the template in the editor.
4
  * and open the template in the editor.
5
  */
5
  */
6
-package org.openzen.drawablegui;
6
+package org.openzen.drawablegui.layout;
7
 
7
 
8
 import java.util.function.Consumer;
8
 import java.util.function.Consumer;
9
 import java.util.function.Predicate;
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
 import org.openzen.drawablegui.listeners.ListenerHandle;
18
 import org.openzen.drawablegui.listeners.ListenerHandle;
11
 import org.openzen.drawablegui.live.LiveObject;
19
 import org.openzen.drawablegui.live.LiveObject;
12
 import org.openzen.drawablegui.live.MutableLiveObject;
20
 import org.openzen.drawablegui.live.MutableLiveObject;
13
-import org.openzen.drawablegui.live.SimpleLiveObject;
14
 import org.openzen.drawablegui.style.DStyleClass;
21
 import org.openzen.drawablegui.style.DStyleClass;
15
 import org.openzen.drawablegui.style.DStylePath;
22
 import org.openzen.drawablegui.style.DStylePath;
16
 
23
 
30
 	private DIRectangle bounds;
37
 	private DIRectangle bounds;
31
 	private float totalGrow;
38
 	private float totalGrow;
32
 	private float totalShrink;
39
 	private float totalShrink;
40
+	private DPath shape;
33
 	
41
 	
34
 	public DVerticalLayout(DStyleClass styleClass, Alignment alignment, Element... components) {
42
 	public DVerticalLayout(DStyleClass styleClass, Alignment alignment, Element... components) {
35
 		this.styleClass = styleClass;
43
 		this.styleClass = styleClass;
92
 	@Override
100
 	@Override
93
 	public void setBounds(DIRectangle bounds) {
101
 	public void setBounds(DIRectangle bounds) {
94
 		this.bounds = bounds;
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
 		layout();
109
 		layout();
96
 	}
110
 	}
97
 
111
 
98
 	@Override
112
 	@Override
99
 	public void paint(DCanvas canvas) {
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
 		for (Element element : components) {
115
 		for (Element element : components) {
102
 			element.component.paint(canvas);
116
 			element.component.paint(canvas);
103
 		}
117
 		}
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
 		DSizing myPreferences = sizing.getValue();
186
 		DSizing myPreferences = sizing.getValue();
187
+		return myPreferences.preferredHeight - style.margin.getVertical() - style.border.getPaddingVertical();
188
+	}
189
+	
190
+	private void layoutShrinked() {
160
 		if (totalShrink == 0) {
191
 		if (totalShrink == 0) {
161
 			// now what?
192
 			// now what?
162
 			// shrink proportionally, we have to shrink...
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
 			for (int i = 0; i < components.length; i++) {
198
 			for (int i = 0; i < components.length; i++) {
167
 				Element element = components[i];
199
 				Element element = components[i];
173
 				y = idealY;
205
 				y = idealY;
174
 			}
206
 			}
175
 		} else {
207
 		} else {
176
-			int delta = bounds.height - myPreferences.preferredHeight;
208
+			int delta = getInnerHeight() - getPreferredInnerHeight();
177
 			float deltaScaled = delta / totalShrink;
209
 			float deltaScaled = delta / totalShrink;
178
 			int y = bounds.y;
210
 			int y = bounds.y;
179
 			for (Element element : components) {
211
 			for (Element element : components) {
189
 	
221
 	
190
 	private void layoutGrown() {
222
 	private void layoutGrown() {
191
 		// resize according to grow values
223
 		// resize according to grow values
192
-		DSizing myPreferences = sizing.getValue();
193
-		
194
 		if (totalGrow == 0) {
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
 			for (Element element : components) {
227
 			for (Element element : components) {
198
 				DSizing preferences = element.component.getSizing().getValue();
228
 				DSizing preferences = element.component.getSizing().getValue();
199
 				int newY = y + preferences.preferredHeight;
229
 				int newY = y + preferences.preferredHeight;
201
 				y = newY;
231
 				y = newY;
202
 			}
232
 			}
203
 		} else {
233
 		} else {
204
-			int delta = bounds.width - myPreferences.preferredWidth;
234
+			int delta = getPreferredInnerHeight() - getInnerHeight();
205
 			float deltaScaled = delta / totalGrow;
235
 			float deltaScaled = delta / totalGrow;
206
-			int y = bounds.y;
236
+			int y = bounds.y + style.margin.top + style.border.getPaddingTop();
207
 			for (Element element : components) {
237
 			for (Element element : components) {
208
 				DSizing preferences = element.component.getSizing().getValue();
238
 				DSizing preferences = element.component.getSizing().getValue();
209
 				float scaledSize = preferences.preferredHeight + deltaScaled * element.grow;
239
 				float scaledSize = preferences.preferredHeight + deltaScaled * element.grow;
221
 		int width;
251
 		int width;
222
 		switch (element.alignment) {
252
 		switch (element.alignment) {
223
 			case LEFT:
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
 				break;
256
 				break;
227
 			case CENTER:
257
 			case CENTER:
228
 				width = Math.min(preferences.preferredWidth, bounds.width - style.border.getPaddingHorizontal());
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
 				break;
260
 				break;
231
 			case RIGHT:
261
 			case RIGHT:
232
 				width = Math.min(preferences.preferredWidth, bounds.width - style.border.getPaddingHorizontal());
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
 				break;
264
 				break;
235
 			case STRETCH:
265
 			case STRETCH:
236
 			default:
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
 				break;
269
 				break;
240
 		}
270
 		}
241
 		element.component.setBounds(new DIRectangle(x, y, width, height));
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 View File

3
  * To change this template file, choose Tools | Templates
3
  * To change this template file, choose Tools | Templates
4
  * and open the template in the editor.
4
  * and open the template in the editor.
5
  */
5
  */
6
-package org.openzen.drawablegui;
6
+package org.openzen.drawablegui.layout;
7
 
7
 
8
 import org.openzen.drawablegui.border.DBorder;
8
 import org.openzen.drawablegui.border.DBorder;
9
 import org.openzen.drawablegui.border.DPaddedBorder;
9
 import org.openzen.drawablegui.border.DPaddedBorder;
10
 import org.openzen.drawablegui.style.DDpDimension;
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
 import org.openzen.drawablegui.style.DStyleDefinition;
14
 import org.openzen.drawablegui.style.DStyleDefinition;
12
 
15
 
13
 /**
16
 /**
18
 	public final int spacing;
21
 	public final int spacing;
19
 	public final DBorder border;
22
 	public final DBorder border;
20
 	public final int backgroundColor;
23
 	public final int backgroundColor;
24
+	public final DMargin margin;
25
+	public final int cornerRadius;
26
+	public final DShadow shadow;
21
 	
27
 	
22
 	public DVerticalLayoutStyle(DStyleDefinition style) {
28
 	public DVerticalLayoutStyle(DStyleDefinition style) {
23
 		spacing = style.getDimension("spacing", new DDpDimension(8));
29
 		spacing = style.getDimension("spacing", new DDpDimension(8));
24
 		border = style.getBorder("border", context -> new DPaddedBorder(context.dp(8)));
30
 		border = style.getBorder("border", context -> new DPaddedBorder(context.dp(8)));
25
 		backgroundColor = style.getColor("backgroundColor", 0);
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 View File

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 View File

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

+ 3
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/live/SimpleLiveObject.java View File

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

+ 3
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/live/SimpleLiveString.java View File

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

+ 5
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/style/DEmptyStyleDefinition.java View File

49
 	public DBorder getBorder(String name, DBorderElement defaultValue) {
49
 	public DBorder getBorder(String name, DBorderElement defaultValue) {
50
 		return defaultValue.eval(context);
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 View File

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 View File

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 View File

12
  * @author Hoofdgebruiker
12
  * @author Hoofdgebruiker
13
  */
13
  */
14
 public class DPxDimension implements DDimension {
14
 public class DPxDimension implements DDimension {
15
+	public static final DPxDimension ZERO = new DPxDimension(0);
16
+	
15
 	private final float pixels;
17
 	private final float pixels;
16
 	
18
 	
17
 	public DPxDimension(float pixels) {
19
 	public DPxDimension(float pixels) {

+ 1
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/style/DShadow.java View File

11
  */
11
  */
12
 public class DShadow {
12
 public class DShadow {
13
 	public static final DShadow NONE = new DShadow(0, 0, 0, 0);
13
 	public static final DShadow NONE = new DShadow(0, 0, 0, 0);
14
+	public static final DShadowElement NONE_ELEMENT = context -> NONE;
14
 	
15
 	
15
 	public final int color;
16
 	public final int color;
16
 	public final float offsetX;
17
 	public final float offsetX;

+ 8
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/style/DSimpleStylesheet.java View File

80
 			
80
 			
81
 			return elements.get(name).asBorder().eval(context);
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 View File

24
 	public DFont getFont(String name, DFontElement defaultValue);
24
 	public DFont getFont(String name, DFontElement defaultValue);
25
 	
25
 	
26
 	public DBorder getBorder(String name, DBorderElement defaultValue);
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 View File

31
 		throw new RuntimeException("Not a border!");
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
 	default DShadowElement asShadow() {
38
 	default DShadowElement asShadow() {
35
 		throw new RuntimeException("Not a shadow!");
39
 		throw new RuntimeException("Not a shadow!");
36
 	}
40
 	}

+ 5
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/style/DStylesheetBuilder.java View File

50
 		return this;
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
 	public DStylesheet build() {
58
 	public DStylesheet build() {
54
 		return new DSimpleStylesheet(elements);
59
 		return new DSimpleStylesheet(elements);
55
 	}
60
 	}

+ 7
- 2
DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingCanvas.java View File

118
 	}
118
 	}
119
 
119
 
120
 	@Override
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
 			return;
124
 			return;
125
+		}
124
 		
126
 		
125
 		if (shadow.radius == 0) {
127
 		if (shadow.radius == 0) {
126
 			fillPath(path, transform, shadow.color);
128
 			fillPath(path, transform, shadow.color);
129
+			fillPath(path, transform, color);
127
 			return;
130
 			return;
128
 		}
131
 		}
129
 		
132
 		
143
 		image = getGaussianBlurFilter((int)Math.ceil(shadow.radius), true).filter(image, null);
146
 		image = getGaussianBlurFilter((int)Math.ceil(shadow.radius), true).filter(image, null);
144
 		image = getGaussianBlurFilter((int)Math.ceil(shadow.radius), false).filter(image, null);
147
 		image = getGaussianBlurFilter((int)Math.ceil(shadow.radius), false).filter(image, null);
145
 		g.drawImage(image, bounds.x - offset, bounds.y - offset, null);
148
 		g.drawImage(image, bounds.x - offset, bounds.y - offset, null);
149
+		
150
+		fillPath(path, transform, color);
146
 	}
151
 	}
147
 
152
 
148
 	@Override
153
 	@Override

+ 22
- 3
DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingDialog.java View File

7
 
7
 
8
 import java.awt.BorderLayout;
8
 import java.awt.BorderLayout;
9
 import java.awt.Color;
9
 import java.awt.Color;
10
+import java.awt.event.ComponentAdapter;
11
+import java.awt.event.ComponentEvent;
10
 import java.awt.event.WindowEvent;
12
 import java.awt.event.WindowEvent;
11
 import java.awt.event.WindowListener;
13
 import java.awt.event.WindowListener;
12
 import java.awt.event.WindowStateListener;
14
 import java.awt.event.WindowStateListener;
20
 import org.openzen.drawablegui.border.DCustomWindowBorder;
22
 import org.openzen.drawablegui.border.DCustomWindowBorder;
21
 import org.openzen.drawablegui.live.LiveBool;
23
 import org.openzen.drawablegui.live.LiveBool;
22
 import org.openzen.drawablegui.live.LiveObject;
24
 import org.openzen.drawablegui.live.LiveObject;
25
+import org.openzen.drawablegui.live.MutableLiveObject;
23
 import org.openzen.drawablegui.live.SimpleLiveBool;
26
 import org.openzen.drawablegui.live.SimpleLiveBool;
24
 import org.openzen.drawablegui.live.SimpleLiveObject;
27
 import org.openzen.drawablegui.live.SimpleLiveObject;
25
 import org.openzen.drawablegui.style.DStyleClass;
28
 import org.openzen.drawablegui.style.DStyleClass;
33
 	private final boolean noTitleBar;
36
 	private final boolean noTitleBar;
34
 	private final SimpleLiveObject<State> state = new SimpleLiveObject<>(State.NORMAL);
37
 	private final SimpleLiveObject<State> state = new SimpleLiveObject<>(State.NORMAL);
35
 	private final SimpleLiveBool active = new SimpleLiveBool(true);
38
 	private final SimpleLiveBool active = new SimpleLiveBool(true);
39
+	private final MutableLiveObject<DIRectangle> bounds = new SimpleLiveObject<>(DIRectangle.EMPTY);
36
 	
40
 	
37
 	public SwingDialog(SwingWindow owner, String title, DComponent root, boolean noTitleBar) {
41
 	public SwingDialog(SwingWindow owner, String title, DComponent root, boolean noTitleBar) {
38
 		super(owner, title);
42
 		super(owner, title);
46
 		
50
 		
47
 		addWindowListener(this);
51
 		addWindowListener(this);
48
 		addWindowStateListener(this);
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
 		getContentPane().add(swingComponent = new SwingRoot(root), BorderLayout.CENTER);
65
 		getContentPane().add(swingComponent = new SwingRoot(root), BorderLayout.CENTER);
51
 		swingComponent.setWindow(this);
66
 		swingComponent.setWindow(this);
76
 	}
91
 	}
77
 
92
 
78
 	@Override
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
 	@Override
98
 	@Override
135
 
150
 
136
 	@Override
151
 	@Override
137
 	public void windowOpened(WindowEvent e) {
152
 	public void windowOpened(WindowEvent e) {
138
-		
153
+		updateBounds();
139
 	}
154
 	}
140
 
155
 
141
 	@Override
156
 	@Override
173
 		state.setValue(getStateFromWindowState());
188
 		state.setValue(getStateFromWindowState());
174
 	}
189
 	}
175
 	
190
 	
191
+	private void updateBounds() {
192
+		bounds.setValue(new DIRectangle(getX(), getY(), getWidth(), getHeight()));
193
+	}
194
+	
176
 	private State getStateFromWindowState() {
195
 	private State getStateFromWindowState() {
177
 		/*switch (ge()) {
196
 		/*switch (ge()) {
178
 			case NORMAL:
197
 			case NORMAL:

+ 6
- 5
DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingGraphicsContext.java View File

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

+ 23
- 3
DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingInlineWindow.java View File

6
 package org.openzen.drawablegui.swing;
6
 package org.openzen.drawablegui.swing;
7
 
7
 
8
 import java.awt.BorderLayout;
8
 import java.awt.BorderLayout;
9
+import java.awt.event.ComponentAdapter;
10
+import java.awt.event.ComponentEvent;
9
 import java.awt.event.WindowEvent;
11
 import java.awt.event.WindowEvent;
10
 import java.awt.event.WindowListener;
12
 import java.awt.event.WindowListener;
11
 import java.awt.event.WindowStateListener;
13
 import java.awt.event.WindowStateListener;
17
 import org.openzen.drawablegui.live.ImmutableLiveObject;
19
 import org.openzen.drawablegui.live.ImmutableLiveObject;
18
 import org.openzen.drawablegui.live.LiveBool;
20
 import org.openzen.drawablegui.live.LiveBool;
19
 import org.openzen.drawablegui.live.LiveObject;
21
 import org.openzen.drawablegui.live.LiveObject;
22
+import org.openzen.drawablegui.live.MutableLiveObject;
20
 import org.openzen.drawablegui.live.SimpleLiveBool;
23
 import org.openzen.drawablegui.live.SimpleLiveBool;
24
+import org.openzen.drawablegui.live.SimpleLiveObject;
21
 
25
 
22
 /**
26
 /**
23
  *
27
  *
27
 	public final SwingRoot swingComponent;
31
 	public final SwingRoot swingComponent;
28
 	private final LiveObject<State> state = new ImmutableLiveObject<>(State.NORMAL);
32
 	private final LiveObject<State> state = new ImmutableLiveObject<>(State.NORMAL);
29
 	private final SimpleLiveBool active = new SimpleLiveBool(true);
33
 	private final SimpleLiveBool active = new SimpleLiveBool(true);
34
+	private final MutableLiveObject<DIRectangle> bounds = new SimpleLiveObject<>(DIRectangle.EMPTY);
30
 	
35
 	
31
 	public SwingInlineWindow(SwingWindow owner, String title, DComponent root) {
36
 	public SwingInlineWindow(SwingWindow owner, String title, DComponent root) {
32
 		super(owner);
37
 		super(owner);
37
 		getContentPane().add(swingComponent = new SwingRoot(root), BorderLayout.CENTER);
42
 		getContentPane().add(swingComponent = new SwingRoot(root), BorderLayout.CENTER);
38
 		swingComponent.setWindow(this);
43
 		swingComponent.setWindow(this);
39
 		swingComponent.requestFocusInWindow();
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
 	@Override
58
 	@Override
45
 	}
61
 	}
46
 
62
 
47
 	@Override
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
 	@Override
68
 	@Override
96
 
112
 
97
 	@Override
113
 	@Override
98
 	public void windowOpened(WindowEvent e) {
114
 	public void windowOpened(WindowEvent e) {
99
-		
115
+		updateBounds();
100
 	}
116
 	}
101
 
117
 
102
 	@Override
118
 	@Override
133
 	public void windowStateChanged(WindowEvent e) {
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 View File

87
 
87
 
88
 	@Override
88
 	@Override
89
 	public void componentResized(ComponentEvent e) {
89
 	public void componentResized(ComponentEvent e) {
90
+		if (firstPaint)
91
+			return;
92
+		
90
 		component.setBounds(new DIRectangle(0, 0,
93
 		component.setBounds(new DIRectangle(0, 0,
91
 				e.getComponent().getWidth(),
94
 				e.getComponent().getWidth(),
92
 				e.getComponent().getHeight()));
95
 				e.getComponent().getHeight()));

+ 24
- 3
DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingWindow.java View File

7
 
7
 
8
 import java.awt.BorderLayout;
8
 import java.awt.BorderLayout;
9
 import java.awt.Color;
9
 import java.awt.Color;
10
+import java.awt.event.ComponentAdapter;
11
+import java.awt.event.ComponentEvent;
10
 import java.awt.event.WindowEvent;
12
 import java.awt.event.WindowEvent;
11
 import java.awt.event.WindowListener;
13
 import java.awt.event.WindowListener;
12
 import java.awt.event.WindowStateListener;
14
 import java.awt.event.WindowStateListener;
19
 import org.openzen.drawablegui.border.DCustomWindowBorder;
21
 import org.openzen.drawablegui.border.DCustomWindowBorder;
20
 import org.openzen.drawablegui.live.LiveBool;
22
 import org.openzen.drawablegui.live.LiveBool;
21
 import org.openzen.drawablegui.live.LiveObject;
23
 import org.openzen.drawablegui.live.LiveObject;
24
+import org.openzen.drawablegui.live.MutableLiveObject;
22
 import org.openzen.drawablegui.live.SimpleLiveBool;
25
 import org.openzen.drawablegui.live.SimpleLiveBool;
23
 import org.openzen.drawablegui.live.SimpleLiveObject;
26
 import org.openzen.drawablegui.live.SimpleLiveObject;
24
 import org.openzen.drawablegui.style.DStyleClass;
27
 import org.openzen.drawablegui.style.DStyleClass;
32
 	private final boolean noTitleBar;
35
 	private final boolean noTitleBar;
33
 	private final SimpleLiveObject<State> state = new SimpleLiveObject<>(State.NORMAL);
36
 	private final SimpleLiveObject<State> state = new SimpleLiveObject<>(State.NORMAL);
34
 	private final SimpleLiveBool active = new SimpleLiveBool(true);
37
 	private final SimpleLiveBool active = new SimpleLiveBool(true);
38
+	private final MutableLiveObject<DIRectangle> bounds = new SimpleLiveObject<>(DIRectangle.EMPTY);
35
 	
39
 	
36
 	public SwingWindow(String title, DComponent root, boolean noTitleBar) {
40
 	public SwingWindow(String title, DComponent root, boolean noTitleBar) {
37
 		super(title);
41
 		super(title);
45
 		
49
 		
46
 		addWindowListener(this);
50
 		addWindowListener(this);
47
 		addWindowStateListener(this);
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
 		getContentPane().add(swingComponent = new SwingRoot(root), BorderLayout.CENTER);
64
 		getContentPane().add(swingComponent = new SwingRoot(root), BorderLayout.CENTER);
50
 		swingComponent.setWindow(this);
65
 		swingComponent.setWindow(this);
51
 		swingComponent.requestFocusInWindow();
66
 		swingComponent.requestFocusInWindow();
67
+		
52
 	}
68
 	}
53
 	
69
 	
54
 	@Override
70
 	@Override
57
 	}
73
 	}
58
 
74
 
59
 	@Override
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
 	@Override
80
 	@Override
116
 
132
 
117
 	@Override
133
 	@Override
118
 	public void windowOpened(WindowEvent e) {
134
 	public void windowOpened(WindowEvent e) {
119
-		
135
+		updateBounds();
120
 	}
136
 	}
121
 
137
 
122
 	@Override
138
 	@Override
154
 		state.setValue(getStateFromWindowState());
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
 	private State getStateFromWindowState() {
178
 	private State getStateFromWindowState() {
158
 		switch (getExtendedState()) {
179
 		switch (getExtendedState()) {
159
 			case NORMAL:
180
 			case NORMAL:

+ 36
- 4
IDE/src/main/java/org/openzen/zenscript/ide/Main.java View File

4
 import java.io.IOException;
4
 import java.io.IOException;
5
 import java.util.Arrays;
5
 import java.util.Arrays;
6
 import javax.swing.JFrame;
6
 import javax.swing.JFrame;
7
+import org.openzen.drawablegui.DUIWindow;
7
 import org.openzen.zenscript.ide.host.DevelopmentHost;
8
 import org.openzen.zenscript.ide.host.DevelopmentHost;
8
 import org.openzen.zenscript.ide.host.local.LocalProjectDevelopmentHost;
9
 import org.openzen.zenscript.ide.host.local.LocalProjectDevelopmentHost;
9
 import org.openzen.drawablegui.swing.SwingWindow;
10
 import org.openzen.drawablegui.swing.SwingWindow;
10
 import org.openzen.zenscript.compiler.CompilationUnit;
11
 import org.openzen.zenscript.compiler.CompilationUnit;
11
 import org.openzen.zenscript.constructor.ModuleLoader;
12
 import org.openzen.zenscript.constructor.ModuleLoader;
12
 import org.openzen.zenscript.constructor.Project;
13
 import org.openzen.zenscript.constructor.Project;
14
+import org.openzen.zenscript.ide.host.IDEPropertyDirectory;
15
+import org.openzen.zenscript.ide.host.IDEPropertyStore;
13
 import org.openzen.zenscript.ide.ui.IDEWindow;
16
 import org.openzen.zenscript.ide.ui.IDEWindow;
14
 import org.openzen.zenscript.ide.ui.view.WindowView;
17
 import org.openzen.zenscript.ide.ui.view.WindowView;
15
 
18
 
26
 		Project project = new Project(loader, directory);
29
 		Project project = new Project(loader, directory);
27
 		
30
 		
28
 		DevelopmentHost host = new LocalProjectDevelopmentHost(project);
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
 		IDEWindow window = new IDEWindow(host);
38
 		IDEWindow window = new IDEWindow(host);
33
 		WindowView root = new WindowView(window, host);
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
 		SwingWindow swingWindow = new SwingWindow("ZenCode IDE - " + host.getName(), root, false);
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
 		swingWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
51
 		swingWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
52
+		swingWindow.setExtendedState(uiState.getBool("maximized", false) ? JFrame.MAXIMIZED_BOTH : JFrame.NORMAL);
38
 		swingWindow.setVisible(true);
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 View File

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 View File

14
 public interface DevelopmentHost {
14
 public interface DevelopmentHost {
15
 	public String getName();
15
 	public String getName();
16
 	
16
 	
17
+	public IDEPropertyStore getPropertyStore();
18
+	
17
 	public LiveList<IDEModule> getModules();
19
 	public LiveList<IDEModule> getModules();
18
 	
20
 	
19
 	public LiveList<IDELibrary> getLibraries();
21
 	public LiveList<IDELibrary> getLibraries();

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

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 View File

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 View File

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

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

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 View File

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 View File

48
 		}
48
 		}
49
 		
49
 		
50
 		subPackagesSorted = new SortedLiveList<>(subPackages, (a, b) -> a.getName().compareTo(b.getName()));
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
 	@Override
54
 	@Override

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

5
  */
5
  */
6
 package org.openzen.zenscript.ide.host.local;
6
 package org.openzen.zenscript.ide.host.local;
7
 
7
 
8
+import java.io.File;
8
 import org.openzen.drawablegui.live.LiveArrayList;
9
 import org.openzen.drawablegui.live.LiveArrayList;
9
 import org.openzen.drawablegui.live.LiveList;
10
 import org.openzen.drawablegui.live.LiveList;
10
 import org.openzen.drawablegui.live.MutableLiveList;
11
 import org.openzen.drawablegui.live.MutableLiveList;
15
 import org.openzen.zenscript.ide.host.DevelopmentHost;
16
 import org.openzen.zenscript.ide.host.DevelopmentHost;
16
 import org.openzen.zenscript.ide.host.IDEModule;
17
 import org.openzen.zenscript.ide.host.IDEModule;
17
 import org.openzen.zenscript.ide.host.IDELibrary;
18
 import org.openzen.zenscript.ide.host.IDELibrary;
19
+import org.openzen.zenscript.ide.host.IDEPropertyStore;
18
 import org.openzen.zenscript.ide.host.IDETarget;
20
 import org.openzen.zenscript.ide.host.IDETarget;
19
 
21
 
20
 /**
22
 /**
47
 	public String getName() {
49
 	public String getName() {
48
 		return project.name;
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
 	@Override
58
 	@Override
52
 	public LiveList<IDEModule> getModules() {
59
 	public LiveList<IDEModule> getModules() {

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

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

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

6
 package org.openzen.zenscript.ide.ui;
6
 package org.openzen.zenscript.ide.ui;
7
 
7
 
8
 import org.openzen.drawablegui.live.ImmutableLiveString;
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
 import org.openzen.drawablegui.style.DStyleClass;
9
 import org.openzen.drawablegui.style.DStyleClass;
14
 import org.openzen.zenscript.ide.host.DevelopmentHost;
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
 import org.openzen.zenscript.ide.host.IDESourceFile;
11
 import org.openzen.zenscript.ide.host.IDESourceFile;
18
 import org.openzen.zenscript.ide.host.IDETarget;
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
 import org.openzen.zenscript.ide.ui.icons.BuildIcon;
13
 import org.openzen.zenscript.ide.ui.icons.BuildIcon;
23
 import org.openzen.zenscript.ide.ui.icons.PlayIcon;
14
 import org.openzen.zenscript.ide.ui.icons.PlayIcon;
24
 import org.openzen.zenscript.ide.ui.icons.SettingsIcon;
15
 import org.openzen.zenscript.ide.ui.icons.SettingsIcon;
38
 	
29
 	
39
 	public IDEAspectToolbar projectToolbar;
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
 	public IDEWindow(DevelopmentHost host) {
32
 	public IDEWindow(DevelopmentHost host) {
47
 		this.host = host;
33
 		this.host = host;
48
 		
34
 		
84
 		}));
70
 		}));
85
 		aspectBar.toolbars.add(projectToolbar);
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 View File

8
 import org.openzen.drawablegui.DAnchor;
8
 import org.openzen.drawablegui.DAnchor;
9
 import org.openzen.drawablegui.DButton;
9
 import org.openzen.drawablegui.DButton;
10
 import org.openzen.drawablegui.DComponent;
10
 import org.openzen.drawablegui.DComponent;
11
-import org.openzen.drawablegui.DHorizontalLayout;
11
+import org.openzen.drawablegui.layout.DHorizontalLayout;
12
 import org.openzen.drawablegui.DIRectangle;
12
 import org.openzen.drawablegui.DIRectangle;
13
 import org.openzen.drawablegui.DInputField;
13
 import org.openzen.drawablegui.DInputField;
14
 import org.openzen.drawablegui.DLabel;
14
 import org.openzen.drawablegui.DLabel;
15
 import org.openzen.drawablegui.DUIWindow;
15
 import org.openzen.drawablegui.DUIWindow;
16
-import org.openzen.drawablegui.DVerticalLayout;
16
+import org.openzen.drawablegui.layout.DVerticalLayout;
17
 import org.openzen.drawablegui.form.DForm;
17
 import org.openzen.drawablegui.form.DForm;
18
 import org.openzen.drawablegui.form.DFormComponent;
18
 import org.openzen.drawablegui.form.DFormComponent;
19
 import org.openzen.drawablegui.live.ImmutableLiveBool;
19
 import org.openzen.drawablegui.live.ImmutableLiveBool;
23
 import org.openzen.drawablegui.style.DStyleClass;
23
 import org.openzen.drawablegui.style.DStyleClass;
24
 import org.openzen.zenscript.ide.host.IDEModule;
24
 import org.openzen.zenscript.ide.host.IDEModule;
25
 import org.openzen.zenscript.ide.host.IDEPackage;
25
 import org.openzen.zenscript.ide.host.IDEPackage;
26
-import org.openzen.zenscript.ide.ui.IDEWindow;
27
 
26
 
28
 /**
27
 /**
29
  *
28
  *
71
 	}
70
 	}
72
 	
71
 	
73
 	public void open(DUIWindow parent) {
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
 		window.focus(input);
75
 		window.focus(input);
77
 	}
76
 	}
78
 	
77
 	

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

8
 import org.openzen.drawablegui.DAnchor;
8
 import org.openzen.drawablegui.DAnchor;
9
 import org.openzen.drawablegui.DButton;
9
 import org.openzen.drawablegui.DButton;
10
 import org.openzen.drawablegui.DComponent;
10
 import org.openzen.drawablegui.DComponent;
11
-import org.openzen.drawablegui.DHorizontalLayout;
11
+import org.openzen.drawablegui.layout.DHorizontalLayout;
12
 import org.openzen.drawablegui.DIRectangle;
12
 import org.openzen.drawablegui.DIRectangle;
13
 import org.openzen.drawablegui.DInputField;
13
 import org.openzen.drawablegui.DInputField;
14
 import org.openzen.drawablegui.DLabel;
14
 import org.openzen.drawablegui.DLabel;
15
 import org.openzen.drawablegui.DUIWindow;
15
 import org.openzen.drawablegui.DUIWindow;
16
-import org.openzen.drawablegui.DVerticalLayout;
16
+import org.openzen.drawablegui.layout.DVerticalLayout;
17
 import org.openzen.drawablegui.form.DForm;
17
 import org.openzen.drawablegui.form.DForm;
18
 import org.openzen.drawablegui.form.DFormComponent;
18
 import org.openzen.drawablegui.form.DFormComponent;
19
 import org.openzen.drawablegui.live.ImmutableLiveBool;
19
 import org.openzen.drawablegui.live.ImmutableLiveBool;
74
 	}
74
 	}
75
 	
75
 	
76
 	public void open(DUIWindow parent) {
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
 		window.focus(input);
79
 		window.focus(input);
80
 	}
80
 	}
81
 	
81
 	

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

49
 	
49
 	
50
 	@Override
50
 	@Override
51
 	public void draw(DCanvas canvas, DTransform2D transform, int color) {
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
 	@Override
55
 	@Override

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

36
 	
36
 	
37
 	@Override
37
 	@Override
38
 	public void draw(DCanvas canvas, DTransform2D transform, int color) {
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
 	@Override
42
 	@Override

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

26
 	
26
 	
27
 	@Override
27
 	@Override
28
 	public void draw(DCanvas canvas, DTransform2D transform, int color) {
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
 	@Override
32
 	@Override

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

68
 	
68
 	
69
 	@Override
69
 	@Override
70
 	public void draw(DCanvas canvas, DTransform2D transform, int color) {
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
 	@Override
74
 	@Override

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

45
 	
45
 	
46
 	@Override
46
 	@Override
47
 	public void draw(DCanvas canvas, DTransform2D transform, int color) {
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
 	@Override
51
 	@Override

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

109
 	@Override
109
 	@Override
110
 	public void paint(DCanvas canvas) {
110
 	public void paint(DCanvas canvas) {
111
 		if (disabled.getValue()) {
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
 		} else if (press) {
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
 		} else if (hover) {
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
 		} else {
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
 		DDrawable icon = disabled.getValue() ? iconDisabled : this.icon;
121
 		DDrawable icon = disabled.getValue() ? iconDisabled : this.icon;

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

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

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

7
 
7
 
8
 import org.openzen.drawablegui.DComponent;
8
 import org.openzen.drawablegui.DComponent;
9
 import org.openzen.drawablegui.DDrawable;
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
  * @author Hoofdgebruiker
15
  * @author Hoofdgebruiker
14
  */
16
  */
15
 public class TabbedViewComponent {
17
 public class TabbedViewComponent {
16
-	public final String title;
18
+	public final LiveString title;
17
 	public final DDrawable icon;
19
 	public final DDrawable icon;
18
 	public final DComponent content;
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
 		this.title = title;
24
 		this.title = title;
22
 		this.icon = icon;
25
 		this.icon = icon;
23
 		this.content = content;
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 View File

14
 import org.openzen.drawablegui.DPath;
14
 import org.openzen.drawablegui.DPath;
15
 import org.openzen.drawablegui.DTransform2D;
15
 import org.openzen.drawablegui.DTransform2D;
16
 import org.openzen.drawablegui.DUIContext;
16
 import org.openzen.drawablegui.DUIContext;
17
+import org.openzen.drawablegui.listeners.ListenerHandle;
18
+import org.openzen.drawablegui.live.LiveBool;
17
 import org.openzen.drawablegui.live.LiveObject;
19
 import org.openzen.drawablegui.live.LiveObject;
20
+import org.openzen.drawablegui.live.LiveString;
18
 import org.openzen.drawablegui.live.MutableLiveObject;
21
 import org.openzen.drawablegui.live.MutableLiveObject;
19
 import org.openzen.drawablegui.style.DStyleClass;
22
 import org.openzen.drawablegui.style.DStyleClass;
20
 import org.openzen.drawablegui.style.DStylePath;
23
 import org.openzen.drawablegui.style.DStylePath;
37
 	private int textWidth;
40
 	private int textWidth;
38
 	private DIRectangle bounds;
41
 	private DIRectangle bounds;
39
 	
42
 	
43
+	private final ListenerHandle<LiveString.Listener> titleListener;
44
+	private final ListenerHandle<LiveBool.Listener> updatedListener;
45
+	
40
 	private boolean hover;
46
 	private boolean hover;
41
 	private boolean press;
47
 	private boolean press;
42
 	
48
 	
45
 		this.currentTab = currentTab;
51
 		this.currentTab = currentTab;
46
 		this.tab = tab;
52
 		this.tab = tab;
47
 		this.closeButton = new TabbedViewTabClose(this);
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
 	public void closeTab() {
59
 	public void closeTab() {
59
 		fontMetrics = context.getFontMetrics(style.tabFont);
68
 		fontMetrics = context.getFontMetrics(style.tabFont);
60
 		closeButton.setContext(path, context);
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
 						+ style.closeIconPadding
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
 				style.paddingTop + fontMetrics.getAscent() + fontMetrics.getDescent()
87
 				style.paddingTop + fontMetrics.getAscent() + fontMetrics.getDescent()
68
 						+ style.paddingBottom));
88
 						+ style.paddingBottom));
69
 	}
89
 	}
99
 	public void paint(DCanvas canvas) {
119
 	public void paint(DCanvas canvas) {
100
 		int width = style.paddingLeft + textWidth + style.paddingRight
120
 		int width = style.paddingLeft + textWidth + style.paddingRight
101
 				+ closeButton.getSizing().getValue().preferredWidth + style.closeIconPadding;
121
 				+ closeButton.getSizing().getValue().preferredWidth + style.closeIconPadding;
122
+		
123
+		if (tab.updated.getValue())
124
+			width += style.updatedDiameter + style.updatedPadding;
102
 
125
 
103
 		int color = style.tabColorNormal;
126
 		int color = style.tabColorNormal;
104
 		if (currentTab.getValue() == tab)
127
 		if (currentTab.getValue() == tab)
110
 
133
 
111
 		canvas.fillRectangle(bounds.x, bounds.y, width, bounds.height, color);
134
 		canvas.fillRectangle(bounds.x, bounds.y, width, bounds.height, color);
112
 		canvas.strokePath(DPath.rectangle(bounds.x, bounds.y, width, bounds.height), DTransform2D.IDENTITY, style.borderColor, style.borderWidth);
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
 		closeButton.paint(canvas);
148
 		closeButton.paint(canvas);
117
 	}
149
 	}
118
 
150
 
119
 	@Override
151
 	@Override
120
 	public void close() {
152
 	public void close() {
121
-		
153
+		titleListener.close();
154
+		updatedListener.close();
122
 	}
155
 	}
123
 	
156
 	
124
 	@Override
157
 	@Override

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

35
 	public final int closeIconSize;
35
 	public final int closeIconSize;
36
 	public final int closeIconPadding;
36
 	public final int closeIconPadding;
37
 	
37
 	
38
+	public final int updatedDiameter;
39
+	public final int updatedPadding;
40
+	public final int updatedColor;
41
+	
38
 	public TabbedViewTabStyle(DStyleDefinition style) {
42
 	public TabbedViewTabStyle(DStyleDefinition style) {
39
 		tabFont = style.getFont("tabFont", context -> new DFont(DFontFamily.UI, false, false, false, (int)(12 * context.getScale())));
43
 		tabFont = style.getFont("tabFont", context -> new DFont(DFontFamily.UI, false, false, false, (int)(12 * context.getScale())));
40
 		tabFontColor = style.getColor("tabFontColor", 0xFF000000);
44
 		tabFontColor = style.getColor("tabFontColor", 0xFF000000);
54
 		
58
 		
55
 		closeIconSize = style.getDimension("closeIconSize", new DDpDimension(16));
59
 		closeIconSize = style.getDimension("closeIconSize", new DDpDimension(16));
56
 		closeIconPadding = style.getDimension("closeIconPadding", new DDpDimension(6));
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 View File

5
  */
5
  */
6
 package org.openzen.zenscript.ide.ui.view;
6
 package org.openzen.zenscript.ide.ui.view;
7
 
7
 
8
-import org.openzen.drawablegui.DSizing;
9
 import org.openzen.drawablegui.DEmptyView;
8
 import org.openzen.drawablegui.DEmptyView;
10
-import org.openzen.drawablegui.DHorizontalLayout;
11
 import org.openzen.drawablegui.scroll.DScrollPane;
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
 import org.openzen.drawablegui.live.LiveString;
11
 import org.openzen.drawablegui.live.LiveString;
17
 import org.openzen.drawablegui.live.SimpleLiveString;
12
 import org.openzen.drawablegui.live.SimpleLiveString;
18
 import org.openzen.drawablegui.style.DStyleClass;
13
 import org.openzen.drawablegui.style.DStyleClass;
19
 import org.openzen.drawablegui.style.DStylesheetBuilder;
14
 import org.openzen.drawablegui.style.DStylesheetBuilder;
20
-import org.openzen.drawablegui.tree.DTreeView;
21
-import org.openzen.drawablegui.tree.DTreeViewStyle;
22
 import org.openzen.zenscript.ide.host.DevelopmentHost;
15
 import org.openzen.zenscript.ide.host.DevelopmentHost;
23
 import org.openzen.zenscript.ide.host.IDESourceFile;
16
 import org.openzen.zenscript.ide.host.IDESourceFile;
24
 import org.openzen.zenscript.ide.ui.IDEDockWindow;
17
 import org.openzen.zenscript.ide.ui.IDEDockWindow;
25
 import org.openzen.zenscript.ide.ui.IDEWindow;
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
 import org.openzen.zenscript.ide.ui.view.aspectbar.AspectBarView;
19
 import org.openzen.zenscript.ide.ui.view.aspectbar.AspectBarView;
30
 import org.openzen.zenscript.ide.ui.view.editor.SourceEditor;
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
 	private final IDEWindow window;
28
 	private final IDEWindow window;
39
 	private final TabbedView tabs;
29
 	private final TabbedView tabs;
40
 	public final LiveString status = new SimpleLiveString("IDE initialized");
30
 	public final LiveString status = new SimpleLiveString("IDE initialized");
31
+	private final ProjectBrowser projectBrowser;
41
 	
32
 	
42
 	public WindowView(IDEWindow window, DevelopmentHost host) {
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
 		this.window = window;
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
 		setMain(tabs = new TabbedView(DStyleClass.EMPTY));
41
 		setMain(tabs = new TabbedView(DStyleClass.EMPTY));
94
-		add(Side.LEFT,projectView);
42
+		add(Side.LEFT, projectBrowser.view);
95
 		add(Side.BOTTOM, new StatusBarView(DStyleClass.EMPTY, status));
43
 		add(Side.BOTTOM, new StatusBarView(DStyleClass.EMPTY, status));
96
 		add(Side.TOP, new AspectBarView(DStyleClass.EMPTY, window.aspectBar));
44
 		add(Side.TOP, new AspectBarView(DStyleClass.EMPTY, window.aspectBar));
97
 		
45
 		
101
 	private class DockWindowListener implements IDEDockWindow.Listener {
49
 	private class DockWindowListener implements IDEDockWindow.Listener {
102
 		@Override
50
 		@Override
103
 		public void onOpen(IDESourceFile sourceFile) {
51
 		public void onOpen(IDESourceFile sourceFile) {
52
+			SourceEditor editor = new SourceEditor(DStyleClass.EMPTY, window, sourceFile);
104
 			TabbedViewComponent tab = new TabbedViewComponent(
53
 			TabbedViewComponent tab = new TabbedViewComponent(
105
 					sourceFile.getName(),
54
 					sourceFile.getName(),
106
 					null,
55
 					null,
107
-					new DScrollPane(DStyleClass.EMPTY, new SourceEditor(DStyleClass.EMPTY, window, sourceFile)));
56
+					new DScrollPane(DStyleClass.EMPTY, editor),
57
+					editor.isUpdated());
108
 			tabs.tabs.add(tab);
58
 			tabs.tabs.add(tab);
109
 			tabs.currentTab.setValue(tab);
59
 			tabs.currentTab.setValue(tab);
110
 		}
60
 		}

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

110
 		canvas.shadowPath(
110
 		canvas.shadowPath(
111
 					shape,
111
 					shape,
112
 					DTransform2D.translate(bounds.x, bounds.y),
112
 					DTransform2D.translate(bounds.x, bounds.y),
113
+					color,
113
 					shadow);
114
 					shadow);
114
-		canvas.fillPath(
115
-				shape,
116
-				DTransform2D.translate(bounds.x, bounds.y),
117
-				color);
118
 		icon.draw(canvas, DTransform2D.scaleAndTranslate(
115
 		icon.draw(canvas, DTransform2D.scaleAndTranslate(
119
 				bounds.x + (style.width - icon.getNominalWidth() * context.getScale()) / 2,
116
 				bounds.x + (style.width - icon.getNominalWidth() * context.getScale()) / 2,
120
 				bounds.y + (style.height - icon.getNominalHeight() * context.getScale()) / 2,
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 View File

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

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

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

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

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

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 View File

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 View File

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 View File

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 View File

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 View File

20
 	private final IDELibrary library;
20
 	private final IDELibrary library;
21
 	private final LiveList<ProjectOverviewNode> modules;
21
 	private final LiveList<ProjectOverviewNode> modules;
22
 	
22
 	
23
-	public LibraryTreeNode(IDEWindow window, IDELibrary library) {
23
+	public LibraryTreeNode(ProjectBrowser browser, IDELibrary library) {
24
 		this.library = library;
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
 	@Override
29
 	@Override

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

16
  * @author Hoofdgebruiker
16
  * @author Hoofdgebruiker
17
  */
17
  */
18
 public class ModuleTreeNode extends PackageTreeNode {
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
 		init(module);
22
 		init(module);
23
 	}
23
 	}
39
 	
39
 	
40
 	@Override
40
 	@Override
41
 	public void onMouseClick(DMouseEvent e) {
41
 	public void onMouseClick(DMouseEvent e) {
42
-		window.setContextModule(module);
42
+		browser.setContextModule(module);
43
 	}
43
 	}
44
 
44
 
45
 	@Override
45
 	@Override

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

12
 import org.openzen.drawablegui.live.LiveMappedList;
12
 import org.openzen.drawablegui.live.LiveMappedList;
13
 import org.openzen.zenscript.ide.host.IDEModule;
13
 import org.openzen.zenscript.ide.host.IDEModule;
14
 import org.openzen.zenscript.ide.host.IDEPackage;
14
 import org.openzen.zenscript.ide.host.IDEPackage;
15
-import org.openzen.zenscript.ide.ui.IDEWindow;
16
 import org.openzen.zenscript.ide.ui.icons.FolderIcon;
15
 import org.openzen.zenscript.ide.ui.icons.FolderIcon;
17
 
16
 
18
 /**
17
 /**
20
  * @author Hoofdgebruiker
19
  * @author Hoofdgebruiker
21
  */
20
  */
22
 public class PackageTreeNode extends ProjectOverviewNode {
21
 public class PackageTreeNode extends ProjectOverviewNode {
23
-	protected final IDEWindow window;
22
+	protected final ProjectBrowser browser;
24
 	protected IDEModule module;
23
 	protected IDEModule module;
25
 	private final IDEPackage pkg;
24
 	private final IDEPackage pkg;
26
 	private LiveList<ProjectOverviewNode> contents;
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
 		this.pkg = pkg;
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
 		this.module = module;
34
 		this.module = module;
36
 		this.pkg = pkg;
35
 		this.pkg = pkg;
37
 		
36
 		
41
 	protected final void init(IDEModule module) {
40
 	protected final void init(IDEModule module) {
42
 		this.module = module;
41
 		this.module = module;
43
 		contents = new LiveConcatList<>(
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
 	
77
 	
79
 	@Override
78
 	@Override
80
 	public void onMouseClick(DMouseEvent e) {
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 View File

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 View File

10
 import org.openzen.drawablegui.live.LiveList;
10
 import org.openzen.drawablegui.live.LiveList;
11
 import org.openzen.drawablegui.live.LiveMappedList;
11
 import org.openzen.drawablegui.live.LiveMappedList;
12
 import org.openzen.zenscript.ide.host.DevelopmentHost;
12
 import org.openzen.zenscript.ide.host.DevelopmentHost;
13
-import org.openzen.zenscript.ide.ui.IDEWindow;
14
 import org.openzen.zenscript.ide.ui.icons.ProjectIcon;
13
 import org.openzen.zenscript.ide.ui.icons.ProjectIcon;
15
 
14
 
16
 /**
15
 /**
18
  * @author Hoofdgebruiker
17
  * @author Hoofdgebruiker
19
  */
18
  */
20
 public class ProjectTreeNode extends ProjectOverviewNode {
19
 public class ProjectTreeNode extends ProjectOverviewNode {
21
-	private final IDEWindow window;
20
+	private final ProjectBrowser browser;
22
 	private final DevelopmentHost host;
21
 	private final DevelopmentHost host;
23
 	private final LiveList<ProjectOverviewNode> modules;
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
 		this.host = host;
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
 	@Override
31
 	@Override
61
 	
60
 	
62
 	@Override
61
 	@Override
63
 	public void onMouseClick(DMouseEvent e) {
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 View File

10
 import org.openzen.drawablegui.live.LiveMappedList;
10
 import org.openzen.drawablegui.live.LiveMappedList;
11
 import org.openzen.drawablegui.live.LivePrefixedList;
11
 import org.openzen.drawablegui.live.LivePrefixedList;
12
 import org.openzen.zenscript.ide.host.DevelopmentHost;
12
 import org.openzen.zenscript.ide.host.DevelopmentHost;
13
-import org.openzen.zenscript.ide.ui.IDEWindow;
14
 import org.openzen.zenscript.ide.ui.icons.ProjectIcon;
13
 import org.openzen.zenscript.ide.ui.icons.ProjectIcon;
15
 
14
 
16
 /**
15
 /**
21
 	private final DevelopmentHost host;
20
 	private final DevelopmentHost host;
22
 	private final LiveList<ProjectOverviewNode> children;
21
 	private final LiveList<ProjectOverviewNode> children;
23
 	
22
 	
24
-	public RootTreeNode(IDEWindow window, DevelopmentHost host) {
23
+	public RootTreeNode(ProjectBrowser browser, DevelopmentHost host) {
25
 		this.host = host;
24
 		this.host = host;
26
 		
25
 		
27
 		children = new LivePrefixedList<>(
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
 	@Override
31
 	@Override

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

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

Loading…
Cancel
Save