Changes

Jump to navigation Jump to search
1,715 bytes added ,  06:35, 31 July 2010
Line 81: Line 81:  
A new, tighter spiral for the Home View:
 
A new, tighter spiral for the Home View:
   −
[[File:SpiralHomeView.png|300px]]
+
[[File:Spiral-home-view.png|300px]]
 +
 
 +
<code>
 +
class MyLayout(RingLayout):
 +
    """Spiral layout based on Archimedean spiral: r = a + b*theta."""
 +
 
 +
    __gtype_name__ = 'MyLayout'
 +
 
 +
    icon_name = 'view-mylayout'
 +
    """Name of icon used in home view dropdown palette."""
 +
 
 +
    profile_key = 'my-layout'
 +
    """String used in profile to represent this view."""
 +
 
 +
    def __init__(self):
 +
        RingLayout.__init__(self)
 +
        self.my_radius = _MINIMUM_RADIUS
 +
        self.my_orientation = math.pi
 +
 
 +
    def _calculate_radius_and_icon_size(self, children_count):
 +
        """Stub out this method; not used in `My Layout`."""
 +
        return _MINIMUM_RADIUS, style.STANDARD_ICON_SIZE
 +
 
 +
    def _calculate_position(self, radius, icon_size, index, children_count):
 +
        """ Increment the radius as you go """
 +
 
 +
        if index == 0:
 +
            self.my_radius = _MINIMUM_RADIUS
 +
            self.my_orientation = math.pi
 +
 
 +
        x, y = self._calculate_xy()
 +
 
 +
        # add some buffering around the icon
 +
        self._calculate_new_radius_orientation(icon_size + 10)
 +
 
 +
        width, height = self.box.get_allocation()
 +
        return int(x) + (width - icon_size) / 2, \
 +
            int(y) + (height - icon_size - (style.GRID_CELL_SIZE / 2) ) / 2
 +
 
 +
    def _calculate_xy(self):
 +
        """ Convert r, o to x, y """
 +
        return -math.sin(self.my_orientation) * self.my_radius, \
 +
            math.cos(self.my_orientation) * self.my_radius
 +
 
 +
    def _calculate_new_radius_orientation(self, icon_size):
 +
        """ Based upon current radius, calculate new increments """
 +
        circumference = self.my_radius * 2 * math.pi
 +
        n = circumference / icon_size
 +
        self.my_orientation += 2 * math.pi / n
 +
        self.my_radius += float(icon_size) / n
 +
</code>
    
====Keyboards====
 
====Keyboards====

Navigation menu