From 57e7e289cc3502bb954874e0b669967eecaf2cb1 Mon Sep 17 00:00:00 2001 From: "g@localhost.localdomain" Date: Sat, 30 Sep 2006 22:41:19 +0200 Subject: [PATCH] Add command line option to ask a simpler cairo drawing --- pysize/main.py | 2 ++ pysize/ui/gtk/pysize_widget_draw.py | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/pysize/main.py b/pysize/main.py index b326520..267a8a3 100644 --- a/pysize/main.py +++ b/pysize/main.py @@ -65,6 +65,8 @@ def main(): parser.add_option('--min-size', type='str', dest='min_size', default='auto', metavar='SIZE', help='minimum size to consider drawing [auto]') + parser.add_option('--fast-drawing', action='store_true', dest='fast', + default=False, help='faster but simpler drawing with GTK') parser.add_option('--profile', action='store_true', dest='profile', default=False, help=optparse.SUPPRESS_HELP) (options, args) = parser.parse_args() diff --git a/pysize/ui/gtk/pysize_widget_draw.py b/pysize/ui/gtk/pysize_widget_draw.py index f912c8e..9867c83 100644 --- a/pysize/ui/gtk/pysize_widget_draw.py +++ b/pysize/ui/gtk/pysize_widget_draw.py @@ -12,13 +12,13 @@ from pysize.ui.utils import human_unit, min_size_to_consider RADIUS = 20.0 LINE_WIDTH = 4.0 -CAIRO_IS_FAST = True class PysizeWidget_Draw(object): def __init__(self, options, args): self.connect('expose-event', type(self)._expose_event) self.modify_font(pango.FontDescription('Monospace 12')) self.max_text_height = self.measure_font_height() + self.fast = options.fast def measure_font_height(self): (w, h) = self.create_pango_layout('a').get_pixel_size() @@ -70,7 +70,15 @@ class PysizeWidget_Draw(object): y1 -= LINE_WIDTH/4.0 node.rectangle = (x0, x1, y0, y1) - if CAIRO_IS_FAST: + if self.fast: + context.rectangle(x0, y0, x1 - x0, y1 - y0) + context.set_source_rgb(0, 0, 0) + context.stroke_preserve() + + colors = self._get_node_colors(node, [0, 0.5, 1.0]) + context.set_source_rgb(*colors) + context.fill() + else: context.new_path() context.arc(x0 + RADIUS, y0 + RADIUS, RADIUS, - math.pi, - math.pi / 2.0) @@ -94,14 +102,6 @@ class PysizeWidget_Draw(object): gradient.add_color_stop_rgb(1.0, *colors[3:]) context.set_source(gradient) context.fill() - else: - context.rectangle(x0, y0, x1 - x0, y1 - y0) - context.set_source_rgb(0, 0, 0) - context.stroke_preserve() - - colors = self._get_node_colors(node, [0, 0.5, 1.0]) - context.set_source_rgb(*colors) - context.fill() name = node.get_name() size = human_unit(node.size) -- 2.11.4.GIT