mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Init new focus() command
This commit is contained in:
parent
003c4d8626
commit
97b6e39abb
2 changed files with 18 additions and 0 deletions
|
@ -234,6 +234,7 @@ class Scene(object):
|
||||||
add=self.add,
|
add=self.add,
|
||||||
remove=self.remove,
|
remove=self.remove,
|
||||||
clear=self.clear,
|
clear=self.clear,
|
||||||
|
focus=self.focus,
|
||||||
save_state=self.save_state,
|
save_state=self.save_state,
|
||||||
undo=self.undo,
|
undo=self.undo,
|
||||||
redo=self.redo,
|
redo=self.redo,
|
||||||
|
@ -985,6 +986,11 @@ class Scene(object):
|
||||||
def on_close(self) -> None:
|
def on_close(self) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def focus(self) -> None:
|
||||||
|
if not self.window:
|
||||||
|
return
|
||||||
|
self.window.focus()
|
||||||
|
|
||||||
|
|
||||||
class SceneState():
|
class SceneState():
|
||||||
def __init__(self, scene: Scene, ignore: list[Mobject] | None = None):
|
def __init__(self, scene: Scene, ignore: list[Mobject] | None = None):
|
||||||
|
|
|
@ -49,6 +49,18 @@ class Window(PygletWindow):
|
||||||
|
|
||||||
self.to_default_position()
|
self.to_default_position()
|
||||||
|
|
||||||
|
def focus(self):
|
||||||
|
"""
|
||||||
|
Puts focus on this window by hiding and showing it again.
|
||||||
|
|
||||||
|
Note that the pyglet `activate()` method didn't work as expected here,
|
||||||
|
so that's why we have to use this workaround. This will produce a small
|
||||||
|
flicker on the window but at least reliably focuses it. It may also
|
||||||
|
offset the window position slightly.
|
||||||
|
"""
|
||||||
|
self._window.set_visible(False)
|
||||||
|
self._window.set_visible(True)
|
||||||
|
|
||||||
def to_default_position(self):
|
def to_default_position(self):
|
||||||
self.position = self.default_position
|
self.position = self.default_position
|
||||||
# Hack. Sometimes, namely when configured to open in a separate window,
|
# Hack. Sometimes, namely when configured to open in a separate window,
|
||||||
|
|
Loading…
Add table
Reference in a new issue