Support changing ui::default_element_factory close icon
This commit is contained in:
parent
3a93ddce65
commit
a1307b84b9
2 changed files with 13 additions and 4 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#include <psemek/ui/element_factory.hpp>
|
||||
|
||||
#include <psemek/util/pimpl.hpp>
|
||||
#include <psemek/gfx/pixmap.hpp>
|
||||
|
||||
namespace psemek::ui
|
||||
{
|
||||
|
|
@ -13,6 +14,8 @@ namespace psemek::ui
|
|||
default_element_factory();
|
||||
~default_element_factory();
|
||||
|
||||
void set_close_icon(gfx::pixmap_rgba const & icon);
|
||||
|
||||
std::shared_ptr<button> make_button() override;
|
||||
using element_factory::make_button;
|
||||
std::shared_ptr<frame> make_frame() override;
|
||||
|
|
|
|||
|
|
@ -234,6 +234,7 @@ namespace psemek::ui
|
|||
{
|
||||
close_button_->set_child(std::make_shared<image_view>());
|
||||
close_button_->icon()->set_image({close_texture_.get()});
|
||||
close_button_->icon()->set_downscale(false);
|
||||
|
||||
caption_->set_parent(this);
|
||||
close_button_->set_parent(this);
|
||||
|
|
@ -767,15 +768,15 @@ namespace psemek::ui
|
|||
|
||||
struct default_element_factory::impl
|
||||
{
|
||||
std::shared_ptr<gfx::texture_2d> cross_red_16x16;
|
||||
std::shared_ptr<gfx::texture_2d> close_icon;
|
||||
|
||||
impl();
|
||||
};
|
||||
|
||||
default_element_factory::impl::impl()
|
||||
{
|
||||
cross_red_16x16 = std::make_shared<gfx::texture_2d>(gfx::texture_2d::from_pixmap(gfx::read_png(io::memory_istream{resources::cross_red_16x16_png.data})));
|
||||
cross_red_16x16->nearest_filter();
|
||||
close_icon = std::make_shared<gfx::texture_2d>(gfx::texture_2d::from_pixmap(gfx::read_png(io::memory_istream{resources::cross_red_16x16_png.data})));
|
||||
close_icon->nearest_filter();
|
||||
}
|
||||
|
||||
default_element_factory::default_element_factory()
|
||||
|
|
@ -784,6 +785,11 @@ namespace psemek::ui
|
|||
|
||||
default_element_factory::~default_element_factory() = default;
|
||||
|
||||
void default_element_factory::set_close_icon(gfx::pixmap_rgba const & icon)
|
||||
{
|
||||
impl().close_icon->load(icon);
|
||||
}
|
||||
|
||||
std::shared_ptr<button> default_element_factory::make_button()
|
||||
{
|
||||
return std::make_shared<button_impl>();
|
||||
|
|
@ -796,7 +802,7 @@ namespace psemek::ui
|
|||
|
||||
std::shared_ptr<window> default_element_factory::make_window(std::string caption)
|
||||
{
|
||||
auto r = std::make_shared<window_impl>(impl().cross_red_16x16);
|
||||
auto r = std::make_shared<window_impl>(impl().close_icon);
|
||||
r->setup_close();
|
||||
r->caption()->set_text(std::move(caption));
|
||||
return r;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue