Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 25f26600 in mainline


Ignore:
Timestamp:
2020-12-07T23:44:20Z (11 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
13d20e5, 4db4718d, e9c1639
Parents:
7e38970d
Message:

Resize application GC when resizing window (and app GC is being used)

Location:
uspace/lib/ui
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/include/ui/wdecor.h

    r7e38970d r25f26600  
    5454extern void ui_wdecor_rect_from_app(ui_wdecor_style_t, gfx_rect_t *,
    5555    gfx_rect_t *);
     56extern void ui_wdecor_app_from_rect(ui_wdecor_style_t, gfx_rect_t *,
     57    gfx_rect_t *);
    5658
    5759#endif
  • uspace/lib/ui/private/window.h

    r7e38970d r25f26600  
    4343#include <io/kbd_event.h>
    4444#include <io/pos_event.h>
     45#include <memgfx/memgc.h>
    4546
    4647/** Actual structure of window.
     
    6364        /** Application area bitmap */
    6465        gfx_bitmap_t *app_bmp;
     66        /** Application area memory GC */
     67        mem_gc_t *app_mgc;
    6568        /** Application area GC */
    6669        gfx_context_t *app_gc;
  • uspace/lib/ui/src/wdecor.c

    r7e38970d r25f26600  
    359359}
    360360
     361/** Application area rectangle from window rectangle.
     362 *
     363 * Note that this needs to work just based on a UI, without having an actual
     364 * window decoration, since we need it in process of resizing the window,
     365 * before it is actually resized.
     366 *
     367 * @param style Decoration style
     368 * @param rect Window decoration rectangle
     369 * @param app Place to store application area rectangle
     370 */
     371void ui_wdecor_app_from_rect(ui_wdecor_style_t style, gfx_rect_t *rect,
     372    gfx_rect_t *app)
     373{
     374        *app = *rect;
     375
     376        if ((style & ui_wds_frame) != 0) {
     377                app->p0.x += wdecor_edge_w;
     378                app->p0.y += wdecor_edge_h;
     379                app->p1.x -= wdecor_edge_w;
     380                app->p1.y -= wdecor_edge_h;
     381        }
     382
     383        if ((style & ui_wds_titlebar) != 0)
     384                app->p0.y += 22;
     385}
     386
    361387/** Get resize type for pointer at the specified position.
    362388 *
  • uspace/lib/ui/src/window.c

    r7e38970d r25f26600  
    292292        gfx_coord2_t offs;
    293293        gfx_rect_t nrect;
     294        gfx_rect_t arect;
     295        gfx_bitmap_t *app_bmp = NULL;
     296        gfx_bitmap_params_t params;
     297        gfx_bitmap_alloc_t alloc;
    294298        errno_t rc;
    295299
     
    301305        gfx_rect_rtranslate(&offs, rect, &nrect);
    302306
     307        if (window->app_gc != NULL) {
     308                assert(window->app_bmp != NULL);
     309
     310                gfx_bitmap_params_init(&params);
     311
     312                /*
     313                 * The bitmap will have the same dimensions as the
     314                 * application rectangle, but start at 0,0.
     315                 */
     316                ui_wdecor_app_from_rect(window->wdecor->style, &nrect, &arect);
     317                gfx_rect_rtranslate(&arect.p0, &arect, &params.rect);
     318
     319                rc = gfx_bitmap_create(window->gc, &params, NULL,
     320                    &app_bmp);
     321                if (rc != EOK)
     322                        goto error;
     323
     324                rc = gfx_bitmap_get_alloc(app_bmp, &alloc);
     325                if (rc != EOK)
     326                        goto error;
     327        }
     328
    303329        /* dwindow can be NULL in case of unit tests */
    304330        if (window->dwindow != NULL) {
    305331                rc = display_window_resize(window->dwindow, &offs, &nrect);
    306332                if (rc != EOK)
    307                         return rc;
     333                        goto error;
    308334        }
    309335
    310336        ui_wdecor_set_rect(window->wdecor, &nrect);
    311337        ui_wdecor_paint(window->wdecor);
     338
     339        if (window->app_gc != NULL) {
     340                mem_gc_retarget(window->app_mgc, &params.rect, &alloc);
     341
     342                gfx_bitmap_destroy(window->app_bmp);
     343                window->app_bmp = app_bmp;
     344        }
     345
    312346        return EOK;
     347error:
     348        if (app_bmp != NULL)
     349                gfx_bitmap_destroy(app_bmp);
     350        return rc;
    313351}
    314352
     
    389427                }
    390428
     429                window->app_mgc = memgc;
    391430                window->app_gc = mem_gc_get_ctx(memgc);
    392431        }
Note: See TracChangeset for help on using the changeset viewer.