[goffice] Auto fill color made transparent for opened markers. [#691025]
- From: Jean Bréfort <jbrefort src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Auto fill color made transparent for opened markers. [#691025]
- Date: Wed, 1 Apr 2015 15:24:56 +0000 (UTC)
commit 16446e0a8fbbb501b8604ebce802914aa75309d7
Author: Jean Brefort <jean brefort normalesup org>
Date: Wed Apr 1 17:24:39 2015 +0200
Auto fill color made transparent for opened markers. [#691025]
ChangeLog | 14 ++++++++++++++
NEWS | 1 +
goffice/graph/gog-renderer.c | 18 ++++++++++++++++--
goffice/graph/gog-theme.c | 11 +----------
goffice/gtk/go-marker-selector.c | 21 ++++++++++++++++++++-
goffice/gtk/go-marker-selector.h | 2 ++
goffice/utils/go-marker.c | 14 ++++++++++++++
goffice/utils/go-marker.h | 1 +
goffice/utils/go-style.c | 2 ++
9 files changed, 71 insertions(+), 13 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a1dd7ab..64bfcda 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2015-04-01 Jean Brefort <jean brefort normalesup org>
+
+ * goffice/graph/gog-renderer.c (_get_marker_surface),
+ (gog_renderer_draw_marker), (_free_marker_data): auto fill color made
+ transparent for opened markers (x, +, and *). [#691025]
+ * goffice/graph/gog-theme.c (map_marker): ditto.
+ * goffice/gtk/go-marker-selector.c (go_marker_palette_render_func),
+ (go_marker_selector_set_shape), (go_marker_selector_set_auto_fill): ditto.
+ * goffice/gtk/go-marker-selector.h: ditto.
+ * goffice/utils/go-marker.c (go_marker_is_closed_shape): ditto.
+ * goffice/utils/go-marker.h: ditto.
+ * goffice/utils/go-style.c (cb_marker_fill_color_changed),
+ (marker_init): ditto.
+
2015-03-31 Morten Welinder <terra gnome org>
* goffice/graph/gog-object-xml.c (gog_dtd): Remove duplicate node.
diff --git a/NEWS b/NEWS
index 0f1b899..eb865a6 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ Jean:
* Fix selection of axes using only part fo the plot area. [#746456]
* Protect colored xy and bubble plots against NULL z values.
* Update circular axis bounds after a unit change. [#746738]
+ * Auto fill color made transparent for opened markers. [#691025]
Johannes Deutsch:
* Do not draw the line over the arrow head at start. [#745736]
diff --git a/goffice/graph/gog-renderer.c b/goffice/graph/gog-renderer.c
index ec70363..1677151 100644
--- a/goffice/graph/gog-renderer.c
+++ b/goffice/graph/gog-renderer.c
@@ -94,6 +94,7 @@ struct _GogRenderer {
gboolean marker_as_surface;
cairo_surface_t *marker_surface;
double marker_offset;
+ GOMarker *marker;
};
typedef struct {
@@ -777,7 +778,7 @@ gog_renderer_draw_selection_rectangle (GogRenderer *renderer, GogViewAllocation
static cairo_surface_t *
_get_marker_surface (GogRenderer *rend)
{
- GOMarker *marker = rend->cur_style->marker.mark;
+ GOMarker *marker = rend->marker;
double width;
if (rend->marker_surface != NULL)
@@ -803,8 +804,17 @@ gog_renderer_draw_marker (GogRenderer *rend, double x, double y)
g_return_if_fail (GOG_IS_RENDERER (rend));
g_return_if_fail (rend->cur_style != NULL);
+ if (rend->marker == NULL) {
+ if (rend->cur_style->marker.auto_fill_color &&
+ !go_marker_is_closed_shape (rend->cur_style->marker.mark)) {
+ rend->marker = go_marker_dup (rend->cur_style->marker.mark);
+ go_marker_set_fill_color (rend->marker, 0);
+ } else
+ rend->marker = g_object_ref (rend->cur_style->marker.mark);
+ }
+
if (rend->is_vector && !rend->marker_as_surface) {
- go_marker_render (rend->cur_style->marker.mark, rend->cairo,
+ go_marker_render (rend->marker, rend->cairo,
x, y, rend->scale);
return;
}
@@ -1262,6 +1272,10 @@ _free_marker_data (GogRenderer *rend)
cairo_surface_destroy (rend->marker_surface);
rend->marker_surface = NULL;
}
+ if (rend->marker) {
+ g_object_unref (rend->marker);
+ rend->marker = NULL;
+ }
}
void
diff --git a/goffice/graph/gog-theme.c b/goffice/graph/gog-theme.c
index 23582f1..d9d7d4d 100644
--- a/goffice/graph/gog-theme.c
+++ b/goffice/graph/gog-theme.c
@@ -1024,13 +1024,6 @@ map_marker (GOStyleMark *mark, unsigned shape, unsigned palette_index,
GO_MARKER_CROSS, GO_MARKER_HALF_BAR,
GO_MARKER_BAR
};
- static gboolean const shape_is_fill_transparent [] = {
- TRUE, TRUE,
- TRUE, FALSE,
- FALSE, TRUE,
- FALSE, TRUE,
- TRUE
- };
if (shape >= G_N_ELEMENTS (shape_palette))
shape %= G_N_ELEMENTS (shape_palette);
@@ -1041,9 +1034,7 @@ map_marker (GOStyleMark *mark, unsigned shape, unsigned palette_index,
go_marker_set_outline_color (mark->mark,
palette [palette_index]);
if (mark->auto_fill_color)
- go_marker_set_fill_color (mark->mark,
- shape_is_fill_transparent [shape]
- ? palette [palette_index] : 0);
+ go_marker_set_fill_color (mark->mark, palette [palette_index]);
}
static GOColor const default_palette [] = {
diff --git a/goffice/gtk/go-marker-selector.c b/goffice/gtk/go-marker-selector.c
index 0e464d6..2ba5a78 100644
--- a/goffice/gtk/go-marker-selector.c
+++ b/goffice/gtk/go-marker-selector.c
@@ -26,6 +26,7 @@
typedef struct {
GOColor outline_color;
GOColor fill_color;
+ gboolean auto_fill;
} GOMarkerSelectorState;
static void
@@ -42,10 +43,10 @@ go_marker_palette_render_func (cairo_t *cr,
return;
marker = go_marker_new ();
- go_marker_set_fill_color (marker, state->fill_color);
go_marker_set_outline_color (marker, state->outline_color);
go_marker_set_size (marker, size);
go_marker_set_shape (marker, index);
+ go_marker_set_fill_color (marker, (state->auto_fill && !go_marker_is_closed_shape (marker))? 0:
state->fill_color);
cairo_set_line_width (cr, 1);
cairo_set_source_rgb (cr, 1., 1., 1.);
@@ -129,3 +130,21 @@ go_marker_selector_set_shape (GOSelector *selector, GOMarkerShape shape)
CLAMP (shape, 0, GO_MARKER_MAX - 1));
go_selector_update_swatch (selector);
}
+
+
+/**
+ * go_marker_selector_set_auto_fill:
+ * @selector: a #GOSelector
+ * @auto_fill: whether to use a transparent color for opened markers such as
+ * cross, x, or asterisk.
+ *
+ **/
+void
+go_marker_selector_set_auto_fill (GOSelector *selector, gboolean auto_fill)
+{
+ GOMarkerSelectorState *state;
+ g_return_if_fail (GO_IS_SELECTOR (selector));
+ state = go_selector_get_user_data (selector);
+ g_return_if_fail (state != NULL);
+ state->auto_fill = auto_fill;
+}
diff --git a/goffice/gtk/go-marker-selector.h b/goffice/gtk/go-marker-selector.h
index e5bf59c..1628ce3 100644
--- a/goffice/gtk/go-marker-selector.h
+++ b/goffice/gtk/go-marker-selector.h
@@ -33,6 +33,8 @@ void go_marker_selector_set_colors (GOSelector *selector,
GOColor fill);
void go_marker_selector_set_shape (GOSelector *selector,
GOMarkerShape shape);
+void go_marker_selector_set_auto_fill (GOSelector *selector,
+ gboolean auto_fill);
G_END_DECLS
diff --git a/goffice/utils/go-marker.c b/goffice/utils/go-marker.c
index 38ff3e0..71e2f5c 100644
--- a/goffice/utils/go-marker.c
+++ b/goffice/utils/go-marker.c
@@ -171,6 +171,20 @@ go_marker_set_shape (GOMarker *marker, GOMarkerShape shape)
marker->shape = shape;
}
+gboolean
+go_marker_is_closed_shape (GOMarker const *m)
+{
+ g_return_val_if_fail (GO_IS_MARKER (m), FALSE);
+ switch (m->shape) {
+ case GO_MARKER_X:
+ case GO_MARKER_CROSS:
+ case GO_MARKER_ASTERISK:
+ return FALSE;
+ default:
+ return TRUE;
+ }
+}
+
GOColor
go_marker_get_outline_color (GOMarker const *marker)
{
diff --git a/goffice/utils/go-marker.h b/goffice/utils/go-marker.h
index a13a447..f995bd2 100644
--- a/goffice/utils/go-marker.h
+++ b/goffice/utils/go-marker.h
@@ -56,6 +56,7 @@ GOMarkerShape go_marker_shape_from_str (char const *name);
char const *go_marker_shape_as_str (GOMarkerShape shape);
GOMarkerShape go_marker_get_shape (GOMarker const *m);
void go_marker_set_shape (GOMarker *m, GOMarkerShape shape);
+gboolean go_marker_is_closed_shape (GOMarker const *m);
GOColor go_marker_get_outline_color (GOMarker const *m);
void go_marker_set_outline_color (GOMarker *m, GOColor color);
GOColor go_marker_get_fill_color (GOMarker const *m);
diff --git a/goffice/utils/go-style.c b/goffice/utils/go-style.c
index f0f7372..ab6310d 100644
--- a/goffice/utils/go-style.c
+++ b/goffice/utils/go-style.c
@@ -787,6 +787,7 @@ cb_marker_fill_color_changed (GOSelector *selector,
color = go_color_selector_get_color (selector, &is_auto);
go_marker_set_fill_color (style->marker.mark, color);
style->marker.auto_fill_color = is_auto;
+ go_marker_selector_set_auto_fill (GO_SELECTOR (state->marker.selector), is_auto);
set_style (state);
go_marker_selector_set_colors (GO_SELECTOR (state->marker.selector),
@@ -831,6 +832,7 @@ marker_init (StylePrefState *state, gboolean enable, GOEditor *editor, GOCmdCont
else
go_marker_selector_set_colors (GO_SELECTOR (selector),
GO_COLOR_BLUE, GO_COLOR_BLUE);
+ go_marker_selector_set_auto_fill (GO_SELECTOR (selector), style->marker.auto_fill_color);
w = go_gtk_builder_get_widget (gui, "marker_shape_label");
gtk_label_set_mnemonic_widget (GTK_LABEL (w), selector);
gtk_grid_attach (GTK_GRID (grid), selector, 1, 1, 1, 1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]