bug-gv
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gv] [bug #24069] Table of Contents not displayed for large docu


From: Bernhard R. Link
Subject: Re: [bug-gv] [bug #24069] Table of Contents not displayed for large documents
Date: Sat, 3 Jan 2009 11:39:33 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

* Markus Steinborn <address@hidden> [090102 21:08]:
> > And that scrolling
> >  to the very end of the list does not shows the very last item (but
> >  only a few pixel rows not containing a single black pixel)
> Here again the same is true for the page panel (if you are not using the
> arrow to scroll down).
> That is because the percent value does not reach 1 (i. e. 100%). This
> means that scaling it to a position will not reach the end.
> With very long file lists (tested with 4001 items) several items are not
> reachable by the scroll bar. I do not know Xaw good enough to calculate
> the largest possible percentage in order to rescale the values... I am
> trying with debug outputs... May help or not...

Indeed, the situation is worse than I thought. When I remember correctly
the TOC window case, it is quite of problematic because the situation is
quite messy (the Vlist window being in some layout widget, being in the
scroll widget still doing horizontal scrolls), so getting the actual
visible area reliable is quite hard.

The original code uses the layout widget size (aaa->core.height) and
the clip widget size (clip->core.height).

The following diff changes that to give the core.height to the Vlist
widget so it can say how many fit in there:


Index: src/FileSel.c
===================================================================
RCS file: /sources/gv/gv/src/FileSel.c,v
retrieving revision 1.15
diff -u -r1.15 FileSel.c
--- src/FileSel.c       2 Jan 2009 20:03:50 -0000       1.15
+++ src/FileSel.c       3 Jan 2009 10:21:19 -0000
@@ -1875,13 +1874,12 @@
     else if (s[0] == 's') { clip = FS_SUBCLIP; aaa = FS_SUBAAA; scroll = 
FS_SUBSCROLL; list = FS_SUBLIST; }
     else style=0;
     if (style == SCROLL_SCROLLPROC || style == SCROLL_JUMPPROC) {
-      int x,y;
+      int x;
       x = (int) aaa->core.x;
       ClipWidgetSetCoordinates(clip, x, 0);
       if (((int)(intptr_t)client_data)==1) 
       {
          int dy = (int)(intptr_t)call_data;
-         float h = (float)aaa->core.height;
          int ly = ((VlistWidget)list)->vlist.ydelta;
 
          /* Just scroll one position less... */
@@ -1889,21 +1887,21 @@
          if (dy<-ly) dy+=ly;
         
          VlistMoveFirstVisible(list, VlistGetFirstVisible(list), dy);
-         if (h < 1.0) h = 1.0;
-         
XawScrollbarSetThumb(scroll,VlistScrollPosition(list),(float)clip->core.height/h);
+         XawScrollbarSetThumb(scroll,VlistScrollPosition(list),
+                     VlistVisibleLength(list,clip->core.height));
       }
       else
       {
          float *percent = (float *) call_data;
-         float h = (float)aaa->core.height*2;
-         if (h < 1.0) h = 1.0;
-            VlistSetFirstVisible(list, (int)(VlistEntries(list)**percent));
+#if 0
+        printf("scrolling to %f\n", *percent);
+#endif
+        VlistSetFirstVisible(list, (int)(VlistEntries(list)**percent));
       }
 
     } else if (style == SCROLL_CLIPREPORT) {
-      float h = (float)aaa->core.height*2;
-      if (h < 1.0) h = 1.0;
-      
XawScrollbarSetThumb(scroll,VlistScrollPosition(list),(float)clip->core.height/h);
+      XawScrollbarSetThumb(scroll,VlistScrollPosition(list),
+                     VlistVisibleLength(list,clip->core.height));
     }
   }    
   ENDMESSAGE(cb_scroll)
Index: src/Vlist.c
===================================================================
RCS file: /sources/gv/gv/src/Vlist.c,v
retrieving revision 1.9
diff -u -r1.9 Vlist.c
--- src/Vlist.c 1 Jan 2009 11:43:42 -0000       1.9
+++ src/Vlist.c 3 Jan 2009 10:21:19 -0000
@@ -979,5 +979,35 @@
 {
   VlistWidget vw = (VlistWidget)w;
 
+#if 0
+  printf("Scroll position %d/%d=%f\n",
+                 vw->vlist.firstVisible,(int)(vw->vlist.entries),
+                 vw->vlist.firstVisible/(float)(vw->vlist.entries));
+#endif
   return vw->vlist.firstVisible/(float)vw->vlist.entries;
 }
+
+float VlistVisibleLength(Widget w, unsigned int height)
+{
+  VlistWidget vw = (VlistWidget)w;
+  float percent;
+  int entriesvisible = -1;
+
+  if (vw->vlist.ydelta > 0) {
+    if (height < 0) entriesvisible = -1;
+    else            entriesvisible = height/vw->vlist.ydelta;
+  }
+#if 0
+  printf("fitting %d entries of height %d in %d",
+                 entriesvisible, (int)vw->vlist.ydelta, (int)height);
+#endif
+  if (entriesvisible >= vw->vlist.entries)
+         entriesvisible = vw->vlist.entries;
+#if 0
+  printf(", visible percents %d/%d=%f\n",
+                 entriesvisible,(int)(vw->vlist.entries),
+                 entriesvisible/(float)(vw->vlist.entries));
+#endif
+  percent = entriesvisible/(float)(vw->vlist.entries);
+  return percent;
+}
Index: src/Vlist.h
===================================================================
RCS file: /sources/gv/gv/src/Vlist.h,v
retrieving revision 1.4
diff -u -r1.4 Vlist.h
--- src/Vlist.h 1 Jan 2009 11:42:47 -0000       1.4
+++ src/Vlist.h 3 Jan 2009 10:21:20 -0000
@@ -136,5 +136,6 @@
 extern void VlistSetFirstVisible(Widget, int);
 extern void VlistMoveFirstVisible(Widget, int, int);
 float VlistScrollPosition(Widget);
+float VlistVisibleLength(Widget, unsigned int);
 
 #endif /* _Vlist_h_ */

This already improves the situation a bit (Once it is finished,
it might also be needed for TOC listing).

The remaining issues seem to come from the Scrollbar, I fear.

With --disable-scrollbar-code, the patch leads to file windows that
scroll to the end find, but with really many items, scrolling to the
very first makes problems (with 80000, the first 6 seem to be missing,
looks like scrollbar does not generate scrolls to less then 0.0001).

With --enable-scrollbar-code, the first entries are reachable fine, but
at the end still quite some entries are missing. (and looking at the
values it sends, percent is still lower than (1 - the last visible length
given), so I guess this is in the scroll code)

Hochachtungsvoll,
        Bernhard R. Link




reply via email to

[Prev in Thread] Current Thread [Next in Thread]