Bwidget Source Code
View Ticket
Not logged in
Ticket UUID: d5480d1da2ec9898400f218af80b336e8399747d
Title: ScrollableFrame: show scrollbars only when mouse in widget
Type: RFE Version: 1.9.10
Submitter: oehhar Created on: 2017-01-12 14:33:36
Subsystem: bwidget 1.x Assigned To: oehhar
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2017-01-23 12:57:05
Resolution: None Closed By: nobody
    Closed on:
Description: (text/x-fossil-wiki)
Alexandru provided a patch by E-Mail to only show the Scrollbars within a ScrollableFrame when the mouse is within the widget.

The option is "-onlyhover".
Tag: [rfe-d5480d1da2]
First commit: [246eaca515]
User Comments: oehhar added on 2017-01-23 12:57:05: (text/x-fossil-wiki)
Alexandru gave the following comment on c.l.t.:

I have an workarround for the flickering problem (and also an explanation why the flickering did not happen in my Tcl/Tk application). Just see next text code. It has comments on the issues:
<verbatim>
package require BWidget

# This frame is a necessary container for the ScrolledWindow.
# Do not pack the ScrolledWindow directly into the toplevel, since this would cause flickering when the mouse enters the window and move to the edge of the scroll bar.
pack [ttk::frame .f] -side top -expand 1 -fill both

pack [ScrolledWindow .f.sw -autohidescrollbar 1] -side top -expand 1 -fill both
text .f.sw.text -wrap none -relief sunken -bd 2 -fg #3F3F3F -setgrid 1 -width 70 -height 5 -undo 1 -autosep 1 -cursor arrow
.f.sw setwidget .f.sw.text

# Turn geometry propagation off. 
# This will avoid window size change when scrollbars are shown or hidden.
pack propagate . 0
</verbatim>

I also tried to replace the way scrollbars are manged: "place" instead of "grid". But I was very unhappy with the result. The scroll bars disappear when I click on them. Weird...

Nevertheless, I regard the new option as "working" provided one considers the two best practices when using "-autohidescrollbar 1":

   *   1. Do not pack the ScrolledWindow directly into the toplevel, since this would cause flickering when the mouse enters the window and move to the edge of the scroll bar. Use a simple "frame" as a container for the ScrolledWindow
   *   2. Turn geometry propagation off. This will avoid window size change when scrollbars are shown or hidden.

oehhar added on 2017-01-16 11:46:57: (text/x-fossil-wiki)
<h1>Test for ScrollingWindow</h1>

<h2>Text widget</h2>
Here is a test for ScrolledWindow with the text widget:
<verbatim>
pack [ScrolledWindow .sw -autohidescrollbar 1] -side top -expand 1 -fill both
text .sw.text
.sw setwidget .sw.text
.sw.text insert end [string repeat [string repeat A 1000]\n 200]
</verbatim>
Issues I see:
- when the window is in normal state, the window size flickers. When the mouse pointer is within the scrollbars while dragging, they are unmapped. One may drag the mouse-bars without seeing them ;-)
- When the window is maximized, the size does not change. When the mouse pointer is on the scrollbar, it flickers. 

<h2>ScrollableFrame</h2>
<verbatim>
set fInScrolledWindow 1
pack [ScrolledWindow .sw -autohidescrollbar $fInScrolledWindow] -side top -expand 1 -fill both
ScrollableFrame .sw.f -autohidescrollbar [expr {!$fInScrolledWindow}]
.sw setwidget .sw.f
set fc [.sw.f getframe]
pack [frame $fc.f -width 1000 -height 1000 -background yellow]
</verbatim>
Within this test script, there are the same issues as with the text widget.
In addition, if the mouse is over space not covered by ScrollableFrame within the ScrolledWindow, the scrollbars are errorneously hidden.

<h1>Test for ScrollableFrame</h1>

Please use the upper test with:
<verbatim>
set fInScrolledWindow 0
</verbatim>
Then, the upper drawbacks are solved.
Nevertheless, the required size flickers with the mouse.
The required size of the ScrolledWindow is not constant.

<Dynamic configuration>

None of the patches support:
<verbatim>
$f configure -autohidescrollbar 0
</verbatim>

<hr />

IMHO the drawbacks should be solved first.

oehhar added on 2017-01-16 08:38:00: (text/x-fossil-wiki)
<h1>Option Name</h1>
Kevin Waltzer and myself found:
<verbatim>
-autohidescrollbar 0/1
</verbatim>

<h1>Usage</h1>
Alexandru wrote:

The option is present in ScrolledWindow and ScrollableFrame to cover different applications:
<h2>ScrolledWindow and a scrolling-capable widget</h2>
One may use ScrolledWindow and a Widget which supports scrolling itself like TreeCtrl or TableList.
An additional ScrolledWindow would cause issues.

<h2>ScrolledWindow and ScrollableFrame</h2>
Only ScrollableFrame requires '-onlyhover 1'.

oehhar added on 2017-01-14 13:16:34: (text/x-fossil-wiki)
How is the usage ?
Why is there an option for ScrollableFrame and ScrolledWindow ?

Thanks,
Harald

oehhar added on 2017-01-14 12:43:10: (text/x-fossil-wiki)
<H1>Test</H1>
To test, one may use the bwidget demo by modifying the following line in demo/manager.tcl:
<verbatim>
--- bwidget-rfe-d5480d1da2/demo/manager.tcl
+++ bwidget-rfe-d5480d1da2/demo/manager_ori.tcl
@@ -76,15 +76,15 @@
             $lb insert end "Value $i"
         }
         $sw setwidget $lb
         pack $sw -fill both -expand yes
     }
 
     set sw [ScrolledWindow $pane3.sw -relief sunken -borderwidth 2]
+    set sf [ScrollableFrame $sw.f -onlyhover 1]
-    set sf [ScrollableFrame $sw.f]
     $sw setwidget $sf
     set subf [$sf getframe]
     set lab [label $subf.lab -text "This is a ScrollableFrame"]
     set chk [checkbutton $subf.chk -text "Constrained width" \
                  -variable DemoManager::_constw \
                  -command  "$sf configure -constrainedwidth \$DemoManager::_constw"]
     pack $lab
</verbatim>
<h1>Active by default</h1>
It is proposed that this option is active by default if themed.
I don't think this is a good idea.

<h1>Documentation</h1>
   *   File documentation always repets the same sentence
   *   User documentation missing

I suppose, I will correct all this in a follow-up commit.