YCLIMP
Yandex Command Line Interface Music Player
Loading...
Searching...
No Matches
SWManager.hpp
1#pragma once
2
3#include "Context.hpp"
4#include "HotKeyComponent.hpp"
5#include "SWHolder.hpp"
6#include "SubWindow.hpp"
7
8#include <functional>
9#include <unordered_map>
10#include <vector>
11
20class SWManager
21{
22private:
23 using SWFactoryTable =
24 std::unordered_map<ESWTypes, std::function<SubWindow::Ptr(Recti, SWHolderType)>>;
25
26public:
27 SWManager(const Recti& rect, MainWindow& mainWindow);
28
29 template <std::derived_from<SubWindow> T>
30 void RegisterSW(ESWTypes swType);
31
32 void InitStartupState();
33
34 void AddSWEvent(SWEvent swEvent);
35 void EventLoopIterationStart();
36 void HandleUserEvent(Event event);
37 void HandleSWEvents();
38 void Update();
39 void Draw() const;
40 void HandleResizeEvent(Recti newRect);
42
43 void setRawInputMode(bool rawInputMode);
44
45private:
46 SubWindow::Ptr CreateSubWindow(ESWTypes swType, SWHolderType holderType);
47
48 void SelectTopInfoHolder();
49 void SelectMainHolder();
50 void SelectAdditionalHolder();
51
52 void InitializeHotKeyActions();
53 void InitializePosElementsSize();
54
55 void DeselectAll();
56
57 SWHolder& GetSWHolder(SWHolderType holderType);
58 inline size_t GetSWIndex(ESWTypes swType) const;
59 Recti GetBoundsFromPosType(PositionType posType) const;
60
61private:
62 Recti mRect;
63 Context mContext;
64 HotKeyComponent mHotKeyComponent;
65 bool mRawInputMode;
66
67 Recti mTopElementRect;
68 Recti mOneMidElementRect;
69 Recti mLeftElementRect;
70 Recti mRightElementRect;
71 Recti mCentralElementRect;
72
73 std::array<SWHolder, 4> mSWHolders;
74 std::vector<SubWindow::Ptr> mSubWindows;
75 SWFactoryTable mFactories;
76
77 std::vector<SWEvent> mSWEvents;
78};
79
80// register to be able to create it from SWFactoryTable
81template <std::derived_from<SubWindow> T>
82void SWManager::RegisterSW(ESWTypes swType)
83{
84 mFactories[swType] = [this](
85 Recti bounds, SWHolderType inHolderType = SWHolderType::None)
86 { return std::make_unique<T>(bounds, mContext, inHolderType); };
87}
The HotKeyComponent class - class to handle pre defined bindings.
Definition HotKeyComponent.hpp:20
The MainWindow class.
Definition MainWindow.hpp:19
The SWHolder class does not own SubWindows It's only responsible for Positions, Size,...
Definition SWHolder.hpp:35
void InitStartupState()
SWManager::InitStartupState.
Definition SWManager.cpp:70
void setRawInputMode(bool rawInputMode)
if rawInputMode enabled for class, it's hotkeys(hotkeycomponent) won't be processed
Definition SWManager.cpp:404
void UpdatePosElementsSize()
SWManager::UpdatePosElementsSize.
Definition SWManager.cpp:285
Definition Context.hpp:14
Definition Primitives.hpp:88
SubWindow Event.
Definition SubWindow.hpp:56