@@ -22,52 +22,49 @@ public class TransformContainer extends DropdownContainer {
2222 @ Getter
2323 private final ObjectOrEvent object ;
2424
25- private final PositionPicker xPosition , yPosition ;
26- private final PositionPicker xScale , yScale ;
27- private final PositionPicker xRotation , yRotation , zRotation ;
28- private final PositionPicker xPivot , yPivot ;
25+ private final FixedSizePicker xPosition , yPosition ;
26+ private final FixedSizePicker xScale , yScale ;
27+ private final FixedSizePicker xRotation , yRotation , zRotation ;
28+ private final FixedSizePicker xPivot , yPivot ;
2929
3030 public TransformContainer (ObjectOrEvent object ) {
3131 super ("Transforms" , new GridLayout (10 , 5 ));
3232
3333 this .object = object ;
3434
35- container .addChild (new Label ("Position X" ). scale ( 0.8f ). horizontalOrigin ( TextOrigin . Horizontal . VISUAL_LEFT ) , c -> c .layoutOptions (new GridOptions (0 , 0 ). withAnchor ( GridAnchor . LEFT )));
36- container .addChild (new Label ("Position Y" ). scale ( 0.8f ). horizontalOrigin ( TextOrigin . Horizontal . VISUAL_LEFT ) , c -> c .layoutOptions (new GridOptions (0 , 1 ). withAnchor ( GridAnchor . LEFT )));
35+ container .addChild (label ("Position X" ), c -> c .layoutOptions (leftGrid (0 , 0 )));
36+ container .addChild (label ("Position Y" ), c -> c .layoutOptions (leftGrid (0 , 1 )));
3737
3838 Vec2 position = (Vec2 ) object .transformations ().getOrDefault (ObjectTransform .POSITION , new Vec2 (0 , 0 ));
3939
40- container .addChild (xPosition = new PositionPicker (-10000.0 , 10000.0 , 5 , position .x ()), c -> c .layoutOptions (new GridOptions (1 , 0 )));
41- container .addChild (yPosition = new PositionPicker (-10000.0 , 10000.0 , 5 , position .y ()), c -> c .layoutOptions (new GridOptions (1 , 1 )));
40+ container .addChild (xPosition = new FixedSizePicker (-10000.0 , 10000.0 , 5 , position .x ()), c -> c .layoutOptions (grid (1 , 0 )));
41+ container .addChild (yPosition = new FixedSizePicker (-10000.0 , 10000.0 , 5 , position .y ()), c -> c .layoutOptions (grid (1 , 1 )));
4242
43- container .addChild (new Label ("Scale X" ).scale (0.8f ).horizontalOrigin (TextOrigin .Horizontal .VISUAL_LEFT ),
44- c -> c .layoutOptions (new GridOptions (0 , 3 ).withAnchor (GridAnchor .LEFT ).withPadding (new Padding (0 , 5 , 0 , 0 ))));
45- container .addChild (new Label ("Scale Y" ).scale (0.8f ).horizontalOrigin (TextOrigin .Horizontal .VISUAL_LEFT ), c -> c .layoutOptions (new GridOptions (0 , 4 ).withAnchor (GridAnchor .LEFT )));
43+ container .addChild (label ("Scale X" ), c -> c .layoutOptions (leftGrid (0 , 3 ).withPadding (new Padding (0 , 5 , 0 , 0 ))));
44+ container .addChild (label ("Scale Y" ), c -> c .layoutOptions (leftGrid (0 , 4 )));
4645
4746 Vec2 scale = (Vec2 ) object .transformations ().getOrDefault (ObjectTransform .SCALE , new Vec2 (1 , 1 ));
4847
49- container .addChild (xScale = new PositionPicker (0 , 1000 , 1 , scale .x ()), c -> c .layoutOptions (new GridOptions (1 , 3 ).withPadding (new Padding (0 , 5 , 0 , 0 ))));
50- container .addChild (yScale = new PositionPicker (0 , 1000 , 1 , scale .y ()), c -> c .layoutOptions (new GridOptions (1 , 4 )));
48+ container .addChild (xScale = new FixedSizePicker (0 , 1000 , 1 , scale .x ()), c -> c .layoutOptions (grid (1 , 3 ).withPadding (new Padding (0 , 5 , 0 , 0 ))));
49+ container .addChild (yScale = new FixedSizePicker (0 , 1000 , 1 , scale .y ()), c -> c .layoutOptions (grid (1 , 4 )));
5150
52- container .addChild (new Label ("Rotation X" ).scale (0.8f ).horizontalOrigin (TextOrigin .Horizontal .VISUAL_LEFT ),
53- c -> c .layoutOptions (new GridOptions (0 , 5 ).withAnchor (GridAnchor .LEFT ).withPadding (new Padding (0 , 5 , 0 , 0 ))));
54- container .addChild (new Label ("Rotation Y" ).scale (0.8f ).horizontalOrigin (TextOrigin .Horizontal .VISUAL_LEFT ), c -> c .layoutOptions (new GridOptions (0 , 6 ).withAnchor (GridAnchor .LEFT )));
55- container .addChild (new Label ("Rotation Z" ).scale (0.8f ).horizontalOrigin (TextOrigin .Horizontal .VISUAL_LEFT ), c -> c .layoutOptions (new GridOptions (0 , 7 ).withAnchor (GridAnchor .LEFT )));
51+ container .addChild (label ("Rotation X" ), c -> c .layoutOptions (leftGrid (0 , 5 ).withPadding (new Padding (0 , 5 , 0 , 0 ))));
52+ container .addChild (label ("Rotation Y" ), c -> c .layoutOptions (leftGrid (0 , 6 )));
53+ container .addChild (label ("Rotation Z" ), c -> c .layoutOptions (leftGrid (0 , 7 )));
5654
5755 Vec3 rotation = (Vec3 ) object .transformations ().getOrDefault (ObjectTransform .ROTATE , new Vec3 (0 , 0 , 0 ));
5856
59- container .addChild (xRotation = new PositionPicker (-360 , 360 , 1 , rotation .x ()), c -> c .layoutOptions (new GridOptions (1 , 5 ).withPadding (new Padding (0 , 5 , 0 , 0 ))));
60- container .addChild (yRotation = new PositionPicker (-360 , 360 , 1 , rotation .y ()), c -> c .layoutOptions (new GridOptions (1 , 6 )));
61- container .addChild (zRotation = new PositionPicker (-360 , 360 , 1 , rotation .z ()), c -> c .layoutOptions (new GridOptions (1 , 7 )));
57+ container .addChild (xRotation = new FixedSizePicker (-360 , 360 , 1 , rotation .x ()), c -> c .layoutOptions (grid (1 , 5 ).withPadding (new Padding (0 , 5 , 0 , 0 ))));
58+ container .addChild (yRotation = new FixedSizePicker (-360 , 360 , 1 , rotation .y ()), c -> c .layoutOptions (grid (1 , 6 )));
59+ container .addChild (zRotation = new FixedSizePicker (-360 , 360 , 1 , rotation .z ()), c -> c .layoutOptions (grid (1 , 7 )));
6260
63- container .addChild (new Label ("Pivot X" ).scale (0.8f ).horizontalOrigin (TextOrigin .Horizontal .VISUAL_LEFT ),
64- c -> c .layoutOptions (new GridOptions (0 , 8 ).withAnchor (GridAnchor .LEFT ).withPadding (new Padding (0 , 5 , 0 , 0 ))));
65- container .addChild (new Label ("Pivot Y" ).scale (0.8f ).horizontalOrigin (TextOrigin .Horizontal .VISUAL_LEFT ), c -> c .layoutOptions (new GridOptions (0 , 9 ).withAnchor (GridAnchor .LEFT )));
61+ container .addChild (label ("Pivot X" ), c -> c .layoutOptions (leftGrid (0 , 8 ).withPadding (new Padding (0 , 5 , 0 , 0 ))));
62+ container .addChild (label ("Pivot Y" ), c -> c .layoutOptions (leftGrid (0 , 9 )));
6663
6764 Vec2 pivot = (Vec2 ) object .transformations ().getOrDefault (ObjectTransform .PIVOT , new Vec2 (0 , 0 ));
6865
69- container .addChild (xPivot = new PositionPicker (-10000.0 , 10000.0 , 5 , pivot .x ()), c -> c .layoutOptions (new GridOptions (1 , 8 ).withPadding (new Padding (0 , 5 , 0 , 0 ))));
70- container .addChild (yPivot = new PositionPicker (-10000.0 , 10000.0 , 5 , pivot .y ()), c -> c .layoutOptions (new GridOptions (1 , 9 )));
66+ container .addChild (xPivot = new FixedSizePicker (-10000.0 , 10000.0 , 5 , pivot .x ()), c -> c .layoutOptions (grid (1 , 8 ).withPadding (new Padding (0 , 5 , 0 , 0 ))));
67+ container .addChild (yPivot = new FixedSizePicker (-10000.0 , 10000.0 , 5 , pivot .y ()), c -> c .layoutOptions (grid (1 , 9 )));
7168 }
7269
7370 @ Override
@@ -95,14 +92,32 @@ public void render(Renderer renderer, Size size) {
9592 }
9693 }
9794
98- private static class PositionPicker extends NumberPicker {
99- public PositionPicker (double min , double max , double step , double value ) {
95+ private static class FixedSizePicker extends NumberPicker {
96+ public FixedSizePicker (double min , double max , double step , double value ) {
10097 super (min , max , step , value );
10198 }
10299
100+ @ Override
101+ protected void onComponentAdded () {
102+ super .onComponentAdded ();
103+ font (rivet ().backend ().font ().derive (14 ));
104+ }
105+
103106 @ Override
104107 public Size computeIdealSize (Size constraints ) {
105108 return super .computeIdealSize (constraints ).withWidth (constraints .width () - 60f );
106109 }
107110 }
111+
112+ private GridOptions leftGrid (int column , int row ) {
113+ return new GridOptions (column , row ).withAnchor (GridAnchor .LEFT );
114+ }
115+
116+ private GridOptions grid (int column , int row ) {
117+ return new GridOptions (column , row );
118+ }
119+
120+ private Label label (String string ) {
121+ return new Label (string ).scale (0.8f ).horizontalOrigin (TextOrigin .Horizontal .VISUAL_LEFT );
122+ }
108123}
0 commit comments