From a95a5e0d9bc4c4fa70571efda849fcbc8a100463 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sat, 6 Mar 2021 22:19:00 -0800 Subject: [PATCH] [glass] Move NetworkTablesSettings to libglassnt (#3224) --- glass/src/app/native/cpp/main.cpp | 6 +++--- .../{app => libnt}/native/cpp/NetworkTablesSettings.cpp | 8 ++++++-- .../include/glass/networktables}/NetworkTablesSettings.h | 6 +++++- 3 files changed, 14 insertions(+), 6 deletions(-) rename glass/src/{app => libnt}/native/cpp/NetworkTablesSettings.cpp (93%) rename glass/src/{app/native/cpp => libnt/native/include/glass/networktables}/NetworkTablesSettings.h (92%) diff --git a/glass/src/app/native/cpp/main.cpp b/glass/src/app/native/cpp/main.cpp index 247e352652..62821538bf 100644 --- a/glass/src/app/native/cpp/main.cpp +++ b/glass/src/app/native/cpp/main.cpp @@ -10,12 +10,12 @@ #include #include -#include "NetworkTablesSettings.h" #include "glass/Context.h" #include "glass/Model.h" #include "glass/View.h" #include "glass/networktables/NetworkTables.h" #include "glass/networktables/NetworkTablesProvider.h" +#include "glass/networktables/NetworkTablesSettings.h" #include "glass/other/Log.h" #include "glass/other/Plot.h" @@ -37,7 +37,7 @@ static std::unique_ptr gPlotProvider; static std::unique_ptr gNtProvider; static std::unique_ptr gNetworkTablesModel; -static std::unique_ptr gNetworkTablesSettings; +static std::unique_ptr gNetworkTablesSettings; static glass::LogData gNetworkTablesLog; static glass::Window* gNetworkTablesWindow; static glass::Window* gNetworkTablesSettingsWindow; @@ -111,7 +111,7 @@ static void NtInitialize() { } // NetworkTables settings window - gNetworkTablesSettings = std::make_unique(); + gNetworkTablesSettings = std::make_unique(); gui::AddEarlyExecute([] { gNetworkTablesSettings->Update(); }); gNetworkTablesSettingsWindow = gNtProvider->AddWindow( diff --git a/glass/src/app/native/cpp/NetworkTablesSettings.cpp b/glass/src/libnt/native/cpp/NetworkTablesSettings.cpp similarity index 93% rename from glass/src/app/native/cpp/NetworkTablesSettings.cpp rename to glass/src/libnt/native/cpp/NetworkTablesSettings.cpp index f9f234048c..c495c7a662 100644 --- a/glass/src/app/native/cpp/NetworkTablesSettings.cpp +++ b/glass/src/libnt/native/cpp/NetworkTablesSettings.cpp @@ -2,7 +2,7 @@ // Open Source Software; you can modify and/or share it under the terms of // the WPILib BSD license file in the root directory of this project. -#include "NetworkTablesSettings.h" +#include "glass/networktables/NetworkTablesSettings.h" #include @@ -15,6 +15,8 @@ #include "glass/Context.h" +using namespace glass; + NetworkTablesSettings::NetworkTablesSettings(NT_Inst inst, const char* storageName) : m_inst{inst} { @@ -53,7 +55,7 @@ void NetworkTablesSettings::Update() { } } -void NetworkTablesSettings::Display() { +bool NetworkTablesSettings::Display() { static const char* modeOptions[] = {"Disabled", "Client", "Server"}; ImGui::Combo("Mode", m_pMode, modeOptions, 3); switch (*m_pMode) { @@ -69,5 +71,7 @@ void NetworkTablesSettings::Display() { } if (ImGui::Button("Apply")) { m_restart = true; + return true; } + return false; } diff --git a/glass/src/app/native/cpp/NetworkTablesSettings.h b/glass/src/libnt/native/include/glass/networktables/NetworkTablesSettings.h similarity index 92% rename from glass/src/app/native/cpp/NetworkTablesSettings.h rename to glass/src/libnt/native/include/glass/networktables/NetworkTablesSettings.h index 044372360c..09cbf063bc 100644 --- a/glass/src/app/native/cpp/NetworkTablesSettings.h +++ b/glass/src/libnt/native/include/glass/networktables/NetworkTablesSettings.h @@ -13,6 +13,8 @@ template class SmallVectorImpl; } // namespace wpi +namespace glass { + class NetworkTablesSettings { public: explicit NetworkTablesSettings( @@ -20,7 +22,7 @@ class NetworkTablesSettings { const char* storageName = "NetworkTables Settings"); void Update(); - void Display(); + bool Display(); private: NT_Inst m_inst; @@ -30,3 +32,5 @@ class NetworkTablesSettings { std::string* m_pServerTeam; std::string* m_pListenAddress; }; + +} // namespace glass