Skip to content

Create all Ui:s from a parent Ui #3524

@emilk

Description

@emilk

Summary

I would like each egui viewport (read: native window) to have a single root Ui that covers the entire available space.
The user can then add egui::Windows to this Ui, as well as sub-divide it using panels.
The root Ui would have no background color, and no margin.
To get that, the user can use a Frame.

Benefits

The Context::create_viewport* functions coming in #3172 would likewise return a Ui.
If possible, these Uis will fill a new native window, and otherwise they will instead fill an egui::Window floating on top of the parent viewport. This makes their interfacer a lot simpler. Basically ctx.create_viewport(…, |ui| ui.label("Hello World")); would show the new ui either in a separate native window (if the backend supports it), or fall back to a egui::Window if not.

We can also simplify panels.
CentralPanel can be removed (replaced by Frame) and the show/show_inside dichotomy would disappear.

Area and Window should float on top of the entire viewport by default, and a user should be able to create them at any time.

Current behavior

There are currently a few different ways to create a Ui from a Context:

  • Panels (CentralPanel, SidePanel, TopBottomPanel)
  • Area an Window
  • Ui::new

For instance, SidePanel::left(…).show(ctx, |ui| { … }).
The panels also have special show_inside functions to use them inside another Ui: SidePanel::left(…).show_inside(ui, |ui| { … }).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions