Add XCUI expansion state and coverage tests
This commit is contained in:
@@ -64,6 +64,7 @@ bool UsesUIEditorCollectionPrimitiveColumnLayout(UIEditorCollectionPrimitiveKind
|
||||
bool IsUIEditorCollectionPrimitiveHoverable(UIEditorCollectionPrimitiveKind kind) {
|
||||
return kind == UIEditorCollectionPrimitiveKind::TreeItem ||
|
||||
kind == UIEditorCollectionPrimitiveKind::ListItem ||
|
||||
kind == UIEditorCollectionPrimitiveKind::PropertySection ||
|
||||
kind == UIEditorCollectionPrimitiveKind::FieldRow;
|
||||
}
|
||||
|
||||
|
||||
57
engine/src/UI/Widgets/UIExpansionModel.cpp
Normal file
57
engine/src/UI/Widgets/UIExpansionModel.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#include <XCEngine/UI/Widgets/UIExpansionModel.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace XCEngine {
|
||||
namespace UI {
|
||||
namespace Widgets {
|
||||
|
||||
bool UIExpansionModel::HasExpandedItems() const {
|
||||
return !m_expandedIds.empty();
|
||||
}
|
||||
|
||||
std::size_t UIExpansionModel::GetExpandedCount() const {
|
||||
return m_expandedIds.size();
|
||||
}
|
||||
|
||||
bool UIExpansionModel::IsExpanded(std::string_view id) const {
|
||||
return m_expandedIds.contains(std::string(id));
|
||||
}
|
||||
|
||||
bool UIExpansionModel::SetExpanded(std::string itemId, bool expanded) {
|
||||
return expanded
|
||||
? Expand(std::move(itemId))
|
||||
: Collapse(std::move(itemId));
|
||||
}
|
||||
|
||||
bool UIExpansionModel::Expand(std::string itemId) {
|
||||
return m_expandedIds.insert(std::move(itemId)).second;
|
||||
}
|
||||
|
||||
bool UIExpansionModel::Collapse(std::string itemId) {
|
||||
return m_expandedIds.erase(itemId) > 0u;
|
||||
}
|
||||
|
||||
bool UIExpansionModel::ToggleExpanded(std::string itemId) {
|
||||
const auto it = m_expandedIds.find(itemId);
|
||||
if (it != m_expandedIds.end()) {
|
||||
m_expandedIds.erase(it);
|
||||
return true;
|
||||
}
|
||||
|
||||
m_expandedIds.insert(std::move(itemId));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UIExpansionModel::Clear() {
|
||||
if (m_expandedIds.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_expandedIds.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Widgets
|
||||
} // namespace UI
|
||||
} // namespace XCEngine
|
||||
Reference in New Issue
Block a user