1
0
Fork 0
mirror of https://github.com/diamondburned/cchat-gtk.git synced 2024-11-16 11:12:44 +00:00
cchat-gtk/internal/ui/primitives/scrollinput/scrollinput.go

34 lines
798 B
Go
Raw Normal View History

2020-07-01 01:09:22 +00:00
package scrollinput
import "github.com/gotk3/gotk3/gtk"
func NewVScroll(maxHeight int) *gtk.ScrolledWindow {
sw, _ := gtk.ScrolledWindowNew(nil, nil)
sw.SetPolicy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
sw.SetProperty("propagate-natural-height", true)
sw.SetProperty("max-content-height", maxHeight)
return sw
}
2020-07-01 01:09:22 +00:00
func NewV(text *gtk.TextView, maxHeight int) *gtk.ScrolledWindow {
// Wrap mode needed since we're not doing horizontal scrolling.
text.SetWrapMode(gtk.WRAP_WORD_CHAR)
sw := NewVScroll(maxHeight)
2020-07-01 01:09:22 +00:00
sw.Add(text)
return sw
}
func NewH(text *gtk.TextView) *gtk.ScrolledWindow {
text.SetHExpand(true)
sw, _ := gtk.ScrolledWindowNew(nil, nil)
sw.Add(text)
sw.SetPolicy(gtk.POLICY_EXTERNAL, gtk.POLICY_NEVER)
sw.SetProperty("propagate-natural-width", true)
return sw
}