From 4cc2af5eb6cd2e3576f2820e3eb53fc11669f165 Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Fri, 7 Sep 2012 13:29:45 +0000 Subject: [PATCH] fanchart feature: single color background + filter improvement: bold text svn: r20351 --- src/gui/widgets/fanchart.py | 35 ++++++++++++++++++++++++-------- src/plugins/view/fanchartview.py | 2 ++ 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/gui/widgets/fanchart.py b/src/gui/widgets/fanchart.py index 870ddb3d8..0fb7aa638 100644 --- a/src/gui/widgets/fanchart.py +++ b/src/gui/widgets/fanchart.py @@ -85,9 +85,9 @@ def gender_code(is_male): #------------------------------------------------------------------------- PIXELS_PER_GENERATION = 50 # size of radius for generation -BORDER_EDGE_WIDTH = 10 -CHILDRING_WIDTH = 12 -TRANSLATE_PX = 10 +BORDER_EDGE_WIDTH = 10 # empty white box size at edge to indicate parents +CHILDRING_WIDTH = 12 # width of the children ring inside the person +TRANSLATE_PX = 10 # size of the central circle, used to move the chart BACKGROUND_SCHEME1 = 0 BACKGROUND_SCHEME2 = 1 @@ -439,7 +439,7 @@ class FanChartWidget(Gtk.DrawingArea): cr.save() name = name_displayer.display(person) self.draw_text(cr, name, self.center - 10, 95, 455, False, - self.fontcolor(r,g,b)) + self.fontcolor(r, g, b), self.fontbold(a)) cr.restore() #draw center to move chart cr.set_source_rgb(0, 0, 0) # black @@ -523,7 +523,7 @@ class FanChartWidget(Gtk.DrawingArea): radial = True radstart = radius - PIXELS_PER_GENERATION + 4 self.draw_text(cr, name, radstart, start, stop, radial, - self.fontcolor(r, g, b)) + self.fontcolor(r, g, b), self.fontbold(a)) cr.restore() def drawchildring(self, cr): @@ -576,7 +576,7 @@ class FanChartWidget(Gtk.DrawingArea): cr.fill() def draw_text(self, cr, text, radius, start, stop, radial=False, - fontcolor=(0, 0, 0)): + fontcolor=(0, 0, 0), bold=False): """ Display text at a particular radius, between start and stop degrees. @@ -585,6 +585,8 @@ class FanChartWidget(Gtk.DrawingArea): font = Pango.FontDescription(self.fontdescr) fontsize = self.fontsize font.set_size(fontsize * Pango.SCALE) + if bold: + font.set_weight(Pango.Weight.BOLD) cr.set_source_rgb(fontcolor[0], fontcolor[1], fontcolor[2]) if radial and self.radialtext: cr.save() @@ -739,9 +741,10 @@ class FanChartWidget(Gtk.DrawingArea): cstart[2]/255) cend_hsv = colorsys.rgb_to_hsv(cend[0]/255, cend[1]/255, cend[2]/255) - if self.background == BACKGROUND_GENDER: + if self.background in [BACKGROUND_GENDER, BACKGROUND_SINGLE_COLOR]: # nothing to precompute self.colors = None + self.maincolor = cstart elif self.background == BACKGROUND_GRAD_GEN: #compute the colors, -1, 0, ..., maxgen divs = [x/(maxgen-1) for x in range(maxgen)] @@ -827,6 +830,8 @@ class FanChartWidget(Gtk.DrawingArea): alive = False backgr, border = gui.utils.color_graph_box(alive, person.gender) color = gui.utils.hex_to_rgb(backgr) + elif self.background == BACKGROUND_SINGLE_COLOR: + color = self.maincolor elif self.background == BACKGROUND_GRAD_AGE: color = userdata[0] else: @@ -837,7 +842,10 @@ class FanChartWidget(Gtk.DrawingArea): color = [x*.9 for x in color] # now we set transparency data if self.filter and not self.filter.match(person.handle, self.dbstate.db): - alpha = self.alpha_filter + if self.background == BACKGROUND_SINGLE_COLOR: + alpha = 0. # no color shown + else: + alpha = self.alpha_filter else: alpha = 1. @@ -858,6 +866,15 @@ class FanChartWidget(Gtk.DrawingArea): self.cache_fontcolor[(r, g, b)] = (255, 255, 255) return self.cache_fontcolor[(r, g, b)] + def fontbold(self, a): + """ + The font should be bold if no transparency and font is set. + In that case, True is returned + """ + if a >= 1. and self.filter: + return True + return False + def expand_parents(self, generation, selected, current): if generation >= self.generations: return selected = 2 * selected @@ -941,7 +958,7 @@ class FanChartWidget(Gtk.DrawingArea): self.angle[generation][selected-1] = [start,start,male, COLLAPSED] self.hide_parents(generation+1, selected-1, start) - elif gstate == self.EXPANDED: # let's shrink + elif gstate == EXPANDED: # let's shrink if gmale: # shrink from right slice = (gstop - gstart)/2.0 diff --git a/src/plugins/view/fanchartview.py b/src/plugins/view/fanchartview.py index 7b83b5a09..c068a2bb6 100644 --- a/src/plugins/view/fanchartview.py +++ b/src/plugins/view/fanchartview.py @@ -274,6 +274,8 @@ class FanChartView(fanchart.FanChartGrampsGUI, NavigationView): (fanchart.BACKGROUND_GENDER, _('Gender colors')), (fanchart.BACKGROUND_GRAD_GEN, _('Generation based gradient')), (fanchart.BACKGROUND_GRAD_AGE, _('Age (0-100) based gradient')), + (fanchart.BACKGROUND_SINGLE_COLOR, + _('Single main (filter) color')), (fanchart.BACKGROUND_WHITE, _('White')), (fanchart.BACKGROUND_SCHEME1, _('Color scheme classic report')), (fanchart.BACKGROUND_SCHEME2, _('Color scheme classic view')),