Use ListBox for slide picker in Viewer
Interaction is much nicer (the bulleted list of text had dead space between entries, so mouse clicks could go unnoticed). This version also keeps the currently active slide highlighted in the list, which is nice. Bug: skia: Change-Id: I609d90f3b1ff99765f0a7f1ca43e02a0a534dc4d Reviewed-on: https://skia-review.googlesource.com/68780 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
df429f3bea
commit
f479e42981
@ -1180,21 +1180,29 @@ void Viewer::drawImGui(SkCanvas* canvas) {
|
||||
|
||||
if (ImGui::CollapsingHeader("Slide")) {
|
||||
static ImGuiTextFilter filter;
|
||||
static ImVector<const char*> filteredSlideNames;
|
||||
static ImVector<int> filteredSlideIndices;
|
||||
|
||||
filter.Draw();
|
||||
int previousSlide = fCurrentSlide;
|
||||
fCurrentSlide = 0;
|
||||
for (auto slide : fSlides) {
|
||||
if (filter.PassFilter(slide->getName().c_str())) {
|
||||
ImGui::BulletText("%s", slide->getName().c_str());
|
||||
if (ImGui::IsItemClicked()) {
|
||||
setupCurrentSlide(previousSlide);
|
||||
break;
|
||||
filteredSlideNames.clear();
|
||||
filteredSlideIndices.clear();
|
||||
int filteredIndex = 0;
|
||||
for (int i = 0; i < fSlides.count(); ++i) {
|
||||
const char* slideName = fSlides[i]->getName().c_str();
|
||||
if (filter.PassFilter(slideName) || i == fCurrentSlide) {
|
||||
if (i == fCurrentSlide) {
|
||||
filteredIndex = filteredSlideIndices.size();
|
||||
}
|
||||
filteredSlideNames.push_back(slideName);
|
||||
filteredSlideIndices.push_back(i);
|
||||
}
|
||||
++fCurrentSlide;
|
||||
}
|
||||
if (fCurrentSlide >= fSlides.count()) {
|
||||
fCurrentSlide = previousSlide;
|
||||
|
||||
int previousSlide = fCurrentSlide;
|
||||
if (ImGui::ListBox("", &filteredIndex, filteredSlideNames.begin(),
|
||||
filteredSlideNames.size(), 20)) {
|
||||
fCurrentSlide = filteredSlideIndices[filteredIndex];
|
||||
setupCurrentSlide(previousSlide);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user