Changeset 9c7dc8e in mainline for uspace/lib/ui/src
- Timestamp:
- 2021-03-01T10:50:25Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cd74fa8
- Parents:
- 77ffa01
- git-author:
- Jiri Svoboda <jiri@…> (2021-02-28 10:50:05)
- git-committer:
- Jiri Svoboda <jiri@…> (2021-03-01 10:50:25)
- Location:
- uspace/lib/ui/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/src/entry.c
r77ffa01 r9c7dc8e 46 46 #include <ui/paint.h> 47 47 #include <ui/entry.h> 48 #include <ui/ui.h> 48 49 #include "../private/entry.h" 49 50 #include "../private/resource.h" … … 55 56 enum { 56 57 ui_entry_hpad = 4, 57 ui_entry_vpad = 4 58 ui_entry_vpad = 4, 59 ui_entry_hpad_text = 1, 60 ui_entry_vpad_text = 0 58 61 }; 59 62 … … 173 176 gfx_text_fmt_t fmt; 174 177 gfx_coord2_t pos; 178 gfx_coord_t hpad; 179 gfx_coord_t vpad; 175 180 gfx_rect_t inside; 176 181 errno_t rc; 182 183 if (entry->res->textmode) { 184 hpad = ui_entry_hpad_text; 185 vpad = ui_entry_vpad_text; 186 } else { 187 hpad = ui_entry_hpad; 188 vpad = ui_entry_vpad; 189 } 177 190 178 191 /* Paint inset frame */ … … 195 208 case gfx_halign_left: 196 209 case gfx_halign_justify: 197 pos.x = inside.p0.x + ui_entry_hpad;210 pos.x = inside.p0.x + hpad; 198 211 break; 199 212 case gfx_halign_center: … … 201 214 break; 202 215 case gfx_halign_right: 203 pos.x = inside.p1.x - ui_entry_hpad;216 pos.x = inside.p1.x - hpad; 204 217 break; 205 218 } 206 219 207 pos.y = inside.p0.y + ui_entry_vpad;220 pos.y = inside.p0.y + vpad; 208 221 209 222 gfx_text_fmt_init(&fmt); -
uspace/lib/ui/src/resource.c
r77ffa01 r9c7dc8e 50 50 * 51 51 * @param gc Graphic context 52 * @param textmode @c true if running in text mode 52 53 * @param rresource Place to store pointer to new UI resource 53 54 * @return EOK on success, ENOMEM if out of memory 54 55 */ 55 errno_t ui_resource_create(gfx_context_t *gc, ui_resource_t **rresource) 56 errno_t ui_resource_create(gfx_context_t *gc, bool textmode, 57 ui_resource_t **rresource) 56 58 { 57 59 ui_resource_t *resource; … … 83 85 return ENOMEM; 84 86 85 rc = gfx_typeface_open(gc, ui_typeface_path, &tface); 86 if (rc != EOK) 87 goto error; 88 89 finfo = gfx_typeface_first_font(tface); 90 if (finfo == NULL) { 91 rc = EIO; 92 goto error; 87 if (textmode) { 88 /* Create dummy font for text mode */ 89 rc = gfx_typeface_create(gc, &tface); 90 if (rc != EOK) 91 goto error; 92 93 rc = gfx_font_create_textmode(tface, &font); 94 if (rc != EOK) 95 goto error; 96 } else { 97 rc = gfx_typeface_open(gc, ui_typeface_path, &tface); 98 if (rc != EOK) 99 goto error; 100 101 finfo = gfx_typeface_first_font(tface); 102 if (finfo == NULL) { 103 rc = EIO; 104 goto error; 105 } 106 107 rc = gfx_font_open(finfo, &font); 108 if (rc != EOK) 109 goto error; 93 110 } 94 95 rc = gfx_font_open(finfo, &font);96 if (rc != EOK)97 goto error;98 111 99 112 rc = gfx_color_new_rgb_i16(0, 0, 0, &btn_frame_color); … … 177 190 resource->tface = tface; 178 191 resource->font = font; 192 resource->textmode = textmode; 179 193 180 194 resource->btn_frame_color = btn_frame_color; -
uspace/lib/ui/src/ui.c
r77ffa01 r9c7dc8e 254 254 } 255 255 256 /** Determine if we are running in text mode. 257 * 258 * @param ui User interface 259 * @return @c true iff we are running in text mode 260 */ 261 bool ui_is_textmode(ui_t *ui) 262 { 263 /* 264 * XXX Currently console is always text and display is always 265 * graphics, but this need not always be true. 266 */ 267 return (ui->console != NULL); 268 } 269 256 270 /** @} 257 271 */ -
uspace/lib/ui/src/window.c
r77ffa01 r9c7dc8e 47 47 #include <ui/control.h> 48 48 #include <ui/resource.h> 49 #include <ui/ui.h> 49 50 #include <ui/wdecor.h> 50 51 #include <ui/window.h> … … 255 256 window->gc = gc; 256 257 #endif 257 rc = ui_resource_create(window->gc, &res);258 rc = ui_resource_create(window->gc, ui_is_textmode(ui), &res); 258 259 if (rc != EOK) 259 260 goto error;
Note:
See TracChangeset
for help on using the changeset viewer.