mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 06:10:06 -04:00
Implement BitOr and BitOrAssign for Rect (#7319)
This commit is contained in:
@@ -705,7 +705,7 @@ fn automatic_area_position(ctx: &Context, layer_id: LayerId) -> Pos2 {
|
||||
let current_column_bb = column_bbs.last_mut().unwrap();
|
||||
if rect.left() < current_column_bb.right() {
|
||||
// same column
|
||||
*current_column_bb = current_column_bb.union(rect);
|
||||
*current_column_bb |= rect;
|
||||
} else {
|
||||
// new column
|
||||
column_bbs.push(rect);
|
||||
|
||||
@@ -185,7 +185,7 @@ impl Sides {
|
||||
wrap_mode,
|
||||
);
|
||||
|
||||
ui.advance_cursor_after_rect(left_rect.union(right_rect));
|
||||
ui.advance_cursor_after_rect(left_rect | right_rect);
|
||||
(result_left, result_right)
|
||||
}
|
||||
SidesKind::ShrinkRight => {
|
||||
@@ -205,7 +205,7 @@ impl Sides {
|
||||
wrap_mode,
|
||||
);
|
||||
|
||||
ui.advance_cursor_after_rect(left_rect.union(right_rect));
|
||||
ui.advance_cursor_after_rect(left_rect | right_rect);
|
||||
(result_left, result_right)
|
||||
}
|
||||
SidesKind::Extend => {
|
||||
@@ -225,7 +225,7 @@ impl Sides {
|
||||
None,
|
||||
);
|
||||
|
||||
let mut final_rect = left_rect.union(right_rect);
|
||||
let mut final_rect = left_rect | right_rect;
|
||||
let min_width = left_rect.width() + spacing + right_rect.width();
|
||||
|
||||
if ui.is_sizing_pass() {
|
||||
|
||||
@@ -163,7 +163,7 @@ impl Tooltip<'_> {
|
||||
// The popup might not be shown on at_pointer if there is no pointer.
|
||||
if let Some(response) = &response {
|
||||
state.tooltip_count += 1;
|
||||
state.bounding_rect = state.bounding_rect.union(response.response.rect);
|
||||
state.bounding_rect |= response.response.rect;
|
||||
response
|
||||
.response
|
||||
.ctx
|
||||
|
||||
@@ -2689,7 +2689,7 @@ impl Context {
|
||||
self.write(|ctx| {
|
||||
let mut used = ctx.viewport().this_pass.used_by_panels;
|
||||
for (_id, window) in ctx.memory.areas().visible_windows() {
|
||||
used = used.union(window.rect());
|
||||
used |= window.rect();
|
||||
}
|
||||
used.round_ui()
|
||||
})
|
||||
|
||||
@@ -102,7 +102,7 @@ impl State {
|
||||
let location_rect =
|
||||
Align2::RIGHT_TOP.anchor_size(pos - 4.0 * Vec2::X, location_galley.size());
|
||||
painter.galley(location_rect.min, location_galley, color);
|
||||
bounding_rect = bounding_rect.union(location_rect);
|
||||
bounding_rect |= location_rect;
|
||||
}
|
||||
|
||||
{
|
||||
@@ -117,7 +117,7 @@ impl State {
|
||||
);
|
||||
let rect = Align2::LEFT_TOP.anchor_size(pos, galley.size());
|
||||
painter.galley(rect.min, galley, color);
|
||||
bounding_rect = bounding_rect.union(rect);
|
||||
bounding_rect |= rect;
|
||||
}
|
||||
|
||||
pos.y = bounding_rect.max.y + 4.0;
|
||||
|
||||
@@ -50,8 +50,8 @@ pub(crate) struct Region {
|
||||
impl Region {
|
||||
/// Expand the `min_rect` and `max_rect` of this ui to include a child at the given rect.
|
||||
pub fn expand_to_include_rect(&mut self, rect: Rect) {
|
||||
self.min_rect = self.min_rect.union(rect);
|
||||
self.max_rect = self.max_rect.union(rect);
|
||||
self.min_rect |= rect;
|
||||
self.max_rect |= rect;
|
||||
}
|
||||
|
||||
/// Ensure we are big enough to contain the given X-coordinate.
|
||||
@@ -725,7 +725,7 @@ impl Layout {
|
||||
if self.main_wrap {
|
||||
if cursor.intersects(frame_rect.shrink(1.0)) {
|
||||
// make row/column larger if necessary
|
||||
*cursor = cursor.union(frame_rect);
|
||||
*cursor |= frame_rect;
|
||||
} else {
|
||||
// this is a new row or column. We temporarily use NAN for what will be filled in later.
|
||||
match self.main_dir {
|
||||
|
||||
@@ -318,7 +318,7 @@ impl PassState {
|
||||
);
|
||||
self.available_rect.min.x = panel_rect.max.x;
|
||||
self.unused_rect.min.x = panel_rect.max.x;
|
||||
self.used_by_panels = self.used_by_panels.union(panel_rect);
|
||||
self.used_by_panels |= panel_rect;
|
||||
}
|
||||
|
||||
/// Shrink `available_rect`.
|
||||
@@ -329,7 +329,7 @@ impl PassState {
|
||||
);
|
||||
self.available_rect.max.x = panel_rect.min.x;
|
||||
self.unused_rect.max.x = panel_rect.min.x;
|
||||
self.used_by_panels = self.used_by_panels.union(panel_rect);
|
||||
self.used_by_panels |= panel_rect;
|
||||
}
|
||||
|
||||
/// Shrink `available_rect`.
|
||||
@@ -340,7 +340,7 @@ impl PassState {
|
||||
);
|
||||
self.available_rect.min.y = panel_rect.max.y;
|
||||
self.unused_rect.min.y = panel_rect.max.y;
|
||||
self.used_by_panels = self.used_by_panels.union(panel_rect);
|
||||
self.used_by_panels |= panel_rect;
|
||||
}
|
||||
|
||||
/// Shrink `available_rect`.
|
||||
@@ -351,13 +351,13 @@ impl PassState {
|
||||
);
|
||||
self.available_rect.max.y = panel_rect.min.y;
|
||||
self.unused_rect.max.y = panel_rect.min.y;
|
||||
self.used_by_panels = self.used_by_panels.union(panel_rect);
|
||||
self.used_by_panels |= panel_rect;
|
||||
}
|
||||
|
||||
pub(crate) fn allocate_central_panel(&mut self, panel_rect: Rect) {
|
||||
// Note: we do not shrink `available_rect`, because
|
||||
// we allow windows to cover the CentralPanel.
|
||||
self.unused_rect = Rect::NOTHING; // Nothing left unused after this
|
||||
self.used_by_panels = self.used_by_panels.union(panel_rect);
|
||||
self.used_by_panels |= panel_rect;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ impl Placer {
|
||||
let region = &mut self.region;
|
||||
region.max_rect.min.x = rect.min.x;
|
||||
region.max_rect.max.x = rect.max.x;
|
||||
region.max_rect = region.max_rect.union(region.min_rect); // make sure we didn't shrink too much
|
||||
region.max_rect |= region.min_rect; // make sure we didn't shrink too much
|
||||
|
||||
region.cursor.min.x = region.max_rect.min.x;
|
||||
region.cursor.max.x = region.max_rect.max.x;
|
||||
@@ -246,7 +246,7 @@ impl Placer {
|
||||
let region = &mut self.region;
|
||||
region.max_rect.min.y = rect.min.y;
|
||||
region.max_rect.max.y = rect.max.y;
|
||||
region.max_rect = region.max_rect.union(region.min_rect); // make sure we didn't shrink too much
|
||||
region.max_rect |= region.min_rect; // make sure we didn't shrink too much
|
||||
|
||||
region.cursor.min.y = region.max_rect.min.y;
|
||||
region.cursor.max.y = region.max_rect.max.y;
|
||||
|
||||
@@ -546,7 +546,7 @@ impl LabelSelectionState {
|
||||
|
||||
if let Some(mut cursor_range) = cursor_state.range(galley) {
|
||||
let galley_rect = global_from_galley * Rect::from_min_size(Pos2::ZERO, galley.size());
|
||||
self.selection_bbox_this_frame = self.selection_bbox_this_frame.union(galley_rect);
|
||||
self.selection_bbox_this_frame |= galley_rect;
|
||||
|
||||
if let Some(selection) = &self.selection {
|
||||
if selection.primary.widget_id == response.id {
|
||||
|
||||
@@ -165,7 +165,7 @@ impl Label {
|
||||
};
|
||||
select_sense -= Sense::FOCUSABLE; // Don't move focus to labels with TAB key.
|
||||
|
||||
sense = sense.union(select_sense);
|
||||
sense |= select_sense;
|
||||
}
|
||||
|
||||
if let WidgetText::Galley(galley) = self.text {
|
||||
|
||||
Reference in New Issue
Block a user