mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 06:40:06 -04:00
Add #[inline] to all builder-pattern functions (#3557)
Better performance and maybe code size
This commit is contained in:
@@ -33,36 +33,42 @@ impl<'a> DatePickerButton<'a> {
|
||||
|
||||
/// Add id source.
|
||||
/// Must be set if multiple date picker buttons are in the same Ui.
|
||||
#[inline]
|
||||
pub fn id_source(mut self, id_source: &'a str) -> Self {
|
||||
self.id_source = Some(id_source);
|
||||
self
|
||||
}
|
||||
|
||||
/// Show combo boxes in date picker popup. (Default: true)
|
||||
#[inline]
|
||||
pub fn combo_boxes(mut self, combo_boxes: bool) -> Self {
|
||||
self.combo_boxes = combo_boxes;
|
||||
self
|
||||
}
|
||||
|
||||
/// Show arrows in date picker popup. (Default: true)
|
||||
#[inline]
|
||||
pub fn arrows(mut self, arrows: bool) -> Self {
|
||||
self.arrows = arrows;
|
||||
self
|
||||
}
|
||||
|
||||
/// Show calendar in date picker popup. (Default: true)
|
||||
#[inline]
|
||||
pub fn calendar(mut self, calendar: bool) -> Self {
|
||||
self.calendar = calendar;
|
||||
self
|
||||
}
|
||||
|
||||
/// Show calendar week in date picker popup. (Default: true)
|
||||
#[inline]
|
||||
pub fn calendar_week(mut self, week: bool) -> Self {
|
||||
self.calendar_week = week;
|
||||
self
|
||||
}
|
||||
|
||||
/// Show the calendar icon on the button. (Default: true)
|
||||
#[inline]
|
||||
pub fn show_icon(mut self, show_icon: bool) -> Self {
|
||||
self.show_icon = show_icon;
|
||||
self
|
||||
|
||||
@@ -112,6 +112,7 @@ impl RetainedImage {
|
||||
/// let image = RetainedImage::from_color_image("my_image", color_image)
|
||||
/// .with_options(TextureOptions::NEAREST);
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn with_options(mut self, options: TextureOptions) -> Self {
|
||||
self.options = options;
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ impl Size {
|
||||
}
|
||||
|
||||
/// Won't shrink below this size (in points).
|
||||
#[inline]
|
||||
pub fn at_least(mut self, minimum: f32) -> Self {
|
||||
match &mut self {
|
||||
Self::Absolute { range, .. }
|
||||
@@ -59,6 +60,7 @@ impl Size {
|
||||
}
|
||||
|
||||
/// Won't grow above this size (in points).
|
||||
#[inline]
|
||||
pub fn at_most(mut self, maximum: f32) -> Self {
|
||||
match &mut self {
|
||||
Self::Absolute { range, .. }
|
||||
|
||||
@@ -61,24 +61,28 @@ impl<'a> StripBuilder<'a> {
|
||||
}
|
||||
|
||||
/// Should we clip the contents of each cell? Default: `false`.
|
||||
#[inline]
|
||||
pub fn clip(mut self, clip: bool) -> Self {
|
||||
self.clip = clip;
|
||||
self
|
||||
}
|
||||
|
||||
/// What layout should we use for the individual cells?
|
||||
#[inline]
|
||||
pub fn cell_layout(mut self, cell_layout: egui::Layout) -> Self {
|
||||
self.cell_layout = cell_layout;
|
||||
self
|
||||
}
|
||||
|
||||
/// Allocate space for one column/row.
|
||||
#[inline]
|
||||
pub fn size(mut self, size: Size) -> Self {
|
||||
self.sizing.add(size);
|
||||
self
|
||||
}
|
||||
|
||||
/// Allocate space for several columns/rows at once.
|
||||
#[inline]
|
||||
pub fn sizes(mut self, size: Size, count: usize) -> Self {
|
||||
for _ in 0..count {
|
||||
self.sizing.add(size);
|
||||
|
||||
@@ -90,6 +90,7 @@ impl Column {
|
||||
///
|
||||
/// If you don't call this, the fallback value of
|
||||
/// [`TableBuilder::resizable`] is used (which by default is `false`).
|
||||
#[inline]
|
||||
pub fn resizable(mut self, resizable: bool) -> Self {
|
||||
self.resizable = Some(resizable);
|
||||
self
|
||||
@@ -103,6 +104,7 @@ impl Column {
|
||||
/// If you turn on clipping you should also consider calling [`Self::at_least`].
|
||||
///
|
||||
/// Default: `false`.
|
||||
#[inline]
|
||||
pub fn clip(mut self, clip: bool) -> Self {
|
||||
self.clip = clip;
|
||||
self
|
||||
@@ -111,6 +113,7 @@ impl Column {
|
||||
/// Won't shrink below this width (in points).
|
||||
///
|
||||
/// Default: 0.0
|
||||
#[inline]
|
||||
pub fn at_least(mut self, minimum: f32) -> Self {
|
||||
self.width_range.min = minimum;
|
||||
self
|
||||
@@ -119,12 +122,14 @@ impl Column {
|
||||
/// Won't grow above this width (in points).
|
||||
///
|
||||
/// Default: [`f32::INFINITY`]
|
||||
#[inline]
|
||||
pub fn at_most(mut self, maximum: f32) -> Self {
|
||||
self.width_range.max = maximum;
|
||||
self
|
||||
}
|
||||
|
||||
/// Allowed range of movement (in points), if in a resizable [`Table`](crate::table::Table).
|
||||
#[inline]
|
||||
pub fn range(mut self, range: impl Into<Rangef>) -> Self {
|
||||
self.width_range = range.into();
|
||||
self
|
||||
@@ -244,6 +249,7 @@ impl<'a> TableBuilder<'a> {
|
||||
/// Enable striped row background for improved readability.
|
||||
///
|
||||
/// Default is whatever is in [`egui::Visuals::striped`].
|
||||
#[inline]
|
||||
pub fn striped(mut self, striped: bool) -> Self {
|
||||
self.striped = Some(striped);
|
||||
self
|
||||
@@ -259,12 +265,14 @@ impl<'a> TableBuilder<'a> {
|
||||
/// (and instead use up the remainder).
|
||||
///
|
||||
/// Default is `false`.
|
||||
#[inline]
|
||||
pub fn resizable(mut self, resizable: bool) -> Self {
|
||||
self.resizable = resizable;
|
||||
self
|
||||
}
|
||||
|
||||
/// Enable vertical scrolling in body (default: `true`)
|
||||
#[inline]
|
||||
pub fn vscroll(mut self, vscroll: bool) -> Self {
|
||||
self.scroll_options.vscroll = vscroll;
|
||||
self
|
||||
@@ -278,6 +286,7 @@ impl<'a> TableBuilder<'a> {
|
||||
/// Enables scrolling the table's contents using mouse drag (default: `true`).
|
||||
///
|
||||
/// See [`ScrollArea::drag_to_scroll`] for more.
|
||||
#[inline]
|
||||
pub fn drag_to_scroll(mut self, drag_to_scroll: bool) -> Self {
|
||||
self.scroll_options.drag_to_scroll = drag_to_scroll;
|
||||
self
|
||||
@@ -286,6 +295,7 @@ impl<'a> TableBuilder<'a> {
|
||||
/// Should the scroll handle stick to the bottom position even as the content size changes
|
||||
/// dynamically? The scroll handle remains stuck until manually changed, and will become stuck
|
||||
/// once again when repositioned to the bottom. Default: `false`.
|
||||
#[inline]
|
||||
pub fn stick_to_bottom(mut self, stick: bool) -> Self {
|
||||
self.scroll_options.stick_to_bottom = stick;
|
||||
self
|
||||
@@ -298,6 +308,7 @@ impl<'a> TableBuilder<'a> {
|
||||
/// If `align` is `None`, the table will scroll just enough to bring the cursor into view.
|
||||
///
|
||||
/// See also: [`Self::vertical_scroll_offset`].
|
||||
#[inline]
|
||||
pub fn scroll_to_row(mut self, row: usize, align: Option<Align>) -> Self {
|
||||
self.scroll_options.scroll_to_row = Some((row, align));
|
||||
self
|
||||
@@ -306,6 +317,7 @@ impl<'a> TableBuilder<'a> {
|
||||
/// Set the vertical scroll offset position, in points.
|
||||
///
|
||||
/// See also: [`Self::scroll_to_row`].
|
||||
#[inline]
|
||||
pub fn vertical_scroll_offset(mut self, offset: f32) -> Self {
|
||||
self.scroll_options.scroll_offset_y = Some(offset);
|
||||
self
|
||||
@@ -317,6 +329,7 @@ impl<'a> TableBuilder<'a> {
|
||||
/// (and so we don't require scroll bars).
|
||||
///
|
||||
/// Default: `200.0`.
|
||||
#[inline]
|
||||
pub fn min_scrolled_height(mut self, min_scrolled_height: f32) -> Self {
|
||||
self.scroll_options.min_scrolled_height = min_scrolled_height;
|
||||
self
|
||||
@@ -326,6 +339,7 @@ impl<'a> TableBuilder<'a> {
|
||||
///
|
||||
/// In other words: add scroll-bars when this height is reached.
|
||||
/// Default: `800.0`.
|
||||
#[inline]
|
||||
pub fn max_scroll_height(mut self, max_scroll_height: f32) -> Self {
|
||||
self.scroll_options.max_scroll_height = max_scroll_height;
|
||||
self
|
||||
@@ -338,24 +352,28 @@ impl<'a> TableBuilder<'a> {
|
||||
/// Default: `true`.
|
||||
///
|
||||
/// See [`ScrollArea::auto_shrink`] for more.
|
||||
#[inline]
|
||||
pub fn auto_shrink(mut self, auto_shrink: impl Into<Vec2b>) -> Self {
|
||||
self.scroll_options.auto_shrink = auto_shrink.into();
|
||||
self
|
||||
}
|
||||
|
||||
/// What layout should we use for the individual cells?
|
||||
#[inline]
|
||||
pub fn cell_layout(mut self, cell_layout: egui::Layout) -> Self {
|
||||
self.cell_layout = cell_layout;
|
||||
self
|
||||
}
|
||||
|
||||
/// Allocate space for one column.
|
||||
#[inline]
|
||||
pub fn column(mut self, column: Column) -> Self {
|
||||
self.columns.push(column);
|
||||
self
|
||||
}
|
||||
|
||||
/// Allocate space for several columns at once.
|
||||
#[inline]
|
||||
pub fn columns(mut self, column: Column, count: usize) -> Self {
|
||||
for _ in 0..count {
|
||||
self.columns.push(column);
|
||||
|
||||
Reference in New Issue
Block a user