Create cairo context in expose callback

This commit is contained in:
Paul Dicker
2025-04-03 21:27:17 +02:00
committed by Stéphane Lesimple
parent 6dc80bb542
commit 5da5fa54dc
12 changed files with 85 additions and 86 deletions

View File

@@ -169,9 +169,8 @@ void GuiUpdateCurveGeometry(Curve *curve, char *largest_left_label, int right_pa
*** Redraw the coordinate axes *** Redraw the coordinate axes
***/ ***/
void GuiRedrawAxes(Curve *curve) void GuiRedrawAxes(cairo_t *cr, Curve *curve)
{ cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(curve->widget)); { int i,w,h,x,y;
int i,w,h,x,y;
int yg=0; int yg=0;
int step; int step;
int bottom_y; int bottom_y;
@@ -369,9 +368,8 @@ void GuiRedrawAxes(Curve *curve)
* Redraw the curve * Redraw the curve
*/ */
void GuiRedrawCurve(Curve *curve, int last) void GuiRedrawCurve(cairo_t *cr, Curve *curve, int last)
{ cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(curve->widget)); { int i,x0,x1,fy0;
int i,x0,x1,fy0;
gdk_cairo_set_source_color(cr, Closure->curveColor); gdk_cairo_set_source_color(cr, Closure->curveColor);
cairo_set_line_width(cr, 1.0); cairo_set_line_width(cr, 1.0);

View File

@@ -692,8 +692,8 @@ int GuiCurveX(Curve*, gdouble);
int GuiCurveY(Curve*, gdouble); int GuiCurveY(Curve*, gdouble);
int GuiCurveLogY(Curve*, gdouble); int GuiCurveLogY(Curve*, gdouble);
void GuiRedrawAxes(Curve*); void GuiRedrawAxes(cairo_t *cr, Curve*);
void GuiRedrawCurve(Curve*, int); void GuiRedrawCurve(cairo_t *cr, Curve*, int);
#endif #endif
/*** /***
@@ -1542,8 +1542,8 @@ void GuiSetSpiralWidget(Spiral*, GtkWidget*);
void GuiFreeSpiral(Spiral*); void GuiFreeSpiral(Spiral*);
void GuiFillSpiral(Spiral*, GdkColor*); void GuiFillSpiral(Spiral*, GdkColor*);
void GuiDrawSpiral(Spiral*); void GuiDrawSpiral(cairo_t *cr, Spiral*);
void GuiDrawSpiralLabel(Spiral*, PangoLayout*, char*, GdkColor*, int, int); void GuiDrawSpiralLabel(cairo_t *cr, Spiral*, PangoLayout*, char*, GdkColor*, int, int);
void GuiChangeSpiralCursor(Spiral*, int); void GuiChangeSpiralCursor(Spiral*, int);
void GuiMoveSpiralCursor(Spiral*, int); void GuiMoveSpiralCursor(Spiral*, int);
void GuiSetSpiralSegmentColor(Spiral*, GdkColor*, GdkColor*, int); void GuiSetSpiralSegmentColor(Spiral*, GdkColor*, GdkColor*, int);

View File

@@ -106,7 +106,7 @@ typedef struct _raw_editor_context
} raw_editor_context; } raw_editor_context;
static void evaluate_vectors(raw_editor_context*); static void evaluate_vectors(raw_editor_context*);
static void render_sector(raw_editor_context*); static void render_sector(cairo_t *cr, raw_editor_context*);
static raw_editor_context* create_raw_editor_context() static raw_editor_context* create_raw_editor_context()
{ raw_editor_context *rec = Closure->rawEditorContext; { raw_editor_context *rec = Closure->rawEditorContext;
@@ -540,14 +540,13 @@ static void evaluate_vectors(raw_editor_context *rec)
/* Render the sector */ /* Render the sector */
static void render_sector(raw_editor_context *rec) static void render_sector(cairo_t *cr, raw_editor_context *rec)
{ GdkWindow *d = gtk_widget_get_window(rec->drawingArea); { GdkWindow *d = gtk_widget_get_window(rec->drawingArea);
unsigned char *buf = rec->rb->recovered; unsigned char *buf = rec->rb->recovered;
int idx=0; int idx=0;
int i,j,w,h,x,y; int i,j,w,h,x,y;
if(!d) return; if(!d) return;
cairo_t *cr = gdk_cairo_create(d);
gdk_cairo_set_source_color(cr, Closure->background); gdk_cairo_set_source_color(cr, Closure->background);
cairo_rectangle(cr, 0, 0, rec->daWidth, rec->daHeight); cairo_rectangle(cr, 0, 0, rec->daWidth, rec->daHeight);
@@ -605,8 +604,10 @@ static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer dat
if(event->count) /* Exposure compression */ if(event->count) /* Exposure compression */
return TRUE; return TRUE;
cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(widget)));
evaluate_vectors(rec); evaluate_vectors(rec);
render_sector(rec); render_sector(cr, rec);
return TRUE; return TRUE;
} }

View File

@@ -61,9 +61,8 @@ static int draw_text(cairo_t *cr, PangoLayout *l, char *text, int x, int y, GdkC
return h; return h;
} }
static void redraw_labels(GtkWidget *widget, int erase_mask) static void redraw_labels(cairo_t *cr, GtkWidget *widget, int erase_mask)
{ cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(Closure->readAdaptiveDrawingArea)); { char buf[256];
char buf[256];
int x,y,w,h; int x,y,w,h;
/* Draw the labels */ /* Draw the labels */
@@ -161,15 +160,15 @@ static void update_geometry(GtkWidget *widget)
/* Expose event handler */ /* Expose event handler */
static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data) static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
{ { cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(widget)));
GuiSetSpiralWidget(Closure->readAdaptiveSpiral, widget); GuiSetSpiralWidget(Closure->readAdaptiveSpiral, widget);
if(event->count) /* Exposure compression */ if(event->count) /* Exposure compression */
return TRUE; return TRUE;
update_geometry(widget); update_geometry(widget);
redraw_labels(widget, ~0); redraw_labels(cr, widget, ~0);
GuiDrawSpiral(Closure->readAdaptiveSpiral); GuiDrawSpiral(cr, Closure->readAdaptiveSpiral);
return TRUE; return TRUE;
} }

