mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 04:40:03 -04:00
Remove clip_rect_margin (#8366)
* Closes https://github.com/emilk/egui/issues/5605 It has been zero by default for a few months now, and I do not wish to support it. It was always an ugly hack, and it is no longer needed.
This commit is contained in:
@@ -289,16 +289,16 @@ impl Resize {
|
||||
Rect::from_min_size(position, state.desired_size)
|
||||
};
|
||||
|
||||
let mut content_clip_rect = inner_rect.expand(ui.visuals().clip_rect_margin);
|
||||
let mut content_clip_rect = inner_rect;
|
||||
|
||||
// If we pull the resize handle to shrink, we want to TRY to shrink it.
|
||||
// After laying out the contents, we might be much bigger.
|
||||
// In those cases we don't want the clip_rect to be smaller, because
|
||||
// then we will clip the contents of the region even thought the result gets larger. This is simply ugly!
|
||||
// So we use the memory of last_content_size to make the clip rect large enough.
|
||||
content_clip_rect.max = content_clip_rect.max.max(
|
||||
inner_rect.min + state.last_content_size + Vec2::splat(ui.visuals().clip_rect_margin),
|
||||
);
|
||||
content_clip_rect.max = content_clip_rect
|
||||
.max
|
||||
.max(inner_rect.min + state.last_content_size);
|
||||
|
||||
content_clip_rect = content_clip_rect.intersect(ui.clip_rect()); // Respect parent region
|
||||
|
||||
|
||||
@@ -810,12 +810,11 @@ impl ScrollArea {
|
||||
|
||||
{
|
||||
// Clip the content, but only when we really need to:
|
||||
let clip_rect_margin = ui.visuals().clip_rect_margin;
|
||||
let mut content_clip_rect = ui.clip_rect();
|
||||
for d in 0..2 {
|
||||
if direction_enabled[d] {
|
||||
content_clip_rect.min[d] = inner_rect.min[d] - clip_rect_margin;
|
||||
content_clip_rect.max[d] = inner_rect.max[d] + clip_rect_margin;
|
||||
content_clip_rect.min[d] = inner_rect.min[d];
|
||||
content_clip_rect.max[d] = inner_rect.max[d];
|
||||
} else {
|
||||
// Nice handling of forced resizing beyond the possible:
|
||||
content_clip_rect.max[d] = ui.clip_rect().max[d] - current_bar_use[d];
|
||||
@@ -1306,8 +1305,6 @@ impl Prepared {
|
||||
// * When one ScrollArea is nested inside another, and the outer
|
||||
// is scrolled so that the scroll-bars of the inner ScrollArea (us)
|
||||
// is outside the clip rectangle.
|
||||
// Really this should use the tighter clip_rect that ignores clip_rect_margin, but we don't store that.
|
||||
// clip_rect_margin is quite a hack. It would be nice to get rid of it.
|
||||
max_cross = ui.clip_rect().max[1 - d] - outer_margin;
|
||||
}
|
||||
|
||||
@@ -1575,9 +1572,7 @@ fn paint_fade_areas_impl(ui: &Ui, inner_rect: Rect, content_size: Vec2, offset:
|
||||
|
||||
let overflow = content_size - inner_rect.size();
|
||||
|
||||
let paint_rect = inner_rect
|
||||
.intersect(ui.min_rect())
|
||||
.expand(ui.visuals().clip_rect_margin);
|
||||
let paint_rect = inner_rect.intersect(ui.min_rect());
|
||||
|
||||
// Top fade: animate opacity based on how far we've scrolled down.
|
||||
if 0.0 < offset.y {
|
||||
|
||||
@@ -1074,12 +1074,6 @@ pub struct Visuals {
|
||||
/// How the text cursor acts.
|
||||
pub text_cursor: TextCursorStyle,
|
||||
|
||||
/// Allow widgets to paint this much outside the scroll area rect.
|
||||
///
|
||||
/// Legacy. Should not be used anymore.
|
||||
/// Use [`crate::ScrollArea::content_margin`] instead.
|
||||
pub clip_rect_margin: f32,
|
||||
|
||||
/// Show a background behind buttons.
|
||||
pub button_frame: bool,
|
||||
|
||||
@@ -1534,7 +1528,6 @@ impl Visuals {
|
||||
|
||||
text_cursor: Default::default(),
|
||||
|
||||
clip_rect_margin: 0.0,
|
||||
button_frame: true,
|
||||
collapsing_header_frame: false,
|
||||
indent_has_left_vline: true,
|
||||
@@ -2297,7 +2290,6 @@ impl Visuals {
|
||||
|
||||
text_cursor,
|
||||
|
||||
clip_rect_margin,
|
||||
button_frame,
|
||||
collapsing_header_frame,
|
||||
indent_has_left_vline,
|
||||
@@ -2484,8 +2476,6 @@ impl Visuals {
|
||||
|
||||
ui.collapsing("Misc", |ui| {
|
||||
ui.add(Slider::new(resize_corner_size, 0.0..=20.0).text("resize_corner_size"));
|
||||
ui.add(Slider::new(clip_rect_margin, 0.0..=20.0).text("clip_rect_margin"));
|
||||
|
||||
ui.checkbox(button_frame, "Button has a frame");
|
||||
ui.checkbox(collapsing_header_frame, "Collapsing header has a frame");
|
||||
ui.checkbox(
|
||||
|
||||
@@ -340,10 +340,8 @@ impl crate::View for ScrollTo {
|
||||
ui.scroll_to_cursor(Some(Align::BOTTOM));
|
||||
}
|
||||
|
||||
let margin = ui.visuals().clip_rect_margin;
|
||||
|
||||
let current_scroll = ui.clip_rect().top() - ui.min_rect().top() + margin;
|
||||
let max_scroll = ui.min_rect().height() - ui.clip_rect().height() + 2.0 * margin;
|
||||
let current_scroll = ui.clip_rect().top() - ui.min_rect().top();
|
||||
let max_scroll = ui.min_rect().height() - ui.clip_rect().height();
|
||||
(current_scroll, max_scroll)
|
||||
})
|
||||
.inner;
|
||||
|
||||
@@ -217,10 +217,7 @@ impl<'l> StripLayout<'l> {
|
||||
let mut child_ui = self.ui.new_child(ui_builder);
|
||||
|
||||
if flags.clip {
|
||||
let margin = egui::Vec2::splat(self.ui.visuals().clip_rect_margin);
|
||||
let margin = margin.min(0.5 * self.ui.spacing().item_spacing);
|
||||
let clip_rect = max_rect.expand2(margin);
|
||||
child_ui.shrink_clip_rect(clip_rect);
|
||||
child_ui.shrink_clip_rect(max_rect);
|
||||
|
||||
if !child_ui.is_sizing_pass() {
|
||||
// Better to truncate (if we can), rather than hard clipping:
|
||||
|
||||
@@ -451,17 +451,13 @@ fn drop_target<R>(
|
||||
) -> egui::InnerResponse<R> {
|
||||
let is_being_dragged = ui.ctx().dragged_id().is_some();
|
||||
|
||||
let margin = egui::Vec2::splat(ui.visuals().clip_rect_margin); // 3.0
|
||||
|
||||
let background_id = ui.painter().add(egui::Shape::Noop);
|
||||
|
||||
let available_rect = ui.available_rect_before_wrap();
|
||||
let inner_rect = available_rect.shrink2(margin);
|
||||
let mut content_ui = ui.new_child(UiBuilder::new().max_rect(inner_rect));
|
||||
let mut content_ui = ui.new_child(UiBuilder::new().max_rect(available_rect));
|
||||
let ret = body(&mut content_ui);
|
||||
|
||||
let outer_rect =
|
||||
egui::Rect::from_min_max(available_rect.min, content_ui.min_rect().max + margin);
|
||||
let outer_rect = egui::Rect::from_min_max(available_rect.min, content_ui.min_rect().max);
|
||||
let (rect, response) = ui.allocate_at_least(outer_rect.size(), egui::Sense::hover());
|
||||
|
||||
let style = if is_being_dragged && response.hovered() {
|
||||
|
||||
Reference in New Issue
Block a user