Skip to content

Commit

Permalink
cleaned up for merge
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyiq committed Apr 6, 2013
1 parent 3d72dcc commit 89d1f8d
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 2,952 deletions.
10 changes: 9 additions & 1 deletion fontforge/baseviews.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -301,10 +301,18 @@ extern void SCCopyLookupData(SplineChar *sc);
extern void PasteRemoveSFAnchors(SplineFont *); extern void PasteRemoveSFAnchors(SplineFont *);
extern void PasteAnchorClassMerge(SplineFont *sf,AnchorClass *into,AnchorClass *from); extern void PasteAnchorClassMerge(SplineFont *sf,AnchorClass *into,AnchorClass *from);
extern void PasteRemoveAnchorClass(SplineFont *sf,AnchorClass *dying); extern void PasteRemoveAnchorClass(SplineFont *sf,AnchorClass *dying);

/** /**
* Convert the undo into a string. You must free() the returned string. * Serialize and undo into a string.
* You must free() the returned string.
*/ */
extern char* UndoToString( SplineChar* sc, Undoes *undo ); extern char* UndoToString( SplineChar* sc, Undoes *undo );

/**
* Dump a list of undos for a splinechar starting at the given 'undo'.
* msg is used as a header message so that a dump at a particular time stands
* out from one that occurs later in the code.
*/
extern void dumpUndoChain( char* msg, SplineChar* sc, Undoes *undo ); extern void dumpUndoChain( char* msg, SplineChar* sc, Undoes *undo );


