InputBox.h
1 /*
2 
3 Copyright (c) 2018, Johnathan Corkery. (jcorkery@umich.edu)
4 All rights reserved.
5 
6 This file is part of the Dynacoe project (https://github.com/jcorks/Dynacoe)
7 Dynacoe was released under the MIT License, as detailed below.
8 
9 
10 
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is furnished
16 to do so, subject to the following conditions:
17 
18 The above copyright notice and this permission notice shall
19 be included in all copies or substantial portions of the Software.
20 
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 DEALINGS IN THE SOFTWARE.
28 
29 
30 
31 */
32 
33 #ifndef INPUT_BOX_H_INCLUDED
34 #define INPUT_BOX_H_INCLUDED
35 
36 #include <Dynacoe/Entity.h>
37 #include <Dynacoe/Modules/Graphics.h>
38 #include <Dynacoe/Components/Shape2D.h>
39 #include <Dynacoe/Components/GUI.h>
40 #include <Dynacoe/Components/Text2D.h>
41 
42 namespace Dynacoe {
43 
44 
47 class InputBox : public Dynacoe::Entity {
48  public:
49 
50  InputBox();
51 
54  void Resize(int, int);
55 
58  void SetText(const std::string &);
59 
62  std::string GetText();
63 
67  void Activate(bool act=true);
68 
69 
70  protected:
71  void OnStep();
72  void OnDraw();
73 
74  private:
75 
76  static DynacoeEvent(Event_OnClick);
77 
78  GUI * gui;
79  Shape2D * bg;
80  Text2D * text2D;
81  std::string text;
82  std::string visibleText;
83  Color textColor;
84 };
85 }
86 
87 
88 #endif //INPUT_BOX_H_INCLUDED
A standard object representing an RGBA color.
Definition: Color.h:47
Basic interactive object.
Definition: Entity.h:62
void OnDraw()
Called when Draw() is called.
Aspect2D class that handles text rendering.
Definition: Text2D.h:60
void Activate(bool act=true)
Sets whether to activate the InputBox. When activated, the InputBox will accept input.
Definition: AssetID.h:37
A component that provides managed input interaction suitable for making things like buttons...
Definition: GUI.h:52
void SetText(const std::string &)
Sets the text within the InputBox.
void Resize(int, int)
Resizes the InputBox region.
Allows a user to type inside of it.
Definition: InputBox.h:47
An aspect that can express basic 2D objects, such as images and shapes.
Definition: Shape2D.h:46
std::string GetText()
Reutrns the text currently within the InputBox.
void OnStep()
Called when Step() is called.