diff options
Diffstat (limited to 'xA/xA.go')
-rw-r--r-- | xA/xA.go | 57 |
1 files changed, 53 insertions, 4 deletions
@@ -15,6 +15,7 @@ import ( "net" "os" "slices" + "strings" "sync" "time" @@ -104,7 +105,12 @@ func (t *customTheme) Icon(i fyne.ThemeIconName) fyne.Resource { } func (t *customTheme) Size(s fyne.ThemeSizeName) float32 { - return theme.DefaultTheme().Size(s) + switch s { + case theme.SizeNameInnerPadding: + return 2 + default: + return theme.DefaultTheme().Size(s) + } } // --- Relay state ------------------------------------------------------------- @@ -186,6 +192,7 @@ var ( wWindow fyne.Window wTopic *widget.RichText + wBufferList *widget.List wRichText *widget.RichText wRichScroll *container.Scroll wPrompt *widget.Label @@ -329,7 +336,12 @@ func refreshTopic(topic []bufferLineItem) { } func refreshBufferList() { - // TODO(p): First off, add a buffer list, second, refresh it. + // TODO(p): See if this is enough, or even doing anything. + // - In particular, within RelayEventDataBufferRemove handling. + wBufferList.Refresh() + for i := range buffers { + wBufferList.RefreshItem(widget.ListItemID(i)) + } } func refreshPrompt() { @@ -776,10 +788,18 @@ func relayProcessMessage(m *RelayEventMessage) { old.historyAt = len(old.history) } - // TODO(p): Port the rest as well. + // TODO(p): Hide the log if visible. + b.highlighted = false + for i := range buffers { + if buffers[i].bufferName == bufferCurrent { + wBufferList.Select(widget.ListItemID(i)) + break + } + } refreshIcon() refreshTopic(b.topic) + refreshBufferList() refreshBuffer(b) refreshPrompt() refreshStatus() @@ -919,6 +939,34 @@ func main() { wWindow = a.NewWindow(projectName) // TODO(p): Consider using data bindings. + wBufferList = widget.NewList(func() int { return len(buffers) }, + func() fyne.CanvasObject { + return widget.NewLabel(strings.Repeat(" ", 16)) + }, + func(id widget.ListItemID, item fyne.CanvasObject) { + label, b := item.(*widget.Label), &buffers[int(id)] + label.TextStyle.Italic = b.bufferName == bufferCurrent + label.TextStyle.Bold = false + text := b.bufferName + if b.bufferName != bufferCurrent && b.newMessages != 0 { + label.TextStyle.Bold = true + text += fmt.Sprintf(" (%d)", b.newMessages) + } + label.Importance = widget.MediumImportance + if b.highlighted { + label.Importance = widget.HighImportance + } + label.SetText(text) + }) + wBufferList.HideSeparators = true + wBufferList.OnSelected = func(id widget.ListItemID) { + // TODO(p): See if we can deselect it now without consequences. + request := buffers[int(id)].bufferName + if request != bufferCurrent { + bufferActivate(request) + } + } + wTopic = widget.NewRichText() wTopic.Truncation = fyne.TextTruncateEllipsis wRichText = widget.NewRichText() @@ -930,11 +978,12 @@ func main() { "", fyne.TextAlignTrailing, fyne.TextStyle{}) wEntry = widget.NewMultiLineEntry() bottom := container.NewVBox( + widget.NewSeparator(), container.NewBorder(nil, nil, wPrompt, wStatus), wEntry, ) wWindow.SetContent(container.NewBorder( - wTopic, bottom, nil, nil, wRichScroll)) + wTopic, bottom, wBufferList, nil, wRichScroll)) go relayRun() |