Skip to content

Commit

Permalink
Merge branch 'main' into docoptions
Browse files Browse the repository at this point in the history
  • Loading branch information
jeertmans committed Dec 24, 2024
2 parents 8553cd4 + 2169938 commit 14863e8
Show file tree
Hide file tree
Showing 19 changed files with 1,900 additions and 1,241 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: actions/checkout@v4

- name: Setup uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v4
with:
enable-cache: true

Expand Down
12 changes: 3 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,10 @@ jobs:
uses: actions/checkout@v4

- name: Setup uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v4
with:
enable-cache: true

- name: Setup Python ${{ matrix.pyversion }}
run: uv python install ${{ matrix.pyversion }}

- name: Install manim dependencies on MacOS
if: matrix.os == 'macos-latest'
run: brew install ffmpeg py3cairo pango pkg-config scipy
Expand All @@ -96,14 +93,11 @@ jobs:
if: matrix.os == 'windows-latest'
uses: ssciwr/setup-mesa-dist-win@v2

- name: Install Manim Slides
run: uv sync --locked --extra tests

- name: Run pytest
run: uv run pytest
run: uv run --python ${{ matrix.pyversion }} --frozen --extra tests pytest

- name: Upload to codecov.io
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ repos:
exclude: poetry.lock
args: [--autofix, --trailing-commas]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.1
rev: v0.8.4
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
rev: v1.14.0
hooks:
- id: mypy
additional_dependencies: [types-requests, types-setuptools]
Expand Down
41 changes: 38 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
<!-- start changelog -->

(unreleased)=
## [Unreleased](https://github.com/jeertmans/manim-slides/compare/v5.1.9...HEAD)
## [Unreleased](https://github.com/jeertmans/manim-slides/compare/v5.2.0...HEAD)

(unreleased-added)=
(v5.2.0)=
## [v5.2.0](https://github.com/jeertmans/manim-slides/compare/v5.1.10...v5.2.0)

(v5.2.0-changed)=
### Changed

- The info window is now only shown in presentations when there
are multiple monitors. However, the `--show-info-window` option
was added to `manim-slides present` to force the info window.
When there are multiple monitors, the info window will no longer
be on the same monitor as the main window, unless overridden.
[@PeculiarProgrammer](https://github.com/PeculiarProgrammer)
[#482](https://github.com/jeertmans/manim-slides/pull/482)

(v5.2.0-chore)=
### Chore

- Bump ManimGL to `>=1.7.1`, to remove conflicting dependencies
with Manim's.
[#499](https://github.com/jeertmans/manim-slides/pull/499)

(v5.1.10)=
## [v5.1.10](https://github.com/jeertmans/manim-slides/compare/v5.1.9...v5.1.10)

(v5.1.10-added)=
### Added

- Added `--offline` option to `manim-slides convert` for offline
Expand All @@ -20,12 +44,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
when using `--show-config`.
[#485](https://github.com/jeertmans/manim-slides/pull/485)

(unreleased-changed)=
(v5.1.10-changed)=
### Changed

- Allow multiple slide reverses by going backward [@PeculiarProgrammer](https://github.com/PeculiarProgrammer).
[#488](https://github.com/jeertmans/manim-slides/pull/488)

(v5.1.10-fixed)=
### Fixed

- Fixed PyAV issue by pinning its version to `<14`.
A future release will contain a fix that supports both `av>=14`
and `av<14`, as their syntax differ, but the former doesn't
provide binary wheels for Python 3.9.
[#494](https://github.com/jeertmans/manim-slides/pull/494)
- Fixed blank web page when converting multiple slides into HTML.
[#497](https://github.com/jeertmans/manim-slides/pull/497)

(v5.1.9)=
## [v5.1.9](https://github.com/jeertmans/manim-slides/compare/v5.1.8...v5.1.9)

Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ keywords:
- PowerPoint
- Python
license: MIT
version: v5.1.9
version: v5.2.0
preferred-citation:
publisher:
name: The Open Journal
Expand Down
9 changes: 2 additions & 7 deletions docs/source/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,8 @@ ManimGL support is only guaranteed to work
on a very minimal set of versions, because it differs quite a lot from ManimCE,
and its development is not very active.

The typical issues are that (1) ManimGL needs an outdated NumPy version
and (2) ManimGL **should not** be installed from the GitHub repository,
at least not from the `main` branch, but from a version released to PyPI.

To solve the NumPy issue, you can safely downgrade NumPy to a version supported
by ManimGL,
while ignoring the possible *conflicting dependencies* messages from `pip` (or else).
The typical issue is that ManimGL `<1.7.1` needs an outdated NumPy version, but
can be resolved by manually downgrading NumPy, or upgrading ManimGL (**recommended**).

### Presenting

Expand Down
13 changes: 0 additions & 13 deletions docs/source/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,6 @@ please refer to their specific installation guidelines:
- [Manim](https://docs.manim.community/en/stable/installation.html)
- [ManimGL](https://3b1b.github.io/manim/getting_started/installation.html)

:::{warning}
If you install Manim from its git repository, as suggested by ManimGL,
make sure to first check out a supported version (e.g., `git checkout tags/v1.6.1`
for ManimGL), otherwise it might install an unsupported version of Manim!
See [#314](https://github.com/jeertmans/manim-slides/issues/314).

Also, note that ManimGL uses outdated dependencies, and may
not work out-of-the-box. One example is NumPy: ManimGL
does not specify any restriction on this package, but
only `numpy<1.25` will work, see
[#2053](https://github.com/3b1b/manim/issues/2053).
:::

<!-- end deps -->

## Pip Install
Expand Down
2 changes: 1 addition & 1 deletion manim_slides/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "5.1.9"
__version__ = "5.2.0"
1 change: 1 addition & 0 deletions manim_slides/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ def prefix(i: int) -> str:
get_duration_ms=get_duration_ms,
has_notes=has_notes,
env=os.environ,
prefix=prefix if not self.data_uri else None,
**options,
)

Expand Down
44 changes: 33 additions & 11 deletions manim_slides/present/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import signal
import sys
from pathlib import Path
from typing import Optional
from typing import Literal, Optional

import click
from click import Context, Parameter
Expand Down Expand Up @@ -222,20 +222,28 @@ def str_to_int_or_none(value: str) -> Optional[int]:
)
@click.option(
"--hide-info-window",
is_flag=True,
help="Hide info window.",
flag_value="always",
help="Hide info window. By default, hide the info window if there is only one screen.",
)
@click.option(
"--show-info-window",
"hide_info_window",
flag_value="never",
help="Force to show info window.",
)
@click.option(
"--info-window-screen",
"info_window_screen_number",
metavar="NUMBER",
type=int,
default=None,
help="Put info window on the given screen (a.k.a. display).",
help="Put info window on the given screen (a.k.a. display). "
"If there is more than one screen, it will by default put the info window "
"on a different screen than the main player.",
)
@click.help_option("-h", "--help")
@verbosity_option
def present(
def present( # noqa: C901
scenes: list[str],
config_path: Path,
folder: Path,
Expand All @@ -251,7 +259,7 @@ def present(
screen_number: Optional[int],
playback_rate: float,
next_terminates_loop: bool,
hide_info_window: bool,
hide_info_window: Optional[Literal["always", "never"]],
info_window_screen_number: Optional[int],
) -> None:
"""
Expand Down Expand Up @@ -294,22 +302,36 @@ def present(
app = qapp()
app.setApplicationName("Manim Slides")

screens = app.screens()

def get_screen(number: int) -> Optional[QScreen]:
try:
return app.screens()[number]
return screens[number]
except IndexError:
logger.error(
f"Invalid screen number {number}, "
f"allowed values are from 0 to {len(app.screens())-1} (incl.)"
f"allowed values are from 0 to {len(screens)-1} (incl.)"
)
return None

should_hide_info_window = False

if hide_info_window is None:
should_hide_info_window = len(screens) == 1
elif hide_info_window == "always":
should_hide_info_window = True

if should_hide_info_window and info_window_screen_number is not None:
logger.warning(
f"Ignoring `--info-window-screen` because `--hide-info-window` is set to `{hide_info_window}`."
)

if screen_number is not None:
screen = get_screen(screen_number)
else:
screen = None

if info_window_screen_number is not None:
if info_window_screen_number is not None and not should_hide_info_window:
info_window_screen = get_screen(info_window_screen_number)
else:
info_window_screen = None
Expand All @@ -333,11 +355,11 @@ def get_screen(number: int) -> Optional[QScreen]:
screen=screen,
playback_rate=playback_rate,
next_terminates_loop=next_terminates_loop,
hide_info_window=hide_info_window,
hide_info_window=should_hide_info_window,
info_window_screen=info_window_screen,
)

player.show()
player.show(screens)

signal.signal(signal.SIGINT, signal.SIG_DFL)
sys.exit(app.exec())
28 changes: 21 additions & 7 deletions manim_slides/present/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class Info(QWidget): # type: ignore[misc]
def __init__(
self,
*,
full_screen: bool,
aspect_ratio_mode: Qt.AspectRatioMode,
screen: Optional[QScreen],
) -> None:
Expand All @@ -38,9 +37,6 @@ def __init__(
self.setScreen(screen)
self.move(screen.geometry().topLeft())

if full_screen:
self.setWindowState(Qt.WindowFullScreen)

layout = QHBoxLayout()

# Current slide view
Expand Down Expand Up @@ -243,7 +239,6 @@ def __init__(
self.slide_changed.connect(self.slide_changed_callback)

self.info = Info(
full_screen=full_screen,
aspect_ratio_mode=aspect_ratio_mode,
screen=info_window_screen,
)
Expand Down Expand Up @@ -484,11 +479,28 @@ def preview_next_slide(self) -> None:
self.info.next_media_player.setSource(url)
self.info.next_media_player.play()

def show(self) -> None:
def show(self, screens: list[QScreen]) -> None:
"""Screens is necessary to prevent the info window from being shown on the same screen as the main window (especially in full screen mode)."""
super().show()

if not self.hide_info_window:
self.info.show()
if len(screens) > 1 and self.isFullScreen():
self.ensure_different_screens(screens)

if self.isFullScreen():
self.info.showFullScreen()
else:
self.info.show()

if (
len(screens) > 1 and self.info.screen() == self.screen()
): # It is better when Qt assigns the location, but if it fails to, this is a fallback
self.ensure_different_screens(screens)

def ensure_different_screens(self, screens: list[QScreen]) -> None:
target_screen = screens[1] if self.screen() == screens[0] else screens[0]
self.info.setScreen(target_screen)
self.info.move(target_screen.geometry().topLeft())

@Slot()
def close(self) -> None:
Expand Down Expand Up @@ -538,8 +550,10 @@ def play_pause(self) -> None:
def full_screen(self) -> None:
if self.windowState() == Qt.WindowFullScreen:
self.setWindowState(Qt.WindowNoState)
self.info.setWindowState(Qt.WindowNoState)
else:
self.setWindowState(Qt.WindowFullScreen)
self.info.setWindowState(Qt.WindowFullScreen)

@Slot()
def hide_mouse(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion manim_slides/slide/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__all__ = [
"API_NAME",
"MANIM",
"MANIMGL",
"API_NAME",
"Slide",
"ThreeDSlide",
]
Expand Down
Loading

0 comments on commit 14863e8

Please sign in to comment.