Rename ui.advance_cursor to ui.add_space
This commit is contained in:
@@ -331,7 +331,7 @@ impl<'open> Window<'open> {
|
||||
.add_contents(&mut frame.content_ui, collapsing_id, |ui| {
|
||||
resize.show(ui, |ui| {
|
||||
if title_bar.is_some() {
|
||||
ui.advance_cursor(title_content_spacing);
|
||||
ui.add_space(title_content_spacing);
|
||||
}
|
||||
|
||||
if let Some(scroll) = scroll {
|
||||
@@ -698,7 +698,7 @@ fn show_title_bar(
|
||||
let pad = (height - button_size.y) / 2.0; // calculated so that the icon is on the diagonal (if window padding is symmetrical)
|
||||
|
||||
if collapsible {
|
||||
ui.advance_cursor(pad);
|
||||
ui.add_space(pad);
|
||||
|
||||
let (_id, rect) = ui.allocate_space(button_size);
|
||||
let collapse_button_response = ui.interact(rect, collapsing_id, Sense::click());
|
||||
|
||||
+2
-2
@@ -791,14 +791,14 @@ impl Context {
|
||||
.unwrap_or_default()
|
||||
))
|
||||
.on_hover_text("Is egui currently listening for text input?");
|
||||
ui.advance_cursor(16.0);
|
||||
ui.add_space(16.0);
|
||||
|
||||
ui.label(format!(
|
||||
"There are {} text galleys in the layout cache",
|
||||
self.fonts().num_galleys_in_cache()
|
||||
))
|
||||
.on_hover_text("This is approximately the number of text strings on screen");
|
||||
ui.advance_cursor(16.0);
|
||||
ui.add_space(16.0);
|
||||
|
||||
CollapsingHeader::new("📥 Input")
|
||||
.default_open(false)
|
||||
|
||||
@@ -79,7 +79,7 @@ impl Widget for &epaint::stats::PaintStats {
|
||||
"egui generates intermediate level shapes like circles and text. \
|
||||
These are later tessellated into triangles.",
|
||||
);
|
||||
ui.advance_cursor(10.0);
|
||||
ui.add_space(10.0);
|
||||
|
||||
ui.style_mut().body_text_style = TextStyle::Monospace;
|
||||
|
||||
@@ -100,14 +100,14 @@ impl Widget for &epaint::stats::PaintStats {
|
||||
label(ui, shape_path, "paths");
|
||||
label(ui, shape_mesh, "nested meshes");
|
||||
label(ui, shape_vec, "nested shapes");
|
||||
ui.advance_cursor(10.0);
|
||||
ui.add_space(10.0);
|
||||
|
||||
ui.label("Tessellated:");
|
||||
label(ui, clipped_meshes, "clipped_meshes")
|
||||
.on_hover_text("Number of separate clip rectangles");
|
||||
label(ui, vertices, "vertices");
|
||||
label(ui, indices, "indices").on_hover_text("Three 32-bit indices per triangles");
|
||||
ui.advance_cursor(10.0);
|
||||
ui.add_space(10.0);
|
||||
|
||||
// ui.label("Total:");
|
||||
// ui.label(self.total().format(""));
|
||||
|
||||
+6
-1
@@ -62,7 +62,12 @@ impl Style {
|
||||
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(feature = "persistence", serde(default))]
|
||||
pub struct Spacing {
|
||||
/// Horizontal and vertical spacing between widgets
|
||||
/// Horizontal and vertical spacing between widgets.
|
||||
///
|
||||
/// To add extra space between widgets, use [`Ui::add_space`].
|
||||
///
|
||||
/// `item_spacing` is inserted _after_ adding a widget, so to increase the spacing between
|
||||
/// widgets `A` and `B` you need to change `item_spacing` before adding `A`.
|
||||
pub item_spacing: Vec2,
|
||||
|
||||
/// Horizontal and vertical padding within a window frame.
|
||||
|
||||
+16
-14
@@ -510,19 +510,6 @@ impl Ui {
|
||||
pub fn hovered(&self, rect: Rect) -> bool {
|
||||
self.interact(rect, self.id, Sense::hover()).hovered
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Stuff that moves the cursor, i.e. allocates space in this ui!
|
||||
|
||||
/// Advance the cursor (where the next widget is put) by this many points.
|
||||
///
|
||||
/// The direction is dependent on the layout.
|
||||
/// This is useful for creating some extra space between widgets.
|
||||
///
|
||||
/// [`Self::min_rect`] will expand to contain the cursor.
|
||||
pub fn advance_cursor(&mut self, amount: f32) {
|
||||
self.placer.advance_cursor(amount);
|
||||
}
|
||||
}
|
||||
|
||||
/// # Allocating space: where do I put my widgets?
|
||||
@@ -833,6 +820,21 @@ impl Ui {
|
||||
.inner
|
||||
}
|
||||
|
||||
/// Add extra space before the next widget.
|
||||
///
|
||||
/// The direction is dependent on the layout.
|
||||
/// This will be in addition to the [`Spacing::item_spacing`}.
|
||||
///
|
||||
/// [`Self::min_rect`] will expand to contain the space.
|
||||
pub fn add_space(&mut self, amount: f32) {
|
||||
self.placer.advance_cursor(amount);
|
||||
}
|
||||
|
||||
#[deprecated = "Use add_space instead"]
|
||||
pub fn advance_cursor(&mut self, amount: f32) {
|
||||
self.add_space(amount);
|
||||
}
|
||||
|
||||
/// Shortcut for `add(Label::new(text))`
|
||||
///
|
||||
/// See also [`Label`].
|
||||
@@ -1214,7 +1216,7 @@ impl Ui {
|
||||
|
||||
let end_with_horizontal_line = true;
|
||||
if end_with_horizontal_line {
|
||||
child_ui.advance_cursor(4.0);
|
||||
child_ui.add_space(4.0);
|
||||
}
|
||||
|
||||
// draw a faint line on the left to mark the indented section
|
||||
|
||||
Reference in New Issue
Block a user