Get foreground color while drawing, don't bother with background
This commit is contained in:
committed by
Stéphane Lesimple
parent
d66ee15738
commit
9f583b1ffb
@@ -582,10 +582,6 @@ void InitClosure()
|
||||
g_mutex_init(Closure->logLock);
|
||||
|
||||
#ifdef WITH_GUI_YES
|
||||
Closure->background = g_malloc0(sizeof(GdkRGBA));
|
||||
Closure->foreground = g_malloc0(sizeof(GdkRGBA));
|
||||
Closure->grid = g_malloc0(sizeof(GdkRGBA));
|
||||
|
||||
Closure->redText = g_malloc0(sizeof(GdkRGBA));
|
||||
Closure->greenText = g_malloc0(sizeof(GdkRGBA));
|
||||
Closure->barColor = g_malloc0(sizeof(GdkRGBA));
|
||||
@@ -607,6 +603,10 @@ void InitClosure()
|
||||
DefaultLogFile();
|
||||
}
|
||||
|
||||
#ifdef WITH_GUI_YES
|
||||
GdkRGBA transparent = {0};
|
||||
#endif /* WITH_GUI_YES */
|
||||
|
||||
/*
|
||||
* Add some localized file name defaults.
|
||||
* Can't do this in InitClosure() as the locale has not been
|
||||
@@ -654,9 +654,6 @@ void FreeClosure()
|
||||
if(Closure->rawEditorContext)
|
||||
GuiFreeRawEditorContext(Closure->rawEditorContext);
|
||||
|
||||
cond_free(Closure->background);
|
||||
cond_free(Closure->foreground);
|
||||
cond_free(Closure->grid);
|
||||
cond_free(Closure->redText);
|
||||
cond_free(Closure->greenText);
|
||||
cond_free(Closure->barColor);
|
||||
|
||||
31
src/curve.c
31
src/curve.c
@@ -177,6 +177,15 @@ void GuiRedrawAxes(cairo_t *cr, Curve *curve)
|
||||
|
||||
cairo_set_line_cap(cr, CAIRO_LINE_CAP_SQUARE);
|
||||
cairo_set_line_width(cr, 1);
|
||||
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
|
||||
|
||||
/* Get foreground and grid colors */
|
||||
|
||||
GdkRGBA fg = {0};
|
||||
GtkStyleContext *context = gtk_widget_get_style_context(curve->widget);
|
||||
gtk_style_context_get_color(context, gtk_widget_get_state_flags(curve->widget), &fg);
|
||||
GdkRGBA grid = fg;
|
||||
grid.alpha = 0.25;
|
||||
|
||||
/* Draw and label the grid lines for the log curve */
|
||||
|
||||
@@ -200,18 +209,18 @@ void GuiRedrawAxes(cairo_t *cr, Curve *curve)
|
||||
gdk_cairo_set_source_rgba(cr, Closure->logColor);
|
||||
cairo_move_to(cr, curve->leftX-9-w, y-h/2);
|
||||
pango_cairo_show_layout(cr, curve->layout);
|
||||
gdk_cairo_set_source_rgba(cr, Closure->foreground);
|
||||
gdk_cairo_set_source_rgba(cr, &fg);
|
||||
cairo_move_to(cr, curve->leftX-6 + 0.5, y + 0.5);
|
||||
cairo_line_to(cr, curve->leftX + 0.5, y + 0.5);
|
||||
cairo_stroke(cr);
|
||||
gdk_cairo_set_source_rgba(cr, Closure->grid);
|
||||
gdk_cairo_set_source_rgba(cr, &grid);
|
||||
cairo_move_to(cr, curve->leftX + 0.5, y + 0.5);
|
||||
cairo_line_to(cr, curve->rightX + 0.5, y + 0.5);
|
||||
cairo_stroke(cr);
|
||||
|
||||
val /=2;
|
||||
y = GuiCurveLogY(curve, val);
|
||||
gdk_cairo_set_source_rgba(cr, Closure->foreground);
|
||||
gdk_cairo_set_source_rgba(cr, &fg);
|
||||
cairo_move_to(cr, curve->leftX-3 + 0.5, y + 0.5);
|
||||
cairo_line_to(cr, curve->leftX + 0.5, y + 0.5);
|
||||
cairo_stroke(cr);
|
||||
@@ -243,17 +252,17 @@ void GuiRedrawAxes(cairo_t *cr, Curve *curve)
|
||||
gdk_cairo_set_source_rgba(cr, Closure->curveColor);
|
||||
cairo_move_to(cr, curve->leftX-9-w, y-h/2);
|
||||
pango_cairo_show_layout(cr, curve->layout);
|
||||
gdk_cairo_set_source_rgba(cr, Closure->foreground);
|
||||
gdk_cairo_set_source_rgba(cr, &fg);
|
||||
cairo_move_to(cr, curve->leftX-6 + 0.5, y + 0.5);
|
||||
cairo_line_to(cr, curve->leftX + 0.5, y + 0.5);
|
||||
cairo_stroke(cr);
|
||||
|
||||
gdk_cairo_set_source_rgba(cr, Closure->grid);
|
||||
gdk_cairo_set_source_rgba(cr, &grid);
|
||||
cairo_move_to(cr, curve->leftX + 0.5, y + 0.5);
|
||||
cairo_line_to(cr, curve->rightX + 0.5, y + 0.5);
|
||||
cairo_stroke(cr);
|
||||
|
||||
gdk_cairo_set_source_rgba(cr, Closure->foreground);
|
||||
gdk_cairo_set_source_rgba(cr, &fg);
|
||||
y = GuiCurveY(curve, i+step/2);
|
||||
if(y >= curve->topY) {
|
||||
cairo_move_to(cr, curve->leftX-3 + 0.5, y + 0.5);
|
||||
@@ -264,7 +273,7 @@ void GuiRedrawAxes(cairo_t *cr, Curve *curve)
|
||||
|
||||
|
||||
/* Draw and label the left coordinate axis */
|
||||
gdk_cairo_set_source_rgba(cr, Closure->foreground);
|
||||
gdk_cairo_set_source_rgba(cr, &fg);
|
||||
|
||||
cairo_move_to(cr, curve->leftX + 0.5, curve->topY + 0.5);
|
||||
cairo_line_to(cr, curve->leftX + 0.5, curve->bottomY + 0.5);
|
||||
@@ -285,7 +294,7 @@ void GuiRedrawAxes(cairo_t *cr, Curve *curve)
|
||||
|
||||
/* Draw the right coordinate axis */
|
||||
|
||||
gdk_cairo_set_source_rgba(cr, Closure->foreground);
|
||||
gdk_cairo_set_source_rgba(cr, &fg);
|
||||
|
||||
cairo_move_to(cr, curve->rightX + 0.5, curve->topY + 0.5);
|
||||
cairo_line_to(cr, curve->rightX + 0.5, curve->bottomY + 0.5);
|
||||
@@ -299,7 +308,7 @@ void GuiRedrawAxes(cairo_t *cr, Curve *curve)
|
||||
|
||||
/* Draw and label the bottom coordinate axis */
|
||||
|
||||
gdk_cairo_set_source_rgba(cr, Closure->foreground);
|
||||
gdk_cairo_set_source_rgba(cr, &fg);
|
||||
|
||||
cairo_move_to(cr, curve->leftX + 0.5, curve->bottomY + 0.5);
|
||||
cairo_line_to(cr, curve->rightX + 0.5, curve->bottomY + 0.5);
|
||||
@@ -344,7 +353,7 @@ void GuiRedrawAxes(cairo_t *cr, Curve *curve)
|
||||
pango_cairo_show_layout(cr, curve->layout);
|
||||
|
||||
if(i && x < curve->rightX)
|
||||
{ gdk_cairo_set_source_rgba(cr, Closure->grid);
|
||||
{ gdk_cairo_set_source_rgba(cr, &grid);
|
||||
cairo_move_to(cr, x + 0.5, curve->bottomY-1 + 0.5);
|
||||
cairo_line_to(cr, x + 0.5, yg + 0.5);
|
||||
cairo_stroke(cr);
|
||||
@@ -356,7 +365,7 @@ void GuiRedrawAxes(cairo_t *cr, Curve *curve)
|
||||
}
|
||||
}
|
||||
|
||||
gdk_cairo_set_source_rgba(cr, Closure->foreground);
|
||||
gdk_cairo_set_source_rgba(cr, &fg);
|
||||
x = GuiCurveLX(curve,i+step/2)-1;
|
||||
if(x < curve->rightX) {
|
||||
cairo_move_to(cr, x + 0.5, bottom_y+3 + 0.5);
|
||||
|
||||
@@ -394,7 +394,6 @@ typedef struct _GlobalClosure
|
||||
/*** Common stuff for drawing curves and spirals */
|
||||
|
||||
gboolean colors_initialized;
|
||||
GdkRGBA *background,*foreground,*grid;
|
||||
GdkRGBA *redText;
|
||||
char *redMarkup;
|
||||
GdkRGBA *greenText;
|
||||
@@ -437,6 +436,10 @@ typedef struct _GlobalClosure
|
||||
extern GlobalClosure *Closure; /* these should be the only global variables! */
|
||||
extern int exitCode; /* value to use on exit() */
|
||||
|
||||
#ifdef WITH_GUI_YES
|
||||
extern GdkRGBA transparent;
|
||||
#endif /* WITH_GUI_YES */
|
||||
|
||||
/***
|
||||
***
|
||||
***/
|
||||
@@ -1537,7 +1540,7 @@ typedef struct _Spiral
|
||||
} Spiral;
|
||||
|
||||
#ifdef WITH_GUI_YES
|
||||
Spiral* GuiCreateSpiral(GdkRGBA*, GdkRGBA*, int, int, int);
|
||||
Spiral* GuiCreateSpiral(GdkRGBA*, int, int, int);
|
||||
void GuiSetSpiralWidget(Spiral*, GtkWidget*);
|
||||
void GuiFreeSpiral(Spiral*);
|
||||
|
||||
|
||||
@@ -548,9 +548,11 @@ static void render_sector(cairo_t *cr, raw_editor_context *rec)
|
||||
|
||||
if(!d) return;
|
||||
|
||||
gdk_cairo_set_source_rgba(cr, Closure->background);
|
||||
cairo_rectangle(cr, 0, 0, rec->daWidth, rec->daHeight);
|
||||
cairo_fill(cr);
|
||||
/* Get foreground color */
|
||||
|
||||
GdkRGBA fg = {0};
|
||||
GtkStyleContext *context = gtk_widget_get_style_context(rec->drawingArea);
|
||||
gtk_style_context_get_color(context, gtk_widget_get_state_flags(rec->drawingArea), &fg);
|
||||
|
||||
idx = 12;
|
||||
for(j=0,y=0; j<P_VECTOR_SIZE; j++, y+=rec->charHeight)
|
||||
@@ -580,7 +582,7 @@ static void render_sector(cairo_t *cr, raw_editor_context *rec)
|
||||
}
|
||||
}
|
||||
|
||||
gdk_cairo_set_source_rgba(cr, Closure->foreground);
|
||||
gdk_cairo_set_source_rgba(cr, &fg);
|
||||
|
||||
sprintf(byte, "%c", canprint(buf[idx]) ? buf[idx] : '.');
|
||||
idx++;
|
||||
|
||||
@@ -49,10 +49,6 @@ static int draw_text(cairo_t *cr, PangoLayout *l, char *text, int x, int y, GdkR
|
||||
{ erase_to = Closure->readAdaptiveSpiral->mx - Closure->readAdaptiveSpiral->diameter/2;
|
||||
pw = erase_to-x;
|
||||
|
||||
gdk_cairo_set_source_rgba(cr, Closure->background);
|
||||
cairo_rectangle(cr, x, y, pw, h);
|
||||
cairo_fill(cr);
|
||||
|
||||
gdk_cairo_set_source_rgba(cr, color);
|
||||
cairo_move_to(cr, x, y);
|
||||
pango_cairo_show_layout(cr, l);
|
||||
@@ -65,14 +61,20 @@ static void redraw_labels(cairo_t *cr, GtkWidget *widget, int erase_mask)
|
||||
{ char buf[256];
|
||||
int x,y,w,h;
|
||||
|
||||
/* Get foreground color */
|
||||
|
||||
GdkRGBA fg = {0};
|
||||
GtkStyleContext *context = gtk_widget_get_style_context(widget);
|
||||
gtk_style_context_get_color(context, gtk_widget_get_state_flags(widget), &fg);
|
||||
|
||||
/* Draw the labels */
|
||||
|
||||
x = 10;
|
||||
gdk_cairo_set_source_rgba(cr, Closure->foreground);
|
||||
gdk_cairo_set_source_rgba(cr, &fg);
|
||||
|
||||
y = Closure->readAdaptiveSpiral->my - Closure->readAdaptiveSpiral->diameter/2;
|
||||
h = draw_text(cr, Closure->readLinearCurve->layout,
|
||||
_("Adaptive reading:"), x, y, Closure->foreground, erase_mask & REDRAW_TITLE);
|
||||
_("Adaptive reading:"), x, y, &fg, erase_mask & REDRAW_TITLE);
|
||||
|
||||
y += h+h/2;
|
||||
if(Closure->readAdaptiveSubtitle)
|
||||
@@ -84,37 +86,37 @@ static void redraw_labels(cairo_t *cr, GtkWidget *widget, int erase_mask)
|
||||
if(*c) /* split text into two lines */
|
||||
{ *c = 0;
|
||||
h = draw_text(cr, Closure->readLinearCurve->layout,
|
||||
Closure->readAdaptiveSubtitle, x, y, Closure->foreground,
|
||||
Closure->readAdaptiveSubtitle, x, y, &fg,
|
||||
erase_mask & REDRAW_SUBTITLE);
|
||||
h = draw_text(cr, Closure->readLinearCurve->layout,
|
||||
c+1, x, y+h, Closure->foreground,
|
||||
c+1, x, y+h, &fg,
|
||||
erase_mask & REDRAW_SUBTITLE);
|
||||
*c = ' ';
|
||||
}
|
||||
else /* draw text in one line */
|
||||
{ h = draw_text(cr, Closure->readLinearCurve->layout,
|
||||
Closure->readAdaptiveSubtitle, x, y, Closure->foreground,
|
||||
Closure->readAdaptiveSubtitle, x, y, &fg,
|
||||
erase_mask & REDRAW_SUBTITLE);
|
||||
}
|
||||
}
|
||||
|
||||
y += 4*h;
|
||||
h = draw_text(cr, Closure->readLinearCurve->layout,
|
||||
_("Sectors processed"), x, y, Closure->foreground, erase_mask & REDRAW_TITLE);
|
||||
_("Sectors processed"), x, y, &fg, erase_mask & REDRAW_TITLE);
|
||||
|
||||
y += h;
|
||||
snprintf(buf, 255, " %s: %lld", _("readable"), readable);
|
||||
h = draw_text(cr, Closure->readLinearCurve->layout, buf, x, y, Closure->foreground,
|
||||
h = draw_text(cr, Closure->readLinearCurve->layout, buf, x, y, &fg,
|
||||
erase_mask & REDRAW_PROGRESS);
|
||||
|
||||
y += h;
|
||||
snprintf(buf, 255, " %s: %lld", _("correctable"), correctable);
|
||||
h = draw_text(cr, Closure->readLinearCurve->layout, buf, x, y, Closure->foreground,
|
||||
h = draw_text(cr, Closure->readLinearCurve->layout, buf, x, y, &fg,
|
||||
erase_mask & REDRAW_PROGRESS);
|
||||
|
||||
y += h;
|
||||
snprintf(buf, 255, " %s: %lld", _("missing"), missing);
|
||||
h = draw_text(cr, Closure->readLinearCurve->layout, buf, x, y, Closure->foreground,
|
||||
h = draw_text(cr, Closure->readLinearCurve->layout, buf, x, y, &fg,
|
||||
erase_mask & REDRAW_PROGRESS);
|
||||
|
||||
if(min_required > 0 && readable > 0)
|
||||
@@ -127,18 +129,18 @@ static void redraw_labels(cairo_t *cr, GtkWidget *widget, int erase_mask)
|
||||
snprintf(buf, 255, _("Readable: %d.%d%% / %d.%d%% required"),
|
||||
percent/10, percent%10,
|
||||
min_required/10, min_required%10);
|
||||
h = draw_text(cr, Closure->readLinearCurve->layout, buf, x, y, Closure->foreground,
|
||||
h = draw_text(cr, Closure->readLinearCurve->layout, buf, x, y, &fg,
|
||||
erase_mask & REDRAW_PROGRESS);
|
||||
}
|
||||
|
||||
y += h;
|
||||
snprintf(buf, 255, _("Total recoverable: %d.%d%%"), percent/10, percent%10);
|
||||
h = draw_text(cr, Closure->readLinearCurve->layout, buf, x, y, Closure->foreground,
|
||||
h = draw_text(cr, Closure->readLinearCurve->layout, buf, x, y, &fg,
|
||||
erase_mask & REDRAW_PROGRESS);
|
||||
|
||||
|
||||
if(Closure->readAdaptiveErrorMsg && erase_mask & REDRAW_ERRORMSG)
|
||||
{ gdk_cairo_set_source_rgba(cr, footer_color);
|
||||
{ gdk_cairo_set_source_rgba(cr, footer_color ? footer_color : &fg);
|
||||
|
||||
GuiSetText(Closure->readLinearCurve->layout, Closure->readAdaptiveErrorMsg, &w, &h);
|
||||
y = Closure->readAdaptiveSpiral->my + Closure->readAdaptiveSpiral->diameter/2 - h;
|
||||
@@ -184,14 +186,14 @@ static gboolean clip_idle_func(gpointer data)
|
||||
spiral->segmentClipping = spiral->segmentCount;
|
||||
|
||||
for(i=clipping; i < spiral->segmentCount; i++)
|
||||
GuiSetSpiralSegmentColor(spiral, Closure->background, Closure->background, i);
|
||||
GuiSetSpiralSegmentColor(spiral, &transparent, &transparent, i);
|
||||
|
||||
spiral->segmentClipping = clipping;
|
||||
|
||||
/* Now redraw the last turn */
|
||||
|
||||
for(i=ADAPTIVE_READ_SPIRAL_SIZE-300; i<=clipping; i++)
|
||||
GuiSetSpiralSegmentColor(spiral, Closure->background, 0, i);
|
||||
GuiSetSpiralSegmentColor(spiral, &transparent, 0, i);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
@@ -232,7 +234,7 @@ static gboolean remove_fill_idle_func(gpointer data)
|
||||
|
||||
for(i=0; i<spiral->segmentCount; i++)
|
||||
if(spiral->segmentColor[i] == Closure->whiteSector)
|
||||
GuiSetSpiralSegmentColor(spiral, Closure->background, 0, i);
|
||||
GuiSetSpiralSegmentColor(spiral, &transparent, 0, i);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@@ -298,7 +300,7 @@ void GuiUpdateAdaptiveResults(gint64 r, gint64 c, gint64 m, int p)
|
||||
***/
|
||||
|
||||
void GuiResetAdaptiveReadWindow()
|
||||
{ GuiFillSpiral(Closure->readAdaptiveSpiral, Closure->background);
|
||||
{ GuiFillSpiral(Closure->readAdaptiveSpiral, &transparent);
|
||||
// DrawSpiral(Closure->readAdaptiveSpiral);
|
||||
|
||||
if(Closure->readAdaptiveSubtitle)
|
||||
@@ -358,8 +360,7 @@ void GuiCreateAdaptiveReadWindow(GtkWidget *parent)
|
||||
g_signal_connect(G_OBJECT(d_area), "draw", G_CALLBACK(draw_cb), NULL);
|
||||
|
||||
Closure->readAdaptiveSpiral
|
||||
= GuiCreateSpiral(Closure->grid, Closure->background, 10, 5,
|
||||
ADAPTIVE_READ_SPIRAL_SIZE);
|
||||
= GuiCreateSpiral(&transparent, 10, 5, ADAPTIVE_READ_SPIRAL_SIZE);
|
||||
|
||||
gtk_widget_set_size_request(d_area, -1, Closure->readAdaptiveSpiral->diameter);
|
||||
}
|
||||
|
||||
@@ -1316,14 +1316,16 @@ void fill_gap(read_closure *rc)
|
||||
|
||||
/* Show progress in the spiral */
|
||||
|
||||
#ifdef WITH_GUI_YES
|
||||
if(Closure->guiMode)
|
||||
{ int segment = i / rc->sectorsPerSegment;
|
||||
|
||||
if(Closure->readAdaptiveSpiral->segmentColor[segment] == Closure->background)
|
||||
if(Closure->readAdaptiveSpiral->segmentColor[segment] == &transparent)
|
||||
{ GuiChangeSegmentColor(Closure->whiteSector, segment);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* WITH_GUI_YES */
|
||||
}
|
||||
|
||||
PrintCLI(" \n");
|
||||
rc->highestWrittenSector = rc->intervalStart-1;
|
||||
@@ -1845,7 +1847,7 @@ reread:
|
||||
if(rc->readMode != IMAGE_ONLY)
|
||||
{ PrintLog("%s", t);
|
||||
if(rc->ei)
|
||||
{ GuiSetAdaptiveReadFootline(t, Closure->foreground);
|
||||
{ GuiSetAdaptiveReadFootline(t, 0);
|
||||
}
|
||||
}
|
||||
if(Closure->eject)
|
||||
@@ -1995,7 +1997,7 @@ finished:
|
||||
PrintLog(_("\n%s\n"
|
||||
"(%" PRId64 " readable, %" PRId64 " correctable, %" PRId64 " still missing).\n"),
|
||||
t, rc->readable, rc->correctable, rc->expectedSectors-total);
|
||||
GuiSetAdaptiveReadFootline(t, Closure->foreground);
|
||||
GuiSetAdaptiveReadFootline(t, 0);
|
||||
|
||||
g_free(t);
|
||||
exitCode = EXIT_FAILURE;
|
||||
@@ -2007,7 +2009,7 @@ finished:
|
||||
{ if(rc->readable == rc->expectedSectors)
|
||||
{ char *t = _("\nGood! All sectors have been read.\n");
|
||||
PrintLog("%s", t);
|
||||
GuiSetAdaptiveReadFootline(t, Closure->foreground);
|
||||
GuiSetAdaptiveReadFootline(t, 0);
|
||||
if(Closure->eject)
|
||||
LoadMedium(rc->dh, FALSE);
|
||||
}
|
||||
@@ -2020,7 +2022,7 @@ finished:
|
||||
"%2d.%1d%% of the image have been read (%" PRId64 " sectors).\n"),
|
||||
t, percent/10, percent%10, rc->readable);
|
||||
|
||||
GuiSetAdaptiveReadFootline(t, Closure->foreground);
|
||||
GuiSetAdaptiveReadFootline(t, 0);
|
||||
g_free(t);
|
||||
exitCode = EXIT_FAILURE;
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ void GuiResetLinearReadWindow()
|
||||
gtk_notebook_set_current_page(GTK_NOTEBOOK(Closure->readLinearNotebook), 0);
|
||||
|
||||
GuiZeroCurve(Closure->readLinearCurve);
|
||||
GuiFillSpiral(Closure->readLinearSpiral, Closure->background);
|
||||
GuiFillSpiral(Closure->readLinearSpiral, &transparent);
|
||||
if (Closure->readLinearSpiral->widget)
|
||||
gtk_widget_queue_draw(Closure->readLinearSpiral->widget);
|
||||
}
|
||||
@@ -372,7 +372,7 @@ void GuiCreateLinearReadWindow(GtkWidget *parent)
|
||||
gtk_box_pack_start(GTK_BOX(hbox), curve, TRUE, TRUE, 0);
|
||||
g_signal_connect(G_OBJECT(curve), "draw", G_CALLBACK(draw_curve_cb), NULL);
|
||||
|
||||
Closure->readLinearSpiral = GuiCreateSpiral(Closure->grid, Closure->background, 10, 5, 1000);
|
||||
Closure->readLinearSpiral = GuiCreateSpiral(&transparent, 10, 5, 1000);
|
||||
spiral = gtk_drawing_area_new();
|
||||
gtk_widget_set_size_request(spiral, Closure->readLinearSpiral->diameter + 20, -1);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), spiral, FALSE, FALSE, 0);
|
||||
|
||||
@@ -55,7 +55,7 @@ void ResetRS01VerifyWindow(Method *self)
|
||||
|
||||
wl->lastPercent = 0;
|
||||
|
||||
GuiFillSpiral(wl->cmpSpiral, Closure->background);
|
||||
GuiFillSpiral(wl->cmpSpiral, &transparent);
|
||||
if (wl->cmpSpiral->widget)
|
||||
gtk_widget_queue_draw(wl->cmpSpiral->widget);
|
||||
}
|
||||
@@ -251,7 +251,7 @@ void CreateRS01VerifyWindow(Method *self, GtkWidget *parent)
|
||||
frame = gtk_frame_new(_utf("Image state"));
|
||||
gtk_table_attach(GTK_TABLE(table), frame, 1, 2, 0, 2, GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_FILL, 5, 5);
|
||||
|
||||
wl->cmpSpiral = GuiCreateSpiral(Closure->grid, Closure->background, 10, 5, VERIFY_IMAGE_SEGMENTS);
|
||||
wl->cmpSpiral = GuiCreateSpiral(&transparent, 10, 5, VERIFY_IMAGE_SEGMENTS);
|
||||
d_area = wl->cmpDrawingArea = gtk_drawing_area_new();
|
||||
gtk_widget_set_size_request(d_area, wl->cmpSpiral->diameter+20, -1);
|
||||
gtk_container_add(GTK_CONTAINER(frame), d_area);
|
||||
|
||||
@@ -58,7 +58,7 @@ void ResetRS02VerifyWindow(Method *self)
|
||||
|
||||
wl->lastPercent = 0;
|
||||
|
||||
GuiFillSpiral(wl->cmpSpiral, Closure->background);
|
||||
GuiFillSpiral(wl->cmpSpiral, &transparent);
|
||||
if (wl->cmpSpiral->widget)
|
||||
gtk_widget_queue_draw(wl->cmpSpiral->widget);
|
||||
}
|
||||
@@ -248,7 +248,7 @@ void CreateRS02VerifyWindow(Method *self, GtkWidget *parent)
|
||||
frame = gtk_frame_new(_utf("Image state"));
|
||||
gtk_table_attach(GTK_TABLE(table), frame, 1, 2, 0, 2, GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_FILL, 5, 5);
|
||||
|
||||
wl->cmpSpiral = GuiCreateSpiral(Closure->grid, Closure->background, 10, 5, VERIFY_IMAGE_SEGMENTS);
|
||||
wl->cmpSpiral = GuiCreateSpiral(&transparent, 10, 5, VERIFY_IMAGE_SEGMENTS);
|
||||
d_area = wl->cmpDrawingArea = gtk_drawing_area_new();
|
||||
gtk_widget_set_size_request(d_area, wl->cmpSpiral->diameter+20, -1);
|
||||
gtk_container_add(GTK_CONTAINER(frame), d_area);
|
||||
|
||||
@@ -68,7 +68,7 @@ void ResetRS03VerifyWindow(Method *self)
|
||||
|
||||
wl->lastPercent = 0;
|
||||
|
||||
GuiFillSpiral(wl->cmpSpiral, Closure->background);
|
||||
GuiFillSpiral(wl->cmpSpiral, &transparent);
|
||||
if (wl->cmpSpiral->widget)
|
||||
gtk_widget_queue_draw(wl->cmpSpiral->widget);
|
||||
}
|
||||
@@ -267,7 +267,7 @@ void CreateRS03VerifyWindow(Method *self, GtkWidget *parent)
|
||||
frame = gtk_frame_new(_utf("Image state"));
|
||||
gtk_table_attach(GTK_TABLE(table), frame, 1, 2, 0, 2, GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_FILL, 5, 5);
|
||||
|
||||
wl->cmpSpiral = GuiCreateSpiral(Closure->grid, Closure->background, 10, 5, VERIFY_IMAGE_SEGMENTS);
|
||||
wl->cmpSpiral = GuiCreateSpiral(&transparent, 10, 5, VERIFY_IMAGE_SEGMENTS);
|
||||
d_area = wl->cmpDrawingArea = gtk_drawing_area_new();
|
||||
gtk_widget_set_size_request(d_area, wl->cmpSpiral->diameter+20, -1);
|
||||
gtk_container_add(GTK_CONTAINER(frame), d_area);
|
||||
|
||||
30
src/spiral.c
30
src/spiral.c
@@ -34,8 +34,7 @@
|
||||
* Allocate and fill in the spiral data structure
|
||||
*/
|
||||
|
||||
Spiral* GuiCreateSpiral(GdkRGBA *outline, GdkRGBA *fill,
|
||||
int start_radius, int segment_size, int n_segments)
|
||||
Spiral* GuiCreateSpiral(GdkRGBA *fill, int start_radius, int segment_size, int n_segments)
|
||||
{ Spiral *spiral;
|
||||
double a = 0.0;
|
||||
double scale_o = start_radius + segment_size;
|
||||
@@ -59,7 +58,7 @@ Spiral* GuiCreateSpiral(GdkRGBA *outline, GdkRGBA *fill,
|
||||
{
|
||||
spiral->segmentPos[i] = a;
|
||||
spiral->segmentColor[i] = fill;
|
||||
spiral->segmentOutline[i] = outline;
|
||||
spiral->segmentOutline[i] = 0; /* foreground */
|
||||
|
||||
ring_expand = ((double)segment_size * a) / (2.0*M_PI);
|
||||
a += atan((double)segment_size / scale_o);
|
||||
@@ -119,6 +118,15 @@ void GuiDrawSpiral(cairo_t *cr, Spiral *spiral)
|
||||
if(!spiral->widget) return;
|
||||
|
||||
cairo_set_line_width(cr, 1.0);
|
||||
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
|
||||
|
||||
/* Get foreground and grid colors */
|
||||
|
||||
GdkRGBA fg = {0};
|
||||
GtkStyleContext *context = gtk_widget_get_style_context(spiral->widget);
|
||||
gtk_style_context_get_color(context, gtk_widget_get_state_flags(spiral->widget), &fg);
|
||||
GdkRGBA outline_default = fg;
|
||||
outline_default.alpha = 0.25;
|
||||
|
||||
scale_i = spiral->startRadius;
|
||||
scale_o = spiral->startRadius + spiral->segmentSize;
|
||||
@@ -140,7 +148,7 @@ void GuiDrawSpiral(cairo_t *cr, Spiral *spiral)
|
||||
yo1 = spiral->my + scale_o*sin(a);
|
||||
|
||||
|
||||
GdkRGBA *outline = spiral->segmentOutline[i] ? spiral->segmentOutline[i] : Closure->grid;
|
||||
GdkRGBA *outline = spiral->segmentOutline[i] ? spiral->segmentOutline[i] : &outline_default;
|
||||
|
||||
cairo_move_to(cr, xi0, yi0);
|
||||
cairo_line_to(cr, xo0, yo0);
|
||||
@@ -181,18 +189,28 @@ void GuiDrawSpiralLabel(cairo_t *cr, Spiral *spiral, PangoLayout *layout,
|
||||
char *text, GdkRGBA *color, int x, int line)
|
||||
{ int w,h,y;
|
||||
|
||||
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
|
||||
|
||||
/* Get foreground and grid colors */
|
||||
|
||||
GdkRGBA fg = {0};
|
||||
GtkStyleContext *context = gtk_widget_get_style_context(spiral->widget);
|
||||
gtk_style_context_get_color(context, gtk_widget_get_state_flags(spiral->widget), &fg);
|
||||
GdkRGBA outline = fg;
|
||||
outline.alpha = 0.25;
|
||||
|
||||
GuiSetText(layout, text, &w, &h);
|
||||
if(line > 0) y = spiral->my + spiral->diameter / 2 + 20 + (line-1) * (10 + h);
|
||||
else y = spiral->my - spiral->diameter / 2 - 20 - h + (line+1) * (10 + h);
|
||||
cairo_rectangle(cr, x + 0.5, y+(h-6)/2 + 0.5, 6, 6);
|
||||
gdk_cairo_set_source_rgba(cr, color);
|
||||
cairo_fill_preserve(cr);
|
||||
gdk_cairo_set_source_rgba(cr, Closure->grid);
|
||||
gdk_cairo_set_source_rgba(cr, &outline);
|
||||
cairo_set_line_width(cr, 1.0);
|
||||
cairo_stroke(cr);
|
||||
|
||||
cairo_move_to(cr, x+10, y);
|
||||
gdk_cairo_set_source_rgba(cr, Closure->foreground);
|
||||
gdk_cairo_set_source_rgba(cr, &fg);
|
||||
pango_cairo_show_layout(cr, layout);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,12 +45,6 @@ static gboolean draw_cb(GtkWidget *widget, cairo_t *cr, gpointer data)
|
||||
|
||||
if(!Closure->colors_initialized)
|
||||
{
|
||||
GdkRGBA fg = {0};
|
||||
GtkStyleContext *context = gtk_widget_get_style_context(widget);
|
||||
gtk_style_context_get_color(context, GTK_STATE_FLAG_NORMAL, &fg);
|
||||
*Closure->foreground = fg;
|
||||
*Closure->grid = fg;
|
||||
Closure->grid->alpha = 0.25;
|
||||
Closure->colors_initialized = TRUE;
|
||||
|
||||
/* Dirty trick for indenting the list:
|
||||
|
||||
Reference in New Issue
Block a user