Chira Engine
A customizable MIT-licensed game engine.
IPanel.h
1 #pragma once
2 
3 #include <string>
4 #include <string_view>
5 #include <imgui.h>
6 #include <math/Types.h>
7 
8 namespace chira {
9 
10 class IPanel {
11 public:
12  IPanel(std::string title_, bool startVisible, ImVec2 windowSize = {}, bool enforceSize = false);
13  virtual ~IPanel() = default;
14  void render();
15  virtual void preRenderContents() {};
16  virtual void renderContents() = 0;
17  virtual void postRenderContents() {};
18  [[nodiscard]] std::string_view getTitle() const;
19  void setTitle(const std::string& newTitle);
20  [[nodiscard]] bool isVisible() const;
21  void setVisible(bool visible_);
22  [[nodiscard]] bool wasActivatedThisFrame() const;
23  [[nodiscard]] glm::vec2 getWindowSize() const;
24  void setWindowSize(glm::vec2 size);
25  ImGuiWindowFlags& getWindowFlags();
26 protected:
27  std::string title;
28  bool visible;
29  bool activatedThisFrame;
30  ImVec2 nextWindowSize;
31  ImGuiCond_ windowSizeCondition;
32  ImGuiWindowFlags flags;
33 };
34 
35 } // namespace chira