Skip to content

Commit 16114d8

Browse files
committed
Fix label size so that it does not resize based on fontsize
If the fontsize was larger than the widget height then the Label widget woult increase the height to fit the fontsize. This was undesired behaviour and also not the behaviour of other widgets displaying text. Now we fix the label widget to be the size defined by the user and the text will be cropped if too large for the widget.
1 parent c3c0fa6 commit 16114d8

File tree

1 file changed

+9
-0
lines changed
  • app/display/representation-javafx/src/main/java/org/csstudio/display/builder/representation/javafx/widgets

1 file changed

+9
-0
lines changed

app/display/representation-javafx/src/main/java/org/csstudio/display/builder/representation/javafx/widgets/LabelRepresentation.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import javafx.geometry.Dimension2D;
1919
import javafx.geometry.Insets;
2020
import javafx.geometry.Pos;
21+
import javafx.scene.control.Control;
2122
import javafx.scene.control.Label;
2223
import javafx.scene.layout.Background;
2324
import javafx.scene.layout.BackgroundFill;
@@ -137,23 +138,31 @@ public void updateChanges()
137138
{
138139
case NONE:
139140
jfx_node.setPrefSize(width, height);
141+
jfx_node.setMinSize(Control.USE_PREF_SIZE, Control.USE_PREF_SIZE);
142+
jfx_node.setMaxSize(Control.USE_PREF_SIZE, Control.USE_PREF_SIZE);
140143
if (was_ever_transformed)
141144
jfx_node.getTransforms().clear();
142145
break;
143146
case NINETY:
144147
jfx_node.setPrefSize(height, width);
148+
jfx_node.setMinSize(Control.USE_PREF_SIZE, Control.USE_PREF_SIZE);
149+
jfx_node.setMaxSize(Control.USE_PREF_SIZE, Control.USE_PREF_SIZE);
145150
jfx_node.getTransforms().setAll(new Rotate(-rotation.getAngle()),
146151
new Translate(-height, 0));
147152
was_ever_transformed = true;
148153
break;
149154
case ONEEIGHTY:
150155
jfx_node.setPrefSize(width, height);
156+
jfx_node.setMinSize(Control.USE_PREF_SIZE, Control.USE_PREF_SIZE);
157+
jfx_node.setMaxSize(Control.USE_PREF_SIZE, Control.USE_PREF_SIZE);
151158
jfx_node.getTransforms().setAll(new Rotate(-rotation.getAngle()),
152159
new Translate(-width, -height));
153160
was_ever_transformed = true;
154161
break;
155162
case MINUS_NINETY:
156163
jfx_node.setPrefSize(height, width);
164+
jfx_node.setMinSize(Control.USE_PREF_SIZE, Control.USE_PREF_SIZE);
165+
jfx_node.setMaxSize(Control.USE_PREF_SIZE, Control.USE_PREF_SIZE);
157166
jfx_node.getTransforms().setAll(new Rotate(-rotation.getAngle()),
158167
new Translate(0, -width));
159168
was_ever_transformed = true;

0 commit comments

Comments
 (0)