def mouse_exit(self, event): ''' Mouse exited item. This is a filtered event from super GuiControl. Assert no button down (not a drag.) Dynamic orthogonality. A handle menu MIGHT follow the mouse in orthogonal directions, if the handle menu is a TrackingHandleMenu AND we didn't hit a stop (the limit of an edge of the controlee morph.) Exit from item is EITHER in "menu exit" direction OR in "menu change item" direction. ''' # Calculate vector in DCS of mouse exit. center = self.bounds.center_of() exit_vector = vector.Point(event.x, event.y) - center # normalize to manager's (the menu's) axis norm_vect = vector.normalize_vector_to_vector(exit_vector, self.group_manager.layout_spec.vector) if norm_vect.y > 10 or norm_vect.y < -10: # FIXME not hardcoded # exited the side, which means close menu self.close_manager() else: # Exited "change item" side of menu item. # Tell manager to decide next action (another item, or close menu.) self.group_manager.do_change_item(event, exit_vector)
def mouse_exit(self, event): ''' Mouse exited item. This is a filtered event from super GuiControl. Assert no button down (not a drag.) Dynamic orthogonality. A handle menu MIGHT follow the mouse in orthogonal directions, if the handle menu is a TrackingHandleMenu AND we didn't hit a stop (the limit of an edge of the controlee morph.) Exit from item is EITHER in "menu exit" direction OR in "menu change item" direction. ''' # Calculate vector in DCS of mouse exit. center = self.bounds.center_of() exit_vector = vector.Point(event.x, event.y) - center # normalize to manager's (the menu's) axis norm_vect = vector.normalize_vector_to_vector( exit_vector, self.group_manager.layout_spec.vector) if norm_vect.y > 10 or norm_vect.y < -10: # FIXME not hardcoded # exited the side, which means close menu self.close_manager() else: # Exited "change item" side of menu item. # Tell manager to decide next action (another item, or close menu.) self.group_manager.do_change_item(event, exit_vector)
def do_change_item(self, event, exit_vector): ''' The mouse has exited an item in exit_vector. Do next item or previous item or close menu. !!! Note that handle menus slide sideways, should not get an exit orthogonal to the menu vector. FIXME make a handle menu slide around a corner and make the menu_vector change as the menu slides along a curve. ''' vect = vector.normalize_vector_to_vector(exit_vector, self.layout_spec.vector) # Seems backwards, but since menu vector is opposite direction to layout, inverse sign if vect.x > 0 : self._change_item(event, 1) else : self._change_item(event, -1)
def pixels_off_menu_axis(self, event): ''' Is mouse motion orthogonal (sideways) to menu axis? Returns count of pixels off axis. !!! Note that the sign indicates left(countercw) or right (clockwise) of the menu axis, not a direction along the coordinate system. ''' # Specific for horiz menus: return not event.y == self.get_center().y # vector from menu origin to mouse event menu_vector = self.group_manager.layout_spec.vector menu_benchmark = self.group_manager.layout_spec.benchmark mouse_vector = vector.Point(event.x, event.y) - menu_benchmark # normalize to menu vector normal_vector = vector.normalize_vector_to_vector(mouse_vector, menu_vector) # print "mouse", mouse_vector, "menu", menu_vector, "normal", normal_vector return normal_vector.y
def do_change_item(self, event, exit_vector): ''' The mouse has exited an item in exit_vector. Do next item or previous item or close menu. !!! Note that handle menus slide sideways, should not get an exit orthogonal to the menu vector. FIXME make a handle menu slide around a corner and make the menu_vector change as the menu slides along a curve. ''' vect = vector.normalize_vector_to_vector(exit_vector, self.layout_spec.vector) # Seems backwards, but since menu vector is opposite direction to layout, inverse sign if vect.x > 0: self._change_item(event, 1) else: self._change_item(event, -1)
def pixels_off_menu_axis(self, event): ''' Is mouse motion orthogonal (sideways) to menu axis? Returns count of pixels off axis. !!! Note that the sign indicates left(countercw) or right (clockwise) of the menu axis, not a direction along the coordinate system. ''' # Specific for horiz menus: return not event.y == self.get_center().y # vector from menu origin to mouse event menu_vector = self.group_manager.layout_spec.vector menu_benchmark = self.group_manager.layout_spec.benchmark mouse_vector = vector.Point(event.x, event.y) - menu_benchmark # normalize to menu vector normal_vector = vector.normalize_vector_to_vector( mouse_vector, menu_vector) # print "mouse", mouse_vector, "menu", menu_vector, "normal", normal_vector return normal_vector.y