1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 21:30:03 -04:00

Refactor: pass Rect:s by value (cleaner)

This commit is contained in:
Emil Ernerfeldt
2020-05-05 19:12:00 +02:00
parent 9d1cf77aa7
commit 6aadf4128e
13 changed files with 39 additions and 39 deletions

View File

@@ -138,7 +138,7 @@ fn paint_icon(region: &mut Region, state: &State, interact: &InteractInfo) {
let stroke_color = region.style().interact_stroke_color(&interact);
let stroke_width = region.style().interact_stroke_width(&interact);
let (mut small_icon_rect, _) = region.style().icon_rectangles(&interact.rect);
let (mut small_icon_rect, _) = region.style().icon_rectangles(interact.rect);
small_icon_rect.set_center(pos2(
interact.rect.left() + region.style().indent / 2.0,
interact.rect.center().y,

View File

@@ -78,7 +78,7 @@ impl Floating {
let rect = Rect::from_min_size(state.pos, state.size);
let clip_rect = Rect::everything();
let move_interact = ctx.interact(layer, &clip_rect, &rect, Some(id.with("move")));
let move_interact = ctx.interact(layer, clip_rect, rect, Some(id.with("move")));
let input = ctx.input();
if move_interact.active {

View File

@@ -160,7 +160,7 @@ impl Resize {
position + state.size + self.handle_offset - corner_size,
corner_size,
);
let corner_interact = region.interact_rect(&corner_rect, id.with("corner"));
let corner_interact = region.interact_rect(corner_rect, id.with("corner"));
if corner_interact.active {
if let Some(mouse_pos) = region.input().mouse_pos {
@@ -181,7 +181,7 @@ impl Resize {
let desired_size = {
let mut content_clip_rect = region
.clip_rect()
.intersect(&inner_rect.expand(region.style().clip_rect_margin));
.intersect(inner_rect.expand(region.style().clip_rect_margin));
// If we pull the resize handle to shrink, we want to TRY to shink it.
// After laying out the contents, we might be much bigger.

View File

@@ -80,7 +80,7 @@ impl ScrollArea {
outer_region.cursor() - state.offset,
vec2(inner_size.x, f32::INFINITY),
));
let mut content_clip_rect = outer_region.clip_rect().intersect(&inner_rect);
let mut content_clip_rect = outer_region.clip_rect().intersect(inner_rect);
content_clip_rect.max.x = outer_region.clip_rect().max.x - current_scroll_bar_width; // Nice handling of forced resizing beyond the possible
content_region.set_clip_rect(content_clip_rect);
@@ -100,14 +100,14 @@ impl ScrollArea {
inner_rect.size() + vec2(current_scroll_bar_width, 0.0),
);
let content_interact = outer_region.interact_rect(&inner_rect, scroll_area_id.with("area"));
let content_interact = outer_region.interact_rect(inner_rect, scroll_area_id.with("area"));
if content_interact.active {
// Dragging scroll area to scroll:
state.offset.y -= ctx.input().mouse_move.y;
}
// TODO: check that nothing else is being inteacted with
if outer_region.contains_mouse(&outer_rect) && ctx.memory().active_id.is_none() {
if outer_region.contains_mouse(outer_rect) && ctx.memory().active_id.is_none() {
state.offset.y -= ctx.input().scroll_delta.y;
}
@@ -134,7 +134,7 @@ impl ScrollArea {
// intentionally use same id for inside and outside of handle
let interact_id = scroll_area_id.with("vertical");
let handle_interact = outer_region.interact_rect(&handle_rect, interact_id);
let handle_interact = outer_region.interact_rect(handle_rect, interact_id);
if let Some(mouse_pos) = ctx.input().mouse_pos {
if handle_interact.active {
@@ -145,7 +145,7 @@ impl ScrollArea {
} else {
// Check for mouse down outside handle:
let scroll_bg_interact =
outer_region.interact_rect(&outer_scroll_rect, interact_id);
outer_region.interact_rect(outer_scroll_rect, interact_id);
if scroll_bg_interact.active {
// Center scroll at mouse pos: