gui: keyboard: support longpress label offset, code cleanup
To position the longpress label:
<longpress font="..." textcolor="..." x="5" y="0"/>
x and y is the distance from the upper right corner.
- extract method GUIKeyboard::DrawKey
- clean up handling of currently pressed key
- integrate key highlighting into main key drawing loops
Change-Id: I80ccf2975d30cffa2a48627a74ab3693c84e4fa4
diff --git a/gui/objects.hpp b/gui/objects.hpp
index 881b390..be1f973 100644
--- a/gui/objects.hpp
+++ b/gui/objects.hpp
@@ -853,6 +853,7 @@
};
int ParseKey(const char* keyinfo, Key& key, int& Xindex, int keyWidth, bool longpress);
void LoadKeyLabels(xml_node<>* parent, int layout);
+ void DrawKey(Key& key, int keyX, int keyY, int keyW, int keyH);
enum {
MAX_KEYBOARD_LAYOUTS = 5,
@@ -886,7 +887,8 @@
std::string mVariable;
int currentLayout;
bool CapsLockOn;
- int rowY, colX, highlightRenderCount;
+ int highlightRenderCount;
+ Key* currentKey;
bool hasHighlight, hasCapsHighlight;
COLOR mHighlightColor;
COLOR mCapsHighlightColor;
@@ -895,6 +897,7 @@
FontResource* mFont; // for main key labels
FontResource* mSmallFont; // for key labels like "?123"
FontResource* mLongpressFont; // for the small longpress label in the upper right corner
+ int longpressOffsetX, longpressOffsetY; // distance of the longpress label from the key corner
COLOR mLongpressFontColor;
COLOR mBackgroundColor; // keyboard background color
COLOR mKeyColorAlphanumeric; // key background color