mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 15:45:38 +00:00
Multiple layout improvements when running in vertical screen orientation.
Also cleaned up some code.
This commit is contained in:
parent
589068f747
commit
a2e400dd2b
|
@ -21,6 +21,7 @@
|
|||
|
||||
GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(std::string title)
|
||||
: GuiSettings {title}
|
||||
, mRenderer {Renderer::getInstance()}
|
||||
, mAddedCustomCollection {false}
|
||||
, mDeletedCustomCollection {false}
|
||||
{
|
||||
|
@ -217,9 +218,11 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(std::string title)
|
|||
|
||||
if (Settings::getInstance()->getBool("VirtualKeyboard")) {
|
||||
row.makeAcceptInputHandler([this, createCollectionCall] {
|
||||
mWindow->pushGui(new GuiTextEditKeyboardPopup(getHelpStyle(), "New Collection Name", "",
|
||||
createCollectionCall, false, "CREATE",
|
||||
"CREATE COLLECTION?"));
|
||||
const float verticalPosition {
|
||||
mRenderer->getIsVerticalOrientation() ? getMenu().getPosition().y : 0.0f};
|
||||
mWindow->pushGui(new GuiTextEditKeyboardPopup(
|
||||
getHelpStyle(), verticalPosition, "New Collection Name", "", createCollectionCall,
|
||||
false, "CREATE", "CREATE COLLECTION?"));
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
@ -304,8 +307,9 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(std::string title)
|
|||
// Make the menu slightly wider to fit the scroll indicators.
|
||||
glm::vec2 menuSize {ss->getMenuSize()};
|
||||
glm::vec3 menuPos {ss->getMenuPosition()};
|
||||
ss->setMenuSize(glm::vec2 {menuSize.x * 1.08f, menuSize.y});
|
||||
menuPos.x = (Renderer::getScreenWidth() - ss->getMenuSize().x) / 2.0f;
|
||||
const float maxWidthModifier {mRenderer->getIsVerticalOrientation() ? 1.0f : 1.08f};
|
||||
ss->setMenuSize(glm::vec2 {menuSize.x * maxWidthModifier, menuSize.y});
|
||||
menuPos.x = (mRenderer->getScreenWidth() - ss->getMenuSize().x) / 2.0f;
|
||||
ss->setMenuPosition(menuPos);
|
||||
mWindow->pushGui(ss);
|
||||
});
|
||||
|
|
|
@ -22,6 +22,7 @@ public:
|
|||
private:
|
||||
void createCustomCollection(std::string inName);
|
||||
|
||||
Renderer* mRenderer;
|
||||
std::shared_ptr<OptionListComponent<std::string>> mCollectionSystemsAuto;
|
||||
std::shared_ptr<OptionListComponent<std::string>> mCollectionSystemsCustom;
|
||||
|
||||
|
|
|
@ -118,9 +118,11 @@ void GuiGamelistFilter::addFiltersToMenu()
|
|||
|
||||
if (Settings::getInstance()->getBool("VirtualKeyboard")) {
|
||||
row.makeAcceptInputHandler([this, updateVal] {
|
||||
mWindow->pushGui(new GuiTextEditKeyboardPopup(getHelpStyle(), "GAME NAME",
|
||||
mTextFilterField->getValue(), updateVal,
|
||||
false, "OK", "APPLY CHANGES?"));
|
||||
const float verticalPosition {
|
||||
Renderer::getIsVerticalOrientation() ? mMenu.getPosition().y : 0.0f};
|
||||
mWindow->pushGui(new GuiTextEditKeyboardPopup(
|
||||
getHelpStyle(), verticalPosition, "GAME NAME", mTextFilterField->getValue(),
|
||||
updateVal, false, "OK", "APPLY CHANGES?"));
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -1179,11 +1179,22 @@ void GuiMenu::openConfigInput(GuiSettings* settings)
|
|||
// the input device settings menu later on.
|
||||
settings->setNeedsSaving(false);
|
||||
|
||||
std::string message {"THE KEYBOARD AND CONTROLLERS ARE AUTOMATICALLY\n"
|
||||
"CONFIGURED, BUT USING THIS CONFIGURATION TOOL\n"
|
||||
"YOU CAN OVERRIDE THE DEFAULT BUTTON MAPPINGS\n"
|
||||
"(THIS WILL NOT AFFECT THE HELP PROMPTS)\n"
|
||||
"CONTINUE?"};
|
||||
std::string message;
|
||||
if (Renderer::getIsVerticalOrientation()) {
|
||||
message = "THE KEYBOARD AND CONTROLLERS ARE\n"
|
||||
"AUTOMATICALLY CONFIGURED, BUT USING\n"
|
||||
"THIS CONFIGURATION TOOL YOU CAN\n"
|
||||
"OVERRIDE THE DEFAULT BUTTON MAPPINGS\n"
|
||||
"(THIS WILL NOT AFFECT THE HELP PROMPTS)\n"
|
||||
"CONTINUE?";
|
||||
}
|
||||
else {
|
||||
message = "THE KEYBOARD AND CONTROLLERS ARE AUTOMATICALLY\n"
|
||||
"CONFIGURED, BUT USING THIS CONFIGURATION TOOL\n"
|
||||
"YOU CAN OVERRIDE THE DEFAULT BUTTON MAPPINGS\n"
|
||||
"(THIS WILL NOT AFFECT THE HELP PROMPTS)\n"
|
||||
"CONTINUE?";
|
||||
}
|
||||
|
||||
Window* window {mWindow};
|
||||
window->pushGui(new GuiMsgBox(
|
||||
|
@ -1228,14 +1239,15 @@ void GuiMenu::openOtherOptions()
|
|||
ViewController::getInstance()->reloadAll();
|
||||
mWindow->invalidateCachedBackground();
|
||||
};
|
||||
rowMediaDir.makeAcceptInputHandler([this, titleMediaDir, mediaDirectoryStaticText,
|
||||
rowMediaDir.makeAcceptInputHandler([this, s, titleMediaDir, mediaDirectoryStaticText,
|
||||
defaultDirectoryText, initValueMediaDir, updateValMediaDir,
|
||||
multiLineMediaDir] {
|
||||
if (Settings::getInstance()->getBool("VirtualKeyboard")) {
|
||||
mWindow->pushGui(new GuiTextEditKeyboardPopup(
|
||||
getHelpStyle(), titleMediaDir, Settings::getInstance()->getString("MediaDirectory"),
|
||||
updateValMediaDir, multiLineMediaDir, "SAVE", "SAVE CHANGES?",
|
||||
mediaDirectoryStaticText, defaultDirectoryText, "load default directory"));
|
||||
getHelpStyle(), s->getMenu().getPosition().y, titleMediaDir,
|
||||
Settings::getInstance()->getString("MediaDirectory"), updateValMediaDir,
|
||||
multiLineMediaDir, "SAVE", "SAVE CHANGES?", mediaDirectoryStaticText,
|
||||
defaultDirectoryText, "load default directory"));
|
||||
}
|
||||
else {
|
||||
mWindow->pushGui(new GuiTextEditPopup(
|
||||
|
|
|
@ -42,7 +42,8 @@ GuiMetaDataEd::GuiMetaDataEd(MetaDataList* md,
|
|||
std::function<void()> saveCallback,
|
||||
std::function<void()> clearGameFunc,
|
||||
std::function<void()> deleteGameFunc)
|
||||
: mBackground {":/graphics/frame.svg"}
|
||||
: mRenderer {Renderer::getInstance()}
|
||||
, mBackground {":/graphics/frame.svg"}
|
||||
, mGrid {glm::ivec2 {2, 6}}
|
||||
, mScraperParams {scraperParams}
|
||||
, mControllerBadges {BadgeComponent::getGameControllers()}
|
||||
|
@ -160,7 +161,7 @@ GuiMetaDataEd::GuiMetaDataEd(MetaDataList* md,
|
|||
}
|
||||
case MD_RATING: {
|
||||
auto spacer = std::make_shared<GuiComponent>();
|
||||
spacer->setSize(Renderer::getScreenWidth() * 0.0025f, 0.0f);
|
||||
spacer->setSize(mRenderer->getScreenWidth() * 0.0025f, 0.0f);
|
||||
row.addElement(spacer, false);
|
||||
|
||||
ed = std::make_shared<RatingComponent>(true, true);
|
||||
|
@ -176,7 +177,7 @@ GuiMetaDataEd::GuiMetaDataEd(MetaDataList* md,
|
|||
}
|
||||
case MD_DATE: {
|
||||
auto spacer = std::make_shared<GuiComponent>();
|
||||
spacer->setSize(Renderer::getScreenWidth() * 0.0025f, 0.0f);
|
||||
spacer->setSize(mRenderer->getScreenWidth() * 0.0025f, 0.0f);
|
||||
row.addElement(spacer, false);
|
||||
|
||||
ed = std::make_shared<DateTimeEditComponent>(true);
|
||||
|
@ -195,7 +196,7 @@ GuiMetaDataEd::GuiMetaDataEd(MetaDataList* md,
|
|||
row.addElement(ed, true);
|
||||
|
||||
auto spacer = std::make_shared<GuiComponent>();
|
||||
spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0.0f);
|
||||
spacer->setSize(mRenderer->getScreenWidth() * 0.005f, 0.0f);
|
||||
row.addElement(spacer, false);
|
||||
|
||||
auto bracket = std::make_shared<ImageComponent>();
|
||||
|
@ -258,9 +259,9 @@ GuiMetaDataEd::GuiMetaDataEd(MetaDataList* md,
|
|||
s->addRow(row, false);
|
||||
}
|
||||
|
||||
float aspectValue {1.778f / Renderer::getScreenAspectRatio()};
|
||||
float maxWidthModifier {glm::clamp(0.64f * aspectValue, 0.42f, 0.92f)};
|
||||
float maxWidth {Renderer::getScreenWidth() * maxWidthModifier};
|
||||
const float aspectValue {1.778f / mRenderer->getScreenAspectRatio()};
|
||||
const float maxWidthModifier {glm::clamp(0.64f * aspectValue, 0.42f, 0.92f)};
|
||||
const float maxWidth {mRenderer->getScreenWidth() * maxWidthModifier};
|
||||
|
||||
s->setMenuSize(glm::vec2 {maxWidth, s->getMenuSize().y});
|
||||
s->setMenuPosition(
|
||||
|
@ -277,7 +278,7 @@ GuiMetaDataEd::GuiMetaDataEd(MetaDataList* md,
|
|||
row.addElement(ed, true);
|
||||
|
||||
auto spacer = std::make_shared<GuiComponent>();
|
||||
spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0.0f);
|
||||
spacer->setSize(mRenderer->getScreenWidth() * 0.005f, 0.0f);
|
||||
row.addElement(spacer, false);
|
||||
|
||||
auto bracket = std::make_shared<ImageComponent>();
|
||||
|
@ -389,10 +390,10 @@ GuiMetaDataEd::GuiMetaDataEd(MetaDataList* md,
|
|||
s->addRow(row, false);
|
||||
}
|
||||
|
||||
const float aspectValue {1.778f / Renderer::getScreenAspectRatio()};
|
||||
const float aspectValue {1.778f / mRenderer->getScreenAspectRatio()};
|
||||
const float maxWidthModifier {
|
||||
glm::clamp(0.64f * aspectValue, 0.42f, 0.92f)};
|
||||
const float maxWidth {static_cast<float>(Renderer::getScreenWidth()) *
|
||||
const float maxWidth {static_cast<float>(mRenderer->getScreenWidth()) *
|
||||
maxWidthModifier};
|
||||
|
||||
s->setMenuSize(glm::vec2 {maxWidth, s->getMenuSize().y});
|
||||
|
@ -413,7 +414,7 @@ GuiMetaDataEd::GuiMetaDataEd(MetaDataList* md,
|
|||
row.addElement(ed, true);
|
||||
|
||||
auto spacer = std::make_shared<GuiComponent>();
|
||||
spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0.0f);
|
||||
spacer->setSize(mRenderer->getScreenWidth() * 0.005f, 0.0f);
|
||||
row.addElement(spacer, false);
|
||||
|
||||
auto bracket = std::make_shared<ImageComponent>();
|
||||
|
@ -510,9 +511,9 @@ GuiMetaDataEd::GuiMetaDataEd(MetaDataList* md,
|
|||
s->addRow(row, false);
|
||||
}
|
||||
|
||||
float aspectValue {1.778f / Renderer::getScreenAspectRatio()};
|
||||
float maxWidthModifier {glm::clamp(0.64f * aspectValue, 0.42f, 0.92f)};
|
||||
float maxWidth {Renderer::getScreenWidth() * maxWidthModifier};
|
||||
const float aspectValue {1.778f / mRenderer->getScreenAspectRatio()};
|
||||
const float maxWidthModifier {glm::clamp(0.64f * aspectValue, 0.42f, 0.92f)};
|
||||
const float maxWidth {mRenderer->getScreenWidth() * maxWidthModifier};
|
||||
|
||||
s->setMenuSize(glm::vec2 {maxWidth, s->getMenuSize().y});
|
||||
s->setMenuPosition(
|
||||
|
@ -529,7 +530,7 @@ GuiMetaDataEd::GuiMetaDataEd(MetaDataList* md,
|
|||
row.addElement(ed, true);
|
||||
|
||||
auto spacer = std::make_shared<GuiComponent>();
|
||||
spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0.0f);
|
||||
spacer->setSize(mRenderer->getScreenWidth() * 0.005f, 0.0f);
|
||||
row.addElement(spacer, false);
|
||||
|
||||
auto bracket = std::make_shared<ImageComponent>();
|
||||
|
@ -586,9 +587,11 @@ GuiMetaDataEd::GuiMetaDataEd(MetaDataList* md,
|
|||
|
||||
if (Settings::getInstance()->getBool("VirtualKeyboard")) {
|
||||
row.makeAcceptInputHandler([this, title, ed, updateVal, multiLine] {
|
||||
const float verticalPosition {
|
||||
mRenderer->getIsVerticalOrientation() ? mPosition.y : 0.0f};
|
||||
mWindow->pushGui(new GuiTextEditKeyboardPopup(
|
||||
getHelpStyle(), title, ed->getValue(), updateVal, multiLine, "apply",
|
||||
"APPLY CHANGES?", "", ""));
|
||||
getHelpStyle(), verticalPosition, title, ed->getValue(), updateVal,
|
||||
multiLine, "apply", "APPLY CHANGES?", "", ""));
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
@ -699,7 +702,9 @@ GuiMetaDataEd::GuiMetaDataEd(MetaDataList* md,
|
|||
mGrid.setEntry(mButtons, glm::ivec2 {0, 5}, true, false, glm::ivec2 {2, 1});
|
||||
|
||||
// Resize + center.
|
||||
float width {std::min(Renderer::getScreenHeight() * 1.05f, Renderer::getScreenWidth() * 0.90f)};
|
||||
float width {std::min(mRenderer->getScreenHeight() * 1.05f,
|
||||
mRenderer->getScreenWidth() *
|
||||
(mRenderer->getIsVerticalOrientation() ? 0.95f : 0.90f))};
|
||||
|
||||
// Set height explicitly to ten rows for the component list.
|
||||
float height {mList->getRowHeight(0) * 10.0f + mTitle->getSize().y + mSubtitle->getSize().y +
|
||||
|
@ -723,8 +728,8 @@ void GuiMetaDataEd::onSizeChanged()
|
|||
mGrid.setSize(mSize);
|
||||
mBackground.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f});
|
||||
|
||||
setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f,
|
||||
(Renderer::getScreenHeight() - mSize.y) / 2.0f);
|
||||
setPosition((mRenderer->getScreenWidth() - mSize.x) / 2.0f,
|
||||
(mRenderer->getScreenHeight() - mSize.y) / 2.0f);
|
||||
|
||||
// Add some extra margins to the file/folder name.
|
||||
const float newSizeX {mSize.x * 0.96f};
|
||||
|
|
|
@ -46,6 +46,7 @@ private:
|
|||
void fetchDone(const ScraperSearchResult& result);
|
||||
void close();
|
||||
|
||||
Renderer* mRenderer;
|
||||
NinePatchComponent mBackground;
|
||||
ComponentGrid mGrid;
|
||||
|
||||
|
|
|
@ -923,8 +923,8 @@ void GuiScraperSearch::openInputScreen(ScraperSearchParams& params)
|
|||
searchString = Utils::String::replace(searchString, "_", " ");
|
||||
|
||||
if (Settings::getInstance()->getBool("VirtualKeyboard")) {
|
||||
mWindow->pushGui(new GuiTextEditKeyboardPopup(getHelpStyle(), "REFINE SEARCH", searchString,
|
||||
searchForFunc, false, "SEARCH",
|
||||
mWindow->pushGui(new GuiTextEditKeyboardPopup(getHelpStyle(), 0.0f, "REFINE SEARCH",
|
||||
searchString, searchForFunc, false, "SEARCH",
|
||||
"SEARCH USING REFINED NAME?"));
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -23,7 +23,8 @@
|
|||
#include <SDL2/SDL.h>
|
||||
|
||||
GuiSettings::GuiSettings(std::string title)
|
||||
: mMenu {title}
|
||||
: mRenderer {Renderer::getInstance()}
|
||||
, mMenu {title}
|
||||
, mGoToSystem {nullptr}
|
||||
, mNeedsSaving {false}
|
||||
, mNeedsCollectionsUpdate {false}
|
||||
|
@ -213,12 +214,13 @@ void GuiSettings::addEditableTextComponent(const std::string label,
|
|||
row.makeAcceptInputHandler([this, label, ed, updateVal, isPassword] {
|
||||
// Never display the value if it's a password, instead set it to blank.
|
||||
if (isPassword)
|
||||
mWindow->pushGui(new GuiTextEditKeyboardPopup(getHelpStyle(), label, "", updateVal,
|
||||
false, "SAVE", "SAVE CHANGES?"));
|
||||
mWindow->pushGui(
|
||||
new GuiTextEditKeyboardPopup(getHelpStyle(), getMenu().getPosition().y, label,
|
||||
"", updateVal, false, "SAVE", "SAVE CHANGES?"));
|
||||
else
|
||||
mWindow->pushGui(new GuiTextEditKeyboardPopup(getHelpStyle(), label, ed->getValue(),
|
||||
updateVal, false, "SAVE",
|
||||
"SAVE CHANGES?"));
|
||||
mWindow->pushGui(new GuiTextEditKeyboardPopup(
|
||||
getHelpStyle(), getMenu().getPosition().y, label, ed->getValue(), updateVal,
|
||||
false, "SAVE", "SAVE CHANGES?"));
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -64,6 +64,7 @@ public:
|
|||
HelpStyle getHelpStyle() override { return ViewController::getInstance()->getViewHelpStyle(); }
|
||||
|
||||
private:
|
||||
Renderer* mRenderer;
|
||||
MenuComponent mMenu;
|
||||
std::vector<std::function<void()>> mSaveFuncs;
|
||||
SystemData* mGoToSystem;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include "views/ViewController.h"
|
||||
|
||||
#include "CollectionSystemsManager.h"
|
||||
#include "FileFilterIndex.h"
|
||||
#include "InputManager.h"
|
||||
#include "Log.h"
|
||||
|
@ -59,11 +60,11 @@ ViewController* ViewController::getInstance()
|
|||
|
||||
void ViewController::invalidSystemsFileDialog()
|
||||
{
|
||||
std::string errorMessage = "COULDN'T PARSE THE SYSTEMS CONFIGURATION FILE.\n"
|
||||
"IF YOU HAVE A CUSTOMIZED es_systems.xml FILE, THEN\n"
|
||||
"SOMETHING IS LIKELY WRONG WITH YOUR XML SYNTAX.\n"
|
||||
"IF YOU DON'T HAVE A CUSTOM SYSTEMS FILE, THEN THE\n"
|
||||
"EMULATIONSTATION INSTALLATION IS BROKEN. SEE THE\n"
|
||||
std::string errorMessage = "COULDN'T PARSE THE SYSTEMS CONFIGURATION FILE. "
|
||||
"IF YOU HAVE A CUSTOMIZED es_systems.xml FILE, THEN "
|
||||
"SOMETHING IS LIKELY WRONG WITH YOUR XML SYNTAX. "
|
||||
"IF YOU DON'T HAVE A CUSTOM SYSTEMS FILE, THEN THE "
|
||||
"EMULATIONSTATION INSTALLATION IS BROKEN. SEE THE "
|
||||
"APPLICATION LOG FILE es_log.txt FOR ADDITIONAL INFO.";
|
||||
|
||||
mWindow->pushGui(new GuiMsgBox(
|
||||
|
@ -78,11 +79,11 @@ void ViewController::invalidSystemsFileDialog()
|
|||
|
||||
void ViewController::noGamesDialog()
|
||||
{
|
||||
mNoGamesErrorMessage = "NO GAME FILES WERE FOUND. EITHER PLACE YOUR GAMES IN\n"
|
||||
"THE CURRENTLY CONFIGURED ROM DIRECTORY OR CHANGE\n"
|
||||
"ITS PATH USING THE BUTTON BELOW. OPTIONALLY THE ROM\n"
|
||||
"DIRECTORY STRUCTURE CAN BE GENERATED WHICH WILL\n"
|
||||
"CREATE A TEXT FILE FOR EACH SYSTEM PROVIDING SOME\n"
|
||||
mNoGamesErrorMessage = "NO GAME FILES WERE FOUND. EITHER PLACE YOUR GAMES IN "
|
||||
"THE CURRENTLY CONFIGURED ROM DIRECTORY OR CHANGE "
|
||||
"ITS PATH USING THE BUTTON BELOW. OPTIONALLY THE ROM "
|
||||
"DIRECTORY STRUCTURE CAN BE GENERATED WHICH WILL "
|
||||
"CREATE A TEXT FILE FOR EACH SYSTEM PROVIDING SOME "
|
||||
"INFORMATION SUCH AS THE SUPPORTED FILE EXTENSIONS.\n"
|
||||
"THIS IS THE CURRENTLY CONFIGURED ROM DIRECTORY:\n";
|
||||
|
||||
|
@ -103,7 +104,7 @@ void ViewController::noGamesDialog()
|
|||
#endif
|
||||
if (Settings::getInstance()->getBool("VirtualKeyboard")) {
|
||||
mWindow->pushGui(new GuiTextEditKeyboardPopup(
|
||||
HelpStyle(), "ENTER ROM DIRECTORY PATH", currentROMDirectory,
|
||||
HelpStyle(), 0.0f, "ENTER ROM DIRECTORY PATH", currentROMDirectory,
|
||||
[this](const std::string& newROMDirectory) {
|
||||
Settings::getInstance()->setString("ROMDirectory",
|
||||
Utils::String::trim(newROMDirectory));
|
||||
|
|
|
@ -77,6 +77,7 @@ std::vector<std::vector<const char*>> kbLastRowLoad {
|
|||
|
||||
GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
||||
const HelpStyle& helpstyle,
|
||||
const float verticalPosition,
|
||||
const std::string& title,
|
||||
const std::string& initValue,
|
||||
const std::function<void(const std::string&)>& okCallback,
|
||||
|
@ -104,6 +105,7 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
|||
, mDeleteRepeat {false}
|
||||
, mShift {false}
|
||||
, mAlt {false}
|
||||
, mVerticalPosition {verticalPosition}
|
||||
, mDeleteRepeatTimer {0}
|
||||
, mNavigationRepeatTimer {0}
|
||||
, mNavigationRepeatDirX {0}
|
||||
|
@ -129,7 +131,7 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
|||
mHorizontalKeyCount = static_cast<int>(kbLayout[0].size());
|
||||
|
||||
mKeyboardGrid = std::make_shared<ComponentGrid>(
|
||||
glm::ivec2(mHorizontalKeyCount, static_cast<int>(kbLayout.size()) / 3));
|
||||
glm::ivec2 {mHorizontalKeyCount, static_cast<int>(kbLayout.size()) / 3});
|
||||
|
||||
mText = std::make_shared<TextEditComponent>();
|
||||
mText->setValue(initValue);
|
||||
|
@ -137,7 +139,7 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
|||
// Header.
|
||||
mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true);
|
||||
|
||||
int yPos = 1;
|
||||
int yPos {1};
|
||||
|
||||
if (mComplexMode) {
|
||||
mInfoString = std::make_shared<TextComponent>(infoString, Font::get(FONT_SIZE_MEDIUM),
|
||||
|
@ -157,19 +159,19 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
|||
std::vector<std::vector<std::shared_ptr<ButtonComponent>>> buttonList;
|
||||
|
||||
// Create keyboard.
|
||||
for (int i = 0; i < static_cast<int>(kbLayout.size()) / 4; ++i) {
|
||||
for (int i {0}; i < static_cast<int>(kbLayout.size()) / 4; ++i) {
|
||||
std::vector<std::shared_ptr<ButtonComponent>> buttons;
|
||||
|
||||
for (int j = 0; j < static_cast<int>(kbLayout[i].size()); ++j) {
|
||||
std::string lower = kbLayout[4 * i][j];
|
||||
for (int j {0}; j < static_cast<int>(kbLayout[i].size()); ++j) {
|
||||
std::string lower {kbLayout[4 * i][j]};
|
||||
if (lower.empty() || lower == "-rowspan-" || lower == "-colspan-")
|
||||
continue;
|
||||
|
||||
std::string upper = kbLayout[4 * i + 1][j];
|
||||
std::string alted = kbLayout[4 * i + 2][j];
|
||||
std::string altshifted = kbLayout[4 * i + 3][j];
|
||||
std::string upper {kbLayout[4 * i + 1][j]};
|
||||
std::string alted {kbLayout[4 * i + 2][j]};
|
||||
std::string altshifted {kbLayout[4 * i + 3][j]};
|
||||
|
||||
std::shared_ptr<ButtonComponent> button = nullptr;
|
||||
std::shared_ptr<ButtonComponent> button;
|
||||
|
||||
if (lower == "DEL") {
|
||||
lower = DELETE_SYMBOL;
|
||||
|
@ -211,12 +213,12 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
|||
}
|
||||
|
||||
button->setPadding(
|
||||
glm::vec4(BUTTON_GRID_HORIZ_PADDING / 4.0f, BUTTON_GRID_HORIZ_PADDING / 4.0f,
|
||||
BUTTON_GRID_HORIZ_PADDING / 4.0f, BUTTON_GRID_HORIZ_PADDING / 4.0f));
|
||||
glm::vec4 {BUTTON_GRID_HORIZ_PADDING / 4.0f, BUTTON_GRID_HORIZ_PADDING / 4.0f,
|
||||
BUTTON_GRID_HORIZ_PADDING / 4.0f, BUTTON_GRID_HORIZ_PADDING / 4.0f});
|
||||
buttons.push_back(button);
|
||||
|
||||
int colSpan = 1;
|
||||
for (int cs = j + 1; cs < static_cast<int>(kbLayout[i].size()); ++cs) {
|
||||
int colSpan {1};
|
||||
for (int cs {j + 1}; cs < static_cast<int>(kbLayout[i].size()); ++cs) {
|
||||
if (std::string(kbLayout[4 * i][cs]) == "-colspan-")
|
||||
++colSpan;
|
||||
else
|
||||
|
@ -224,7 +226,7 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
|||
}
|
||||
|
||||
int rowSpan = 1;
|
||||
for (int cs = (4 * i) + 4; cs < static_cast<int>(kbLayout.size()); cs += 4) {
|
||||
for (int cs {(4 * i) + 4}; cs < static_cast<int>(kbLayout.size()); cs += 4) {
|
||||
if (std::string(kbLayout[cs][j]) == "-rowspan-")
|
||||
++rowSpan;
|
||||
else
|
||||
|
@ -240,7 +242,7 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
|||
|
||||
mGrid.setEntry(mKeyboardGrid, glm::ivec2 {0, yPos + 1}, true, true, glm::ivec2 {1, 4});
|
||||
|
||||
float textHeight = mText->getFont()->getHeight();
|
||||
float textHeight {mText->getFont()->getHeight()};
|
||||
// If the multiLine option has been set, then include three lines of text on screen.
|
||||
if (multiLine) {
|
||||
textHeight *= 3.0f;
|
||||
|
@ -268,15 +270,20 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
|||
|
||||
// Adapt width to the geometry of the display. The 1.778 aspect ratio is the 16:9 reference.
|
||||
float aspectValue {1.778f / mRenderer->getScreenAspectRatio()};
|
||||
float width {glm::clamp(0.78f * aspectValue, 0.35f, 0.90f) * mRenderer->getScreenWidth()};
|
||||
const float maxWidthMultiplier {mRenderer->getIsVerticalOrientation() ? 0.95f : 0.90f};
|
||||
float width {glm::clamp(0.78f * aspectValue, 0.35f, maxWidthMultiplier) *
|
||||
mRenderer->getScreenWidth()};
|
||||
|
||||
// The combination of multiLine and complex mode is not supported as there is currently
|
||||
// no need for that.
|
||||
if (mMultiLine) {
|
||||
setSize(width, KEYBOARD_HEIGHT + textHeight - mText->getFont()->getHeight());
|
||||
|
||||
setPosition((mRenderer->getScreenWidth() - mSize.x) / 2.0f,
|
||||
(mRenderer->getScreenHeight() - mSize.y) / 2.0f);
|
||||
if (mVerticalPosition == 0.0f)
|
||||
setPosition((mRenderer->getScreenWidth() - mSize.x) / 2.0f,
|
||||
(mRenderer->getScreenHeight() - mSize.y) / 2.0f);
|
||||
else
|
||||
setPosition((mRenderer->getScreenWidth() - mSize.x) / 2.0f, mVerticalPosition);
|
||||
}
|
||||
else {
|
||||
if (mComplexMode)
|
||||
|
@ -284,8 +291,11 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
|||
else
|
||||
setSize(width, KEYBOARD_HEIGHT);
|
||||
|
||||
setPosition((mRenderer->getScreenWidth() - mSize.x) / 2.0f,
|
||||
(mRenderer->getScreenHeight() - mSize.y) / 2.0f);
|
||||
if (mVerticalPosition == 0.0f)
|
||||
setPosition((mRenderer->getScreenWidth() - mSize.x) / 2.0f,
|
||||
(mRenderer->getScreenHeight() - mSize.y) / 2.0f);
|
||||
else
|
||||
setPosition((mRenderer->getScreenWidth() - mSize.x) / 2.0f, mVerticalPosition);
|
||||
}
|
||||
|
||||
if (!multiLine)
|
||||
|
@ -294,7 +304,7 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
|||
|
||||
void GuiTextEditKeyboardPopup::onSizeChanged()
|
||||
{
|
||||
mBackground.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f});
|
||||
mBackground.fitTo(mSize, glm::vec3 {0.0f, 0.0f, 0.0f}, glm::vec2 {-32.0f, -32.0f});
|
||||
mText->setSize(mSize.x - KEYBOARD_PADDINGX - KEYBOARD_PADDINGX, mText->getSize().y);
|
||||
|
||||
// Update grid.
|
||||
|
@ -345,8 +355,8 @@ bool GuiTextEditKeyboardPopup::input(InputConfig* config, Input input)
|
|||
}
|
||||
|
||||
// Ignore whatever key is mapped to the back button so it can be used for text input.
|
||||
bool keyboardBack {config->getDeviceId() == DEVICE_KEYBOARD && mText->isEditing() &&
|
||||
config->isMappedLike("b", input)};
|
||||
const bool keyboardBack {config->getDeviceId() == DEVICE_KEYBOARD && mText->isEditing() &&
|
||||
config->isMappedLike("b", input)};
|
||||
|
||||
// Pressing back (or the escape key if using keyboard input) closes us.
|
||||
if ((config->getDeviceId() == DEVICE_KEYBOARD && input.value && input.id == SDLK_ESCAPE) ||
|
||||
|
@ -391,7 +401,7 @@ bool GuiTextEditKeyboardPopup::input(InputConfig* config, Input input)
|
|||
mDeleteRepeat = true;
|
||||
mDeleteRepeatTimer = -(DELETE_REPEAT_START_DELAY - DELETE_REPEAT_SPEED);
|
||||
|
||||
bool editing = mText->isEditing();
|
||||
const bool editing {mText->isEditing()};
|
||||
if (!editing)
|
||||
mText->startEditing();
|
||||
|
||||
|
@ -410,7 +420,7 @@ bool GuiTextEditKeyboardPopup::input(InputConfig* config, Input input)
|
|||
|
||||
// Right shoulder button inserts a blank space.
|
||||
if (config->isMappedTo("rightshoulder", input) && input.value) {
|
||||
bool editing = mText->isEditing();
|
||||
const bool editing {mText->isEditing()};
|
||||
if (!editing)
|
||||
mText->startEditing();
|
||||
|
||||
|
@ -527,7 +537,7 @@ void GuiTextEditKeyboardPopup::updateDeleteRepeat(int deltaTime)
|
|||
mDeleteRepeatTimer += deltaTime;
|
||||
|
||||
while (mDeleteRepeatTimer >= DELETE_REPEAT_SPEED) {
|
||||
bool editing = mText->isEditing();
|
||||
bool editing {mText->isEditing()};
|
||||
if (!editing)
|
||||
mText->startEditing();
|
||||
|
||||
|
@ -595,7 +605,7 @@ void GuiTextEditKeyboardPopup::shiftKeys()
|
|||
}
|
||||
else {
|
||||
for (auto& kb : mKeyboardButtons) {
|
||||
const std::string& text = mShift ? kb.shiftedKey : kb.key;
|
||||
const std::string& text {mShift ? kb.shiftedKey : kb.key};
|
||||
auto sz = kb.button->getSize();
|
||||
kb.button->setText(text, text, false);
|
||||
kb.button->setSize(sz);
|
||||
|
@ -628,7 +638,7 @@ void GuiTextEditKeyboardPopup::altKeys()
|
|||
}
|
||||
else {
|
||||
for (auto& kb : mKeyboardButtons) {
|
||||
const std::string& text = mAlt ? kb.altedKey : kb.key;
|
||||
const std::string& text {mAlt ? kb.altedKey : kb.key};
|
||||
auto sz = kb.button->getSize();
|
||||
kb.button->setText(text, text, false);
|
||||
kb.button->setSize(sz);
|
||||
|
@ -639,7 +649,7 @@ void GuiTextEditKeyboardPopup::altKeys()
|
|||
void GuiTextEditKeyboardPopup::altShiftKeys()
|
||||
{
|
||||
for (auto& kb : mKeyboardButtons) {
|
||||
const std::string& text = kb.altshiftedKey;
|
||||
const std::string& text {kb.altshiftedKey};
|
||||
auto sz = kb.button->getSize();
|
||||
kb.button->setText(text, text, false);
|
||||
kb.button->setSize(sz);
|
||||
|
@ -652,7 +662,7 @@ std::shared_ptr<ButtonComponent> GuiTextEditKeyboardPopup::makeButton(
|
|||
const std::string& altedKey,
|
||||
const std::string& altshiftedKey)
|
||||
{
|
||||
std::shared_ptr<ButtonComponent> button = std::make_shared<ButtonComponent>(
|
||||
std::shared_ptr<ButtonComponent> button {std::make_shared<ButtonComponent>(
|
||||
key, key,
|
||||
[this, key, shiftedKey, altedKey, altshiftedKey] {
|
||||
if (key == (OK_SYMBOL) || key.find("OK") != std::string::npos) {
|
||||
|
@ -702,9 +712,9 @@ std::shared_ptr<ButtonComponent> GuiTextEditKeyboardPopup::makeButton(
|
|||
|
||||
mText->stopEditing();
|
||||
},
|
||||
false, true);
|
||||
false, true)};
|
||||
|
||||
KeyboardButton kb(button, key, shiftedKey, altedKey, altshiftedKey);
|
||||
KeyboardButton kb {button, key, shiftedKey, altedKey, altshiftedKey};
|
||||
mKeyboardButtons.push_back(kb);
|
||||
return button;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ class GuiTextEditKeyboardPopup : public GuiComponent
|
|||
{
|
||||
public:
|
||||
GuiTextEditKeyboardPopup(const HelpStyle& helpstyle,
|
||||
const float verticalPosition,
|
||||
const std::string& title,
|
||||
const std::string& initValue,
|
||||
const std::function<void(const std::string&)>& okCallback,
|
||||
|
@ -101,6 +102,8 @@ private:
|
|||
bool mShift;
|
||||
bool mAlt;
|
||||
|
||||
float mVerticalPosition;
|
||||
|
||||
int mHorizontalKeyCount;
|
||||
int mDeleteRepeatTimer;
|
||||
int mNavigationRepeatTimer;
|
||||
|
|
Loading…
Reference in a new issue