-
Notifications
You must be signed in to change notification settings - Fork 815
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 support for env variable TEXTUAL_ANIMATIONS #4062
Changes from all commits
d1d6fe2
136da2f
fda29ea
37e7668
98d4fd2
ef55ab3
023bb33
89844e8
add06b6
66f3ec6
13c1815
15b2063
264a985
350d53b
14f83e5
6b1e166
5cb2471
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
::: textuals.constants |
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -3,7 +3,7 @@ | |||||||||||
from typing import TYPE_CHECKING | ||||||||||||
|
||||||||||||
from .._animator import Animation, EasingFunction | ||||||||||||
from .._types import CallbackType | ||||||||||||
from .._types import AnimationLevel, CallbackType | ||||||||||||
from .scalar import Scalar, ScalarOffset | ||||||||||||
|
||||||||||||
if TYPE_CHECKING: | ||||||||||||
|
@@ -23,6 +23,7 @@ def __init__( | |||||||||||
speed: float | None, | ||||||||||||
easing: EasingFunction, | ||||||||||||
on_complete: CallbackType | None = None, | ||||||||||||
level: AnimationLevel = "full", | ||||||||||||
): | ||||||||||||
assert ( | ||||||||||||
speed is not None or duration is not None | ||||||||||||
|
@@ -34,6 +35,7 @@ def __init__( | |||||||||||
self.final_value = value | ||||||||||||
self.easing = easing | ||||||||||||
self.on_complete = on_complete | ||||||||||||
self.level = level | ||||||||||||
|
||||||||||||
size = widget.outer_size | ||||||||||||
viewport = widget.app.size | ||||||||||||
|
@@ -48,11 +50,18 @@ def __init__( | |||||||||||
assert duration is not None, "Duration expected to be non-None" | ||||||||||||
self.duration = duration | ||||||||||||
|
||||||||||||
def __call__(self, time: float) -> bool: | ||||||||||||
def __call__( | ||||||||||||
self, time: float, app_animation_level: AnimationLevel = "full" | ||||||||||||
) -> bool: | ||||||||||||
factor = min(1.0, (time - self.start_time) / self.duration) | ||||||||||||
eased_factor = self.easing(factor) | ||||||||||||
|
||||||||||||
if eased_factor >= 1: | ||||||||||||
if ( | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess this sets the value to its final position, but what is to prevent the animator calling it multiple times? Anything? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah. The textual/src/textual/_animator.py Lines 528 to 532 in 16656e6
|
||||||||||||
eased_factor >= 1 | ||||||||||||
or app_animation_level == "none" | ||||||||||||
or app_animation_level == "basic" | ||||||||||||
and self.level == "full" | ||||||||||||
): | ||||||||||||
setattr(self.styles, self.attribute, self.final_value) | ||||||||||||
return True | ||||||||||||
|
||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where we need the
app.show_animations
. Could we pass it to__call__
?Alternatively, do we even need to do this logic here? The animator calls this method. Could we not perform this logic from the animator? The animator has a reference to the app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could perform the logic there but I think it's cleaner here.
If we do it on the animator, then we also need to set the attribute to its value in the animator and I think it'll look clunky there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may need to elaborate on "cleaner" and "clunky" which are quite subjective terms.
It does feel like it is the animators job to decide if to animate something. Perhaps an Animation object should grow a
finalize
method which sets the attribute to its final stage.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While addressing your other remarks I think this stopped being a problem.