Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add focus() command #2241

Merged
merged 2 commits into from
Nov 25, 2024
Merged

Add focus() command #2241

merged 2 commits into from
Nov 25, 2024

Conversation

Splines
Copy link
Contributor

@Splines Splines commented Nov 10, 2024

Motivation

When working in the interactive mode, the OpenGL window might be hidden behind other programs. Therefore, we introduce a new focus() command here to focus the window. This could also be very beneficial to our Manim Notebook VSCode extension (in construction) allowing to automatically focus when previewing a Manim Cell.

Proposed changes

  • Add a focus() method to the scene.
  • Implement the focus mechanism in the window.

Unfortunately, the pyglet activate() method did not work for me (using WSL) while the proposed solution works, but produces a small flickering and also offsets the window by a small amount in the upper left direction. Maybe you know a better approach?

Test

Just take any Manim code and get into the interactive mode.

from manimlib import *


class ReloadTest(Scene):
    def construct(self):
        ## Circle creation
        circle = Circle()
        self.play(ShowCreation(circle))

        ## Circle movement
        self.play(circle.animate.shift(2 * UP + 2 * RIGHT))
manimgl ./reload_sample.py ReloadTest -se 6

Then issue the reload() command.

@Splines Splines changed the title Add new focus() command Add focus() command Nov 12, 2024
@3b1b 3b1b merged commit 314ca89 into 3b1b:master Nov 25, 2024
@3b1b
Copy link
Owner

3b1b commented Nov 25, 2024

Thanks for the contribution!

@Splines Splines deleted the feature/focus branch November 25, 2024 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants