// Copyright 2025 System76 // SPDX-License-Identifier: MPL-2.0 AND MIT //! Operate on dropdown widgets. pub trait Dropdown { fn close(&mut self); fn open(&mut self); } // /// Produces a [`Task`] that closes a [`Dropdown`] popup. // pub fn close(id: Id) -> impl Operation { // struct Close(Id); // impl Operation 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; // } // let Some(state) = state.downcast_mut::() else { // return; // }; // state.close(); // } // fn container( // &mut self, // _id: Option<&Id>, // _bounds: Rectangle, // operate_on_children: &mut dyn FnMut(&mut dyn Operation), // ) { // operate_on_children(self) // } // } // Close(id) // } // /// Produces a [`Task`] that opens a [`Dropdown`] popup. // pub fn open(id: Id) -> impl Operation { // struct Open(Id); // impl Operation 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; // } // let Some(state) = state.downcast_mut::() else { // return; // }; // state.open(); // } // fn container( // &mut self, // _id: Option<&Id>, // _bounds: Rectangle, // operate_on_children: &mut dyn FnMut(&mut dyn Operation), // ) { // operate_on_children(self) // } // } // Open(id) // }