mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-26 16:15:39 +00:00
Scraper GUIs open faster.
The ScraperSearchComponent uses a custom font size for metadata/descriptions. This was causing a short hang when it got resized multiple times (because it would rasterize like 4 fonts unnecessarily). So, I added an "update" parameter to ComponentGrid::setRowHeightPerc/setColWidthPerc. This can be used to only cause *one* resize/reposition "event" when setting multiple cell sizes (as is typical) by passing "false" as the last argument and then using ComponentGrid::setSize after setting all of the cell sizes.
This commit is contained in:
parent
330f45d5fe
commit
654b93dd94
|
@ -62,20 +62,24 @@ float ComponentGrid::getRowHeight(int row)
|
||||||
return (freeHeightPerc * mSize.y()) / between;
|
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(width >= 0 && width <= 1);
|
||||||
assert(col >= 0 && col < mGridSize.x());
|
assert(col >= 0 && col < mGridSize.x());
|
||||||
mColWidths[col] = width;
|
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(height >= 0 && height <= 1);
|
||||||
assert(row >= 0 && row < mGridSize.y());
|
assert(row >= 0 && row < mGridSize.y());
|
||||||
mRowHeights[row] = height;
|
mRowHeights[row] = height;
|
||||||
onSizeChanged();
|
|
||||||
|
if(update)
|
||||||
|
onSizeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComponentGrid::setEntry(const std::shared_ptr<GuiComponent>& comp, const Eigen::Vector2i& pos, bool canFocus, bool resize, const Eigen::Vector2i& size,
|
void ComponentGrid::setEntry(const std::shared_ptr<GuiComponent>& comp, const Eigen::Vector2i& pos, bool canFocus, bool resize, const Eigen::Vector2i& size,
|
||||||
|
|
|
@ -46,8 +46,8 @@ public:
|
||||||
float getColWidth(int col);
|
float getColWidth(int col);
|
||||||
float getRowHeight(int row);
|
float getRowHeight(int row);
|
||||||
|
|
||||||
void setColWidthPerc(int col, float width);
|
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);
|
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);
|
bool moveCursor(Eigen::Vector2i dir);
|
||||||
void setCursorTo(const std::shared_ptr<GuiComponent>& comp);
|
void setCursorTo(const std::shared_ptr<GuiComponent>& comp);
|
||||||
|
|
|
@ -32,6 +32,7 @@ public:
|
||||||
void search(const ScraperSearchParams& params);
|
void search(const ScraperSearchParams& params);
|
||||||
void openInputScreen(ScraperSearchParams& from);
|
void openInputScreen(ScraperSearchParams& from);
|
||||||
void stop();
|
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).
|
// 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<void(const ScraperSearchResult&)>& acceptCallback) { mAcceptCallback = acceptCallback; }
|
inline void setAcceptCallback(const std::function<void(const ScraperSearchResult&)>& acceptCallback) { mAcceptCallback = acceptCallback; }
|
||||||
|
|
|
@ -84,13 +84,13 @@ void GuiGameScraper::onSizeChanged()
|
||||||
{
|
{
|
||||||
mBox.fitTo(mSize, Eigen::Vector3f::Zero(), Eigen::Vector2f(-32, -32));
|
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.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)
|
bool GuiGameScraper::input(InputConfig* config, Input input)
|
||||||
|
|
|
@ -40,7 +40,7 @@ GuiScraperMulti::GuiScraperMulti(Window* window, const std::queue<ScraperSearchP
|
||||||
mSearchComp->setAcceptCallback(std::bind(&GuiScraperMulti::acceptResult, this, std::placeholders::_1));
|
mSearchComp->setAcceptCallback(std::bind(&GuiScraperMulti::acceptResult, this, std::placeholders::_1));
|
||||||
mSearchComp->setSkipCallback(std::bind(&GuiScraperMulti::skip, this));
|
mSearchComp->setSkipCallback(std::bind(&GuiScraperMulti::skip, this));
|
||||||
mSearchComp->setCancelCallback(std::bind(&GuiScraperMulti::finish, 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<ButtonComponent> > buttons;
|
std::vector< std::shared_ptr<ButtonComponent> > buttons;
|
||||||
|
|
||||||
|
@ -78,12 +78,12 @@ GuiScraperMulti::~GuiScraperMulti()
|
||||||
void GuiScraperMulti::onSizeChanged()
|
void GuiScraperMulti::onSizeChanged()
|
||||||
{
|
{
|
||||||
mBackground.fitTo(mSize, Vector3f::Zero(), Vector2f(-32, -32));
|
mBackground.fitTo(mSize, Vector3f::Zero(), Vector2f(-32, -32));
|
||||||
mGrid.setSize(mSize);
|
|
||||||
|
|
||||||
mGrid.setRowHeightPerc(0, mTitle->getFont()->getLetterHeight() * 1.9725f / mGrid.getSize().y());
|
mGrid.setRowHeightPerc(0, mTitle->getFont()->getLetterHeight() * 1.9725f / mSize.y(), false);
|
||||||
mGrid.setRowHeightPerc(1, (mSystem->getFont()->getLetterHeight() + 2) / mGrid.getSize().y());
|
mGrid.setRowHeightPerc(1, (mSystem->getFont()->getLetterHeight() + 2) / mSize.y(), false);
|
||||||
mGrid.setRowHeightPerc(2, mSubtitle->getFont()->getHeight() * 1.75f / mGrid.getSize().y());
|
mGrid.setRowHeightPerc(2, mSubtitle->getFont()->getHeight() * 1.75f / mSize.y(), false);
|
||||||
mGrid.setRowHeightPerc(4, mButtonGrid->getSize().y() / mGrid.getSize().y());
|
mGrid.setRowHeightPerc(4, mButtonGrid->getSize().y() / mSize.y(), false);
|
||||||
|
mGrid.setSize(mSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiScraperMulti::doNextSearch()
|
void GuiScraperMulti::doNextSearch()
|
||||||
|
|
Loading…
Reference in a new issue