summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authorDees_Troy <dees_troy@teamw.in>2013-02-27 23:21:41 +0100
committerDees_Troy <dees_troy@teamw.in>2013-02-27 23:21:41 +0100
commit58f5cf0ab5dfc3c002103b9e34e0e117e1ca8ffd (patch)
treeb2035b2b4ccb6b5d546b1ad9a0e21a203cba07f2 /gui
parentAdd fast scroll bar to fileselector (diff)
downloadandroid_bootable_recovery-58f5cf0ab5dfc3c002103b9e34e0e117e1ca8ffd.tar
android_bootable_recovery-58f5cf0ab5dfc3c002103b9e34e0e117e1ca8ffd.tar.gz
android_bootable_recovery-58f5cf0ab5dfc3c002103b9e34e0e117e1ca8ffd.tar.bz2
android_bootable_recovery-58f5cf0ab5dfc3c002103b9e34e0e117e1ca8ffd.tar.lz
android_bootable_recovery-58f5cf0ab5dfc3c002103b9e34e0e117e1ca8ffd.tar.xz
android_bootable_recovery-58f5cf0ab5dfc3c002103b9e34e0e117e1ca8ffd.tar.zst
android_bootable_recovery-58f5cf0ab5dfc3c002103b9e34e0e117e1ca8ffd.zip
Diffstat (limited to 'gui')
-rw-r--r--gui/listbox.cpp95
-rw-r--r--gui/objects.hpp8
2 files changed, 101 insertions, 2 deletions
diff --git a/gui/listbox.cpp b/gui/listbox.cpp
index 263f82f90..605172348 100644
--- a/gui/listbox.cpp
+++ b/gui/listbox.cpp
@@ -48,6 +48,8 @@ GUIListBox::GUIListBox(xml_node<>* node)
mHeaderSeparatorH = mLineHeight = mHeaderIsStatic = mHeaderH = actualLineHeight = 0;
mIconSelected = mIconUnselected = mBackground = mFont = mHeaderIcon = NULL;
mBackgroundX = mBackgroundY = mBackgroundW = mBackgroundH = 0;
+ mFastScrollW = mFastScrollLineW = mFastScrollRectW = mFastScrollRectH = 0;
+ mFastScrollRectX = mFastScrollRectY = -1;
mUpdate = 0;
touchDebounce = 6;
ConvertStrToColor("black", &mBackgroundColor);
@@ -56,6 +58,8 @@ GUIListBox::GUIListBox(xml_node<>* node)
ConvertStrToColor("black", &mHeaderSeparatorColor);
ConvertStrToColor("white", &mFontColor);
ConvertStrToColor("white", &mHeaderFontColor);
+ ConvertStrToColor("white", &mFastScrollLineColor);
+ ConvertStrToColor("white", &mFastScrollRectColor);
hasHighlightColor = false;
hasFontHighlightColor = false;
isHighlighted = false;
@@ -215,6 +219,43 @@ GUIListBox::GUIListBox(xml_node<>* node)
DataManager::SetValue(mVariable, attr->value());
}
+ // Fast scroll colors
+ child = node->first_node("fastscroll");
+ if (child)
+ {
+ attr = child->first_attribute("linecolor");
+ if(attr)
+ ConvertStrToColor(attr->value(), &mFastScrollLineColor);
+
+ attr = child->first_attribute("rectcolor");
+ if(attr)
+ ConvertStrToColor(attr->value(), &mFastScrollRectColor);
+
+ attr = child->first_attribute("w");
+ if (attr) {
+ string parsevalue = gui_parse_text(attr->value());
+ mFastScrollW = atoi(parsevalue.c_str());
+ }
+
+ attr = child->first_attribute("linew");
+ if (attr) {
+ string parsevalue = gui_parse_text(attr->value());
+ mFastScrollLineW = atoi(parsevalue.c_str());
+ }
+
+ attr = child->first_attribute("rectw");
+ if (attr) {
+ string parsevalue = gui_parse_text(attr->value());
+ mFastScrollRectW = atoi(parsevalue.c_str());
+ }
+
+ attr = child->first_attribute("recth");
+ if (attr) {
+ string parsevalue = gui_parse_text(attr->value());
+ mFastScrollRectH = atoi(parsevalue.c_str());
+ }
+ }
+
// Retrieve the line height
gr_getFontDetails(mFont ? mFont->GetResource() : NULL, &mFontHeight, NULL);
mLineHeight = mFontHeight;
@@ -314,11 +355,14 @@ int GUIListBox::Render(void)
int line;
int listSize = mList.size();
+ int listW = mRenderW;
if (listSize < lines) {
lines = listSize;
scrollingY = 0;
+ mFastScrollRectX = mFastScrollRectY = -1;
} else {
+ listW -= mFastScrollW; // space for fast scroll
lines++;
if (lines < listSize)
lines++;
@@ -397,12 +441,12 @@ int GUIListBox::Render(void)
rect_y = currentIconHeight;
gr_blit(icon->GetResource(), 0, 0, currentIconWidth, rect_y, mRenderX + currentIconOffsetX, image_y);
}
- gr_textExWH(mRenderX + mIconWidth + 5, yPos + fontOffsetY, label.c_str(), fontResource, mRenderX + mRenderW, mRenderY + mRenderH);
+ gr_textExWH(mRenderX + mIconWidth + 5, yPos + fontOffsetY, label.c_str(), fontResource, mRenderX + listW, mRenderY + mRenderH);
// Add the separator
if (yPos + actualLineHeight < mRenderH + mRenderY) {
gr_color(mSeparatorColor.red, mSeparatorColor.green, mSeparatorColor.blue, 255);
- gr_fill(mRenderX, yPos + actualLineHeight - mSeparatorH, mRenderW, mSeparatorH);
+ gr_fill(mRenderX, yPos + actualLineHeight - mSeparatorH, listW, mSeparatorH);
}
// Move the yPos
@@ -437,6 +481,27 @@ int GUIListBox::Render(void)
gr_fill(mRenderX, yPos + mHeaderH - mHeaderSeparatorH, mRenderW, mHeaderSeparatorH);
}
+ // render fast scroll
+ lines = (mRenderH - mHeaderH) / (actualLineHeight);
+ if(mFastScrollW > 0 && listSize > lines)
+ {
+ int startX = listW + mRenderX;
+ int fWidth = mRenderW - listW;
+ int fHeight = mRenderH - mHeaderH;
+
+ // line
+ gr_color(mFastScrollLineColor.red, mFastScrollLineColor.green, mFastScrollLineColor.blue, 255);
+ gr_fill(startX + fWidth/2, mRenderY + mHeaderH, mFastScrollLineW, mRenderH - mHeaderH);
+
+ // rect
+ int pct = ((mStart*actualLineHeight - scrollingY)*100)/((listSize)*actualLineHeight-lines*actualLineHeight);
+ mFastScrollRectX = startX + (fWidth - mFastScrollRectW)/2;
+ mFastScrollRectY = mRenderY+mHeaderH + ((fHeight - mFastScrollRectH)*pct)/100;
+
+ gr_color(mFastScrollRectColor.red, mFastScrollRectColor.green, mFastScrollRectColor.blue, 255);
+ gr_fill(mFastScrollRectX, mFastScrollRectY, mFastScrollRectW, mFastScrollRectH);
+ }
+
mUpdate = 0;
return 0;
}
@@ -551,6 +616,32 @@ int GUIListBox::NotifyTouch(TOUCH_STATE state, int x, int y)
break;
}
+ // Fast scroll
+ if(mFastScrollRectX != -1 && x >= mRenderX + mRenderW - mFastScrollW)
+ {
+ int pct = ((y-mRenderY-mHeaderH)*100)/(mRenderH-mHeaderH);
+ int totalSize = mList.size();
+ int lines = (mRenderH - mHeaderH) / (actualLineHeight);
+
+ float l = float((totalSize-lines)*pct)/100;
+ if(l + lines >= totalSize)
+ {
+ mStart = totalSize - lines;
+ scrollingY = 0;
+ }
+ else
+ {
+ mStart = l;
+ scrollingY = -(l - int(l))*actualLineHeight;
+ }
+
+ startSelection = -1;
+ mUpdate = 1;
+ scrollingSpeed = 0;
+ isHighlighted = false;
+ break;
+ }
+
// Provide some debounce on initial touches
if (startSelection != -1 && abs(y - startY) < touchDebounce) {
isHighlighted = true;
diff --git a/gui/objects.hpp b/gui/objects.hpp
index 86353685a..8e0cc94f2 100644
--- a/gui/objects.hpp
+++ b/gui/objects.hpp
@@ -550,6 +550,12 @@ protected:
int mLineSpacing;
int mUpdate;
int mBackgroundX, mBackgroundY, mBackgroundW, mBackgroundH, mHeaderH;
+ int mFastScrollW;
+ int mFastScrollLineW;
+ int mFastScrollRectW;
+ int mFastScrollRectH;
+ int mFastScrollRectX;
+ int mFastScrollRectY;
int mIconWidth, mIconHeight, mSelectedIconWidth, mSelectedIconHeight, mUnselectedIconWidth, mUnselectedIconHeight, mHeaderIconHeight, mHeaderIconWidth;
int scrollingSpeed;
int scrollingY;
@@ -567,6 +573,8 @@ protected:
COLOR mHeaderFontColor;
COLOR mSeparatorColor;
COLOR mHeaderSeparatorColor;
+ COLOR mFastScrollLineColor;
+ COLOR mFastScrollRectColor;
bool hasHighlightColor;
bool hasFontHighlightColor;
bool isHighlighted;