def on_event(self, daemon, what, data): # Restricts Y axis to dead center, as nothing # else makes sense in this kind of menu if self._submenu: return self._submenu.on_event(daemon, what, data) if what == self._control_with and self._use_cursor: data = data[0], STICK_PAD_MIN Menu.on_event(self, daemon, what, data)
def on_event(self, daemon, what, data): if self._submenu: return self._submenu.on_event(daemon, what, data) if what == self._control_with: x, y = data max_w = self.get_allocation().width - (self.cursor.get_allocation().width * 1.0) max_h = self.get_allocation().height - (self.cursor.get_allocation().height * 1.0) x = ((x * 0.75 / (STICK_PAD_MAX * 2.0)) + 0.5) * max_w y = (0.5 - (y * 0.75 / (STICK_PAD_MAX * 2.0))) * max_h x -= self.cursor.get_allocation().width * 0.5 y -= self.cursor.get_allocation().height * 0.5 self.f.move(self.cursor, int(x), int(y)) x, y = data if abs(x) + abs(y) > RadialMenu.MIN_DISTANCE: angle = atan2(*data) * 180.0 / PI half_width = 180.0 / len(self.items) for i in self.items: if abs(degdiff(i.a, angle)) < half_width: if self._selected != i: self._selected = i self.b.hilight({ "menuitem_" + i.id : "#" + self.config["osd_colors"]["menuitem_hilight"], "text_" + i.id : "#" + self.config["osd_colors"]["menuitem_hilight_text"], }) else: return Menu.on_event(self, daemon, what, data)
def on_event(self, daemon, what, data): if self._submenu: return self._submenu.on_event(daemon, what, data) if what == self._control_with: x, y = data # Special case, both confirm_with and cancel_with can be set to STICK if self._cancel_with == STICK and self._control_with == STICK: if self._control_equals_cancel(daemon, x, y): return if self.rotation: rx = x * cos(self.rotation) - y * sin(self.rotation) ry = x * sin(self.rotation) + y * cos(self.rotation) x, y = rx, ry max_w = self.get_allocation().width * self.scale - (self.cursor.get_allocation().width * 1.0) max_h = self.get_allocation().height * self.scale - (self.cursor.get_allocation().height * 1.0) cx = ((x * 0.75 / (STICK_PAD_MAX * 2.0)) + 0.5) * max_w cy = (0.5 - (y * 0.75 / (STICK_PAD_MAX * 2.0))) * max_h cx -= self.cursor.get_allocation().width * 0.5 cy -= self.cursor.get_allocation().height * 0.5 self.f.move(self.cursor, int(cx), int(cy)) if abs(x) + abs(y) > RadialMenu.MIN_DISTANCE: angle = atan2(x, y) * 180.0 / PI half_width = 180.0 / len(self.items) for i in self.items: if abs(degdiff(i.a, angle)) < half_width: if self._selected != i: if self.feedback and self.controller: self.controller.feedback(*self.feedback) self.select(i) else: return Menu.on_event(self, daemon, what, data)
def on_event(self, daemon, what, data): if self._submenu: return self._submenu.on_event(daemon, what, data) if what == self._control_with: x, y = data # Special case, both confirm_with and cancel_with can be set to STICK if self._cancel_with == STICK and self._control_with == STICK: if self._control_equals_cancel(daemon, x, y): return max_w = self.get_allocation().width - ( self.cursor.get_allocation().width * 1.0) max_h = self.get_allocation().height - ( self.cursor.get_allocation().height * 1.0) x = ((x * 0.75 / (STICK_PAD_MAX * 2.0)) + 0.5) * max_w y = (0.5 - (y * 0.75 / (STICK_PAD_MAX * 2.0))) * max_h x -= self.cursor.get_allocation().width * 0.5 y -= self.cursor.get_allocation().height * 0.5 self.f.move(self.cursor, int(x), int(y)) x, y = data if abs(x) + abs(y) > RadialMenu.MIN_DISTANCE: angle = atan2(*data) * 180.0 / PI half_width = 180.0 / len(self.items) for i in self.items: if abs(degdiff(i.a, angle)) < half_width: if self._selected != i: self._selected = i self.b.hilight({ "menuitem_" + i.id: "#" + self.config["osd_colors"]["menuitem_hilight"], "text_" + i.id: "#" + self.config["osd_colors"] ["menuitem_hilight_text"], }) else: return Menu.on_event(self, daemon, what, data)