Commit Graph

461 Commits

Author SHA1 Message Date
Timm Bäder
601839c825 Remove various sizing related style properties 2016-10-16 18:17:21 +02:00
Timm Bäder
efffa3b6bd range: Remove min slider size setter/getter 2016-10-16 18:17:21 +02:00
Matthias Clasen
5b21c7d79f range: Ensure we don't underallocate the highlight gadget
This was causing warnings in HighContrast.

https://bugzilla.gnome.org/show_bug.cgi?id=770614
2016-09-04 09:43:51 -04:00
Benjamin Otte
e1a03ead7a Use NULL for generic marshallers in g_signal_new()
glib will use the correct marshaller automatically. And as a side
effect, we also get all glib optimizations, like a va marshaller.
2016-08-29 16:20:54 +02:00
Matthias Clasen
7f06f2818a Ensure that GtkRange allocates enough space for the value
This is a long-standing problem of GtkScale.

https://bugzilla.gnome.org/show_bug.cgi?id=766372
https://bugzilla.gnome.org/show_bug.cgi?id=578626
https://bugzilla.gnome.org/show_bug.cgi?id=79229
2016-06-07 21:28:44 -04:00
Matthias Clasen
9a8335a135 range: Free gadgets in finalize
This is the right place for this.
2016-06-05 20:00:43 -04:00
Timm Bäder
6301827dac range: Properly indent closing brace
Make sure it's obvious what if block it belongs to.
2016-05-30 19:15:49 +02:00
Timm Bäder
301652de1f Remove useless casts from gdk_event_triggers_context_menu calls 2016-05-12 20:39:51 +02:00
Matthias Clasen
2148708917 box gadget: Redo expand flag handling
We only keep one align flag per child, so it seems odd to
keep separate h/v expand flags. Just keep one expand flag
and interpret it according to orientation. Allow setting
the expand flag for child widgets too, though, so we can
make widget expand without interfering with the recursive
widget expand flag.

Update all callers.

Use the new possibility of expanding child widgets to make
the label of check and radio buttons expand. This fixes
unexpected behavior of these widgets in RTL in some places.

