def __init__(self):
		super(Graticule, self).__init__()
		self.__constraints = []

		constraint = Clutter.AlignConstraint()
		constraint.set_factor(0.5)
		constraint.set_align_axis(Clutter.AlignAxis.X_AXIS)
		self.__constraints += [constraint]

		constraint = Clutter.AlignConstraint()
		constraint.set_align_axis(Clutter.AlignAxis.Y_AXIS)
		constraint.set_factor(0.5)
		self.__constraints += [constraint]

		constraint = Clutter.BindConstraint()
		constraint.set_coordinate(Clutter.BindCoordinate.SIZE)
		self.__constraints += [constraint]

		for constraint in self.__constraints:
			self.add_constraint(constraint)

		self.connect('paint', self.paint)
Exemple #2
0
def create_scroll_actor(stage):
    scroll = Clutter.ScrollActor(name='scroll')
    scroll.set_position(0, 18)
    scroll.add_constraint(
        Clutter.AlignConstraint(source=stage,
                                align_axis=Clutter.AlignAxis.X_AXIS,
                                factor=0.5))
    scroll.add_constraint(
        Clutter.BindConstraint(source=stage,
                               coordinate=Clutter.BindCoordinate.HEIGHT,
                               offset=-36))
    scroll.set_scroll_mode(Clutter.ScrollMode.VERTICALLY)
    scroll.set_easing_duration(250)
    scroll.add_child(create_menu_actor())

    stage.add_child(scroll)
Exemple #3
0
    return False


if __name__ == '__main__':
    Clutter.init(None)

    stage = Clutter.Stage(title='Actor Model', user_resizable=True)
    stage.connect('destroy', Clutter.main_quit)
    stage.connect('key-press-event', on_key_press_event)
    stage.show()

    scroll = Clutter.ScrollActor(name='scroll')
    scroll.set_position(0, 18)
    scroll.add_constraint(
        Clutter.AlignConstraint(source=stage,
                                align_axis=Clutter.AlignAxis.X_AXIS,
                                factor=0.5))
    scroll.add_constraint(
        Clutter.BindConstraint(source=stage,
                               coordinate=Clutter.BindCoordinate.HEIGHT,
                               offset=-36))
    scroll.set_scroll_mode(Clutter.ScrollMode.VERTICALLY)
    scroll.set_easing_duration(250)
    stage.add_child(scroll)

    menu = Menu()
    scroll.add_child(menu)
    menu.populate()

    Clutter.main()
Exemple #4
0
if __name__ == '__main__':
    Clutter.init(None)

    # The main stage
    stage = Clutter.Stage(title='Constraints', user_resizable=True)
    stage.props.background_color = Clutter.Color.get_static(Clutter.StaticColor.ALUMINIUM_1)
    stage.connect('destroy', Clutter.main_quit)

    # First actor, with a fixed (100, 25) size
    layer_a = Clutter.Actor()
    layer_a.props.background_color = Clutter.Color.get_static(Clutter.StaticColor.SCARLET_RED)
    layer_a.set_size(100, 25)
    stage.add_child(layer_a)

    # The first actor is anchored to the center of the stage
    layer_a.add_constraint(Clutter.AlignConstraint(source=stage, align_axis=Clutter.AlignAxis.BOTH, factor=0.5))

    # Second actor, with no explicit size
    layer_b = Clutter.Actor()
    layer_b.props.background_color = Clutter.Color.get_static(Clutter.StaticColor.BUTTER_DARK)
    stage.add_child(layer_b)

    # The second actor tracks the X coordinate and the width of the first actor
    layer_b.add_constraint(Clutter.BindConstraint(source=layer_a, coordinate=Clutter.BindCoordinate.X))
    layer_b.add_constraint(Clutter.BindConstraint(source=layer_a, coordinate=Clutter.BindCoordinate.WIDTH))

    # The second actor is snapped between the bottom edge of the first actor
    # and the bottom edge of the stage; vertical spacing of 10px is added for
    # padding
    layer_b.add_constraint(Clutter.SnapConstraint(source=layer_a,
                                                  from_edge=Clutter.SnapEdge.TOP,
Exemple #5
0
    stage = Clutter.Stage()
    stage.props.title = 'Multi-layout'
    stage.connect('destroy', Clutter.main_quit)
    stage.show()

    N_RECTS = 16
    RECT_SIZE = 64
    N_ROWS = 4
    PADDING = 12
    BOX_SIZE = (RECT_SIZE * (N_RECTS / N_ROWS) + PADDING * (N_RECTS / N_ROWS - 1))

    layout = MultiLayout()
    layout.spacing = PADDING
    box = Clutter.Actor(layout_manager=layout, width=BOX_SIZE, height=BOX_SIZE)
    box.set_margin(Clutter.Margin(PADDING))
    box.add_constraint(Clutter.AlignConstraint(source=stage, align_axis=Clutter.AlignAxis.BOTH, factor=0.5))
    stage.add_child(box)

    for i in range(N_RECTS):
        color = Clutter.Color.from_hls(360 / N_RECTS * i, 0.5, 0.8)
        color.alpha = 128 + 128 / N_RECTS * i

        rect = Clutter.Actor()
        rect.props.background_color = color
        rect.props.opacity = 0
        rect.props.reactive = True
        rect.set_size(RECT_SIZE, RECT_SIZE)
        rect.set_pivot_point(0.5, 0.5)
        rect.set_easing_duration(250)
        rect.set_easing_mode(Clutter.AnimationMode.EASE_OUT_CUBIC)
        box.add_child(rect)