void flx_seek_frame(SHORT frame) /* scrub the cur-frame, and do a tseek */ { if (flix.xf == NULL) return; flx_clear_olays(); frame = wrap_frame(frame); if(frame != vs.frame_ix) { if(frame != (scrub_cur_frame()-1)) { if (frame == vs.frame_ix+1) { /* optimization for just the next frame */ pj_cmap_copy(vb.pencel->cmap,undof->cmap); fli_tseek(vb.pencel,vs.frame_ix,frame); if(!cmaps_same(vb.pencel->cmap,undof->cmap)) see_cmap(); zoom_it(); save_undo(); } else { save_undo(); fli_tseek(undof,vs.frame_ix,frame); zoom_unundo(); } } else zoom_unundo(); vs.frame_ix = frame; } flx_draw_olays(); }
mlast_frame() { register WORD **myframe; register WORD *frame; if (screen_ct >= MAX_SCREENS) { too_many_frames(); return; } if (mem_free < 32000 + 8000) { outta_memory(); return; } if ((frame = alloc(32000)) == NULL) { outta_memory(); return; } save_undo(); myframe = screens+screen_ix; copy_pointers(myframe, myframe+1, screen_ct - screen_ix); *myframe = frame; copy_screen(cscreen, frame); screen_ct++; show_status(); }
static void render_trails(void) { static char *keys[] = { "ask", "kp", "vu", "esc", NULL }; short steps = 16; if(!soft_qreq_number(&steps,2,100,"twe_trsteps")) goto done; if (steps < 2) steps = 2; tween_undraw(); save_undo(); softerr(tween_trail_frame(&twcb->cur, steps), NULL); for(;;) { switch(soft_multi_box(keys, "twe_trail")) { case 2: wait_click(); break; default: zoom_unundo(); case 1: goto done; } } done: tween_redraw(); return; }
static Errcode make_frames(int frames) /* change the number of frames in this fli. Will chop off ones at end if less, add empty frames (duplicates of last one) if at beginning */ { Errcode err; if (frames == flix.hdr.frame_count) /* whew! That was easy */ return(Success); flx_clear_olays(); if (frames > flix.hdr.frame_count) { err = insert_frames(frames-flix.hdr.frame_count, flix.hdr.frame_count-1); } else { err = delete_middle_frames(frames,flix.hdr.frame_count - frames); if (vs.frame_ix >= flix.hdr.frame_count) vs.frame_ix = flix.hdr.frame_count-1; if (frames >= vs.bframe_ix) vs.bframe_ix = 0; fli_abs_tseek(vb.pencel, vs.frame_ix); save_undo(); } dirties(); flx_draw_olays(); return(err); }
/* * add a character */ int CHtmlInputBuf::add_char(textchar_t c) { int changed; /* if there's a selection range, delete it */ changed = del_selection(); /* if there's room, insert the character */ if (len_ < bufsiz_) { /* if we didn't already make a change, save undo */ if (!changed) save_undo(); /* move characters to right of cursor to make room if necessary */ if (caret_ != len_) memmove(buf_ + caret_ + 1, buf_ + caret_, len_ - caret_); /* add the new character */ buf_[caret_] = c; ++len_; /* move the insertion point */ sel_start_ = sel_end_ = ++caret_; show_caret(); /* we made a change */ changed = TRUE; } /* return change indication */ return changed; }
void next_frame(void *data) /* Jump to next frame of temp file, wrapping back to 1st frame if go past end... */ { int oix; int undoix; (void)data; if (flix.xf == NULL) return; flx_clear_olays(); oix = vs.frame_ix; undoix = scrub_cur_frame()-1; ++vs.frame_ix; check_loop(); if(undoix != vs.frame_ix) { if (unfli(vb.pencel,vs.frame_ix,1) < 0) vs.frame_ix = oix; zoom_it(); save_undo(); } else { zoom_unundo(); /* undo has next frame left in it by sub_cur_frame() */ } flx_draw_olays(); }
static void make_grid(void) { save_undo(); vs.use_grid = 0; if((gcut_out_rect(&vl.grid)) >= 0) { if(!vl.grid.width) vl.grid.width = 1; if (!vl.grid.height) vl.grid.height = 1; vl.grid.x = vl.grid.x % vl.grid.width; vl.grid.y = vl.grid.y % vl.grid.height; /* move changed values into vs buffer */ vs.gridx = scale_vscoor(vl.grid.x,vb.pencel->width); vs.gridw = scale_vscoor(vl.grid.width,vb.pencel->width); vs.gridy = scale_vscoor(vl.grid.y,vb.pencel->height); vs.gridh = scale_vscoor(vl.grid.height,vb.pencel->height); vs.use_grid = 1; } load_wndo_iostate(NULL); /* screen settings */ see_grid(); }
static void see_grid(void) { save_undo(); draw_grid(); zoom_it(); wait_wndo_input(ANY_CLICK); zoom_unundo(); }
last_frame() { if (screen_ix > 0) { save_undo(); --screen_ix; see_screen_ix(); } }
next_frame() { if (screen_ix < screen_ct - 1) { save_undo(); screen_ix++; see_screen_ix(); } }
Errcode scrub_frame_save_undo() /* a scrub cur frame that insures undo is current index and saves it if not */ { Errcode ret; if((ret = scrub_cur_frame()-1) != vs.frame_ix) save_undo(); return(ret); }
static void qsee_grid(void) { save_undo(); paste_grid(); zoom_it(); wait_click(); unundo(); zoom_it(); }
void do_resetdialog() { changeFullScreen(0); save_undo(); if (okcancel("Are you sure you want to reset?\nAny unsaved changes will be lost.")) { resetfilename(); do_reset(); } }
Errcode delete_some(int x) /* delete X frames from current position forward */ { Errcode err; if(vs.frame_ix == 0 && x == flix.hdr.frame_count) { kill_seq(); zoom_it(); return(Success); } flx_clear_olays(); if ((err = scrub_cur_frame()) < Success) return(err); if (vs.frame_ix == 0) { delete_first_frames(x); if (vs.bframe_ix > x) vs.bframe_ix -= x; else vs.bframe_ix = 0; /* invalidate back screen cashe */ #ifdef LATER fli_abs_tseek(vb.pencel, 0); #endif /* LATER */ save_undo(); } else { err = delete_middle_frames(vs.frame_ix, x); if(vs.bframe_ix >= vs.frame_ix) vs.bframe_ix = 0; if(vs.frame_ix >= flix.hdr.frame_count) /* we were on the last frame */ { vs.frame_ix = flix.hdr.frame_count-1; zoom_unundo(); } else save_undo(); } dirties(); flx_draw_olays(); return(err); }
static Errcode tween_size_polys(Mpl_data *mpl, int *pp, int *pq) /* Let user resize a polygon list. */ { Errcode err; Rcel_save oundo; if ((err = report_temp_save_rcel(&oundo, undof)) < Success) return(err); save_undo(); err = rub_size_polys(mpl, pp, pq); report_temp_restore_rcel(&oundo, undof); redraw_both_ends(); return(err); }
static Errcode get_sep_source_colors(Sep_cb *sep) { int color; Errcode err; SHORT ogrid; if ((sep->p.ctable = pj_malloc(COLORS)) == NULL) return(Err_no_memory); save_undo(); if (vs.sep_box) { if((err = get_rub_rect(&sep->p.rect)) < 0) goto error; if((err = rub_rect_in_place(&sep->p.rect)) < 0) goto error; } else { sep->p.rect.x = sep->p.rect.y = 0; sep->p.rect.width = vb.pencel->width; sep->p.rect.height = vb.pencel->height; } if (vs.sep_rgb == 2) /* range */ { sep->p.ccount = cluster_count(); pj_copy_bytes(cluster_bundle(), sep->p.ctable, sep->p.ccount); return(Success); } ogrid = vs.use_grid; vs.use_grid = FALSE; for (;;) /* gather up a table while pen down of colors under cursor */ { color = pj_get_dot(vb.pencel,icb.mx,icb.my); if (!in_cnums(color, sep->p.ctable, sep->p.ccount) ) sep->p.ctable[sep->p.ccount++] = color; wait_any_input(); if (!ISDOWN(MBPEN)) break; } vs.use_grid = ogrid; err = Success; error: return(err); }
static void handle_async_call(chipinfostruct &chip) { switch (chip.mAsyncCall) { case ATANUA_ASYNC_CALL_OKCANCEL: chip.mAsyncCallReturn = (void*)okcancel((const char*)chip.mAsyncCallParam); break; case ATANUA_ASYNC_CALL_OPENFILE: chip.mAsyncCallReturn = (void*)openfiledialog((const char*)chip.mAsyncCallParam); break; case ATANUA_ASYNC_CALL_SAVEFILE: chip.mAsyncCallReturn = (void*)savefiledialog((const char*)chip.mAsyncCallParam); break; case ATANUA_ASYNC_CALL_STORE_UNDO: save_undo(); break; } }
static void set_rad_center(void) { hide_mp(); save_undo(); if (cut_cursor()) { if (rub_circle()) { vs.rgr = center_rad(); if (vs.rgr <= 0) vs.rgr = 1; vs.rgx = x_0; vs.rgy = y_0; } } draw_mp(); }
static void tti_mtween(void) /* move both ends of tween */ { Mpl_2p m2; int dx,dy; Rcel_save oundo; if (!init_2p_mpl(&m2)) return; if ((report_temp_save_rcel(&oundo, undof)) < Success) return; save_undo(); move_polys_loop(&m2.mpl, &dx, &dy); report_temp_restore_rcel(&oundo, undof); redraw_both_ends(); }
static Errcode load_fli(char *title) /* Convert a FLI file into an indexed frame (FLX) file - into our main temp file in fact. Make first frame visible. On failure generate an empty FLX file */ { Errcode err; vs.frame_ix = 0; if((err = make_tempflx(title,1)) < 0) goto OUT; if((err = unfli(vb.pencel,0,1)) < 0) goto OUT; save_undo(); OUT: if(err < 0) kill_seq(); zoom_it(); return(err); }
static void tw_mag(int mag_mode) /* Magnet tween tool. Moves points with effect falling off as of square of distance between point and initial pen-down */ { Rcel_save oundo; Poly *poly; LLpoint *pl; long distance; if ((report_temp_save_rcel(&oundo, undof)) < Success) return; save_undo(); if (closest_in_tween(&poly, &pl, &distance, icb.mx, icb.my,vs.tween_end)) { mag_loop(poly, get_pcolor(poly), distance, mag_mode); } report_temp_restore_rcel(&oundo, undof); redraw_both_ends(); }
static int rub_spiral(void) { int itheta; int t0,t1,dt; int cenx, ceny; int lx,ly; char buf[40]; save_undo(); /* 1st get initial angle... */ if (!rub_line()) return(0); t0 = -arctan(x_1-x_0, y_1-y_0); itheta = t0+TWOPI/4; spi_ttheta = 0; for (;;) { spi_rad = calc_distance(x_0,y_0,grid_x,grid_y); t1 = -arctan(grid_x-x_0, grid_y-y_0); dt = t1-t0; if (dt > TWOPI/2) dt = dt-TWOPI; if (dt < -TWOPI/2) dt = dt+TWOPI; spi_ttheta += dt; t0 = t1; sprintf(buf, spiral_100 /* " %6ld degrees" */, spi_ttheta*360/TWOPI); top_text(buf); if (!make_spiral_poly(x_0,y_0,spi_rad,itheta,spi_ttheta)) return(0); dot_poly(&working_poly, sdot); wait_input(); dot_poly(&working_poly,copydot); if (PJSTDN || RJSTDN) break; } restore_top_bar(); return(PJSTDN); }
static Errcode go_vpaint() { Errcode err; extern Errcode go_quick_menu(); init_wrefresh(vb.screen); /* clear window refresh stack start over */ fake_push(); pop_most(); /* restore screen from pic file if there if not seek in fli */ if(pop_screen_id(flix.hdr.id.update_time) != Success) { fli_abs_tseek(undof, vs.frame_ix); zoom_unundo(); } else save_undo(); init_zoom(); find_colors(); fliborder_on(); vl.undoit = swap_undo; vl.redoit = do_auto_redo; menu_to_quickcent(&quick_menu); if(cl_poco_name != NULL) { err = do_cl_poco(cl_poco_name); if (err < Success && err != Err_abort) { cleanup(TRUE); if (err == Err_in_err_file) po_file_to_stdout(poco_err_name); exit(err); } cl_poco_name = NULL; /* don't keep re-executing */ } return(go_quick_menu()); }
/* * backspace */ int CHtmlInputBuf::backspace() { /* if not already showing the caret, make it visible again */ show_caret(); /* see if there's a selection range */ if (sel_start_ != sel_end_) { /* there's a range - delete it */ return del_selection(); } else if (caret_ > 0) { /* save undo */ save_undo(); /* * no range - delete character to left of cursor. Move the * characters to the right of the cursor over the character to * the left of the cursor, if necessary. */ size_t prv = prevchar(caret_); if (len_ > caret_) memmove(buf_ + prv, buf_ + caret_, len_ - caret_); /* it's now one character shorter */ len_ -= (caret_ - prv); /* back up the caret one position */ sel_start_ = sel_end_ = caret_ = prv; /* we made a change */ return TRUE; } else { /* we didn't change anything */ return FALSE; } }
/* * Add a UTF-8 character */ int CHtmlInputBuf::add_char_utf8(unsigned int c) { int changed; /* we only accept BMP characters */ if (c > 0xffff) return FALSE; /* figure the size (in bytes) of the character's UTF-8 representation */ size_t siz = (c <= 0x7f ? 1 : c <= 0x7ff ? 2 : 3); /* if there's a selection, delete it first */ changed = del_selection(); /* if there's room, add the new character */ if (len_ + siz <= bufsiz_) { /* save undo if we haven't made a change already */ if (!changed) save_undo(); /* move characters to right of cursor to make room if necessary */ if (caret_ != len_) memmove(buf_ + caret_ + siz, buf_ + caret_, len_ - caret_); /* add the new character */ if (c < 0x7f) { /* 0..7f -> 1-byte UTF-8 */ buf_[caret_] = (textchar_t)(c & 0x7f); } else if (c < 0x7ff) { /* 80..7ff -> 2-byte UTF-8 */ buf_[caret_] = (textchar_t)(0xC0 | ((c >> 6) & 0x1F)); buf_[caret_+1] = (textchar_t)(0x80 | (c & 0x3F)); } else {
/* * delete the selected range */ int CHtmlInputBuf::del_selection() { /* if nothing's selected, there's nothing to do */ if (sel_start_ == sel_end_) return FALSE; /* save undo */ save_undo(); /* move the tail over the selection, if necessary */ if (len_ != sel_end_) memmove(buf_ + sel_start_, buf_ + sel_end_, len_ - sel_end_); /* reduce the length by the selection size */ len_ -= sel_end_ - sel_start_; /* move the selection end to the start */ caret_ = sel_end_ = sel_start_; show_caret(); /* we made a change */ return TRUE; }
/* * delete right */ int CHtmlInputBuf::del_right() { /* if not already showing the caret, make it visible again */ show_caret(); /* see if there's a selection range */ if (sel_start_ != sel_end_) { /* there's a range - delete it */ return del_selection(); } else if (caret_ < len_) { /* save undo */ save_undo(); /* * no range - delete character to right of cursor. Move the * characters after the character to the right of the cursor * over the character to the right of the cursor, if necessary. */ size_t nxt = nextchar(caret_); if (len_ > nxt) memmove(buf_ + caret_, buf_ + nxt, len_ - nxt); /* it's now one character shorter */ len_ -= (nxt - caret_); /* we made a change */ return TRUE; } else { /* we didn't change anything */ return FALSE; } }
static void qmake_grid(void) { save_undo(); vs.use_grid = 0; if (gcut_out()) { vs.gridx = intmin(grid_x,firstx); vs.gridy = intmin(grid_y,firsty); if ((vs.gridw = intabs(grid_x - firstx)) <= 0) vs.gridw = 1; if ((vs.gridh = intabs(grid_y - firsty)) <= 0) vs.gridh = 1; while (vs.gridx >= 0) vs.gridx -= vs.gridw; vs.gridx += vs.gridw; while (vs.gridy >= 0) vs.gridy -= vs.gridh; vs.gridy += vs.gridh; vs.use_grid = 1; } qsee_grid(); grid_asterisks(); }
static Errcode write_transition_frames(Initpframe init_pframe, Getmask get_mask_frame, Closepframe cleanup_pframe) /* note the scaling is done so that it goes from 0 to one less than frame after * wipe the frame before is all cel a and the frame after is all cel b and all * inbetween are part a and part a from 1/(count+1) count/(count+1) proportion * of mask generator 0 being all a and count being all b */ { Errcode err; SHORT frame_a, frame_b; Cmap *cmapa, *cmapb, *dcmap; int mask_scale0, mask_scale1, cmap_scale; Pframedat pfd; LONG cbufsize, size; Celcfit blend_cfit; clear_struct(&pfd); if(ccb.preview_mode) { pfd.dest = undof; pfd.history = vb.pencel; save_undo(); } else { pfd.dest = vb.pencel; pfd.history = undof; } init_celcfit(&blend_cfit); err = reopen_fcelio(ccb.start_cel, XREADONLY); if (err < Success) goto error; err = reopen_fcelio(ccb.end_cel, XREADONLY); if (err < Success) goto error; cbufsize = pj_fli_cel_cbuf_size(pfd.dest); if( fcel_needs_seekbuf(ccb.fcelb) && (size = fcel_cbuf_size(ccb.fcelb)) > cbufsize) { cbufsize = size; } if((vs.co_type == COMP_MASK) && fcel_needs_seekbuf(ccb.mask_cel) && ((size = fcel_cbuf_size(ccb.mask_cel)) > cbufsize)) { cbufsize = size; } if(NULL == (pfd.cbuf = pj_malloc(cbufsize))) goto nomem_error; /* the mask mover uses cel a and cel b not start_cel and end_cel * uses invert flag */ pfd.reverse_wipe = vs.co_reverse; pfd.acfit = ccb.fcela->cfit->ctable; pfd.bcfit = ccb.fcelb->cfit->ctable; pfd.frame_count = ccb.transition_frames; /** calculate and preset frame counts etc */ frame_a = ccb.cela_transtart; frame_b = ccb.celb_start; cmapa = ccb.start_cel->rc->cmap; cmapb = ccb.end_cel->rc->cmap; dcmap = pfd.dest->cmap; if(init_pframe && (err = (*init_pframe)(&pfd)) < Success) goto error; for(pfd.frame = 0;pfd.frame < pfd.frame_count;++pfd.frame) { if(!ccb.preview_mode) save_undo(); if((err = poll_abort()) < Success) goto error; if((err = gb_seek_fcel_frame(ccb.start_cel, frame_a, pfd.cbuf, FALSE)) < Success) { goto error; } if((err = gb_seek_fcel_frame(ccb.end_cel, frame_b, pfd.cbuf, FALSE)) < Success) { goto error; } if(pfd.frame_count > 1) { mask_scale0 = rscale_by(SCALE_ONE, pfd.frame, pfd.frame_count-1); mask_scale1 = cmap_scale = rscale_by(SCALE_ONE, pfd.frame + 1,pfd.frame_count+1); if(pfd.reverse_wipe) { mask_scale0 = SCALE_ONE - mask_scale0; mask_scale1 = SCALE_ONE - mask_scale1; } } else { mask_scale0 = mask_scale1 = cmap_scale = SCALE_ONE/2; } if((err = (*get_mask_frame)(mask_scale0,mask_scale1,&pfd)) < Success) goto error; if((err = make_trans_colors(cmap_scale,cmapa,cmapb,dcmap)) < Success) goto error; if(!ccb.preview_mode && !cmaps_same(dcmap,undof->cmap)) see_cmap(); /* note cfit is done in absolute order so docfit is set to absolute * order (not start and end) because the mask_move_cels() does * move in this order and doesn't care about start and end */ pfd.docfit = 0; if(make_simple_cfit(ccb.fcela->rc->cmap,dcmap, ccb.fcela->cfit,ccb.clearc)) { pfd.docfit = 1; } if(make_simple_cfit(ccb.fcelb->rc->cmap,dcmap, ccb.fcelb->cfit,ccb.clearc)) { pfd.docfit |= 2; } if((err = mask_move_cels(&pfd)) < Success) goto error; if(!ccb.preview_mode) { if(flix.hdr.frame_count == 0) err = write_first_flxframe(NULL,&flix,pfd.cbuf,pfd.dest); else { err = write_next_flxframe(NULL,&flix,pfd.cbuf, pfd.history,pfd.dest); } if(err < Success) goto error; dirties(); } else { ++ccb.preview_frame; /* for poll abort verify in preview */ zoom_unundo(); } if(!vs.co_still) { ++frame_a; ++frame_b; } } goto done; nomem_error: err = Err_no_memory; error: done: if(cleanup_pframe) (*cleanup_pframe)(&pfd); pj_gentle_free(pfd.cbuf); close_fcelio(ccb.fcelb); close_fcelio(ccb.fcela); return(err); }
void do_loaddialog(int merge, const char *aFilename) { changeFullScreen(0); clear_boxcache(); FILE *fh = 0; char *boxfn = NULL; char *origactivefilename = NULL; if (gFilename) origactivefilename = mystrdup(gFilename); if (aFilename) { fh = fopen(aFilename, "rb"); storefilename(aFilename); } else { if (merge == 2) { // pop up the dialog fh = openfiledialog(NULL); if (fh) { // find the last part of the file without path char * s1 = strrchr(gFilename,'\\'); if (s1 == NULL) { s1 = strrchr(gFilename,'/'); } // if above fails, just use the whole name if (s1 == NULL) { s1 = gFilename; } else { // skip the last slash/backslash s1++; } // this shall be the box filename boxfn = mystrdup(s1); } } else { fh = openfiledialog(NULL); } } if (fh) { save_undo(); if (!merge) do_reset(); File * f = new File(fh); int id = f->readint(); f->seek(0); if (id == 0x00617441) // 'Ata\0' { // It's binary do_loadoldbinary(f); } else { // It's XML if (merge == 2) { // boxing BoxStitchingInformation * bsi = do_preparse_box(boxfn); if (bsi == NULL) { // box loading failed delete[] boxfn; delete f; storefilename(origactivefilename); delete[] origactivefilename; return; } Box * b = new Box(boxfn, bsi); // do actual loading do_flush_boxloadqueue(); gNewChip = b; gNewChipName = boxfn; do_build_nets(); // causes cancel; otherwise the drag mode gets cancelled. gDragMode = DRAGMODE_NEWCHIP; storefilename(origactivefilename); delete[] origactivefilename; } else { int oldmaxchip = gChip.size(); int oldmaxwire = gWire.size(); do_loadxml(fh, 0); if (merge) { int i; for (i = oldmaxchip; i < (signed)gChip.size(); i++) { if (gChip[i]->mBox == 0) { gMultiSelectChip.push_back(gChip[i]); gChip[i]->mMultiSelectState = 1; } } for (i = oldmaxwire; i < (signed)gWire.size(); i++) { if (gWire[i]->mBox == 0) { gMultiSelectWire.push_back(gWire[i]); gWire[i]->mMultiSelectState = 1; } } storefilename(origactivefilename); delete[] origactivefilename; } } } delete f; // closes handle } }