Changeset d68239a1 in mainline for uspace/lib/ui/src/paint.c


Ignore:
Timestamp:
2022-04-04T14:48:41Z (2 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
86fff971
Parents:
0d1d0ea
git-author:
Jiri Svoboda <jiri@…> (2022-04-03 17:48:17)
git-committer:
Jiri Svoboda <jiri@…> (2022-04-04 14:48:41)
Message:

Scrollbar needs custom button decorations

Push button now allows setting a 'custom decoration' which means
instead of painting the button text a callback function is invoked
to paint the decoration.

File:
1 edited

Legend:

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

    r0d1d0ea rd68239a1  
    360360}
    361361
     362/** Paint upward pointing triangle.
     363 *
     364 * @param gc Graphic context
     365 * @param pos Center position
     366 * @param n Length of triangle side
     367 */
     368errno_t ui_paint_up_triangle(gfx_context_t *gc, gfx_coord2_t *pos,
     369    gfx_coord_t n)
     370{
     371        gfx_coord_t i;
     372        errno_t rc;
     373        gfx_rect_t rect;
     374
     375        for (i = 0; i < n; i++) {
     376                rect.p0.x = pos->x - i;
     377                rect.p0.y = pos->y - n / 2 + i;
     378                rect.p1.x = pos->x + i + 1;
     379                rect.p1.y = pos->y - n / 2 + i + 1;
     380                rc = gfx_fill_rect(gc, &rect);
     381                if (rc != EOK)
     382                        return rc;
     383        }
     384
     385        return EOK;
     386}
     387
     388/** Paint downward pointing triangle.
     389 *
     390 * @param gc Graphic context
     391 * @param pos Center position
     392 * @param n Length of triangle side
     393 */
     394errno_t ui_paint_down_triangle(gfx_context_t *gc, gfx_coord2_t *pos,
     395    gfx_coord_t n)
     396{
     397        gfx_coord_t i;
     398        errno_t rc;
     399        gfx_rect_t rect;
     400
     401        for (i = 0; i < n; i++) {
     402                rect.p0.x = pos->x - i;
     403                rect.p0.y = pos->y + n / 2 - i;
     404                rect.p1.x = pos->x + i + 1;
     405                rect.p1.y = pos->y + n / 2 - i + 1;
     406                rc = gfx_fill_rect(gc, &rect);
     407                if (rc != EOK)
     408                        return rc;
     409        }
     410
     411        return EOK;
     412}
     413
     414/** Paint left pointing triangle.
     415 *
     416 * @param gc Graphic context
     417 * @param pos Center position
     418 * @param n Length of triangle side
     419 */
     420errno_t ui_paint_left_triangle(gfx_context_t *gc, gfx_coord2_t *pos,
     421    gfx_coord_t n)
     422{
     423        gfx_coord_t i;
     424        errno_t rc;
     425        gfx_rect_t rect;
     426
     427        for (i = 0; i < n; i++) {
     428                rect.p0.x = pos->x - n / 2 + i;
     429                rect.p0.y = pos->y - i;
     430                rect.p1.x = pos->x - n / 2 + i + 1;
     431                rect.p1.y = pos->y + i + 1;
     432                rc = gfx_fill_rect(gc, &rect);
     433                if (rc != EOK)
     434                        return rc;
     435        }
     436
     437        return EOK;
     438}
     439
     440/** Paint right pointing triangle.
     441 *
     442 * @param gc Graphic context
     443 * @param pos Center position
     444 * @param n Length of triangle side
     445 */
     446errno_t ui_paint_right_triangle(gfx_context_t *gc, gfx_coord2_t *pos,
     447    gfx_coord_t n)
     448{
     449        gfx_coord_t i;
     450        errno_t rc;
     451        gfx_rect_t rect;
     452
     453        for (i = 0; i < n; i++) {
     454                rect.p0.x = pos->x + n / 2 - i;
     455                rect.p0.y = pos->y - i;
     456                rect.p1.x = pos->x + n / 2 - i + 1;
     457                rect.p1.y = pos->y + i + 1;
     458                rc = gfx_fill_rect(gc, &rect);
     459                if (rc != EOK)
     460                        return rc;
     461        }
     462
     463        return EOK;
     464}
     465
    362466/** Paint a text box.
    363467 *
Note: See TracChangeset for help on using the changeset viewer.