[gtk+/wip/actor: 2/24] sizerequestcache: Store floats instead of ints



commit 55f3ad0bf3b7d35a828a3a1e2cb64ee3fbf3d190
Author: Benjamin Otte <otte redhat com>
Date:   Thu Nov 15 00:22:35 2012 +0100

    sizerequestcache: Store floats instead of ints
    
    This is in preparation for the GtkActor work.

 gtk/gtksizerequest.c             |   10 ++++++++--
 gtk/gtksizerequestcache.c        |   12 ++++++------
 gtk/gtksizerequestcacheprivate.h |   20 ++++++++++----------
 3 files changed, 24 insertions(+), 18 deletions(-)
---
diff --git a/gtk/gtksizerequest.c b/gtk/gtksizerequest.c
index 7ad9439..ee87a3a 100644
--- a/gtk/gtksizerequest.c
+++ b/gtk/gtksizerequest.c
@@ -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;
diff --git a/gtk/gtksizerequestcache.c b/gtk/gtksizerequestcache.c
index 102e2dd..7f2b1bb 100644
--- a/gtk/gtksizerequestcache.c
+++ b/gtk/gtksizerequestcache.c
@@ -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;
 
diff --git a/gtk/gtksizerequestcacheprivate.h b/gtk/gtksizerequestcacheprivate.h
index ac851dd..9254b86 100644
--- a/gtk/gtksizerequestcacheprivate.h
+++ b/gtk/gtksizerequestcacheprivate.h
@@ -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
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]