GNOME Bugzilla – Bug 565656
Add marks to scales
Last modified: 2009-01-20 05:11:11 UTC
Sometimes it is useful to point out certain values in a scale, and make it easy for the user to select them exactly. See e.g bug 565144 where a scale is used for fade control between left and right, and midpoint would be very beneficial. Another use case would be to mark the 0dB position on a volume slider. Here is a patch that adds this feature to GtkScale. It allows to place "marks" on either side of the scale, optionally with text or icons. Behaviour-wise, selecting the mark values is made easier by adding a little resistance while dragging the slider with the mouse, and making keynav go exactly to the mark value instead of stepping over it. I'm not entirely sold on the api, and allowing icons as decoration may be a bit over the top.
Created attachment 125316 [details] [review] patch
Created attachment 125317 [details] test cases
Created attachment 125318 [details] screenshot
I've decided to leave out icons for now. If we want them later on, we can add another function for that. Bug 565656 – Add marks to scales * gtk/gtkrange.[hc]: Add internal api to define 'stop values' that have a little resistance when dragging the slider over it. * gtk/gtk.symbols: * gtk/gtkscale.[hc] (gtk_scale_add_mark): New function to add a 'mark' to a scale, which will draws a tick, plus optionally some text, and makes the value a stop value. (gtk_scale_clear_values): Removes all marks. * tests/testscale.c: Test for marks on scales * tests/Makefile.am: Integrate it