mirror of
https://github.com/3b1b/manim.git
synced 2025-11-14 04:27:53 +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.needs_new_bounding_box: bool = True
|
||||
self._is_animating: bool = False
|
||||
self._is_movable: bool = False
|
||||
self.interaction_allowed: bool = False
|
||||
|
||||
self.init_data()
|
||||
self.init_uniforms()
|
||||
|
|
@ -692,20 +692,20 @@ class Mobject(object):
|
|||
# Check if mark as static or not for camera
|
||||
|
||||
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:
|
||||
for mob in self.get_family(recurse):
|
||||
mob._is_animating = is_animating
|
||||
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):
|
||||
mob._is_movable = value
|
||||
mob.interaction_allowed = value
|
||||
return self
|
||||
|
||||
def is_movable(self) -> bool:
|
||||
return self._is_movable
|
||||
def is_interaction_allowed(self) -> bool:
|
||||
return self.interaction_allowed
|
||||
|
||||
# Transforming operations
|
||||
|
||||
|
|
|
|||
|
|
@ -145,8 +145,11 @@ class InteractiveScene(Scene):
|
|||
self.select_top_level_mobs = not self.select_top_level_mobs
|
||||
self.refresh_selection_scope()
|
||||
|
||||
def get_selection_search_set(self):
|
||||
mobs = [m for m in self.mobjects if m not in self.unselectables]
|
||||
def get_selection_search_set(self) -> list[Mobject]:
|
||||
mobs = [
|
||||
m for m in self.mobjects
|
||||
if m not in self.unselectables and m.is_interaction_allowed()
|
||||
]
|
||||
if self.select_top_level_mobs:
|
||||
return mobs
|
||||
else:
|
||||
|
|
@ -173,7 +176,7 @@ class InteractiveScene(Scene):
|
|||
)
|
||||
self.refresh_selection_highlight()
|
||||
|
||||
def get_corner_dots(self, mobject):
|
||||
def get_corner_dots(self, mobject: Mobject) -> Mobject:
|
||||
dots = DotCloud(**self.corner_dot_config)
|
||||
radius = self.corner_dot_config["radius"]
|
||||
if mobject.get_depth() < 1e-2:
|
||||
|
|
@ -186,7 +189,7 @@ class InteractiveScene(Scene):
|
|||
]))
|
||||
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:
|
||||
result = VHighlight(mobject)
|
||||
result.add_updater(lambda m: m.replace(mobject))
|
||||
|
|
@ -223,9 +226,13 @@ class InteractiveScene(Scene):
|
|||
|
||||
def add(self, *new_mobjects: Mobject):
|
||||
for mob in new_mobjects:
|
||||
mob.make_movable()
|
||||
mob.allow_interaction()
|
||||
super().add(*new_mobjects)
|
||||
|
||||
def disable_interaction(self, *mobjects: Mobject):
|
||||
for mob in mobjects:
|
||||
mob.allow_interaction(False)
|
||||
|
||||
# Functions for keyboard actions
|
||||
|
||||
def copy_selection(self):
|
||||
|
|
@ -376,7 +383,7 @@ class InteractiveScene(Scene):
|
|||
self.is_selecting = False
|
||||
self.remove(self.selection_rectangle)
|
||||
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)
|
||||
elif chr(symbol) == CURSOR_LOCATION_KEY:
|
||||
self.remove(self.cursor_location_label)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue