View Issue Details

IDProjectCategoryView StatusLast Update
0036942LazarusWidgetsetpublic2020-09-25 22:21
ReporterChris Rorden Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformRyzen 3900XOSUbuntu 
Product Version2.1 (SVN) 
Summary0036942: GTK3: Anchor autosizing
DescriptionAnton's recent GTK3 patches have made huge strides in usability for many applications.

I note a few outstanding issues. These can be seen with my MRIcroGL github project, but I provide a simpler project below to demonstrate:
 
1. TSpinEdit spinner width ignored for anchoring (e.g. "color" button should be to the left of the "width" spin edit.
2. Button size not accurate (note overlap for L/A/P/R buttons, though note improved if buttons have AutoSize := true
3. Toggling visibility of components can lead to errors: Press the "Options" button a few times to show/hide boxes: not that the "Lines" and "Cutout" group boxes overlap. This is fixed if the user interactively resizes the form. Perhaps hiding/showing components requires some resize/refresh call.

Note: This issue is related to and extends issue 0036826 with a better example. If that issue is set to fixed, I will close it.

TagsNo tags attached.
Fixed in Revision63911
LazTarget-
WidgetsetGTK 3
Attached Files

Relationships

related to 0036826 new GTK3 AutoSize TCheckListBox 
related to 0037802 closedJuha Manninen gtk3: Implement TextHint for TEdit 

Activities

Chris Rorden

2020-04-21 13:38

reporter  

overlap.png (40,664 bytes)   
overlap.png (40,664 bytes)   
overlap2.png (44,421 bytes)   
overlap2.png (44,421 bytes)   
gtk3_autosize.zip (113,660 bytes)

Chris Rorden

2020-04-21 13:48

reporter   ~0122314

Another strange and perhaps related issue in this project: when the gtk3 project first launches, the TTrackbars are frozen - the user can not move their position. Resizing the form allows the user to interact with these controls normally.

Anton Kavalenka

2020-04-21 14:03

reporter   ~0122317

Last edited: 2020-04-21 14:05

View 3 revisions

About frozen trackbars - it looks like spinbuttons inside the gropbox think they are occupying the same places as trackbar.
I my case the situation is even worse.
See the spinbuttons (top-right corner), which have to be inside groupbox. Btw - they are handling mouse clicks, and update edits.

Looks like GTK3 Fixed widget (which is used inside TGroupBox) does not care about child controls.

Chris Rorden

2020-04-24 18:12

reporter   ~0122385

I do hope you can resolve this. Thanks to your work (and others), a lot of GTK3 now works with Lazarus. But it is unclear how some of these details will get addressed. Your issue sounds like this:

https://blog.gtk.org/2017/04/25/widget-hierarchies-in-gtk-4-0/
"complicated widgets in GTK+3 which don’t inherit from GtkContainer, e.g. GtkSpinButton or GtkSwitch. These never have real GtkWidget children. Consider, for example, the two clickable areas in a GtkSpinButton. I’m not calling them “buttons” here for a reason, since in GTK+3, they are not actual GtkButton instances, as GtkSpinButton is not a GtkContainer. Instead, GtkSpinButton has to work around that fact, and create two GdkWindows for the up/down areas and then render two icons in there"

Anton Kavalenka

2020-09-23 15:22

reporter   ~0125776

Last edited: 2020-09-23 15:22

View 2 revisions

Looks like button autosizing problem was caused by incoherence between LCL and GTK3.
The patch forces button constraint (as GTK3 button size can not be less than specified by theme)
Also fixes the button click handler double delivery. As button "clicked" handler introduced, there is no need in default mouse processing.
gtk3widgets.diff (1,034 bytes)   
Index: lcl/interfaces/gtk3/gtk3widgets.pas
===================================================================
--- lcl/interfaces/gtk3/gtk3widgets.pas	(revision 63907)
+++ lcl/interfaces/gtk3/gtk3widgets.pas	(working copy)
@@ -2649,6 +2649,7 @@
   ARect: TGdkRectangle;
   ARgba: TGdkRGBA;
   i: TGtkStateType;
+  mh,nh,mw,nw:gint;
 begin
   FFocusableByMouse := False;
   FCentralWidget := nil;
@@ -2671,6 +2672,13 @@
       height := LCLObject.Height;
     end;
     FWidget^.set_allocation(@ARect);
+
+    fWidget^.get_preferred_height(@mh,@nh);
+    fWidget^.get_preferred_width(@mw,@nw);
+
+    LCLObject.Constraints.MinHeight:=mh;
+    LCLObject.Constraints.MinWidth:=mw;
+
   end;
   LCLIntf.SetProp(HWND(Self),'lclwidget',Self);
 
@@ -6562,6 +6570,8 @@
   g_signal_connect_data(btn,'clicked',
         TGCallback(@TGtk3Button.ButtonClicked), LCLObject, nil, 0);
 
+  LCLObject.ControlStyle:=LCLObject.ControlStyle+[csClickEvents];
+
   FMargin := -1;
   FLayout := GTK_POS_LEFT;
   FSpacing := 2; // default gtk3 spacing is 2
gtk3widgets.diff (1,034 bytes)   

Juha Manninen

2020-09-23 21:35

developer   ~0125790

I plan to test and apply this soon.
A question: do you know why Lazarus IDE itself does not work when built for LCL-GTK3? I tested some weeks ago and IIRC it crashed at the start.

Anton Kavalenka

2020-09-23 21:37

reporter   ~0125791

I will look

Anton Kavalenka

2020-09-23 21:40

reporter   ~0125793

Juha Manninen

2020-09-24 11:34

developer   ~0125812

The patch is already applied earlier in 63911. Does it solve this issue?

Anton Kavalenka

2020-09-24 11:56

reporter   ~0125813

Yes, these lines
fWidget^.get_preferred_height(@mh,@nh);
fWidget^.get_preferred_width(@mw,@nw);

LCLObject.Constraints.MinHeight:=mh;
LCLObject.Constraints.MinWidth:=mw;

Juha Manninen

2020-09-24 17:11

developer   ~0125823

Resolving.

Issue History

Date Modified Username Field Change
2020-04-21 13:38 Chris Rorden New Issue
2020-04-21 13:38 Chris Rorden File Added: overlap.png
2020-04-21 13:38 Chris Rorden File Added: overlap2.png
2020-04-21 13:38 Chris Rorden File Added: gtk3_autosize.zip
2020-04-21 13:48 Chris Rorden Note Added: 0122314
2020-04-21 14:03 Anton Kavalenka Note Added: 0122317
2020-04-21 14:03 Anton Kavalenka File Added: Здымак экрана, 2020-04-21 15-01-13.png
2020-04-21 14:05 Anton Kavalenka Note Edited: 0122317 View Revisions
2020-04-21 14:05 Anton Kavalenka Note Edited: 0122317 View Revisions
2020-04-21 16:26 Juha Manninen Relationship added related to 0036826
2020-04-24 18:12 Chris Rorden Note Added: 0122385
2020-09-23 15:22 Anton Kavalenka Note Added: 0125776
2020-09-23 15:22 Anton Kavalenka File Added: gtk3widgets.diff
2020-09-23 15:22 Anton Kavalenka Note Edited: 0125776 View Revisions
2020-09-23 21:32 Juha Manninen Assigned To => Juha Manninen
2020-09-23 21:32 Juha Manninen Status new => assigned
2020-09-23 21:35 Juha Manninen Note Added: 0125790
2020-09-23 21:37 Anton Kavalenka Note Added: 0125791
2020-09-23 21:40 Anton Kavalenka Note Added: 0125793
2020-09-23 21:40 Anton Kavalenka File Added: Здымак экрана, 2020-09-23 22-40-23.png
2020-09-24 11:33 Juha Manninen Relationship added related to 0037802
2020-09-24 11:34 Juha Manninen Status assigned => feedback
2020-09-24 11:34 Juha Manninen LazTarget => -
2020-09-24 11:34 Juha Manninen Note Added: 0125812
2020-09-24 11:56 Anton Kavalenka Note Added: 0125813
2020-09-24 17:11 Juha Manninen Status feedback => resolved
2020-09-24 17:11 Juha Manninen Resolution open => fixed
2020-09-24 17:11 Juha Manninen Fixed in Revision => 63911
2020-09-24 17:11 Juha Manninen Widgetset GTK 3 => GTK 3
2020-09-24 17:11 Juha Manninen Note Added: 0125823
2020-09-25 22:21 Chris Rorden Status resolved => closed