imgui-rs icon indicating copy to clipboard operation
imgui-rs copied to clipboard

StyleColor::Header not working

Open coolit opened this issue 6 years ago • 1 comments

Not sure if I used it right. HeaderHovered was working, but Header was not.

use imgui::*;

mod support;

fn main() {
    let mut state = State::default();

    let system = support::init(file!());
    system.main_loop(|_, ui| {
        Window::new(im_str!("Hello world"))
            .position([0.0, 0.0], Condition::FirstUseEver)
            .size([300.0, 200.0], Condition::FirstUseEver)
            .build(ui, || {
                ChildWindow::new("child")
                    .size([200.0, 300.0])
                    .border(true)
                    .build(ui, || {
                        ui.text(im_str!("no_borders"));
                        ui.columns(2, im_str!("hi"), false);
                        ui.separator();
                        for v in &state.tab_depth {
                            let idx_color = [0.69412, 0.69412, 0.10588, 1.0];
                            let style_normal =
                                ui.push_style_color(StyleColor::HeaderHovered, idx_color); //Header if used, not working
                            if Selectable::new(&im_str!("Item01 {}", v[0]))
                                .span_all_columns(true)
                                .build(ui)
                            {
                                println!("01{:?}", v);
                                ui.open_popup(im_str!("popup_test"));
                            }
                            style_normal.pop(ui);
                            if ui.is_item_hovered() && ui.is_mouse_clicked(MouseButton::Right) {
                                println!("111");
                                ui.open_popup(im_str!("popup_test"));
                            }
                            ui.popup(im_str!("popup_test"), || {
                                ui.text(im_str!("Aquarium"));
                                ui.separator();
                                if ui.small_button(im_str!("test")) {
                                    println!("222")
                                }
                            });
                            ui.next_column();
                            if Selectable::new(&im_str!("Item02 {}", v[1]))
                                .span_all_columns(true)
                                .build(ui)
                            {
                                // println!("02{:?}", v)
                            }
                            ui.next_column();
                        }
                    });
            });
    });
}

struct State {
    tab_depth: Vec<Vec<String>>,
}

impl Default for State {
    fn default() -> Self {
        State {
            tab_depth: vec![
                vec!["w".to_owned(), "w".to_owned()],
                vec!["w".to_owned(), "w".to_owned()],
            ],
        }
    }
}

coolit avatar Oct 24 '19 12:10 coolit