https://bugzilla.gnome.org/show_bug.cgi?id=765742
2016-04-28 21:59:34 -04:00
Cosimo Cecchi
9f48b6b07a range: use gadget pointers for grab/mouse locations
Simplify code and remove the mouse location indirection.
2016-03-26 22:43:53 -07:00
Matthias Clasen
7fe1037e84 range: Simplify highlight allocation
Since we are really only interested in the center point of the
slider allocation, the pre-computed slider geometry is perfectly
fine, just use it always. This avoids the complication with
gadget visibility.
2016-03-26 13:50:42 -04:00
Matthias Clasen
e33188ad41 range: Avoid miscalculating highlight allocation
The slider gadget may be turned invisible as side-effect of
gtk_range_calc_slider(). If that happens,
gtk_css_gadget_get_content_allocation() returns { 0, 0, 0, 0},
which leads us to calculate a negative allocation for the highlight
node. Avoid this, by just reusing our already calculated slider
allocation in this case (it is not technically the same as the
content, allocation, but the difference hardly matter here.

https://bugzilla.gnome.org/show_bug.cgi?id=764022
2016-03-26 10:50:00 -04:00
Timm Bäder
4b0abc13e3 range: Fix a few typos
Depreacated -> Deprecated
through -> trough
2016-03-11 19:18:07 +01:00
Benjamin Otte
fc7335bdb4 colorscale: Draw a trough
Make sure the color info is actually drawn inside the trough.
2016-03-11 16:39:34 +01:00
Matthias Clasen
1d19065979 range: Fix trough clickability
We previously considered any click inside the trough if it
hit an area that the slider might cover. Bring this behavior
back; the trough of scales is otherwise just too narrow to
hit easily with a click.
2016-03-11 01:27:21 -05:00
Matthias Clasen
fa48dbf1a5 range: Fix gadget state propagation
The contents node was not getting state updates at all, and the
trough node was missing some state updates as well, because we
were not calling update_trough_state() in all the places where
it is needed.
2016-03-09 14:15:40 -05:00
Cosimo Cecchi
9509bbb4a1 range: remove unneeded gtk_widget_queue_draw() 2016-03-06 11:10:44 -08:00
Cosimo Cecchi
c4615eff7b range: rename function
The function queues an allocation now, not a draw.
2016-03-06 11:10:44 -08:00
Cosimo Cecchi
de1c4bad6f range: remove duplicated code
This is already called by range_grab_add().
2016-03-06 11:10:44 -08:00
Cosimo Cecchi
a9b50b6f69 scale: port scale values to gadgets
And add a default color like it was before.
This also fixes other issues with scale values interacting with scale
mark labels, which were buggy at least since 3.18.
2016-03-06 11:09:46 -08:00
Cosimo Cecchi
27a6183b98 range: simplify calculation 2016-03-05 19:09:18 -08:00
Cosimo Cecchi
8242182404 range: move declarations to inner block
Where they're needed.
2016-03-05 19:09:18 -08:00
Cosimo Cecchi
990bd03c35 range: use a fixed offset for mark "snap" size
Instead of making it dependent on the slider size.
2016-03-05 19:09:18 -08:00
Cosimo Cecchi
6efe1f411a Revert "range: use border box for slider area"
Since it causes problems with event coordinates.

This reverts commit 0883ff5eed.
2016-03-05 19:09:18 -08:00
Cosimo Cecchi
f3e068bb31 range: avoid setting slider coordinates to negative numbers
This can happen if the theme sets a negative margin, but the coordinate
should never be negative.
2016-03-04 18:13:53 -08:00
Cosimo Cecchi
fce344d31f range: factor out a function
We're going to modify this in the next commit.
2016-03-04 18:13:53 -08:00
Cosimo Cecchi
5a42c2e478 range: fix warning for gadget slider
The slider is not HFW/WFH - just pass -1 to get rid of the warnings.
2016-03-04 17:28:53 -08:00
Cosimo Cecchi
7ff2f451ce range: add positional style classes to fill/highlight
Requested by Lapo.
2016-03-04 11:57:31 -08:00
Cosimo Cecchi
8ebc03a1d1 range: use border allocation for gadget hit test
The border is typically part of the reactive part of the widget. This
matches the pre-gadget behavior.
2016-03-02 22:23:11 -08:00
Matthias Clasen
cb614cc838 range: Don't leave css nodes behind
We create and destroy gadgets inside the range hierarchy here,
and if we don't explicitly remove their CSS nodes from the parent,
they stick around.
2016-03-01 15:48:01 -05:00
Cosimo Cecchi
d000b212c6 range: fix fill level for vertical inverted scales 2016-02-29 12:53:08 -08:00
Cosimo Cecchi
0c8dbf07ce range: draw slider on top of all contents
This is so that e.g. the focus ring is drawn under the slider.
2016-02-29 10:45:14 -08:00
Cosimo Cecchi
bc41ff8af4 range: better hack for GtkColorScale
Just draw the slider, since that is the only thing GtkColorScale cares
about.
2016-02-29 10:45:13 -08:00
Cosimo Cecchi
887b6d65a1 range: deprecate gtk_range_get/set_min_slider_size()
Nothing uses these functions inside GTK anymore.
2016-02-29 10:45:13 -08:00
Cosimo Cecchi
424f17c0fb range: don't use gtk_range_set_min_slider_size()
The way this method is used from the GtkRange subclasses doesn't really
work well when the slider properties change as a consequence of e.g. a
style class being applied (e.g. the fine-tune style class).

In fact, there's no need to read the minimum slider size out of band,
and we can obtain the same result in a way that always work by setting a
private property on GtkRange.
2016-02-29 10:45:13 -08:00
Cosimo Cecchi
0883ff5eed range: use border box for slider area
Since we can use negative margins, we should not use the margin box
for the slider area. Use the border box instead, since that's what is
typically mapped to the visible area.
2016-02-29 10:45:13 -08:00
Cosimo Cecchi
6ecab5ee6b range: use new GtkCssGadget API instead of rolling our own 2016-02-29 10:45:13 -08:00
Cosimo Cecchi
2d2a81682d range: simplify code
Instead of directly accessing the widget allocation, we can use the
gadget API to test whether the coordinates are in the main gadget.
2016-02-29 10:45:13 -08:00
Cosimo Cecchi
d1433c25f3 range: add a gadget for the whole widget area
This commit introduces another node, called "contents", that holds the
main contents of the range. This allows for the main gadget itself to
span across the whole surface of the widget now.
2016-02-29 10:45:13 -08:00
Cosimo Cecchi
a9ea544f3d scale: always add marks at the beginning or the end
Marks are always either the first or the last child of the scale.
2016-02-29 10:45:13 -08:00
Cosimo Cecchi
1d047f0097 range: use new GtkBoxGadget API instead of counting children 2016-02-29 10:45:13 -08:00
Cosimo Cecchi
6401e2405e range: use new GtkBoxGadget API instead of removing/inserting 2016-02-29 10:45:13 -08:00
Cosimo Cecchi
6827bd5e04 range: move slider drawing where it belongs
The slider gadget is a child of the trough gadget, so draw it from
there.
2016-02-29 10:45:12 -08:00
Cosimo Cecchi
0974b0d843 range: whitespace fix 2016-02-29 10:45:12 -08:00
Cosimo Cecchi
fb11cc1baf range: remove border allocation hack
We can achieve the same result with a negative margin.
2016-02-29 10:45:12 -08:00
Cosimo Cecchi
8b87eca11e Revert "range: move GtkColorScale special case to GtkColorScale"
This reverts commit d93d266ed9e3e26e382a4f6d4b5d4ea19eff3bcf.
2016-02-29 10:45:12 -08:00
Cosimo Cecchi
b927fc0874 Revert "range: simplify code"
This reverts commit a74f7dcaf8a02c96c6bfecab6969e1d33ecb9332.
2016-02-29 10:45:12 -08:00
Cosimo Cecchi
a7099d1468 range: simplify code
Now that everything is in the main gadget, we can just let it propagate
drawing to its children.
2016-02-29 10:45:12 -08:00
Cosimo Cecchi
b6f0b6be87 range: move GtkColorScale special case to GtkColorScale
Now we can just tweak the node visibility for it.
2016-02-29 10:45:12 -08:00
Cosimo Cecchi
cbbe237c18 range: remove special case that's not needed
We already set the gadget not to be visible in that case.
2016-02-29 10:45:12 -08:00
Cosimo Cecchi
ddb863e523 range: move slider inside the trough
This will require a rewrite of most of the theme, but it's the right
thing to do.
2016-02-29 10:45:12 -08:00
Cosimo Cecchi
d1c5ecfaef scale: deprecate slider-length style property
This can be achieved using min-height/min-width CSS properties now.
2016-02-29 10:45:12 -08:00
Cosimo Cecchi
c1eff2cce5 range: deprecate more style properties
These are never read now.
2016-02-29 10:45:12 -08:00
Cosimo Cecchi
413b9d5b3c range: continue porting to GtkGadgets
This commit rewrites a lot of the GtkRange internals to make full use
of the gadget structure.
2016-02-29 10:45:12 -08:00
Cosimo Cecchi
8c43b3ee60 range: remove unused code 2016-02-29 10:45:12 -08:00
Cosimo Cecchi
6c19947859 range: remove call that is not needed
gtk_range_calc_slider() already calls the same function when needed.
2016-02-29 10:45:12 -08:00
Cosimo Cecchi
83a6471c4e range: simplify code a bit 2016-02-29 10:45:11 -08:00
Cosimo Cecchi
d19215015e range: don't call gtk_range_calc_layout() in realize()
This should not be needed, and we want to get rid of
gtk_range_calc_layout().
2016-02-29 10:45:11 -08:00
Cosimo Cecchi
1f9de3cfec range: deprecate arrow-scaling style property
This can be done with CSS now.
2016-02-29 10:45:11 -08:00
Cosimo Cecchi
3b37f2a42a range: use newer GtkCssGadget API 2016-02-29 10:45:11 -08:00
Cosimo Cecchi
d0c671ddfe range: deprecate trough-under-steppers
It's not clear what this would do in a CSS world, and all the themes set
it to TRUE anyway...
2016-02-29 10:45:11 -08:00
Cosimo Cecchi
4bb0a8db47 range: first pass at porting to gadgets
There's still a lot to be done, but this is functional and we'll improve
the loose ends in the next commits.
2016-02-29 10:45:11 -08:00
Timm Bäder
35cd0be468 Range: Group all three gestures
And reset the grab_location in the ::released handler of the multipress
gesture.

Previously, when leaving fine-tune mode, the ::released handler of the
multipress gesture would call stop_scrolling, which calls
range_grab_remove and resets the grab_location. The ::drag-end handler
is executed after that, and only unsets priv->in_drag if the
grab_location is MOUSE_OUTSIDE, which it never was, since the ::released
handler already reset it. This lead to priv->in_drag being set even
though no dragging was in progress anymore, which e.g. made shift
pressed after leaving the fine-tune mode entering it again.

https://bugzilla.gnome.org/show_bug.cgi?id=761402
2016-02-04 17:08:30 +01:00
Benjamin Otte
971a277419 cssnode: Change style-changed signal
Instead of having old and new style, now have a GtkCssStyleChange opaque
object that will compute the changes you are interested in for you.

This simplifies change signal handlers quite a bit and avoids lots of
repeated computation in every signal handler.
2015-12-12 02:16:04 +01:00
Timm Bäder
2b9d57f726 GtkRange: Return proper constants in signal handlers 2015-12-02 21:06:11 +01:00
Timm Bäder
5a6bac7831 GtkRange: Remove recalc_marks field
And instead recalculate the marks on demand, i.e. whenever we were
previously setting recalc_marks to TRUE.
2015-12-02 21:06:11 +01:00
Timm Bäder
414ffbb708 GtkRange: Use G_MININT as default mouse position, not -1
Otherwise we're getting MOUSE_WIDGET as mouse position for unmapped
GtkRanges.
2015-12-02 21:06:11 +01:00
Benjamin Otte
3513e5e87b Chain up in state_flags_changed
When introducing handlers for state_flags_changed in the node
transitions, chaining up was forgotten.
2015-12-02 04:36:31 +01:00
Matthias Clasen
43f822e70f Annotate deprecated style properties
Use G_PARAM_DEPRECATED with deprecated style properties.
This will make it easier to identify and remove such stale
properties from css, since it will now trigger warnings.
2015-11-16 15:13:33 -05:00
Matthias Clasen
90f8b054b3 range: Document some style properties as deprecated
Remove dead code dealing with the arrow-displacement-x/y style
properties, and document them as deprecated.
2015-11-16 07:20:18 -05:00
Matthias Clasen
6c5d08d75a Cosmetic: Avoid explicit state variables
Fold it into its single user.
2015-11-14 12:32:57 -05:00
Matthias Clasen
d25e0657be range: Fixes to the new trough rendering
There was an errant y that caused some troughs to not be drawn.
And also set the state of the fill node.
2015-11-06 22:27:31 -05:00
Matthias Clasen
11d7f6df7c range: Use CSS nodes for all trough rendering
This replaces the somewhat freewheeling use of style classes to
render a part of the trough highlighted and show a fill level.
2015-11-06 19:25:58 -05:00
Benjamin Otte
68ed166c60 range: Use right state when querying margin 2015-11-06 18:59:15 +01:00
Matthias Clasen
38cd2c1239 range: Update trough state
It might make sense for the theme to render an insensitive trough
differently.
2015-11-06 11:53:42 -05:00
Matthias Clasen
4ed47e757f Fix a crash with steppers
The introduction of the trough node was not properly carried
into the code constructing stepper nodes, and was causing
assertion failures there. This was only showing up on Windows,
since Adwaita and HighContrast don't have steppers.
2015-11-05 09:44:14 -05:00
Matthias Clasen
2e314940af range: Redraw when slider visiblity changes
We were not queuing a draw (and not updating the CSS node) when
the slider visibility changed. This was exposed by the Trough
button in tests/testscale.
Fix this by taking slider visibility into account when deciding
whether to queue a draw in response to adjustment changes.
2015-11-05 07:26:10 -05:00
Matthias Clasen
973836d395 range: Add private api to get the trough node
This will be needed in range subclasses to position their
own subnodes.
2015-11-05 07:26:10 -05:00
Matthias Clasen
2bfb5ad812 range: Add a CSS node for the trough
This is in sync with what we do elsewhere for troughs.
2015-11-05 07:26:10 -05:00
Matthias Clasen
8727c8fe24 range: Convert to CSS nodes
Use CSS nodes for GtkScale and GtkScrollbar. See their documentation
for details on what subnodes with what names exist.
2015-11-03 23:17:09 -05:00
Benjamin Otte
2dad7c1319 gdk: Add gdk_rectangle_equal()
There's enough users inside GTK to warrant this convenience function.
2015-10-03 22:26:27 -04:00
Matthias Clasen
c3038c2fe1 range: Convert to g_object_notify_by_pspec
This avoids pspec lookup overhead in g_object_notify.
2015-09-06 17:11:36 -04:00
Matthias Clasen
0f479deb5e range: Tweak button bindings
Change things around so that warp-to-click and jump-by-pages are
bound to left-click and shift-left-click, depending on the value
of gtk-primary-button-warps-slider. Autoscrolling is bound to
right-click.

To achieve this, reorganize gtk_range_multipress_gesture_pressed
so that the functions are clearly separated.
2015-07-13 22:40:43 -04:00
Matthias Clasen
1ca6d8b1b5 range: Trivial field ordering 2015-07-12 01:53:36 -04:00
Matthias Clasen
1c780beb8b range: Add a stepper alternative
Make shift right-click on the trough start autoscrolling. The
autoscrolling is similar to the way steppers operate now, with
the difference that we vary the scrolling speed based on the
distance of the pointer from the widget.
2015-07-12 01:42:03 -04:00
Matthias Clasen
6e280d2478 range: switch secondary and middle button on steppers
Clicking on steppers does different things depending on which
button you use. We used to scroll to the end on secondary click
and use high-speed autoscrolling on middle-click. Switch these
two around, since the scroll-to-end functionality is less likely
to be useful, and the seconary button makes the autoscrolling
more easily available.
2015-07-12 00:23:32 -04:00
Matthias Clasen
93f9a81ac5 GtkRange: Improve zoom handling a bit
The calculation to update the initial slider position on zoom
changes was not working correctly when using keys to toggle
zoom on and off for scales. Avoid it by updating the position
beforehand.
2015-06-20 20:26:42 -04:00
Matthias Clasen
27dabaefa6 GtkRange: Make drag gesture less agressive
Moving the mouse while pressing one of the steppers was making
the slider jump to the end, unexpectedly. This was caused by the
drag gesture kicking in when it shouldn't. Fix this by making
all drag gesture signal handlers only do something if we are in
a drag thats started on the slider.

https://bugzilla.gnome.org/show_bug.cgi?id=751050
2015-06-20 18:37:15 -04:00
Lars Uebernickel
422d8728fa GtkRange: fix horizontal scrolling
https://bugzilla.gnome.org/show_bug.cgi?id=737175
2015-04-17 11:00:25 -04:00
Marcus Karlsson
38f61dd445 GtkRange: Check "inverted" property when drawing
The direction in which the slider moves can be inverted by setting the
inverted property. But the draw method does not check this, instead it
checks if the direction of the widget is set to be right to left.

Call the should_invert function in order to determine if the direction
of the range should be inverted. It too checks the widget's direction,
but also checks the "inverted" property, and allows the range to be
drawn inverted even if it is vertically oriented.

https://bugzilla.gnome.org/show_bug.cgi?id=746712
2015-03-24 23:19:50 -04:00
Marcus Karlsson
abf3d78b57 GtkRange: Fix drawing of fill-level
Compute the proportion of the range that should be filled to match the
fill level, and use it to compute the starting point and length of the
area between the slider and the fill level.

https://bugzilla.gnome.org/show_bug.cgi?id=734741
2015-03-24 22:45:14 -04:00
Matthias Clasen
eea16f03f5 Stop using GDK_POINTER_MOTION_HINT_MASK in widgets
It is deprecated and no longer needed, and,as observed in
https://bugzilla.gnome.org/show_bug.cgi?id=746253 it
interferes with turning off event compression.
2015-03-22 17:33:38 -04:00
Matthias Clasen
416c370da1 GtkRange: Fix scroll wheel direction for horizontal ranges
The expected behavior here is that scrolling up goes towards
larger values, ie to the right. This matches e.g. volume
sliders in gnome-shell.

https://bugzilla.gnome.org/show_bug.cgi?id=737175
2015-03-17 22:02:35 -04:00
Matthias Clasen
c73ab94d3f range: Make steppers use smooth autoscrolling
This makes them work much nicer than the old timer-based
implementation.
2015-02-23 08:38:38 -05:00
Matthias Clasen
3222de2f91 range: Make zoom scrolling less sensitive
Use the new long press delay factor to make the zoom
scrolling less easy to trigger accidentally.
2015-02-23 08:38:25 -05:00
Matthias Clasen
c060d93e3d zoom scrolling: Improve the previous fix
As Sebastian pointed out, just resetting the initial slider
position was an incomplete fix, because it does not cause the
delta to be recomputed, which is important in this scenario,
because you've likely travelled some distance over the slider
before the long press kicks in.
Instead, explicitly record both the slider position and the
delta.
2015-02-23 07:28:40 -05:00
Matthias Clasen
8726c6d5d2 zoom scrolling: avoid 'jumping back'
We record the starting position on button press, but only
start the zoom mode when the long press timeout kicks in.
Depending on circumstances, this can cause a noticable jump.

Avoid this by resetting the recorded starting position after
the long press timeout. Suggested by Sebastian Keller.
2015-02-23 06:46:21 -05:00
Benjamin Otte
4c33645a7a range: Implement :hover for the whole widget 2014-11-29 03:42:29 +01:00
Benjamin Otte
116cc53105 range: Handle redraws inside update_mouse_location
This way, we can do finer-grained invalidation. Plus, we get to not
duplicate all the queue_draw() calls.
2014-11-29 03:42:29 +01:00
Benjamin Otte
95dc96901e range: Properly queue draws when doing a drag
The dragged area needs to be marked as :active during the drag.
2014-11-29 03:42:29 +01:00