combo box for enumerations [WIP]
This commit is contained in:
parent
d6cff821dd
commit
36b3872fb6
|
@ -55,7 +55,26 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
auto const& type = property.get_type();
|
auto const& type = property.get_type();
|
||||||
|
|
||||||
if (type == rttr::type::get<SHVec4>())
|
if(type.is_enumeration())
|
||||||
|
{
|
||||||
|
auto enumAlign = type.get_enumeration();
|
||||||
|
auto names = enumAlign.get_names();
|
||||||
|
std::vector<const char*> list;
|
||||||
|
for(auto const& name : names)
|
||||||
|
list.push_back(name.data());
|
||||||
|
ComboBox(property.get_name().data(), list, [component, property]{return property.get_value(component).to_int();}, [component, property](int const& idx)
|
||||||
|
{
|
||||||
|
auto enumAlign = property.get_enumeration();
|
||||||
|
auto names = enumAlign.get_names();
|
||||||
|
|
||||||
|
property.set_value(component, *(enumAlign.get_values().begin().operator++(idx)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if(type.is_arithmetic())
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (type == rttr::type::get<SHVec4>())
|
||||||
{
|
{
|
||||||
DragVec4(property.get_name().data(), { "X", "Y", "Z", "W" }, [component, property]() {return property.get_value(component).template convert<SHVec4>(); }, [component, property](SHVec4 vec) {return property.set_value(component, vec); });
|
DragVec4(property.get_name().data(), { "X", "Y", "Z", "W" }, [component, property]() {return property.get_value(component).template convert<SHVec4>(); }, [component, property](SHVec4 vec) {return property.set_value(component, vec); });
|
||||||
}
|
}
|
||||||
|
@ -67,6 +86,7 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
DragVec2(property.get_name().data(), { "X", "Y"}, [component, property]() {return property.get_value(component).template convert<SHVec2>(); }, [component, property](SHVec2 vec) {return property.set_value(component, vec); });
|
DragVec2(property.get_name().data(), { "X", "Y"}, [component, property]() {return property.get_value(component).template convert<SHVec2>(); }, [component, property](SHVec2 vec) {return property.set_value(component, vec); });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else DrawContextMenu(component);
|
else DrawContextMenu(component);
|
||||||
|
|
|
@ -293,6 +293,17 @@ namespace SHADE
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool ComboBox(const std::string& fieldLabel, std::vector<const char*> list, std::function<int(void)> get, std::function<void(int const&)> set)
|
||||||
|
{
|
||||||
|
int selected = get();
|
||||||
|
if (ImGui::Combo(fieldLabel.c_str(), &selected, list.data(), list.size()))
|
||||||
|
{
|
||||||
|
SHCommandManager::PerformCommand(std::reinterpret_pointer_cast<SHBaseCommand>(std::make_shared<SHCommand<int>>(get(), selected, set)), false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}//namespace SHADE
|
}//namespace SHADE
|
||||||
|
|
Loading…
Reference in New Issue