Layouts are now attributes
This commit is contained in:
parent
75fd31bb24
commit
f561b71c56
17
attribute.go
17
attribute.go
@ -85,6 +85,8 @@ type AttrFace struct { font.Face }
|
|||||||
type AttrAlign struct { X, Y Align }
|
type AttrAlign struct { X, Y Align }
|
||||||
// AttrOverflow sets the overflow, if the box is a ContentBox.
|
// AttrOverflow sets the overflow, if the box is a ContentBox.
|
||||||
type AttrOverflow struct { X, Y bool }
|
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.
|
// AColor is a convenience constructor for the color attribute.
|
||||||
func AColor (col color.Color) AttrColor {
|
func AColor (col color.Color) AttrColor {
|
||||||
@ -134,6 +136,10 @@ func AAlign (x, y Align) AttrAlign {
|
|||||||
func AOverflow (x, y bool) AttrOverflow {
|
func AOverflow (x, y bool) AttrOverflow {
|
||||||
return AttrOverflow { X: x, Y: y }
|
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.
|
// Equals returns true if both attributes can reasonably be declared equal.
|
||||||
func (this AttrColor) Equals (other Attr) bool {
|
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 {
|
func (this AttrOverflow) Equals (other Attr) bool {
|
||||||
if other, ok := other.(AttrOverflow); ok {
|
if other, ok := other.(AttrOverflow); ok {
|
||||||
return this == other
|
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
|
// 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
|
// unique number. The exact values of these numbers are not part of the API and
|
||||||
// may change.
|
// may change.
|
||||||
@ -259,3 +275,4 @@ func (AttrDotColor) attr () int { return 8 }
|
|||||||
func (AttrFace) attr () int { return 9 }
|
func (AttrFace) attr () int { return 9 }
|
||||||
func (AttrAlign) attr () int { return 10 }
|
func (AttrAlign) attr () int { return 10 }
|
||||||
func (AttrOverflow) attr () int { return 11 }
|
func (AttrOverflow) attr () int { return 11 }
|
||||||
|
func (AttrLayout) attr () int { return 12 }
|
||||||
|
@ -204,9 +204,6 @@ type ContainerBox interface {
|
|||||||
Len () int
|
Len () int
|
||||||
// At returns the child Object at the specified index.
|
// At returns the child Object at the specified index.
|
||||||
At (int) Object
|
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
|
// SetInputMask sets whether or not user input events will be sent to
|
||||||
// this Box's children. If false, which is the default, input events
|
// 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,
|
// will be sent to this Box as well as all of its children. If true,
|
||||||
|
Loading…
Reference in New Issue
Block a user