Bug 561364 - [GTK] Set size is ignored for checkboxes
Summary: [GTK] Set size is ignored for checkboxes
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-03-23 08:03 EDT by Thomas Singer CLA
Modified: 2020-09-23 11:10 EDT (History)
2 users (show)

See Also:


Attachments
Snippet (989 bytes, text/plain)
2020-03-23 08:03 EDT, Thomas Singer CLA
no flags Details
Screenshot illustrating the problem (5.64 KB, image/png)
2020-03-23 08:04 EDT, Thomas Singer CLA
no flags Details
Screenshot on Windows 10 (2.27 KB, image/png)
2020-03-23 08:05 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-03-23 08:03:18 EDT
Please execute the attached snippet on Linux. For me the set size of the checkbox is ignored - it is drawn as large as the text is.
Comment 1 Thomas Singer CLA 2020-03-23 08:03:58 EDT
Created attachment 282191 [details]
Snippet
Comment 2 Thomas Singer CLA 2020-03-23 08:04:22 EDT
Created attachment 282192 [details]
Screenshot illustrating the problem
Comment 3 Thomas Singer CLA 2020-03-23 08:05:55 EDT
Created attachment 282193 [details]
Screenshot on Windows 10
Comment 4 Alexandr Miloslavskiy CLA 2020-09-23 11:10:30 EDT
I have studied GTK sources and it seems to be by design:

1) Every widget has two rectangles:
   allocation - this is the designated widget size
   clip       - this is the area where widget is allowed to paint. It
                is often larger than allocation.
2) When a clip rectangle is changed for a widget, all parents that
   share the same GdkWindow have their clip rects adjusted to include
   the child's rect
   * see gtk_widget_set_clip()
3) GtkLabel includes entire text length in its clip rectangle. This
   seems to only be changed by enabling wrapping or ellipsis
   * see gtk_label_get_ink_rect() in gtk_label_size_allocate()
4) GtkLabel also calculates its minimum size as full text length,
   which is again modified by wrapping and ellipsis
   * see gtk_label_get_preferred_layout_size()
5) When GtkBox container performs layout, and there is not enough space
   to fit minimum sizes, it prints a warning and early returns.
   * see gtk_box_gadget_distribute()
6) Checkbox/radio/pushbuton all have a Label with text inside them.

To summarize, when a Label doesn't fit, it still paints remaining text
outside of bounds. SWT Label however is not affected because SWT
wraps it in an intermediate GtkEventBox which creates its own GdkWindow.

The simplest workaround is to wrap overflowing Button into a Composite.
Just like Label, this will wrap the control in an intermediate GdkWindow,
which stops clip rect propagation in gtk_widget_set_clip().