Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of el17ajf by
Diff: Menus/UI/UI.cpp
- Revision:
- 21:62d2b5b73160
- Parent:
- 19:370d83a8dc33
- Child:
- 26:baa7077449e7
diff -r cd96f98f5f79 -r 62d2b5b73160 Menus/UI/UI.cpp
--- a/Menus/UI/UI.cpp Wed Apr 03 17:25:15 2019 +0000
+++ b/Menus/UI/UI.cpp Wed Apr 03 20:33:27 2019 +0000
@@ -1,77 +1,78 @@
#include "UI.h"
#include "Graphics.h"
-
-UI::UI() {
- reset();
-}
-
-void UI::reset() {
- buttonCurrentlySelected = 0;
-}
-
-UI::~UI() {
+namespace Menus {
+ UI::UI() {
+ reset();
+ }
+
+ void UI::reset() {
+ buttonCurrentlySelected = 0;
+ }
+
+ UI::~UI() {
+
+ }
-}
-
-void UI::clear() {
- buttonPressedFrame = false;
- nextYPos = PADDING_Y;
- buttonCurrentlyDrawing = -1;
-}
-
-void UI::drawTitle(const char * text) {
- drawLabel(text);
-}
-
-void UI::drawLabel(const char * text) {
- Graphics::UI::drawText(PADDING_X, nextY(), text);
-}
-
-void UI::newLine() {
- nextY();
-}
-
-bool UI::drawAndCheckButton(const char * text) {
- buttonCurrentlyDrawing++;
+ void UI::clear() {
+ buttonPressedFrame = false;
+ nextYPos = PADDING_Y;
+ buttonCurrentlyDrawing = -1;
+ }
- int y = nextY();
+ void UI::drawTitle(const char * text) {
+ drawLabel(text);
+ }
- Graphics::UI::drawText(PADDING_X, y, text);
+ void UI::drawLabel(const char * text) {
+ Graphics::UI::drawText(PADDING_X, nextY(), text);
+ }
+
+ void UI::newLine() {
+ nextY();
+ }
- bool selected = buttonCurrentlyDrawing == buttonCurrentlySelected;
-
- int wordWidth = strlen(text) * (Graphics::UI::CHAR_WIDTH + Graphics::UI::CHAR_SPACE) - 1;
+ bool UI::drawAndCheckButton(const char * text) {
+ buttonCurrentlyDrawing++;
+
+ int y = nextY();
+
+ Graphics::UI::drawText(PADDING_X, y, text);
+
+ bool selected = buttonCurrentlyDrawing == buttonCurrentlySelected;
+
+ int wordWidth = strlen(text) * (Graphics::UI::CHAR_WIDTH + Graphics::UI::CHAR_SPACE) - 1;
+
+ if (selected) {
+ Graphics::UI::drawBorder(
+ PADDING_X - 2,
+ y - 2,
+ PADDING_X + wordWidth + 2,
+ y + Graphics::UI::CHAR_HEIGHT + 1
+ );
+ }
- if (selected) {
- Graphics::UI::drawBorder(
- PADDING_X - 2,
- y - 2,
- PADDING_X + wordWidth + 2,
- y + Graphics::UI::CHAR_HEIGHT + 1
- );
+ return buttonPressedFrame && selected;
}
-
- return buttonPressedFrame && selected;
-}
-
-void UI::selectNextButton() {
- if (buttonCurrentlySelected < buttonCurrentlyDrawing) {
- buttonCurrentlySelected++;
+
+ void UI::selectNextButton() {
+ if (buttonCurrentlySelected < buttonCurrentlyDrawing) {
+ buttonCurrentlySelected++;
+ }
+ }
+
+ void UI::selectPreviousButton() {
+ if (buttonCurrentlySelected > 0) {
+ buttonCurrentlySelected--;
+ }
}
-}
-
-void UI::selectPreviousButton() {
- if (buttonCurrentlySelected > 0) {
- buttonCurrentlySelected--;
+
+ void UI::pressButton() {
+ buttonPressedFrame = true;
}
-}
-
-void UI::pressButton() {
- buttonPressedFrame = true;
-}
-
-int UI::nextY() {
- int currentYPos = nextYPos;
- nextYPos += Graphics::UI::CHAR_HEIGHT + LINE_PADDING;
- return currentYPos;
-}
\ No newline at end of file
+
+ int UI::nextY() {
+ int currentYPos = nextYPos;
+ nextYPos += Graphics::UI::CHAR_HEIGHT + LINE_PADDING;
+ return currentYPos;
+ }
+};
\ No newline at end of file
