Show the variables pane even when it is empty.

The widget layout shouldn't change when there are no variables.

Change-Id: Iedb48642486944127fa800072c1f4c57a574b513
Bug: skia:12666
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/484836
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2021-12-15 13:11:32 -05:00 committed by SkCQ
parent 16a06174df
commit 457f1b9f41

View File

@ -186,34 +186,33 @@ void SkSLDebuggerSlide::showVariableTable() {
} else {
vars = fPlayer.getGlobalVariables();
}
if (vars.empty()) {
return;
}
ImVec2 varViewSize = ImVec2(0.0f, ImGui::GetTextLineHeightWithSpacing() * kNumTopRows);
if (ImGui::BeginTable("Variables", /*column=*/2, kTableFlags, varViewSize)) {
ImGui::TableSetupColumn("Variable", kColumnFlags);
ImGui::TableSetupColumn("Value", kColumnFlags);
ImGui::TableHeadersRow();
if (!vars.empty()) {
ImGuiListClipper clipper;
clipper.Begin(vars.size());
while (clipper.Step()) {
for (int row = clipper.DisplayStart; row < clipper.DisplayEnd; row++) {
const SkSL::SkVMDebugTracePlayer::VariableData& var = vars.at(row);
SkASSERT(var.fSlotIndex >= 0);
SkASSERT((size_t)var.fSlotIndex < fTrace->fSlotInfo.size());
const SkSL::SkVMSlotInfo& slotInfo = fTrace->fSlotInfo[var.fSlotIndex];
ImGuiListClipper clipper;
clipper.Begin(vars.size());
while (clipper.Step()) {
for (int row = clipper.DisplayStart; row < clipper.DisplayEnd; row++) {
const SkSL::SkVMDebugTracePlayer::VariableData& var = vars.at(row);
SkASSERT(var.fSlotIndex >= 0 && (size_t)var.fSlotIndex < fTrace->fSlotInfo.size());
const SkSL::SkVMSlotInfo& slotInfo = fTrace->fSlotInfo[var.fSlotIndex];
ImGui::TableNextRow();
if (var.fDirty) {
// Highlight recently-changed variables.
ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg1,
ImGui::GetColorU32(ImVec4{0.0f, 1.0f, 0.0f, 0.20f}));
ImGui::TableNextRow();
if (var.fDirty) {
// Highlight recently-changed variables.
ImGui::TableSetBgColor(ImGuiTableBgTarget_RowBg1,
ImGui::GetColorU32(ImVec4{0.0f, 1.0f, 0.0f, 0.20f}));
}
ImGui::TableSetColumnIndex(0);
ImGui::Text("%s%s", slotInfo.name.c_str(),
fTrace->getSlotComponentSuffix(var.fSlotIndex).c_str());
ImGui::TableSetColumnIndex(1);
ImGui::Text("%s", fTrace->getSlotValue(var.fSlotIndex, var.fValue).c_str());
}
ImGui::TableSetColumnIndex(0);
ImGui::Text("%s%s", slotInfo.name.c_str(),
fTrace->getSlotComponentSuffix(var.fSlotIndex).c_str());
ImGui::TableSetColumnIndex(1);
ImGui::Text("%s", fTrace->getSlotValue(var.fSlotIndex, var.fValue).c_str());
}
}
ImGui::EndTable();