mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:07:45 +00:00
QuickShow: Animate animated images :^)
With a little help (read: copy & paste) from ImageWidget, QuickShow will now cycle through the frames of animated images - enjoy the cat GIFs! Future improvement: cache decoded images like LibWeb's ImageResource to waste less CPU - the same applies to LibGUI though, maybe we can put something shared in LibGfx. Closes #5837.
This commit is contained in:
parent
41e5155467
commit
10843a2c8c
3 changed files with 68 additions and 9 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021, Linus Groh <mail@linusgroh.de>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -26,12 +27,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <LibCore/Timer.h>
|
||||
#include <LibGUI/Frame.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibGfx/ImageDecoder.h>
|
||||
#include <LibGfx/Point.h>
|
||||
|
||||
class QSLabel;
|
||||
|
||||
class QSWidget final : public GUI::Frame {
|
||||
C_OBJECT(QSWidget)
|
||||
public:
|
||||
|
@ -72,18 +73,25 @@ private:
|
|||
virtual void mousewheel_event(GUI::MouseEvent&) override;
|
||||
virtual void drop_event(GUI::DropEvent&) override;
|
||||
|
||||
void set_bitmap(const Gfx::Bitmap* bitmap);
|
||||
|
||||
void relayout();
|
||||
void resize_window();
|
||||
void reset_view();
|
||||
void animate();
|
||||
|
||||
String m_path;
|
||||
RefPtr<Gfx::Bitmap> m_bitmap;
|
||||
int m_toolbar_height { 28 };
|
||||
|
||||
Gfx::IntRect m_bitmap_rect;
|
||||
int m_scale { -1 };
|
||||
Gfx::FloatPoint m_pan_origin;
|
||||
|
||||
RefPtr<Gfx::ImageDecoder> m_image_decoder;
|
||||
size_t m_current_frame_index { 0 };
|
||||
size_t m_loops_completed { 0 };
|
||||
NonnullRefPtr<Core::Timer> m_timer;
|
||||
|
||||
int m_scale { -1 };
|
||||
int m_toolbar_height { 28 };
|
||||
Gfx::FloatPoint m_pan_origin;
|
||||
Gfx::IntPoint m_click_position;
|
||||
Gfx::FloatPoint m_saved_pan_origin;
|
||||
Vector<String> m_files_in_same_dir;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue