Added theming tag for the Fast Select box's text color.

This commit is contained in:
Aloshi 2012-10-10 08:51:48 -05:00
parent 9b3589a22f
commit 6de46003d9
11 changed files with 47 additions and 14 deletions

View file

@ -81,6 +81,8 @@ Display tags must be at the root of the <theme> tree - for example, they can't b
The Fast Select box can be themed with these tags:
`<fastSelectColor>` - the hex color to use for the letter display on the Fast Select box.
`<boxBackground>` - path to a background image file. ~ and . are expanded.
`<boxBackgroundTiled />` - if present, the background will be tiled instead of stretched.
@ -95,6 +97,10 @@ The Fast Select box can be themed with these tags:
`<boxCorner>` - path to the "top left corner" image file. It will be flipped for the top right, bottom right, and bottom left corners. ~ and . are expanded.
**NOTE:** The tiling tags are in and will tile, but will not properly cut off where they should. This should be fixed in a later commit.
List of variables
=================

View file

@ -1,8 +1,11 @@
October 10
-Added a theming tag for the Fast Select box's text.
October 7
-Fixed borders for GuiBox. The right and bottom borders are flipped, too.
-Added corners for GuiBox.
-Added setFlipX() and setFlipY() to the GuiImage class.
-Added theming options for the Fast Select GuiBox! See THEMES.md for more details.
-Added theming tags for the Fast Select GuiBox! See THEMES.md for more details. Tiling still not perfect though.
October 5
-GuiFastSelect is working, but ugly.

View file

@ -1,5 +1,4 @@
#include "GuiBox.h"
#include <iostream>
GuiBox::GuiBox(int offsetX, int offsetY, unsigned int width, unsigned int height)
{
@ -20,20 +19,20 @@ void GuiBox::setData(GuiBoxData data)
void GuiBox::setHorizontalImage(std::string path, bool tiled)
{
mHorizontalImage.setResize(12, mHeight, true);
mHorizontalImage.setTiling(tiled);
mHorizontalImage.setOrigin(0, 0);
mHorizontalImage.setImage(path);
mHorizontalImage.setResize(mHorizontalImage.getHeight(), mHeight, true);
}
void GuiBox::setVerticalImage(std::string path, bool tiled)
{
mVerticalImage.setResize(mWidth, 12, true);
mVerticalImage.setTiling(tiled);
mVerticalImage.setOrigin(0, 0);
mVerticalImage.setImage(path);
mVerticalImage.setResize(mWidth, mVerticalImage.getHeight(), true);
}
void GuiBox::setBackgroundImage(std::string path, bool tiled)
@ -56,6 +55,8 @@ void GuiBox::setCornerImage(std::string path)
void GuiBox::onRender()
{
mBackgroundImage.render();
//left border
mHorizontalImage.setOffsetX(getOffsetX() - getHorizontalBorderWidth());
mHorizontalImage.setOffsetY(getOffsetY());
@ -123,10 +124,15 @@ void GuiBox::onDeinit()
int GuiBox::getHorizontalBorderWidth()
{
return 12;
return mHorizontalImage.getWidth();
}
int GuiBox::getVerticalBorderWidth()
{
return 12;
return mVerticalImage.getHeight();
}
bool GuiBox::hasBackground()
{
return mBackgroundImage.hasImage();
}

View file

@ -27,6 +27,8 @@ public:
void setVerticalImage(std::string path, bool tiled = false);
void setCornerImage(std::string path);
bool hasBackground();
void onRender();
void onInit();

View file

@ -6,7 +6,7 @@ const std::string GuiFastSelect::LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int GuiFastSelect::SCROLLSPEED = 100;
const int GuiFastSelect::SCROLLDELAY = 507;
GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, char startLetter, GuiBoxData data)
GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, char startLetter, GuiBoxData data, int textcolor)
{
mLetterID = LETTERS.find(toupper(startLetter));
if(mLetterID == std::string::npos)
@ -27,6 +27,8 @@ GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, cha
mBox->setData(data);
addChild(mBox);
mTextColor = textcolor;
mParent->pause();
}
@ -45,8 +47,10 @@ void GuiFastSelect::onRender()
{
unsigned int sw = Renderer::getScreenWidth(), sh = Renderer::getScreenHeight();
if(!mBox->hasBackground())
Renderer::drawRect(sw * 0.2, sh * 0.2, sw * 0.6, sh * 0.6, 0x000FF0);
Renderer::drawCenteredText(LETTERS.substr(mLetterID, 1), 0, sh * 0.5 - (Renderer::getFontHeight(Renderer::LARGE) * 0.5), 0xFF0000, Renderer::LARGE);
Renderer::drawCenteredText(LETTERS.substr(mLetterID, 1), 0, sh * 0.5 - (Renderer::getFontHeight(Renderer::LARGE) * 0.5), mTextColor, Renderer::LARGE);
}
void GuiFastSelect::onInput(InputManager::InputButton button, bool keyDown)

