-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
gui.hh
39 lines (29 loc) · 948 Bytes
/
gui.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <string>
#include <map>
#include "imgui.h"
#include "tinyusdz.hh"
#include "usdShade.hh"
namespace example {
template<typename T>
bool ImGuiComboUI(const std::string &caption, std::string ¤t_key,
const std::map<std::string, T> &items) {
bool changed = false;
if (ImGui::BeginCombo(caption.c_str(), current_key.c_str())) {
for (const auto &item : items) {
bool is_selected = (current_key == item.first);
if (ImGui::Selectable(item.first.c_str(), is_selected)) {
current_key = item.first;
changed = true;
}
if (is_selected) {
// Set the initial focus when opening the combo (scrolling + for
// keyboard navigation support in the upcoming navigation branch)
ImGui::SetItemDefaultFocus();
}
}
ImGui::EndCombo();
}
return changed;
}
bool material_ui(tinyusdz::UsdPreviewSurface &material);
} // namesapce example