Search code examples
user-interfacerustegui

How do I make my own window frame in egui (eframe) Rust


Here is how I start my app and remove the window frame:

    let app = RustClicker::default();
    let mut native_options = eframe::NativeOptions::default();
    native_options.decorated = false; // I remove window frame here
    eframe::run_native(Box::new(app), native_options);

I made my own top-panel like this:

        egui::TopBottomPanel::top("decoration").show(ctx, |ui| {
            egui::menu::bar(ui, |ui| {
                ui.with_layout(egui::Layout::left_to_right(), |ui| {
                    ui.label("🖱");
                });

                ui.with_layout(egui::Layout::right_to_left(), |ui| {
                    if ui.button("🗙").clicked() {
                        frame.quit();
                    }
                    let change_theme = ui.button("🎨");
                    if change_theme.clicked() {
                        if self.dark_theme {
                            self.dark_theme = false;
                        }
                        else {
                            self.dark_theme = true;
                        }
                    }
                });
            });
        });

But I can't move it with holding moue button on, TopPanel is there anyway to fix this?


Solution

  • Found an example https://github.com/emilk/egui/tree/master/examples/custom_window_frame this works and the corners are also rounded