Fix not being able to open Redstone Emitter GUI

This commit is contained in:
Shadowfacts 2021-03-06 15:53:25 -05:00
parent 219033476c
commit 89e91796a5
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
2 changed files with 15 additions and 7 deletions

View File

@ -84,7 +84,7 @@ class Label(
if (RenderHelper.disabled) return false
val oldSize = intrinsicContentSize
if (wrappingMode == WrappingMode.WRAP && canWrap) {
if (wrappingMode == WrappingMode.WRAP && canWrap && hasSolver) {
val lines = textRenderer.wrapLines(text, bounds.width.toInt())
val height = (if (maxLines == 0) lines.size else min(lines.size, maxLines)) * textRenderer.fontHeight
intrinsicContentSize = Size(bounds.width, height.toDouble())

View File

@ -48,6 +48,9 @@ open class View(): Responder {
*/
var solver: Solver by solverDelegate
val hasSolver: Boolean
get() = solverDelegate.isInitialized
/**
* Layout anchor for the left edge of this view in the window's coordinate system.
*/
@ -92,17 +95,22 @@ open class View(): Responder {
/**
* The rectangle for this view in the coordinate system of its superview view (or the window, if there is no superview).
* If using constraint based layout, this property is not initialized until [didLayout] called.
* If using constraint based layout, this property has zero dimensions until [didLayout] called.
* Otherwise, this must be set manually.
* Setting this property updates the [bounds].
*/
var frame: Rect by ObservableLateInitProperty { this.bounds = Rect(Point.ORIGIN, it.size) }
var frame = Rect(0.0, 0.0, 0.0, 0.0)
set(value) {
field = value
bounds = Rect(Point.ORIGIN, value.size)
}
/**
* The rectangle for this view in its own coordinate system.
* If using constraint based layout, this property is not initialized until [didLayout] called.
* If using constraint based layout, this property has zero dimensions until [didLayout] called.
* Otherwise, this will be initialized when [frame] is set.
*/
lateinit var bounds: Rect
var bounds = Rect(0.0, 0.0, 0.0, 0.0)
/**
* The position on the Z-axis of this view.
@ -182,7 +190,7 @@ open class View(): Responder {
subviewsSortedByZIndex = subviews.sortedBy(View::zIndex)
view.superview = this
if (solverDelegate.isInitialized) {
if (hasSolver) {
view.solver = solver
}
view.window = window
@ -293,7 +301,7 @@ open class View(): Responder {
}
private fun updateIntrinsicContentSizeConstraints(old: Size?, new: Size?) {
if (!usesConstraintBasedLayout || !solverDelegate.isInitialized) return
if (!usesConstraintBasedLayout || !hasSolver) return
if (old != null) {
solver.removeConstraint(intrinsicContentSizeWidthConstraint!!)