22
33use controls:: Control ;
44use draw;
5- use std:: os:: raw:: c_int;
65use std:: mem;
6+ use std:: os:: raw:: c_int;
77use ui:: UI ;
88pub use ui_sys:: uiExtKey as ExtKey ;
99use ui_sys:: {
@@ -30,11 +30,11 @@ impl RustAreaHandler {
3030 fn new ( _ctx : & UI , trait_object : Box < AreaHandler > ) -> Box < RustAreaHandler > {
3131 return Box :: new ( RustAreaHandler {
3232 ui_area_handler : uiAreaHandler {
33- Draw : draw,
34- MouseEvent : mouse_event,
35- MouseCrossed : mouse_crossed,
36- DragBroken : drag_broken,
37- KeyEvent : key_event,
33+ Draw : Some ( draw) ,
34+ MouseEvent : Some ( mouse_event) ,
35+ MouseCrossed : Some ( mouse_crossed) ,
36+ DragBroken : Some ( drag_broken) ,
37+ KeyEvent : Some ( key_event) ,
3838 } ,
3939 trait_object : trait_object,
4040 } ) ;
@@ -116,7 +116,7 @@ impl RustAreaHandler {
116116 }
117117}
118118
119- define_control ! {
119+ define_control ! {
120120 /// A space on which the application can draw custom content.
121121 /// Area is a Control that represents a blank canvas that a program can draw on as
122122 /// it wishes. Areas also receive keyboard and mouse events, and programs can react
@@ -170,8 +170,8 @@ impl Area {
170170 let mut rust_area_handler = RustAreaHandler :: new ( ctx, area_handler) ;
171171 let area = Area :: from_raw ( ui_sys:: uiNewScrollingArea (
172172 & mut * rust_area_handler as * mut RustAreaHandler as * mut uiAreaHandler ,
173- width,
174- height,
173+ width as i32 ,
174+ height as i32 ,
175175 ) ) ;
176176 mem:: forget ( rust_area_handler) ;
177177 area
@@ -188,7 +188,7 @@ impl Area {
188188 /// If called on a non-scrolling `Area`, this function's behavior is undefined.
189189 pub unsafe fn set_size ( & self , _ctx : & UI , width : u64 , height : u64 ) {
190190 // TODO: Check if the area is scrolling?
191- unsafe { ui_sys:: uiAreaSetSize ( self . uiArea , width as i64 , height as i64 ) }
191+ ui_sys:: uiAreaSetSize ( self . uiArea , width as i32 , height as i32 ) ;
192192 }
193193
194194 /// Queues the entire `Area` to be redrawn. This function returns immediately;
@@ -205,7 +205,7 @@ impl Area {
205205 /// If called on a non-scrolling `Area`, this function's behavior is undefined.
206206 pub unsafe fn scroll_to ( & self , _ctx : & UI , x : f64 , y : f64 , width : f64 , height : f64 ) {
207207 // TODO: Make some way to check whether the given area is scrolling or not.
208- unsafe { ui_sys:: uiAreaScrollTo ( self . uiArea , x, y, width, height) }
208+ ui_sys:: uiAreaScrollTo ( self . uiArea , x, y, width, height) ;
209209 }
210210}
211211
@@ -253,11 +253,11 @@ impl AreaDrawParams {
253253}
254254
255255bitflags ! {
256- pub flags Modifiers : u8 {
257- const MODIFIER_CTRL = 1 << 0 ,
258- const MODIFIER_ALT = 1 << 1 ,
259- const MODIFIER_SHIFT = 1 << 2 ,
260- const MODIFIER_SUPER = 1 << 3 ,
256+ pub struct Modifiers : u8 {
257+ const MODIFIER_CTRL = 1 << 0 ;
258+ const MODIFIER_ALT = 1 << 1 ;
259+ const MODIFIER_SHIFT = 1 << 2 ;
260+ const MODIFIER_SUPER = 1 << 3 ;
261261 }
262262}
263263
0 commit comments