change window_logo_scale to float, add granular xy scaling options to window_logo_scale
This commit is contained in:
parent
a8b28ca32b
commit
4d8b34cab8
8 changed files with 51 additions and 18 deletions
|
|
@ -1160,11 +1160,12 @@
|
|||
'''
|
||||
)
|
||||
|
||||
opt('window_logo_scale', '0',
|
||||
option_type='int', ctype='int',
|
||||
opt('window_logo_scale', '0.0 -1.0',
|
||||
option_type='window_logo_scale', ctype='!window_logo_scale',
|
||||
long_text='''
|
||||
The percentage [1-100] of the window which the logo should scale to.
|
||||
0 to disable.
|
||||
The percentage [1-100] of the window which the logo should scale to.
|
||||
Optionally setting 2 seperate values allows individual Width/Height scaling.
|
||||
Value of 0 in a given dimension disables scaling in that direction, single 0 to disable scaling.
|
||||
'''
|
||||
)
|
||||
|
||||
|
|
|
|||
5
kitty/options/parse.py
generated
5
kitty/options/parse.py
generated
|
|
@ -18,7 +18,8 @@
|
|||
shell_integration, store_multiple, symbol_map, tab_activity_symbol, tab_bar_edge,
|
||||
tab_bar_margin_height, tab_bar_min_tabs, tab_fade, tab_font_style, tab_separator,
|
||||
tab_title_template, titlebar_color, to_cursor_shape, to_font_size, to_layout_names, to_modifiers,
|
||||
url_prefixes, url_style, visual_window_select_characters, window_border_width, window_size
|
||||
url_prefixes, url_style, visual_window_select_characters, window_border_width, window_logo_scale,
|
||||
window_size
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -1391,7 +1392,7 @@ def window_logo_position(self, val: str, ans: typing.Dict[str, typing.Any]) -> N
|
|||
choices_for_window_logo_position = choices_for_placement_strategy
|
||||
|
||||
def window_logo_scale(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
|
||||
ans['window_logo_scale'] = int(val)
|
||||
ans['window_logo_scale'] = window_logo_scale(val)
|
||||
|
||||
def window_margin_width(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
|
||||
ans['window_margin_width'] = edge_width(val)
|
||||
|
|
|
|||
2
kitty/options/to-c-generated.h
generated
2
kitty/options/to-c-generated.h
generated
|
|
@ -618,7 +618,7 @@ convert_from_opts_window_logo_alpha(PyObject *py_opts, Options *opts) {
|
|||
|
||||
static void
|
||||
convert_from_python_window_logo_scale(PyObject *val, Options *opts) {
|
||||
opts->window_logo_scale = PyLong_AsLong(val);
|
||||
window_logo_scale(val, opts);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -338,6 +338,12 @@ tab_bar_margin_height(PyObject *val, Options *opts) {
|
|||
opts->tab_bar_margin_height.inner = PyFloat_AsDouble(PyTuple_GET_ITEM(val, 1));
|
||||
}
|
||||
|
||||
static void
|
||||
window_logo_scale(PyObject *src, Options *opts) {
|
||||
opts->window_logo_scale.width = PyFloat_AsFloat(PyTuple_GET_ITEM(src, 0));
|
||||
opts->window_logo_scale.height = PyFloat_AsFloat(PyTuple_GET_ITEM(src, 1));
|
||||
}
|
||||
|
||||
static void
|
||||
resize_debounce_time(PyObject *src, Options *opts) {
|
||||
opts->resize_debounce_time.on_end = s_double_to_monotonic_t(PyFloat_AsDouble(PyTuple_GET_ITEM(src, 0)));
|
||||
|
|
|
|||
2
kitty/options/types.py
generated
2
kitty/options/types.py
generated
|
|
@ -620,7 +620,7 @@ class Options:
|
|||
window_logo_alpha: float = 0.5
|
||||
window_logo_path: typing.Optional[str] = None
|
||||
window_logo_position: choices_for_window_logo_position = 'bottom-right'
|
||||
window_logo_scale: int = 0
|
||||
window_logo_scale: typing.Tuple[float, float] = (0, -1.0)
|
||||
window_margin_width: FloatEdges = FloatEdges(left=0, top=0, right=0, bottom=0)
|
||||
window_padding_width: FloatEdges = FloatEdges(left=0, top=0, right=0, bottom=0)
|
||||
window_resize_step_cells: int = 2
|
||||
|
|
|
|||
|
|
@ -646,6 +646,13 @@ def resize_draw_strategy(x: str) -> int:
|
|||
return cmap.get(x.lower(), 0)
|
||||
|
||||
|
||||
def window_logo_scale(x: str) -> Tuple[float, float]:
|
||||
parts = x.split(maxsplit=1)
|
||||
if len(parts) == 1:
|
||||
return positive_float(parts[0]), -1.0
|
||||
return positive_float(parts[0]), positive_float(parts[1])
|
||||
|
||||
|
||||
def resize_debounce_time(x: str) -> Tuple[float, float]:
|
||||
parts = x.split(maxsplit=1)
|
||||
if len(parts) == 1:
|
||||
|
|
|
|||
|
|
@ -733,16 +733,34 @@ draw_window_logo(ssize_t vao_idx, OSWindow *os_window, const WindowLogoRenderDat
|
|||
GLfloat logo_width_gl = gl_size(wl->instance->width, os_window->viewport_width);
|
||||
GLfloat logo_height_gl = gl_size(wl->instance->height, os_window->viewport_height);
|
||||
|
||||
if (OPT(window_logo_scale) != 0) {
|
||||
unsigned int scaled_wl_width;
|
||||
unsigned int scaled_wl_height;
|
||||
if (OPT(window_logo_scale.width) > 0 || OPT(window_logo_scale.height) > 0) {
|
||||
unsigned int scaled_wl_width = os_window->viewport_width;
|
||||
unsigned int scaled_wl_height = os_window->viewport_height;
|
||||
|
||||
if (os_window->viewport_height < os_window->viewport_width) {
|
||||
scaled_wl_height = os_window->viewport_height * OPT(window_logo_scale) / 100;
|
||||
scaled_wl_width = wl->instance->width * scaled_wl_height / wl->instance->height;
|
||||
} else {
|
||||
scaled_wl_width = os_window->viewport_width * OPT(window_logo_scale) / 100;
|
||||
scaled_wl_height = wl->instance->height * scaled_wl_width / wl->instance->width;
|
||||
// [sx] Scales logo to sx % of the viewports shortest dimension, preserving aspect ratio
|
||||
if (OPT(window_logo_scale.height) < 0) {
|
||||
if (os_window->viewport_height < os_window->viewport_width) {
|
||||
scaled_wl_height = (int)(os_window->viewport_height * OPT(window_logo_scale.width) / 100);
|
||||
scaled_wl_width = wl->instance->width * scaled_wl_height / wl->instance->height;
|
||||
} else {
|
||||
scaled_wl_width = (int)(os_window->viewport_width * OPT(window_logo_scale.width) / 100);
|
||||
scaled_wl_height = wl->instance->height * scaled_wl_width / wl->instance->width;
|
||||
}
|
||||
}
|
||||
// [0 sy] Scales logo's y dimension to sy % of viewporty keeping original x dimension
|
||||
else if (OPT(window_logo_scale.width) == 0.0) {
|
||||
scaled_wl_height = (int)(scaled_wl_height * OPT(window_logo_scale.height) / 100);
|
||||
scaled_wl_width = wl->instance->width;
|
||||
}
|
||||
// [sx 0] Scales logo's x dimension to sx % of viewportx keeping original y dimension
|
||||
else if (OPT(window_logo_scale.height) == 0.0) {
|
||||
scaled_wl_width = (int)(scaled_wl_width * OPT(window_logo_scale.width) / 100);
|
||||
scaled_wl_height = wl->instance->height;
|
||||
}
|
||||
// [sx sy] Scales logo's x and y dimension to sx and sy % of viewportx and viewporty respectively
|
||||
else {
|
||||
scaled_wl_height = (int)(scaled_wl_height * OPT(window_logo_scale.height) / 100);
|
||||
scaled_wl_width = (int)(scaled_wl_width * OPT(window_logo_scale.width) / 100);
|
||||
}
|
||||
|
||||
logo_height_gl = gl_size(scaled_wl_height, os_window->viewport_height);
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ typedef struct {
|
|||
ImageAnchorPosition window_logo_position;
|
||||
bool background_image_linear;
|
||||
float background_tint, background_tint_gaps, window_logo_alpha;
|
||||
unsigned int window_logo_scale;
|
||||
struct { float width, height; } window_logo_scale;
|
||||
|
||||
bool dynamic_background_opacity;
|
||||
float inactive_text_alpha;
|
||||
|
|
|
|||
Loading…
Reference in a new issue