only highlight message for a short while

This commit is contained in:
diamondburned 2021-01-02 01:55:19 -08:00
parent e2b316a4df
commit bfad966cd2
5 changed files with 16 additions and 18 deletions

View File

@ -52,10 +52,8 @@ type Container interface {
// Message finds and returns the message, if any. // Message finds and returns the message, if any.
Message(id cchat.ID, nonce string) MessageRow Message(id cchat.ID, nonce string) MessageRow
// Highlight temporarily highlights the given message. // Highlight temporarily highlights the given message for a short while.
Highlight(msg MessageRow) Highlight(msg MessageRow)
// Unhighlight removes the message highlight.
Unhighlight()
// UI methods. // UI methods.

View File

@ -29,8 +29,8 @@ func WrapCollapsedMessage(gc *message.GenericContainer) *CollapsedMessage {
gc.Timestamp.SetSizeRequest(AvatarSize, -1) gc.Timestamp.SetSizeRequest(AvatarSize, -1)
gc.Timestamp.SetVAlign(gtk.ALIGN_START) gc.Timestamp.SetVAlign(gtk.ALIGN_START)
gc.Timestamp.SetXAlign(0.5) // middle align gc.Timestamp.SetXAlign(0.5) // middle align
gc.Timestamp.SetMarginEnd(container.ColumnSpacing)
gc.Timestamp.SetMarginStart(container.ColumnSpacing * 2) gc.Timestamp.SetMarginStart(container.ColumnSpacing * 2)
gc.Timestamp.SetMarginTop(container.ColumnSpacing)
// Set Content's padding accordingly to FullMessage's main box. // Set Content's padding accordingly to FullMessage's main box.
gc.Content.ToWidget().SetMarginEnd(container.ColumnSpacing * 2) gc.Content.ToWidget().SetMarginEnd(container.ColumnSpacing * 2)

View File

@ -3,6 +3,7 @@ package container
import ( import (
"container/list" "container/list"
"log" "log"
"time"
"github.com/diamondburned/cchat" "github.com/diamondburned/cchat"
"github.com/diamondburned/cchat-gtk/internal/gts" "github.com/diamondburned/cchat-gtk/internal/gts"
@ -83,10 +84,10 @@ func (c *ListStore) findIndex(id cchat.ID) (*messageRow, int) {
// //
// TODO: combine compact and full so they share the same attach method. // TODO: combine compact and full so they share the same attach method.
func (c *ListStore) SwapMessage(msg MessageRow) bool { func (c *ListStore) SwapMessage(msg MessageRow) bool {
// Wrap msg inside a *messageRow if it's not already. // Unwrap msg from a *messageRow if it's not already.
m, ok := msg.(*messageRow) m, ok := msg.(*messageRow)
if !ok { if ok {
m = &messageRow{MessageRow: msg} msg = m.MessageRow
} }
// Get the current message's index. // Get the current message's index.
@ -95,16 +96,16 @@ func (c *ListStore) SwapMessage(msg MessageRow) bool {
return false return false
} }
// Remove the to-be-replaced message box. We should probably reuse the row.
c.ListBox.Remove(oldMsg.Row())
// Add a row at index. The actual row we want to delete will be shifted // Add a row at index. The actual row we want to delete will be shifted
// downwards. // downwards.
c.ListBox.Insert(m.Row(), ix) c.ListBox.Insert(msg.Row(), ix)
// Delete the to-be-replaced message.
oldMsg.Row().Destroy()
// Set the message into the map. // Set the message into the map.
row := c.messages[idKey(m.ID())] row := c.messages[idKey(msg.ID())]
*row = *m row.MessageRow = msg
return true return true
} }
@ -403,9 +404,6 @@ func (c *ListStore) Highlight(msg MessageRow) {
row := msg.Row() row := msg.Row()
row.GrabFocus() row.GrabFocus()
c.ListBox.DragHighlightRow(row) c.ListBox.DragHighlightRow(row)
gts.DoAfter(2*time.Second, c.ListBox.DragUnhighlightRow)
}) })
} }
func (c *ListStore) Unhighlight() {
c.ListBox.DragUnhighlightRow()
}

View File

@ -113,6 +113,8 @@ func NewEmptyContainer() *GenericContainer {
user.Show() user.Show()
ctbody := labeluri.NewLabel(text.Rich{}) ctbody := labeluri.NewLabel(text.Rich{})
ctbody.SetVExpand(true)
ctbody.SetHExpand(true)
ctbody.SetEllipsize(pango.ELLIPSIZE_NONE) ctbody.SetEllipsize(pango.ELLIPSIZE_NONE)
ctbody.SetLineWrap(true) ctbody.SetLineWrap(true)
ctbody.SetLineWrapMode(pango.WRAP_WORD_CHAR) ctbody.SetLineWrapMode(pango.WRAP_WORD_CHAR)

View File

@ -108,7 +108,7 @@ func NewRequest(auther cchat.Authenticator, done func()) *Request {
continueBtn, _ := gtk.ButtonNewWithLabel("Continue") continueBtn, _ := gtk.ButtonNewWithLabel("Continue")
continueBtn.SetHAlign(gtk.ALIGN_CENTER) continueBtn.SetHAlign(gtk.ALIGN_CENTER)
continueBtn.Connect("clicked", done) continueBtn.Connect("clicked", func(*gtk.Button) { done() })
continueBtn.SetBorderWidth(12) continueBtn.SetBorderWidth(12)
continueBtn.Show() continueBtn.Show()