diff --git a/src/vecparse.c b/src/vecparse.c index e56b440..4cbcc0c 100644 --- a/src/vecparse.c +++ b/src/vecparse.c @@ -55,7 +55,7 @@ static int parserGetWord(char *wordList, char **tokenEnd); static gboolean parserGetX(char **tokenEnd, char ***variables, int *x); static gboolean parserGetXY(char **tokenEnd, char ***variables, int *x, int *y); static gboolean parserGetXYZ(char **tokenEnd, char ***variables, int *x, int *y, int *z); -static int variableCollect(char *value, char ***variables); +static gboolean variableCollect(char *value, char ***variables, int *result); static int labelGetValue(int lineNumber, VecByteCodeT *bytecode, LabelT *labels, LabelT ***unresolved, char *label) { @@ -145,9 +145,7 @@ static gboolean parserGetNextValue(char *token, char **valueEnd, char ***variabl value = strtok_r(token, ",", valueEnd); if (value == NULL) return FALSE; - *x = variableCollect(value, variables); - - return TRUE; + return variableCollect(value, variables, x);; } @@ -183,9 +181,7 @@ static gboolean parserGetX(char **tokenEnd, char ***variables, int *x) { value = strtok_r(NULL, " ", tokenEnd); if (value == NULL) return FALSE; - *x = variableCollect(value, variables); - - return TRUE; + return variableCollect(value, variables, x); } @@ -222,7 +218,7 @@ static gboolean parserGetXYZ(char **tokenEnd, char ***variables, int *x, int *y, } -static int variableCollect(char *value, char ***variables) { +static gboolean variableCollect(char *value, char ***variables, int *result) { int index; int found; char *endPtr = NULL; @@ -263,7 +259,9 @@ static int variableCollect(char *value, char ***variables) { } - return found; + *result = found; + + return TRUE; } @@ -685,32 +683,35 @@ int vecparser(char *programIn, VecByteCodeT *bytecode) { } // read program line // Resolve forward label declarations and patch bytecode. + if (lineOkay) { #ifdef DEBUG - for (y1=0; y1key); - } -#endif - for (y1=0; y1key, labels[x1].key); - if (strcasecmp(unresolved[y1]->key, labels[x1].key) == 0) { - x2 = x1; - break; - } + for (y1 = 0; y1 < shlen(labels); y1++) { + debug("Resolved - %s\n", labels[y1].key); } - if (x2 < 0) { - // Label not found! Error! - result = unresolved[y1]->line; - break; - } else { - // Write this label offset into the unresolved offset. - bytecode->bytes[unresolved[y1]->value++] = (labels[x2].value & 0xFF00) >> 8; - bytecode->bytes[unresolved[y1]->value] = labels[x2].value & 0x00FF; + for (y1 = 0; y1 < arrlen(unresolved); y1++) { + debug("Unresolved - %s\n", unresolved[y1]->key); + } +#endif + for (y1 = 0; y1 < arrlen(unresolved); y1++) { + // Find offset of this unresolved label. We search ourselves so it's case-insensitive. + x2 = -1; + for (x1 = 0; x1 < shlen(labels); x1++) { + debug("Checking label %d of %d - %s == %s\n", y1, (int)arrlen(unresolved), unresolved[y1]->key, + labels[x1].key); + if (strcasecmp(unresolved[y1]->key, labels[x1].key) == 0) { + x2 = x1; + break; + } + } + if (x2 < 0) { + // Label not found! Error! + result = unresolved[y1]->line; + break; + } else { + // Write this label offset into the unresolved offset. + bytecode->bytes[unresolved[y1]->value++] = (labels[x2].value & 0xFF00) >> 8; + bytecode->bytes[unresolved[y1]->value] = labels[x2].value & 0x00FF; + } } } diff --git a/src/vector.c b/src/vector.c index 17af6ae..87eb6b8 100644 --- a/src/vector.c +++ b/src/vector.c @@ -78,7 +78,7 @@ static int _nextEditorId = 0; static int byte(VectorDataT *self, unsigned char byte); EVENT void drawVectorImageClick(GtkWidget *object, GdkEventButton *event, gpointer userData); EVENT gboolean drawVectorImageDraw(GtkWidget *widget, cairo_t *cr, gpointer userData); -EVENT gboolean drawVectorImageMotionEvent(GtkWidget* widget, GdkEventMotion* event, gpointer userData); +EVENT gboolean drawVectorImageMotionEvent(GtkWidget *widget, GdkEventMotion *event, gpointer userData); EVENT void editorVectorNotify(GtkWidget *sciWidget, gint ctrlID, struct SCNotification *notifyData, gpointer userData); EVENT void fileVectorTraceImageFileSet(GtkWidget *object, gpointer userData); static int getWord(VecByteCodeT *bytecode, int *index); @@ -96,6 +96,13 @@ EVENT void menuVectorHelpVector(GtkWidget *object, gpointer userData); static void renderBytecode(VecByteCodeT *bytecode, VectorDataT *self); EVENT void scaleVectorTraceImageValueChanged(GtkWidget *object, gpointer userData); static void setDirty(VectorDataT *self, gboolean dirty); +EVENT void toolBoxClicked(GtkToolButton *object, gpointer user_data); +EVENT void toolCircleClicked(GtkToolButton *object, gpointer user_data); +EVENT void toolEllipseClicked(GtkToolButton *object, gpointer user_data); +EVENT void toolFillClicked(GtkToolButton *object, gpointer user_data); +EVENT void toolLineClicked(GtkToolButton *object, gpointer user_data); +EVENT void toolPlotClicked(GtkToolButton *object, gpointer user_data); +EVENT void toolRectangleClicked(GtkToolButton *object, gpointer user_data); static float variable(VectorDataT *self, unsigned char byte); static int word(VectorDataT *self, unsigned short word); EVENT gboolean winVectorClose(GtkWidget *object, gpointer userData); @@ -220,6 +227,11 @@ EVENT gboolean drawVectorImageMotionEvent(GtkWidget *widget, GdkEventMotion *eve SSM(SCI_SETSEL, temp, temp + strlen(buffer)); // If they're holding the button down, update the point. if (event->state & GDK_BUTTON1_MASK) { + // Are these values sane? + if (x < 0) x = 0; + if (x > 319) x = 319; + if (y < 0) y = 0; + if (y > 199) y = 199; snprintf(buffer, 8, "%d,%d", x, y); SSM(SCI_REPLACETARGET, -1, (sptr_t)buffer); } @@ -647,7 +659,7 @@ static void renderBytecode(VecByteCodeT *bytecode, VectorDataT *self) { x2 = word(self, GET_WORD); y2 = word(self, GET_WORD); debug("Box %d,%d to %d,%d\n", x1, y1, x2, y2); - jlDrawBox(self->jlc, x1, y1, x2, y2); + jlDrawBoxFilled(self->jlc, x1, y1, x2, y2); ADD_POINT(x1, y1); ADD_POINT(x2, y2); break; @@ -891,7 +903,7 @@ static void renderBytecode(VecByteCodeT *bytecode, VectorDataT *self) { x2 = word(self, GET_WORD); y2 = word(self, GET_WORD); debug("Rectangle %d,%d to %d,%d\n", x1, y1, x2, y2); - jlDrawBoxFilled(self->jlc, x1, y1, x2, y2); + jlDrawBox(self->jlc, x1, y1, x2, y2); ADD_POINT(x1, y1); ADD_POINT(x2, y2); break; @@ -968,6 +980,41 @@ static void setDirty(VectorDataT *self, gboolean dirty) { } +EVENT void toolBoxClicked(GtkToolButton *object, gpointer user_data) { + +} + + +EVENT void toolCircleClicked(GtkToolButton *object, gpointer user_data) { + +} + + +EVENT void toolEllipseClicked(GtkToolButton *object, gpointer user_data) { + +} + + +EVENT void toolFillClicked(GtkToolButton *object, gpointer user_data) { + +} + + +EVENT void toolLineClicked(GtkToolButton *object, gpointer user_data) { + +} + + +EVENT void toolPlotClicked(GtkToolButton *object, gpointer user_data) { + +} + + +EVENT void toolRectangleClicked(GtkToolButton *object, gpointer user_data) { + +} + + static float variable(VectorDataT *self, unsigned char byte) { int value; @@ -1026,8 +1073,19 @@ EVENT gboolean winVectorClose(GtkWidget *object, gpointer userData) { void winVectorCreate(void) { VectorDataT *self; - char *widgetNames[] = { "winVector", "boxVectorForEditor", "drawVectorImage", "fileVectorTraceImage", NULL }; - GtkWidget **widgets[] = { NULL, NULL, NULL, NULL }; + char *widgetNames[] = { + "winVector", + "boxVectorForEditor", + "drawVectorImage", + "fileVectorTraceImage", + NULL + }; + GtkWidget **widgets[] = { + NULL, + NULL, + NULL, + NULL + }; // Set up instance data. self = NEW(VectorDataT); @@ -1046,6 +1104,9 @@ void winVectorCreate(void) { // Grab title. self->title = strdup(gtk_window_get_title(GTK_WINDOW(self->windowData.window))); + // Add our custom icons. + gtk_icon_theme_add_resource_path(gtk_icon_theme_get_for_screen(gdk_screen_get_default()), "/com/kangaroopunch/joeydev/icons"); + // Add missing event to drawVectorImage gtk_widget_add_events(self->drawVectorImage, GDK_BUTTON_PRESS_MASK); g_signal_connect(G_OBJECT(self->drawVectorImage), "button-press-event", G_CALLBACK(drawVectorImageClick), self); diff --git a/tools/prebuild.sh b/tools/prebuild.sh index aa9f593..2fc3dec 100755 --- a/tools/prebuild.sh +++ b/tools/prebuild.sh @@ -27,25 +27,29 @@ ROOT=$1 pushd "${ROOT}" || exit &> /dev/null - mkdir -p ui/generated + echo Generating UI Embedded Code... + mkdir -p ui/generated +:<<'SKIP' glib-compile-resources \ --sourcedir=ui/ \ --target=ui/generated/resources \ --generate \ ui/joeydev.gresource.xml + glib-compile-resources \ + --sourcedir=ui/ \ + --target=ui/generated/resources.h \ + --generate-header \ + ui/joeydev.gresource.xml +SKIP + glib-compile-resources \ --sourcedir=ui/ \ --target=ui/generated/resources.c \ --generate-source \ ui/joeydev.gresource.xml - glib-compile-resources \ - --sourcedir=ui/ \ - --target=ui/generated/resources.h \ - --generate-header \ - ui/joeydev.gresource.xml popd || true &> /dev/null diff --git a/ui/JoeyDev.glade b/ui/JoeyDev.glade index 91dcae5..5f2e6ef 100644 --- a/ui/JoeyDev.glade +++ b/ui/JoeyDev.glade @@ -1,7 +1,33 @@ - + + + + + + False JoeyDev diff --git a/ui/Vector.glade b/ui/Vector.glade index 4a4ac2e..361070b 100644 --- a/ui/Vector.glade +++ b/ui/Vector.glade @@ -1,7 +1,33 @@ - + + + + + + 100 50 @@ -203,17 +229,102 @@ False vertical - + True False - icons + both + + + True + False + Box + True + action-box + + + + False + True + + + + + True + False + Circle + True + action-circle + + + + False + True + + + + + True + False + Ellipse + True + action-ellipse + + + + False + True + + + + + True + False + Fill + True + action-fill + + + + False + True + + True False Line True - dialog-ok + action-line + + + + False + True + + + + + True + False + Plot + True + action-plot + + + + False + True + + + + + True + False + Rectangle + True + action-rectangle + False diff --git a/ui/action-box.png b/ui/action-box.png new file mode 100644 index 0000000..aa988eb --- /dev/null +++ b/ui/action-box.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c5a29724a3719ee28a8456ddae24b01e1705847f3bea2076c09aadc7e448a8ae +size 607 diff --git a/ui/action-circle.png b/ui/action-circle.png new file mode 100644 index 0000000..3667601 --- /dev/null +++ b/ui/action-circle.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f890c8c87e85b937b095d3c9f34f7774de9ae8ffdfd442f75a3b3c96f8d749ce +size 664 diff --git a/ui/action-ellipse.png b/ui/action-ellipse.png new file mode 100644 index 0000000..fabc1ef --- /dev/null +++ b/ui/action-ellipse.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:09960d1ad8110d1e35007c185eb232f1453e87cf911908aa0c665204ffd22203 +size 657 diff --git a/ui/action-fill.png b/ui/action-fill.png new file mode 100644 index 0000000..3b12a8e --- /dev/null +++ b/ui/action-fill.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d7642d1cfe7123eeaaeca2e52893c8c7d10fbda7939e1fa184622f7b0924735d +size 1158 diff --git a/ui/action-line.png b/ui/action-line.png new file mode 100644 index 0000000..1eb2fd3 --- /dev/null +++ b/ui/action-line.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e173a8f89e8480c4289f8bf9bec993b5bdb89defb609d175be70ec9a9b13dc31 +size 665 diff --git a/ui/action-plot.png b/ui/action-plot.png new file mode 100644 index 0000000..dcfbc34 --- /dev/null +++ b/ui/action-plot.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c3a1c8be0befef2fd4868b072adc1b8ff08fd3d9c5a7cf5abd5ebe785f5a9a98 +size 620 diff --git a/ui/action-rectangle.png b/ui/action-rectangle.png new file mode 100644 index 0000000..1fa040e --- /dev/null +++ b/ui/action-rectangle.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:468b01edd88979cc191f09c1ad9861b77fa0b0d26f99e4d0a5221d2d33b78702 +size 620 diff --git a/ui/joeydev.gresource.xml b/ui/joeydev.gresource.xml index 437d25a..5c84bb5 100644 --- a/ui/joeydev.gresource.xml +++ b/ui/joeydev.gresource.xml @@ -5,4 +5,13 @@ Vector.glade Logo.png + + action-box.png + action-circle.png + action-ellipse.png + action-fill.png + action-line.png + action-plot.png + action-rectangle.png +