Some more work on list with header

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8614 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2011-05-17 00:49:57 +00:00
parent 3cee2ddbe3
commit 5041199771
13 changed files with 37 additions and 5 deletions

View File

@@ -2,7 +2,7 @@
Glass skin by Marianne Gagnon, released under creative-commons BY-SA 3.0+
Except background.jpg, by elisee
Except left_arrow and right_arrow by Dakal
Except left_arrow, right_arrow and list_sort_up by Dakal
To make your own skin, I suggest simply duplicating this file and modifying it as needed.
There are two types of images : some will be simply stretched as a whole, others will
@@ -177,6 +177,10 @@ when the border that intersect at this corner are enabled.
<element type="left_arrow" state="focus" image="glass/left_arrow_focus.png" />
<element type="right_arrow" state="focus" image="glass/right_arrow_focus.png" />
<element type="list_header" state="neutral" image="glass/table_header.png" />
<element type="list_header" state="down" image="glass/table_header_down.png" />
<element type="list_sort_up" state="neutral" image="glass/list_sort_up.png" />
<!-- Stateless -->
<element type="section" image="glass/glass_section.png"
left_border="15" right_border="15" top_border="15" bottom_border="15"

View File

@@ -176,6 +176,10 @@ when the border that intersect at this corner are enabled.
<element type="left_arrow" state="focus" image="ocean/left_arrow_focus.png" />
<element type="right_arrow" state="focus" image="ocean/right_arrow_focus.png" />
<element type="list_header" state="neutral" image="ocean/table_header.png" />
<element type="list_sort_up" state="neutral" image="ocean/list_sort_up.png" />
<element type="list_header" state="down" image="ocean/table_header_down.png" />
<!-- Stateless -->
<element type="section" image="ocean/glass_section.png"
left_border="15" right_border="15" top_border="15" bottom_border="15"

View File

@@ -178,6 +178,7 @@ when the border that intersect at this corner are enabled.
<element type="list_header" state="neutral" image="peach/table_header.png" />
<element type="list_sort_up" state="neutral" image="peach/list_sort_up.png" />
<element type="list_header" state="down" image="peach/table_header_down.png" />
<!-- Stateless -->
<element type="section" image="peach/glass_section.png"

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 860 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 891 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 860 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -1270,10 +1270,14 @@ void Skin::drawListHeader(const irr::core::rect< irr::s32 > &rect, Widget* widge
//ListWidget* list = dynamic_cast<ListWidget*>(widget);
//assert(list != NULL);
drawBoxFromStretchableTexture(widget, rect,
SkinConfig::m_render_params["list_header::neutral"], false, NULL /* clip */);
IGUIButton* btn = widget->getIrrlichtElement<IGUIButton>();
drawBoxFromStretchableTexture(widget, rect,
(btn->isPressed() ? SkinConfig::m_render_params["list_header::down"] :
SkinConfig::m_render_params["list_header::neutral"]),
false, NULL /* clip */);
if (btn->isPressed())
{
ITexture* img = SkinConfig::m_render_params["list_sort_up::neutral"].getImage();

View File

@@ -35,6 +35,7 @@ ListWidget::ListWidget() : Widget(WTYPE_LIST)
{
m_use_icons = false;
m_icons = NULL;
m_listener = NULL;
}
// -----------------------------------------------------------------------------
@@ -88,7 +89,7 @@ void ListWidget::add()
{
const int col_size = m_w / m_header.size();
for (int n=0; n<m_header.size(); n++)
for (unsigned int n=0; n<m_header.size(); n++)
{
std::ostringstream name;
name << m_properties[PROP_ID];
@@ -323,6 +324,8 @@ EventPropagation ListWidget::transmitEvent(Widget* w, std::string& originator, c
}
m_header_elements[col].getIrrlichtElement<IGUIButton>()->setPressed(true);
if (m_listener) m_listener->onColumnClicked(col);
return EVENT_BLOCK;
}

View File

@@ -30,6 +30,14 @@ namespace irr { namespace gui { class STKModifiedSpriteBank; } }
namespace GUIEngine
{
class IListWidgetHeaderListener
{
public:
virtual ~IListWidgetHeaderListener(){}
virtual void onColumnClicked(int columnId) = 0;
};
/** \brief A vertical list widget with text entries
* \ingroup widgets
* \note items you add to a list are not kept after the the list is in was removed
@@ -56,6 +64,8 @@ namespace GUIEngine
/** Leave empty for no header */
std::vector< irr::core::stringw > m_header;
IListWidgetHeaderListener* m_listener;
public:
ListWidget();
@@ -171,6 +181,12 @@ namespace GUIEngine
/** Override callback from Widget */
virtual EventPropagation transmitEvent(Widget* w, std::string& originator, const int playerID);
void setColumnListener(IListWidgetHeaderListener* listener)
{
if (m_listener) delete m_listener;
m_listener = listener;
}
/** To be called before Widget::add(); columns are persistent across multiple add/remove cycles
*/
void addColumn(irr::core::stringw col) { m_header.push_back( col ); }