extern void ClipboardClear(void); extern void ClipboardClear(void);
Expand Down
37 changes: 19 additions & 18 deletions fontforge/charview.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4030,6 +4030,9 @@ return;
if( lastSel.lastselpt != fs.p->sp if( lastSel.lastselpt != fs.p->sp
|| lastSel.lastselcp != fs.p->spiro ) || lastSel.lastselcp != fs.p->spiro )
{ {
// If we are in a collab session, we might like to preserve here
// so that we can send a change of selected points to other members
// of the group
if( collabclient_inSession( cv ) ) if( collabclient_inSession( cv ) )
{ {
CVPreserveState(&cv->b); CVPreserveState(&cv->b);
Expand Down Expand Up @@ -6893,24 +6896,24 @@ static void CVUndo(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e))


Undoes *undo = cv->b.layerheads[cv->b.drawmode]->undoes; Undoes *undo = cv->b.layerheads[cv->b.drawmode]->undoes;


printf("CVUndo() undo:%p u->next:%p\n", undo, ( undo ? undo->next : 0 ) ); // printf("CVUndo() undo:%p u->next:%p\n", undo, ( undo ? undo->next : 0 ) );
if( undo ) if( undo )
{ {
printf("undo:\n%s\n", UndoToString( cv->b.sc, undo ) ); /* printf("undo:\n%s\n", UndoToString( cv->b.sc, undo ) ); */
{ /* { */
int len = 0; /* int len = 0; */
Undoes *p = undo; /* Undoes *p = undo; */
for( ; p; p = p->next ) /* for( ; p; p = p->next ) */
len++; /* len++; */
printf("u.len:%d\n", len ); /* printf("u.len:%d\n", len ); */
} /* } */
{ /* { */
int len = 0; /* int len = 0; */
Undoes *p = cv->b.layerheads[cv->b.drawmode]->redoes; /* Undoes *p = cv->b.layerheads[cv->b.drawmode]->redoes; */
for( ; p; p = p->next ) /* for( ; p; p = p->next ) */
len++; /* len++; */
printf("r.len:%d\n", len ); /* printf("r.len:%d\n", len ); */
} /* } */


if( collabclient_inSession( cv ) ) if( collabclient_inSession( cv ) )
{ {
Expand Down Expand Up @@ -8089,8 +8092,6 @@ static void transfunc(void *d,real transform[6],int otype,BVTFunc *bvts,
CharView *cv = (CharView *) d; CharView *cv = (CharView *) d;
int anya, l, cvlayer = CVLayer((CharViewBase *) cv); int anya, l, cvlayer = CVLayer((CharViewBase *) cv);


printf("transfunc() cv:%p\n", cv );

if ( cv->b.layerheads[cv->b.drawmode]->undoes!=NULL && if ( cv->b.layerheads[cv->b.drawmode]->undoes!=NULL &&
cv->b.layerheads[cv->b.drawmode]->undoes->undotype==ut_tstate ) cv->b.layerheads[cv->b.drawmode]->undoes->undotype==ut_tstate )
CVDoUndo(&cv->b); CVDoUndo(&cv->b);
Expand Down
7 changes: 7 additions & 0 deletions fontforge/collabclient.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ int pref_collab_roundTripTimerMS = 2000;
#define MSG_TYPE_SFD "msg_type_sfd" #define MSG_TYPE_SFD "msg_type_sfd"
#define MSG_TYPE_UNDO "msg_type_undo" #define MSG_TYPE_UNDO "msg_type_undo"


//
// Set to true if you want to see the raw SFD undo fragments which
// are moving to/from the server.
//
#define DEBUG_SHOW_SFD_CHUNKS 0 #define DEBUG_SHOW_SFD_CHUNKS 0




Expand Down Expand Up @@ -709,6 +713,9 @@ FontViewBase* collabclient_sessionJoin( void* ccvp, FontView *fv )
cc->sequence = 0; cc->sequence = 0;
zstr_sendm (cc->snapshot, "ICANHAZ?"); zstr_sendm (cc->snapshot, "ICANHAZ?");
zstr_send (cc->snapshot, SUBTREE); zstr_send (cc->snapshot, SUBTREE);

// if we wait for timeoutMS millisec then we assume failure
// timeWaitedMS is used to keep track of how long we have waited
kvmsg_t* lastSFD = 0; kvmsg_t* lastSFD = 0;
int timeWaitedMS = 0; int timeWaitedMS = 0;
int timeoutMS = pref_collab_sessionJoinTimeoutMS; int timeoutMS = pref_collab_sessionJoinTimeoutMS;
Expand Down
6 changes: 6 additions & 0 deletions fontforge/collabclient.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ extern void collabclient_closeLocalServer( FontViewBase* fv );
extern void collabclient_setGeneratingUndoForWire( int v ); extern void collabclient_setGeneratingUndoForWire( int v );




/**
* Every message send from the server has a monotonically increasing
* SequenceNumber. This function gets what that value is right now and
* can be used to check if any messages have been received from the
* server by calling again and comparing the return value.
*/
extern int64_t collabclient_getCurrentSequenceNumber(void* ccvp); extern int64_t collabclient_getCurrentSequenceNumber(void* ccvp);


#endif #endif
Expand Down
63 changes: 30 additions & 33 deletions fontforge/metricsview.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -980,6 +980,10 @@ static real GGadgetToReal(GGadget *g)
return val; return val;
} }


/**
* If we are in a collab session then send the redo through to the
* server to update other clients to our state.
*/
static void MV_handle_collabclient_sendRedo( MetricsView *mv, SplineChar *sc ) static void MV_handle_collabclient_sendRedo( MetricsView *mv, SplineChar *sc )
{ {
if( collabclient_inSessionFV( mv->fv ) ) if( collabclient_inSessionFV( mv->fv ) )
Expand Down Expand Up @@ -1012,7 +1016,7 @@ return( true );
if (!isValidInt(end)) if (!isValidInt(end))
GDrawBeep(NULL); GDrawBeep(NULL);
else if ( !mv->vertical && val!=sc->width ) { else if ( !mv->vertical && val!=sc->width ) {
dumpUndoChain( "before SCPreserveWidth...", sc, &sc->layers[ly_fore].undoes ); // dumpUndoChain( "before SCPreserveWidth...", sc, &sc->layers[ly_fore].undoes );
SCPreserveWidth(sc); SCPreserveWidth(sc);
if( collabclient_inSessionFV( mv->fv ) ) if( collabclient_inSessionFV( mv->fv ) )
{ {
Expand Down Expand Up @@ -1080,16 +1084,19 @@ return( true );
if (!isValidInt(end)) if (!isValidInt(end))
GDrawBeep(NULL); GDrawBeep(NULL);
else if ( !mv->vertical && val!=bb.minx ) { else if ( !mv->vertical && val!=bb.minx ) {
int dohints = 0; if( collabclient_inSessionFV( mv->fv ) )
SCPreserveState( sc, dohints ); {
int dohints = 0;
SCPreserveState( sc, dohints );
}


real transform[6]; real transform[6];
transform[0] = transform[3] = 1.0; transform[0] = transform[3] = 1.0;
transform[1] = transform[2] = transform[5] = 0; transform[1] = transform[2] = transform[5] = 0;
transform[4] = val-bb.minx; transform[4] = val-bb.minx;
FVTrans( (FontViewBase *)mv->fv,sc,transform,NULL,0 | fvt_alllayers ); FVTrans( (FontViewBase *)mv->fv,sc,transform,NULL,0 | fvt_alllayers );


dumpUndoChain( "LBearing Changed...e", sc, &sc->layers[ly_fore].undoes ); // dumpUndoChain( "LBearing Changed...e", sc, &sc->layers[ly_fore].undoes );
MV_handle_collabclient_sendRedo( mv, sc ); MV_handle_collabclient_sendRedo( mv, sc );


} else if ( mv->vertical && val!=sc->parent->ascent-bb.maxy ) { } else if ( mv->vertical && val!=sc->parent->ascent-bb.maxy ) {
Expand Down Expand Up @@ -1135,21 +1142,22 @@ return( true );
/* Width is an integer. Adjust the lbearing so that the rbearing */ /* Width is an integer. Adjust the lbearing so that the rbearing */
/* remains what was just typed in */ /* remains what was just typed in */
if ( newwidth!=bb.maxx+val ) { if ( newwidth!=bb.maxx+val ) {
int dohints = 0; if( collabclient_inSessionFV( mv->fv ) )
SCPreserveState( sc, dohints ); {
int dohints = 0;
SCPreserveState( sc, dohints );
}


printf("RBearing Changed... transform!\n");
real transform[6]; real transform[6];
transform[0] = transform[3] = 1.0; transform[0] = transform[3] = 1.0;
transform[1] = transform[2] = transform[5] = 0; transform[1] = transform[2] = transform[5] = 0;
transform[4] = newwidth-val-bb.maxx; transform[4] = newwidth-val-bb.maxx;
FVTrans( (FontViewBase *)mv->fv,sc,transform,NULL,fvt_dontmovewidth); FVTrans( (FontViewBase *)mv->fv,sc,transform,NULL,fvt_dontmovewidth);
} }
dumpUndoChain( "RBearing Changed...2", sc, &sc->layers[ly_fore].undoes );
SCSynchronizeWidth(sc,newwidth,sc->width,NULL); SCSynchronizeWidth(sc,newwidth,sc->width,NULL);
dumpUndoChain( "RBearing Changed...3", sc, &sc->layers[ly_fore].undoes );
SCCharChangedUpdate(sc,ly_none); SCCharChangedUpdate(sc,ly_none);
dumpUndoChain( "RBearing Changed...e", sc, &sc->layers[ly_fore].undoes );
// dumpUndoChain( "RBearing Changed...2", sc, &sc->layers[ly_fore].undoes );
MV_handle_collabclient_sendRedo( mv, sc ); MV_handle_collabclient_sendRedo( mv, sc );
} else if ( mv->vertical && val!=sc->vwidth-(sc->parent->ascent-bb.miny) ) { } else if ( mv->vertical && val!=sc->vwidth-(sc->parent->ascent-bb.miny) ) {
double vw = val+(sc->parent->ascent-bb.miny); double vw = val+(sc->parent->ascent-bb.miny);
Expand Down Expand Up @@ -1201,23 +1209,6 @@ static int MV_ChangeKerning(MetricsView *mv, int which, int offset, int is_diff)
kc = mv->glyphs[which-1].kc; kc = mv->glyphs[which-1].kc;
index = mv->glyphs[which-1].kc_index; index = mv->glyphs[which-1].kc_index;


printf("MV_ChangeKerning(top)\n");
printf("MV_ChangeKerning() kp:%p\n", kp );
printf("MV_ChangeKerning() kc:%p\n", kc );
// FIXME: MIQ:
{
SplineFont *sf = mv->sf;
int lookup_type = gpos_pair;
char* str = SFDCreateUndoForLookup( sf, lookup_type );
GFileWriteAll( "/tmp/mv-old-lookup-table.sfd", str );
printf("MV_ChangeKerning() sf->kerns:%p\n", sf->kerns );
if( sf->kerns )
{
printf("MV_ChangeKerning() first_cnt:%d\n", sf->kerns->first_cnt );
printf("MV_ChangeKerning() second_cnt:%d\n", sf->kerns->second_cnt );
}
}

if ( kc!=NULL ) { if ( kc!=NULL ) {
if ( index==-1 ) if ( index==-1 )
kc = NULL; kc = NULL;
Expand Down Expand Up @@ -4555,8 +4546,13 @@ return;
} }
mv->pressed_x = event->u.mouse.x; mv->pressed_x = event->u.mouse.x;
} else if ( event->type == et_mousemove && mv->pressed ) { } else if ( event->type == et_mousemove && mv->pressed ) {
printf("move & pressed pressedwidth:%d pressedkern:%d type!=mv_kernonly:%d\n",mv->pressedwidth,mv->pressedkern,(mv->type!=mv_kernonly)); // printf("move & pressed pressedwidth:%d pressedkern:%d type!=mv_kernonly:%d\n",mv->pressedwidth,mv->pressedkern,(mv->type!=mv_kernonly));
for ( i=0; i<mv->glyphcnt && !mv->perchar[i].selected; ++i );
for ( i=0; i<mv->glyphcnt && !mv->perchar[i].selected; ++i )
{
// nothing
}

if ( mv->pressedwidth ) { if ( mv->pressedwidth ) {
int ow = mv->perchar[i].dwidth; int ow = mv->perchar[i].dwidth;
if ( mv->right_to_left ) diff = -diff; if ( mv->right_to_left ) diff = -diff;
Expand Down Expand Up @@ -4607,9 +4603,11 @@ return;
if ( mv->showgrid==mv_hidemovinggrid ) if ( mv->showgrid==mv_hidemovinggrid )
GDrawRequestExpose(mv->v,NULL,false); GDrawRequestExpose(mv->v,NULL,false);
} else if ( event->type == et_mouseup && mv->pressed ) { } else if ( event->type == et_mouseup && mv->pressed ) {
printf("mouse up!\n"); for ( i=0; i<mv->glyphcnt && !mv->perchar[i].selected; ++i )
printf("pressedwidth:%d pressedkern:%d type!=mv_kernonly:%d\n",mv->pressedwidth,mv->pressedkern,(mv->type!=mv_kernonly)); {
for ( i=0; i<mv->glyphcnt && !mv->perchar[i].selected; ++i ); // nothing
}

mv->pressed = false; mv->pressed = false;
mv->activeoff = 0; mv->activeoff = 0;
sc = mv->glyphs[i].sc; sc = mv->glyphs[i].sc;
Expand All @@ -4622,7 +4620,6 @@ return;
SCSynchronizeWidth(sc,sc->width+diff,sc->width,NULL); SCSynchronizeWidth(sc,sc->width+diff,sc->width,NULL);
SCCharChangedUpdate(sc,ly_none); SCCharChangedUpdate(sc,ly_none);
MV_handle_collabclient_sendRedo( mv, sc ); MV_handle_collabclient_sendRedo( mv, sc );
// FIXME: MIQ: collab send redo call
} }
} else if ( mv->pressedkern ) { } else if ( mv->pressedkern ) {
mv->pressedkern = false; mv->pressedkern = false;
Expand Down
5 changes: 5 additions & 0 deletions fontforge/views.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -890,6 +890,11 @@ extern void PI_ShowHints(SplineChar *sc, GGadget *list, int set);
extern GTextInfo *SCHintList(SplineChar *sc,HintMask *); extern GTextInfo *SCHintList(SplineChar *sc,HintMask *);
extern void CVResize(CharView *cv ); extern void CVResize(CharView *cv );
extern CharView *CharViewCreate(SplineChar *sc,FontView *fv,int enc); extern CharView *CharViewCreate(SplineChar *sc,FontView *fv,int enc);

/**
* Extended version of CharViewCreate() which allows a window to be created but
* not displayed.
*/
extern CharView *CharViewCreateExtended(SplineChar *sc, FontView *fv,int enc, int show ); extern CharView *CharViewCreateExtended(SplineChar *sc, FontView *fv,int enc, int show );
extern void CharViewFree(CharView *cv); extern void CharViewFree(CharView *cv);
extern int CVValid(SplineFont *sf, SplineChar *sc, CharView *cv); extern int CVValid(SplineFont *sf, SplineChar *sc, CharView *cv);
Expand Down
Loading

0 comments on commit 89d1f8d

Please sign in to comment.