Skip to content

Commit c0252d8

Browse files
committed
Update index.grid
1 parent 01a1f51 commit c0252d8

File tree

4 files changed

+48
-3
lines changed

4 files changed

+48
-3
lines changed

index.grid.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@
164164
</el-input>
165165
</el-col>
166166
</el-row>
167-
167+
<el-row>
168+
<lvgl-align v-bind:id="currentWidget.id"></lvgl-align>
169+
</el-row>
168170
</el-form-item>
169171

170172
<el-form-item label="Size">

src/gen_apis_js.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import json
66

77
Setter = {}
8-
path = '../lv_mpy_example.json'
8+
path = '../../lv_mpy_example.json' # Path to lv_mpy_example.json
99

1010
with open(path) as f:
1111
data = json.load(f)

src/utils.js

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,43 @@ Vue.component('lvgl-setter', {
6969
}
7070
},
7171
template: '<span> {{ name }} (<small v-for="arg in args">{{arg.name}}:<input type="checkbox" v-if="arg.type === `bool`" v-model="arg.value" v-on:change="checkArgs()"/> <input type="text" style="width: 35px" v-else v-model="arg.value" v-bind:placeholder="arg.type" v-on:input="checkArgs()"/>,</small>)</span>'
72-
})
72+
});
73+
74+
// https://docs.littlevgl.com/en/html/object-types/obj.html
75+
// Vue.component('lvgl-layout', {
76+
// props: ['id', 'x', 'y', 'align', 'obj_ref', 'x_shift', 'y_shift'], // lv_obj_set_x, lv_obj_set_y, lv_obj_align(obj, obj_ref, LV_ALIGN_..., x_shift, y_shift)
77+
// data: function() {
78+
// return {
79+
// x: 0,
80+
// y: 0,
81+
// align: "",
82+
// }
83+
// },
84+
// template: ''
85+
// });
86+
87+
// TODO: Only support align to its parent now
88+
Vue.component('lvgl-align', {
89+
props: ['id', 'ref_id'],
90+
data: function() {
91+
return {
92+
align: '',
93+
ref_obj: '',
94+
x_shift: 0,
95+
y_shift: 0,
96+
options: [
97+
'', 'OUT_TOP_LEFT', 'OUT_TOP_MID', 'OUT_TOP_RIGHT', '', 0,
98+
'OUT_LEFT_TOP', 'IN_TOP_LEFT', 'IN_TOP_MID', 'IN_TOP_RIGHT', 'OUT_RIGHT_TOP', 0,
99+
'OUT_LEFT_MID', 'IN_LEFT_MID', 'CENTER', 'IN_RIGHT_MID', 'OUT_RIGHT_MID', 0,
100+
'OUT_LEFT_BOTTOM', 'IN_BOTTOM_LEFT', 'IN_BOTTOM_MID', 'IN_BOTTOM_RIGHT', 'OUT_RIGHT_BOTTOM', 0,
101+
'', 'OUT_BOTTOM_LEFT', 'OUT_BOTTOM_MID', 'OUT_BOTTOM_RIGHT', '', 0,
102+
]
103+
}
104+
},
105+
watch: {
106+
align: (type) => {
107+
wrap_align(this.id, 'None', type, 0, 0);
108+
}
109+
},
110+
template: '<div><p>{{align}}</p><span v-for="type in options"><input type="radio" v-bind:disabled="type === ``" v-if="type !== 0" v-bind:value="type" v-model="align"/><br v-else /></span></div>'
111+
});

src/wrapper.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ const wrap_setter = (id, type, name, params, database) => {
5555
mp_js_do_str(code);
5656
}
5757

58+
const wrap_align = (id, ref_id, offset_x, offset_y) => {
59+
mp_js_do_str(`${id}.align(${ref_id}, ${offset_x}, ${offset_y})`);
60+
}
61+
5862
const wrap_setter_str = (id, api, params) => {
5963
// params is a string
6064
let code = `${id}.${api}(${params})`;

0 commit comments

Comments
 (0)