YCLIMP
Yandex Command Line Interface Music Player
Loading...
Searching...
No Matches
SubWindow.hpp
1#pragma once
2
3#include "Context.hpp"
4#include "HotKeyComponent.hpp"
5#include "Primitives.hpp"
6#include "Utility.hpp"
7
8#include <memory>
9#include <variant>
10
12enum class ESWTypes
13{
14 None = -1,
15 Player,
16 PlayerStatus,
17 FileExplorer,
18 LocalFiles,
19 YandexFiles,
20 AppFiles,
21 Dialog,
22 Settings,
23 StartWindow
24};
25
28enum class ESWEventAction
29{
30 None,
31 PlayMusicFile,
32 PlayMusicBytes,
33 PlayedMusicDone,
34 OpenNewDirInPlayerSW,
35 OpenOneFileInPlayerSW,
36 AppendNewDirInPlayerSW,
37 AppendOneFileToPlayerSW,
38 OpenPlaylistOfTheDayInPlayerSW,
39 OpenMyVibeInPlayerSW,
40 EnableCentralHolder,
41 DisableCentralHolder,
42 ChooseActionWithSelectedElements,
43};
44
45class File;
46using File_Ptr = std::shared_ptr<File>;
47
55struct SWEvent
56{
57 SWEvent(ESWTypes evTarget, ESWEventAction evAction,
58 const std::variant<std::vector<File_Ptr>, File_Ptr, std::string>& data,
59 const std::string& data_2 = "");
60
61 ESWTypes target;
62 ESWEventAction action;
63 std::variant<std::vector<File_Ptr>, File_Ptr, std::string> data;
64 std::string data_2;
65};
66
80class SubWindow
81{
82public:
83 using Ptr = std::shared_ptr<SubWindow>;
84
85public:
86 SubWindow(ESWTypes swType, const Recti& rect, Context text,
87 SWHolderType inHolderType = SWHolderType::None);
88 virtual ~SubWindow() = default;
89
90public:
91 virtual void EventLoopIterationStart();
92 virtual void HandleUserEvent(Event event, bool rawInputMode);
93 virtual void HandleSWEvents(std::vector<SWEvent>& swEvents) = 0;
94 virtual void Update() = 0;
95 virtual void Draw() const = 0;
96 virtual void HandleResizeEvent(const Recti& newRect);
97
98 // manually reload the data displayed on a SubWindow
99 virtual void Reload();
100
101 virtual bool HasSelection() const;
102 virtual void Select();
103 virtual void Deselect();
104
105 virtual bool IsVisible() const;
106 virtual void SetVisible(bool visibleValue);
107
109 virtual void SetHighDrawPriority(bool priority);
111 virtual bool GetDrawPriority() const;
112
113 SWHolderType GetHolderType() const;
114 const std::string& GetName() const;
115 ESWTypes GetSWType() const;
116 const Recti& GetBounds() const;
117
118public:
120 static const std::string& ConvertToSWName(ESWTypes swType);
121
122private:
123 virtual void InitializeHotKeysActions() = 0;
124
125protected:
126 Context GetContext();
127 void DrawBoundsRectangle(const std::string& rectName = "") const;
128
129protected:
130 HotKeyComponent mHotKeyComponent;
131
132private:
133 Recti mBounds;
134 const ESWTypes mType;
135 Context mContext;
136 SWHolderType mInHolderType;
137 bool mSelected;
138 bool mIsVisible;
139 bool mHighDrawPriority;
140
141 static std::unordered_map<ESWTypes, std::string> mTypeToNameTable;
142};
Utility function list.
The File class - Abstract class for FsFile, YaFile and AppFile.
Definition FileManager.hpp:50
The HotKeyComponent class - class to handle pre defined bindings.
Definition HotKeyComponent.hpp:20
virtual bool GetDrawPriority() const
only boolean, if true, drawn last
Definition SubWindow.cpp:104
virtual void SetHighDrawPriority(bool priority)
if true, drawn last
Definition SubWindow.cpp:99
static const std::string & ConvertToSWName(ESWTypes swType)
Convert ESWTypes to it's std::string representation.
Definition SubWindow.cpp:25
Definition Context.hpp:14
Definition Primitives.hpp:88