3#include "ListDialogElement.hpp"
7template <
typename ElementPtr>
10 const Recti& newBounds)
13 auto& textBounds = lBounds.text;
14 auto& listBounds = lBounds.list;
15 auto& confirmBounds = lBounds.confirm;
16 textBounds.left = newBounds.left + 1;
17 textBounds.width = newBounds.width - 1;
18 listBounds.left = newBounds.left;
19 listBounds.width = newBounds.width;
20 confirmBounds.left = newBounds.left;
21 confirmBounds.width = newBounds.width;
24 textBounds.top = newBounds.top;
25 textBounds.height = 1;
28 listBounds.top = newBounds.top + textBounds.height;
29 listBounds.height = newBounds.height - 1 - 1;
32 confirmBounds.top = listBounds.top + listBounds.height;
33 confirmBounds.height = 1;
39template <
typename ElementPtr>
41ListDialogElement<ElementPtr>::ListDialogElement(
const Recti& bounds, std::string text,
42 std::vector<ElementPtr> elements, Type type, std::vector<std::string>&& options)
45 , mLBounds{CalculateLocalBounds<ElementPtr>(bounds)}
46 , mHorizontalChoice{std::move(options), mLBounds.confirm}
47 , mText{std::move(text)}
48 , mFileSelector{mLBounds.list}
51 mFileSelector.Load(std::move(elements),
true);
54template <
typename ElementPtr>
56void ListDialogElement<ElementPtr>::Draw()
const
58 if (IsFinished() ==
true)
64 mHorizontalChoice.Draw();
67template <
typename ElementPtr>
69void ListDialogElement<ElementPtr>::HandleResizeEvent(
const Recti& newRect)
71 if (IsFinished() ==
true)
75 mLBounds = CalculateLocalBounds<ElementPtr>(newRect);
76 mFileSelector.HandleResize(mLBounds.list);
77 mHorizontalChoice.HandleResizeEvent(mLBounds.confirm);
80template <
typename ElementPtr>
82void ListDialogElement<ElementPtr>::HandleRawInput(
int rawInputChar)
84 if (IsFinished() ==
true)
88template <
typename ElementPtr>
90void ListDialogElement<ElementPtr>::InputUp()
92 if (IsFinished() ==
true)
95 mFileSelector.SelectUp();
98template <
typename ElementPtr>
100void ListDialogElement<ElementPtr>::InputDown()
102 if (IsFinished() ==
true)
105 mFileSelector.SelectDown();
108template <
typename ElementPtr>
110void ListDialogElement<ElementPtr>::InputLeft()
112 if (IsFinished() ==
true)
116template <
typename ElementPtr>
118void ListDialogElement<ElementPtr>::InputRight()
120 if (IsFinished() ==
true)
123 if (mType == Type::ReadOnly)
126 if (mType == Type::OneChoice)
128 mFileSelector.ClearAllLastingSelections();
131 mFileSelector.LastingSelectOnCurrent();
134template <
typename ElementPtr>
136void ListDialogElement<ElementPtr>::InputEnter()
138 if (IsFinished() ==
true)
141 mHorizontalChoice.ConfirmCurrentChoice();
142 SetFinished(std::string{mHorizontalChoice.GetFinalChoice()});
144 auto selected = mFileSelector.GetSelected();
145 if (selected.has_value())
147 SetData(mFileSelector.GetSelected().value()->name);
151template <
typename ElementPtr>
153void ListDialogElement<ElementPtr>::InputTab()
155 if (IsFinished() ==
true)
158 mHorizontalChoice.SelectNext();
void printwMsgBox(const std::string &msg, const Recti &availableSpace)
Definition Utility.cpp:106
void clearArea(const Recti &rect)
clearArea - clears specified rect, rect itself is not included, only area inside rectangle without bo...
Definition Utility.cpp:74
The DialogElement class - Abstract class. Visual element designed to process some user input in a dia...
Definition DialogElement.hpp:50
Definition ElementSelector.hpp:28
Definition ListDialogElement.hpp:33