mirror of
https://github.com/labwc/labwc.git
synced 2026-02-12 04:27:57 -05:00
cycle: implement scrollable OSD
Before this commit, the OSD could overflow the screen when displaying many window items. In this commit, we hide the overflowed items and show a scrollbar to fit the OSD within the screen.
This commit is contained in:
parent
97b31429a0
commit
742c2b53fd
5 changed files with 185 additions and 13 deletions
|
|
@ -8,6 +8,7 @@
|
|||
#include "config/types.h"
|
||||
|
||||
struct output;
|
||||
struct wlr_box;
|
||||
|
||||
enum lab_cycle_dir {
|
||||
LAB_CYCLE_DIR_NONE,
|
||||
|
|
@ -67,8 +68,21 @@ struct cycle_osd_output {
|
|||
struct output *output;
|
||||
struct wl_listener tree_destroy;
|
||||
|
||||
/* set by cycle_osd_impl->init() */
|
||||
struct wl_list items; /* struct cycle_osd_item.link */
|
||||
struct wlr_scene_tree *tree;
|
||||
/* set by cycle_osd_impl->init() and moved by cycle_osd_scroll_update() */
|
||||
struct wlr_scene_tree *items_tree;
|
||||
|
||||
/* used in osd-scroll.c */
|
||||
struct cycle_osd_scroll_context {
|
||||
int top_row_idx;
|
||||
int nr_rows, nr_cols, nr_visible_rows;
|
||||
int delta_y;
|
||||
struct wlr_box bar_area;
|
||||
struct wlr_scene_tree *bar_tree;
|
||||
struct lab_scene_rect *bar;
|
||||
} scroll;
|
||||
};
|
||||
|
||||
struct buf;
|
||||
|
|
@ -124,6 +138,28 @@ struct cycle_osd_impl {
|
|||
void (*update)(struct cycle_osd_output *osd_output);
|
||||
};
|
||||
|
||||
#define SCROLLBAR_W 10
|
||||
|
||||
/**
|
||||
* Initialize the context and scene for scrolling OSD items.
|
||||
*
|
||||
* @output: Output of the OSD
|
||||
* @bar_area: Area where the scrollbar is drawn
|
||||
* @delta_y: The vertical delta by which items are scrolled (usually item height)
|
||||
* @nr_cols: Number of columns in the OSD
|
||||
* @nr_rows: Number of rows in the OSD
|
||||
* @nr_visible_rows: Number of visible rows in the OSD
|
||||
* @border_color: Border color of the scrollbar
|
||||
* @bg_color: Background color of the scrollbar
|
||||
*/
|
||||
void cycle_osd_scroll_init(struct cycle_osd_output *osd_output,
|
||||
struct wlr_box bar_area, int delta_y,
|
||||
int nr_cols, int nr_rows, int nr_visible_rows,
|
||||
float *border_color, float *bg_color);
|
||||
|
||||
/* Scroll the OSD to show server->cycle.selected_view if needed */
|
||||
void cycle_osd_scroll_update(struct cycle_osd_output *osd_output);
|
||||
|
||||
extern struct cycle_osd_impl cycle_osd_classic_impl;
|
||||
extern struct cycle_osd_impl cycle_osd_thumbnail_impl;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue