Skip to content

Commit ee70263

Browse files
committed
Graph View: make font color adapt to node background
Fixes #11957
1 parent 195f139 commit ee70263

File tree

3 files changed

+117
-114
lines changed

3 files changed

+117
-114
lines changed

GraphView/graphview.gpr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
name = _("Graph View"),
3333
category = ("Ancestry", _("Charts")),
3434
description = _("Dynamic and interactive graph of relations"),
35-
version = '1.0.116',
35+
version = '1.0.117',
3636
gramps_target_version = "5.1",
3737
status = STABLE,
3838
fname = 'graphview.py',

GraphView/graphview.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@
7373
from gramps.gui.dialog import OptionDialog, ErrorDialog, QuestionDialog2
7474
from gramps.gui.display import display_url
7575
from gramps.gui.editors import EditPerson, EditFamily, EditTagList
76-
from gramps.gui.utils import color_graph_box, color_graph_family, rgb_to_hex
76+
from gramps.gui.utils import (color_graph_box, color_graph_family,
77+
rgb_to_hex, hex_to_rgb_float)
7778
from gramps.gui.views.navigationview import NavigationView
7879
from gramps.gui.views.bookmarks import PersonBookmarks
7980
from gramps.gui.views.tags import OrganizeTagsDialog
@@ -3030,8 +3031,10 @@ def add_node(self, node_id, label, shape="", color="",
30303031
text += ' color="%s"' % color
30313032

30323033
if fillcolor:
3033-
text += ' fillcolor="%s"' % fillcolor
3034-
3034+
color = hex_to_rgb_float(fillcolor)
3035+
yiq = (color[0] * 299 + color[1] * 587 + color[2] * 114)
3036+
fontcolor = "white" if yiq < 500 else "black"
3037+
text += ' fillcolor="%s" fontcolor="%s"' % (fillcolor, fontcolor)
30353038
if style:
30363039
text += ' style="%s"' % style
30373040

0 commit comments

Comments
 (0)