Skip to content

Commit

Permalink
Make foreground opacity configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
quantum5 committed Jun 16, 2021
1 parent 258b268 commit 4e55a8c
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 6 deletions.
4 changes: 2 additions & 2 deletions kittens/diff/options/types.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions kitty/cell_vertex.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

// Inputs {{{
layout(std140) uniform CellRenderData {
float xstart, ystart, dx, dy, sprite_dx, sprite_dy, background_opacity, cursor_text_uses_bg;
float xstart, ystart, dx, dy, sprite_dx, sprite_dy, background_opacity, foreground_opacity, cursor_text_uses_bg;

uint default_fg, default_bg, highlight_fg, highlight_bg, cursor_color, cursor_text_color, url_color, url_style, inverted;

Expand Down Expand Up @@ -184,7 +184,7 @@ void main() {
fg_as_uint = has_mark * color_table[NUM_COLORS + MARK_MASK + 1 + mark] + (ONE - has_mark) * fg_as_uint;
foreground = color_to_vec(fg_as_uint);
float has_dim = float((text_attrs >> DIM_SHIFT) & ONE);
effective_text_alpha = inactive_text_alpha * mix(1.0, dim_opacity, has_dim);
effective_text_alpha = foreground_opacity * inactive_text_alpha * mix(1.0, dim_opacity, has_dim);
float in_url = float((is_selected & TWO) >> 1);
decoration_fg = choose_color(in_url, color_to_vec(url_color), to_color(colors[2], fg_as_uint));
#ifdef USE_SELECTION_FG
Expand Down
8 changes: 8 additions & 0 deletions kitty/options/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,14 @@
'''
)

opt('foreground_opacity', '1.0',
option_type='unit_float', ctype='float',
long_text='''
The opacity of the foreground. A number between 0 and 1, where 1 is opaque and
0 is fully transparent. This has similar constraints to :opt:`background_opacity`.
'''
)

opt('background_image', 'none',
option_type='config_or_absolute_path', ctype='!background_image',
long_text='Path to a background image. Must be in PNG format.'
Expand Down
3 changes: 3 additions & 0 deletions kitty/options/parse.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions kitty/options/to-c-generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions kitty/options/types.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion kitty/shaders.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ send_graphics_data_to_gpu(size_t image_count, ssize_t gvao_idx, const ImageRende
static inline void
cell_update_uniform_block(ssize_t vao_idx, Screen *screen, int uniform_buffer, GLfloat xstart, GLfloat ystart, GLfloat dx, GLfloat dy, CursorRenderInfo *cursor, bool inverted, OSWindow *os_window) {
struct CellRenderData {
GLfloat xstart, ystart, dx, dy, sprite_dx, sprite_dy, background_opacity, cursor_text_uses_bg;
GLfloat xstart, ystart, dx, dy, sprite_dx, sprite_dy, background_opacity, foreground_opacity, cursor_text_uses_bg;

GLuint default_fg, default_bg, highlight_fg, highlight_bg, cursor_color, cursor_text_color, url_color, url_style, inverted;

Expand Down Expand Up @@ -295,6 +295,7 @@ cell_update_uniform_block(ssize_t vao_idx, Screen *screen, int uniform_buffer, G
rd->sprite_dx = 1.0f / (float)x; rd->sprite_dy = 1.0f / (float)y;
rd->inverted = inverted ? 1 : 0;
rd->background_opacity = os_window->is_semi_transparent ? os_window->background_opacity : 1.0f;
rd->foreground_opacity = os_window->is_semi_transparent ? OPT(foreground_opacity) : 1.0f;

#define COLOR(name) colorprofile_to_color(screen->color_profile, screen->color_profile->overridden.name, screen->color_profile->configured.name)
rd->default_fg = COLOR(default_fg); rd->default_bg = COLOR(default_bg); rd->highlight_fg = COLOR(highlight_fg); rd->highlight_bg = COLOR(highlight_bg);
Expand Down
2 changes: 1 addition & 1 deletion kitty/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ typedef struct {
WindowTitleIn macos_show_window_title_in;
int adjust_line_height_px, adjust_column_width_px;
float adjust_line_height_frac, adjust_column_width_frac;
float background_opacity, dim_opacity;
float background_opacity, foreground_opacity, dim_opacity;

char* background_image;
BackgroundImageLayout background_image_layout;
Expand Down

0 comments on commit 4e55a8c

Please sign in to comment.