-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTextField.h
57 lines (44 loc) · 1.29 KB
/
TextField.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once
#ifndef TEXT_FIELD
#define TEXT_FIELD
#include "Input.h"
#include "InteractiveElement.h"
#include "RenderableElement.h"
#include "Module.h"
class TextField : public Module, public Interactive, public Renderable
{
MakeModuleOutput(TextField)
private:
int visibleCharacters = 5;
int dstCharacterSize = 8;
int characterGap = 2;
padding pad = {0,0,0,0};
float anchorX = 0, anchorY = 0;
SDL_Rect area = {0,0,0,0};
bool typing = false;
std::string capturedData = "";
protected:
void startTyping();
void stopTyping();
void PresentState();
void Update(double);
void Render(SDL_Renderer*);
public:
int maxData = -1;
size_t caret = 0; // The cursor thingy
SDL_Texture* characters = NULL;
int srcCharacterSize = 8;
int flashCycleStart = 0;
int flashCycle = 500;
TextFieldOutput<std::string> out_output;
void recalculateArea();
void setAnchor(float aX, float aY);
void setPosition(int x, int y);
void setPadding(padding pad);
void setVisibleCharacters(int size);
void setCharacterSize(int size);
void setCharacterGap(int size);
bool InArea(int x, int y) const;
TextField(ModuleRegistry& mRegistry = ModuleRegistry::globalRegistry, InteractiveRegistry& iRegistry = InteractiveRegistry::globalRegistry, RenderableRegistry& rRegistry = RenderableRegistry::globalRegistry);
};
#endif