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

animate: allow 3rd party plugins to provide additional animations #2525

Merged
merged 1 commit into from
Dec 6, 2024

Conversation

ammen99
Copy link
Member

@ammen99 ammen99 commented Nov 27, 2024

The API for it is installed in the wayfire/plugins/animate/animate.hpp header.

How it works:

  1. The external plugin providing extra animations needs to implement the actual animation by deriving from (and implementing the methods of) the animation_base_t class:
class animation_base_t
{
    virtual void init(wayfire_view view, wf::animation_description_t duration, animation_type type)
    {}

    /**
     * @return True if the animation should continue for at least one more frame.
     */
    virtual bool step()
    {
        return false;
    }

    /**
     * Reverse the animation direction (hiding -> showing, showing -> hiding)
     */
    virtual void reverse()
    {}
};
  1. The plugin can register its animation type with the animate plugin by using the animation effects registry class:
// Automatically fetches the global instance of the effects registry
wf::shared_data::ref_ptr_t<wf::animate::animate_effects_registry_t> effects_registry;

effects_registry->register_effect("coolneweffect", wf::animate::effect_description_t{
    .generator = [] { return std::make_unique<cool_new_effect_t>(); },
    .default_duration = [cfg_option] { return cfg_option->get_value(); },
});

// On unloading the plugin:
effects_registry->unregister_effect("coolneweffect");

@ammen99 ammen99 merged commit 7b44ec6 into master Dec 6, 2024
8 checks passed
@ammen99 ammen99 deleted the animate-addons branch December 6, 2024 15:54
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.

1 participant