Changeset e0e612b in mainline
- Timestamp:
- 2022-10-07T08:38:50Z (2 years ago)
- 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)
- Location:
- uspace
- Files:
-
- 4 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/taskbar/meson.build
rc77cfd8 re0e612b 32 32 'main.c', 33 33 'taskbar.c', 34 'wndlist.c', 34 35 ) 35 36 … … 37 38 'clock.c', 38 39 'taskbar.c', 40 'wndlist.c', 39 41 'test/clock.c', 40 42 'test/main.c', 41 43 'test/taskbar.c', 44 'test/wndlist.c', 42 45 ) -
uspace/app/taskbar/taskbar.c
rc77cfd8 re0e612b 44 44 #include "clock.h" 45 45 #include "taskbar.h" 46 #include "wndlist.h" 46 47 47 48 static void wnd_close(ui_window_t *, void *); … … 135 136 } 136 137 137 rc = ui_label_create(ui_res, " Task bar!", &taskbar->label);138 rc = ui_label_create(ui_res, "HelenOS", &taskbar->label); 138 139 if (rc != EOK) { 139 140 printf("Error creating label.\n"); … … 142 143 143 144 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 } 144 150 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); 146 152 ui_label_set_valign(taskbar->label, gfx_valign_center); 147 153 … … 150 156 printf("Error adding control to layout.\n"); 151 157 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"); 152 170 goto error; 153 171 } … … 191 209 if (taskbar->clock != NULL) 192 210 taskbar_clock_destroy(taskbar->clock); 211 if (taskbar->wndlist != NULL) 212 wndlist_destroy(taskbar->wndlist); 193 213 if (taskbar->window != NULL) 194 214 ui_window_destroy(taskbar->window); -
uspace/app/taskbar/taskbar.h
rc77cfd8 re0e612b 1 1 /* 2 * Copyright (c) 202 0Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 40 40 #include "types/taskbar.h" 41 41 42 e rrno_t taskbar_create(const char *display_spec, taskbar_t **);43 void taskbar_destroy(taskbar_t *);42 extern errno_t taskbar_create(const char *display_spec, taskbar_t **); 43 extern void taskbar_destroy(taskbar_t *); 44 44 45 45 #endif -
uspace/app/taskbar/test/main.c
rc77cfd8 re0e612b 33 33 PCUT_IMPORT(clock); 34 34 PCUT_IMPORT(taskbar); 35 PCUT_IMPORT(wndlist); 35 36 36 37 PCUT_MAIN(); -
uspace/app/taskbar/types/taskbar.h
rc77cfd8 re0e612b 42 42 #include <ui/window.h> 43 43 #include "clock.h" 44 #include "wndlist.h" 44 45 45 46 /** Task bar */ 46 typedef struct {47 typedef struct taskbar { 47 48 /** User interface */ 48 49 ui_t *ui; … … 52 53 ui_fixed_t *fixed; 53 54 ui_label_t *label; 55 /** Window list */ 56 wndlist_t *wndlist; 54 57 /** Clock */ 55 58 taskbar_clock_t *clock; -
uspace/lib/ui/include/ui/resource.h
rc77cfd8 re0e612b 50 50 extern void ui_resource_expose(ui_resource_t *); 51 51 extern gfx_font_t *ui_resource_get_font(ui_resource_t *); 52 extern bool ui_resource_is_textmode(ui_resource_t *); 52 53 extern gfx_color_t *ui_resource_get_wnd_face_color(ui_resource_t *); 53 54 extern gfx_color_t *ui_resource_get_wnd_text_color(ui_resource_t *); -
uspace/lib/ui/src/resource.c
rc77cfd8 re0e612b 677 677 } 678 678 679 /** Determine if resource is textmode. 680 * 681 * @param resource UI resource 682 * @return @c true iff resource is textmode 683 */ 684 bool ui_resource_is_textmode(ui_resource_t *resource) 685 { 686 return resource->textmode; 687 } 688 679 689 /** Get the UI window face color. 680 690 * -
uspace/lib/ui/test/resource.c
rc77cfd8 re0e612b 134 134 } 135 135 136 /** ui_resource_get_font() returns the font */ 137 PCUT_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 */ 163 PCUT_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 */ 191 PCUT_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 */ 217 PCUT_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 136 242 static errno_t testgc_bitmap_create(void *arg, gfx_bitmap_params_t *params, 137 243 gfx_bitmap_alloc_t *alloc, void **rbm)
Note:
See TracChangeset
for help on using the changeset viewer.