summaryrefslogtreecommitdiff
path: root/src/ui/listwidget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-11-25 21:30:49 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-11-25 21:30:49 +0200
commitc19be4f64f2f38f692b9987a7b5268bdb87fa8be (patch)
treee3070566cd7f6cecec41f960e4fa47fa03d938ff /src/ui/listwidget.c
parent9c1fac30f92eadc292ca0b4326b93d4cf9b4008c (diff)
SidebarWidget: Bookmark tag icons; Feeds presentation
Special tags of bookmarks are now visualized with icons. Feed items show an indicator if the currently open document matches the entry URL.
Diffstat (limited to 'src/ui/listwidget.c')
-rw-r--r--src/ui/listwidget.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/ui/listwidget.c b/src/ui/listwidget.c
index 39b9bfe5..b27107df 100644
--- a/src/ui/listwidget.c
+++ b/src/ui/listwidget.c
@@ -139,6 +139,10 @@ void setItemHeight_ListWidget(iListWidget *d, int itemHeight) {
139 invalidate_ListWidget(d); 139 invalidate_ListWidget(d);
140} 140}
141 141
142int scrollBarWidth_ListWidget(const iListWidget *d) {
143 return isVisible_Widget(d->scroll) ? width_Widget(d->scroll) : 0;
144}
145
142int itemHeight_ListWidget(const iListWidget *d) { 146int itemHeight_ListWidget(const iListWidget *d) {
143 return d->itemHeight; 147 return d->itemHeight;
144} 148}
@@ -318,6 +322,7 @@ static iBool processEvent_ListWidget_(iListWidget *d, const SDL_Event *ev) {
318 return processEvent_Widget(w, ev); 322 return processEvent_Widget(w, ev);
319} 323}
320 324
325#if 0
321static void drawItem_ListWidget_(const iListWidget *d, iPaint *p, size_t index, iInt2 pos) { 326static void drawItem_ListWidget_(const iListWidget *d, iPaint *p, size_t index, iInt2 pos) {
322 const iWidget * w = constAs_Widget(d); 327 const iWidget * w = constAs_Widget(d);
323 const iRect bounds = innerBounds_Widget(w); 328 const iRect bounds = innerBounds_Widget(w);
@@ -325,6 +330,7 @@ static void drawItem_ListWidget_(const iListWidget *d, iPaint *p, size_t index,
325 const iRect itemRect = { pos, init_I2(width_Rect(bounds), d->itemHeight) }; 330 const iRect itemRect = { pos, init_I2(width_Rect(bounds), d->itemHeight) };
326 class_ListItem(item)->draw(item, p, itemRect, d); 331 class_ListItem(item)->draw(item, p, itemRect, d);
327} 332}
333#endif
328 334
329static const iListItem *item_ListWidget_(const iListWidget *d, size_t pos) { 335static const iListItem *item_ListWidget_(const iListWidget *d, size_t pos) {
330 return constAt_PtrArray(&d->items, pos); 336 return constAt_PtrArray(&d->items, pos);
@@ -364,6 +370,9 @@ static void draw_ListWidget_(const iListWidget *d) {
364 beginTarget_Paint(&p, buf->texture); 370 beginTarget_Paint(&p, buf->texture);
365 fillRect_Paint(&p, (iRect){ zero_I2(), d->visBuf->texSize }, bg[i]); 371 fillRect_Paint(&p, (iRect){ zero_I2(), d->visBuf->texSize }, bg[i]);
366 } 372 }
373 const iRect sbBlankRect =
374 { init_I2(d->visBuf->texSize.x - scrollBarWidth_ListWidget(d), 0),
375 init_I2(scrollBarWidth_ListWidget(d), d->itemHeight) };
367 iConstForEach(IntSet, v, &d->invalidItems) { 376 iConstForEach(IntSet, v, &d->invalidItems) {
368 const size_t index = *v.value; 377 const size_t index = *v.value;
369 if (contains_Range(&drawItems, index)) { 378 if (contains_Range(&drawItems, index)) {
@@ -373,6 +382,7 @@ static void draw_ListWidget_(const iListWidget *d) {
373 beginTarget_Paint(&p, buf->texture); 382 beginTarget_Paint(&p, buf->texture);
374 fillRect_Paint(&p, itemRect, bg[i]); 383 fillRect_Paint(&p, itemRect, bg[i]);
375 class_ListItem(item)->draw(item, &p, itemRect, d); 384 class_ListItem(item)->draw(item, &p, itemRect, d);
385 fillRect_Paint(&p, moved_Rect(sbBlankRect, init_I2(0, top_Rect(itemRect))), bg[i]);
376 } 386 }
377 } 387 }
378 /* Visible range is not fully covered. Fill in the new items. */ 388 /* Visible range is not fully covered. Fill in the new items. */
@@ -386,6 +396,7 @@ static void draw_ListWidget_(const iListWidget *d) {
386 init_I2(d->visBuf->texSize.x, d->itemHeight) }; 396 init_I2(d->visBuf->texSize.x, d->itemHeight) };
387 fillRect_Paint(&p, itemRect, bg[i]); 397 fillRect_Paint(&p, itemRect, bg[i]);
388 class_ListItem(item)->draw(item, &p, itemRect, d); 398 class_ListItem(item)->draw(item, &p, itemRect, d);
399 fillRect_Paint(&p, moved_Rect(sbBlankRect, init_I2(0, top_Rect(itemRect))), bg[i]);
389 } 400 }
390 } 401 }
391 endTarget_Paint(&p); 402 endTarget_Paint(&p);