Skip to content

Commit

Permalink
Rename is_movable to interaction_allowed
Browse files Browse the repository at this point in the history
  • Loading branch information
3b1b committed Apr 23, 2022
1 parent 7b342a2 commit 3961005
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
12 changes: 6 additions & 6 deletions manimlib/mobject/mobject.py
Expand Up @@ -84,7 +84,7 @@ def __init__(self, **kwargs):
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()
Expand Down Expand Up @@ -692,20 +692,20 @@ def refresh_has_updater_status(self):
# 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

Expand Down
19 changes: 13 additions & 6 deletions manimlib/scene/interactive_scene.py
Expand Up @@ -145,8 +145,11 @@ def toggle_selection_mode(self):
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:
Expand All @@ -173,7 +176,7 @@ def refresh_selection_scope(self):
)
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:
Expand All @@ -186,7 +189,7 @@ def get_corner_dots(self, mobject):
]))
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))
Expand Down Expand Up @@ -223,9 +226,13 @@ def clear_selection(self):

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):
Expand Down Expand Up @@ -376,7 +383,7 @@ def on_key_release(self, symbol: int, modifiers: int) -> None:
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)
Expand Down

0 comments on commit 3961005

Please sign in to comment.