ソースを参照

Merge remote-tracking branch 'Stan/development' into development

kindlich 6年前
コミット
9f38fe453f
この署名に対応する既知のキーがデータベースに存在しません

+ 26
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/DTooltip.java ファイルの表示

@@ -0,0 +1,26 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.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 ファイルの表示

@@ -0,0 +1,14 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.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 ファイルの表示

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

+ 29
- 6
DrawableGui/src/main/java/org/openzen/drawablegui/scroll/DScrollPane.java ファイルの表示

@@ -15,6 +15,8 @@ import org.openzen.drawablegui.DFontMetrics;
15 15
 import org.openzen.drawablegui.DIRectangle;
16 16
 import org.openzen.drawablegui.DMouseEvent;
17 17
 import org.openzen.drawablegui.DTimerHandle;
18
+import org.openzen.drawablegui.DTooltip;
19
+import org.openzen.drawablegui.DTooltipHandle;
18 20
 import org.openzen.drawablegui.listeners.ListenerHandle;
19 21
 import org.openzen.drawablegui.live.LiveInt;
20 22
 import org.openzen.drawablegui.live.LiveObject;
@@ -231,12 +233,28 @@ public class DScrollPane implements DComponent {
231 233
 	private DMouseEvent translateMouseEvent(DMouseEvent e) {
232 234
 		return new DMouseEvent(
233 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 238
 				e.modifiers,
237 239
 				e.deltaZ,
238 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 259
 	private class TranslatedContext implements DUIContext {
242 260
 		
@@ -257,8 +275,8 @@ public class DScrollPane implements DComponent {
257 275
 
258 276
 		@Override
259 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 280
 			int right = left + width;
263 281
 			int bottom = top + height;
264 282
 			
@@ -308,12 +326,17 @@ public class DScrollPane implements DComponent {
308 326
 
309 327
 		@Override
310 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 332
 		@Override
315 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 ファイルの表示

@@ -21,6 +21,8 @@ import org.openzen.drawablegui.DFont;
21 21
 import org.openzen.drawablegui.DFontMetrics;
22 22
 import org.openzen.drawablegui.DPathTracer;
23 23
 import org.openzen.drawablegui.DTimerHandle;
24
+import org.openzen.drawablegui.DTooltip;
25
+import org.openzen.drawablegui.DTooltipHandle;
24 26
 import org.openzen.drawablegui.DUIContext;
25 27
 import org.openzen.drawablegui.DUIWindow;
26 28
 import org.openzen.drawablegui.style.DStylePathRoot;
@@ -187,6 +189,11 @@ public class SwingGraphicsContext implements DUIContext {
187 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 197
 	private class PathTracer implements DPathTracer {
191 198
 		private final GeneralPath path;
192 199
 		

+ 32
- 0
DrawableGui/src/main/java/org/openzen/drawablegui/swing/SwingTooltipWindow.java ファイルの表示

@@ -0,0 +1,32 @@
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 ファイルの表示

@@ -78,8 +78,7 @@ public class ParsedExpressionFunction extends ParsedExpression {
78 78
 		}
79 79
 		
80 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 84
 	@Override

読み込み中…
キャンセル
保存