1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 13:50:04 -04:00

Remove Ui::cursor() function

This commit is contained in:
Emil Ernerfeldt
2020-05-12 22:21:04 +02:00
parent 7a1c97ccfe
commit 1dff2ad721
8 changed files with 39 additions and 45 deletions

View File

@@ -115,7 +115,7 @@ impl Area {
Rect::from_min_size(state.pos, Vec2::infinity()),
);
add_contents(&mut ui);
state.size = ui.bounding_size().ceil();
state.size = (ui.child_bounds().max - state.pos).ceil();
let rect = Rect::from_min_size(state.pos, state.size);
let clip_rect = Rect::everything(); // TODO: get from context

View File

@@ -56,16 +56,14 @@ impl CollapsingHeader {
// TODO: horizontal layout, with icon and text as labels. Insert background behind using Frame.
let title = &label.text; // TODO: not this
let title = label.text();
let id = ui.make_unique_id(title);
let text_pos = ui.cursor() + vec2(ui.style().indent, 0.0);
let (title, text_size) = label.layout(text_pos, ui);
let available = ui.available_finite();
let text_pos = available.min + vec2(ui.style().indent, 0.0);
let (text, text_size) = label.layout(available.width() - ui.style().indent, ui);
let text_max_x = text_pos.x + text_size.x;
let desired_width = ui
.available_finite()
.size()
.x
.max(text_max_x - ui.cursor().x);
let desired_width = available.width().max(text_max_x - available.left());
let interact = ui.reserve_space(
vec2(
@@ -96,7 +94,7 @@ impl CollapsingHeader {
ui.add_text(
text_pos,
label.text_style,
title,
text,
Some(ui.style().interact(&interact).stroke_color),
);

View File

@@ -20,7 +20,7 @@ impl Default for BarState {
}
}
pub fn bar(ui: &mut Ui, add_contents: impl FnOnce(&mut Ui)) {
pub fn bar(ui: &mut Ui, add_contents: impl FnOnce(&mut Ui)) -> InteractInfo {
ui.horizontal(|ui| {
Frame::default().show(ui, |ui| {
let mut style = ui.style().clone();

View File

@@ -159,7 +159,7 @@ impl Resize {
state.size = state.size.clamp(self.min_size..=self.max_size);
let last_frame_size = state.size;
let position = ui.cursor();
let position = ui.available().min;
let corner_interact = if self.resizable {
// Resize-corner:
@@ -189,7 +189,7 @@ impl Resize {
// ------------------------------
let inner_rect = Rect::from_min_size(ui.cursor(), state.size);
let inner_rect = Rect::from_min_size(position, state.size);
let desired_size = {
let mut content_clip_rect = ui
.clip_rect()

View File

@@ -74,10 +74,10 @@ impl ScrollArea {
);
let inner_size = outer_size - vec2(current_scroll_bar_width, 0.0);
let inner_rect = Rect::from_min_size(outer_ui.cursor(), inner_size);
let inner_rect = Rect::from_min_size(outer_ui.available().min, inner_size);
let mut content_ui = outer_ui.child_ui(Rect::from_min_size(
outer_ui.cursor() - state.offset,
inner_rect.min - state.offset,
vec2(inner_size.x, f32::INFINITY),
));
let mut content_clip_rect = outer_ui.clip_rect().intersect(inner_rect);