diff options
author | Ruben Undheim <ruben.undheim@gmail.com> | 2018-10-20 17:54:32 +0200 |
---|---|---|
committer | Ruben Undheim <ruben.undheim@gmail.com> | 2018-10-20 17:54:32 +0200 |
commit | ca2442640f4394296d9d6b0c42d41d399dbf9667 (patch) | |
tree | 879c0a6065d6982d5a82b35dc3ff67299e2ea7d9 /undo.c | |
parent | 04d5d0ea0f65a434e568fe031f6396caec9b3a8d (diff) |
New upstream version 3.9.73+dfsg.1
Diffstat (limited to 'undo.c')
-rw-r--r-- | undo.c | 96 |
1 files changed, 67 insertions, 29 deletions
@@ -86,6 +86,11 @@ typedef struct { float scale; /* old scale value */ } scaleinfo; +typedef struct { + XPoint rotpos; /* original position */ + float rotation; /* old rotation value */ +} rotateinfo; + u_char undo_collect = (u_char)0; /*----------------------------------------------------------------------*/ @@ -418,7 +423,8 @@ void undelete_one_element(objinstptr thisinst, genericptr thiselem) void register_for_undo(u_int type, u_char mode, objinstptr thisinst, ...) { va_list args; - int drawmode, nval, oval, *idata, snum, deltax, deltay, dir, i; + int drawmode, nval, oval, *idata, snum, deltax, deltay, i; + double dir; short *slist; objectptr delobj; objinstptr newinst; @@ -541,7 +547,7 @@ void register_for_undo(u_int type, u_char mode, objinstptr thisinst, ...) erec->save.string = stringcopyall(((labelptr)egen)->string, areawin->topinstance); - newrecord->idata = ((labelptr)egen)->justify; + newrecord->idata = ((labelptr)egen)->anchor; break; case POLYGON: newrecord->idata = ((polyptr)egen)->number; @@ -589,7 +595,7 @@ void register_for_undo(u_int type, u_char mode, objinstptr thisinst, ...) break; case XCF_ChangeStyle: - case XCF_Justify: + case XCF_Anchor: case XCF_Color: /* 2 args: */ /* egen = element that was changed (with new value) */ @@ -627,13 +633,13 @@ void register_for_undo(u_int type, u_char mode, objinstptr thisinst, ...) case XCF_Rotate: /* 2 args: */ /* fpoint = point of flip (XPoint *) */ - /* dir = direction and amound of rotation (int) */ + /* dir = direction and amount of rotation (float) */ fpoint = va_arg(args, XPoint *); - dir = va_arg(args, int); - newrecord->undodata = (char *)malloc(sizeof(XPoint)); - ((XPoint *)newrecord->undodata)->x = fpoint->x; - ((XPoint *)newrecord->undodata)->y = fpoint->y; - newrecord->idata = dir; + dir = va_arg(args, double); + newrecord->undodata = (char *)malloc(sizeof(rotateinfo)); + ((rotateinfo *)newrecord->undodata)->rotpos.x = fpoint->x; + ((rotateinfo *)newrecord->undodata)->rotpos.y = fpoint->y; + ((rotateinfo *)newrecord->undodata)->rotation = (float)dir; break; case XCF_Move: @@ -773,11 +779,12 @@ short undo_one_action() newpage(thisrecord->idata); break; - case XCF_Justify: + case XCF_Anchor: thislabel = (labelptr)(thisrecord->undodata); snum = thisrecord->idata; - thisrecord->idata = thislabel->justify; - thislabel->justify = snum; + thisrecord->idata = thislabel->anchor; + thislabel->anchor = snum; + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); break; @@ -788,8 +795,10 @@ short undo_one_action() need_redraw = (areawin->selects > 0) ? True : False; select_previous(thisrecord); - if (need_redraw) + if (need_redraw) { + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); + } else draw_all_selected(); break; @@ -805,6 +814,7 @@ short undo_one_action() } else { delete_one_element(thisrecord->thisinst, egen); + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); } break; @@ -814,16 +824,16 @@ short undo_one_action() switch (erec->element->type) { case LABEL: { stringpart *tmpstr; - int tmpjust; + int tmpanchor; labelptr elab = (labelptr)(erec->element); undrawtext(elab); tmpstr = elab->string; - tmpjust = (int)elab->justify; + tmpanchor = (int)elab->anchor; elab->string = stringcopyback(erec->save.string, thisrecord->thisinst); - elab->justify = (short)thisrecord->idata; + elab->anchor = (short)thisrecord->idata; erec->save.string = tmpstr; - thisrecord->idata = tmpjust; + thisrecord->idata = tmpanchor; resolveparams(thisrecord->thisinst); redrawtext(elab); } break; @@ -842,6 +852,7 @@ short undo_one_action() earc->position = erec->save.arcspecs->position; *(erec->save.arcspecs) = tmpinfo; calcarc(earc); + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); } break; case OBJINST: { @@ -851,6 +862,7 @@ short undo_one_action() tmppt = einst->position; einst->position = erec->save.instpos; erec->save.instpos = tmppt; + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); } break; case POLYGON: { @@ -863,6 +875,7 @@ short undo_one_action() epoly->number = thisrecord->idata; erec->save.points = tmppts; thisrecord->idata = tmpnum; + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); } break; case SPLINE: { @@ -874,6 +887,7 @@ short undo_one_action() free(erec->save.points); erec->save.points = tmppts; calcspline(espline); + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); } break; case PATH: { @@ -905,6 +919,7 @@ short undo_one_action() break; } } + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); } } @@ -930,6 +945,7 @@ short undo_one_action() /* Revert selection to previously selected */ select_previous(thisrecord); + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); draw_all_selected(); break; @@ -960,6 +976,7 @@ short undo_one_action() thisspline->style = snum; break; } + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); break; @@ -989,6 +1006,7 @@ short undo_one_action() thisspline->color = snum; break; } + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); break; @@ -1026,7 +1044,9 @@ short undo_one_action() thisgraphic = (graphicptr)egen; escale->scale = thisgraphic->scale; thisgraphic->scale = fnum; +#ifndef HAVE_CAIRO thisgraphic->valid = FALSE; +#endif /* HAVE_CAIRO */ break; case LABEL: thislabel = (labelptr)egen; @@ -1034,6 +1054,7 @@ short undo_one_action() thislabel->scale = fnum; break; } + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); break; @@ -1048,8 +1069,8 @@ short undo_one_action() break; case XCF_Rotate: - position = *((XPoint *)thisrecord->undodata); - elementrotate(-thisrecord->idata, &position); + position = ((rotateinfo *)thisrecord->undodata)->rotpos; + elementrotate(-((rotateinfo *)thisrecord->undodata)->rotation, &position); break; case XCF_Move: @@ -1057,12 +1078,14 @@ short undo_one_action() select_connected_pins(); placeselects(-(delta->x), -(delta->y), NULL); reset_cycles(); + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); draw_all_selected(); break; case XCF_Reorder: reorder_selection(thisrecord); + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); break; @@ -1182,6 +1205,7 @@ short redo_one_action() thisrecord->undodata = (char *)thisobj; thisrecord->idata = (int)DRAW; unselect_all(); + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); break; @@ -1195,11 +1219,12 @@ short redo_one_action() newpage(*((int *)thisrecord->undodata)); break; - case XCF_Justify: + case XCF_Anchor: thislabel = (labelptr)(thisrecord->undodata); snum = thisrecord->idata; - thisrecord->idata = thislabel->justify; - thislabel->justify = snum; + thisrecord->idata = thislabel->anchor; + thislabel->anchor = snum; + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); break; @@ -1249,6 +1274,7 @@ short redo_one_action() case XCF_Spline: case XCF_Dot: case XCF_Graphic: case XCF_Join: egen = (genericptr)thisrecord->undodata; undelete_one_element(thisrecord->thisinst, egen); + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); break; @@ -1257,16 +1283,16 @@ short redo_one_action() switch (erec->element->type) { case LABEL: { stringpart *tmpstr; - int tmpjust; + int tmpanchor; labelptr elab = (labelptr)(erec->element); undrawtext(elab); tmpstr = elab->string; - tmpjust = (int)elab->justify; + tmpanchor = (int)elab->anchor; elab->string = stringcopyback(erec->save.string, thisrecord->thisinst); - elab->justify = (short)thisrecord->idata; + elab->anchor = (short)thisrecord->idata; erec->save.string = tmpstr; - thisrecord->idata = tmpjust; + thisrecord->idata = tmpanchor; resolveparams(thisrecord->thisinst); redrawtext(elab); } break; @@ -1277,6 +1303,7 @@ short redo_one_action() tmppt = einst->position; einst->position = erec->save.instpos; erec->save.instpos = tmppt; + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); } break; case ARC: { @@ -1294,6 +1321,7 @@ short redo_one_action() earc->position = erec->save.arcspecs->position; *(erec->save.arcspecs) = tmpinfo; calcarc(earc); + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); } break; case POLYGON: { @@ -1306,6 +1334,7 @@ short redo_one_action() epoly->number = thisrecord->idata; erec->save.points = tmppts; thisrecord->idata = tmpnum; + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); } break; case SPLINE: { @@ -1317,6 +1346,7 @@ short redo_one_action() free(erec->save.points); erec->save.points = tmppts; calcspline(espline); + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); } break; case PATH: { @@ -1348,6 +1378,7 @@ short redo_one_action() break; } } + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); } } @@ -1389,6 +1420,7 @@ short redo_one_action() thisspline->style = snum; break; } + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); break; @@ -1418,6 +1450,7 @@ short redo_one_action() thisspline->color = snum; break; } + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); break; @@ -1455,7 +1488,9 @@ short redo_one_action() thisgraphic = (graphicptr)egen; escale->scale = thisgraphic->scale; thisgraphic->scale = fnum; +#ifndef HAVE_CAIRO thisgraphic->valid = FALSE; +#endif /* HAVE_CAIRO */ break; case LABEL: thislabel = (labelptr)egen; @@ -1463,12 +1498,13 @@ short redo_one_action() thislabel->scale = fnum; break; } + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); break; case XCF_Rotate: - position = *((XPoint *)thisrecord->undodata); - elementrotate(thisrecord->idata, &position); + position = ((rotateinfo *)thisrecord->undodata)->rotpos; + elementrotate(((rotateinfo *)thisrecord->undodata)->rotation, &position); break; case XCF_Move: @@ -1476,11 +1512,13 @@ short redo_one_action() select_connected_pins(); placeselects(delta->x, delta->y, NULL); reset_cycles(); + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); break; case XCF_Reorder: reorder_selection(thisrecord); + areawin->redraw_needed = True; drawarea(areawin->area, NULL, NULL); break; @@ -1628,7 +1666,7 @@ void free_undo_data(Undoptr thisrecord, u_char mode) case XCF_Push: case XCF_ChangeStyle: - case XCF_Justify: + case XCF_Anchor: case XCF_Color: /* Do nothing --- undodata points to a valid element */ break; |