Further simplified the API and updated the X backend to match
The MinimumWidth and MinimumHeight behaviors have been condensed into MinimumSize, which returns both dimensions at once.
This commit is contained in:
parent
c94329e273
commit
292669a43f
@ -10,13 +10,11 @@ import "github.com/jezek/xgbutil/xgraphics"
|
|||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
|
|
||||||
type Window struct {
|
type Window struct {
|
||||||
backend *Backend
|
backend *Backend
|
||||||
xWindow *xwindow.Window
|
xWindow *xwindow.Window
|
||||||
xCanvas *xgraphics.Image
|
xCanvas *xgraphics.Image
|
||||||
child tomo.Element
|
child tomo.Element
|
||||||
onClose func ()
|
onClose func ()
|
||||||
drawCallback func (region tomo.Image)
|
|
||||||
minimumSizeChangeCallback func (width, height int)
|
|
||||||
skipChildDrawCallback bool
|
skipChildDrawCallback bool
|
||||||
|
|
||||||
metrics struct {
|
metrics struct {
|
||||||
@ -89,9 +87,7 @@ func (window *Window) Adopt (child tomo.Element) {
|
|||||||
})
|
})
|
||||||
window.resizeChildToFit()
|
window.resizeChildToFit()
|
||||||
}
|
}
|
||||||
window.childMinimumSizeChangeCallback (
|
window.childMinimumSizeChangeCallback(child.MinimumSize())
|
||||||
child.MinimumWidth(),
|
|
||||||
child.MinimumHeight())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (window *Window) Child () (child tomo.Element) {
|
func (window *Window) Child () (child tomo.Element) {
|
||||||
|
14
tomo.go
14
tomo.go
@ -95,15 +95,11 @@ type Element interface {
|
|||||||
// element adopts a child element, it must set these callbacks.
|
// element adopts a child element, it must set these callbacks.
|
||||||
SetParentHooks (callbacks ParentHooks)
|
SetParentHooks (callbacks ParentHooks)
|
||||||
|
|
||||||
// MinimumWidth specifies the minimum amount of pixels this element's
|
// MinimumSize specifies the minimum amount of pixels this element's
|
||||||
// width may be set to. If the element is resized to an amount smaller
|
// width and height may be set to. If the element is given a resize
|
||||||
// that MinimumWidth, it will instead set its width to MinimumWidth.
|
// event with dimensions smaller than this, it will use its minimum
|
||||||
MinimumWidth () (minimum int)
|
// instead of the offending dimension(s).
|
||||||
|
MinimumSize () (width, height int)
|
||||||
// MinimumHeight specifies the minimum amount of pixels this element's
|
|
||||||
// height may be set to. If the element is resized to an amount smaller
|
|
||||||
// that MinimumHeight, it will instead set its height to MinimumHeight.
|
|
||||||
MinimumHeight () (minimum int)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Window represents a top-level container generated by the currently running
|
// Window represents a top-level container generated by the currently running
|
||||||
|
Reference in New Issue
Block a user