View File

@@ -34,7 +34,7 @@
*** Forward declarations *** Forward declarations
***/ ***/
static void redraw_curve(void); static void redraw_curve(cairo_t *cr);
static void update_geometry(void); static void update_geometry(void);
/*** /***
@@ -230,10 +230,10 @@ void GuiMarkExistingSectors(void)
* Redraw the whole curve * Redraw the whole curve
*/ */
static void redraw_curve(void) static void redraw_curve(cairo_t *cr)
{ {
GuiRedrawAxes(Closure->readLinearCurve); GuiRedrawAxes(cr, Closure->readLinearCurve);
GuiRedrawCurve(Closure->readLinearCurve, 1000); GuiRedrawCurve(cr, Closure->readLinearCurve, 1000);
} }
/* Calculate the geometry of the curve */ /* Calculate the geometry of the curve */
@@ -251,9 +251,8 @@ static void update_geometry(void)
} }
static void redraw_spiral_labels(void) static void redraw_spiral_labels(cairo_t *cr)
{ cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(Closure->readLinearSpiral->widget)); { int x,w,h;
int x,w,h;
int pos = 1; int pos = 1;
/* Draw and label the spiral */ /* Draw and label the spiral */
@@ -265,36 +264,37 @@ static void redraw_spiral_labels(void)
pango_cairo_show_layout(cr, Closure->readLinearCurve->layout); pango_cairo_show_layout(cr, Closure->readLinearCurve->layout);
if(Closure->additionalSpiralColor == 0) if(Closure->additionalSpiralColor == 0)
GuiDrawSpiralLabel(Closure->readLinearSpiral, Closure->readLinearCurve->layout, GuiDrawSpiralLabel(cr, Closure->readLinearSpiral, Closure->readLinearCurve->layout,
_("Not touched this time"), Closure->curveColor, x, -1); _("Not touched this time"), Closure->curveColor, x, -1);
if(Closure->additionalSpiralColor == 3) if(Closure->additionalSpiralColor == 3)
GuiDrawSpiralLabel(Closure->readLinearSpiral, Closure->readLinearCurve->layout, GuiDrawSpiralLabel(cr, Closure->readLinearSpiral, Closure->readLinearCurve->layout,
_("Already present"), Closure->darkSector, x, -1); _("Already present"), Closure->darkSector, x, -1);
GuiDrawSpiralLabel(Closure->readLinearSpiral, Closure->readLinearCurve->layout, GuiDrawSpiralLabel(cr, Closure->readLinearSpiral, Closure->readLinearCurve->layout,
_("Successfully read"), Closure->greenSector, x, pos++); _("Successfully read"), Closure->greenSector, x, pos++);
if(Closure->crcBuf && Closure->crcBuf->crcCached) if(Closure->crcBuf && Closure->crcBuf->crcCached)
GuiDrawSpiralLabel(Closure->readLinearSpiral, Closure->readLinearCurve->layout, GuiDrawSpiralLabel(cr, Closure->readLinearSpiral, Closure->readLinearCurve->layout,
_("Sectors with CRC errors"), Closure->yellowSector, x, pos++); _("Sectors with CRC errors"), Closure->yellowSector, x, pos++);
GuiDrawSpiralLabel(Closure->readLinearSpiral, Closure->readLinearCurve->layout, GuiDrawSpiralLabel(cr, Closure->readLinearSpiral, Closure->readLinearCurve->layout,
_("Unreadable / skipped"), Closure->redSector, x, pos++); _("Unreadable / skipped"), Closure->redSector, x, pos++);
GuiDrawSpiral(Closure->readLinearSpiral); GuiDrawSpiral(cr, Closure->readLinearSpiral);
} }
static gboolean expose_curve_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data) static gboolean expose_curve_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
{ { cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(widget)));
update_geometry(); update_geometry();
redraw_curve(); redraw_curve(cr);
return TRUE; return TRUE;
} }
static gboolean expose_spiral_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data) static gboolean expose_spiral_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
{ GtkAllocation a = {0}; { cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(widget)));
GtkAllocation a = {0};
gtk_widget_get_allocation(widget, &a); gtk_widget_get_allocation(widget, &a);
GuiSetSpiralWidget(Closure->readLinearSpiral, widget); GuiSetSpiralWidget(Closure->readLinearSpiral, widget);
@@ -309,7 +309,7 @@ static gboolean expose_spiral_cb(GtkWidget *widget, GdkEventExpose *event, gpoin
Closure->readLinearSpiral->my = a.height/2 - h; Closure->readLinearSpiral->my = a.height/2 - h;
} }
redraw_spiral_labels(); redraw_spiral_labels(cr);
return TRUE; return TRUE;
} }

View File

@@ -121,19 +121,19 @@ void RS01AddVerifyValues(Method *method, int percent,
* Redraw whole spiral * Redraw whole spiral
*/ */
static void redraw_spiral(RS01Widgets *wl) static void redraw_spiral(cairo_t *cr, RS01Widgets *wl)
{ int x = wl->cmpSpiral->mx - wl->cmpSpiral->diameter/2 + 10; { int x = wl->cmpSpiral->mx - wl->cmpSpiral->diameter/2 + 10;
GuiDrawSpiralLabel(wl->cmpSpiral, wl->cmpLayout, GuiDrawSpiralLabel(cr, wl->cmpSpiral, wl->cmpLayout,
_("Good sectors"), Closure->greenSector, x, 1); _("Good sectors"), Closure->greenSector, x, 1);
GuiDrawSpiralLabel(wl->cmpSpiral, wl->cmpLayout, GuiDrawSpiralLabel(cr, wl->cmpSpiral, wl->cmpLayout,
_("Sectors with CRC errors"), Closure->yellowSector, x, 2); _("Sectors with CRC errors"), Closure->yellowSector, x, 2);
GuiDrawSpiralLabel(wl->cmpSpiral, wl->cmpLayout, GuiDrawSpiralLabel(cr, wl->cmpSpiral, wl->cmpLayout,
_("Missing sectors"), Closure->redSector, x, 3); _("Missing sectors"), Closure->redSector, x, 3);
GuiDrawSpiral(wl->cmpSpiral); GuiDrawSpiral(cr, wl->cmpSpiral);
} }
/* /*
@@ -141,7 +141,8 @@ static void redraw_spiral(RS01Widgets *wl)
*/ */
static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data) static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
{ RS01Widgets *wl = (RS01Widgets*)data; { cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(widget)));
RS01Widgets *wl = (RS01Widgets*)data;
GtkAllocation a = {0}; GtkAllocation a = {0};
gtk_widget_get_allocation(widget, &a); gtk_widget_get_allocation(widget, &a);
int w,h,size; int w,h,size;
@@ -165,7 +166,7 @@ static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer dat
/* Redraw the spiral */ /* Redraw the spiral */
redraw_spiral(wl); redraw_spiral(cr, wl);
return TRUE; return TRUE;
} }

View File

