Make text wrapping an attribute
This commit is contained in:
25
attribute.go
25
attribute.go
@@ -72,6 +72,8 @@ type AttrTextColor struct { color.Color }
|
|||||||
type AttrDotColor struct { color.Color }
|
type AttrDotColor struct { color.Color }
|
||||||
// AttrFace sets the font face, if the box is a TextBox.
|
// AttrFace sets the font face, if the box is a TextBox.
|
||||||
type AttrFace struct { font.Face }
|
type AttrFace struct { font.Face }
|
||||||
|
// AttrWrap sets if the text wraps, if the box is a TextBox.
|
||||||
|
type AttrWrap bool
|
||||||
// AttrAlign sets the alignment, if the box is a ContentBox.
|
// AttrAlign sets the alignment, if the box is a ContentBox.
|
||||||
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.
|
||||||
@@ -119,6 +121,10 @@ func ADotColor (col color.Color) AttrDotColor {
|
|||||||
func AFace (face font.Face) AttrFace {
|
func AFace (face font.Face) AttrFace {
|
||||||
return AttrFace { Face: face }
|
return AttrFace { Face: face }
|
||||||
}
|
}
|
||||||
|
// AWrap is a convenience constructor for the wrap attribute.
|
||||||
|
func AWrap (wrap bool) AttrWrap {
|
||||||
|
return AttrWrap(wrap)
|
||||||
|
}
|
||||||
// AAlign is a convenience constructor for the align attribute.
|
// AAlign is a convenience constructor for the align attribute.
|
||||||
func AAlign (x, y Align) AttrAlign {
|
func AAlign (x, y Align) AttrAlign {
|
||||||
return AttrAlign { X: x, Y: y }
|
return AttrAlign { X: x, Y: y }
|
||||||
@@ -210,7 +216,6 @@ func (this AttrDotColor) Equals (other Attr) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Equals returns true if both attributes can reasonably be declared equal.
|
// Equals returns true if both attributes can reasonably be declared equal.
|
||||||
func (this AttrFace) Equals (other Attr) bool {
|
func (this AttrFace) Equals (other Attr) bool {
|
||||||
if other, ok := other.(AttrFace); ok {
|
if other, ok := other.(AttrFace); ok {
|
||||||
@@ -219,7 +224,14 @@ func (this AttrFace) Equals (other Attr) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Equals returns true if both attributes can reasonably be declared equal.
|
||||||
|
func (this AttrWrap) Equals (other Attr) bool {
|
||||||
|
if other, ok := other.(AttrWrap); ok {
|
||||||
|
return this == other
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
// Equals returns true if both attributes can reasonably be declared equal.
|
// Equals returns true if both attributes can reasonably be declared equal.
|
||||||
func (this AttrAlign) Equals (other Attr) bool {
|
func (this AttrAlign) Equals (other Attr) bool {
|
||||||
if other, ok := other.(AttrAlign); ok {
|
if other, ok := other.(AttrAlign); ok {
|
||||||
@@ -228,7 +240,6 @@ func (this AttrAlign) Equals (other Attr) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Equals returns true if both attributes can reasonably be declared equal.
|
// 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 {
|
||||||
@@ -237,7 +248,6 @@ func (this AttrOverflow) Equals (other Attr) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Equals returns true if both attributes can reasonably be declared equal.
|
// Equals returns true if both attributes can reasonably be declared equal.
|
||||||
func (this AttrLayout) Equals (other Attr) bool {
|
func (this AttrLayout) Equals (other Attr) bool {
|
||||||
if other, ok := other.(AttrLayout); ok {
|
if other, ok := other.(AttrLayout); ok {
|
||||||
@@ -264,6 +274,7 @@ func (AttrGap) attr () int { return 6 }
|
|||||||
func (AttrTextColor) attr () int { return 7 }
|
func (AttrTextColor) attr () int { return 7 }
|
||||||
func (AttrDotColor) attr () int { return 8 }
|
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 (AttrWrap) attr () int { return 10 }
|
||||||
func (AttrOverflow) attr () int { return 11 }
|
func (AttrAlign) attr () int { return 11 }
|
||||||
func (AttrLayout) attr () int { return 12 }
|
func (AttrOverflow) attr () int { return 12 }
|
||||||
|
func (AttrLayout) attr () int { return 13 }
|
||||||
|
|||||||
@@ -169,9 +169,7 @@ type TextBox interface {
|
|||||||
|
|
||||||
// SetText sets the text content of the Box.
|
// SetText sets the text content of the Box.
|
||||||
SetText (string)
|
SetText (string)
|
||||||
// SetWrap sets whether or not the text wraps.
|
|
||||||
SetWrap (bool)
|
|
||||||
|
|
||||||
// SetSelectable sets whether or not the text content can be
|
// SetSelectable sets whether or not the text content can be
|
||||||
// highlighted/selected.
|
// highlighted/selected.
|
||||||
SetSelectable (bool)
|
SetSelectable (bool)
|
||||||
|
|||||||
Reference in New Issue
Block a user