sizerequestcache: Store floats instead of ints

This is in preparation for the GtkActor work.
This commit is contained in:
Benjamin Otte
2012-11-15 00:22:35 +01:00
parent 38df4155b7
commit 55f3ad0bf3
3 changed files with 24 additions and 18 deletions

View File

@@ -103,6 +103,7 @@ gtk_widget_query_size_for_orientation (GtkWidget *widget,
SizeRequestCache *cache;
gint min_size = 0;
gint nat_size = 0;
gfloat min_float, nat_float;
gboolean found_in_cache;
if (gtk_widget_get_request_mode (widget) == GTK_SIZE_REQUEST_CONSTANT_SIZE)
@@ -112,8 +113,8 @@ gtk_widget_query_size_for_orientation (GtkWidget *widget,
found_in_cache = _gtk_size_request_cache_lookup (cache,
orientation,
for_size,
&min_size,
&nat_size);
&min_float,
&nat_float);
if (!found_in_cache)
{
@@ -233,6 +234,11 @@ gtk_widget_query_size_for_orientation (GtkWidget *widget,
min_size,
nat_size);
}
else
{
min_size = min_float;
nat_size = nat_float;
}
if (minimum_size)
*minimum_size = min_size;

View File

@@ -65,9 +65,9 @@ _gtk_size_request_cache_clear (SizeRequestCache *cache)
void
_gtk_size_request_cache_commit (SizeRequestCache *cache,
GtkOrientation orientation,
gint for_size,
gint minimum_size,
gint natural_size)
gfloat for_size,
gfloat minimum_size,
gfloat natural_size)
{
SizeRequest **cached_sizes;
SizeRequest *cached_size;
@@ -135,9 +135,9 @@ _gtk_size_request_cache_commit (SizeRequestCache *cache,
gboolean
_gtk_size_request_cache_lookup (SizeRequestCache *cache,
GtkOrientation orientation,
gint for_size,
gint *minimum,
gint *natural)
gfloat for_size,
gfloat *minimum,
gfloat *natural)
{
CachedSize *result = NULL;

View File

@@ -39,14 +39,14 @@ G_BEGIN_DECLS
#define GTK_SIZE_REQUEST_CACHED_SIZES (5)
typedef struct {
gint minimum_size;
gint natural_size;
gfloat minimum_size;
gfloat natural_size;
} CachedSize;
typedef struct
{
gint lower_for_size; /* The minimum for_size with the same result */
gint upper_for_size; /* The maximum for_size with the same result */
gfloat lower_for_size; /* The minimum for_size with the same result */
gfloat upper_for_size; /* The maximum for_size with the same result */
CachedSize cached_size;
} SizeRequest;
@@ -70,14 +70,14 @@ void _gtk_size_request_cache_free (SizeRequestCach
void _gtk_size_request_cache_clear (SizeRequestCache *cache);
void _gtk_size_request_cache_commit (SizeRequestCache *cache,
GtkOrientation orientation,
gint for_size,
gint minimum_size,
gint natural_size);
gfloat for_size,
gfloat minimum_size,
gfloat natural_size);
gboolean _gtk_size_request_cache_lookup (SizeRequestCache *cache,
GtkOrientation orientation,
gint for_size,
gint *minimum,
gint *natural);
gfloat for_size,
gfloat *minimum,
gfloat *natural);
G_END_DECLS