33 lines
720 B
Go
33 lines
720 B
Go
package objects
|
|
|
|
import "git.tebibyte.media/tomo/tomo"
|
|
|
|
// Icon displays a single icon.
|
|
type Icon struct {
|
|
tomo.Box
|
|
}
|
|
|
|
func iconSizeString (size tomo.IconSize) string {
|
|
switch size {
|
|
case tomo.IconSizeLarge: return "large"
|
|
case tomo.IconSizeMedium: return "medium"
|
|
default: return "small"
|
|
}
|
|
}
|
|
|
|
// NewIcon creates a new icon from an icon ID.
|
|
func NewIcon (icon tomo.Icon, size tomo.IconSize) *Icon {
|
|
this := &Icon {
|
|
Box: tomo.NewBox(),
|
|
}
|
|
this.SetRole(tomo.R("objects", "Icon"))
|
|
this.SetIcon(icon, size)
|
|
return this
|
|
}
|
|
|
|
// SetIcon sets the icon.
|
|
func (this *Icon) SetIcon (icon tomo.Icon, size tomo.IconSize) {
|
|
this.SetAttr(tomo.AIcon(icon, size))
|
|
this.SetTag(iconSizeString(size), true)
|
|
}
|