コード例 #1
0
ファイル: elements.py プロジェクト: MathieuDuponchelle/Pitivi
    def __init__(self, timelineElement, keyframe, lastKeyframe):
        Clutter.Actor.__init__(self)
        self.timelineElement = weakref.proxy(timelineElement)

        self.canvas = Clutter.Canvas()
        self.canvas.set_size(1000, KEYFRAME_SIZE)
        self.canvas.connect("draw", self._drawCb)
        self.set_content(self.canvas)
        self.set_reactive(True)

        self.gotDragged = False

        self.dragAction = Clutter.DragAction()
        self.add_action(self.dragAction)

        self.dragAction.connect("drag-begin", self._dragBeginCb)
        self.dragAction.connect("drag-end", self._dragEndCb)
        self.dragAction.connect("drag-progress", self._dragProgressCb)

        self.connect("button-release-event", self._clickedCb)
        self.connect("motion-event", self._motionEventCb)
        self.connect("enter-event", self._enterEventCb)
        self.connect("leave-event", self._leaveEventCb)

        self.previousKeyframe = lastKeyframe
        self.nextKeyframe = keyframe
コード例 #2
0
 def __init__(self, app, rows, cols, spacing=15):
     Clutter.Actor.__init__(self)
     self.settings = Gio.Settings.new(base.SCHEMA_ID)
     self.settings.connect("changed::cards", self.update_cards)
     self.settings.connect("changed::show-value-on-cards",
                           self.update_cards)
     self.app = app
     self.canvas = Clutter.Canvas()
     self.canvas.connect("draw", self.draw_rect)
     self.set_content(self.canvas)
     self.set_x_expand(False)
     self.set_y_expand(False)
     self.column_width, self.row_height = base.get_card_size()
     self.canvas.set_size(cols * self.column_width + (cols + 1) * spacing,
                          rows * self.row_height + (rows + 1) * spacing)
     self.max_height = 0
     self.max_width = 0
     self.rows = rows
     self.cols = cols
     self.face_up = True
     self.spacing = spacing
     self.children = []
     n = 0
     while n < rows:
         self.children.append([])
         i = 0
         while i < cols:
             self.children[n].append(0)
             i = i + 1
         n = n + 1
コード例 #3
0
 def __init__(self):
     self.canvas = Clutter.Canvas()
     self.set_content(self.canvas)
     self.localizer = None
     self.navigator = None
     self.yardstick = None
     self.bender = None
     self.line_width = 10
     self.width = 0 # widgth of the drawing area
     self.height = 0 # height of the drawing area
     self.rgba = (100, 100, 0, 255)  # current drawing color
     self.from_x = 0  # x coordinate of current spot
     self.from_y = 0  # x coordinate of current spot
     self.to_x = 0 # x coordinate of current destination spot
     self.to_y = 0 # y coordinate of current destination spot
     self.through_x = 0  # x coordinate of current through spot
     self.through_y = 0  # y coordinate of current through spot
     self.background_color = (0.843, 0.784, 0.843, 1)  # color of the background
                                                   # canvas
     self.path_history = []  # history of drawing
     self.line_cap = cairo.LINE_CAP_ROUND  # cap of the draw lines
     self.set_background_color(Clutter.Color.new(255*self.background_color[0],
                                                  255*self.background_color[1],
                                                  255*self.background_color[2],
                                                  255*self.background_color[3]))
     self.angle = 0  # angle of the draw line direction
     self.connect("notify::mapped", self.run)
     self.set_reactive(True)
     self.stage_handler_id = 0  # id of the current stage handler
     self.stage = None
コード例 #4
0
 def __init__(self):
     super().__init__()
     self.set_clip_to_allocation(True)
     self.canvas = Clutter.Canvas()
     self.set_content(self.canvas)
     self.line_rgba = ()
     self.click_handlers = []
