Make list line height and alternate darkness .stkgui options
This commit is contained in:
parent
e34e08253e
commit
830c85a262
@ -204,6 +204,8 @@ if(prop_name != NULL) widget.m_properties[prop_flag] = core::stringc(prop_name).
|
||||
READ_PROPERTY(child_width, PROP_CHILD_WIDTH);
|
||||
READ_PROPERTY(child_height, PROP_CHILD_HEIGHT);
|
||||
READ_PROPERTY(word_wrap, PROP_WORD_WRAP);
|
||||
READ_PROPERTY(alternate_bg, PROP_ALTERNATE_BG);
|
||||
READ_PROPERTY(line_height, PROP_LINE_HEIGHT);
|
||||
//READ_PROPERTY(grow_with_text, PROP_GROW_WITH_TEXT);
|
||||
READ_PROPERTY(x, PROP_X);
|
||||
READ_PROPERTY(y, PROP_Y);
|
||||
|
@ -89,6 +89,8 @@ namespace GUIEngine
|
||||
PROP_CHILD_WIDTH,
|
||||
PROP_CHILD_HEIGHT,
|
||||
PROP_WORD_WRAP,
|
||||
PROP_ALTERNATE_BG,
|
||||
PROP_LINE_HEIGHT,
|
||||
//PROP_GROW_WITH_TEXT, // yet unused
|
||||
PROP_X,
|
||||
PROP_Y,
|
||||
|
@ -586,7 +586,7 @@ void CGUISTKListBox::draw()
|
||||
}
|
||||
|
||||
core::rect<s32> lineRect = textRect;
|
||||
int line_height = Font->getDimension(L"A").Height;
|
||||
int line_height = Font->getDimension(L"A").Height*Items[i].m_line_height_scale;
|
||||
int supp_lines = Items[i].m_contents[x].m_text_lines.size() - 1;
|
||||
lineRect.UpperLeftCorner.Y -= (line_height*supp_lines)/2;
|
||||
lineRect.LowerRightCorner.Y -= (line_height*supp_lines)/2;
|
||||
|
@ -55,6 +55,7 @@ namespace irr
|
||||
int m_current_id;
|
||||
|
||||
bool m_word_wrap = false;
|
||||
float m_line_height_scale = 0.0f;
|
||||
|
||||
// A multicolor extension
|
||||
struct ListItemOverrideColor
|
||||
|
@ -45,7 +45,6 @@ ListWidget::ListWidget() : Widget(WTYPE_LIST)
|
||||
m_sort_col = 0;
|
||||
m_sortable = true;
|
||||
m_header_created = false;
|
||||
m_alternating_darkness = false;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -111,7 +110,7 @@ void ListWidget::add()
|
||||
true,
|
||||
false);
|
||||
|
||||
list_box->setAlternatingDarkness(m_alternating_darkness);
|
||||
list_box->setAlternatingDarkness(m_properties[PROP_ALTERNATE_BG] == "true");
|
||||
if (current_skin && current_skin->getSpriteBank())
|
||||
{
|
||||
list_box->setSpriteBank(current_skin->getSpriteBank());
|
||||
@ -228,7 +227,7 @@ void ListWidget::clearColumns()
|
||||
} //clearColumns
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
//FIXME : remove the code duplication of the two addItem functions
|
||||
void ListWidget::addItem( const std::string& internal_name,
|
||||
const irr::core::stringw &name,
|
||||
const int icon,
|
||||
@ -242,6 +241,10 @@ void ListWidget::addItem( const std::string& internal_name,
|
||||
newItem.m_internal_name = internal_name;
|
||||
newItem.m_contents.push_back(cell);
|
||||
newItem.m_word_wrap = (m_properties[PROP_WORD_WRAP] == "true");
|
||||
newItem.m_line_height_scale = m_properties[PROP_LINE_HEIGHT] == "small" ? 0.75f :
|
||||
m_properties[PROP_LINE_HEIGHT] == "normal" ? 1.0f :
|
||||
m_properties[PROP_LINE_HEIGHT] == "big" ? 1.25f : 1.0f;
|
||||
|
||||
|
||||
CGUISTKListBox* list = getIrrlichtElement<CGUISTKListBox>();
|
||||
assert(list != NULL);
|
||||
@ -270,6 +273,9 @@ void ListWidget::addItem(const std::string& internal_name,
|
||||
newItem.m_contents.push_back(contents[i]);
|
||||
}
|
||||
newItem.m_word_wrap = (m_properties[PROP_WORD_WRAP] == "true");
|
||||
newItem.m_line_height_scale = m_properties[PROP_LINE_HEIGHT] == "small" ? 0.75f :
|
||||
m_properties[PROP_LINE_HEIGHT] == "normal" ? 1.0f :
|
||||
m_properties[PROP_LINE_HEIGHT] == "big" ? 1.25f : 1.0f;
|
||||
|
||||
CGUISTKListBox* list = getIrrlichtElement<CGUISTKListBox>();
|
||||
assert(list != NULL);
|
||||
|
@ -91,8 +91,6 @@ namespace GUIEngine
|
||||
|
||||
bool m_header_created;
|
||||
|
||||
bool m_alternating_darkness;
|
||||
|
||||
public:
|
||||
typedef irr::gui::CGUISTKListBox::ListItem ListItem;
|
||||
typedef ListItem::ListCell ListCell;
|
||||
@ -278,8 +276,6 @@ 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; }
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user