fixed double tap registered during pinch gesture, mouse cursor
Former-commit-id: 58fa2af1042fa4ecb906a41ae5b1deba84886c5b Former-commit-id: 2411214bb4b74323f7dbef5817659c08461e4473
This commit is contained in:
parent
2a0f6e01eb
commit
07429b75c3
|
@ -4,7 +4,7 @@ static uint64_t mstime(void) {
|
|||
struct timeval tv;
|
||||
uint64_t mst;
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
gettimeofday(&tv, nullptr);
|
||||
mst = ((uint64_t)tv.tv_sec)*1000;
|
||||
mst += tv.tv_usec/1000;
|
||||
return mst;
|
||||
|
@ -17,7 +17,7 @@ Aircraft *AircraftList::find(uint32_t addr) {
|
|||
if (p->addr == addr) return (p);
|
||||
p = p->next;
|
||||
}
|
||||
return (NULL);
|
||||
return (nullptr);
|
||||
}
|
||||
|
||||
//instead of this, net_io should call this class directly to update info
|
||||
|
@ -90,7 +90,7 @@ void AircraftList::update(Modes *modes) {
|
|||
}
|
||||
|
||||
p = head;
|
||||
Aircraft *prev = NULL;
|
||||
Aircraft *prev = nullptr;
|
||||
|
||||
while(p) {
|
||||
if(!p->live) {
|
||||
|
@ -111,11 +111,11 @@ void AircraftList::update(Modes *modes) {
|
|||
}
|
||||
|
||||
AircraftList::AircraftList() {
|
||||
head = NULL;
|
||||
head = nullptr;
|
||||
}
|
||||
|
||||
AircraftList::~AircraftList() {
|
||||
while(head != NULL) {
|
||||
while(head != nullptr) {
|
||||
Aircraft *temp = head;
|
||||
head = head->next;
|
||||
delete(temp);
|
||||
|
|
12
Input.cpp
12
Input.cpp
|
@ -60,7 +60,10 @@ void Input::getInput()
|
|||
break;
|
||||
|
||||
case SDL_FINGERMOTION:;
|
||||
touchDownTime = 0;
|
||||
if(mstime() - touchDownTime > 150) {
|
||||
tapCount = 0;
|
||||
touchDownTime = 0;
|
||||
}
|
||||
view->moveCenterRelative( view->screen_width * event.tfinger.dx, view->screen_height * event.tfinger.dy);
|
||||
break;
|
||||
|
||||
|
@ -68,11 +71,14 @@ void Input::getInput()
|
|||
if(mstime() - touchDownTime > 500) {
|
||||
tapCount = 0;
|
||||
}
|
||||
touchDownTime = mstime();
|
||||
|
||||
if(SDL_GetNumTouchFingers(event.tfinger.touchId) == 0) {
|
||||
touchDownTime = mstime();
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_FINGERUP:
|
||||
if(mstime() - touchDownTime < 120) {
|
||||
if(mstime() - touchDownTime < 150 && SDL_GetNumTouchFingers(event.tfinger.touchId) == 0) {
|
||||
touchx = view->screen_width * event.tfinger.x;
|
||||
touchy = view->screen_height * event.tfinger.y;
|
||||
tapCount++;
|
||||
|
|
2
Makefile
2
Makefile
|
@ -3,7 +3,7 @@
|
|||
# sure that the variable PREFIX is defined, e.g. make PREFIX=/usr/local
|
||||
#
|
||||
|
||||
CFLAGS=-O2 -g -Wall -W
|
||||
CFLAGS=-O2 -g -Wno-write-strings
|
||||
LIBS=-lm -lSDL2 -lSDL2_ttf -lSDL2_gfx
|
||||
CC=g++
|
||||
|
||||
|
|
57
View.cpp
57
View.cpp
|
@ -1095,32 +1095,12 @@ void View::drawPlanes() {
|
|||
usey = y + (mstime() - p->msSeenLatLon) * vely;
|
||||
}
|
||||
|
||||
if(p == selectedAircraft) {
|
||||
// this logic should be in input, register a callback for click?
|
||||
float elapsed = mstime() - clickTime;
|
||||
|
||||
int boxSize;
|
||||
if(elapsed < 300) {
|
||||
boxSize = (int)(20.0 * (1.0 - (1.0 - elapsed / 300.0) * cos(sqrt(elapsed))));
|
||||
} else {
|
||||
boxSize = 20;
|
||||
}
|
||||
//rectangleRGBA(renderer, usex - boxSize, usey - boxSize, usex + boxSize, usey + boxSize, pink.r, pink.g, pink.b, 255);
|
||||
lineRGBA(renderer, usex - boxSize, usey - boxSize, usex - boxSize/2, usey - boxSize, pink.r, pink.g, pink.b, 255);
|
||||
lineRGBA(renderer, usex - boxSize, usey - boxSize, usex - boxSize, usey - boxSize/2, pink.r, pink.g, pink.b, 255);
|
||||
|
||||
lineRGBA(renderer, usex + boxSize, usey - boxSize, usex + boxSize/2, usey - boxSize, pink.r, pink.g, pink.b, 255);
|
||||
lineRGBA(renderer, usex + boxSize, usey - boxSize, usex + boxSize, usey - boxSize/2, pink.r, pink.g, pink.b, 255);
|
||||
|
||||
lineRGBA(renderer, usex + boxSize, usey + boxSize, usex + boxSize/2, usey + boxSize, pink.r, pink.g, pink.b, 255);
|
||||
lineRGBA(renderer, usex + boxSize, usey + boxSize, usex + boxSize, usey + boxSize/2, pink.r, pink.g, pink.b, 255);
|
||||
|
||||
lineRGBA(renderer, usex - boxSize, usey + boxSize, usex - boxSize/2, usey + boxSize, pink.r, pink.g, pink.b, 255);
|
||||
lineRGBA(renderer, usex - boxSize, usey + boxSize, usex - boxSize, usey + boxSize/2, pink.r, pink.g, pink.b, 255);
|
||||
}
|
||||
|
||||
planeColor = lerpColor(style.planeColor, style.planeGoneColor, (now - p->seen) / (float) DISPLAY_ACTIVE);
|
||||
|
||||
if(p == selectedAircraft) {
|
||||
planeColor = style.selectedColor;
|
||||
}
|
||||
|
||||
if(outOfBounds(x,y)) {
|
||||
drawPlaneOffMap(x, y, &(p->cx), &(p->cy), planeColor);
|
||||
} else {
|
||||
|
@ -1261,6 +1241,31 @@ void View::drawClick() {
|
|||
|
||||
filledCircleRGBA(renderer, clickx, clicky, radius, white.r, white.g, white.b, alpha);
|
||||
}
|
||||
|
||||
|
||||
if(selectedAircraft) {
|
||||
// this logic should be in input, register a callback for click?
|
||||
float elapsed = mstime() - clickTime;
|
||||
|
||||
int boxSize;
|
||||
if(elapsed < 300) {
|
||||
boxSize = (int)(20.0 * (1.0 - (1.0 - elapsed / 300.0) * cos(sqrt(elapsed))));
|
||||
} else {
|
||||
boxSize = 20;
|
||||
}
|
||||
//rectangleRGBA(renderer, selectedAircraft->cx - boxSize, selectedAircraft->cy - boxSize, selectedAircraft->cx + boxSize, selectedAircraft->cy + boxSize, style.selectedColor.r, style.selectedColor.g, style.selectedColor.b, 255);
|
||||
lineRGBA(renderer, selectedAircraft->cx - boxSize, selectedAircraft->cy - boxSize, selectedAircraft->cx - boxSize/2, selectedAircraft->cy - boxSize, style.selectedColor.r, style.selectedColor.g, style.selectedColor.b, 255);
|
||||
lineRGBA(renderer, selectedAircraft->cx - boxSize, selectedAircraft->cy - boxSize, selectedAircraft->cx - boxSize, selectedAircraft->cy - boxSize/2, style.selectedColor.r, style.selectedColor.g, style.selectedColor.b, 255);
|
||||
|
||||
lineRGBA(renderer, selectedAircraft->cx + boxSize, selectedAircraft->cy - boxSize, selectedAircraft->cx + boxSize/2, selectedAircraft->cy - boxSize, style.selectedColor.r, style.selectedColor.g, style.selectedColor.b, 255);
|
||||
lineRGBA(renderer, selectedAircraft->cx + boxSize, selectedAircraft->cy - boxSize, selectedAircraft->cx + boxSize, selectedAircraft->cy - boxSize/2, style.selectedColor.r, style.selectedColor.g, style.selectedColor.b, 255);
|
||||
|
||||
lineRGBA(renderer, selectedAircraft->cx + boxSize, selectedAircraft->cy + boxSize, selectedAircraft->cx + boxSize/2, selectedAircraft->cy + boxSize, style.selectedColor.r, style.selectedColor.g, style.selectedColor.b, 255);
|
||||
lineRGBA(renderer, selectedAircraft->cx + boxSize, selectedAircraft->cy + boxSize, selectedAircraft->cx + boxSize, selectedAircraft->cy + boxSize/2, style.selectedColor.r, style.selectedColor.g, style.selectedColor.b, 255);
|
||||
|
||||
lineRGBA(renderer, selectedAircraft->cx - boxSize, selectedAircraft->cy + boxSize, selectedAircraft->cx - boxSize/2, selectedAircraft->cy + boxSize, style.selectedColor.r, style.selectedColor.g, style.selectedColor.b, 255);
|
||||
lineRGBA(renderer, selectedAircraft->cx - boxSize, selectedAircraft->cy + boxSize, selectedAircraft->cx - boxSize, selectedAircraft->cy + boxSize/2, style.selectedColor.r, style.selectedColor.g, pink.b, 255);
|
||||
}
|
||||
}
|
||||
|
||||
void View::registerClick(int tapcount, int x, int y) {
|
||||
|
@ -1297,8 +1302,7 @@ void View::registerClick(int tapcount, int x, int y) {
|
|||
}
|
||||
|
||||
void View::registerMouseMove(int x, int y) {
|
||||
lastFrameTime = mstime();
|
||||
|
||||
mouseMovedTime = mstime();
|
||||
this->mousex = x;
|
||||
this->mousey = y;
|
||||
}
|
||||
|
@ -1345,6 +1349,7 @@ void View::draw() {
|
|||
drawPlanes();
|
||||
drawStatus();
|
||||
drawMouse();
|
||||
drawClick();
|
||||
|
||||
char fps[13] = " ";
|
||||
snprintf(fps,13," %.1ffps", 1000.0 / (mstime() - lastFrameTime));
|
||||
|
|
|
@ -1 +1 @@
|
|||
884676a0069dc93832d407eea2d3e612de57d44a
|
||||
85bf9e07a831ad5a30abf7ae4737f9c8a543f9e2
|
Loading…
Reference in a new issue