mirror of
https://github.com/geode-sdk/geode.git
synced 2025-03-24 03:39:56 -04:00
List color fix (#856)
* Added a fix for the color support in generic cells
This commit is contained in:
parent
e9304c60ac
commit
cb81e86e2f
2 changed files with 34 additions and 8 deletions
loader
|
@ -18,7 +18,7 @@ namespace geode {
|
|||
public:
|
||||
static GenericListCell* create(char const* key, cocos2d::CCSize size);
|
||||
|
||||
virtual void updateBGColor(int index);
|
||||
void updateBGColor(int index);
|
||||
void setPrimaryColor(cocos2d::ccColor3B color);
|
||||
void setSecondaryColor(cocos2d::ccColor3B color);
|
||||
void setOpacity(GLubyte opacity);
|
||||
|
@ -30,6 +30,10 @@ namespace geode {
|
|||
*/
|
||||
class GEODE_DLL ListView : public CustomListView {
|
||||
protected:
|
||||
cocos2d::ccColor3B m_primaryCellColor;
|
||||
cocos2d::ccColor3B m_secondaryCellColor;
|
||||
GLubyte m_cellOpacity;
|
||||
|
||||
void setupList(float) override;
|
||||
TableViewCell* getListCell(char const* key) override;
|
||||
void loadCell(TableViewCell* cell, int index) override;
|
||||
|
@ -49,5 +53,9 @@ namespace geode {
|
|||
cocos2d::CCArray* items, float itemHeight = 40.f, float width = 358.f,
|
||||
float height = 220.f
|
||||
);
|
||||
|
||||
void setPrimaryCellColor(cocos2d::ccColor3B color);
|
||||
void setSecondaryCellColor(cocos2d::ccColor3B color);
|
||||
void setCellOpacity(GLubyte opacity);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -35,6 +35,18 @@ void GenericListCell::updateBGColor(int index) {
|
|||
m_backgroundLayer->setOpacity(m_opacity);
|
||||
}
|
||||
|
||||
void GenericListCell::setPrimaryColor(cocos2d::ccColor3B color) {
|
||||
m_primaryColor = color;
|
||||
}
|
||||
|
||||
void GenericListCell::setSecondaryColor(cocos2d::ccColor3B color) {
|
||||
m_secondaryColor = color;
|
||||
}
|
||||
|
||||
void GenericListCell::setOpacity(GLubyte opacity) {
|
||||
m_opacity = opacity;
|
||||
}
|
||||
|
||||
void ListView::setupList(float) {
|
||||
if (!m_entries->count()) return;
|
||||
m_tableView->reloadData();
|
||||
|
@ -65,6 +77,9 @@ void ListView::loadCell(TableViewCell* cell, int index) {
|
|||
node->setContentSize(lcell->getScaledContentSize());
|
||||
node->setPosition(0, 0);
|
||||
lcell->addChild(node);
|
||||
lcell->setPrimaryColor(m_primaryCellColor);
|
||||
lcell->setSecondaryColor(m_secondaryCellColor);
|
||||
lcell->setOpacity(m_cellOpacity);
|
||||
lcell->updateBGColor(index);
|
||||
}
|
||||
}
|
||||
|
@ -73,6 +88,9 @@ ListView* ListView::create(CCArray* items, float itemHeight, float width, float
|
|||
auto ret = new ListView();
|
||||
if (ret) {
|
||||
ret->m_itemSeparation = itemHeight;
|
||||
ret->m_primaryCellColor = ccc3(0xa1, 0x58, 0x2c);
|
||||
ret->m_secondaryCellColor = ccc3(0xc2, 0x72, 0x3e);
|
||||
ret->m_cellOpacity = 0xff;
|
||||
if (ret->init(items, BoomListType::Default, width, height)) {
|
||||
ret->autorelease();
|
||||
return ret;
|
||||
|
@ -82,14 +100,14 @@ ListView* ListView::create(CCArray* items, float itemHeight, float width, float
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void GenericListCell::setPrimaryColor(cocos2d::ccColor3B color) {
|
||||
m_primaryColor = color;
|
||||
void ListView::setPrimaryCellColor(cocos2d::ccColor3B color) {
|
||||
m_primaryCellColor = color;
|
||||
}
|
||||
|
||||
void GenericListCell::setSecondaryColor(cocos2d::ccColor3B color) {
|
||||
m_secondaryColor = color;
|
||||
void ListView::setSecondaryCellColor(cocos2d::ccColor3B color) {
|
||||
m_secondaryCellColor = color;
|
||||
}
|
||||
|
||||
void GenericListCell::setOpacity(GLubyte opacity) {
|
||||
m_opacity = opacity;
|
||||
}
|
||||
void ListView::setCellOpacity(GLubyte opacity) {
|
||||
m_cellOpacity = opacity;
|
||||
}
|
Loading…
Add table
Reference in a new issue