Beispiel #1
0
 def _collide_with_overlap(self, x, y):
     if self.top_slider_object is not None and isinstance(self.top_slider_object, SliderWidgetLayout):
         x_overlap = kvmetrics.mm(self.top_slider_object.x_overlap_mm)
         y_overlap = kvmetrics.mm(self.top_slider_object.y_overlap_mm)
         x1, x2 = self.x - x_overlap, self.right + x_overlap
         y1, y2 = self.y - y_overlap, self.top + y_overlap
         return x1 <= x <= x2 and y1 <= y <= y2 and self.parent.collide_point(x, y)
     else:
         Logger.warning('Using electrode widget outside slider widget')
         return super().collide_point(x, y)
Beispiel #2
0
    def __init__(self, **kwargs):
        super(KeyDisplay, self).__init__(**kwargs)

        print(self.pos)
        x = self.pos[0]
        y = self.pos[1]
        sz = metrics.pt(21)
        sz2 = metrics.pt(21) * 2.5
        gap = metrics.mm(2)  # 2 millimeters

        # print(metrics.pt(21), metrics.sp(21), metrics.dp(21), metrics.mm(10))

        # keyboard up / down messages
        self.active_keys = {}
        self.slots = []
        for i in range(5):
            self.slots.append(
                SimpleNamespace(icon=None,
                                pos=(x + (gap + sz) * i, y + gap + sz),
                                size=(sz, sz)))
        self.meta_slots = []
        for i in range(5):
            self.meta_slots.append(
                SimpleNamespace(icon=None,
                                pos=(x + (gap + sz2) * i, y),
                                size=(sz2, sz)))

        kb = Window.request_keyboard(target=self, callback=None)
        kb.bind(on_key_down=self._key_down)
        kb.bind(on_key_up=self._key_up)
Beispiel #3
0
    def __init__(self, txt, pos, size):
        super(KeyIcon, self).__init__()

        label = CLabelRect(cpos=pos, text=txt)
        self.add(label)
        x, y = pos
        hw = size[0] // 2
        hh = size[1] // 2
        box = Line(points=[
            x - hw, y - hh, x - hw, y + hh, x + hw, y + hh, x + hw, y - hh,
            x - hw, y - hh
        ],
                   width=metrics.mm(.25))
        self.add(box)
Beispiel #4
0
 def get_o_naub_pos(self):
     label, game = self.label, self.game
     x, y        = Vector(label.o_center) #* 0.5#- game.center
     x, y        = x / mm(2), y / mm(-2) #y / mm(-1)
     return x, y