Files
allwpilib/simulation/halsim_gui/src/main/native/cpp/HALSimGui.cpp

58 lines
1.6 KiB
C++
Raw Normal View History

// Copyright (c) FIRST and other WPILib contributors.
// 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.
2025-11-07 19:56:21 -05:00
#include "wpi/halsim/gui/HALSimGui.hpp"
2024-09-20 17:43:39 -07:00
#include <memory>
#include <utility>
2025-11-07 19:57:55 -05:00
#include <imgui.h>
2025-11-07 19:56:21 -05:00
#include "wpi/glass/Context.hpp"
#include "wpi/glass/Storage.hpp"
#include "wpi/gui/wpigui.hpp"
using namespace halsimgui;
glass::MainMenuBar HALSimGui::mainMenu;
std::unique_ptr<glass::WindowManager> HALSimGui::manager;
std::unique_ptr<HALProvider> HALSimGui::halProvider;
std::unique_ptr<glass::NetworkTablesProvider> HALSimGui::ntProvider;
void HALSimGui::GlobalInit() {
manager = std::make_unique<glass::WindowManager>(
glass::GetStorageRoot().GetChild("SimWindow"));
manager->GlobalInit();
halProvider = std::make_unique<HALProvider>(
glass::GetStorageRoot().GetChild("HALProvider"));
halProvider->GlobalInit();
ntProvider = std::make_unique<glass::NetworkTablesProvider>(
glass::GetStorageRoot().GetChild("NTProvider"));
ntProvider->GlobalInit();
wpi::gui::AddLateExecute([] { mainMenu.Display(); });
glass::AddStandardNetworkTablesViews(*ntProvider);
}
namespace halsimgui {
void AddGuiInit(std::function<void()> initialize) {
wpi::gui::AddInit(std::move(initialize));
}
void AddGuiEarlyExecute(std::function<void()> execute) {
wpi::gui::AddEarlyExecute(std::move(execute));
}
void AddGuiLateExecute(std::function<void()> execute) {
wpi::gui::AddLateExecute(std::move(execute));
}
void GuiExit() {
wpi::gui::Exit();
}
} // namespace halsimgui