Styling now supports selection

This commit is contained in:
2023-01-09 15:14:36 -05:00
parent d1ec5f2cec
commit 70e0566f3f
6 changed files with 125 additions and 120 deletions
+5 -40
View File
@@ -1,24 +1,24 @@
package basic
import "image"
import "image/color"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/theme"
import "git.tebibyte.media/sashakoshka/tomo/artist"
type Label struct {
core Core
*Core
core CoreControl
text string
drawer artist.TextDrawer
}
func NewLabel (text string) (element *Label) {
element = &Label { }
element.core = NewCore(element)
element.Core, element.core = NewCore(element)
face := theme.FontFaceRegular()
element.drawer.SetFace(face)
element.SetText(text)
// FIXME: set the minimum size to one char
metrics := face.Metrics()
emspace, _ := face.GlyphAdvance('M')
intEmspace := emspace.Round()
@@ -52,46 +52,11 @@ func (element *Label) SetText (text string) {
}
}
func (element *Label) ColorModel () (model color.Model) {
return color.RGBAModel
}
func (element *Label) At (x, y int) (pixel color.Color) {
pixel = element.core.At(x, y)
return
}
func (element *Label) RGBAAt (x, y int) (pixel color.RGBA) {
pixel = element.core.RGBAAt(x, y)
return
}
func (element *Label) Bounds () (bounds image.Rectangle) {
bounds = element.core.Bounds()
return
}
func (element *Label) SetDrawCallback (draw func (region tomo.Image)) {
element.core.SetDrawCallback(draw)
}
func (element *Label) SetMinimumSizeChangeCallback (
notify func (width, height int),
) {
element.core.SetMinimumSizeChangeCallback(notify)
}
func (element *Label) Selectable () (selectable bool) {
return
}
func (element *Label) MinimumWidth () (minimum int) {
minimum = element.core.MinimumWidth()
return
}
func (element *Label) MinimumHeight () (minimum int) {
minimum = element.core.MinimumHeight()
func (element *Label) AdvanceSelection (direction int) (ok bool) {
return
}