libcosmic-yoda/src/widget/dropdown/operation.rs

70 lines
1.8 KiB
Rust
Raw Normal View History

// Copyright 2025 System76 <info@system76.com>
// SPDX-License-Identifier: MPL-2.0 AND MIT
//! Operate on dropdown widgets.
pub trait Dropdown {
fn close(&mut self);
fn open(&mut self);
}
2026-02-10 15:37:41 -05:00
// /// Produces a [`Task`] that closes a [`Dropdown`] popup.
// pub fn close<T>(id: Id) -> impl Operation<T> {
// struct Close(Id);
2026-02-10 15:37:41 -05:00
// impl<T> Operation<T> for Close {
// fn custom(&mut self, state: &mut dyn std::any::Any, id: Option<&Id>) {
// if id.map_or(true, |id| id != &self.0) {
// return;
// }
2026-02-10 15:37:41 -05:00
// let Some(state) = state.downcast_mut::<State>() else {
// return;
// };
2026-02-10 15:37:41 -05:00
// state.close();
// }
2026-02-10 15:37:41 -05:00
// fn container(
// &mut self,
// _id: Option<&Id>,
// _bounds: Rectangle,
// operate_on_children: &mut dyn FnMut(&mut dyn Operation<T>),
// ) {
// operate_on_children(self)
// }
// }
2026-02-10 15:37:41 -05:00
// Close(id)
// }
2026-02-10 15:37:41 -05:00
// /// Produces a [`Task`] that opens a [`Dropdown`] popup.
// pub fn open<T>(id: Id) -> impl Operation<T> {
// struct Open(Id);
2026-02-10 15:37:41 -05:00
// impl<T> Operation<T> for Open {
// fn custom(&mut self, state: &mut dyn std::any::Any, id: Option<&Id>) {
// if id.map_or(true, |id| id != &self.0) {
// return;
// }
2026-02-10 15:37:41 -05:00
// let Some(state) = state.downcast_mut::<State>() else {
// return;
// };
2026-02-10 15:37:41 -05:00
// state.open();
// }
2026-02-10 15:37:41 -05:00
// fn container(
// &mut self,
// _id: Option<&Id>,
// _bounds: Rectangle,
// operate_on_children: &mut dyn FnMut(&mut dyn Operation<T>),
// ) {
// operate_on_children(self)
// }
// }
2026-02-10 15:37:41 -05:00
// Open(id)
// }