You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.2 KiB
45 lines
1.2 KiB
package wow.doge.chatto.control
|
|
|
|
import javafx.scene.layout.HBox
|
|
import scalafx.Includes._
|
|
import wow.doge.chatto.model.Message
|
|
import com.sandec.mdfx.MDFXNode
|
|
import javafx.geometry.Pos
|
|
import javafx.scene.layout.Priority
|
|
|
|
class MessageBox() extends HBox() {
|
|
import MessageBox._
|
|
private var mdfxNode = new MDFXNode("");
|
|
mdfxNode
|
|
.getStylesheets()
|
|
.add(markdownStyleSheet)
|
|
|
|
setAlignment(Pos.CENTER_RIGHT)
|
|
maxWidth(500)
|
|
this.hgrow = Priority.ALWAYS
|
|
this.vgrow = Priority.ALWAYS
|
|
this.children ++= Seq(mdfxNode)
|
|
this.fillHeight = true
|
|
|
|
def setItem(message: Message): Unit = {
|
|
// val index = this.children.indexOf(mdfxNode)
|
|
val mdfxNode2 = new MDFXNode(message.message)
|
|
mdfxNode2
|
|
.getStylesheets()
|
|
.add(markdownStyleSheet)
|
|
mdfxNode2.setMaxWidth(500)
|
|
mdfxNode2.vgrow = Priority.ALWAYS
|
|
mdfxNode2.setAlignment(Pos.CENTER)
|
|
mdfxNode2.styleClass = Seq("chat-message-box")
|
|
|
|
this.children -= mdfxNode
|
|
this.children += mdfxNode2
|
|
|
|
mdfxNode = mdfxNode2
|
|
// this.children.updated(index, mdfxNode2)
|
|
}
|
|
}
|
|
object MessageBox {
|
|
lazy val markdownStyleSheet =
|
|
getClass().getResource("/styles/markdown.css").toExternalForm()
|
|
}
|