Skip to content

Commit b8752d1

Browse files
lcolittiammen99
authored andcommitted
wf-background: Add an option to configure fade duration.
Among other things, this allows disabling fading, by setting the fade duration to zero.
1 parent f74900c commit b8752d1

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

metadata/background.xml.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
<_short>Cycle Timeout</_short>
1414
<default>150</default>
1515
</option>
16+
<option name="fade_duration" type="int">
17+
<_short>Fade Duration</_short>
18+
<default>1000</default>
19+
</option>
1620
<option name="randomize" type="bool">
1721
<_short>Randomize</_short>
1822
<default>false</default>

src/background/background.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ void BackgroundDrawingArea::show_image(Glib::RefPtr<Gdk::Pixbuf> image,
3535

3636
to_image.x = offset_x / this->get_scale_factor();
3737
to_image.y = offset_y / this->get_scale_factor();
38+
39+
fade = {
40+
fade_duration,
41+
wf::animation::smoothing::linear
42+
};
43+
3844
fade.animate(from_image.source ? 0.0 : 1.0, 1.0);
3945

4046
Glib::signal_idle().connect_once([=] ()

src/background/background.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ class BackgroundImage
1818

1919
class BackgroundDrawingArea : public Gtk::DrawingArea
2020
{
21-
wf::animation::simple_animation_t fade{
22-
wf::create_option(1000),
23-
wf::animation::smoothing::linear
24-
};
21+
wf::animation::simple_animation_t fade;
22+
WfOption<int> fade_duration{"background/fade_duration"};
23+
2524
/* These two pixbufs are used for fading one background
2625
* image to the next when changing backgrounds or when
2726
* automatically cycling through a directory of images.

0 commit comments

Comments
 (0)