add 'visible' theme element

This commit is contained in:
John Rassa 2019-07-21 23:13:48 -04:00
parent 13819ec0d9
commit 8de1fc8860
16 changed files with 89 additions and 14 deletions

View file

@ -576,6 +576,8 @@ Can be created as an extra.
- If true, the image will be tiled instead of stretched to fit its size. Useful for backgrounds.
* `color` - type: COLOR.
- Multiply each pixel's color by this color. For example, an all-white image with `<color>FF0000</color>` would become completely red. You can also control the transparency of an image with `<color>FFFFFFAA</color>` - keeping all the pixels their normal color and only affecting the alpha channel.
* `visible` - type: BOOLEAN.
- If true, component will be rendered, otherwise rendering will be skipped. Can be used to hide elements from a particular view.
* `zIndex` - type: FLOAT.
- z-index value for component. Components will be rendered in order of z-index value from low to high.
@ -632,6 +634,8 @@ Can be created as an extra.
- If true, image will be shown when selected game does not have a video and no `default` video is configured.
* `showSnapshotDelay` - type: BOOLEAN
- If true, playing of video will be delayed for `delayed` seconds, when game is selected.
* `visible` - type: BOOLEAN.
- If true, component will be rendered, otherwise rendering will be skipped. Can be used to hide elements from a particular view.
* `zIndex` - type: FLOAT.
- z-index value for component. Components will be rendered in order of z-index value from low to high.
@ -662,6 +666,8 @@ Can be created as an extra.
- Valid values are "left", "center", or "right". Controls alignment on the X axis. "center" will also align vertically.
* `forceUppercase` - type: BOOLEAN. Draw text in uppercase.
* `lineSpacing` - type: FLOAT. Controls the space between lines (as a multiple of font height). Default is 1.5.
* `visible` - type: BOOLEAN.
- If true, component will be rendered, otherwise rendering will be skipped. Can be used to hide elements from a particular view.
* `zIndex` - type: FLOAT.
- z-index value for component. Components will be rendered in order of z-index value from low to high.
@ -705,11 +711,13 @@ Can be created as an extra.
* `pos` - type: NORMALIZED_PAIR.
* `size` - type: NORMALIZED_PAIR.
* `path` - type: PATH.
EmulationStation borrows the concept of "nine patches" from Android (or "9-Slices"). Currently the implementation is very simple and hard-coded to only use 48x48px images (16x16px for each "patch"). Check the `data/resources` directory for some examples (button.png, frame.png).
* `visible` - type: BOOLEAN.
- If true, component will be rendered, otherwise rendering will be skipped. Can be used to hide elements from a particular view.
* `zIndex` - type: FLOAT.
- z-index value for component. Components will be rendered in order of z-index value from low to high.
EmulationStation borrows the concept of "nine patches" from Android (or "9-Slices"). Currently the implementation is very simple and hard-coded to only use 48x48px images (16x16px for each "patch"). Check the `data/resources` directory for some examples (button.png, frame.png).
#### rating
* `pos` - type: NORMALIZED_PAIR.
@ -727,6 +735,8 @@ EmulationStation borrows the concept of "nine patches" from Android (or "9-Slice
- Path to the "unfilled star" image. Image must be square (width equals height).
* `color` - type: COLOR.
- Multiply each pixel's color by this color. For example, an all-white image with `<color>FF0000</color>` would become completely red. You can also control the transparency of an image with `<color>FFFFFFAA</color>` - keeping all the pixels their normal color and only affecting the alpha channel.
* `visible` - type: BOOLEAN.
- If true, component will be rendered, otherwise rendering will be skipped. Can be used to hide elements from a particular view.
* `zIndex` - type: FLOAT.
- z-index value for component. Components will be rendered in order of z-index value from low to high.
@ -753,6 +763,8 @@ EmulationStation borrows the concept of "nine patches" from Android (or "9-Slice
- Valid values are "left", "center", or "right". Controls alignment on the X axis. "center" will also align vertically.
* `forceUppercase` - type: BOOLEAN. Draw text in uppercase.
* `lineSpacing` - type: FLOAT. Controls the space between lines (as a multiple of font height). Default is 1.5.
* `visible` - type: BOOLEAN.
- If true, component will be rendered, otherwise rendering will be skipped. Can be used to hide elements from a particular view.
* `zIndex` - type: FLOAT.
- z-index value for component. Components will be rendered in order of z-index value from low to high.
* `displayRelative` - type: BOOLEAN. Renders the datetime as a a relative string (ex: 'x days ago')

View file

@ -112,6 +112,9 @@ void RatingComponent::updateColors()
void RatingComponent::render(const Transform4x4f& parentTrans)
{
if (!isVisible())
return;
Transform4x4f trans = parentTrans * getTransform();
trans.round();
Renderer::setMatrix(trans);

View file

@ -86,7 +86,7 @@ void DetailedGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& them
BasicGameListView::onThemeChanged(theme);
using namespace ThemeFlags;
mImage.applyTheme(theme, getName(), "md_image", POSITION | ThemeFlags::SIZE | Z_INDEX | ROTATION);
mImage.applyTheme(theme, getName(), "md_image", POSITION | ThemeFlags::SIZE | Z_INDEX | ROTATION | VISIBLE);
mName.applyTheme(theme, getName(), "md_name", ALL);
initMDLabels();
@ -116,7 +116,7 @@ void DetailedGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& them
values[i]->applyTheme(theme, getName(), valElements[i], ALL ^ ThemeFlags::TEXT);
}
mDescContainer.applyTheme(theme, getName(), "md_description", POSITION | ThemeFlags::SIZE | Z_INDEX);
mDescContainer.applyTheme(theme, getName(), "md_description", POSITION | ThemeFlags::SIZE | Z_INDEX | VISIBLE);
mDescription.setSize(mDescContainer.getSize().x(), 0);
mDescription.applyTheme(theme, getName(), "md_description", ALL ^ (POSITION | ThemeFlags::SIZE | ThemeFlags::ORIGIN | TEXT | ROTATION));

View file

@ -163,7 +163,7 @@ void GridGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
values[i]->applyTheme(theme, getName(), valElements[i], ALL ^ ThemeFlags::TEXT);
}
mDescContainer.applyTheme(theme, getName(), "md_description", POSITION | ThemeFlags::SIZE | Z_INDEX);
mDescContainer.applyTheme(theme, getName(), "md_description", POSITION | ThemeFlags::SIZE | Z_INDEX | VISIBLE);
mDescription.setSize(mDescContainer.getSize().x(), 0);
mDescription.applyTheme(theme, getName(), "md_description", ALL ^ (POSITION | ThemeFlags::SIZE | ThemeFlags::ORIGIN | TEXT | ROTATION));

View file

@ -123,9 +123,9 @@ void VideoGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
BasicGameListView::onThemeChanged(theme);
using namespace ThemeFlags;
mMarquee.applyTheme(theme, getName(), "md_marquee", POSITION | ThemeFlags::SIZE | Z_INDEX | ROTATION);
mImage.applyTheme(theme, getName(), "md_image", POSITION | ThemeFlags::SIZE | Z_INDEX | ROTATION);
mVideo->applyTheme(theme, getName(), "md_video", POSITION | ThemeFlags::SIZE | ThemeFlags::DELAY | Z_INDEX | ROTATION);
mMarquee.applyTheme(theme, getName(), "md_marquee", POSITION | ThemeFlags::SIZE | Z_INDEX | ROTATION | VISIBLE);
mImage.applyTheme(theme, getName(), "md_image", POSITION | ThemeFlags::SIZE | Z_INDEX | ROTATION | VISIBLE);
mVideo->applyTheme(theme, getName(), "md_video", POSITION | ThemeFlags::SIZE | ThemeFlags::DELAY | Z_INDEX | ROTATION | VISIBLE);
mName.applyTheme(theme, getName(), "md_name", ALL);
initMDLabels();
@ -155,7 +155,7 @@ void VideoGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
values[i]->applyTheme(theme, getName(), valElements[i], ALL ^ ThemeFlags::TEXT);
}
mDescContainer.applyTheme(theme, getName(), "md_description", POSITION | ThemeFlags::SIZE | Z_INDEX);
mDescContainer.applyTheme(theme, getName(), "md_description", POSITION | ThemeFlags::SIZE | Z_INDEX | VISIBLE);
mDescription.setSize(mDescContainer.getSize().x(), 0);
mDescription.applyTheme(theme, getName(), "md_description", ALL ^ (POSITION | ThemeFlags::SIZE | ThemeFlags::ORIGIN | TEXT | ROTATION));

