mirror of
https://github.com/stenzek/duckstation.git
synced 2026-07-11 01:24:11 +02:00
FullscreenUI: Fix styling of input string dialogs
This commit is contained in:
@@ -3471,7 +3471,7 @@ void FullscreenUI::DoSaveNewInputProfile()
|
||||
{
|
||||
OpenInputStringDialog(FSUI_ICONSTR(ICON_FA_FLOPPY_DISK, "Save Controller Preset"),
|
||||
FSUI_STR("Enter the name of the controller preset you wish to create."), std::string(),
|
||||
FSUI_ICONSTR(ICON_FA_FOLDER_PLUS, "Create"), [](std::string title) {
|
||||
FSUI_ICONSTR(ICON_FA_FOLDER_PLUS, "Create"), std::string(), [](std::string title) {
|
||||
if (!title.empty())
|
||||
DoSaveInputProfile(title);
|
||||
});
|
||||
|
||||
@@ -354,7 +354,7 @@ public:
|
||||
~InputStringDialog();
|
||||
|
||||
void Open(std::string_view title, std::string message, std::string caption, std::string ok_button_text,
|
||||
InputStringDialogCallback callback);
|
||||
std::string initial_value, InputStringDialogCallback callback);
|
||||
void ClearState();
|
||||
|
||||
void Draw();
|
||||
@@ -5716,10 +5716,11 @@ bool FullscreenUI::IsInputDialogOpen()
|
||||
}
|
||||
|
||||
void FullscreenUI::OpenInputStringDialog(std::string_view title, std::string message, std::string caption,
|
||||
std::string ok_button_text, InputStringDialogCallback callback)
|
||||
std::string ok_button_text, std::string initial_value,
|
||||
InputStringDialogCallback callback)
|
||||
{
|
||||
s_state.input_string_dialog.Open(title, std::move(message), std::move(caption), std::move(ok_button_text),
|
||||
std::move(callback));
|
||||
std::move(initial_value), std::move(callback));
|
||||
QueueResetFocus(FocusResetType::PopupOpened);
|
||||
}
|
||||
|
||||
@@ -5728,12 +5729,14 @@ FullscreenUI::InputStringDialog::InputStringDialog() = default;
|
||||
FullscreenUI::InputStringDialog::~InputStringDialog() = default;
|
||||
|
||||
void FullscreenUI::InputStringDialog::Open(std::string_view title, std::string message, std::string caption,
|
||||
std::string ok_button_text, InputStringDialogCallback callback)
|
||||
std::string ok_button_text, std::string initial_value,
|
||||
InputStringDialogCallback callback)
|
||||
{
|
||||
SetTitleAndOpen(fmt::format("{}##input_string_dialog", title));
|
||||
m_message = std::move(message);
|
||||
m_caption = std::move(caption);
|
||||
m_ok_text = std::move(ok_button_text);
|
||||
m_text = std::move(initial_value);
|
||||
m_callback = std::move(callback);
|
||||
}
|
||||
|
||||
@@ -5764,27 +5767,30 @@ void FullscreenUI::InputStringDialog::Draw()
|
||||
ResetFocusHere();
|
||||
ImGui::TextWrapped("%s", m_message.c_str());
|
||||
|
||||
BeginMenuButtons();
|
||||
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + LayoutScale(10.0f));
|
||||
|
||||
if (!m_caption.empty())
|
||||
{
|
||||
const float prev = ImGui::GetCursorPosX();
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::TextUnformatted(IMSTR_START_END(m_caption));
|
||||
ImGui::SetNextItemWidth(ImGui::GetCursorPosX() - prev);
|
||||
ImGui::SameLine(0.0f, LayoutScale(10.0f));
|
||||
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::SetNextItemWidth(ImGui::GetCurrentWindow()->WorkRect.GetWidth());
|
||||
}
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, LayoutScale(LAYOUT_WIDGET_FRAME_ROUNDING));
|
||||
ImGui::InputText("##input", &m_text);
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + LayoutScale(10.0f));
|
||||
|
||||
const bool ok_enabled = !m_text.empty();
|
||||
|
||||
if (MenuButtonWithoutSummary(m_ok_text, ok_enabled) && ok_enabled)
|
||||
BeginHorizontalMenuButtons(2, 200.0f);
|
||||
|
||||
if (HorizontalMenuButton(m_ok_text, ok_enabled) && ok_enabled)
|
||||
{
|
||||
// have to move out in case they open another dialog in the callback
|
||||
const InputStringDialogCallback cb = std::exchange(m_callback, InputStringDialogCallback());
|
||||
@@ -5793,10 +5799,10 @@ void FullscreenUI::InputStringDialog::Draw()
|
||||
cb(std::move(text));
|
||||
}
|
||||
|
||||
if (MenuButtonWithoutSummary(ICON_FA_XMARK " Cancel"))
|
||||
if (HorizontalMenuButton(FSUI_ICONVSTR(ICON_FA_XMARK, "Cancel")))
|
||||
StartClose();
|
||||
|
||||
EndMenuButtons();
|
||||
EndHorizontalMenuButtons();
|
||||
|
||||
if (IsGamepadInputSource())
|
||||
{
|
||||
@@ -6061,8 +6067,7 @@ void FullscreenUI::ProgressDialog::Draw()
|
||||
else
|
||||
{
|
||||
const float animation_frac = Easing::OutExpo(m_animation_time / PROGRESS_BAR_ANIMATION_TIME);
|
||||
m_last_frac = m_animation_start_frac +
|
||||
((m_animation_target_frac - m_animation_start_frac) * animation_frac);
|
||||
m_last_frac = m_animation_start_frac + ((m_animation_target_frac - m_animation_start_frac) * animation_frac);
|
||||
}
|
||||
}
|
||||
frac = m_last_frac;
|
||||
|
||||
@@ -579,7 +579,7 @@ void CloseDropdownDialog();
|
||||
using InputStringDialogCallback = std::function<void(std::string text)>;
|
||||
bool IsInputDialogOpen();
|
||||
void OpenInputStringDialog(std::string_view title, std::string message, std::string caption, std::string ok_button_text,
|
||||
InputStringDialogCallback callback);
|
||||
std::string initial_value, InputStringDialogCallback callback);
|
||||
void CloseInputDialog();
|
||||
|
||||
using ConfirmMessageDialogCallback = std::function<void(bool)>;
|
||||
|
||||
Reference in New Issue
Block a user