summaryrefslogtreecommitdiff
path: root/gtk/gtksizerequestcache.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2013-03-05 14:54:03 +0100
committerAlexander Larsson <alexl@redhat.com>2013-04-23 05:50:37 +0200
commit852cbb62b8b98bb3345604ce1dcf4186613f74e8 (patch)
tree58315efdf359698bb49c6b0febfc86b28db40337 /gtk/gtksizerequestcache.c
parentf15bc7818e0941da80c4ee380a25daf7fcd99d72 (diff)
downloadgtk+-852cbb62b8b98bb3345604ce1dcf4186613f74e8.tar.gz
Initial support for baselines
This modifies the size machinery in order to allow baseline support. We add a new widget vfunc get_preferred_height_and_baseline_for_width which queries the normal height_for_width (or non-for-width if width is -1) and additionally returns optional (-1 means "no baseline") baselines for the minimal and natural heights. We also add a new gtk_widget_size_allocate_with_baseline() which baseline-aware containers can use to allocate children with a specific baseline, either one inherited from the parent, or one introduced due to requested baseline alignment in the container itself. size_allocate_with_baseline() works just like a normal size allocation, except the baseline gets recorded so that the child can access it via gtk_widget_get_allocated_baseline() when it aligns itself. There are also adjust_baseline_request/allocation similar to the allocation adjustment, and we extend the size request cache to also store the baselines.
Diffstat (limited to 'gtk/gtksizerequestcache.c')
-rw-r--r--gtk/gtksizerequestcache.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/gtk/gtksizerequestcache.c b/gtk/gtksizerequestcache.c
index 102e2ddd99..e6107c7cb1 100644
--- a/gtk/gtksizerequestcache.c
+++ b/gtk/gtksizerequestcache.c
@@ -67,7 +67,9 @@ _gtk_size_request_cache_commit (SizeRequestCache *cache,
GtkOrientation orientation,
gint for_size,
gint minimum_size,
- gint natural_size)
+ gint natural_size,
+ gint minimum_baseline,
+ gint natural_baseline)
{
SizeRequest **cached_sizes;
SizeRequest *cached_size;
@@ -78,6 +80,8 @@ _gtk_size_request_cache_commit (SizeRequestCache *cache,
{
cache->cached_size[orientation].minimum_size = minimum_size;
cache->cached_size[orientation].natural_size = natural_size;
+ cache->cached_size[orientation].minimum_baseline = minimum_baseline;
+ cache->cached_size[orientation].natural_baseline = natural_baseline;
cache->flags[orientation].cached_size_valid = TRUE;
return;
}
@@ -92,7 +96,9 @@ _gtk_size_request_cache_commit (SizeRequestCache *cache,
for (i = 0; i < n_sizes; i++)
{
if (cached_sizes[i]->cached_size.minimum_size == minimum_size &&
- cached_sizes[i]->cached_size.natural_size == natural_size)
+ cached_sizes[i]->cached_size.natural_size == natural_size &&
+ cached_sizes[i]->cached_size.minimum_baseline == minimum_baseline &&
+ cached_sizes[i]->cached_size.natural_baseline == natural_baseline)
{
cached_sizes[i]->lower_for_size = MIN (cached_sizes[i]->lower_for_size, for_size);
cached_sizes[i]->upper_for_size = MAX (cached_sizes[i]->upper_for_size, for_size);
@@ -125,6 +131,8 @@ _gtk_size_request_cache_commit (SizeRequestCache *cache,
cached_size->upper_for_size = for_size;
cached_size->cached_size.minimum_size = minimum_size;
cached_size->cached_size.natural_size = natural_size;
+ cached_size->cached_size.minimum_baseline = minimum_baseline;
+ cached_size->cached_size.natural_baseline = natural_baseline;
}
/* looks for a cached size request for this for_size.
@@ -137,7 +145,9 @@ _gtk_size_request_cache_lookup (SizeRequestCache *cache,
GtkOrientation orientation,
gint for_size,
gint *minimum,
- gint *natural)
+ gint *natural,
+ gint *minimum_baseline,
+ gint *natural_baseline)
{
CachedSize *result = NULL;
@@ -168,6 +178,8 @@ _gtk_size_request_cache_lookup (SizeRequestCache *cache,
{
*minimum = result->minimum_size;
*natural = result->natural_size;
+ *minimum_baseline = result->minimum_baseline;
+ *natural_baseline = result->natural_baseline;
return TRUE;
}
else