Searcher size
This commit is contained in:
@@ -58,14 +58,26 @@ func (s *UiScreen) Init(ui *Ui) {
|
|||||||
dat = append(dat, RandomString(15))
|
dat = append(dat, RandomString(15))
|
||||||
}
|
}
|
||||||
searcher.SetData(dat)
|
searcher.SetData(dat)
|
||||||
|
searcher.SetSelectFunc(func(idx int, v string) bool {
|
||||||
|
s.log.Log("Searcher Value Selected: %s", v)
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
searcher.SetH(10)
|
||||||
hl.Add(searcher)
|
hl.Add(searcher)
|
||||||
|
|
||||||
db := w.NewButton("test-bd-1", ui.style)
|
db := w.NewButton("test-bd-1", ui.style)
|
||||||
db.SetLabel("Button 1")
|
db.SetLabel("Button 1")
|
||||||
db.SetOnPressed(
|
db.SetOnPressed(func() bool {
|
||||||
|
s.log.Log("Button 1 Pressed")
|
||||||
|
return true
|
||||||
|
})
|
||||||
hl.Add(db)
|
hl.Add(db)
|
||||||
db = w.NewButton("test-bd-2", ui.style)
|
db = w.NewButton("test-bd-2", ui.style)
|
||||||
db.SetLabel("Button 2")
|
db.SetLabel("Button 2")
|
||||||
|
db.SetOnPressed(func() bool {
|
||||||
|
s.log.Log("Button 2 Pressed")
|
||||||
|
return true
|
||||||
|
})
|
||||||
hl.Add(db)
|
hl.Add(db)
|
||||||
s.ll.Add(hl)
|
s.ll.Add(hl)
|
||||||
|
|
||||||
@@ -76,11 +88,19 @@ func (s *UiScreen) Init(ui *Ui) {
|
|||||||
|
|
||||||
btnCancel := w.NewButton("btn-cancel", ui.style)
|
btnCancel := w.NewButton("btn-cancel", ui.style)
|
||||||
btnCancel.SetLabel("Cancel")
|
btnCancel.SetLabel("Cancel")
|
||||||
|
btnCancel.SetOnPressed(func() bool {
|
||||||
|
s.log.Log("Cancel Pressed")
|
||||||
|
return true
|
||||||
|
})
|
||||||
btnL.Add(btnCancel)
|
btnL.Add(btnCancel)
|
||||||
btnL.AddFlag(btnCancel, w.LFAlignVBottom)
|
btnL.AddFlag(btnCancel, w.LFAlignVBottom)
|
||||||
|
|
||||||
btnOk := w.NewButton("btn-ok", ui.style)
|
btnOk := w.NewButton("btn-ok", ui.style)
|
||||||
btnOk.SetLabel("Ok")
|
btnOk.SetLabel("Ok")
|
||||||
|
btnOk.SetOnPressed(func() bool {
|
||||||
|
s.log.Log("Ok Pressed")
|
||||||
|
return true
|
||||||
|
})
|
||||||
btnL.Add(btnOk)
|
btnL.Add(btnOk)
|
||||||
btnL.AddFlag(btnOk, w.LFAlignVBottom)
|
btnL.AddFlag(btnOk, w.LFAlignVBottom)
|
||||||
s.ll.Add(btnL)
|
s.ll.Add(btnL)
|
||||||
|
|||||||
@@ -175,7 +175,8 @@ func (w *Searcher) Draw(screen tcell.Screen) {
|
|||||||
}
|
}
|
||||||
dStyle := w.style.Dim(!w.active)
|
dStyle := w.style.Dim(!w.active)
|
||||||
if len(w.title) > 0 {
|
if len(w.title) > 0 {
|
||||||
wh.TitledBorderFilled(w.x, w.y, w.x+w.w, w.y+w.h, w.title, wh.BRD_CSIMPLE, dStyle, screen)
|
wh.TitledBorderFilled(w.x, w.y, w.x+w.w, w.y+w.h-1, w.title, wh.BRD_CSIMPLE, dStyle, screen)
|
||||||
|
// w.Log("Searcher<%s> Bounds: %d,%d -> %d,%d", w.Id(), w.x, w.y, w.x+w.w, w.y+w.h)
|
||||||
} else {
|
} else {
|
||||||
wh.BorderFilled(w.x, w.y, w.x+w.w, w.y+w.h, wh.BRD_CSIMPLE, dStyle, screen)
|
wh.BorderFilled(w.x, w.y, w.x+w.w, w.y+w.h, wh.BRD_CSIMPLE, dStyle, screen)
|
||||||
}
|
}
|
||||||
@@ -197,7 +198,7 @@ func (w *Searcher) Draw(screen tcell.Screen) {
|
|||||||
}
|
}
|
||||||
wh.DrawText(x, y, w.filteredData[i], st, screen)
|
wh.DrawText(x, y, w.filteredData[i], st, screen)
|
||||||
y++
|
y++
|
||||||
if y >= w.y+w.h {
|
if y >= w.y+w.h-1 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user