Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GTK4] Implement correct moveAbove()/moveBelow() control behavior #1780

Merged
merged 1 commit into from
Feb 12, 2025

Conversation

ptziegler
Copy link
Contributor

@ptziegler ptziegler commented Jan 30, 2025

Regardless of which control are given as input parameters, the controls are currently always added as last child to their parents. Underlying issue seems to be that the swt_fixed_restack() method does not handle the GTK4 widgets correctly. As a solution, perform the movement using the proper API.

To understand the combination in which GTK methods need to be called, consider the expected behavior based on the GTK and SWT documentation:

[GTK4 Documentation]

  • gtk_widget_insert_after(widget, parent, previous_sibling)

    It will be placed after previous_sibling, or at the beginning if previous_sibling is NULL.

  • gtk_widget_insert_before(widget, parent, next_sibling)

    It will be placed before next_sibling, or at the end if next_sibling is NULL.

[SWT Documentation]

  • moveAbove(control)

    Moves the receiver above the specified control in the drawing order. If the argument is null, then the receiver is moved to the top of the drawing order

This means that if the specified control is NULL,
gtk_widget_insert_after(...) needs to be called, otherwise gtk_widget_insert_before(...).

  • moveBelow(control)

    Moves the receiver below the specified control in the drawing order. If the argument is null, then the receiver is moved to the bottom of the drawing order.

Here the inverse applies. If the specified control is NULL, gtk_widget_insert_before(...) needs to be called, otherwise gtk_widget_insert_after(...).

@ptziegler
Copy link
Contributor Author

Just a little demo to illustrate how it behaves using Snippet6.

Recording.webm

Copy link
Contributor

github-actions bot commented Jan 30, 2025

Test Results

   502 files  ±0     502 suites  ±0   11m 17s ⏱️ + 1m 45s
 4 334 tests ±0   4 320 ✅ ±0   14 💤 ±0  0 ❌ ±0 
16 575 runs  ±0  16 466 ✅ ±0  109 💤 ±0  0 ❌ ±0 

Results for commit 8f1f5be. ± Comparison against base commit 3e8da4a.

♻️ This comment has been updated with latest results.

@ptziegler ptziegler force-pushed the gtk4-move-widgets branch 2 times, most recently from d154c29 to 1c281f5 Compare February 10, 2025 18:26
Regardless of which control are given as input parameters, the controls
are currently always added as last child to their parents. Underlying
issue seems to be that the swt_fixed_restack() method does not handle
the GTK4 widgets correctly. As a solution, perform the movement using
the proper API.

To understand the combination in which GTK methods need to be called,
consider the expected behavior based on the GTK and SWT documentation:

[GTK4 Documentation]

- gtk_widget_insert_after(widget, parent, previous_sibling)

  It will be placed after previous_sibling, or at the beginning if
  previous_sibling is NULL.

- gtk_widget_insert_before(widget, parent, next_sibling)

  It will be placed before next_sibling, or at the end if next_sibling
  is NULL.

[SWT Documentation]

- moveAbove(control)

  Moves the receiver above the specified control in the drawing order.
  If the argument is null, then the receiver is moved to the top of the
  drawing order

This means that if the specified control is NULL,
gtk_widget_insert_after(...) needs to be called, otherwise
gtk_widget_insert_before(...).

- moveBelow(control)

  Moves the receiver below the specified control in the drawing order.
  If the argument is null, then the receiver is moved to the bottom of
  the drawing order.

Here the inverse applies. If the specified control is NULL,
gtk_widget_insert_before(...) needs to be called, otherwise
gtk_widget_insert_after(...).
@ptziegler
Copy link
Contributor Author

Everything is green now. Unless there are any objections, I'll plan on merging this later today.

@laeubi
Copy link
Contributor

laeubi commented Feb 12, 2025

Everything is green now. Unless there are any objections, I'll plan on merging this later today.

Just go ahead!

@ptziegler ptziegler merged commit 709f323 into eclipse-platform:master Feb 12, 2025
14 checks passed
@ptziegler ptziegler deleted the gtk4-move-widgets branch February 12, 2025 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants