OpenShaderDesigner 0.0.1
Loading...
Searching...
No Matches
EditorWindow.h
1// =====================================================================================================================
2// Copyright 2024 Medusa Slockbower
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14// =====================================================================================================================
15
16#ifndef EDITORWINDOW_H
17#define EDITORWINDOW_H
18
19#include <string>
20#include <imgui-docking/imgui.h>
21
22namespace OpenShaderDesigner
23{
28 {
29 public:
33 void Open();
34
38 void Draw();
39
43 void Close();
44
49 [[nodiscard]] bool IsOpen() const { return bOpen; }
50
51 const std::string Title;
52
53 void SetFlags(ImGuiWindowFlags flags) { Flags |= flags; }
54 void ClearFlags(ImGuiWindowFlags flags) { Flags &= ~flags; }
55 void ToggleFlags(ImGuiWindowFlags flags) { Flags ^= flags; }
56 [[nodiscard]] bool CheckFlag(ImGuiWindowFlags flag) const { return Flags & flag; }
57
58 [[nodiscard]] bool HasMenuBar() const { return CheckFlag(ImGuiWindowFlags_MenuBar); }
59
60 protected:
61 ~EditorWindow() = default;
62 EditorWindow(const std::string& title
63 , ImGuiWindowFlags flags);
64
68 virtual void OnOpen()
69 {
70 };
71
75 virtual void DrawWindow()
76 {
77 };
78
82 virtual void DrawMenu()
83 {
84 };
85
89 virtual void OnClose()
90 {
91 };
92
93 private:
94 EditorWindow(const EditorWindow&) = delete;
95
96 EditorWindow(EditorWindow&&) = delete;
97
98 int Flags;
99 bool bOpen;
100
101 friend class EditorSystem;
102 };
103}
104
105
106#endif //EDITORWINDOW_H
Definition EditorSystem.h:30
EditorWindow class for wrapping ImGui window functionality.
Definition EditorWindow.h:28
virtual void DrawWindow()
DrawWindow function for when the EditorWindow is being drawn.
Definition EditorWindow.h:75
const std::string Title
Title for the EditorWindow.
Definition EditorWindow.h:51
virtual void OnOpen()
OnOpen callback for when the EditorWindow is opened.
Definition EditorWindow.h:68
void Draw()
Draw the EditorWindow.
Definition EditorWindow.cpp:27
void Close()
Close the EditorWindow.
Definition EditorWindow.cpp:52
virtual void DrawMenu()
DrawMenu function for when the EditorWindow Menu is being drawn.
Definition EditorWindow.h:82
virtual void OnClose()
OnClose callback for when the EditorWindow is closed.
Definition EditorWindow.h:89
void Open()
Open the EditorWindow.
Definition EditorWindow.cpp:20
bool IsOpen() const
Check if the EditorWindow is open.
Definition EditorWindow.h:49