Пример #1
0
 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)
Пример #2
0
	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)
Пример #3
0
	def parse_argumets(self, argv):
		self.editor = self.b.edit()
		rv = Menu.parse_argumets(self, argv)
		self.rotation = self.args.rotation
		if rv:
			self.enable_cursor()
		return rv
Пример #4
0
	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)
Пример #5
0
	def parse_argumets(self, argv):
		self.editor = self.b.edit()
		rv = Menu.parse_argumets(self, argv)
		self.rotation = self.args.rotation
		if rv:
			self.enable_cursor()
		return rv
Пример #6
0
 def on_unknown_message(self, daemon, message):
     if not message.startswith("OSD:"):
         return
     if message.startswith("OSD: message"):
         args = split(message)[1:]
         m = Message()
         m.parse_argumets(args)
         m.show()
     elif message.startswith("OSD: keyboard"):
         if self._window:
             log.warning(
                 "Another OSD is already visible - refusing to show keyboard"
             )
         else:
             args = split(message)[1:]
             self._window = Keyboard()
             self._window.connect('destroy', self.on_keyboard_closed)
             # self._window.parse_argumets(args) # TODO: No arguments so far
             self._window.show()
             self._window.use_daemon(self.daemon)
     elif message.startswith("OSD: menu") or message.startswith(
             "OSD: gridmenu"):
         args = split(message)[1:]
         if self._window:
             log.warning(
                 "Another OSD is already visible - refusing to show menu")
         else:
             self._window = GridMenu() if "gridmenu" in message else Menu()
             self._window.connect('destroy', self.on_menu_closed)
             self._window.use_config(self.config)
             if self._window.parse_argumets(args):
                 self._window.show()
                 self._window.use_daemon(self.daemon)
             else:
                 log.error("Failed to show menu")
                 self._window = None
     elif message.startswith("OSD: area"):
         args = split(message)[1:]
         if self._window:
             log.warning(
                 "Another OSD is already visible - refusing to show area")
         else:
             args = split(message)[1:]
             self._window = Area()
             self._window.connect('destroy', self.on_keyboard_closed)
             if self._window.parse_argumets(args):
                 self._window.show()
             else:
                 self._window.quit()
                 self._window = None
     elif message.startswith("OSD: clear"):
         # Clears active OSD window (if any)
         if self._window:
             self._window.quit()
             self._window = None
     else:
         log.warning("Unknown command from daemon: '%s'", message)
Пример #7
0
	def generate_widget(self, item):
		if isinstance(item, Separator):
			# Ignored here
			return None
		elif item.id is None:
			# Dummies are ignored as well
			return None
		else:
			icon_file, has_colors = find_icon(item.icon, False)
			if icon_file:
				# Gridmenu hides label when icon is displayed
				widget = Gtk.Button()
				widget.set_relief(Gtk.ReliefStyle.NONE)
				widget.set_name("osd-menu-item-big-icon")
				if isinstance(item, Submenu):
					item.callback = self.show_submenu
				icon = MenuIcon(icon_file, has_colors)
				widget.add(icon)
				return widget
			else:
				return Menu.generate_widget(self, item)
 def generate_widget(self, item):
     if isinstance(item, Separator):
         # Ignored here
         return None
     elif item.id is None:
         # Dummies are ignored as well
         return None
     else:
         icon_file, has_colors = find_icon(item.icon, False)
         if icon_file:
             # Gridmenu hides label when icon is displayed
             widget = Gtk.Button()
             widget.set_relief(Gtk.ReliefStyle.NONE)
             widget.set_name("osd-menu-item-big-icon")
             if isinstance(item, Submenu):
                 item.callback = self.show_submenu
             icon = MenuIcon(icon_file, has_colors)
             widget.add(icon)
             return widget
         else:
             return Menu.generate_widget(self, item)
Пример #9
0
    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)
Пример #10
0
 def __init__(self, cls="osd-menu"):
     Menu.__init__(self, cls)
     self._cancel_with = 'START'
     self._pressed = []
     self._icons = []
     self._timer = None
Пример #11
0
	def __init__(self,):
		Menu.__init__(self, "osd-radial-menu")
		self.angle = 0
		self.rotation = 0
