[gnumeric] GUI: Allow styling of cell extension indicators.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] GUI: Allow styling of cell extension indicators.
- Date: Thu, 27 Jan 2022 22:28:18 +0000 (UTC)
commit 4d9798aa41092c49c1239a29adf98a29c91852e4
Author: Morten Welinder <terra gnome org>
Date: Thu Jan 27 17:28:01 2022 -0500
GUI: Allow styling of cell extension indicators.
NEWS | 2 ++
src/cell-draw.c | 57 +++++++++++++++++++++++++++++++++---------------------
src/cell-draw.h | 8 +++++++-
src/gnm-pane.c | 10 ++++++++++
src/gnumeric.css | 7 +++++++
src/item-grid.c | 23 +++++++++++++++++-----
src/preview-grid.c | 2 +-
src/wbc-gtk.c | 2 +-
8 files changed, 81 insertions(+), 30 deletions(-)
---
diff --git a/NEWS b/NEWS
index 0b568e60d..a63c9f4eb 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ Morten:
* Improve the toolbar styling a bit.
* Fix toolbar overflow menu's labeling.
* Many improvements to vertical toolbars.
+ * Install appdata file in new location [#612]
+ * Allow styling of cell extension indicators.
--------------------------------------------------------------------------
Gnumeric 1.12.51
diff --git a/src/cell-draw.c b/src/cell-draw.c
index 6500c2517..e7e52fcd8 100644
--- a/src/cell-draw.c
+++ b/src/cell-draw.c
@@ -331,37 +331,43 @@ cell_finish_layout (GnmCell *cell, GnmRenderedValue *rv,
static void
-cell_draw_extension_mark_bottom (cairo_t *cr, int x1, int y1, int height, int h_center)
+cell_draw_extension_mark_bottom (cairo_t *cr, GnmCellDrawStyle const *style,
+ int x1, int y1, int height, int h_center)
{
- cairo_set_source_rgba (cr, 1, 0, 0, 0.7);
+ double s = style->extension_marker_size;
+ gdk_cairo_set_source_rgba (cr, &style->extension_marker_color);
cairo_new_path (cr);
cairo_move_to (cr, x1 + h_center, y1 + height);
- cairo_rel_line_to (cr, -3, -3);
- cairo_rel_line_to (cr, 6, 0);
+ cairo_rel_line_to (cr, s / -2, s / -2);
+ cairo_rel_line_to (cr, s, 0);
cairo_close_path (cr);
cairo_fill (cr);
}
static void
-cell_draw_extension_mark_left (cairo_t *cr, int x1, int y1, int height)
+cell_draw_extension_mark_left (cairo_t *cr, GnmCellDrawStyle const *style,
+ int x1, int y1, int height)
{
- cairo_set_source_rgba (cr, 1, 0, 0, 0.7);
+ double s = style->extension_marker_size;
+ gdk_cairo_set_source_rgba (cr, &style->extension_marker_color);
cairo_new_path (cr);
cairo_move_to (cr, x1, y1 + height/2);
- cairo_rel_line_to (cr, 3, -3);
- cairo_rel_line_to (cr, 0, 6);
+ cairo_rel_line_to (cr, s / 2, s / -2);
+ cairo_rel_line_to (cr, 0, s);
cairo_close_path (cr);
cairo_fill (cr);
}
static void
-cell_draw_extension_mark_right (cairo_t *cr, int x1, int y1, int width, int height)
+cell_draw_extension_mark_right (cairo_t *cr, GnmCellDrawStyle const *style,
+ int x1, int y1, int width, int height)
{
- cairo_set_source_rgba (cr, 1, 0, 0, 0.7);
+ double s = style->extension_marker_size;
+ gdk_cairo_set_source_rgba (cr, &style->extension_marker_color);
cairo_new_path (cr);
cairo_move_to (cr, x1 + width, y1 + height/2);
- cairo_rel_line_to (cr, -3, -3);
- cairo_rel_line_to (cr, 0, 6);
+ cairo_rel_line_to (cr, s / -2, s / -2);
+ cairo_rel_line_to (cr, 0, s);
cairo_close_path (cr);
cairo_fill (cr);
@@ -369,23 +375,25 @@ cell_draw_extension_mark_right (cairo_t *cr, int x1, int y1, int width, int heig
static void
-cell_draw_h_extension_markers (cairo_t *cr, GnmRenderedValue *rv,
+cell_draw_h_extension_markers (cairo_t *cr,
+ GnmCellDrawStyle const *style,
+ GnmRenderedValue *rv,
int x1, int y1,
int width, int height)
{
switch (rv->effective_halign) {
case GNM_HALIGN_GENERAL:
case GNM_HALIGN_LEFT:
- cell_draw_extension_mark_right (cr, x1, y1, width, height);
+ cell_draw_extension_mark_right (cr, style, x1, y1, width, height);
break;
case GNM_HALIGN_RIGHT:
- cell_draw_extension_mark_left (cr, x1, y1, height);
+ cell_draw_extension_mark_left (cr, style, x1, y1, height);
break;
case GNM_HALIGN_DISTRIBUTED:
case GNM_HALIGN_CENTER:
case GNM_HALIGN_CENTER_ACROSS_SELECTION:
- cell_draw_extension_mark_right (cr, x1, y1, width, height);
- cell_draw_extension_mark_left (cr, x1, y1, height);
+ cell_draw_extension_mark_right (cr, style, x1, y1, width, height);
+ cell_draw_extension_mark_left (cr, style, x1, y1, height);
break;
case GNM_HALIGN_FILL:
default:
@@ -395,13 +403,14 @@ cell_draw_h_extension_markers (cairo_t *cr, GnmRenderedValue *rv,
static void
cell_draw_v_extension_markers (cairo_t *cr,
+ GnmCellDrawStyle const *style,
int x1, int y1,
int width, int height,
int h_center)
{
if (h_center == -1)
h_center = width / 2;
- cell_draw_extension_mark_bottom (cr, x1, y1, height, h_center);
+ cell_draw_extension_mark_bottom (cr, style, x1, y1, height, h_center);
}
/**
@@ -413,18 +422,21 @@ cell_draw_v_extension_markers (cairo_t *cr,
* @width: including margins and leading grid line
* @height: including margins and leading grid line
* @h_center:
- * @show_extension_markers:
+ * @style: (nullable):
**/
void
cell_draw (GnmCell const *cell, cairo_t *cr,
int x1, int y1, int width, int height, int h_center,
- gboolean show_extension_markers)
+ gboolean show_extension_markers,
+ GnmCellDrawStyle const *style)
{
GOColor fore_color;
gint x;
gint y;
GnmRenderedValue *rv;
+ g_return_if_fail (!show_extension_markers || style != NULL);
+
/* Get the sizes exclusive of margins and grids */
/* Note: +1 because size_pixels includes leading gridline. */
height -= GNM_ROW_MARGIN + GNM_ROW_MARGIN + 1;
@@ -485,7 +497,7 @@ cell_draw (GnmCell const *cell, cairo_t *cr,
width < PANGO_PIXELS (rv->layout_natural_width)) {
cairo_save (cr);
cell_draw_h_extension_markers
- (cr, rv,
+ (cr, style, rv,
x1 + 1 + GNM_COL_MARGIN,
y1 + 1 + GNM_ROW_MARGIN,
width, height);
@@ -496,7 +508,8 @@ cell_draw (GnmCell const *cell, cairo_t *cr,
height < PANGO_PIXELS (rv->layout_natural_height)) {
cairo_save (cr);
cell_draw_v_extension_markers
- (cr, x1 + 1 + GNM_COL_MARGIN,
+ (cr, style,
+ x1 + 1 + GNM_COL_MARGIN,
y1 + 1 + GNM_ROW_MARGIN,
width, height, h_center);
cairo_restore (cr);
diff --git a/src/cell-draw.h b/src/cell-draw.h
index efc1e7650..bfe16be9b 100644
--- a/src/cell-draw.h
+++ b/src/cell-draw.h
@@ -13,9 +13,15 @@ void cell_finish_layout (GnmCell *cell, GnmRenderedValue *rv,
int col_width,
gboolean inhibit_overflow);
+typedef struct {
+ GdkRGBA extension_marker_color;
+ int extension_marker_size;
+} GnmCellDrawStyle;
+
void cell_draw (GnmCell const *cell, cairo_t* cr,
int x, int y, int height, int width, int h_center,
- gboolean show_extension_markers);
+ gboolean show_extension_markers,
+ GnmCellDrawStyle const *style);
G_END_DECLS
diff --git a/src/gnm-pane.c b/src/gnm-pane.c
index 26e432a6e..514a6e793 100644
--- a/src/gnm-pane.c
+++ b/src/gnm-pane.c
@@ -990,6 +990,16 @@ gnm_pane_class_init (GnmPaneClass *klass)
10,
G_PARAM_READABLE));
+ gtk_widget_class_install_style_property
+ (widget_class,
+ g_param_spec_int ("extension-indicator-size",
+ P_("Extension Indicator Size"),
+ P_("Size of cell extension indicator"),
+ 0,
+ G_MAXINT,
+ 100,
+ G_PARAM_READABLE));
+
gtk_widget_class_install_style_property
(widget_class,
g_param_spec_int ("comment-indicator-size",
diff --git a/src/gnumeric.css b/src/gnumeric.css
index 68aa6015c..6dfe3d8f0 100644
--- a/src/gnumeric.css
+++ b/src/gnumeric.css
@@ -7,6 +7,7 @@ GnmPane,
pane {
-GnmPane-function-indicator-size: 10px;
-GnmPane-comment-indicator-size: 6px;
+ -GnmPane-extension-indicator-size: 12px;
-GnmPane-resize-guide-width: 1px;
-GnmPane-pane-resize-guide-width: 7px;
-GnmPane-control-circle-size: 5px;
@@ -45,6 +46,12 @@ GnmItemGrid.function-marker {
/* Size defined for GnmPane */
}
+/* Extension markers are enabled from View->View Properties->Cell Markers */
+GnmItemGrid.extension-marker {
+ color: rgba(255,0,0,0.7);
+ /* Size defined for GnmPane */
+}
+
/* This is the divider between panes when an area is frozen. */
GnmItemGrid.pane-divider {
color: #333333;
diff --git a/src/item-grid.c b/src/item-grid.c
index ed121b83e..b31c18170 100644
--- a/src/item-grid.c
+++ b/src/item-grid.c
@@ -85,6 +85,7 @@ struct _GnmItemGrid {
GdkRGBA pane_divider_color;
int pane_divider_width;
+ GnmCellDrawStyle cell_draw_style;
};
typedef GocItemClass GnmItemGridClass;
static GocItemClass *parent_class;
@@ -114,6 +115,13 @@ ig_reload_style (GnmItemGrid *ig)
gnm_css_debug_color ("function-marker.border-border", &ig->function_marker_border_color);
gtk_style_context_restore (context);
+ gtk_style_context_save (context);
+ gtk_style_context_add_class (context, "extension-marker");
+ gnm_style_context_get_color (context, GTK_STATE_FLAG_NORMAL,
+ &ig->cell_draw_style.extension_marker_color);
+ gnm_css_debug_color ("extension-marker.color", &ig->cell_draw_style.extension_marker_color);
+ gtk_style_context_restore (context);
+
gtk_style_context_save (context);
gtk_style_context_add_class (context, "pane-divider");
gnm_style_context_get_color (context, GTK_STATE_FLAG_NORMAL,
@@ -132,6 +140,12 @@ ig_reload_style (GnmItemGrid *ig)
&ig->function_marker_size,
NULL);
gnm_css_debug_int ("function-marker.size", ig->function_marker_size);
+
+ gtk_widget_style_get (GTK_WIDGET (pane),
+ "extension-indicator-size",
+ &ig->cell_draw_style.extension_marker_size,
+ NULL);
+ gnm_css_debug_int ("extension-marker.size", ig->cell_draw_style.extension_marker_size);
}
static void
@@ -364,14 +378,14 @@ item_grid_draw_merged_range (cairo_t *cr, GnmItemGrid *ig,
r - l, b - t, dir);
cell_draw (cell, cr,
l, t, r - l, b - t, -1,
- show_extension_markers);
+ show_extension_markers, &ig->cell_draw_style);
} else {
if (show_function_cell_markers)
draw_function_marker (ig, cell, cr, r, t,
l - r, b - t, dir);
cell_draw (cell, cr,
r, t, l - r, b - t, -1,
- show_extension_markers);
+ show_extension_markers, &ig->cell_draw_style);
}
}
if (dir > 0)
@@ -754,7 +768,7 @@ plain_draw : /* a quick hack to deal with 142267 */
cell_draw (cell, cr,
x, y, ci->size_pixels,
ri->size_pixels, -1,
- show_extension_markers);
+ show_extension_markers, &ig->cell_draw_style);
}
/* Only draw spaning cells after all the backgrounds
* that we are going to draw have been drawn. No need
@@ -811,8 +825,7 @@ plain_draw : /* a quick hack to deal with 142267 */
cell_draw (cell, cr,
real_x, y, tmp_width,
ri->size_pixels, center_offset,
- show_extension_markers);
-
+ show_extension_markers, &ig->cell_draw_style);
} else if (col != span->left)
sr.vertical [col] = NULL;
diff --git a/src/preview-grid.c b/src/preview-grid.c
index c42eb36a2..bfbd1ecd1 100644
--- a/src/preview-grid.c
+++ b/src/preview-grid.c
@@ -270,7 +270,7 @@ preview_grid_draw_region (GocItem const *item, cairo_t *cr,
if (!gnm_cell_is_empty (cell))
cell_draw (cell, cr,
x, y, colwidths[col], row_height,
- -1, FALSE);
+ -1, FALSE, NULL);
x += colwidths[col];
}
diff --git a/src/wbc-gtk.c b/src/wbc-gtk.c
index 01acb1dd0..366c6f263 100644
--- a/src/wbc-gtk.c
+++ b/src/wbc-gtk.c
@@ -2426,7 +2426,7 @@ cb_screen_changed (GtkWidget *widget)
data->screens = NULL;
if (debug)
- g_printerr ("Loading style from %s\n", resource);
+ g_printerr ("Loading style from resource %s\n", resource);
else
g_signal_connect (data->css, "parsing-error",
G_CALLBACK (cb_css_parse_error),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]