mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-02 22:28:45 +00:00
Better UI
This commit is contained in:
parent
c1195fdb2b
commit
fa3d4b06aa
1 changed files with 27 additions and 11 deletions
|
@ -345,7 +345,7 @@ ImeDialogUi::~ImeDialogUi() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ImeDialogUi::ImeDialogUi(ImeDialogUi&& other) noexcept
|
ImeDialogUi::ImeDialogUi(ImeDialogUi&& other) noexcept
|
||||||
: state(other.state), status(other.status), result(other.result) {
|
: state(other.state), status(other.status), result(other.result), first_render(other.first_render) {
|
||||||
|
|
||||||
std::scoped_lock lock(draw_mutex, other.draw_mutex);
|
std::scoped_lock lock(draw_mutex, other.draw_mutex);
|
||||||
other.state = nullptr;
|
other.state = nullptr;
|
||||||
|
@ -364,6 +364,7 @@ ImeDialogUi& ImeDialogUi::operator=(ImeDialogUi&& other) {
|
||||||
state = other.state;
|
state = other.state;
|
||||||
status = other.status;
|
status = other.status;
|
||||||
result = other.result;
|
result = other.result;
|
||||||
|
first_render = other.first_render;
|
||||||
other.state = nullptr;
|
other.state = nullptr;
|
||||||
other.status = nullptr;
|
other.status = nullptr;
|
||||||
other.result = nullptr;
|
other.result = nullptr;
|
||||||
|
@ -396,9 +397,9 @@ void ImeDialogUi::Draw() {
|
||||||
ImVec2 window_size;
|
ImVec2 window_size;
|
||||||
|
|
||||||
if (state->is_multiLine) {
|
if (state->is_multiLine) {
|
||||||
window_size = {400.0f, 200.0f};
|
window_size = {500.0f, 300.0f};
|
||||||
} else {
|
} else {
|
||||||
window_size = {400.0f, 100.0f};
|
window_size = {500.0f, 150.0f};
|
||||||
}
|
}
|
||||||
|
|
||||||
CentralizeWindow();
|
CentralizeWindow();
|
||||||
|
@ -409,17 +410,13 @@ void ImeDialogUi::Draw() {
|
||||||
SetNextWindowFocus();
|
SetNextWindowFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
first_render = false;
|
|
||||||
|
|
||||||
if (Begin("IME Dialog##ImeDialog", nullptr, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings)) {
|
if (Begin("IME Dialog##ImeDialog", nullptr, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings)) {
|
||||||
DrawPrettyBackground();
|
DrawPrettyBackground();
|
||||||
Separator();
|
|
||||||
|
|
||||||
if (state->title) {
|
if (state->title) {
|
||||||
SetWindowFontScale(1.7f);
|
SetWindowFontScale(1.7f);
|
||||||
TextUnformatted(state->title);
|
TextUnformatted(state->title);
|
||||||
SetWindowFontScale(1.0f);
|
SetWindowFontScale(1.0f);
|
||||||
Separator();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->is_multiLine) {
|
if (state->is_multiLine) {
|
||||||
|
@ -428,7 +425,7 @@ void ImeDialogUi::Draw() {
|
||||||
DrawInputText();
|
DrawInputText();
|
||||||
}
|
}
|
||||||
|
|
||||||
Separator();
|
SetCursorPosY(GetCursorPosY() + 10.0f);
|
||||||
|
|
||||||
const char* button_text;
|
const char* button_text;
|
||||||
|
|
||||||
|
@ -448,29 +445,48 @@ void ImeDialogUi::Draw() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float button_spacing = 10.0f;
|
||||||
|
float total_button_width = BUTTON_SIZE.x * 2 + button_spacing;
|
||||||
|
float button_start_pos = (window_size.x - total_button_width) / 2.0f;
|
||||||
|
|
||||||
|
SetCursorPosX(button_start_pos);
|
||||||
|
|
||||||
if (Button(button_text, BUTTON_SIZE)) {
|
if (Button(button_text, BUTTON_SIZE)) {
|
||||||
*status = OrbisImeDialogStatus::FINISHED;
|
*status = OrbisImeDialogStatus::FINISHED;
|
||||||
result->endstatus = OrbisImeDialogEndStatus::OK;
|
result->endstatus = OrbisImeDialogEndStatus::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SameLine(0.0f, button_spacing);
|
||||||
|
|
||||||
if (Button("Cancel##ImeDialogCancel", BUTTON_SIZE)) {
|
if (Button("Cancel##ImeDialogCancel", BUTTON_SIZE)) {
|
||||||
*status = OrbisImeDialogStatus::FINISHED;
|
*status = OrbisImeDialogStatus::FINISHED;
|
||||||
result->endstatus = OrbisImeDialogEndStatus::USER_CANCELED;
|
result->endstatus = OrbisImeDialogEndStatus::USER_CANCELED;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
End();
|
End();
|
||||||
|
|
||||||
|
first_render = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImeDialogUi::DrawInputText() {
|
void ImeDialogUi::DrawInputText() {
|
||||||
if (InputTextEx("##ImeDialogInput", state->placeholder, state->current_text, state->max_text_length, ImVec2(0, 0), ImGuiInputTextFlags_CallbackCharFilter, InputTextCallback, this)) {
|
ImVec2 input_size = {GetWindowWidth() - 40.0f, 0.0f};
|
||||||
|
SetCursorPosX(20.0f);
|
||||||
|
if (first_render) {
|
||||||
|
SetKeyboardFocusHere();
|
||||||
|
}
|
||||||
|
if (InputTextEx("##ImeDialogInput", state->placeholder, state->current_text, state->max_text_length, input_size, ImGuiInputTextFlags_CallbackCharFilter, InputTextCallback, this)) {
|
||||||
state->input_changed = true;
|
state->input_changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImeDialogUi::DrawMultiLineInputText() {
|
void ImeDialogUi::DrawMultiLineInputText() {
|
||||||
|
ImVec2 input_size = {GetWindowWidth() - 40.0f, 200.0f};
|
||||||
|
SetCursorPosX(20.0f);
|
||||||
ImGuiInputTextFlags flags = ImGuiInputTextFlags_CallbackCharFilter | static_cast<ImGuiInputTextFlags>(ImGuiInputTextFlags_Multiline);
|
ImGuiInputTextFlags flags = ImGuiInputTextFlags_CallbackCharFilter | static_cast<ImGuiInputTextFlags>(ImGuiInputTextFlags_Multiline);
|
||||||
if (InputTextEx("##ImeDialogInput", state->placeholder, state->current_text, state->max_text_length, ImVec2(380.0f, 100.0f), flags, InputTextCallback, this)) {
|
if (first_render) {
|
||||||
|
SetKeyboardFocusHere();
|
||||||
|
}
|
||||||
|
if (InputTextEx("##ImeDialogInput", state->placeholder, state->current_text, state->max_text_length, input_size, flags, InputTextCallback, this)) {
|
||||||
state->input_changed = true;
|
state->input_changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue