Sound Bakery  v0.1.0
Open-source audio middleware for games
Loading...
Searching...
No Matches
WidgetSubsystem.h
1#pragma once
2
3#include "Subsystem.h"
4#include "Widgets/Widget.h"
5
7{
8public:
9 WidgetSubsystem(App* appOwner) : Subsystem(appOwner) {}
10
11public:
12 virtual int Init() override;
13 virtual void Tick(double deltaTime) override;
14 virtual void Exit() override;
15
16public:
17 template <class T>
18 T* AddWidgetClass()
19 {
20 m_widgets.push_back(std::make_unique<T>(this));
21 return dynamic_cast<T*>(m_widgets.back().get());
22 }
23
24 template <class T>
25 T* AddWidgetClassToRoot()
26 {
27 assert(m_rootWidget);
28
29 return m_rootWidget->AddChildWidget<T>();
30 }
31
32private:
33 std::vector<std::unique_ptr<Widget>> m_widgets;
34 Widget* m_rootWidget = nullptr;
35};
Definition App.h:10
Definition Subsystem.h:8
Definition WidgetSubsystem.h:7
virtual int Init() override
Init the subsystem / start.
Definition WidgetSubsystem.cpp:6
virtual void Tick(double deltaTime) override
Called every frame regardless of if the app is closing.
Definition WidgetSubsystem.cpp:12
virtual void Exit() override
Called when closing the app.
Definition WidgetSubsystem.cpp:41
Definition Widget.h:16