MCPcopy Create free account
hub / github.com/OneLoneCoder/olcPixelGameEngine / BaseControl

Class BaseControl

extensions/olcPGEX_QuickGUI.h:86–127  ·  view source on GitHub ↗

Virtual base class for all controls

Source from the content-addressed store, hash-verified

84
85 // Virtual base class for all controls
86 class BaseControl
87 {
88 public:
89 BaseControl(olc::QuickGUI::Manager& manager);
90 virtual ~BaseControl();
91
92 public:
93 // Switches the control on/off
94 void Enable(const bool bEnable);
95 // Sets whether or not the control is interactive/displayed
96 bool bVisible = true;
97
98 // True on single frame control begins being manipulated
99 bool bPressed = false;
100 // True on all frames control is under user manipulation
101 bool bHeld = false;
102 // True on single frame control ceases being manipulated
103 bool bReleased = false;
104
105 public:
106 // Updates the controls behvaiour
107 virtual void Update(olc::PixelGameEngine* pge) = 0;
108 // Draws the control using "sprite" based CPU operations
109 virtual void Draw(olc::PixelGameEngine* pge) = 0;
110 // Draws the control using "decal" based GPU operations
111 virtual void DrawDecal(olc::PixelGameEngine* pge) = 0;
112
113 protected:
114 // Controls are related to a manager, where the theme resides
115 // and control groups can be implemented
116 olc::QuickGUI::Manager& m_manager;
117
118 // All controls exists in one of four states
119 // Disabled - Greyed out and not interactive
120 // Normal - interactive and operational
121 // Hover - currently under the users mouse focus
122 // Click - user is interacting with the control
123 enum class State { Disabled, Normal, Hover, Click } m_state = State::Normal;
124
125 // To add a "swish" to things, controls can fade between states
126 float m_fTransition = 0.0;
127 };
128
129
130 // A QuickGUI::Manager acts as a convenient grouping of controls

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected