summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xgui/devices/1024x600/res/ui.xml1
-rw-r--r--gui/devices/1024x768/res/ui.xml1
-rw-r--r--gui/devices/1280x800/res/ui.xml1
-rw-r--r--gui/devices/1920x1200/res/ui.xml1
-rw-r--r--gui/devices/320x480/res/ui.xml1
-rw-r--r--gui/devices/480x800/res/ui.xml1
-rw-r--r--gui/devices/480x854/res/ui.xml1
-rw-r--r--gui/devices/540x960/res/ui.xml1
-rw-r--r--gui/devices/720x1280/res/ui.xml1
-rwxr-xr-xgui/devices/800x1280/res/ui.xml1
-rwxr-xr-xgui/devices/800x480/res/ui.xml1
-rw-r--r--gui/keyboard.cpp90
-rw-r--r--gui/objects.hpp2
-rw-r--r--gui/pages.cpp29
14 files changed, 117 insertions, 15 deletions
diff --git a/gui/devices/1024x600/res/ui.xml b/gui/devices/1024x600/res/ui.xml
index 9873669ef..2542a1868 100755
--- a/gui/devices/1024x600/res/ui.xml
+++ b/gui/devices/1024x600/res/ui.xml
@@ -364,6 +364,7 @@
<object type="keyboard">
<placement x="0" y="341" />
<layout resource1="keyboard1" resource2="keyboard2" resource3="keyboard3" resource4="keyboard4" />
+ <highlight color="#90909080" />
<layout1>
<keysize height="65" width="92" />
<row1 key01="q" long01="1" key02="w" long02="2" key03="e" long03="3" key04="r" long04="4" key05="t" long05="5" key06="y" long06="6" key07="u" long07="7" key08="i" long08="8" key09="o" long09="9" key10="p" long10="0" key11="104:c:8" />
diff --git a/gui/devices/1024x768/res/ui.xml b/gui/devices/1024x768/res/ui.xml
index ab269c1f4..af14bc219 100644
--- a/gui/devices/1024x768/res/ui.xml
+++ b/gui/devices/1024x768/res/ui.xml
@@ -364,6 +364,7 @@
<object type="keyboard">
<placement x="0" y="408" />
<layout resource1="keyboard1" resource2="keyboard2" resource3="keyboard3" resource4="keyboard4" />
+ <highlight color="#90909080" />
<layout1>
<keysize height="90" width="85" />
<row1 key01="80:" key02="q" long02="1" key03="w" long03="2" key04="e" long04="3" key05="r" long05="4" key06="t" long06="5" key07="y" long07="6" key08="u" long08="7" key09="i" long09="8" key10="o" long10="9" key11="p" long11="0" key12="94:c:8" />
diff --git a/gui/devices/1280x800/res/ui.xml b/gui/devices/1280x800/res/ui.xml
index 8b9503def..14f2b77fc 100644
--- a/gui/devices/1280x800/res/ui.xml
+++ b/gui/devices/1280x800/res/ui.xml
@@ -364,6 +364,7 @@
<object type="keyboard">
<placement x="0" y="438" />
<layout resource1="keyboard1" resource2="keyboard2" resource3="keyboard3" resource4="keyboard4" />
+ <highlight color="#90909080" />
<layout1>
<keysize height="91" width="106" />
<row1 key01="102:" key02="q" long02="1" key03="w" long03="2" key04="e" long04="3" key05="r" long05="4" key06="t" long06="5" key07="y" long07="6" key08="u" long08="7" key09="i" long09="8" key10="o" long10="9" key11="p" long11="0" key12="118:c:8" />
diff --git a/gui/devices/1920x1200/res/ui.xml b/gui/devices/1920x1200/res/ui.xml
index 3220dc045..62c07d626 100644
--- a/gui/devices/1920x1200/res/ui.xml
+++ b/gui/devices/1920x1200/res/ui.xml
@@ -364,6 +364,7 @@
<object type="keyboard">
<placement x="0" y="684" />
<layout resource1="keyboard1" resource2="keyboard2" resource3="keyboard3" resource4="keyboard4" />
+ <highlight color="#90909080" />
<layout1>
<keysize height="129" width="159" />
<row1 key01="153:" key02="q" long02="1" key03="w" long03="2" key04="e" long04="3" key05="r" long05="4" key06="t" long06="5" key07="y" long07="6" key08="u" long08="7" key09="i" long09="8" key10="o" long10="9" key11="p" long11="0" key12="177:c:8" />
diff --git a/gui/devices/320x480/res/ui.xml b/gui/devices/320x480/res/ui.xml
index 3231f5f10..04807cdbb 100644
--- a/gui/devices/320x480/res/ui.xml
+++ b/gui/devices/320x480/res/ui.xml
@@ -321,6 +321,7 @@
<object type="keyboard">
<placement x="0" y="253" />
<layout resource1="keyboard1" resource2="keyboard2" resource3="keyboard3" resource4="keyboard4" />
+ <highlight color="#90909080" />
<layout1>
<keysize height="52" width="32" />
<row1 key01="q" long01="1" key02="w" long02="2" key03="e" long03="3" key04="r" long04="4" key05="t" long05="5" key06="y" long06="6" key07="u" long07="7" key08="i" long08="8" key09="o" long09="9" key10="p" long10="0" />
diff --git a/gui/devices/480x800/res/ui.xml b/gui/devices/480x800/res/ui.xml
index 3d6b8799e..5ac411310 100644
--- a/gui/devices/480x800/res/ui.xml
+++ b/gui/devices/480x800/res/ui.xml
@@ -320,6 +320,7 @@
<object type="keyboard">
<placement x="0" y="450" />
<layout resource1="keyboard1" resource2="keyboard2" resource3="keyboard3" resource4="keyboard4" />
+ <highlight color="#90909080" />
<layout1>
<keysize height="78" width="48" />
<row1 key01="q" long01="1" key02="w" long02="2" key03="e" long03="3" key04="r" long04="4" key05="t" long05="5" key06="y" long06="6" key07="u" long07="7" key08="i" long08="8" key09="o" long09="9" key10="p" long10="0" />
diff --git a/gui/devices/480x854/res/ui.xml b/gui/devices/480x854/res/ui.xml
index 1733b90b8..7593601d8 100644
--- a/gui/devices/480x854/res/ui.xml
+++ b/gui/devices/480x854/res/ui.xml
@@ -319,6 +319,7 @@
<object type="keyboard">
<placement x="0" y="504" />
<layout resource1="keyboard1" resource2="keyboard2" resource3="keyboard3" resource4="keyboard4" />
+ <highlight color="#90909080" />
<layout1>
<keysize height="78" width="48" />
<row1 key01="q" long01="1" key02="w" long02="2" key03="e" long03="3" key04="r" long04="4" key05="t" long05="5" key06="y" long06="6" key07="u" long07="7" key08="i" long08="8" key09="o" long09="9" key10="p" long10="0" />
diff --git a/gui/devices/540x960/res/ui.xml b/gui/devices/540x960/res/ui.xml
index 5a82579c0..587ccc72c 100644
--- a/gui/devices/540x960/res/ui.xml
+++ b/gui/devices/540x960/res/ui.xml
@@ -320,6 +320,7 @@
<object type="keyboard">
<placement x="0" y="600" />
<layout resource1="keyboard1" resource2="keyboard2" resource3="keyboard3" resource4="keyboard4" />
+ <highlight color="#90909080" />
<layout1>
<keysize height="78" width="54" />
<row1 key01="q" long01="1" key02="w" long02="2" key03="e" long03="3" key04="r" long04="4" key05="t" long05="5" key06="y" long06="6" key07="u" long07="7" key08="i" long08="8" key09="o" long09="9" key10="p" long10="0" />
diff --git a/gui/devices/720x1280/res/ui.xml b/gui/devices/720x1280/res/ui.xml
index 5490accc5..1c16783ac 100644
--- a/gui/devices/720x1280/res/ui.xml
+++ b/gui/devices/720x1280/res/ui.xml
@@ -325,6 +325,7 @@
<object type="keyboard">
<placement x="0" y="800" />
<layout resource1="keyboard1" resource2="keyboard2" resource3="keyboard3" resource4="keyboard4" />
+ <highlight color="#90909080" />
<layout1>
<keysize height="106" width="72" />
<row1 key01="q" long01="1" key02="w" long02="2" key03="e" long03="3" key04="r" long04="4" key05="t" long05="5" key06="y" long06="6" key07="u" long07="7" key08="i" long08="8" key09="o" long09="9" key10="p" long10="0" />
diff --git a/gui/devices/800x1280/res/ui.xml b/gui/devices/800x1280/res/ui.xml
index a86c7d6a3..0a9290e3c 100755
--- a/gui/devices/800x1280/res/ui.xml
+++ b/gui/devices/800x1280/res/ui.xml
@@ -321,6 +321,7 @@
<object type="keyboard">
<placement x="0" y="740" />
<layout resource1="keyboard1" resource2="keyboard2" resource3="keyboard3" resource4="keyboard4" />
+ <highlight color="#90909080" />
<layout1>
<keysize height="115" width="80" />
<row1 key01="q" long01="1" key02="w" long02="2" key03="e" long03="3" key04="r" long04="4" key05="t" long05="5" key06="y" long06="6" key07="u" long07="7" key08="i" long08="8" key09="o" long09="9" key10="p" long10="0" />
diff --git a/gui/devices/800x480/res/ui.xml b/gui/devices/800x480/res/ui.xml
index dc7324635..53530d58e 100755
--- a/gui/devices/800x480/res/ui.xml
+++ b/gui/devices/800x480/res/ui.xml
@@ -364,6 +364,7 @@
<object type="keyboard">
<placement x="0" y="277" />
<layout resource1="keyboard1" resource2="keyboard2" resource3="keyboard3" resource4="keyboard4" />
+ <highlight color="#90909080" />
<layout1>
<keysize height="51" width="73" />
<row1 key01="q" long01="1" key02="w" long02="2" key03="e" long03="3" key04="r" long04="4" key05="t" long05="5" key06="y" long06="6" key07="u" long07="7" key08="i" long08="8" key09="o" long09="9" key10="p" long10="0" key11="70:c:8" />
diff --git a/gui/keyboard.cpp b/gui/keyboard.cpp
index 6595d8da2..f44e56357 100644
--- a/gui/keyboard.cpp
+++ b/gui/keyboard.cpp
@@ -1,4 +1,24 @@
-// keyboard.cpp - GUIKeyboard object
+/* keyboard.cpp - GUIKeyboard object
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * The code was written from scratch by Dees_Troy dees_troy at
+ * yahoo
+ *
+ * Copyright (c) 2012
+ */
#include <stdarg.h>
#include <stdio.h>
@@ -30,6 +50,8 @@ GUIKeyboard::GUIKeyboard(xml_node<>* node)
: Conditional(node)
{
int layoutindex, rowindex, keyindex, Xindex, Yindex, keyHeight = 0, keyWidth = 0;
+ rowY = colX = -1;
+ highlightRenderCount = hasHighlight = 0;
char resource[9], layout[7], row[4], key[5], longpress[6];
xml_attribute<>* attr;
xml_node<>* child;
@@ -53,6 +75,17 @@ GUIKeyboard::GUIKeyboard(xml_node<>* node)
mAction = new GUIAction(node);
}
+ memset(&mHighlightColor, 0, sizeof(COLOR));
+ child = node->first_node("highlight");
+ if (child) {
+ attr = child->first_attribute("color");
+ if (attr) {
+ hasHighlight = 1;
+ std::string color = attr->value();
+ ConvertStrToColor(color, &mHighlightColor);
+ }
+ }
+
// Load the images for the different layouts
child = node->first_node("layout");
if (child)
@@ -294,7 +327,26 @@ int GUIKeyboard::Render(void)
if (keyboardImg[currentLayout - 1] && keyboardImg[currentLayout - 1]->GetResource())
gr_blit(keyboardImg[currentLayout - 1]->GetResource(), 0, 0, KeyboardWidth, KeyboardHeight, mRenderX, mRenderY);
- mRendered = true;
+ if (hasHighlight && highlightRenderCount != 0) {
+ int boxheight, boxwidth, x;
+ if (rowY == 0)
+ boxheight = row_heights[currentLayout - 1][rowY];
+ else
+ boxheight = row_heights[currentLayout - 1][rowY] - row_heights[currentLayout - 1][rowY - 1];
+ if (colX == 0) {
+ x = mRenderX;
+ boxwidth = keyboard_keys[currentLayout - 1][rowY][colX].end_x;
+ } else {
+ x = mRenderX + keyboard_keys[currentLayout - 1][rowY][colX - 1].end_x;
+ boxwidth = keyboard_keys[currentLayout - 1][rowY][colX].end_x - keyboard_keys[currentLayout - 1][rowY][colX - 1].end_x;
+ }
+ gr_color(mHighlightColor.red, mHighlightColor.green, mHighlightColor.blue, mHighlightColor.alpha);
+ gr_fill(x, mRenderY + row_heights[currentLayout - 1][rowY - 1], boxwidth, boxheight);
+ if (highlightRenderCount > 0)
+ highlightRenderCount--;
+ } else
+ mRendered = true;
+
return ret;
}
@@ -323,7 +375,7 @@ int GUIKeyboard::SetRenderPos(int x, int y, int w, int h)
int GUIKeyboard::GetSelection(int x, int y)
{
- if (x < mRenderX || x - mRenderX > KeyboardWidth || y < mRenderY || y - mRenderY > KeyboardHeight) return -1;
+ if (x < mRenderX || x - mRenderX > (int)KeyboardWidth || y < mRenderY || y - mRenderY > (int)KeyboardHeight) return -1;
return 0;
}
@@ -349,6 +401,7 @@ int GUIKeyboard::NotifyTouch(TOUCH_STATE state, int x, int y)
for (indexy=0; indexy<MAX_KEYBOARD_ROWS; indexy++) {
if (row_heights[currentLayout - 1][indexy] > rely) {
rowIndex = indexy;
+ rowY = indexy;
indexy = MAX_KEYBOARD_ROWS;
}
}
@@ -358,10 +411,19 @@ int GUIKeyboard::NotifyTouch(TOUCH_STATE state, int x, int y)
if (keyboard_keys[currentLayout - 1][rowIndex][indexx].end_x > relx) {
// This is the key that was pressed!
initial_key = keyboard_keys[currentLayout - 1][rowIndex][indexx].key;
+ colX = indexx;
indexx = MAX_KEYBOARD_KEYS;
}
}
+ if (initial_key != 0)
+ highlightRenderCount = -1;
+ else
+ highlightRenderCount = 0;
+ mRendered = false;
} else {
+ if (highlightRenderCount != 0)
+ mRendered = false;
+ highlightRenderCount = 0;
startSelection = 0;
}
break;
@@ -369,9 +431,17 @@ int GUIKeyboard::NotifyTouch(TOUCH_STATE state, int x, int y)
break;
case TOUCH_RELEASE:
if (x < startX - (KeyboardWidth * 0.5)) {
+ if (highlightRenderCount != 0) {
+ highlightRenderCount = 0;
+ mRendered = false;
+ }
PageManager::NotifyKeyboard(KEYBOARD_SWIPE_LEFT);
return 0;
} else if (x > startX + (KeyboardWidth * 0.5)) {
+ if (highlightRenderCount != 0) {
+ highlightRenderCount = 0;
+ mRendered = false;
+ }
PageManager::NotifyKeyboard(KEYBOARD_SWIPE_RIGHT);
return 0;
}
@@ -379,8 +449,19 @@ int GUIKeyboard::NotifyTouch(TOUCH_STATE state, int x, int y)
case TOUCH_HOLD:
case TOUCH_REPEAT:
- if (startSelection == 0 || GetSelection(x, y) == -1)
+ if (startSelection == 0 || GetSelection(x, y) == -1) {
+ if (highlightRenderCount != 0) {
+ highlightRenderCount = 0;
+ mRendered = false;
+ }
return 0;
+ } else if (highlightRenderCount != 0) {
+ if (state == TOUCH_RELEASE)
+ highlightRenderCount = 2;
+ else
+ highlightRenderCount = -1;
+ mRendered = false;
+ }
// Find the correct row
for (indexy=0; indexy<MAX_KEYBOARD_ROWS; indexy++) {
@@ -408,6 +489,7 @@ int GUIKeyboard::NotifyTouch(TOUCH_STATE state, int x, int y)
mRendered = false;
} else if ((int)keyboard_keys[currentLayout - 1][rowIndex][indexx].key == KEYBOARD_ACTION) {
// Action
+ highlightRenderCount = 0;
if (mAction) {
// Keyboard has its own action defined
return (mAction ? mAction->NotifyTouch(state, x, y) : 1);
diff --git a/gui/objects.hpp b/gui/objects.hpp
index 8f7823663..c310b369a 100644
--- a/gui/objects.hpp
+++ b/gui/objects.hpp
@@ -675,7 +675,9 @@ protected:
unsigned int currentLayout;
unsigned int row_heights[MAX_KEYBOARD_LAYOUTS][MAX_KEYBOARD_ROWS];
unsigned int KeyboardWidth, KeyboardHeight;
+ int rowY, colX, highlightRenderCount, hasHighlight;
GUIAction* mAction;
+ COLOR mHighlightColor;
};
// GUIInput - Used for keyboard input
diff --git a/gui/pages.cpp b/gui/pages.cpp
index 7e9274def..c4a65b43a 100644
--- a/gui/pages.cpp
+++ b/gui/pages.cpp
@@ -54,17 +54,24 @@ int ConvertStrToColor(std::string str, COLOR* color)
if (str[0] != '#') return -1;
str.erase(0, 1);
- int result = strtol(str.c_str(), NULL, 16);
- if (str.size() > 6)
- {
- // We have alpha channel
- color->alpha = result & 0x000000FF;
- result = result >> 8;
- }
- color->red = (result >> 16) & 0x000000FF;
- color->green = (result >> 8) & 0x000000FF;
- color->blue = result & 0x000000FF;
- return 0;
+ int result;
+ if (str.size() >= 8) {
+ // We have alpha channel
+ string alpha = str.substr(6, 2);
+ result = strtol(alpha.c_str(), NULL, 16);
+ color->alpha = result & 0x000000FF;
+ str.resize(6);
+ result = strtol(str.c_str(), NULL, 16);
+ color->red = (result >> 16) & 0x000000FF;
+ color->green = (result >> 8) & 0x000000FF;
+ color->blue = result & 0x000000FF;
+ } else {
+ result = strtol(str.c_str(), NULL, 16);
+ color->red = (result >> 16) & 0x000000FF;
+ color->green = (result >> 8) & 0x000000FF;
+ color->blue = result & 0x000000FF;
+ }
+ return 0;
}
// Helper APIs