summaryrefslogtreecommitdiffstats
path: root/gui/listbox.cpp
diff options
context:
space:
mode:
authorthat <github@that.at>2015-02-14 20:23:16 +0100
committerthat <github@that.at>2015-02-15 20:36:40 +0100
commitf6ed8fc1f51e368bb76905d9f1d2d3735e70a644 (patch)
treeba66418d418869274d259ce35cca8d4021d8ce4e /gui/listbox.cpp
parentRetain and display previous selection for image flashing (diff)
downloadandroid_bootable_recovery-f6ed8fc1f51e368bb76905d9f1d2d3735e70a644.tar
android_bootable_recovery-f6ed8fc1f51e368bb76905d9f1d2d3735e70a644.tar.gz
android_bootable_recovery-f6ed8fc1f51e368bb76905d9f1d2d3735e70a644.tar.bz2
android_bootable_recovery-f6ed8fc1f51e368bb76905d9f1d2d3735e70a644.tar.lz
android_bootable_recovery-f6ed8fc1f51e368bb76905d9f1d2d3735e70a644.tar.xz
android_bootable_recovery-f6ed8fc1f51e368bb76905d9f1d2d3735e70a644.tar.zst
android_bootable_recovery-f6ed8fc1f51e368bb76905d9f1d2d3735e70a644.zip
Diffstat (limited to 'gui/listbox.cpp')
-rw-r--r--gui/listbox.cpp31
1 files changed, 6 insertions, 25 deletions
diff --git a/gui/listbox.cpp b/gui/listbox.cpp
index 37ba958c1..7c7afa957 100644
--- a/gui/listbox.cpp
+++ b/gui/listbox.cpp
@@ -34,36 +34,17 @@ GUIListBox::GUIListBox(xml_node<>* node) : GUIScrollList(node)
xml_attribute<>* attr;
xml_node<>* child;
mIconSelected = mIconUnselected = NULL;
- int mSelectedIconWidth = 0, mSelectedIconHeight = 0, mUnselectedIconWidth = 0, mUnselectedIconHeight = 0, mIconWidth = 0, mIconHeight = 0;
mUpdate = 0;
// Get the icons, if any
child = node->first_node("icon");
if (child) {
- attr = child->first_attribute("selected");
- if (attr)
- mIconSelected = PageManager::FindResource(attr->value());
- attr = child->first_attribute("unselected");
- if (attr)
- mIconUnselected = PageManager::FindResource(attr->value());
- }
- if (mIconSelected && mIconSelected->GetResource()) {
- mSelectedIconWidth = gr_get_width(mIconSelected->GetResource());
- mSelectedIconHeight = gr_get_height(mIconSelected->GetResource());
- if (mSelectedIconHeight > mIconHeight)
- mIconHeight = mSelectedIconHeight;
- mIconWidth = mSelectedIconWidth;
- }
-
- if (mIconUnselected && mIconUnselected->GetResource()) {
- mUnselectedIconWidth = gr_get_width(mIconUnselected->GetResource());
- mUnselectedIconHeight = gr_get_height(mIconUnselected->GetResource());
- if (mUnselectedIconHeight > mIconHeight)
- mIconHeight = mUnselectedIconHeight;
- if (mUnselectedIconWidth > mIconWidth)
- mIconWidth = mUnselectedIconWidth;
+ mIconSelected = LoadAttrImage(child, "selected");
+ mIconUnselected = LoadAttrImage(child, "unselected");
}
- SetMaxIconSize(mIconWidth, mIconHeight);
+ int iconWidth = std::max(mIconSelected->GetWidth(), mIconUnselected->GetWidth());
+ int iconHeight = std::max(mIconSelected->GetHeight(), mIconUnselected->GetHeight());
+ SetMaxIconSize(iconWidth, iconHeight);
// Handle the result variable
child = node->first_node("data");
@@ -160,7 +141,7 @@ size_t GUIListBox::GetItemCount()
return mList.size();
}
-int GUIListBox::GetListItem(size_t item_index, Resource*& icon, std::string &text)
+int GUIListBox::GetListItem(size_t item_index, ImageResource*& icon, std::string &text)
{
text = mList.at(item_index).displayName;
if (mList.at(item_index).selected)