wgui: custom attribs
This commit is contained in:
@@ -246,7 +246,7 @@ pub fn construct<U1, U2>(
|
||||
listeners: &mut EventListenerCollection<U1, U2>,
|
||||
parent: WidgetID,
|
||||
params: Params,
|
||||
) -> anyhow::Result<Rc<ComponentButton>> {
|
||||
) -> anyhow::Result<(WidgetID, Rc<ComponentButton>)> {
|
||||
let mut style = params.style;
|
||||
|
||||
// force-override style
|
||||
@@ -256,7 +256,7 @@ pub fn construct<U1, U2>(
|
||||
|
||||
let globals = layout.state.globals.clone();
|
||||
|
||||
let (id_rect, _) = layout.add_child(
|
||||
let (id_root, _) = layout.add_child(
|
||||
parent,
|
||||
WidgetRectangle::create(WidgetRectangleParams {
|
||||
color: params.color,
|
||||
@@ -268,6 +268,7 @@ pub fn construct<U1, U2>(
|
||||
}),
|
||||
style,
|
||||
)?;
|
||||
let id_rect = id_root;
|
||||
|
||||
let light_text = (params.color.r + params.color.g + params.color.b) < 1.5;
|
||||
|
||||
@@ -316,5 +317,5 @@ pub fn construct<U1, U2>(
|
||||
let button = Rc::new(ComponentButton { base, data, state });
|
||||
|
||||
layout.defer_component_init(Component(button.clone()));
|
||||
Ok(button)
|
||||
Ok((id_root, button))
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ pub fn construct<U1, U2>(
|
||||
listeners: &mut EventListenerCollection<U1, U2>,
|
||||
parent: WidgetID,
|
||||
params: Params,
|
||||
) -> anyhow::Result<Rc<ComponentCheckbox>> {
|
||||
) -> anyhow::Result<(WidgetID, Rc<ComponentCheckbox>)> {
|
||||
let mut style = params.style;
|
||||
|
||||
// force-override style
|
||||
@@ -282,7 +282,7 @@ pub fn construct<U1, U2>(
|
||||
|
||||
let globals = layout.state.globals.clone();
|
||||
|
||||
let (id_container, _) = layout.add_child(
|
||||
let (id_root, _) = layout.add_child(
|
||||
parent,
|
||||
WidgetRectangle::create(WidgetRectangleParams {
|
||||
color: Color::new(1.0, 1.0, 1.0, 0.0),
|
||||
@@ -292,6 +292,7 @@ pub fn construct<U1, U2>(
|
||||
}),
|
||||
style,
|
||||
)?;
|
||||
let id_container = id_root;
|
||||
|
||||
let box_size = taffy::Size {
|
||||
width: length(params.box_size),
|
||||
@@ -375,5 +376,5 @@ pub fn construct<U1, U2>(
|
||||
let checkbox = Rc::new(ComponentCheckbox { base, data, state });
|
||||
|
||||
layout.defer_component_init(Component(checkbox.clone()));
|
||||
Ok(checkbox)
|
||||
Ok((id_root, checkbox))
|
||||
}
|
||||
|
||||
@@ -322,13 +322,14 @@ pub fn construct<U1, U2>(
|
||||
listeners: &mut EventListenerCollection<U1, U2>,
|
||||
parent: WidgetID,
|
||||
params: Params,
|
||||
) -> anyhow::Result<Rc<ComponentSlider>> {
|
||||
) -> anyhow::Result<(WidgetID, Rc<ComponentSlider>)> {
|
||||
let mut style = params.style;
|
||||
style.position = taffy::Position::Relative;
|
||||
style.min_size = style.size;
|
||||
style.max_size = style.size;
|
||||
|
||||
let (body_id, slider_body_node) = layout.add_child(parent, WidgetDiv::create(), style)?;
|
||||
let (root_id, slider_body_node) = layout.add_child(parent, WidgetDiv::create(), style)?;
|
||||
let body_id = root_id;
|
||||
|
||||
let (_background_id, _) = layout.add_child(
|
||||
body_id,
|
||||
@@ -432,5 +433,5 @@ pub fn construct<U1, U2>(
|
||||
let slider = Rc::new(ComponentSlider { base, data, state });
|
||||
|
||||
layout.defer_component_init(Component(slider.clone()));
|
||||
Ok(slider)
|
||||
Ok((root_id, slider))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user