[gnumeric] GUI: Theme col/row/pane resizing.



commit bbdf3881229affe8d1a4714b6779e8f9c27f26ac
Author: Morten Welinder <terra gnome org>
Date:   Wed Mar 27 11:43:47 2013 -0400

    GUI: Theme col/row/pane resizing.

 src/gnm-pane.c          |   79 ++++++++++++++++++++++++++++++++--------------
 src/gnm-pane.h          |    2 +-
 src/gnumeric.css        |   35 ++++++++++++++++-----
 src/item-bar.c          |    4 ++-
 src/sheet-control-gui.c |    7 ++--
 src/sheet-control-gui.h |    2 +-
 6 files changed, 91 insertions(+), 38 deletions(-)
---
diff --git a/src/gnm-pane.c b/src/gnm-pane.c
index 84720c4..54cd8c0 100644
--- a/src/gnm-pane.c
+++ b/src/gnm-pane.c
@@ -989,6 +989,26 @@ gnm_pane_class_init (GnmPaneClass *klass)
                                   G_MAXINT,
                                   6,
                                   G_PARAM_READABLE));
+
+       gtk_widget_class_install_style_property
+               (widget_class,
+                g_param_spec_int ("resize-guide-width",
+                                  P_("Resize Guide Width"),
+                                  P_("With of the guides used for resizing columns and rows"),
+                                  0,
+                                  G_MAXINT,
+                                  1,
+                                  G_PARAM_READABLE));
+
+       gtk_widget_class_install_style_property
+               (widget_class,
+                g_param_spec_int ("pane-resize-guide-width",
+                                  P_("Pane Resize Guide Width"),
+                                  P_("With of the guides used for resizing panes"),
+                                  0,
+                                  G_MAXINT,
+                                  7,
+                                  G_PARAM_READABLE));
 }
 
 GSF_CLASS (GnmPane, gnm_pane,
@@ -2021,12 +2041,19 @@ gnm_pane_bound_set (GnmPane *pane,
 /****************************************************************************/
 
 void
-gnm_pane_size_guide_start (GnmPane *pane, gboolean vert, int colrow, int width)
+gnm_pane_size_guide_start (GnmPane *pane,
+                          gboolean vert, int colrow, gboolean is_colrow_resize)
 {
        SheetControlGUI const *scg;
-       double x0, y0, x1, y1;
+       double x0, y0, x1, y1, pos;
        double zoom;
        GOStyle *style;
+       GdkRGBA rgba;
+       GtkStyleContext *context;
+       const char *guide_class = is_colrow_resize ? "resize-guide" : "pane-resize-guide";
+       const char *colrow_class = vert ? "col" : "row";
+       const char *width_prop_name = is_colrow_resize ? "resize-guide-width" : "pane-resize-guide-width";
+       int width;
 
        g_return_if_fail (pane != NULL);
        g_return_if_fail (pane->size_guide.guide  == NULL);
@@ -2036,26 +2063,25 @@ gnm_pane_size_guide_start (GnmPane *pane, gboolean vert, int colrow, int width)
        zoom = GOC_CANVAS (pane)->pixels_per_unit;
        scg = pane->simple.scg;
 
+       pos = scg_colrow_distance_get (scg, vert, 0, colrow) / zoom;
        if (vert) {
-               double x = (scg_colrow_distance_get (scg, TRUE,
-                                       0, colrow) - .5) / zoom;
-               x0 = x;
+               x0 = pos;
                y0 = scg_colrow_distance_get (scg, FALSE,
-                                       0, pane->first.row) / zoom;
-               x1 = x;
+                                             0, pane->first.row) / zoom;
+               x1 = pos;
                y1 = scg_colrow_distance_get (scg, FALSE,
-                                       0, pane->last_visible.row+1) / zoom;
+                                             0, pane->last_visible.row+1) / zoom;
        } else {
-               double const y = (scg_colrow_distance_get (scg, FALSE,
-                                       0, colrow) - .5) / zoom;
                x0 = scg_colrow_distance_get (scg, TRUE,
-                                       0, pane->first.col) / zoom;
-               y0 = y;
+                                             0, pane->first.col) / zoom;
+               y0 = pos;
                x1 = scg_colrow_distance_get (scg, TRUE,
-                                       0, pane->last_visible.col+1) / zoom;
-               y1 = y;
+                                             0, pane->last_visible.col+1) / zoom;
+               y1 = pos;
        }
 
