PixelBullet  0.0.1
A C++ game engine
Loading...
Searching...
No Matches
layer.h
1#pragma once
2
3#include "pixelbullet/application/event.h"
4#include "pixelbullet/time/duration.h"
5
6#include <string>
7
8namespace pixelbullet
9{
10enum class EventPhase
11{
12 Early,
13 Normal
14};
15
17{
18public:
19 virtual ~UiFrameLayer() = default;
20
21 virtual bool BeginUiFrame() = 0;
22 virtual void CancelUiFrame() = 0;
23};
24
25class Layer
26{
27public:
28 explicit Layer(const std::string& name = "layer");
29 virtual ~Layer() = default;
30
31 virtual void OnAttach()
32 {
33 }
34 virtual void OnDetach()
35 {
36 }
37 virtual void OnUpdate([[maybe_unused]] Duration ts)
38 {
39 }
40 virtual void OnImGuiRender()
41 {
42 }
43 virtual EventResult OnEvent([[maybe_unused]] Event& event)
44 {
45 return EventResult::Ignored;
46 }
47 virtual EventPhase GetEventPhase() const
48 {
49 return EventPhase::Normal;
50 }
51
52 const std::string& GetName() const
53 {
54 return debug_name_;
55 }
56
57protected:
58 std::string debug_name_;
59};
60} // namespace pixelbullet
A lightweight duration class that holds a time span in seconds.
Definition duration.h:9
Definition event.h:72
Definition layer.h:26
Definition layer.h:17