pub struct ColorPicker<'a> {
pub title: &'a str,
pub value: ColorValue,
pub owner: Option<&'a dyn HasWindowHandle>,
}Expand description
Color picker dialog.
The color picker dialog allows the user to select a color, which is returned as an RGB value. The dialog may also show a palette of predefined colors for the user to choose from.
Fields§
§title: &'a strThe title of the dialog.
value: ColorValueThe initial color value to show in the color picker dialog.
owner: Option<&'a dyn HasWindowHandle>The owner window of the dialog.
Implementations§
Source§impl<'a> ColorPicker<'a>
impl<'a> ColorPicker<'a>
Sourcepub fn show(&self) -> Option<ColorValue>
pub fn show(&self) -> Option<ColorValue>
Show the dialog.
Returns Some(ColorValue) if the user selected a color and confirmed the dialog, or None if the user cancelled the dialog.
Examples found in repository?
examples/color_picker.rs (line 12)
1fn main() {
2 let picker = rustydialogs::ColorPicker {
3 title: "Pick a color",
4 value: rustydialogs::ColorValue {
5 red: 0xFF,
6 green: 0x00,
7 blue: 0x77,
8 },
9 owner: None,
10 };
11
12 match picker.show() {
13 Some(color) => println!(
14 "Selected color: #{:02X}{:02X}{:02X}",
15 color.red, color.green, color.blue
16 ),
17 None => println!("Color selection canceled"),
18 }
19}Trait Implementations§
Source§impl<'a> Clone for ColorPicker<'a>
impl<'a> Clone for ColorPicker<'a>
Source§fn clone(&self) -> ColorPicker<'a>
fn clone(&self) -> ColorPicker<'a>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<'a> Copy for ColorPicker<'a>
Auto Trait Implementations§
impl<'a> Freeze for ColorPicker<'a>
impl<'a> !RefUnwindSafe for ColorPicker<'a>
impl<'a> !Send for ColorPicker<'a>
impl<'a> !Sync for ColorPicker<'a>
impl<'a> Unpin for ColorPicker<'a>
impl<'a> UnsafeUnpin for ColorPicker<'a>
impl<'a> !UnwindSafe for ColorPicker<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more