41 lines
1.1 KiB
C++
41 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
namespace XCEngine {
|
|
namespace UI {
|
|
namespace Widgets {
|
|
|
|
class UISelectionModel {
|
|
public:
|
|
bool HasSelection() const;
|
|
const std::string& GetSelectedId() const;
|
|
const std::vector<std::string>& GetSelectedIds() const;
|
|
std::size_t GetSelectionCount() const;
|
|
bool HasMultipleSelection() const;
|
|
bool IsSelected(std::string_view id) const;
|
|
|
|
bool SetSelection(std::string selectionId);
|
|
bool SetSelections(
|
|
std::vector<std::string> selectionIds,
|
|
std::string primarySelectionId = {});
|
|
bool SetPrimarySelection(std::string selectionId);
|
|
bool AddSelection(std::string selectionId, bool makePrimary = false);
|
|
bool RemoveSelection(std::string_view selectionId);
|
|
bool ClearSelection();
|
|
bool ToggleSelection(std::string selectionId);
|
|
|
|
private:
|
|
static void NormalizeSelectionIds(std::vector<std::string>& selectionIds);
|
|
|
|
std::vector<std::string> m_selectedIds = {};
|
|
std::string m_primarySelectedId = {};
|
|
};
|
|
|
|
} // namespace Widgets
|
|
} // namespace UI
|
|
} // namespace XCEngine
|