/* * Copyright (c) 2018-2020, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include namespace GUI { class IconImpl : public RefCounted { public: static NonnullRefPtr create() { return adopt_ref(*new IconImpl); } ~IconImpl() { } const Gfx::Bitmap* bitmap_for_size(int) const; void set_bitmap_for_size(int, RefPtr&&); Vector sizes() const { Vector sizes; for (auto& it : m_bitmaps) sizes.append(it.key); return sizes; } private: IconImpl() { } HashMap> m_bitmaps; }; class Icon { public: Icon(); explicit Icon(RefPtr&&); explicit Icon(RefPtr&&, RefPtr&&); explicit Icon(const IconImpl&); Icon(const Icon&); ~Icon() { } static Icon default_icon(const StringView&); Icon& operator=(const Icon& other) { if (this != &other) m_impl = other.m_impl; return *this; } const Gfx::Bitmap* bitmap_for_size(int size) const { return m_impl->bitmap_for_size(size); } void set_bitmap_for_size(int size, RefPtr&& bitmap) { m_impl->set_bitmap_for_size(size, move(bitmap)); } const IconImpl& impl() const { return *m_impl; } Vector sizes() const { return m_impl->sizes(); } private: NonnullRefPtr m_impl; }; }