[olympic/studio] Add PushButton, PopupBtns, ComboBox, and IDStackItem to ImGui utils
This commit is contained in:
@@ -2,12 +2,42 @@
|
||||
* Copyright 2016 - 2024 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <imgui.h>
|
||||
|
||||
#include <turbine/context.hpp>
|
||||
|
||||
namespace studio::ig {
|
||||
|
||||
inline constexpr auto BtnSz = ImVec2{50, 22};
|
||||
|
||||
template<typename T>
|
||||
class IDStackItem {
|
||||
private:
|
||||
T m_id;
|
||||
public:
|
||||
explicit IDStackItem(T id) noexcept: m_id(id) {
|
||||
ImGui::PushID(m_id);
|
||||
}
|
||||
~IDStackItem() noexcept {
|
||||
ImGui::PopID();
|
||||
}
|
||||
};
|
||||
|
||||
void centerNextWindow(turbine::Context &ctx) noexcept;
|
||||
|
||||
bool PushButton(ox::CStringView lbl, ImVec2 const&btnSz = BtnSz) noexcept;
|
||||
|
||||
void PopupBtns(float popupWidth, bool &popupOpen);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param lbl
|
||||
* @param list
|
||||
* @param selectedIdx
|
||||
* @return true if new value selected, false otherwise
|
||||
*/
|
||||
bool ComboBox(ox::CStringView lbl, ox::SpanView<ox::String> list, size_t &selectedIdx) noexcept;
|
||||
|
||||
}
|
Reference in New Issue
Block a user