layout: Keep content purpose around
This allows to add proper CSS style classes based on that
This commit is contained in:
@ -61,7 +61,7 @@ pub mod c {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let (kind, layout) = load_layout_data_with_fallback(&name, type_, variant, overlay_str);
|
let (kind, layout) = load_layout_data_with_fallback(&name, type_, variant, overlay_str);
|
||||||
let layout = ::layout::Layout::new(layout, kind);
|
let layout = ::layout::Layout::new(layout, kind, variant);
|
||||||
Box::into_raw(Box::new(layout))
|
Box::into_raw(Box::new(layout))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -233,7 +233,7 @@ bitflags!{
|
|||||||
/// use rs::imservice::ContentPurpose;
|
/// use rs::imservice::ContentPurpose;
|
||||||
/// assert_eq!(ContentPurpose::Alpha as u32, 1);
|
/// assert_eq!(ContentPurpose::Alpha as u32, 1);
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub enum ContentPurpose {
|
pub enum ContentPurpose {
|
||||||
Normal = 0,
|
Normal = 0,
|
||||||
Alpha = 1,
|
Alpha = 1,
|
||||||
|
|||||||
@ -33,6 +33,7 @@ struct transformation squeek_layout_calculate_transformation(
|
|||||||
|
|
||||||
struct squeek_layout *squeek_load_layout(const char *name, uint32_t type, uint32_t variant_type, const char *overlay_name);
|
struct squeek_layout *squeek_load_layout(const char *name, uint32_t type, uint32_t variant_type, const char *overlay_name);
|
||||||
enum squeek_arrangement_kind squeek_layout_get_kind(const struct squeek_layout *);
|
enum squeek_arrangement_kind squeek_layout_get_kind(const struct squeek_layout *);
|
||||||
|
uint32_t squeek_layout_get_purpose(const struct squeek_layout *);
|
||||||
void squeek_layout_free(struct squeek_layout*);
|
void squeek_layout_free(struct squeek_layout*);
|
||||||
|
|
||||||
void squeek_layout_release(struct squeek_layout *layout,
|
void squeek_layout_release(struct squeek_layout *layout,
|
||||||
|
|||||||
@ -32,6 +32,8 @@ use ::manager;
|
|||||||
use ::submission::{ Submission, SubmitData, Timestamp };
|
use ::submission::{ Submission, SubmitData, Timestamp };
|
||||||
use ::util::find_max_double;
|
use ::util::find_max_double;
|
||||||
|
|
||||||
|
use ::imservice::ContentPurpose;
|
||||||
|
|
||||||
// Traits
|
// Traits
|
||||||
use std::borrow::Borrow;
|
use std::borrow::Borrow;
|
||||||
use ::logging::Warn;
|
use ::logging::Warn;
|
||||||
@ -183,6 +185,13 @@ pub mod c {
|
|||||||
layout.kind.clone() as u32
|
layout.kind.clone() as u32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C"
|
||||||
|
fn squeek_layout_get_purpose(layout: *const Layout) -> u32 {
|
||||||
|
let layout = unsafe { &*layout };
|
||||||
|
layout.purpose.clone() as u32
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C"
|
pub extern "C"
|
||||||
fn squeek_layout_free(layout: *mut Layout) {
|
fn squeek_layout_free(layout: *mut Layout) {
|
||||||
@ -627,6 +636,7 @@ pub enum LatchedState {
|
|||||||
pub struct Layout {
|
pub struct Layout {
|
||||||
pub margins: Margins,
|
pub margins: Margins,
|
||||||
pub kind: ArrangementKind,
|
pub kind: ArrangementKind,
|
||||||
|
pub purpose: ContentPurpose,
|
||||||
pub current_view: String,
|
pub current_view: String,
|
||||||
|
|
||||||
// If current view is latched,
|
// If current view is latched,
|
||||||
@ -676,7 +686,7 @@ impl fmt::Display for NoSuchView {
|
|||||||
// The usage of &mut on Rc<RefCell<KeyState>> doesn't mean anything special.
|
// The usage of &mut on Rc<RefCell<KeyState>> doesn't mean anything special.
|
||||||
// Cloning could also be used.
|
// Cloning could also be used.
|
||||||
impl Layout {
|
impl Layout {
|
||||||
pub fn new(data: LayoutData, kind: ArrangementKind) -> Layout {
|
pub fn new(data: LayoutData, kind: ArrangementKind, purpose: ContentPurpose) -> Layout {
|
||||||
Layout {
|
Layout {
|
||||||
kind,
|
kind,
|
||||||
current_view: "base".to_owned(),
|
current_view: "base".to_owned(),
|
||||||
@ -685,6 +695,7 @@ impl Layout {
|
|||||||
keymaps: data.keymaps,
|
keymaps: data.keymaps,
|
||||||
pressed_keys: HashSet::new(),
|
pressed_keys: HashSet::new(),
|
||||||
margins: data.margins,
|
margins: data.margins,
|
||||||
|
purpose,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1194,6 +1205,7 @@ mod test {
|
|||||||
"base".into() => (c::Point { x: 0.0, y: 0.0 }, view.clone()),
|
"base".into() => (c::Point { x: 0.0, y: 0.0 }, view.clone()),
|
||||||
"locked".into() => (c::Point { x: 0.0, y: 0.0 }, view),
|
"locked".into() => (c::Point { x: 0.0, y: 0.0 }, view),
|
||||||
},
|
},
|
||||||
|
purpose: ContentPurpose::Normal,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Basic cycle
|
// Basic cycle
|
||||||
@ -1270,6 +1282,7 @@ mod test {
|
|||||||
"locked".into() => (c::Point { x: 0.0, y: 0.0 }, view.clone()),
|
"locked".into() => (c::Point { x: 0.0, y: 0.0 }, view.clone()),
|
||||||
"unlocked".into() => (c::Point { x: 0.0, y: 0.0 }, view),
|
"unlocked".into() => (c::Point { x: 0.0, y: 0.0 }, view),
|
||||||
},
|
},
|
||||||
|
purpose: ContentPurpose::Normal,
|
||||||
};
|
};
|
||||||
|
|
||||||
layout.apply_view_transition(&switch);
|
layout.apply_view_transition(&switch);
|
||||||
@ -1336,6 +1349,7 @@ mod test {
|
|||||||
"locked".into() => (c::Point { x: 0.0, y: 0.0 }, view.clone()),
|
"locked".into() => (c::Point { x: 0.0, y: 0.0 }, view.clone()),
|
||||||
"ĄĘ".into() => (c::Point { x: 0.0, y: 0.0 }, view),
|
"ĄĘ".into() => (c::Point { x: 0.0, y: 0.0 }, view),
|
||||||
},
|
},
|
||||||
|
purpose: ContentPurpose::Normal,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Latch twice, then Ąto-unlatch across 2 levels
|
// Latch twice, then Ąto-unlatch across 2 levels
|
||||||
@ -1436,6 +1450,7 @@ mod test {
|
|||||||
views: hashmap! {
|
views: hashmap! {
|
||||||
String::new() => (c::Point { x: 0.0, y: 0.0 }, view),
|
String::new() => (c::Point { x: 0.0, y: 0.0 }, view),
|
||||||
},
|
},
|
||||||
|
purpose: ContentPurpose::Normal,
|
||||||
};
|
};
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
layout.calculate_inner_size(),
|
layout.calculate_inner_size(),
|
||||||
|
|||||||
Reference in New Issue
Block a user