Skip to content

Commit

Permalink
plugins: use the new animation option type from wf-config
Browse files Browse the repository at this point in the history
  • Loading branch information
ammen99 committed Mar 13, 2024
1 parent 390aff1 commit aa95a6c
Show file tree
Hide file tree
Showing 30 changed files with 68 additions and 73 deletions.
20 changes: 10 additions & 10 deletions metadata/animate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,48 +53,48 @@
<_long>Specifies the window types to be animated.</_long>
<default>(type equals "toplevel" | (type equals "x-or" &amp; focusable equals true))</default>
</option>
<option name="duration" type="int">
<option name="duration" type="animation">
<_short>Duration</_short>
<_long>Sets the duration of the animation in milliseconds.</_long>
<default>400</default>
<default>400ms</default>
</option>
<option name="startup_duration" type="int">
<option name="startup_duration" type="animation">
<_short>System fade duration when Wayfire starts</_short>
<_long>Sets the duration of fading (in milliseconds) when Wayfire starts.</_long>
<default>600</default>
<default>600ms linear</default>
</option>
<!-- Fade animation -->
<option name="fade_enabled_for" type="string">
<_short>Fade animation enabled for specified window types</_short>
<_long>Specifies the window types to be animated with a fade effect.</_long>
<default>type equals "overlay"</default>
</option>
<option name="fade_duration" type="int">
<option name="fade_duration" type="animation">
<_short>Fade duration</_short>
<_long>Sets the duration for the _fade_ animation in milliseconds. Only applies for windows matched by `animate.fade_enabled_for`.</_long>
<default>400</default>
<default>400ms</default>
</option>
<!-- Zoom animation -->
<option name="zoom_enabled_for" type="string">
<_short>Zoom animation enabled for specified window types</_short>
<_long>Specifies the window types to be animated with a zoom effect.</_long>
<default>none</default>
</option>
<option name="zoom_duration" type="int">
<option name="zoom_duration" type="animation">
<_short>Zoom duration</_short>
<_long>Sets the duration for the _zoom_ animation in milliseconds. Only applies for windows matched by `animate.zoom_enabled_for`.</_long>
<default>500</default>
<default>500ms circle</default>
</option>
<!-- Fire animation -->
<option name="fire_enabled_for" type="string">
<_short>Fire animation enabled for specified window types</_short>
<_long>Specifies the window types to be animated with a fire effect.</_long>
<default>none</default>
</option>
<option name="fire_duration" type="int">
<option name="fire_duration" type="animation">
<_short>Fire duration</_short>
<_long>Sets the duration for the _fire_ animation in milliseconds. Only applies for windows matched by `animate.fire_enabled_for`.</_long>
<default>300</default>
<default>300ms linear</default>
</option>
<option name="fire_particles" type="int">
<_short>Fire particles</_short>
Expand Down
4 changes: 2 additions & 2 deletions metadata/cube.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@
<default>0.1</default>
<precision>0.01</precision>
</option>
<option name="initial_animation" type="int">
<option name="initial_animation" type="animation">
<_short>Duration</_short>
<_long>Sets the initial animation duration in milliseconds.</_long>
<default>350</default>
<default>350ms</default>
</option>
<!-- Velocity -->
<option name="speed_zoom" type="double">
Expand Down
4 changes: 2 additions & 2 deletions metadata/expo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
<_long>Sets the background color.</_long>
<default>0.1 0.1 0.1 1.0</default>
</option>
<option name="duration" type="int">
<option name="duration" type="animation">
<_short>Zoom duration</_short>
<_long>Sets the zoom duration in milliseconds.</_long>
<default>300</default>
<default>300ms circle</default>
</option>
<option name="offset" type="int">
<_short>Delimiter offset</_short>
Expand Down
4 changes: 2 additions & 2 deletions metadata/grid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<_short>Grid</_short>
<_long>A plugin to position the windows in certain regions of the output.</_long>
<category>Window Management</category>
<option name="duration" type="int">
<option name="duration" type="animation">
<_short>Duration</_short>
<_long>Sets the duration of the animation in milliseconds.</_long>
<default>300</default>
<default>300ms</default>
</option>
<option name="type" type="string">
<_short>Type</_short>
Expand Down
4 changes: 2 additions & 2 deletions metadata/scale.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
<_long>Toggles scale showing windows from all workspaces.</_long>
<default></default>
</option>
<option name="duration" type="int">
<option name="duration" type="animation">
<_short>Animation Transition Time</_short>
<_long>Time it takes for views to transition. Units are in milliseconds.</_long>
<default>750</default>
<default>750ms</default>
<min>0</min>
</option>
<option name="allow_zoom" type="bool">
Expand Down
2 changes: 1 addition & 1 deletion metadata/simple-tile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<_long>Number of pixels to shrink of a view when it has no neighbor above or below.</_long>
<default>0</default>
</option>
<option name="animation_duration" type="int">
<option name="animation_duration" type="animation">
<_short>Resize animation duration</_short>
<_long>The duration of the crossfade animation in situations where a tiled view's geometry changes.</_long>
<default>0</default>
Expand Down
2 changes: 1 addition & 1 deletion metadata/switcher.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<default>&lt;alt&gt; &lt;shift&gt; KEY_TAB</default>
</option>
<!-- Effects -->
<option name="speed" type="int">
<option name="speed" type="animation">
<_short>Duration</_short>
<_long>Sets the duration of the animation in milliseconds.</_long>
<default>500</default>
Expand Down
4 changes: 2 additions & 2 deletions metadata/vswipe.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
<_long>Enables or disables smooth transition.</_long>
<default>false</default>
</option>
<option name="duration" type="int">
<option name="duration" type="animation">
<_short>Duration</_short>
<_long>Sets the duration of the animation in milliseconds.</_long>
<default>180</default>
<default>180ms</default>
</option>
<option name="background" type="color">
<_short>Background color</_short>
Expand Down
2 changes: 1 addition & 1 deletion metadata/vswitch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
</entry>
</option>

<option name="duration" type="int">
<option name="duration" type="animation">
<_short>Duration</_short>
<_long>Sets the duration of the workspace switching animation in milliseconds.</_long>
<default>300</default>
Expand Down
4 changes: 2 additions & 2 deletions metadata/wsets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
<_long>A binding to move the currently focused window to the workspace set #N.</_long>
<entry prefix="send_to_wset_" type="activator"/>
</option>
<option name="label_duration" type="int">
<option name="label_duration" type="animation">
<_short>Label duration</_short>
<_long>Sets the duration in milliseconds for which the workspace set label is shown.</_long>
<default>2000</default>
<default>2s linear</default>
</option>
</plugin>
</wayfire>
4 changes: 2 additions & 2 deletions metadata/zoom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
<default>0.01</default>
<precision>0.001</precision>
</option>
<option name="smoothing_duration" type="int">
<option name="smoothing_duration" type="animation">
<_short>Smoothing duration</_short>
<_long>Sets the smoothing duration in milliseconds.</_long>
<default>300</default>
<default>300ms linear</default>
</option>
<option name="interpolation_method" type="int">
<_short>Interpolation method</_short>
Expand Down
22 changes: 10 additions & 12 deletions plugins/animate/animate.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#include <cstddef>
#include <wayfire/per-output-plugin.hpp>
#include <wayfire/output.hpp>
#include <wayfire/signal-definitions.hpp>
#include <wayfire/render-manager.hpp>
#include <wayfire/workspace-set.hpp>
#include <type_traits>
#include <map>
#include <wayfire/core.hpp>
#include "animate.hpp"
#include "system_fade.hpp"
Expand All @@ -19,7 +17,7 @@
#include "wayfire/view.hpp"
#include <wayfire/matcher.hpp>

void animation_base::init(wayfire_view, int, wf_animation_type)
void animation_base::init(wayfire_view, wf::animation_description_t, wf_animation_type)
{}
bool animation_base::step()
{
Expand Down Expand Up @@ -122,7 +120,7 @@ struct animation_hook : public animation_hook_base
set_output(view->get_output());
};

animation_hook(wayfire_view view, int duration, wf_animation_type type,
animation_hook(wayfire_view view, wf::animation_description_t duration, wf_animation_type type,
std::string name)
{
this->type = type;
Expand Down Expand Up @@ -269,12 +267,12 @@ class wayfire_animation : public wf::plugin_interface_t, private wf::per_output_
wf::option_wrapper_t<std::string> open_animation{"animate/open_animation"};
wf::option_wrapper_t<std::string> close_animation{"animate/close_animation"};

wf::option_wrapper_t<int> default_duration{"animate/duration"};
wf::option_wrapper_t<int> fade_duration{"animate/fade_duration"};
wf::option_wrapper_t<int> zoom_duration{"animate/zoom_duration"};
wf::option_wrapper_t<int> fire_duration{"animate/fire_duration"};
wf::option_wrapper_t<wf::animation_description_t> default_duration{"animate/duration"};
wf::option_wrapper_t<wf::animation_description_t> fade_duration{"animate/fade_duration"};
wf::option_wrapper_t<wf::animation_description_t> zoom_duration{"animate/zoom_duration"};
wf::option_wrapper_t<wf::animation_description_t> fire_duration{"animate/fire_duration"};

wf::option_wrapper_t<int> startup_duration{"animate/startup_duration"};
wf::option_wrapper_t<wf::animation_description_t> startup_duration{"animate/startup_duration"};

wf::view_matcher_t animation_enabled_for{"animate/enabled_for"};
wf::view_matcher_t fade_enabled_for{"animate/fade_enabled_for"};
Expand Down Expand Up @@ -308,7 +306,7 @@ class wayfire_animation : public wf::plugin_interface_t, private wf::per_output_
struct view_animation_t
{
std::string animation_name;
int duration;
wf::animation_description_t duration;
};

view_animation_t get_animation_for_view(
Expand Down Expand Up @@ -337,7 +335,7 @@ class wayfire_animation : public wf::plugin_interface_t, private wf::per_output_
return {anim_type, default_duration};
}

return {"none", 0};
return {"none", wf::animation_description_t{0, {}, ""}};
}

bool try_reverse(wayfire_view view, wf_animation_type type, std::string name,
Expand All @@ -359,7 +357,7 @@ class wayfire_animation : public wf::plugin_interface_t, private wf::per_output_

template<class animation_t>
void set_animation(wayfire_view view,
wf_animation_type type, int duration, std::string name)
wf_animation_type type, wf::animation_description_t duration, std::string name)
{
name = "animation-hook-" + name;

Expand Down
2 changes: 1 addition & 1 deletion plugins/animate/animate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ enum wf_animation_type
class animation_base
{
public:
virtual void init(wayfire_view view, int duration, wf_animation_type type);
virtual void init(wayfire_view view, wf::animation_description_t duration, wf_animation_type type);
virtual bool step(); /* return true if continue, false otherwise */
virtual void reverse(); /* reverse the animation */
virtual int get_direction();
Expand Down
8 changes: 4 additions & 4 deletions plugins/animate/basic_animations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class fade_animation : public animation_base

public:

void init(wayfire_view view, int dur, wf_animation_type type) override
void init(wayfire_view view, wf::animation_description_t dur, wf_animation_type type) override
{
this->view = view;
this->progression =
wf::animation::simple_animation_t(wf::create_option<int>(dur));
wf::animation::simple_animation_t(wf::create_option<wf::animation_description_t>(dur));

this->progression.animate(start, end);

Expand Down Expand Up @@ -81,10 +81,10 @@ class zoom_animation : public animation_base

public:

void init(wayfire_view view, int dur, wf_animation_type type) override
void init(wayfire_view view, wf::animation_description_t dur, wf_animation_type type) override
{
this->view = view;
this->progression = zoom_animation_t(wf::create_option<int>(dur));
this->progression = zoom_animation_t(wf::create_option<wf::animation_description_t>(dur));
this->progression.alpha = wf::animation::timed_transition_t(
this->progression, 0, 1);
this->progression.zoom = wf::animation::timed_transition_t(
Expand Down
9 changes: 4 additions & 5 deletions plugins/animate/fire/fire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "wayfire/view-transform.hpp"

#include <memory>
#include <thread>
#include <wayfire/output.hpp>
#include <wayfire/core.hpp>
#include <glm/gtc/matrix_transform.hpp>
Expand Down Expand Up @@ -234,14 +233,14 @@ static float fire_duration_mod_for_height(int height)
return std::min(height / 400.0, 3.0);
}

void FireAnimation::init(wayfire_view view, int dur, wf_animation_type type)
void FireAnimation::init(wayfire_view view, wf::animation_description_t dur, wf_animation_type type)
{
this->view = view;

auto bbox = view->get_transformed_node()->get_bounding_box();
int msec = dur * fire_duration_mod_for_height(bbox.height);
this->progression = wf::animation::simple_animation_t(wf::create_option<int>(
msec), wf::animation::smoothing::linear);
dur.length_ms *= fire_duration_mod_for_height(bbox.height);
this->progression = wf::animation::simple_animation_t(
wf::create_option<wf::animation_description_t>(dur));
this->progression.animate(0, 1);

if (type & HIDING_ANIMATION)
Expand Down
4 changes: 1 addition & 3 deletions plugins/animate/fire/fire.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

#include <wayfire/view-transform.hpp>
#include <wayfire/render-manager.hpp>
#include <memory>

#include "../animate.hpp"

class FireTransformer;
Expand All @@ -19,7 +17,7 @@ class FireAnimation : public animation_base
public:

~FireAnimation();
void init(wayfire_view view, int duration, wf_animation_type type) override;
void init(wayfire_view view, wf::animation_description_t, wf_animation_type type) override;
bool step() override; /* return true if continue, false otherwise */
void reverse() override; /* reverse the animation */
};
Expand Down
6 changes: 3 additions & 3 deletions plugins/animate/system_fade.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <wayfire/output.hpp>
#include <wayfire/opengl.hpp>
#include <wayfire/render-manager.hpp>
#include "animate.hpp"
#include <wayfire/util/duration.hpp>

/* animates wake from suspend/startup by fading in the whole output */
class wf_system_fade
Expand All @@ -17,8 +17,8 @@ class wf_system_fade
wf::effect_hook_t damage_hook, render_hook;

public:
wf_system_fade(wf::output_t *out, int dur) :
progression(wf::create_option<int>(dur)), output(out)
wf_system_fade(wf::output_t *out, wf::animation_description_t dur) :
progression(wf::create_option<wf::animation_description_t>(dur)), output(out)
{
damage_hook = [=] ()
{ output->render->damage_whole(); };
Expand Down
2 changes: 1 addition & 1 deletion plugins/cube/cube.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class cube_animation_t : public duration_t

struct wf_cube_animation_attribs
{
wf::option_wrapper_t<int> animation_duration{"cube/initial_animation"};
wf::option_wrapper_t<wf::animation_description_t> animation_duration{"cube/initial_animation"};
cube_animation_t cube_animation{animation_duration};

glm::mat4 projection, view;
Expand Down
3 changes: 1 addition & 2 deletions plugins/grid/grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <wayfire/workarea.hpp>
#include <wayfire/workspace-set.hpp>
#include <wayfire/render-manager.hpp>
#include <algorithm>
#include <cmath>
#include <linux/input-event-codes.h>
#include "wayfire/plugin.hpp"
Expand Down Expand Up @@ -33,7 +32,7 @@ nonstd::observer_ptr<wf::grid::grid_animation_t> ensure_grid_view(wayfire_toplev
if (!view->has_data<wf::grid::grid_animation_t>())
{
wf::option_wrapper_t<std::string> animation_type{"grid/type"};
wf::option_wrapper_t<int> duration{"grid/duration"};
wf::option_wrapper_t<wf::animation_description_t> duration{"grid/duration"};

wf::grid::grid_animation_t::type_t type = wf::grid::grid_animation_t::NONE;
if (animation_type.value() == "crossfade")
Expand Down
2 changes: 1 addition & 1 deletion plugins/grid/wayfire/plugins/crossfade.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class grid_animation_t : public wf::custom_data_t
* @param duration Indicates the duration of the animation (only for crossfade)
*/
grid_animation_t(wayfire_toplevel_view view, type_t type,
wf::option_sptr_t<int> duration)
wf::option_sptr_t<wf::animation_description_t> duration)
{
this->view = view;
this->output = view->get_output();
Expand Down
Loading

0 comments on commit aa95a6c

Please sign in to comment.