UI: implement 'pumblend' option for semi-transparent popupmenu

Why?

- Because we can.
- Because the TUI is just another GUI™
- Because it looks kinda nice, and provides useful context like 1 out of 100
  times

Complies with "don't pay for what you don't use".

Some crashes for resizing were unfolded, add tests for those.
This commit is contained in:
Björn Linse
2019-01-20 21:23:17 +01:00
parent ed0e96cd28
commit 37f8df8824
15 changed files with 417 additions and 19 deletions

View File

@@ -44,6 +44,7 @@ static int pum_col; // left column of pum
static bool pum_is_visible = false;
static bool pum_is_drawn = false;
static bool pum_external = false;
static bool pum_invalid = false; // the screen was just cleared
static ScreenGrid pum_grid = SCREEN_GRID_INIT;
@@ -360,12 +361,14 @@ void pum_redraw(void)
grid_assign_handle(&pum_grid);
bool moved = ui_comp_put_grid(&pum_grid, pum_row, pum_col-col_off,
pum_height, grid_width);
bool invalid_grid = moved || pum_invalid;
pum_invalid = false;
if (!pum_grid.chars
|| pum_grid.Rows != pum_height || pum_grid.Columns != grid_width) {
grid_alloc(&pum_grid, pum_height, grid_width, !moved, false);
grid_alloc(&pum_grid, pum_height, grid_width, !invalid_grid, false);
ui_call_grid_resize(pum_grid.handle, pum_grid.Columns, pum_grid.Rows);
} else if (moved) {
} else if (invalid_grid) {
grid_invalidate(&pum_grid);
}
@@ -806,6 +809,17 @@ bool pum_drawn(void)
return pum_visible() && !pum_external;
}
/// Screen was cleared, need to redraw next time
void pum_invalidate(void)
{
pum_invalid = true;
}
void pum_recompose(void)
{
ui_comp_compose_grid(&pum_grid);
}
/// Gets the height of the menu.
///
/// @return the height of the popup menu, the number of entries visible.