BuGUI
BUtton Grid User Interface
Loading...
Searching...
No Matches
deleter.hpp
1#pragma once
2
3#include "widgets/base_widget.hpp"
4#include <concepts/widget.hpp>
5
6namespace bugui
7{
8template <typename T
9 , std::derived_from<base_widget> H
10 , bool can_delete = true>
11struct deleter : H
12{
13 using H::H;
14
18 bool handle_Delete() override final
19 {
20 if constexpr (has_Delete<T>)
21 {
22 static_cast<T*>(this)->on_Delete();
23 return true;
24 }
25
26 H::parent->remove_widget(this);
27 return true;
28 }
29};
30
33template <typename T, std::derived_from<base_widget> H>
34struct deleter<T, H, false> : H
35{
36 using H::H;
37
38 bool handle_Delete() override final
39 {
40 if constexpr (has_Delete<T>)
41 {
42 static_cast<T*>(this)->on_Delete();
43 return true;
44 }
45 else return false;
46 }
47};
48
49} // namespace bugui
Definition widget.hpp:63
Definition deleter.hpp:12
bool handle_Delete() override final
Calls on_Delete if defined, otherwise simply deletes the widget.
Definition deleter.hpp:18