コード例 #5
0
ファイル: previewers.py プロジェクト: tomak-git/pitivi
    def __init__(self, bElement, timeline):
        Clutter.Actor.__init__(self)
        PreviewGenerator.__init__(self, GES.TrackType.AUDIO)
        Zoomable.__init__(self)
        Loggable.__init__(self)

        self.pipeline = None
        self.discovered = False
        self.bElement = bElement
        self._uri = quote_uri(bElement.props.uri)  # Guard against malformed URIs
        self.timeline = timeline
        self.actors = []

        self.set_content_scaling_filters(Clutter.ScalingFilter.NEAREST, Clutter.ScalingFilter.NEAREST)
        self.canvas = Clutter.Canvas()
        self.set_content(self.canvas)
        self.width = 0
        self._num_failures = 0
        self.lastUpdate = None

        self.current_geometry = (-1, -1)

        self.adapter = None
        self.surface = None
        self.timeline.connect("scrolled", self._scrolledCb)
        self.canvas.connect("draw", self._drawContentCb)
        self.canvas.invalidate()

        self._callback_id = 0
コード例 #6
0
 def __init__(self):
     super().__init__()
     self._canvas = Clutter.Canvas()
     self._canvas.set_size(640, 480)
     self.set_content(self._canvas)
     self._canvas.connect("draw", self._draw_canvas)
     self._canvas.invalidate()
コード例 #7
0
 def __init__(self, app, with_scopa=False, padding=15):
     Clutter.Actor.__init__(self)
     self.settings = Gio.Settings.new(base.SCHEMA_ID)
     self.settings.connect("changed::cards", self.update_cards)
     self.app = app
     self.canvas = Clutter.Canvas()
     self.canvas.connect("draw", self._draw)
     self.set_content(self.canvas)
     self.child_w, self.child_h = base.get_card_size()
     self.set_x_expand(False)
     self.set_y_expand(False)
     self.padding = padding
     self.surface = cairo.ImageSurface.create_from_png(
         base.percorso_carte + self.settings.get_string('cards') + '/' +
         base.immagini[1][0])
     self.cards = []
     self.with_scopa = with_scopa
     self.scopa_card = None
     self.scope = 0
     if with_scopa:
         self.canvas.set_size(2 * (padding + self.child_w),
                              2 * padding + self.child_h + 20)
     else:
         self.canvas.set_size(2 * padding + self.child_w + 20,
                              2 * padding + self.child_h + 20)
コード例 #8
0
 def __init__(self):
     self.canvas = Clutter.Canvas()
     self.set_content(self.canvas)
     self.canvas_handler_id = self.canvas.connect("draw", self._draw)
     self.localizer = None
     self.navigator = None
     self.yardstick = None
     self.bender = None
     self.tools = []
     self.stage = None
     self.working_tool = None  # currently working tool
     self.stage_handler_id = None  # id of the current stage handler
     self.line_width = 10  # width of the drawing line
     self.line_rgba = (0, 0, 0, 1)  # current drawing color
     self.from_x = 0  # x coordinate of current spot
     self.from_y = 0  # x coordinate of current spot
     self.to_x = 0  # x coordinate of current destination spot
     self.to_y = 0  # y coordinate of current destination spot
     self.through_x = 0  # x coordinate of current through spot
     self.through_y = 0  # y coordinate of current through spot
     self.path_history = []  # history of drawing
     self.line_cap = cairo.LINE_CAP_ROUND  # cap of the draw lines
     self.angle = 0  # angle of the draw line direction
     self.connect("notify::mapped", self._on_mapped)
     self.connect("notify::size", self._on_size_changed)
コード例 #9
0
    def __init__(self):
        GtkClutter.Embed.__init__(self)

        self.connect('realize', self.on_realize)
        self.connect('size-allocate', self.on_size_allocate)
        self.connect('style-updated', self.on_style_changed)

        self._canvas = Clutter.Canvas(width=200, height=200)
        self._canvas.connect('draw', self.on_canvas_draw)
コード例 #10
0
ファイル: pisak_text.py プロジェクト: karolaug/pisak
    def __init__(self):
        super().__init__()

        self.set_size(10, 10)
        self.canvas = Clutter.Canvas()
        self.canvas.set_size(10, 10)
        self.canvas.connect('draw', self.draw)
        self.canvas.invalidate()
        self.set_content(self.canvas)
コード例 #11
0
 def __init__(self):
     super().__init__()
     background_image = Clutter.Canvas()
     background_image.set_size(unit.mm(2), unit.mm(2))
     background_image.connect("draw", self.fence_pattern)
     background_image.invalidate()
     self.set_content(background_image)
     self.set_content_repeat(Clutter.ContentRepeat.BOTH)
     self.set_content_scaling_filters(Clutter.ScalingFilter.TRILINEAR,
                                      Clutter.ScalingFilter.TRILINEAR)
コード例 #12
0
 def __init__(self, size):
     super().__init__()
     self.width = size[0]
     self.height = size[1]
     self.set_size(self.width, self.height)
     self.canvas = Clutter.Canvas()
     self.canvas.set_size(self.width, self.height)
     self.canvas.connect('draw', self._draw)
     self.canvas.invalidate()
     self.set_content(self.canvas)
コード例 #13
0
 def __init__(self, suit, value):
     Clutter.Actor.__init__(self)
     self.settings = Gio.Settings.new(base.SCHEMA_ID)
     self.suit = suit
     self.value = value
     self.mouse_over = False
     self.face_up = False
     self.canvas = Clutter.Canvas()
     self.canvas.connect("draw", self._draw)
     self.set_content(self.canvas)
     self.w = 0
     self.h = 0
コード例 #14
0
    def __init__(self):
        super(CairoActor, self).__init__()
        self.set_background_color(color('orange'))
        self.canvas = Clutter.Canvas()
        self.set_content(self.canvas)
        self.canvas.connect('draw', self.draw)

        svg = Rsvg.Handle.new_from_file('awesome_tiger.svg')
        self.tiger = cairo.ImageSurface(cairo.FORMAT_ARGB32, 1000, 1000)
        svg.render_cairo(cairo.Context(self.tiger))

        self.connect('notify::allocation', self.on_allocation)
コード例 #15
0
 def create(self):
     """
     Create the clutter object
     """
     if not self.width or not self.height:
         self.width = self.height = 1
     self.obj = clutter.Actor()
     self.content = clutter.Canvas()
     self.content.set_size(self.width, self.height)
     self.obj.set_content(self.content);
     self.content.connect('draw', self._draw_canvas)
     self.obj.show()
コード例 #16
0
 def __init__(self):
     super().__init__()
     self.canvas = Clutter.Canvas()
     self.set_content(self.canvas)
     self.rgba = (0, 0, 0, 255)  # current yardstick color
     self.step_duration = 100  # pace of yardstick in mscs
     self.step = 10 # yardstick fluency in pixels
     self.from_x = 0  # x coordinate of yardstick base spot
     self.from_y = 0  # x coordinate of yardstick base spot
     self.to_x = 0 # x coordinate of current yardstick destination spot
     self.to_y = 0 # y coordinate of current yardstick destination spot
     self.angle = 0  # angle of drawing direction in radians
     self.click_handlers = [self._on_user_decision]
コード例 #17
0
ファイル: widgets.py プロジェクト: jgrynczewski/pisak
    def __init__(self):
        super().__init__()
        self._step_duration = 100
        self._step = 0.01
        self._max_cycles = 2
        self._line_width = 5
        self._line_color = Clutter.Color.new(0, 0, 0, 255)

        self.set_clip_to_allocation(True)
        self.canvas = Clutter.Canvas()
        self.set_content(self.canvas)
        self.line_rgba = ()
        self.click_handlers = []
コード例 #18
0
ファイル: elements.py プロジェクト: MathieuDuponchelle/Pitivi
 def __init__(self, rb, gb, bb, re, ge, be):
     """
     Creates a rectangle with a gradient. The first three parameters
     are the gradient's RGB values at the top, the last three params
     are the RGB values at the bottom.
     """
     Clutter.Actor.__init__(self)
     self.canvas = Clutter.Canvas()
     self.linear = cairo.LinearGradient(0, 0, 10, EXPANDED_SIZE)
     self.linear.add_color_stop_rgb(0, rb / 255., gb / 255., bb / 255.)
     self.linear.add_color_stop_rgb(1, re / 255., ge / 255., be / 255.)
     self.canvas.set_size(10, EXPANDED_SIZE)
     self.canvas.connect("draw", self._drawCb)
     self.set_content(self.canvas)
     self.canvas.invalidate()
