Skip to content

Commit

Permalink
feat(preview: entry): correctly show border
Browse files Browse the repository at this point in the history
  • Loading branch information
actionless committed Dec 27, 2019
1 parent ac14b2a commit 17d7ac9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
8 changes: 6 additions & 2 deletions oomox_gui/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ def color_hex_from_list(color_list):
return ''.join([int_to_hex(i) for i in color_list])


def is_dark(color_text):
def hex_lightness(color_text):
# @TODO: use real lightness from HSV or Lab color model
return sum([
hex_to_int(channel_text)
for channel_text in color_list_from_hex(color_text)
]) < 384
]) / 765


def is_dark(color_text):
return hex_lightness(color_text) < 0.5


def hex_darker(color_text, darken_amount=10):
Expand Down
14 changes: 8 additions & 6 deletions oomox_gui/preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from .theme_model import THEME_MODEL
from .color import (
convert_theme_color_to_gdk, mix_theme_colors, mix_gdk_colors,
convert_theme_color_to_gdk, mix_theme_colors, mix_gdk_colors, hex_lightness,
)
from .gtk_helpers import ScaledImage
from .preview_terminal import TerminalThemePreview
Expand Down Expand Up @@ -344,11 +344,13 @@ def update_preview_borders(self, colorscheme):
), (
'entry',
self.gtk_preview.entry,
mix_theme_colors(
colorscheme['TXT_FG'], colorscheme['TXT_BG'], 0.20
),
colorscheme['BG'],
0.69
colorscheme['TXT_BG'],
colorscheme['TXT_FG'],
0.8 * (0.7 + (
0 if hex_lightness(colorscheme['TXT_BG']) > 0.66 else (
0.1 if hex_lightness(colorscheme['TXT_BG']) > 0.33 else 0.3
)
))
),
):
border_color = mix_theme_colors(fg, bg, ratio)
Expand Down

0 comments on commit 17d7ac9

Please sign in to comment.