[glass] Use .controllable to set widgets' read-only state (#3035)

This modifies the mecanum drive, differential drive, speed controller,
and PID controller widgets to only be writeable when .controllable is
set to true.
This commit is contained in:
Prateek Machiraju
2021-01-05 21:33:05 -05:00
committed by GitHub
parent d8652cfd4f
commit 278e0f126e
11 changed files with 63 additions and 7 deletions

View File

@@ -20,10 +20,12 @@ void glass::DisplayPIDController(PIDControllerModel* m) {
}
if (m->Exists()) {
auto createTuningParameter = [](const char* name, double* v,
std::function<void(double)> callback) {
auto flag = m->IsReadOnly() ? ImGuiInputTextFlags_ReadOnly
: ImGuiInputTextFlags_None;
auto createTuningParameter = [flag](const char* name, double* v,
std::function<void(double)> callback) {
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 4);
if (ImGui::InputDouble(name, v, 0.0, 0.0, "%.3f")) {
if (ImGui::InputDouble(name, v, 0.0, 0.0, "%.3f", flag)) {
callback(*v);
}
};