Vesper 0.5.1
Vesper is short form for the Latin word for "Bat", as Vesper is designed to be small, lightweight, and easily handle things like particles and flocking behaviors in accordance with the nature of bats. \n It is meant to be a particle simulation, VFX editor, and CAN be used secondarily as a small game engine.
GitHub | Vesper Updates | Creator
Loading...
Searching...
No Matches
Vesper::ImGuiLayer Class Reference

#include <ImGuiLayer.h>

Inheritance diagram for Vesper::ImGuiLayer:
Vesper::Layer Vesper::OpenGLImGuiLayer

Public Member Functions

 ImGuiLayer ()
 ~ImGuiLayer ()
virtual void OnAttach () override
 Called when the layer is attached to the application.
virtual void OnDetach () override
 Called when the layer is detached from the application.
virtual void OnImGuiRender () override
 Called when the layer should render its ImGui components.
virtual void OnEvent (Event &e) override
 Called when an event is dispatched to the layer.
virtual void Begin ()
virtual void End ()
virtual void SetBlockEvents (bool block)
virtual void SetDarkThemeColors ()
Public Member Functions inherited from Vesper::Layer
 Layer (const std::string &name="Layer")
 Constructs a Layer with an optional name for debugging purposes.
virtual ~Layer ()
virtual void OnUpdate (Timestep ts)
 Called every frame to update the layer with the given timestep.
virtual void OnRender ()
 Called when the layer should render its contents.
const std::string & GetName () const
 Retrieves the name of the layer for debugging purposes.

Protected Attributes

bool m_BlockEvents = true
float m_Time = 0.0f
Protected Attributes inherited from Vesper::Layer
std::string m_DebugName
 The name of the layer assigned at creation, used for debugging.

Constructor & Destructor Documentation

◆ ImGuiLayer()

Vesper::ImGuiLayer::ImGuiLayer ( )
21 : Layer("ImGuiLayer")
22 {
23 }
Layer(const std::string &name="Layer")
Constructs a Layer with an optional name for debugging purposes.
Definition Layer.cpp:6

Referenced by Vesper::Application::Application(), and Vesper::OpenGLImGuiLayer::OpenGLImGuiLayer().

◆ ~ImGuiLayer()

Vesper::ImGuiLayer::~ImGuiLayer ( )
26 {
27 }

Member Function Documentation

◆ Begin()

void Vesper::ImGuiLayer::Begin ( )
virtual

Reimplemented in Vesper::OpenGLImGuiLayer.

96 {
98 ImGui_ImplOpenGL3_NewFrame();
99 ImGui_ImplGlfw_NewFrame();
100 ImGui::NewFrame();
101 ImGuizmo::BeginFrame();
102 }
#define VZ_PROFILE_FUNCTION()
Definition Instrumentor.h:240

Referenced by Vesper::OpenGLImGuiLayer::Begin(), and Vesper::Application::Run().

◆ End()

void Vesper::ImGuiLayer::End ( )
virtual

Reimplemented in Vesper::OpenGLImGuiLayer.

105 {
107 ImGuiIO& io = ImGui::GetIO();
108 Application& app = Application::Get();
109 io.DisplaySize = ImVec2((float)app.GetWindow().GetWidth(), (float)app.GetWindow().GetHeight());
110 ImGui::Render();
111 ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
112 if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
113 {
114 GLFWwindow* backup_current_context = glfwGetCurrentContext();
115 ImGui::UpdatePlatformWindows();
116 ImGui::RenderPlatformWindowsDefault();
117 glfwMakeContextCurrent(backup_current_context);
118 }
119 }
static Application & Get()
Retrieves the singleton instance of the Application.
Definition Application.h:67

References Vesper::Application::Get(), Vesper::Window::GetHeight(), Vesper::Window::GetWidth(), and Vesper::Application::GetWindow().

Referenced by Vesper::OpenGLImGuiLayer::End(), and Vesper::Application::Run().

◆ OnAttach()

void Vesper::ImGuiLayer::OnAttach ( )
overridevirtual

Called when the layer is attached to the application.

TODO: Remove to openGL specific

Reimplemented from Vesper::Layer.

Reimplemented in Vesper::OpenGLImGuiLayer.

30 {
32 IMGUI_CHECKVERSION();
33 ImGui::CreateContext();
34 ImGuiIO& io = ImGui::GetIO(); (void)io;
35 //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
36 //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
37 io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
38 io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
39 //io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoTaskBarIcons; // Disable Platform Windows task bar icons
40 //io.ConfigFlags |= ImGuiConfigFlags_ViewportsNoMerge; // Disable Platform Windows merging into host window
41
42 io.Fonts->AddFontFromFileTTF("../../Vesper-Editor/assets/fonts/RedHatMono/static/RedHatMono-Bold.ttf", 18.0f);
43 io.FontDefault = io.Fonts->AddFontFromFileTTF("../../Vesper-Editor/assets/fonts/RedHatMono/static/RedHatMono-Light.ttf", 18.0f);
44
45
46 ImGui::StyleColorsDark();
47
48 // When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
49 ImGuiStyle& style = ImGui::GetStyle();
50 if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
51 {
52 style.WindowRounding = 0.0f;
53 style.Colors[ImGuiCol_WindowBg].w = 1.0f;
54 }
55
57
58
60 {
61 Application& app = Application::Get();
62 GLFWwindow* window = static_cast<GLFWwindow*>(app.GetWindow().GetNativeWindow());
63 ImGui_ImplGlfw_InitForOpenGL(window, true);
64 ImGui_ImplOpenGL3_Init("#version 410");
65 }
66
67 }
virtual void SetDarkThemeColors()
Definition ImGuiLayer.cpp:120

