mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-25 05:38:11 +08:00
Fix popover layout
This commit is contained in:
@@ -241,6 +241,12 @@ impl<'a> Iterator for WidgetIter<'a> {
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
if let Some(item) = self.current_slice.and_then(|slice| slice.first()) {
|
||||
self.current_slice = Some(&self.current_slice.unwrap()[1..]);
|
||||
|
||||
if let WidgetHolder { widget: Widget::PopoverButton(p), .. } = item {
|
||||
self.stack.extend(p.options_widget.iter());
|
||||
return self.next();
|
||||
}
|
||||
|
||||
return Some(item);
|
||||
}
|
||||
|
||||
@@ -276,6 +282,12 @@ impl<'a> Iterator for WidgetIterMut<'a> {
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
if let Some((first, rest)) = self.current_slice.take().and_then(|slice| slice.split_first_mut()) {
|
||||
self.current_slice = Some(rest);
|
||||
|
||||
if let WidgetHolder { widget: Widget::PopoverButton(p), .. } = first {
|
||||
self.stack.extend(p.options_widget.iter_mut());
|
||||
return self.next();
|
||||
}
|
||||
|
||||
return Some(first);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use crate::messages::input_mapper::utility_types::misc::ActionKeys;
|
||||
use crate::messages::layout::utility_types::layout_widget::WidgetCallback;
|
||||
use crate::messages::layout::utility_types::widget_prelude::SubLayout;
|
||||
use crate::messages::layout::utility_types::widget_prelude::WidgetLayout;
|
||||
use crate::messages::portfolio::document::node_graph::FrontendGraphDataType;
|
||||
|
||||
@@ -49,7 +50,8 @@ pub struct PopoverButton {
|
||||
|
||||
pub tooltip: String,
|
||||
|
||||
pub options_widget: WidgetLayout,
|
||||
#[serde(rename = "optionsWidget")]
|
||||
pub options_widget: SubLayout,
|
||||
|
||||
#[serde(skip)]
|
||||
pub tooltip_shortcut: Option<ActionKeys>,
|
||||
|
||||
@@ -1565,15 +1565,23 @@ impl DocumentMessageHandler {
|
||||
WidgetHolder::new(Widget::PopoverButton(PopoverButton {
|
||||
header: "Snapping".into(),
|
||||
text: "Select the vector to snap to.".into(), // TODO: check whether this is an apt description
|
||||
options_widget: WidgetLayout::new(vec![LayoutGroup::Row {
|
||||
options_widget: vec![LayoutGroup::Row {
|
||||
widgets: vec![WidgetHolder::new(Widget::DropdownInput(DropdownInput {
|
||||
entries: vec![vec![
|
||||
DropdownEntryData {
|
||||
label: SnappingOptions::BoundingBoxes.to_string(),
|
||||
on_update: WidgetCallback::new(|_| {
|
||||
info!("Bouding boxes");
|
||||
Message::NoOp
|
||||
}),
|
||||
..DropdownEntryData::default()
|
||||
},
|
||||
DropdownEntryData {
|
||||
label: SnappingOptions::Nodes.to_string(),
|
||||
on_update: WidgetCallback::new(|_| {
|
||||
info!("Nodes");
|
||||
Message::NoOp
|
||||
}),
|
||||
..DropdownEntryData::default()
|
||||
},
|
||||
]],
|
||||
@@ -1582,7 +1590,7 @@ impl DocumentMessageHandler {
|
||||
interactive: true,
|
||||
..Default::default()
|
||||
}))],
|
||||
}]),
|
||||
}],
|
||||
..Default::default()
|
||||
})),
|
||||
WidgetHolder::new(Widget::Separator(Separator {
|
||||
|
||||
Reference in New Issue
Block a user