Completely removed GuiBox.

This commit is contained in:
Aloshi 2013-09-14 12:51:13 -05:00
parent d7a6cae4ce
commit 8e12ff9506
7 changed files with 3 additions and 188 deletions

View file

@ -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

View file

@ -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

View file

@ -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);
}

View file

@ -1,46 +0,0 @@
#ifndef _GUIBOX_H_
#define _GUIBOX_H_
#include "../GuiComponent.h"
#include "ImageComponent.h"
#include <string>
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

View file

@ -8,6 +8,7 @@ NinePatchComponent::NinePatchComponent(Window* window, const std::string& path,
mPath(path),
mVertices(NULL), mColors(NULL)
{
if(!mPath.empty())
buildVertices();
}

View file

@ -1,7 +1,6 @@
#pragma once
#include "../GuiComponent.h"
#include "GuiBox.h"
#include "NinePatchComponent.h"
class Font;

View file

@ -5,7 +5,6 @@
#include "../GuiComponent.h"
#include "../pugiXML/pugixml.hpp"
#include "GuiBox.h"
#include "../AudioManager.h"
#include "../Font.h"