14#include <lagrange/ui/Entity.h>
15#include <lagrange/ui/api.h>
16#include <lagrange/ui/utils/pair_hash.h>
22entt::id_type register_tool_type(
23 const std::string& display_name,
24 const std::string& icon,
25 const std::string& keybind)
27 using namespace entt::literals;
30 .prop(
"display_name"_hs, display_name)
31 .prop(
"icon"_hs, icon)
32 .prop(
"keybind"_hs, keybind);
34 return entt::type_id<T>().hash();
44 template <
typename ToolType,
typename ElementType>
45 void register_tool(
const System& tool_system)
47 const auto k = key<ToolType, ElementType>();
48 m_tool_systems[k] = tool_system;
50 if (std::find(m_tool_types.begin(), m_tool_types.end(), k.first) == m_tool_types.end()) {
51 m_tool_types.push_back(k.first);
54 if (std::find(m_element_types.begin(), m_element_types.end(), k.second) ==
55 m_element_types.end()) {
56 m_element_types.push_back(k.second);
60 template <
typename ToolType,
typename ElementType>
61 void run(Registry& registry)
63 m_tool_systems[key<ToolType, ElementType>()](registry);
66 void run(entt::id_type tool_type, entt::id_type element_type, Registry& registry);
69 bool run_current(Registry& registry);
72 const std::vector<entt::id_type>& get_element_types()
const;
73 const std::vector<entt::id_type>& get_tool_types()
const;
75 std::vector<entt::id_type>& get_element_types();
76 std::vector<entt::id_type>& get_tool_types();
78 entt::id_type get_current_tool_type()
const;
79 entt::id_type get_current_element_type()
const;
81 bool has_backface_selection_tool()
const;
82 void enable_backface_selection_tool(
bool has_backfaces_tool);
84 void set_current_element_type(entt::id_type element_type);
86 void set_current_tool_type(entt::id_type tool_type);
89 void set_current_element_type()
91 set_current_element_type(entt::type_id<T>().hash());
95 void set_current_tool_type()
97 set_current_tool_type(entt::type_id<T>().hash());
101 using KeyType = std::pair<entt::id_type, entt::id_type>;
103 template <
typename ToolType,
typename ElementType>
104 static constexpr KeyType key()
106 return {entt::type_id<ToolType>().hash(), entt::type_id<ElementType>().hash()};
108 std::unordered_map<KeyType, System, utils::pair_hash> m_tool_systems;
109 std::vector<entt::id_type> m_tool_types;
110 std::vector<entt::id_type> m_element_types;
112 KeyType m_current_key = {0, 0};
114 bool m_has_backface_selection_tool =
true;
Lagrange UI Viewer and mini 3D engine.
Definition: AcceleratedPicking.h:22
Main namespace for Lagrange.
Definition: AABBIGL.h:30