summaryrefslogtreecommitdiff
path: root/Userland/Services/WindowServer/Window.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-06-27 17:07:31 +0200
committerAndreas Kling <kling@serenityos.org>2021-06-27 19:38:11 +0200
commit6a132d8672d9569543f40bb5a72d8457e7c01d10 (patch)
treef2d5684e301fa6f8eab40e948e8bc5587edfe8a4 /Userland/Services/WindowServer/Window.cpp
parent75f870a93f7bbed7b877fa5dd11466eff7c94928 (diff)
downloadserenity-6a132d8672d9569543f40bb5a72d8457e7c01d10.zip
WindowServer+LibGUI: Allow specifying a "launch origin" for new windows
The launch_origin_rect parameter to create_window() specifies where on screen the window was launched from. It's optional, but if you provide it, the new window will have a short wireframe animation from the origin to the initial window frame rect. GUI::Window looks for the "__libgui_launch_origin_rect" environment variable. Put your launch origin rect in there with the format "<x>,<y>,<width>,<height>" and the first GUI::Window shown by the app will use that as the launch origin rect. Also it looks pretty neat, although I'm sure we can improve it. :^)
Diffstat (limited to 'Userland/Services/WindowServer/Window.cpp')
-rw-r--r--Userland/Services/WindowServer/Window.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/Userland/Services/WindowServer/Window.cpp b/Userland/Services/WindowServer/Window.cpp
index 98a33c34e9..3253f0dba8 100644
--- a/Userland/Services/WindowServer/Window.cpp
+++ b/Userland/Services/WindowServer/Window.cpp
@@ -365,6 +365,26 @@ void Window::start_minimize_animation()
m_animation->start();
}
+void Window::start_launch_animation(Gfx::IntRect const& launch_origin_rect)
+{
+ m_animation = Animation::create();
+ m_animation->set_length(150);
+ m_animation->on_update = [this, launch_origin_rect](float progress, Gfx::Painter& painter, Screen& screen, Gfx::DisjointRectSet& flush_rects) {
+ Gfx::PainterStateSaver saver(painter);
+ painter.set_draw_op(Gfx::Painter::DrawOp::Invert);
+
+ auto rect = interpolate_rect(launch_origin_rect, frame().rect(), progress);
+
+ painter.draw_rect(rect, Color::Transparent); // Color doesn't matter, we draw inverted
+ flush_rects.add(rect.intersected(screen.rect()));
+ Compositor::the().invalidate_screen(rect);
+ };
+ m_animation->on_stop = [this] {
+ m_animation = nullptr;
+ };
+ m_animation->start();
+}
+
void Window::set_opacity(float opacity)
{
if (m_opacity == opacity)