[xiph-commits] r10130 - trunk/planarity
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Wed Oct 5 05:25:21 PDT 2005
Author: xiphmont
Date: 2005-10-05 05:25:18 -0700 (Wed, 05 Oct 2005)
New Revision: 10130
Modified:
trunk/planarity/gameboard.h
trunk/planarity/gameboard_draw_main.c
trunk/planarity/gameboard_logic_fade.c
trunk/planarity/gameboard_logic_mouse.c
trunk/planarity/graph.c
trunk/planarity/main.c
trunk/planarity/version.h
Log:
Consistency cleanup:
Round font sizes up, not down
Fade verticies attached to a group drag like with a single drag
use an incremental add to place group dragged edges back into background
Modified: trunk/planarity/gameboard.h
===================================================================
--- trunk/planarity/gameboard.h 2005-10-05 11:37:32 UTC (rev 10129)
+++ trunk/planarity/gameboard.h 2005-10-05 12:25:18 UTC (rev 10130)
@@ -272,6 +272,7 @@
extern void expose_full(Gameboard *g);
extern void update_full_delayed(Gameboard *g);
extern void update_add_vertex(Gameboard *g, vertex *v);
+extern void update_add_selgroup(Gameboard *g);
extern void gameboard_draw(Gameboard *g, int x, int y, int w, int h);
extern void draw_foreground(Gameboard *g,cairo_t *c,
int x,int y,int width,int height);
@@ -328,4 +329,5 @@
extern void fade_cancel(Gameboard *g);
extern void fade_attached(Gameboard *g,vertex *v);
+extern void fade_grabbed(Gameboard *g);
Modified: trunk/planarity/gameboard_draw_main.c
===================================================================
--- trunk/planarity/gameboard_draw_main.c 2005-10-05 11:37:32 UTC (rev 10129)
+++ trunk/planarity/gameboard_draw_main.c 2005-10-05 12:25:18 UTC (rev 10130)
@@ -115,7 +115,7 @@
draw_vertex(c,v,g->vertex_sel);
} else if ( v == g->lit_vertex){
draw_vertex(c,v,g->vertex_lit);
- } else if (v->attached_to_grabbed && !g->group_drag){
+ } else if (v->attached_to_grabbed){
draw_vertex(c,v,g->vertex_attached);
}else{
draw_vertex(c,v,g->vertex);
@@ -220,8 +220,7 @@
while(el){
edge *e=el->edge;
- if(e->active)
- draw_edge(c,e);
+ draw_edge(c,e);
el=el->next;
}
@@ -232,6 +231,37 @@
invalidate_attached(widget,v);
}
+/* as above for re-inserting group drag edges to the background.
+ Doesn't require a full redraw. */
+void update_add_selgroup(Gameboard *g){
+ if(!g->hide_lines){
+ GtkWidget *widget = GTK_WIDGET(g);
+ cairo_t *c = cairo_create(g->background);
+ vertex *v = g->g.verticies;
+
+ setup_background_edge(c);
+
+ while(v){
+ if(v->grabbed){
+ edge_list *el=v->edges;
+ while(el){
+ edge *e=el->edge;
+
+ // draw the edge only once if it spans two grabbed verticies
+ if(e->A->grabbed==0 || e->B->grabbed==0 || v==e->A)
+ draw_edge(c,e);
+
+ el=el->next;
+ }
+ }
+ invalidate_attached(widget,v);
+ v=v->next;
+ }
+ finish_edge(c);
+ cairo_destroy(c);
+ }
+}
+
/* top level draw function called by expose. May also be called
directly to immediately render a region of the board without going
through the expose mechanism (necessary for some button draw
Modified: trunk/planarity/gameboard_logic_fade.c
===================================================================
--- trunk/planarity/gameboard_logic_fade.c 2005-10-05 11:37:32 UTC (rev 10129)
+++ trunk/planarity/gameboard_logic_fade.c 2005-10-05 12:25:18 UTC (rev 10130)
@@ -119,3 +119,36 @@
f->fade_timer = g_timeout_add(FADE_ANIM_INTERVAL, animate_fade, (gpointer)g);
}
+void fade_grabbed(Gameboard *g){
+ fade_state *f = &g->fade;
+ vertex *v = g->g.verticies;
+
+ /* If a fade is already in progress, cancel it */
+ fade_cancel(g);
+
+ while(v){
+ if(v->grabbed){
+ edge_list *el=v->edges;
+
+
+ while(el){
+ edge *e=el->edge;
+
+ if(v == e->A){
+ if(!e->B->grabbed)
+ fade_add_vertex(f,e->B);
+ }else{
+ if(!e->A->grabbed)
+ fade_add_vertex(f,e->A);
+ }
+ el=el->next;
+ }
+ }
+ v=v->next;
+ }
+
+ f->count = FADE_FRAMES;
+
+ f->fade_timer = g_timeout_add(FADE_ANIM_INTERVAL, animate_fade, (gpointer)g);
+}
+
Modified: trunk/planarity/gameboard_logic_mouse.c
===================================================================
--- trunk/planarity/gameboard_logic_mouse.c 2005-10-05 11:37:32 UTC (rev 10129)
+++ trunk/planarity/gameboard_logic_mouse.c 2005-10-05 12:25:18 UTC (rev 10130)
@@ -215,6 +215,7 @@
// vertex change
grab_selected(&g->g);
invalidate_verticies_selection(widget);
+ fade_cancel(g);
update_full_delayed(g);
return TRUE;
}
@@ -333,9 +334,11 @@
/* case: release a group drag */
if(g->group_drag){
move_selected_verticies(&g->g,g->dragx,g->dragy);
+ fade_grabbed(g);
+ update_add_selgroup(g);
ungrab_verticies(&g->g);
- update_full(g); // cheating
update_score(g);
+
g->group_drag=0;
if(g->g.active_intersections<=g->g.objective)
Modified: trunk/planarity/graph.c
===================================================================
--- trunk/planarity/graph.c 2005-10-05 11:37:32 UTC (rev 10129)
+++ trunk/planarity/graph.c 2005-10-05 12:25:18 UTC (rev 10130)
@@ -519,15 +519,15 @@
vertex *v = g->verticies;
while(v){
if(v->selected){
- //edge_list *el=v->edges;
+ edge_list *el=v->edges;
deactivate_vertex(g,v);
- //while(el){
- //edge_list *next=el->next;
- //edge *e=el->edge;
- //vertex *other=(e->A==v?e->B:e->A);
- //other->attached_to_grabbed=1;
- //el=next;
- //}
+ while(el){
+ edge_list *next=el->next;
+ edge *e=el->edge;
+ vertex *other=(e->A==v?e->B:e->A);
+ other->attached_to_grabbed=1;
+ el=next;
+ }
v->grabbed=1;
}
v=v->next;
@@ -551,15 +551,15 @@
vertex *v = g->verticies;
while(v){
if(v->grabbed){
- //edge_list *el=v->edges;
+ edge_list *el=v->edges;
activate_vertex(g,v);
- //while(el){
- //edge_list *next=el->next;
- //edge *e=el->edge;
- //vertex *other=(e->A==v?e->B:e->A);
- //other->attached_to_grabbed=1;
- //el=next;
- //}
+ while(el){
+ edge_list *next=el->next;
+ edge *e=el->edge;
+ vertex *other=(e->A==v?e->B:e->A);
+ other->attached_to_grabbed=0;
+ el=next;
+ }
v->grabbed=0;
}
v=v->next;
Modified: trunk/planarity/main.c
===================================================================
--- trunk/planarity/main.c 2005-10-05 11:37:32 UTC (rev 10129)
+++ trunk/planarity/main.c 2005-10-05 12:25:18 UTC (rev 10130)
@@ -242,13 +242,13 @@
if(slant){
cairo_set_font_face(c,ital_face);
- cairo_matrix_init_scale (&m, rint(w*adjust_x_normal),rint(h*adjust_y_normal));
+ cairo_matrix_init_scale (&m, ceil(w*adjust_x_normal),ceil(h*adjust_y_normal));
}else if (bold){
cairo_set_font_face(c,bold_face);
- cairo_matrix_init_scale (&m, rint(w*adjust_x_bold),rint(h*adjust_y_bold));
+ cairo_matrix_init_scale (&m, ceil(w*adjust_x_bold),ceil(h*adjust_y_bold));
}else{
cairo_set_font_face(c,font_face);
- cairo_matrix_init_scale (&m, rint(w*adjust_x_normal),rint(h*adjust_y_normal));
+ cairo_matrix_init_scale (&m, ceil(w*adjust_x_normal),ceil(h*adjust_y_normal));
}
cairo_set_font_matrix (c,&m);
Modified: trunk/planarity/version.h
===================================================================
--- trunk/planarity/version.h 2005-10-05 11:37:32 UTC (rev 10129)
+++ trunk/planarity/version.h 2005-10-05 12:25:18 UTC (rev 10130)
@@ -1,2 +1,2 @@
#define VERSION "$Id$ "
-/* DO NOT EDIT: Automated versioning hack [Wed Oct 5 07:33:25 EDT 2005] */
+/* DO NOT EDIT: Automated versioning hack [Wed Oct 5 08:22:03 EDT 2005] */
More information about the commits
mailing list