From 0438a0df2c9107330d696b1d7056f6379db661ca Mon Sep 17 00:00:00 2001 From: Michael Theall Date: Tue, 1 Jun 2021 20:01:15 -0500 Subject: [PATCH] Fix config button sizes --- Makefile.3ds | 2 +- Makefile.nds | 2 +- Makefile.switch | 2 +- source/ftpServer.cpp | 36 ++++++++++++++++++++++++++++++------ 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/Makefile.3ds b/Makefile.3ds index e8d869a..f31477f 100644 --- a/Makefile.3ds +++ b/Makefile.3ds @@ -52,7 +52,7 @@ RSF_FILE := meta/ftpd-classic-cia.rsf endif APP_DESCRIPTION := v$(VERSION) -APP_AUTHOR := (c) 2014-2020 Michael Theall, Dave Murphy, TuxSH +APP_AUTHOR := (c) 2021 Michael Theall, Dave Murphy, TuxSH ICON := meta/icon.png BNR_IMAGE := meta/banner.png diff --git a/Makefile.nds b/Makefile.nds index 25c2ebc..283da3d 100644 --- a/Makefile.nds +++ b/Makefile.nds @@ -35,7 +35,7 @@ NITRO := # These set the information text in the nds file GAME_TITLE := ftpd classic GAME_SUBTITLE1 := v$(VERSION) -GAME_SUBTITLE2 := (c) 2014-2020 mtheall +GAME_SUBTITLE2 := (c) 2021 mtheall #--------------------------------------------------------------------------------- # options for code generation diff --git a/Makefile.switch b/Makefile.switch index 953cbfc..2141f46 100644 --- a/Makefile.switch +++ b/Makefile.switch @@ -37,7 +37,7 @@ include $(DEVKITPRO)/libnx/switch_rules # of a homebrew executable (.nro). This is intended to be used for sysmodules. # NACP building is skipped as well. #--------------------------------------------------------------------------------- -APP_AUTHOR := (c) 2014-2020 Michael Theall, Dave Murphy, TuxSH +APP_AUTHOR := (c) 2021 Michael Theall, Dave Murphy, TuxSH ICON := meta/ftpd.jpg APP_VERSION := $(VERSION) diff --git a/source/ftpServer.cpp b/source/ftpServer.cpp index 37ac7de..00d0354 100644 --- a/source/ftpServer.cpp +++ b/source/ftpServer.cpp @@ -3,7 +3,7 @@ // - RFC 3659 (https://tools.ietf.org/html/rfc3659) // - suggested implementation details from https://cr.yp.to/ftp/filesystem.html // -// Copyright (C) 2020 Michael Theall +// Copyright (C) 2021 Michael Theall // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -448,13 +449,34 @@ void FtpServer::showSettings () ImGui::TextColored (ImVec4 (1.0f, 0.4f, 0.4f, 1.0f), passphraseError); #endif - auto const apply = ImGui::Button ("Apply", ImVec2 (75, 0)); + static ImVec2 const sizes[] = { + ImGui::CalcTextSize ("Apply"), + ImGui::CalcTextSize ("Save"), + ImGui::CalcTextSize ("Reset"), + ImGui::CalcTextSize ("Cancel"), + }; + + static auto const maxWidth = std::max_element ( + std::begin (sizes), std::end (sizes), [] (auto const &lhs_, auto const &rhs_) { + return lhs_.x < rhs_.x; + })->x; + + static auto const maxHeight = std::max_element ( + std::begin (sizes), std::end (sizes), [] (auto const &lhs_, auto const &rhs_) { + return lhs_.y < rhs_.y; + })->y; + + auto const &style = ImGui::GetStyle (); + auto const width = maxWidth + 2 * style.FramePadding.x; + auto const height = maxHeight + 2 * style.FramePadding.y; + + auto const apply = ImGui::Button ("Apply", ImVec2 (width, height)); ImGui::SameLine (); - auto const save = ImGui::Button ("Save", ImVec2 (75, 0)); + auto const save = ImGui::Button ("Save", ImVec2 (width, height)); ImGui::SameLine (); - auto const reset = ImGui::Button ("Reset", ImVec2 (75, 0)); + auto const reset = ImGui::Button ("Reset", ImVec2 (width, height)); ImGui::SameLine (); - auto const cancel = ImGui::Button ("Cancel", ImVec2 (75, 0)); + auto const cancel = ImGui::Button ("Cancel", ImVec2 (width, height)); if (apply || save) { @@ -539,7 +561,7 @@ void FtpServer::showAbout () ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize)) { ImGui::TextUnformatted (STATUS_STRING); - ImGui::TextWrapped ("Copyright © 2014-2020 Michael Theall, Dave Murphy, TuxSH"); + ImGui::TextWrapped ("Copyright © 2021 Michael Theall, Dave Murphy, TuxSH"); ImGui::Separator (); ImGui::Text ("Platform: %s", io.BackendPlatformName); ImGui::Text ("Renderer: %s", io.BackendRendererName); @@ -620,6 +642,7 @@ void FtpServer::loop () { if (!m_socket) { +#ifndef CLASSIC #ifdef __SWITCH__ if (!m_apError) { @@ -636,6 +659,7 @@ void FtpServer::loop () m_apError = !platform::enableAP (enable, ssid, passphrase); } +#endif #endif if (platform::networkVisible ())