Extract XCUI text input controller to common layer
This commit is contained in:
39
engine/include/XCEngine/UI/Text/UITextInputController.h
Normal file
39
engine/include/XCEngine/UI/Text/UITextInputController.h
Normal 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
|
||||
Reference in New Issue
Block a user