[gnumeric] filter combos: improve rendering.



commit bee0ca4f803d5bcd2d50315089f2bfdb552f64ed
Author: Morten Welinder <terra gnome org>
Date:   Sat Feb 20 10:56:08 2021 -0500

    filter combos: improve rendering.

 NEWS                                |  1 +
 src/gnumeric.css                    | 17 +++++++----------
 src/widgets/ChangeLog               |  6 ++++++
 src/widgets/gnm-filter-combo-view.c | 35 +++++++++++++++++++++++++----------
 4 files changed, 39 insertions(+), 20 deletions(-)
---
diff --git a/NEWS b/NEWS
index f39f87110..bbf34939b 100644
--- a/NEWS
+++ b/NEWS
@@ -32,6 +32,7 @@ Morten:
        * Move from style regions to style classes in css.
        * Implement #ifdef for built-in css.
        * Dead kitten in css.
+       * Improve the drawing of filter combos.
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.48
diff --git a/src/gnumeric.css b/src/gnumeric.css
index 4412aac3d..0dccb84fb 100644
--- a/src/gnumeric.css
+++ b/src/gnumeric.css
@@ -242,17 +242,15 @@ pane GocLine.resize-guide {
    "row" or "col".  */
 pane GocLine.pane-resize-guide {
   color: #c0c0c0;
-  /* See also GnmPane */
 }
 
 
 /* Auto filter in two versions: the first one for "all", second for others.  */
-/* Not working: */
-arrow.auto-filter {
+button > *.auto-filter {
   color: black;
 }
-arrow.auto-filter:active {
-  color: yellow;
+button > *.auto-filter:active {
+  color: #ff6000;
 }
 
 #else
@@ -272,12 +270,11 @@ GtkDialog.fixed-format-ruler {
 }
 
 /* Auto filter in two versions: the first one for "all", second for others.  */
-GtkArrow.auto-filter {
+GtkDrawingArea.auto-filter {
   color: black;
 }
-
-GtkArrow.auto-filter:active {
-  color: yellow;
+GtkDrawingArea.auto-filter:active {
+  color: #ff6000;
 }
 
 /* Functions' arguments link-like appearance in pseudo-tooltips.  */
@@ -292,7 +289,7 @@ GtkDialog GtkTextView.function-help {
 /* The resize guide used when resizing columns or rows.  This can be
    subclassed with "row" or "col" as well as with "start" or "end".  */
 GnmPane GocLine.resize-guide {
-  color: yellow;
+  color: black;
   /* See also GnmPane */
 }
 
diff --git a/src/widgets/ChangeLog b/src/widgets/ChangeLog
index 1717a1ebc..119e10290 100644
--- a/src/widgets/ChangeLog
+++ b/src/widgets/ChangeLog
@@ -1,3 +1,9 @@
+2021-02-20  Morten Welinder  <terra gnome org>
+
+       * gnm-filter-combo-view.c (fcombo_create_arrow): Use a drawing
+       area and draw as an expander, not an arrow.  GtkArrow is
+       deprecated and is, in any case, not the right visual here.
+
 2020-08-12  Morten Welinder <terra gnome org>
 
        * Release 1.12.48
diff --git a/src/widgets/gnm-filter-combo-view.c b/src/widgets/gnm-filter-combo-view.c
index 87f3d1ade..08e758b55 100644
--- a/src/widgets/gnm-filter-combo-view.c
+++ b/src/widgets/gnm-filter-combo-view.c
@@ -285,30 +285,45 @@ fcombo_create_list (SheetObject *so,
 static void
 fcombo_arrow_format (GnmFilterCombo *fcombo, GtkWidget *arrow)
 {
-       if (gtk_widget_get_parent (arrow)) {
+       gboolean is_active = (fcombo->cond != NULL);
+       GtkWidget *button = gtk_widget_get_parent (arrow);
+
+       if (button) {
                char *desc = NULL;
-               if (NULL != fcombo->cond) {
+               if (is_active) {
+                       // Presumably we could cook up a description of the filter
+                       // here.
                }
                if (desc) {
-                       gtk_widget_set_tooltip_text (gtk_widget_get_parent (arrow), desc);
+                       gtk_widget_set_tooltip_text (button, desc);
                        g_free (desc);
                }
        }
 
-       gtk_arrow_set (GTK_ARROW (arrow),
-               fcombo->cond != NULL ? GTK_ARROW_RIGHT : GTK_ARROW_DOWN,
-               GTK_SHADOW_IN);
-       if (fcombo->cond)
-               gtk_widget_set_state_flags (arrow, GTK_STATE_FLAG_ACTIVE, FALSE);
+       if (is_active)
+               gtk_widget_set_state_flags (arrow, GTK_STATE_FLAG_ACTIVE | GTK_STATE_FLAG_CHECKED, FALSE);
        else
-               gtk_widget_unset_state_flags (arrow, GTK_STATE_FLAG_ACTIVE);
+               gtk_widget_unset_state_flags (arrow, GTK_STATE_FLAG_ACTIVE | GTK_STATE_FLAG_CHECKED);
+}
+
+static gboolean
+fcombo_draw_arrow (GtkWidget *widget, cairo_t *cr, gpointer data)
+{
+       GtkStyleContext *context = gtk_widget_get_style_context (widget);
+       guint width = gtk_widget_get_allocated_width (widget);
+       guint height = gtk_widget_get_allocated_height (widget);
+       gtk_render_background (context, cr, 0, 0, width, height);
+       gtk_render_expander (context, cr, 0, 0, width, height);
+       return FALSE;
 }
 
 static GtkWidget *
 fcombo_create_arrow (SheetObject *so)
 {
        GnmFilterCombo *fcombo = GNM_FILTER_COMBO (so);
-       GtkWidget *arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_IN);
+       GtkWidget *arrow = gtk_drawing_area_new ();
+       g_signal_connect (G_OBJECT (arrow), "draw",
+                         G_CALLBACK (fcombo_draw_arrow), NULL);
        gtk_style_context_add_class (gtk_widget_get_style_context (arrow),
                                     "auto-filter");
        fcombo_arrow_format (fcombo, arrow);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]