OpenShaderDesigner 0.0.1
Loading...
Searching...
No Matches
EditorWindow.h
1// =====================================================================================================================
2// OpenShaderDesigner, an open source software utility to create materials and shaders.
3// Copyright (C) 2024 Medusa Slockbower
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see <https://www.gnu.org/licenses/>.
17// =====================================================================================================================
18
19#ifndef EDITORWINDOW_H
20#define EDITORWINDOW_H
21
22#include <string>
23#include <imgui-docking/imgui.h>
24
25namespace OpenShaderDesigner
26{
27
32{
33public:
37 void Open();
38
42 void Draw();
43
47 void Close();
48
53 [[nodiscard]] bool IsOpen() const { return bOpen_; }
54
55 const std::string Title;
56
57 void SetFlags(ImGuiWindowFlags flags) { Flags_ |= flags; }
58 void ClearFlags(ImGuiWindowFlags flags) { Flags_ &= ~flags; }
59 void ToggleFlags(ImGuiWindowFlags flags) { Flags_ ^= flags; }
60 [[nodiscard]] bool CheckFlag(ImGuiWindowFlags flag) const { return Flags_ & flag; }
61
62 [[nodiscard]] bool HasMenuBar() const { return CheckFlag(ImGuiWindowFlags_MenuBar); }
63
64protected:
65 ~EditorWindow() = default;
66 EditorWindow(const std::string& title
67 , ImGuiWindowFlags flags);
68
72 virtual void OnOpen()
73 {
74 };
75
79 virtual void DrawWindow()
80 {
81 };
82
86 virtual void DrawMenu()
87 {
88 };
89
93 virtual void OnClose()
94 {
95 };
96
97private:
98 EditorWindow(const EditorWindow&) = delete;
99
100 EditorWindow(EditorWindow&&) = delete;
101
102 int Flags_;
103 bool bOpen_;
104
105 friend class EditorSystem;
106};
107
108}
109
110
111#endif //EDITORWINDOW_H
Definition EditorSystem.h:35
EditorWindow class for wrapping ImGui window functionality.
Definition EditorWindow.h:32
virtual void DrawWindow()
DrawWindow function for when the EditorWindow is being drawn.
Definition EditorWindow.h:79
const std::string Title
Title for the EditorWindow.
Definition EditorWindow.h:55
virtual void OnOpen()
OnOpen callback for when the EditorWindow is opened.
Definition EditorWindow.h:72
void Draw()
Draw the EditorWindow.
Definition EditorWindow.cpp:30
void Close()
Close the EditorWindow.
Definition EditorWindow.cpp:55
virtual void DrawMenu()
DrawMenu function for when the EditorWindow Menu is being drawn.
Definition EditorWindow.h:86
virtual void OnClose()
OnClose callback for when the EditorWindow is closed.
Definition EditorWindow.h:93
void Open()
Open the EditorWindow.
Definition EditorWindow.cpp:23
bool IsOpen() const
Check if the EditorWindow is open.
Definition EditorWindow.h:53