More design tweaks.

Fixed some DateTime sizing stuff to be less weird.
This commit is contained in:
Aloshi 2014-03-25 14:14:09 -05:00
parent 4fafd58da0
commit 98eda43bab
4 changed files with 19 additions and 14 deletions

View file

@ -7,9 +7,8 @@
DateTimeComponent::DateTimeComponent(Window* window, DisplayMode dispMode) : GuiComponent(window), DateTimeComponent::DateTimeComponent(Window* window, DisplayMode dispMode) : GuiComponent(window),
mEditing(false), mEditIndex(0), mDisplayMode(dispMode), mRelativeUpdateAccumulator(0), 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(); updateTextCache();
} }
@ -253,7 +252,9 @@ void DateTimeComponent::updateTextCache()
const std::string dispString = getDisplayString(mode); const std::string dispString = getDisplayString(mode);
std::shared_ptr<Font> font = getFont(); std::shared_ptr<Font> font = getFont();
mTextCache = std::unique_ptr<TextCache>(font->buildTextCache(dispString, 0, 0, mColor)); mTextCache = std::unique_ptr<TextCache>(font->buildTextCache(dispString, 0, 0, mColor));
setSize(mTextCache->metrics.size);
if(!mSizeSet)
mSize = mTextCache->metrics.size;
//set up cursor positions //set up cursor positions
mCursorBoxes.clear(); mCursorBoxes.clear();
@ -292,10 +293,12 @@ void DateTimeComponent::setColor(unsigned int color)
void DateTimeComponent::setFont(std::shared_ptr<Font> font) void DateTimeComponent::setFont(std::shared_ptr<Font> font)
{ {
mFont = font; mFont = font;
updateTextCache();
}
if(getSize().y() < mFont->getHeight()) void DateTimeComponent::onSizeChanged()
setSize(getSize().x(), (float)mFont->getHeight()); {
mSizeSet = true;
updateTextCache(); updateTextCache();
} }

View file

@ -23,6 +23,7 @@ public:
bool input(InputConfig* config, Input input) override; bool input(InputConfig* config, Input input) override;
void update(int deltaTime) override; void update(int deltaTime) override;
void render(const Eigen::Affine3f& parentTrans) override; void render(const Eigen::Affine3f& parentTrans) override;
void onSizeChanged() override;
// Set how the point in time will be displayed: // Set how the point in time will be displayed:
// * DISP_DATE - only display the date. // * DISP_DATE - only display the date.
@ -58,4 +59,6 @@ private:
unsigned int mColor; unsigned int mColor;
std::shared_ptr<Font> mFont; std::shared_ptr<Font> mFont;
bool mSizeSet;
}; };

View file

@ -67,7 +67,7 @@ ScraperSearchComponent::ScraperSearchComponent(Window* window, SearchType type)
i++; i++;
} }
mGrid.setEntry(mMD_Grid, Vector2i(2, 1), false, true); mGrid.setEntry(mMD_Grid, Vector2i(2, 1), false, false);
// result list // result list
mResultList = std::make_shared<ComponentList>(mWindow); mResultList = std::make_shared<ComponentList>(mWindow);
@ -87,10 +87,8 @@ void ScraperSearchComponent::onSizeChanged()
mGrid.setColWidthPerc(3, 0.49f); mGrid.setColWidthPerc(3, 0.49f);
// row heights // row heights
const float fontHeightPerc = (mResultName->getFont()->getHeight()) / mGrid.getSize().y();
if(mSearchType == ALWAYS_ACCEPT_FIRST_RESULT) // show name 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 else
mGrid.setRowHeightPerc(0, 0.05f); // hide name but do padding 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 // 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 // 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 // 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()) if(mMD_Grid->getSize().y() > mMD_Pairs.size())
{ {
const int fontHeight = (int)(mMD_Grid->getSize().y() / mMD_Pairs.size() * 0.8f); const int fontHeight = (int)(mMD_Grid->getSize().y() / mMD_Pairs.size() * 0.8f);
@ -130,10 +127,12 @@ void ScraperSearchComponent::onSizeChanged()
// rating is manually sized // rating is manually sized
mMD_Rating->setSize(mMD_Grid->getColWidth(1), fontLbl->getLetterHeight()); mMD_Rating->setSize(mMD_Grid->getColWidth(1), fontLbl->getLetterHeight());
mMD_Grid->onSizeChanged();
// make result font follow label font // make result font follow label font
mResultDesc->setFont(Font::get(fontHeight, FONT_PATH_REGULAR)); mResultDesc->setFont(Font::get(fontHeight, FONT_PATH_REGULAR));
} }
mGrid.onSizeChanged();
mResultDesc->setSize(mDescContainer->getSize().x(), 0); // make desc text wrap at edge of container mResultDesc->setSize(mDescContainer->getSize().x(), 0); // make desc text wrap at edge of container
} }

View file

@ -47,7 +47,7 @@ GuiScraperMulti::GuiScraperMulti(Window* window, const std::queue<ScraperSearchP
mButtonGrid = makeButtonGrid(mWindow, buttons); mButtonGrid = makeButtonGrid(mWindow, buttons);
mGrid.setEntry(mButtonGrid, Vector2i(0, 4), true, false); mGrid.setEntry(mButtonGrid, Vector2i(0, 4), true, false);
setSize(Renderer::getScreenWidth() * 0.85f, Renderer::getScreenHeight() * 0.849f); setSize(Renderer::getScreenWidth() * 0.875f, Renderer::getScreenHeight() * 0.849f);
setPosition((Renderer::getScreenWidth() - mSize.x()) / 2, (Renderer::getScreenHeight() - mSize.y()) / 2); setPosition((Renderer::getScreenWidth() - mSize.x()) / 2, (Renderer::getScreenHeight() - mSize.y()) / 2);
doNextSearch(); doNextSearch();