View file

@ -10,7 +10,7 @@
class GuiFastSelect : GuiComponent
{
public:
GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, char startLetter, GuiBoxData data);
GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, char startLetter, GuiBoxData data, int textcolor);
~GuiFastSelect();
void onRender();
@ -31,6 +31,7 @@ private:
GuiComponent* mParent;
GuiBox* mBox;
int mTextColor;
int mScrollTimer, mScrollOffset;
bool mScrolling;

View file

@ -154,7 +154,7 @@ void GuiGameList::onInput(InputManager::InputButton button, bool keyDown)
if(button == InputManager::SELECT && keyDown)
{
new GuiFastSelect(this, mList, mList->getSelectedObject()->getName()[0], mTheme->getBoxData());
new GuiFastSelect(this, mList, mList->getSelectedObject()->getName()[0], mTheme->getBoxData(), mTheme->getFastSelectColor());
}
if(mDetailed)

View file

@ -3,8 +3,8 @@
#include <boost/filesystem.hpp>
#include <math.h>
unsigned int GuiImage::getWidth() { return mWidth; }
unsigned int GuiImage::getHeight() { return mHeight; }
unsigned int GuiImage::getWidth() { return mDrawWidth; }
unsigned int GuiImage::getHeight() { return mDrawHeight; }
GuiImage::GuiImage(int offsetX, int offsetY, std::string path, unsigned int resizeWidth, unsigned int resizeHeight, bool resizeExact)
{
@ -352,3 +352,8 @@ void GuiImage::onDeinit()
{
unloadImage();
}
bool GuiImage::hasImage()
{
return !mPath.empty();
}

View file

@ -27,6 +27,8 @@ public:
unsigned int getWidth(); //Returns render width in pixels. May be different than actual texture width.
unsigned int getHeight(); //Returns render height in pixels. May be different than actual texture height.
bool hasImage();
void onRender();
//Image textures will be deleted on renderer deinitialization, and recreated on reinitialization (if mPath is not empty).

View file

@ -11,6 +11,7 @@ int GuiTheme::getPrimaryColor() { return mListPrimaryColor; }
int GuiTheme::getSecondaryColor() { return mListSecondaryColor; }
int GuiTheme::getSelectorColor() { return mListSelectorColor; }
int GuiTheme::getDescColor() { return mDescColor; }
int GuiTheme::getFastSelectColor() { return mFastSelectColor; }
bool GuiTheme::getHeaderHidden() { return mHideHeader; }
bool GuiTheme::getDividersHidden() { return mHideDividers; }
bool GuiTheme::getListCentered() { return mListCentered; }
@ -43,6 +44,7 @@ void GuiTheme::setDefaults()
mListSelectorColor = 0x000000;
mListSelectedColor = -1; //-1 = use original list color when selected
mDescColor = 0x0000FF;
mFastSelectColor = 0xFF0000;
mHideHeader = false;
mHideDividers = false;
mListCentered = true;
@ -107,6 +109,7 @@ void GuiTheme::readXML(std::string path)
mListSelectorColor = resolveColor(root.child("listSelectorColor").text().get(), mListSelectorColor);
mListSelectedColor = resolveColor(root.child("listSelectedColor").text().get(), mListSelectedColor);
mDescColor = resolveColor(root.child("descColor").text().get(), mDescColor);
mFastSelectColor = resolveColor(root.child("fastSelectColor").text().get(), mFastSelectColor);
mHideHeader = root.child("hideHeader");
mHideDividers = root.child("hideDividers");
mListCentered = !root.child("listLeftAlign");

View file

@ -19,6 +19,7 @@ public:
int getSelectorColor();
int getSelectedTextColor();
int getDescColor();
int getFastSelectColor();
bool getHeaderHidden();
bool getDividersHidden();
bool getListCentered();
@ -43,7 +44,7 @@ private:
std::vector<GuiComponent*> mComponentVector;
std::string mPath;
int mListPrimaryColor, mListSecondaryColor, mListSelectorColor, mListSelectedColor, mDescColor;
int mListPrimaryColor, mListSecondaryColor, mListSelectorColor, mListSelectedColor, mDescColor, mFastSelectColor;
bool mHideHeader, mHideDividers, mListCentered;
float mListOffsetX, mGameImageOffsetY, mListTextOffsetX;