Commit Graph

61 Commits

Author SHA1 Message Date
Benjamin Otte
87497ca2e1 snapshot: Rename gtk_snapshot_translate_2d()
It's now called gtk_snapshot_offset().
2017-01-13 14:37:48 +01:00
Alexander Larsson
c00f8dce9f GtkSnapshot: Always use int for the translation
We already take ints when setting the translation, so it can't
currently take any other values. Additionally, I was seeing large
costs in int -> double -> int for the rects in
gtk_snapshot_clips_rect(), as all callers really are ints (widget
allocations) and the clip region is int-based.

This change completely cleared a 2% rectangle_init_from_graphene from
the profile and is likely to have nice performance effects elsewhere
too.
2017-01-11 16:14:03 +01:00
Alexander Larsson
68a27a9951 gtkcssgadget: Use private non-checking versions of gtk_widget calls
This avoids a lot of checking overhead.
2017-01-11 12:05:44 +01:00
Matthias Clasen
ecd0ce3993 Use gtk_internal_return_val_if_fail here
It seems odd to have checks in just a few functions,
so switch everything over to use the internal versions.
2017-01-10 19:56:09 -05:00
Benjamin Otte
dcb15d6728 cssgadget: Compute clip correctly
We were computing it relative to the gadget allocation, but it should be
relative to the widget allocation.
2017-01-09 01:12:06 +01: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
95a2a5c54c gtk: Remove GtkJunctionSides 2016-12-20 18:01:12 +01:00
Benjamin Otte
9af468cdec gtk: Remove unused argument from function 2016-12-20 18:01:11 +01:00
Benjamin Otte
cb8483b0a6 gtk: Remove unneeded gtk_snapshot_push()/pop() calls 2016-12-09 21:39:43 +01:00
Benjamin Otte
633631a47b cssgadget: Compute relative to own allocation, not widget allocation
This would lead to clipped gadgets when the gadget allocation differed
from the widget allocation, like in GtkListBox.
2016-12-05 15:02:46 +01:00
Benjamin Otte
475cffd7f8 gadget: Remove gtk_css_gadget_get_render_node()
It's unused now that we can snapshot.
2016-11-15 17:49:19 +01:00
Benjamin Otte
4e06d8f73c snapshot: Add gtk_css_gadget_snapshot()
Including a snpahsot() vfunc, wee!
2016-11-15 17:48:45 +01:00
Matthias Clasen
30a56acc7d gadget: Add a get_render_node vfunc
This will let us do box gadgets like we do containers.
2016-11-01 14:29:25 -04:00
Benjamin Otte
a0e63b8a07 rendernode: Require passing a renderer to get_draw_context()
This is in preparation of making render nodes independent of the
renderer, so that they can be rendered multiple times with different
renderers.
2016-11-01 16:32:26 +01:00
Timm Bäder
48602e500c cssgadget: Move gadgets to their allocated position 2016-10-28 16:33:02 +02:00
Matthias Clasen
39c1aa5e27 Split css background into individual render nodes
Use separate render nodes for each layer in a multi-image
background. WARNING: blend modes don't work right yet.
2016-10-18 11:49:15 +01:00
Matthias Clasen
cffb8ae4b5 Break out the css background render node in a function
This is in preparation for creating separate render nodes
for individual backgrounds.
2016-10-18 11:49:14 +01:00
Matthias Clasen
f74dd416d6 Make outer shadows work again
Change get_render_node to return nodes that are sized to the clip
area and expect to be placed at the clip position; change
gtk_container_propagate_render_node to place child render nodes
accordingly, and change gtk_css_gadget_get_render_node to return
nodes that are sized accordingly as well.
2016-10-18 11:49:14 +01:00
Emmanuele Bassi
b2f5a69742 gtk: Add a box render node for gadgets
Instead of using the background as the gadget's node, we add a
non-drawing node that can be used to apply offsets; all other nodes are
children of the "box" node.
2016-10-18 11:49:13 +01:00
Matthias Clasen
1046262048 gadget: Fix handling of custom content
The transformations here were wrong, causing content to go nowhere.
This patch fixes check and radio buttons to appear as expected.
2016-10-18 11:49:13 +01:00
Matthias Clasen
62eb900b83 gadget: Add a has_content vfunc
...and implement it for GtkCssGadget and GtkCssCustomGadget.
This allows us to decide on a per-object basis if a custom
gadget needs a render node for content or not.
2016-10-18 11:49:12 +01:00
Matthias Clasen
02187371a2 Add details to css render nodes
Give all nodes the same detail about the owner widget.
This reveals that every GtkCssCustomGadget gets a
DrawGadgetContents node, even if their draw_func is NULL.
We may want to come up with a better solution for that.
2016-10-18 11:49:12 +01:00
Matthias Clasen
b371b5da42 Drop an unused variable 2016-10-18 11:49:12 +01:00
Emmanuele Bassi
abe19f1826 gtk: Attempt at handling CSS coordinates
When creating the GskRenderNodes for the gadgets we should not translate
the coordinates inside the Cairo context, but we should tweak the
coordinates of the anchor point.