+       gtk_widget_style_get (GTK_WIDGET (pane), width_prop_name, &width, NULL);
+
        /* Guideline positioning is done in gnm_pane_size_guide_motion */
        pane->size_guide.guide = goc_item_new (pane->action_items,
                GOC_TYPE_LINE,
@@ -2064,23 +2090,28 @@ gnm_pane_size_guide_start (GnmPane *pane, gboolean vert, int colrow, int width)
                NULL);
        style = go_styled_object_get_style (GO_STYLED_OBJECT (pane->size_guide.guide));
        style->line.width = width;
-
-       /* cheat for now and differentiate between col/row resize and frozen panes
-        * using the width.  Frozen pane guides do not require a start line */
-       if (width == 1) {
-               style->line.color = GO_COLOR_BLACK;
+       context = goc_item_get_style_context (pane->size_guide.guide);
+       gtk_style_context_add_class (context, guide_class);
+       gtk_style_context_add_class (context, colrow_class);
+       if (is_colrow_resize)
+               gtk_style_context_add_class (context, "end");
+       gtk_style_context_get_color (context, GTK_STATE_FLAG_SELECTED, &rgba);
+       go_color_from_gdk_rgba (&rgba, &style->line.color);
+
+       if (is_colrow_resize) {
                pane->size_guide.start = goc_item_new (pane->action_items,
                        GOC_TYPE_LINE,
                        "x0", x0, "y0", y0,
                        "x1", x1, "y1", y1,
                        NULL);
                style = go_styled_object_get_style (GO_STYLED_OBJECT (pane->size_guide.start));
-               style->line.color = GO_COLOR_BLACK;
+               context = goc_item_get_style_context (pane->size_guide.start);
+               gtk_style_context_add_class (context, guide_class);
+               gtk_style_context_add_class (context, colrow_class);
+               gtk_style_context_add_class (context, "start");
+               gtk_style_context_get_color (context, GTK_STATE_FLAG_SELECTED, &rgba);
+               go_color_from_gdk_rgba (&rgba, &style->line.color);
                style->line.width = width;
-       } else {
-               style->line.pattern = GO_PATTERN_GREY25;
-               style->line.color = GO_COLOR_WHITE;
-               style->line.fore = GO_COLOR_BLACK;
        }
 }
 
