Browse Source

Changed scaling for tree view icons.

Stan Hebben 6 years ago
parent
commit
1f77d3080b

+ 4
- 2
DrawableGui/src/main/java/org/openzen/drawablegui/tree/DTreeView.java View File

37
 	
37
 	
38
 	private DComponentContext context;
38
 	private DComponentContext context;
39
 	private DIRectangle bounds = DIRectangle.EMPTY;
39
 	private DIRectangle bounds = DIRectangle.EMPTY;
40
+	private float iconScale;
40
 	
41
 	
41
 	private int selectedRow = -1;
42
 	private int selectedRow = -1;
42
 	private N selectedNode = null;
43
 	private N selectedNode = null;
75
 		context = parent.getChildContext("tree", styleClass);
76
 		context = parent.getChildContext("tree", styleClass);
76
 		style = context.getStyle(DTreeViewStyle::new);
77
 		style = context.getStyle(DTreeViewStyle::new);
77
 		fontMetrics = context.getFontMetrics(style.font);
78
 		fontMetrics = context.getFontMetrics(style.font);
79
+		iconScale = context.getUIContext().getScale() / 1.75f;
78
 		
80
 		
79
 		background = context.fillRect(0, DIRectangle.EMPTY, style.backgroundColor);
81
 		background = context.fillRect(0, DIRectangle.EMPTY, style.backgroundColor);
80
 		selectedBackground = context.fillRect(1, DIRectangle.EMPTY, 0);
82
 		selectedBackground = context.fillRect(1, DIRectangle.EMPTY, 0);
263
 					context.surface,
265
 					context.surface,
264
 					context.z + 2,
266
 					context.z + 2,
265
 					node.getIcon(),
267
 					node.getIcon(),
266
-					DTransform2D.translate(baseX + icon.getNominalWidth() + style.iconTextSpacing, baseY + fontMetrics.getAscent() + fontMetrics.getDescent() - icon.getNominalHeight()),
268
+					DTransform2D.scaleAndTranslate(baseX + icon.getNominalWidth() + style.iconTextSpacing, baseY + fontMetrics.getAscent() + fontMetrics.getDescent() - icon.getNominalHeight(), iconScale),
267
 					node == selectedNode ? style.selectedNodeTextColor : style.nodeTextColor);
269
 					node == selectedNode ? style.selectedNodeTextColor : style.nodeTextColor);
268
 			
270
 			
269
 			if (!node.isLeaf())
271
 			if (!node.isLeaf())
271
 						context.surface, 
273
 						context.surface, 
272
 						context.z + 2,
274
 						context.z + 2,
273
 						icon,
275
 						icon,
274
-						DTransform2D.translate(baseX, baseY + fontMetrics.getAscent() + fontMetrics.getDescent() - icon.getNominalHeight()));
276
+						DTransform2D.scaleAndTranslate(baseX, baseY + fontMetrics.getAscent() + fontMetrics.getDescent() - icon.getNominalHeight(), iconScale));
275
 			
277
 			
276
 			text = context.drawText(
278
 			text = context.drawText(
277
 					2,
279
 					2,

Loading…
Cancel
Save