#:kivy 1.0

<Label>:
	canvas:
		Color:
			rgba: self.color
		Rectangle:
			texture: self.texture
			size: self.texture_size
			pos: int(self.center[0] - self.texture_size[0] / 2.), int(self.center[1] - self.texture_size[1] / 2.)

<Button,ToggleButton>:
	canvas:
		Color:
			rgb: (1, 1, 1)
		BorderImage:
			border: (16, 16, 16, 16)
			pos: self.pos
			size: self.size
			source: self.background_normal if self.state == 'normal' else self.background_down
		Color:
			rgba: self.color
		Rectangle:
			texture: self.texture
			size: self.texture_size
			pos: int(self.center_x - self.texture_size[0] / 2.), int(self.center_y - self.texture_size[1] / 2.)


<Slider>:
    canvas:
        Color:
            rgb: 1, 1, 1
		BorderImage:
			border: (0, 18, 0, 18) if self.orientation == 'horizontal' else (18, 0, 18, 0)
			pos: (self.x, self.center_y - 18) if self.orientation == 'horizontal' else (self.center_x - 18, self.y)
			size: (self.width, 37) if self.orientation == 'horizontal' else (37, self.height)
			source: 'data/images/slider%s_background.png' % self.orientation[0]
		Image:
			pos: (self.value_pos[0] - 16, self.center_y - 17) if self.orientation == 'horizontal' else (self.center_x - 16, self.value_pos[1] - 16)
			size: (32, 32)
			source: 'data/images/slider_cursor.png'

<Scatter>:
	canvas.before:
		PushMatrix
		MatrixInstruction:
			matrix: self.transform
	canvas.after:
		PopMatrix

<Image,AsyncImage>:
	canvas:
		Color:
			rgb: (1, 1, 1)
		Rectangle:
			texture: self.texture
			size: self.norm_image_size
			pos: self.center_x - self.norm_image_size[0] / 2., self.center_y - self.norm_image_size[1] / 2.

<TextInput>:
	padding_x: 6
	padding_y: 6
	canvas.before:
		Color:
			rgb: (1, 1, 1)
		BorderImage:
			border: (16, 16, 16, 16)
			pos: self.pos
			size: self.size
			source: 'data/images/textinput.png' if not self.focus else 'data/images/textinput_active.png'
		Color:
			rgba: (1, 0, 0, 1 if self.focus and not self.cursor_blink else 0)
		Rectangle:
			pos: map(int, self.cursor_pos)
			size: 1, -self.line_height
		Color:
			rgb: (0, 0, 0)


<TreeViewNode>:
    canvas.before:
        Color:
            rgba: self.color_selected if self.is_selected else (0, 0, 0, 0)
        Rectangle:
            pos: [self.parent.x, self.y] if self.parent else [0, 0]
            size: [self.parent.width, self.height] if self.parent else [1, 1]
        Color:
            rgba: 1, 1, 1, int(not self.is_leaf)
        Rectangle:
            source: 'data/images/tree_%s.png' % ('opened' if self.is_open else 'closed')
            size: 16, 16
            pos: self.x - 20, self.center[1] - 8
    canvas.after:
        Color:
            rgba: .5, .5, .5, .2
        Line:
            points: [self.parent.x, self.y, self.parent.right, self.y] if self.parent else []


<TreeViewLabel>:
    width: self.texture_size[0]
    height: max(self.texture_size[1], 24)
	text_size: self.size


<StencilView>:
	canvas.before:
		StencilPush
		Rectangle:
			pos: self.pos
			size: self.size
		StencilUse

	canvas.after:
		StencilPop
