static int RH_Remove(GGadget *g, GEvent *e) { if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) { ReviewHintData *hd = GDrawGetUserData(GGadgetGetWindow(g)); StemInfo *prev; if ( hd->active==NULL ) return( true ); /* Eh? */ if ( hd->active==hd->cv->b.sc->hstem ) { hd->cv->b.sc->hstem = hd->active->next; prev = hd->cv->b.sc->hstem; } else if ( hd->active==hd->cv->b.sc->vstem ) { hd->cv->b.sc->vstem = hd->active->next; prev = hd->cv->b.sc->vstem; } else { prev = hd->ishstem ? hd->cv->b.sc->hstem : hd->cv->b.sc->vstem; for ( ; prev->next!=hd->active && prev->next!=NULL; prev = prev->next ); prev->next = hd->active->next; } if ( hd->ishstem ) hd->cv->b.sc->hconflicts = StemListAnyConflicts(hd->cv->b.sc->hstem); else hd->cv->b.sc->vconflicts = StemListAnyConflicts(hd->cv->b.sc->vstem); hd->cv->b.sc->manualhints = true; hd->changed = true; StemInfoFree( hd->active ); hd->active = prev; SCOutOfDateBackground(hd->cv->b.sc); RH_SetupHint(hd); /*SCUpdateAll(hd->cv->b.sc);*/ /* Done in RH_SetupHint now */ } return( true ); }
void SCClearContents(SplineChar *sc,int layer) { int ly_first, ly_last; if ( sc==NULL ) return; if ( sc->parent!=NULL && sc->parent->multilayer ) { ly_first = ly_fore; ly_last = sc->layer_cnt-1; } else ly_first = ly_last = layer; for ( layer = ly_first; layer<=ly_last; ++layer ) SCClearLayer(sc,layer); --layer; if ( sc->parent!=NULL && (sc->parent->multilayer || (!sc->parent->layers[layer].background && SCWasEmpty(sc,layer)))) { sc->widthset = false; if ( sc->parent!=NULL && sc->width!=0 ) sc->width = sc->parent->ascent+sc->parent->descent; AnchorPointsFree(sc->anchor); sc->anchor = NULL; StemInfosFree(sc->hstem); sc->hstem = NULL; StemInfosFree(sc->vstem); sc->vstem = NULL; DStemInfosFree(sc->dstem); sc->dstem = NULL; MinimumDistancesFree(sc->md); sc->md = NULL; free(sc->ttf_instrs); sc->ttf_instrs = NULL; sc->ttf_instrs_len = 0; SCOutOfDateBackground(sc); } }
static void Do_OKRegen(ReviewHintData *hd) { SplineChar *sc = hd->cv->b.sc; StemInfo *curh = sc->hstem, *curv = sc->vstem; int do_regen = GGadgetIsChecked(GWidgetGetControl(hd->gw,CID_RegenHM)); /* We go backwards here, but not for long. The point is to go back to */ /* the original hint state so we can preserve it, now that we know we*/ /* are going to modify it */ sc->hstem = hd->oldh; sc->vstem = hd->oldv; SCPreserveHints(sc,CVLayer((CharViewBase *) hd->cv)); sc->hstem = curh; sc->vstem = curv; StemInfosFree(hd->oldh); StemInfosFree(hd->oldv); if ( hd->lastactive!=NULL ) hd->lastactive->active = false; if ( hd->changed ) { SCClearHintMasks(hd->cv->b.sc,CVLayer((CharViewBase *) (hd->cv)),true); if ( do_regen ) SCFigureHintMasks(hd->cv->b.sc,CVLayer((CharViewBase *) (hd->cv))); } /* Everything else got done as we went along... */ SCOutOfDateBackground(hd->cv->b.sc); SCUpdateAll(hd->cv->b.sc); SCHintsChanged(hd->cv->b.sc); hd->done = true; }
static void DoCancel(ReviewHintData *hd) { StemInfosFree(hd->cv->b.sc->hstem); StemInfosFree(hd->cv->b.sc->vstem); hd->cv->b.sc->hstem = hd->oldh; hd->cv->b.sc->vstem = hd->oldv; hd->cv->b.sc->hconflicts = StemListAnyConflicts(hd->cv->b.sc->hstem); hd->cv->b.sc->vconflicts = StemListAnyConflicts(hd->cv->b.sc->vstem); hd->cv->b.sc->manualhints = hd->oldmanual; if ( hd->undocreated ) SCDoUndo(hd->cv->b.sc,ly_fore); SCOutOfDateBackground(hd->cv->b.sc); SCUpdateAll(hd->cv->b.sc); hd->done = true; }
static void RH_SetupHint(ReviewHintData *hd) { char buffer[20]; unichar_t ubuf[20]; static unichar_t nullstr[] = {'\0'}; StemInfo *h; int pos,cnt; if ( hd->lastactive!=NULL ) hd->lastactive->active = false; pos = cnt = 0; for ( h=hd->ishstem ? hd->cv->b.sc->hstem : hd->cv->b.sc->vstem; h!=NULL; h=h->next ) { ++cnt; if ( h==hd->active ) pos=cnt; } sprintf( buffer,"%d/%d", pos, cnt ); if ( cnt==3 ) { StemInfo *h2, *h3; h = hd->ishstem ? hd->cv->b.sc->hstem : hd->cv->b.sc->vstem; h2 = h->next; h3 = h2->next; if ( h->width == h2->width && h2->width==h3->width && h2->start-h->start == h3->start-h2->start ) strcat( buffer, hd->ishstem ? " hstem3" : " vstem3" ); } uc_strcpy(ubuf,buffer); GGadgetSetTitle(GWidgetGetControl(hd->gw,CID_Count),ubuf); if ( hd->active==NULL ) { GGadgetSetTitle(GWidgetGetControl(hd->gw,CID_Base),nullstr); GGadgetSetTitle(GWidgetGetControl(hd->gw,CID_Width),nullstr); GGadgetSetVisible(GWidgetGetControl(hd->gw,CID_Overlap),false); } else { hd->active->active = true; sprintf( buffer,"%g", (double) (!hd->active->ghost ? hd->active->start : hd->active->start+hd->active->width) ); uc_strcpy(ubuf,buffer); GGadgetSetTitle(GWidgetGetControl(hd->gw,CID_Base),ubuf); GTextFieldShow(GWidgetGetControl(hd->gw,CID_Base),0); sprintf( buffer,"%g", (double) (!hd->active->ghost ? hd->active->width : -hd->active->width) ); uc_strcpy(ubuf,buffer); GGadgetSetTitle(GWidgetGetControl(hd->gw,CID_Width),ubuf); GTextFieldShow(GWidgetGetControl(hd->gw,CID_Width),0); GGadgetSetVisible(GWidgetGetControl(hd->gw,CID_Overlap),hd->active->hasconflicts); } if ( hd->lastactive!=hd->active ) { hd->lastactive = hd->active; SCOutOfDateBackground(hd->cv->b.sc); SCUpdateAll(hd->cv->b.sc); /* Changing the active Hint means we should redraw everything */ } RH_SetNextPrev(hd); }
static int RH_TextChanged(GGadget *g, GEvent *e) { int wasconflict; if ( e->type==et_controlevent && e->u.control.subtype == et_textchanged ) { ReviewHintData *hd = GDrawGetUserData(GGadgetGetWindow(g)); if ( hd->active!=NULL ) { int cid = GGadgetGetCid(g); int err=0; real start = GetCalmReal8(hd->gw,CID_Base,_("Base:"),&err); real width = GetCalmReal8(hd->gw,CID_Width,_("Size:"),&err); if ( err ) return( true ); if ( GGadgetIsChecked(GWidgetGetControl(GGadgetGetWindow(g),CID_MovePoints)) ) { if ( width<0 ) RH_MovePoints(hd,hd->active,start+width,-width); else RH_MovePoints(hd,hd->active,start,width); } if ( cid==CID_Base ) hd->active->start = start; else hd->active->width = width; if ( width<0 ) { hd->active->ghost = true; hd->active->width = -width; hd->active->start = start+width; } else hd->active->ghost = false; wasconflict = hd->active->hasconflicts; if ( hd->ishstem ) hd->cv->b.sc->hconflicts = StemListAnyConflicts(hd->cv->b.sc->hstem); else hd->cv->b.sc->vconflicts = StemListAnyConflicts(hd->cv->b.sc->vstem); hd->cv->b.sc->manualhints = true; hd->changed = true; if ( wasconflict!=hd->active->hasconflicts ) { GGadgetSetVisible(GWidgetGetControl(hd->gw,CID_Overlap),hd->active->hasconflicts); if ( hd->active->hasconflicts ) GHVBoxFitWindow(GWidgetGetControl(hd->gw,CID_TopBox)); } SCOutOfDateBackground(hd->cv->b.sc); SCUpdateAll(hd->cv->b.sc); } } return( true ); }
static int CH_OK(GGadget *g, GEvent *e) { if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) { CreateHintData *hd = GDrawGetUserData(GGadgetGetWindow(g)); real base, width; int err = 0; StemInfo *h; int layer = CVLayer((CharViewBase *) hd->cv); base = GetReal8(hd->gw,CID_Base,_("Base:"),&err); width = GetReal8(hd->gw,CID_Width,_("Size:"),&err); if ( err ) return(true); if ( hd->preservehints ) { SCPreserveHints(hd->cv->b.sc,layer); SCHintsChanged(hd->cv->b.sc); } h = chunkalloc(sizeof(StemInfo)); if ( width==-21 || width==-20 ) { base += width; width = -width; h->ghost = true; } h->start = base; h->width = width; if ( hd->ishstem ) { SCGuessHHintInstancesAndAdd(hd->cv->b.sc,layer,h,0x80000000,0x80000000); hd->cv->b.sc->hconflicts = StemListAnyConflicts(hd->cv->b.sc->hstem); } else { SCGuessVHintInstancesAndAdd(hd->cv->b.sc,layer,h,0x80000000,0x80000000); hd->cv->b.sc->vconflicts = StemListAnyConflicts(hd->cv->b.sc->vstem); } hd->cv->b.sc->manualhints = true; if ( h!=NULL && hd->cv->b.sc->parent->mm==NULL ) SCModifyHintMasksAdd(hd->cv->b.sc,layer,h); else SCClearHintMasks(hd->cv->b.sc,layer,true); SCOutOfDateBackground(hd->cv->b.sc); SCUpdateAll(hd->cv->b.sc); hd->done = true; } return( true ); }