Commit Graph

531 Commits

Author SHA1 Message Date
Timm Bäder
01d7ec2c83 range: Fix coord/value translation
Save the x/y we allocated the slider at, which is different than
the coordinates we get from any of the widget allocation accessors.
2018-02-23 10:47:18 +01:00
Timm Bäder
79426a0a50 range: Compute slider allocation in update_initial_slider_position
Instead of outside at every call-site.
2018-02-23 10:47:05 +01:00
Timm Bäder
4095cac75c range: Remove GtkScale special casing
This is unnecessary these days due to the negative margins of the
slider.
2018-02-23 10:47:05 +01:00
Timm Bäder
af4474f752 range: Simplify allocate_trough 2018-02-23 10:47:05 +01:00
Timm Bäder
1fea980930 range: Simplify compute_slider_position 2018-02-23 10:47:05 +01:00
Timm Bäder
4c952da6cb range: Fix coordinates in coord_to_value
The given coordinate needs to be trough-relative, since that's what the
slider is relative to. Also use the trough's content size and not the
outer size.
2018-02-23 10:47:05 +01:00
Timm Bäder
52f877d606 range: Remove some unneeded includes 2018-02-23 10:47:05 +01:00
Timm Bäder
82d459f015 range: Remove priv pointer 2018-02-23 10:47:05 +01:00
Timm Bäder
ece26b847b range: Stop tracking mouse position
We have the mouse position available everywhere we want to use it
anyway, so use that instead.
2018-02-23 10:47:05 +01:00
Timm Bäder
e9ecfeaca6 range: Stop tracking mouse location
Instead, just use gtk_widget_pick() to get the widget at the pointer
position whenever we need it.
2018-02-23 10:47:05 +01:00
Timm Bäder
69fa3c4876 range: Don't call calc_slider() on value changes
calc_slider() updates the slider visibility, but that can only change if
the upper or lower change.
2018-02-23 10:47:05 +01:00
Timm Bäder
8a38f62915 range: Remove unnecessary queue_draw calls 2018-02-23 10:47:05 +01:00
Timm Bäder
c200758c26 range: Remove scale special case
This is done automatically nowadays since the value is shown in a
widget.
2018-02-23 10:47:05 +01:00
Benjamin Otte
f08bc40fbb a11y: Don't include gtk.h
Also add missing includes and sort them for all the widgets that relied
on that before.
2018-02-08 15:25:53 +01:00
Matthias Clasen
4c150d8eb5 The big versioning cleanup
Remove all the old 2.x and 3.x version annotations.
GTK+ 4 is a new start, and from the perspective of a
GTK+ 4 developer all these APIs have been around since
the beginning.
2018-02-06 01:16:32 -05:00
Emmanuele Bassi
c655759cef Replace gdk_threads_add_timeout* with g_timeout_add()
The main GDK thread lock is not portable and deprecated.

The only reason why gdk_threads_add_timeout() and
gdk_threads_add_timeout_full() exist is to allow invoking a callback
with the GDK lock held, in case 3rd party libraries still use the
deprecated gdk_threads_enter()/gdk_threads_leave() API.

Since we're removing the GDK lock, and we're releasing a new major API,
such code cannot exist any more; this means we can use the GLib API for
installing timeout callbacks.

https://bugzilla.gnome.org/show_bug.cgi?id=793124
2018-02-03 12:06:58 +01:00
Timm Bäder
c8a936cdcc range: Always queue an allocate if the adjustment changed
The slider gets its new size in size-allocate, so we have to do this
even if the range has no origin.
2018-01-30 21:51:50 +01:00
Matthias Clasen
b891d205dd range: Add private api to autoscroll
This will be used to scroll the scale in scale buttons.
2017-12-12 22:17:49 -05:00
Timm Bäder
93df23d962 Remove some more gtk_widget_get_content_size uses 2017-12-04 12:42:52 +01:00
Matthias Clasen
ffd6baec42 gtk: Intern css names
This avoids a bunch of strdups at startup.
2017-11-17 22:49:57 -05:00
Benjamin Otte
c4a9fa9865 range: Stop trying to be smarter than GTK
GTK deals with PRELIGHT properly itself now, so there's no need to try
do it manually.
2017-11-05 05:13:17 +01:00
Benjamin Otte
4bb9a6360f range: Use gtk_widget_pick() to pick the mouse location
That's rather unsuccessful so far because it requires skipping a bunch
of irrelevant widgets, but oh well...
2017-11-05 05:13:17 +01:00
Benjamin Otte
cf1cd19b61 range: Stack widgets properly
The trough widgets have the slider on top of the fill level and the
hilight widget. Make sure the widget stacking respects that.

