From 98a23246e479c36b98769faeeb0d92408f4d83b7 Mon Sep 17 00:00:00 2001 From: qydysky Date: Tue, 20 Oct 2020 11:29:17 +0800 Subject: [PATCH] =?utf8?q?gtk=E5=BC=B9=E5=B9=95=E7=AA=97=E6=89=8B=E5=8A=A8?= =?utf8?q?=E6=BB=9A=E5=8A=A8=E6=9A=82=E5=81=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Reply/Reply.go | 2 +- Reply/gtk.go | 26 ++++++++++++++++++++++---- demo/ui/1.glade | 2 +- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/Reply/Reply.go b/Reply/Reply.go index 0ef3123..fcfd1fd 100644 --- a/Reply/Reply.go +++ b/Reply/Reply.go @@ -537,7 +537,7 @@ func Msg_showdanmu(auth interface{}, msg string) { return } else {msg = _msg} Assf(msg)//ass - Gui_show(msg) + Gui_show(fmt.Sprint(auth) +`: `+ msg) } fmt.Println(msg) diff --git a/Reply/gtk.go b/Reply/gtk.go index 4a2bde0..bdb5470 100644 --- a/Reply/gtk.go +++ b/Reply/gtk.go @@ -15,6 +15,7 @@ var BList = list.New() var ( Gtk_on bool + Gtk_Tra bool Gtk_danmuChan chan string = make(chan string, 10) ) @@ -52,6 +53,15 @@ func Gtk_danmu() { } } + var viewport0 *gtk.Viewport + { + obj, err := builder.GetObject("viewport0") + if err != nil {return} + if tmp,ok := obj.(*gtk.Viewport); ok { + viewport0 = tmp + } + } + var grid0 *gtk.Grid; { obj, err := builder.GetObject("grid0") @@ -76,16 +86,24 @@ func Gtk_danmu() { b.SetText(s) t.HandlerDisconnect(handle) - tmp := scrolledwindow0.GetVAdjustment() - tmp.SetValue(tmp.GetUpper()) + if Gtk_Tra { + tmp := scrolledwindow0.GetVAdjustment() + tmp.SetValue(tmp.GetUpper()) + } if len(Gtk_danmuChan) != 0 {y()} }) - + + { + tmp := scrolledwindow0.GetVAdjustment() + h := viewport0.GetViewWindow().WindowGetHeight() + Gtk_Tra = tmp.GetUpper() - tmp.GetValue() < float64(h) + 10 + } + tmp,_ := t.Container.Widget.Cast() loc := int(grid0.Container.GetChildren().Length()); grid0.InsertRow(loc); grid0.Attach(tmp, 0, loc, 1, 1) - if loc > 50 { + if Gtk_Tra && loc > 50 { l,_ := grid0.GetChildAt(0, 0) l.ToWidget().Destroy() grid0.RemoveRow(0) diff --git a/demo/ui/1.glade b/demo/ui/1.glade index abc1796..7d10415 100644 --- a/demo/ui/1.glade +++ b/demo/ui/1.glade @@ -16,7 +16,7 @@ True never - + True False none -- 2.39.2