HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
icon_widget.hpp
1// Copyright Take Vos 2021.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "widget.hpp"
8#include "../GFX/paged_image.hpp"
9#include "../alignment.hpp"
10#include "../icon.hpp"
11#include <memory>
12#include <string>
13#include <array>
14#include <optional>
15#include <future>
16
17namespace hi::inline v1 {
18
24class icon_widget final : public widget {
25public:
26 using super = widget;
27
31
34 observable<color> color = color::foreground();
35
38 observable<alignment> alignment = hi::alignment{horizontal_alignment::center, vertical_alignment::middle};
39
40 template<typename Icon, typename Color = hi::color>
41 icon_widget(gui_window& window, widget *parent, Icon&& icon, Color&& color = color::foreground()) noexcept :
42 icon_widget(window, parent)
43 {
44 this->icon = std::forward<Icon>(icon);
45 this->color = std::forward<Color>(color);
46 }
47
49 widget_constraints const &set_constraints() noexcept override;
50 void set_layout(widget_layout const &layout) noexcept override;
51 void draw(draw_context const &context) noexcept override;
53private:
54 enum class icon_type { no, glyph, pixmap };
55
56 icon_type _icon_type;
57 glyph_ids _glyph;
58 paged_image _pixmap_backing;
59 decltype(icon)::token_type _icon_cbt;
60 std::atomic<bool> _icon_has_modified = true;
61
62 extent2 _icon_size;
63 aarectangle _icon_rectangle;
64
65 icon_widget(gui_window &window, widget *parent) noexcept;
66};
67
68} // namespace hi::inline v1
Definition alignment.hpp:64
This is a RGBA floating point color.
Definition color.hpp:39
Definition gui_window.hpp:39
An image, in different formats.
Definition icon.hpp:19
An observable value.
Definition observable.hpp:359
An simple GUI widget that displays an icon.
Definition icon_widget.hpp:24
observable< icon > icon
The icon to be displayed.
Definition icon_widget.hpp:30
An interactive graphical object as part of the user-interface.
Definition widget.hpp:39