[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

@@ -106,6 +106,12 @@ void glass::DisplayDrive(DriveModel* m) {
drawArrow(arrowPos, a2 + adder);
}
// Set the buttons and sliders to read-only if the model is read-only.
if (m->IsReadOnly()) {
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(210, 210, 210, 255));
}
// Add sliders for the wheel percentages.
ImGui::SetCursorPosY(y2 - pos.y + ImGui::GetFontSize() * 0.5);
for (auto&& wheel : wheels) {
@@ -124,4 +130,9 @@ void glass::DisplayDrive(DriveModel* m) {
}
}
}
if (m->IsReadOnly()) {
ImGui::PopStyleColor();
ImGui::PopItemFlag();
}
}