[dia] standard: fix warnings
- From: Zander <zbrown src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] standard: fix warnings
- Date: Fri, 27 Mar 2020 19:51:33 +0000 (UTC)
commit fd0b14c0ca9a4e4e7cf129b800a7f75d411b5d3c
Author: Zander Brown <zbrown gnome org>
Date: Fri Mar 27 19:17:24 2020 +0000
standard: fix warnings
objects/standard/image.c | 206 +++++++++++++++++++++++++--------------------
objects/standard/outline.c | 69 ++++++++++-----
objects/standard/textobj.c | 33 +++++---
3 files changed, 182 insertions(+), 126 deletions(-)
---
diff --git a/objects/standard/image.c b/objects/standard/image.c
index ae297235..194122d4 100644
--- a/objects/standard/image.c
+++ b/objects/standard/image.c
@@ -319,22 +319,29 @@ image_distance_from(Image *image, Point *point)
return distance_rectangle_point(&rect, point);
}
+
static void
-image_select(Image *image, Point *clicked_point,
- DiaRenderer *interactive_renderer)
+image_select (Image *image,
+ Point *clicked_point,
+ DiaRenderer *interactive_renderer)
{
- element_update_handles(&image->element);
+ element_update_handles (&image->element);
}
+
static ObjectChange*
-image_move_handle(Image *image, Handle *handle,
- Point *to, ConnectionPoint *cp,
- HandleMoveReason reason, ModifierKeys modifiers)
+image_move_handle (Image *image,
+ Handle *handle,
+ Point *to,
+ ConnectionPoint *cp,
+ HandleMoveReason reason,
+ ModifierKeys modifiers)
{
Element *elem = &image->element;
- assert(image!=NULL);
- assert(handle!=NULL);
- assert(to!=NULL);
+
+ g_return_val_if_fail (image != NULL, NULL);
+ g_return_val_if_fail (handle != NULL, NULL);
+ g_return_val_if_fail (to != NULL, NULL);
if (image->keep_aspect) {
float width, height;
@@ -343,97 +350,109 @@ image_move_handle(Image *image, Handle *handle,
height = image->element.height;
switch (handle->id) {
- case HANDLE_RESIZE_NW:
- new_width = -(to->x-image->element.corner.x)+width;
- new_height = -(to->y-image->element.corner.y)+height;
- if (new_height == 0 || new_width/new_height > width/height) {
- new_height = new_width*height/width;
- } else {
- new_width = new_height*width/height;
- }
- to->x = image->element.corner.x+(image->element.width-new_width);
- to->y = image->element.corner.y+(image->element.height-new_height);
- element_move_handle(elem, HANDLE_RESIZE_NW, to, cp, reason, modifiers);
- break;
- case HANDLE_RESIZE_N:
- new_width = (-(to->y-image->element.corner.y)+height)*width/height;
- to->x = image->element.corner.x+new_width;
- element_move_handle(elem, HANDLE_RESIZE_NE, to, cp, reason, modifiers);
- break;
- case HANDLE_RESIZE_NE:
- new_width = to->x-image->element.corner.x;
- new_height = -(to->y-image->element.corner.y)+height;
- if (new_height == 0 || new_width/new_height > width/height) {
- new_height = new_width*height/width;
- } else {
- new_width = new_height*width/height;
- }
- to->x = image->element.corner.x+new_width;
- to->y = image->element.corner.y+(image->element.height-new_height);
- element_move_handle(elem, HANDLE_RESIZE_NE, to, cp, reason, modifiers);
- break;
- case HANDLE_RESIZE_E:
- new_height = (to->x-image->element.corner.x)*height/width;
- to->y = image->element.corner.y+new_height;
- element_move_handle(elem, HANDLE_RESIZE_SE, to, cp, reason, modifiers);
- break;
- case HANDLE_RESIZE_SE:
- new_width = to->x-image->element.corner.x;
- new_height = to->y-image->element.corner.y;
- if (new_height == 0 || new_width/new_height > width/height) {
- new_height = new_width*height/width;
- } else {
- new_width = new_height*width/height;
- }
- to->x = image->element.corner.x+new_width;
- to->y = image->element.corner.y+new_height;
- element_move_handle(elem, HANDLE_RESIZE_SE, to, cp, reason, modifiers);
- break;
- case HANDLE_RESIZE_S:
- new_width = (to->y-image->element.corner.y)*width/height;
- to->x = image->element.corner.x+new_width;
- element_move_handle(elem, HANDLE_RESIZE_SE, to, cp, reason, modifiers);
- break;
- case HANDLE_RESIZE_SW:
- new_width = -(to->x-image->element.corner.x)+width;
- new_height = to->y-image->element.corner.y;
- if (new_height == 0 || new_width/new_height > width/height) {
- new_height = new_width*height/width;
- } else {
- new_width = new_height*width/height;
- }
- to->x = image->element.corner.x+(image->element.width-new_width);
- to->y = image->element.corner.y+new_height;
- element_move_handle(elem, HANDLE_RESIZE_SW, to, cp, reason, modifiers);
- break;
- case HANDLE_RESIZE_W:
- new_height = (-(to->x-image->element.corner.x)+width)*height/width;
- to->y = image->element.corner.y+new_height;
- element_move_handle(elem, HANDLE_RESIZE_SW, to, cp, reason, modifiers);
- break;
- default:
- message_warning("Unforeseen handle in image_move_handle: %d\n",
- handle->id);
-
+ case HANDLE_RESIZE_NW:
+ new_width = -(to->x-image->element.corner.x)+width;
+ new_height = -(to->y-image->element.corner.y)+height;
+ if (new_height == 0 || new_width/new_height > width/height) {
+ new_height = new_width*height/width;
+ } else {
+ new_width = new_height*width/height;
+ }
+ to->x = image->element.corner.x+(image->element.width-new_width);
+ to->y = image->element.corner.y+(image->element.height-new_height);
+ element_move_handle (elem, HANDLE_RESIZE_NW, to, cp, reason, modifiers);
+ break;
+ case HANDLE_RESIZE_N:
+ new_width = (-(to->y-image->element.corner.y)+height)*width/height;
+ to->x = image->element.corner.x+new_width;
+ element_move_handle (elem, HANDLE_RESIZE_NE, to, cp, reason, modifiers);
+ break;
+ case HANDLE_RESIZE_NE:
+ new_width = to->x-image->element.corner.x;
+ new_height = -(to->y-image->element.corner.y)+height;
+ if (new_height == 0 || new_width/new_height > width/height) {
+ new_height = new_width*height/width;
+ } else {
+ new_width = new_height*width/height;
+ }
+ to->x = image->element.corner.x+new_width;
+ to->y = image->element.corner.y+(image->element.height-new_height);
+ element_move_handle (elem, HANDLE_RESIZE_NE, to, cp, reason, modifiers);
+ break;
+ case HANDLE_RESIZE_E:
+ new_height = (to->x-image->element.corner.x)*height/width;
+ to->y = image->element.corner.y+new_height;
+ element_move_handle (elem, HANDLE_RESIZE_SE, to, cp, reason, modifiers);
+ break;
+ case HANDLE_RESIZE_SE:
+ new_width = to->x-image->element.corner.x;
+ new_height = to->y-image->element.corner.y;
+ if (new_height == 0 || new_width/new_height > width/height) {
+ new_height = new_width*height/width;
+ } else {
+ new_width = new_height*width/height;
+ }
+ to->x = image->element.corner.x+new_width;
+ to->y = image->element.corner.y+new_height;
+ element_move_handle (elem, HANDLE_RESIZE_SE, to, cp, reason, modifiers);
+ break;
+ case HANDLE_RESIZE_S:
+ new_width = (to->y-image->element.corner.y)*width/height;
+ to->x = image->element.corner.x+new_width;
+ element_move_handle (elem, HANDLE_RESIZE_SE, to, cp, reason, modifiers);
+ break;
+ case HANDLE_RESIZE_SW:
+ new_width = -(to->x-image->element.corner.x)+width;
+ new_height = to->y-image->element.corner.y;
+ if (new_height == 0 || new_width/new_height > width/height) {
+ new_height = new_width*height/width;
+ } else {
+ new_width = new_height*width/height;
+ }
+ to->x = image->element.corner.x+(image->element.width-new_width);
+ to->y = image->element.corner.y+new_height;
+ element_move_handle (elem, HANDLE_RESIZE_SW, to, cp, reason, modifiers);
+ break;
+ case HANDLE_RESIZE_W:
+ new_height = (-(to->x-image->element.corner.x)+width)*height/width;
+ to->y = image->element.corner.y+new_height;
+ element_move_handle (elem, HANDLE_RESIZE_SW, to, cp, reason, modifiers);
+ break;
+ case HANDLE_MOVE_STARTPOINT:
+ case HANDLE_MOVE_ENDPOINT:
+ case HANDLE_CUSTOM1:
+ case HANDLE_CUSTOM2:
+ case HANDLE_CUSTOM3:
+ case HANDLE_CUSTOM4:
+ case HANDLE_CUSTOM5:
+ case HANDLE_CUSTOM6:
+ case HANDLE_CUSTOM7:
+ case HANDLE_CUSTOM8:
+ case HANDLE_CUSTOM9:
+ default:
+ message_warning ("Unforeseen handle in image_move_handle: %d\n",
+ handle->id);
}
} else {
- element_move_handle(elem, handle->id, to, cp, reason, modifiers);
+ element_move_handle (elem, handle->id, to, cp, reason, modifiers);
}
- image_update_data(image);
+ image_update_data (image);
return NULL;
}
+
static ObjectChange*
-image_move(Image *image, Point *to)
+image_move (Image *image, Point *to)
{
image->element.corner = *to;
- image_update_data(image);
+ image_update_data (image);
return NULL;
}
+
static void
image_draw (Image *image, DiaRenderer *renderer)
{
@@ -526,8 +545,9 @@ image_transform(Image *image, const DiaMatrix *m)
return TRUE;
}
+
static void
-image_update_data(Image *image)
+image_update_data (Image *image)
{
Element *elem = &image->element;
ElementBBExtras *extra = &elem->extra_spacing;
@@ -535,8 +555,8 @@ image_update_data(Image *image)
if (image->keep_aspect && image->image) {
/* maybe the image got changes since */
- real aspect_org = (float)dia_image_width(image->image)
- / (float)dia_image_height(image->image);
+ real aspect_org = (float) dia_image_width (image->image)
+ / (float) dia_image_height (image->image);
real aspect_now = elem->width / elem->height;
if (fabs (aspect_now - aspect_org) > 1e-4) {
@@ -553,7 +573,7 @@ image_update_data(Image *image)
DiaMatrix m = { 1.0, 0.0, 0.0, 1.0, cx, cy };
DiaMatrix t = { 1.0, 0.0, 0.0, 1.0, -cx, -cy };
int i;
- PolyBBExtras extra = { 0, };
+ PolyBBExtras extraa = { 0, };
Point poly[4];
@@ -563,15 +583,15 @@ image_update_data(Image *image)
transform_point (&image->connections[i].pos, &m);
element_get_poly (elem, image->angle, poly);
- extra.middle_trans = (image->draw_border ? image->border_width : 0.0);
- polyline_bbox(poly, 4, &extra, TRUE, &elem->object.bounding_box);
+ extraa.middle_trans = (image->draw_border ? image->border_width : 0.0);
+ polyline_bbox (poly, 4, &extraa, TRUE, &elem->object.bounding_box);
} else {
/* the image border is drawn completely outside of the image, so no /2.0 on border width */
extra->border_trans = (image->draw_border ? image->border_width : 0.0);
- element_update_boundingbox(elem);
+ element_update_boundingbox (elem);
}
obj->position = elem->corner;
- element_update_handles(elem);
+ element_update_handles (elem);
}
diff --git a/objects/standard/outline.c b/objects/standard/outline.c
index 3591ec65..33e09045 100644
--- a/objects/standard/outline.c
+++ b/objects/standard/outline.c
@@ -433,24 +433,33 @@ outline_set_props (Outline *outline, GPtrArray *props)
object_set_props_from_offsets(&outline->object, outline_offsets, props);
outline_update_data (outline);
}
-/*!
- * \brief Calculate the distance of the whole object to the given point
- * \memberof Outline
+
+
+/**
+ * outline_distance_from:
+ *
+ * Calculate the distance of the whole object to the given point
*/
static real
outline_distance_from (Outline *outline, Point *point)
{
- return distance_polygon_point (&outline->ink_rect[0], 4, outline->line_width, point);
+ return distance_polygon_point (&outline->ink_rect[0], 4,
+ outline->line_width, point);
}
-/*!
- * \brief Move one of the objects handles
- * \memberof Outline
+
+
+/**
+ * outline_move_handle:
+ *
+ * Move one of the objects handles
*/
static ObjectChange*
-outline_move_handle (Outline *outline,
- Handle *handle,
- Point *to, ConnectionPoint *cp,
- HandleMoveReason reason, ModifierKeys modifiers)
+outline_move_handle (Outline *outline,
+ Handle *handle,
+ Point *to,
+ ConnectionPoint *cp,
+ HandleMoveReason reason,
+ ModifierKeys modifiers)
{
DiaObject *obj = &outline->object;
Point start = obj->position;
@@ -459,17 +468,36 @@ outline_move_handle (Outline *outline,
Point norm = end;
point_sub (&norm, &start);
point_normalize (&norm);
+
/* we use this to modify angle and scale */
switch (handle->id) {
- case HANDLE_RESIZE_NW :
- start = *to;
- break;
- case HANDLE_RESIZE_SE :
- end = *to;
- break;
- default :
- g_warning ("Outline unknown handle");
+ case HANDLE_RESIZE_NW :
+ start = *to;
+ break;
+ case HANDLE_RESIZE_SE :
+ end = *to;
+ break;
+ case HANDLE_RESIZE_N:
+ case HANDLE_RESIZE_NE:
+ case HANDLE_RESIZE_W:
+ case HANDLE_RESIZE_E:
+ case HANDLE_RESIZE_SW:
+ case HANDLE_RESIZE_S:
+ case HANDLE_MOVE_STARTPOINT:
+ case HANDLE_MOVE_ENDPOINT:
+ case HANDLE_CUSTOM1:
+ case HANDLE_CUSTOM2:
+ case HANDLE_CUSTOM3:
+ case HANDLE_CUSTOM4:
+ case HANDLE_CUSTOM5:
+ case HANDLE_CUSTOM6:
+ case HANDLE_CUSTOM7:
+ case HANDLE_CUSTOM8:
+ case HANDLE_CUSTOM9:
+ default:
+ g_warning ("Outline unknown handle");
}
+
dist = distance_point_point (&start, &end);
/* disallow everything below a certain level, otherwise the font-size could become invalid */
if (dist > 0.1) {
@@ -479,8 +507,11 @@ outline_move_handle (Outline *outline,
outline_update_data (outline);
}
+
return NULL;
}
+
+
/*!
* \brief Move the whole object to the given position
*
diff --git a/objects/standard/textobj.c b/objects/standard/textobj.c
index 7bcdd17f..e24fb318 100644
--- a/objects/standard/textobj.c
+++ b/objects/standard/textobj.c
@@ -321,29 +321,34 @@ textobj_draw(Textobj *textobj, DiaRenderer *renderer)
}
}
+
static void
textobj_valign_point (Textobj *textobj, Point* p)
{
DiaRectangle *bb = &(textobj->object.bounding_box);
real offset;
+
switch (textobj->vert_align){
- case VALIGN_BOTTOM:
- offset = bb->bottom - textobj->object.position.y;
- p->y -= offset;
- break;
- case VALIGN_TOP:
- offset = bb->top - textobj->object.position.y;
- p->y -= offset;
- break;
- case VALIGN_CENTER:
- offset = (bb->bottom + bb->top)/2 - textobj->object.position.y;
- p->y -= offset;
- break;
- case VALIGN_FIRST_LINE:
- break;
+ case VALIGN_BOTTOM:
+ offset = bb->bottom - textobj->object.position.y;
+ p->y -= offset;
+ break;
+ case VALIGN_TOP:
+ offset = bb->top - textobj->object.position.y;
+ p->y -= offset;
+ break;
+ case VALIGN_CENTER:
+ offset = (bb->bottom + bb->top)/2 - textobj->object.position.y;
+ p->y -= offset;
+ break;
+ case VALIGN_FIRST_LINE:
+ break;
+ default:
+ g_return_if_reached ();
}
}
+
static void
textobj_update_data (Textobj *textobj)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]