@@ -32,7 +32,7 @@
*** Forward declarations *** Forward declarations
***/ ***/
static void redraw_curve(RS01Widgets*); static void redraw_curve(cairo_t *cr, RS01Widgets*);
static void update_geometry(RS01Widgets*); static void update_geometry(RS01Widgets*);
/* Protected widget access */ /* Protected widget access */
@@ -257,19 +257,18 @@ static void update_geometry(RS01Widgets *wl)
TRUE, TRUE, wl->fixCurve->leftX, GTK_PACK_START); TRUE, TRUE, wl->fixCurve->leftX, GTK_PACK_START);
} }
static void redraw_curve(RS01Widgets *wl) static void redraw_curve(cairo_t *cr, RS01Widgets *wl)
{ int y; { int y;
/* Redraw the curve */ /* Redraw the curve */
GuiRedrawAxes(wl->fixCurve); GuiRedrawAxes(cr, wl->fixCurve);
GuiRedrawCurve(wl->fixCurve, wl->percent); GuiRedrawCurve(cr, wl->fixCurve, wl->percent);
/* Ecc capacity threshold line */ /* Ecc capacity threshold line */
y = GuiCurveY(wl->fixCurve, wl->eccBytes); y = GuiCurveY(wl->fixCurve, wl->eccBytes);
cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(wl->fixCurve->widget));
gdk_cairo_set_source_color(cr, Closure->greenSector); gdk_cairo_set_source_color(cr, Closure->greenSector);
cairo_set_line_width(cr, 1.0); cairo_set_line_width(cr, 1.0);
cairo_move_to(cr, wl->fixCurve->leftX-5.5, y+0.5); cairo_move_to(cr, wl->fixCurve->leftX-5.5, y+0.5);
@@ -282,14 +281,15 @@ static void redraw_curve(RS01Widgets *wl)
*/ */
static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data) static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
{ RS01Widgets *wl = (RS01Widgets*)data; { cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(widget)));
RS01Widgets *wl = (RS01Widgets*)data;
if(event->count) /* Exposure compression */ if(event->count) /* Exposure compression */
{ return TRUE; { return TRUE;
} }
update_geometry(wl); update_geometry(wl);
redraw_curve(wl); redraw_curve(cr, wl);
return TRUE; return TRUE;
} }

View File

@@ -114,19 +114,19 @@ static void add_verify_values(Method *method, int percent,
* Redraw whole spiral * Redraw whole spiral
*/ */
static void redraw_spiral(RS02Widgets *wl) static void redraw_spiral(cairo_t *cr, RS02Widgets *wl)
{ int x = wl->cmpSpiral->mx - wl->cmpSpiral->diameter/2 + 10; { int x = wl->cmpSpiral->mx - wl->cmpSpiral->diameter/2 + 10;
GuiDrawSpiralLabel(wl->cmpSpiral, wl->cmpLayout, GuiDrawSpiralLabel(cr, wl->cmpSpiral, wl->cmpLayout,
_("Good sectors"), Closure->greenSector, x, 1); _("Good sectors"), Closure->greenSector, x, 1);
GuiDrawSpiralLabel(wl->cmpSpiral, wl->cmpLayout, GuiDrawSpiralLabel(cr, wl->cmpSpiral, wl->cmpLayout,
_("Sectors with CRC errors"), Closure->yellowSector, x, 2); _("Sectors with CRC errors"), Closure->yellowSector, x, 2);
GuiDrawSpiralLabel(wl->cmpSpiral, wl->cmpLayout, GuiDrawSpiralLabel(cr, wl->cmpSpiral, wl->cmpLayout,
_("Missing sectors"), Closure->redSector, x, 3); _("Missing sectors"), Closure->redSector, x, 3);
GuiDrawSpiral(wl->cmpSpiral); GuiDrawSpiral(cr, wl->cmpSpiral);
} }
/* /*
@@ -134,7 +134,8 @@ static void redraw_spiral(RS02Widgets *wl)
*/ */
static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data) static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
{ RS02Widgets *wl = (RS02Widgets*)data; { cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(widget)));
RS02Widgets *wl = (RS02Widgets*)data;
GtkAllocation a = {0}; GtkAllocation a = {0};
gtk_widget_get_allocation(widget, &a); gtk_widget_get_allocation(widget, &a);
int w,h,size; int w,h,size;
@@ -153,7 +154,7 @@ static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer dat
wl->cmpSpiral->my = (wl->cmpSpiral->diameter + a.height - size)/2; wl->cmpSpiral->my = (wl->cmpSpiral->diameter + a.height - size)/2;
if(!event->count) /* Exposure compression */ if(!event->count) /* Exposure compression */
redraw_spiral(wl); /* Redraw the spiral */ redraw_spiral(cr, wl); /* Redraw the spiral */
return TRUE; return TRUE;
} }

