Add: status page screen change support

This commit is contained in:
Andrey Egorov
2024-10-06 21:31:23 +03:00
parent 0495860996
commit 58a0d17e47
3 changed files with 155 additions and 76 deletions

View File

@ -50,7 +50,6 @@ func (t *text) Clear() {
}
func (t *text) Draw() {
t.Clear() // Assume that is draw is invoked string has been changed
t.drawer.PutText(t.rect.x, t.rect.y, t.str)
t.drawer.GetDisplay().FlushByMask(t.mask.bits)
}
@ -61,9 +60,18 @@ func (t *text) updateW() {
func (t *text) SetStr(str string) {
t.str = str
t.updateW()
t.mask.Update(t.rect)
newW := len(t.str)*(drawer.FontCharW+drawer.CharGap) - drawer.CharGap
if t.rect.w-newW > 0 {
// Need to clear some space
t.Clear()
t.drawer.FillBar(t.rect.x+newW, t.rect.y, t.rect.x+t.rect.w, t.rect.y+t.rect.h, 0)
} else {
t.rect.w = newW
t.mask.Update(t.rect)
}
t.Draw()
t.rect.w = newW
t.mask.Update(t.rect)
}
func (t *text) GetPos() (int, int) {