All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.soywiz.korge.ui.Label.kt Maven / Gradle / Ivy

There is a newer version: 0.19.2
Show newest version
package com.soywiz.korge.ui

import com.soywiz.korge.html.Html
import com.soywiz.korge.view.IHtml
import com.soywiz.korge.view.IText
import com.soywiz.korge.view.text
import com.soywiz.korim.color.Colors
import com.soywiz.korio.util.redirectField

class Label(factory: UIFactory, skin: UISkin = factory.skin, initialText: String = "Label") : Widget(factory, skin), IText, IHtml {
	val textView = views.text(initialText).apply { this@Label += this }

	override var text: String by redirectField(textView::text)
	override var html: String by redirectField(textView::html)
	var format: Html.Format by redirectField(textView::format)

	init {
		format = Html.Format(size = 16, align = Html.Alignment.MIDDLE_CENTER, color = Colors.BLACK)
	}

	override fun updateSize() {
		textView.textBounds.setTo(0, 0, width, height)
	}

}

fun UIFactory.label(text: String = "Label", skin: UISkin = this.skin) = Label(this, skin, text)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy