예제 #1
0
    def create_display(self, width, height):
        self.rect = clutter.Rectangle()
        self.label = clutter.Text()

        # group
        clutter.Group.set_size(self, width, height)

        # rectangle box
        self.rect.set_border_width(2)
        self.rect.set_border_color(self.get_color('stroke-color'))
        self.rect.set_position(0, 0)
        self.rect.set_size(width, height)
        self.rect.set_depth(-1)
        self.rect.set_reactive(False)

        # label
        self.label.set_position(self.label_off_x, self.label_off_y)
        self.label.set_color(self.get_color('text-color'))
        self.label.set_font_name(self.get_fontspec())
        self.label.connect('text-changed', self.label_changed_cb)
        self.label.set_reactive(False)

        # chart created later
        self.xyplot = None

        self.add_actor(self.label)
        self.add_actor(self.rect)
        self.set_reactive(True)
예제 #2
0
파일: patch_window.py 프로젝트: wrl/mfp
    def hud_banner(self, msg, disp_time=3.0):
        def anim_complete(anim, actor):
            actor.destroy()

        if self.hud_banner_anim is not None: 
            self.hud_banner_anim.completed()

        self.hud_banner_text = Clutter.Group()
        txt = Clutter.Text()
        bg = Clutter.Rectangle()
        self.hud_banner_text.add_actor(bg)
        self.hud_banner_text.add_actor(txt)

        bg.set_color(ColorDB().find(255, 255, 255, 200))

        self.stage.add_actor(self.hud_banner_text)
        self.hud_banner_text.set_position(12, 4)
        self.hud_banner_text.set_property("opacity", 255)
        txt.set_markup(msg)
        bg.set_size(self.hud_banner_text.get_width(), self.hud_banner_text.get_height())

        anim = self.hud_banner_text.animatev(Clutter.AnimationMode.EASE_IN_CUBIC,
                                             disp_time * 1000.0, ['opacity'], [0])
        anim.connect_after("completed", anim_complete, self.hud_banner_text)
        self.hud_banner_anim = anim
예제 #3
0
        def confport(pid, px, py):
            pobj = self.port_elements.get(pid)
            dsp_port = False
            if (pid[0] == self.PORT_IN) and pid[1] in self.dsp_inlets:
                dsp_port = True

            if (pid[0] == self.PORT_OUT) and pid[1] in self.dsp_outlets:
                dsp_port = True

            if pobj is None:
                pobj = Clutter.Rectangle()
                pobj.set_size(self.get_style('porthole_width'),
                              self.get_style('porthole_height'))
                self.add_actor(pobj)
                self.port_elements[pid] = pobj

            if dsp_port:
                pobj.set_border_width(1.5)
                pobj.set_color(self.stage.color_bg)
                pobj.set_border_color(self.get_color('stroke-color'))
            else:
                pobj.set_color(self.get_color('stroke-color'))

            pobj.set_position(px, py)
            pobj.set_z_position(0.2)
            pobj.show()
            ports_done.append(pobj)
예제 #4
0
def panel(stage, x, y, width, headText):
    r = Clutter.Rectangle()
    r.set_color(Clutter.Color.new(0, 255, 255, 180))
    r.set_size(width, 200)
    r.set_position(x, y)
    #r.set_reactive(True)
    stage.add_actor(r)
    return r
    def __init__(self, r, g, b, a):
        Clutter.Group.__init__(self)

        self.rectangle = Clutter.Rectangle(color=Clutter.Color(r, g, b, a))
        self.hand      = Clutter.Texture(filename="../data/redhand.png")

        for actor in self.rectangle, self.hand:
            actor.set_size(ACTOR_WIDTH, ACTOR_HEIGHT)

        self.add(self.rectangle, self.hand)
예제 #6
0
 def rectangle(self, x, y):
     r = Clutter.Rectangle()
     r.set_color(Clutter.Color.new(0, 0, 255, 255))
     r.set_size(200, 40)
     r.set_position(x, y)
     r.set_reactive(True)
     t = Clutter.Text()
     t.set_text('wow')
     t.set_position(x, y)
     return t
예제 #7
0
파일: xyplot.py 프로젝트: wrl/mfp
    def create(self):
        self.border = Clutter.Rectangle()
        self.border.set_border_width(0)
        self.border.set_border_color(self.color_fg)
        self.border.set_color(self.color_bg)
        self.border.set_size(self.width, self.height)
        self.border.set_position(0, 0)
        self.add_actor(self.border)

        self.plot_w = self.width - self.MARGIN_LEFT
        self.plot_h = self.height - self.MARGIN_BOT
        self._recalc_x_scale()
        self._recalc_y_scale()

        self.x_axis = Quilt(self.plot_w, self.MARGIN_BOT)
        self.x_axis.set_position(self.MARGIN_LEFT,
                                 self.height - self.MARGIN_BOT)
        self.x_axis.set_viewport_origin(0, 0)
        self.add_actor(self.x_axis)

        self.y_axis = Quilt(self.MARGIN_LEFT, self.plot_h)
        self.y_axis.set_position(0, 0)
        self.y_axis.set_viewport_origin(0, -self.plot_h / 2.0)
        self.add_actor(self.y_axis)

        self.x_axis.set_render_cb(self.draw_xaxis_cb)
        self.y_axis.set_render_cb(self.draw_yaxis_cb)

        self.plot_border = Clutter.Rectangle()
        self.plot_border.set_border_width(0)
        self.plot_border.set_border_color(self.color_fg)
        self.plot_border.set_color(self.color_bg)
        self.plot_border.set_size(self.plot_w, self.plot_h)
        self.plot_border.set_position(self.MARGIN_LEFT, 0)
        self.add_actor(self.plot_border)

        self.create_plot()
        self.plot.set_position(self.MARGIN_LEFT, 0)
        self.add_actor(self.plot)
예제 #8
0
def label(stage, x, y, width, text):
    r = Clutter.Rectangle()
    r.set_color(Clutter.Color.new(0, 255, 255, 255))
    r.set_size(width, 32)
    r.set_position(x, y)
    r.set_reactive(True)
    stage.add_actor(r)
    t = Clutter.Text()
    t.set_text(text)
    #t.set_markup('<span foreground="blue" background="red">' + text + '</span>')
    t.set_max_length(width - 8)
    t.set_position(x + 8, y + 6)
    #t.set_ellipsize = Pango.PangoEllipsizeMode.PANGO_ELLIPSIZE_END
    t.set_ellipsize(Pango.EllipsizeMode.END)
    t.set_reactive(True)
    stage.add_actor(t)
예제 #9
0
def show_selection_box(self, x0, y0, x1, y1): 
    def boxes_overlap(b1, b2): 
        if ((b1[0] >= b2[0]) and (b1[0] <= b2[2])
            or (b2[0] >= b1[0]) and (b2[0] <= b1[2])
            or (b1[2] >= b2[0]) and (b1[2] <= b2[2])
            or (b2[2] >= b1[0]) and (b2[2] <= b1[2])):
            pass
        else:
            return False 
        if ((b1[1] >= b2[1]) and (b1[1] <= b2[3])
            or (b2[1] >= b1[1]) and (b2[1] <= b1[3])
            or (b1[3] >= b2[1]) and (b1[3] <= b2[3])
            or (b2[3] >= b1[1]) and (b2[3] <= b1[3])):
            return True 
        else:
            return False 

    if x0 > x1:
        t = x1; x1 = x0; x0 = t

    if y0 > y1:
        t = y1; y1 = y0; y0 = t

    from gi.repository import Clutter 
    if self.selection_box is None:
        self.selection_box = Clutter.Rectangle()
        self.selection_box.set_border_width(1.0)
        self.selection_box.set_color(self.color_transparent)
        self.selection_box.set_border_color(self.color_unselected)
        self.selection_box_layer = self.selected_layer
        self.selection_box_layer.group.add_actor(self.selection_box)
    elif self.selection_box_layer != self.selected_layer:
        self.selection_box_layer.group.remove_actor(self.selection_box)
        self.selection_box_layer = self.selected_layer
        self.selection_box_layer.group.add_actor(self.selection_box)
    self.selection_box.set_position(x0, y0)
    self.selection_box.set_size(max(1, x1-x0), max(1, y1-y0))
    self.selection_box.show()

    enclosed = [] 
    for obj in self.selected_layer.objects: 
        if boxes_overlap((x0, y0, x1, y1),
                         (obj.position_x, obj.position_y, 
                          obj.position_x + obj.width, obj.position_y + obj.height)):
            enclosed.append(obj)
    return enclosed 
예제 #10
0
def label2(stage, x, y, width, text):
    bl = Clutter.BinLayout.new(Clutter.BinAlignment.CENTER,
                               Clutter.BinAlignment.CENTER)
    # Aint happening?
    #b.set_position(x, y)
    #stage.add_actor(b)

    #container = Clutter.Actor.new()
    #container.set_layout_manager(bl)
    r = Clutter.Rectangle()
    r.set_layout_manager(bl)
    r.set_color(Clutter.Color.new(180, 100, 0, 255))
    r.set_size(width, 32)
    r.set_reactive(True)
    #stage.add_child(r)

    #bl.add_child(r)
    #label(p, x, y, width, headText)
    #inStage = r.get_stage()
    t = Clutter.Text()
    t.set_text(text)
    t.set_x_expand(True)
    t.set_x_align(Clutter.ActorAlign.CENTER)
    t.set_y_expand(True)
    t.set_y_align(Clutter.ActorAlign.CENTER)
    t.set_background_color(Clutter.Color.new(255, 255, 200, 255))
    t.set_position(0, 0)
    #t.set_markup('<span foreground="blue" background="red">' + text + '</span>')
    #t.set_max_length(width - 8)
    #t.set_ellipsize = Pango.PangoEllipsizeMode.PANGO_ELLIPSIZE_END
    #t.set_ellipsize = Pango.PangoEllipsizeMode.PANGO_ELLIPSIZE_END
    #s = r.get_stage()
    #r.add_child(t)
    #r.insert_child_above(t)
    #r.add_child(t)
    #t.margin_top = 5
    #t.margin_left = 15
    stage.add_child(t)
예제 #11
0
def show_selection_box(self, x0, y0, x1, y1):
    if x0 > x1:
        t = x1
        x1 = x0
        x0 = t

    if y0 > y1:
        t = y1
        y1 = y0
        y0 = t

    from gi.repository import Clutter
    if self.selection_box is None:
        self.selection_box = Clutter.Rectangle()
        self.selection_box.set_border_width(1.0)
        self.selection_box.set_color(self.color_transparent)
        self.selection_box.set_border_color(self.color_unselected)
        self.selection_box_layer = self.selected_layer
        self.selection_box_layer.group.add_actor(self.selection_box)
    elif self.selection_box_layer != self.selected_layer:
        self.selection_box_layer.group.remove_actor(self.selection_box)
        self.selection_box_layer = self.selected_layer
        self.selection_box_layer.group.add_actor(self.selection_box)
    self.selection_box.set_position(x0, y0)
    self.selection_box.set_size(max(1, x1 - x0), max(1, y1 - y0))
    self.selection_box.show()

    enclosed = []
    selection_corners = [(x0, y0), (x1, y0), (x0, y1), (x1, y1)]
    for obj in self.selected_layer.objects:
        if obj.parent_id and MFPGUI().recall(obj.parent_id).parent_id:
            continue
        corners = obj.corners()

        if corners and collision_check(selection_corners, corners):
            enclosed.append(obj)

    return enclosed
예제 #12
0
def pointer_motion_cb(self, event):
    stage_x, stage_y = event.get_coords()
    actor_x, actor_y = self.transform_stage_point(stage_x, stage_y)

    print("pointer on actor %s @ x %s, y %s" %
          (self.get_name(), actor_x, actor_y))

    return True


stage = Clutter.Stage()
stage.set_size(300, 300)
stage.set_color(Clutter.Color.from_string("#333355"))
stage.connect("destroy", Clutter.main_quit)

r1 = Clutter.Rectangle()
r1.set_color(Clutter.Color.from_string("red"))
r1.set_size(150, 150)
r1.add_constraint(
    Clutter.AlignConstraint.new(stage, Clutter.AlignAxis.X_AXIS, 0.25))
r1.add_constraint(
    Clutter.AlignConstraint.new(stage, Clutter.AlignAxis.Y_AXIS, 0.25))
r1.set_reactive(True)
r1.set_name("red")

r2 = Clutter.Rectangle()
r2.set_color(Clutter.Color.from_string("green"))
r2.set_size(150, 150)
r2.add_constraint(
    Clutter.AlignConstraint.new(stage, Clutter.AlignAxis.X_AXIS, 0.5))
r2.add_constraint(
        print("enter; x %s, y %s" % (x, y))

        self._path.add_move_to(x, y)

        self.queue_redraw()

        return True


if __name__ == "__main__":
    stage = Clutter.Stage()
    stage.set_color(Clutter.Color.from_string("#333355"))
    stage.set_size(400, 400)
    stage.connect("destroy", Clutter.main_quit)

    rect = Clutter.Rectangle()
    rect.set_color(Clutter.Color.from_string("#aa9900"))
    rect.set_size(300, 300)
    rect.add_constraint(
        Clutter.AlignConstraint.new(stage, Clutter.AlignAxis.X_AXIS, 0.5))
    rect.add_constraint(
        Clutter.AlignConstraint.new(stage, Clutter.AlignAxis.Y_AXIS, 0.5))

    stage.add_actor(rect)

    canvas = Canvas()
    canvas.set_size(300, 300)
    canvas.add_constraint(
        Clutter.AlignConstraint.new(rect, Clutter.AlignAxis.X_AXIS, 0))
    canvas.add_constraint(
        Clutter.AlignConstraint.new(rect, Clutter.AlignAxis.Y_AXIS, 0))
예제 #14
0
파일: user.py 프로젝트: rmatam/vivo
    def __init__(self, w=10, h=10):
        super().__init__(Clutter.Rectangle())

        self.width, self.height = w, h
예제 #15
0
    def __init__(self, options):
        """
        Build the user interface.
        """
        self.itime = time()
        self.shader = None
        self.destroyed = False
        self.font = "%s %s" % (options.font_name, options.font_size)
        self.size = None, None
        self.mainStage = Clutter.Stage.get_default()
        self.mainStage.set_title("Clutterm")
        self.mainStage.set_reactive(True)
        self.mainStage.set_user_resizable(True)
        if options.transparency > 0:
            self.mainStage.set_use_alpha(True)
        self.mainStage.set_color(
            Clutter.Color.new(0, 0, 0, 255 - options.transparency))

        # Create lines group
        self.linesGroup = Clutter.Group()
        self.mainStage.add_actor(self.linesGroup)
        dummy_text = Clutter.Text()
        dummy_text.set_font_name(self.font)
        dummy_text.set_text("#")
        self.char_width = dummy_text.get_width()
        self.char_height = dummy_text.get_height()
        self.shell = Shell(options, end_callback=self.destroy)
        self.lexer = Lexer(self.shell.cols, self.shell.rows,
                           self.set_title, self.bell)

        self.cursor = Clutter.Rectangle()
        self.cursor.set_color(Clutter.Color.new(255, 255, 255, 100))
        self.cursor.set_x(self.char_width * self.lexer.cursor.x)
        self.cursor.set_y(self.char_height * self.lexer.cursor.y)
        self.cursor.set_width(self.char_width)
        self.cursor.set_height(self.char_height)
        self.mainStage.add_actor(self.cursor)

        def create_line(i):
            line = Clutter.Text()
            # We must never see this color:
            line.set_color(Clutter.Color.new(255, 0, 255, 255))
            line.set_font_name(self.font)
            line.set_width(self.char_width * self.shell.cols)
            line.set_height(self.char_height)
            line.set_y(i * self.char_height)
            self.linesGroup.add_actor(line)
            return line

        def resize(w, h):
            w = self.mainStage.get_width()
            h = self.mainStage.get_height()
            cols = int(w / self.char_width)
            rows = int(h / self.char_height)
            if (cols, rows) == (self.lexer.matrix.cols, self.shell.rows):
                return
            log.info('resize %s %s %s %s' % (w, h, cols, rows))
            self.shell.resize(cols, rows)
            self.lexer.resize(cols, rows)
            self.linesGroup.set_geometry(self.mainStage.get_geometry())
            for line in self.lines:
                self.linesGroup.remove_actor(line)
            self.lines = [create_line(i)
                          for i in range(self.shell.rows)]

        self.lines = [create_line(i)
                      for i in range(self.shell.rows)]

        self.thread = ReaderAsync(self.shell, self.write, self.destroy)
        self.thread.start()

        # Clutter.threads_add_timeout(300, 40, self.tick, None)
        # Setup key bindings on the terminal
        self.mainStage.connect_after("key-press-event", self.onKeyPress)
        self.mainStage.connect_after("notify::width", resize)
        self.mainStage.connect_after("notify::height", resize)
        self.mainStage.set_size(
            self.shell.cols * self.char_width,
            self.shell.rows * self.char_height)
        self.linesGroup.set_geometry(self.mainStage.get_geometry())
        # Present the main stage (and make sure everything is shown)
        self.mainStage.show_all()