Change LdSymbolArea members.

Now it contains coordinates of the top-left delimiting
point and computed dimensions (instead of coorinates of
both delimiting points).
This commit is contained in:
Přemysl Eric Janouch 2010-12-10 08:57:42 +01:00
parent 3d3a71d5d2
commit 37d898fb1a
3 changed files with 19 additions and 12 deletions

View File

@ -501,28 +501,35 @@ get_translation (lua_State *L, int index)
static gboolean
read_symbol_area (lua_State *L, int index, LdSymbolArea *area)
{
lua_Number x1, x2, y1, y2;
if (lua_objlen (L, index) != 4)
return FALSE;
lua_rawgeti (L, index, 1);
if (!lua_isnumber (L, -1))
return FALSE;
area->x1 = lua_tonumber (L, -1);
x1 = lua_tonumber (L, -1);
lua_rawgeti (L, index, 2);
if (!lua_isnumber (L, -1))
return FALSE;
area->y1 = lua_tonumber (L, -1);
y1 = lua_tonumber (L, -1);
lua_rawgeti (L, index, 3);
if (!lua_isnumber (L, -1))
return FALSE;
area->x2 = lua_tonumber (L, -1);
x2 = lua_tonumber (L, -1);
lua_rawgeti (L, index, 4);
if (!lua_isnumber (L, -1))
return FALSE;
area->y2 = lua_tonumber (L, -1);
y2 = lua_tonumber (L, -1);
area->x = MIN (x1, x2);
area->y = MIN (y1, y2);
area->width = ABS (x2 - x1);
area->height = ABS (y2 - y1);
return TRUE;
}

View File

@ -20,18 +20,18 @@ typedef struct _LdSymbolArea LdSymbolArea;
/**
* LdSymbolArea:
* @x1: Left-top X coordinate.
* @y1: Left-top Y coordinate.
* @x2: Right-bottom X coordinate.
* @y2: Right-bottom Y coordinate.
* @x: Left-top X coordinate.
* @y: Left-top Y coordinate.
* @width: Width of the area, must be positive.
* @height: Height of the area, must be positive.
*
* Defines the area of the symbol relative to the center of the symbol,
* which is at the (0, 0) coordinates.
*/
struct _LdSymbolArea
{
gdouble x1, y1;
gdouble x2, y2;
gdouble x, y;
gdouble width, height;
};

View File

@ -509,9 +509,9 @@ on_category_toggle (GtkToggleButton *toggle_button, gpointer user_data)
* in the center of it's symbol menu item.
*/
item->scale = data->menu_height * 0.5
/ MAX (ABS (area.y1), ABS (area.y2)) / 2;
/ MAX (ABS (area.y), ABS (area.y + area.height)) / 2;
/* FIXME: The width is probably wrong (related to the center). */
item->width = item->scale * ABS (area.x2 - area.x1)
item->width = item->scale * area.width
+ data->menu_height * 0.5;
menu_width += item++->width;