From ad17143eb36a7e1fbead512ba8eb17263bde7c83 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Wed, 28 Feb 2007 18:00:03 +0100 Subject: [PATCH 1/4] Missing file --- shell/view/Makefile.am | 1 + tools/build-snapshot.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/shell/view/Makefile.am b/shell/view/Makefile.am index 8388b38c..abbb230e 100644 --- a/shell/view/Makefile.am +++ b/shell/view/Makefile.am @@ -9,5 +9,6 @@ sugar_PYTHON = \ clipboardicon.py \ clipboardmenu.py \ keyhandler.py \ + pulsingicon.py \ OverlayWindow.py \ Shell.py diff --git a/tools/build-snapshot.sh b/tools/build-snapshot.sh index 5a937631..0fcb2bcd 100755 --- a/tools/build-snapshot.sh +++ b/tools/build-snapshot.sh @@ -1,6 +1,6 @@ VERSION=0.63 DATE=`date +%Y%m%d` -RELEASE=2.25 +RELEASE=2.27 TARBALL=sugar-$VERSION-$RELEASE.${DATE}git.tar.bz2 rm sugar-$VERSION.tar.bz2 From abc400f84106b70905c6136253590dc59922a562 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Wed, 28 Feb 2007 19:05:56 +0100 Subject: [PATCH 2/4] Fix points_to_pixels impl --- sugar/graphics/units.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sugar/graphics/units.py b/sugar/graphics/units.py index 397b7028..ec3958e7 100644 --- a/sugar/graphics/units.py +++ b/sugar/graphics/units.py @@ -73,7 +73,8 @@ def _compute_zoom_factor(): else: return min(_MAX_ZOOM_FACTOR, screen_width / _ZOOM_CONSTANT) -_dpi_factor = float(_sugar.get_screen_dpi()) / 201.0 +_screen_dpi = float(_sugar.get_screen_dpi()) +_dpi_factor = _screen_dpi / 201.0 _zoom_factor = _compute_zoom_factor() STANDARD_ICON_SCALE = 1.0 * _dpi_factor * _zoom_factor @@ -83,7 +84,7 @@ LARGE_ICON_SCALE = 2.0 * _dpi_factor * _zoom_factor XLARGE_ICON_SCALE = 3.0 * _dpi_factor * _zoom_factor def points_to_pixels(points): - return int(points * _zoom_factor) + return int(points * _screen_dpi * 72.0 * _zoom_factor) def grid_to_pixels(units): return int(units * 75.0 * _dpi_factor * _zoom_factor) From 1b869a04f8571fd2bb501d80667b5269db300b56 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Wed, 28 Feb 2007 19:53:06 +0100 Subject: [PATCH 3/4] Icon and Button fixes. --- sugar/graphics/canvasicon.py | 48 +++++++++++++++++++++++------------- sugar/graphics/color.py | 4 --- sugar/graphics/iconbutton.py | 25 ++----------------- 3 files changed, 33 insertions(+), 44 deletions(-) diff --git a/sugar/graphics/canvasicon.py b/sugar/graphics/canvasicon.py index 4b1134c6..3438c829 100644 --- a/sugar/graphics/canvasicon.py +++ b/sugar/graphics/canvasicon.py @@ -14,7 +14,7 @@ # License along with this library; if not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. - +import logging import re import gobject @@ -137,7 +137,7 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem): 'icon-name' : (str, None, None, None, gobject.PARAM_READWRITE), 'xo-color' : (object, None, None, - gobject.PARAM_READWRITE), + gobject.PARAM_WRITABLE), 'fill-color' : (object, None, None, gobject.PARAM_READWRITE), 'stroke-color' : (object, None, None, @@ -148,6 +148,8 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem): 'cache' : (bool, None, None, False, gobject.PARAM_READWRITE), 'tooltip' : (str, None, None, None, + gobject.PARAM_READWRITE), + 'active' : (bool, None, None, True, gobject.PARAM_READWRITE) } @@ -165,6 +167,7 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem): self._popup = None self._hover_popup = False self._tooltip = False + self._active = True self._timeline = Timeline(self) self._timeline.add_tag('popup', 6, 6) @@ -216,38 +219,47 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem): self._cache = value elif pspec.name == 'tooltip': self._tooltip = value + elif pspec.name == 'active': + if self._active != value: + if not self._cache: + self._clear_buffers() + self._active = value + self._handle = None + self.emit_paint_needed(0, 0, -1, -1) + + def _choose_colors(self): + fill_color = None + stroke_color = None + if self._active: + if self._fill_color: + fill_color = self._fill_color.get_html() + if self._stroke_color: + stroke_color = self._stroke_color.get_html() + else: + stroke_color = color.ICON_STROKE_INACTIVE.get_html() + if self._fill_color: + fill_color = self._fill_color.get_html() + return [fill_color, stroke_color] def _get_handle(self): if not self._handle: cache = CanvasIcon._cache - fill_color = None - if self._fill_color: - fill_color = self._fill_color.get_html() + [fill_color, stroke_color] = self._choose_colors() - stroke_color = None - if self._stroke_color: - stroke_color = self._stroke_color.get_html() - self._handle = cache.get_handle(self._icon_name, fill_color, stroke_color) return self._handle def _get_current_buffer_key(self): - return (self._icon_name, self._fill_color, self._stroke_color, self._scale) + [fill_color, stroke_color] = self._choose_colors() + return (self._icon_name, fill_color, stroke_color, self._scale) def do_get_property(self, pspec): if pspec.name == 'scale': return self._scale elif pspec.name == 'icon-name': return self._icon_name - elif pspec.name == 'xo-color': - if self._stroke_color and self._fill_color: - xo_color = XoColor('%s,%s' % (self._stroke_color.get_html(), - self._fill_color.get_html())) - return xo_color - else: - return None elif pspec.name == 'fill-color': return self._fill_color elif pspec.name == 'stroke-color': @@ -256,6 +268,8 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem): return self._cache elif pspec.name == 'tooltip': return self._tooltip + elif pspec.name == 'active': + return self._active def _get_icon_size(self): handle = self._get_handle() diff --git a/sugar/graphics/color.py b/sugar/graphics/color.py index 5ff4c928..068aa160 100644 --- a/sugar/graphics/color.py +++ b/sugar/graphics/color.py @@ -20,8 +20,6 @@ _system_colors = { 'button-background-normal' : '#424242', 'button-hover' : '#808080', 'button-background-hover' : '#000000', - 'button-inactive' : '#808080', - 'button-background-inactive' : '#424242', 'icon-stroke-inactive' : '#757575', 'icon-fill-inactive' : '#9D9FA1' } @@ -100,7 +98,5 @@ BUTTON_NORMAL = SystemColor('button-normal') BUTTON_BACKGROUND_NORMAL = SystemColor('button-background-normal') BUTTON_HOVER = SystemColor('button-hover') BUTTON_BACKGROUND_HOVER = SystemColor('button-background-hover') -BUTTON_INACTIVE = SystemColor('button-inactive') -BUTTON_BACKGROUND_INACTIVE = SystemColor('button-background-inactive') ICON_FILL_INACTIVE = SystemColor('icon-fill-inactive') ICON_STROKE_INACTIVE = SystemColor('icon-stroke-inactive') diff --git a/sugar/graphics/iconbutton.py b/sugar/graphics/iconbutton.py index fea02fbd..822ddf1f 100644 --- a/sugar/graphics/iconbutton.py +++ b/sugar/graphics/iconbutton.py @@ -33,26 +33,15 @@ class IconButton(CanvasIcon): __gproperties__ = { 'size' : (int, None, None, 0, sys.maxint, STANDARD_SIZE, - gobject.PARAM_READWRITE), - 'active' : (bool, None, None, True, gobject.PARAM_READWRITE) } def __init__(self, **kwargs): - self._active = True - CanvasIcon.__init__(self, cache=True, **kwargs) - if self._active: + if not self.props.fill_color and not self.props.stroke_color: self.props.fill_color = color.BUTTON_BACKGROUND_NORMAL self.props.stroke_color = color.BUTTON_NORMAL - self.props.background_color = \ - color.BUTTON_BACKGROUND_NORMAL.get_int() - else: - self.props.fill_color = color.BUTTON_BACKGROUND_INACTIVE - self.props.stroke_color = color.BUTTON_INACTIVE - self.props.background_color = \ - color.BUTTON_BACKGROUND_INACTIVE.get_int() self._set_size(STANDARD_SIZE) @@ -74,22 +63,12 @@ class IconButton(CanvasIcon): def do_set_property(self, pspec, value): if pspec.name == 'size': self._set_size(value) - elif pspec.name == 'active': - self._active = value - if self._active: - self.props.fill_color = color.BUTTON_BACKGROUND_NORMAL - self.props.stroke_color = color.BUTTON_NORMAL - else: - self.props.fill_color = color.BUTTON_BACKGROUND_INACTIVE - self.props.stroke_color = color.BUTTON_INACTIVE else: CanvasIcon.do_set_property(self, pspec, value) def do_get_property(self, pspec): if pspec.name == 'size': return self._size - elif pspec.name == 'active': - return self._active else: return CanvasIcon.do_get_property(self, pspec) @@ -100,7 +79,7 @@ class IconButton(CanvasIcon): def prelight(self, enter): if enter: - if self._active: + if self.props.active: self.props.background_color = color.BLACK.get_int() else: self.props.background_color = \ From 6c16653173a780ff3234d6ccd2f5f2dd83c61da1 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Wed, 28 Feb 2007 21:04:26 +0100 Subject: [PATCH 4/4] Convert points correctly to device. Tweak zoom factor logic a bit --- sugar/graphics/font.py | 4 ++-- sugar/graphics/units.py | 7 +++++-- tools/build-snapshot.sh | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/sugar/graphics/font.py b/sugar/graphics/font.py index bf532694..6750f871 100644 --- a/sugar/graphics/font.py +++ b/sugar/graphics/font.py @@ -3,8 +3,8 @@ import pango from sugar.graphics import units _system_fonts = { - 'default' : 'Bitstream Vera Sans %dpx' % units.points_to_pixels(9), - 'default-bold' : 'Bitstream Vera Sans bold %dpx' % units.points_to_pixels(9) + 'default' : 'Bitstream Vera Sans %d' % units.points_to_device(9), + 'default-bold' : 'Bitstream Vera Sans bold %d' % units.points_to_device(9) } class Font(object): diff --git a/sugar/graphics/units.py b/sugar/graphics/units.py index ec3958e7..2ec3dd5b 100644 --- a/sugar/graphics/units.py +++ b/sugar/graphics/units.py @@ -64,7 +64,7 @@ import gtk import _sugar _MAX_ZOOM_FACTOR = 1.5 -_ZOOM_CONSTANT = 600.0 +_ZOOM_CONSTANT = 800.0 def _compute_zoom_factor(): screen_width = gtk.gdk.screen_width() @@ -83,8 +83,11 @@ MEDIUM_ICON_SCALE = 1.5 * _dpi_factor * _zoom_factor LARGE_ICON_SCALE = 2.0 * _dpi_factor * _zoom_factor XLARGE_ICON_SCALE = 3.0 * _dpi_factor * _zoom_factor +def points_to_device(points): + return int(points * _zoom_factor) + def points_to_pixels(points): - return int(points * _screen_dpi * 72.0 * _zoom_factor) + return int(points * _screen_dpi / 72.0 * _zoom_factor) def grid_to_pixels(units): return int(units * 75.0 * _dpi_factor * _zoom_factor) diff --git a/tools/build-snapshot.sh b/tools/build-snapshot.sh index 0fcb2bcd..b5d9b8ad 100755 --- a/tools/build-snapshot.sh +++ b/tools/build-snapshot.sh @@ -1,6 +1,6 @@ VERSION=0.63 DATE=`date +%Y%m%d` -RELEASE=2.27 +RELEASE=2.29 TARBALL=sugar-$VERSION-$RELEASE.${DATE}git.tar.bz2 rm sugar-$VERSION.tar.bz2