Skip to content

Commit 632a11f

Browse files
k4pranbehackl
andauthored
OpenGL: changed submobjects to be a property (#1926)
* Add property for submobjects * Use property for opengl submobjects * Update manim/mobject/opengl_mobject.py Co-authored-by: Benjamin Hackl <[email protected]> Co-authored-by: Benjamin Hackl <[email protected]>
1 parent 25b3126 commit 632a11f

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

manim/mobject/opengl_mobject.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def __init__(
101101
# Event listener
102102
self.listen_to_events = listen_to_events
103103

104-
self.submobjects = []
104+
self._submobjects = []
105105
self.parents = []
106106
self.parent = None
107107
self.family = [self]
@@ -471,6 +471,12 @@ def replace_submobject(self, index, new_submob):
471471
self.assemble_family()
472472
return self
473473

474+
@deprecated(
475+
since="v0.12.0",
476+
until="v0.13.0",
477+
replacement="self.submobjects",
478+
message="Switching to using properties for submobjects",
479+
)
474480
def set_submobjects(self, submobject_list):
475481
self.remove(*self.submobjects)
476482
self.add(*submobject_list)
@@ -1904,6 +1910,15 @@ def get_shader_uniforms(self):
19041910
def get_shader_vert_indices(self):
19051911
return self.shader_indices
19061912

1913+
@property
1914+
def submobjects(self):
1915+
return self._submobjects
1916+
1917+
@submobjects.setter
1918+
def submobjects(self, submobject_list):
1919+
self.remove(*self.submobjects)
1920+
self.add(*submobject_list)
1921+
19071922
# Event Handlers
19081923
"""
19091924
Event handling follows the Event Bubbling model of DOM in javascript.

manim/mobject/svg/text_mobject.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -482,10 +482,7 @@ def __init__(
482482
)
483483
self.text = text
484484
if self.disable_ligatures:
485-
if config.renderer == "opengl":
486-
self.set_submobjects(self.gen_chars())
487-
else:
488-
self.submobjects = [*self.gen_chars()]
485+
self.submobjects = [*self.gen_chars()]
489486
self.chars = self.get_group_class()(*self.submobjects)
490487
self.text = text_without_tabs.replace(" ", "").replace("\n", "")
491488
if config.renderer == "opengl":

0 commit comments

Comments
 (0)