vlang / ui

A cross-platform UI library written in V
MIT License
2.32k stars 154 forks source link

fix: Stack widget should have lower z-index than child with the lowest z-index #527

Closed ArtemkaKun closed 1 year ago

ArtemkaKun commented 1 year ago

Currently, the Stack (column/row) calculates it's z-index based on children's z-index. Stack will have z-index = child_with_biggest_z_index - 1, which is wrong since a Stack can have children with different z-index and a Stack must have the lowest z-index to not cover children.

As an example, I have the following UI setup

    app.window = ui.window(
        width: 600
        height: 600
        title: 'Polygon Editor'
        children: [
            ui.column(
                id: 'test'
                children: [
                    ui.menubar(
                        height: 30
                        z_index: 2
                        items: [
                            ui.menuitem(
                                id: 'file_menu_button'
                                text: 'File...'
                                action: open_file_menu
                            ),
                        ]
                    ),
                    ui.menu(
                        id: 'file_menu_dropdown'
                        z_index: 2
                    ),
                    gg_canvaslayout(
                        app: viewport_app
                        z_index: 1
                    ),
                ]
            ),
        ]
    )

Both menubar and menu widgets must be above gg_canvaslayout, and gg_canvaslayout must be above column widget. So in this case column widget must have z-index 0

This PR fixes current behavior, so Stack widget will have z-index = child_with_lowest_z_index - 1