Changeset 66a2becf in mainline for uspace/lib/ui/src/window.c
- Timestamp:
- 2020-11-11T18:05:01Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b93ec7c0
- Parents:
- d942ca4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/src/window.c
rd942ca4 r66a2becf 36 36 #include <display.h> 37 37 #include <errno.h> 38 #include <gfx/bitmap.h> 38 39 #include <gfx/context.h> 39 40 #include <gfx/render.h> … … 41 42 #include <io/pos_event.h> 42 43 #include <mem.h> 44 #include <memgfx/memgc.h> 43 45 #include <stdlib.h> 44 46 #include <ui/control.h> … … 74 76 .move = wd_move 75 77 }; 78 79 static void ui_window_app_update(void *, gfx_rect_t *); 76 80 77 81 /** Initialize window parameters structure. … … 223 227 } 224 228 229 /** Get UI resource from window. 230 * 231 * @param window Window 232 * @return UI resource 233 */ 225 234 ui_resource_t *ui_window_get_res(ui_window_t *window) 226 235 { … … 228 237 } 229 238 239 /** Get window GC. 240 * 241 * @param window Window 242 * @return GC (relative to window) 243 */ 230 244 gfx_context_t *ui_window_get_gc(ui_window_t *window) 231 245 { … … 233 247 } 234 248 249 /** Get window application area GC 250 * 251 * @param window Window 252 * @param rgc Place to store GC (relative to application area) 253 * @return EOK on success or an error code 254 */ 255 errno_t ui_window_get_app_gc(ui_window_t *window, gfx_context_t **rgc) 256 { 257 gfx_bitmap_params_t params; 258 gfx_bitmap_alloc_t alloc; 259 gfx_rect_t rect; 260 mem_gc_t *memgc; 261 errno_t rc; 262 263 if (window->app_gc == NULL) { 264 assert(window->app_bmp == NULL); 265 266 gfx_bitmap_params_init(¶ms); 267 268 /* 269 * The bitmap will have the same dimensions as the 270 * application rectangle, but start at 0,0. 271 */ 272 ui_window_get_app_rect(window, &rect); 273 gfx_rect_rtranslate(&rect.p0, &rect, ¶ms.rect); 274 275 rc = gfx_bitmap_create(window->gc, ¶ms, NULL, 276 &window->app_bmp); 277 if (rc != EOK) 278 return rc; 279 280 rc = gfx_bitmap_get_alloc(window->app_bmp, &alloc); 281 if (rc != EOK) { 282 gfx_bitmap_destroy(window->app_bmp); 283 return rc; 284 } 285 286 rc = mem_gc_create(¶ms.rect, &alloc, ui_window_app_update, 287 (void *) window, &memgc); 288 if (rc != EOK) { 289 gfx_bitmap_destroy(window->app_bmp); 290 return rc; 291 } 292 293 window->app_gc = mem_gc_get_ctx(memgc); 294 } 295 296 *rgc = window->app_gc; 297 return EOK; 298 } 299 300 /** Get window application rectangle 301 * 302 * @param window Window 303 * @param rect Place to store application rectangle 304 */ 235 305 void ui_window_get_app_rect(ui_window_t *window, gfx_rect_t *rect) 236 306 { … … 241 311 } 242 312 313 /** Paint window 314 * 315 * @param window Window 316 * @return EOK on success or an error code 317 */ 243 318 errno_t ui_window_paint(ui_window_t *window) 244 319 { … … 428 503 } 429 504 505 /** Application area update callback 506 * 507 * @param arg Argument (ui_window_t *) 508 * @param rect Rectangle to update 509 */ 510 static void ui_window_app_update(void *arg, gfx_rect_t *rect) 511 { 512 ui_window_t *window = (ui_window_t *) arg; 513 gfx_rect_t arect; 514 515 ui_window_get_app_rect(window, &arect); 516 517 /* Render bitmap rectangle inside the application area */ 518 (void) gfx_bitmap_render(window->app_bmp, rect, &arect.p0); 519 } 520 430 521 /** @} 431 522 */
Note:
See TracChangeset
for help on using the changeset viewer.