diff --git a/CMakeLists.txt b/CMakeLists.txt index d285202d7..0b51fffc6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,7 +148,6 @@ set(ES_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/components/TextEditComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/TextListComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ThemeComponent.h - ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiBox.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiDetectDevice.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiFastSelect.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiMetaDataEd.h @@ -195,7 +194,6 @@ set(ES_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/components/TextComponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/TextEditComponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ThemeComponent.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiBox.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiDetectDevice.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiFastSelect.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiMetaDataEd.cpp diff --git a/src/components/ComponentListComponent.h b/src/components/ComponentListComponent.h index 1f79d20bb..0db561084 100644 --- a/src/components/ComponentListComponent.h +++ b/src/components/ComponentListComponent.h @@ -117,7 +117,7 @@ private: //clip rect to our size //render a "selected" effect behind component with focus somehow // an edge filter would be cool, but we can't really do that without shader support -// a transparent rect will work for now, but it's kind of ugly...maybe a GuiBox +// a transparent rect will work for now, but it's kind of ugly... //glTranslatef by our render offset // doesn't handle getGlobalOffset for our components...would need parenting for that diff --git a/src/components/GuiBox.cpp b/src/components/GuiBox.cpp deleted file mode 100644 index 010d204a6..000000000 --- a/src/components/GuiBox.cpp +++ /dev/null @@ -1,136 +0,0 @@ -#include "GuiBox.h" - -GuiBox::GuiBox(Window* window, float offsetX, float offsetY, float width, float height) : GuiComponent(window), mBackgroundImage(window), - mHorizontalImage(window), mVerticalImage(window), mCornerImage(window) -{ - setPosition(offsetX, offsetY); - setSize(width, height); -} - -void GuiBox::setData(GuiBoxData data) -{ - setBackgroundImage(data.backgroundPath, data.backgroundTiled); - setHorizontalImage(data.horizontalPath, data.horizontalTiled); - setVerticalImage(data.verticalPath, data.verticalTiled); - setCornerImage(data.cornerPath); -} - -void GuiBox::setHorizontalImage(std::string path, bool tiled) -{ - mHorizontalImage.setTiling(tiled); - mHorizontalImage.setOrigin(0, 0); - - mHorizontalImage.setImage(path); - mHorizontalImage.setResize(mSize.x(), getHorizontalBorderWidth(), true); -} - -void GuiBox::setVerticalImage(std::string path, bool tiled) -{ - mVerticalImage.setTiling(tiled); - mVerticalImage.setOrigin(0, 0); - - mVerticalImage.setImage(path); - mVerticalImage.setResize(getVerticalBorderWidth(), mSize.y(), true); -} - -void GuiBox::setBackgroundImage(std::string path, bool tiled) -{ - mBackgroundImage.setOrigin(0, 0); - mBackgroundImage.setResize(mSize.x(), mSize.y(), true); - mBackgroundImage.setTiling(tiled); - mBackgroundImage.setPosition(0, 0); - - mBackgroundImage.setImage(path); -} - -void GuiBox::setCornerImage(std::string path) -{ - mCornerImage.setOrigin(0, 0); - mCornerImage.setResize(getHorizontalBorderWidth(), getVerticalBorderWidth(), true); - - mCornerImage.setImage(path); -} - -void GuiBox::setBackgroundColor(unsigned int color) -{ - mBackgroundImage.setColorShift(color); -} - -void GuiBox::setBorderColor(unsigned int color) -{ - mHorizontalImage.setColorShift(color); - mVerticalImage.setColorShift(color); - mCornerImage.setColorShift(color); -} - -void GuiBox::render(const Eigen::Affine3f& parentTrans) -{ - Eigen::Affine3f trans = parentTrans * getTransform(); - - mBackgroundImage.render(trans); - - //left border - mVerticalImage.setPosition(-getVerticalBorderWidth(), 0); - mVerticalImage.setFlipX(false); - mVerticalImage.render(trans); - - //right border - mVerticalImage.setPosition(mSize.x(), 0); - mVerticalImage.setFlipX(true); - mVerticalImage.render(trans); - - //top border - mHorizontalImage.setPosition(0, -getHorizontalBorderWidth()); - mHorizontalImage.setFlipY(false); - mHorizontalImage.render(trans); - - //bottom border - mHorizontalImage.setPosition(0, mSize.y()); - mHorizontalImage.setFlipY(true); - mHorizontalImage.render(trans); - - - //corner top left - mCornerImage.setPosition(-getHorizontalBorderWidth(), -getVerticalBorderWidth()); - mCornerImage.setFlipX(false); - mCornerImage.setFlipY(false); - mCornerImage.render(trans); - - //top right - mCornerImage.setPosition(mSize.x(), mCornerImage.getPosition().y()); - mCornerImage.setFlipX(true); - mCornerImage.render(trans); - - //bottom right - mCornerImage.setPosition(mCornerImage.getPosition().x(), mSize.y()); - mCornerImage.setFlipY(true); - mCornerImage.render(trans); - - //bottom left - mCornerImage.setPosition(-getHorizontalBorderWidth(), mCornerImage.getPosition().y()); - mCornerImage.setFlipX(false); - mCornerImage.render(trans); - - GuiComponent::renderChildren(trans); -} - -float GuiBox::getHorizontalBorderWidth() -{ - return (float)mHorizontalImage.getTextureSize().y(); -} - -float GuiBox::getVerticalBorderWidth() -{ - return (float)mVerticalImage.getTextureSize().x(); -} - -bool GuiBox::hasBackground() -{ - return mBackgroundImage.hasImage(); -} - -void GuiBox::onSizeChanged() -{ - mHorizontalImage.setResize(mSize.x(), getHorizontalBorderWidth(), true); - mVerticalImage.setResize(getVerticalBorderWidth(), mSize.y(), true); -} \ No newline at end of file diff --git a/src/components/GuiBox.h b/src/components/GuiBox.h deleted file mode 100644 index bd5c4b187..000000000 --- a/src/components/GuiBox.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef _GUIBOX_H_ -#define _GUIBOX_H_ - -#include "../GuiComponent.h" -#include "ImageComponent.h" -#include - -struct GuiBoxData -{ - std::string backgroundPath; - bool backgroundTiled; - std::string horizontalPath; - bool horizontalTiled; - std::string verticalPath; - bool verticalTiled; - std::string cornerPath; -}; - -class GuiBox : public GuiComponent -{ -public: - GuiBox(Window* window, float offsetX, float offsetY, float width, float height); - - void setData(GuiBoxData data); - - 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); - - bool hasBackground(); - - void setBackgroundColor(unsigned int color); - void setBorderColor(unsigned int color); - - void render(const Eigen::Affine3f& parentTrans) override; - - void onSizeChanged() override; -private: - ImageComponent mBackgroundImage, mHorizontalImage, mVerticalImage, mCornerImage; - - float getHorizontalBorderWidth(); - float getVerticalBorderWidth(); -}; - -#endif diff --git a/src/components/NinePatchComponent.cpp b/src/components/NinePatchComponent.cpp index d5c9f57cf..e4bc675d8 100644 --- a/src/components/NinePatchComponent.cpp +++ b/src/components/NinePatchComponent.cpp @@ -8,7 +8,8 @@ NinePatchComponent::NinePatchComponent(Window* window, const std::string& path, mPath(path), mVertices(NULL), mColors(NULL) { - buildVertices(); + if(!mPath.empty()) + buildVertices(); } void NinePatchComponent::updateColors() diff --git a/src/components/TextEditComponent.h b/src/components/TextEditComponent.h index 24d65e063..7eaef527d 100644 --- a/src/components/TextEditComponent.h +++ b/src/components/TextEditComponent.h @@ -1,7 +1,6 @@ #pragma once #include "../GuiComponent.h" -#include "GuiBox.h" #include "NinePatchComponent.h" class Font; diff --git a/src/components/ThemeComponent.h b/src/components/ThemeComponent.h index a5da1d25a..e364ba3df 100644 --- a/src/components/ThemeComponent.h +++ b/src/components/ThemeComponent.h @@ -5,7 +5,6 @@ #include "../GuiComponent.h" #include "../pugiXML/pugixml.hpp" -#include "GuiBox.h" #include "../AudioManager.h" #include "../Font.h"