Browse Source

One more fix...

Stan Hebben 6 years ago
parent
commit
57b8ee27bf

+ 26
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/DTooltip.java View File

1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.drawablegui;
7
+
8
+import org.openzen.drawablegui.style.DStylePath;
9
+
10
+/**
11
+ *
12
+ * @author Hoofdgebruiker
13
+ */
14
+public interface DTooltip {
15
+	void setContext(DUIContext context, DStylePath parent);
16
+	
17
+	int getWidth();
18
+	
19
+	int getHeight();
20
+	
21
+	void setBounds(DIRectangle bounds);
22
+	
23
+	DIRectangle getBounds();
24
+	
25
+	void paint(DCanvas canvas);
26
+}

+ 14
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/DTooltipHandle.java View File

1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.drawablegui;
7
+
8
+/**
9
+ *
10
+ * @author Hoofdgebruiker
11
+ */
12
+public interface DTooltipHandle {
13
+	void close();
14
+}

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

40
 	
40
 	
41
 	DUIWindow openView(int x, int y, DAnchor anchor, DComponent root);
41
 	DUIWindow openView(int x, int y, DAnchor anchor, DComponent root);
42
 	
42
 	
43
+	DTooltipHandle openTooltip(int x, int y, DTooltip tooltip);
44
+	
43
 	default int dp(float dp) {
45
 	default int dp(float dp) {
44
 		return (int)(dp * getScale());
46
 		return (int)(dp * getScale());
45
 	}
47
 	}

+ 29
- 6
DrawableGui/src/main/java/org/openzen/drawablegui/scroll/DScrollPane.java View File

15
 import org.openzen.drawablegui.DIRectangle;
15
 import org.openzen.drawablegui.DIRectangle;
16
 import org.openzen.drawablegui.DMouseEvent;
16
 import org.openzen.drawablegui.DMouseEvent;
17
 import org.openzen.drawablegui.DTimerHandle;
17
 import org.openzen.drawablegui.DTimerHandle;
18
+import org.openzen.drawablegui.DTooltip;
19
+import org.openzen.drawablegui.DTooltipHandle;
18
 import org.openzen.drawablegui.listeners.ListenerHandle;
20
 import org.openzen.drawablegui.listeners.ListenerHandle;
19
 import org.openzen.drawablegui.live.LiveInt;
21
 import org.openzen.drawablegui.live.LiveInt;
20
 import org.openzen.drawablegui.live.LiveObject;
22
 import org.openzen.drawablegui.live.LiveObject;
231
 	private DMouseEvent translateMouseEvent(DMouseEvent e) {
233
 	private DMouseEvent translateMouseEvent(DMouseEvent e) {
232
 		return new DMouseEvent(
234
 		return new DMouseEvent(
233
 				e.window,
235
 				e.window,
234
-				e.x - bounds.x + offsetX.getValue(),
235
-				e.y - bounds.y + offsetY.getValue(),
236
+				toLocalX(e.x),
237
+				toLocalY(e.y),
236
 				e.modifiers,
238
 				e.modifiers,
237
 				e.deltaZ,
239
 				e.deltaZ,
238
 				e.clickCount);
240
 				e.clickCount);
239
 	}
241
 	}
242
+
243
+	private int toGlobalX(int x) {
244
+		return x + bounds.x - offsetX.getValue();
245
+	}
246
+
247
+	private int toGlobalY(int y) {
248
+		return y + bounds.y - offsetY.getValue();
249
+	}
250
+
251
+	private int toLocalX(int x) {
252
+		return x - bounds.x + offsetX.getValue();
253
+	}
254
+
255
+	private int toLocalY(int y) {
256
+		return y - bounds.y + offsetY.getValue();
257
+	}
240
 	
258
 	
