Window now checks for minimum size on adopt

This commit is contained in:
Sasha Koshka 2023-04-15 01:19:39 -04:00
parent 437aef0c27
commit a43f5ce595
3 changed files with 3 additions and 10 deletions

View File

@ -153,6 +153,9 @@ func (window *window) Adopt (child tomo.Element) {
if ok && childEntity != nil {
window.child = childEntity
childEntity.setWindow(window)
window.setMinimumSize (
childEntity.minWidth,
childEntity.minHeight)
window.resizeChildToFit()
}
}

View File

@ -65,7 +65,6 @@ func (element *Checkbox) Enabled () bool {
func (element *Checkbox) SetEnabled (enabled bool) {
if element.enabled == enabled { return }
element.enabled = enabled
if element.entity == nil { return }
element.entity.Invalidate()
}
@ -150,7 +149,6 @@ func (element *Checkbox) HandleMouseUp (x, y int, button input.Button) {
}
func (element *Checkbox) HandleKeyDown (key input.Key, modifiers input.Modifiers) {
if element.entity == nil { return }
if key == input.KeyEnter {
element.pressed = true
element.entity.Invalidate()

View File

@ -51,7 +51,6 @@ func (element *Label) Entity () tomo.Entity {
func (element *Label) EmCollapse (columns int, rows int) {
element.forcedColumns = columns
element.forcedRows = rows
if element.entity == nil { return }
element.updateMinimumSize()
}
@ -71,7 +70,6 @@ func (element *Label) SetText (text string) {
element.text = text
element.drawer.SetText([]rune(text))
if element.entity == nil { return }
element.updateMinimumSize()
element.entity.Invalidate()
}
@ -87,7 +85,6 @@ func (element *Label) SetWrap (wrap bool) {
element.drawer.SetMaxHeight(0)
}
element.wrap = wrap
if element.entity == nil { return }
element.updateMinimumSize()
element.entity.Invalidate()
}
@ -97,7 +94,6 @@ func (element *Label) SetAlign (align textdraw.Align) {
if align == element.align { return }
element.align = align
element.drawer.SetAlign(align)
if element.entity == nil { return }
element.updateMinimumSize()
element.entity.Invalidate()
}
@ -109,7 +105,6 @@ func (element *Label) SetTheme (new tomo.Theme) {
element.drawer.SetFace (element.theme.FontFace (
tomo.FontStyleRegular,
tomo.FontSizeNormal))
if element.entity == nil { return }
element.updateMinimumSize()
element.entity.Invalidate()
}
@ -118,15 +113,12 @@ func (element *Label) SetTheme (new tomo.Theme) {
func (element *Label) SetConfig (new tomo.Config) {
if new == element.config.Config { return }
element.config.Config = new
if element.entity == nil { return }
element.updateMinimumSize()
element.entity.Invalidate()
}
// Draw causes the element to draw to the specified destination canvas.
func (element *Label) Draw (destination canvas.Canvas) {
if element.entity == nil { return }
bounds := element.entity.Bounds()
if element.wrap {