References Vesper::Application::Get(), and SetDarkThemeColors().

Referenced by Vesper::OpenGLImGuiLayer::OnAttach().

◆ OnDetach()

void Vesper::ImGuiLayer::OnDetach ( )
overridevirtual

Called when the layer is detached from the application.

TODO: Remove to openGL specific

Reimplemented from Vesper::Layer.

Reimplemented in Vesper::OpenGLImGuiLayer.

70 {
72
74 {
75 ImGui_ImplOpenGL3_Shutdown();
76 ImGui_ImplGlfw_Shutdown();
77 ImGui::DestroyContext();
78 }
79 }

Referenced by Vesper::OpenGLImGuiLayer::OnDetach().

◆ OnEvent()

void Vesper::ImGuiLayer::OnEvent ( Event & event)
overridevirtual

Called when an event is dispatched to the layer.

Parameters
eventThe event being dispatched.

Reimplemented from Vesper::Layer.

Reimplemented in Vesper::OpenGLImGuiLayer.

87 {
88 if (m_BlockEvents) {
89 ImGuiIO& io = ImGui::GetIO();
90 e.Handled |= e.IsInCategory(EventCategoryMouse) & io.WantCaptureMouse;
91 e.Handled |= e.IsInCategory(EventCategoryKeyboard) & io.WantCaptureKeyboard;
92 }
93 }
bool m_BlockEvents
Definition ImGuiLayer.h:29
@ EventCategoryMouse
Definition Event.h:29
@ EventCategoryKeyboard
Definition Event.h:28

References Vesper::EventCategoryKeyboard, Vesper::EventCategoryMouse, Vesper::Event::Handled, Vesper::Event::IsInCategory(), and m_BlockEvents.

Referenced by Vesper::OpenGLImGuiLayer::OnEvent().

◆ OnImGuiRender()

void Vesper::ImGuiLayer::OnImGuiRender ( )
overridevirtual

Called when the layer should render its ImGui components.

Reimplemented from Vesper::Layer.

Reimplemented in Vesper::OpenGLImGuiLayer.

82 {
83
84 }

Referenced by Vesper::OpenGLImGuiLayer::OnImGuiRender().

◆ SetBlockEvents()

virtual void Vesper::ImGuiLayer::SetBlockEvents ( bool block)
inlinevirtual

Reimplemented in Vesper::OpenGLImGuiLayer.

26{ m_BlockEvents = block; }

References m_BlockEvents.

Referenced by Vesper::EditorLayer::OnImGuiRender().

◆ SetDarkThemeColors()

void Vesper::ImGuiLayer::SetDarkThemeColors ( )
virtual

Reimplemented in Vesper::OpenGLImGuiLayer.

121 {
122 auto& colors = ImGui::GetStyle().Colors;
123 colors[ImGuiCol_WindowBg] = ImVec4{ 0.1f, 0.105f, 0.11f, 1.0f };
124
125 // Header
126 colors[ImGuiCol_Header] = ImVec4{ 0.2f, 0.205f, 0.21f, 1.0f };
127 colors[ImGuiCol_HeaderHovered] = ImVec4{ 0.3f, 0.305f, 0.31f, 1.0f };
128 colors[ImGuiCol_HeaderActive] = ImVec4{ 0.15f, 0.1505f, 0.151f, 1.0f };
129
130 // Buttons
131 colors[ImGuiCol_Button] = ImVec4{ 0.2f, 0.205f, 0.21f, 1.0f };
132 colors[ImGuiCol_ButtonHovered] = ImVec4{ 0.3f, 0.305f, 0.31f, 1.0f };
133 colors[ImGuiCol_ButtonActive] = ImVec4{ 0.15f, 0.1505f, 0.151f, 1.0f };
134
135 // Frame BG
136 colors[ImGuiCol_FrameBg] = ImVec4{ 0.2f, 0.205f, 0.21f, 1.0f };
137 colors[ImGuiCol_FrameBgHovered] = ImVec4{ 0.3f, 0.305f, 0.31f, 1.0f };
138 colors[ImGuiCol_FrameBgActive] = ImVec4{ 0.15f, 0.1505f, 0.151f, 1.0f };
139
140 // Tabs
141 colors[ImGuiCol_Tab] = ImVec4{ 0.15f, 0.1505f, 0.151f, 1.0f };
142 colors[ImGuiCol_TabHovered] = ImVec4{ 0.38f, 0.3805f, 0.381f, 1.0f };
143 colors[ImGuiCol_TabActive] = ImVec4{ 0.28f, 0.2805f, 0.281f, 1.0f };
144 colors[ImGuiCol_TabUnfocused] = ImVec4{ 0.15f, 0.1505f, 0.151f, 1.0f };
145 colors[ImGuiCol_TabUnfocusedActive] = ImVec4{ 0.2f, 0.205f, 0.21f, 1.0f };
146
147 // Title
148 colors[ImGuiCol_TitleBg] = ImVec4{ 0.1f, 0.105f, 0.11f, 1.0f };
149 colors[ImGuiCol_TitleBgActive] = ImVec4{ 0.1f, 0.105f, 0.11f, 1.0f };
150 colors[ImGuiCol_TitleBgCollapsed] = ImVec4{ 0.1f, 0.105f, 0.11f, 1.0f };
151
152
153
154 }

Referenced by OnAttach(), and Vesper::OpenGLImGuiLayer::SetDarkThemeColors().

Member Data Documentation

◆ m_BlockEvents

bool Vesper::ImGuiLayer::m_BlockEvents = true
protected

◆ m_Time

float Vesper::ImGuiLayer::m_Time = 0.0f
protected

The documentation for this class was generated from the following files: