allow gui::Window to execute the passed lambda right before ImGui::Begin()
This commit is contained in:
@@ -25,12 +25,14 @@ class Window {
|
||||
Window& operator=(const Window&) = delete;
|
||||
Window& operator=(Window&&) = delete;
|
||||
|
||||
bool Begin() noexcept {
|
||||
bool Begin(const std::function<void()>& before = {}) noexcept {
|
||||
if (std::exchange(set_focus_, false)) {
|
||||
ImGui::SetNextWindowFocus();
|
||||
shown_ = true;
|
||||
}
|
||||
if (!shown_) return false;
|
||||
|
||||
before();
|
||||
need_end_ = true;
|
||||
return ImGui::Begin(id().c_str(), &shown_);
|
||||
}
|
||||
|
@@ -205,9 +205,11 @@ void Dir::Update() noexcept {
|
||||
}
|
||||
|
||||
// tree view window
|
||||
const auto kInit = [em]() {
|
||||
ImGui::SetNextWindowSize({8*em, 8*em}, ImGuiCond_FirstUseEver);
|
||||
};
|
||||
const char* popup = nullptr;
|
||||
ImGui::SetNextWindowSize({8*em, 8*em}, ImGuiCond_FirstUseEver);
|
||||
if (win_.Begin()) {
|
||||
if (win_.Begin(kInit)) {
|
||||
if (ImGui::BeginPopupContextWindow()) {
|
||||
if (ImGui::MenuItem("new")) {
|
||||
popup = "NewItemPopup";
|
||||
|
@@ -146,6 +146,8 @@ void Logger::Update() noexcept {
|
||||
ImGui::OpenPopup(name);
|
||||
}
|
||||
|
||||
const auto em = ImGui::GetFontSize();
|
||||
|
||||
// config popup
|
||||
if (ImGui::BeginPopup("ConfigPopup")) {
|
||||
ImGui::TextUnformatted("System/Logger Config");
|
||||
@@ -172,7 +174,10 @@ void Logger::Update() noexcept {
|
||||
}
|
||||
|
||||
// LogView
|
||||
if (win_.Begin()) {
|
||||
const auto kInit = [em]() {
|
||||
ImGui::SetNextWindowSize({48*em, 16*em}, ImGuiCond_FirstUseEver);
|
||||
};
|
||||
if (win_.Begin(kInit)) {
|
||||
constexpr auto kTableFlags =
|
||||
ImGuiTableFlags_Resizable |
|
||||
ImGuiTableFlags_Hideable |
|
||||
|
Reference in New Issue
Block a user