mirror of
https://github.com/3b1b/manim.git
synced 2025-11-14 14:27:46 +00:00
Rename is_movable to interaction_allowed
This commit is contained in:
parent
7b342a2759
commit
3961005fd7
2 changed files with 19 additions and 12 deletions
|
|
@ -84,7 +84,7 @@ class Mobject(object):
|
||||||
self.locked_data_keys: set[str] = set()
|
self.locked_data_keys: set[str] = set()
|
||||||
self.needs_new_bounding_box: bool = True
|
self.needs_new_bounding_box: bool = True
|
||||||
self._is_animating: bool = False
|
self._is_animating: bool = False
|
||||||
self._is_movable: bool = False
|
self.interaction_allowed: bool = False
|
||||||
|
|
||||||
self.init_data()
|
self.init_data()
|
||||||
self.init_uniforms()
|
self.init_uniforms()
|
||||||
|
|
@ -692,20 +692,20 @@ class Mobject(object):
|
||||||
# Check if mark as static or not for camera
|
# Check if mark as static or not for camera
|
||||||
|
|
||||||
def is_changing(self) -> bool:
|
def is_changing(self) -> bool:
|
||||||
return self._is_animating or self.has_updaters or self._is_movable
|
return self._is_animating or self.has_updaters or self.interaction_allowed
|
||||||
|
|
||||||
def set_animating_status(self, is_animating: bool, recurse: bool = True) -> None:
|
def set_animating_status(self, is_animating: bool, recurse: bool = True) -> None:
|
||||||
for mob in self.get_family(recurse):
|
for mob in self.get_family(recurse):
|
||||||
mob._is_animating = is_animating
|
mob._is_animating = is_animating
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def make_movable(self, value: bool = True, recurse: bool = True) -> None:
|
def allow_interaction(self, value: bool = True, recurse: bool = True) -> None:
|
||||||
for mob in self.get_family(recurse):
|
for mob in self.get_family(recurse):
|
||||||
mob._is_movable = value
|
mob.interaction_allowed = value
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def is_movable(self) -> bool:
|
def is_interaction_allowed(self) -> bool:
|
||||||
return self._is_movable
|
return self.interaction_allowed
|
||||||
|
|
||||||
# Transforming operations
|
# Transforming operations
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -145,8 +145,11 @@ class InteractiveScene(Scene):
|
||||||
self.select_top_level_mobs = not self.select_top_level_mobs
|
self.select_top_level_mobs = not self.select_top_level_mobs
|
||||||
self.refresh_selection_scope()
|
self.refresh_selection_scope()
|
||||||
|
|
||||||
def get_selection_search_set(self):
|
def get_selection_search_set(self) -> list[Mobject]:
|
||||||
mobs = [m for m in self.mobjects if m not in self.unselectables]
|
mobs = [
|
||||||
|
m for m in self.mobjects
|
||||||
|
if m not in self.unselectables and m.is_interaction_allowed()
|
||||||
|
]
|
||||||
if self.select_top_level_mobs:
|
if self.select_top_level_mobs:
|
||||||
return mobs
|
return mobs
|
||||||
else:
|
else:
|
||||||
|
|
@ -173,7 +176,7 @@ class InteractiveScene(Scene):
|
||||||
)
|
)
|
||||||
self.refresh_selection_highlight()
|
self.refresh_selection_highlight()
|
||||||
|
|
||||||
def get_corner_dots(self, mobject):
|
def get_corner_dots(self, mobject: Mobject) -> Mobject:
|
||||||
dots = DotCloud(**self.corner_dot_config)
|
dots = DotCloud(**self.corner_dot_config)
|
||||||
radius = self.corner_dot_config["radius"]
|
radius = self.corner_dot_config["radius"]
|
||||||
if mobject.get_depth() < 1e-2:
|
if mobject.get_depth() < 1e-2:
|
||||||
|
|
@ -186,7 +189,7 @@ class InteractiveScene(Scene):
|
||||||
]))
|
]))
|
||||||
return dots
|
return dots
|
||||||
|
|
||||||
def get_highlight(self, mobject):
|
def get_highlight(self, mobject: Mobject) -> Mobject:
|
||||||
if isinstance(mobject, VMobject) and mobject.has_points() and not self.select_top_level_mobs:
|
if isinstance(mobject, VMobject) and mobject.has_points() and not self.select_top_level_mobs:
|
||||||
result = VHighlight(mobject)
|
result = VHighlight(mobject)
|
||||||
result.add_updater(lambda m: m.replace(mobject))
|
result.add_updater(lambda m: m.replace(mobject))
|
||||||
|
|
@ -223,9 +226,13 @@ class InteractiveScene(Scene):
|
||||||
|
|
||||||
def add(self, *new_mobjects: Mobject):
|
def add(self, *new_mobjects: Mobject):
|
||||||
for mob in new_mobjects:
|
for mob in new_mobjects:
|
||||||
mob.make_movable()
|
mob.allow_interaction()
|
||||||
super().add(*new_mobjects)
|
super().add(*new_mobjects)
|
||||||
|
|
||||||
|
def disable_interaction(self, *mobjects: Mobject):
|
||||||
|
for mob in mobjects:
|
||||||
|
mob.allow_interaction(False)
|
||||||
|
|
||||||
# Functions for keyboard actions
|
# Functions for keyboard actions
|
||||||
|
|
||||||
def copy_selection(self):
|
def copy_selection(self):
|
||||||
|
|
@ -376,7 +383,7 @@ class InteractiveScene(Scene):
|
||||||
self.is_selecting = False
|
self.is_selecting = False
|
||||||
self.remove(self.selection_rectangle)
|
self.remove(self.selection_rectangle)
|
||||||
for mob in reversed(self.get_selection_search_set()):
|
for mob in reversed(self.get_selection_search_set()):
|
||||||
if mob.is_movable() and self.selection_rectangle.is_touching(mob):
|
if self.selection_rectangle.is_touching(mob):
|
||||||
self.add_to_selection(mob)
|
self.add_to_selection(mob)
|
||||||
elif chr(symbol) == CURSOR_LOCATION_KEY:
|
elif chr(symbol) == CURSOR_LOCATION_KEY:
|
||||||
self.remove(self.cursor_location_label)
|
self.remove(self.cursor_location_label)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue