new chat fixes, about dialog fixes

This commit is contained in:
camh 2022-01-02 23:36:23 -08:00
parent d806e62373
commit 1e205315c8
4 changed files with 144 additions and 135 deletions

View File

@ -5,7 +5,7 @@ const createHttpLink = require('apollo-link-http').createHttpLink;
const gql = require('graphql-tag')
// TEST_MODE can be turned on or off to prevent communications with the Apollo iMessage Server running on your moder Mac
const TEST_MODE = true
const TEST_MODE = false
const defaultOptions = {
watchQuery: {

View File

@ -160,7 +160,7 @@ resource 'MENU' (mHelp, preload) {
/* this ALRT and DITL are used as an About screen */
resource 'ALRT' (rAboutAlert, purgeable) {
{40, 20, 160, 290},
{40, 20, 160, 412},
rAboutAlert,
{ /* array: 4 elements */
/* [1] */
@ -178,7 +178,7 @@ resource 'ALRT' (rAboutAlert, purgeable) {
resource 'DITL' (rAboutAlert, purgeable) {
{ /* array DITLarray: 5 elements */
/* [1] */
{88, 180, 108, 260},
{88, 380, 108, 260},
Button {
enabled,
"OK"

View File

@ -1,9 +1,7 @@
// TODO:
// - IN PROGRESS new message window -- needs to blank out messages, then needs fixes on new mac end
// - chat during the day for a few minutes and figure out small issues
// - start writing blog posts
// - get new messages in other chats and display some sort of alert
// - need timeout on serial messages in case the computer at the other end dies (prevent hard reset)
// - need timeout on serial messages in case the computer at the other end dies (prevent hard reset) -- probably possible in coprocessorjs library
// - delete doesnt work right (leaves characters at end of string)
#define WINDOW_WIDTH 510
@ -105,7 +103,7 @@ void getMessagesFromjsFunctionResponse() {
void sendMessage() {
char output[2048];
sprintf(output, "%s&&&%s", activeChat, box_input_buffer);
sprintf(output, "%s&&&%.*s", activeChat, box_input_len, box_input_buffer);
memset(&box_input_buffer, '\0', 2048);
sprintf(box_input_buffer, "");
@ -125,8 +123,7 @@ void sendMessage() {
void sendIPAddressToCoprocessor() {
char output[2048];
sprintf(output, "%s", ip_input_buffer);
sprintf(output, "%.*s", ip_input_buffer_len, ip_input_buffer);
writeSerialPortDebug(boutRefNum, output);
callFunctionOnCoprocessor("setIPAddress", output, jsFunctionResponse);
@ -276,21 +273,34 @@ static void nuklearApp(struct nk_context *ctx) {
// prompt the user for new chat
if (sendNewChat) {
if (nk_begin_titled(ctx, "Enter New Message Recipient", "Enter New Message Recipient", nk_rect(WINDOW_WIDTH / 4, WINDOW_HEIGHT / 4, WINDOW_WIDTH / 2, 120), NK_WINDOW_TITLE|NK_WINDOW_BORDER)) {
if (nk_begin_titled(ctx, "Enter New Message Recipient", "Enter New Message Recipient", nk_rect(50, WINDOW_HEIGHT / 4, WINDOW_WIDTH - 100, 140), NK_WINDOW_TITLE|NK_WINDOW_BORDER)) {
nk_layout_row_begin(ctx, NK_STATIC, 30, 1);
{
nk_layout_row_push(ctx, WINDOW_WIDTH - 120);
nk_label(ctx, "this is known to be a bit finnicky,", NK_TEXT_ALIGN_LEFT);
nk_layout_row_push(ctx, WINDOW_WIDTH - 120);
nk_label(ctx, "input exact phone number", NK_TEXT_ALIGN_LEFT);
}
nk_layout_row_end(ctx);
nk_layout_row_begin(ctx, NK_STATIC, 30, 2);
{
nk_layout_row_push(ctx, WINDOW_WIDTH / 2 - 110);
nk_layout_row_push(ctx, WINDOW_WIDTH / 2);
nk_edit_string(ctx, NK_EDIT_SIMPLE, new_message_input_buffer, &new_message_input_buffer_len, 2048, nk_filter_default);
nk_layout_row_push(ctx, 80);
nk_layout_row_push(ctx, 100);
if (nk_button_label(ctx, "open chat")) {
sendNewChat = 0;
forceRedraw = 2;
sprintf(activeChat, new_message_input_buffer);
sprintf(activeChat, "%.*s", new_message_input_buffer_len, new_message_input_buffer);
for (int i = 0; i < MAX_CHAT_MESSAGES; i++) {
memset(&activeChatMessages[i], '\0', 2048);
}
}
}
nk_layout_row_end(ctx);
@ -376,12 +386,12 @@ static void nuklearApp(struct nk_context *ctx) {
if (forceRedraw) {
forceRedraw--;
forceRedraw = 0;
}
if (drawChatsOneMoreTime) {
drawChatsOneMoreTime--;
drawChatsOneMoreTime = 0;
}
}

View File

@ -48,7 +48,7 @@ NK_API NkQuickDrawFont* nk_quickdraw_font_create_from_file();
*
* ===============================================================
*/
#define MAX_MEMORY_IN_KB 6
#define MAX_MEMORY_IN_KB 4
#ifdef NK_QUICKDRAW_IMPLEMENTATION
#ifndef NK_QUICKDRAW_TEXT_MAX
#define NK_QUICKDRAW_TEXT_MAX 256
@ -561,10 +561,10 @@ void updateBounds(int top, int bottom, int left, int right) {
// #endif
Rect quickDrawRectangle;
quickDrawRectangle.top = (int)s->y;
quickDrawRectangle.left = (int)s->x;
quickDrawRectangle.bottom = (int)s->y + (int)s->h;
quickDrawRectangle.right = (int)s->x + (int)s->w;
quickDrawRectangle.top = s->y;
quickDrawRectangle.left = s->x;
quickDrawRectangle.bottom = s->y + s->h;
quickDrawRectangle.right = s->x + s->w;
#ifdef ENABLED_DOUBLE_BUFFERING
// we use "-8192" here to filter out nuklear "nk_null_rect" which we do not want updating bounds
@ -577,36 +577,6 @@ void updateBounds(int top, int bottom, int left, int right) {
ClipRect(&quickDrawRectangle);
}
break;
case NK_COMMAND_LINE: {
#ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
writeSerialPortDebug(boutRefNum, "NK_COMMAND_LINE");
#endif
const struct nk_command_line *l = (const struct nk_command_line *)cmd;
#ifdef COMMAND_CACHING
if (cmd->type == lastCmd->type && memcmp(l, lastCmd, sizeof(struct nk_command_line)) == 0) {
#ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
writeSerialPortDebug(boutRefNum, "ALREADY DREW CMD nk_command_line");
#endif
break;
}
#endif
color = nk_color_to_quickdraw_bw_color(l->color);
// great reference: http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/QuickDraw/QuickDraw-60.html
ForeColor(color);
PenSize((int)l->line_thickness, (int)l->line_thickness);
MoveTo((int)l->begin.x, (int)l->begin.y);
LineTo((int)l->end.x, (int)l->end.y);
}
break;
case NK_COMMAND_RECT: {
@ -633,19 +603,19 @@ void updateBounds(int top, int bottom, int left, int right) {
color = nk_color_to_quickdraw_bw_color(r->color);
ForeColor(color);
PenSize((int)r->line_thickness, (int)r->line_thickness);
PenSize(r->line_thickness, r->line_thickness);
Rect quickDrawRectangle;
quickDrawRectangle.top = (int)r->y;
quickDrawRectangle.left = (int)r->x;
quickDrawRectangle.bottom = (int)r->y + (int)r->h;
quickDrawRectangle.right = (int)r->x + (int)r->w;
quickDrawRectangle.top = r->y;
quickDrawRectangle.left = r->x;
quickDrawRectangle.bottom = r->y + r->h;
quickDrawRectangle.right = r->x + r->w;
#ifdef ENABLED_DOUBLE_BUFFERING
updateBounds(quickDrawRectangle.top, quickDrawRectangle.bottom, quickDrawRectangle.left, quickDrawRectangle.right);
#endif
FrameRoundRect(&quickDrawRectangle, (float)r->rounding, (float)r->rounding);
FrameRoundRect(&quickDrawRectangle, r->rounding, r->rounding);
}
break;
@ -661,16 +631,16 @@ void updateBounds(int top, int bottom, int left, int right) {
if (r->allowCache == false) {
Rect quickDrawRectangle;
quickDrawRectangle.top = (int)r->y;
quickDrawRectangle.left = (int)r->x;
quickDrawRectangle.bottom = (int)r->y + (int)r->h;
quickDrawRectangle.right = (int)r->x + (int)r->w;
quickDrawRectangle.top = r->y;
quickDrawRectangle.left = r->x;
quickDrawRectangle.bottom = r->y + r->h;
quickDrawRectangle.right = r->x + r->w;
#ifdef ENABLED_DOUBLE_BUFFERING
updateBounds(quickDrawRectangle.top, quickDrawRectangle.bottom, quickDrawRectangle.left, quickDrawRectangle.right);
#endif
FillRoundRect(&quickDrawRectangle, (float)r->rounding, (float)r->rounding, &qd.white);
FillRoundRect(&quickDrawRectangle, r->rounding, r->rounding, &qd.white);
break;
}
@ -692,17 +662,96 @@ void updateBounds(int top, int bottom, int left, int right) {
PenSize(1.0, 1.0);
Rect quickDrawRectangle;
quickDrawRectangle.top = (int)r->y;
quickDrawRectangle.left = (int)r->x;
quickDrawRectangle.bottom = (int)r->y + (int)r->h;
quickDrawRectangle.right = (int)r->x + (int)r->w;
quickDrawRectangle.top = r->y;
quickDrawRectangle.left = r->x;
quickDrawRectangle.bottom = r->y + r->h;
quickDrawRectangle.right = r->x + r->w;
#ifdef ENABLED_DOUBLE_BUFFERING
updateBounds(quickDrawRectangle.top, quickDrawRectangle.bottom, quickDrawRectangle.left, quickDrawRectangle.right);
#endif
FillRoundRect(&quickDrawRectangle, (float)r->rounding, (float)r->rounding, &colorPattern);
FrameRoundRect(&quickDrawRectangle, (float)r->rounding, (float)r->rounding); // http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/QuickDraw/QuickDraw-105.html#HEADING105-0
FillRoundRect(&quickDrawRectangle, r->rounding, r->rounding, &colorPattern);
FrameRoundRect(&quickDrawRectangle, r->rounding, r->rounding); // http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/QuickDraw/QuickDraw-105.html#HEADING105-0
}
break;
case NK_COMMAND_TEXT: {
const struct nk_command_text *t = (const struct nk_command_text*)cmd;
#ifdef COMMAND_CACHING
if (t->allowCache && cmd->type == lastCmd->type && memcmp(t, lastCmd, sizeof(struct nk_command_text)) == 0) {
#ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
char log[255];
sprintf(log, "ALREADY DREW CMD nk_command_text string: \"%s\", height: %d, length: %d, x: %d, y: %d, allowCache: %d", t->string, t->height, t->length, t->x, t->y, t->allowCache);
writeSerialPortDebug(boutRefNum, log);
#endif
break;
}
#endif
#ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
char log[255];
sprintf(log, "NK_COMMAND_TEXT string: \"%s\", height: %d, length: %d, x: %d, y: %d, allowCache: %d", t->string, t->height, t->length, t->x, t->y, t->allowCache);
writeSerialPortDebug(boutRefNum, log);
#endif
Rect quickDrawRectangle;
quickDrawRectangle.top = t->y;
quickDrawRectangle.left = t->x;
quickDrawRectangle.bottom = t->y + 15;
quickDrawRectangle.right = t->x + _get_text_width((const char*)t->string, (int)t->length);
#ifdef ENABLED_DOUBLE_BUFFERING
updateBounds(quickDrawRectangle.top, quickDrawRectangle.bottom, quickDrawRectangle.left, quickDrawRectangle.right);
#endif
#ifdef COMMAND_CACHING
EraseRect(&quickDrawRectangle);
#endif
color = nk_color_to_quickdraw_bw_color(t->foreground);
ForeColor(color);
MoveTo(t->x, t->y + t->height);
PenSize(1.0, 1.0);
DrawText((const char*)t->string, 0, t->length);
}
break;
case NK_COMMAND_LINE: {
#ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
writeSerialPortDebug(boutRefNum, "NK_COMMAND_LINE");
#endif
const struct nk_command_line *l = (const struct nk_command_line *)cmd;
#ifdef COMMAND_CACHING
if (cmd->type == lastCmd->type && memcmp(l, lastCmd, sizeof(struct nk_command_line)) == 0) {
#ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
writeSerialPortDebug(boutRefNum, "ALREADY DREW CMD nk_command_line");
#endif
break;
}
#endif
color = nk_color_to_quickdraw_bw_color(l->color);
// great reference: http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/QuickDraw/QuickDraw-60.html
ForeColor(color);
PenSize(l->line_thickness, l->line_thickness);
MoveTo(l->begin.x, l->begin.y);
LineTo(l->end.x, l->end.y);
}
break;
@ -730,10 +779,10 @@ void updateBounds(int top, int bottom, int left, int right) {
ForeColor(color);
Rect quickDrawRectangle;
quickDrawRectangle.top = (int)c->y;
quickDrawRectangle.left = (int)c->x;
quickDrawRectangle.bottom = (int)c->y + (int)c->h;
quickDrawRectangle.right = (int)c->x + (int)c->w;
quickDrawRectangle.top = c->y;
quickDrawRectangle.left = c->x;
quickDrawRectangle.bottom = c->y + c->h;
quickDrawRectangle.right = c->x + c->w;
#ifdef ENABLED_DOUBLE_BUFFERING
updateBounds(quickDrawRectangle.top, quickDrawRectangle.bottom, quickDrawRectangle.left, quickDrawRectangle.right);
@ -770,10 +819,10 @@ void updateBounds(int top, int bottom, int left, int right) {
// BackPat(&colorPattern); // inside macintosh: imaging with quickdraw 3-48
PenSize(1.0, 1.0);
Rect quickDrawRectangle;
quickDrawRectangle.top = (int)c->y;
quickDrawRectangle.left = (int)c->x;
quickDrawRectangle.bottom = (int)c->y + (int)c->h;
quickDrawRectangle.right = (int)c->x + (int)c->w;
quickDrawRectangle.top = c->y;
quickDrawRectangle.left = c->x;
quickDrawRectangle.bottom = c->y + c->h;
quickDrawRectangle.right = c->x + c->w;
#ifdef ENABLED_DOUBLE_BUFFERING
updateBounds(quickDrawRectangle.top, quickDrawRectangle.bottom, quickDrawRectangle.left, quickDrawRectangle.right);
@ -808,12 +857,12 @@ void updateBounds(int top, int bottom, int left, int right) {
color = nk_color_to_quickdraw_bw_color(t->color);
ForeColor(color);
PenSize((int)t->line_thickness, (int)t->line_thickness);
PenSize(t->line_thickness, t->line_thickness);
MoveTo((int)t->a.x, (int)t->a.y);
LineTo((int)t->b.x, (int)t->b.y);
LineTo((int)t->c.x, (int)t->c.y);
LineTo((int)t->a.x, (int)t->a.y);
MoveTo(t->a.x, t->a.y);
LineTo(t->b.x, t->b.y);
LineTo(t->c.x, t->c.y);
LineTo(t->a.x, t->a.y);
}
break;
@ -844,10 +893,10 @@ void updateBounds(int top, int bottom, int left, int right) {
ForeColor(color);
PolyHandle trianglePolygon = OpenPoly();
MoveTo((int)t->a.x, (int)t->a.y);
LineTo((int)t->b.x, (int)t->b.y);
LineTo((int)t->c.x, (int)t->c.y);
LineTo((int)t->a.x, (int)t->a.y);
MoveTo(t->a.x, t->a.y);
LineTo(t->b.x, t->b.y);
LineTo(t->c.x, t->c.y);
LineTo(t->a.x, t->a.y);
ClosePoly();
FillPoly(trianglePolygon, &colorPattern);
@ -982,56 +1031,6 @@ void updateBounds(int top, int bottom, int left, int right) {
}
}
break;
case NK_COMMAND_TEXT: {
const struct nk_command_text *t = (const struct nk_command_text*)cmd;
#ifdef COMMAND_CACHING
if (t->allowCache && cmd->type == lastCmd->type && memcmp(t, lastCmd, sizeof(struct nk_command_text)) == 0) {
#ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
char log[255];
sprintf(log, "ALREADY DREW CMD nk_command_text string: \"%s\", height: %d, length: %d, x: %d, y: %d, allowCache: %d", t->string, t->height, t->length, t->x, t->y, t->allowCache);
writeSerialPortDebug(boutRefNum, log);
#endif
break;
}
#endif
#ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
char log[255];
sprintf(log, "NK_COMMAND_TEXT string: \"%s\", height: %d, length: %d, x: %d, y: %d, allowCache: %d", t->string, t->height, t->length, t->x, t->y, t->allowCache);
writeSerialPortDebug(boutRefNum, log);
#endif
Rect quickDrawRectangle;
quickDrawRectangle.top = (int)t->y;
quickDrawRectangle.left = (int)t->x;
quickDrawRectangle.bottom = (int)t->y + 15;
quickDrawRectangle.right = (int)t->x + _get_text_width((const char*)t->string, (int)t->length);
#ifdef ENABLED_DOUBLE_BUFFERING
updateBounds(quickDrawRectangle.top, quickDrawRectangle.bottom, quickDrawRectangle.left, quickDrawRectangle.right);
#endif
// if (!t->allowCache) {
EraseRect(&quickDrawRectangle);
// }
color = nk_color_to_quickdraw_bw_color(t->foreground);
ForeColor(color);
MoveTo((int)t->x, (int)t->y + (int)t->height);
PenSize(1.0, 1.0);
DrawText((const char*)t->string, 0, (int)t->length);
}
break;
case NK_COMMAND_CURVE: {