This is still not enough to get an appropriate rendering, as the result
is still slightly offset to the left.
2016-10-18 11:49:12 +01:00
Emmanuele Bassi
e5dace2d51 Integrate CSS gadget with GSK render nodes
First stab at an internal API that generates render nodes when drawing a
CSS gadget.
2016-10-18 11:49:10 +01:00
Timm Bäder
c1d1d46d34 cssgadget: Remove unused function 2016-05-05 11:31:41 +02:00
Matthias Clasen
d58885c9b9 css gadget: Fix baseline debug
We were not using the baseline that we're computing.
2016-04-19 23:26:57 -04:00
Matthias Clasen
c01befe5cc css gadget: Don't get display flags twice
This got more expensive now that we store them per-display,
so don't get them twice in the same function.
2016-04-19 23:26:57 -04:00
Matthias Clasen
1a5cb41bd9 Use per-display debug flags for visual debugging 2016-03-11 00:22:36 -05:00
Matthias Clasen
ad54697594 gadget: Show layout
When the layout debug key is set, overlay boxes for the content
and border area of each gadget.
2016-03-10 23:21:22 -05:00
Matthias Clasen
4d2e7a0314 gadget: Add more details to warning
All the other warnings in this file include the css node name
and the gadget owners type. Be consistent about this.
2016-03-04 13:56:26 -05:00
Matthias Clasen
51b83c4389 gadget: Warn if for_size is too small
It does not make sense to pass a for_size into the size allocation
machinery that is smaller than the min-size in that direction.
Warn if it happens, so we can track it down when it occurs.
2016-03-04 13:43:19 -05:00
Cosimo Cecchi
0fb50dc9a8 gadget: improve debug message 2016-02-29 10:45:14 -08:00
Cosimo Cecchi
3ff66edb6b gadget: simplify code 2016-02-29 10:45:13 -08:00
Cosimo Cecchi
44178c0541 gadget: add API to get various area boxes
Compared to the function returning the allocation, these will return the
box in gadget coordinates.
2016-02-29 10:45:13 -08:00
Cosimo Cecchi
e9fe46ea5f gadget: add hit test functions
These will be useful in later commits.
2016-02-29 10:45:12 -08:00
Matthias Clasen
09b1571093 Better baseline adjustment
The way we were adjusting baselines if min-height forces
a size increase was not quite working as intended. Redo
it in a simpler way: just split up the excess and count
half of it for above the baseline and half below.

This fixes button labels in dialogs appearing too low.
2016-02-25 16:36:13 -05:00
Matthias Clasen
dde33623ca gadget: Warn about missing size allocation
When size_allocate is overridden in widgets, but draw is not,
we can end up drawing a gadget that has not been given a size.

Warn about this, and limp along by drawing the gadget over the
full allocation of its owner widget.

https://bugzilla.gnome.org/show_bug.cgi?id=762614
2016-02-24 22:22:11 -05:00
Matthias Clasen
a754579e44 css gadget: Adjust baselines for min-height
We were forcing the size to be at least min-height, but we left the
baselines as they were, which had the effect of making text e.g
in entries 'stick to the top'.

With this change, we adjust the baseline to keep the ratio of
baseline to height unchanged.
2016-02-20 22:31:39 -05:00
Benjamin Otte
e4a485dca2 renderborder: Add API to query the outline clip
And use it in implementation of gadgets.
2016-02-21 01:02:51 +01:00
Matthias Clasen
51af70495a gadget: Be careful in geometry calculations
Margins can be negative, and if we are not careful, then
content+padding+margin can end up with negative dimensions,
which can upset pixman and others. This commit ensures
that a gadget will not request or draw boxes with negative
dimensions, and get_border_allocation and get_content_allocation
will not return boxes with negative dimensions.

This fixes a crash in the paned separator drawing code that
can be reproduced by setting separator padding to 0.

https://bugzilla.gnome.org/show_bug.cgi?id=759657
2016-02-12 22:26:04 -05:00
Matthias Clasen
029d568b04 gadget: Add baseline debugging
This should help to understand whats going wrong with
baselines.
2016-01-22 21:34:54 -05:00
Benjamin Otte
a6845091f9 spinbutton: Make the entry gadget be the entry's gadget
This is a big and somewhat evil hack: We replace the entry's gadget's
node with the spinbutton's entry node.
2016-01-22 13:46:01 +01:00
Benjamin Otte
8020d5f93a notebook: Don't store gadget allocation twice
If we care about a gadget's allocation, we can ask it. There's no need
to store it in GtkNotebookPage.allocation.
2016-01-11 17:05:24 +01:00
Benjamin Otte
f1e277969a gadget: Add queue_resize/allocate/draw() functions 2016-01-11 17:05:23 +01:00
Benjamin Otte
8c1a73326c gadget: Add helpers for modifying state
They will be used in future commits.

I also was too lazy to convert existing widgets.
2016-01-11 17:05:22 +01:00
Timm Bäder
ca6d01a678 GtkCssGadget: Set valid clip values for invisible gadgets 2016-01-07 20:39:37 +01:00
Benjamin Otte
acbff85402 gadget: Handle visibility
As GtkCssNode has the visibility concept, it makes sense to mirror it in
gadgets.

Do what visibility does in widgets: Hidden gadgets can't be drawn or
allocated and request a 0x0 size.

Note that just like widgets, gadget visibility must not be changed in
size request, allocate or draw handlers.

GtkWidget::child-visible has no equivalent yet, code will have to
emulate that manually.
2015-12-29 13:48:58 -08:00
Cosimo Cecchi
105b45dce0 cssgadget: print more information when warning 2015-12-21 09:22:16 -08:00
Cosimo Cecchi
5611e81bbc cssgadget: fix fallback case
We should be resetting the height here, not the width.
2015-12-21 09:22:16 -08:00