diff options
| author | Polesznyák Márk László <116908301+pml68@users.noreply.github.com> | 2025-01-11 23:13:07 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-11 23:13:07 +0100 |
| commit | 103699beeb8bdce38bc5803cbe038e74cbc20e40 (patch) | |
| tree | b79e13b3decc778cc7c66af7187c647ae0a21a52 /iced_drop/src/widget/operation | |
| parent | Merge pull request #4 from pml68/feat/playground (diff) | |
| parent | refactor: remove iced_drop & workspace (diff) | |
| download | iced-builder-103699beeb8bdce38bc5803cbe038e74cbc20e40.tar.gz | |
Merge pull request #5 from pml68/feat/config
Config done
Diffstat (limited to '')
| -rw-r--r-- | iced_drop/src/widget/operation.rs | 1 | ||||
| -rw-r--r-- | iced_drop/src/widget/operation/drop.rs | 90 |
2 files changed, 0 insertions, 91 deletions
diff --git a/iced_drop/src/widget/operation.rs b/iced_drop/src/widget/operation.rs deleted file mode 100644 index 3d7dcff..0000000 --- a/iced_drop/src/widget/operation.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod drop; diff --git a/iced_drop/src/widget/operation/drop.rs b/iced_drop/src/widget/operation/drop.rs deleted file mode 100644 index a76181c..0000000 --- a/iced_drop/src/widget/operation/drop.rs +++ /dev/null @@ -1,90 +0,0 @@ -use iced::{ - advanced::widget::{ - operation::{Outcome, Scrollable}, - Id, Operation, - }, - Rectangle, Vector, -}; - -/// Produces an [`Operation`] that will find the drop zones that pass a filter on the zone's bounds. -/// For any drop zone to be considered, the Element must have some Id. -/// If `options` is `None`, all drop zones will be considered. -/// Depth determines how how deep into nested drop zones to go. -/// If 'depth' is `None`, nested dropzones will be fully explored -pub fn find_zones<F>( - filter: F, - options: Option<Vec<Id>>, - depth: Option<usize>, -) -> impl Operation<Vec<(Id, Rectangle)>> -where - F: Fn(&Rectangle) -> bool + Send + 'static, -{ - struct FindDropZone<F> { - filter: F, - options: Option<Vec<Id>>, - zones: Vec<(Id, Rectangle)>, - max_depth: Option<usize>, - c_depth: usize, - offset: Vector, - } - - impl<F> Operation<Vec<(Id, Rectangle)>> for FindDropZone<F> - where - F: Fn(&Rectangle) -> bool + Send + 'static, - { - fn container( - &mut self, - id: Option<&Id>, - bounds: iced::Rectangle, - operate_on_children: &mut dyn FnMut(&mut dyn Operation<Vec<(Id, Rectangle)>>), - ) { - match id { - Some(id) => { - let is_option = match &self.options { - Some(options) => options.contains(id), - None => true, - }; - let bounds = bounds - self.offset; - if is_option && (self.filter)(&bounds) { - self.c_depth += 1; - self.zones.push((id.clone(), bounds)); - } - } - None => (), - } - let goto_next = match &self.max_depth { - Some(m_depth) => self.c_depth < *m_depth, - None => true, - }; - if goto_next { - operate_on_children(self); - } - } - - fn finish(&self) -> Outcome<Vec<(Id, Rectangle)>> { - Outcome::Some(self.zones.clone()) - } - - fn scrollable( - &mut self, - _state: &mut dyn Scrollable, - _id: Option<&Id>, - bounds: Rectangle, - _content_bounds: Rectangle, - translation: Vector, - ) { - if (self.filter)(&bounds) { - self.offset = self.offset + translation; - } - } - } - - FindDropZone { - filter, - options, - zones: vec![], - max_depth: depth, - c_depth: 0, - offset: Vector { x: 0.0, y: 0.0 }, - } -} |
