Changeset e54de59 in mainline


Ignore:
Timestamp:
2023-09-29T16:49:53Z (15 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
be0ec50
Parents:
4034954c
Message:

Place menus above parent rectangle if they do not fit below

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/src/window.c

    r4034954c re54de59  
    178178{
    179179        gfx_coord2_t dims;
     180        gfx_coord2_t below_pos;
     181        gfx_rect_t below_rect;
    180182
    181183        assert(params->placement != ui_wnd_place_default ||
     
    211213                break;
    212214        case ui_wnd_place_popup:
    213                 /* Place popup window below parent rectangle */
    214                 pos->x = params->prect.p0.x;
    215                 pos->y = params->prect.p1.y;
     215                /* Compute rectangle when placed below */
     216                below_pos.x = params->prect.p0.x;
     217                below_pos.y = params->prect.p1.y;
     218                gfx_rect_translate(&below_pos, &params->rect, &below_rect);
     219
     220                /* Does below_rect fit within the display? */
     221                if (gfx_rect_is_inside(&below_rect, drect)) {
     222                        /* Place popup window below parent rectangle */
     223                        pos->x = params->prect.p0.x - params->rect.p0.x;
     224                        pos->y = params->prect.p1.y - params->rect.p0.y;
     225                } else {
     226                        /* Place popup window above parent rectangle */
     227                        pos->x = params->prect.p0.x;
     228                        pos->y = params->prect.p0.y -
     229                            (params->rect.p1.y - params->rect.p0.y);
     230                }
    216231                break;
    217232        }
Note: See TracChangeset for help on using the changeset viewer.