Ver código fonte

Performed major drawing optimizations, introducing a new drawing system

Stan Hebben 6 anos atrás
pai
commit
dfac1f9a73
48 arquivos alterados com 1269 adições e 361 exclusões
  1. 10
    9
      DrawableGui/src/main/java/org/openzen/drawablegui/DButton.java
  2. 2
    1
      DrawableGui/src/main/java/org/openzen/drawablegui/DComponent.java
  3. 2
    1
      DrawableGui/src/main/java/org/openzen/drawablegui/DEmptyView.java
  4. 13
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/DIRectangle.java
  5. 14
    13
      DrawableGui/src/main/java/org/openzen/drawablegui/DInputField.java
  6. 10
    7
      DrawableGui/src/main/java/org/openzen/drawablegui/DLabel.java
  7. 37
    15
      DrawableGui/src/main/java/org/openzen/drawablegui/DSimpleTooltipComponent.java
  8. 2
    2
      DrawableGui/src/main/java/org/openzen/drawablegui/border/DBorder.java
  9. 3
    3
      DrawableGui/src/main/java/org/openzen/drawablegui/border/DCompositeBorder.java
  10. 10
    10
      DrawableGui/src/main/java/org/openzen/drawablegui/border/DCustomWindowBorder.java
  11. 2
    2
      DrawableGui/src/main/java/org/openzen/drawablegui/border/DEmptyBorder.java
  12. 9
    3
      DrawableGui/src/main/java/org/openzen/drawablegui/border/DLineBorder.java
  13. 2
    1
      DrawableGui/src/main/java/org/openzen/drawablegui/border/DPaddedBorder.java
  14. 20
    5
      DrawableGui/src/main/java/org/openzen/drawablegui/border/DSideBorder.java
  15. 50
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/draw/DDrawSurface.java
  16. 22
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/draw/DDrawnRectangle.java
  17. 22
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/draw/DDrawnShape.java
  18. 21
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/draw/DDrawnText.java
  19. 18
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/draw/DSubSurface.java
  20. 8
    6
      DrawableGui/src/main/java/org/openzen/drawablegui/form/DForm.java
  21. 22
    14
      DrawableGui/src/main/java/org/openzen/drawablegui/layout/DLinearLayout.java
  22. 24
    13
      DrawableGui/src/main/java/org/openzen/drawablegui/layout/DSideLayout.java
  23. 7
    7
      DrawableGui/src/main/java/org/openzen/drawablegui/scroll/DScrollBar.java
  24. 35
    13
      DrawableGui/src/main/java/org/openzen/drawablegui/scroll/DScrollPane.java
  25. 1
    3
      DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingCanvas.java
  26. 119
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingDrawSurface.java
  27. 30
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingDrawnElement.java
  28. 43
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingDrawnRectangle.java
  29. 54
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingDrawnText.java
  30. 61
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingFilledPath.java
  31. 12
    4
      DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingGraphicsContext.java
  32. 11
    2
      DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingRoot.java
  33. 91
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingShadowedPath.java
  34. 70
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingStrokedPath.java
  35. 157
    0
      DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingSubSurface.java
  36. 36
    23
      DrawableGui/src/main/java/org/openzen/drawablegui/tree/DTreeView.java
  37. 22
    65
      DrawableGui/src/main/java/org/openzen/drawablegui/tree/DTreeViewStyle.java
  38. 14
    13
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/IconButtonControl.java
  39. 20
    8
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/StatusBarView.java
  40. 15
    11
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/TabbedView.java
  41. 9
    9
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/TabbedViewTab.java
  42. 7
    7
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/TabbedViewTabClose.java
  43. 11
    11
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/aspectbar/AspectBarSelectorButton.java
  44. 67
    42
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/aspectbar/AspectBarView.java
  45. 10
    10
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/aspectbar/WindowActionButton.java
  46. 34
    21
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/SourceEditor.java
  47. 5
    6
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/output/OutputView.java
  48. 5
    1
      IDE/src/main/java/org/openzen/zenscript/ide/ui/view/project/ProjectBrowser.java

+ 10
- 9
DrawableGui/src/main/java/org/openzen/drawablegui/DButton.java Ver arquivo

@@ -5,6 +5,7 @@
5 5
  */
6 6
 package org.openzen.drawablegui;
7 7
 
8
+import org.openzen.drawablegui.draw.DDrawSurface;
8 9
 import org.openzen.drawablegui.live.LiveBool;
9 10
 import org.openzen.drawablegui.live.LiveObject;
10 11
 import org.openzen.drawablegui.live.LiveString;
@@ -24,7 +25,7 @@ public class DButton implements DComponent {
24 25
 	private final LiveBool disabled;
25 26
 	private final Runnable action;
26 27
 	
27
-	private DUIContext context;
28
+	private DDrawSurface surface;
28 29
 	private DIRectangle bounds;
29 30
 	
30 31
 	private DButtonStyle style;
@@ -39,14 +40,14 @@ public class DButton implements DComponent {
39 40
 		this.disabled = disabled;
40 41
 		this.action = action;
41 42
 	}
42
-
43
+	
43 44
 	@Override
44
-	public void setContext(DStylePath parent, DUIContext context) {
45
-		this.context = context;
45
+	public void setSurface(DStylePath parent, int z, DDrawSurface surface) {
46
+		this.surface = surface;
46 47
 		
47 48
 		DStylePath path = parent.getChild("Button", styleClass);
48
-		this.style = new DButtonStyle(context.getStylesheets().get(context, path));
49
-		fontMetrics = context.getFontMetrics(style.font);
49
+		this.style = new DButtonStyle(surface.getStylesheet(path));
50
+		fontMetrics = surface.getFontMetrics(style.font);
50 51
 		
51 52
 		sizing.setValue(new DSizing(
52 53
 				style.paddingLeft + style.paddingRight + fontMetrics.getWidth(label.getValue()),
@@ -90,7 +91,7 @@ public class DButton implements DComponent {
90 91
 			shadow = style.shadowDisabled;
91 92
 		}
92 93
 		
93
-		DPath shape = DPath.roundedRectangle(bounds.x, bounds.y, bounds.width, bounds.height, 2 * context.getScale());
94
+		DPath shape = DPath.roundedRectangle(bounds.x, bounds.y, bounds.width, bounds.height, 2 * surface.getScale());
94 95
 		canvas.shadowPath(shape, DTransform2D.IDENTITY, backgroundColor, shadow);
95 96
 		canvas.drawText(style.font, style.textColor, bounds.x + style.paddingLeft, bounds.y + style.paddingTop + fontMetrics.getAscent(), label.getValue());
96 97
 	}
@@ -131,9 +132,9 @@ public class DButton implements DComponent {
131 132
 	}
132 133
 	
133 134
 	private void repaint() {
134
-		if (context == null || bounds == null)
135
+		if (surface == null || bounds == null)
135 136
 			return;
136 137
 		
137
-		context.repaint(bounds);
138
+		surface.repaint(bounds);
138 139
 	}
139 140
 }

+ 2
- 1
DrawableGui/src/main/java/org/openzen/drawablegui/DComponent.java Ver arquivo

@@ -6,6 +6,7 @@
6 6
 package org.openzen.drawablegui;
7 7
 
8 8
 import java.io.Closeable;
9
+import org.openzen.drawablegui.draw.DDrawSurface;
9 10
 import org.openzen.drawablegui.live.LiveObject;
10 11
 import org.openzen.drawablegui.style.DStylePath;
11 12
 
@@ -14,7 +15,7 @@ import org.openzen.drawablegui.style.DStylePath;
14 15
  * @author Hoofdgebruiker
15 16
  */
16 17
 public interface DComponent extends Closeable {
17
-	void setContext(DStylePath parent, DUIContext context);
18
+	void setSurface(DStylePath parent, int z, DDrawSurface surface);
18 19
 	
19 20
 	LiveObject<DSizing> getSizing();
20 21
 	

+ 2
- 1
DrawableGui/src/main/java/org/openzen/drawablegui/DEmptyView.java Ver arquivo

@@ -5,6 +5,7 @@
5 5
  */
6 6
 package org.openzen.drawablegui;
7 7
 
8
+import org.openzen.drawablegui.draw.DDrawSurface;
8 9
 import org.openzen.drawablegui.live.ImmutableLiveObject;
9 10
 import org.openzen.drawablegui.live.LiveObject;
10 11
 import org.openzen.drawablegui.style.DStylePath;
@@ -21,7 +22,7 @@ public class DEmptyView implements DComponent {
21 22
 	private DEmptyView() {}
22 23
 
23 24
 	@Override
24
-	public void setContext(DStylePath parent, DUIContext context) {
25
+	public void setSurface(DStylePath parent, int z, DDrawSurface surface) {
25 26
 		
26 27
 	}
27 28
 	

+ 13
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/DIRectangle.java Ver arquivo

@@ -42,6 +42,19 @@ public class DIRectangle {
42 42
 				&& y >= this.y && y < (this.y + this.height);
43 43
 	}
44 44
 	
45
+	public boolean overlaps(DIRectangle other) {
46
+		if (x + width < other.x)
47
+			return false;
48
+		if (y + width < other.y)
49
+			return false;
50
+		if (other.x + other.width < x)
51
+			return false;
52
+		if (other.y + other.height < y)
53
+			return false;
54
+		
55
+		return true;
56
+	}
57
+	
45 58
 	@Override
46 59
 	public String toString() {
47 60
 		return "(x = " + x + ", y = " + y + ", width = " + width + ", height = " + height + ")";

+ 14
- 13
DrawableGui/src/main/java/org/openzen/drawablegui/DInputField.java Ver arquivo

@@ -5,6 +5,7 @@
5 5
  */
6 6
 package org.openzen.drawablegui;
7 7
 
8
+import org.openzen.drawablegui.draw.DDrawSurface;
8 9
 import org.openzen.drawablegui.listeners.ListenerHandle;
9 10
 import org.openzen.drawablegui.live.LiveObject;
10 11
 import org.openzen.drawablegui.live.LiveString;
@@ -27,7 +28,7 @@ public class DInputField implements DComponent {
27 28
 	private DIRectangle bounds = DIRectangle.EMPTY;
28 29
 	private final DDimension preferredWidth;
29 30
 	
30
-	private DUIContext context;
31
+	private DDrawSurface surface;
31 32
 	private DInputFieldStyle style;
32 33
 	private DFontMetrics fontMetrics;
33 34
 	private int cursorFrom = -1;
@@ -64,24 +65,24 @@ public class DInputField implements DComponent {
64 65
 	}
65 66
 
66 67
 	@Override
67
-	public void setContext(DStylePath parent, DUIContext context) {
68
-		this.context = context;
68
+	public void setSurface(DStylePath parent, int z, DDrawSurface surface) {
69
+		this.surface = surface;
69 70
 		
70 71
 		DStylePath path = parent.getChild("input", styleClass);
71
-		style = new DInputFieldStyle(context.getStylesheets().get(context, path));
72
-		fontMetrics = context.getFontMetrics(style.font);
72
+		style = new DInputFieldStyle(surface.getStylesheet(path));
73
+		fontMetrics = surface.getFontMetrics(style.font);
73 74
 		sizing.setValue(new DSizing(
74
-				preferredWidth.evalInt(context) + style.paddingLeft + style.paddingRight + 2 * style.borderWidth,
75
+				preferredWidth.evalInt(surface.getContext()) + style.paddingLeft + style.paddingRight + 2 * style.borderWidth,
75 76
 				fontMetrics.getAscent() + fontMetrics.getDescent() + style.paddingTop + style.paddingBottom + 2 * style.borderWidth));
76 77
 		
77 78
 		if (blinkTimer != null)
78 79
 			blinkTimer.close();
79
-		blinkTimer = context.setTimer(300, this::blink);
80
+		blinkTimer = surface.getContext().setTimer(300, this::blink);
80 81
 	}
81 82
 	
82 83
 	private void blink() {
83 84
 		cursorBlink = !cursorBlink;
84
-		context.repaint(bounds);
85
+		surface.repaint(bounds);
85 86
 	}
86 87
 
87 88
 	@Override
@@ -140,17 +141,17 @@ public class DInputField implements DComponent {
140 141
 	
141 142
 	@Override
142 143
 	public void onMouseEnter(DMouseEvent e) {
143
-		context.setCursor(DUIContext.Cursor.TEXT);
144
+		surface.getContext().setCursor(DUIContext.Cursor.TEXT);
144 145
 	}
145 146
 	
146 147
 	@Override
147 148
 	public void onMouseExit(DMouseEvent e) {
148
-		context.setCursor(DUIContext.Cursor.NORMAL);
149
+		surface.getContext().setCursor(DUIContext.Cursor.NORMAL);
149 150
 	}
150 151
 	
151 152
 	@Override
152 153
 	public void onMouseClick(DMouseEvent e) {
153
-		context.getWindow().focus(this);
154
+		surface.getContext().getWindow().focus(this);
154 155
 	}
155 156
 	
156 157
 	@Override
@@ -197,11 +198,11 @@ public class DInputField implements DComponent {
197 198
 	private void setCursor(int from, int to) {
198 199
 		cursorFrom = from;
199 200
 		cursorTo = to;
200
-		context.repaint(bounds);
201
+		surface.repaint(bounds);
201 202
 	}
202 203
 	
203 204
 	private void handleValueUpdated(String newValue) {
204
-		context.repaint(bounds);
205
+		surface.repaint(bounds);
205 206
 	}
206 207
 	
207 208
 	private void backspace() {

+ 10
- 7
DrawableGui/src/main/java/org/openzen/drawablegui/DLabel.java Ver arquivo

@@ -5,6 +5,7 @@
5 5
  */
6 6
 package org.openzen.drawablegui;
7 7
 
8
+import org.openzen.drawablegui.draw.DDrawSurface;
8 9
 import org.openzen.drawablegui.listeners.ListenerHandle;
9 10
 import org.openzen.drawablegui.live.LiveObject;
10 11
 import org.openzen.drawablegui.live.LiveString;
@@ -22,7 +23,8 @@ public class DLabel implements DComponent {
22 23
 	private final MutableLiveObject<DSizing> sizing = DSizing.create();
23 24
 	private final ListenerHandle<LiveString.Listener> labelListener;
24 25
 	
25
-	private DUIContext context;
26
+	private DDrawSurface surface;
27
+	private int z;
26 28
 	private DIRectangle bounds;
27 29
 	private DLabelStyle style;
28 30
 	private DFontMetrics fontMetrics;
@@ -35,13 +37,14 @@ public class DLabel implements DComponent {
35 37
 	}
36 38
 
37 39
 	@Override
38
-	public void setContext(DStylePath parent, DUIContext context) {
39
-		this.context = context;
40
+	public void setSurface(DStylePath parent, int z, DDrawSurface surface) {
41
+		this.surface = surface;
42
+		this.z = z;
40 43
 		
41 44
 		DStylePath path = parent.getChild("label", styleClass);
42
-		style = new DLabelStyle(context.getStylesheets().get(context, path));
45
+		style = new DLabelStyle(surface.getStylesheet(path));
43 46
 		
44
-		fontMetrics = context.getFontMetrics(style.font);
47
+		fontMetrics = surface.getFontMetrics(style.font);
45 48
 		calculateDimension();
46 49
 	}
47 50
 
@@ -63,11 +66,11 @@ public class DLabel implements DComponent {
63 66
 	@Override
64 67
 	public void setBounds(DIRectangle bounds) {
65 68
 		this.bounds = bounds;
69
+		style.border.update(surface, z + 1, bounds);
66 70
 	}
67 71
 
68 72
 	@Override
69 73
 	public void paint(DCanvas canvas) {
70
-		style.border.paint(canvas, bounds);
71 74
 		canvas.drawText(style.font, style.color, bounds.x + style.border.getPaddingLeft(), bounds.y + style.border.getPaddingTop() + fontMetrics.getAscent(), label.getValue());
72 75
 	}
73 76
 
@@ -78,7 +81,7 @@ public class DLabel implements DComponent {
78 81
 	
79 82
 	private void onLabelChanged(String oldValue, String newValue) {
80 83
 		calculateDimension();
81
-		context.repaint(bounds);
84
+		surface.repaint(bounds);
82 85
 	}
83 86
 	
84 87
 	private void calculateDimension() {

+ 37
- 15
DrawableGui/src/main/java/org/openzen/drawablegui/DSimpleTooltipComponent.java Ver arquivo

@@ -5,6 +5,9 @@
5 5
  */
6 6
 package org.openzen.drawablegui;
7 7
 
8
+import org.openzen.drawablegui.draw.DDrawSurface;
9
+import org.openzen.drawablegui.draw.DDrawnRectangle;
10
+import org.openzen.drawablegui.draw.DDrawnText;
8 11
 import org.openzen.drawablegui.listeners.ListenerHandle;
9 12
 import org.openzen.drawablegui.live.LiveObject;
10 13
 import org.openzen.drawablegui.live.LiveString;
@@ -22,11 +25,15 @@ public class DSimpleTooltipComponent implements DComponent {
22 25
 	private final MutableLiveObject<DSizing> sizing = DSizing.create();
23 26
 	private final ListenerHandle<LiveString.Listener> tooltipListener;
24 27
 	
25
-	private DUIContext context;
28
+	private DDrawSurface surface;
29
+	private int z;
26 30
 	private DIRectangle bounds;
27 31
 	private DFontMetrics fontMetrics;
28 32
 	private DSimpleTooltipStyle style;
29 33
 	
34
+	private DDrawnRectangle background;
35
+	private DDrawnText text;
36
+	
30 37
 	public DSimpleTooltipComponent(DStyleClass styleClass, LiveString tooltip) {
31 38
 		this.styleClass = styleClass;
32 39
 		this.tooltip = tooltip;
@@ -34,7 +41,7 @@ public class DSimpleTooltipComponent implements DComponent {
34 41
 	}
35 42
 	
36 43
 	private void onTooltipChanged(String oldValue, String newValue) {
37
-		if (context == null || bounds == null)
44
+		if (surface == null || bounds == null)
38 45
 			return;
39 46
 		
40 47
 		calculateSize();
@@ -43,12 +50,31 @@ public class DSimpleTooltipComponent implements DComponent {
43 50
 				bounds.y,
44 51
 				style.border.getPaddingLeft() + fontMetrics.getWidth(tooltip.getValue()) + style.border.getPaddingRight(),
45 52
 				style.border.getPaddingTop() + fontMetrics.getAscent() + fontMetrics.getDescent() + style.border.getPaddingBottom());
46
-		context.repaint(bounds);
53
+		surface.repaint(bounds);
54
+		
55
+		if (text != null)
56
+			text.close();
57
+		
58
+		text = surface.drawText(
59
+				z,
60
+				style.font,
61
+				style.textColor,
62
+				bounds.x + style.border.getPaddingLeft(),
63
+				bounds.y + style.border.getPaddingTop() + fontMetrics.getAscent(),
64
+				newValue);
47 65
 	}
48 66
 	
49 67
 	@Override
50 68
 	public void setBounds(DIRectangle bounds) {
51 69
 		this.bounds = bounds;
70
+		style.border.update(surface, z + 1, bounds);
71
+		
72
+		if (background != null)
73
+			background.close();
74
+		background = surface.fillRect(z, bounds, style.backgroundColor);
75
+		text.setPosition(
76
+				bounds.x + style.border.getPaddingLeft(),
77
+				bounds.y + style.border.getPaddingTop() + fontMetrics.getAscent());
52 78
 	}
53 79
 	
54 80
 	@Override
@@ -67,25 +93,21 @@ public class DSimpleTooltipComponent implements DComponent {
67 93
 	}
68 94
 	
69 95
 	@Override
70
-	public void setContext(DStylePath parent, DUIContext context) {
71
-		this.context = context;
96
+	public void setSurface(DStylePath parent, int z, DDrawSurface surface) {
97
+		this.surface = surface;
98
+		this.z = z;
72 99
 		
73 100
 		DStylePath path = parent.getChild("tooltip", styleClass);
74
-		style = new DSimpleTooltipStyle(context.getStylesheets().get(context, path));
75
-		fontMetrics = context.getFontMetrics(style.font);
101
+		style = new DSimpleTooltipStyle(surface.getStylesheet(path));
102
+		fontMetrics = surface.getFontMetrics(style.font);
76 103
 		calculateSize();
104
+		
105
+		text = surface.drawText(z + 1, style.font, style.textColor, 0, 0, tooltip.getValue());
77 106
 	}
78 107
 	
79 108
 	@Override
80 109
 	public void paint(DCanvas canvas) {
81
-		canvas.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height, style.backgroundColor);
82
-		style.border.paint(canvas, bounds);
83
-		canvas.drawText(
84
-				style.font,
85
-				style.textColor,
86
-				bounds.x + style.border.getPaddingLeft(),
87
-				bounds.y + style.border.getPaddingTop() + fontMetrics.getAscent(),
88
-				tooltip.getValue());
110
+		
89 111
 	}
90 112
 	
91 113
 	@Override

+ 2
- 2
DrawableGui/src/main/java/org/openzen/drawablegui/border/DBorder.java Ver arquivo

@@ -5,15 +5,15 @@
5 5
  */
6 6
 package org.openzen.drawablegui.border;
7 7
 
8
-import org.openzen.drawablegui.DCanvas;
9 8
 import org.openzen.drawablegui.DIRectangle;
9
+import org.openzen.drawablegui.draw.DDrawSurface;
10 10
 
11 11
 /**
12 12
  *
13 13
  * @author Hoofdgebruiker
14 14
  */
15 15
 public interface DBorder {
16
-	public void paint(DCanvas canvas, DIRectangle bounds);
16
+	public void update(DDrawSurface surface, int z, DIRectangle bounds);
17 17
 	
18 18
 	public int getPaddingLeft();
19 19
 	

+ 3
- 3
DrawableGui/src/main/java/org/openzen/drawablegui/border/DCompositeBorder.java Ver arquivo

@@ -5,8 +5,8 @@
5 5
  */
6 6
 package org.openzen.drawablegui.border;
7 7
 
8
-import org.openzen.drawablegui.DCanvas;
9 8
 import org.openzen.drawablegui.DIRectangle;
9
+import org.openzen.drawablegui.draw.DDrawSurface;
10 10
 
11 11
 /**
12 12
  *
@@ -20,9 +20,9 @@ public class DCompositeBorder implements DBorder {
20 20
 	}
21 21
 
22 22
 	@Override
23
-	public void paint(DCanvas canvas, DIRectangle bounds) {
23
+	public void update(DDrawSurface surface, int z, DIRectangle bounds) {
24 24
 		for (DBorder border : borders) {
25
-			border.paint(canvas, bounds);
25
+			border.update(surface, z, bounds);
26 26
 			bounds = new DIRectangle(
27 27
 					bounds.x + border.getPaddingLeft(),
28 28
 					bounds.y + border.getPaddingTop(),

+ 10
- 10
DrawableGui/src/main/java/org/openzen/drawablegui/border/DCustomWindowBorder.java Ver arquivo

@@ -11,9 +11,9 @@ import org.openzen.drawablegui.DSizing;
11 11
 import org.openzen.drawablegui.DMouseEvent;
12 12
 import org.openzen.drawablegui.DPath;
13 13
 import org.openzen.drawablegui.DTransform2D;
14
-import org.openzen.drawablegui.DUIContext;
15 14
 import org.openzen.drawablegui.DUIWindow;
16 15
 import org.openzen.drawablegui.DIRectangle;
16
+import org.openzen.drawablegui.draw.DDrawSurface;
17 17
 import org.openzen.drawablegui.listeners.ListenerHandle;
18 18
 import org.openzen.drawablegui.live.ImmutableLiveObject;
19 19
 import org.openzen.drawablegui.live.LiveBool;
@@ -30,7 +30,7 @@ public class DCustomWindowBorder implements DComponent {
30 30
 	private final DComponent content;
31 31
 	private final LiveObject<DSizing> sizing = new ImmutableLiveObject<>(DSizing.EMPTY);
32 32
 	
33
-	private DUIContext context;
33
+	private DDrawSurface surface;
34 34
 	private DCustomWindowBorderStyle style;
35 35
 	private DIRectangle bounds;
36 36
 	private DPath border;
@@ -47,17 +47,17 @@ public class DCustomWindowBorder implements DComponent {
47 47
 	}
48 48
 
49 49
 	@Override
50
-	public void setContext(DStylePath parent, DUIContext context) {
51
-		this.context = context;
52
-		content.setContext(parent, context);
50
+	public void setSurface(DStylePath parent, int z, DDrawSurface surface) {
51
+		this.surface = surface;
52
+		content.setSurface(parent, z + 1, surface);
53 53
 		
54
-		state = context.getWindow().getWindowState();
55
-		active = context.getWindow().getActive();
54
+		state = surface.getContext().getWindow().getWindowState();
55
+		active = surface.getContext().getWindow().getActive();
56 56
 		stateListener = state.addListener(this::onStateChanged);
57 57
 		activeListener = active.addListener(this::onActiveChanged);
58 58
 		
59 59
 		DStylePath path = parent.getChild("customwindowborder", styleClass);
60
-		style = new DCustomWindowBorderStyle(context.getStylesheets().get(context, path));
60
+		style = new DCustomWindowBorderStyle(surface.getStylesheet(path));
61 61
 		
62 62
 		if (bounds != null)
63 63
 			layout();
@@ -107,7 +107,7 @@ public class DCustomWindowBorder implements DComponent {
107 107
 		} else {
108 108
 			content.setBounds(bounds);
109 109
 		}
110
-		context.repaint(bounds);
110
+		surface.repaint(bounds);
111 111
 	}
112 112
 
113 113
 	@Override
@@ -184,6 +184,6 @@ public class DCustomWindowBorder implements DComponent {
184 184
 	}
185 185
 	
186 186
 	private void onActiveChanged(boolean oldValue, boolean newValue) {
187
-		context.repaint(bounds);
187
+		surface.repaint(bounds);
188 188
 	}
189 189
 }

+ 2
- 2
DrawableGui/src/main/java/org/openzen/drawablegui/border/DEmptyBorder.java Ver arquivo

@@ -5,8 +5,8 @@
5 5
  */
6 6
 package org.openzen.drawablegui.border;
7 7
 
8
-import org.openzen.drawablegui.DCanvas;
9 8
 import org.openzen.drawablegui.DIRectangle;
9
+import org.openzen.drawablegui.draw.DDrawSurface;
10 10
 import org.openzen.drawablegui.style.DBorderElement;
11 11
 
12 12
 /**
@@ -20,7 +20,7 @@ public class DEmptyBorder implements DBorder {
20 20
 	private DEmptyBorder() {}
21 21
 	
22 22
 	@Override
23
-	public void paint(DCanvas canvas, DIRectangle bounds) {
23
+	public void update(DDrawSurface surface, int z, DIRectangle bounds) {
24 24
 		
25 25
 	}
26 26
 

+ 9
- 3
DrawableGui/src/main/java/org/openzen/drawablegui/border/DLineBorder.java Ver arquivo

@@ -5,9 +5,10 @@
5 5
  */
6 6
 package org.openzen.drawablegui.border;
7 7
 
8
-import org.openzen.drawablegui.DCanvas;
9 8
 import org.openzen.drawablegui.DTransform2D;
10 9
 import org.openzen.drawablegui.DIRectangle;
10
+import org.openzen.drawablegui.draw.DDrawSurface;
11
+import org.openzen.drawablegui.draw.DDrawnShape;
11 12
 
12 13
 /**
13 14
  *
@@ -17,14 +18,19 @@ public class DLineBorder implements DBorder {
17 18
 	private final int color;
18 19
 	private final int borderWidth;
19 20
 	
21
+	private DDrawnShape shape;
22
+	
20 23
 	public DLineBorder(int color, int borderWidth) {
21 24
 		this.color = color;
22 25
 		this.borderWidth = borderWidth;
23 26
 	}
24 27
 
25 28
 	@Override
26
-	public void paint(DCanvas canvas, DIRectangle bounds) {
27
-		canvas.strokePath(tracer -> {
29
+	public void update(DDrawSurface surface, int z, DIRectangle bounds) {
30
+		if (shape != null)
31
+			shape.close();
32
+		
33
+		shape = surface.strokePath(z, tracer -> {
28 34
 				tracer.moveTo(bounds.x, bounds.y);
29 35
 				tracer.lineTo(bounds.x + bounds.width - borderWidth, bounds.y);
30 36
 				tracer.lineTo(bounds.x + bounds.width - borderWidth, bounds.y + bounds.height - borderWidth);

+ 2
- 1
DrawableGui/src/main/java/org/openzen/drawablegui/border/DPaddedBorder.java Ver arquivo

@@ -7,6 +7,7 @@ package org.openzen.drawablegui.border;
7 7
 
8 8
 import org.openzen.drawablegui.DCanvas;
9 9
 import org.openzen.drawablegui.DIRectangle;
10
+import org.openzen.drawablegui.draw.DDrawSurface;
10 11
 
11 12
 /**
12 13
  *
@@ -30,7 +31,7 @@ public class DPaddedBorder implements DBorder {
30 31
 	}
31 32
 
32 33
 	@Override
33
-	public void paint(DCanvas canvas, DIRectangle bounds) {
34
+	public void update(DDrawSurface surface, int z, DIRectangle bounds) {
34 35
 		// nothing to paint
35 36
 	}
36 37
 

+ 20
- 5
DrawableGui/src/main/java/org/openzen/drawablegui/border/DSideBorder.java Ver arquivo

@@ -9,6 +9,8 @@ import org.openzen.drawablegui.DCanvas;
9 9
 import org.openzen.drawablegui.DIRectangle;
10 10
 import org.openzen.drawablegui.DPath;
11 11
 import org.openzen.drawablegui.DTransform2D;
12
+import org.openzen.drawablegui.draw.DDrawSurface;
13
+import org.openzen.drawablegui.draw.DDrawnShape;
12 14
 
13 15
 /**
14 16
  *
@@ -24,6 +26,11 @@ public class DSideBorder implements DBorder {
24 26
 	public final int bottomWidth;
25 27
 	public final int bottomColor;
26 28
 	
29
+	private DDrawnShape left;
30
+	private DDrawnShape top;
31
+	private DDrawnShape right;
32
+	private DDrawnShape bottom;
33
+	
27 34
 	public DSideBorder(
28 35
 			int leftWidth, int leftColor,
29 36
 			int topWidth, int topColor,
@@ -40,22 +47,30 @@ public class DSideBorder implements DBorder {
40 47
 	}
41 48
 
42 49
 	@Override
43
-	public void paint(DCanvas canvas, DIRectangle bounds) {
50
+	public void update(DDrawSurface surface, int z, DIRectangle bounds) {
44 51
 		if (leftWidth > 0) {
45 52
 			int x = bounds.x;
46
-			canvas.strokePath(DPath.line(x, bounds.y, x, bounds.y + bounds.height), DTransform2D.IDENTITY, topColor, topWidth);
53
+			if (left != null)
54
+				left.close();
55
+			left = surface.strokePath(z, DPath.line(x, bounds.y, x, bounds.y + bounds.height), DTransform2D.IDENTITY, topColor, topWidth);
47 56
 		}
48 57
 		if (topWidth > 0) {
49 58
 			int y = bounds.y;
50
-			canvas.strokePath(DPath.line(bounds.x, y, bounds.x + bounds.width, y), DTransform2D.IDENTITY, topColor, topWidth);
59
+			if (top != null)
60
+				top.close();
61
+			top = surface.strokePath(z, DPath.line(bounds.x, y, bounds.x + bounds.width, y), DTransform2D.IDENTITY, topColor, topWidth);
51 62
 		}
52 63
 		if (rightWidth > 0) {
53 64
 			int x = bounds.x + bounds.width - rightWidth;
54
-			canvas.strokePath(DPath.line(x, bounds.y, x, bounds.y + bounds.height), DTransform2D.IDENTITY, topColor, topWidth);
65
+			if (right != null)
66
+				right.close();
67
+			right = surface.strokePath(z, DPath.line(x, bounds.y, x, bounds.y + bounds.height), DTransform2D.IDENTITY, topColor, topWidth);
55 68
 		}
56 69
 		if (bottomWidth > 0) {
57 70
 			int y = bounds.y + bounds.height - bottomWidth;
58
-			canvas.strokePath(DPath.line(bounds.x, y, bounds.x + bounds.width, y), DTransform2D.IDENTITY, topColor, topWidth);
71
+			if (bottom != null)
72
+				bottom.close();
73
+			bottom = surface.strokePath(z, DPath.line(bounds.x, y, bounds.x + bounds.width, y), DTransform2D.IDENTITY, topColor, topWidth);
59 74
 		}
60 75
 	}
61 76
 

+ 50
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/draw/DDrawSurface.java Ver arquivo

@@ -0,0 +1,50 @@
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.draw;
7
+
8
+import org.openzen.drawablegui.DFont;
9
+import org.openzen.drawablegui.DFontMetrics;
10
+import org.openzen.drawablegui.DIRectangle;
11
+import org.openzen.drawablegui.DPath;
12
+import org.openzen.drawablegui.DTransform2D;
13
+import org.openzen.drawablegui.DUIContext;
14
+import org.openzen.drawablegui.style.DShadow;
15
+import org.openzen.drawablegui.style.DStyleDefinition;
16
+import org.openzen.drawablegui.style.DStylePath;
17
+
18
+/**
19
+ *
20
+ * @author Hoofdgebruiker
21
+ */
22
+public interface DDrawSurface {
23
+	DUIContext getContext();
24
+	
25
+	DStyleDefinition getStylesheet(DStylePath path);
26
+	
27
+	DFontMetrics getFontMetrics(DFont font);
28
+	
29
+	float getScale();
30
+	
31
+	float getTextScale();
32
+	
33
+	DDrawnText drawText(int z, DFont font, int color, float x, float y, String text);
34
+	
35
+	DDrawnRectangle fillRect(int z, DIRectangle rectangle, int color);
36
+	
37
+	DDrawnShape strokePath(int z, DPath path, DTransform2D transform, int color, float lineWidth);
38
+	
39
+	DDrawnShape fillPath(int z, DPath path, DTransform2D transform, int color);
40
+	
41
+	DDrawnShape shadowPath(int z, DPath path, DTransform2D transform, int color, DShadow shadow);
42
+	
43
+	DSubSurface createSubSurface(int z);
44
+	
45
+	void repaint(int x, int y, int width, int height);
46
+	
47
+	default void repaint(DIRectangle rectangle) {
48
+		repaint(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
49
+	}
50
+}

+ 22
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/draw/DDrawnRectangle.java Ver arquivo

@@ -0,0 +1,22 @@
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.draw;
7
+
8
+import java.io.Closeable;
9
+import org.openzen.drawablegui.DIRectangle;
10
+
11
+/**
12
+ *
13
+ * @author Hoofdgebruiker
14
+ */
15
+public interface DDrawnRectangle extends Closeable {
16
+	void setRectangle(DIRectangle rectangle);
17
+	
18
+	void setColor(int color);
19
+	
20
+	@Override
21
+	void close();
22
+}

+ 22
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/draw/DDrawnShape.java Ver arquivo

@@ -0,0 +1,22 @@
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.draw;
7
+
8
+import java.io.Closeable;
9
+import org.openzen.drawablegui.DTransform2D;
10
+
11
+/**
12
+ *
13
+ * @author Hoofdgebruiker
14
+ */
15
+public interface DDrawnShape extends Closeable {
16
+	public void setTransform(DTransform2D transform);
17
+	
18
+	public void setColor(int color);
19
+	
20
+	@Override
21
+	public void close();
22
+}

+ 21
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/draw/DDrawnText.java Ver arquivo

@@ -0,0 +1,21 @@
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.draw;
7
+
8
+import java.io.Closeable;
9
+
10
+/**
11
+ *
12
+ * @author Hoofdgebruiker
13
+ */
14
+public interface DDrawnText extends Closeable {
15
+	void setPosition(float x, float y);
16
+	
17
+	void setColor(int color);
18
+	
19
+	@Override
20
+	void close();
21
+}

+ 18
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/draw/DSubSurface.java Ver arquivo

@@ -0,0 +1,18 @@
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.draw;
7
+
8
+import org.openzen.drawablegui.DIRectangle;
9
+
10
+/**
11
+ *
12
+ * @author Hoofdgebruiker
13
+ */
14
+public interface DSubSurface extends DDrawSurface {
15
+	void setOffset(int x, int y);
16
+	
17
+	void setClip(DIRectangle bounds);
18
+}

+ 8
- 6
DrawableGui/src/main/java/org/openzen/drawablegui/form/DForm.java Ver arquivo

@@ -14,6 +14,7 @@ import org.openzen.drawablegui.DSizing;
14 14
 import org.openzen.drawablegui.DFontMetrics;
15 15
 import org.openzen.drawablegui.DIRectangle;
16 16
 import org.openzen.drawablegui.DUIContext;
17
+import org.openzen.drawablegui.draw.DDrawSurface;
17 18
 import org.openzen.drawablegui.live.LiveObject;
18 19
 import org.openzen.drawablegui.live.MutableLiveObject;
19 20
 import org.openzen.drawablegui.style.DStyleClass;
@@ -29,7 +30,7 @@ public class DForm extends BaseComponentGroup {
29 30
 	private final MutableLiveObject<DSizing> sizing = DSizing.create();
30 31
 	
31 32
 	private DIRectangle bounds;
32
-	private DUIContext context;
33
+	private DDrawSurface context;
33 34
 	private DFormStyle style;
34 35
 	private DFontMetrics fontMetrics;
35 36
 	private int maxFieldWidth;
@@ -41,14 +42,15 @@ public class DForm extends BaseComponentGroup {
41 42
 	}
42 43
 
43 44
 	@Override
44
-	public void setContext(DStylePath parent, DUIContext context) {
45
-		this.context = context;
45
+	public void setSurface(DStylePath parent, int z, DDrawSurface surface) {
46
+		this.context = surface;
46 47
 		
47 48
 		DStylePath path = parent.getChild("form", styleClass);
48
-		style = new DFormStyle(context.getStylesheets().get(context, path));
49
-		fontMetrics = context.getFontMetrics(style.labelFont);
49
+		style = new DFormStyle(surface.getStylesheet(path));
50
+		fontMetrics = surface.getFontMetrics(style.labelFont);
51
+		
50 52
 		for (DFormComponent component : components)
51
-			component.component.setContext(path, context);
53
+			component.component.setSurface(path, z + 1, surface);
52 54
 		
53 55
 		int height = style.paddingBottom + style.paddingTop;
54 56
 		int maxLabelWidth = style.minimumLabelSize;

+ 22
- 14
DrawableGui/src/main/java/org/openzen/drawablegui/layout/DLinearLayout.java Ver arquivo

@@ -11,10 +11,10 @@ import org.openzen.drawablegui.BaseComponentGroup;
11 11
 import org.openzen.drawablegui.DCanvas;
12 12
 import org.openzen.drawablegui.DComponent;
13 13
 import org.openzen.drawablegui.DIRectangle;
14
-import org.openzen.drawablegui.DPath;
15 14
 import org.openzen.drawablegui.DSizing;
16 15
 import org.openzen.drawablegui.DTransform2D;
17
-import org.openzen.drawablegui.DUIContext;
16
+import org.openzen.drawablegui.draw.DDrawSurface;
17
+import org.openzen.drawablegui.draw.DDrawnShape;
18 18
 import org.openzen.drawablegui.listeners.ListenerHandle;
19 19
 import org.openzen.drawablegui.live.LiveObject;
20 20
 import org.openzen.drawablegui.live.MutableLiveObject;
@@ -33,12 +33,13 @@ public class DLinearLayout extends BaseComponentGroup {
33 33
 	private final ListenerHandle<LiveObject.Listener<DSizing>>[] componentSizeListeners;
34 34
 	private final MutableLiveObject<DSizing> sizing = DSizing.create();
35 35
 	
36
-	private DUIContext context;
36
+	private DDrawSurface surface;
37
+	private int z;
37 38
 	private DLinearLayoutStyle style;
38 39
 	private DIRectangle bounds;
39 40
 	private float totalGrow;
40 41
 	private float totalShrink;
41
-	private DPath shape;
42
+	private DDrawnShape shape;
42 43
 	
43 44
 	public DLinearLayout(DStyleClass styleClass, Orientation orientation, Alignment alignment, Element... components) {
44 45
 		this.styleClass = styleClass;
@@ -74,14 +75,15 @@ public class DLinearLayout extends BaseComponentGroup {
74 75
 	}
75 76
 
76 77
 	@Override
77
-	public void setContext(DStylePath parent, DUIContext context) {
78
-		this.context = context;
78
+	public void setSurface(DStylePath parent, int z, DDrawSurface surface) {
79
+		this.surface = surface;
80
+		this.z = z;
79 81
 		
80
-		DStylePath path = parent.getChild("verticalLayout", styleClass);
81
-		style = new DLinearLayoutStyle(context.getStylesheets().get(context, path));
82
+		DStylePath path = parent.getChild("linearlayout", styleClass);
83
+		style = new DLinearLayoutStyle(surface.getStylesheet(path));
82 84
 		
83 85
 		for (Element element : components)
84
-			element.component.setContext(parent, context);
86
+			element.component.setSurface(parent, z + 1, surface);
85 87
 	}
86 88
 
87 89
 	@Override
@@ -101,15 +103,21 @@ public class DLinearLayout extends BaseComponentGroup {
101 103
 
102 104
 	@Override
103 105
 	public void setBounds(DIRectangle bounds) {
106
+		if (bounds.equals(this.bounds))
107
+			return;
108
+		
104 109
 		this.bounds = bounds;
105
-		shape = style.shape.instance(style.margin.apply(bounds));
110
+		style.border.update(surface, z + 1, bounds);
111
+		
112
+		if (shape != null)
113
+			shape.close();
114
+		shape = surface.shadowPath(z, style.shape.instance(style.margin.apply(bounds)), DTransform2D.IDENTITY, style.backgroundColor, style.shadow);
115
+		
106 116
 		layout();
107 117
 	}
108 118
 
109 119
 	@Override
110 120
 	public void paint(DCanvas canvas) {
111
-		canvas.shadowPath(shape, DTransform2D.IDENTITY, style.backgroundColor, style.shadow);
112
-		style.border.paint(canvas, bounds);
113 121
 		for (Element element : components) {
114 122
 			element.component.paint(canvas);
115 123
 		}
@@ -149,7 +157,7 @@ public class DLinearLayout extends BaseComponentGroup {
149 157
 	}
150 158
 	
151 159
 	private void layoutHorizontal() {
152
-		if (bounds == null || context == null)
160
+		if (bounds == null || surface == null)
153 161
 			return;
154 162
 		
155 163
 		DSizing myPreferences = sizing.getValue();
@@ -161,7 +169,7 @@ public class DLinearLayout extends BaseComponentGroup {
161 169
 	}
162 170
 	
163 171
 	private void layoutVertical() {
164
-		if (bounds == null || context == null)
172
+		if (bounds == null || surface == null)
165 173
 			return;
166 174
 		
167 175
 		DSizing myPreferences = sizing.getValue();

+ 24
- 13
DrawableGui/src/main/java/org/openzen/drawablegui/layout/DSideLayout.java Ver arquivo

@@ -15,7 +15,8 @@ import org.openzen.drawablegui.DCanvas;
15 15
 import org.openzen.drawablegui.DComponent;
16 16
 import org.openzen.drawablegui.DIRectangle;
17 17
 import org.openzen.drawablegui.DSizing;
18
-import org.openzen.drawablegui.DUIContext;
18
+import org.openzen.drawablegui.draw.DDrawSurface;
19
+import org.openzen.drawablegui.draw.DDrawnRectangle;
19 20
 import org.openzen.drawablegui.listeners.ListenerHandle;
20 21
 import org.openzen.drawablegui.live.LiveObject;
21 22
 import org.openzen.drawablegui.live.MutableLiveObject;
@@ -34,18 +35,21 @@ public class DSideLayout extends BaseComponentGroup {
34 35
 	private final MutableLiveObject<DSizing> sizing = DSizing.create();
35 36
 	
36 37
 	private DStylePath path;
37
-	private DUIContext context;
38
+	private DDrawSurface surface;
39
+	private int z;
38 40
 	private DSideLayoutStyle style;
39 41
 	private DIRectangle bounds;
40 42
 	
43
+	private DDrawnRectangle background;
44
+	
41 45
 	public DSideLayout(DStyleClass styleClass, DComponent main) {
42 46
 		this.styleClass = styleClass;
43 47
 		this.main = main;
44 48
 	}
45 49
 	
46 50
 	public void add(Side side, DComponent component) {
47
-		if (context != null)
48
-			component.setContext(path, context);
51
+		if (surface != null)
52
+			component.setSurface(path, z + 1, surface);
49 53
 		
50 54
 		sides.add(new SideComponent(side, component));
51 55
 	}
@@ -56,22 +60,25 @@ public class DSideLayout extends BaseComponentGroup {
56 60
 		
57 61
 		this.main = component;
58 62
 		
59
-		if (context != null && bounds != null) {
60
-			main.setContext(path, context);
63
+		if (surface != null && bounds != null) {
64
+			main.setSurface(path, z + 1, surface);
61 65
 			setBounds(bounds);
62
-			context.repaint(bounds);
66
+			surface.repaint(bounds);
63 67
 		}
64 68
 	}
65 69
 
66 70
 	@Override
67
-	public void setContext(DStylePath parent, DUIContext context) {
68
-		this.context = context;
71
+	public void setSurface(DStylePath parent, int z, DDrawSurface surface) {
72
+		this.surface = surface;
73
+		this.z = z;
69 74
 		this.path = parent.getChild("sidelayout", styleClass);
70
-		style = new DSideLayoutStyle(context.getStylesheets().get(context, path));
75
+		style = new DSideLayoutStyle(surface.getStylesheet(path));
71 76
 		
72
-		main.setContext(path, context);
77
+		main.setSurface(path, z + 1, surface);
73 78
 		for (SideComponent side : sides)
74
-			side.component.setContext(path, context);
79
+			side.component.setSurface(path, z + 1, surface);
80
+		
81
+		background = surface.fillRect(z, DIRectangle.EMPTY, style.backgroundColor);
75 82
 	}
76 83
 	
77 84
 	@Override
@@ -99,6 +106,8 @@ public class DSideLayout extends BaseComponentGroup {
99 106
 	public void setBounds(DIRectangle bounds) {
100 107
 		this.bounds = bounds;
101 108
 		
109
+		background.setRectangle(bounds);
110
+		
102 111
 		int left = bounds.x;
103 112
 		int right = bounds.x + bounds.width;
104 113
 		int top = bounds.y;
@@ -176,7 +185,7 @@ public class DSideLayout extends BaseComponentGroup {
176 185
 
177 186
 	@Override
178 187
 	public void paint(DCanvas canvas) {
179
-		canvas.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height, style.backgroundColor);
188
+		//canvas.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height, style.backgroundColor);
180 189
 		main.paint(canvas);
181 190
 		
182 191
 		for (SideComponent component : sides)
@@ -248,6 +257,8 @@ public class DSideLayout extends BaseComponentGroup {
248 257
 		main.close();
249 258
 		for (SideComponent side : sides)
250 259
 			side.close();
260
+		
261
+		background.close();
251 262
 	}
252 263
 	
253 264
 	public class SideComponent implements Closeable, LiveObject.Listener<DSizing> {

+ 7
- 7
DrawableGui/src/main/java/org/openzen/drawablegui/scroll/DScrollBar.java Ver arquivo

@@ -13,7 +13,7 @@ import org.openzen.drawablegui.DIRectangle;
13 13
 import org.openzen.drawablegui.listeners.ListenerHandle;
14 14
 import org.openzen.drawablegui.live.LiveInt;
15 15
 import org.openzen.drawablegui.live.LiveObject;
16
-import org.openzen.drawablegui.DUIContext;
16
+import org.openzen.drawablegui.draw.DDrawSurface;
17 17
 import org.openzen.drawablegui.live.MutableLiveObject;
18 18
 import org.openzen.drawablegui.style.DStyleClass;
19 19
 import org.openzen.drawablegui.style.DStylePath;
@@ -32,7 +32,7 @@ public class DScrollBar implements DComponent {
32 32
 	private final ListenerHandle<LiveInt.Listener> targetHeightListener;
33 33
 	private final ListenerHandle<LiveInt.Listener> offsetListener;
34 34
 	
35
-	private DUIContext context;
35
+	private DDrawSurface surface;
36 36
 	private DScrollBarStyle style;
37 37
 	private DIRectangle bounds;
38 38
 	
@@ -53,9 +53,9 @@ public class DScrollBar implements DComponent {
53 53
 	}
54 54
 
55 55
 	@Override
56
-	public void setContext(DStylePath parent, DUIContext context) {
57
-		this.context = context;
58
-		this.style = new DScrollBarStyle(context.getStylesheets().get(context, parent.getChild("scrollbar", styleClass)));
56
+	public void setSurface(DStylePath parent, int z, DDrawSurface context) {
57
+		this.surface = context;
58
+		this.style = new DScrollBarStyle(context.getStylesheet(parent.getChild("scrollbar", styleClass)));
59 59
 		sizing.setValue(new DSizing(style.width, 0));
60 60
 	}
61 61
 
@@ -150,7 +150,7 @@ public class DScrollBar implements DComponent {
150 150
 			return;
151 151
 		
152 152
 		this.hovering = hovering;
153
-		context.repaint(bounds.x, fromY, bounds.width, toY - fromY);
153
+		surface.repaint(bounds.x, fromY, bounds.width, toY - fromY);
154 154
 	}
155 155
 	
156 156
 	private void setDragging(boolean dragging) {
@@ -158,7 +158,7 @@ public class DScrollBar implements DComponent {
158 158
 			return;
159 159
 		
160 160
 		this.dragging = dragging;
161
-		context.repaint(bounds.x, fromY, bounds.width, toY - fromY);
161
+		surface.repaint(bounds.x, fromY, bounds.width, toY - fromY);
162 162
 	}
163 163
 	
164 164
 	private void recalculate() {

+ 35
- 13
DrawableGui/src/main/java/org/openzen/drawablegui/scroll/DScrollPane.java Ver arquivo

@@ -14,7 +14,6 @@ import org.openzen.drawablegui.DFont;
14 14
 import org.openzen.drawablegui.DFontMetrics;
15 15
 import org.openzen.drawablegui.DIRectangle;
16 16
 import org.openzen.drawablegui.DMouseEvent;
17
-import org.openzen.drawablegui.DPath;
18 17
 import org.openzen.drawablegui.DTimerHandle;
19 18
 import org.openzen.drawablegui.DTransform2D;
20 19
 import org.openzen.drawablegui.listeners.ListenerHandle;
@@ -23,6 +22,9 @@ import org.openzen.drawablegui.live.LiveObject;
23 22
 import org.openzen.drawablegui.live.SimpleLiveInt;
24 23
 import org.openzen.drawablegui.DUIContext;
25 24
 import org.openzen.drawablegui.DUIWindow;
25
+import org.openzen.drawablegui.draw.DDrawSurface;
26
+import org.openzen.drawablegui.draw.DDrawnShape;
27
+import org.openzen.drawablegui.draw.DSubSurface;
26 28
 import org.openzen.drawablegui.live.MutableLiveObject;
27 29
 import org.openzen.drawablegui.style.DStyleClass;
28 30
 import org.openzen.drawablegui.style.DStylePath;
@@ -36,11 +38,12 @@ public class DScrollPane implements DComponent {
36 38
 	private final DStyleClass styleClass;
37 39
 	private final DComponent contents;
38 40
 	private final DScrollBar scrollBar;
39
-	private DUIContext context;
41
+	private DDrawSurface surface;
40 42
 	private DIRectangle bounds;
41 43
 	
42 44
 	private DScrollPaneStyle style;
43
-	private DPath shape;
45
+	private int z;
46
+	private DDrawnShape shape;
44 47
 	private final LiveInt contentsHeight;
45 48
 	private final LiveInt offsetX;
46 49
 	private final LiveInt offsetY;
@@ -56,6 +59,8 @@ public class DScrollPane implements DComponent {
56 59
 	
57 60
 	private DComponent hovering = null;
58 61
 	
62
+	private DSubSurface subSurface;
63
+	
59 64
 	public DScrollPane(DStyleClass styleClass, DComponent contents, LiveInt preferredHeight) {
60 65
 		this.styleClass = styleClass;
61 66
 		this.contents = contents;
@@ -97,13 +102,14 @@ public class DScrollPane implements DComponent {
97 102
 	}
98 103
 
99 104
 	@Override
100
-	public void setContext(DStylePath parent, DUIContext context) {
101
-		this.context = context;
105
+	public void setSurface(DStylePath parent, int z, DDrawSurface surface) {
106
+		this.surface = surface;
102 107
 		
103 108
 		DStylePath path = parent.getChild("scrollpane", styleClass);
104
-		contents.setContext(path, new TranslatedContext());
105
-		scrollBar.setContext(path, context);
106
-		style = new DScrollPaneStyle(context.getStylesheets().get(context, path));
109
+		subSurface = surface.createSubSurface(z + 1);
110
+		contents.setSurface(path, 0, subSurface);
111
+		scrollBar.setSurface(path, z + 2, surface);
112
+		style = new DScrollPaneStyle(surface.getStylesheet(path));
107 113
 	}
108 114
 
109 115
 	@Override
@@ -124,7 +130,11 @@ public class DScrollPane implements DComponent {
124 130
 	@Override
125 131
 	public void setBounds(DIRectangle bounds) {
126 132
 		this.bounds = bounds;
127
-		shape = style.shape.instance(style.margin.apply(bounds));
133
+		
134
+		if (shape != null)
135
+			shape.close();
136
+		shape = surface.shadowPath(z, style.shape.instance(style.margin.apply(bounds)), DTransform2D.IDENTITY, style.backgroundColor, style.shadow);
137
+		style.border.update(surface, z + 1, style.margin.apply(bounds));
128 138
 		
129 139
 		int height = Math.max(bounds.height - style.border.getPaddingTop() - style.border.getPaddingBottom(),
130 140
 				contents.getSizing().getValue().preferredHeight);
@@ -136,12 +146,17 @@ public class DScrollPane implements DComponent {
136 146
 				bounds.height - style.border.getPaddingVertical() - style.margin.getVertical()));
137 147
 		contents.setBounds(new DIRectangle(0, 0, bounds.width - scrollBar.getBounds().width, height));
138 148
 		contentsHeight.setValue(height);
149
+		
150
+		subSurface.setOffset(bounds.x - offsetX.getValue(), bounds.y - offsetY.getValue());
151
+		subSurface.setClip(new DIRectangle(
152
+				bounds.x + style.border.getPaddingLeft(),
153
+				bounds.y + style.border.getPaddingTop(),
154
+				bounds.width - style.border.getPaddingLeft() - style.border.getPaddingTop() - scrollBar.getBounds().width,
155
+				bounds.height - style.border.getPaddingTop() - style.border.getPaddingBottom()));
139 156
 	}
140 157
 
141 158
 	@Override
142 159
 	public void paint(DCanvas canvas) {
143
-		canvas.shadowPath(shape, DTransform2D.IDENTITY, style.backgroundColor, style.shadow);
144
-		style.border.paint(canvas, style.margin.apply(bounds));
145 160
 		scrollBar.paint(canvas);
146 161
 		
147 162
 		canvas.pushBounds(new DIRectangle(
@@ -264,6 +279,11 @@ public class DScrollPane implements DComponent {
264 279
 	}
265 280
 	
266 281
 	private class TranslatedContext implements DUIContext {
282
+		private final DUIContext context;
283
+		
284
+		public TranslatedContext(DUIContext context) {
285
+			this.context = context;
286
+		}
267 287
 		
268 288
 		@Override
269 289
 		public DStyleSheets getStylesheets(){
@@ -354,8 +374,10 @@ public class DScrollPane implements DComponent {
354 374
 			
355 375
 			if (value != offsetY.getValue())
356 376
 				offsetY.setValue(value);
357
-			if (context != null && bounds != null)
358
-				context.repaint(bounds);
377
+			if (surface != null && bounds != null)
378
+				surface.repaint(bounds);
379
+			
380
+			subSurface.setOffset(bounds.x - offsetX.getValue(), bounds.y - offsetY.getValue());
359 381
 		}
360 382
 	}
361 383
 }

+ 1
- 3
DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingCanvas.java Ver arquivo

@@ -39,8 +39,6 @@ public class SwingCanvas implements DCanvas {
39 39
 	
40 40
 	public SwingCanvas(Graphics2D g, SwingGraphicsContext context, DIRectangle bounds) {
41 41
 		this.g = g;
42
-		g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
43
-		g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
44 42
 		
45 43
 		this.context = context;
46 44
 		
@@ -173,7 +171,7 @@ public class SwingCanvas implements DCanvas {
173 171
 		font.cached = Font.decode(baseFontName).deriveFont(style, font.size);
174 172
 	}
175 173
 	
176
-	private AffineTransform getTransform(DTransform2D transform) {
174
+	public static AffineTransform getTransform(DTransform2D transform) {
177 175
 		return new AffineTransform(transform.xx, transform.xy, transform.yx, transform.yy, transform.dx, transform.dy);
178 176
 	}
179 177
     

+ 119
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingDrawSurface.java Ver arquivo

@@ -0,0 +1,119 @@
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.swing;
7
+
8
+import java.awt.Graphics2D;
9
+import java.util.ArrayList;
10
+import java.util.List;
11
+import org.openzen.drawablegui.DFont;
12
+import org.openzen.drawablegui.DFontMetrics;
13
+import org.openzen.drawablegui.DIRectangle;
14
+import org.openzen.drawablegui.DPath;
15
+import org.openzen.drawablegui.DTransform2D;
16
+import org.openzen.drawablegui.DUIContext;
17
+import org.openzen.drawablegui.draw.DDrawSurface;
18
+import org.openzen.drawablegui.draw.DDrawnRectangle;
19
+import org.openzen.drawablegui.draw.DDrawnShape;
20
+import org.openzen.drawablegui.draw.DDrawnText;
21
+import org.openzen.drawablegui.draw.DSubSurface;
22
+import org.openzen.drawablegui.style.DShadow;
23
+import org.openzen.drawablegui.style.DStyleDefinition;
24
+import org.openzen.drawablegui.style.DStylePath;
25
+
26
+/**
27
+ *
28
+ * @author Hoofdgebruiker
29
+ */
30
+public class SwingDrawSurface implements DDrawSurface {
31
+	private final List<SwingDrawnElement> elements = new ArrayList<>();
32
+	private final SwingGraphicsContext context;
33
+	
34
+	public SwingDrawSurface(SwingGraphicsContext context) {
35
+		this.context = context;
36
+	}
37
+	
38
+	public void paint(Graphics2D g) {
39
+		for (SwingDrawnElement element : elements)
40
+			element.paint(g);
41
+	}
42
+
43
+	@Override
44
+	public SwingGraphicsContext getContext() {
45
+		return context;
46
+	}
47
+
48
+	@Override
49
+	public DStyleDefinition getStylesheet(DStylePath path) {
50
+		return context.getStylesheets().get(context, path);
51
+	}
52
+	
53
+	@Override
54
+	public DFontMetrics getFontMetrics(DFont font) {
55
+		return context.getFontMetrics(font);
56
+	}
57
+	
58
+	@Override
59
+	public float getScale() {
60
+		return context.getScale();
61
+	}
62
+	
63
+	@Override
64
+	public float getTextScale() {
65
+		return context.getTextScale();
66
+	}
67
+
68
+	@Override
69
+	public DDrawnText drawText(int z, DFont font, int color, float x, float y, String text) {
70
+		return addElement(new SwingDrawnText(this, z, x, y, color, font, text));
71
+	}
72
+
73
+	@Override
74
+	public DDrawnShape strokePath(int z, DPath path, DTransform2D transform, int color, float lineWidth) {
75
+		return addElement(new SwingStrokedPath(this, z, transform, color, context.getPath(path), lineWidth));
76
+	}
77
+	
78
+	@Override
79
+	public DDrawnRectangle fillRect(int z, DIRectangle rectangle, int color) {
80
+		return addElement(new SwingDrawnRectangle(this, z, rectangle, color));
81
+	}
82
+
83
+	@Override
84
+	public DDrawnShape fillPath(int z, DPath path, DTransform2D transform, int color) {
85
+		return addElement(new SwingFilledPath(this, z, transform, context.getPath(path), color));
86
+	}
87
+
88
+	@Override
89
+	public DDrawnShape shadowPath(int z, DPath path, DTransform2D transform, int color, DShadow shadow) {
90
+		if (shadow.color == 0 || shadow.radius == 0) {
91
+			return fillPath(z, path, transform, color);
92
+		}
93
+		
94
+		return addElement(new SwingShadowedPath(this, z, transform, path, context.getPath(path), color, shadow));
95
+	}
96
+	
97
+	@Override
98
+	public DSubSurface createSubSurface(int z) {
99
+		return addElement(new SwingSubSurface(this, z));
100
+	}
101
+	
102
+	public void remove(SwingDrawnElement element) {
103
+		elements.remove(element);
104
+	}
105
+
106
+	@Override
107
+	public void repaint(int x, int y, int width, int height) {
108
+		context.repaint(x, y, width, height);
109
+	}
110
+	
111
+	private <T extends SwingDrawnElement> T addElement(T element) {
112
+		int index = elements.size();
113
+		while (index > 0 && element.z < elements.get(index - 1).z)
114
+			index--;
115
+		
116
+		elements.add(index, element);
117
+		return element;
118
+	}
119
+}

+ 30
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingDrawnElement.java Ver arquivo

@@ -0,0 +1,30 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.drawablegui.swing;
7
+
8
+import java.awt.Graphics2D;
9
+import java.io.Closeable;
10
+
11
+/**
12
+ *
13
+ * @author Hoofdgebruiker
14
+ */
15
+public abstract class SwingDrawnElement implements Closeable {
16
+	public final SwingDrawSurface target;
17
+	public final int z;
18
+	
19
+	public SwingDrawnElement(SwingDrawSurface target, int z) {
20
+		this.target = target;
21
+		this.z = z;
22
+	}
23
+	
24
+	abstract void paint(Graphics2D g);
25
+	
26
+	@Override
27
+	public void close() {
28
+		target.remove(this);
29
+	}
30
+}

+ 43
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingDrawnRectangle.java Ver arquivo

@@ -0,0 +1,43 @@
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.swing;
7
+
8
+import java.awt.Color;
9
+import java.awt.Graphics2D;
10
+import org.openzen.drawablegui.DIRectangle;
11
+import org.openzen.drawablegui.draw.DDrawnRectangle;
12
+
13
+/**
14
+ *
15
+ * @author Hoofdgebruiker
16
+ */
17
+public class SwingDrawnRectangle extends SwingDrawnElement implements DDrawnRectangle {
18
+	private DIRectangle rectangle;
19
+	private Color color;
20
+	
21
+	public SwingDrawnRectangle(SwingDrawSurface target, int z, DIRectangle rectangle, int color) {
22
+		super(target, z);
23
+		
24
+		this.rectangle = rectangle;
25
+		this.color = new Color(color, true);
26
+	}
27
+
28
+	@Override
29
+	public void setRectangle(DIRectangle rectangle) {
30
+		this.rectangle = rectangle;
31
+	}
32
+
33
+	@Override
34
+	public void setColor(int color) {
35
+		this.color = new Color(color, true);
36
+	}
37
+
38
+	@Override
39
+	public void paint(Graphics2D g) {
40
+		g.setColor(color);
41
+		g.fillRect(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
42
+	}
43
+}

+ 54
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingDrawnText.java Ver arquivo

@@ -0,0 +1,54 @@
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.swing;
7
+
8
+import java.awt.Color;
9
+import java.awt.Font;
10
+import java.awt.Graphics2D;
11
+import org.openzen.drawablegui.DFont;
12
+import org.openzen.drawablegui.draw.DDrawnText;
13
+import static org.openzen.drawablegui.swing.SwingCanvas.prepare;
14
+
15
+/**
16
+ *
17
+ * @author Hoofdgebruiker
18
+ */
19
+public class SwingDrawnText extends SwingDrawnElement implements DDrawnText {
20
+	private float x;
21
+	private float y;
22
+	private int color;
23
+	private final DFont font;
24
+	private final String text;
25
+	
26
+	public SwingDrawnText(SwingDrawSurface target, int z, float x, float y, int color, DFont font, String text) {
27
+		super(target, z);
28
+		
29
+		this.x = x;
30
+		this.y = y;
31
+		this.color = color;
32
+		this.font = font;
33
+		this.text = text;
34
+	}
35
+
36
+	@Override
37
+	public void setPosition(float x, float y) {
38
+		this.x = x;
39
+		this.y = y;
40
+	}
41
+
42
+	@Override
43
+	public void setColor(int color) {
44
+		this.color = color;
45
+	}
46
+
47
+	@Override
48
+	public void paint(Graphics2D g) {
49
+		prepare(font);
50
+		g.setColor(new Color(color, true));
51
+		g.setFont((Font) font.cached);
52
+		g.drawString(text, x, y);
53
+	}
54
+}

+ 61
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingFilledPath.java Ver arquivo

@@ -0,0 +1,61 @@
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.swing;
7
+
8
+import java.awt.Color;
9
+import java.awt.Graphics2D;
10
+import java.awt.geom.AffineTransform;
11
+import java.awt.geom.GeneralPath;
12
+import org.openzen.drawablegui.DTransform2D;
13
+import org.openzen.drawablegui.draw.DDrawnShape;
14
+import static org.openzen.drawablegui.swing.SwingCanvas.getTransform;
15
+
16
+/**
17
+ *
18
+ * @author Hoofdgebruiker
19
+ */
20
+public class SwingFilledPath extends SwingDrawnElement implements DDrawnShape {
21
+	private int color;
22
+	private DTransform2D transform;
23
+	
24
+	private final GeneralPath path;
25
+	
26
+	public SwingFilledPath(
27
+			SwingDrawSurface target,
28
+			int z,
29
+			DTransform2D transform,
30
+			GeneralPath path,
31
+			int color) {
32
+		super(target, z);
33
+		
34
+		this.path = path;
35
+		
36
+		this.color = color;
37
+		this.transform = transform;
38
+	}
39
+
40
+	@Override
41
+	public void setTransform(DTransform2D transform) {
42
+		this.transform = transform;
43
+	}
44
+
45
+	@Override
46
+	public void setColor(int color) {
47
+		this.color = color;
48
+	}
49
+
50
+	@Override
51
+	public void paint(Graphics2D g) {
52
+		if (color == 0)
53
+			return;
54
+		
55
+		AffineTransform old = g.getTransform();
56
+		g.setColor(new Color(color, true));
57
+		g.transform(getTransform(transform));
58
+		g.fill(path);
59
+		g.setTransform(old);
60
+	}
61
+}

+ 12
- 4
DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingGraphicsContext.java Ver arquivo

@@ -24,6 +24,7 @@ import org.openzen.drawablegui.DPathTracer;
24 24
 import org.openzen.drawablegui.DTimerHandle;
25 25
 import org.openzen.drawablegui.DUIContext;
26 26
 import org.openzen.drawablegui.DUIWindow;
27
+import org.openzen.drawablegui.draw.DDrawSurface;
27 28
 import org.openzen.drawablegui.style.DStylePathRoot;
28 29
 import org.openzen.drawablegui.style.DStyleSheets;
29 30
 
@@ -40,6 +41,7 @@ public class SwingGraphicsContext implements DUIContext {
40 41
 	private final JavaClipboard clipboard = new JavaClipboard();
41 42
 	private Graphics graphics;
42 43
 	private DUIWindow window;
44
+	private DDrawSurface surface;
43 45
 	
44 46
 	public SwingGraphicsContext(DStyleSheets stylesheets, float scale, float textScale, SwingRoot root) {
45 47
 		this.stylesheets = stylesheets;
@@ -48,6 +50,10 @@ public class SwingGraphicsContext implements DUIContext {
48 50
 		this.root = root;
49 51
 	}
50 52
 	
53
+	public void setSurface(DDrawSurface surface) {
54
+		this.surface = surface;
55
+	}
56
+	
51 57
 	public GeneralPath getPath(DPath path) {
52 58
 		GeneralPath generalPath = preparedPaths.get(path);
53 59
 		if (generalPath == null) {
@@ -152,13 +158,14 @@ public class SwingGraphicsContext implements DUIContext {
152 158
 	public DUIWindow openDialog(int x, int y, DAnchor anchor, String title, DComponent root) {
153 159
 		SwingWindow swingWindow = (SwingWindow)this.window;
154 160
 		SwingDialog window = new SwingDialog(swingWindow, title, root, false);
155
-		SwingGraphicsContext windowContext = new SwingGraphicsContext(stylesheets, scale, textScale, window.swingComponent);
161
+		SwingGraphicsContext windowContext = window.swingComponent.context;
156 162
 		windowContext.setWindow(window);
157 163
 		windowContext.graphics = this.graphics; // help a little...
164
+		windowContext.setSurface(window.swingComponent.surface);
158 165
 		
159 166
 		Point rootLocation = swingWindow.swingComponent.getLocationOnScreen();
160 167
 		
161
-		root.setContext(DStylePathRoot.INSTANCE, windowContext);
168
+		root.setSurface(DStylePathRoot.INSTANCE, 0, windowContext.surface);
162 169
 		DSizing dimension = root.getSizing().getValue();
163 170
 		int tx = (int)(x + rootLocation.x - anchor.alignX * dimension.preferredWidth);
164 171
 		int ty = (int)(y + rootLocation.y - anchor.alignY * dimension.preferredHeight);
@@ -175,11 +182,12 @@ public class SwingGraphicsContext implements DUIContext {
175 182
 	public DUIWindow openView(int x, int y, DAnchor anchor, DComponent root) {
176 183
 		SwingWindow swingWindow = (SwingWindow)this.window;
177 184
 		SwingInlineWindow window = new SwingInlineWindow(swingWindow, "", root);
178
-		SwingGraphicsContext windowContext = new SwingGraphicsContext(stylesheets, scale, textScale, window.swingComponent);
185
+		SwingGraphicsContext windowContext = window.swingComponent.context;
179 186
 		windowContext.setWindow(window);
180 187
 		windowContext.graphics = this.graphics; // help a little...
188
+		windowContext.setSurface(window.swingComponent.surface);
181 189
 		
182
-		root.setContext(DStylePathRoot.INSTANCE, windowContext);
190
+		root.setSurface(DStylePathRoot.INSTANCE, 0, windowContext.surface);
183 191
 		DSizing dimension = root.getSizing().getValue();
184 192
 		
185 193
 		Point rootLocation = swingWindow.swingComponent.getLocationOnScreen();

+ 11
- 2
DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingRoot.java Ver arquivo

@@ -9,6 +9,7 @@ import java.awt.Component;
9 9
 import java.awt.Graphics;
10 10
 import java.awt.Graphics2D;
11 11
 import java.awt.Rectangle;
12
+import java.awt.RenderingHints;
12 13
 import java.awt.Toolkit;
13 14
 import java.awt.event.ComponentEvent;
14 15
 import java.awt.event.ComponentListener;
@@ -34,6 +35,7 @@ import org.openzen.drawablegui.style.DStylePathRoot;
34 35
  */
35 36
 public final class SwingRoot extends Component implements ComponentListener, MouseListener, MouseMotionListener, MouseWheelListener, KeyListener {
36 37
 	public final SwingGraphicsContext context;
38
+	public final SwingDrawSurface surface;
37 39
 	public final DComponent component;
38 40
 	private DComponent focus = null;
39 41
 	private boolean firstPaint = true;
@@ -48,6 +50,8 @@ public final class SwingRoot extends Component implements ComponentListener, Mou
48 50
 				Toolkit.getDefaultToolkit().getScreenResolution() / 96.0f,
49 51
 				Toolkit.getDefaultToolkit().getScreenResolution() / 96.0f,
50 52
 				this);
53
+		surface = new SwingDrawSurface(context);
54
+		context.setSurface(surface);
51 55
 		
52 56
 		addComponentListener(this);
53 57
 		addMouseListener(this);
@@ -75,14 +79,19 @@ public final class SwingRoot extends Component implements ComponentListener, Mou
75 79
 	public void paint(Graphics g) {
76 80
 		if (firstPaint) {
77 81
 			firstPaint = false;
78
-			component.setContext(DStylePathRoot.INSTANCE, context);
82
+			component.setSurface(DStylePathRoot.INSTANCE, 0, surface);
79 83
 			component.setBounds(new DIRectangle(0, 0, getWidth(), getHeight()));
80 84
 		}
81 85
 		
82 86
 		long start = System.currentTimeMillis();
83 87
 		Rectangle clipBounds = g.getClipBounds();
84 88
 		DIRectangle clipBounds2 = clipBounds == null ? null : new DIRectangle(clipBounds.x, clipBounds.y, clipBounds.width, clipBounds.height);
85
-		SwingCanvas canvas = new SwingCanvas((Graphics2D) g, context, clipBounds2);
89
+		Graphics2D g2d = (Graphics2D) g;
90
+		g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
91
+		g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
92
+		
93
+		surface.paint(g2d);
94
+		SwingCanvas canvas = new SwingCanvas(g2d, context, clipBounds2);
86 95
 		component.paint(canvas);
87 96
 		
88 97
 		System.out.println("Paint in " + (System.currentTimeMillis() - start) + " ms");

+ 91
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingShadowedPath.java Ver arquivo

@@ -0,0 +1,91 @@
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.swing;
7
+
8
+import java.awt.Color;
9
+import java.awt.Graphics2D;
10
+import java.awt.RenderingHints;
11
+import java.awt.geom.AffineTransform;
12
+import java.awt.geom.GeneralPath;
13
+import java.awt.image.BufferedImage;
14
+import org.openzen.drawablegui.DIRectangle;
15
+import org.openzen.drawablegui.DPath;
16
+import org.openzen.drawablegui.DPathBoundsCalculator;
17
+import org.openzen.drawablegui.DTransform2D;
18
+import org.openzen.drawablegui.draw.DDrawnShape;
19
+import org.openzen.drawablegui.style.DShadow;
20
+import static org.openzen.drawablegui.swing.SwingCanvas.getGaussianBlurFilter;
21
+import static org.openzen.drawablegui.swing.SwingCanvas.getTransform;
22
+
23
+/**
24
+ *
25
+ * @author Hoofdgebruiker
26
+ */
27
+public class SwingShadowedPath extends SwingDrawnElement implements DDrawnShape {
28
+	private final GeneralPath path;
29
+	private final BufferedImage shadowImage;
30
+	private final DIRectangle shadowBounds;
31
+	private final int shadowOffset;
32
+	
33
+	private int color;
34
+	private DTransform2D transform;
35
+	
36
+	public SwingShadowedPath(
37
+			SwingDrawSurface target,
38
+			int z,
39
+			DTransform2D transform,
40
+			DPath originalPath,
41
+			GeneralPath path,
42
+			int color,
43
+			DShadow shadow) {
44
+		super(target, z);
45
+		
46
+		this.transform = transform;
47
+		this.path = path;
48
+		this.color = color;
49
+		
50
+		shadowBounds = DPathBoundsCalculator.getBounds(originalPath, transform.offset(shadow.offsetX, shadow.offsetY));
51
+		shadowOffset = 2 * (int)Math.ceil(shadow.radius);
52
+		
53
+		BufferedImage image = new BufferedImage(shadowBounds.width + 2 * shadowOffset, shadowBounds.height + 2 * shadowOffset, BufferedImage.TYPE_INT_ARGB_PRE);
54
+		Graphics2D imageG = (Graphics2D) image.getGraphics();
55
+		
56
+		imageG.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
57
+		imageG.setColor(new Color(shadow.color, true));
58
+		imageG.setTransform(getTransform(transform.offset(shadowOffset + shadow.offsetX - shadowBounds.x, shadowOffset + shadow.offsetY - shadowBounds.y)));
59
+		imageG.fill(path);
60
+		
61
+		image = getGaussianBlurFilter((int)Math.ceil(shadow.radius), true).filter(image, null);
62
+		image = getGaussianBlurFilter((int)Math.ceil(shadow.radius), false).filter(image, null);
63
+		shadowImage = image;
64
+	}
65
+
66
+	@Override
67
+	public void setTransform(DTransform2D transform) {
68
+		this.transform = transform;
69
+	}
70
+
71
+	@Override
72
+	public void setColor(int color) {
73
+		this.color = color;
74
+	}
75
+
76
+	@Override
77
+	public void paint(Graphics2D g) {
78
+		g.drawImage(shadowImage, shadowBounds.x - shadowOffset, shadowBounds.y - shadowOffset, null);
79
+		
80
+		AffineTransform old = g.getTransform();
81
+		g.setColor(new Color(color, true));
82
+		g.transform(getTransform(transform));
83
+		g.fill(path);
84
+		g.setTransform(old);
85
+	}
86
+
87
+	@Override
88
+	public void close() {
89
+		target.remove(this);
90
+	}
91
+}

+ 70
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingStrokedPath.java Ver arquivo

@@ -0,0 +1,70 @@
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.swing;
7
+
8
+import java.awt.BasicStroke;
9
+import java.awt.Color;
10
+import java.awt.Graphics2D;
11
+import java.awt.geom.AffineTransform;
12
+import java.awt.geom.GeneralPath;
13
+import org.openzen.drawablegui.DPath;
14
+import org.openzen.drawablegui.DTransform2D;
15
+import org.openzen.drawablegui.draw.DDrawnShape;
16
+
17
+/**
18
+ *
19
+ * @author Hoofdgebruiker
20
+ */
21
+public class SwingStrokedPath extends SwingDrawnElement implements DDrawnShape {
22
+	private DTransform2D transform;
23
+	private int color;
24
+	
25
+	private final GeneralPath path;
26
+	private final float lineWidth;
27
+	
28
+	public SwingStrokedPath(
29
+			SwingDrawSurface target,
30
+			int z,
31
+			DTransform2D transform,
32
+			int color,
33
+			GeneralPath path,
34
+			float lineWidth) {
35
+		super(target, z);
36
+		
37
+		this.transform = transform;
38
+		this.color = color;
39
+		this.path = path;
40
+		this.lineWidth = lineWidth;
41
+	}
42
+
43
+	@Override
44
+	public void setTransform(DTransform2D transform) {
45
+		this.transform = transform;
46
+	}
47
+
48
+	@Override
49
+	public void setColor(int color) {
50
+		this.color = color;
51
+	}
52
+
53
+	@Override
54
+	public void close() {
55
+		target.remove(this);
56
+	}
57
+
58
+	@Override
59
+	public void paint(Graphics2D g) {
60
+		if (color == 0)
61
+			return;
62
+		
63
+		AffineTransform old = g.getTransform();
64
+		g.setColor(new Color(color, true));
65
+		g.setStroke(new BasicStroke(lineWidth));
66
+		g.transform(SwingCanvas.getTransform(transform));
67
+		g.draw(path);
68
+		g.setTransform(old);
69
+	}
70
+}

+ 157
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingSubSurface.java Ver arquivo

@@ -0,0 +1,157 @@
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.swing;
7
+
8
+import java.awt.Graphics2D;
9
+import java.awt.Rectangle;
10
+import java.awt.geom.AffineTransform;
11
+import org.openzen.drawablegui.DFont;
12
+import org.openzen.drawablegui.DFontMetrics;
13
+import org.openzen.drawablegui.DIRectangle;
14
+import org.openzen.drawablegui.DPath;
15
+import org.openzen.drawablegui.DTransform2D;
16
+import org.openzen.drawablegui.DUIContext;
17
+import org.openzen.drawablegui.draw.DDrawnRectangle;
18
+import org.openzen.drawablegui.draw.DDrawnShape;
19
+import org.openzen.drawablegui.draw.DDrawnText;
20
+import org.openzen.drawablegui.draw.DSubSurface;
21
+import org.openzen.drawablegui.style.DShadow;
22
+import org.openzen.drawablegui.style.DStyleDefinition;
23
+import org.openzen.drawablegui.style.DStylePath;
24
+
25
+/**
26
+ *
27
+ * @author Hoofdgebruiker
28
+ */
29
+public class SwingSubSurface extends SwingDrawnElement implements DSubSurface {
30
+	private final SwingDrawSurface surface;
31
+	
32
+	private int offsetX = 0;
33
+	private int offsetY = 0;
34
+	private DIRectangle clip = null;
35
+	
36
+	public SwingSubSurface(SwingDrawSurface parent, int z) {
37
+		super(parent, z);
38
+		
39
+		this.surface = new SwingDrawSurface(parent.getContext());
40
+	}
41
+	
42
+	@Override
43
+	public void paint(Graphics2D g) {
44
+		Rectangle clipBounds = g.getClipBounds();
45
+		if (clip != null) {
46
+			g.setClip(clip.x, clip.y, clip.width, clip.height);
47
+		}
48
+		
49
+		AffineTransform oldTransform = g.getTransform();
50
+		g.transform(AffineTransform.getTranslateInstance(offsetX, offsetY));
51
+		surface.paint(g);
52
+		g.setTransform(oldTransform);
53
+		g.setClip(clipBounds.x, clipBounds.y, clipBounds.width, clipBounds.height);
54
+	}
55
+
56
+	@Override
57
+	public void setOffset(int x, int y) {
58
+		offsetX = x;
59
+		offsetY = y;
60
+	}
61
+
62
+	@Override
63
+	public void setClip(DIRectangle bounds) {
64
+		clip = bounds;
65
+	}
66
+
67
+	@Override
68
+	public DUIContext getContext() {
69
+		return surface.getContext();
70
+	}
71
+
72
+	@Override
73
+	public DStyleDefinition getStylesheet(DStylePath path) {
74
+		return surface.getStylesheet(path);
75
+	}
76
+
77
+	@Override
78
+	public DFontMetrics getFontMetrics(DFont font) {
79
+		return surface.getFontMetrics(font);
80
+	}
81
+
82
+	@Override
83
+	public float getScale() {
84
+		return surface.getScale();
85
+	}
86
+
87
+	@Override
88
+	public float getTextScale() {
89
+		return surface.getTextScale();
90
+	}
91
+
92
+	@Override
93
+	public DDrawnText drawText(int z, DFont font, int color, float x, float y, String text) {
94
+		return surface.drawText(z, font, color, x, y, text);
95
+	}
96
+
97
+	@Override
98
+	public DDrawnShape strokePath(int z, DPath path, DTransform2D transform, int color, float lineWidth) {
99
+		return surface.strokePath(z, path, transform, color, lineWidth);
100
+	}
101
+	
102
+	@Override
103
+	public DDrawnRectangle fillRect(int z, DIRectangle rectangle, int color) {
104
+		return surface.fillRect(z, rectangle, color);
105
+	}
106
+
107
+	@Override
108
+	public DDrawnShape fillPath(int z, DPath path, DTransform2D transform, int color) {
109
+		return surface.fillPath(z, path, transform, color);
110
+	}
111
+
112
+	@Override
113
+	public DDrawnShape shadowPath(int z, DPath path, DTransform2D transform, int color, DShadow shadow) {
114
+		return surface.shadowPath(z, path, transform, color, shadow);
115
+	}
116
+
117
+	@Override
118
+	public DSubSurface createSubSurface(int z) {
119
+		return surface.createSubSurface(z);
120
+	}
121
+
122
+	@Override
123
+	public void repaint(int x, int y, int width, int height) {
124
+		int left = toGlobalX(x);
125
+		int top = toGlobalY(y);
126
+		int right = left + width;
127
+		int bottom = top + height;
128
+
129
+		if (clip != null) {
130
+			left = Math.max(clip.x, left);
131
+			top = Math.max(clip.y, top);
132
+			right = Math.min(clip.x + clip.width, right);
133
+			bottom = Math.min(clip.y + clip.height, bottom);
134
+		}
135
+
136
+		if (left >= right || top >= bottom)
137
+			return;
138
+
139
+		target.repaint(left, top, right - left, bottom - top);
140
+	}
141
+
142
+	private int toGlobalX(int x) {
143
+		return x + offsetX;
144
+	}
145
+
146
+	private int toGlobalY(int y) {
147
+		return y + offsetY;
148
+	}
149
+
150
+	private int toLocalX(int x) {
151
+		return x - offsetX;
152
+	}
153
+
154
+	private int toLocalY(int y) {
155
+		return y - offsetY;
156
+	}
157
+}

+ 36
- 23
DrawableGui/src/main/java/org/openzen/drawablegui/tree/DTreeView.java Ver arquivo

@@ -18,9 +18,10 @@ import org.openzen.drawablegui.DTransform2D;
18 18
 import org.openzen.drawablegui.DIRectangle;
19 19
 import org.openzen.drawablegui.listeners.ListenerHandle;
20 20
 import org.openzen.drawablegui.live.LiveBool;
21
-import org.openzen.drawablegui.DUIContext;
21
+import org.openzen.drawablegui.draw.DDrawSurface;
22 22
 import org.openzen.drawablegui.live.LiveList;
23 23
 import org.openzen.drawablegui.live.MutableLiveObject;
24
+import org.openzen.drawablegui.style.DStyleClass;
24 25
 import org.openzen.drawablegui.style.DStylePath;
25 26
 
26 27
 /**
@@ -28,32 +29,44 @@ import org.openzen.drawablegui.style.DStylePath;
28 29
  * @author Hoofdgebruiker
29 30
  */
30 31
 public class DTreeView<N extends DTreeNode<N>> implements DComponent {
32
+	private final DStyleClass styleClass;
31 33
 	private final MutableLiveObject<DSizing> sizing = DSizing.create();
32 34
 	private DIRectangle bounds;
33 35
 	
34 36
 	private int selectedRow = -1;
35 37
 	private N selectedNode = null;
36 38
 	
37
-	private final DTreeViewStyle styleDefinition;
38
-	private DTreeViewStyle.Calculated style;
39
+	private DTreeViewStyle style;
39 40
 	private DFontMetrics fontMetrics;
40 41
 	
41
-	private DUIContext context;
42
+	private final DDrawable nodeOpenedIcon;
43
+	private final DDrawable nodeClosedIcon;
44
+	
45
+	private DDrawSurface surface;
42 46
 	private final N root;
43 47
 	private final boolean showRoot;
44 48
 	private final List<Row> rows = new ArrayList<>();
45 49
 	
46
-	public DTreeView(DTreeViewStyle style, N root, boolean showRoot) {
47
-		this.styleDefinition = style;
50
+	public DTreeView(
51
+			DStyleClass styleClass,
52
+			DDrawable nodeOpenedIcon,
53
+			DDrawable nodeClosedIcon,
54
+			N root,
55
+			boolean showRoot)
56
+	{
57
+		this.styleClass = styleClass;
48 58
 		this.root = root;
49 59
 		this.showRoot = showRoot;
60
+		
61
+		this.nodeOpenedIcon = nodeOpenedIcon;
62
+		this.nodeClosedIcon = nodeClosedIcon;
50 63
 	}
51 64
 
52 65
 	@Override
53
-	public void setContext(DStylePath parent, DUIContext context) {
54
-		this.context = context;
55
-		style = styleDefinition.forContext(context);
56
-		fontMetrics = context.getFontMetrics(style.font);
66
+	public void setSurface(DStylePath parent, int z, DDrawSurface surface) {
67
+		this.surface = surface;
68
+		style = new DTreeViewStyle(surface.getStylesheet(parent.getChild("tree", styleClass)));
69
+		fontMetrics = surface.getFontMetrics(style.font);
57 70
 		
58 71
 		updateLayout();
59 72
 	}
@@ -80,7 +93,7 @@ public class DTreeView<N extends DTreeNode<N>> implements DComponent {
80 93
 
81 94
 	@Override
82 95
 	public void paint(DCanvas canvas) {
83
-		canvas.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height, styleDefinition.backgroundColor);
96
+		canvas.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height, style.backgroundColor);
84 97
 		
85 98
 		int drawX = bounds.x + style.padding;
86 99
 		int drawY = bounds.y + style.padding;
@@ -99,7 +112,7 @@ public class DTreeView<N extends DTreeNode<N>> implements DComponent {
99 112
 		int row = yToRow(e.y);
100 113
 		if (row >= 0 && row < rows.size()) {
101 114
 			Row rowEntry = rows.get(row);
102
-			if (e.x >= rowEntry.x && e.x < (rowEntry.x + styleDefinition.nodeOpenedIcon.getNominalWidth())) {
115
+			if (e.x >= rowEntry.x && e.x < (rowEntry.x + nodeOpenedIcon.getNominalWidth())) {
103 116
 				if (!rowEntry.node.isLeaf())
104 117
 					rowEntry.node.isCollapsed().toggle();
105 118
 				return;
@@ -113,12 +126,12 @@ public class DTreeView<N extends DTreeNode<N>> implements DComponent {
113 126
 				selectedNode = rows.get(row).node;
114 127
 
115 128
 				if (oldRow >= 0)
116
-					context.repaint(
129
+					surface.repaint(
117 130
 							bounds.x,
118 131
 							rowToY(oldRow) - style.selectedPaddingTop,
119 132
 							bounds.width,
120 133
 							fontMetrics.getAscent() + fontMetrics.getDescent() + style.selectedPaddingTop + style.selectedPaddingBottom);
121
-				context.repaint(
134
+				surface.repaint(
122 135
 						bounds.x,
123 136
 						rowToY(row) - style.selectedPaddingTop,
124 137
 						bounds.width,
@@ -136,24 +149,24 @@ public class DTreeView<N extends DTreeNode<N>> implements DComponent {
136 149
 	}
137 150
 	
138 151
 	private int paintNode(DCanvas canvas, N node, int drawX, int drawY) {
139
-		int textColor = styleDefinition.nodeTextColor;
152
+		int textColor = style.nodeTextColor;
140 153
 		if (node == selectedNode) {
141
-			textColor = styleDefinition.selectedNodeTextColor;
154
+			textColor = style.selectedNodeTextColor;
142 155
 			canvas.fillRectangle(
143 156
 					bounds.x,
144 157
 					drawY - style.selectedPaddingTop,
145 158
 					bounds.width,
146 159
 					fontMetrics.getAscent() + fontMetrics.getDescent() + style.selectedPaddingTop + style.selectedPaddingBottom,
147
-					styleDefinition.selectedBackgroundColor);
160
+					style.selectedBackgroundColor);
148 161
 		}
149 162
 		
150 163
 		int drawingX = drawX;
151 164
 		if (!node.isLeaf()) {
152
-			DDrawable icon = node.isCollapsed().getValue() ? style.nodeClosedIcon : style.nodeOpenedIcon;
165
+			DDrawable icon = node.isCollapsed().getValue() ? nodeClosedIcon : nodeOpenedIcon;
153 166
 			icon.draw(canvas, DTransform2D.translate(drawingX, drawY + fontMetrics.getAscent() + fontMetrics.getDescent() - icon.getNominalHeight()));
154 167
 			drawingX += style.iconTextSpacing + icon.getNominalWidth();
155 168
 		} else {
156
-			drawingX += style.iconTextSpacing + style.nodeClosedIcon.getNominalWidth();
169
+			drawingX += style.iconTextSpacing + nodeClosedIcon.getNominalWidth();
157 170
 		}
158 171
 		node.getIcon().draw(canvas, DTransform2D.translate(drawingX, drawY + fontMetrics.getAscent() + fontMetrics.getDescent() - node.getIcon().getNominalHeight()), textColor);
159 172
 		drawingX += style.iconTextSpacing + node.getIcon().getNominalWidth();
@@ -232,25 +245,25 @@ public class DTreeView<N extends DTreeNode<N>> implements DComponent {
232 245
 		@Override
233 246
 		public void onChanged(boolean oldValue, boolean newValue) {
234 247
 			updateLayout();
235
-			context.repaint(bounds);
248
+			surface.repaint(bounds);
236 249
 		}
237 250
 
238 251
 		@Override
239 252
 		public void onInserted(int index, N value) {
240 253
 			updateLayout();
241
-			context.repaint(bounds);
254
+			surface.repaint(bounds);
242 255
 		}
243 256
 
244 257
 		@Override
245 258
 		public void onChanged(int index, N oldValue, N newValue) {
246 259
 			updateLayout();
247
-			context.repaint(bounds);
260
+			surface.repaint(bounds);
248 261
 		}
249 262
 
250 263
 		@Override
251 264
 		public void onRemoved(int index, N oldValue) {
252 265
 			updateLayout();
253
-			context.repaint(bounds);
266
+			surface.repaint(bounds);
254 267
 		}
255 268
 		
256 269
 		@Override

+ 22
- 65
DrawableGui/src/main/java/org/openzen/drawablegui/tree/DTreeViewStyle.java Ver arquivo

@@ -11,81 +11,38 @@ import org.openzen.drawablegui.DFontFamily;
11 11
 import org.openzen.drawablegui.style.DDimension;
12 12
 import org.openzen.drawablegui.style.DDpDimension;
13 13
 import org.openzen.drawablegui.DUIContext;
14
+import org.openzen.drawablegui.style.DStyleDefinition;
14 15
 
15 16
 /**
16 17
  *
17 18
  * @author Hoofdgebruiker
18 19
  */
19 20
 public class DTreeViewStyle {
20
-	public static DTreeViewStyle DEFAULT = new DTreeViewStyle();
21
-	
22
-	public final DDrawable nodeOpenedIcon;
23
-	public final DDrawable nodeClosedIcon;
24 21
 	public final int backgroundColor;
25 22
 	public final int borderColor;
26
-	public final DDimension padding;
27
-	public final DDimension rowSpacing;
28
-	public final DDimension fontSize;
29
-	public final DDimension indent;
30
-	public final DDimension iconTextSpacing;
23
+	public final int padding;
24
+	public final int rowSpacing;
25
+	public final DFont font;
26
+	public final int indent;
27
+	public final int iconTextSpacing;
31 28
 	public final int nodeTextColor;
32 29
 	public final int selectedNodeTextColor;
33 30
 	public final int selectedBackgroundColor;
34
-	public final DDimension selectedPaddingTop;
35
-	public final DDimension selectedPaddingBottom;
36
-	
37
-	private DTreeViewStyle() {
38
-		nodeOpenedIcon = ExpandedArrow.INSTANCE;
39
-		nodeClosedIcon = CollapsedArrow.INSTANCE;
40
-		backgroundColor = 0;
41
-		borderColor = 0xFF888888;
42
-		padding = new DDpDimension(3);
43
-		rowSpacing = new DDpDimension(2);
44
-		fontSize = new DDpDimension(12.5f);  
45
-		indent = new DDpDimension(12);
46
-		iconTextSpacing = new DDpDimension(2);
47
-		nodeTextColor = 0xFF000000;
48
-		selectedNodeTextColor = 0xFFFFFFFF;
49
-		selectedBackgroundColor = 0xFF007ACC;
50
-		selectedPaddingTop = new DDpDimension(1);
51
-		selectedPaddingBottom = new DDpDimension(1);
52
-	}
53
-	
54
-	public Calculated forContext(DUIContext context) {
55
-		return new Calculated(this, context);
56
-	}
57
-	
58
-	public static class Calculated {
59
-		public final DDrawable nodeOpenedIcon;
60
-		public final DDrawable nodeClosedIcon;
61
-		public final int backgroundColor;
62
-		public final int borderColor;
63
-		public final int padding;
64
-		public final int rowSpacing;
65
-		public final DFont font;
66
-		public final int indent;
67
-		public final int iconTextSpacing;
68
-		public final int nodeTextColor;
69
-		public final int selectedNodeTextColor;
70
-		public final int selectedBackgroundColor;
71
-		public final int selectedPaddingTop;
72
-		public final int selectedPaddingBottom;
73
-		
74
-		private Calculated(DTreeViewStyle style, DUIContext context) {
75
-			nodeOpenedIcon = style.nodeOpenedIcon;
76
-			nodeClosedIcon = style.nodeClosedIcon;
77
-			backgroundColor = style.backgroundColor;
78
-			borderColor = style.borderColor;
79
-			padding = style.padding.evalInt(context);
80
-			rowSpacing = style.rowSpacing.evalInt(context);
81
-			font = new DFont(DFontFamily.UI, false, false, false, style.fontSize.evalInt(context));
82
-			indent = style.indent.evalInt(context);
83
-			iconTextSpacing = style.iconTextSpacing.evalInt(context);
84
-			nodeTextColor = style.nodeTextColor;
85
-			selectedNodeTextColor = style.selectedNodeTextColor;
86
-			selectedBackgroundColor = style.selectedBackgroundColor;
87
-			selectedPaddingTop = style.selectedPaddingTop.evalInt(context);
88
-			selectedPaddingBottom = style.selectedPaddingBottom.evalInt(context);
89
-		}
31
+	public final int selectedPaddingTop;
32
+	public final int selectedPaddingBottom;
33
+
34
+	public DTreeViewStyle(DStyleDefinition style) {
35
+		backgroundColor = style.getColor("backgroundColor", 0);
36
+		borderColor = style.getColor("borderColor", 0xFF888888);
37
+		padding = style.getDimension("padding", new DDpDimension(3));
38
+		rowSpacing = style.getDimension("rowSpacing", new DDpDimension(2));
39
+		font = style.getFont("font", context -> new DFont(DFontFamily.UI, false, false, false, context.sp(12.5f)));
40
+		indent = style.getDimension("indent", new DDpDimension(12));
41
+		iconTextSpacing = style.getDimension("iconTextSpacing", new DDpDimension(2));
42
+		nodeTextColor = style.getColor("nodeTextColor", 0xFF000000);
43
+		selectedNodeTextColor = style.getColor("selectedNodeTextColor", 0xFFFFFFFF);
44
+		selectedBackgroundColor = style.getColor("selectedBackgroundColor", 0xFF007ACC);
45
+		selectedPaddingTop = style.getDimension("selectedPaddingTop", new DDpDimension(1));
46
+		selectedPaddingBottom = style.getDimension("selectedPaddingBottom", new DDpDimension(1));
90 47
 	}
91 48
 }

+ 14
- 13
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/IconButtonControl.java Ver arquivo

@@ -16,6 +16,7 @@ import org.openzen.drawablegui.DTransform2D;
16 16
 import org.openzen.drawablegui.DUIContext;
17 17
 import org.openzen.drawablegui.DIRectangle;
18 18
 import org.openzen.drawablegui.DSimpleTooltip;
19
+import org.openzen.drawablegui.draw.DDrawSurface;
19 20
 import org.openzen.drawablegui.listeners.ListenerHandle;
20 21
 import org.openzen.drawablegui.live.ImmutableLiveBool;
21 22
 import org.openzen.drawablegui.live.LiveBool;
@@ -38,7 +39,7 @@ public class IconButtonControl implements DComponent {
38 39
 	private final ListenerHandle<LiveBool.Listener> disabledListener;
39 40
 	private final DSimpleTooltip tooltip;
40 41
 	
41
-	private DUIContext context;
42
+	private DDrawSurface surface;
42 43
 	private IconButtonControlStyle style;
43 44
 	private DIRectangle bounds;
44 45
 	private final MutableLiveObject<DSizing> preferences = DSizing.create();
@@ -61,15 +62,15 @@ public class IconButtonControl implements DComponent {
61 62
 	}
62 63
 
63 64
 	@Override
64
-	public void setContext(DStylePath parent, DUIContext context) {
65
-		this.context = context;
66
-		tooltip.setContext(context);
65
+	public void setSurface(DStylePath parent, int z, DDrawSurface surface) {
66
+		this.surface = surface;
67
+		tooltip.setContext(surface.getContext());
67 68
 		
68 69
 		DStylePath path = parent.getChild("iconbutton", styleClass);
69
-		style = new IconButtonControlStyle(context.getStylesheets().get(context, path));
70
+		style = new IconButtonControlStyle(surface.getStylesheet(path));
70 71
 		
71
-		int iconWidth = (int)(icon.getNominalWidth() * context.getScale() + 0.5f);
72
-		int iconHeight = (int)(icon.getNominalWidth() * context.getScale() + 0.5f);
72
+		int iconWidth = (int)(icon.getNominalWidth() * surface.getScale() + 0.5f);
73
+		int iconHeight = (int)(icon.getNominalWidth() * surface.getScale() + 0.5f);
73 74
 		int width = iconWidth + 2 * style.padding + 2 * style.margin;
74 75
 		int height = iconHeight + 2 * style.padding + 2 * style.margin;
75 76
 		preferences.setValue(new DSizing(width, height));
@@ -97,7 +98,7 @@ public class IconButtonControl implements DComponent {
97 98
 	public void setBounds(DIRectangle bounds) {
98 99
 		this.bounds = bounds;
99 100
 		
100
-		if (context != null)
101
+		if (surface != null)
101 102
 			shape = DPath.roundedRectangle(
102 103
 					bounds.x + style.margin,
103 104
 					bounds.y + style.margin,
@@ -120,9 +121,9 @@ public class IconButtonControl implements DComponent {
120 121
 		
121 122
 		DDrawable icon = disabled.getValue() ? iconDisabled : this.icon;
122 123
 		icon.draw(canvas, DTransform2D.scaleAndTranslate(
123
-				bounds.x + (bounds.width - icon.getNominalWidth() * context.getScale()) / 2,
124
-				bounds.y + (bounds.height - icon.getNominalHeight() * context.getScale()) / 2,
125
-				context.getScale()));
124
+				bounds.x + (bounds.width - icon.getNominalWidth() * surface.getScale()) / 2,
125
+				bounds.y + (bounds.height - icon.getNominalHeight() * surface.getScale()) / 2,
126
+				surface.getScale()));
126 127
 	}
127 128
 
128 129
 	@Override
@@ -168,9 +169,9 @@ public class IconButtonControl implements DComponent {
168 169
 	}
169 170
 	
170 171
 	private void repaint() {
171
-		if (context == null || bounds == null)
172
+		if (surface == null || bounds == null)
172 173
 			return;
173 174
 		
174
-		context.repaint(bounds);
175
+		surface.repaint(bounds);
175 176
 	}
176 177
 }

+ 20
- 8
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/StatusBarView.java Ver arquivo

@@ -14,7 +14,8 @@ import org.openzen.drawablegui.DPath;
14 14
 import org.openzen.drawablegui.DTransform2D;
15 15
 import org.openzen.drawablegui.live.LiveObject;
16 16
 import org.openzen.drawablegui.live.SimpleLiveObject;
17
-import org.openzen.drawablegui.DUIContext;
17
+import org.openzen.drawablegui.draw.DDrawSurface;
18
+import org.openzen.drawablegui.draw.DDrawnShape;
18 19
 import org.openzen.drawablegui.live.LiveString;
19 20
 import org.openzen.drawablegui.style.DStyleClass;
20 21
 import org.openzen.drawablegui.style.DStylePath;
@@ -29,22 +30,26 @@ public class StatusBarView implements DComponent {
29 30
 	private final DStyleClass styleClass;
30 31
 	private final LiveString content;
31 32
 	private DIRectangle bounds;
32
-	private DUIContext context;
33
+	private DDrawSurface surface;
34
+	private int z;
33 35
 	private StatusBarStyle style;
34 36
 	private DFontMetrics fontMetrics;
35 37
 
38
+	private DDrawnShape shape;
39
+	
36 40
 	public StatusBarView(DStyleClass styleClass, LiveString content) {
37 41
 		this.styleClass = styleClass;
38 42
 		this.content = content;
39 43
 	}
40 44
 	
41 45
 	@Override
42
-	public void setContext(DStylePath parent, DUIContext context) {
43
-		this.context = context;
46
+	public void setSurface(DStylePath parent, int z, DDrawSurface surface) {
47
+		this.surface = surface;
48
+		this.z = z;
44 49
 		
45 50
 		DStylePath path = parent.getChild("StatusBar", styleClass);
46
-		style = new StatusBarStyle(context.getStylesheets().get(context, path));
47
-		fontMetrics = context.getFontMetrics(style.font);
51
+		style = new StatusBarStyle(surface.getStylesheet(path));
52
+		fontMetrics = surface.getFontMetrics(style.font);
48 53
 		
49 54
 		dimensionPreferences.setValue(new DSizing(0, style.paddingTop + fontMetrics.getAscent() + fontMetrics.getDescent() + style.paddingBottom));
50 55
 	}
@@ -67,12 +72,19 @@ public class StatusBarView implements DComponent {
67 72
 	@Override
68 73
 	public void setBounds(DIRectangle bounds) {
69 74
 		this.bounds = bounds;
75
+		
76
+		if (shape != null)
77
+			shape.close();
78
+		shape = surface.shadowPath(z, DPath.rectangle(bounds.x, bounds.y, bounds.width, bounds.height), DTransform2D.IDENTITY, style.backgroundColor, style.shadow);
70 79
 	}
71 80
 
72 81
 	@Override
73 82
 	public void paint(DCanvas canvas) {
74
-		canvas.shadowPath(DPath.rectangle(bounds.x, bounds.y, bounds.width, bounds.height), DTransform2D.IDENTITY, style.backgroundColor, style.shadow);
75
-		canvas.drawText(style.font, style.textColor, style.paddingLeft, style.paddingTop + fontMetrics.getAscent(), content.getValue());
83
+		canvas.drawText(
84
+				style.font,
85
+				style.textColor,
86
+				bounds.x + style.paddingLeft,
87
+				bounds.y + style.paddingTop + fontMetrics.getAscent(), content.getValue());
76 88
 	}
77 89
 
78 90
 	@Override

+ 15
- 11
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/TabbedView.java Ver arquivo

@@ -16,6 +16,7 @@ import org.openzen.drawablegui.DSizing;
16 16
 import org.openzen.drawablegui.DFontMetrics;
17 17
 import org.openzen.drawablegui.DIRectangle;
18 18
 import org.openzen.drawablegui.DUIContext;
19
+import org.openzen.drawablegui.draw.DDrawSurface;
19 20
 import org.openzen.drawablegui.listeners.ListenerHandle;
20 21
 import org.openzen.drawablegui.live.LiveArrayList;
21 22
 import org.openzen.drawablegui.live.LiveList;
@@ -39,17 +40,18 @@ public class TabbedView extends BaseComponentGroup {
39 40
 	
40 41
 	private final Map<TabbedViewTab, ListenerHandle<LiveObject.Listener<DSizing>>> tabSizeListeners = new HashMap<>();
41 42
 	
42
-	private DUIContext context;
43
+	private DDrawSurface surface;
43 44
 	private DStylePath path;
44 45
 	private DIRectangle bounds;
45 46
 	private TabbedViewStyle style;
46 47
 	private int totalTabHeight;
47 48
 	private DFontMetrics fontMetrics;
49
+	private int z;
48 50
 
49 51
 	private final LiveList<TabbedViewTab> tabComponents = new LiveMappedList<>(tabs, tab -> {
50 52
 		TabbedViewTab result = new TabbedViewTab(this, currentTab, tab);
51
-		if (context != null)
52
-			result.setContext(path, context);
53
+		if (surface != null)
54
+			result.setSurface(path, z + 2, surface);
53 55
 		
54 56
 		tabSizeListeners.put(result, result.getSizing().addListener((oldSize, newSize) -> layoutTabs()));
55 57
 		return result;
@@ -71,17 +73,19 @@ public class TabbedView extends BaseComponentGroup {
71 73
 					bounds.width, bounds.height - totalTabHeight);
72 74
 				newValue.content.setBounds(contentBounds);
73 75
 			}
74
-			if (newValue == null && context != null && bounds != null)
75
-				context.repaint(bounds);
76
+			if (newValue == null && surface != null && bounds != null)
77
+				surface.repaint(bounds);
76 78
 		});
77 79
 	}
78 80
 	
79 81
 	@Override
80
-	public void setContext(DStylePath parent, DUIContext context) {
81
-		this.context = context;
82
+	public void setSurface(DStylePath parent, int z, DDrawSurface surface) {
83
+		this.surface = surface;
84
+		this.z = z;
85
+		
82 86
 		path = parent.getChild("tabbedView", styleClass);
83
-		style = new TabbedViewStyle(context.getStylesheets().get(context, path));
84
-		fontMetrics = context.getFontMetrics(style.tabFont);
87
+		style = new TabbedViewStyle(surface.getStylesheet(path));
88
+		fontMetrics = surface.getFontMetrics(style.tabFont);
85 89
 		totalTabHeight = style.tabBorder.getPaddingVertical() + fontMetrics.getAscent() + fontMetrics.getDescent();
86 90
 		
87 91
 		for (TabbedViewComponent tab : tabs)
@@ -134,11 +138,11 @@ public class TabbedView extends BaseComponentGroup {
134 138
 	}
135 139
 	
136 140
 	private void repaintTabs() {
137
-		context.repaint(bounds.x, bounds.y, bounds.width, totalTabHeight);
141
+		surface.repaint(bounds.x, bounds.y, bounds.width, totalTabHeight);
138 142
 	}
139 143
 	
140 144
 	private void prepare(TabbedViewComponent tab) {
141
-		tab.content.setContext(path, context);
145
+		tab.content.setSurface(path, z + 1, surface);
142 146
 	}
143 147
 	
144 148
 	private void layoutTabs() {

+ 9
- 9
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/TabbedViewTab.java Ver arquivo

@@ -13,7 +13,7 @@ import org.openzen.drawablegui.DIRectangle;
13 13
 import org.openzen.drawablegui.DMouseEvent;
14 14
 import org.openzen.drawablegui.DPath;
15 15
 import org.openzen.drawablegui.DTransform2D;
16
-import org.openzen.drawablegui.DUIContext;
16
+import org.openzen.drawablegui.draw.DDrawSurface;
17 17
 import org.openzen.drawablegui.listeners.ListenerHandle;
18 18
 import org.openzen.drawablegui.live.LiveBool;
19 19
 import org.openzen.drawablegui.live.LiveObject;
@@ -34,7 +34,7 @@ public class TabbedViewTab implements DComponent {
34 34
 	private final TabbedView parent;
35 35
 	public final TabbedViewTabClose closeButton;
36 36
 	
37
-	private DUIContext context;
37
+	private DDrawSurface surface;
38 38
 	private TabbedViewTabStyle style;
39 39
 	private DFontMetrics fontMetrics;
40 40
 	private int textWidth;
@@ -61,12 +61,12 @@ public class TabbedViewTab implements DComponent {
61 61
 	}
62 62
 
63 63
 	@Override
64
-	public void setContext(DStylePath parent, DUIContext context) {
65
-		this.context = context;
64
+	public void setSurface(DStylePath parent, int z, DDrawSurface surface) {
65
+		this.surface = surface;
66 66
 		DStylePath path = parent.getChild("tab", DStyleClass.EMPTY);
67
-		style = new TabbedViewTabStyle(context.getStylesheets().get(context, path));
68
-		fontMetrics = context.getFontMetrics(style.tabFont);
69
-		closeButton.setContext(path, context);
67
+		style = new TabbedViewTabStyle(surface.getStylesheet(path));
68
+		fontMetrics = surface.getFontMetrics(style.tabFont);
69
+		closeButton.setSurface(path, z + 1, surface);
70 70
 		
71 71
 		calculateSizing();
72 72
 	}
@@ -185,7 +185,7 @@ public class TabbedViewTab implements DComponent {
185 185
 	}
186 186
 	
187 187
 	private void repaint() {
188
-		if (context != null && bounds != null)
189
-			context.repaint(bounds);
188
+		if (surface != null && bounds != null)
189
+			surface.repaint(bounds);
190 190
 	}
191 191
 }

+ 7
- 7
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/TabbedViewTabClose.java Ver arquivo

@@ -12,7 +12,7 @@ import org.openzen.drawablegui.DSizing;
12 12
 import org.openzen.drawablegui.DIRectangle;
13 13
 import org.openzen.drawablegui.DMouseEvent;
14 14
 import org.openzen.drawablegui.DTransform2D;
15
-import org.openzen.drawablegui.DUIContext;
15
+import org.openzen.drawablegui.draw.DDrawSurface;
16 16
 import org.openzen.drawablegui.live.LiveObject;
17 17
 import org.openzen.drawablegui.live.MutableLiveObject;
18 18
 import org.openzen.drawablegui.style.DStyleClass;
@@ -27,7 +27,7 @@ public class TabbedViewTabClose implements DComponent {
27 27
 	private final TabbedViewTab tab;
28 28
 	private final MutableLiveObject<DSizing> sizing = DSizing.create();
29 29
 	
30
-	private DUIContext context;
30
+	private DDrawSurface surface;
31 31
 	private DIRectangle bounds;
32 32
 	private TabbedViewTabCloseStyle style;
33 33
 	private DColorableIcon icon;
@@ -40,11 +40,11 @@ public class TabbedViewTabClose implements DComponent {
40 40
 	}
41 41
 
42 42
 	@Override
43
-	public void setContext(DStylePath parent, DUIContext context) {
44
-		this.context = context;
43
+	public void setSurface(DStylePath parent, int z, DDrawSurface surface) {
44
+		this.surface = surface;
45 45
 		
46 46
 		DStylePath path = parent.getChild("tabClose", DStyleClass.EMPTY);
47
-		style = new TabbedViewTabCloseStyle(context.getStylesheets().get(context, path));
47
+		style = new TabbedViewTabCloseStyle(surface.getStylesheet(path));
48 48
 		sizing.setValue(new DSizing(style.size, style.size));
49 49
 		icon = new ScalableCloseIcon(style.size / 24);
50 50
 	}
@@ -89,13 +89,13 @@ public class TabbedViewTabClose implements DComponent {
89 89
 	@Override
90 90
 	public void onMouseEnter(DMouseEvent e) {
91 91
 		hover = true;
92
-		context.repaint(bounds);
92
+		surface.repaint(bounds);
93 93
 	}
94 94
 	
95 95
 	@Override
96 96
 	public void onMouseExit(DMouseEvent e) {
97 97
 		hover = false;
98
-		context.repaint(bounds);
98
+		surface.repaint(bounds);
99 99
 	}
100 100
 	
101 101
 	@Override

+ 11
- 11
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/aspectbar/AspectBarSelectorButton.java Ver arquivo

@@ -13,9 +13,9 @@ import org.openzen.drawablegui.DDrawable;
13 13
 import org.openzen.drawablegui.DMouseEvent;
14 14
 import org.openzen.drawablegui.DPath;
15 15
 import org.openzen.drawablegui.DTransform2D;
16
-import org.openzen.drawablegui.DUIContext;
17 16
 import org.openzen.drawablegui.DIRectangle;
18 17
 import org.openzen.drawablegui.DSimpleTooltip;
18
+import org.openzen.drawablegui.draw.DDrawSurface;
19 19
 import org.openzen.drawablegui.listeners.ListenerHandle;
20 20
 import org.openzen.drawablegui.live.ImmutableLiveString;
21 21
 import org.openzen.drawablegui.live.LiveBool;
@@ -36,7 +36,7 @@ public class AspectBarSelectorButton implements DComponent {
36 36
 	private final DDrawable icon;
37 37
 	private final MutableLiveObject<DSizing> sizing = DSizing.create();
38 38
 	private final Consumer<DMouseEvent> onClick;
39
-	private DUIContext context;
39
+	private DDrawSurface surface;
40 40
 	private AspectBarSelectorButtonStyle style;
41 41
 	private DIRectangle bounds = DIRectangle.EMPTY;
42 42
 	private DPath shape;
@@ -57,10 +57,10 @@ public class AspectBarSelectorButton implements DComponent {
57 57
 	}
58 58
 
59 59
 	@Override
60
-	public void setContext(DStylePath parent, DUIContext context) {
61
-		this.context = context;
60
+	public void setSurface(DStylePath parent, int z, DDrawSurface surface) {
61
+		this.surface = surface;
62 62
 		DStylePath path = parent.getChild("selectorbutton", styleClass);
63
-		style = new AspectBarSelectorButtonStyle(context.getStylesheets().get(context, path));
63
+		style = new AspectBarSelectorButtonStyle(surface.getStylesheet(path));
64 64
 		sizing.setValue(new DSizing(style.width, style.height));
65 65
 		shape = DPath.roundedRectangle(
66 66
 				0,
@@ -69,7 +69,7 @@ public class AspectBarSelectorButton implements DComponent {
69 69
 				style.height,
70 70
 				style.roundingRadius);
71 71
 		
72
-		tooltip.setContext(context);
72
+		tooltip.setContext(surface.getContext());
73 73
 	}
74 74
 
75 75
 	@Override
@@ -113,9 +113,9 @@ public class AspectBarSelectorButton implements DComponent {
113 113
 					color,
114 114
 					shadow);
115 115
 		icon.draw(canvas, DTransform2D.scaleAndTranslate(
116
-				bounds.x + (style.width - icon.getNominalWidth() * context.getScale()) / 2,
117
-				bounds.y + (style.height - icon.getNominalHeight() * context.getScale()) / 2,
118
-				context.getScale()));
116
+				bounds.x + (style.width - icon.getNominalWidth() * surface.getScale()) / 2,
117
+				bounds.y + (style.height - icon.getNominalHeight() * surface.getScale()) / 2,
118
+				surface.getScale()));
119 119
 	}
120 120
 	
121 121
 	@Override
@@ -160,7 +160,7 @@ public class AspectBarSelectorButton implements DComponent {
160 160
 	}
161 161
 	
162 162
 	private void repaint() {
163
-		if (context != null && bounds != null)
164
-			context.repaint(bounds);
163
+		if (surface != null && bounds != null)
164
+			surface.repaint(bounds);
165 165
 	}
166 166
 }

+ 67
- 42
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/aspectbar/AspectBarView.java Ver arquivo

@@ -5,8 +5,6 @@
5 5
  */
6 6
 package org.openzen.zenscript.ide.ui.view.aspectbar;
7 7
 
8
-import java.util.ArrayList;
9
-import java.util.List;
10 8
 import java.util.function.Consumer;
11 9
 import java.util.function.Predicate;
12 10
 import org.openzen.drawablegui.BaseComponentGroup;
@@ -20,14 +18,17 @@ import org.openzen.drawablegui.DIRectangle;
20 18
 import org.openzen.drawablegui.live.LiveObject;
21 19
 import org.openzen.zenscript.ide.ui.IDEAspectBar;
22 20
 import org.openzen.zenscript.ide.ui.IDEAspectToolbar;
23
-import org.openzen.drawablegui.DUIContext;
24 21
 import org.openzen.drawablegui.DUIWindow;
22
+import org.openzen.drawablegui.draw.DDrawSurface;
23
+import org.openzen.drawablegui.draw.DDrawnRectangle;
24
+import org.openzen.drawablegui.draw.DDrawnShape;
25 25
 import org.openzen.drawablegui.listeners.ListenerHandle;
26 26
 import org.openzen.drawablegui.live.LiveBool;
27 27
 import org.openzen.drawablegui.live.LiveList;
28 28
 import org.openzen.drawablegui.live.LiveMappedList;
29 29
 import org.openzen.drawablegui.live.LivePredicateBool;
30 30
 import org.openzen.drawablegui.live.MutableLiveObject;
31
+import org.openzen.drawablegui.style.DShadow;
31 32
 import org.openzen.drawablegui.style.DStyleClass;
32 33
 import org.openzen.drawablegui.style.DStylePath;
33 34
 import org.openzen.zenscript.ide.ui.IDEAspectBarControl;
@@ -45,7 +46,9 @@ public class AspectBarView extends BaseComponentGroup {
45 46
 	private final IDEAspectBar aspectBar;
46 47
 	
47 48
 	private DIRectangle bounds;
48
-	private DUIContext context;
49
+	private DDrawSurface surface;
50
+	private int z;
51
+	
49 52
 	private DStylePath path;
50 53
 	private AspectBarStyle style;
51 54
 	private DFontMetrics activeToolbarTitleFontMetrics;
@@ -55,7 +58,6 @@ public class AspectBarView extends BaseComponentGroup {
55 58
 	private LiveMappedList<IDEAspectBarControl, DComponent> activeToolbarComponents;
56 59
 	
57 60
 	private final ListenerHandle<LiveList.Listener<IDEAspectToolbar>> listener;
58
-	private DPath aspectBarShape;
59 61
 	private DPath windowControlsShape;
60 62
 	private int aspectSelectorEndX = 0;
61 63
 	
@@ -67,6 +69,10 @@ public class AspectBarView extends BaseComponentGroup {
67 69
 	private final ListenerHandle<LiveObject.Listener<DSizing>> maximizeRestoreRelayout;
68 70
 	private final ListenerHandle<LiveObject.Listener<DSizing>> closeRelayout;
69 71
 	
72
+	private DDrawnRectangle topBackground;
73
+	private DDrawnRectangle bottomBackground;
74
+	private DDrawnShape aspectBarShape;
75
+	
70 76
 	public AspectBarView(DStyleClass styleClass, IDEAspectBar aspectBar) {
71 77
 		this.styleClass = styleClass;
72 78
 		this.aspectBar = aspectBar;
@@ -74,16 +80,16 @@ public class AspectBarView extends BaseComponentGroup {
74 80
 		aspectBar.active.addListener(this::onActiveChanged);
75 81
 		listener = aspectBar.toolbars.addListener(new ToolbarListListener());
76 82
 		
77
-		minimize = new WindowActionButton(scale -> new ScalableMinimizeIcon(scale), e -> context.getWindow().minimize());
83
+		minimize = new WindowActionButton(scale -> new ScalableMinimizeIcon(scale), e -> surface.getContext().getWindow().minimize());
78 84
 		minimizeRelayout = minimize.getSizing().addListener((a, b) -> layout());
79 85
 		maximizeRestore = new WindowActionButton(ScalableMaximizeIcon::new, e -> {
80
-			if (context.getWindow().getWindowState().getValue() == DUIWindow.State.MAXIMIZED)
81
-				context.getWindow().restore();
86
+			if (surface.getContext().getWindow().getWindowState().getValue() == DUIWindow.State.MAXIMIZED)
87
+				surface.getContext().getWindow().restore();
82 88
 			else
83
-				context.getWindow().maximize();
89
+				surface.getContext().getWindow().maximize();
84 90
 		});
85 91
 		maximizeRestoreRelayout = maximizeRestore.getSizing().addListener((a, b) -> layout());
86
-		close = new WindowActionButton(scale -> new ScalableCloseIcon(scale), e -> context.getWindow().close());
92
+		close = new WindowActionButton(scale -> new ScalableCloseIcon(scale), e -> surface.getContext().getWindow().close());
87 93
 		closeRelayout = close.getSizing().addListener((a, b) -> layout());
88 94
 		
89 95
 		selectorButtons = new LiveMappedList<>(
@@ -91,8 +97,8 @@ public class AspectBarView extends BaseComponentGroup {
91 97
 				bar -> {
92 98
 					LiveBool buttonActive = new LivePredicateBool<>(aspectBar.active, activeBar -> activeBar == bar);
93 99
 					AspectBarSelectorButton button = new AspectBarSelectorButton(DStyleClass.EMPTY, bar.icon, buttonActive, bar.description, e -> aspectBar.active.setValue(bar));
94
-					if (context != null)
95
-						button.setContext(path, context);
100
+					if (surface != null)
101
+						button.setSurface(path, z + 1, surface);
96 102
 					
97 103
 					return button;
98 104
 				});
@@ -103,25 +109,35 @@ public class AspectBarView extends BaseComponentGroup {
103 109
 	}
104 110
 	
105 111
 	@Override
106
-	public void setContext(DStylePath parent, DUIContext context) {
107
-		this.context = context;
112
+	public void setSurface(DStylePath parent, int z, DDrawSurface surface) {
113
+		this.surface = surface;
114
+		this.z = z;
108 115
 		this.path = parent.getChild("aspectbar", styleClass);
109
-		this.style = new AspectBarStyle(context.getStylesheets().get(context, path));
110
-		activeToolbarTitleFontMetrics = context.getFontMetrics(style.activeToolbarTitleFont);
111
-		showWindowControls = !context.getWindow().hasTitleBar();
116
+		this.style = new AspectBarStyle(surface.getStylesheet(path));
117
+		
118
+		activeToolbarTitleFontMetrics = surface.getFontMetrics(style.activeToolbarTitleFont);
119
+		showWindowControls = !surface.getContext().getWindow().hasTitleBar();
112 120
 		
113 121
 		sizing.setValue(new DSizing(0, style.height));
114 122
 		
115 123
 		for (DComponent selectorButton : selectorButtons)
116
-			selectorButton.setContext(path, context);
124
+			selectorButton.setSurface(path, z + 2, surface);
117 125
 		
118 126
 		if (activeToolbarComponents != null)
119 127
 			for (DComponent component : activeToolbarComponents)
120
-				component.setContext(path, context);
128
+				component.setSurface(path, z + 2, surface);
129
+		
130
+		minimize.setSurface(path, z + 2, surface);
131
+		maximizeRestore.setSurface(path, z + 2, surface);
132
+		close.setSurface(path, z + 2, surface);
121 133
 		
122
-		minimize.setContext(path, context);
123
-		maximizeRestore.setContext(path, context);
124
-		close.setContext(path, context);
134
+		if (topBackground != null)
135
+			topBackground.close();
136
+		if (bottomBackground != null)
137
+			bottomBackground.close();
138
+		
139
+		topBackground = surface.fillRect(z, DIRectangle.EMPTY, style.backgroundColor);
140
+		bottomBackground = surface.fillRect(z, DIRectangle.EMPTY, style.backgroundColorBottom);
125 141
 	}
126 142
 	
127 143
 	@Override
@@ -143,17 +159,17 @@ public class AspectBarView extends BaseComponentGroup {
143 159
 	public void setBounds(DIRectangle bounds) {
144 160
 		this.bounds = bounds;
145 161
 		
146
-		if (context != null) {
162
+		if (surface != null) {
147 163
 			layout();
148
-			context.repaint(bounds);
164
+			surface.repaint(bounds);
149 165
 		}
150 166
 	}
151 167
 
152 168
 	@Override
153 169
 	public void paint(DCanvas canvas) {
154 170
 		canvas.pushBounds(bounds);
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);
171
+		//canvas.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height, style.backgroundColor);
172
+		//canvas.fillRectangle(bounds.x, bounds.y + bounds.height - style.marginBottom, bounds.width, style.marginBottom, style.backgroundColorBottom);
157 173
 		
158 174
 		for (DComponent button : selectorButtons) {
159 175
 			if (button.getBounds() == null)
@@ -162,11 +178,11 @@ public class AspectBarView extends BaseComponentGroup {
162 178
 			button.paint(canvas);
163 179
 		}
164 180
 		
165
-		canvas.shadowPath(
181
+		/*canvas.shadowPath(
166 182
 				aspectBarShape,
167 183
 				DTransform2D.IDENTITY,
168 184
 				style.foregroundColor,
169
-				style.aspectBarShadow);
185
+				style.aspectBarShadow);*/
170 186
 		
171 187
 		if (aspectBar.active.getValue() != null) {
172 188
 			int y = bounds.y
@@ -201,6 +217,9 @@ public class AspectBarView extends BaseComponentGroup {
201 217
 	@Override
202 218
 	public void close() {
203 219
 		listener.close();
220
+		
221
+		topBackground.close();
222
+		bottomBackground.close();
204 223
 	}
205 224
 	
206 225
 	private void onActiveChanged(IDEAspectToolbar previous, IDEAspectToolbar aspectBar) {
@@ -209,8 +228,8 @@ public class AspectBarView extends BaseComponentGroup {
209 228
 		
210 229
 		activeToolbarComponents = new LiveMappedList<>(aspectBar.controls, control -> {
211 230
 			DComponent result = control.instantiate();
212
-			if (context != null)
213
-				result.setContext(path, context);
231
+			if (surface != null)
232
+				result.setSurface(path, z + 2, surface);
214 233
 			return result;
215 234
 		});
216 235
 		
@@ -221,6 +240,9 @@ public class AspectBarView extends BaseComponentGroup {
221 240
 		if (bounds == null)
222 241
 			return;
223 242
 		
243
+		topBackground.setRectangle(new DIRectangle(bounds.x, bounds.y, bounds.width, bounds.height - style.marginBottom));
244
+		bottomBackground.setRectangle(new DIRectangle(bounds.x, bounds.y + bounds.height - style.marginBottom, bounds.width, style.marginBottom));
245
+		
224 246
 		layoutAspectSelectorButtons();
225 247
 		layoutActiveToolbarComponents();
226 248
 		
@@ -237,7 +259,7 @@ public class AspectBarView extends BaseComponentGroup {
237 259
 		minimize.setBounds(new DIRectangle(x, bounds.y, minimizeSize.preferredWidth, minimizeSize.preferredHeight));
238 260
 		
239 261
 		calculateAspectBarShape();
240
-		context.repaint(bounds);
262
+		surface.repaint(bounds);
241 263
 	}
242 264
 	
243 265
 	private void layoutAspectSelectorButtons() {
@@ -277,7 +299,7 @@ public class AspectBarView extends BaseComponentGroup {
277 299
 			x += width;
278 300
 		}
279 301
 		
280
-		context.repaint(bounds);
302
+		surface.repaint(bounds);
281 303
 	}
282 304
 
283 305
 	@Override
@@ -324,23 +346,26 @@ public class AspectBarView extends BaseComponentGroup {
324 346
 	private void calculateAspectBarShape() {
325 347
 		int toX = aspectSelectorEndX;
326 348
 		
327
-		aspectBarShape = tracer -> {
349
+		if (aspectBarShape != null)
350
+			aspectBarShape.close();
351
+		
352
+		aspectBarShape = surface.shadowPath(z + 1, tracer -> {
328 353
 			int height = bounds.height - style.marginBottom;
329 354
 			int baseY = bounds.y + height - style.aspectSelectorBottomSize;
330 355
 			int barBaseX = toX + style.aspectSelectorToToolbarSpacing;
331 356
 			int barBaseY = bounds.y + style.aspectBarPaddingTop;
332 357
 			
333 358
 			tracer.moveTo(bounds.x, baseY);
334
-			tracer.lineTo(toX - 3 * context.getScale(), baseY);
359
+			tracer.lineTo(toX - 3 * surface.getScale(), baseY);
335 360
 			tracer.bezierCubic(
336
-					toX + 0 * context.getScale(), baseY,
337
-					toX + 2 * context.getScale(), baseY,
338
-					toX + 3.5f * context.getScale(), baseY - 4 * context.getScale());
339
-			tracer.lineTo(barBaseX - 3.5f * context.getScale(), barBaseY + 4 * context.getScale());
361
+					toX + 0 * surface.getScale(), baseY,
362
+					toX + 2 * surface.getScale(), baseY,
363
+					toX + 3.5f * surface.getScale(), baseY - 4 * surface.getScale());
364
+			tracer.lineTo(barBaseX - 3.5f * surface.getScale(), barBaseY + 4 * surface.getScale());
340 365
 			tracer.bezierCubic(
341
-					barBaseX - 2 * context.getScale(), barBaseY,
342
-					barBaseX - 0 * context.getScale(), barBaseY,
343
-					barBaseX + 3 * context.getScale(), barBaseY);
366
+					barBaseX - 2 * surface.getScale(), barBaseY,
367
+					barBaseX - 0 * surface.getScale(), barBaseY,
368
+					barBaseX + 3 * surface.getScale(), barBaseY);
344 369
 			
345 370
 			if (showWindowControls) {
346 371
 				int spacingLeft = style.windowControlSpacingLeft;
@@ -357,7 +382,7 @@ public class AspectBarView extends BaseComponentGroup {
357 382
 			tracer.lineTo(bounds.x + bounds.width, bounds.y + height);
358 383
 			tracer.lineTo(bounds.x, bounds.y + height);
359 384
 			tracer.close();
360
-		};
385
+		}, DTransform2D.IDENTITY, style.foregroundColor, style.aspectBarShadow);
361 386
 		
362 387
 		if (showWindowControls) {
363 388
 			DIRectangle minimizeBounds = minimize.getBounds();

+ 10
- 10
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/aspectbar/WindowActionButton.java Ver arquivo

@@ -13,8 +13,8 @@ import org.openzen.drawablegui.DComponent;
13 13
 import org.openzen.drawablegui.DSizing;
14 14
 import org.openzen.drawablegui.DMouseEvent;
15 15
 import org.openzen.drawablegui.DTransform2D;
16
-import org.openzen.drawablegui.DUIContext;
17 16
 import org.openzen.drawablegui.DIRectangle;
17
+import org.openzen.drawablegui.draw.DDrawSurface;
18 18
 import org.openzen.drawablegui.listeners.ListenerHandle;
19 19
 import org.openzen.drawablegui.live.LiveBool;
20 20
 import org.openzen.drawablegui.live.LiveObject;
@@ -39,7 +39,7 @@ public class WindowActionButton implements DComponent {
39 39
 	private DIRectangle bounds;
40 40
 	private boolean hover;
41 41
 	private boolean press;
42
-	private DUIContext context;
42
+	private DDrawSurface surface;
43 43
 	
44 44
 	public WindowActionButton(Function<Float, DColorableIcon> icon, Consumer<DMouseEvent> action) {
45 45
 		this.scalableIcon = icon;
@@ -47,16 +47,16 @@ public class WindowActionButton implements DComponent {
47 47
 	}
48 48
 
49 49
 	@Override
50
-	public void setContext(DStylePath parent, DUIContext context) {
51
-		this.context = context;
50
+	public void setSurface(DStylePath parent, int z, DDrawSurface surface) {
51
+		this.surface = surface;
52 52
 		
53
-		windowFocused = context.getWindow().getActive();
53
+		windowFocused = surface.getContext().getWindow().getActive();
54 54
 		windowFocusedListener = windowFocused.addListener((a, b) -> repaint());
55 55
 		
56
-		icon = scalableIcon == null ? null : scalableIcon.apply(context.getScale());
56
+		icon = scalableIcon == null ? null : scalableIcon.apply(surface.getScale());
57 57
 		sizing.setValue(new DSizing(
58
-				(int)(48 * context.getScale()),
59
-				(int)(24 * context.getScale())));
58
+				(int)(48 * surface.getScale()),
59
+				(int)(24 * surface.getScale())));
60 60
 	}
61 61
 
62 62
 	@Override
@@ -139,9 +139,9 @@ public class WindowActionButton implements DComponent {
139 139
 	}
140 140
 	
141 141
 	private void repaint() {
142
-		if (context == null)
142
+		if (surface == null)
143 143
 			return;
144 144
 		
145
-		context.repaint(bounds);
145
+		surface.repaint(bounds);
146 146
 	}
147 147
 }

+ 34
- 21
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/editor/SourceEditor.java Ver arquivo

@@ -28,6 +28,8 @@ import org.openzen.zenscript.lexer.ZSToken;
28 28
 import org.openzen.zenscript.lexer.ZSTokenParser;
29 29
 import org.openzen.zenscript.lexer.ZSTokenType;
30 30
 import org.openzen.drawablegui.DUIContext;
31
+import org.openzen.drawablegui.draw.DDrawSurface;
32
+import org.openzen.drawablegui.draw.DDrawnRectangle;
31 33
 import org.openzen.drawablegui.live.ImmutableLiveString;
32 34
 import org.openzen.drawablegui.live.InverseLiveBool;
33 35
 import org.openzen.drawablegui.live.LiveBool;
@@ -55,7 +57,8 @@ public class SourceEditor implements DComponent {
55 57
 	private final SimpleLiveBool unchanged = new SimpleLiveBool(true);
56 58
 	
57 59
 	private DIRectangle bounds;
58
-	private DUIContext context;
60
+	private int z;
61
+	private DDrawSurface surface;
59 62
 	private SourceEditorStyle style;
60 63
 	private DTimerHandle blinkTimer;
61 64
 	
@@ -79,6 +82,9 @@ public class SourceEditor implements DComponent {
79 82
 	
80 83
 	private final LiveBool updated;
81 84
 	
85
+	private DDrawnRectangle background;
86
+	private DDrawnRectangle lineBarBackground;
87
+	
82 88
 	public SourceEditor(DStyleClass styleClass, IDEWindow window, IDESourceFile sourceFile) {
83 89
 		this.styleClass = styleClass;
84 90
 		this.window = window;
@@ -125,11 +131,12 @@ public class SourceEditor implements DComponent {
125 131
 	}
126 132
 
127 133
 	@Override
128
-	public void setContext(DStylePath parent, DUIContext context) {
129
-		this.context = context;
130
-		this.style = new SourceEditorStyle(context.getStylesheets().get(context, parent.getChild("sourceeditor", styleClass)));
134
+	public void setSurface(DStylePath parent, int z, DDrawSurface surface) {
135
+		this.surface = surface;
136
+		this.z = z;
137
+		this.style = new SourceEditorStyle(surface.getStylesheet(parent.getChild("sourceeditor", styleClass)));
131 138
 		
132
-		fontMetrics = context.getFontMetrics(font);
139
+		fontMetrics = surface.getFontMetrics(font);
133 140
 		textLineHeight = fontMetrics.getAscent() + fontMetrics.getDescent();
134 141
 		fullLineHeight = textLineHeight + fontMetrics.getLeading() + style.extraLineSpacing;
135 142
 		selectionLineHeight = textLineHeight + style.selectionPaddingTop + style.selectionPaddingBottom;
@@ -138,7 +145,7 @@ public class SourceEditor implements DComponent {
138 145
 		
139 146
 		if (blinkTimer != null)
140 147
 			blinkTimer.close();
141
-		blinkTimer = context.setTimer(300, this::blink);
148
+		blinkTimer = surface.getContext().setTimer(300, this::blink);
142 149
 	}
143 150
 
144 151
 	@Override
@@ -159,17 +166,23 @@ public class SourceEditor implements DComponent {
159 166
 	@Override
160 167
 	public void setBounds(DIRectangle bounds) {
161 168
 		this.bounds = bounds;
169
+		
170
+		lineBarWidth = Math.max(style.lineBarMinWidth, fontMetrics.getWidth(Integer.toString(tokens.getLineCount())))
171
+				+ style.lineBarSpacingLeft
172
+				+ style.lineBarSpacingRight;
173
+		
174
+		if (background != null)
175
+			background.close();
176
+		if (lineBarBackground != null)
177
+			lineBarBackground.close();
178
+		background = surface.fillRect(z, new DIRectangle(bounds.x + lineBarWidth, bounds.y, bounds.width - lineBarWidth, bounds.height), style.backgroundColor);
179
+		lineBarBackground = surface.fillRect(z, new DIRectangle(bounds.x, bounds.y, lineBarWidth, bounds.height), style.lineBarBackgroundColor);
162 180
 	}
163 181
 
164 182
 	@Override
165 183
 	public void paint(DCanvas canvas) {
166 184
 		DIRectangle canvasBounds = canvas.getBounds();
167
-		canvas.fillRectangle(bounds.x, bounds.y, bounds.width, bounds.height, style.backgroundColor);
168 185
 		
169
-		lineBarWidth = Math.max(style.lineBarMinWidth, fontMetrics.getWidth(Integer.toString(tokens.getLineCount())))
170
-				+ style.lineBarSpacingLeft
171
-				+ style.lineBarSpacingRight;
172
-		canvas.fillRectangle(bounds.x, bounds.y, lineBarWidth, bounds.height, style.lineBarBackgroundColor);
173 186
 		if (style.lineBarStrokeWidth > 0) {
174 187
 			canvas.strokePath(tracer -> {
175 188
 				tracer.moveTo(bounds.x + lineBarWidth, bounds.y);
@@ -234,17 +247,17 @@ public class SourceEditor implements DComponent {
234 247
 	
235 248
 	@Override
236 249
 	public void onMouseEnter(DMouseEvent e) {
237
-		context.setCursor(DUIContext.Cursor.TEXT);
250
+		surface.getContext().setCursor(DUIContext.Cursor.TEXT);
238 251
 	}
239 252
 	
240 253
 	@Override
241 254
 	public void onMouseExit(DMouseEvent e) {
242
-		context.setCursor(DUIContext.Cursor.NORMAL);
255
+		surface.getContext().setCursor(DUIContext.Cursor.NORMAL);
243 256
 	}
244 257
 	
245 258
 	@Override
246 259
 	public void onMouseClick(DMouseEvent e) {
247
-		context.getWindow().focus(this);
260
+		surface.getContext().getWindow().focus(this);
248 261
 		
249 262
 		SourcePosition position = getPositionAt(e.x, e.y);
250 263
 		if (e.isDoubleClick()) {
@@ -404,7 +417,7 @@ public class SourceEditor implements DComponent {
404 417
 		String extract = tokens.extract(
405 418
 				SourcePosition.min(cursorStart, cursorEnd),
406 419
 				SourcePosition.max(cursorStart, cursorEnd));
407
-		context.getClipboard().copyAsString(extract);
420
+		surface.getContext().getClipboard().copyAsString(extract);
408 421
 	}
409 422
 	
410 423
 	private void cut() {
@@ -417,7 +430,7 @@ public class SourceEditor implements DComponent {
417 430
 	}
418 431
 	
419 432
 	private void paste() {
420
-		String text = context.getClipboard().getAsString();
433
+		String text = surface.getContext().getClipboard().getAsString();
421 434
 		if (text == null)
422 435
 			return;
423 436
 		
@@ -550,11 +563,11 @@ public class SourceEditor implements DComponent {
550 563
 			int x2 = getX(to);
551 564
 			int fromX = Math.min(x1, x2);
552 565
 			int toX = Math.max(x1, x2) + 2;
553
-			context.repaint(fromX, y, toX - fromX, selectionLineHeight);
566
+			surface.repaint(fromX, y, toX - fromX, selectionLineHeight);
554 567
 		} else {
555 568
 			int fromY = lineToY(Math.min(from.line, to.line));
556 569
 			int toY = lineToY(Math.max(from.line, to.line) + 1);
557
-			context.repaint(bounds.x, fromY, bounds.width, toY - fromY);
570
+			surface.repaint(bounds.x, fromY, bounds.width, toY - fromY);
558 571
 		}
559 572
 	}
560 573
 	
@@ -562,11 +575,11 @@ public class SourceEditor implements DComponent {
562 575
 		if (bounds == null)
563 576
 			return;
564 577
 		
565
-		context.repaint(bounds.x, lineToY(line), bounds.width, selectionLineHeight);
578
+		surface.repaint(bounds.x, lineToY(line), bounds.width, selectionLineHeight);
566 579
 	}
567 580
 	
568 581
 	public void scrollTo(SourcePosition position) {
569
-		context.scrollInView(getX(position), getY(position), 2, selectionLineHeight);
582
+		surface.getContext().scrollInView(getX(position), getY(position), 2, selectionLineHeight);
570 583
 	}
571 584
 	
572 585
 	private void blink() {
@@ -661,7 +674,7 @@ public class SourceEditor implements DComponent {
661 674
 		sizing.setValue(new DSizing(0, fullLineHeight * tokens.getLineCount()));
662 675
 		
663 676
 		if (bounds != null)
664
-			context.repaint(bounds);
677
+			surface.repaint(bounds);
665 678
 	}
666 679
 	
667 680
 	private class TokenListener implements TokenModel.Listener {

+ 5
- 6
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/output/OutputView.java Ver arquivo

@@ -11,9 +11,8 @@ import org.openzen.drawablegui.DIRectangle;
11 11
 import org.openzen.drawablegui.DPath;
12 12
 import org.openzen.drawablegui.DSizing;
13 13
 import org.openzen.drawablegui.DTransform2D;
14
-import org.openzen.drawablegui.DUIContext;
14
+import org.openzen.drawablegui.draw.DDrawSurface;
15 15
 import org.openzen.drawablegui.live.LiveList;
16
-import org.openzen.drawablegui.live.LiveObject;
17 16
 import org.openzen.drawablegui.live.MutableLiveObject;
18 17
 import org.openzen.drawablegui.style.DStyleClass;
19 18
 import org.openzen.drawablegui.style.DStylePath;
@@ -27,7 +26,7 @@ public class OutputView implements DComponent {
27 26
 	private final DStyleClass styleClass;
28 27
 	private final LiveList<OutputLine> lines;
29 28
 	
30
-	private DUIContext context;
29
+	private DDrawSurface surface;
31 30
 	private DIRectangle bounds;
32 31
 	private DPath shape;
33 32
 	private OutputViewStyle style;
@@ -38,11 +37,11 @@ public class OutputView implements DComponent {
38 37
 	}
39 38
 
40 39
 	@Override
41
-	public void setContext(DStylePath parent, DUIContext context) {
42
-		this.context = context;
40
+	public void setSurface(DStylePath parent, int z, DDrawSurface surface) {
41
+		this.surface = surface;
43 42
 		
44 43
 		DStylePath path = parent.getChild("outputview", styleClass);
45
-		style = new OutputViewStyle(context.getStylesheets().get(context, path));
44
+		style = new OutputViewStyle(surface.getStylesheet(path));
46 45
 	}
47 46
 
48 47
 	@Override

+ 5
- 1
IDE/src/main/java/org/openzen/zenscript/ide/ui/view/project/ProjectBrowser.java Ver arquivo

@@ -25,8 +25,10 @@ import org.openzen.drawablegui.style.DRoundedRectangleShape;
25 25
 import org.openzen.drawablegui.style.DShadow;
26 26
 import org.openzen.drawablegui.style.DStyleClass;
27 27
 import org.openzen.drawablegui.style.DStylesheetBuilder;
28
+import org.openzen.drawablegui.tree.CollapsedArrow;
28 29
 import org.openzen.drawablegui.tree.DTreeView;
29 30
 import org.openzen.drawablegui.tree.DTreeViewStyle;
31
+import org.openzen.drawablegui.tree.ExpandedArrow;
30 32
 import org.openzen.zenscript.ide.host.DevelopmentHost;
31 33
 import org.openzen.zenscript.ide.host.IDEModule;
32 34
 import org.openzen.zenscript.ide.host.IDEPackage;
@@ -92,7 +94,9 @@ public class ProjectBrowser {
92 94
 				new Element(addPackageButton, 0, 0, ElementAlignment.TOP),
93 95
 				new Element(addFileButton, 0, 0, ElementAlignment.TOP));
94 96
 		DTreeView projectTree = new DTreeView(
95
-				DTreeViewStyle.DEFAULT,
97
+				DStyleClass.EMPTY,
98
+				ExpandedArrow.INSTANCE,
99
+				CollapsedArrow.INSTANCE,
96 100
 				new RootTreeNode(this, host), false);
97 101
 		projectTree.getSizing().setValue(new DSizing(500, 500));
98 102
 		DScrollPane treeScrollPane = new DScrollPane(

Carregando…
Cancelar
Salvar