-
-
Notifications
You must be signed in to change notification settings - Fork 77
Introduce a GesturePropertyTransition #2074
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
445d730
Introduce a PropertyGestureTarget
leolost2605 725177f
Some fixes and use in workspace clone
leolost2605 d36034f
Use in WindowClone
leolost2605 2b7653d
Rename to GesturePropertyTransition, add done signal
leolost2605 a2ae8a5
Some API improvements
leolost2605 bb05871
Add documentation and allow intermediate without gesture
leolost2605 8ff631b
Better value transforms, use in windowmanager
leolost2605 6b4851d
Rename file, follow animation settings
leolost2605 0991190
Add missing file
leolost2605 377c397
Merge branch 'main' into leolost/propertygesturetarget
leolost2605 4f5db98
Fix initial window position
leolost2605 f4c9462
Fix window icon position
leolost2605 ef61a5e
Add done_callback
leolost2605 2a7c2e0
Merge branch 'main' into leolost/propertygesturetarget
leolost2605 4af996f
Fix rare crash
leolost2605 3eb95ef
Merge branch 'leolost/propertygesturetarget' of github.com:elementary…
leolost2605 f5fb15c
Merge branch 'main' into leolost/propertygesturetarget
leolost2605 3299054
Merge branch 'main' into leolost/propertygesturetarget
leolost2605 0935972
Merge branch 'main' into leolost/propertygesturetarget
lenemter 529aa13
Use `AnimationsSettings`
lenemter 2e7af0b
Merge branch 'main' into leolost/propertygesturetarget
leolost2605 6acf811
Remove done signal
leolost2605 7c34a54
Add comment
leolost2605 d423d62
Fix desktop nudge and cancel
leolost2605 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
|
|
||
|
|
||
| public class Gala.GesturePropertyTransition : Object { | ||
| public signal void done (); | ||
|
|
||
| public Clutter.Actor actor { get; construct; } | ||
| public GestureTracker gesture_tracker { get; construct; } | ||
| public string property { get; construct; } | ||
| public Value? from_value { get; construct; } | ||
| public Value to_value { get; construct; } | ||
| public bool with_gesture { get; construct; } | ||
| public Value? intermediate_value { get; construct; } | ||
|
|
||
| public GesturePropertyTransition ( | ||
| Clutter.Actor actor, | ||
| GestureTracker gesture_tracker, | ||
| string property, | ||
| Value? from_value, | ||
| Value to_value, | ||
| bool with_gesture, | ||
| Value? intermediate_value = null | ||
| ) { | ||
| Object ( | ||
| actor: actor, | ||
| gesture_tracker: gesture_tracker, | ||
| property: property, | ||
| from_value: from_value, | ||
| to_value: to_value, | ||
| with_gesture: with_gesture, | ||
| intermediate_value: intermediate_value | ||
| ); | ||
| } | ||
|
|
||
| construct { | ||
| ref (); | ||
|
|
||
| if (from_value == null) { | ||
| Value current_value; | ||
| actor.get_property (property, ref current_value); | ||
| from_value = current_value; | ||
| } | ||
|
|
||
| GestureTracker.OnBegin on_animation_begin = () => { | ||
| actor.set_property (property, from_value); | ||
| }; | ||
|
|
||
| GestureTracker.OnUpdate on_animation_update = (percentage) => { | ||
| var animation_value = GestureTracker.animation_value (value_to_float (from_value), value_to_float (intermediate_value ?? to_value), percentage); | ||
| actor.set_property (property, value_from_float (animation_value)); | ||
| }; | ||
|
|
||
| GestureTracker.OnEnd on_animation_end = (percentage, cancel_action, calculated_duration) => { | ||
| if (cancel_action) { | ||
| return; | ||
| } | ||
|
|
||
| actor.save_easing_state (); | ||
| actor.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD); | ||
| actor.set_easing_duration (calculated_duration); | ||
| actor.set_property (property, cancel_action ? from_value : to_value); | ||
| actor.restore_easing_state (); | ||
|
|
||
| done (); | ||
|
|
||
| unref (); | ||
| }; | ||
|
|
||
| if (with_gesture) { | ||
| gesture_tracker.connect_handlers (on_animation_begin, on_animation_update, on_animation_end); | ||
| } else { | ||
| on_animation_begin (0); | ||
| on_animation_end (1, false, gesture_tracker.min_animation_duration); | ||
| } | ||
| } | ||
|
|
||
| private float value_to_float (Value val) { | ||
| if (val.holds (typeof (float))) { | ||
| return val.get_float (); | ||
| } | ||
|
|
||
| if (val.holds (typeof (double))) { | ||
| return (float) val.get_double (); | ||
| } | ||
|
|
||
| if (val.holds (typeof (uint))) { | ||
| return (float) val.get_uint (); | ||
| } | ||
|
|
||
| critical ("Non numeric property specified"); | ||
| return 0; | ||
| } | ||
|
|
||
| private Value value_from_float (float f) { | ||
| var val = Value (from_value.type ()); | ||
| val.set_float (f); | ||
| return val; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.