swapping out color names in preparation for styles
Former-commit-id: 4ffc36aa3a42586e1a7d4a17a5946175e23c3cb3 Former-commit-id: 93bbe2405261c2b98ba36a1548ec1993cdbf0538
This commit is contained in:
parent
06276d33c2
commit
293c7d2a6d
46
draw.c
46
draw.c
|
@ -21,6 +21,20 @@ float sign(float x) {
|
||||||
return (x > 0) - (x < 0);
|
return (x > 0) - (x < 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float clamp(float in, float min, float max) {
|
||||||
|
float out = in;
|
||||||
|
|
||||||
|
if(in < min) {
|
||||||
|
out = min;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(in > max) {
|
||||||
|
out = max;
|
||||||
|
}
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
void CROSSVP(float *v, float *u, float *w)
|
void CROSSVP(float *v, float *u, float *w)
|
||||||
{
|
{
|
||||||
v[0] = u[1]*w[2] - u[2]*(w)[1];
|
v[0] = u[1]*w[2] - u[2]*(w)[1];
|
||||||
|
@ -314,11 +328,7 @@ void drawTrail(float *oldDx, float *oldDy, float *oldHeading, time_t * oldSeen,
|
||||||
|
|
||||||
float age = pow(1.0 - (float)(now - oldSeen[currentIdx]) / TRAIL_TTL, 2.2);
|
float age = pow(1.0 - (float)(now - oldSeen[currentIdx]) / TRAIL_TTL, 2.2);
|
||||||
|
|
||||||
if(age < 0) {
|
uint8_t colorVal = (uint8_t)floor(255.0 * clamp(age,0,1));
|
||||||
age = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t colorVal = (uint8_t)floor(255.0 * age);
|
|
||||||
|
|
||||||
thickLineRGBA(appData.renderer, prevX, prevY, currentX, currentY, 2 * appData.screen_uiscale, colorVal, colorVal, colorVal, 64);
|
thickLineRGBA(appData.renderer, prevX, prevY, currentX, currentY, 2 * appData.screen_uiscale, colorVal, colorVal, colorVal, 64);
|
||||||
|
|
||||||
|
@ -332,7 +342,7 @@ void drawTrail(float *oldDx, float *oldDy, float *oldHeading, time_t * oldSeen,
|
||||||
//tick marks
|
//tick marks
|
||||||
|
|
||||||
age = 1.0 - (float) 4.0 * (now - oldSeen[currentIdx]) / TRAIL_TTL;
|
age = 1.0 - (float) 4.0 * (now - oldSeen[currentIdx]) / TRAIL_TTL;
|
||||||
colorVal = (uint8_t)floor(255.0 * age);
|
colorVal = (uint8_t)floor(255.0 * clamp(age,0,1));
|
||||||
|
|
||||||
float vec[3];
|
float vec[3];
|
||||||
vec[0] = sin(oldHeading[currentIdx] * M_PI / 180);
|
vec[0] = sin(oldHeading[currentIdx] * M_PI / 180);
|
||||||
|
@ -345,7 +355,6 @@ void drawTrail(float *oldDx, float *oldDy, float *oldHeading, time_t * oldSeen,
|
||||||
|
|
||||||
CROSSVP(out,vec,up);
|
CROSSVP(out,vec,up);
|
||||||
|
|
||||||
|
|
||||||
int x1, y1, x2, y2;
|
int x1, y1, x2, y2;
|
||||||
|
|
||||||
int cross_size = 5 * appData.screen_uiscale;
|
int cross_size = 5 * appData.screen_uiscale;
|
||||||
|
@ -375,10 +384,10 @@ void drawScaleBars()
|
||||||
|
|
||||||
char scaleLabel[13] = "";
|
char scaleLabel[13] = "";
|
||||||
|
|
||||||
lineRGBA(appData.renderer,10,10,10,10*appData.screen_uiscale,pink.r, pink.g, pink.b, 255);
|
lineRGBA(appData.renderer,10,10,10,10*appData.screen_uiscale,style.scaleBarColor.r, style.scaleBarColor.g, style.scaleBarColor.b, 255);
|
||||||
|
|
||||||
while(scaleBarDist < appData.screen_width) {
|
while(scaleBarDist < appData.screen_width) {
|
||||||
lineRGBA(appData.renderer,10+scaleBarDist,8,10+scaleBarDist,16*appData.screen_uiscale,pink.r, pink.g, pink.b, 255);
|
lineRGBA(appData.renderer,10+scaleBarDist,8,10+scaleBarDist,16*appData.screen_uiscale,style.scaleBarColor.r, style.scaleBarColor.g, style.scaleBarColor.b, 255);
|
||||||
|
|
||||||
if (Modes.metric) {
|
if (Modes.metric) {
|
||||||
snprintf(scaleLabel,13,"%dkm", (int)pow(10,scalePower));
|
snprintf(scaleLabel,13,"%dkm", (int)pow(10,scalePower));
|
||||||
|
@ -386,7 +395,7 @@ void drawScaleBars()
|
||||||
snprintf(scaleLabel,13,"%dmi", (int)pow(10,scalePower));
|
snprintf(scaleLabel,13,"%dmi", (int)pow(10,scalePower));
|
||||||
}
|
}
|
||||||
|
|
||||||
drawString(scaleLabel, 10+scaleBarDist, 15*appData.screen_uiscale, appData.mapFont, pink);
|
drawString(scaleLabel, 10+scaleBarDist, 15*appData.screen_uiscale, appData.mapFont, style.scaleBarColor);
|
||||||
|
|
||||||
scalePower++;
|
scalePower++;
|
||||||
scaleBarDist = screenDist((float)pow(10,scalePower));
|
scaleBarDist = screenDist((float)pow(10,scalePower));
|
||||||
|
@ -395,7 +404,7 @@ void drawScaleBars()
|
||||||
scalePower--;
|
scalePower--;
|
||||||
scaleBarDist = screenDist((float)pow(10,scalePower));
|
scaleBarDist = screenDist((float)pow(10,scalePower));
|
||||||
|
|
||||||
lineRGBA(appData.renderer,10,10+5*appData.screen_uiscale,10+scaleBarDist,10+5*appData.screen_uiscale,pink.r, pink.g, pink.b, 255);
|
lineRGBA(appData.renderer,10,10+5*appData.screen_uiscale,10+scaleBarDist,10+5*appData.screen_uiscale, style.scaleBarColor.r, style.scaleBarColor.g, style. scaleBarColor.b, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawPolys(QuadTree *tree, float screen_lat_min, float screen_lat_max, float screen_lon_min, float screen_lon_max) {
|
void drawPolys(QuadTree *tree, float screen_lat_min, float screen_lat_max, float screen_lon_min, float screen_lon_max) {
|
||||||
|
@ -460,7 +469,7 @@ void drawPolys(QuadTree *tree, float screen_lat_min, float screen_lat_max, float
|
||||||
|
|
||||||
float factor = 1.0 - (d1+d2) / (3* appData.maxDist * appData.maxDist);
|
float factor = 1.0 - (d1+d2) / (3* appData.maxDist * appData.maxDist);
|
||||||
|
|
||||||
SDL_Color lineColor = lerpColor(purple, blue, factor);
|
SDL_Color lineColor = lerpColor(style.mapOuterColor, style.mapInnerColor, factor);
|
||||||
|
|
||||||
lineRGBA(appData.renderer, x1, y1, x2, y2, lineColor.r, lineColor.g, lineColor.b, 255);
|
lineRGBA(appData.renderer, x1, y1, x2, y2, lineColor.r, lineColor.g, lineColor.b, 255);
|
||||||
|
|
||||||
|
@ -913,9 +922,9 @@ void drawPlanes() {
|
||||||
|
|
||||||
lineRGBA(appData.renderer, usex - boxSize, usey + boxSize, usex - boxSize/2, usey + boxSize, pink.r, pink.g, pink.b, 255);
|
lineRGBA(appData.renderer, usex - boxSize, usey + boxSize, usex - boxSize/2, usey + boxSize, pink.r, pink.g, pink.b, 255);
|
||||||
lineRGBA(appData.renderer, usex - boxSize, usey + boxSize, usex - boxSize, usey + boxSize/2, pink.r, pink.g, pink.b, 255);
|
lineRGBA(appData.renderer, usex - boxSize, usey + boxSize, usex - boxSize, usey + boxSize/2, pink.r, pink.g, pink.b, 255);
|
||||||
planeColor = lerpColor(pink, grey, (now - p->seen) / (float) DISPLAY_ACTIVE);
|
planeColor = lerpColor(style.selectedColor, style.planeGoneColor, (now - p->seen) / (float) DISPLAY_ACTIVE);
|
||||||
} else {
|
} else {
|
||||||
planeColor = lerpColor(green, grey, (now - p->seen) / (float) DISPLAY_ACTIVE);
|
planeColor = lerpColor(style.planeColor, style.planeGoneColor, (now - p->seen) / (float) DISPLAY_ACTIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(outOfBounds(x,y)) {
|
if(outOfBounds(x,y)) {
|
||||||
|
@ -1061,7 +1070,7 @@ void drawMouse() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void registerClick() {
|
void registerClick() {
|
||||||
if(appData.tapCount == 1) {
|
if(appData.tapCount == 1 && appData.isDragging == 0) {
|
||||||
struct planeObj *p = planes;
|
struct planeObj *p = planes;
|
||||||
struct planeObj *selection = NULL;
|
struct planeObj *selection = NULL;
|
||||||
|
|
||||||
|
@ -1108,7 +1117,8 @@ void draw() {
|
||||||
if(appData.mapMoved) {
|
if(appData.mapMoved) {
|
||||||
SDL_SetRenderTarget(appData.renderer, appData.mapTexture);
|
SDL_SetRenderTarget(appData.renderer, appData.mapTexture);
|
||||||
|
|
||||||
SDL_SetRenderDrawColor(appData.renderer, 0, 0, 0, 0);
|
SDL_SetRenderDrawColor(appData.renderer, style.backgroundColor.r, style.backgroundColor.g, style.backgroundColor.b, 255);
|
||||||
|
|
||||||
SDL_RenderClear(appData.renderer);
|
SDL_RenderClear(appData.renderer);
|
||||||
|
|
||||||
drawGeography();
|
drawGeography();
|
||||||
|
@ -1125,7 +1135,7 @@ void draw() {
|
||||||
}
|
}
|
||||||
|
|
||||||
//SDL_SetRenderDrawColor( appData.renderer, 0, 15, 30, 0);
|
//SDL_SetRenderDrawColor( appData.renderer, 0, 15, 30, 0);
|
||||||
SDL_SetRenderDrawColor(appData.renderer, 0, 0, 0, 0);
|
SDL_SetRenderDrawColor(appData.renderer, style.backgroundColor.r, style.backgroundColor.g, style.backgroundColor.b, 255);
|
||||||
|
|
||||||
SDL_RenderClear(appData.renderer);
|
SDL_RenderClear(appData.renderer);
|
||||||
|
|
||||||
|
@ -1136,7 +1146,7 @@ void draw() {
|
||||||
drawMouse();
|
drawMouse();
|
||||||
|
|
||||||
char fps[13] = " ";
|
char fps[13] = " ";
|
||||||
snprintf(fps,13," %ffps", 1000.0 / (mstime() - appData.lastFrameTime));
|
snprintf(fps,13," %.1ffps", 1000.0 / (mstime() - appData.lastFrameTime));
|
||||||
drawStringBG(fps, 0,0, appData.mapFont, grey, black);
|
drawStringBG(fps, 0,0, appData.mapFont, grey, black);
|
||||||
|
|
||||||
SDL_RenderPresent(appData.renderer);
|
SDL_RenderPresent(appData.renderer);
|
||||||
|
|
17
init.c
17
init.c
|
@ -1,5 +1,6 @@
|
||||||
#include "dump1090.h"
|
#include "dump1090.h"
|
||||||
#include "structs.h"
|
#include "structs.h"
|
||||||
|
#include "monokai.h"
|
||||||
|
|
||||||
void init(char *title) {
|
void init(char *title) {
|
||||||
|
|
||||||
|
@ -46,6 +47,7 @@ void init(char *title) {
|
||||||
appData.mapTargetLon = 0;
|
appData.mapTargetLon = 0;
|
||||||
appData.mapTargetLat = 0;
|
appData.mapTargetLat = 0;
|
||||||
appData.mapTargetMaxDist = 0;
|
appData.mapTargetMaxDist = 0;
|
||||||
|
appData.isDragging = 0;
|
||||||
selectedPlane = NULL;
|
selectedPlane = NULL;
|
||||||
|
|
||||||
if(appData.fullscreen) {
|
if(appData.fullscreen) {
|
||||||
|
@ -70,6 +72,21 @@ void init(char *title) {
|
||||||
appData.labelFontWidth = 6 * appData.screen_uiscale;
|
appData.labelFontWidth = 6 * appData.screen_uiscale;
|
||||||
appData.labelFontHeight = 12 * appData.screen_uiscale;
|
appData.labelFontHeight = 12 * appData.screen_uiscale;
|
||||||
|
|
||||||
|
SDL_Color bgcolor = {10,20,30,255};
|
||||||
|
SDL_Color greenblue = {236,192,68,255};
|
||||||
|
SDL_Color lightblue = {211,208,203,255};
|
||||||
|
SDL_Color mediumblue ={110,136,152,255};
|
||||||
|
SDL_Color darkblue = {46,82,102,255};
|
||||||
|
|
||||||
|
style.backgroundColor = bgcolor;
|
||||||
|
style.selectedColor = pink;
|
||||||
|
style.planeColor = greenblue;
|
||||||
|
style.planeGoneColor = grey;
|
||||||
|
style.mapInnerColor = mediumblue;
|
||||||
|
style.mapOuterColor = darkblue;
|
||||||
|
style.scaleBarColor = lightGrey;
|
||||||
|
style.buttonColor = lightblue;
|
||||||
|
|
||||||
initMaps();
|
initMaps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
31
input.c
31
input.c
|
@ -45,48 +45,24 @@ void getInput()
|
||||||
case SDL_MULTIGESTURE:
|
case SDL_MULTIGESTURE:
|
||||||
appData.maxDist /=1.0 + 4.0*event.mgesture.dDist;
|
appData.maxDist /=1.0 + 4.0*event.mgesture.dDist;
|
||||||
appData.mapTargetMaxDist = 0;
|
appData.mapTargetMaxDist = 0;
|
||||||
//moveCenterRelative((appData.screen_width/2) * event.mgesture.x, (appData.screen_height/2) * event.mgesture.y);
|
|
||||||
//moveCenterRelative(event.mgesture.x, event.mgesture.y);
|
|
||||||
|
|
||||||
appData.mapMoved = 1;
|
appData.mapMoved = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// case SDL_FINGERMOTION:;
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
// moveCenterRelative(appData.screen_width * event.tfinger.dx, appData.screen_height * event.tfinger.dy);
|
|
||||||
// break;
|
|
||||||
|
|
||||||
case SDL_FINGERDOWN:
|
|
||||||
if(mstime() - appData.touchDownTime > 500) {
|
if(mstime() - appData.touchDownTime > 500) {
|
||||||
appData.tapCount = 0;
|
appData.tapCount = 0;
|
||||||
}
|
}
|
||||||
appData.touchDownTime = mstime();
|
appData.touchDownTime = mstime();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// case SDL_FINGERUP:
|
|
||||||
// if(mstime() - appData.touchDownTime < 30) {
|
|
||||||
// appData.touchx = appData.screen_width * event.tfinger.x;
|
|
||||||
// appData.touchy = appData.screen_height * event.tfinger.y;
|
|
||||||
// selectedPlane = NULL;
|
|
||||||
// //appData.tapCount++;
|
|
||||||
|
|
||||||
// registerClick();
|
|
||||||
// } else {
|
|
||||||
// appData.touchx = 0;
|
|
||||||
// appData.touchy = 0;
|
|
||||||
// appData.tapCount = 0;
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
|
|
||||||
// case SDL_MOUSEBUTTONDOWN:;
|
|
||||||
// appData.tapCount = 0;
|
|
||||||
// break;
|
|
||||||
|
|
||||||
case SDL_MOUSEBUTTONUP:;
|
case SDL_MOUSEBUTTONUP:;
|
||||||
appData.touchx = event.motion.x;
|
appData.touchx = event.motion.x;
|
||||||
appData.touchy = event.motion.y;
|
appData.touchy = event.motion.y;
|
||||||
appData.tapCount = event.button.clicks;
|
appData.tapCount = event.button.clicks;
|
||||||
|
|
||||||
registerClick();
|
registerClick();
|
||||||
|
|
||||||
|
appData.isDragging = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_MOUSEMOTION:;
|
case SDL_MOUSEMOTION:;
|
||||||
|
@ -95,6 +71,7 @@ void getInput()
|
||||||
appData.mousey = event.motion.y;
|
appData.mousey = event.motion.y;
|
||||||
|
|
||||||
if (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT)) {
|
if (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT)) {
|
||||||
|
appData.isDragging = 1;
|
||||||
moveCenterRelative(event.motion.xrel, event.motion.yrel);
|
moveCenterRelative(event.motion.xrel, event.motion.yrel);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
./view1090 --screensize 640 480 --fullscreen --server adsb --lat 47.6 --lon -122.3
|
./view1090 --screensize 640 360 --fullscreen --server adsb --lat 47.6 --lon -122.3
|
||||||
|
|
9
status.c
9
status.c
|
@ -175,17 +175,18 @@ void drawStatus() {
|
||||||
|
|
||||||
char strLoc[20] = " ";
|
char strLoc[20] = " ";
|
||||||
snprintf(strLoc, 20, "%3.3fN %3.3f%c", appData.centerLat, fabs(appData.centerLon),(appData.centerLon > 0) ? 'E' : 'W');
|
snprintf(strLoc, 20, "%3.3fN %3.3f%c", appData.centerLat, fabs(appData.centerLon),(appData.centerLon > 0) ? 'E' : 'W');
|
||||||
drawStatusBox(&left, &top, "loc", strLoc, pink);
|
drawStatusBox(&left, &top, "loc", strLoc, style.buttonColor);
|
||||||
|
|
||||||
char strPlaneCount[10] = " ";
|
char strPlaneCount[10] = " ";
|
||||||
snprintf(strPlaneCount, 10,"%d/%d", Status.numVisiblePlanes, Status.numPlanes);
|
snprintf(strPlaneCount, 10,"%d/%d", Status.numVisiblePlanes, Status.numPlanes);
|
||||||
drawStatusBox(&left, &top, "disp", strPlaneCount, yellow);
|
drawStatusBox(&left, &top, "disp", strPlaneCount, style.buttonColor);
|
||||||
|
|
||||||
char strMsgRate[18] = " ";
|
char strMsgRate[18] = " ";
|
||||||
snprintf(strMsgRate, 18,"%.0f/s", Status.msgRate);
|
snprintf(strMsgRate, 18,"%.0f/s", Status.msgRate);
|
||||||
drawStatusBox(&left, &top, "rate", strMsgRate, orange);
|
drawStatusBox(&left, &top, "rate", strMsgRate, style.buttonColor);
|
||||||
|
|
||||||
char strSig[18] = " ";
|
char strSig[18] = " ";
|
||||||
snprintf(strSig, 18, "%.0f%%", 100.0 * Status.avgSig / 1024.0);
|
snprintf(strSig, 18, "%.0f%%", 100.0 * Status.avgSig / 1024.0);
|
||||||
drawStatusBox(&left, &top, "sAvg", strSig, green);
|
drawStatusBox(&left, &top, "sAvg", strSig, style.buttonColor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
16
structs.h
16
structs.h
|
@ -41,6 +41,7 @@ typedef struct AppData
|
||||||
int touchx;
|
int touchx;
|
||||||
int touchy;
|
int touchy;
|
||||||
int tapCount;
|
int tapCount;
|
||||||
|
int isDragging;
|
||||||
|
|
||||||
uint64_t mouseMovedTime;
|
uint64_t mouseMovedTime;
|
||||||
int mousex;
|
int mousex;
|
||||||
|
@ -106,6 +107,21 @@ struct {
|
||||||
double maxDist;
|
double maxDist;
|
||||||
struct aircraft *closeCall;
|
struct aircraft *closeCall;
|
||||||
} Status;
|
} Status;
|
||||||
|
typedef struct Style {
|
||||||
|
SDL_Color backgroundColor;
|
||||||
|
|
||||||
|
SDL_Color selectedColor;
|
||||||
|
SDL_Color planeColor;
|
||||||
|
SDL_Color planeGoneColor;
|
||||||
|
|
||||||
|
SDL_Color mapInnerColor;
|
||||||
|
SDL_Color mapOuterColor;
|
||||||
|
SDL_Color scaleBarColor;
|
||||||
|
|
||||||
|
SDL_Color buttonColor;
|
||||||
|
} Style;
|
||||||
|
|
||||||
|
Style style;
|
||||||
|
|
||||||
// functions
|
// functions
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
9a8fdd967629e70f6eb3ebced534ec141239aa05
|
b7d48859caf08d954d9a9d596481d36962f33b98
|
Loading…
Reference in a new issue