Changeset 68d68e9 in mainline for uspace/app/taskbar/wndlist.c
- Timestamp:
- 2022-11-23T12:50:27Z (2 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c4a53280
- Parents:
- 6e91475
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/taskbar/wndlist.c
r6e91475 r68d68e9 35 35 #include <gfx/coord.h> 36 36 #include <stdbool.h> 37 #include <stddef.h> 37 38 #include <stdio.h> 38 39 #include <stdlib.h> … … 65 66 66 67 enum { 67 /** X distance between left edges of two consecutive buttons */ 68 wndlist_button_pitch = 145, 69 /** X distance between left edges of two consecutive buttons (text) */ 70 wndlist_button_pitch_text = 17, 68 /** Min. X distance between left edges of two consecutive buttons */ 69 wndlist_button_pitch_min = 85, 70 /** Max. X distance between left edges of two consecutive buttons (text) */ 71 wndlist_button_pitch_min_text = 10, 72 /** Min. X distance between left edges of two consecutive buttons */ 73 wndlist_button_pitch_max = 165, 74 /** Max. X distance between left edges of two consecutive buttons (text) */ 75 wndlist_button_pitch_max_text = 17, 71 76 /** Padding between buttons */ 72 77 wndlist_button_pad = 5, … … 197 202 wndlist_entry_t *entry = NULL; 198 203 ui_resource_t *res; 204 wndlist_entry_t *e; 199 205 errno_t rc; 200 206 … … 217 223 entry->visible = false; 218 224 219 /* Set the button rectangle and add it to layout, if applicable */ 220 wndlist_set_entry_rect(wndlist, entry); 225 /* 226 * Update rectangles for all entries, including @a entry, adding 227 * it to the layout, if applicable. 228 */ 229 e = wndlist_first(wndlist); 230 while (e != NULL) { 231 wndlist_set_entry_rect(wndlist, e); 232 e = wndlist_next(e); 233 } 221 234 222 235 /* Set button callbacks */ 223 236 ui_pbutton_set_cb(entry->button, &wndlist_button_cb, (void *)entry); 224 237 225 if (paint && entry->visible) { 226 rc = ui_pbutton_paint(entry->button); 227 if (rc != EOK) 228 goto error; 229 } 238 if (paint) 239 return wndlist_repaint(wndlist); 230 240 231 241 return EOK; … … 249 259 bool paint) 250 260 { 251 wndlist_entry_t * next;261 wndlist_entry_t *e; 252 262 assert(entry->wndlist == wndlist); 253 263 254 next = wndlist_next(entry); 255 256 ui_fixed_remove(wndlist->fixed, ui_pbutton_ctl(entry->button)); 264 if (entry->visible) 265 ui_fixed_remove(wndlist->fixed, ui_pbutton_ctl(entry->button)); 257 266 ui_pbutton_destroy(entry->button); 258 267 list_remove(&entry->lentries); 259 268 free(entry); 260 269 261 /* Update positions of the remaining entries */ 262 while (next != NULL) { 263 wndlist_set_entry_rect(wndlist, next); 264 next = wndlist_next(next); 270 /* Update positions of the all entries */ 271 e = wndlist_first(wndlist); 272 while (e != NULL) { 273 wndlist_set_entry_rect(wndlist, e); 274 e = wndlist_next(e); 265 275 } 266 276 … … 307 317 ui_resource_t *res; 308 318 gfx_coord_t pitch; 319 gfx_coord_t pitch_max; 320 gfx_coord_t pitch_min; 309 321 gfx_coord_t pad; 310 322 size_t idx; 323 size_t nbuttons; 311 324 312 325 /* Determine entry index */ … … 322 335 323 336 if (ui_resource_is_textmode(res)) { 324 pitch = wndlist_button_pitch_text; 337 pitch_max = wndlist_button_pitch_max_text; 338 pitch_min = wndlist_button_pitch_min_text; 325 339 pad = wndlist_button_pad_text; 326 340 } else { 327 pitch = wndlist_button_pitch; 341 pitch_max = wndlist_button_pitch_max; 342 pitch_min = wndlist_button_pitch_min; 328 343 pad = wndlist_button_pad; 329 344 } 345 346 /* Compute pitch that fits all buttons perfectly */ 347 nbuttons = wndlist_count(wndlist); 348 pitch = (wndlist->rect.p1.x - wndlist->rect.p0.x + pad) / nbuttons; 349 if (pitch < pitch_min) 350 pitch = pitch_min; 351 if (pitch > pitch_max) 352 pitch = pitch_max; 330 353 331 354 rect.p0.x = wndlist->rect.p0.x + pitch * idx; … … 478 501 } 479 502 503 /** Get number of window list entries. 504 * 505 * @param wndlist Window list 506 * @return Number of entries 507 */ 508 size_t wndlist_count(wndlist_t *wndlist) 509 { 510 return list_count(&wndlist->entries); 511 } 512 480 513 /** Repaint window list. 481 514 *
Note:
See TracChangeset
for help on using the changeset viewer.