From 2886e8e8d8fb038379e5a4cf17151b90014f6bda Mon Sep 17 00:00:00 2001 From: Aloshi Date: Mon, 17 Feb 2014 11:40:31 -0600 Subject: [PATCH] Compile on Linux/gcc again This better not have broken VS --- src/components/IList.h | 5 +++-- src/components/ImageGridComponent.h | 21 ++++++++++++++++--- src/components/TextListComponent.h | 31 +++++++++++++++++++++-------- 3 files changed, 44 insertions(+), 13 deletions(-) diff --git a/src/components/IList.h b/src/components/IList.h index 4d4d8f72b..10a03d662 100644 --- a/src/components/IList.h +++ b/src/components/IList.h @@ -6,6 +6,7 @@ #include "../GuiComponent.h" #include "ImageComponent.h" #include "../resources/Font.h" +#include "../Renderer.h" enum CursorState { @@ -148,9 +149,9 @@ public: protected: void remove(typename std::vector::iterator& it) { - if(getCursorIndex() > 0 && it - mEntries.begin() <= getCursorIndex()) + if(mCursor > 0 && it - mEntries.begin() <= mCursor) { - setCursorIndex(mCursor - 1); + mCursor--; onCursorChanged(CURSOR_STOPPED); } diff --git a/src/components/ImageGridComponent.h b/src/components/ImageGridComponent.h index 6f0d5b8a5..d58e80cf7 100644 --- a/src/components/ImageGridComponent.h +++ b/src/components/ImageGridComponent.h @@ -13,7 +13,22 @@ struct ImageGridData template class ImageGridComponent : public IList { +protected: + using IList::mEntries; + using IList::listUpdate; + using IList::listInput; + using IList::listRenderTitleOverlay; + using IList::getTransform; + using IList::mSize; + using IList::mCursor; + using IList::Entry; + using IList::mWindow; + public: + using IList::size; + using IList::isScrolling; + using IList::stopScrolling; + ImageGridComponent(Window* window); void add(const std::string& name, const std::string& imagePath, const T& obj); @@ -79,7 +94,7 @@ private: }; template -ImageGridComponent::ImageGridComponent(Window* window) : IList(window) +ImageGridComponent::ImageGridComponent(Window* window) : IList(window) { mEntriesDirty = true; } @@ -87,7 +102,7 @@ ImageGridComponent::ImageGridComponent(Window* window) : IList(window) template void ImageGridComponent::add(const std::string& name, const std::string& imagePath, const T& obj) { - Entry entry; + typename IList::Entry entry; entry.name = name; entry.object = obj; entry.data.texture = ResourceManager::getInstance()->fileExists(imagePath) ? TextureResource::get(imagePath) : TextureResource::get(":/button.png"); @@ -148,7 +163,7 @@ void ImageGridComponent::render(const Eigen::Affine3f& parentTrans) it->render(trans); } - renderChildren(trans); + GuiComponent::renderChildren(trans); } template diff --git a/src/components/TextListComponent.h b/src/components/TextListComponent.h index 6ed8249a2..973709321 100644 --- a/src/components/TextListComponent.h +++ b/src/components/TextListComponent.h @@ -22,7 +22,21 @@ struct TextListData template class TextListComponent : public IList { +protected: + using IList::mEntries; + using IList::listUpdate; + using IList::listInput; + using IList::listRenderTitleOverlay; + using IList::getTransform; + using IList::mSize; + using IList::mCursor; + using IList::Entry; + public: + using IList::size; + using IList::isScrolling; + using IList::stopScrolling; + TextListComponent(Window* window); bool input(InputConfig* config, Input input) override; @@ -46,7 +60,7 @@ public: inline void setFont(const std::shared_ptr& font) { mFont = font; - mTitleOverlayFont = Font::get(FONT_SIZE_LARGE, mFont->getPath()); + this->mTitleOverlayFont = Font::get(FONT_SIZE_LARGE, mFont->getPath()); for(auto it = mEntries.begin(); it != mEntries.end(); it++) it->data.textCache.reset(); @@ -62,6 +76,7 @@ protected: virtual void onScroll(int amt) { if(mScrollSound) mScrollSound->play(); } virtual void onCursorChanged(const CursorState& state); + private: static const int MARQUEE_DELAY = 900; static const int MARQUEE_SPEED = 16; @@ -85,7 +100,7 @@ private: template TextListComponent::TextListComponent(Window* window) : - IList(window) + IList(window) { mMarqueeOffset = 0; mMarqueeTime = -MARQUEE_DELAY; @@ -137,7 +152,7 @@ void TextListComponent::render(const Eigen::Affine3f& parentTrans) if(listCutoff > size()) listCutoff = size(); - Eigen::Vector3f dim(getSize().x(), getSize().y(), 0); + Eigen::Vector3f dim(mSize.x(), mSize.y(), 0); dim = trans * dim - trans.translation(); Renderer::pushClipRect(Eigen::Vector2i((int)trans.translation().x(), (int)trans.translation().y()), Eigen::Vector2i((int)dim.x(), (int)dim.y())); @@ -147,10 +162,10 @@ void TextListComponent::render(const Eigen::Affine3f& parentTrans) if(mCursor == i) { Renderer::setMatrix(trans); - Renderer::drawRect(0, (int)y, (int)getSize().x(), font->getHeight(), mSelectorColor); + Renderer::drawRect(0, (int)y, (int)mSize.x(), font->getHeight(), mSelectorColor); } - Entry& entry = mEntries.at((unsigned int)i); + typename IList::Entry& entry = mEntries.at((unsigned int)i); unsigned int color; if(mCursor == i && mSelectedColor) @@ -256,7 +271,7 @@ void TextListComponent::update(int deltaTime) Eigen::Vector2f textSize = mFont->sizeText(text); //it's long enough to marquee - if(textSize.x() - mMarqueeOffset > getSize().x() - 12 - (mAlignment != ALIGN_CENTER ? mHorizontalMargin : 0)) + if(textSize.x() - mMarqueeOffset > mSize.x() - 12 - (mAlignment != ALIGN_CENTER ? mHorizontalMargin : 0)) { mMarqueeTime += deltaTime; while(mMarqueeTime > MARQUEE_SPEED) @@ -276,7 +291,7 @@ void TextListComponent::add(const std::string& name, const T& obj, unsigned i { assert(color < COLOR_ID_COUNT); - Entry entry; + typename IList::Entry entry; entry.name = name; entry.object = obj; entry.data.colorId = color; @@ -336,7 +351,7 @@ void TextListComponent::applyTheme(const std::shared_ptr& theme, c } if(elem->has("horizontalMargin")) { - mHorizontalMargin = elem->get("horizontalMargin") * (mParent ? mParent->getSize().x() : (float)Renderer::getScreenWidth()); + mHorizontalMargin = elem->get("horizontalMargin") * (this->mParent ? this->mParent->getSize().x() : (float)Renderer::getScreenWidth()); } } }