コード例 #19
0
ファイル: Graph.py プロジェクト: intelligent-agent/toggle
 def __init__(self, width, height):
     super(Graph, self).__init__()
     self.set_size(width, height)
     self.set_margin_top(0)
     self.set_margin_right(0)
     self.set_margin_bottom(0)
     self.set_margin_left(0)
     self.canvas = Clutter.Canvas()
     self.set_content(self.canvas)
     self.canvas.connect('draw', self.draw)
     self.line_width = 3
     self.refresh_millis = 100
     self.plots = []
     self.idle_resize_id = 0
     self.connect('notify::allocation', self.on_allocation)
     self.set_reactive(True)
コード例 #20
0
 def __init__(self):
     super().__init__()
     self.canvas = Clutter.Canvas()
     self.set_content(self.canvas)
     self.rotations_count = 1 # limit of navigator idle rotations
     self.angle = 0  # angle of navigator line current position in radians
     self.step_duration = 1  # pace of navigator in mscs
     self.step = 0.005  # navigator rotation fluency in radians
     self.from_x = 0  # x coordinate of navigator base point
     self.from_y = 0  # y coordinate of navigator base point
     self.to_x = 0 # x coordinate of current navigator end spot
     self.to_y = 0 # y coordinate of current navigator end spot
     self.rgba = (0, 0, 0, 255)  # current navigator color
     self.line_width = 5  # current navigator line width
     self.line_length = 0  # length of the navigator line
     self.click_handlers = [self._on_user_decision]  # handlers of user click
コード例 #21
0
    def __init__(self):
        super(GraphActor, self).__init__()
        self.set_background_color(color('white'))
        self.set_margin_top(50)
        self.set_margin_right(50)
        self.set_margin_bottom(50)
        self.set_margin_left(50)
        self.canvas = Clutter.Canvas()
        self.set_content(self.canvas)
        self.canvas.connect('draw', self.draw)
        self.line_width = 3
        self.refresh_millis = 10

        self.temps = []

        self.idle_resize_id = 0
        self.connect('notify::allocation', self.on_allocation)
コード例 #22
0
    def _init_bg_content(self):
        def draw_canvas(canvas, context, w, h):
            context.scale(w, h)
            context.set_line_width(0.2)
            context.set_source_rgba(1, 1, 1, 0.25)
            context.arc(0.5, 0.5, 0.45, 0, 6.3)
            context.stroke()
            return True

        background_image = Clutter.Canvas()
        background_image.set_size(unit.mm(4), unit.mm(4))
        background_image.connect("draw", draw_canvas)
        background_image.invalidate()
        self.bg.set_content(background_image)
        self.bg.set_content_repeat(Clutter.ContentRepeat.BOTH)
        self.bg.set_content_scaling_filters(Clutter.ScalingFilter.LINEAR,
                                            Clutter.ScalingFilter.LINEAR)
コード例 #23
0
    def __init__(self):
        super(CairoActor, self).__init__()
        self.set_background_color(color('white'))
        self.set_margin_top(50)
        self.set_margin_right(50)
        self.set_margin_bottom(50)
        self.set_margin_left(50)
        self.canvas = Clutter.Canvas()
        self.set_content(self.canvas)
        self.canvas.connect('draw', self.draw)
        self.line_width = 5
        self.border_radius = 50
        self.refresh_millis = 10
        self.fill_color = 0.39, 0.58, 0.93  # crimson
        self.stroke_color = 0.8, 0.27, 0  # orange red

        self.idle_resize_id = 0
        self.connect('notify::allocation', self.on_allocation)