Пример #12
0
 def on_unknown_message(self, daemon, message):
     if not message.startswith("OSD:"):
         return
     if message.startswith("OSD: message"):
         args = shsplit(message)[1:]
         m = Message()
         m.parse_argumets(args)
         m.show()
     elif message.startswith("OSD: keyboard"):
         if self._window:
             log.warning(
                 "Another OSD is already visible - refusing to show keyboard"
             )
         else:
             args = shsplit(message)[1:]
             self._window = Keyboard(self.config)
             self._window.connect('destroy', self.on_keyboard_closed)
             self._window.parse_argumets(args)
             self._window.show()
             self._window.use_daemon(self.daemon)
     elif message.startswith("OSD: gesture"):
         if self._window:
             log.warning(
                 "Another OSD is already visible - refusing to show keyboard"
             )
         else:
             args = shsplit(message)[1:]
             self._window = GestureDisplay(self.config)
             self._window.parse_argumets(args)
             self._window.use_daemon(self.daemon)
             self._window.show()
             self._window.connect('destroy', self.on_gesture_recognized)
     elif self._is_menu_message(message):
         args = shsplit(message)[1:]
         if self._window:
             log.warning(
                 "Another OSD is already visible - refusing to show menu")
         else:
             if message.startswith("OSD: hmenu"):
                 self._window = HorizontalMenu()
             elif message.startswith("OSD: radialmenu"):
                 self._window = RadialMenu()
             elif message.startswith("OSD: quickmenu"):
                 self._window = QuickMenu()
             elif message.startswith("OSD: gridmenu"):
                 self._window = GridMenu()
             elif message.startswith("OSD: dialog"):
                 self._window = Dialog()
             else:
                 self._window = Menu()
             self._window.connect('destroy', self.on_menu_closed)
             self._window.use_config(self.config)
             if self._window.parse_argumets(args):
                 self._window.show()
                 self._window.use_daemon(self.daemon)
             else:
                 log.error("Failed to show menu")
                 self._window = None
     elif message.startswith("OSD: area"):
         args = shsplit(message)[1:]
         if self._window:
             log.warning(
                 "Another OSD is already visible - refusing to show area")
         else:
             args = shsplit(message)[1:]
             self._window = Area()
             self._window.connect('destroy', self.on_keyboard_closed)
             if self._window.parse_argumets(args):
                 self._window.show()
             else:
                 self._window.quit()
                 self._window = None
     elif message.startswith("OSD: clear"):
         # Clears active OSD window (if any)
         if self._window:
             self._window.quit()
             self._window = None
     else:
         log.warning("Unknown command from daemon: '%s'", message)
Пример #13
0
 def show(self, *a):
     Menu.show(self, *a)
     self.restart_timer()
Пример #14
0
 def __init__(self, ):
     Menu.__init__(self, "osd-radial-menu")
     self.angle = 0
     self.rotation = 0
     self.scale = 1.0
     self.items_with_icon = []
Пример #15
0
 def get_window_size(self):
     w, h = Menu.get_window_size(self)
     if self.scale != 1.0:
         w = int(w * self.scale)
         h = int(h * self.scale)
     return w, h
Пример #16
0
	def _add_arguments(self):
		Menu._add_arguments(self)
		self.argparser.add_argument('--rotation', type=float, default=0,
			help="rotates input by angle (default: 0)")
Пример #17
0
 def __init__(self, cls="osd-menu"):
     Menu.__init__(self, cls)
     self.ipr = 1  # items per row
Пример #18
0
	def __init__(self,):
		Menu.__init__(self, "osd-radial-menu")
		self.angle = 0
		self.rotation = 0
		self.scale = 1.0
		self.items_with_icon = []
Пример #19
0
	def _add_arguments(self):
		Menu._add_arguments(self)
		self.argparser.add_argument('--rotation', type=float, default=0,
			help="rotates input by angle (default: 0)")
Пример #20
0
	def show(self, *a):
		Menu.show(self, *a)
		self.restart_timer()
Пример #21
0
	def parse_argumets(self, argv):
		self.editor = self.b.edit()
		rv = Menu.parse_argumets(self, argv)
		if rv:
			self.enable_cursor()
		return rv
Пример #22
0
	def __init__(self,):
		Menu.__init__(self, "osd-radial-menu")
		self.angle = 0
Пример #23
0
	def get_window_size(self):
		w, h = Menu.get_window_size(self)
		if self.scale != 1.0:
			w = int(w * self.scale)
			h = int(h * self.scale)
		return w, h
Пример #24
0
	def __init__(self, cls="osd-menu"):
		Menu.__init__(self, cls)
		self._cancel_with = 'START'
		self._pressed = []
Пример #25
0
 def parse_argumets(self, argv):
     self.editor = self.b.edit()
     rv = Menu.parse_argumets(self, argv)
     if rv:
         self.enable_cursor()
     return rv
Пример #26
0
 def __init__(self, cls="osd-menu"):
     Menu.__init__(self, cls)
Пример #27
0
	def __init__(self, cls="osd-menu"):
		Menu.__init__(self, cls)
		self._cancel_with = 'START'
		self._pressed = []
		self._icons = []
		self._timer = None
Пример #28
0
	def __init__(self, cls="osd-menu"):
		Menu.__init__(self, cls)
		self.ipr = 1	# items per row