5 IPanel::IPanel(std::string title_,
bool startVisible, ImVec2 windowSize,
bool enforceSize)
6 : title(std::move(title_))
7 , visible(startVisible)
8 , activatedThisFrame(startVisible)
9 , nextWindowSize(windowSize)
10 , windowSizeCondition(enforceSize ? ImGuiCond_Always : ImGuiCond_FirstUseEver)
13 void IPanel::render() {
15 ImGui::SetNextWindowSize(this->nextWindowSize, this->windowSizeCondition);
16 this->preRenderContents();
17 if (ImGui::Begin(this->title.c_str(), &this->visible, this->flags)) {
18 this->renderContents();
21 this->postRenderContents();
23 if (this->activatedThisFrame)
24 this->activatedThisFrame =
false;
28 std::string_view IPanel::getTitle()
const {
32 void IPanel::setTitle(
const std::string& newTitle) {
33 this->title = newTitle;
36 bool IPanel::isVisible()
const {
40 void IPanel::setVisible(
bool visible_) {
42 this->activatedThisFrame =
true;
43 this->visible = visible_;
46 bool IPanel::wasActivatedThisFrame()
const {
47 return this->activatedThisFrame;
50 glm::vec2 IPanel::getWindowSize()
const {
51 return {this->nextWindowSize.x, this->nextWindowSize.y};
54 ImGuiWindowFlags& IPanel::getWindowFlags() {
58 void IPanel::setWindowSize(glm::vec2 size) {
59 this->nextWindowSize.x = size.x;
60 this->nextWindowSize.y = size.y;