pebble_rust/pebble/internal/functions/
interface.rs1#![allow(unused)]
27
28use crate::pebble::internal::types::*;
29use core::intrinsics;
30
31use crate::pebble::internal::functions::declarations;
32
33pub fn app_event_loop() {
34 unsafe {
35 declarations::app_event_loop();
36 }
37}
38
39pub fn window_create() -> *mut Window {
40 unsafe {
41 declarations::window_create()
42 }
43}
44
45pub fn window_destroy(window: *mut Window) {
46 unsafe {
47 declarations::window_destroy(window);
48 }
49}
50
51pub fn window_set_click_config_provider<T>(window: *mut Window, func: extern fn(*mut T)) {
52 unsafe {
53 declarations::window_set_click_config_provider(window, intrinsics::transmute(func));
54 }
55}
56
57pub fn window_set_click_config_provider_with_context<T>(window: *mut Window, func: extern fn(*mut T), ctx: *mut T) {
58 unsafe {
59 declarations::window_set_click_config_provider_with_context(window,
60 intrinsics::transmute(func),
61 intrinsics::transmute(ctx));
62 }
63}
64
65pub fn window_set_window_handlers(window: *mut Window, handlers: WindowHandlers) {
66 unsafe {
67 declarations::window_set_window_handlers(window, handlers);
68 }
69}
70
71pub fn window_set_background_color(window: *mut Window, color: GColor) {
72 unsafe {
73 declarations::window_set_background_color(window, color);
74 }
75}
76
77pub fn window_set_user_data<T>(window: *mut Window, data: *mut T) {
78 unsafe {
79 declarations::window_set_user_data(window, intrinsics::transmute(data));
80 }
81}
82
83pub fn window_get_user_data<T>(window: *mut Window) -> *mut T {
84 unsafe {
85 intrinsics::transmute(declarations::window_get_user_data(window))
86 }
87}
88
89pub fn window_stack_push(window: *mut Window, animate: bool) {
90 unsafe {
91 if animate {
92 declarations::window_stack_push(window, 1);
93 } else {
94 declarations::window_stack_push(window, 0);
95 }
96 }
97}
98
99pub fn window_get_root_layer(window: *mut Window) -> *mut Layer {
100 unsafe {
101 declarations::window_get_root_layer(window)
102 }
103}
104
105pub fn window_single_click_subscribe<T>(button: u8, func: extern fn(*mut ClickRecognizer, *mut T)) {
106 unsafe {
107 declarations::window_single_click_subscribe(button, intrinsics::transmute(func));
108 }
109}
110
111pub fn layer_create(bounds: GRect) -> *mut Layer {
112 unsafe {
113 declarations::layer_create(bounds)
114 }
115}
116
117pub fn layer_destroy(layer: *mut Layer) {
118 unsafe {
119 declarations::layer_destroy(layer);
120 }
121}
122
123pub fn layer_get_frame(layer: *mut Layer) -> GRect {
124 unsafe {
125 declarations::layer_get_frame(layer)
126 }
127}
128
129pub fn layer_get_bounds(layer: *mut Layer) -> GRect {
130 unsafe {
131 declarations::layer_get_bounds(layer)
132 }
133}
134
135pub fn layer_add_child(layer: *mut Layer, child: *mut Layer) {
136 unsafe {
137 declarations::layer_add_child(layer, child);
138 }
139}
140
141pub fn layer_mark_dirty(layer: *mut Layer) {
142 unsafe {
143 declarations::layer_mark_dirty(layer);
144 }
145}
146
147pub fn layer_set_update_proc(layer: *mut Layer, func: extern fn(*mut Layer, *mut GContext)) {
148 unsafe {
149 declarations::layer_set_update_proc(layer, func);
150 }
151}
152
153pub fn text_layer_create(bounds: GRect) -> *mut TextLayer {
154 unsafe {
155 declarations::text_layer_create(bounds)
156 }
157}
158
159pub fn text_layer_set_text(layer: *mut TextLayer, text: &str) {
160 unsafe {
161 declarations::text_layer_set_text(layer, text.as_ptr());
162 }
163}
164pub fn text_layer_get_layer(layer: *mut TextLayer) -> *mut Layer {
165 unsafe {
166 declarations::text_layer_get_layer(layer)
167 }
168}
169
170pub fn gbitmap_create_with_resource(id: u32) -> *mut GBitmap {
171 unsafe {
172 declarations::gbitmap_create_with_resource(id)
173 }
174}
175
176pub fn bitmap_layer_create(frame: GRect) -> *mut BitmapLayer {
177 unsafe {
178 declarations::bitmap_layer_create(frame)
179 }
180}
181
182pub fn bitmap_layer_set_bitmap(layer: *mut BitmapLayer, bitmap: *mut GBitmap) {
183 unsafe {
184 declarations::bitmap_layer_set_bitmap(layer, bitmap);
185 }
186}
187
188pub fn bitmap_layer_set_compositing_mode(layer: *mut BitmapLayer, mode: GCompOp) {
189 unsafe {
190 declarations::bitmap_layer_set_compositing_mode(layer, mode);
191 }
192}
193
194pub fn bitmap_layer_get_layer(layer: *mut BitmapLayer) -> *mut Layer {
195 unsafe {
196 declarations::bitmap_layer_get_layer(layer)
197 }
198}
199
200pub fn graphics_context_set_fill_color(ctx: *mut GContext, color: GColor) {
201 unsafe {
202 declarations::graphics_context_set_fill_color(ctx, color);
203 }
204}
205
206pub fn graphics_fill_circle(ctx: *mut GContext, center: GPoint, radius: u16) {
207 unsafe {
208 declarations::graphics_fill_circle(ctx, center, radius);
209 }
210}
211
212pub fn clock_is_24h_style() -> bool {
213 unsafe {
214 let response = declarations::clock_is_24h_style();
215 if response == 0 {
216 false
217 } else {
218 true
219 }
220 }
221}
222
223pub fn tick_timer_service_subscribe(unit: TimeUnits, func: extern fn(*mut tm, TimeUnits)) {
224 unsafe {
225 declarations::tick_timer_service_subscribe(unit, func);
226 }
227}
228
229pub fn time() -> usize {
230 unsafe {
231 declarations::time(0 as *mut usize)
232 }
233}
234
235pub fn localtime(now: usize) -> *mut tm {
236 unsafe {
237 let now_ptr = &now as *const usize;
238 declarations::localtime(now_ptr)
239 }
240}
241
242pub fn app_log(msg: &str) {
243 unsafe {
244 declarations::app_log(50, "main\0".as_ptr(), 0, msg.as_ptr());
245 }
246}