View file

@ -10,7 +10,7 @@
GuiComponent::GuiComponent(Window* window) : mWindow(window), mParent(NULL), mOpacity(255),
mPosition(Vector3f::Zero()), mOrigin(Vector2f::Zero()), mRotationOrigin(0.5, 0.5),
mSize(Vector2f::Zero()), mTransform(Transform4x4f::Identity()), mIsProcessing(false)
mSize(Vector2f::Zero()), mTransform(Transform4x4f::Identity()), mIsProcessing(false), mVisible(true)
{
for(unsigned char i = 0; i < MAX_ANIMATIONS; i++)
mAnimationMap[i] = NULL;
@ -62,6 +62,9 @@ void GuiComponent::update(int deltaTime)
void GuiComponent::render(const Transform4x4f& parentTrans)
{
if (!isVisible())
return;
Transform4x4f trans = parentTrans * getTransform();
renderChildren(trans);
}
@ -157,6 +160,15 @@ void GuiComponent::setDefaultZIndex(float z)
mDefaultZIndex = z;
}
bool GuiComponent::isVisible() const
{
return mVisible;
}
void GuiComponent::setVisible(bool visible)
{
mVisible = visible;
}
Vector2f GuiComponent::getCenter() const
{
return Vector2f(mPosition.x() - (getSize().x() * mOrigin.x()) + getSize().x() / 2,
@ -424,6 +436,11 @@ void GuiComponent::applyTheme(const std::shared_ptr<ThemeData>& theme, const std
setZIndex(elem->get<float>("zIndex"));
else
setZIndex(getDefaultZIndex());
if(properties & ThemeFlags::VISIBLE && elem->has("visible"))
setVisible(elem->get<bool>("visible"));
else
setVisible(true);
}
void GuiComponent::updateHelpPrompts()

View file

@ -76,6 +76,9 @@ public:
float getDefaultZIndex() const;
void setDefaultZIndex(float zIndex);
bool isVisible() const;
void setVisible(bool visible);
// Returns the center point of the image (takes origin into account).
Vector2f getCenter() const;
@ -157,6 +160,7 @@ protected:
float mZIndex = 0;
bool mIsProcessing;
bool mVisible;
public:
const static unsigned char MAX_ANIMATIONS = 4;

View file

@ -10,7 +10,7 @@
#include <algorithm>
std::vector<std::string> ThemeData::sSupportedViews { { "system" }, { "basic" }, { "detailed" }, { "grid" }, { "video" } };
std::vector<std::string> ThemeData::sSupportedFeatures { { "video" }, { "carousel" }, { "z-index" } };
std::vector<std::string> ThemeData::sSupportedFeatures { { "video" }, { "carousel" }, { "z-index" }, { "visible" } };
std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>> ThemeData::sElementMap {
{ "image", {
@ -24,6 +24,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>> The
{ "default", PATH },
{ "tile", BOOLEAN },
{ "color", COLOR },
{ "visible", BOOLEAN },
{ "zIndex", FLOAT } } },
{ "imagegrid", {
{ "pos", NORMALIZED_PAIR },
@ -56,6 +57,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>> The
{ "forceUppercase", BOOLEAN },
{ "lineSpacing", FLOAT },
{ "value", STRING },
{ "visible", BOOLEAN },
{ "zIndex", FLOAT } } },
{ "textlist", {
{ "pos", NORMALIZED_PAIR },
@ -81,11 +83,13 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>> The
{ "pos", NORMALIZED_PAIR },
{ "size", NORMALIZED_PAIR },
{ "origin", NORMALIZED_PAIR },
{ "zIndex", FLOAT } } },
{ "visible", BOOLEAN },
{ "zIndex", FLOAT } } },
{ "ninepatch", {
{ "pos", NORMALIZED_PAIR },
{ "size", NORMALIZED_PAIR },
{ "path", PATH },
{ "visible", BOOLEAN },
{ "zIndex", FLOAT } } },
{ "datetime", {
{ "pos", NORMALIZED_PAIR },
@ -103,7 +107,8 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>> The
{ "value", STRING },
{ "format", STRING },
{ "displayRelative", BOOLEAN },
{ "zIndex", FLOAT } } },
{ "visible", BOOLEAN },
{ "zIndex", FLOAT } } },
{ "rating", {
{ "pos", NORMALIZED_PAIR },
{ "size", NORMALIZED_PAIR },
@ -113,6 +118,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>> The
{ "color", COLOR },
{ "filledPath", PATH },
{ "unfilledPath", PATH },
{ "visible", BOOLEAN },
{ "zIndex", FLOAT } } },
{ "sound", {
{ "path", PATH } } },
@ -132,7 +138,8 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>> The
{ "rotationOrigin", NORMALIZED_PAIR },
{ "default", PATH },
{ "delay", FLOAT },
{ "zIndex", FLOAT },
{ "visible", BOOLEAN },
{ "zIndex", FLOAT },
{ "showSnapshotNoVideo", BOOLEAN },
{ "showSnapshotDelay", BOOLEAN } } },
{ "carousel", {

View file

@ -41,6 +41,7 @@ namespace ThemeFlags
DELAY = 4096,
Z_INDEX = 8192,
ROTATION = 16384,
VISIBLE = 32768,
ALL = 0xFFFFFFFF
};
}

