Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
TextInput.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2025
3** Air-Trap
4** File description:
5** TextInput
6*/
7
8#pragma once
9
10#include <cstdint>
11#include <functional>
12#include <string>
13#include "RType/Math/Vec2.hpp"
14
16
17struct TextInput {
19 Vec2f size{320.0f, 45.0f};
20
21 std::string value;
22 std::string placeholder{"..."};
23 std::string fontPath{"assets/fonts/main.ttf"};
24 unsigned int fontSize{22};
25
26 bool isFocused{false};
27 bool isPassword{false};
28 std::size_t maxLength{64};
29
30 bool showCursor{true};
31 float blinkTimer{0.0f};
32 float blinkInterval{0.5f};
33
34 std::function<void(const std::string&)> onSubmit;
35 std::function<void(const std::string&)> onChange;
36
37 uint8_t bgColor[3]{30, 30, 30};
38 uint8_t borderColor[3]{120, 120, 120};
39 uint8_t focusBorderColor[3]{100, 200, 100};
40 uint8_t textColor[3]{255, 255, 255};
41 uint8_t placeholderColor[3]{150, 150, 150};
42 uint8_t alpha{255};
43 int zIndex{5};
44
45 std::string getDisplayValue() const {
46 if (!isPassword) return value;
47 return std::string(value.size(), '*');
48 }
49};
50
51} // namespace rtp::ecs::components::ui
Declaration of the 2-dimensional vector class.
File : SpritePreview.hpp License: MIT Author : GitHub Copilot Date : 14/01/2026.
Definition Button.hpp:14
std::function< void(const std::string &)> onChange
Definition TextInput.hpp:35
std::function< void(const std::string &)> onSubmit
Definition TextInput.hpp:34
std::string getDisplayValue() const
Definition TextInput.hpp:45