Handle touching the message boxes.
This commit is contained in:
parent
afbf85a65f
commit
5f04f106cf
@ -57,6 +57,7 @@ typedef union {
|
|||||||
#include "nanojpeg.h"
|
#include "nanojpeg.h"
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
|
#include "message-box.h"
|
||||||
|
|
||||||
void menuStartup();
|
void menuStartup();
|
||||||
void menuLoop();
|
void menuLoop();
|
||||||
|
@ -74,11 +74,6 @@ double menuTimer;
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void menuCreateMsgBox(int width, int height, const char *text);
|
|
||||||
void menuCloseMsgBox();
|
|
||||||
bool menuIsMsgBoxOpen();
|
|
||||||
void menuDrawMsgBox(void);
|
|
||||||
|
|
||||||
void menuEntryInit(menuEntry_s* me, MenuEntryType type);
|
void menuEntryInit(menuEntry_s* me, MenuEntryType type);
|
||||||
void menuEntryFree(menuEntry_s* me);
|
void menuEntryFree(menuEntry_s* me);
|
||||||
bool fileExists(const char* path);
|
bool fileExists(const char* path);
|
||||||
|
@ -1,12 +1,5 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "message-box.h"
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
uint32_t width;
|
|
||||||
uint32_t height;
|
|
||||||
color_t *bg;
|
|
||||||
char *text;
|
|
||||||
} MessageBox;
|
|
||||||
|
|
||||||
MessageBox currMsgBox;
|
MessageBox currMsgBox;
|
||||||
|
|
||||||
@ -177,3 +170,7 @@ void menuCloseMsgBox() {
|
|||||||
currMsgBox.text = NULL;
|
currMsgBox.text = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MessageBox menuGetCurrentMsgBox() {
|
||||||
|
return currMsgBox;
|
||||||
|
}
|
||||||
|
15
common/message-box.h
Normal file
15
common/message-box.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
uint32_t width;
|
||||||
|
uint32_t height;
|
||||||
|
color_t *bg;
|
||||||
|
char *text;
|
||||||
|
} MessageBox;
|
||||||
|
|
||||||
|
void menuCreateMsgBox(int width, int height, const char *text);
|
||||||
|
void menuCloseMsgBox();
|
||||||
|
bool menuIsMsgBoxOpen();
|
||||||
|
void menuDrawMsgBox(void);
|
||||||
|
MessageBox menuGetCurrentMsgBox();
|
@ -1,5 +1,4 @@
|
|||||||
#include "nx_touch.h"
|
#include "nx_touch.h"
|
||||||
#include "../common/common.h"
|
|
||||||
|
|
||||||
#define TAP_MOVEMENT_GAP 20
|
#define TAP_MOVEMENT_GAP 20
|
||||||
#define LISTING_START_Y 475
|
#define LISTING_START_Y 475
|
||||||
@ -73,7 +72,15 @@ void handleTouch(menu_s* menu) {
|
|||||||
// On touch end.
|
// On touch end.
|
||||||
else if (touchInfo.firstTouch != NULL) {
|
else if (touchInfo.firstTouch != NULL) {
|
||||||
if (menuIsMsgBoxOpen()) {
|
if (menuIsMsgBoxOpen()) {
|
||||||
// Handle tapping ok.
|
MessageBox currMsgBox = menuGetCurrentMsgBox();
|
||||||
|
int start_x = 1280 / 2 - currMsgBox.width / 2;
|
||||||
|
int start_y = (720 / 2 - currMsgBox.height / 2) + (currMsgBox.height - 80);
|
||||||
|
int end_x = start_x + currMsgBox.width;
|
||||||
|
int end_y = start_y + 80;
|
||||||
|
|
||||||
|
if (touchInfo.firstTouch->px > start_x && touchInfo.firstTouch->px < end_x && touchInfo.firstTouch->py > start_y && touchInfo.firstTouch->py < end_y && touchInfo.isTap) {
|
||||||
|
menuCloseMsgBox();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (touchInfo.firstTouch->py > LISTING_START_Y && touchInfo.firstTouch->py < LISTING_END_Y && touchInfo.isTap) {
|
if (touchInfo.firstTouch->py > LISTING_START_Y && touchInfo.firstTouch->py < LISTING_END_Y && touchInfo.isTap) {
|
||||||
handleTap(menu, touchInfo.prevTouch->px);
|
handleTap(menu, touchInfo.prevTouch->px);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
#include "../common/common.h"
|
||||||
|
|
||||||
struct touchInfo_s {
|
struct touchInfo_s {
|
||||||
touchPosition* firstTouch;
|
touchPosition* firstTouch;
|
||||||
@ -8,4 +9,6 @@ struct touchInfo_s {
|
|||||||
bool isTap;
|
bool isTap;
|
||||||
int initMenuXPos;
|
int initMenuXPos;
|
||||||
int initMenuIndex;
|
int initMenuIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void handleTouch(menu_s* menu);
|
Loading…
Reference in New Issue
Block a user