Layouts are now attributes

This commit is contained in:
Sasha Koshka 2024-07-24 20:06:20 -04:00
parent 75fd31bb24
commit f561b71c56
2 changed files with 17 additions and 3 deletions

View File

@ -85,6 +85,8 @@ type AttrFace struct { font.Face }
type AttrAlign struct { X, Y Align }
// AttrOverflow sets the overflow, if the box is a ContentBox.
type AttrOverflow struct { X, Y bool }
// AttrLayout sets the layout, if the box is a ContentBox.
type AttrLayout struct { Layout }
// AColor is a convenience constructor for the color attribute.
func AColor (col color.Color) AttrColor {
@ -134,6 +136,10 @@ func AAlign (x, y Align) AttrAlign {
func AOverflow (x, y bool) AttrOverflow {
return AttrOverflow { X: x, Y: y }
}
// ALayout is a convenience constructor for the overflow attribute.
func ALayout (layout Layout) AttrLayout {
return AttrLayout { Layout: layout }
}
// Equals returns true if both attributes can reasonably be declared equal.
func (this AttrColor) Equals (other Attr) bool {
@ -232,6 +238,7 @@ func (this AttrAlign) Equals (other Attr) bool {
}
}
// Equals returns true if both attributes can reasonably be declared equal.
func (this AttrOverflow) Equals (other Attr) bool {
if other, ok := other.(AttrOverflow); ok {
return this == other
@ -240,6 +247,15 @@ func (this AttrOverflow) Equals (other Attr) bool {
}
}
// Equals returns true if both attributes can reasonably be declared equal.
func (this AttrLayout) Equals (other Attr) bool {
if other, ok := other.(AttrLayout); ok {
return this == other
} else {
return false
}
}
// AttrNumber returns the number of an attribute. Each attribute type has a
// unique number. The exact values of these numbers are not part of the API and
// may change.
@ -259,3 +275,4 @@ func (AttrDotColor) attr () int { return 8 }
func (AttrFace) attr () int { return 9 }
func (AttrAlign) attr () int { return 10 }
func (AttrOverflow) attr () int { return 11 }
func (AttrLayout) attr () int { return 12 }

View File

@ -204,9 +204,6 @@ type ContainerBox interface {
Len () int
// At returns the child Object at the specified index.
At (int) Object
// SetLayout sets the layout of this Box. Child Objects will be
// positioned according to it.
SetLayout (Layout)
// SetInputMask sets whether or not user input events will be sent to
// this Box's children. If false, which is the default, input events
// will be sent to this Box as well as all of its children. If true,