mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-05-13 16:37:27 +00:00
Make scrollbar wider when mouse hovers over it
This commit is contained in:
parent
e397239076
commit
68eee50aee
7 changed files with 27 additions and 1 deletions
|
|
@ -447,6 +447,7 @@ calculate_scrollbar_geometry(Window *w) {
|
|||
WindowGeometry *g = &w->render_data.geometry;
|
||||
unsigned cell_width = w->render_data.screen->cell_size.width;
|
||||
geom.width = OPT(scrollbar_width) * cell_width;
|
||||
if (w->scrollbar.is_hovering) geom.width = OPT(scrollbar_hover_width) * cell_width;
|
||||
geom.gap = OPT(scrollbar_gap) * cell_width;
|
||||
geom.hitbox_expansion = OPT(scrollbar_hitbox_expansion) * cell_width;
|
||||
|
||||
|
|
|
|||
|
|
@ -471,6 +471,10 @@ opt('scrollbar_width', '0.5', option_type='positive_float', ctype='float', long_
|
|||
The width of the scroll bar in units of cell width.
|
||||
''')
|
||||
|
||||
opt('scrollbar_hover_width', '1', option_type='positive_float', ctype='float', long_text='''
|
||||
The width of the scroll bar when the mouse is hovering over it, in units of cell width.
|
||||
''')
|
||||
|
||||
opt('scrollbar_handle_opacity', '0.5', option_type='positive_float', ctype='float', long_text='''
|
||||
The opacity of the scrollbar handle, 0 being fully transparent and 1 being full opaque.
|
||||
''')
|
||||
|
|
|
|||
3
kitty/options/parse.py
generated
3
kitty/options/parse.py
generated
|
|
@ -1226,6 +1226,9 @@ class Parser:
|
|||
def scrollbar_hitbox_expansion(self, val: str, ans: dict[str, typing.Any]) -> None:
|
||||
ans['scrollbar_hitbox_expansion'] = positive_float(val)
|
||||
|
||||
def scrollbar_hover_width(self, val: str, ans: dict[str, typing.Any]) -> None:
|
||||
ans['scrollbar_hover_width'] = positive_float(val)
|
||||
|
||||
def scrollbar_interactive(self, val: str, ans: dict[str, typing.Any]) -> None:
|
||||
ans['scrollbar_interactive'] = to_bool(val)
|
||||
|
||||
|
|
|
|||
15
kitty/options/to-c-generated.h
generated
15
kitty/options/to-c-generated.h
generated
|
|
@ -304,6 +304,19 @@ convert_from_opts_scrollbar_width(PyObject *py_opts, Options *opts) {
|
|||
Py_DECREF(ret);
|
||||
}
|
||||
|
||||
static void
|
||||
convert_from_python_scrollbar_hover_width(PyObject *val, Options *opts) {
|
||||
opts->scrollbar_hover_width = PyFloat_AsFloat(val);
|
||||
}
|
||||
|
||||
static void
|
||||
convert_from_opts_scrollbar_hover_width(PyObject *py_opts, Options *opts) {
|
||||
PyObject *ret = PyObject_GetAttrString(py_opts, "scrollbar_hover_width");
|
||||
if (ret == NULL) return;
|
||||
convert_from_python_scrollbar_hover_width(ret, opts);
|
||||
Py_DECREF(ret);
|
||||
}
|
||||
|
||||
static void
|
||||
convert_from_python_scrollbar_handle_opacity(PyObject *val, Options *opts) {
|
||||
opts->scrollbar_handle_opacity = PyFloat_AsFloat(val);
|
||||
|
|
@ -1392,6 +1405,8 @@ convert_opts_from_python_opts(PyObject *py_opts, Options *opts) {
|
|||
if (PyErr_Occurred()) return false;
|
||||
convert_from_opts_scrollbar_width(py_opts, opts);
|
||||
if (PyErr_Occurred()) return false;
|
||||
convert_from_opts_scrollbar_hover_width(py_opts, opts);
|
||||
if (PyErr_Occurred()) return false;
|
||||
convert_from_opts_scrollbar_handle_opacity(py_opts, opts);
|
||||
if (PyErr_Occurred()) return false;
|
||||
convert_from_opts_scrollbar_radius(py_opts, opts);
|
||||
|
|
|
|||
2
kitty/options/types.py
generated
2
kitty/options/types.py
generated
|
|
@ -420,6 +420,7 @@ option_names = (
|
|||
'scrollbar_handle_color',
|
||||
'scrollbar_handle_opacity',
|
||||
'scrollbar_hitbox_expansion',
|
||||
'scrollbar_hover_width',
|
||||
'scrollbar_interactive',
|
||||
'scrollbar_jump_on_click',
|
||||
'scrollbar_min_handle_height',
|
||||
|
|
@ -606,6 +607,7 @@ class Options:
|
|||
scrollbar_handle_color: int = 0
|
||||
scrollbar_handle_opacity: float = 0.5
|
||||
scrollbar_hitbox_expansion: float = 0.25
|
||||
scrollbar_hover_width: float = 1.0
|
||||
scrollbar_interactive: bool = True
|
||||
scrollbar_jump_on_click: bool = True
|
||||
scrollbar_min_handle_height: float = 1.0
|
||||
|
|
|
|||
|
|
@ -906,6 +906,7 @@ draw_scrollbar(const UIRenderData *ui) {
|
|||
float opacity = OPT(scrollbar_handle_opacity);
|
||||
float track_opacity = window->scrollbar.is_hovering ? OPT(scrollbar_track_hover_opacity) : OPT(scrollbar_track_opacity);
|
||||
GLsizei scrollbar_width_px = (GLsizei)(OPT(scrollbar_width) * ui->cell_width);
|
||||
if (window->scrollbar.is_hovering) scrollbar_width_px = (GLsizei)(OPT(scrollbar_hover_width) * ui->cell_width);
|
||||
GLsizei scrollbar_gap_px = (GLsizei)(OPT(scrollbar_gap) * ui->cell_width);
|
||||
unsigned scrollbar_radius = (unsigned)(OPT(scrollbar_radius) * ui->cell_width);
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ typedef struct Options {
|
|||
ScrollbarVisibilityPolicy scrollbar;
|
||||
bool scrollbar_interactive, scrollbar_jump_on_click;
|
||||
float scrollbar_width, scrollbar_radius, scrollbar_gap, scrollbar_min_handle_height, scrollbar_hitbox_expansion;
|
||||
float scrollbar_handle_opacity, scrollbar_track_opacity, scrollbar_track_hover_opacity;
|
||||
float scrollbar_hover_width, scrollbar_handle_opacity, scrollbar_track_opacity, scrollbar_track_hover_opacity;
|
||||
color_type scrollbar_handle_color, scrollbar_track_color;
|
||||
|
||||
float text_contrast, text_gamma_adjustment;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue