static void textobj_update_data(Textobj *textobj) { Point to2; DiaObject *obj = &textobj->object; Rectangle tx_bb; text_set_position(textobj->text, &obj->position); text_calc_boundingbox(textobj->text, &obj->bounding_box); to2 = obj->position; textobj_valign_point(textobj, &to2); /* shift text position depending on text alignment */ if (VALIGN_TOP == textobj->vert_align) to2.y += textobj->margin; /* down */ else if (VALIGN_BOTTOM == textobj->vert_align) to2.y -= textobj->margin; /* up */ if (ALIGN_LEFT == textobj->text->alignment) to2.x += textobj->margin; /* right */ else if (ALIGN_RIGHT == textobj->text->alignment) to2.x -= textobj->margin; /* left */ text_set_position(textobj->text, &to2); /* always use the unrotated box ... */ text_calc_boundingbox(textobj->text, &tx_bb); /* grow the bounding box by 2x margin */ obj->bounding_box.top -= textobj->margin; obj->bounding_box.left -= textobj->margin; obj->bounding_box.bottom += textobj->margin; obj->bounding_box.right += textobj->margin; textobj->text_handle.pos = obj->position; if (textobj->text_angle == 0) { obj->bounding_box = tx_bb; g_return_if_fail (obj->enclosing_box != NULL); *obj->enclosing_box = tx_bb; } else { /* ... and grow it when necessary */ Point poly[4]; int i; _textobj_get_poly (textobj, poly); /* we don't want the joined box for boundingbox because * selection would become too greedy than. */ obj->bounding_box.left = obj->bounding_box.right = poly[0].x; obj->bounding_box.top = obj->bounding_box.bottom = poly[0].y; for (i = 1; i < 4; ++i) rectangle_add_point (&obj->bounding_box, &poly[i]); g_return_if_fail (obj->enclosing_box != NULL); *obj->enclosing_box = obj->bounding_box; /* join for editing/selection bbox */ rectangle_union (obj->enclosing_box, &tx_bb); } }
static void textobj_update_data(Textobj *textobj) { Point to2; DiaObject *obj = &textobj->object; text_set_position(textobj->text, &obj->position); text_calc_boundingbox(textobj->text, &obj->bounding_box); to2 = obj->position; textobj_valign_point(textobj, &to2, 1); text_set_position(textobj->text, &to2); text_calc_boundingbox(textobj->text, &obj->bounding_box); textobj->text_handle.pos = obj->position; }