Skip to content

Commit f26701e

Browse files
committed
Improve the layout of the panels and set maximum sizes
1 parent 1770567 commit f26701e

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

examples/example2d.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ fn edit_fruit_type(
387387
egui::Button::image(
388388
egui::Image::new(egui::load::SizedTexture {
389389
id: *texture_id,
390-
size: egui::Vec2::new(100.0, 100.0),
390+
size: egui::Vec2::new(25.0, 25.0),
391391
})
392392
.uv(*rect),
393393
)

src/editor_panels.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ impl EditorPanel for YoleckEditorLeftPanelSections {
108108
egui::SidePanel::left("yoleck_left_panel")
109109
.resizable(true)
110110
.default_width(300.0)
111+
.max_width(ctx.content_rect().width() / 4.0)
111112
.show(ctx, |ui| {
112113
ui.heading("Level Hierarchy");
113114
ui.separator();
@@ -145,6 +146,7 @@ impl EditorPanel for YoleckEditorRightPanelSections {
145146
egui::SidePanel::right("yoleck_right_panel")
146147
.resizable(true)
147148
.default_width(300.0)
149+
.max_width(ctx.content_rect().width() / 4.0)
148150
.show(ctx, |ui| {
149151
ui.heading("Properties");
150152
ui.separator();
@@ -246,6 +248,7 @@ impl EditorPanel for YoleckEditorBottomPanelSections {
246248
egui::TopBottomPanel::bottom("yoleck_bottom_panel")
247249
.resizable(true)
248250
.default_height(200.0)
251+
.max_height(ctx.content_rect().height() / 4.0)
249252
.show(ctx, |ui| {
250253
let inner_margin = 3.;
251254
ui.add_space(inner_margin);

src/editor_window.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ pub(crate) fn yoleck_editor_window(
2626

2727
let ctx = borrowed_egui.get_mut();
2828

29+
// The order of panels is important, because panels that go first will take height/width from
30+
// adjacent panels. The top panel must go first because it's height is very small (so it won't
31+
// be impacting the side panels much) and it needs all the width it can get. The bottom panel
32+
// can go last because giving the side panels more height for displaying their lists is more
33+
// important than giving extra width to the console.
34+
35+
let top = YoleckEditorTopPanelSections::show_panel(world, ctx)
36+
.rect
37+
.height();
38+
2939
let left = YoleckEditorLeftPanelSections::show_panel(world, ctx)
3040
.rect
3141
.width();
@@ -34,10 +44,6 @@ pub(crate) fn yoleck_editor_window(
3444
.rect
3545
.width();
3646

37-
let top = YoleckEditorTopPanelSections::show_panel(world, ctx)
38-
.rect
39-
.height();
40-
4147
let bottom = YoleckEditorBottomPanelSections::show_panel(world, ctx)
4248
.rect
4349
.height();

0 commit comments

Comments
 (0)