Exemple #1
0
	def __init__(self, ingr):
		GObject.__init__(self);
		#render strings
		#TODO : check if they exist
		self.name = newIngredientString(ingr.getName())
		self.amount = newIngredientString(ingr.getAmount() + " " + ingr.getUnit())

		#icon
		self.image = GBillboard(0,ingr.image)

		self.image.w = Constants.ingredient.icon_size
		self.image.h = Constants.ingredient.icon_size
		
		#calculate width
		self.w = max(self.name.w, self.amount.w, self.image.w)

		#calculate positions
		y = 0
		
		self.amount.centerX((0,self.w))
		self.amount.y = y
		y += self.name.h + Constants.ingredient.padding		
	
		self.name.centerX((0,self.w))
		self.name.y = y
		y += self.name.h + Constants.ingredient.padding
		
		self.image.centerX((0,self.w))
		self.image.y = y
		y += self.image.h 
		self.h = y
Exemple #2
0
	def __init__(self, recipe):
		GObject.__init__(self)
		#create ingredients list
		#TODO : delete ingredient duplicates
		self.ingredients = []
		for step in recipe.getSteps().values():
			for i in step.getIngredients():
				print "w "+i.getName()
				self.ingredients.append(GIngredient(i))

		#create underline
		self.underline = GRect()
		self.underline.color = Constants.ingredient_list.underline_color
		self.underline.h = Constants.ingredient_list.underline_height
Exemple #3
0
	def __init__(self, step):
		GObject.__init__(self)
		self.h = Constants.step.h
		#initialize action
		self.action = newStepString(step.getAction()+ " "+step.getDescription())
		
		#initialize ingredients
		self.ingredients = []
		for i in step.getIngredients():
			self.ingredients.append(GIngredient(i))
		
		#calculate width
		self.w = 2*Constants.step.ingredient_padding
		for i in self.ingredients:
			self.w += i.w + Constants.step.ingredient_padding
		self.w += self.action.w

		#calculate ingredient x
		x = Constants.step.ingredient_padding
		for i in self.ingredients:
			i.x = x
			x += i.w + Constants.step.ingredient_padding
		
		#position action
		self.action.x = x
		self.action.centerY((0,self.h))
		x += self.action.w 

		#create bakckground
		if Constants.step.background_image:
			self.background = GBillboard(0,Constants.step.background_image)
			self.background.h = self.h
		
		else:
			self.background = GRect()
		
		self.background.w = self.w
		self.background.h = Constants.step.background_height
		self.background.centerY((0,self.h))

		#initialize arrow ends
		self.upperArrowEnd = GObject()
		self.upperArrowEnd.x = self.x + Constants.step.arrow_head_height/2.0
		self.upperArrowEnd.y = self.background.y + self.y + self.background.h
		
		self.lowerArrowEnd = GObject()
		self.lowerArrowEnd.x = Constants.step.arrow_head_height/2.0
		self.lowerArrowEnd.y = self.background.y
Exemple #4
0
	def __init__(self, recipe):
		GObject.__init__(self)
		#recipe name
		self.name = newString(recipe.getName(),Constants.recipe_description.name_font)
		#description
		desc_text = recipe.getDescription()
		self.description = newString(desc_text,Constants.recipe_description.description_font)
		
		#details
		det_text = recipe.getPeople() + " " + Constants.getPeopleWord(recipe.getPeople())
		det_text += ", " + recipe.getTime()
		self.details = newString(det_text,Constants.recipe_description.description_font)
		
		#underline
		self.underline = GRect()
		self.underline.color = Constants.recipe_description.underline_color
		self.underline.h = Constants.recipe_description.underline_height

		#position everything
		padding = Constants.recipe_description.padding
		padding2 = Constants.recipe_description.name_desc_padding
		padding3 = Constants.recipe_description.line_padding
		padding4 = Constants.recipe_description.underline_padding
		
		self.underline.y = padding

		self.name.x = padding
		self.name.y = padding + padding4 + Constants.recipe_description.underline_padding

		self.description.x = self.name.x + self.name.w + padding2
		self.details.x = self.description.x
		self.details.y = self.name.y
		self.description.y = padding3 + self.details.y + self.details.h

		#calculate size
		self.h = 2*padding + padding4 + max(self.name.h , self.description.h+ self.details.h + padding3)
		self.h += Constants.recipe_description.underline_height
		self.w = 2*padding + self.name.w + padding2 + max(self.description.w, self.details.w)
	
		self.underline.w = self.w