From 37d898fb1a29f074747dbd9c81d6e2ad97d2e23e Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Fri, 10 Dec 2010 08:57:42 +0100 Subject: Change LdSymbolArea members. Now it contains coordinates of the top-left delimiting point and computed dimensions (instead of coorinates of both delimiting points). --- src/ld-lua.c | 15 +++++++++++---- src/ld-symbol.h | 12 ++++++------ src/ld-window-main.c | 4 ++-- 3 files changed, 19 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/ld-lua.c b/src/ld-lua.c index 54ba0c4..4ed68eb 100644 --- a/src/ld-lua.c +++ b/src/ld-lua.c @@ -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; } diff --git a/src/ld-symbol.h b/src/ld-symbol.h index 9eff89b..0290720 100644 --- a/src/ld-symbol.h +++ b/src/ld-symbol.h @@ -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; }; diff --git a/src/ld-window-main.c b/src/ld-window-main.c index 0597d33..bcacf3f 100644 --- a/src/ld-window-main.c +++ b/src/ld-window-main.c @@ -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; -- cgit v1.2.3-70-g09d2