Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def make_circular_action(self):
"""
Constructs Circular Modifier
"""
if self.circular_axis and any(self.circular_buttons):
return CircularModifier(MultiAction(
self.circular_axis, ButtonAction(*self.circular_buttons)))
elif any(self.circular_buttons):
return CircularModifier(ButtonAction(*self.circular_buttons))
else:
return CircularModifier(self.circular_axis)
def _set_label(self, action):
if is_gyro_enable(action):
action = action.mods.values()[0] or action.default
if isinstance(action, MultiAction):
rv = []
for a in action.actions:
d = a.describe(self.ACTION_CONTEXT)
if not d in rv : rv.append(d)
self.label.set_label("\n".join(rv))
return
self.label.set_label(action.describe(self.ACTION_CONTEXT))
def _make_action(self):
""" Generates and returns Action instance """
cbMode = self.builder.get_object("cbMode")
key = cbMode.get_model().get_value(cbMode.get_active_iter(), 0)
if key == "inner":
return MultiAction(
self.actions[1],
RingAction(self.radius, self.actions[0], NoAction())
)
elif key == "outer":
return MultiAction(
self.actions[0],
RingAction(self.radius, NoAction(), self.actions[1])
)
else:
return RingAction(self.radius, *self.actions)
def handles(self, mode, action):
# Handles ButtonAction and MultiAction if all subactions are ButtonAction
if isinstance(action, (ButtonAction, NoAction, InvalidAction)):
return True
if isinstance(action, AxisAction):
return len(action.parameters) == 1
if isinstance(action, MouseAction):
if action.axis == Rels.REL_WHEEL:
return True
if is_button_togle(action):
return True
if is_button_repeat(action):
return True
if isinstance(action, MultiAction):
if len(action.actions) > 0:
for a in action.actions:
if not isinstance(a, ButtonAction):
return False
return True
return False
def set_action(self, mode, action):
if self.handles(mode, action):
if isinstance(action, ModeModifier):
self._recursing = True
self.builder.get_object("cbInvertGyro").set_active(bool(action.default))
self._recursing = False
b = action.mods.keys()[0]
action = action.mods[b] or action.default
self.select_gyro_button(b)
else:
self.select_gyro_button(None)
actions = [ action ]
if isinstance(action, MultiAction):
actions = action.actions
self._recursing = True
for a in actions:
if isinstance(a, GyroAction):
pars = ensure_size(3, a.parameters)
for i in xrange(0, 3):
if pars[i] is not None:
self.axes[i] = pars[i]
self.cbs[i].set_active(isinstance(a, GyroAbsAction))
self.update()
self._recursing = False
def _make_action(self):
""" Generates and returns Action instance """
cbMode = self.builder.get_object("cbMode")
key = cbMode.get_model().get_value(cbMode.get_active_iter(), 0)
if key == "inner":
return MultiAction(
self.actions[1],
RingAction(self.radius, self.actions[0], NoAction())
)
elif key == "outer":
return MultiAction(
self.actions[0],
RingAction(self.radius, NoAction(), self.actions[1])
)
else:
return RingAction(self.radius, *self.actions)
def handles(self, mode, action):
if isinstance(action, MultiAction) and len(action.actions) == 2:
# Handles combination of axis + button on fully pressed trigger
if not isinstance(action.actions[0], ButtonAction):
return False
action = action.actions[1]
return isinstance(action, (AxisAction, MouseAction))