Changeset 50a16d9 in mainline


Ignore:
Timestamp:
2022-09-26T11:58:09Z (19 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3fd38b2
Parents:
2139676
git-author:
Jiri Svoboda <jiri@…> (2022-09-24 23:57:50)
git-committer:
Jiri Svoboda <jiri@…> (2022-09-26 11:58:09)
Message:

Add simple digital clock display to task bar

Location:
uspace
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/taskbar/meson.build

    r2139676 r50a16d9  
    2929deps = [ 'ui' ]
    3030src = files(
     31        'clock.c',
    3132        'main.c',
    3233        'taskbar.c',
  • uspace/app/taskbar/taskbar.c

    r2139676 r50a16d9  
    4242#include <ui/ui.h>
    4343#include <ui/window.h>
     44#include "clock.h"
    4445#include "taskbar.h"
    4546
     
    9697                params.rect.p0.x = 0;
    9798                params.rect.p0.y = 0;
    98                 params.rect.p1.x = 24;
    99                 params.rect.p1.y = 5;
     99                params.rect.p1.x = 80;
     100                params.rect.p1.y = 1;
     101                params.style &= ~ui_wds_frame;
    100102        } else {
    101103                params.rect.p0.x = 0;
     
    138140        }
    139141
     142        rc = taskbar_clock_create(taskbar->window, &taskbar->clock);
     143        if (rc != EOK)
     144                goto error;
     145
     146        rect.p0.x = 1024 - 80;
     147        rect.p0.y = 4;
     148        rect.p1.x = 1024 - 4;
     149        rect.p1.y = 32 - 4;
     150        taskbar_clock_set_rect(taskbar->clock, &rect);
     151
     152        rc = ui_fixed_add(taskbar->fixed, taskbar_clock_ctl(taskbar->clock));
     153        if (rc != EOK) {
     154                printf("Error adding control to layout.\n");
     155                taskbar_clock_destroy(taskbar->clock);
     156                goto error;
     157        }
     158
    140159        ui_window_add(taskbar->window, ui_fixed_ctl(taskbar->fixed));
    141160
     
    149168        return EOK;
    150169error:
     170        if (taskbar->clock != NULL)
     171                taskbar_clock_destroy(taskbar->clock);
    151172        if (taskbar->window != NULL)
    152173                ui_window_destroy(taskbar->window);
     
    160181void taskbar_destroy(taskbar_t *taskbar)
    161182{
     183        taskbar_clock_destroy(taskbar->clock);
    162184        ui_window_destroy(taskbar->window);
    163185        ui_destroy(taskbar->ui);
  • uspace/app/taskbar/types/taskbar.h

    r2139676 r50a16d9  
    4141#include <ui/ui.h>
    4242#include <ui/window.h>
     43#include "clock.h"
    4344
    4445/** Task bar */
     
    5152        ui_fixed_t *fixed;
    5253        ui_label_t *label;
     54        /** Clock */
     55        taskbar_clock_t *clock;
    5356} taskbar_t;
    5457
  • uspace/lib/ui/include/ui/resource.h

    r2139676 r50a16d9  
    3838
    3939#include <errno.h>
     40#include <gfx/color.h>
    4041#include <gfx/context.h>
    4142#include <gfx/font.h>
     
    4950extern void ui_resource_expose(ui_resource_t *);
    5051extern gfx_font_t *ui_resource_get_font(ui_resource_t *);
     52extern gfx_color_t *ui_resource_get_wnd_face_color(ui_resource_t *);
     53extern gfx_color_t *ui_resource_get_wnd_text_color(ui_resource_t *);
    5154
    5255#endif
  • uspace/lib/ui/src/resource.c

    r2139676 r50a16d9  
    677677}
    678678
     679/** Get the UI window face color.
     680 *
     681 * @param resource UI resource
     682 * @return UI window face color
     683 */
     684gfx_color_t *ui_resource_get_wnd_face_color(ui_resource_t *resource)
     685{
     686        return resource->wnd_face_color;
     687}
     688
     689/** Get the UI window text color.
     690 *
     691 * @param resource UI resource
     692 * @return UI window text color
     693 */
     694gfx_color_t *ui_resource_get_wnd_text_color(ui_resource_t *resource)
     695{
     696        return resource->wnd_text_color;
     697}
     698
    679699/** @}
    680700 */
Note: See TracChangeset for help on using the changeset viewer.