241
 	private class TranslatedContext implements DUIContext {
259
 	private class TranslatedContext implements DUIContext {
242
 		
260
 		
257
 
275
 
258
 		@Override
276
 		@Override
259
 		public void repaint(int x, int y, int width, int height) {
277
 		public void repaint(int x, int y, int width, int height) {
260
-			int left = x + bounds.x - offsetX.getValue();
261
-			int top = y + bounds.y - offsetY.getValue();
278
+			int left = toGlobalX(x);
279
+			int top = toGlobalY(y);
262
 			int right = left + width;
280
 			int right = left + width;
263
 			int bottom = top + height;
281
 			int bottom = top + height;
264
 			
282
 			
308
 
326
 
309
 		@Override
327
 		@Override
310
 		public DUIWindow openDialog(int x, int y, DAnchor anchor, String title, DComponent root) {
328
 		public DUIWindow openDialog(int x, int y, DAnchor anchor, String title, DComponent root) {
311
-			return context.openDialog(x, y, anchor, title, root);
329
+			return context.openDialog(toGlobalX(x), toGlobalY(y), anchor, title, root);
312
 		}
330
 		}
313
 
331
 
314
 		@Override
332
 		@Override
315
 		public DUIWindow openView(int x, int y, DAnchor anchor, DComponent root) {
333
 		public DUIWindow openView(int x, int y, DAnchor anchor, DComponent root) {
316
-			return context.openView(x, y, anchor, root);
334
+			return context.openView(toGlobalX(x), toGlobalY(y), anchor, root);
335
+		}
336
+		
337
+		@Override
338
+		public DTooltipHandle openTooltip(int x, int y, DTooltip tooltip) {
339
+			return context.openTooltip(toGlobalX(x), toGlobalY(y), tooltip);
317
 		}
340
 		}
318
 	}
341
 	}
319
 	
342
 	

+ 7
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingGraphicsContext.java View File

21
 import org.openzen.drawablegui.DFontMetrics;
21
 import org.openzen.drawablegui.DFontMetrics;
22
 import org.openzen.drawablegui.DPathTracer;
22
 import org.openzen.drawablegui.DPathTracer;
23
 import org.openzen.drawablegui.DTimerHandle;
23
 import org.openzen.drawablegui.DTimerHandle;
24
+import org.openzen.drawablegui.DTooltip;
25
+import org.openzen.drawablegui.DTooltipHandle;
24
 import org.openzen.drawablegui.DUIContext;
26
 import org.openzen.drawablegui.DUIContext;
25
 import org.openzen.drawablegui.DUIWindow;
27
 import org.openzen.drawablegui.DUIWindow;
26
 import org.openzen.drawablegui.style.DStylePathRoot;
28
 import org.openzen.drawablegui.style.DStylePathRoot;
187
 		return window;
189
 		return window;
188
 	}
190
 	}
189
 	
191
 	
192
+	@Override
193
+	public DTooltipHandle openTooltip(int x, int y, DTooltip tooltip) {
194
+		return null; // TODO
195
+	}
196
+	
190
 	private class PathTracer implements DPathTracer {
197
 	private class PathTracer implements DPathTracer {
191
 		private final GeneralPath path;
198
 		private final GeneralPath path;
192
 		
199
 		

+ 32
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingTooltipWindow.java View File

1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.drawablegui.swing;
7
+
8
+import javax.swing.JWindow;
9
+import org.openzen.drawablegui.DComponent;
10
+import org.openzen.drawablegui.DTooltipHandle;
11
+import org.openzen.drawablegui.style.DStylePathRoot;
12
+
13
+/**
14
+ *
15
+ * @author Hoofdgebruiker
16
+ */
17
+public class SwingTooltipWindow extends JWindow implements DTooltipHandle {
18
+	private final SwingGraphicsContext context;
19
+	
20
+	public SwingTooltipWindow(SwingGraphicsContext parent, DComponent rootComponent) {
21
+		SwingRoot root = new SwingRoot(rootComponent);
22
+		context = new SwingGraphicsContext(parent.getStylesheets(), parent.getScale(), parent.getTextScale(), root);
23
+		rootComponent.setContext(DStylePathRoot.INSTANCE, context);
24
+		rootPane.add(root);
25
+		pack();
26
+	}
27
+	
28
+	@Override
29
+	public void close() {
30
+		dispose();
31
+	}
32
+}

+ 1
- 2
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpressionFunction.java View File

78
 		}
78
 		}
79
 		
79
 		
80
 		FunctionTypeID functionType = scope.getTypeRegistry().getFunction(genericHeader.withGenericArguments(new GenericMapper(scope.getTypeRegistry(), scope.genericInferenceMap)));
80
 		FunctionTypeID functionType = scope.getTypeRegistry().getFunction(genericHeader.withGenericArguments(new GenericMapper(scope.getTypeRegistry(), scope.genericInferenceMap)));
81
-		definedHeader = definedHeader.forLambda(functionType.header);
82
-		return new FunctionExpression(position, functionType, closure, definedHeader, statements);
81
+		return new FunctionExpression(position, functionType, closure, header, statements);
83
 	}
82
 	}
84
 	
83
 	
85
 	@Override
84
 	@Override

Loading…
Cancel
Save