Drag&Drop support for multiple screens

This commit is contained in:
Maschell 2020-02-22 21:17:37 +01:00
parent 0776a13841
commit 11c295b2b5
2 changed files with 50 additions and 2 deletions

View File

@ -88,8 +88,12 @@ GuiIconGrid::GuiIconGrid(int32_t w, int32_t h, uint64_t GameIndex,bool sortByNam
arrowLeftButton.setTrigger(&touchTrigger); arrowLeftButton.setTrigger(&touchTrigger);
arrowLeftButton.setTrigger(&wpadTouchTrigger); arrowLeftButton.setTrigger(&wpadTouchTrigger);
arrowLeftButton.setTrigger(&buttonLTrigger); arrowLeftButton.setTrigger(&buttonLTrigger);
arrowLeftButton.setHoldable(true);
arrowLeftButton.setSoundClick(buttonClickSound); arrowLeftButton.setSoundClick(buttonClickSound);
arrowLeftButton.clicked.connect(this, &GuiIconGrid::OnLeftArrowClick); arrowLeftButton.clicked.connect(this, &GuiIconGrid::OnLeftArrowClick);
arrowLeftButton.held.connect(this, &GuiIconGrid::OnLeftArrowHeld);
arrowLeftButton.released.connect(this, &GuiIconGrid::OnLeftArrowReleased);
append(&arrowLeftButton); append(&arrowLeftButton);
arrowRightButton.setImage(&arrowRightImage); 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(&touchTrigger);
arrowRightButton.setTrigger(&wpadTouchTrigger); arrowRightButton.setTrigger(&wpadTouchTrigger);
arrowRightButton.setTrigger(&buttonRTrigger); arrowRightButton.setTrigger(&buttonRTrigger);
arrowRightButton.setHoldable(true);
arrowRightButton.setSoundClick(buttonClickSound); arrowRightButton.setSoundClick(buttonClickSound);
arrowRightButton.clicked.connect(this, &GuiIconGrid::OnRightArrowClick); arrowRightButton.clicked.connect(this, &GuiIconGrid::OnRightArrowClick);
arrowRightButton.held.connect(this, &GuiIconGrid::OnRightArrowHeld);
arrowRightButton.released.connect(this, &GuiIconGrid::OnRightArrowReleased);
append(&arrowRightButton); append(&arrowRightButton);
// at most we are rendering 2 screens at the same time // 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) { void GuiIconGrid::OnLeftArrowClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) {
//setSelectedGame(0);
curPage--; curPage--;
setSelectedGame(0);
bUpdatePositions = true; bUpdatePositions = true;
} }
void GuiIconGrid::OnRightArrowClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) { void GuiIconGrid::OnRightArrowClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) {
//setSelectedGame(0);
curPage++; curPage++;
setSelectedGame(0);
bUpdatePositions = true; 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) { void GuiIconGrid::OnGameButtonHeld(GuiButton *button, const GuiController *controller, GuiTrigger *trigger) {
if(currentlyHeld == NULL) { if(currentlyHeld == NULL) {
currentlyHeld = button; currentlyHeld = button;

View File

@ -91,10 +91,19 @@ private:
void OnGameButtonPointedOn(GuiButton *button, const GuiController *controller); void OnGameButtonPointedOn(GuiButton *button, const GuiController *controller);
void OnGameButtonPointedOff(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 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(); void updateButtonPositions();
int32_t offsetForTitleId(uint64_t titleId); int32_t offsetForTitleId(uint64_t titleId);
uint32_t lArrowHeldCounter = 0;
uint32_t rArrowHeldCounter = 0;
int32_t curPage = 0; int32_t curPage = 0;
int32_t listOffset; int32_t listOffset;
uint64_t selectedGame; uint64_t selectedGame;