コード例 #24
0
 def __init__(self):
     super().__init__()
     self.canvas = Clutter.Canvas()
     self.set_content(self.canvas)
     self.vertical_count = -1  # limit of vertical localizer cycles
     self.horizontal_count = -1  # limit of horizontal localizer cycles
     self.rgba = (0, 0, 0, 255)  # current localizer color
     self.line_width = 5  # localizer line width
     self.step_duration = 10  # pace of localizer in mscs
     self.step = 1  # localizer fluency in pixels
     self.localized_x = None  # x coordinate of user declared point
     self.localized_y = None  # y coordinate of user declared point
     self.x = 0  # x coordinate of localizer vertical line
     self.y = 0  # y coordinate of localizer horizontal line
     self.from_x = 0  # x coordinate of current line base point
     self.from_y = 0  # x coordinate of current line base point
     self.to_x = 0  # x coordinate of current line end spot
     self.to_y = 0  # y coordinate of current line end spot
     self.click_handlers = []  # handlers of user click
コード例 #25
0
    def __init__(self, widget):
        Clutter.Actor.__init__(self)

        self.props.reactive = True

        self._widget = widget
        self._context = widget.get_style_context()

        self._canvas = Clutter.Canvas(width=100, height=100)
        self._canvas.connect('draw', self._on_canvas_draw)
        self.props.content = self._canvas
        self.set_content_scaling_filters(Clutter.ScalingFilter.TRILINEAR,
                                         Clutter.ScalingFilter.LINEAR)

        action = Clutter.ClickAction()
        action.connect('clicked', self._on_clicked)
        self.add_action(action)

        self._crossing = False
コード例 #26
0
 def __init__(self):
     super().__init__()
     self.canvas = Clutter.Canvas()
     self.set_content(self.canvas)
     self.angle = 0  # angle of bending line direction
     self.bender_cycles_count = 1  # bender cycles repeat count
     self.step_duration = 10  # pace of nbender in mscs
     self.step = 10 # bender fluency in pixels
     self.line_width = 10  # line width of the bender
     self.width = 0 # width of the drawing area
     self.height = 0 # height of the drawing area
     self.rgba = (100, 100, 0, 255)  # current drawing color
     self.from_x = 0  # x coordinate of bender base spot
     self.from_y = 0  # x coordinate of bender base spot
     self.to_x = 0 # x coordinate of bender reach spot
     self.to_y = 0 # y coordinate of bender reach spot
     self.through_x = 0  # x coordinate of bender current through spot
     self.through_y = 0  # y coordinate of bender current through spot
     self.fraction = 0.1 # part of the limit length increased in one step
     self.repeat_index = 0  # counter of cycles repeats
     self.click_handlers = [self._on_user_decision]
コード例 #27
0
 def _init_content(self):
     self.canvas = Clutter.Canvas()
     self.canvas.set_size(140, 140)
     self.canvas.connect("draw", self._draw)
     self.set_content(self.canvas)
コード例 #28
0
if __name__ == '__main__':
    Clutter.init(None)

    # Create our stage
    stage = Clutter.Stage()
    stage.props.title = 'Rounded Rectangle'
    stage.props.background_color = Clutter.Color.get_static(
        Clutter.StaticColor.BLACK)
    stage.props.use_alpha = True
    stage.props.opacity = 64
    stage.set_size(500, 500)
    stage.connect('destroy', Clutter.main_quit)
    stage.show()

    # The canvas used for drawing the rounded rectanglr
    canvas = Clutter.Canvas(width=300, height=300)

    # The actor displaying the canvas content; the actor has the same
    # preferred size as the content, but if it gets allocated more
    # space, the content will be centered inside that allocation
    actor = Clutter.Actor(content=canvas,
                          content_gravity=Clutter.ContentGravity.CENTER,
                          request_mode=Clutter.RequestMode.CONTENT_SIZE)
    actor.set_content_scaling_filters(Clutter.ScalingFilter.TRILINEAR,
                                      Clutter.ScalingFilter.LINEAR)
    actor.set_pivot_point(0.5, 0.5)
    actor.add_constraint(
        Clutter.AlignConstraint(source=stage,
                                align_axis=Clutter.AlignAxis.BOTH,
                                factor=0.5))
    stage.add_child(actor)