File size: 4,464 Bytes
40c7241
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150


struct EG_context_t {

	perLayout: &uint32
	font: &FNT_font_t
	color: uint16
	bgColor: uint16
	id: uint16
	pos: uint16
	x: uint16
	y: uint16
	width: uint16
	height: uint16
	cX: uint16
	cY: uint16
	maxX: uint16
	minY: uint16
	isRedraw: uint8
	isSkip: uint8
	perLayoutPos: uint8
	cols: uint8
}


struct EG_userContext_t {

	isValueChanged: bool
	isApplied: bool

	isLeastOneValueChanged: bool
	isLeastOneValueApplied: bool
	
    cursorPos: &uint32
	data: mut &EG_dummyData_t
	
	func isApplied(self: &EG_userContext_t) -> bool {
		let mutSelf: mut &EG_userContext_t = #self
		let isApplied = self.isApplied
		mutSelf.isApplied = false
		return isApplied
	}
	
	func isValueChanged(self: &EG_userContext_t) -> bool {
		let mutSelf: mut &EG_userContext_t = #self
		let isValueChanged = self.isValueChanged
		mutSelf.isValueChanged = false
		return isValueChanged
	}
	
	func isLeastOneValueChanged(self: &EG_userContext_t) -> bool {
		//let isLeastOneValueChanged = self.isLeastOneValueChanged
		//self.isLeastOneValueChanged = false
		//return isLeastOneValueChanged
		return self.isLeastOneValueChanged
	}
	
	func isLeastOneValueApplied(self: &EG_userContext_t) -> bool {
		//let isLeastOneValueApplied = self.isLeastOneValueApplied
		//self.isLeastOneValueApplied = false
		//return isLeastOneValueApplied
		return self.isLeastOneValueApplied
	}
}

struct EG_dummyData_t {
    cursorPos: &uint32
	data: uint8
}

enum {
	GUI_ALIGN_LEFT = 0,
	GUI_ALIGN_RIGHT,
	GUI_ALIGN_CENTER
}




extern demangle func __eg_set_color(uint16, uint16, uint16)
extern demangle func __eg_set_font(&FNT_font_t, uint16)
extern demangle func __eg_row_begin(uint8, uint16, uint16)
extern demangle func __eg_row_draw()
extern demangle func __eg_layout_begin(uint16, uint16, uint16)
extern demangle func __eg_flow_layout_begin(uint16, uint16, uint16, uint16, uint16)
extern demangle func __eg_list_begin(uint16, uint8, uint16)
extern demangle func __eg_layout_draw()
extern demangle func __eg_flow_layout_draw()
extern demangle func __eg_canvas_draw()
extern demangle func __eg_label_draw(c_string, uint32, uint16)
extern demangle func __eg_dyn_label_draw(c_string, uint32, uint16)
extern demangle func __eg_img_draw(&IMG_dat_t, func {(uint8)->void}, uint8, uint16)
extern demangle func __eg_animation_draw(
	pointer, pointer, uint8, 
	uint16, uint16, 
	uint8,
	uint16, uint16,
	uint16
)
extern demangle func __eg_list_draw()
extern demangle func __eg_switcher_draw(&EEmbBindVal_t, uint8, uint16)
extern demangle func __eg_input_int_draw(&EEmbBindVal_t, int32, int32,  uint32,  uint8, uint16)
extern demangle func __eg_input_float_draw(&EEmbBindVal_t, int32, int32,  uint8, uint32,  uint8, uint16)
extern demangle func __eg_fill_draw(uint16, uint16)
extern demangle func __eg_button_draw(c_string, uint16, int8, func {(uint8)->void}, uint16) 
extern demangle func __eg_combo_box_draw(&EEmbBindVal_t, uint16, uint32, pointer, pointer, uint8, uint16)
extern demangle func __eg_ghostStepInParent()
extern demangle func __eg_set_borders(uint16, uint16)
extern demangle func __eg_set_unit(c_string, uint16)

extern demangle func __eg_fixed_layout_begin(int16, int16, uint16, uint16, uint16)
extern demangle func __eg_fixed_flow_layout_begin(uint16, uint16, uint16, uint16, uint16)
extern demangle func __eg_canvas_begin(int16, int16, uint16, uint16, uint16)

extern demangle func GUI_buttonHandler(uint32, func {(uint8)->void}) -> uint8
extern demangle func GUI_setDraw(func {(&EG_userContext_t)})
extern demangle func GUI_clearContext()
extern demangle func GUI_rowStartStep(uint8) -> uint8


extern demangle var EEMB_GUI_CONTEXT_PTR: mut &EG_context_t
extern demangle var EEMB_GUI_PARENT_CONTEXT_PTR: mut &EG_context_t



func __eg_set_per_layout(layouts: pointer) {
	//bkpt()
	EEMB_GUI_CONTEXT_PTR.perLayout <- layouts
	//EEMB_GUI_CONTEXT_PTR.perLayoutPos = 0
}

func __eg_set_layout_height(h: uint32) -> uint16 {
	return (h*( EEMB_GUI_PARENT_CONTEXT_PTR.height ? EEMB_GUI_PARENT_CONTEXT_PTR.height : EEMB_GUI_PARENT_CONTEXT_PTR.y - EEMB_GUI_PARENT_CONTEXT_PTR.minY  )) / 100
}

func GET_COLOR(r: uint8, g: uint8, b: uint8) -> uint16 {
	return ( (((r)>>3)<<11) | (((g)>>2)<<5) | (((b)>>3)) )
}



func __fpToInt32(val: fp32, decimalNumberSize: uint8) -> int32 {
    var res = val
	for i in 1 to decimalNumberSize {
		res *= 10
	}
	return res
}