Scrollbar and right window border
When a scrollbar is on display in APP or TOD windows, the right vertical border (outside the scrollbar) is not highlighted when the window is selected. The scrollbar itself is always highlighted: - when APP or TOD is deselected - in configuration windows where borders otherwise are not The patch moves the scrollbar parameters from arguments of draw_scrollbar() to the function itself. The highlight argument to draw_scrollbar() was always 1. Instead call circumstances are figured out and highlight set accordingly. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
parent
e733d09ea0
commit
9e060b96c2
@ -1144,7 +1144,7 @@ long date_sec_change(long, int, int);
|
|||||||
long update_time_in_date(long, unsigned, unsigned);
|
long update_time_in_date(long, unsigned, unsigned);
|
||||||
time_t get_sec_date(struct date);
|
time_t get_sec_date(struct date);
|
||||||
long min2sec(unsigned);
|
long min2sec(unsigned);
|
||||||
void draw_scrollbar(WINDOW *, int, int, int, int, int, unsigned);
|
void draw_scrollbar(struct scrollwin *);
|
||||||
void item_in_popup(const char *, const char *, const char *, const char *);
|
void item_in_popup(const char *, const char *, const char *, const char *);
|
||||||
time_t get_today(void);
|
time_t get_today(void);
|
||||||
long now(void);
|
long now(void);
|
||||||
|
35
src/utils.c
35
src/utils.c
@ -575,17 +575,36 @@ long min2sec(unsigned minutes)
|
|||||||
* can not be displayed inside the corresponding panel.
|
* can not be displayed inside the corresponding panel.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
draw_scrollbar(WINDOW * win, int y, int x, int length,
|
draw_scrollbar(struct scrollwin *sw)
|
||||||
int bar_top, int bar_bottom, unsigned hilt)
|
|
||||||
{
|
{
|
||||||
mvwvline(win, bar_top, x, ACS_VLINE, bar_bottom - bar_top + 1);
|
int y = (conf.compact_panels ? 1 : 3);
|
||||||
|
int h = sw->h - (conf.compact_panels ? 2 : 4);
|
||||||
|
|
||||||
|
int sbar_h = MAX(h * h / sw->line_num, 1);
|
||||||
|
int sbar_y = y + sw->line_off * (h - sbar_h) / (sw->line_num - h);
|
||||||
|
int sbar_x = sw->w - 1;
|
||||||
|
|
||||||
|
/* which scrollwin am I? */
|
||||||
|
enum win swid = -1;
|
||||||
|
if (strcmp(sw->label, _("TODO")) == 0)
|
||||||
|
swid = TOD;
|
||||||
|
else if (strcmp(sw->label, _("Appointments")) == 0)
|
||||||
|
swid = APP;
|
||||||
|
/*
|
||||||
|
* Redraw the vertical right border.
|
||||||
|
* For APP and TOD this is done as part of the move up/down.
|
||||||
|
*/
|
||||||
|
if (swid == -1)
|
||||||
|
mvwvline(sw->win, y, sbar_x, ACS_VLINE, h);
|
||||||
|
|
||||||
|
int hilt = swid == wins_slctd();
|
||||||
if (hilt)
|
if (hilt)
|
||||||
custom_apply_attr(win, ATTR_HIGHEST);
|
custom_apply_attr(sw->win, ATTR_HIGHEST);
|
||||||
wattron(win, A_REVERSE);
|
wattron(sw->win, A_REVERSE);
|
||||||
mvwvline(win, y, x, ' ', length);
|
mvwvline(sw->win, sbar_y, sbar_x, ' ', sbar_h);
|
||||||
wattroff(win, A_REVERSE);
|
wattroff(sw->win, A_REVERSE);
|
||||||
if (hilt)
|
if (hilt)
|
||||||
custom_remove_attr(win, ATTR_HIGHEST);
|
custom_remove_attr(sw->win, ATTR_HIGHEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
35
src/wins.c
35
src/wins.c
@ -357,25 +357,32 @@ void wins_scrollwin_draw_deco(struct scrollwin *sw, int hilt)
|
|||||||
/* Display a scrolling window. */
|
/* Display a scrolling window. */
|
||||||
void wins_scrollwin_display(struct scrollwin *sw)
|
void wins_scrollwin_display(struct scrollwin *sw)
|
||||||
{
|
{
|
||||||
int inner_y = (conf.compact_panels ? 1 : 3);
|
int inner_y = sw->y + (conf.compact_panels ? 1 : 3);
|
||||||
int inner_x = 1;
|
int inner_x = sw->x + 1;
|
||||||
int inner_h = sw->h - (conf.compact_panels ? 2 : 4);
|
int inner_h = sw->h - (conf.compact_panels ? 2 : 4);
|
||||||
int inner_w = sw->w - 2;
|
int inner_w = sw->w - 2;
|
||||||
|
|
||||||
if (sw->line_num > inner_h) {
|
if (sw->line_num > inner_h)
|
||||||
int sbar_h = MAX(inner_h * inner_h / sw->line_num, 1);
|
draw_scrollbar(sw);
|
||||||
int sbar_y = inner_y + sw->line_off * (inner_h - sbar_h) / (sw->line_num - inner_h);
|
|
||||||
int sbar_x = sw->w - 1;
|
|
||||||
|
|
||||||
draw_scrollbar(sw->win, sbar_y, sbar_x, sbar_h, inner_y,
|
|
||||||
inner_y + inner_h - 1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
wmove(win[STA].p, 0, 0);
|
wmove(win[STA].p, 0, 0);
|
||||||
wnoutrefresh(sw->win);
|
wnoutrefresh(sw->win);
|
||||||
pnoutrefresh(sw->inner, sw->line_off, 0, sw->y + inner_y,
|
/*
|
||||||
sw->x + inner_x, sw->y + inner_y + inner_h - 1,
|
(sw->line_off, 0): upper left corner in pad to display;
|
||||||
sw->x + inner_x + inner_w - 1);
|
scrolling is achieved by in/decreasing sw->line_off
|
||||||
|
between 0 and line_num - inner.h
|
||||||
|
|
||||||
|
(Y,X)=(inner_y,inner_x): upper left corner in screen window
|
||||||
|
(Y,X) + (inner_h - 1,inner_w - 1): lower right corner in screen window
|
||||||
|
|
||||||
|
|-inner_w-|
|
||||||
|
(Y,X)-> +---------+ -
|
||||||
|
| | |
|
||||||
|
| (pad) | inner_h
|
||||||
|
| | |
|
||||||
|
+---------+ <- -
|
||||||
|
*/
|
||||||
|
pnoutrefresh(sw->inner, sw->line_off, 0, inner_y, inner_x,
|
||||||
|
inner_y + inner_h - 1, inner_x + inner_w - 1);
|
||||||
wins_doupdate();
|
wins_doupdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user