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

Changeset 6df564c in mainline


Ignore:
Timestamp:
2021-09-19T18:02:14Z (5 weeks ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
68632b4
Parents:
80d4aea
Message:

Custom colors for selected text in text entry

In text mode, swapping 'background' and 'text' color does not work,
they are the same. Looks better in graphics mode, too.

Location:
uspace/lib/ui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ui/private/resource.h

    r80d4aea r6df564c  
    105105        /** Entry (text entry, checkbox, raido button) active background color */
    106106        gfx_color_t *entry_act_bg_color;
     107        /** Entry selected text foreground color */
     108        gfx_color_t *entry_sel_text_fg_color;
     109        /** Entry selected text background color */
     110        gfx_color_t *entry_sel_text_bg_color;
    107111
    108112        /** Expose callback or @c NULL */
  • uspace/lib/ui/src/entry.c

    r80d4aea r6df564c  
    343343                c = entry->text[off2];
    344344                entry->text[off2] = '\0';
    345                 cfmt.color = res->entry_bg_color;
     345                cfmt.color = res->entry_sel_text_fg_color;
    346346
    347347                gfx_text_rect(res->font, &cpos, &cfmt, entry->text + off1, &sel);
     
    351351                sel.p1.y += ui_entry_sel_vpad;
    352352
    353                 rc = gfx_set_color(res->gc, res->entry_fg_color);
     353                rc = gfx_set_color(res->gc, res->entry_sel_text_bg_color);
    354354                if (rc != EOK)
    355355                        goto error;
  • uspace/lib/ui/src/resource.c

    r80d4aea r6df564c  
    8080        gfx_color_t *entry_bg_color = NULL;
    8181        gfx_color_t *entry_act_bg_color = NULL;
     82        gfx_color_t *entry_sel_text_fg_color = NULL;
     83        gfx_color_t *entry_sel_text_bg_color = NULL;
    8284        errno_t rc;
    8385
     
    183185
    184186        rc = gfx_color_new_rgb_i16(0xc8c8, 0xc8c8, 0xc8c8, &entry_act_bg_color);
     187        if (rc != EOK)
     188                goto error;
     189
     190        rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff,
     191            &entry_sel_text_fg_color);
     192        if (rc != EOK)
     193                goto error;
     194
     195        rc = gfx_color_new_rgb_i16(0, 0, 0xffff, &entry_sel_text_bg_color);
    185196        if (rc != EOK)
    186197                goto error;
     
    214225        resource->entry_bg_color = entry_bg_color;
    215226        resource->entry_act_bg_color = entry_act_bg_color;
     227        resource->entry_sel_text_fg_color = entry_sel_text_fg_color;
     228        resource->entry_sel_text_bg_color = entry_sel_text_bg_color;
    216229
    217230        *rresource = resource;
     
    259272        if (entry_bg_color != NULL)
    260273                gfx_color_delete(entry_bg_color);
     274        if (entry_sel_text_fg_color != NULL)
     275                gfx_color_delete(entry_sel_text_fg_color);
     276        if (entry_sel_text_bg_color != NULL)
     277                gfx_color_delete(entry_sel_text_bg_color);
    261278        if (entry_act_bg_color != NULL)
    262279                gfx_color_delete(entry_act_bg_color);
     
    299316        gfx_color_t *entry_fg_color = NULL;
    300317        gfx_color_t *entry_bg_color = NULL;
     318        gfx_color_t *entry_sel_text_fg_color = NULL;
     319        gfx_color_t *entry_sel_text_bg_color = NULL;
    301320        gfx_color_t *entry_act_bg_color = NULL;
    302321        errno_t rc;
     
    388407
    389408        rc = gfx_color_new_ega(0x1b, &entry_bg_color);
     409        if (rc != EOK)
     410                goto error;
     411
     412        rc = gfx_color_new_ega(0x20, &entry_sel_text_fg_color);
     413        if (rc != EOK)
     414                goto error;
     415
     416        rc = gfx_color_new_ega(0x20, &entry_sel_text_bg_color);
    390417        if (rc != EOK)
    391418                goto error;
     
    423450        resource->entry_bg_color = entry_bg_color;
    424451        resource->entry_act_bg_color = entry_act_bg_color;
     452        resource->entry_sel_text_fg_color = entry_sel_text_fg_color;
     453        resource->entry_sel_text_bg_color = entry_sel_text_bg_color;
    425454
    426455        *rresource = resource;
     
    470499        if (entry_act_bg_color != NULL)
    471500                gfx_color_delete(entry_act_bg_color);
     501        if (entry_sel_text_fg_color != NULL)
     502                gfx_color_delete(entry_sel_text_fg_color);
     503        if (entry_sel_text_bg_color != NULL)
     504                gfx_color_delete(entry_sel_text_bg_color);
    472505
    473506        if (tface != NULL)
     
    525558        gfx_color_delete(resource->entry_bg_color);
    526559        gfx_color_delete(resource->entry_act_bg_color);
     560        gfx_color_delete(resource->entry_sel_text_fg_color);
     561        gfx_color_delete(resource->entry_sel_text_bg_color);
    527562
    528563        gfx_font_close(resource->font);
Note: See TracChangeset for help on using the changeset viewer.