From 6f74ab94aae28ffc7a4cd1a2559f4908dfb6b7fb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org>
Date: Wed, 20 Mar 2013 22:49:34 -0300
Subject: [PATCH 3/5] CellRendererIcon: more improvement in
point_in_cell_renderer - SL #4343
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Mail-Followup-To: <sugar-devel@lists.sugarlabs.org>
Cache the absolute x and the width of the cell, and use this
information as a gross filter at the beginning of the
point_in_cell_renderer method.
Signed-off-by: Manuel Quiñones <manuq@laptop.org>
---
src/sugar3/graphics/icon.py | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/sugar3/graphics/icon.py b/src/sugar3/graphics/icon.py
index 7c428b7..57c6d4e 100644
a
|
b
|
class CellRendererIcon(Gtk.CellRenderer): |
761 | 761 | self._prelit_stroke_color = None |
762 | 762 | self._active_state = False |
763 | 763 | self._palette_invoker = CellRendererInvoker() |
| 764 | self._x = None |
| 765 | self._width = None |
764 | 766 | |
765 | 767 | Gtk.CellRenderer.__init__(self) |
766 | 768 | |
… |
… |
class CellRendererIcon(Gtk.CellRenderer): |
887 | 889 | if x is None and y is None: |
888 | 890 | x, y = tree_view.get_pointer() |
889 | 891 | x, y = tree_view.convert_widget_to_bin_window_coords(x, y) |
| 892 | |
| 893 | # Horizontal filter. |
| 894 | if self._x is not None: |
| 895 | if x < self._x or x > self._x + self._width: |
| 896 | return False |
| 897 | |
890 | 898 | pos = tree_view.get_path_at_pos(int(x), int(y)) |
891 | 899 | if pos is None: |
892 | 900 | return False |
893 | 901 | |
894 | | path_, column, x, y_ = pos |
| 902 | path, column, x, y_ = pos |
895 | 903 | result = column.cell_get_position(self) |
896 | 904 | |
897 | 905 | # If this cell was not found in the column: |
… |
… |
class CellRendererIcon(Gtk.CellRenderer): |
899 | 907 | return False |
900 | 908 | |
901 | 909 | cell_x, cell_width = result |
| 910 | |
| 911 | # Cache the absolute x and width of this cell if not done yet. |
| 912 | if self._x is None: |
| 913 | column_area = tree_view.get_cell_area(path, column) |
| 914 | self._x = column_area.x + cell_x |
| 915 | self._width = cell_width |
| 916 | |
902 | 917 | for cell_renderer in column.get_cells(): |
903 | 918 | if cell_renderer == self: |
904 | 919 | if x > cell_x and x < (cell_x + cell_width): |