Extract XCUI text input controller to common layer

This commit is contained in:
2026-04-05 06:33:06 +08:00
parent b4c95e4085
commit 6159eef3af
7 changed files with 354 additions and 123 deletions

View File

@@ -0,0 +1,39 @@
#pragma once
#include <XCEngine/UI/Types.h>
#include <cstddef>
#include <cstdint>
#include <string>
namespace XCEngine {
namespace UI {
namespace Text {
struct UITextInputState {
std::string value = {};
std::size_t caret = 0u;
};
struct UITextInputOptions {
bool multiline = false;
std::size_t tabWidth = 4u;
};
struct UITextInputEditResult {
bool handled = false;
bool valueChanged = false;
bool submitRequested = false;
};
void ClampCaret(UITextInputState& state);
bool InsertCharacter(UITextInputState& state, std::uint32_t character);
UITextInputEditResult HandleKeyDown(
UITextInputState& state,
std::int32_t keyCode,
const UIInputModifiers& modifiers,
const UITextInputOptions& options = {});
} // namespace Text
} // namespace UI
} // namespace XCEngine