Skip to content

Commit fa70e61

Browse files
committed
update
1 parent d9e4319 commit fa70e61

File tree

1 file changed

+34
-14
lines changed

1 file changed

+34
-14
lines changed

src/imgui_stdweb.rs

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
pub struct ImguiIO{
55
}
66

7+
#[derive(Debug, Clone)]
8+
pub struct ImguiDrawData{
9+
}
10+
711
#[derive(Debug, Clone)]
812
pub struct ImDrawList{
913
draw_list:stdweb::Value
@@ -22,59 +26,75 @@ impl ImDrawList{
2226
self.draw_list.Flags
2327
}
2428

25-
pub fn iterate_draw_lists(&self){
26-
29+
pub fn iterate_draw_lists(&self, callback:fn(stdweb::Value)->()){
30+
js! {
31+
window.Imgui.IterateDrawLists(@{callback});
32+
};
33+
}
34+
35+
pub fn iterate_draw_cmds(&self, callback:fn(stdweb::Value)->()){
36+
js! {
37+
window.Imgui.IterateDrawCmds(@{callback});
38+
};
2739
}
2840
}
2941

3042
#[derive(Debug, Clone)]
3143
pub struct Imgui{
32-
module: stdweb::Value
3344
}
3445

3546

3647
impl Imgui{
3748
pub fn new() -> Imgui{
3849
Imgui{
39-
module:js!{return window.Imgui;}
4050
}
4151
}
4252

53+
#[allow(non_snake_case)]
54+
pub fn IMGUI_VERSION(&self) -> String{
55+
let ret = js! {
56+
return window.Imgui.IMGUI_VERSION;
57+
};
58+
ret
59+
}
60+
4361
#[allow(non_snake_case)]
4462
pub fn IMGUI_CHECKVERSION(&self){
45-
let module = &self.module;
4663
js! {
47-
@{module}.IMGUI_CHECKVERSION();
64+
window.Imgui.IMGUI_CHECKVERSION();
4865
};
4966
}
5067

5168
pub fn create_context(&self){
52-
let module = &self.module;
5369
js! {
54-
return @{module}.create_context();
70+
return window.Imgui.create_context();
5571
};
5672
}
5773

5874
pub fn get_io(&self) -> stdweb::Value{
59-
let module = &self.module;
6075
let ret = js! {
61-
return @{module}.get_io();
76+
return window.Imgui.get_io();
77+
};
78+
ret
79+
}
80+
81+
pub fn get_draw_data(&self) -> stdweb::Value{
82+
let ret = js! {
83+
return window.Imgui.GetDrawData();
6284
};
6385
ret
6486
}
6587

6688
pub fn style_colors_dark(&self){
67-
let module = &self.module;
6889
js! {
69-
return @{module}.StyleColorsDark();
90+
return window.Imgui.StyleColorsDark();
7091
};
7192
}
7293

7394
#[allow(non_snake_case)]
7495
pub fn IM_ASSERT(&self, cond:bool){
75-
let module = &self.module;
7696
js! {
77-
@{module}.IM_ASSERT(@{cond});
97+
window.Imgui.IM_ASSERT(@{cond});
7898
};
7999
}
80100
}

0 commit comments

Comments
 (0)