Add XCUI command routing and widget state models

This commit is contained in:
2026-04-05 12:10:55 +08:00
parent 511e94fd30
commit 68c4c80b06
18 changed files with 1329 additions and 9 deletions

View File

@@ -0,0 +1,40 @@
#pragma once
#include <cstddef>
namespace XCEngine {
namespace UI {
namespace Widgets {
class UIKeyboardNavigationModel {
public:
static constexpr std::size_t InvalidIndex = static_cast<std::size_t>(-1);
std::size_t GetItemCount() const;
bool SetItemCount(std::size_t itemCount);
bool ClampToItemCount();
bool HasCurrentIndex() const;
std::size_t GetCurrentIndex() const;
bool SetCurrentIndex(std::size_t index, bool updateAnchor = true);
bool ClearCurrentIndex();
bool HasSelectionAnchor() const;
std::size_t GetSelectionAnchorIndex() const;
bool SetSelectionAnchorIndex(std::size_t index);
bool ClearSelectionAnchor();
bool MoveNext();
bool MovePrevious();
bool MoveHome();
bool MoveEnd();
private:
std::size_t m_itemCount = 0;
std::size_t m_currentIndex = InvalidIndex;
std::size_t m_selectionAnchorIndex = InvalidIndex;
};
} // namespace Widgets
} // namespace UI
} // namespace XCEngine

View File

@@ -0,0 +1,32 @@
#pragma once
#include <string>
namespace XCEngine {
namespace UI {
namespace Widgets {
class UIPropertyEditModel {
public:
bool HasActiveEdit() const;
const std::string& GetActiveFieldId() const;
const std::string& GetStagedValue() const;
bool IsDirty() const;
bool BeginEdit(std::string fieldId, std::string initialValue);
bool UpdateStagedValue(std::string stagedValue);
bool CommitEdit(
std::string* outFieldId = nullptr,
std::string* outCommittedValue = nullptr);
bool CancelEdit();
private:
std::string m_activeFieldId = {};
std::string m_baselineValue = {};
std::string m_stagedValue = {};
bool m_dirty = false;
};
} // namespace Widgets
} // namespace UI
} // namespace XCEngine