[goffice] Fix text alignment. [#728752]
- From: Jean Bréfort <jbrefort src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Fix text alignment. [#728752]
- Date: Wed, 23 Apr 2014 15:08:53 +0000 (UTC)
commit ef19e2035261a3f325a7c287eec8c2de0eb85eeb
Author: Jean Brefort <jean brefort normalesup org>
Date: Wed Apr 23 17:08:38 2014 +0200
Fix text alignment. [#728752]
ChangeLog | 8 ++++++++
NEWS | 1 +
goffice/graph/goffice-graph.h | 5 ++++-
goffice/graph/gog-graph.c | 3 ++-
goffice/graph/gog-label.c | 2 +-
goffice/graph/gog-object.c | 13 ++++++++-----
6 files changed, 24 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c10d1e5..0d096b4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2014-04-23 Jean Brefort <jean brefort normalesup org>
+
+ * goffice/graph/goffice-graph.h: add expand fields to GogPosition.
+ * goffice/graph/gog-graph.c (gog_graph_class_init): make charts expand.
+ * goffice/graph/gog-label.c (gog_text_view_render): fix alignment.
+ * goffice/graph/gog-object.c (gog_object_get_manual_allocation): take expand
+ field into account. [#728752]
+
2014-04-22 Morten Welinder <terra gnome org>
* goffice/math/go-dtoa.c (go_dtoa): Mostly implement the
diff --git a/NEWS b/NEWS
index ea8a683..a881c37 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ goffice 0.10.15:
Jean:
* Explicitly allow manual charts size. [#728134]
* Fix automatic chart size for manual position. [#728391]
+ * Fix text alignment. [#728752]
Morten:
* Portability improvements.
diff --git a/goffice/graph/goffice-graph.h b/goffice/graph/goffice-graph.h
index 28cf54a..1343359 100644
--- a/goffice/graph/goffice-graph.h
+++ b/goffice/graph/goffice-graph.h
@@ -201,7 +201,10 @@ typedef enum {
GOG_POSITION_MANUAL_W_ABS = 1 << 22, /* absolute width */
GOG_POSITION_MANUAL_H = 1 << 23, /* relative height */
GOG_POSITION_MANUAL_H_ABS = 1 << 24, /* absolute height */
- GOG_POSITION_ANY_MANUAL_SIZE = 0x1e00000
+ GOG_POSITION_ANY_MANUAL_SIZE = 0x1e00000,
+ GOG_POSITION_HEXPAND = 1 << 25,
+ GOG_POSITION_VEXPAND = 1 << 26,
+ GOG_POSITION_EXPAND = GOG_POSITION_HEXPAND | GOG_POSITION_VEXPAND
} GogObjectPosition;
typedef enum {
diff --git a/goffice/graph/gog-graph.c b/goffice/graph/gog-graph.c
index 9375a33..8c45a48 100644
--- a/goffice/graph/gog-graph.c
+++ b/goffice/graph/gog-graph.c
@@ -422,7 +422,8 @@ gog_graph_class_init (GogGraphClass *klass)
static GogObjectRole const roles[] = {
{ N_("Chart"), "GogChart", 1,
- GOG_POSITION_SPECIAL|GOG_POSITION_ANY_MANUAL|GOG_POSITION_ANY_MANUAL_SIZE,
+ GOG_POSITION_SPECIAL|GOG_POSITION_ANY_MANUAL|
+ GOG_POSITION_ANY_MANUAL_SIZE|GOG_POSITION_EXPAND,
GOG_POSITION_SPECIAL,
GOG_OBJECT_NAME_BY_ROLE,
NULL, NULL, NULL, role_chart_post_add, role_chart_pre_remove, NULL },
diff --git a/goffice/graph/gog-label.c b/goffice/graph/gog-label.c
index 5292cda..78d33f7 100644
--- a/goffice/graph/gog-label.c
+++ b/goffice/graph/gog-label.c
@@ -739,7 +739,7 @@ gog_text_view_render (GogView *view, GogViewAllocation const *bbox)
GOStyle *style = text->base.base.style;
char *str = gog_text_get_str (text);
PangoAttrList *pl = gog_text_get_markup (text);
- double w = text->allow_wrap? view->allocation.w: -1.;
+ double w = text->allow_wrap? view->residual.w: -1.;
gog_renderer_push_style (view->renderer, style);
if (str != NULL) {
diff --git a/goffice/graph/gog-object.c b/goffice/graph/gog-object.c
index 131a18d..ca56e03 100644
--- a/goffice/graph/gog-object.c
+++ b/goffice/graph/gog-object.c
@@ -1932,7 +1932,7 @@ gog_object_get_manual_allocation (GogObject *gobj,
GogViewRequisition const *requisition)
{
GogViewAllocation pos;
- unsigned anchor, size;
+ unsigned anchor, size, expand;
GogManualSizeMode size_mode = gog_object_get_manual_size_mode (gobj);
pos.x = parent_allocation->x + gobj->manual_position.x * parent_allocation->w;
@@ -1940,11 +1940,12 @@ gog_object_get_manual_allocation (GogObject *gobj,
size = gog_object_get_position_flags (gobj, GOG_POSITION_ANY_MANUAL_SIZE);
anchor = gog_object_get_position_flags (gobj, GOG_POSITION_ANCHOR);
+ expand = gobj->role->allowable_positions & GOG_POSITION_EXPAND;
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 {
+ else if (expand & GOG_POSITION_HEXPAND) {
/* use available width */
switch (anchor) {
case GOG_POSITION_ANCHOR_N:
@@ -1964,7 +1965,8 @@ gog_object_get_manual_allocation (GogObject *gobj,
}
if (pos.w < requisition->w)
pos.w = requisition->w;
- }
+ } else
+ pos.w = requisition->w;
switch (anchor) {
case GOG_POSITION_ANCHOR_N:
@@ -1983,7 +1985,7 @@ gog_object_get_manual_allocation (GogObject *gobj,
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 {
+ else if (expand & GOG_POSITION_VEXPAND) {
/* use available width */
switch (anchor) {
case GOG_POSITION_ANCHOR_E:
@@ -2003,7 +2005,8 @@ gog_object_get_manual_allocation (GogObject *gobj,
}
if (pos.h < requisition->h)
pos.h = requisition->h;
- }
+ } else
+ 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]