[upstream_utils] Update imgui and implot (#8762)

Not updating GLFW yet due to a likely future move to SDL.
This commit is contained in:
Peter Johnson
2026-04-12 12:19:32 -07:00
committed by GitHub
parent d76486d885
commit 476b9641c1
47 changed files with 27710 additions and 12792 deletions

View File

@@ -27,6 +27,8 @@ namespace gui = wpi::gui;
const char* GetWPILibVersion();
extern ImGuiKey ImGui_ImplGlfw_KeyToImGuiKey(int keycode, int scancode);
namespace wpi::glass {
std::string_view GetResource_glass_16_png();
std::string_view GetResource_glass_32_png();
@@ -54,6 +56,7 @@ static bool gAbout = false;
static bool gSetEnterKey = false;
static bool gKeyEdit = false;
static int* gEnterKey;
static int* gEnterScancode;
static void (*gPrevKeyCallback)(GLFWwindow*, int, int, int, int);
static bool gNetworkTablesDebugLog = false;
static unsigned int gPrevMode = NT_NET_MODE_NONE;
@@ -64,7 +67,7 @@ static void RemapEnterKeyCallback(GLFWwindow* window, int key, int scancode,
if (gKeyEdit) {
*gEnterKey = key;
gKeyEdit = false;
} else if (*gEnterKey == key) {
} else if (*gEnterKey == key || *gEnterScancode == scancode) {
key = GLFW_KEY_ENTER;
}
}
@@ -221,7 +224,7 @@ int main(int argc, char** argv) {
gui::AddIcon(wpi::glass::GetResource_glass_512_png());
gui::AddEarlyExecute(
[] { ImGui::DockSpaceOverViewport(ImGui::GetMainViewport()); });
[] { ImGui::DockSpaceOverViewport(0, ImGui::GetMainViewport()); });
gui::AddInit([] { ImGui::GetIO().ConfigDockingWithShift = true; });
@@ -330,7 +333,11 @@ int main(int argc, char** argv) {
ImGui::SameLine();
char editLabel[40];
char nameBuf[32];
const char* name = glfwGetKeyName(*gEnterKey, 0);
const char* name = glfwGetKeyName(*gEnterKey, *gEnterScancode);
if (!name) {
name = ImGui::GetKeyName(
ImGui_ImplGlfw_KeyToImGuiKey(*gEnterKey, *gEnterScancode));
}
if (!name) {
wpi::util::format_to_n_c_str(nameBuf, sizeof(nameBuf), "{}",
*gEnterKey);
@@ -346,6 +353,7 @@ int main(int argc, char** argv) {
ImGui::SameLine();
if (ImGui::SmallButton("Reset")) {
*gEnterKey = GLFW_KEY_ENTER;
*gEnterScancode = glfwGetKeyScancode(GLFW_KEY_ENTER);
}
if (ImGui::Button("Close")) {
@@ -359,6 +367,8 @@ int main(int argc, char** argv) {
gui::Initialize("Glass - DISCONNECTED", 1024, 768,
ImGuiConfigFlags_DockingEnable);
gEnterKey = &wpi::glass::GetStorageRoot().GetInt("enterKey", GLFW_KEY_ENTER);
gEnterScancode = &wpi::glass::GetStorageRoot().GetInt(
"enterScancode", glfwGetKeyScancode(GLFW_KEY_ENTER));
if (auto win = gui::GetSystemWindow()) {
gPrevKeyCallback = glfwSetKeyCallback(win, RemapEnterKeyCallback);
}

View File

@@ -543,8 +543,8 @@ bool wpi::glass::ItemEditName(std::string* name) {
if (ImGui::InputText("##editname", name)) {
rv = true;
}
if (ImGui::Button("Close") || ImGui::IsKeyPressedMap(ImGuiKey_Enter) ||
ImGui::IsKeyPressedMap(ImGuiKey_KeyPadEnter)) {
if (ImGui::Button("Close") || ImGui::IsKeyPressed(ImGuiKey_Enter) ||
ImGui::IsKeyPressed(ImGuiKey_KeypadEnter)) {
ImGui::CloseCurrentPopup();
}

View File

@@ -59,9 +59,9 @@ bool wpi::glass::DisplayPneumaticControlSolenoids(PneumaticControlModel* model,
// header
bool open = CollapsingHeader(label);
ImGui::SetNextItemAllowOverlap();
PopupEditName("header", &name);
ImGui::SetItemAllowOverlap();
ImGui::SameLine();
// show channels as LED indicators

View File

@@ -384,12 +384,12 @@ PlotSeries::Action PlotSeries::EmitPlot(PlotView& view, double now, size_t i,
if (m_color.GetColorFloat()[3] == IMPLOT_AUTO) {
SetColor(ImPlot::GetColormapColor(i));
}
ImPlot::SetNextLineStyle(m_color.GetColor(), m_weight);
ImPlotSpec spec{ImPlotProp_LineColor, m_color.GetColor(),
ImPlotProp_LineWeight, m_weight};
if (IsDigital()) {
ImPlot::PushStyleVar(ImPlotStyleVar_DigitalBitHeight, m_digitalBitHeight);
ImPlot::PushStyleVar(ImPlotStyleVar_DigitalBitGap, m_digitalBitGap);
ImPlot::PlotDigitalG(label, getter, &getterData, size + 1);
ImPlot::PopStyleVar();
spec.SetProp(ImPlotProp_Size, m_digitalBitHeight);
ImPlot::PushStyleVar(ImPlotStyleVar_DigitalSpacing, m_digitalBitGap);
ImPlot::PlotDigitalG(label, getter, &getterData, size + 1, spec);
ImPlot::PopStyleVar();
} else {
if (ImPlot::GetCurrentPlot()->YAxis(m_yAxis).Enabled) {
@@ -397,8 +397,8 @@ PlotSeries::Action PlotSeries::EmitPlot(PlotView& view, double now, size_t i,
} else {
ImPlot::SetAxis(ImAxis_Y1);
}
ImPlot::SetNextMarkerStyle(m_marker.GetValue() - 1);
ImPlot::PlotLineG(label, getter, &getterData, size + 1);
spec.SetProp(ImPlotProp_Marker, m_marker.GetValue() - 1);
ImPlot::PlotLineG(label, getter, &getterData, size + 1, spec);
}
// DND source for PlotSeries

View File

@@ -97,8 +97,8 @@ bool NameSetting::PopupEditName(int index) {
if (InputTextName("##edit")) {
rv = true;
}
if (ImGui::Button("Close") || ImGui::IsKeyPressedMap(ImGuiKey_Enter) ||
ImGui::IsKeyPressedMap(ImGuiKey_KeyPadEnter)) {
if (ImGui::Button("Close") || ImGui::IsKeyPressed(ImGuiKey_Enter) ||
ImGui::IsKeyPressed(ImGuiKey_KeypadEnter)) {
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
@@ -117,8 +117,8 @@ bool NameSetting::PopupEditName(const char* name) {
if (InputTextName("##edit")) {
rv = true;
}
if (ImGui::Button("Close") || ImGui::IsKeyPressedMap(ImGuiKey_Enter) ||
ImGui::IsKeyPressedMap(ImGuiKey_KeyPadEnter)) {
if (ImGui::Button("Close") || ImGui::IsKeyPressed(ImGuiKey_Enter) ||
ImGui::IsKeyPressed(ImGuiKey_KeypadEnter)) {
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();

View File

@@ -1898,9 +1898,8 @@ static void EmitEntry(NetworkTablesModel* model,
bool havePopup = GetHeadingTypeString(&ts);
wpi::util::format_to_n_c_str(label, sizeof(label), "{}##v_{}", ts.data(),
entry.info.name.c_str());
valueChildrenOpen =
TreeNodeEx(label, ImGuiTreeNodeFlags_SpanFullWidth |
ImGuiTreeNodeFlags_AllowItemOverlap);
valueChildrenOpen = TreeNodeEx(label, ImGuiTreeNodeFlags_SpanFullWidth |
ImGuiTreeNodeFlags_AllowOverlap);
if (havePopup) {
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();