From 11c295b2b5aa16aa798e2e8e76bcf36e3fda3a93 Mon Sep 17 00:00:00 2001 From: Maschell Date: Sat, 22 Feb 2020 21:17:37 +0100 Subject: [PATCH] Drag&Drop support for multiple screens --- src/gui/GuiIconGrid.cpp | 43 +++++++++++++++++++++++++++++++++++++++-- src/gui/GuiIconGrid.h | 9 +++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/src/gui/GuiIconGrid.cpp b/src/gui/GuiIconGrid.cpp index 1e42a15..1636322 100644 --- a/src/gui/GuiIconGrid.cpp +++ b/src/gui/GuiIconGrid.cpp @@ -88,8 +88,12 @@ GuiIconGrid::GuiIconGrid(int32_t w, int32_t h, uint64_t GameIndex,bool sortByNam arrowLeftButton.setTrigger(&touchTrigger); arrowLeftButton.setTrigger(&wpadTouchTrigger); arrowLeftButton.setTrigger(&buttonLTrigger); + arrowLeftButton.setHoldable(true); arrowLeftButton.setSoundClick(buttonClickSound); arrowLeftButton.clicked.connect(this, &GuiIconGrid::OnLeftArrowClick); + arrowLeftButton.held.connect(this, &GuiIconGrid::OnLeftArrowHeld); + arrowLeftButton.released.connect(this, &GuiIconGrid::OnLeftArrowReleased); + append(&arrowLeftButton); arrowRightButton.setImage(&arrowRightImage); @@ -99,8 +103,11 @@ GuiIconGrid::GuiIconGrid(int32_t w, int32_t h, uint64_t GameIndex,bool sortByNam arrowRightButton.setTrigger(&touchTrigger); arrowRightButton.setTrigger(&wpadTouchTrigger); arrowRightButton.setTrigger(&buttonRTrigger); + arrowRightButton.setHoldable(true); arrowRightButton.setSoundClick(buttonClickSound); arrowRightButton.clicked.connect(this, &GuiIconGrid::OnRightArrowClick); + arrowRightButton.held.connect(this, &GuiIconGrid::OnRightArrowHeld); + arrowRightButton.released.connect(this, &GuiIconGrid::OnRightArrowReleased); append(&arrowRightButton); // at most we are rendering 2 screens at the same time @@ -222,14 +229,14 @@ void GuiIconGrid::OnGameTitleListUpdated(GameList * gameList) { } void GuiIconGrid::OnLeftArrowClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) { + //setSelectedGame(0); curPage--; - setSelectedGame(0); bUpdatePositions = true; } void GuiIconGrid::OnRightArrowClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) { + //setSelectedGame(0); curPage++; - setSelectedGame(0); bUpdatePositions = true; } @@ -325,6 +332,38 @@ void GuiIconGrid::OnLaunchClick(GuiButton *button, const GuiController *controll } +void GuiIconGrid::OnLeftArrowHeld(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) { + if(currentlyHeld != NULL) { + if(lArrowHeldCounter++ > 30) { + OnLeftArrowClick(button,controller,trigger); + lArrowHeldCounter = 0; + } + } else { + lArrowHeldCounter = 0; + } +} + +void GuiIconGrid::OnLeftArrowReleased(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) { + lArrowHeldCounter = 0; +} + +void GuiIconGrid::OnRightArrowHeld(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) { + if(currentlyHeld != NULL) { + if(rArrowHeldCounter++ > 30) { + DEBUG_FUNCTION_LINE("CLICK\n"); + OnRightArrowClick(button,controller,trigger); + rArrowHeldCounter = 0; + } + } else { + rArrowHeldCounter = 0; + } +} + +void GuiIconGrid::OnRightArrowReleased(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) { + rArrowHeldCounter = 0; +} + + void GuiIconGrid::OnGameButtonHeld(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) { if(currentlyHeld == NULL) { currentlyHeld = button; diff --git a/src/gui/GuiIconGrid.h b/src/gui/GuiIconGrid.h index a121d3a..5909c20 100644 --- a/src/gui/GuiIconGrid.h +++ b/src/gui/GuiIconGrid.h @@ -91,10 +91,19 @@ private: void OnGameButtonPointedOn(GuiButton *button, const GuiController *controller); void OnGameButtonPointedOff(GuiButton *button, const GuiController *controller); void OnDrag(GuiDragListener *button, const GuiController *controller, GuiTrigger *trigger, int32_t dx, int32_t dy); + + void OnLeftArrowHeld(GuiButton *button, const GuiController *controller, GuiTrigger *trigger); + void OnRightArrowHeld(GuiButton *button, const GuiController *controller, GuiTrigger *trigger); + void OnLeftArrowReleased(GuiButton *button, const GuiController *controller, GuiTrigger *trigger); + void OnRightArrowReleased(GuiButton *button, const GuiController *controller, GuiTrigger *trigger); + void updateButtonPositions(); int32_t offsetForTitleId(uint64_t titleId); + uint32_t lArrowHeldCounter = 0; + uint32_t rArrowHeldCounter = 0; + int32_t curPage = 0; int32_t listOffset; uint64_t selectedGame;