View file

@ -317,6 +317,9 @@ void ImageComponent::updateColors()
void ImageComponent::render(const Transform4x4f& parentTrans)
{
if (!isVisible())
return;
Transform4x4f trans = parentTrans * getTransform();
Renderer::setMatrix(trans);
@ -466,6 +469,11 @@ void ImageComponent::applyTheme(const std::shared_ptr<ThemeData>& theme, const s
setZIndex(elem->get<float>("zIndex"));
else
setZIndex(getDefaultZIndex());
if(properties & ThemeFlags::VISIBLE && elem->has("visible"))
setVisible(elem->get<bool>("visible"));
else
setVisible(true);
}
std::vector<HelpPrompt> ImageComponent::getHelpPrompts()

View file

@ -103,6 +103,9 @@ void NinePatchComponent::buildVertices()
void NinePatchComponent::render(const Transform4x4f& parentTrans)
{
if (!isVisible())
return;
Transform4x4f trans = parentTrans * getTransform();
trans.round();

View file

@ -13,6 +13,9 @@ ScrollableContainer::ScrollableContainer(Window* window) : GuiComponent(window),
void ScrollableContainer::render(const Transform4x4f& parentTrans)
{
if (!isVisible())
return;
Transform4x4f trans = parentTrans * getTransform();
Vector2i clipPos((int)trans.translation().x(), (int)trans.translation().y());

View file

@ -95,6 +95,9 @@ void TextComponent::setUppercase(bool uppercase)
void TextComponent::render(const Transform4x4f& parentTrans)
{
if (!isVisible())
return;
Transform4x4f trans = parentTrans * getTransform();
if (mRenderBackground)

View file

@ -145,6 +145,9 @@ void VideoComponent::setOpacity(unsigned char opacity)
void VideoComponent::render(const Transform4x4f& parentTrans)
{
if (!isVisible())
return;
Transform4x4f trans = parentTrans * getTransform();
GuiComponent::renderChildren(trans);
@ -223,6 +226,11 @@ void VideoComponent::applyTheme(const std::shared_ptr<ThemeData>& theme, const s
setZIndex(elem->get<float>("zIndex"));
else
setZIndex(getDefaultZIndex());
if(properties & ThemeFlags::VISIBLE && elem->has("visible"))
setVisible(elem->get<bool>("visible"));
else
setVisible(true);
}
std::vector<HelpPrompt> VideoComponent::getHelpPrompts()

View file

@ -30,6 +30,9 @@ VideoPlayerComponent::~VideoPlayerComponent()
void VideoPlayerComponent::render(const Transform4x4f& parentTrans)
{
if (!isVisible())
return;
VideoComponent::render(parentTrans);
if (!mIsPlaying || mPlayerPid == -1)

View file

@ -131,6 +131,9 @@ void VideoVlcComponent::resize()
void VideoVlcComponent::render(const Transform4x4f& parentTrans)
{
if (!isVisible())
return;
VideoComponent::render(parentTrans);
float x, y;