diff --git a/src/gnm-pane.h b/src/gnm-pane.h
index 0962354..1110a04 100644
--- a/src/gnm-pane.h
+++ b/src/gnm-pane.h
@@ -28,7 +28,7 @@ void  gnm_pane_bound_set      (GnmPane *pane,
 void   gnm_pane_edit_start  (GnmPane *p);
 void   gnm_pane_edit_stop   (GnmPane *p);
 
-void   gnm_pane_size_guide_start  (GnmPane *p, gboolean vert, int colrow, int width);
+void   gnm_pane_size_guide_start  (GnmPane *p, gboolean vert, int colrow, gboolean is_colrow_resize);
 void   gnm_pane_size_guide_motion      (GnmPane *p, gboolean vert, gint64 guide_pos);
 void   gnm_pane_size_guide_stop        (GnmPane *p);
 
diff --git a/src/gnumeric.css b/src/gnumeric.css
index 0a49f71..f4f9b6f 100644
--- a/src/gnumeric.css
+++ b/src/gnumeric.css
@@ -1,4 +1,16 @@
 /* ------------------------------------------------------------------------- */
+
+/* GnmPane is the canvas we use for sheets.  We store custom properties
+   here because there is no un-deprecated way to store them for the
+   canvas items which aren't widgets.  */
+GnmPane {
+  -GnmPane-function-indicator-size: 10px;
+  -GnmPane-cell-comment-indicator-size: 6px;
+  -GnmPane-resize-guide-width: 1px;
+  -GnmPane-pane-resize-guide-width: 7px;
+}
+
+/* ------------------------------------------------------------------------- */
 /* The GnmItemGrid is the canvas area that holds all the cells.  */
 /* GnmPreviewGrid is the canvas used for auto-format previews. */
 GnmItemGrid, GnmPreviewGrid {
@@ -51,14 +63,6 @@ GnmItemCursor.autofill {
 
 /* ------------------------------------------------------------------------- */
 
-/* GnmPane is the canvas we use for sheets.  We store custom properties
-   here because there is no un-deprecated way to store them for the
-   canvas items which aren't widgets.  */
-GnmPane {
-  -GnmPane-function-indicator-size: 10px;
-  -GnmPane-cell-comment-indicator-size: 6px;
-}
-
 CommentView {
   color: red;
   /* See also GnmPane */
@@ -97,6 +101,21 @@ GnmItemBar:hover {
 }
 
 /* ------------------------------------------------------------------------- */
+/* 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: black;
+  /* See also GnmPane */
+}
+
+/* The resize guide used when resizing panes.  This can be subclassed with
+   "row" or "col".  */
+GnmPane GocLine.pane-resize-guide {
+  color: #c0c0c0;
+  /* See also GnmPane */
+}
+
+/* ------------------------------------------------------------------------- */
 /* This GtkDrawingArea is the select-all button above the row buttons.  */
 
 GtkDrawingArea.button.all {
diff --git a/src/item-bar.c b/src/item-bar.c
index b0871de..956d91e 100644
--- a/src/item-bar.c
+++ b/src/item-bar.c
@@ -1014,7 +1014,9 @@ item_bar_motion (GocItem *item, double x_, double y_)
                if (!ib->has_resize_guides) {
                        ib->has_resize_guides = TRUE;
                        scg_size_guide_start (ib->pane->simple.scg,
-                               ib->is_col_header, ib->colrow_being_resized, 1);
+                                             ib->is_col_header,
+                                             ib->colrow_being_resized,
+                                             TRUE);
                }
 
                cri = sheet_colrow_get_info (sheet,
diff --git a/src/sheet-control-gui.c b/src/sheet-control-gui.c
index b644638..abb16c3 100644
--- a/src/sheet-control-gui.c
+++ b/src/sheet-control-gui.c
@@ -1414,7 +1414,7 @@ cb_resize_pane_motion (GtkPaned *p,
                g_signal_handlers_block_by_func
                        (G_OBJECT (p),
                         G_CALLBACK (cb_check_resize), scg);
-               scg_size_guide_start (scg, vert, colrow, 7);
+               scg_size_guide_start (scg, vert, colrow, FALSE);
                scg->pane_drag_handler = g_timeout_add (250,
                        vert ? (GSourceFunc) cb_resize_hpane_finish
                             : (GSourceFunc) cb_resize_vpane_finish,
@@ -3534,11 +3534,12 @@ scg_take_focus (SheetControlGUI *scg)
 
 /*********************************************************************************/
 void
-scg_size_guide_start (SheetControlGUI *scg, gboolean vert, int colrow, int width)
+scg_size_guide_start (SheetControlGUI *scg,
+                     gboolean vert, int colrow, gboolean is_colrow_resize)
 {
        g_return_if_fail (IS_SHEET_CONTROL_GUI (scg));
        SCG_FOREACH_PANE (scg, pane,
-               gnm_pane_size_guide_start (pane, vert, colrow, width););
+                         gnm_pane_size_guide_start (pane, vert, colrow, is_colrow_resize););
 }
 void
 scg_size_guide_motion (SheetControlGUI *scg, gboolean vert, gint64 guide_pos)
diff --git a/src/sheet-control-gui.h b/src/sheet-control-gui.h
index d8ac9b8..35cdb88 100644
--- a/src/sheet-control-gui.h
+++ b/src/sheet-control-gui.h
@@ -91,7 +91,7 @@ void scg_set_left_col         (SheetControlGUI *scg, int new_first_col);
 void scg_set_top_row           (SheetControlGUI *scg, int new_first_row);
 
 void scg_size_guide_start      (SheetControlGUI *scg, gboolean vert,
-                                int colrow, int width);
+                                int colrow, gboolean is_colrow_resize);
 void scg_size_guide_motion     (SheetControlGUI *scg, gboolean vert,
                                 gint64 guide_pos);
 void scg_size_guide_stop       (SheetControlGUI *scg);


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