Add an option to control background image tinting for window gaps

This commit is contained in:
pagedown 2022-11-21 12:21:06 +08:00
parent 4290a8f9ba
commit 08d74a6c56
No known key found for this signature in database
GPG Key ID: E921CF18AC8FF6EB
7 changed files with 34 additions and 3 deletions

View File

@ -49,6 +49,9 @@ Detailed list of changes
- Implement :ref:`edit-in-kitty <edit_file>` using the new ``kitty-tool`` static executable (:iss:`5546`, :iss:`5630`)
- Add an option :opt:`background_tint_gaps` to control background image tinting for window gaps (:iss:`5596`)
0.26.5 [2022-11-07]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -1320,6 +1320,14 @@ set and transparent windows are supported or :opt:`background_image` is set.
'''
)
opt('background_tint_gaps', '1.0',
option_type='unit_float', ctype='float',
long_text='''
How much to tint the background image at the window gaps by the background
color, after applying :opt:`background_tint`.
'''
)
opt('dim_opacity', '0.75',
option_type='unit_float', ctype='float',
long_text='''

View File

@ -84,6 +84,9 @@ class Parser:
def background_tint(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
ans['background_tint'] = unit_float(val)
def background_tint_gaps(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
ans['background_tint_gaps'] = unit_float(val)
def bell_border_color(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
ans['bell_border_color'] = to_color(val)

View File

@ -772,6 +772,19 @@ convert_from_opts_background_tint(PyObject *py_opts, Options *opts) {
Py_DECREF(ret);
}
static void
convert_from_python_background_tint_gaps(PyObject *val, Options *opts) {
opts->background_tint_gaps = PyFloat_AsFloat(val);
}
static void
convert_from_opts_background_tint_gaps(PyObject *py_opts, Options *opts) {
PyObject *ret = PyObject_GetAttrString(py_opts, "background_tint_gaps");
if (ret == NULL) return;
convert_from_python_background_tint_gaps(ret, opts);
Py_DECREF(ret);
}
static void
convert_from_python_dim_opacity(PyObject *val, Options *opts) {
opts->dim_opacity = PyFloat_AsFloat(val);
@ -1126,6 +1139,8 @@ convert_opts_from_python_opts(PyObject *py_opts, Options *opts) {
if (PyErr_Occurred()) return false;
convert_from_opts_background_tint(py_opts, opts);
if (PyErr_Occurred()) return false;
convert_from_opts_background_tint_gaps(py_opts, opts);
if (PyErr_Occurred()) return false;
convert_from_opts_dim_opacity(py_opts, opts);
if (PyErr_Occurred()) return false;
convert_from_opts_mark1_foreground(py_opts, opts);

View File

@ -63,6 +63,7 @@ option_names = ( # {{{
'background_image_linear',
'background_opacity',
'background_tint',
'background_tint_gaps',
'bell_border_color',
'bell_on_tab',
'bell_path',
@ -476,6 +477,7 @@ class Options:
background_image_linear: bool = False
background_opacity: float = 1.0
background_tint: float = 0
background_tint_gaps: float = 1.0
bell_border_color: Color = Color(255, 90, 0)
bell_on_tab: str = '🔔 '
bell_path: typing.Optional[str] = None

View File

@ -980,7 +980,7 @@ draw_borders(ssize_t vao_idx, unsigned int num_border_rects, BorderRect *rect_bu
draw_bg(w);
BLEND_ONTO_OPAQUE;
background_opacity = 1.0f;
tint_opacity = OPT(background_tint);
tint_opacity = OPT(background_tint) * OPT(background_tint_gaps);
tint_premult = w->is_semi_transparent ? OPT(background_tint) : 1.0f;
}

View File

@ -52,7 +52,7 @@ typedef struct {
BackgroundImageLayout background_image_layout;
ImageAnchorPosition window_logo_position;
bool background_image_linear;
float background_tint, window_logo_alpha;
float background_tint, background_tint_gaps, window_logo_alpha;
bool dynamic_background_opacity;
float inactive_text_alpha;