Skip to content

Commit fde50b5

Browse files
committed
Area: automatically request a repaint when showing up for the first time
1 parent 78dfde4 commit fde50b5

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

egui/src/containers/area.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,13 @@ impl Area {
204204

205205
let state = ctx.memory().areas.get(id).cloned();
206206
let is_new = state.is_none();
207-
let mut state = state.unwrap_or_else(|| State {
208-
pos: default_pos.unwrap_or_else(|| automatic_area_position(ctx)),
209-
size: Vec2::ZERO,
210-
interactable,
207+
let mut state = state.unwrap_or_else(|| {
208+
ctx.request_repaint(); // if we don't know the previous size we are likely drawing the area in the wrong place
209+
State {
210+
pos: default_pos.unwrap_or_else(|| automatic_area_position(ctx)),
211+
size: Vec2::ZERO,
212+
interactable,
213+
}
211214
});
212215
state.pos = new_pos.unwrap_or(state.pos);
213216

0 commit comments

Comments
 (0)