uiterm: call uiDraw methods when View properties change

This commit is contained in:
Tim Cooper
2014-12-06 22:34:32 -04:00
parent 634e28f2d3
commit 0019ea7cb8
4 changed files with 14 additions and 1 deletions

View File

@@ -27,6 +27,7 @@ func (l *Label) uiSetBounds(x0, y0, x1, y1 int) {
l.y0 = y0
l.x1 = x1
l.y1 = y1
l.uiDraw()
}
func (l *Label) uiDraw() {

View File

@@ -25,6 +25,7 @@ func (t *Textbox) uiInitialize(ui *Ui) {
func (t *Textbox) uiSetActive(active bool) {
t.active = active
t.uiDraw()
}
func (t *Textbox) uiSetBounds(x0, y0, x1, y1 int) {
@@ -32,6 +33,7 @@ func (t *Textbox) uiSetBounds(x0, y0, x1, y1 int) {
t.y0 = y0
t.x1 = x1
t.y1 = y1
t.uiDraw()
}
func (t *Textbox) uiDraw() {

View File

@@ -31,18 +31,21 @@ func (t *Textview) uiSetBounds(x0, y0, x1, y1 int) {
t.x1 = x1
t.y1 = y1
t.updateParsedLines()
t.uiDraw()
}
func (t *Textview) ScrollUp() {
if newLine := t.CurrentLine + 1; newLine < len(t.parsedLines) {
t.CurrentLine = newLine
}
t.uiDraw()
}
func (t *Textview) ScrollDown() {
if newLine := t.CurrentLine - 1; newLine >= 0 {
t.CurrentLine = newLine
}
t.uiDraw()
}
func (t *Textview) ScrollTop() {
@@ -51,10 +54,12 @@ func (t *Textview) ScrollTop() {
} else {
t.CurrentLine = 0
}
t.uiDraw()
}
func (t *Textview) ScrollBottom() {
t.CurrentLine = 0
t.uiDraw()
}
func (t *Textview) updateParsedLines() {
@@ -94,12 +99,14 @@ func (t *Textview) updateParsedLines() {
func (t *Textview) AddLine(line string) {
t.Lines = append(t.Lines, line)
t.updateParsedLines()
t.uiDraw()
}
func (t *Textview) Clear() {
t.Lines = nil
t.CurrentLine = 0
t.parsedLines = nil
t.uiDraw()
}
func (t *Textview) uiDraw() {

View File

@@ -50,6 +50,7 @@ func (t *Tree) uiInitialize(ui *Ui) {
func (t *Tree) uiSetActive(active bool) {
t.active = active
t.uiDraw()
}
func (t *Tree) uiSetBounds(x0, y0, x1, y1 int) {
@@ -57,6 +58,7 @@ func (t *Tree) uiSetBounds(x0, y0, x1, y1 int) {
t.y0 = y0
t.x1 = x1
t.y1 = y1
t.uiDraw()
}
func (t *Tree) Rebuild() {
@@ -74,6 +76,7 @@ func (t *Tree) Rebuild() {
}
t.lines = lines
t.activeLine = bounded(t.activeLine, 0, len(t.lines)-1)
t.uiDraw()
}
func (t *Tree) rebuild_rec(parent TreeItem, level int) []renderedTreeItem {
@@ -142,7 +145,7 @@ func (t *Tree) uiKeyEvent(mod Modifier, key Key) {
t.Listener(t.ui, t, t.lines[t.activeLine].Item)
}
}
t.ui.Refresh()
t.uiDraw()
}
func (t *Tree) uiCharacterEvent(ch rune) {