fix start load button sizing

This commit is contained in:
Green Sky 2024-06-23 10:33:39 +02:00
parent 7c227457cd
commit 780e1e06d4
No known key found for this signature in database

View File

@ -140,6 +140,9 @@ StartScreen::StartScreen(const std::vector<std::string_view>& args, SDL_Renderer
} }
Screen* StartScreen::render(float, bool&) { Screen* StartScreen::render(float, bool&) {
const float TEXT_LOAD_WIDTH = ImGui::CalcTextSize("load").x;
const float TEXT_BASE_HEIGHT = ImGui::GetTextLineHeightWithSpacing();
// TODO: imgui tox profile selector? // TODO: imgui tox profile selector?
@ -252,7 +255,7 @@ Screen* StartScreen::render(float, bool&) {
// load but file missing // load but file missing
ImGui::BeginDisabled(); ImGui::BeginDisabled();
ImGui::Button("load", {60, 25}); ImGui::Button("load", {TEXT_LOAD_WIDTH*1.5f, TEXT_BASE_HEIGHT*1.5f});
ImGui::EndDisabled(); ImGui::EndDisabled();
if (ImGui::IsItemHovered(ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_AllowWhenDisabled)) { if (ImGui::IsItemHovered(ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_AllowWhenDisabled)) {
@ -262,14 +265,14 @@ Screen* StartScreen::render(float, bool&) {
// new but file exists // new but file exists
ImGui::BeginDisabled(); ImGui::BeginDisabled();
ImGui::Button("load", {60, 25}); ImGui::Button("load", {TEXT_LOAD_WIDTH*1.5f, TEXT_BASE_HEIGHT*1.5f});
ImGui::EndDisabled(); ImGui::EndDisabled();
if (ImGui::IsItemHovered(ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_AllowWhenDisabled)) { if (ImGui::IsItemHovered(ImGuiHoveredFlags_ForTooltip | ImGuiHoveredFlags_AllowWhenDisabled)) {
ImGui::SetTooltip("file already exists"); ImGui::SetTooltip("file already exists");
} }
} else { } else {
if (ImGui::Button("load", {60, 25})) { if (ImGui::Button("load", {TEXT_LOAD_WIDTH*1.5f, TEXT_BASE_HEIGHT*1.5f})) {
auto new_screen = std::make_unique<MainScreen>(std::move(_conf), _renderer, _theme, _tox_profile_path, _password, _user_name, queued_plugin_paths); auto new_screen = std::make_unique<MainScreen>(std::move(_conf), _renderer, _theme, _tox_profile_path, _password, _user_name, queued_plugin_paths);
return new_screen.release(); return new_screen.release();