mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-01 03:58:11 +08:00
Add Snapping Options to the Snap Dropdown Menu (#1321)
* [wip]feat: add snapping options
* [wip]fix: use svelte component for optionsWidget
* fix: use apt PopoverButton types
* refactor: minor formatting improvements
* Fix popover layout
* [wip]feat: attempt implementing CheckboxInputData struct
* fix: use correct Checkbox struct 's default method
* fix: revert adding CheckboxInputData struct
- This reverts commit 2a481887fc.
* feat: use checkboxes for snapping options
* feat: add label to dropdown checkbox elements
* fix: separate Snap dropdown menu elements
- move each element into separate row
* [wip]feat: modularize snapping states
- maintain individual snapping states for document
* fix: snapping checkboxes' behavior
- checkboxes now update internal snapping state
* refactor: update snap states individually
- this prevents out-of-sync states
- enables reusing existing snap state object
* feat: snap to boxes and nodes conditionally
* [wip]feat: attempt to invert checkbox on update
- attempt implementing mutable WidgetCallback struct
- attempt using above struct to invert checkbox state on update
* Fix widget diffing
* refactor: remove unused code
* feat: align checkboxes consistently with labels
* feat: use separators to stylize snapping menu
- removes need for custom CSS and label property
- ensures consistency across the application
* refactor: remove unneeded css
---------
Co-authored-by: hypercube <0hypercube@gmail.com>, TrueDoctor <dennis@kobert.dev>
This commit is contained in:
committed by
Keavon Chambers
co-authored by
hypercube <0hypercube@gmail.com>, TrueDoctor
parent
4c9daadb01
commit
743803ce04
@@ -31,6 +31,10 @@ impl LayoutMessageHandler {
|
||||
widget_path.push(index);
|
||||
return Some((widget, widget_path));
|
||||
}
|
||||
|
||||
if let Widget::PopoverButton(popover) = &widget.widget {
|
||||
stack.extend(popover.options_widget.iter().enumerate().map(|(child, val)| ([widget_path.as_slice(), &[index, child]].concat(), val)));
|
||||
}
|
||||
}
|
||||
}
|
||||
// A section contains more LayoutGroups which we add to the stack.
|
||||
|
||||
@@ -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::portfolio::document::node_graph::FrontendGraphDataType;
|
||||
|
||||
use graphite_proc_macros::WidgetBuilder;
|
||||
@@ -48,6 +49,9 @@ pub struct PopoverButton {
|
||||
|
||||
pub tooltip: String,
|
||||
|
||||
#[serde(rename = "optionsWidget")]
|
||||
pub options_widget: SubLayout,
|
||||
|
||||
#[serde(skip)]
|
||||
pub tooltip_shortcut: Option<ActionKeys>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user