Changeset e0e612b in mainline


Ignore:
Timestamp:
2022-10-07T08:38:50Z (19 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0761448
Parents:
c77cfd8
git-author:
Jiri Svoboda <jiri@…> (2022-10-06 18:38:37)
git-committer:
Jiri Svoboda <jiri@…> (2022-10-07 08:38:50)
Message:

Add window list to taskbar (with one dummy entry so far)

Location:
uspace
Files:
4 added
8 edited

Legend:

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

    rc77cfd8 re0e612b  
    3232        'main.c',
    3333        'taskbar.c',
     34        'wndlist.c',
    3435)
    3536
     
    3738        'clock.c',
    3839        'taskbar.c',
     40        'wndlist.c',
    3941        'test/clock.c',
    4042        'test/main.c',
    4143        'test/taskbar.c',
     44        'test/wndlist.c',
    4245)
  • uspace/app/taskbar/taskbar.c

    rc77cfd8 re0e612b  
    4444#include "clock.h"
    4545#include "taskbar.h"
     46#include "wndlist.h"
    4647
    4748static void wnd_close(ui_window_t *, void *);
     
    135136        }
    136137
    137         rc = ui_label_create(ui_res, "Task bar!", &taskbar->label);
     138        rc = ui_label_create(ui_res, "HelenOS", &taskbar->label);
    138139        if (rc != EOK) {
    139140                printf("Error creating label.\n");
     
    142143
    143144        ui_window_get_app_rect(taskbar->window, &rect);
     145        if (ui_is_textmode(taskbar->ui)) {
     146                rect.p0.x += 1;
     147        } else {
     148                rect.p0.x += 10;
     149        }
    144150        ui_label_set_rect(taskbar->label, &rect);
    145         ui_label_set_halign(taskbar->label, gfx_halign_center);
     151        ui_label_set_halign(taskbar->label, gfx_halign_left);
    146152        ui_label_set_valign(taskbar->label, gfx_valign_center);
    147153
     
    150156                printf("Error adding control to layout.\n");
    151157                ui_label_destroy(taskbar->label);
     158                goto error;
     159        }
     160
     161        rc = wndlist_create(ui_res, taskbar->fixed, &taskbar->wndlist);
     162        if (rc != EOK) {
     163                printf("Error creating window list.\n");
     164                goto error;
     165        }
     166
     167        rc = wndlist_append(taskbar->wndlist, "Text Editor");
     168        if (rc != EOK) {
     169                printf("Error adding window list entry.\n");
    152170                goto error;
    153171        }
     
    191209        if (taskbar->clock != NULL)
    192210                taskbar_clock_destroy(taskbar->clock);
     211        if (taskbar->wndlist != NULL)
     212                wndlist_destroy(taskbar->wndlist);
    193213        if (taskbar->window != NULL)
    194214                ui_window_destroy(taskbar->window);
  • uspace/app/taskbar/taskbar.h

    rc77cfd8 re0e612b  
    11/*
    2  * Copyright (c) 2020 Jiri Svoboda
     2 * Copyright (c) 2022 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    4040#include "types/taskbar.h"
    4141
    42 errno_t taskbar_create(const char *display_spec, taskbar_t **);
    43 void taskbar_destroy(taskbar_t *);
     42extern errno_t taskbar_create(const char *display_spec, taskbar_t **);
     43extern void taskbar_destroy(taskbar_t *);
    4444
    4545#endif
  • uspace/app/taskbar/test/main.c

    rc77cfd8 re0e612b  
    3333PCUT_IMPORT(clock);
    3434PCUT_IMPORT(taskbar);
     35PCUT_IMPORT(wndlist);
    3536
    3637PCUT_MAIN();
  • uspace/app/taskbar/types/taskbar.h

    rc77cfd8 re0e612b  
    4242#include <ui/window.h>
    4343#include "clock.h"
     44#include "wndlist.h"
    4445
    4546/** Task bar */
    46 typedef struct {
     47typedef struct taskbar {
    4748        /** User interface */
    4849        ui_t *ui;
     
    5253        ui_fixed_t *fixed;
    5354        ui_label_t *label;
     55        /** Window list */
     56        wndlist_t *wndlist;
    5457        /** Clock */
    5558        taskbar_clock_t *clock;
  • uspace/lib/ui/include/ui/resource.h

    rc77cfd8 re0e612b  
    5050extern void ui_resource_expose(ui_resource_t *);
    5151extern gfx_font_t *ui_resource_get_font(ui_resource_t *);
     52extern bool ui_resource_is_textmode(ui_resource_t *);
    5253extern gfx_color_t *ui_resource_get_wnd_face_color(ui_resource_t *);
    5354extern gfx_color_t *ui_resource_get_wnd_text_color(ui_resource_t *);
  • uspace/lib/ui/src/resource.c

    rc77cfd8 re0e612b  
    677677}
    678678
     679/** Determine if resource is textmode.
     680 *
     681 * @param resource UI resource
     682 * @return @c true iff resource is textmode
     683 */
     684bool ui_resource_is_textmode(ui_resource_t *resource)
     685{
     686        return resource->textmode;
     687}
     688
    679689/** Get the UI window face color.
    680690 *
  • uspace/lib/ui/test/resource.c

    rc77cfd8 re0e612b  
    134134}
    135135
     136/** ui_resource_get_font() returns the font */
     137PCUT_TEST(get_font)
     138{
     139        errno_t rc;
     140        gfx_context_t *gc = NULL;
     141        test_gc_t tgc;
     142        ui_resource_t *resource = NULL;
     143        gfx_font_t *font;
     144
     145        memset(&tgc, 0, sizeof(tgc));
     146        rc = gfx_context_new(&ops, &tgc, &gc);
     147        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     148
     149        rc = ui_resource_create(gc, false, &resource);
     150        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     151        PCUT_ASSERT_NOT_NULL(resource);
     152
     153        font = ui_resource_get_font(resource);
     154        PCUT_ASSERT_EQUALS(resource->font, font);
     155
     156        ui_resource_destroy(resource);
     157
     158        rc = gfx_context_delete(gc);
     159        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     160}
     161
     162/** ui_resource_is_textmode() returns the textmode flag */
     163PCUT_TEST(is_textmode)
     164{
     165        errno_t rc;
     166        gfx_context_t *gc = NULL;
     167        test_gc_t tgc;
     168        ui_resource_t *resource = NULL;
     169
     170        memset(&tgc, 0, sizeof(tgc));
     171        rc = gfx_context_new(&ops, &tgc, &gc);
     172        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     173
     174        rc = ui_resource_create(gc, false, &resource);
     175        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     176        PCUT_ASSERT_NOT_NULL(resource);
     177
     178        /* To make sure let's test both true and false case */
     179        resource->textmode = true;
     180        PCUT_ASSERT_TRUE(ui_resource_is_textmode(resource));
     181        resource->textmode = false;
     182        PCUT_ASSERT_FALSE(ui_resource_is_textmode(resource));
     183
     184        ui_resource_destroy(resource);
     185
     186        rc = gfx_context_delete(gc);
     187        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     188}
     189
     190/** ui_resource_get_wnd_face_color() returns window face color */
     191PCUT_TEST(get_wnd_face_color)
     192{
     193        errno_t rc;
     194        gfx_context_t *gc = NULL;
     195        test_gc_t tgc;
     196        ui_resource_t *resource = NULL;
     197        gfx_color_t *color;
     198
     199        memset(&tgc, 0, sizeof(tgc));
     200        rc = gfx_context_new(&ops, &tgc, &gc);
     201        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     202
     203        rc = ui_resource_create(gc, false, &resource);
     204        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     205        PCUT_ASSERT_NOT_NULL(resource);
     206
     207        color = ui_resource_get_wnd_face_color(resource);
     208        PCUT_ASSERT_EQUALS(resource->wnd_face_color, color);
     209
     210        ui_resource_destroy(resource);
     211
     212        rc = gfx_context_delete(gc);
     213        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     214}
     215
     216/** ui_resource_get_wnd_text_color() returns window text color */
     217PCUT_TEST(get_wnd_text_color)
     218{
     219        errno_t rc;
     220        gfx_context_t *gc = NULL;
     221        test_gc_t tgc;
     222        ui_resource_t *resource = NULL;
     223        gfx_color_t *color;
     224
     225        memset(&tgc, 0, sizeof(tgc));
     226        rc = gfx_context_new(&ops, &tgc, &gc);
     227        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     228
     229        rc = ui_resource_create(gc, false, &resource);
     230        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     231        PCUT_ASSERT_NOT_NULL(resource);
     232
     233        color = ui_resource_get_wnd_text_color(resource);
     234        PCUT_ASSERT_EQUALS(resource->wnd_text_color, color);
     235
     236        ui_resource_destroy(resource);
     237
     238        rc = gfx_context_delete(gc);
     239        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     240}
     241
    136242static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params,
    137243    gfx_bitmap_alloc_t *alloc, void **rbm)
Note: See TracChangeset for help on using the changeset viewer.