Changeset d70dc1c4 in mainline
- Timestamp:
- 2021-01-06T10:06:42Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7020d1f
- Parents:
- e037cf37
- git-author:
- Jiri Svoboda <jiri@…> (2021-01-05 18:06:37)
- git-committer:
- Jiri Svoboda <jiri@…> (2021-01-06 10:06:42)
- Location:
- uspace
- Files:
-
- 5 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/uidemo/uidemo.c
re037cf37 rd70dc1c4 62 62 }; 63 63 64 static void checkbox_switched(ui_checkbox_t *, void *, bool); 65 66 static ui_checkbox_cb_t checkbox_cb = { 67 .switched = checkbox_switched 68 }; 69 64 70 /** Window close button was clicked. 65 71 * … … 91 97 } else { 92 98 rc = ui_entry_set_text(demo->entry, "Cancel pressed"); 99 if (rc != EOK) 100 printf("Error changing entry text.\n"); 101 (void) ui_entry_paint(demo->entry); 102 } 103 } 104 105 /** Check box was switched. 106 * 107 * @param checkbox Check box 108 * @param arg Argument (demo) 109 */ 110 static void checkbox_switched(ui_checkbox_t *checkbox, void *arg, bool enable) 111 { 112 ui_demo_t *demo = (ui_demo_t *) arg; 113 errno_t rc; 114 115 if (enable) { 116 rc = ui_entry_set_text(demo->entry, "Checked"); 117 if (rc != EOK) 118 printf("Error changing entry text.\n"); 119 (void) ui_entry_paint(demo->entry); 120 } else { 121 rc = ui_entry_set_text(demo->entry, "Unchecked"); 93 122 if (rc != EOK) 94 123 printf("Error changing entry text.\n"); … … 124 153 params.rect.p0.y = 0; 125 154 params.rect.p1.x = 220; 126 params.rect.p1.y = 180;155 params.rect.p1.y = 220; 127 156 128 157 memset((void *) &demo, 0, sizeof(demo)); … … 258 287 259 288 rc = ui_fixed_add(demo.fixed, ui_image_ctl(demo.image)); 289 if (rc != EOK) { 290 printf("Error adding control to layout.\n"); 291 return rc; 292 } 293 294 rc = ui_checkbox_create(ui_res, "Check me", &demo.checkbox); 295 if (rc != EOK) { 296 printf("Error creating check box.\n"); 297 return rc; 298 } 299 300 ui_checkbox_set_cb(demo.checkbox, &checkbox_cb, (void *) &demo); 301 302 rect.p0.x = 15; 303 rect.p0.y = 180; 304 rect.p1.x = 140; 305 rect.p1.y = 200; 306 ui_checkbox_set_rect(demo.checkbox, &rect); 307 308 rc = ui_fixed_add(demo.fixed, ui_checkbox_ctl(demo.checkbox)); 260 309 if (rc != EOK) { 261 310 printf("Error adding control to layout.\n"); -
uspace/app/uidemo/uidemo.h
re037cf37 rd70dc1c4 38 38 39 39 #include <display.h> 40 #include <ui/checkbox.h> 40 41 #include <ui/entry.h> 41 42 #include <ui/fixed.h> … … 55 56 ui_pbutton_t *pb1; 56 57 ui_pbutton_t *pb2; 58 ui_checkbox_t *checkbox; 57 59 } ui_demo_t; 58 60 -
uspace/lib/ui/include/ui/paint.h
re037cf37 rd70dc1c4 40 40 #include <gfx/color.h> 41 41 #include <gfx/coord.h> 42 #include <types/ui/resource.h> 42 43 43 44 errno_t ui_paint_bevel(gfx_context_t *, gfx_rect_t *, gfx_color_t *, 44 45 gfx_color_t *, gfx_coord_t, gfx_rect_t *); 46 errno_t ui_paint_inset_frame(ui_resource_t *, gfx_rect_t *, gfx_rect_t *); 45 47 46 48 #endif -
uspace/lib/ui/meson.build
re037cf37 rd70dc1c4 29 29 deps = [ 'gfx', 'gfxfont', 'memgfx', 'display' ] 30 30 src = files( 31 'src/checkbox.c', 31 32 'src/control.c', 32 33 'src/dummygc.c', … … 44 45 45 46 test_src = files( 47 'test/checkbox.c', 46 48 'test/control.c', 47 49 'test/entry.c', -
uspace/lib/ui/private/resource.h
re037cf37 rd70dc1c4 92 92 /** Entry (text entry, checkbox, raido button) background color */ 93 93 gfx_color_t *entry_bg_color; 94 /** Entry (text entry, checkbox, raido button) active background color */ 95 gfx_color_t *entry_act_bg_color; 94 96 }; 95 97 -
uspace/lib/ui/src/entry.c
re037cf37 rd70dc1c4 173 173 gfx_text_fmt_t fmt; 174 174 gfx_coord2_t pos; 175 gfx_rect_t frame;176 175 gfx_rect_t inside; 177 176 errno_t rc; … … 179 178 /* Paint inset frame */ 180 179 181 rc = ui_paint_bevel(entry->res->gc, &entry->rect, 182 entry->res->wnd_shadow_color, entry->res->wnd_highlight_color, 183 1, &frame); 184 if (rc != EOK) 185 goto error; 186 187 rc = ui_paint_bevel(entry->res->gc, &frame, 188 entry->res->wnd_frame_sh_color, entry->res->wnd_frame_hi_color, 189 1, &inside); 180 rc = ui_paint_inset_frame(entry->res, &entry->rect, &inside); 190 181 if (rc != EOK) 191 182 goto error; -
uspace/lib/ui/src/paint.c
re037cf37 rd70dc1c4 39 39 #include <gfx/render.h> 40 40 #include <ui/paint.h> 41 #include "../private/resource.h" 41 42 42 43 /** Paint bevel. … … 118 119 } 119 120 121 /** Paint inset frame. 122 * 123 * @param resource UI resource 124 * @param rect Rectangle to paint onto 125 * @param inside Place to store inside rectangle or @c NULL 126 * @return EOK on success or an error code 127 */ 128 errno_t ui_paint_inset_frame(ui_resource_t *resource, gfx_rect_t *rect, 129 gfx_rect_t *inside) 130 { 131 gfx_rect_t frame; 132 errno_t rc; 133 134 rc = ui_paint_bevel(resource->gc, rect, 135 resource->wnd_shadow_color, resource->wnd_highlight_color, 136 1, &frame); 137 if (rc != EOK) 138 goto error; 139 140 rc = ui_paint_bevel(resource->gc, &frame, 141 resource->wnd_frame_sh_color, resource->wnd_frame_hi_color, 142 1, inside); 143 if (rc != EOK) 144 goto error; 145 146 return EOK; 147 error: 148 return rc; 149 } 150 120 151 /** @} 121 152 */ -
uspace/lib/ui/src/resource.c
re037cf37 rd70dc1c4 76 76 gfx_color_t *entry_fg_color = NULL; 77 77 gfx_color_t *entry_bg_color = NULL; 78 gfx_color_t *entry_act_bg_color = NULL; 78 79 errno_t rc; 79 80 … … 166 167 167 168 rc = gfx_color_new_rgb_i16(0xffff, 0xffff, 0xffff, &entry_bg_color); 169 if (rc != EOK) 170 goto error; 171 172 rc = gfx_color_new_rgb_i16(0xc8c8, 0xc8c8, 0xc8c8, &entry_act_bg_color); 168 173 if (rc != EOK) 169 174 goto error; … … 193 198 resource->entry_fg_color = entry_fg_color; 194 199 resource->entry_bg_color = entry_bg_color; 200 resource->entry_act_bg_color = entry_act_bg_color; 195 201 196 202 *rresource = resource; … … 234 240 if (entry_bg_color != NULL) 235 241 gfx_color_delete(entry_bg_color); 242 if (entry_act_bg_color != NULL) 243 gfx_color_delete(entry_act_bg_color); 236 244 237 245 if (tface != NULL) … … 270 278 gfx_color_delete(resource->entry_fg_color); 271 279 gfx_color_delete(resource->entry_bg_color); 280 gfx_color_delete(resource->entry_act_bg_color); 272 281 273 282 gfx_font_close(resource->font); -
uspace/lib/ui/test/main.c
re037cf37 rd70dc1c4 32 32 33 33 PCUT_IMPORT(control); 34 PCUT_IMPORT(checkbox); 34 35 PCUT_IMPORT(entry); 35 36 PCUT_IMPORT(fixed); -
uspace/lib/ui/test/paint.c
re037cf37 rd70dc1c4 33 33 #include <stdbool.h> 34 34 #include <ui/paint.h> 35 #include <ui/resource.h> 35 36 36 37 PCUT_INIT; … … 103 104 gfx_color_delete(color2); 104 105 gfx_color_delete(color1); 106 rc = gfx_context_delete(gc); 107 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 108 } 109 110 /** Paint inset frame */ 111 PCUT_TEST(inset_frame) 112 { 113 errno_t rc; 114 gfx_context_t *gc = NULL; 115 ui_resource_t *resource = NULL; 116 test_gc_t tgc; 117 gfx_rect_t rect; 118 gfx_rect_t inside; 119 120 memset(&tgc, 0, sizeof(tgc)); 121 rc = gfx_context_new(&ops, &tgc, &gc); 122 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 123 124 rc = ui_resource_create(gc, &resource); 125 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 126 PCUT_ASSERT_NOT_NULL(resource); 127 128 /* Paint inset frame with NULL 'inside' output parameter */ 129 rc = ui_paint_inset_frame(resource, &rect, NULL); 130 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 131 132 /* Paint inset frame with valid 'inside' output parameter */ 133 rc = ui_paint_inset_frame(resource, &rect, &inside); 134 PCUT_ASSERT_ERRNO_VAL(EOK, rc); 135 105 136 rc = gfx_context_delete(gc); 106 137 PCUT_ASSERT_ERRNO_VAL(EOK, rc);
Note:
See TracChangeset
for help on using the changeset viewer.