changeset 74967:8c79fb85d31c

(auto_resize_tool_bars_p): Replace with ... (Vauto_resize_tool_bars): ... this. (syms_of_xdisp): DEFVAR_LISP and initialize it. Update doc string to describe new value `grow-only', and use of C-l. (display_tool_bar_line): Only use default face for border below toolbar if not grow-only (to get acceptable visual appearence). Explicitly set visible_height for empty toolbar lines. (redisplay_tool_bar): Handle `grow-only' setting. Check and clear minimize_tool_bar_window_p flag.
author Kim F. Storm <storm@cua.dk>
date Fri, 29 Dec 2006 23:29:45 +0000
parents 749691edf645
children 8ad08e091b07
files src/xdisp.c
diffstat 1 files changed, 56 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/src/xdisp.c	Fri Dec 29 23:29:27 2006 +0000
+++ b/src/xdisp.c	Fri Dec 29 23:29:45 2006 +0000
@@ -283,10 +283,12 @@
 
 EMACS_INT tool_bar_button_relief;
 
-/* Non-zero means automatically resize tool-bars so that all tool-bar
-   items are visible, and no blank lines remain.  */
-
-int auto_resize_tool_bars_p;
+/* Non-nil means automatically resize tool-bars so that all tool-bar
+   items are visible, and no blank lines remain.
+
+   If value is `grow-only', only make tool-bar bigger.  */
+
+Lisp_Object Vauto_resize_tool_bars;
 
 /* Non-zero means draw block and hollow cursor as wide as the glyph
    under it.  For example, if a block cursor is over a tab, it will be
@@ -9694,9 +9696,16 @@
  out:;
 
   row->displays_text_p = row->used[TEXT_AREA] != 0;
-  /* Use default face for the border below the tool bar.  */
-  if (!row->displays_text_p)
+
+  /* Use default face for the border below the tool bar.
+
+     FIXME: When auto-resize-tool-bars is grow-only, there is
+     no additional border below the possibly empty tool-bar lines.
+     So to make the extra empty lines look "normal", we have to
+     use the tool-bar face for the border too.  */
+  if (!row->displays_text_p && !EQ (Vauto_resize_tool_bars, Qgrow_only))
     it->face_id = DEFAULT_FACE_ID;
+
   extend_face_to_end_of_line (it);
   last = row->glyphs[TEXT_AREA] + row->used[TEXT_AREA] - 1;
   last->right_box_line_p = 1;
@@ -9718,6 +9727,7 @@
   if (!row->displays_text_p)
     {
       row->height = row->phys_height = it->last_visible_y - row->y;
+      row->visible_height = row->height;
       row->ascent = row->phys_ascent = 0;
       row->extra_line_spacing = 0;
     }
@@ -9820,7 +9830,6 @@
   struct window *w;
   struct it it;
   struct glyph_row *row;
-  int change_height_p = 0;
 
 #ifdef USE_GTK
   if (FRAME_EXTERNAL_TOOL_BAR (f))
@@ -9915,10 +9924,10 @@
   w->desired_matrix->no_scrolling_p = 1;
   w->must_be_updated_p = 1;
 
-  if (auto_resize_tool_bars_p)
-    {
-      int nlines, nrows;
+  if (!NILP (Vauto_resize_tool_bars))
+    {
       int max_tool_bar_height = MAX_FRAME_TOOL_BAR_HEIGHT (f);
+      int change_height_p = 0;
 
       /* If we couldn't display everything, change the tool-bar's
 	 height if there is room for more.  */
@@ -9944,29 +9953,40 @@
 
       /* Resize windows as needed by changing the `tool-bar-lines'
 	 frame parameter.  */
-      if (change_height_p
-	  && (nlines = tool_bar_lines_needed (f, &nrows),
-	      nlines != WINDOW_TOTAL_LINES (w)))
+      if (change_height_p)
 	{
 	  extern Lisp_Object Qtool_bar_lines;
 	  Lisp_Object frame;
 	  int old_height = WINDOW_TOTAL_LINES (w);
-
-	  XSETFRAME (frame, f);
-	  Fmodify_frame_parameters (frame,
-				    Fcons (Fcons (Qtool_bar_lines,
-						  make_number (nlines)),
-					   Qnil));
-	  if (WINDOW_TOTAL_LINES (w) != old_height)
-	    {
-	      clear_glyph_matrix (w->desired_matrix);
-	      f->n_tool_bar_rows = nrows;
-	      fonts_changed_p = 1;
-	    }
-	}
-    }
-
-  return change_height_p;
+	  int nrows;
+	  int nlines = tool_bar_lines_needed (f, &nrows);
+
+	  change_height_p = ((EQ (Vauto_resize_tool_bars, Qgrow_only)
+			      && !f->minimize_tool_bar_window_p)
+			     ? (nlines > old_height)
+			     : (nlines != old_height));
+	  f->minimize_tool_bar_window_p = 0;
+
+	  if (change_height_p)
+	    {
+	      XSETFRAME (frame, f);
+	      Fmodify_frame_parameters (frame,
+					Fcons (Fcons (Qtool_bar_lines,
+						      make_number (nlines)),
+					       Qnil));
+	      if (WINDOW_TOTAL_LINES (w) != old_height)
+		{
+		  clear_glyph_matrix (w->desired_matrix);
+		  f->n_tool_bar_rows = nrows;
+		  fonts_changed_p = 1;
+		  return 1;
+		}
+	    }
+	}
+    }
+
+  f->minimize_tool_bar_window_p = 0;
+  return 0;
 }
 
 
@@ -13447,7 +13467,7 @@
 #else
       redisplay_tool_bar_p = WINDOWP (f->tool_bar_window)
         && (FRAME_TOOL_BAR_LINES (f) > 0
-            || auto_resize_tool_bars_p);
+            || !NILP (Vauto_resize_tool_bars));
 
 #endif
 
@@ -24077,12 +24097,13 @@
 unselects the minibuffer if it is active.  */);
   Vmouse_autoselect_window = Qnil;
 
-  DEFVAR_BOOL ("auto-resize-tool-bars", &auto_resize_tool_bars_p,
+  DEFVAR_LISP ("auto-resize-tool-bars", &Vauto_resize_tool_bars,
     doc: /* *Non-nil means automatically resize tool-bars.
-This increases a tool-bar's height if not all tool-bar items are visible.
-It decreases a tool-bar's height when it would display blank lines
-otherwise.  */);
-  auto_resize_tool_bars_p = 1;
+This dynamically changes the tool-bar's height to the minimum height
+that is needed to make all tool-bar items visible.
+If value is `grow-only', the tool-bar's height is only increased
+automatically; to decreace the tool-bar height, use \\[recenter].  */);
+  Vauto_resize_tool_bars = Qt;
 
   DEFVAR_BOOL ("auto-raise-tool-bar-buttons", &auto_raise_tool_bar_buttons_p,
     doc: /* *Non-nil means raise tool-bar buttons when the mouse moves over them.  */);