This commit is contained in:
Benau
2018-12-15 11:27:48 +08:00
parent ac809f429c
commit 81efd3fce4
5 changed files with 17 additions and 0 deletions

View File

@@ -5,6 +5,7 @@
#include "guiengine/widgets/CGUISTKListBox.hpp"
#include "graphics/2dutils.hpp"
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
#include "IVideoDriver.h"
@@ -32,6 +33,7 @@ CGUISTKListBox::CGUISTKListBox(IGUIEnvironment* environment, IGUIElement* parent
DrawBack(drawBack), MoveOverSelect(moveOverSelect), AutoScroll(true),
HighlightWhenNotFocused(true)
{
m_alternating_darkness = false;
#ifdef _DEBUG
setDebugName("CGUISTKListBox");
#endif
@@ -507,6 +509,12 @@ void CGUISTKListBox::draw()
if (frameRect.LowerRightCorner.Y >= AbsoluteRect.UpperLeftCorner.Y &&
frameRect.UpperLeftCorner.Y <= AbsoluteRect.LowerRightCorner.Y)
{
if (m_alternating_darkness && i % 2 != 0)
{
video::SColor color(0);
color.setAlpha(30);
GL32_draw2DRectangle(color, frameRect, &clientClip);
}
if (i == Selected && hl)
skin->draw2DRectangle(this, skin->getColor(EGDC_HIGH_LIGHT), frameRect, &clientClip);

View File

@@ -170,6 +170,7 @@ namespace irr
//! Sets whether to draw the background
virtual void setDrawBackground(bool draw);
void setAlternatingDarkness(bool val) { m_alternating_darkness = val; }
private:
void recalculateItemHeight();
@@ -197,6 +198,7 @@ namespace irr
bool MoveOverSelect;
bool AutoScroll;
bool HighlightWhenNotFocused;
bool m_alternating_darkness;
};

View File

@@ -45,6 +45,7 @@ ListWidget::ListWidget() : Widget(WTYPE_LIST)
m_sort_col = 0;
m_sortable = true;
m_header_created = false;
m_alternating_darkness = false;
}
// -----------------------------------------------------------------------------
@@ -110,6 +111,7 @@ void ListWidget::add()
true,
false);
list_box->setAlternatingDarkness(m_alternating_darkness);
if (current_skin && current_skin->getSpriteBank())
{
list_box->setSpriteBank(current_skin->getSpriteBank());

View File

@@ -91,6 +91,8 @@ namespace GUIEngine
bool m_header_created;
bool m_alternating_darkness;
public:
typedef irr::gui::CGUISTKListBox::ListItem ListItem;
typedef ListItem::ListCell ListCell;
@@ -276,6 +278,8 @@ namespace GUIEngine
void addColumn(irr::core::stringw col, int proportion=1) { m_header.push_back( Column(col, proportion) ); }
void setSortable(bool sortable) { m_sortable = sortable; }
void setAlternatingDarkness(bool val) { m_alternating_darkness = val; }
};
}

View File

@@ -115,6 +115,7 @@ void ServerSelection::loadedFromFile()
*/
void ServerSelection::beforeAddingWidget()
{
m_server_list_widget->setAlternatingDarkness(true);
m_server_list_widget->clearColumns();
m_server_list_widget->addColumn( _C("column_name", "Name"), 3);
m_server_list_widget->addColumn( _C("column_name", "Players"), 1);