[dia/zbrown/test-build: 6/7] enums: finally rename TextFitting
- From: Zander Brown <zbrown src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia/zbrown/test-build: 6/7] enums: finally rename TextFitting
- Date: Mon, 27 Sep 2021 08:21:40 +0000 (UTC)
commit b6b7c5699549d7c1262c68ca216fe91aebf4b1f1
Author: Zander Brown <zbrown gnome org>
Date: Mon Sep 27 03:04:13 2021 +0100
enums: finally rename TextFitting
lib/dia-enums.h | 10 +++++-----
lib/libdia.def | 7 +++++++
lib/properties.c | 6 +++---
lib/properties.h | 6 +++---
objects/custom/custom_object.c | 16 ++++++++--------
objects/flowchart/box.c | 33 +++++++++++++++++++--------------
objects/flowchart/diamond.c | 25 ++++++++++++++-----------
objects/flowchart/ellipse.c | 25 ++++++++++++++-----------
objects/flowchart/parallelogram.c | 31 +++++++++++++++++--------------
9 files changed, 90 insertions(+), 69 deletions(-)
---
diff --git a/lib/dia-enums.h b/lib/dia-enums.h
index 736aba8bb..50d0a8889 100644
--- a/lib/dia-enums.h
+++ b/lib/dia-enums.h
@@ -57,11 +57,11 @@ typedef enum /*< enum >*/ {
DIA_ALIGN_RIGHT
} DiaAlignment;
-typedef enum {
- TEXTFIT_NEVER,
- TEXTFIT_WHEN_NEEDED,
- TEXTFIT_ALWAYS
-} TextFitting;
+typedef enum /*< enum >*/ {
+ DIA_TEXT_FIT_NEVER,
+ DIA_TEXT_FIT_WHEN_NEEDED,
+ DIA_TEXT_FIT_ALWAYS
+} DiaTextFitting;
/* Used to be in widgets.h polluting a lot of object implementations */
#define DEFAULT_LINESTYLE LINESTYLE_SOLID
diff --git a/lib/libdia.def b/lib/libdia.def
index 3d6f1db11..2f50ea5d2 100644
--- a/lib/libdia.def
+++ b/lib/libdia.def
@@ -565,6 +565,13 @@ EXPORTS
get_paper_rmargin
get_paper_tmargin
+ dia_line_caps_get_type
+ dia_line_join_get_type
+ dia_line_style_get_type
+ dia_fill_style_get_type
+ dia_alignment_get_type
+ dia_text_fitting_get_type
+
dia_unit_get_type
dia_unit_get_name
dia_unit_get_symbol
diff --git a/lib/properties.c b/lib/properties.c
index 14fc65b86..99c5deb91 100644
--- a/lib/properties.c
+++ b/lib/properties.c
@@ -64,9 +64,9 @@ PropEnumData prop_std_text_align_data[] = {
};
/* how the text box interacts with it's containing shape */
PropEnumData prop_std_text_fitting_data[] = {
- { N_("Never"), TEXTFIT_NEVER },
- { N_("When Needed"), TEXTFIT_WHEN_NEEDED },
- { N_("Always"), TEXTFIT_ALWAYS },
+ { N_("Never"), DIA_TEXT_FIT_NEVER },
+ { N_("When Needed"), DIA_TEXT_FIT_WHEN_NEEDED },
+ { N_("Always"), DIA_TEXT_FIT_ALWAYS },
{ NULL, 0 }
};
PropEnumData prop_std_line_join_data[] = {
diff --git a/lib/properties.h b/lib/properties.h
index 2615cd6e1..f6b8363fa 100644
--- a/lib/properties.h
+++ b/lib/properties.h
@@ -615,9 +615,9 @@ static PropEnumData prop_std_text_align_data[] = {
{ NULL, 0 }
};
static PropEnumData prop_std_text_fitting_data[] = {
- { N_("Never"), TEXTFIT_NEVER },
- { N_("When Needed"), TEXTFIT_WHEN_NEEDED },
- { N_("Always"), TEXTFIT_ALWAYS },
+ { N_("Never"), DIA_TEXT_FIT_NEVER },
+ { N_("When Needed"), DIA_TEXT_FIT_WHEN_NEEDED },
+ { N_("Always"), DIA_TEXT_FIT_ALWAYS },
{ NULL, 0 }
};
static PropEnumData prop_std_line_join_data[] = {
diff --git a/objects/custom/custom_object.c b/objects/custom/custom_object.c
index bc460530c..cc8fcffa9 100644
--- a/objects/custom/custom_object.c
+++ b/objects/custom/custom_object.c
@@ -108,7 +108,7 @@ struct _Custom {
Text *text;
double padding;
- TextFitting text_fitting;
+ DiaTextFitting text_fitting;
};
@@ -1342,7 +1342,7 @@ custom_update_data(Custom *custom, AnchorShape horiz, AnchorShape vert)
/* resize shape if text does not fit inside text_bounds */
if ( (info->has_text)
- && (custom->text_fitting != TEXTFIT_NEVER)) {
+ && (custom->text_fitting != DIA_TEXT_FIT_NEVER)) {
real text_width, text_height;
real xscale = 0.0, yscale = 0.0;
DiaRectangle tb;
@@ -1356,8 +1356,8 @@ custom_update_data(Custom *custom, AnchorShape horiz, AnchorShape vert)
transform_rect(custom, &info->text_bounds, &tb);
xscale = text_width / (tb.right - tb.left);
- if ( custom->text_fitting == TEXTFIT_ALWAYS
- || ( custom->text_fitting == TEXTFIT_WHEN_NEEDED
+ if ( custom->text_fitting == DIA_TEXT_FIT_ALWAYS
+ || ( custom->text_fitting == DIA_TEXT_FIT_WHEN_NEEDED
&& xscale > 1.00000001)) {
elem->width *= xscale;
custom->xscale *= xscale;
@@ -1367,8 +1367,8 @@ custom_update_data(Custom *custom, AnchorShape horiz, AnchorShape vert)
}
yscale = text_height / (tb.bottom - tb.top);
- if ( custom->text_fitting == TEXTFIT_ALWAYS
- || ( custom->text_fitting == TEXTFIT_WHEN_NEEDED
+ if ( custom->text_fitting == DIA_TEXT_FIT_ALWAYS
+ || ( custom->text_fitting == DIA_TEXT_FIT_WHEN_NEEDED
&& yscale > 1.00000001)) {
elem->height *= yscale;
custom->yscale *= yscale;
@@ -1739,7 +1739,7 @@ custom_create(Point *startpoint,
g_clear_object (&font);
/* _no_ new default: does not shrink with textbox automatically. */
- custom->text_fitting = (info->resize_with_text ? TEXTFIT_WHEN_NEEDED : TEXTFIT_NEVER);
+ custom->text_fitting = (info->resize_with_text ? DIA_TEXT_FIT_WHEN_NEEDED : DIA_TEXT_FIT_NEVER);
}
shape_info_realise(custom->info);
element_init(elem, 8, info->nconnections);
@@ -1856,7 +1856,7 @@ custom_load_using_properties(ObjectNode obj_node, int version,DiaContext *ctx)
if (version < 1)
custom->padding = 0.5 * M_SQRT1_2; /* old padding */
/* old default: only grow from text box, no auto-shrink. */
- custom->text_fitting = (custom->info->resize_with_text ? TEXTFIT_WHEN_NEEDED : TEXTFIT_NEVER);
+ custom->text_fitting = (custom->info->resize_with_text ? DIA_TEXT_FIT_WHEN_NEEDED : DIA_TEXT_FIT_NEVER);
object_load_props(obj,obj_node,ctx);
custom_update_data(custom, ANCHOR_MIDDLE, ANCHOR_MIDDLE);
diff --git a/objects/flowchart/box.c b/objects/flowchart/box.c
index 94c653e8a..dbed275f2 100644
--- a/objects/flowchart/box.c
+++ b/objects/flowchart/box.c
@@ -66,7 +66,7 @@ struct _Box {
Text *text;
double padding;
- TextFitting text_fitting;
+ DiaTextFitting text_fitting;
};
typedef struct _BoxProperties {
@@ -413,13 +413,14 @@ box_update_data(Box *box, AnchorShape horiz, AnchorShape vert)
* width calculated from text-width, padding and border), then
* set the width to the minimum. Or else;)
*/
- if (box->text_fitting != TEXTFIT_NEVER) {
- if ( box->text_fitting == TEXTFIT_ALWAYS
- || width > elem->width)
+ if (box->text_fitting != DIA_TEXT_FIT_NEVER) {
+ if (box->text_fitting == DIA_TEXT_FIT_ALWAYS || width > elem->width) {
elem->width = width;
- if ( box->text_fitting == TEXTFIT_ALWAYS
- || height > elem->height)
+ }
+
+ if (box->text_fitting == DIA_TEXT_FIT_ALWAYS || height > elem->height) {
elem->height = height;
+ }
}
/* move shape if necessary ... */
@@ -611,7 +612,7 @@ box_create(Point *startpoint,
g_clear_object (&font);
/* new default: let the user decide the size */
- box->text_fitting = TEXTFIT_WHEN_NEEDED;
+ box->text_fitting = DIA_TEXT_FIT_WHEN_NEEDED;
element_init(elem, 8, NUM_CONNECTIONS);
@@ -674,11 +675,14 @@ box_save(Box *box, ObjectNode obj_node, DiaContext *ctx)
data_add_text(new_attribute(obj_node, "text"), box->text, ctx);
- if (box->text_fitting != TEXTFIT_WHEN_NEEDED)
- data_add_enum(new_attribute(obj_node, PROP_STDNAME_TEXT_FITTING),
- box->text_fitting, ctx);
+ if (box->text_fitting != DIA_TEXT_FIT_WHEN_NEEDED) {
+ data_add_enum (new_attribute (obj_node, PROP_STDNAME_TEXT_FITTING),
+ box->text_fitting,
+ ctx);
+ }
}
+
static DiaObject *
box_load(ObjectNode obj_node, int version,DiaContext *ctx)
{
@@ -748,10 +752,11 @@ box_load(ObjectNode obj_node, int version,DiaContext *ctx)
}
/* old default: only growth, manual shrink */
- box->text_fitting = TEXTFIT_WHEN_NEEDED;
- attr = object_find_attribute(obj_node, PROP_STDNAME_TEXT_FITTING);
- if (attr != NULL)
- box->text_fitting = data_enum(attribute_first_data(attr), ctx);
+ box->text_fitting = DIA_TEXT_FIT_WHEN_NEEDED;
+ attr = object_find_attribute (obj_node, PROP_STDNAME_TEXT_FITTING);
+ if (attr != NULL) {
+ box->text_fitting = data_enum (attribute_first_data (attr), ctx);
+ }
element_init(elem, 8, NUM_CONNECTIONS);
diff --git a/objects/flowchart/diamond.c b/objects/flowchart/diamond.c
index d6595ec1e..883f94f3f 100644
--- a/objects/flowchart/diamond.c
+++ b/objects/flowchart/diamond.c
@@ -66,7 +66,7 @@ struct _Diamond {
Text *text;
double padding;
- TextFitting text_fitting;
+ DiaTextFitting text_fitting;
};
typedef struct _DiamondProperties {
@@ -422,8 +422,8 @@ diamond_update_data(Diamond *diamond, AnchorShape horiz, AnchorShape vert)
height = diamond->text->height * diamond->text->numlines +
2 * diamond->padding + diamond->border_width;
- if (diamond->text_fitting == TEXTFIT_ALWAYS
- || ( diamond->text_fitting == TEXTFIT_WHEN_NEEDED
+ if (diamond->text_fitting == DIA_TEXT_FIT_ALWAYS
+ || ( diamond->text_fitting == DIA_TEXT_FIT_WHEN_NEEDED
&& height > (elem->width - width) * elem->height / elem->width)) {
/* increase size of the diamond while keeping its aspect ratio */
real grad = elem->width/elem->height;
@@ -579,7 +579,7 @@ diamond_create(Point *startpoint,
g_clear_object (&font);
/* new default: let the user decide the size */
- diamond->text_fitting = TEXTFIT_WHEN_NEEDED;
+ diamond->text_fitting = DIA_TEXT_FIT_WHEN_NEEDED;
element_init(elem, 8, NUM_CONNECTIONS);
@@ -644,9 +644,11 @@ diamond_save(Diamond *diamond, ObjectNode obj_node, DiaContext *ctx)
data_add_text(new_attribute(obj_node, "text"), diamond->text, ctx);
- if (diamond->text_fitting != TEXTFIT_WHEN_NEEDED)
- data_add_enum(new_attribute(obj_node, PROP_STDNAME_TEXT_FITTING),
- diamond->text_fitting, ctx);
+ if (diamond->text_fitting != DIA_TEXT_FIT_WHEN_NEEDED) {
+ data_add_enum (new_attribute (obj_node, PROP_STDNAME_TEXT_FITTING),
+ diamond->text_fitting,
+ ctx);
+ }
}
static DiaObject *
@@ -714,10 +716,11 @@ diamond_load(ObjectNode obj_node, int version,DiaContext *ctx)
}
/* old default: only growth, manual shrink */
- diamond->text_fitting = TEXTFIT_WHEN_NEEDED;
- attr = object_find_attribute(obj_node, PROP_STDNAME_TEXT_FITTING);
- if (attr != NULL)
- diamond->text_fitting = data_enum(attribute_first_data(attr), ctx);
+ diamond->text_fitting = DIA_TEXT_FIT_WHEN_NEEDED;
+ attr = object_find_attribute (obj_node, PROP_STDNAME_TEXT_FITTING);
+ if (attr != NULL) {
+ diamond->text_fitting = data_enum (attribute_first_data (attr), ctx);
+ }
element_init(elem, 8, NUM_CONNECTIONS);
diff --git a/objects/flowchart/ellipse.c b/objects/flowchart/ellipse.c
index dc329ef01..7f551e587 100644
--- a/objects/flowchart/ellipse.c
+++ b/objects/flowchart/ellipse.c
@@ -66,7 +66,7 @@ struct _Ellipse {
Text *text;
double padding;
- TextFitting text_fitting;
+ DiaTextFitting text_fitting;
};
typedef struct _EllipseProperties {
@@ -432,9 +432,9 @@ ellipse_update_data(Ellipse *ellipse, AnchorShape horiz, AnchorShape vert)
radius1 = ellipse_radius(ellipse, p.x, p.y) - ellipse->border_width/2;
radius2 = distance_point_point(&c, &p);
- if ( (radius1 < radius2 && ellipse->text_fitting == TEXTFIT_WHEN_NEEDED)
+ if ( (radius1 < radius2 && ellipse->text_fitting == DIA_TEXT_FIT_WHEN_NEEDED)
/* stop infinite resizing with 5% tolerance obsvered with _test_movement */
- || (fabs(1.0 - radius2 / radius1) > 0.05 && ellipse->text_fitting == TEXTFIT_ALWAYS)) {
+ || (fabs(1.0 - radius2 / radius1) > 0.05 && ellipse->text_fitting == DIA_TEXT_FIT_ALWAYS)) {
/* increase size of the ellipse while keeping its aspect ratio */
elem->width *= radius2 / radius1;
elem->height *= radius2 / radius1;
@@ -558,7 +558,7 @@ ellipse_create(Point *startpoint,
g_clear_object (&font);
/* new default: let the user decide the size */
- ellipse->text_fitting = TEXTFIT_WHEN_NEEDED;
+ ellipse->text_fitting = DIA_TEXT_FIT_WHEN_NEEDED;
element_init(elem, 8, NUM_CONNECTIONS);
@@ -622,9 +622,11 @@ ellipse_save(Ellipse *ellipse, ObjectNode obj_node, DiaContext *ctx)
data_add_text(new_attribute(obj_node, "text"), ellipse->text, ctx);
- if (ellipse->text_fitting != TEXTFIT_WHEN_NEEDED)
- data_add_enum(new_attribute(obj_node, PROP_STDNAME_TEXT_FITTING),
- ellipse->text_fitting, ctx);
+ if (ellipse->text_fitting != DIA_TEXT_FIT_WHEN_NEEDED) {
+ data_add_enum (new_attribute (obj_node, PROP_STDNAME_TEXT_FITTING),
+ ellipse->text_fitting,
+ ctx);
+ }
}
static DiaObject *
@@ -691,10 +693,11 @@ ellipse_load(ObjectNode obj_node, int version,DiaContext *ctx)
}
/* old default: only growth, manual shrink */
- ellipse->text_fitting = TEXTFIT_WHEN_NEEDED;
- attr = object_find_attribute(obj_node, PROP_STDNAME_TEXT_FITTING);
- if (attr != NULL)
- ellipse->text_fitting = data_enum(attribute_first_data(attr), ctx);
+ ellipse->text_fitting = DIA_TEXT_FIT_WHEN_NEEDED;
+ attr = object_find_attribute (obj_node, PROP_STDNAME_TEXT_FITTING);
+ if (attr != NULL) {
+ ellipse->text_fitting = data_enum (attribute_first_data (attr), ctx);
+ }
element_init(elem, 8, NUM_CONNECTIONS);
diff --git a/objects/flowchart/parallelogram.c b/objects/flowchart/parallelogram.c
index ddc8bb9bb..d46b9ad83 100644
--- a/objects/flowchart/parallelogram.c
+++ b/objects/flowchart/parallelogram.c
@@ -67,7 +67,7 @@ struct _Pgram {
Text *text;
double padding;
- TextFitting text_fitting;
+ DiaTextFitting text_fitting;
};
typedef struct _PgramProperties {
@@ -430,16 +430,16 @@ pgram_update_data(Pgram *pgram, AnchorShape horiz, AnchorShape vert)
text_calc_boundingbox(pgram->text, NULL);
height = pgram->text->height * pgram->text->numlines + pgram->padding*2 +
pgram->border_width;
- if ( pgram->text_fitting == TEXTFIT_ALWAYS
- || (pgram->text_fitting == TEXTFIT_WHEN_NEEDED
+ if ( pgram->text_fitting == DIA_TEXT_FIT_ALWAYS
+ || (pgram->text_fitting == DIA_TEXT_FIT_WHEN_NEEDED
&& height > elem->height))
elem->height = height;
avail_width = elem->width - (pgram->padding*2 + pgram->border_width +
fabs(pgram->shear_grad) * (elem->height + pgram->text->height
* pgram->text->numlines));
- if ( pgram->text_fitting == TEXTFIT_ALWAYS
- || (pgram->text_fitting == TEXTFIT_WHEN_NEEDED
+ if ( pgram->text_fitting == DIA_TEXT_FIT_ALWAYS
+ || (pgram->text_fitting == DIA_TEXT_FIT_WHEN_NEEDED
&& avail_width < pgram->text->max_width)) {
elem->width = (elem->width-avail_width) + pgram->text->max_width;
avail_width = pgram->text->max_width;
@@ -633,7 +633,7 @@ pgram_create(Point *startpoint,
g_clear_object (&font);
/* new default: let the user decide the size */
- pgram->text_fitting = TEXTFIT_WHEN_NEEDED;
+ pgram->text_fitting = DIA_TEXT_FIT_WHEN_NEEDED;
element_init(elem, 8, NUM_CONNECTIONS);
@@ -698,10 +698,12 @@ pgram_save(Pgram *pgram, ObjectNode obj_node, DiaContext *ctx)
data_add_real(new_attribute(obj_node, "padding"), pgram->padding, ctx);
- data_add_text(new_attribute(obj_node, "text"), pgram->text, ctx);
- if (pgram->text_fitting != TEXTFIT_WHEN_NEEDED)
- data_add_enum(new_attribute(obj_node, PROP_STDNAME_TEXT_FITTING),
- pgram->text_fitting, ctx);
+ data_add_text (new_attribute (obj_node, "text"), pgram->text, ctx);
+ if (pgram->text_fitting != DIA_TEXT_FIT_WHEN_NEEDED) {
+ data_add_enum (new_attribute (obj_node, PROP_STDNAME_TEXT_FITTING),
+ pgram->text_fitting,
+ ctx);
+ }
}
static DiaObject *
@@ -775,10 +777,11 @@ pgram_load(ObjectNode obj_node, int version,DiaContext *ctx)
}
/* old default: only growth, manual shrink */
- pgram->text_fitting = TEXTFIT_WHEN_NEEDED;
- attr = object_find_attribute(obj_node, PROP_STDNAME_TEXT_FITTING);
- if (attr != NULL)
- pgram->text_fitting = data_enum(attribute_first_data(attr), ctx);
+ pgram->text_fitting = DIA_TEXT_FIT_WHEN_NEEDED;
+ attr = object_find_attribute (obj_node, PROP_STDNAME_TEXT_FITTING);
+ if (attr != NULL) {
+ pgram->text_fitting = data_enum (attribute_first_data (attr), ctx);
+ }
element_init(elem, 8, NUM_CONNECTIONS);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]