View File

@@ -34,7 +34,7 @@ extern gint64 CurrentMediumSize(int); /* from scsi-layer.h */
*** Forward declarations *** Forward declarations
***/ ***/
static void redraw_curve(RS02Widgets*); static void redraw_curve(cairo_t *cr, RS02Widgets*);
static void update_geometry(RS02Widgets*); static void update_geometry(RS02Widgets*);
/*** /***
@@ -197,19 +197,18 @@ static void update_geometry(RS02Widgets *wl)
TRUE, TRUE, wl->fixCurve->leftX, GTK_PACK_START); TRUE, TRUE, wl->fixCurve->leftX, GTK_PACK_START);
} }
static void redraw_curve(RS02Widgets *wl) static void redraw_curve(cairo_t *cr, RS02Widgets *wl)
{ int y; { int y;
/* Redraw the curve */ /* Redraw the curve */
GuiRedrawAxes(wl->fixCurve); GuiRedrawAxes(cr, wl->fixCurve);
GuiRedrawCurve(wl->fixCurve, wl->percent); GuiRedrawCurve(cr, wl->fixCurve, wl->percent);
/* Ecc capacity threshold line */ /* Ecc capacity threshold line */
y = GuiCurveY(wl->fixCurve, wl->eccBytes); y = GuiCurveY(wl->fixCurve, wl->eccBytes);
cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(wl->fixCurve->widget));
gdk_cairo_set_source_color(cr, Closure->greenSector); gdk_cairo_set_source_color(cr, Closure->greenSector);
cairo_set_line_width(cr, 1.0); cairo_set_line_width(cr, 1.0);
cairo_move_to(cr, wl->fixCurve->leftX-5.5, y+0.5); cairo_move_to(cr, wl->fixCurve->leftX-5.5, y+0.5);
@@ -222,13 +221,14 @@ static void redraw_curve(RS02Widgets *wl)
*/ */
static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data) static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
{ RS02Widgets *wl = (RS02Widgets*)data; { cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(widget)));
RS02Widgets *wl = (RS02Widgets*)data;
if(event->count) /* Exposure compression */ if(event->count) /* Exposure compression */
return TRUE; return TRUE;
update_geometry(wl); update_geometry(wl);
redraw_curve(wl); redraw_curve(cr, wl);
return TRUE; return TRUE;
} }

View File

@@ -124,19 +124,19 @@ static void add_verify_values(Method *method, int percent,
* Redraw whole spiral * Redraw whole spiral
*/ */
static void redraw_spiral(RS03Widgets *wl) static void redraw_spiral(cairo_t *cr, RS03Widgets *wl)
{ int x = wl->cmpSpiral->mx - wl->cmpSpiral->diameter/2 + 10; { int x = wl->cmpSpiral->mx - wl->cmpSpiral->diameter/2 + 10;
GuiDrawSpiralLabel(wl->cmpSpiral, wl->cmpLayout, GuiDrawSpiralLabel(cr, wl->cmpSpiral, wl->cmpLayout,
_("Good sectors"), Closure->greenSector, x, 1); _("Good sectors"), Closure->greenSector, x, 1);
GuiDrawSpiralLabel(wl->cmpSpiral, wl->cmpLayout, GuiDrawSpiralLabel(cr, wl->cmpSpiral, wl->cmpLayout,
_("Sectors with CRC errors"), Closure->yellowSector, x, 2); _("Sectors with CRC errors"), Closure->yellowSector, x, 2);
GuiDrawSpiralLabel(wl->cmpSpiral, wl->cmpLayout, GuiDrawSpiralLabel(cr, wl->cmpSpiral, wl->cmpLayout,
_("Missing sectors"), Closure->redSector, x, 3); _("Missing sectors"), Closure->redSector, x, 3);
GuiDrawSpiral(wl->cmpSpiral); GuiDrawSpiral(cr, wl->cmpSpiral);
} }
/* /*
@@ -144,7 +144,8 @@ static void redraw_spiral(RS03Widgets *wl)
*/ */
static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data) static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
{ RS03Widgets *wl = (RS03Widgets*)data; { cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(widget)));
RS03Widgets *wl = (RS03Widgets*)data;
GtkAllocation a = {0}; GtkAllocation a = {0};
gtk_widget_get_allocation(widget, &a); gtk_widget_get_allocation(widget, &a);
int w,h,size; int w,h,size;
@@ -163,7 +164,7 @@ static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer dat
wl->cmpSpiral->my = (wl->cmpSpiral->diameter + a.height - size)/2; wl->cmpSpiral->my = (wl->cmpSpiral->diameter + a.height - size)/2;
if(!event->count) /* Exposure compression */ if(!event->count) /* Exposure compression */
redraw_spiral(wl); /* Redraw the spiral */ redraw_spiral(cr, wl); /* Redraw the spiral */
return TRUE; return TRUE;
} }

