You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.1 KiB
C++
87 lines
2.1 KiB
C++
/******************************************************************************
|
|
* File - panel.h
|
|
* Author - Joey Pollack
|
|
* Date - 2021/11/01 (y/m/d)
|
|
* Mod Date - 2021/11/01 (y/m/d)
|
|
* Description - Base class for all editor panels
|
|
******************************************************************************/
|
|
|
|
#ifndef PANEL_H_
|
|
#define PANEL_H_
|
|
|
|
#include "panel_defs.h"
|
|
#include "panel_manager.h"
|
|
#include <utils/op_res.h>
|
|
|
|
#include <string>
|
|
#include <map>
|
|
#include <functional>
|
|
|
|
struct ImGuiInputTextCallbackData;
|
|
|
|
namespace lunarium
|
|
{
|
|
class Panel
|
|
{
|
|
public:
|
|
|
|
struct Popup
|
|
{
|
|
std::function<bool(Panel*)> PopupFunc;
|
|
bool IsOpen;
|
|
std::string Name;
|
|
};
|
|
|
|
public:
|
|
Panel(std::string name, PanelDockZone dock_zone, bool isOpen = false, int window_flags = 0);
|
|
virtual ~Panel();
|
|
const char* GetName() const;
|
|
|
|
virtual void Update(float dt);
|
|
bool OnUIRender();
|
|
void SetWindowFlags(int flags);
|
|
void SetOpen(bool isOpen);
|
|
bool IsOpen();
|
|
void GetPosition(int& x, int& y) const;
|
|
void GetSize(int& w, int& h) const;
|
|
PanelDockZone GetDockZone() const;
|
|
|
|
[[nodiscard]] OpRes AddPopup(int id, std::string name, std::function<bool(Panel*)>);
|
|
|
|
private:
|
|
std::string mPanelName;
|
|
bool mIsOpen;
|
|
PanelDockZone mDockZone;
|
|
int mWindowFlags;
|
|
|
|
// TODO: Not sure I like this solution...
|
|
int mNumPushedStyles;
|
|
|
|
// Popups
|
|
std::map<int, Popup*> mPopups;
|
|
|
|
int mX;
|
|
int mY;
|
|
int mWidth;
|
|
int mHeight;
|
|
|
|
private: // Helpers
|
|
void UpdateMetaInfo();
|
|
void RunPopups();
|
|
|
|
protected:
|
|
|
|
/// Called right before ImGui::Begin for this panel
|
|
/// Override to implement any NextWindow or style pushing code
|
|
virtual void PreBegin();
|
|
virtual void DoFrame() = 0;
|
|
|
|
void SetNumPushedStyles(int num);
|
|
[[nodiscard]] OpRes OpenPopup(int id);
|
|
|
|
private:
|
|
friend class PanelManager;
|
|
};
|
|
}
|
|
|
|
#endif // PANEL_H_
|