This is particularly relevant because picking event targets should pick
the slider and not the hilight widget.
2017-11-05 05:13:17 +01:00
Daniel Boles
29b8cfc952 Range: Fix inverted horizontal scroll wheel events
Bug 737175 aimed to ensure that scrolling up on a horizontal range would
result in its value increasing, as that’s what users intuitively expect.
However, its commit 416c370da1 meant that,
if the event gives scroll deltas, we inverted our delta unconditionally.

So it broke horizontal scrolling: scrolling left moved the slider right…

We must only invert if using dy as delta. dx already has the right sign,
so inverting it was wrong.

https://bugzilla.gnome.org/show_bug.cgi?id=788905
2017-10-14 18:56:32 +01:00
Matthias Clasen
2120ea60ed range: Bring back middle clicks
It does not hurt us to keep middle clicks doing the same
as shift-primary clicks. This makes the transition from gtk2
less painful in terms of muscle memory.

https://bugzilla.gnome.org/show_bug.cgi?id=787669
2017-10-11 14:07:53 -05:00
Benjamin Otte
43c212ac28 build: Enable -Wswitch-enum and -Wswitch-default
This patch makes that work using 1 of 2 options:

1. Add all missing enums to the switch statement
  or
2. Cast the switch argument to a uint to avoid having to do that (mostly
   for GdkEventType).

I even found a bug while doing that: clearing a GtkImage with a surface
did not notify thae surface property.

The reason for enabling this flag even though it is tedious at times is
that it is very useful when adding values to an enum, because it makes
GTK immediately warn about all the switch statements where this enum is
relevant.
And I expect changes to enums to be frequent during the GTK4 development
cycle.
2017-10-06 21:23:39 +02:00
Carlos Garnacho
861916fd0b gtkrange: Use scroll event controller 2017-09-19 18:40:49 +02:00
Carlos Garnacho
c0b77a2941 range: Update to using GdkEvent API 2017-09-19 18:39:02 +02:00
Timm Bäder
ccfc568a03 range: Fix trough state update 2017-08-28 11:17:47 +02:00
Timm Bäder
9f3f640c0d widget: Remove gtk_widget_get_border_allocation 2017-08-14 12:22:39 +02:00
Timm Bäder
5f859a1f24 widget: Remove gtk_widget_get_content_allocation
Replace it where we still need something similar, e.g. in
gtk_widget_translate_coordinates
2017-08-14 12:22:39 +02:00
Timm Bäder
9c7e089fc2 widget: Remove gtk_widget_get_margin_allocation
It's not needed anymore with get_outer_allocation (which will be
replaced by something more appropriately named).
2017-08-14 12:22:39 +02:00
Timm Bäder
36ab70ddf5 widget: Add baseline and out_clip parameters to size-allocate
Since setting a clip is mandatory for almost all widgets, we can as well
change the size-allocate signature to include a out_clip parameter, just
like GtkCssGadget did. And since we now always propagate baselines, we
might as well pass that one on to size-allocate.

