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

Constrain Areas to screen by default #4591

Merged
merged 1 commit into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion crates/egui/src/containers/area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl Area {
sense: None,
movable: true,
interactable: true,
constrain: false,
constrain: true,
constrain_rect: None,
enabled: true,
order: Order::Middle,
Expand Down Expand Up @@ -229,6 +229,8 @@ impl Area {
}

/// Constrains this area to [`Context::screen_rect`]?
///
/// Default: `true`.
#[inline]
pub fn constrain(mut self, constrain: bool) -> Self {
self.constrain = constrain;
Expand Down
2 changes: 0 additions & 2 deletions crates/egui/src/containers/popup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ fn show_tooltip_at_avoid_dyn<'c, R>(
.pivot(pivot)
.fixed_pos(anchor)
.default_width(ctx.style().spacing.tooltip_width)
.constrain_to(screen_rect)
.interactable(false)
.show(ctx, |ui| {
Frame::popup(&ctx.style()).show_dyn(ui, add_contents).inner
Expand Down Expand Up @@ -288,7 +287,6 @@ pub fn popup_above_or_below_widget<R>(

let inner = Area::new(popup_id)
.order(Order::Foreground)
.constrain(true)
.fixed_pos(pos)
.default_width(inner_width)
.pivot(pivot)
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/containers/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl<'open> Window<'open> {
/// If you need a changing title, you must call `window.id(…)` with a fixed id.
pub fn new(title: impl Into<WidgetText>) -> Self {
let title = title.into().fallback_text_style(TextStyle::Heading);
let area = Area::new(Id::new(title.text())).constrain(true);
let area = Area::new(Id::new(title.text()));
Self {
title,
open: None,
Expand Down
1 change: 0 additions & 1 deletion crates/egui/src/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ fn menu_popup<'c, R>(
let area = Area::new(menu_id.with("__menu"))
.order(Order::Foreground)
.fixed_pos(pos)
.constrain_to(ctx.screen_rect())
.interactable(true)
.default_width(ctx.style().spacing.menu_width)
.sense(Sense::hover());
Expand Down
1 change: 0 additions & 1 deletion crates/egui/src/widgets/color_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,6 @@ pub fn color_edit_button_hsva(ui: &mut Ui, hsva: &mut Hsva, alpha: Alpha) -> Res
let area_response = Area::new(popup_id)
.order(Order::Foreground)
.fixed_pos(button_response.rect.max)
.constrain(true)
.show(ui.ctx(), |ui| {
ui.spacing_mut().slider_width = COLOR_SLIDER_WIDTH;
Frame::popup(ui.style()).show(ui, |ui| {
Expand Down
1 change: 0 additions & 1 deletion crates/egui_extras/src/datepicker/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ impl<'a> Widget for DatePickerButton<'a> {
} = Area::new(ui.make_persistent_id(self.id_source))
.order(Order::Foreground)
.fixed_pos(pos)
.constrain_to(ui.ctx().screen_rect())
.show(ui.ctx(), |ui| {
let frame = Frame::popup(ui.style());
frame
Expand Down
Loading