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:
		
							parent
							
								
									3d3a71d5d2
								
							
						
					
					
						commit
						37d898fb1a
					
				
							
								
								
									
										15
									
								
								src/ld-lua.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								src/ld-lua.c
									
									
									
									
									
								
							| @ -501,28 +501,35 @@ get_translation (lua_State *L, int index) | |||||||
| static gboolean | static gboolean | ||||||
| read_symbol_area (lua_State *L, int index, LdSymbolArea *area) | read_symbol_area (lua_State *L, int index, LdSymbolArea *area) | ||||||
| { | { | ||||||
|  | 	lua_Number x1, x2, y1, y2; | ||||||
|  | 
 | ||||||
| 	if (lua_objlen (L, index) != 4) | 	if (lua_objlen (L, index) != 4) | ||||||
| 		return FALSE; | 		return FALSE; | ||||||
| 
 | 
 | ||||||
| 	lua_rawgeti (L, index, 1); | 	lua_rawgeti (L, index, 1); | ||||||
| 	if (!lua_isnumber (L, -1)) | 	if (!lua_isnumber (L, -1)) | ||||||
| 		return FALSE; | 		return FALSE; | ||||||
| 	area->x1 = lua_tonumber (L, -1); | 	x1 = lua_tonumber (L, -1); | ||||||
| 
 | 
 | ||||||
| 	lua_rawgeti (L, index, 2); | 	lua_rawgeti (L, index, 2); | ||||||
| 	if (!lua_isnumber (L, -1)) | 	if (!lua_isnumber (L, -1)) | ||||||
| 		return FALSE; | 		return FALSE; | ||||||
| 	area->y1 = lua_tonumber (L, -1); | 	y1 = lua_tonumber (L, -1); | ||||||
| 
 | 
 | ||||||
| 	lua_rawgeti (L, index, 3); | 	lua_rawgeti (L, index, 3); | ||||||
| 	if (!lua_isnumber (L, -1)) | 	if (!lua_isnumber (L, -1)) | ||||||
| 		return FALSE; | 		return FALSE; | ||||||
| 	area->x2 = lua_tonumber (L, -1); | 	x2 = lua_tonumber (L, -1); | ||||||
| 
 | 
 | ||||||
| 	lua_rawgeti (L, index, 4); | 	lua_rawgeti (L, index, 4); | ||||||
| 	if (!lua_isnumber (L, -1)) | 	if (!lua_isnumber (L, -1)) | ||||||
| 		return FALSE; | 		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; | 	return TRUE; | ||||||
| } | } | ||||||
|  | |||||||
| @ -20,18 +20,18 @@ typedef struct _LdSymbolArea LdSymbolArea; | |||||||
| 
 | 
 | ||||||
| /**
 | /**
 | ||||||
|  * LdSymbolArea: |  * LdSymbolArea: | ||||||
|  * @x1: Left-top X coordinate. |  * @x: Left-top X coordinate. | ||||||
|  * @y1: Left-top Y coordinate. |  * @y: Left-top Y coordinate. | ||||||
|  * @x2: Right-bottom X coordinate. |  * @width: Width of the area, must be positive. | ||||||
|  * @y2: Right-bottom Y coordinate. |  * @height: Height of the area, must be positive. | ||||||
|  * |  * | ||||||
|  * Defines the area of the symbol relative to the center of the symbol, |  * Defines the area of the symbol relative to the center of the symbol, | ||||||
|  * which is at the (0, 0) coordinates. |  * which is at the (0, 0) coordinates. | ||||||
|  */ |  */ | ||||||
| struct _LdSymbolArea | struct _LdSymbolArea | ||||||
| { | { | ||||||
| 	gdouble x1, y1; | 	gdouble x, y; | ||||||
| 	gdouble x2, y2; | 	gdouble width, height; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -509,9 +509,9 @@ on_category_toggle (GtkToggleButton *toggle_button, gpointer user_data) | |||||||
| 			 * in the center of it's symbol menu item. | 			 * in the center of it's symbol menu item. | ||||||
| 			 */ | 			 */ | ||||||
| 			item->scale = data->menu_height * 0.5 | 			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). */ | 			/* 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; | 				+ data->menu_height * 0.5; | ||||||
| 
 | 
 | ||||||
| 			menu_width += item++->width; | 			menu_width += item++->width; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user