ELEC2645 (2018/19) / Mbed 2 deprecated el17ajf

Dependencies:   mbed

Fork of el17ajf by Angus Findlay

Revision:
18:24ce897024d0
Parent:
17:cc448ab7266f
Child:
19:370d83a8dc33
--- a/Menus/UI/UI.cpp	Wed Apr 03 13:37:56 2019 +0000
+++ b/Menus/UI/UI.cpp	Wed Apr 03 14:31:49 2019 +0000
@@ -40,8 +40,15 @@
     
     bool selected = buttonCurrentlyDrawing == buttonCurrentlySelected;
     
+    int wordWidth = strlen(text) * (Graphics::UI::CHAR_WIDTH + Graphics::UI::CHAR_SPACE);
+    
     if (selected) {
-        Graphics::UI::drawBorder(PADDING_X - 2, y - 2, PADDING_X + 50, y + Graphics::UI::CHAR_HEIGHT + 2);
+        Graphics::UI::drawBorder(
+            PADDING_X - 2,
+            y - 2,
+            PADDING_X + wordWidth + 2,
+            y + Graphics::UI::CHAR_HEIGHT + 1
+        );
     }
 
     return buttonPressedFrame && selected;