@@ -188,19 +188,25 @@ open class FXGLDefaultMenu(type: MenuType) : FXGLMenu(type) {
188
188
}
189
189
190
190
private fun createTitleView (title : String ): Node {
191
- val text = getUIFactoryService().newText(title.substring(0 , 1 ), 50.0 )
192
- text .fill = null
193
- text .strokeProperty().bind(titleColor)
194
- text .strokeWidth = 1.5
191
+ val firstLetter = getUIFactoryService().newText(title.substring(0 , 1 ), 50.0 )
192
+ firstLetter .fill = null
193
+ firstLetter .strokeProperty().bind(titleColor)
194
+ firstLetter .strokeWidth = 1.5
195
195
196
- val text2 = getUIFactoryService().newText(title.substring(1 , title.length), 50.0 )
197
- text2 .fill = null
198
- text2 .stroke = titleColor.value
199
- text2 .strokeWidth = 1.5
196
+ val restOfTheTittle = getUIFactoryService().newText(title.substring(1 , title.length), 50.0 )
197
+ restOfTheTittle .fill = null
198
+ restOfTheTittle .stroke = titleColor.value
199
+ restOfTheTittle .strokeWidth = 1.5
200
200
201
- val textWidth = text.layoutBounds.width + text2.layoutBounds.width
201
+ var firstLetterWidth = firstLetter.layoutBounds.width
202
+ var restOfTheTittleWidth = restOfTheTittle.layoutBounds.width
202
203
203
- val border = Rectangle (textWidth + 30 , 65.0 , null )
204
+ firstLetter.layoutBoundsProperty().addListener { _, _, newBounds -> firstLetterWidth = newBounds.width}
205
+ restOfTheTittle.layoutBoundsProperty().addListener { _, _, newBounds -> restOfTheTittleWidth = newBounds.width}
206
+
207
+ val tittleWidth = firstLetterWidth + restOfTheTittleWidth
208
+
209
+ val border = Rectangle (tittleWidth + 30 , 65.0 , null )
204
210
border.stroke = Color .WHITE
205
211
border.strokeWidth = 4.0
206
212
border.arcWidth = 25.0
@@ -224,11 +230,11 @@ open class FXGLDefaultMenu(type: MenuType) : FXGLMenu(type) {
224
230
emitter.setSpawnPointFunction { Point2D .ZERO }
225
231
emitter.setAccelerationFunction { Point2D (random(- 1.0 , 1.0 ), random(0.0 , 0.0 )) }
226
232
227
- val box = HBox (text, text2 )
233
+ val box = HBox (firstLetter, restOfTheTittle )
228
234
box.alignment = Pos .CENTER
229
235
230
236
val titleRoot = StackPane (border, box)
231
- titleRoot.translateX = appWidth / 2.0 - (textWidth + 30 ) / 2
237
+ titleRoot.translateX = appWidth / 2.0 - (tittleWidth + 30 ) / 2
232
238
titleRoot.translateY = 50.0
233
239
234
240
if (! FXGL .getSettings().isNative)
0 commit comments