Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coexist with other controls in a window? #27

Open
dbalsom opened this issue Jun 20, 2024 · 4 comments
Open

coexist with other controls in a window? #27

dbalsom opened this issue Jun 20, 2024 · 4 comments

Comments

@dbalsom
Copy link

dbalsom commented Jun 20, 2024

I wanted to use a textedit as a cli entry line, rather than deal with keyboard events and sending them to the terminal.

However the way egui_ratatui calculates the available size is based off the entire window ui; so if you add any additional controls to the window, then egui_ratatui continually resizes itself larger until it hits the edges of the screen.

@gold-silver-copper
Copy link
Owner

gold-silver-copper commented Jun 20, 2024

The way I work around this is by creating a container window that then contains 2 contexts, one for ratatui, another for the controls.

something like

    egui::CentralPanel::default()
  
        .show(contexts.ctx_mut(), |ui| {
            let av_height = ui.available_height().clamp(100., 1500.);
            let av_width = ui.available_width().clamp(100., 1500.);

            egui::SidePanel::right("container")
                .min_width(av_width)
                .max_width(av_width)
           
                .show_inside(ui, |ui| {

                    egui::TopBottomPanel::top("terminal_1")
                            .min_height(200.)
                            .max_height(200.)
                         
                            .show_inside(ui, |ui| {
                                ui.add(ratatui_terminal_1.backend_mut());
                            });
                    

                    egui::TopBottomPanel::bottom("terminal_2")
                        .min_height(ui.available_height())
                        .max_height(ui.available_height())
                
                        .show_inside(ui, |ui| {
                            ui.add(ratatui_terminal_2.backend_mut());
                        });
                });

        
        });


@gold-silver-copper
Copy link
Owner

Please let me know if it works, thank you. If you need further help, I would appreciate if you shared some sample code so I could help you better.

@dbalsom
Copy link
Author

dbalsom commented Jun 20, 2024

thanks, i'll try that out - by the way, your discord invite links are expired!

@gold-silver-copper
Copy link
Owner

thanks, i'll try that out - by the way, your discord invite links are expired!

oops, heres a new one https://discord.gg/tDBPkdgApN

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants