|
@@ -1,7 +1,7 @@
|
|
|
use crate::{
|
|
|
component::Component,
|
|
|
input::InputState,
|
|
|
- layout::{LayoutNode, LayoutNodeAccess, LayoutNodeContainer},
|
|
|
+ layout::{LayoutNode, LayoutNodeAccess, LayoutNodeContainer, SizePolicy, ChildArrangement},
|
|
|
theme::Theme,
|
|
|
ui::UIHandle,
|
|
|
widget::Widget, window::RenderFormat,
|
|
@@ -15,14 +15,41 @@ pub struct PlainGroup<C: Component> {
|
|
|
impl<C: Component> PlainGroup<C> {
|
|
|
pub fn new(uih: &UIHandle) -> Self {
|
|
|
Self {
|
|
|
- lnode: uih.new_layout_node(),
|
|
|
+ lnode: {
|
|
|
+ let mut node = uih.new_layout_node();
|
|
|
+ node.set_width_policy(SizePolicy::expanding(1));
|
|
|
+ node.set_height_policy(SizePolicy::expanding(1));
|
|
|
+ node
|
|
|
+ },
|
|
|
children: vec![],
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ pub fn new_column(uih: &UIHandle) -> Self {
|
|
|
+ let mut ret = Self::new(uih);
|
|
|
+ ret.lnode.set_arrangement(ChildArrangement::Column);
|
|
|
+ ret
|
|
|
+ }
|
|
|
+
|
|
|
+ pub fn new_row(uih: &UIHandle) -> Self {
|
|
|
+ let mut ret = Self::new(uih);
|
|
|
+ ret.lnode.set_arrangement(ChildArrangement::Row);
|
|
|
+ ret
|
|
|
+ }
|
|
|
+
|
|
|
+ pub fn new_table(uih: &UIHandle) -> Self {
|
|
|
+ let mut ret = Self::new(uih);
|
|
|
+ ret.lnode.set_arrangement(ChildArrangement::Table);
|
|
|
+ ret
|
|
|
+ }
|
|
|
+
|
|
|
pub fn append(&mut self, widget: Box<dyn Widget<C>>) {
|
|
|
self.children.push(widget);
|
|
|
}
|
|
|
+
|
|
|
+ pub fn extend(&mut self, with: impl Iterator<Item = Box<dyn Widget<C>>>) {
|
|
|
+ self.children.extend(with);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
impl<C: Component> LayoutNodeContainer for PlainGroup<C> {
|
|
@@ -59,3 +86,47 @@ impl<C: Component> Widget<C> for PlainGroup<C> {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+use super::Label;
|
|
|
+
|
|
|
+pub struct FormGroup<C: Component> {
|
|
|
+ lnode: LayoutNode,
|
|
|
+ labelnode: LayoutNode,
|
|
|
+ widgetnode: LayoutNode,
|
|
|
+ labels: Vec<Label<C>>,
|
|
|
+ widgets: Vec<Box<dyn Widget<C>>>,
|
|
|
+}
|
|
|
+
|
|
|
+struct LabelContainer<'l, C: Component>(&'l FormGroup<C>);
|
|
|
+struct WidgetContainer<'l, C: Component>(&'l FormGroup<C>);
|
|
|
+
|
|
|
+impl<C: Component> LayoutNodeContainer for FormGroup<C> {
|
|
|
+ fn layout_node(&self) -> &LayoutNode {
|
|
|
+ &self.lnode
|
|
|
+ }
|
|
|
+ fn layout_child(&self, ndx: usize) -> Option<LayoutNodeAccess<'_>> {
|
|
|
+ match ndx {
|
|
|
+ 0 => todo!(), // Some(LayoutNodeAccess::new(LabelContainer(self))),
|
|
|
+ 1 => todo!(),
|
|
|
+ _ => None
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fn layout_child_count(&self) -> usize {
|
|
|
+ 2
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+impl<C: Component> Widget<C> for FormGroup<C> {
|
|
|
+ fn layout_node(&self) -> LayoutNodeAccess {
|
|
|
+ todo!()
|
|
|
+ }
|
|
|
+ fn layout_node_mut(&mut self) -> &mut LayoutNode {
|
|
|
+ todo!()
|
|
|
+ }
|
|
|
+ fn poll(&mut self, uih: &mut UIHandle, input_state: Option<&InputState>) -> Vec<<C as Component>::Msg> {
|
|
|
+ todo!()
|
|
|
+ }
|
|
|
+ fn render(&self, theme: &Theme, target: &mut kahlo::BitmapMut<RenderFormat>) {
|
|
|
+
|
|
|
+ }
|
|
|
+}
|