Window now checks for minimum size on adopt
This commit is contained in:
		
							parent
							
								
									437aef0c27
								
							
						
					
					
						commit
						a43f5ce595
					
				| @ -153,6 +153,9 @@ func (window *window) Adopt (child tomo.Element) { | |||||||
| 		if ok && childEntity != nil { | 		if ok && childEntity != nil { | ||||||
| 			window.child = childEntity | 			window.child = childEntity | ||||||
| 			childEntity.setWindow(window) | 			childEntity.setWindow(window) | ||||||
|  | 			window.setMinimumSize ( | ||||||
|  | 				childEntity.minWidth, | ||||||
|  | 				childEntity.minHeight) | ||||||
| 			window.resizeChildToFit() | 			window.resizeChildToFit() | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | |||||||
| @ -65,7 +65,6 @@ func (element *Checkbox) Enabled () bool { | |||||||
| func (element *Checkbox) SetEnabled (enabled bool) { | func (element *Checkbox) SetEnabled (enabled bool) { | ||||||
| 	if element.enabled == enabled { return } | 	if element.enabled == enabled { return } | ||||||
| 	element.enabled = enabled | 	element.enabled = enabled | ||||||
| 	if element.entity == nil { return } |  | ||||||
| 	element.entity.Invalidate() | 	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) { | func (element *Checkbox) HandleKeyDown (key input.Key, modifiers input.Modifiers) { | ||||||
| 	if element.entity == nil { return } |  | ||||||
| 	if key == input.KeyEnter { | 	if key == input.KeyEnter { | ||||||
| 		element.pressed = true | 		element.pressed = true | ||||||
| 		element.entity.Invalidate() | 		element.entity.Invalidate() | ||||||
|  | |||||||
| @ -51,7 +51,6 @@ func (element *Label) Entity () tomo.Entity { | |||||||
| func (element *Label) EmCollapse (columns int, rows int) { | func (element *Label) EmCollapse (columns int, rows int) { | ||||||
| 	element.forcedColumns = columns | 	element.forcedColumns = columns | ||||||
| 	element.forcedRows    = rows | 	element.forcedRows    = rows | ||||||
| 	if element.entity == nil { return } |  | ||||||
| 	element.updateMinimumSize() | 	element.updateMinimumSize() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -71,7 +70,6 @@ func (element *Label) SetText (text string) { | |||||||
| 
 | 
 | ||||||
| 	element.text = text | 	element.text = text | ||||||
| 	element.drawer.SetText([]rune(text)) | 	element.drawer.SetText([]rune(text)) | ||||||
| 	if element.entity == nil { return } |  | ||||||
| 	element.updateMinimumSize() | 	element.updateMinimumSize() | ||||||
| 	element.entity.Invalidate() | 	element.entity.Invalidate() | ||||||
| } | } | ||||||
| @ -87,7 +85,6 @@ func (element *Label) SetWrap (wrap bool) { | |||||||
| 		element.drawer.SetMaxHeight(0) | 		element.drawer.SetMaxHeight(0) | ||||||
| 	} | 	} | ||||||
| 	element.wrap = wrap | 	element.wrap = wrap | ||||||
| 	if element.entity == nil { return } |  | ||||||
| 	element.updateMinimumSize() | 	element.updateMinimumSize() | ||||||
| 	element.entity.Invalidate() | 	element.entity.Invalidate() | ||||||
| } | } | ||||||
| @ -97,7 +94,6 @@ func (element *Label) SetAlign (align textdraw.Align) { | |||||||
| 	if align == element.align { return } | 	if align == element.align { return } | ||||||
| 	element.align = align | 	element.align = align | ||||||
| 	element.drawer.SetAlign(align) | 	element.drawer.SetAlign(align) | ||||||
| 	if element.entity == nil { return } |  | ||||||
| 	element.updateMinimumSize() | 	element.updateMinimumSize() | ||||||
| 	element.entity.Invalidate() | 	element.entity.Invalidate() | ||||||
| } | } | ||||||
| @ -109,7 +105,6 @@ func (element *Label) SetTheme (new tomo.Theme) { | |||||||
| 	element.drawer.SetFace (element.theme.FontFace ( | 	element.drawer.SetFace (element.theme.FontFace ( | ||||||
| 		tomo.FontStyleRegular, | 		tomo.FontStyleRegular, | ||||||
| 		tomo.FontSizeNormal)) | 		tomo.FontSizeNormal)) | ||||||
| 	if element.entity == nil { return } |  | ||||||
| 	element.updateMinimumSize() | 	element.updateMinimumSize() | ||||||
| 	element.entity.Invalidate() | 	element.entity.Invalidate() | ||||||
| } | } | ||||||
| @ -118,15 +113,12 @@ func (element *Label) SetTheme (new tomo.Theme) { | |||||||
| func (element *Label) SetConfig (new tomo.Config) { | func (element *Label) SetConfig (new tomo.Config) { | ||||||
| 	if new == element.config.Config { return } | 	if new == element.config.Config { return } | ||||||
| 	element.config.Config = new | 	element.config.Config = new | ||||||
| 	if element.entity == nil { return } |  | ||||||
| 	element.updateMinimumSize() | 	element.updateMinimumSize() | ||||||
| 	element.entity.Invalidate() | 	element.entity.Invalidate() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Draw causes the element to draw to the specified destination canvas. | // Draw causes the element to draw to the specified destination canvas. | ||||||
| func (element *Label) Draw (destination canvas.Canvas) { | func (element *Label) Draw (destination canvas.Canvas) { | ||||||
| 	if element.entity == nil { return } |  | ||||||
| 	 |  | ||||||
| 	bounds := element.entity.Bounds() | 	bounds := element.entity.Bounds() | ||||||
| 	 | 	 | ||||||
| 	if element.wrap { | 	if element.wrap { | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user