Skip to content

GUI AnchorLayout broken when using ScrollArea #2818

@DragonMoffon

Description

@DragonMoffon

While trying to right align and left aligned different elements in a scroll area the UIAnchorLayout caused all of the UI to disappear. To test I made this small minimal snippet, and discovered that mixing UIBoxLayout and UIAnchorLayout led to the UIAnchorLayout children to draw over the UIBoxLayout.

from arcade import Window, gui
from arcade.gui import experimental


class TestWindow(Window):
    def __init__(self):
        super().__init__()
        self.manager = gui.UIManager()
        self.manager.enable()

        self.entry_box_1 = gui.UIBoxLayout(
            vertical=False,
            width=self.width,
            height=150,
            space_between=15,
            children=(gui.UIDummy() for _ in range(5)),
        )
        self.entry_box_2 = gui.UIAnchorLayout(
            width=self.width, height=150, children=(gui.UIDummy())
        )
        self.entry_box_2.add(gui.UIDummy(), anchor_x="left")

        self.scroll_box = gui.UIBoxLayout(
            width=self.width,
            height=4 * self.height,
            vertical=True,
            children=(
                self.entry_box_1,
                self.entry_box_2,
            ),
        )
        self.scroll_area = experimental.UIScrollArea(
            x=0,
            y=0,
            width=self.width,
            height=self.height,
            canvas_size=(self.width, 4 * self.height),
            children=(self.scroll_box,),
        )
        self.manager.add(self.scroll_area)

    def on_draw(self):
        self.clear()
        self.manager.draw()

    def on_key_press(self, symbol: int, modifiers: int):
        self.manager.debug()


win = TestWindow()
win.run()

Result:
Image

Expected:
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions