From 5f8ff5e3a4409c39bc3150e4ce0739126991a7c6 Mon Sep 17 00:00:00 2001 From: "g@localhost.localdomain" Date: Fri, 5 Jan 2007 23:20:45 +0100 Subject: [PATCH] Lighter colors --- pysize/ui/gtk/pysize_widget_draw.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/pysize/ui/gtk/pysize_widget_draw.py b/pysize/ui/gtk/pysize_widget_draw.py index 52c1bcb..3135255 100644 --- a/pysize/ui/gtk/pysize_widget_draw.py +++ b/pysize/ui/gtk/pysize_widget_draw.py @@ -73,7 +73,7 @@ class PysizeWidget_Draw(object): context.show_layout(pl) return True - def _get_node_colors(self, node, is_selected, colors): + def _get_node_colors(self, node, is_selected, size_color, colors): def transform(colors, dr, dg, db): def clamp(c): return max(0, min(1, c)) @@ -88,10 +88,8 @@ class PysizeWidget_Draw(object): if not node.is_real(): colors = map(lambda c: (min(c), max(c), max(c)), colors) - if self.tree.root.children: - size = node.get_useful_size() / \ - (self.tree.root.children[0].size * 3.0) - colors = transform(colors, -size, -size, -size) + size_delta = size_color(node.size) + colors = transform(colors, size_delta, size_delta, size_delta) if node == self.cursor_node: colors = transform(colors, 0.2, 0.2, 0.2) @@ -99,7 +97,7 @@ class PysizeWidget_Draw(object): colors = transform(colors, -0.4, -0.4, -0.4) return colors - def _draw_box(self, context, x0, x1, y0, y1, node): + def _draw_box(self, context, x0, x1, y0, y1, node, size_color): if x0 == 0.0: x0 += LINE_WIDTH/2.0 else: @@ -112,7 +110,7 @@ class PysizeWidget_Draw(object): y1 -= LINE_WIDTH/4.0 node.rectangle = x0, x1, y0, y1 is_selected = set(node.get_fullpaths()) <= self.selected_paths - colors = self._get_node_colors(node, is_selected, + colors = self._get_node_colors(node, is_selected, size_color, ((0.5, 0.4, 1.0), (0.2, 0.4, 1.0))) context.set_source_rgb(0, 0, 0) if self.fast: @@ -161,7 +159,7 @@ class PysizeWidget_Draw(object): attempt(name, position) or \ attempt(size, position) - def _draw_boxes(self, context, node, depth, offset): + def _draw_boxes(self, context, node, depth, offset, size_color): w = self.allocation.width h = self.allocation.height x0 = depth * (w - 1.0) / (self.tree.height or 1) @@ -169,19 +167,28 @@ class PysizeWidget_Draw(object): y0 = (h - 1.0) * offset / self.tree.root.size y1 = (h - 1.0) * (offset + node.size) / self.tree.root.size - self._draw_box(context, x0, x1, y0, y1, node) + self._draw_box(context, x0, x1, y0, y1, node, size_color) depth += 1 for child in node.children: - self._draw_boxes(context, child, depth, offset) + self._draw_boxes(context, child, depth, offset, size_color) offset += child.size def _draw(self, context): max_text_height_before = self.max_text_height + if self.tree.root.children: + max_size = self.tree.root.children[0].size + min_size = self.tree.root.minimum_node_size() + diff = max_size - min_size + def size_color(size): + return 0.3 - (size - min_size) / (2.0 * diff) + else: + def size_color(size): + return 0 context.set_line_width(LINE_WIDTH) offset = 0 for child in self.tree.root.children or [self.tree.root]: if child.size: - self._draw_boxes(context, child, 0, offset) + self._draw_boxes(context, child, 0, offset, size_color) offset += child.size if self.max_text_height != max_text_height_before: self.schedule_new_tree() -- 2.11.4.GIT