2020-06-07 04:27:28 +00:00
|
|
|
package cozy
|
|
|
|
|
2020-06-13 07:29:32 +00:00
|
|
|
import (
|
|
|
|
"github.com/diamondburned/cchat-gtk/internal/ui/messages/container"
|
|
|
|
"github.com/diamondburned/cchat-gtk/internal/ui/messages/message"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Collapsed is a message that follows after FullMessage. It does not show
|
2020-06-07 04:27:28 +00:00
|
|
|
// the header, and the avatar is invisible.
|
2020-06-13 07:29:32 +00:00
|
|
|
type CollapsedMessage struct {
|
|
|
|
// Author is still updated normally.
|
2021-03-29 21:46:52 +00:00
|
|
|
*message.State
|
2020-06-13 07:29:32 +00:00
|
|
|
}
|
|
|
|
|
2021-03-29 21:46:52 +00:00
|
|
|
// WrapCollapsedMessage wraps the given message state to be a collapsed message.
|
|
|
|
func WrapCollapsedMessage(gc *message.State) *CollapsedMessage {
|
2020-06-13 07:29:32 +00:00
|
|
|
// Set Content's padding accordingly to FullMessage's main box.
|
2021-05-05 03:30:50 +00:00
|
|
|
gc.Content.SetMarginStart(container.ColumnSpacing*2 + AvatarSize)
|
|
|
|
gc.Content.SetMarginEnd(container.ColumnSpacing)
|
2020-06-13 07:29:32 +00:00
|
|
|
|
2021-01-02 09:24:14 +00:00
|
|
|
gc.PackStart(gc.Content, true, true, 0)
|
|
|
|
gc.SetClass("cozy-collapsed")
|
2020-12-31 03:00:00 +00:00
|
|
|
|
2020-06-13 07:29:32 +00:00
|
|
|
return &CollapsedMessage{
|
2021-05-05 03:30:50 +00:00
|
|
|
State: gc,
|
2020-06-13 07:29:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-01 07:26:17 +00:00
|
|
|
func (c *CollapsedMessage) Revert() *message.State {
|
|
|
|
c.ClearBox()
|
2021-05-05 03:30:50 +00:00
|
|
|
c.Content.SetMarginStart(0)
|
2021-05-01 07:26:17 +00:00
|
|
|
c.Content.SetMarginEnd(0)
|
|
|
|
return c.Unwrap()
|
|
|
|
}
|
2020-06-13 07:29:32 +00:00
|
|
|
|
2021-05-01 07:26:17 +00:00
|
|
|
type collapsed interface {
|
|
|
|
collapsed()
|
2020-06-13 07:29:32 +00:00
|
|
|
}
|
|
|
|
|
2021-05-01 07:26:17 +00:00
|
|
|
func (c *CollapsedMessage) collapsed() {}
|
|
|
|
|
2020-06-13 07:29:32 +00:00
|
|
|
type CollapsedSendingMessage struct {
|
2020-06-29 02:55:13 +00:00
|
|
|
*CollapsedMessage
|
2021-03-29 21:46:52 +00:00
|
|
|
message.Presender
|
2020-06-13 07:29:32 +00:00
|
|
|
}
|
|
|
|
|
2021-03-29 21:46:52 +00:00
|
|
|
func WrapCollapsedSendingMessage(pstate *message.PresendState) *CollapsedSendingMessage {
|
2020-06-13 07:29:32 +00:00
|
|
|
return &CollapsedSendingMessage{
|
2021-03-29 21:46:52 +00:00
|
|
|
CollapsedMessage: WrapCollapsedMessage(pstate.State),
|
|
|
|
Presender: pstate,
|
2020-06-13 07:29:32 +00:00
|
|
|
}
|
2020-06-07 04:27:28 +00:00
|
|
|
}
|