@@ -187,16 +187,6 @@ NUIE::EventHandlerResult HeaderWithSlotsAndSwitchLayout::HandleMouseClick ( Basi
187187 return NUIE ::EventHandlerResult::EventNotHandled;
188188}
189189
190- HeaderWithSlotsAndMultilineTextLayout::ClickHandler::ClickHandler ()
191- {
192-
193- }
194-
195- HeaderWithSlotsAndMultilineTextLayout::ClickHandler::~ClickHandler ()
196- {
197-
198- }
199-
200190HeaderWithSlotsAndMultilineTextLayout::HeaderWithSlotsAndMultilineTextLayout ( const std::string& leftButtonId,
201191 const std::wstring& leftButtonText,
202192 const std::string& rightButtonId,
@@ -206,8 +196,8 @@ HeaderWithSlotsAndMultilineTextLayout::HeaderWithSlotsAndMultilineTextLayout ( c
206196 leftButtonText (leftButtonText),
207197 rightButtonId (rightButtonId),
208198 rightButtonText (rightButtonText),
209- storedPageCount (0 ),
210- storedCurrentPage ( 0 )
199+ pageCount (0 ),
200+ currentPage ( 1 )
211201{
212202}
213203
@@ -216,30 +206,48 @@ void HeaderWithSlotsAndMultilineTextLayout::AddPanels ( const BasicUINode& uiNod
216206 NUIE ::NodePanelDrawer& drawer) const
217207{
218208 std::vector<std::wstring> texts;
219- size_t allTextCount = 0 ;
220209 size_t textsPerPage = 0 ;
221- size_t pageCount = 0 ;
222- size_t currentPage = 0 ;
210+ GetTextInfo (uiNode, env.GetStringConverter (), texts, textsPerPage);
211+
212+ size_t textCount = texts.size ();
213+ pageCount = textCount / textsPerPage;
214+ if (textCount % textsPerPage != 0 ) {
215+ pageCount = pageCount + 1 ;
216+ }
217+ if (currentPage > pageCount) {
218+ currentPage = pageCount;
219+ }
223220
224- GetTextInfo (uiNode, env.GetStringConverter (), texts, allTextCount, textsPerPage, pageCount, currentPage);
221+ std::vector<std::wstring> visibleTexts;
222+ if (!texts.empty ()) {
223+ textCount = texts.size ();
224+ for (size_t i = 0 ; i < textsPerPage; ++i) {
225+ size_t textIndex = (currentPage - 1 ) * textsPerPage + i;
226+ if (textIndex < texts.size ()) {
227+ visibleTexts.push_back (texts[textIndex]);
228+ }
229+ }
230+ } else {
231+ textCount = 1 ;
232+ pageCount = 1 ;
233+ currentPage = 1 ;
234+ visibleTexts.push_back (NE::LocalizeString (L" <empty>" ));
235+ }
225236
226237 HeaderBasedLayout::AddPanels (uiNode, env, drawer);
227238 drawer.AddPanel (NUIE::NodeUIPanelPtr (new NodeUISlotPanel (uiNode, env)));
228- drawer.AddPanel (NUIE::NodeUIPanelPtr (new NodeUIMultiLineTextPanel (texts, allTextCount , textsPerPage, env)));
229- if (allTextCount > textsPerPage) {
230- drawer.AddPanel (NUIE::NodeUIPanelPtr (new NodeUILeftRightButtonsPanel (leftButtonId, leftButtonText, rightButtonId, rightButtonText, std::to_wstring (currentPage) + L" / " + std::to_wstring (pageCount) + L" (" + std::to_wstring (allTextCount ) + L" )" , env)));
239+ drawer.AddPanel (NUIE::NodeUIPanelPtr (new NodeUIMultiLineTextPanel (visibleTexts, textCount , textsPerPage, env)));
240+ if (textCount > textsPerPage) {
241+ drawer.AddPanel (NUIE::NodeUIPanelPtr (new NodeUILeftRightButtonsPanel (leftButtonId, leftButtonText, rightButtonId, rightButtonText, std::to_wstring (currentPage) + L" / " + std::to_wstring (pageCount) + L" (" + std::to_wstring (textCount ) + L" )" , env)));
231242 }
232-
233- storedCurrentPage = currentPage;
234- storedPageCount = pageCount;
235243}
236244
237245NUIE ::EventHandlerResult HeaderWithSlotsAndMultilineTextLayout::HandleMouseClick ( BasicUINode& uiNode,
238246 NUIE ::NodeUIEnvironment& env,
239247 const NUIE ::ModifierKeys&,
240248 NUIE ::MouseButton mouseButton,
241249 const NUIE ::Point& position,
242- NUIE ::UINodeCommandInterface& commandInterface ) const
250+ NUIE ::UINodeCommandInterface&) const
243251{
244252 if (mouseButton != NUIE ::MouseButton::Left) {
245253 return NUIE ::EventHandlerResult::EventNotHandled;
@@ -249,27 +257,20 @@ NUIE::EventHandlerResult HeaderWithSlotsAndMultilineTextLayout::HandleMouseClick
249257 return NUIE ::EventHandlerResult::EventNotHandled;
250258 }
251259
252- std::shared_ptr<ClickHandler> clickHandler = GetClickHandler (uiNode);
253260 NUIE ::Rect minusButtonRect = uiNode.GetSpecialRect (env, leftButtonId);
254261 NUIE ::Rect plusButtonRect = uiNode.GetSpecialRect (env, rightButtonId);
255262
256263 if (minusButtonRect.Contains (position)) {
257- commandInterface.RunUndoableCommand ([&] () {
258- size_t newCurrentPage = storedCurrentPage - 1 ;
259- if (newCurrentPage == 0 ) {
260- newCurrentPage = storedPageCount;
261- }
262- clickHandler->SetCurrentPage (newCurrentPage);
263- });
264+ currentPage = currentPage - 1 ;
265+ if (currentPage == 0 ) {
266+ currentPage = pageCount;
267+ }
264268 return NUIE ::EventHandlerResult::EventHandled;
265269 } else if (plusButtonRect.Contains (position)) {
266- commandInterface.RunUndoableCommand ([&] () {
267- size_t newCurrentPage = storedCurrentPage + 1 ;
268- if (newCurrentPage > storedPageCount) {
269- newCurrentPage = 1 ;
270- }
271- clickHandler->SetCurrentPage (newCurrentPage);
272- });
270+ currentPage = currentPage + 1 ;
271+ if (currentPage > pageCount) {
272+ currentPage = 1 ;
273+ }
273274 return NUIE ::EventHandlerResult::EventHandled;
274275 }
275276 return NUIE ::EventHandlerResult::EventNotHandled;
0 commit comments