mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-01 23:26:36 +00:00
Everywhere: Move the Ladybird folder to UI
This commit is contained in:
parent
93712b24bf
commit
db47cc41f8
Notes:
github-actions[bot]
2024-11-10 11:51:45 +00:00
Author: https://github.com/trflynn89
Commit: db47cc41f8
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
203 changed files with 266 additions and 244 deletions
69
UI/Qt/TVGIconEngine.h
Normal file
69
UI/Qt/TVGIconEngine.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Copyright (c) 2023, MacDue <macdue@dueutil.tech>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Function.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibGfx/ImageFormats/TinyVGLoader.h>
|
||||
|
||||
#include <QIconEngine>
|
||||
|
||||
namespace Ladybird {
|
||||
|
||||
class TVGIconEngine : public QIconEngine {
|
||||
public:
|
||||
TVGIconEngine(Gfx::TinyVGDecodedImageData const& image_data)
|
||||
: m_image_data(image_data)
|
||||
{
|
||||
}
|
||||
|
||||
static TVGIconEngine* from_file(QString const& path);
|
||||
|
||||
void paint(QPainter* painter, QRect const& rect, QIcon::Mode mode,
|
||||
QIcon::State state) override;
|
||||
QIconEngine* clone() const override;
|
||||
QPixmap pixmap(QSize const& size, QIcon::Mode mode,
|
||||
QIcon::State state) override;
|
||||
|
||||
void add_filter(QIcon::Mode mode, Function<Color(Color)> filter);
|
||||
|
||||
private:
|
||||
static unsigned next_cache_id()
|
||||
{
|
||||
static unsigned cache_id = 0;
|
||||
return cache_id++;
|
||||
}
|
||||
|
||||
void invalidate_cache()
|
||||
{
|
||||
m_cache_id = next_cache_id();
|
||||
}
|
||||
|
||||
class Filter : public RefCounted<Filter> {
|
||||
public:
|
||||
Filter(QIcon::Mode mode, Function<Color(Color)> function)
|
||||
: m_mode(mode)
|
||||
, m_function(move(function))
|
||||
{
|
||||
}
|
||||
QIcon::Mode mode() const { return m_mode; }
|
||||
Function<Color(Color)> const& function() const { return m_function; }
|
||||
|
||||
private:
|
||||
QIcon::Mode m_mode;
|
||||
Function<Color(Color)> m_function;
|
||||
};
|
||||
|
||||
QString pixmap_cache_key(QSize const& size, QIcon::Mode mode, QIcon::State state);
|
||||
|
||||
Vector<NonnullRefPtr<Filter>> m_filters;
|
||||
NonnullRefPtr<Gfx::TinyVGDecodedImageData> m_image_data;
|
||||
unsigned m_cache_id { next_cache_id() };
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue