[goffice] Fix automatic chart size for manual position. [#728391]



commit dfd3dee13c4b5c761c46de4a99d7ab0e4eb25a8f
Author: Jean Brefort <jean brefort normalesup org>
Date:   Thu Apr 17 14:47:21 2014 +0200

    Fix automatic chart size for manual position. [#728391]

 ChangeLog                  |    5 ++++
 NEWS                       |    1 +
 goffice/graph/gog-object.c |   58 ++++++++++++++++++++++++++++++++++++-------
 3 files changed, 54 insertions(+), 10 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8ea09e7..5d80429 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-04-17  Jean Brefort  <jean brefort normalesup org>
+
+       * goffice/graph/gog-object.c (gog_object_get_manual_allocation): use
+       available space when position is manual but size is automatic. [#728391]
+
 2014-04-16  Morten Welinder  <terra gnome org>
 
        * goffice/graph/gog-view.c (gog_view_size_request): Zero
diff --git a/NEWS b/NEWS
index b8c4748..77dd48f 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ goffice 0.10.15:
 
 Jean:
        * Explicitly allow manual charts size. [#728134]
+       * Fix automatic chart size for manual position. [#728391]
 
 Morten:
        * Portability improvements.
diff --git a/goffice/graph/gog-object.c b/goffice/graph/gog-object.c
index 0c9aaa2..92bec19 100644
--- a/goffice/graph/gog-object.c
+++ b/goffice/graph/gog-object.c
@@ -1939,18 +1939,32 @@ gog_object_get_manual_allocation (GogObject *gobj,
        pos.y = parent_allocation->y + gobj->manual_position.y * parent_allocation->h;
 
        size = gog_object_get_position_flags (gobj, GOG_POSITION_ANY_MANUAL_SIZE);
-
-       pos.w = ((size_mode & GOG_MANUAL_SIZE_WIDTH) &&
-                (size & (GOG_POSITION_MANUAL_W | GOG_POSITION_MANUAL_W_ABS)))?
-               gobj->manual_position.w * parent_allocation->w:
-               requisition->w;
-       pos.h = ((size_mode & GOG_MANUAL_SIZE_HEIGHT) &&
-                    (size & (GOG_POSITION_MANUAL_H | GOG_POSITION_MANUAL_H_ABS)))?
-               gobj->manual_position.h * parent_allocation->h:
-               requisition->h;
-
        anchor = gog_object_get_position_flags (gobj, GOG_POSITION_ANCHOR);
 
+       if ((size_mode & GOG_MANUAL_SIZE_WIDTH) &&
+                (size & (GOG_POSITION_MANUAL_W | GOG_POSITION_MANUAL_W_ABS)))
+               pos.w = gobj->manual_position.w * parent_allocation->w;
+       else {
+               /* use available width */
+               switch (anchor) {
+                       case GOG_POSITION_ANCHOR_N:
+                       case GOG_POSITION_ANCHOR_CENTER:
+                       case GOG_POSITION_ANCHOR_S:
+                               pos.w = MIN (gobj->manual_position.x, 1 - gobj->manual_position.x)
+                                                * 2. * parent_allocation->w;
+                               break;
+                       case GOG_POSITION_ANCHOR_SE:
+                       case GOG_POSITION_ANCHOR_E:
+                       case GOG_POSITION_ANCHOR_NE:
+                               pos.w = gobj->manual_position.x * parent_allocation->w;
+                               break;
+                       default:
+                               pos.w = (1 - gobj->manual_position.x) * parent_allocation->w;
+                               break;
+               }
+               if (pos.w < requisition->w)
+                       pos.w = requisition->w;
+
        switch (anchor) {
                case GOG_POSITION_ANCHOR_N:
                case GOG_POSITION_ANCHOR_CENTER:
@@ -1965,6 +1979,30 @@ gog_object_get_manual_allocation (GogObject *gobj,
                default:
                        break;
        }
+       if ((size_mode & GOG_MANUAL_SIZE_HEIGHT) &&
+                (size & (GOG_POSITION_MANUAL_H | GOG_POSITION_MANUAL_H_ABS)))
+               pos.h = gobj->manual_position.h * parent_allocation->h;
+       else {
+               /* use available width */
+               switch (anchor) {
+                       case GOG_POSITION_ANCHOR_E:
+                       case GOG_POSITION_ANCHOR_CENTER:
+                       case GOG_POSITION_ANCHOR_W:
+                               pos.h = MIN (gobj->manual_position.y, 1 - gobj->manual_position.y)
+                                                * 2. * parent_allocation->h;
+                               break;
+                       case GOG_POSITION_ANCHOR_SE:
+                       case GOG_POSITION_ANCHOR_S:
+                       case GOG_POSITION_ANCHOR_SW:
+                               pos.h = gobj->manual_position.y * parent_allocation->h;
+                               break;
+                       default:
+                               pos.h = (1 - gobj->manual_position.y) * parent_allocation->h;
+                               break;
+               }
+               if (pos.h < requisition->h)
+                       pos.h = requisition->h;
+       }
        switch (anchor) {
                case GOG_POSITION_ANCHOR_E:
                case GOG_POSITION_ANCHOR_CENTER:


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