Make list line height and alternate darkness .stkgui options

This commit is contained in:
Alayan 2018-12-15 08:04:08 +01:00
parent e34e08253e
commit 830c85a262
6 changed files with 15 additions and 8 deletions

View File

@ -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_width, PROP_CHILD_WIDTH);
READ_PROPERTY(child_height, PROP_CHILD_HEIGHT); READ_PROPERTY(child_height, PROP_CHILD_HEIGHT);
READ_PROPERTY(word_wrap, PROP_WORD_WRAP); 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(grow_with_text, PROP_GROW_WITH_TEXT);
READ_PROPERTY(x, PROP_X); READ_PROPERTY(x, PROP_X);
READ_PROPERTY(y, PROP_Y); READ_PROPERTY(y, PROP_Y);

View File

@ -89,6 +89,8 @@ namespace GUIEngine
PROP_CHILD_WIDTH, PROP_CHILD_WIDTH,
PROP_CHILD_HEIGHT, PROP_CHILD_HEIGHT,
PROP_WORD_WRAP, PROP_WORD_WRAP,
PROP_ALTERNATE_BG,
PROP_LINE_HEIGHT,
//PROP_GROW_WITH_TEXT, // yet unused //PROP_GROW_WITH_TEXT, // yet unused
PROP_X, PROP_X,
PROP_Y, PROP_Y,

View File

@ -586,7 +586,7 @@ void CGUISTKListBox::draw()
} }
core::rect<s32> lineRect = textRect; 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; int supp_lines = Items[i].m_contents[x].m_text_lines.size() - 1;
lineRect.UpperLeftCorner.Y -= (line_height*supp_lines)/2; lineRect.UpperLeftCorner.Y -= (line_height*supp_lines)/2;
lineRect.LowerRightCorner.Y -= (line_height*supp_lines)/2; lineRect.LowerRightCorner.Y -= (line_height*supp_lines)/2;

View File

@ -55,6 +55,7 @@ namespace irr
int m_current_id; int m_current_id;
bool m_word_wrap = false; bool m_word_wrap = false;
float m_line_height_scale = 0.0f;
// A multicolor extension // A multicolor extension
struct ListItemOverrideColor struct ListItemOverrideColor

View File

@ -45,7 +45,6 @@ ListWidget::ListWidget() : Widget(WTYPE_LIST)
m_sort_col = 0; m_sort_col = 0;
m_sortable = true; m_sortable = true;
m_header_created = false; m_header_created = false;
m_alternating_darkness = false;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -111,7 +110,7 @@ void ListWidget::add()
true, true,
false); false);
list_box->setAlternatingDarkness(m_alternating_darkness); list_box->setAlternatingDarkness(m_properties[PROP_ALTERNATE_BG] == "true");
if (current_skin && current_skin->getSpriteBank()) if (current_skin && current_skin->getSpriteBank())
{ {
list_box->setSpriteBank(current_skin->getSpriteBank()); list_box->setSpriteBank(current_skin->getSpriteBank());
@ -228,7 +227,7 @@ void ListWidget::clearColumns()
} //clearColumns } //clearColumns
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
//FIXME : remove the code duplication of the two addItem functions
void ListWidget::addItem( const std::string& internal_name, void ListWidget::addItem( const std::string& internal_name,
const irr::core::stringw &name, const irr::core::stringw &name,
const int icon, const int icon,
@ -242,6 +241,10 @@ void ListWidget::addItem( const std::string& internal_name,
newItem.m_internal_name = internal_name; newItem.m_internal_name = internal_name;
newItem.m_contents.push_back(cell); newItem.m_contents.push_back(cell);
newItem.m_word_wrap = (m_properties[PROP_WORD_WRAP] == "true"); 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>(); CGUISTKListBox* list = getIrrlichtElement<CGUISTKListBox>();
assert(list != NULL); assert(list != NULL);
@ -270,6 +273,9 @@ void ListWidget::addItem(const std::string& internal_name,
newItem.m_contents.push_back(contents[i]); newItem.m_contents.push_back(contents[i]);
} }
newItem.m_word_wrap = (m_properties[PROP_WORD_WRAP] == "true"); 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>(); CGUISTKListBox* list = getIrrlichtElement<CGUISTKListBox>();
assert(list != NULL); assert(list != NULL);

View File

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