pub fn pick_color(start: RGB) -> Option<RGB> {
    let rvalue: Rc<Cell<RGB>> = Rc::new(Cell::new(start));

    let mut w = DoubleWindow::default()
        .with_label("Specify a Color")
        .with_size(PICKER_WINDOW_WIDTH, PICKER_WINDOW_HEIGHT);

    let mut prev = DoubleWindow::default()
        .with_size(PICKER_OUTPUT_WIDTH, PICKER_WINDOW_HEIGHT)
        .with_pos(PICKER_ROW_WIDTH, 0);
    prev.end();
    prev.set_color(rgb_to_fltk(start));

    let (_, _, _) = make_picker_row(0, "R", start.r() as f64, prev.clone(), rvalue.clone());
    let (_, _, _) = make_picker_row(
        PICKER_ROW_HEIGHT,
        "G",
        start.g() as f64,
        prev.clone(),
        rvalue.clone(),
    );
    let (_, _, _) = make_picker_row(
        2 * PICKER_ROW_HEIGHT,
        "B",
        start.b() as f64,
        prev.clone(),
        rvalue.clone(),
    );

    let mut ok = Button::default()
        .with_label("Set @returnarrow")
        .with_size(PICKER_BUTTON_WIDTH, PICKER_ROW_HEIGHT)
        .with_pos(0, 3 * PICKER_ROW_HEIGHT);
    ok.set_shortcut(Shortcut::from_key(Key::Enter));
    let mut no = Button::default()
        .with_label("Cancel (Esc)")
        .with_size(PICKER_BUTTON_WIDTH, PICKER_ROW_HEIGHT)
        .with_pos(PICKER_BUTTON_WIDTH, 3 * PICKER_ROW_HEIGHT);
    no.set_shortcut(Shortcut::from_key(Key::Escape));

    w.end();
    w.make_modal(true);
    w.show();

    let (tx, rx) = mpsc::channel::<Option<RGB>>();

    ok.set_callback({
        let tx = tx.clone();
        move |_| {
            tx.send(Some(rvalue.get())).unwrap();
        }
    });
    no.set_callback({
        move |_| {
            tx.send(None).unwrap();
        }
    });

    while match rx.try_recv() {
        Err(_) => true,
        Ok(c) => {
            DoubleWindow::delete(w);
            return c;
        }
    } {
        fltk::app::wait();
    }
    None
}
/**
Pops up a modal window for selecting a color.
*/
Pops up a modal window for selecting a color.
Pops up a modal window for selecting a color .
pub fn pick_color(start: RGB) -> Option<RGB> {
    let rvalue: Rc<Cell<RGB>> = Rc::new(Cell::new(start));
    let mut w = DoubleWindow::default()
        .with_label("Specify a Color")
        .with_size(PICKER_WINDOW_WIDTH, PICKER_WINDOW_HEIGHT);
    let mut prev = DoubleWindow::default()
        .with_size(PICKER_OUTPUT_WIDTH, PICKER_WINDOW_HEIGHT)
        .with_pos(PICKER_ROW_WIDTH, 0);
    prev.end();
    prev.set_color(rgb_to_fltk(start));
    let (_, _, _) = make_picker_row(0, "R", start.r() as f64, prev.clone(), rvalue.clone());
    let (_, _, _) = make_picker_row(
        PICKER_ROW_HEIGHT,
        "G",
        start.g() as f64,
        prev.clone(),
        rvalue.clone(),
    );
    let (_, _, _) = make_picker_row(
        2 * PICKER_ROW_HEIGHT,
        "B",
        start.b() as f64,
        prev.clone(),
        rvalue.clone(),
    );
    let mut ok = Button::default()
        .with_label("Set @returnarrow")
        .with_size(PICKER_BUTTON_WIDTH, PICKER_ROW_HEIGHT)
        .with_pos(0, 3 * PICKER_ROW_HEIGHT);
    ok.set_shortcut(Shortcut::from_key(Key::Enter));
    let mut no = Button::default()
        .with_label("Cancel (Esc)")
        .with_size(PICKER_BUTTON_WIDTH, PICKER_ROW_HEIGHT)
        .with_pos(PICKER_BUTTON_WIDTH, 3 * PICKER_ROW_HEIGHT);
    no.set_shortcut(Shortcut::from_key(Key::Escape));
    w.end();
    w.make_modal(true);
    w.show();
    let (tx, rx) = mpsc::channel::<Option<RGB>>();
    ok.set_callback({
        let tx = tx.clone();
        move |_| {
            tx.send(Some(rvalue.get())).unwrap();
        }
    });
    no.set_callback({
        move |_| {
            tx.send(None).unwrap();
        }
    });
    while match rx.try_recv() {
        Err(_) => true,
        Ok(c) => {
            DoubleWindow::delete(w);
            return c;
        }
    } {
        fltk::app::wait();
    }
    None
}
pub fn pick_color ( start : RGB ) -> Option < RGB > { let rvalue : Rc < Cell < RGB > > = Rc :: new ( Cell :: new ( start ) ) ; let mut w = DoubleWindow :: default ( ) . with_label ( " " ) . with_size ( PICKER_WINDOW_WIDTH , PICKER_WINDOW_HEIGHT ) ; let mut prev = DoubleWindow :: default ( ) . with_size ( PICKER_OUTPUT_WIDTH , PICKER_WINDOW_HEIGHT ) . with_pos ( PICKER_ROW_WIDTH , 0 ) ; prev . end ( ) ; prev . set_color ( rgb_to_fltk ( start ) ) ; let ( _ , _ , _ ) = make_picker_row ( 0 , " " , start . r ( ) as f64 , prev . clone ( ) , rvalue . clone ( ) ) ; let ( _ , _ , _ ) = make_picker_row ( PICKER_ROW_HEIGHT , " " , start . g ( ) as f64 , prev . clone ( ) , rvalue . clone ( ) , ) ; let ( _ , _ , _ ) = make_picker_row ( 2 * PICKER_ROW_HEIGHT , " " , start . b ( ) as f64 , prev . clone ( ) , rvalue . clone ( ) , ) ; let mut ok = Button :: default ( ) . with_label ( " " ) . with_size ( PICKER_BUTTON_WIDTH , PICKER_ROW_HEIGHT ) . with_pos ( 0 , 3 * PICKER_ROW_HEIGHT ) ; ok . set_shortcut ( Shortcut :: from_key ( Key :: Enter ) ) ; let mut no = Button :: default ( ) . with_label ( " " ) . with_size ( PICKER_BUTTON_WIDTH , PICKER_ROW_HEIGHT ) . with_pos ( PICKER_BUTTON_WIDTH , 3 * PICKER_ROW_HEIGHT ) ; no . set_shortcut ( Shortcut :: from_key ( Key :: Escape ) ) ; w . end ( ) ; w . make_modal ( true ) ; w . show ( ) ; let ( tx , rx ) = mpsc :: channel :: < Option < RGB > > ( ) ; ok . set_callback ( { let tx = tx . clone ( ) ; move | _ | { tx . send ( Some ( rvalue . get ( ) ) ) . unwrap ( ) ; } } ) ; no . set_callback ( { move | _ | { tx . send ( None ) . unwrap ( ) ; } } ) ; while match rx . try_recv ( ) { Err ( _ ) => true , Ok ( c ) => { DoubleWindow :: delete ( w ) ; return c ; } } { fltk :: app :: wait ( ) ; } None }
Pops up a modal window for selecting a color.
Pops up a modal window for selecting a color .
start
RGB
start
RGB