Further work on GuiBox.

This commit is contained in:
Aloshi 2012-10-07 16:56:33 -05:00
parent 62336ab2fb
commit 41f164e53b
6 changed files with 59 additions and 10 deletions

View file

@ -1,3 +1,6 @@
October 7
-Fixed borders for GuiBox. Still need to flip the right border and bottom border.
October 5
-GuiFastSelect is working, but ugly.
-Began work on GuiBox for theming the fast select dialog.

View file

@ -107,7 +107,7 @@ void parseGamelist(SystemData* system)
std::string xmlpath = system->getRootFolder()->getPath() + "/gamelist.xml";
std::cout << "Parsing XML file \"" << xmlpath << "\"...\n";
std::cout << "Parsing XML file \"" << xmlpath << "\"...";
pugi::xml_document doc;
pugi::xml_parse_result result = doc.load_file(xmlpath.c_str());
@ -177,5 +177,5 @@ void parseGamelist(SystemData* system)
}
}
std::cout << "XML parsing complete.\n";
std::cout << "done.\n";
}

View file

@ -11,33 +11,63 @@ GuiBox::GuiBox(int offsetX, int offsetY, unsigned int width, unsigned int height
void GuiBox::setHorizontalImage(std::string path, bool tiled)
{
mHorizontalImage.setResize(12, mHeight, true);
mHorizontalImage.setTiling(tiled);
mHorizontalImage.setOrigin(0, 0);
mHorizontalImage.setImage(path);
}
void GuiBox::setVerticalImage(std::string path, bool tiled)
{
mVerticalImage.setResize(mWidth, 12, true);
mVerticalImage.setTiling(tiled);
mVerticalImage.setOrigin(0, 0);
mVerticalImage.setImage(path);
}
void GuiBox::setBackgroundImage(std::string path, bool tiled)
{
mBackgroundImage.setImage(path);
mBackgroundImage.setResize(mWidth, mHeight, true);
mBackgroundImage.setTiling(tiled);
mBackgroundImage.setOffsetX(getOffsetX());
mBackgroundImage.setOffsetY(getOffsetY());
mBackgroundImage.setImage(path);
}
void GuiBox::setCornerImage(std::string path)
{
mCornerImage.setResize(getHorizontalBorderWidth(), getVerticalBorderWidth(), true);
}
void GuiBox::onRender()
{
//left border
mHorizontalImage.setOffsetX(getOffsetX());
mHorizontalImage.setOffsetX(getOffsetX() - getHorizontalBorderWidth());
mHorizontalImage.setOffsetY(getOffsetY());
mHorizontalImage.setOrigin(0.5, 0);
mHorizontalImage.setResize(12, mHeight, true);
mHorizontalImage.render();
//Renderer::drawRect(getOffsetX() - getHorizontalBorderWidth(), getOffsetY(), getHorizontalBorderWidth(), mHeight, 0xFF0000);
//right border
mHorizontalImage.setOffsetX(getOffsetX() + mWidth);
mHorizontalImage.setOffsetY(getOffsetY());
//same Y
mHorizontalImage.render();
//Renderer::drawRect(getOffsetX() + mWidth, getOffsetY(), getHorizontalBorderWidth(), mHeight, 0xFF0000);
//top border
mVerticalImage.setOffsetX(getOffsetX());
mVerticalImage.setOffsetY(getOffsetY() - getVerticalBorderWidth());
mVerticalImage.render();
//Renderer::drawRect(getOffsetX(), getOffsetY() - getVerticalBorderWidth(), mWidth, getVerticalBorderWidth(), 0x00FF00);
//bottom border
//same X
mVerticalImage.setOffsetY(getOffsetY() + mHeight);
mVerticalImage.render();
//Renderer::drawRect(getOffsetX(), getOffsetY() + mHeight, mWidth, getVerticalBorderWidth(), 0x00FF00);
}
void GuiBox::onInit()
@ -51,3 +81,14 @@ void GuiBox::onDeinit()
mHorizontalImage.deinit();
mVerticalImage.deinit();
}
int GuiBox::getHorizontalBorderWidth()
{
return 12;
}
int GuiBox::getVerticalBorderWidth()
{
return 12;
}

View file

@ -13,13 +13,17 @@ public:
void setBackgroundImage(std::string path, bool tiled = true);
void setHorizontalImage(std::string path, bool tiled = false);
void setVerticalImage(std::string path, bool tiled = false);
void setCornerImage(std::string path);
void onRender();
void onInit();
void onDeinit();
private:
GuiImage mBackgroundImage, mHorizontalImage, mVerticalImage;
GuiImage mBackgroundImage, mHorizontalImage, mVerticalImage, mCornerImage;
int getHorizontalBorderWidth();
int getVerticalBorderWidth();
unsigned int mWidth, mHeight;
};

View file

@ -27,7 +27,8 @@ GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, cha
addChild(mBox);
//set test mBox info
//mBox->setHorizontalImage("test.jpg");
//mBox->setHorizontalImage("test.jpg", false);
//mBox->setVerticalImage("test.jpg", false);
mParent->pause();
}

View file

@ -11,7 +11,7 @@ const float GuiGameList::sInfoWidth = 0.5;
GuiGameList::GuiGameList(bool useDetail)
{
std::cout << "Creating GuiGameList\n";
//std::cout << "Creating GuiGameList\n";
mDetailed = useDetail;
mTheme = new GuiTheme(); //not a child because it's rendered manually by GuiGameList::onRender (to make sure it's rendered first)