Parcourir la source

Changed scaling for tree view icons.

Stan Hebben il y a 6 ans
Parent
révision
1f77d3080b

+ 4
- 2
DrawableGui/src/main/java/org/openzen/drawablegui/tree/DTreeView.java Voir le fichier

@@ -37,6 +37,7 @@ public class DTreeView<N extends DTreeNode<N>> implements DComponent {
37 37
 	
38 38
 	private DComponentContext context;
39 39
 	private DIRectangle bounds = DIRectangle.EMPTY;
40
+	private float iconScale;
40 41
 	
41 42
 	private int selectedRow = -1;
42 43
 	private N selectedNode = null;
@@ -75,6 +76,7 @@ public class DTreeView<N extends DTreeNode<N>> implements DComponent {
75 76
 		context = parent.getChildContext("tree", styleClass);
76 77
 		style = context.getStyle(DTreeViewStyle::new);
77 78
 		fontMetrics = context.getFontMetrics(style.font);
79
+		iconScale = context.getUIContext().getScale() / 1.75f;
78 80
 		
79 81
 		background = context.fillRect(0, DIRectangle.EMPTY, style.backgroundColor);
80 82
 		selectedBackground = context.fillRect(1, DIRectangle.EMPTY, 0);
@@ -263,7 +265,7 @@ public class DTreeView<N extends DTreeNode<N>> implements DComponent {
263 265
 					context.surface,
264 266
 					context.z + 2,
265 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 269
 					node == selectedNode ? style.selectedNodeTextColor : style.nodeTextColor);
268 270
 			
269 271
 			if (!node.isLeaf())
@@ -271,7 +273,7 @@ public class DTreeView<N extends DTreeNode<N>> implements DComponent {
271 273
 						context.surface, 
272 274
 						context.z + 2,
273 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 278
 			text = context.drawText(
277 279
 					2,

Loading…
Annuler
Enregistrer