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


Ignore:
Timestamp:
2022-04-04T18:49:30Z (3 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
fd05ea6
Parents:
d68239a1
Message:

'X' does not mark the spot

Stop misusing 'X' character as a cross mark, create a routine for
drawing a cross and use it as a custom decoration for the close button.
Also use it for checkbox cross.

File:
1 edited

Legend:

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

    rd68239a1 r86fff971  
    365365 * @param pos Center position
    366366 * @param n Length of triangle side
     367 * @return EOK on success or an error code
    367368 */
    368369errno_t ui_paint_up_triangle(gfx_context_t *gc, gfx_coord2_t *pos,
     
    391392 * @param pos Center position
    392393 * @param n Length of triangle side
     394 * @return EOK on success or an error code
    393395 */
    394396errno_t ui_paint_down_triangle(gfx_context_t *gc, gfx_coord2_t *pos,
     
    417419 * @param pos Center position
    418420 * @param n Length of triangle side
     421 * @return EOK on success or an error code
    419422 */
    420423errno_t ui_paint_left_triangle(gfx_context_t *gc, gfx_coord2_t *pos,
     
    443446 * @param pos Center position
    444447 * @param n Length of triangle side
     448 * @return EOK on success or an error code
    445449 */
    446450errno_t ui_paint_right_triangle(gfx_context_t *gc, gfx_coord2_t *pos,
     
    456460                rect.p1.x = pos->x + n / 2 - i + 1;
    457461                rect.p1.y = pos->y + i + 1;
     462                rc = gfx_fill_rect(gc, &rect);
     463                if (rc != EOK)
     464                        return rc;
     465        }
     466
     467        return EOK;
     468}
     469
     470/** Paint diagonal cross (X).
     471 *
     472 * @param gc Graphic context
     473 * @param pos Center position
     474 * @param n Length of each leg
     475 * @param w Pen width
     476 * @param h Pen height
     477 * @return EOK on success or an error code
     478 */
     479errno_t ui_paint_cross(gfx_context_t *gc, gfx_coord2_t *pos,
     480    gfx_coord_t n, gfx_coord_t w, gfx_coord_t h)
     481{
     482        gfx_coord_t i;
     483        gfx_rect_t rect;
     484        errno_t rc;
     485
     486        rect.p0.x = pos->x;
     487        rect.p0.y = pos->y;
     488        rect.p1.x = pos->x + w;
     489        rect.p1.y = pos->y + h;
     490        rc = gfx_fill_rect(gc, &rect);
     491        if (rc != EOK)
     492                return rc;
     493
     494        for (i = 1; i < n; i++) {
     495                rect.p0.x = pos->x - i;
     496                rect.p0.y = pos->y - i;
     497                rect.p1.x = pos->x - i + w;
     498                rect.p1.y = pos->y - i + h;
     499                rc = gfx_fill_rect(gc, &rect);
     500                if (rc != EOK)
     501                        return rc;
     502
     503                rect.p0.x = pos->x - i;
     504                rect.p0.y = pos->y + i;
     505                rect.p1.x = pos->x - i + w;
     506                rect.p1.y = pos->y + i + h;
     507                rc = gfx_fill_rect(gc, &rect);
     508                if (rc != EOK)
     509                        return rc;
     510
     511                rect.p0.x = pos->x + i;
     512                rect.p0.y = pos->y - i;
     513                rect.p1.x = pos->x + i + w;
     514                rect.p1.y = pos->y - i + h;
     515                rc = gfx_fill_rect(gc, &rect);
     516                if (rc != EOK)
     517                        return rc;
     518
     519                rect.p0.x = pos->x + i;
     520                rect.p0.y = pos->y + i;
     521                rect.p1.x = pos->x + i + w;
     522                rect.p1.y = pos->y + i + h;
    458523                rc = gfx_fill_rect(gc, &rect);
    459524                if (rc != EOK)
Note: See TracChangeset for help on using the changeset viewer.