Move from scaling to sizes in CanvasIcon.
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
import hippo
|
||||
|
||||
from sugar.graphics.canvasicon import CanvasIcon
|
||||
from sugar.graphics import units
|
||||
from sugar.graphics import style
|
||||
from sugar.graphics.xocolor import XoColor
|
||||
|
||||
class ColorPicker(hippo.CanvasBox, hippo.CanvasItem):
|
||||
@@ -25,7 +25,7 @@ class ColorPicker(hippo.CanvasBox, hippo.CanvasItem):
|
||||
hippo.CanvasBox.__init__(self, **kwargs)
|
||||
self.props.orientation = hippo.ORIENTATION_HORIZONTAL
|
||||
|
||||
self._xo = CanvasIcon(scale=units.XLARGE_ICON_SCALE,
|
||||
self._xo = CanvasIcon(size=style.XLARGE_ICON_SIZE,
|
||||
icon_name='theme:stock-buddy')
|
||||
self._set_random_colors()
|
||||
self._xo.connect('activated', self._xo_activated_cb)
|
||||
|
||||
@@ -23,7 +23,7 @@ import gobject
|
||||
from sugar.graphics.canvasicon import CanvasIcon
|
||||
from view.clipboardmenu import ClipboardMenu
|
||||
from sugar.graphics.xocolor import XoColor
|
||||
from sugar.graphics import units
|
||||
from sugar.graphics import style
|
||||
from sugar.clipboard import clipboardservice
|
||||
from sugar import util
|
||||
from sugar import profile
|
||||
@@ -45,9 +45,7 @@ class ClipboardIcon(CanvasIcon):
|
||||
self._activity = None
|
||||
self._selected = False
|
||||
self._hover = False
|
||||
self.props.box_width = units.grid_to_pixels(1)
|
||||
self.props.box_height = units.grid_to_pixels(1)
|
||||
self.props.scale = units.STANDARD_ICON_SCALE
|
||||
self.props.size = style.STANDARD_ICON_SIZE
|
||||
self.props.xo_color = XoColor(profile.get_color().to_string())
|
||||
|
||||
cb_service = clipboardservice.get_instance()
|
||||
|
||||
@@ -18,7 +18,7 @@ import gtk
|
||||
|
||||
from gettext import gettext as _
|
||||
from sugar.graphics import canvasicon
|
||||
from sugar.graphics import units
|
||||
from sugar.graphics import style
|
||||
from sugar.graphics.palette import Palette
|
||||
|
||||
_ICON_NAME = 'device-battery'
|
||||
@@ -29,7 +29,7 @@ _STATUS_FULLY_CHARGED = 2
|
||||
|
||||
class DeviceView(canvasicon.CanvasIcon):
|
||||
def __init__(self, model):
|
||||
canvasicon.CanvasIcon.__init__(self, scale=units.MEDIUM_ICON_SCALE)
|
||||
canvasicon.CanvasIcon.__init__(self, size=style.MEDIUM_ICON_SIZE)
|
||||
self._model = model
|
||||
self._palette = BatteryPalette(_('My Battery life'))
|
||||
self.set_palette(self._palette)
|
||||
|
||||
@@ -17,12 +17,11 @@
|
||||
|
||||
from sugar.graphics import canvasicon
|
||||
from sugar.graphics import style
|
||||
from sugar.graphics import units
|
||||
from model.devices import device
|
||||
|
||||
class DeviceView(canvasicon.CanvasIcon):
|
||||
def __init__(self, model):
|
||||
canvasicon.CanvasIcon.__init__(self, scale=units.MEDIUM_ICON_SCALE,
|
||||
canvasicon.CanvasIcon.__init__(self, size=style.MEDIUM_ICON_SIZE,
|
||||
icon_name='theme:device-network-mesh')
|
||||
self._model = model
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
from sugar.graphics import canvasicon
|
||||
from sugar.graphics import style
|
||||
from sugar.graphics import units
|
||||
from sugar.graphics import style
|
||||
from model.devices.network import wireless
|
||||
from sugar.graphics.canvasicon import CanvasIcon
|
||||
from model.devices import device
|
||||
@@ -26,7 +26,7 @@ _ICON_NAME = 'device-network-wireless'
|
||||
|
||||
class DeviceView(CanvasIcon):
|
||||
def __init__(self, model):
|
||||
CanvasIcon.__init__(self, scale=units.MEDIUM_ICON_SCALE)
|
||||
CanvasIcon.__init__(self, size=style.MEDIUM_ICON_SIZE)
|
||||
self._model = model
|
||||
|
||||
model.connect('notify::name', self._name_changed_cb)
|
||||
|
||||
@@ -18,7 +18,7 @@ import hippo
|
||||
import gobject
|
||||
|
||||
from sugar.graphics.canvasicon import CanvasIcon
|
||||
from sugar.graphics import units
|
||||
from sugar.graphics import style
|
||||
from sugar.presence import presenceservice
|
||||
|
||||
from model import bundleregistry
|
||||
@@ -32,10 +32,10 @@ class FriendView(hippo.CanvasBox):
|
||||
|
||||
self._buddy = buddy
|
||||
self._buddy_icon = BuddyIcon(shell, buddy)
|
||||
self._buddy_icon.props.scale = units.LARGE_ICON_SCALE
|
||||
self._buddy_icon.props.scale = style.LARGE_ICON_SIZE
|
||||
self.append(self._buddy_icon)
|
||||
|
||||
self._activity_icon = CanvasIcon(scale=units.LARGE_ICON_SCALE)
|
||||
self._activity_icon = CanvasIcon(size=style.LARGE_ICON_SIZE)
|
||||
self._activity_icon_visible = False
|
||||
|
||||
if self._buddy.is_present():
|
||||
|
||||
@@ -21,7 +21,7 @@ import gobject
|
||||
|
||||
from sugar import profile
|
||||
from sugar.graphics.spreadlayout import SpreadLayout
|
||||
from sugar.graphics import units
|
||||
from sugar.graphics import style
|
||||
|
||||
from model.BuddyModel import BuddyModel
|
||||
from view.BuddyIcon import BuddyIcon
|
||||
@@ -40,7 +40,7 @@ class FriendsBox(hippo.CanvasBox):
|
||||
|
||||
buddy_model = BuddyModel(key=profile.get_pubkey())
|
||||
self._owner_icon = BuddyIcon(shell, buddy_model)
|
||||
self._owner_icon.props.scale = units.LARGE_ICON_SCALE
|
||||
self._owner_icon.props.size = style.LARGE_ICON_SIZE
|
||||
self._layout.add_center(self._owner_icon)
|
||||
|
||||
friends = self._shell.get_model().get_friends()
|
||||
|
||||
@@ -24,7 +24,6 @@ import gtk
|
||||
import hippo
|
||||
import dbus
|
||||
|
||||
from sugar.graphics import units
|
||||
from sugar.graphics import style
|
||||
from sugar.graphics.xocolor import XoColor
|
||||
from sugar.graphics.palette import Palette, CanvasInvoker
|
||||
@@ -46,7 +45,7 @@ class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
|
||||
box_height=style.zoom(450))
|
||||
self.append(self._donut)
|
||||
|
||||
self._my_icon = HomeMyIcon(shell, units.XLARGE_ICON_SCALE)
|
||||
self._my_icon = HomeMyIcon(shell, style.XLARGE_ICON_SIZE)
|
||||
self.append(self._my_icon, hippo.PACK_FIXED)
|
||||
|
||||
shell_model = shell.get_model()
|
||||
|
||||
@@ -18,7 +18,7 @@ import gtk
|
||||
import hippo
|
||||
import cairo
|
||||
|
||||
from sugar.graphics import units
|
||||
from sugar.graphics import style
|
||||
|
||||
from view.home.MeshBox import MeshBox
|
||||
from view.home.HomeBox import HomeBox
|
||||
@@ -113,13 +113,13 @@ class HomeWindow(gtk.Window):
|
||||
self._canvas.set_root(self._transition_box)
|
||||
|
||||
if level == ShellModel.ZOOM_HOME:
|
||||
scale = units.XLARGE_ICON_SCALE
|
||||
size = style.XLARGE_ICON_SIZE
|
||||
elif level == ShellModel.ZOOM_FRIENDS:
|
||||
scale = units.LARGE_ICON_SCALE
|
||||
size = style.LARGE_ICON_SIZE
|
||||
elif level == ShellModel.ZOOM_MESH:
|
||||
scale = units.STANDARD_ICON_SCALE
|
||||
size = style.STANDARD_ICON_SIZE
|
||||
|
||||
self._transition_box.set_scale(scale)
|
||||
self._transition_box.set_size(size)
|
||||
|
||||
def _transition_completed_cb(self, transition_box):
|
||||
if self._level == ShellModel.ZOOM_HOME:
|
||||
|
||||
@@ -25,7 +25,7 @@ from sugar.graphics.canvasicon import CanvasIcon
|
||||
from sugar.graphics import style
|
||||
from sugar.graphics import xocolor
|
||||
from sugar.graphics import canvasicon
|
||||
from sugar.graphics import units
|
||||
from sugar.graphics import style
|
||||
from sugar import profile
|
||||
|
||||
from model import accesspointmodel
|
||||
@@ -120,7 +120,7 @@ _MESH_ICON_NAME = 'theme:device-network-mesh'
|
||||
|
||||
class MeshDeviceView(PulsingIcon):
|
||||
def __init__(self, nm_device):
|
||||
PulsingIcon.__init__(self, scale=units.MEDIUM_ICON_SCALE,
|
||||
PulsingIcon.__init__(self, size=style.MEDIUM_ICON_SIZE,
|
||||
icon_name=_MESH_ICON_NAME)
|
||||
self._nm_device = nm_device
|
||||
self.set_tooltip(_("Mesh Network"))
|
||||
|
||||
@@ -18,7 +18,7 @@ from sugar.graphics.canvasicon import CanvasIcon
|
||||
from sugar import profile
|
||||
|
||||
class MyIcon(CanvasIcon):
|
||||
def __init__(self, scale):
|
||||
CanvasIcon.__init__(self, scale=scale,
|
||||
def __init__(self, size):
|
||||
CanvasIcon.__init__(self, size=size,
|
||||
icon_name='theme:stock-buddy',
|
||||
xo_color=profile.get_color())
|
||||
|
||||
@@ -20,7 +20,7 @@ import gobject
|
||||
import colorsys
|
||||
|
||||
from sugar.graphics.canvasicon import CanvasIcon
|
||||
from sugar.graphics import units
|
||||
from sugar.graphics import style
|
||||
from sugar.graphics import xocolor
|
||||
from sugar import profile
|
||||
|
||||
@@ -56,7 +56,7 @@ class ActivityIcon(CanvasIcon):
|
||||
color = self._icon_colors[self._level]
|
||||
|
||||
CanvasIcon.__init__(self, icon_name=icon_name, xo_color=color,
|
||||
scale=units.MEDIUM_ICON_SCALE, cache=True)
|
||||
size=style.MEDIUM_ICON_SIZE, cache=True)
|
||||
|
||||
self._activity = activity
|
||||
self._pulse_id = 0
|
||||
|
||||
@@ -17,23 +17,23 @@
|
||||
import hippo
|
||||
import gobject
|
||||
|
||||
from sugar.graphics import units
|
||||
from sugar.graphics import style
|
||||
from sugar.graphics import animator
|
||||
from sugar.graphics.spreadlayout import SpreadLayout
|
||||
|
||||
from view.home.MyIcon import MyIcon
|
||||
|
||||
class _Animation(animator.Animation):
|
||||
def __init__(self, icon, start_scale, end_scale):
|
||||
def __init__(self, icon, start_size, end_size):
|
||||
animator.Animation.__init__(self, 0.0, 1.0)
|
||||
|
||||
self._icon = icon
|
||||
self.start_scale = start_scale
|
||||
self.end_scale = end_scale
|
||||
self.start_size = start_size
|
||||
self.end_size = end_size
|
||||
|
||||
def next_frame(self, current):
|
||||
d = (self.end_scale - self.start_scale) * current
|
||||
self._icon.props.scale = self.start_scale + d
|
||||
d = (self.end_size - self.start_size) * current
|
||||
self._icon.props.size = self.start_size + d
|
||||
|
||||
class _Layout(gobject.GObject,hippo.CanvasLayout):
|
||||
__gtype_name__ = 'SugarTransitionBoxLayout'
|
||||
@@ -70,12 +70,12 @@ class TransitionBox(hippo.CanvasBox):
|
||||
def __init__(self):
|
||||
hippo.CanvasBox.__init__(self, background_color=0xe2e2e2ff)
|
||||
|
||||
self._scale = units.XLARGE_ICON_SCALE
|
||||
self._size = style.XLARGE_ICON_SIZE
|
||||
|
||||
self._layout = _Layout()
|
||||
self.set_layout(self._layout)
|
||||
|
||||
self._my_icon = MyIcon(self._scale)
|
||||
self._my_icon = MyIcon(self._size)
|
||||
self.append(self._my_icon)
|
||||
|
||||
self._animator = animator.Animator(0.3)
|
||||
@@ -84,10 +84,10 @@ class TransitionBox(hippo.CanvasBox):
|
||||
def _animation_completed_cb(self, anim):
|
||||
self.emit('completed')
|
||||
|
||||
def set_scale(self, scale):
|
||||
def set_size(self, size):
|
||||
self._animator.remove_all()
|
||||
self._animator.add(_Animation(self._my_icon, self._scale, scale))
|
||||
self._animator.add(_Animation(self._my_icon, self._size, size))
|
||||
self._animator.start()
|
||||
|
||||
self._scale = scale
|
||||
self._size = size
|
||||
|
||||
|
||||
Reference in New Issue
Block a user