]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
gtk弹幕窗手动滚动暂停
authorqydysky <qydysky@foxmail.com>
Tue, 20 Oct 2020 03:29:17 +0000 (11:29 +0800)
committerqydysky <qydysky@foxmail.com>
Tue, 20 Oct 2020 03:29:17 +0000 (11:29 +0800)
Reply/Reply.go
Reply/gtk.go
demo/ui/1.glade

index 0ef31234d72e2292d9f077b13ff16bdf13dc4762..fcfd1fdd3badd975dd4ba60c5bb5f60374847b27 100644 (file)
@@ -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)
index 4a2bde04bfbe302d37fb9428e7a1244b1d15f653..bdb5470bca38c8494a90d22d60bda57c77056a81 100644 (file)
@@ -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)
index abc1796c2c757dd1bcb9ab2b4c177f7456b4318c..7d1041552127fc9d9794608416236b77c22a4bc9 100644 (file)
@@ -16,7 +16,7 @@
         <property name="can_focus">True</property>
         <property name="hscrollbar_policy">never</property>
         <child>
-          <object class="GtkViewport">
+          <object class="GtkViewport" id="viewport0">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="shadow_type">none</property>