From 98eda43bab836b7045ab03e8256aed8a3283fb09 Mon Sep 17 00:00:00 2001 From: Aloshi Date: Tue, 25 Mar 2014 14:14:09 -0500 Subject: [PATCH] More design tweaks. Fixed some DateTime sizing stuff to be less weird. --- src/components/DateTimeComponent.cpp | 15 +++++++++------ src/components/DateTimeComponent.h | 3 +++ src/components/ScraperSearchComponent.cpp | 13 ++++++------- src/guis/GuiScraperMulti.cpp | 2 +- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/components/DateTimeComponent.cpp b/src/components/DateTimeComponent.cpp index 0bed43bd3..cf62d06e6 100644 --- a/src/components/DateTimeComponent.cpp +++ b/src/components/DateTimeComponent.cpp @@ -7,9 +7,8 @@ DateTimeComponent::DateTimeComponent(Window* window, DisplayMode dispMode) : GuiComponent(window), mEditing(false), mEditIndex(0), mDisplayMode(dispMode), mRelativeUpdateAccumulator(0), - mColor(0x777777FF), mFont(Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT)) + mColor(0x777777FF), mFont(Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT)), mSizeSet(false) { - mSize << 64, getFont()->getHeight(); updateTextCache(); } @@ -253,7 +252,9 @@ void DateTimeComponent::updateTextCache() const std::string dispString = getDisplayString(mode); std::shared_ptr font = getFont(); mTextCache = std::unique_ptr(font->buildTextCache(dispString, 0, 0, mColor)); - setSize(mTextCache->metrics.size); + + if(!mSizeSet) + mSize = mTextCache->metrics.size; //set up cursor positions mCursorBoxes.clear(); @@ -292,10 +293,12 @@ void DateTimeComponent::setColor(unsigned int color) void DateTimeComponent::setFont(std::shared_ptr font) { mFont = font; + updateTextCache(); +} - if(getSize().y() < mFont->getHeight()) - setSize(getSize().x(), (float)mFont->getHeight()); - +void DateTimeComponent::onSizeChanged() +{ + mSizeSet = true; updateTextCache(); } diff --git a/src/components/DateTimeComponent.h b/src/components/DateTimeComponent.h index 2df70b08b..039cf17bd 100644 --- a/src/components/DateTimeComponent.h +++ b/src/components/DateTimeComponent.h @@ -23,6 +23,7 @@ public: bool input(InputConfig* config, Input input) override; void update(int deltaTime) override; void render(const Eigen::Affine3f& parentTrans) override; + void onSizeChanged() override; // Set how the point in time will be displayed: // * DISP_DATE - only display the date. @@ -58,4 +59,6 @@ private: unsigned int mColor; std::shared_ptr mFont; + + bool mSizeSet; }; diff --git a/src/components/ScraperSearchComponent.cpp b/src/components/ScraperSearchComponent.cpp index abefdcaa3..2bcfb81e1 100644 --- a/src/components/ScraperSearchComponent.cpp +++ b/src/components/ScraperSearchComponent.cpp @@ -67,7 +67,7 @@ ScraperSearchComponent::ScraperSearchComponent(Window* window, SearchType type) i++; } - mGrid.setEntry(mMD_Grid, Vector2i(2, 1), false, true); + mGrid.setEntry(mMD_Grid, Vector2i(2, 1), false, false); // result list mResultList = std::make_shared(mWindow); @@ -87,10 +87,8 @@ void ScraperSearchComponent::onSizeChanged() mGrid.setColWidthPerc(3, 0.49f); // row heights - const float fontHeightPerc = (mResultName->getFont()->getHeight()) / mGrid.getSize().y(); - if(mSearchType == ALWAYS_ACCEPT_FIRST_RESULT) // show name - mGrid.setRowHeightPerc(0, fontHeightPerc); // result name + mGrid.setRowHeightPerc(0, (mResultName->getFont()->getHeight()) / mGrid.getSize().y()); // result name else mGrid.setRowHeightPerc(0, 0.05f); // hide name but do padding @@ -98,11 +96,10 @@ void ScraperSearchComponent::onSizeChanged() // limit thumbnail size using setMaxHeight - we do this instead of letting mGrid call setSize because it maintains the aspect ratio // we also pad a little so it doesn't rub up against the metadata labels - mResultThumbnail->setMaxSize(mGrid.getColWidth(1) - 16, mGrid.getRowHeight(1)); + mResultThumbnail->setMaxSize(mGrid.getColWidth(1) * 0.85f, mGrid.getRowHeight(1) * 0.85f); // metadata - // (mMD_Grid has already been resized by mGrid) - + mMD_Grid->setSize(mGrid.getColWidth(2), mGrid.getRowHeight(1) * 0.9f); if(mMD_Grid->getSize().y() > mMD_Pairs.size()) { const int fontHeight = (int)(mMD_Grid->getSize().y() / mMD_Pairs.size() * 0.8f); @@ -130,10 +127,12 @@ void ScraperSearchComponent::onSizeChanged() // rating is manually sized mMD_Rating->setSize(mMD_Grid->getColWidth(1), fontLbl->getLetterHeight()); + mMD_Grid->onSizeChanged(); // make result font follow label font mResultDesc->setFont(Font::get(fontHeight, FONT_PATH_REGULAR)); } + mGrid.onSizeChanged(); mResultDesc->setSize(mDescContainer->getSize().x(), 0); // make desc text wrap at edge of container } diff --git a/src/guis/GuiScraperMulti.cpp b/src/guis/GuiScraperMulti.cpp index 7b606680e..068e5a284 100644 --- a/src/guis/GuiScraperMulti.cpp +++ b/src/guis/GuiScraperMulti.cpp @@ -47,7 +47,7 @@ GuiScraperMulti::GuiScraperMulti(Window* window, const std::queue