Create cairo context in expose callback
This commit is contained in:
committed by
Stéphane Lesimple
parent
6dc80bb542
commit
5da5fa54dc
10
src/curve.c
10
src/curve.c
@@ -169,9 +169,8 @@ void GuiUpdateCurveGeometry(Curve *curve, char *largest_left_label, int right_pa
|
||||
*** Redraw the coordinate axes
|
||||
***/
|
||||
|
||||
void GuiRedrawAxes(Curve *curve)
|
||||
{ cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(curve->widget));
|
||||
int i,w,h,x,y;
|
||||
void GuiRedrawAxes(cairo_t *cr, Curve *curve)
|
||||
{ int i,w,h,x,y;
|
||||
int yg=0;
|
||||
int step;
|
||||
int bottom_y;
|
||||
@@ -369,9 +368,8 @@ void GuiRedrawAxes(Curve *curve)
|
||||
* Redraw the curve
|
||||
*/
|
||||
|
||||
void GuiRedrawCurve(Curve *curve, int last)
|
||||
{ cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(curve->widget));
|
||||
int i,x0,x1,fy0;
|
||||
void GuiRedrawCurve(cairo_t *cr, Curve *curve, int last)
|
||||
{ int i,x0,x1,fy0;
|
||||
|
||||
gdk_cairo_set_source_color(cr, Closure->curveColor);
|
||||
cairo_set_line_width(cr, 1.0);
|
||||
|
||||
@@ -692,8 +692,8 @@ int GuiCurveX(Curve*, gdouble);
|
||||
int GuiCurveY(Curve*, gdouble);
|
||||
int GuiCurveLogY(Curve*, gdouble);
|
||||
|
||||
void GuiRedrawAxes(Curve*);
|
||||
void GuiRedrawCurve(Curve*, int);
|
||||
void GuiRedrawAxes(cairo_t *cr, Curve*);
|
||||
void GuiRedrawCurve(cairo_t *cr, Curve*, int);
|
||||
#endif
|
||||
|
||||
/***
|
||||
@@ -1542,8 +1542,8 @@ void GuiSetSpiralWidget(Spiral*, GtkWidget*);
|
||||
void GuiFreeSpiral(Spiral*);
|
||||
|
||||
void GuiFillSpiral(Spiral*, GdkColor*);
|
||||
void GuiDrawSpiral(Spiral*);
|
||||
void GuiDrawSpiralLabel(Spiral*, PangoLayout*, char*, GdkColor*, int, int);
|
||||
void GuiDrawSpiral(cairo_t *cr, Spiral*);
|
||||
void GuiDrawSpiralLabel(cairo_t *cr, Spiral*, PangoLayout*, char*, GdkColor*, int, int);
|
||||
void GuiChangeSpiralCursor(Spiral*, int);
|
||||
void GuiMoveSpiralCursor(Spiral*, int);
|
||||
void GuiSetSpiralSegmentColor(Spiral*, GdkColor*, GdkColor*, int);
|
||||
|
||||
@@ -106,7 +106,7 @@ typedef struct _raw_editor_context
|
||||
} 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()
|
||||
{ raw_editor_context *rec = Closure->rawEditorContext;
|
||||
@@ -540,14 +540,13 @@ static void evaluate_vectors(raw_editor_context *rec)
|
||||
|
||||
/* 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);
|
||||
unsigned char *buf = rec->rb->recovered;
|
||||
int idx=0;
|
||||
int i,j,w,h,x,y;
|
||||
|
||||
if(!d) return;
|
||||
cairo_t *cr = gdk_cairo_create(d);
|
||||
|
||||
gdk_cairo_set_source_color(cr, Closure->background);
|
||||
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 */
|
||||
return TRUE;
|
||||
|
||||
cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(widget)));
|
||||
|
||||
evaluate_vectors(rec);
|
||||
render_sector(rec);
|
||||
render_sector(cr, rec);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -61,9 +61,8 @@ static int draw_text(cairo_t *cr, PangoLayout *l, char *text, int x, int y, GdkC
|
||||
return h;
|
||||
}
|
||||
|
||||
static void redraw_labels(GtkWidget *widget, int erase_mask)
|
||||
{ cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(Closure->readAdaptiveDrawingArea));
|
||||
char buf[256];
|
||||
static void redraw_labels(cairo_t *cr, GtkWidget *widget, int erase_mask)
|
||||
{ char buf[256];
|
||||
int x,y,w,h;
|
||||
|
||||
/* Draw the labels */
|
||||
@@ -161,15 +160,15 @@ static void update_geometry(GtkWidget *widget)
|
||||
/* Expose event handler */
|
||||
|
||||
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);
|
||||
|
||||
if(event->count) /* Exposure compression */
|
||||
return TRUE;
|
||||
|
||||
update_geometry(widget);
|
||||
redraw_labels(widget, ~0);
|
||||
GuiDrawSpiral(Closure->readAdaptiveSpiral);
|
||||
redraw_labels(cr, widget, ~0);
|
||||
GuiDrawSpiral(cr, Closure->readAdaptiveSpiral);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
*** Forward declarations
|
||||
***/
|
||||
|
||||
static void redraw_curve(void);
|
||||
static void redraw_curve(cairo_t *cr);
|
||||
static void update_geometry(void);
|
||||
|
||||
/***
|
||||
@@ -230,10 +230,10 @@ void GuiMarkExistingSectors(void)
|
||||
* Redraw the whole curve
|
||||
*/
|
||||
|
||||
static void redraw_curve(void)
|
||||
static void redraw_curve(cairo_t *cr)
|
||||
{
|
||||
GuiRedrawAxes(Closure->readLinearCurve);
|
||||
GuiRedrawCurve(Closure->readLinearCurve, 1000);
|
||||
GuiRedrawAxes(cr, Closure->readLinearCurve);
|
||||
GuiRedrawCurve(cr, Closure->readLinearCurve, 1000);
|
||||
}
|
||||
|
||||
/* Calculate the geometry of the curve */
|
||||
@@ -251,9 +251,8 @@ static void update_geometry(void)
|
||||
|
||||
}
|
||||
|
||||
static void redraw_spiral_labels(void)
|
||||
{ cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(Closure->readLinearSpiral->widget));
|
||||
int x,w,h;
|
||||
static void redraw_spiral_labels(cairo_t *cr)
|
||||
{ int x,w,h;
|
||||
int pos = 1;
|
||||
|
||||
/* Draw and label the spiral */
|
||||
@@ -265,36 +264,37 @@ static void redraw_spiral_labels(void)
|
||||
pango_cairo_show_layout(cr, Closure->readLinearCurve->layout);
|
||||
|
||||
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);
|
||||
|
||||
if(Closure->additionalSpiralColor == 3)
|
||||
GuiDrawSpiralLabel(Closure->readLinearSpiral, Closure->readLinearCurve->layout,
|
||||
GuiDrawSpiralLabel(cr, Closure->readLinearSpiral, Closure->readLinearCurve->layout,
|
||||
_("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++);
|
||||
|
||||
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++);
|
||||
|
||||
GuiDrawSpiralLabel(Closure->readLinearSpiral, Closure->readLinearCurve->layout,
|
||||
GuiDrawSpiralLabel(cr, Closure->readLinearSpiral, Closure->readLinearCurve->layout,
|
||||
_("Unreadable / skipped"), Closure->redSector, x, pos++);
|
||||
|
||||
GuiDrawSpiral(Closure->readLinearSpiral);
|
||||
GuiDrawSpiral(cr, Closure->readLinearSpiral);
|
||||
}
|
||||
|
||||
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();
|
||||
redraw_curve();
|
||||
redraw_curve(cr);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
redraw_spiral_labels();
|
||||
redraw_spiral_labels(cr);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -121,19 +121,19 @@ void RS01AddVerifyValues(Method *method, int percent,
|
||||
* 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;
|
||||
|
||||
GuiDrawSpiralLabel(wl->cmpSpiral, wl->cmpLayout,
|
||||
GuiDrawSpiralLabel(cr, wl->cmpSpiral, wl->cmpLayout,
|
||||
_("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);
|
||||
|
||||
GuiDrawSpiralLabel(wl->cmpSpiral, wl->cmpLayout,
|
||||
GuiDrawSpiralLabel(cr, wl->cmpSpiral, wl->cmpLayout,
|
||||
_("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)
|
||||
{ RS01Widgets *wl = (RS01Widgets*)data;
|
||||
{ cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(widget)));
|
||||
RS01Widgets *wl = (RS01Widgets*)data;
|
||||
GtkAllocation a = {0};
|
||||
gtk_widget_get_allocation(widget, &a);
|
||||
int w,h,size;
|
||||
@@ -165,7 +166,7 @@ static gboolean expose_cb(GtkWidget *widget, GdkEventExpose *event, gpointer dat
|
||||
|
||||
/* Redraw the spiral */
|
||||
|
||||
redraw_spiral(wl);
|
||||
redraw_spiral(cr, wl);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
*** Forward declarations
|
||||
***/
|
||||
|
||||
static void redraw_curve(RS01Widgets*);
|
||||
static void redraw_curve(cairo_t *cr, RS01Widgets*);
|
||||
static void update_geometry(RS01Widgets*);
|
||||
|
||||
/* Protected widget access */
|
||||
@@ -257,19 +257,18 @@ static void update_geometry(RS01Widgets *wl)
|
||||
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;
|
||||
|
||||
/* Redraw the curve */
|
||||
|
||||
GuiRedrawAxes(wl->fixCurve);
|
||||
GuiRedrawCurve(wl->fixCurve, wl->percent);
|
||||
GuiRedrawAxes(cr, wl->fixCurve);
|
||||
GuiRedrawCurve(cr, wl->fixCurve, wl->percent);
|
||||
|
||||
/* Ecc capacity threshold line */
|
||||
|
||||
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);
|
||||
cairo_set_line_width(cr, 1.0);
|
||||
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)
|
||||
{ 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 */
|
||||
{ return TRUE;
|
||||
}
|
||||
|
||||
update_geometry(wl);
|
||||
redraw_curve(wl);
|
||||
redraw_curve(cr, wl);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -114,19 +114,19 @@ static void add_verify_values(Method *method, int percent,
|
||||
* 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;
|
||||
|
||||
GuiDrawSpiralLabel(wl->cmpSpiral, wl->cmpLayout,
|
||||
GuiDrawSpiralLabel(cr, wl->cmpSpiral, wl->cmpLayout,
|
||||
_("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);
|
||||
|
||||
GuiDrawSpiralLabel(wl->cmpSpiral, wl->cmpLayout,
|
||||
GuiDrawSpiralLabel(cr, wl->cmpSpiral, wl->cmpLayout,
|
||||
_("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)
|
||||
{ RS02Widgets *wl = (RS02Widgets*)data;
|
||||
{ cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(widget)));
|
||||
RS02Widgets *wl = (RS02Widgets*)data;
|
||||
GtkAllocation a = {0};
|
||||
gtk_widget_get_allocation(widget, &a);
|
||||
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;
|
||||
|
||||
if(!event->count) /* Exposure compression */
|
||||
redraw_spiral(wl); /* Redraw the spiral */
|
||||
redraw_spiral(cr, wl); /* Redraw the spiral */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ extern gint64 CurrentMediumSize(int); /* from scsi-layer.h */
|
||||
*** Forward declarations
|
||||
***/
|
||||
|
||||
static void redraw_curve(RS02Widgets*);
|
||||
static void redraw_curve(cairo_t *cr, RS02Widgets*);
|
||||
static void update_geometry(RS02Widgets*);
|
||||
|
||||
/***
|
||||
@@ -197,19 +197,18 @@ static void update_geometry(RS02Widgets *wl)
|
||||
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;
|
||||
|
||||
/* Redraw the curve */
|
||||
|
||||
GuiRedrawAxes(wl->fixCurve);
|
||||
GuiRedrawCurve(wl->fixCurve, wl->percent);
|
||||
GuiRedrawAxes(cr, wl->fixCurve);
|
||||
GuiRedrawCurve(cr, wl->fixCurve, wl->percent);
|
||||
|
||||
/* Ecc capacity threshold line */
|
||||
|
||||
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);
|
||||
cairo_set_line_width(cr, 1.0);
|
||||
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)
|
||||
{ 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 */
|
||||
return TRUE;
|
||||
|
||||
update_geometry(wl);
|
||||
redraw_curve(wl);
|
||||
redraw_curve(cr, wl);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -124,19 +124,19 @@ static void add_verify_values(Method *method, int percent,
|
||||
* 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;
|
||||
|
||||
GuiDrawSpiralLabel(wl->cmpSpiral, wl->cmpLayout,
|
||||
GuiDrawSpiralLabel(cr, wl->cmpSpiral, wl->cmpLayout,
|
||||
_("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);
|
||||
|
||||
GuiDrawSpiralLabel(wl->cmpSpiral, wl->cmpLayout,
|
||||
GuiDrawSpiralLabel(cr, wl->cmpSpiral, wl->cmpLayout,
|
||||
_("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)
|
||||
{ RS03Widgets *wl = (RS03Widgets*)data;
|
||||
{ cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(widget)));
|
||||
RS03Widgets *wl = (RS03Widgets*)data;
|
||||
GtkAllocation a = {0};
|
||||
gtk_widget_get_allocation(widget, &a);
|
||||
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;
|
||||
|
||||
if(!event->count) /* Exposure compression */
|
||||
redraw_spiral(wl); /* Redraw the spiral */
|
||||
redraw_spiral(cr, wl); /* Redraw the spiral */
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
*** Forward declarations
|
||||
***/
|
||||
|
||||
static void redraw_curve(RS03Widgets*);
|
||||
static void redraw_curve(cairo_t *cr, RS03Widgets*);
|
||||
static void update_geometry(RS03Widgets*);
|
||||
|
||||
/***
|
||||
@@ -227,19 +227,18 @@ static void update_geometry(RS03Widgets *wl)
|
||||
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;
|
||||
|
||||
/* Redraw the curve */
|
||||
|
||||
GuiRedrawAxes(wl->fixCurve);
|
||||
GuiRedrawCurve(wl->fixCurve, wl->percent);
|
||||
GuiRedrawAxes(cr, wl->fixCurve);
|
||||
GuiRedrawCurve(cr, wl->fixCurve, wl->percent);
|
||||
|
||||
/* Ecc capacity threshold line */
|
||||
|
||||
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);
|
||||
cairo_set_line_width(cr, 1.0);
|
||||
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)
|
||||
{ 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 */
|
||||
return TRUE;
|
||||
|
||||
update_geometry(wl);
|
||||
redraw_curve(wl);
|
||||
redraw_curve(cr, wl);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
12
src/spiral.c
12
src/spiral.c
@@ -110,15 +110,14 @@ void GuiFillSpiral(Spiral *spiral, GdkColor *color)
|
||||
* Draw the whole spiral
|
||||
*/
|
||||
|
||||
void GuiDrawSpiral(Spiral *spiral)
|
||||
{ cairo_t *cr;
|
||||
double a;
|
||||
void GuiDrawSpiral(cairo_t *cr, Spiral *spiral)
|
||||
{ double a;
|
||||
double xi0,yi0,xo0,yo0;
|
||||
double scale_i,scale_o;
|
||||
int i;
|
||||
|
||||
if(!spiral->widget) return;
|
||||
cr = gdk_cairo_create(gtk_widget_get_window(spiral->widget));
|
||||
|
||||
cairo_set_line_width(cr, 1.0);
|
||||
|
||||
scale_i = spiral->startRadius;
|
||||
@@ -178,10 +177,9 @@ void GuiSetSpiralSegmentColor(Spiral *spiral, GdkColor *color, GdkColor *outline
|
||||
* 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)
|
||||
{ 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);
|
||||
if(line > 0) y = spiral->my + spiral->diameter / 2 + 20 + (line-1) * (10 + h);
|
||||
|
||||
Reference in New Issue
Block a user