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

Using Gtk.ScrolledWindow as a native layer produce strange bug #1229

Closed
MuhammadMuradG opened this issue Mar 26, 2021 · 1 comment
Closed
Labels
bug A crash or error in behavior.

Comments

@MuhammadMuradG
Copy link
Contributor

MuhammadMuradG commented Mar 26, 2021

Describe the bug
There is a small bug in Box widget, when we have padding for most outer Box the current implementation of min_width, and also of min_height, does not calculate it. This bug can be solve easily by adding these padding as following for both do_get_preferred_width and do_get_preferred_height functions:

    def do_get_preferred_width(self):
        # Calculate the minimum and natural width of the container.
        # print("GET PREFERRED WIDTH", self._impl.native)
        width = self._impl.interface.layout.width
 -      min_width = 0 if self._impl.min_width is None else self._impl.min_width
        for widget in self.get_children():
            if (
                min_width
                <= widget.interface.layout.absolute_content_right
                + widget.interface.style.padding_right
            ):
                min_width = (
                    widget.interface.layout.absolute_content_right
                    + widget.interface.style.padding_right
                )
+       min_width += self._impl.interface.style.padding_right
        if min_width > width:
            width = min_width

        return min_width, width

Unfortunately, solve this bug make the bug #1205 dominant in any widget that has Gtk.ScrolledWindow as a native layer

To Reproduce
Steps to reproduce the behavior:

  1. Fix min_width bug in Box widget as shown above.
  2. Run detailedlist example, for example.
  3. Try make window size bigger.
  4. Try now, make window size smaller.
  5. You will not be able to make it smaller

Expected behavior
You must be able to make it smaller

Environment:

  • Operating System: Kali
  • Python version: 3.9.2
  • Software versions:
    • Toga: 0.3.0.dev27

Additional context
I think the problem is in the our approach of implementation of the Box widget that may be contrasts with the Gtk.scrolledWindow behavior, also the problem may be related to #1047 question.

@freakboy3742, please take look at this.

@MuhammadMuradG MuhammadMuradG added the bug A crash or error in behavior. label Mar 26, 2021
@MuhammadMuradG
Copy link
Contributor Author

The bug was in incorrect calculation of min_width the correct way must be as follow:

-      min_width = 0 if self._impl.min_width is None else self._impl.min_width
+      min_width = self._impl.interface.style.padding_right if self._impl.min_width is None
                              else self._impl.min_width + self._impl.interface.style.padding_right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A crash or error in behavior.
Projects
None yet
Development

No branches or pull requests

1 participant