Hidetaka Iwai
tyuyu****@debia*****
2005年 5月 4日 (水) 07:47:48 JST
岩井です。 KANOU Hiroki <kanou****@khdd*****> wrote: Message-ID: <20050****@lists*****> > ・全体構成 (snip) > 4/3 複数ストロークに対するストローク情報ダイアログの同時適用 > 複数の決定があれば、デフォルトは空欄に。 これも実装してみました。例によってへろへろパッチですが、添付します。 regards, -- Hidetaka Iwai tyuyu****@debia***** -------------- next part -------------- diff -urN fontforge-20050310/fontforge/charview.c fontforge-20050310.new/fontforge/charview.c --- fontforge-20050310/fontforge/charview.c 2005-05-04 07:33:23.000000000 +0900 +++ fontforge-20050310.new/fontforge/charview.c 2005-05-04 07:32:14.000000000 +0900 @@ -5289,7 +5289,7 @@ #define CID_Width 1000 #define CID_StrokeType 1001 -GTextInfo stroketypelist[num_enum_stroke+1] = { +GTextInfo stroketypelist[num_enum_stroke+2] = { { (unichar_t *) "ten", NULL, 0, 0, (void *)sk_ten, NULL, 0, 0, 0, 0, 0, 0, 1}, { (unichar_t *) "tate", NULL, 0, 0, (void *)sk_tate, NULL, 0, 0, 0, 0, 0, 0, 1}, { (unichar_t *) "yoko", NULL, 0, 0, (void *)sk_yoko, NULL, 0, 0, 0, 0, 0, 0, 1}, @@ -5312,6 +5312,7 @@ { (unichar_t *) "kamae2", NULL, 0, 0, (void *)sk_kamae2, NULL, 0, 0, 0, 0, 0, 0, 1}, { (unichar_t *) "nyou", NULL, 0, 0, (void *)sk_nyou, NULL, 0, 0, 0, 0, 0, 0, 1}, { (unichar_t *) "tare", NULL, 0, 0, (void *)sk_tare, NULL, 0, 0, 0, 0, 0, 0, 1}, + { (unichar_t *) "----", NULL, 0, 0, (void *)num_enum_stroke, NULL, 0, 0, 0, 0, 0, 0, 1}, { NULL } }; @@ -5326,9 +5327,36 @@ int err = false; if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) { + SplinePointList *spl; + int stroketype; + real width; + struct sgid *sgid = GDrawGetUserData(GGadgetGetWindow(g)); - sgid->spl->width = GetRealR(sgid->gw,CID_Width,_STR_Width, &err); - sgid->spl->stroketype = (int) (GGadgetGetListItemSelected(GWidgetGetControl(sgid->gw,CID_StrokeType))->userdata); + width = GetRealR(sgid->gw,CID_Width,_STR_Width, &err); + stroketype = (int) (GGadgetGetListItemSelected(GWidgetGetControl(sgid->gw,CID_StrokeType))->userdata); + + for (spl = sgid->spl; spl != NULL; spl = spl->next) { + SplinePointList *found = NULL; + Spline *spline; + if (spl->first->selected ) + found = spl; + + for (spline = spl->first->next; + spline != NULL ; + spline = spline->to->next ) { + if (spline->to == spl->first ) + /* return to first spline point */ + break; + if (spline->to->selected) + found = spl; + } + if(found != NULL) { + spl->width = width; + if (stroketype != num_enum_stroke) + spl->stroketype = stroketype; + } + } + sgid->cv->sc->parent->default_stroketype = sgid->spl->stroketype; sgid->done = true; } @@ -5356,7 +5384,7 @@ return( true ); } -void StrokeGetInfo(CharView *cv, SplinePointList *spl) { +void StrokeGetInfo(CharView *cv, SplinePointList *spl, int selected_num) { GWindow gw; GWindowAttrs wattrs; GGadgetCreateData gcd[9]; @@ -5403,10 +5431,13 @@ gcd[i].gd.cid = CID_StrokeType; gcd[i].gd.u.list = stroketypelist; gcd[i++].creator = GListButtonCreate; + for ( j=0; j<sizeof(stroketypelist)/sizeof(stroketypelist[0]); j++) { - stroketypelist[j].selected = (j == spl->stroketype); + stroketypelist[j].selected = ((selected_num == 1) && (j == spl->stroketype)); stroketypelist[j].disabled = false; } + if (selected_num > 1) + stroketypelist[num_enum_stroke].selected = true; label[i].text = (unichar_t *) _STR_WidthC; label[i].text_in_resource = true; @@ -5458,14 +5489,12 @@ } static void CVMenuStrokeInfo(GWindow gw,struct gmenuitem *mi,GEvent *e) { - CharView *cv = (CharView *) GDrawGetUserData(gw); - SplinePointList *spl; - RefChar *r; - ImageList *im; + CharView *cv = (CharView *) GDrawGetUserData(gw); + SplinePointList *spl; + int selected_num = 0; - if ( CVOneContourSel(cv,&spl,&r,&im) ) { - StrokeGetInfo(cv, spl); - } + if (CVPointsSel(cv, &spl, &selected_num)) + StrokeGetInfo(cv, spl, selected_num); } #endif diff -urN fontforge-20050310/fontforge/cvaddpoints.c fontforge-20050310.new/fontforge/cvaddpoints.c --- fontforge-20050310/fontforge/cvaddpoints.c 2005-05-04 07:33:23.000000000 +0900 +++ fontforge-20050310.new/fontforge/cvaddpoints.c 2005-05-04 07:10:26.000000000 +0900 @@ -153,6 +153,45 @@ return( false ); } +int CVPointsSel(CharView *cv, + SplinePointList **_spl, + int *selected_num) { + /* if there are selected points, return the first one and the number of selected items*/ + + SplinePointList *spl, *found=NULL; + Spline *spline; + + *selected_num = 0; + for (spl = cv->layerheads[cv->drawmode]->splines; spl != NULL; spl = spl->next) { + if (spl->first->selected ) { + if (found == NULL) { + *selected_num = 1; + found = spl; + } + else if (found != spl) + (*selected_num)++; + } + for (spline = spl->first->next; spline != NULL; spline = spline->to->next ) { + if (spline->to == spl->first ) + break; + if (spline->to->selected) { + if (found == NULL) { + *selected_num = 1; + found = spl; + } + else if (found != spl) + (*selected_num)++; + } + } + } + *_spl = found; + + if (found) + return (true); + + return (false); +} + SplinePointList *CVAnySelPointList(CharView *cv) { /* if there is exactly one point selected and it is on an open splineset */ /* and it is one of the endpoints of the splineset, then return that */ diff -urN fontforge-20050310/fontforge/cvpalettes.c fontforge-20050310.new/fontforge/cvpalettes.c --- fontforge-20050310/fontforge/cvpalettes.c 2005-05-04 07:33:23.000000000 +0900 +++ fontforge-20050310.new/fontforge/cvpalettes.c 2005-05-04 07:03:04.000000000 +0900 @@ -866,10 +866,11 @@ CVDoTransform(cv,pos); #ifdef FONTFORGE_CONFIG_CLWFK { - SplinePointList *spl; RefChar *r; ImageList *im; - if ( event->u.mouse.clicks>=2 && CVOneContourSel(cv,&spl,&r,&im) && + SplinePointList *spl; + int selected_num; + if ( event->u.mouse.clicks>=2 && CVPointsSel(cv,&spl,&selected_num) && (pos == cvt_curve || pos == cvt_corner || pos == cvt_tangent )) - StrokeGetInfo(cv, spl); + StrokeGetInfo(cv, spl, selected_num); } #endif } else if ( event->type == et_mousemove ) { diff -urN fontforge-20050310/fontforge/splinefont.h fontforge-20050310.new/fontforge/splinefont.h --- fontforge-20050310/fontforge/splinefont.h 2005-05-04 07:33:23.000000000 +0900 +++ fontforge-20050310.new/fontforge/splinefont.h 2005-05-04 07:02:17.000000000 +0900 @@ -1886,7 +1886,7 @@ extern SplineFont *SFReadClwfkSkeleton(char *fontname); extern void SCBuildSkeleton(SplineChar *sc, char *name); extern void SCFleshSkeleton(SplineChar *sc, char *face, int normkanji); -extern void StrokeGetInfo(struct charview *cv, SplinePointList *spl); +extern void StrokeGetInfo(struct charview *cv, SplinePointList *spl, int selected_num); extern int ExportSkeletonAs(FILE *skel, SplineChar *sc, char *glyphnmne); extern int ExportSkeleton(char *filename,SplineChar *sc); extern char *u2utf7_copy(const unichar_t *ubuf); diff -urN fontforge-20050310/fontforge/views.h fontforge-20050310.new/fontforge/views.h --- fontforge-20050310/fontforge/views.h 2005-05-04 07:33:23.000000000 +0900 +++ fontforge-20050310.new/fontforge/views.h 2005-05-04 07:02:25.000000000 +0900 @@ -969,6 +969,8 @@ RefChar **ref, ImageList **img, AnchorPoint **ap); extern int CVOneContourSel(CharView *cv, SplinePointList **_spl, RefChar **ref, ImageList **img); +extern int CVPointsSel(CharView *cv, SplinePointList **_spl, + int *selected_num); extern void RevertedGlyphReferenceFixup(SplineChar *sc, SplineFont *sf); extern void CVImport(CharView *cv); extern void BVImport(BitmapView *bv);