editor name filtering improvements, case-sensitive option
This commit is contained in:
+46
-18
@@ -179,7 +179,7 @@ void OptionsWindow::Create(EditorComponent* _editor)
|
||||
|
||||
|
||||
filterCombo.Create("");
|
||||
filterCombo.AddItem("", (uint64_t)Filter::All);
|
||||
filterCombo.AddItem("*", (uint64_t)Filter::All);
|
||||
filterCombo.AddItem(ICON_TRANSFORM, (uint64_t)Filter::Transform);
|
||||
filterCombo.AddItem(ICON_MATERIAL, (uint64_t)Filter::Material);
|
||||
filterCombo.AddItem(ICON_MESH, (uint64_t)Filter::Mesh);
|
||||
@@ -214,8 +214,20 @@ void OptionsWindow::Create(EditorComponent* _editor)
|
||||
filterInput.SetTooltip("Apply filtering to the Entities by name");
|
||||
filterInput.SetDescription(ICON_FILTER ": ");
|
||||
filterInput.SetCancelInputEnabled(false);
|
||||
filterInput.OnInput([=](wi::gui::EventArgs args) {
|
||||
RefreshEntityTree();
|
||||
});
|
||||
AddWidget(&filterInput);
|
||||
|
||||
filterCaseCheckBox.Create("");
|
||||
filterCaseCheckBox.SetCheckText("Aa");
|
||||
filterCaseCheckBox.SetUnCheckText("a");
|
||||
filterCaseCheckBox.SetTooltip("Toggle case-sensitive name filtering");
|
||||
filterCaseCheckBox.OnClick([=](wi::gui::EventArgs args) {
|
||||
RefreshEntityTree();
|
||||
});
|
||||
AddWidget(&filterCaseCheckBox);
|
||||
|
||||
|
||||
entityTree.Create("Entities");
|
||||
entityTree.SetSize(XMFLOAT2(300, 300));
|
||||
@@ -336,13 +348,17 @@ void OptionsWindow::ResizeLayout()
|
||||
|
||||
|
||||
|
||||
float filterHeight = filterCombo.GetSize().y;
|
||||
float filterComboWidth = 30;
|
||||
|
||||
filterInput.SetPos(XMFLOAT2(pos.x + x_off, pos.y));
|
||||
filterInput.SetSize(XMFLOAT2(width - x_off - filterInput.GetScale().y - 3 - filterComboWidth, filterCombo.GetScale().y));
|
||||
filterInput.SetSize(XMFLOAT2(width - x_off - filterHeight - 5 - filterComboWidth - filterHeight, filterCombo.GetScale().y));
|
||||
|
||||
filterCombo.SetPos(XMFLOAT2(filterInput.GetPos().x + filterInput.GetSize().x + 2, pos.y));
|
||||
filterCombo.SetSize(XMFLOAT2(filterComboWidth, filterCombo.GetScale().y));
|
||||
filterCaseCheckBox.SetPos(XMFLOAT2(filterInput.GetPos().x + filterInput.GetSize().x + 2, pos.y));
|
||||
filterCaseCheckBox.SetSize(XMFLOAT2(filterHeight, filterHeight));
|
||||
|
||||
filterCombo.SetPos(XMFLOAT2(filterCaseCheckBox.GetPos().x + filterCaseCheckBox.GetSize().x + 2, pos.y));
|
||||
filterCombo.SetSize(XMFLOAT2(filterComboWidth, filterHeight));
|
||||
pos.y += filterCombo.GetSize().y;
|
||||
pos.y += padding;
|
||||
|
||||
@@ -370,9 +386,32 @@ void OptionsWindow::PushToEntityTree(wi::ecs::Entity entity, int level)
|
||||
item.open = entitytree_opened_items.count(entity) != 0;
|
||||
|
||||
const NameComponent* name = scene.names.GetComponent(entity);
|
||||
if (name == nullptr || name->name.find(filterInput.GetCurrentInputValue()) == std::string::npos)
|
||||
|
||||
std::string name_string;
|
||||
if (name == nullptr)
|
||||
{
|
||||
return;
|
||||
name_string = "[no_name] " + std::to_string(entity);
|
||||
}
|
||||
else if (name->name.empty())
|
||||
{
|
||||
name_string = "[name_empty] " + std::to_string(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
name_string = name->name;
|
||||
}
|
||||
|
||||
std::string name_filter = filterInput.GetCurrentInputValue();
|
||||
if (!name_filter.empty())
|
||||
{
|
||||
if (filterCaseCheckBox.GetCheck() && name_string.find(name_filter) == std::string::npos)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (wi::helper::toUpper(name_string).find(wi::helper::toUpper(name_filter)) == std::string::npos)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Icons:
|
||||
@@ -504,18 +543,7 @@ void OptionsWindow::PushToEntityTree(wi::ecs::Entity entity, int level)
|
||||
}
|
||||
}
|
||||
|
||||
if (name == nullptr)
|
||||
{
|
||||
item.name += "[no_name] " + std::to_string(entity);
|
||||
}
|
||||
else if (name->name.empty())
|
||||
{
|
||||
item.name += "[name_empty] " + std::to_string(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.name += name->name;
|
||||
}
|
||||
item.name += name_string;
|
||||
entityTree.AddItem(item);
|
||||
|
||||
entitytree_added_items.insert(entity);
|
||||
|
||||
Reference in New Issue
Block a user