Bug 565883 - [GTK] Scrolling in Canvas is different than in Table
Summary: [GTK] Scrolling in Canvas is different than in Table
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.15   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-07 05:44 EDT by Thomas Singer CLA
Modified: 2020-09-21 11:22 EDT (History)
3 users (show)

See Also:


Attachments
Snippet to reproduce (1.43 KB, text/plain)
2020-08-07 05:45 EDT, Thomas Singer CLA
no flags Details
After scrolling 2 steps (28.11 KB, image/png)
2020-08-07 05:46 EDT, Thomas Singer CLA
no flags Details
Snippet with large scroll steps in Canvas (1.43 KB, text/plain)
2020-08-07 06:17 EDT, Thomas Singer CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Singer CLA 2020-08-07 05:44:31 EDT
Please launch the attached snippet on Linux and use the mouse wheel to scroll. In the left Canvas scrolling appears to be much slower (sometimes one mouse wheel step does not result in any scrolling at all) then in the right Table (often one mouse wheel step results in 2 scrolled rows).
Comment 1 Thomas Singer CLA 2020-08-07 05:45:15 EDT
Created attachment 283811 [details]
Snippet to reproduce
Comment 2 Thomas Singer CLA 2020-08-07 05:46:50 EDT
Created attachment 283812 [details]
After scrolling 2 steps
Comment 3 Thomas Singer CLA 2020-08-07 06:17:37 EDT
Created attachment 283813 [details]
Snippet with large scroll steps in Canvas
Comment 4 Thomas Singer CLA 2020-08-07 06:18:50 EDT
In the "Snippet with large scroll steps in Canvas" it scrolls 9 rows (Canvas) vs. 2 (Table) per mouse wheel step.
Comment 5 Soraphol (Paul) Damrongpiriyapong CLA 2020-08-21 14:33:53 EDT
Hello, I have tested the snippets and reproduce the same results. However, I'm not sure what the problem is here. Since the canvas scrollbar is having custom values set, it will be different than the Table scroll speed.
Comment 6 Thomas Singer CLA 2020-08-24 03:43:10 EDT
(In reply to Soraphol (Paul) Damrongpiriyapong from comment #5)
> Since the canvas scrollbar is having
> custom values set, it will be different than the Table scroll speed.

Try to implement a table-like control (which we did because Table was too slow on some platforms to handle large amounts of data). The user will expect to see the same scroll effect on a Table or custom control. On Windows it works as expected, but not on Linux.
Comment 7 Alexandr Miloslavskiy CLA 2020-09-21 11:18:46 EDT
I found that GTK table behaves the following way (in GTK terms):
1) Scrolling speed is calculated from verticalBar.setThumb()
2) GTK's Table passes Table height to verticalBar.setThumb()
3) The final formula is for pixels scrolled per wheel step:
   min(tableHeight/2, pow(tableHeight, 2/3))

Note that on Windows, scrolling speed does not depend on tableHeight.

So in order to mimic the behavior of GTK, one should do the following:
1) Set max of verticalBar to total pixel height of contents
2) verticalBar.setThumb(canvas.getSize().y)
3) Consider 'verticalBar.getSelection()' to be measured in pixels.

Note that measuring in anything but pixels is hard because GTK uses pow(,2/3) and SWT discards fractional part of 'verticalBar.getSelection()'.

References in GTK code:
* get_scroll_unit() in gtkscrolledwindow.c
* gtk_adjustment_configure() in gtk_tree_view_size_allocate()