This way we can also make sure to transform the clip returned from
size-allocate to parent-coordinates, i.e. the same coordinate space
priv->allocation is in.
2017-07-19 21:27:16 -04:00
Timm Bäder
4eba9442df range: Fix get_range_rect
get_own_allocation's position is relative to the given widget's origin,
not the parent.
2017-07-19 21:27:15 -04:00
Timm Bäder
468e75e43d range: Fix mark positions
The values returned by gtk_range_compute_slider_position are relative
to the trough_widget (the slider's parent), not the slider widget
itself.
2017-07-19 21:27:15 -04:00
Timm Bäder
993998085f range: Avoid division by zero 2017-07-19 21:27:15 -04:00
Timm Bäder
3dc6d240b3 Fix a few allocation coordinates & sizes 2017-07-19 21:27:15 -04:00
Timm Bäder
c2abb698be Replace a few get_content_allocation calls with get_content_size
The position of the content allocation is almost never relevant since
it's 0/0 for measure, size_allocate and snapshot.
2017-07-19 21:27:14 -04:00
Timm Bäder
1c5eec92fe range: Fix slider allocation 2017-07-19 21:27:14 -04:00
Timm Bäder
30f516ff1f range: Use a gizmo as slider
No need for this to be a GtkIcon.
2017-07-19 21:27:14 -04:00
Timm Bäder
b9f70b473c scrollbar: Add new API to gtk4-sections.txt
and update the css node docs
2017-07-19 21:27:13 -04:00
Timm Bäder
790c153b2c range: Fix click detection in slider trace
The x/y/ coordinates are relative to the range allocation, so take that
into account.
2017-07-19 21:27:13 -04:00
Timm Bäder
4f0140fa6c Remove GtkBuiltinIcon
Now unused.
2017-07-19 21:27:13 -04:00
Timm Bäder
b3f45cf1fe range: Emit value-changed when setting the adjustment
After all, the value kind of just changed.
2017-07-19 21:27:13 -04:00
Timm Bäder
af9d0cdffb range: Return trough allocation from _get_range_rect 2017-07-19 21:27:13 -04:00
Timm Bäder
753e915f87 scrollbar: Add accessor for wheel delta
Make the one in gtkrange.c static since it was only ever used from
GtkScrolledWindow.
2017-07-19 21:27:12 -04:00
Timm Bäder
706bc08b68 range: Draw the colorscale trough at 0,0 2017-07-19 21:27:12 -04:00
Timm Bäder
2e62072cbc range: Allocate the trough when the adjustment value changes
So it repositions the slider.
2017-07-19 21:27:12 -04:00
Timm Bäder
38ff761313 range: Fix mouse location tracking 2017-07-19 21:27:12 -04:00
Timm Bäder
afddfc2397 range: Snapshot slider in trough's snapshot impl 2017-07-19 21:27:12 -04:00
Timm Bäder
6e74975e41 range: make the slider a gadget 2017-07-19 21:27:12 -04:00
Timm Bäder
ba6ba94184 range: Use gizmos for highlight and fill gadgets 2017-07-19 21:27:12 -04:00
Timm Bäder
395185896f range: Use a gizmo as trough 2017-07-19 21:27:12 -04:00
Timm Bäder
90cc401f1a range: Remove contents gadget
It's not needed anymore since the range only has one child gadget: the
trough.
2017-07-19 21:27:12 -04:00
Timm Bäder
7e525ca63b range: Remove steppers
Add them back into the new scrollbars later
2017-07-19 21:27:12 -04:00
Timm Bäder
5049b35fc6 range: Make GtkRange a regular class 2017-07-19 21:27:12 -04:00
Timm Bäder
9e79684762 range: Remove gadget completely 2017-07-19 21:27:12 -04:00
Timm Bäder
1d782b8930 scale: Fix value position
by not using the range's gadget which is not allocated to any position
anymore.
2017-07-19 21:27:12 -04:00
Timm Bäder
bb7b1c56ae range: Remove gadget usage 2017-07-19 21:27:11 -04:00
Carlos Garnacho
c14e6a5119 gtkrange: Remove event window
This is not necessary anymore to receive input events.
2017-05-25 16:25:59 +02:00
Carlos Garnacho
a72404dd5a gtk: Mass delete all GtkWidget event mask API
We now rely on toplevels receiving and forwarding all the events
the windowing should be able to handle. Event masks are no longer a
way to determine whether an event is deliverable ot a widget.

Events will always be delivered in the three captured/target/bubbled
phases, widgets can now just attach GtkEventControllers and let those
handle the events.
2017-05-25 16:25:58 +02:00
Daniel Boles
db7ff6d88a Range: Remove leftover comment about update policy
Update policies were removed way back in 2011… in
commit c43a31ea33
2017-02-27 20:05:37 +00:00
Benjamin Otte
0dbdf0c428 gadget: Remove gtk_css_gadget_draw()
And with it, remove the draw func from custom gadgets, that has been
NULL everywhere.

All gadgets are snapshot now.
2016-12-20 18:01:12 +01:00
Benjamin Otte
81297857cc snapshot: Convert Range, Scale, ColorScale
And of course Scrollbar, but that one does no drawing itself.
2016-12-20 18:01:11 +01:00
Piotr Drąg
a2da4ddceb Use Unicode in translatable strings
See https://developer.gnome.org/hig/stable/typography.html

https://bugzilla.gnome.org/show_bug.cgi?id=772371
2016-12-19 15:08:10 -05:00
Benjamin Otte
da207c9fdd snapshot: Add a snapshot function to GtkCssCustomGadget 2016-11-15 17:48:45 +01:00
Benjamin Otte
c16a7d96b8 range: Don't leak pointers to discarded gadgets 2016-11-08 02:32:40 +01:00
Benjamin Otte
13d8ac83ee range: Use gdk_window_new_input() 2016-11-06 23:46:44 +01:00
Timm Bäder
9992a616ef widget: Use ::measure vfunc to measure size
Add a new ::measure vfunc similar to GtkCssGadget's that widget
implementations have to override instead of the old get_preferred_width,
get_preferred_height, get_preferred_width_for_height,
get_preferred_height_for_width and
get_preferred_height_and_baseline_for_width.
2016-10-22 19:05:47 +02:00
Timm Bäder
3c901d6376 Remove a few more unused style properties 2016-10-16 18:17:21 +02:00
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