TurtleBrains  0.3.5
High quality, portable, C++ framework for rapid 2D game development.
tbx_interface.hpp
1 
9 #ifndef TurtleBrainsExpress_Interface_hpp
10 #define TurtleBrainsExpress_Interface_hpp
11 
12 #include <turtle_brains/graphics/tb_graphic.hpp>
13 
14 #include <array>
15 
16 namespace TurtleBrainsExpress
17 {
18  namespace Interface
19  {
20  namespace Unstable
21  {
22  class Element;
23  typedef tbCore::uint32 ElementHandle;
24 
25  enum class NavigationDirection
26  {
27  Up,
28  Down,
29  Left,
30  Right
31  };
32  extern const std::array<NavigationDirection, 4>& theNavigationDirections;
33  size_t DirectionToIndex(const NavigationDirection& direction);
34  NavigationDirection DirectionFromIndex(const size_t& index);
35  NavigationDirection OppositeDirection(const NavigationDirection& direction);
36 
37 
38  enum class UserEventType
39  {
40  NavigateUp,
41  NavigateDown,
42  NavigateLeft,
43  NavigateRight,
44  Accept,
45  Cancel,
46 
47  PointerMove, //Mouse or Touch
48  PointerDrag, //Mouse or Touch drag while clicked/touching
49  PrimaryPressed, //Mouse or Touch
50  PrimaryReleased, //Mouse or Touch
51  //SecondaryClick,
52  //ScrollUp,
53  //ScrollDown
54 
55  TypedCharacter, //A-Z 0-9
56  };
57 
58  struct Point
59  {
62 
63  Point(const tbGraphics::PixelSpace& valueX = 0, const tbGraphics::PixelSpace& valueY = 0);
64  };
65 
66  struct UserEvent
67  {
68  UserEventType mType;
69  //Great place to use a tbMath::VectorType<PixelSpace>
70  Point mPointerPosition;
71  tbCore::tbString mTypedCharacter;
72 
73  UserEvent(const UserEventType& type, const Point& pointerPosition = Point(0, 0),
74  const tbCore::tbString& typedCharacter = tb_string(""));
75 
76  bool IsNavigating(const NavigationDirection& direction) const;
77  };
78 
79  Element& GetMutableFocusedElement(void);
80  const Element* GetFocusedElementPointer(void);
81  const Element& GetFocusedElement(void);
82  void SetFocusedElement(Element* focusedElement);
83 
84  };
85  }; /* namespace Interface */
86 }; /* namespace TurtleBrainsExpress */
87 
89 
90 #endif /* TurtleBrainsExpress_Interface_hpp */
A collection of objects and functions to express games quickly.
Definition: tbx_interface.hpp:18
Definition: tbx_interface.hpp:58
tbCore::uint16 PixelSpace
Definition: tb_texture_manager.hpp:36
#define tb_string(object)
Definition: tb_string.hpp:28
uint32_t uint32
Unsigned integer with a size of 32 bits. Supports values from 0 to 4294967295, (2^32 - 1)...
Definition: tb_types.hpp:28
Definition: tbx_interface_element.hpp:28
std::string tbString
Definition: tb_string.hpp:335