guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
text_field.hpp
1/*
2 Copyright (c) 2026 ETIB Corporation
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy of
5 this software and associated documentation files (the "Software"), to deal in
6 the Software without restriction, including without limitation the rights to
7 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8 of the Software, and to permit persons to whom the Software is furnished to do
9 so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 SOFTWARE.
21 */
22
23#pragma once
24
25#include <string>
26
27#include "guillaume/ecs/component.hpp"
28
30{
31
53 {
54 private:
55 std::string _placeholder {};
56 std::string _label {};
57 std::string _supportingText {};
58 std::string _prefix {};
59 std::string _suffix {};
60 std::string _errorText {};
61 bool _error { false };
62 bool _labelFloating {
63 false
64 };
65
66 public:
70 TextField(void) = default;
71
75 ~TextField(void) = default;
76
81 const std::string &getPlaceholder(void) const;
82
93 TextField &setPlaceholder(const std::string &placeholder);
94
100 const std::string &getLabel(void) const;
101
111 TextField &setLabel(const std::string &label);
112
117 const std::string &getSupportingText(void) const;
118
129 TextField &setSupportingText(const std::string &supportingText);
130
135 const std::string &getPrefix(void) const;
136
144 TextField &setPrefix(const std::string &prefix);
145
150 const std::string &getSuffix(void) const;
151
159 TextField &setSuffix(const std::string &suffix);
160
166 const std::string &getErrorText(void) const;
167
177 TextField &setErrorText(const std::string &errorText);
178
183 bool isError(void) const;
184
195 TextField &setError(bool error);
196
202 bool isLabelFloating(void) const;
203
215 TextField &setLabelFloating(bool floating);
216 };
217
218} // namespace guillaume::components
bool isLabelFloating(void) const
Tell whether the label is drawn small, above the input.
bool isError(void) const
Tell whether the field is in error.
TextField & setPlaceholder(const std::string &placeholder)
Set the placeholder: the text that names the field, such as "Email".
TextField & setError(bool error)
Put the field in error or clear the error.
const std::string & getErrorText(void) const
Get the message shown under the field while it is in error.
TextField & setErrorText(const std::string &errorText)
Set the message shown under the field while it is in error.
const std::string & getPrefix(void) const
Get the fixed text shown before the input.
TextField & setLabel(const std::string &label)
Store the label.
const std::string & getSupportingText(void) const
Get the helper text shown under the field.
TextField(void)=default
Create a field with no text and no error.
const std::string & getSuffix(void) const
Get the fixed text shown after the input.
const std::string & getPlaceholder(void) const
Get the placeholder: the text that names the field.
TextField & setSupportingText(const std::string &supportingText)
Set the helper text shown under the field, such as "Atleast 8 characters".
TextField & setLabelFloating(bool floating)
Store whether the label floats above the input.
const std::string & getLabel(void) const
Get the label.
TextField & setPrefix(const std::string &prefix)
Set the fixed text shown before the input, such as "$".
~TextField(void)=default
Default destructor.
TextField & setSuffix(const std::string &suffix)
Set the fixed text shown after the input, such as "kg".
Base class of every component: a piece of state attached to an entity, plus a "changed" flag.
Definition component.hpp:72
State. Every class here is plain data attached to an entity.