View File

@@ -31,7 +31,7 @@
*** Forward declarations *** Forward declarations
***/ ***/
static void redraw_curve(RS03Widgets*); static void redraw_curve(cairo_t *cr, RS03Widgets*);
static void update_geometry(RS03Widgets*); static void update_geometry(RS03Widgets*);
/*** /***
@@ -227,19 +227,18 @@ static void update_geometry(RS03Widgets *wl)
TRUE, TRUE, wl->fixCurve->leftX, GTK_PACK_START); TRUE, TRUE, wl->fixCurve->leftX, GTK_PACK_START);
} }
static void redraw_curve(RS03Widgets *wl) static void redraw_curve(cairo_t *cr, RS03Widgets *wl)
{ int y; { int y;
/* Redraw the curve */ /* Redraw the curve */
GuiRedrawAxes(wl->fixCurve); GuiRedrawAxes(cr, wl->fixCurve);
GuiRedrawCurve(wl->fixCurve, wl->percent); GuiRedrawCurve(cr, wl->fixCurve, wl->percent);
/* Ecc capacity threshold line */ /* Ecc capacity threshold line */
y = GuiCurveY(wl->fixCurve, wl->eccBytes); y = GuiCurveY(wl->fixCurve, wl->eccBytes);
cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(wl->fixCurve->widget));
gdk_cairo_set_source_color(cr, Closure->greenSector); gdk_cairo_set_source_color(cr, Closure->greenSector);
cairo_set_line_width(cr, 1.0); cairo_set_line_width(cr, 1.0);
cairo_move_to(cr, wl->fixCurve->leftX-5.5, y+0.5); cairo_move_to(cr, wl->fixCurve->leftX-5.5, y+0.5);
@@ -252,13 +251,14 @@ static void redraw_curve(RS03Widgets *wl)
*/ */
static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data) static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
{ RS03Widgets *wl = (RS03Widgets*)data; { cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(widget)));
RS03Widgets *wl = (RS03Widgets*)data;
if(event->count) /* Exposure compression */ if(event->count) /* Exposure compression */
return TRUE; return TRUE;
update_geometry(wl); update_geometry(wl);
redraw_curve(wl); redraw_curve(cr, wl);
return TRUE; return TRUE;
} }

View File

@@ -110,15 +110,14 @@ void GuiFillSpiral(Spiral *spiral, GdkColor *color)
* Draw the whole spiral * Draw the whole spiral
*/ */
void GuiDrawSpiral(Spiral *spiral) void GuiDrawSpiral(cairo_t *cr, Spiral *spiral)
{ cairo_t *cr; { double a;
double a;
double xi0,yi0,xo0,yo0; double xi0,yi0,xo0,yo0;
double scale_i,scale_o; double scale_i,scale_o;
int i; int i;
if(!spiral->widget) return; if(!spiral->widget) return;
cr = gdk_cairo_create(gtk_widget_get_window(spiral->widget));
cairo_set_line_width(cr, 1.0); cairo_set_line_width(cr, 1.0);
scale_i = spiral->startRadius; scale_i = spiral->startRadius;
@@ -178,10 +177,9 @@ void GuiSetSpiralSegmentColor(Spiral *spiral, GdkColor *color, GdkColor *outline
* Draw a label above or below the spiral * Draw a label above or below the spiral
*/ */
void GuiDrawSpiralLabel(Spiral *spiral, PangoLayout *layout, void GuiDrawSpiralLabel(cairo_t *cr, Spiral *spiral, PangoLayout *layout,
char *text, GdkColor *color, int x, int line) char *text, GdkColor *color, int x, int line)
{ cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(spiral->widget)); { int w,h,y;
int w,h,y;
GuiSetText(layout, text, &w, &h); GuiSetText(layout, text, &w, &h);
if(line > 0) y = spiral->my + spiral->diameter / 2 + 20 + (line-1) * (10 + h); if(line > 0) y = spiral->my + spiral->diameter / 2 + 20 + (line-1) * (10 + h);