[glass] Move NetworkTablesSettings to libglassnt (#3224)

This commit is contained in:
Peter Johnson
2021-03-06 22:19:00 -08:00
committed by GitHub
parent d6f6ceaba5
commit a95a5e0d9b
3 changed files with 14 additions and 6 deletions

View File

@@ -10,12 +10,12 @@
#include <wpi/SmallString.h>
#include <wpigui.h>
#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<glass::PlotProvider> gPlotProvider;
static std::unique_ptr<glass::NetworkTablesProvider> gNtProvider;
static std::unique_ptr<glass::NetworkTablesModel> gNetworkTablesModel;
static std::unique_ptr<NetworkTablesSettings> gNetworkTablesSettings;
static std::unique_ptr<glass::NetworkTablesSettings> 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<NetworkTablesSettings>();
gNetworkTablesSettings = std::make_unique<glass::NetworkTablesSettings>();
gui::AddEarlyExecute([] { gNetworkTablesSettings->Update(); });
gNetworkTablesSettingsWindow = gNtProvider->AddWindow(

View File

@@ -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 <utility>
@@ -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;
}

View File

@@ -13,6 +13,8 @@ template <typename T>
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