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

Made the fields in Context private

This commit is contained in:
Emil Ernerfeldt
2020-05-04 21:35:16 +02:00
parent 45564f952b
commit d02194d33a
9 changed files with 68 additions and 54 deletions

View File

@@ -68,7 +68,7 @@ impl CollapsingHeader {
});
if interact.clicked {
state.open = !state.open;
state.toggle_time = region.ctx.input.time;
state.toggle_time = region.ctx.input().time;
}
*state
};
@@ -93,7 +93,7 @@ impl CollapsingHeader {
);
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.ctx.input().time - state.toggle_time) as f32;
let animate = time_since_toggle < animation_time;
if animate {
region.indent(id, |region| {

View File

@@ -101,8 +101,8 @@ impl Floating {
let margin = 32.0;
state.pos = state.pos.max(pos2(margin - state.size.x, 0.0));
state.pos = state.pos.min(pos2(
ctx.input.screen_size.x - margin,
ctx.input.screen_size.y - margin,
ctx.input().screen_size.x - margin,
ctx.input().screen_size.y - margin,
));
state.pos = state.pos.round();
@@ -115,8 +115,8 @@ impl Floating {
}
fn mouse_pressed_on_floating(ctx: &Context, id: Id) -> bool {
if let Some(mouse_pos) = ctx.input.mouse_pos {
ctx.input.mouse_pressed && ctx.memory().layer_at(mouse_pos) == Layer::Window(id)
if let Some(mouse_pos) = ctx.input().mouse_pos {
ctx.input().mouse_pressed && ctx.memory().layer_at(mouse_pos) == Layer::Window(id)
} else {
false
}

View File

@@ -101,12 +101,12 @@ impl ScrollArea {
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;
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() {
state.offset.y -= ctx.input.scroll_delta.y;
state.offset.y -= ctx.input().scroll_delta.y;
}
let show_scroll_this_frame = content_size.y > inner_size.y || self.always_show_scroll;
@@ -134,11 +134,11 @@ impl ScrollArea {
let interact_id = scroll_area_id.with("vertical");
let handle_interact = outer_region.interact_rect(&handle_rect, interact_id);
if let Some(mouse_pos) = ctx.input.mouse_pos {
if let Some(mouse_pos) = ctx.input().mouse_pos {
if handle_interact.active {
if inner_rect.top() <= mouse_pos.y && mouse_pos.y <= inner_rect.bottom() {
state.offset.y +=
ctx.input.mouse_move.y * content_size.y / inner_rect.height();
ctx.input().mouse_move.y * content_size.y / inner_rect.height();
}
} else {
// Check for mouse down outside handle: