Example #1
0
 def make_simple_layout(self):
     layout = cellpack.Layout()
     layout.add(0, 0, 200, 200, self.drawer.background)
     layout.add(0, 0, 50, 50, self.drawer.foo)
     layout.add_rect(cellpack.LayoutRect(50, 0, 30, 30),
                     self.drawer.right_of_foo,
                     hotspot='right_of_foo')
     layout.add_rect(cellpack.LayoutRect(0, 50, 30, 30),
                     self.drawer.under_foo,
                     hotspot='under_foo')
     return layout
Example #2
0
    def layout_progress(self, layout_manager, width, height):
        """Handle layout when we should display a progress bar """

        layout = cellpack.Layout()
        # add left button
        if not self.info.is_paused:
            left_button = 'pause'
        else:
            left_button = 'resume'
        left_button_rect = layout.add_image(self.button[left_button],
                                            0,
                                            0,
                                            hotspot=left_button)
        # add right button
        right_x = width - self.button['cancel'].width
        layout.add_image(self.button['cancel'], right_x, 0, hotspot='cancel')
        # pack the progress bar in the center
        progress_left = left_button_rect.width + 2
        progress_right = right_x - 2
        progress_rect = cellpack.LayoutRect(progress_left, 0,
                                            progress_right - progress_left,
                                            height)

        layout.add_rect(progress_rect, ItemProgressBarDrawer(self.info).draw)
        # middle-align everything
        layout.center_y(top=0, bottom=height)
        return layout
Example #3
0
 def test_simple(self):
     # check if layout.draw() calls the correct methods
     layout = self.make_simple_layout()
     layout.draw(self.context)
     self.assertSameList(self.drawer.method_calls, [
         ('background', (self.context, 0, 0, 200, 200)),
         ('foo', (self.context, 0, 0, 50, 50)),
         ('right_of_foo', (self.context, 50, 0, 30, 30)),
         ('under_foo', (self.context, 0, 50, 30, 30)),
     ])
     self.assertEquals(layout.last_rect, cellpack.LayoutRect(0, 50, 30, 30))