mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:28:12 +00:00
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. :^)
This commit is contained in:
parent
75f870a93f
commit
6a132d8672
6 changed files with 46 additions and 4 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue