mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 21:30:03 -04:00
Made more Region members private
This commit is contained in:
@@ -39,7 +39,7 @@ impl CollapsingHeader {
|
||||
impl CollapsingHeader {
|
||||
pub fn show(self, region: &mut Region, add_contents: impl FnOnce(&mut Region)) -> GuiResponse {
|
||||
assert!(
|
||||
region.dir == Direction::Vertical,
|
||||
region.direction() == Direction::Vertical,
|
||||
"Horizontal collapsing is unimplemented"
|
||||
);
|
||||
let Self {
|
||||
@@ -55,27 +55,27 @@ impl CollapsingHeader {
|
||||
let interact = region.reserve_space(
|
||||
vec2(
|
||||
region.available_width(),
|
||||
text_size.y + 2.0 * region.style.button_padding.y,
|
||||
text_size.y + 2.0 * region.style().button_padding.y,
|
||||
),
|
||||
Some(id),
|
||||
);
|
||||
|
||||
let state = {
|
||||
let mut memory = region.ctx.memory();
|
||||
let mut memory = region.memory();
|
||||
let mut state = memory.collapsing_headers.entry(id).or_insert(State {
|
||||
open: default_open,
|
||||
..Default::default()
|
||||
});
|
||||
if interact.clicked {
|
||||
state.open = !state.open;
|
||||
state.toggle_time = region.ctx.input().time;
|
||||
state.toggle_time = region.input().time;
|
||||
}
|
||||
*state
|
||||
};
|
||||
|
||||
region.add_paint_cmd(PaintCmd::Rect {
|
||||
corner_radius: region.style.interact_corner_radius(&interact),
|
||||
fill_color: region.style.interact_fill_color(&interact),
|
||||
corner_radius: region.style().interact_corner_radius(&interact),
|
||||
fill_color: region.style().interact_fill_color(&interact),
|
||||
outline: region.style().interact_outline(&interact),
|
||||
rect: interact.rect,
|
||||
});
|
||||
@@ -84,16 +84,16 @@ impl CollapsingHeader {
|
||||
|
||||
region.add_text(
|
||||
pos2(
|
||||
interact.rect.left() + region.style.indent,
|
||||
interact.rect.left() + region.style().indent,
|
||||
interact.rect.center().y - text_size.y / 2.0,
|
||||
),
|
||||
text_style,
|
||||
title,
|
||||
Some(region.style.interact_stroke_color(&interact)),
|
||||
Some(region.style().interact_stroke_color(&interact)),
|
||||
);
|
||||
|
||||
let animation_time = region.style().animation_time;
|
||||
let time_since_toggle = (region.ctx.input().time - state.toggle_time) as f32;
|
||||
let time_since_toggle = (region.input().time - state.toggle_time) as f32;
|
||||
let animate = time_since_toggle < animation_time;
|
||||
if animate {
|
||||
region.indent(id, |region| {
|
||||
@@ -113,12 +113,15 @@ impl CollapsingHeader {
|
||||
)
|
||||
};
|
||||
|
||||
region.clip_rect.max.y = region.clip_rect.max.y.min(region.cursor.y + max_height);
|
||||
region.clip_rect.max.y = region.clip_rect.max.y.min(region.cursor().y + max_height);
|
||||
|
||||
add_contents(region);
|
||||
|
||||
region.child_bounds.max.y =
|
||||
region.child_bounds.max.y.min(region.cursor.y + max_height);
|
||||
region.child_bounds.max.y = region
|
||||
.child_bounds
|
||||
.max
|
||||
.y
|
||||
.min(region.cursor().y + max_height);
|
||||
});
|
||||
} else if state.open {
|
||||
region.indent(id, add_contents);
|
||||
@@ -129,12 +132,12 @@ impl CollapsingHeader {
|
||||
}
|
||||
|
||||
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 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.left() + region.style().indent / 2.0,
|
||||
interact.rect.center().y,
|
||||
));
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ impl ScrollArea {
|
||||
pub fn show(self, outer_region: &mut Region, add_contents: impl FnOnce(&mut Region)) {
|
||||
let ctx = outer_region.ctx().clone();
|
||||
|
||||
let scroll_area_id = outer_region.id.with("scroll_area");
|
||||
let scroll_area_id = outer_region.make_child_id("scroll_area");
|
||||
let mut state = ctx
|
||||
.memory()
|
||||
.scroll_areas
|
||||
@@ -74,7 +74,7 @@ impl ScrollArea {
|
||||
);
|
||||
|
||||
let inner_size = outer_size - vec2(current_scroll_bar_width, 0.0);
|
||||
let inner_rect = Rect::from_min_size(outer_region.cursor, inner_size);
|
||||
let inner_rect = Rect::from_min_size(outer_region.cursor(), inner_size);
|
||||
|
||||
let mut content_region = outer_region.child_region(Rect::from_min_size(
|
||||
outer_region.cursor() - state.offset,
|
||||
|
||||
Reference in New Issue
Block a user