section: Moved bounds to row
This commit is contained in:
		@ -17,6 +17,9 @@ struct squeek_button *squeek_row_create_button_with_state(struct squeek_row *row
 | 
			
		||||
void squeek_row_set_angle(struct squeek_row *row, int32_t angle);
 | 
			
		||||
int32_t squeek_row_get_angle(struct squeek_row*);
 | 
			
		||||
 | 
			
		||||
EekBounds squeek_row_get_bounds(const struct squeek_row*);
 | 
			
		||||
void squeek_row_set_bounds(struct squeek_row* row, EekBounds bounds);
 | 
			
		||||
 | 
			
		||||
uint32_t squeek_row_contains(struct squeek_row*, struct squeek_button *button);
 | 
			
		||||
 | 
			
		||||
struct squeek_button* squeek_row_find_key(struct squeek_row*, struct squeek_key *state);
 | 
			
		||||
 | 
			
		||||
@ -43,6 +43,7 @@ pub mod c {
 | 
			
		||||
        Box::into_raw(Box::new(::layout::Row {
 | 
			
		||||
            buttons: Vec::new(),
 | 
			
		||||
            angle: angle,
 | 
			
		||||
            bounds: None,
 | 
			
		||||
        }))
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
@ -108,6 +109,25 @@ pub mod c {
 | 
			
		||||
        row.angle
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    #[no_mangle]
 | 
			
		||||
    pub extern "C"
 | 
			
		||||
    fn squeek_row_get_bounds(row: *const ::layout::Row) -> Bounds {
 | 
			
		||||
        let row = unsafe { &*row };
 | 
			
		||||
        match &row.bounds {
 | 
			
		||||
            Some(bounds) => bounds.clone(),
 | 
			
		||||
            None => panic!("Row doesn't have any bounds yet"),
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /// Set bounds by consuming the value
 | 
			
		||||
    #[no_mangle]
 | 
			
		||||
    pub extern "C"
 | 
			
		||||
    fn squeek_row_set_bounds(row: *mut ::layout::Row, bounds: Bounds) {
 | 
			
		||||
        let row = unsafe { &mut *row };
 | 
			
		||||
        row.bounds = Some(bounds);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
    #[no_mangle]
 | 
			
		||||
    pub extern "C"
 | 
			
		||||
    fn squeek_row_contains(
 | 
			
		||||
@ -242,8 +262,6 @@ pub mod c {
 | 
			
		||||
    mod procedures {
 | 
			
		||||
        use super::*;
 | 
			
		||||
        
 | 
			
		||||
        use std::convert::TryFrom;
 | 
			
		||||
 | 
			
		||||
        #[repr(transparent)]
 | 
			
		||||
        pub struct LevelKeyboard(*const c_void);
 | 
			
		||||
 | 
			
		||||
@ -376,4 +394,5 @@ pub struct Button {
 | 
			
		||||
pub struct Row {
 | 
			
		||||
    buttons: Vec<Box<Button>>,
 | 
			
		||||
    angle: i32,
 | 
			
		||||
    bounds: Option<c::Bounds>,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user