diff --git a/src/components/ComponentGrid.cpp b/src/components/ComponentGrid.cpp index 5a015daac..18bff6bab 100644 --- a/src/components/ComponentGrid.cpp +++ b/src/components/ComponentGrid.cpp @@ -62,20 +62,24 @@ float ComponentGrid::getRowHeight(int row) return (freeHeightPerc * mSize.y()) / between; } -void ComponentGrid::setColWidthPerc(int col, float width) +void ComponentGrid::setColWidthPerc(int col, float width, bool update) { assert(width >= 0 && width <= 1); assert(col >= 0 && col < mGridSize.x()); mColWidths[col] = width; - onSizeChanged(); + + if(update) + onSizeChanged(); } -void ComponentGrid::setRowHeightPerc(int row, float height) +void ComponentGrid::setRowHeightPerc(int row, float height, bool update) { assert(height >= 0 && height <= 1); assert(row >= 0 && row < mGridSize.y()); mRowHeights[row] = height; - onSizeChanged(); + + if(update) + onSizeChanged(); } void ComponentGrid::setEntry(const std::shared_ptr& comp, const Eigen::Vector2i& pos, bool canFocus, bool resize, const Eigen::Vector2i& size, diff --git a/src/components/ComponentGrid.h b/src/components/ComponentGrid.h index 0cd756cce..68a45ab1b 100644 --- a/src/components/ComponentGrid.h +++ b/src/components/ComponentGrid.h @@ -46,8 +46,8 @@ public: float getColWidth(int col); float getRowHeight(int row); - void setColWidthPerc(int col, float width); - void setRowHeightPerc(int row, float height); + void setColWidthPerc(int col, float width, bool update = true); // if update is false, will not call an onSizeChanged() which triggers a (potentially costly) repositioning + resizing of every element + void setRowHeightPerc(int row, float height, bool update = true); // if update is false, will not call an onSizeChanged() which triggers a (potentially costly) repositioning + resizing of every element bool moveCursor(Eigen::Vector2i dir); void setCursorTo(const std::shared_ptr& comp); diff --git a/src/components/ScraperSearchComponent.h b/src/components/ScraperSearchComponent.h index 612bb1e85..80e339b82 100644 --- a/src/components/ScraperSearchComponent.h +++ b/src/components/ScraperSearchComponent.h @@ -32,6 +32,7 @@ public: void search(const ScraperSearchParams& params); void openInputScreen(ScraperSearchParams& from); void stop(); + inline SearchType getSearchType() const { return mSearchType; } // Metadata assets will be resolved before calling the accept callback (e.g. result.mdl's "image" is automatically downloaded and properly set). inline void setAcceptCallback(const std::function& acceptCallback) { mAcceptCallback = acceptCallback; } diff --git a/src/guis/GuiGameScraper.cpp b/src/guis/GuiGameScraper.cpp index 6430ebf6f..6307fad8d 100644 --- a/src/guis/GuiGameScraper.cpp +++ b/src/guis/GuiGameScraper.cpp @@ -84,13 +84,13 @@ void GuiGameScraper::onSizeChanged() { mBox.fitTo(mSize, Eigen::Vector3f::Zero(), Eigen::Vector2f(-32, -32)); + mGrid.setRowHeightPerc(0, 0.04f, false); + mGrid.setRowHeightPerc(1, mGameName->getFont()->getLetterHeight() / mSize.y(), false); // game name + mGrid.setRowHeightPerc(2, 0.04f, false); + mGrid.setRowHeightPerc(3, mSystemName->getFont()->getLetterHeight() / mSize.y(), false); // system name + mGrid.setRowHeightPerc(4, 0.04f, false); + mGrid.setRowHeightPerc(6, mButtonGrid->getSize().y() / mSize.y(), false); // buttons mGrid.setSize(mSize); - mGrid.setRowHeightPerc(0, 0.04f); - mGrid.setRowHeightPerc(1, mGameName->getFont()->getLetterHeight() / mSize.y()); // game name - mGrid.setRowHeightPerc(2, 0.04f); - mGrid.setRowHeightPerc(3, mSystemName->getFont()->getLetterHeight() / mSize.y()); // system name - mGrid.setRowHeightPerc(4, 0.04f); - mGrid.setRowHeightPerc(6, mButtonGrid->getSize().y() / mSize.y()); // buttons } bool GuiGameScraper::input(InputConfig* config, Input input) diff --git a/src/guis/GuiScraperMulti.cpp b/src/guis/GuiScraperMulti.cpp index 4cc13e9fe..a5b1a879f 100644 --- a/src/guis/GuiScraperMulti.cpp +++ b/src/guis/GuiScraperMulti.cpp @@ -40,7 +40,7 @@ GuiScraperMulti::GuiScraperMulti(Window* window, const std::queuesetAcceptCallback(std::bind(&GuiScraperMulti::acceptResult, this, std::placeholders::_1)); mSearchComp->setSkipCallback(std::bind(&GuiScraperMulti::skip, this)); mSearchComp->setCancelCallback(std::bind(&GuiScraperMulti::finish, this)); - mGrid.setEntry(mSearchComp, Vector2i(0, 3), approveResults, true); + mGrid.setEntry(mSearchComp, Vector2i(0, 3), mSearchComp->getSearchType() != ScraperSearchComponent::ALWAYS_ACCEPT_FIRST_RESULT, true); std::vector< std::shared_ptr > buttons; @@ -78,12 +78,12 @@ GuiScraperMulti::~GuiScraperMulti() void GuiScraperMulti::onSizeChanged() { mBackground.fitTo(mSize, Vector3f::Zero(), Vector2f(-32, -32)); - mGrid.setSize(mSize); - mGrid.setRowHeightPerc(0, mTitle->getFont()->getLetterHeight() * 1.9725f / mGrid.getSize().y()); - mGrid.setRowHeightPerc(1, (mSystem->getFont()->getLetterHeight() + 2) / mGrid.getSize().y()); - mGrid.setRowHeightPerc(2, mSubtitle->getFont()->getHeight() * 1.75f / mGrid.getSize().y()); - mGrid.setRowHeightPerc(4, mButtonGrid->getSize().y() / mGrid.getSize().y()); + mGrid.setRowHeightPerc(0, mTitle->getFont()->getLetterHeight() * 1.9725f / mSize.y(), false); + mGrid.setRowHeightPerc(1, (mSystem->getFont()->getLetterHeight() + 2) / mSize.y(), false); + mGrid.setRowHeightPerc(2, mSubtitle->getFont()->getHeight() * 1.75f / mSize.y(), false); + mGrid.setRowHeightPerc(4, mButtonGrid->getSize().y() / mSize.y(), false); + mGrid.setSize(mSize); } void GuiScraperMulti::doNextSearch()