GNOME Bugzilla – Bug 357950
Style property to control arrow size
Last modified: 2006-11-01 19:16:15 UTC
Maemo adds properties to control the arrow width/height of the arrow in the combo box. Based on this idea I wrote a small patch which adds a style property to set the arrow size. Currently the size of the arrow is determined by size requisition/allocation of the other widgets in the combo box -- choosing a nice default here is difficult. For now I've choosen a default of 18, which looks nice here. Also, this property actually sets a guaranteed minimum size for the arrow. If much more space is allocated the the combo box, the arrow will be bigger than arrow-size.
Created attachment 73485 [details] [review] patch
Looks fine to me. Maybe the docs should say "minimum size" then. And there should be a doc comment with a "Since: 2.12" in it
doesn't this mean that comboboxes will suddenly have really big arrows for people who currently use pretty small fonts? why does there need to be a minimum size of 18 at all? can't we simply default to 0 and have the arrow fill the actual allocation like it currently works?
After some more testing it looks like I was wrong in my original comment. (In reply to comment #0) > Currently the size of the arrow is determined by size requisition/allocation of > the other widgets in the combo box -- choosing a nice default here is > difficult. For now I've choosen a default of 18, which looks nice here. It appears GtkArrow has a default arrow size of 15, with a default requistion of arrow_size + {x,y}pad. > Also, this property actually sets a guaranteed minimum size for the arrow. If > much more space is allocated the the combo box, the arrow will be bigger than > arrow-size. When setting a much bigger font, the button scales up but the arrow doesn't. I guess 15 is a nicer default, seen that xpad/ypad are zero by default.
Created attachment 74941 [details] [review] updated patch To reply again to Tim; for people with really small fonts, the size of the arrow will stay at 15. To me it makes sense to introduce this minimum size to keep the minimum size of the arrow the same as it was before. Also, if we don't do this, the arrow is barely visible for font size 6, for example. The arrow size is also a minimum size now, as it will scale up together with the font size.
Comment on attachment 74941 [details] [review] updated patch (In reply to comment #5) > To reply again to Tim; for people with really small fonts, the size of the > arrow will stay at 15. To me it makes sense to introduce this minimum size to > keep the minimum size of the arrow the same as it was before. Also, if we > don't do this, the arrow is barely visible for font size 6, for example. sounds good. >Index: gtkcombobox.c >=================================================================== >RCS file: /cvs/gnome/gtk+/gtk/gtkcombobox.c,v >retrieving revision 1.185 >diff -u -p -r1.185 gtkcombobox.c >--- gtkcombobox.c 12 Oct 2006 13:48:07 -0000 1.185 >+++ gtkcombobox.c 18 Oct 2006 12:07:43 -0000 >@@ -756,6 +756,25 @@ gtk_combo_box_class_init (GtkComboBoxCla > FALSE, > GTK_PARAM_READABLE)); > >+ /** >+ * GtkComboBox:arrow-size: >+ * >+ * Sets the minimum size of the arrow in the combo box. Note >+ * that the arrow size is coupled to the font size, so in case >+ * a larger font is used, the arrow will be larger than set >+ * by arrow size. >+ * >+ * Since: 2.12 >+ */ >+ gtk_widget_class_install_style_property (widget_class, >+ g_param_spec_int ("arrow-size", >+ P_("Arrow Size"), >+ P_("The minimum size of the arrow in the combo box"), >+ 0, >+ G_MAXINT, >+ 15, >+ GTK_PARAM_READABLE)); >+ > g_type_class_add_private (object_class, sizeof (GtkComboBoxPrivate)); > } > >@@ -1897,6 +1916,8 @@ gtk_combo_box_size_request (GtkWidget > { > gint width, height; > gint focus_width, focus_pad; >+ gint font_size; if font_size is an int... >+ gint arrow_size; > GtkRequisition bin_req; > > GtkComboBox *combo_box = GTK_COMBO_BOX (widget); >@@ -1910,7 +1931,14 @@ gtk_combo_box_size_request (GtkWidget > gtk_widget_style_get (GTK_WIDGET (widget), > "focus-line-width", &focus_width, > "focus-padding", &focus_pad, >+ "arrow-size", &arrow_size, > NULL); >+ >+ font_size = (double)pango_font_description_get_size (GTK_BIN (widget)->child->style->font_desc) / (double)PANGO_SCALE; the double casts here are pretty useless. (and needless casts are generally bad, they blinden the compiler.) in any case, i think your use of pango_font_description_get_size() needs to be fixed to special case absolute size settings, as indicated by the docs: http://developer.gnome.org/doc/API/2.0/pango/pango-Fonts.html#pango-font-description-get-size or, it might be easier to use pango_font_metrics_get_ascent() / pango_font_metrics_get_descent() to figure the arrow size. >+ >+ arrow_size = MAX (arrow_size, font_size); >+ >+ gtk_widget_set_size_request (combo_box->priv->arrow, arrow_size, arrow_size); > > if (!combo_box->priv->tree_view) > { one thing that escapes me here is: > The arrow size is also a minimum size now, as it will scale up together with > the font size. how's that evident from the current code? i.e. what's currently causing the arrow to be 15 pixels?
(In reply to comment #6) > in any case, i think your use of pango_font_description_get_size() needs to be > fixed to special case absolute size settings, as indicated by the docs: > > http://developer.gnome.org/doc/API/2.0/pango/pango-Fonts.html#pango-font-description-get-size > or, it might be easier to use pango_font_metrics_get_ascent() / > pango_font_metrics_get_descent() to figure the arrow size. I saw that and then looked in the gtk+ source for an example, but it appeared that nothing in gtk+ is taking this special case into account. So that means that many more cases need to be fixed ... > > The arrow size is also a minimum size now, as it will scale up together with > > the font size. > > how's that evident from the current code? i.e. what's currently causing the > arrow to be 15 pixels? See comment #4, the arrow has a default (hard coded) size of 15 and it requests that plus xpad/ypad.
Created attachment 75789 [details] [review] patch as committed I ended up using font metrics anyway ...
2006-11-01 Kristian Rietveld <kris@imendio.com> * gtk/gtkcombobox.c (gtk_combo_box_class_init), (gtk_combo_box_size_request): add arrow-size property to control the minimum size of the arrow, have the arrow scale up with the font by default. (#357950).