mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-05 03:21:42 +00:00
[wpigui] Add option to reset UI on exit (#3463)
Also add wpiutil as a dependency for wpigui.
This commit is contained in:
committed by
GitHub
parent
a371235b0d
commit
d29acc90a2
@@ -27,4 +27,5 @@ includeOtherLibs {
|
||||
^imgui
|
||||
^implot
|
||||
^stb
|
||||
^wpi/
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ set_property(TARGET wpigui PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
set_property(TARGET wpigui PROPERTY FOLDER "libraries")
|
||||
|
||||
wpilib_target_warnings(wpigui)
|
||||
target_link_libraries(wpigui PUBLIC imgui)
|
||||
target_link_libraries(wpigui PUBLIC imgui wpiutil)
|
||||
|
||||
target_include_directories(wpigui PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
|
||||
|
||||
@@ -62,6 +62,7 @@ if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxra
|
||||
}
|
||||
binaries.all {
|
||||
nativeUtils.useRequiredLibrary(it, 'imgui_static')
|
||||
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
||||
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.raspbian || it.targetPlatform.name == nativeUtils.wpi.platforms.aarch64bionic) {
|
||||
it.buildable = false
|
||||
return
|
||||
@@ -119,6 +120,7 @@ if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxra
|
||||
binaries.all {
|
||||
lib library: 'wpigui'
|
||||
nativeUtils.useRequiredLibrary(it, 'imgui_static')
|
||||
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <imgui_internal.h>
|
||||
#include <implot.h>
|
||||
#include <stb_image.h>
|
||||
#include <wpi/fs.h>
|
||||
|
||||
#include "wpigui_internal.h"
|
||||
|
||||
@@ -290,6 +291,11 @@ void gui::Main() {
|
||||
ImPlot::DestroyContext();
|
||||
ImGui::DestroyContext();
|
||||
|
||||
// Delete the save file if requested.
|
||||
if (gContext->resetOnExit) {
|
||||
fs::remove(fs::path{gContext->iniPath});
|
||||
}
|
||||
|
||||
glfwDestroyWindow(gContext->window);
|
||||
glfwTerminate();
|
||||
}
|
||||
@@ -466,6 +472,8 @@ void gui::EmitViewMenu() {
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
ImGui::MenuItem("Reset UI on Exit?", nullptr, &gContext->resetOnExit);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ struct Context : public SavedSettings {
|
||||
std::vector<GLFWimage> icons;
|
||||
|
||||
std::string iniPath = "imgui.ini";
|
||||
bool resetOnExit = false;
|
||||
};
|
||||
|
||||
extern Context* gContext;
|
||||
|
||||
Reference in New Issue
Block a user