def check_slide_bbox(self): if self.app.config.getint('viewer', 'thumb') == 1: img_point = (self.bbox[0][0] + self.bbox[1][0], self.bbox[0][1] + self.bbox[1][1]) parent_point = (self.parent.size[0] + self.parent.pos[0], self.parent.size[1] + self.parent.pos[1]) if not Vector.in_bbox(self.bbox[0], self.parent.pos, parent_point) or not Vector.in_bbox( img_point, self.parent.pos, parent_point): if all(child.id != 'img_zoom' for child in self.parent.children): # TODO: Change thumbnail position and size based on config. thumb = Image(source=self.image.source, id='img_zoom', size_hint=(None, None), keep_ratio=True, size=(self.parent.size[0] / 5, (self.parent.size[0] / 5) / self.image.image_ratio), pos=[0, 0.05 * self.parent.size[1]]) self.parent.add_widget(thumb) elif min(self.bbox[0]) > 0: for child in self.parent.children: if child.id == 'img_zoom': self.parent.remove_widget(child)
def test_inbbox(self): bmin = (0, 0) bmax = (100, 100) result = Vector.in_bbox((50, 50), bmin, bmax) self.assertTrue(result) result = Vector.in_bbox((647, -10), bmin, bmax) self.assertFalse(result)
def check_slide_bbox(self): if self.app.config.getint('viewer', 'thumb') == 1: img_point = (self.bbox[0][0] + self.bbox[1][0], self.bbox[0][1] + self.bbox[1][1]) parent_point = (self.parent.size[0] + self.parent.pos[0], self.parent.size[1] + self.parent.pos[1]) if not Vector.in_bbox(self.bbox[0], self.parent.pos, parent_point) or not Vector.in_bbox(img_point, self.parent.pos, parent_point): if all(child.id != 'img_zoom' for child in self.parent.children): # TODO: Change thumbnail position and size based on config. thumb = AsyncImage(source=self.image.source, id='img_zoom', size_hint=(None, None), keep_ratio=True, size=(self.parent.size[0] / 5, (self.parent.size[0] / 5) / self.image.image_ratio), pos=[0, 0.05 * self.parent.size[1]]) self.parent.add_widget(thumb) elif min(self.bbox[0]) > 0: img_zoom = [child for child in self.parent.children if child.id == 'img_zoom'] try: self.parent.remove_widget(img_zoom[0]) except IndexError: pass
def on_touch_down(self, touch, *args): bottom_right_corner = [(dp(self.size[0]) - dp(200), dp(200)), (dp(self.size[0]), 0)] top_left_corner = [(0, dp(self.size[1])), (dp(200), dp(self.size[1]) - dp(200))] top_right_corner = [(dp(self.size[0]) - dp(200), dp(self.size[1])), (dp(self.size[0]), dp(self.size[1]) - dp(200))] center = [(dp(200), dp(200)), (dp(self.size[0]) - dp(200), dp(self.size[1]) - dp(200))] if self.collide_point(*touch.pos): if Vector.in_bbox(touch.pos, bottom_right_corner[0], bottom_right_corner[1]) \ and touch.is_double_tap and len(self.app.presentation['slides']) > 0: self.dialog.to_switch = True self.dialog.title = _('Switch to...') self.dialog.open() return False elif Vector.in_bbox(touch.pos, top_left_corner[0], top_left_corner[1]) \ and touch.is_double_tap: self.app.root.current = 'editor' return True elif Vector.in_bbox(touch.pos, top_right_corner[0], top_right_corner[1]) \ and touch.is_double_tap and len(self.app.presentation['slides']) > 0: # TODO: Switch to toolbox mode. return False elif Vector.in_bbox(touch.pos, center[0], center[1]) \ and touch.is_double_tap and len(self.app.presentation['slides']) > 0: if len(self.box.children) < 2: Logger.info('Application: Switching to compare mode.') self.dialog.to_switch = False self.dialog.title = _('Compare to...') self.dialog.open() else: self.app.compare_slide(action='rm') touch.ungrab(self) return True return super(ViewerScreen, self).on_touch_down(touch)
def getNextNode(self, *args): x = 0 while x < len(self.movelist) - 1: priorpos = self.movelist[x] nextpos = self.movelist[x + 1] if self.roadPos: if Vector.in_bbox((self.roadPos), priorpos, nextpos): self.roadPos = 0 self.curnode = x + 1 break else: if Vector.in_bbox((self.pos), priorpos, nextpos): self.curnode = x + 1 break x += 1 self.useOldNode = True self.move()
def collide_point(self, point): p = point - self.center p.rotate(-self.rotation) return Vector.in_bbox(p, self.get_aligned_bl(), self.get_local_tr())