mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 04:40:03 -04:00
Use IdSalt everywhere
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
Context, Id, InnerResponse, NumExt as _, Rect, Response, Sense, Stroke, TextStyle,
|
Context, Id, IdSalt, InnerResponse, NumExt as _, Rect, Response, Sense, Stroke, TextStyle,
|
||||||
TextWrapMode, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, WidgetInfo, WidgetText, WidgetType,
|
TextWrapMode, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, WidgetInfo, WidgetText, WidgetType,
|
||||||
emath, epaint, pos2, remap, remap_clamp, vec2,
|
emath, epaint, pos2, remap, remap_clamp, vec2,
|
||||||
};
|
};
|
||||||
@@ -391,7 +391,7 @@ pub struct CollapsingHeader {
|
|||||||
text: WidgetText,
|
text: WidgetText,
|
||||||
default_open: bool,
|
default_open: bool,
|
||||||
open: Option<bool>,
|
open: Option<bool>,
|
||||||
id_salt: Id,
|
id_salt: IdSalt,
|
||||||
enabled: bool,
|
enabled: bool,
|
||||||
selectable: bool,
|
selectable: bool,
|
||||||
selected: bool,
|
selected: bool,
|
||||||
@@ -408,7 +408,7 @@ impl CollapsingHeader {
|
|||||||
/// you need to provide a unique id source with [`Self::id_salt`].
|
/// you need to provide a unique id source with [`Self::id_salt`].
|
||||||
pub fn new(text: impl Into<WidgetText>) -> Self {
|
pub fn new(text: impl Into<WidgetText>) -> Self {
|
||||||
let text = text.into();
|
let text = text.into();
|
||||||
let id_salt = Id::new_salt(text.text());
|
let id_salt = IdSalt::new(text.text());
|
||||||
Self {
|
Self {
|
||||||
text,
|
text,
|
||||||
default_open: false,
|
default_open: false,
|
||||||
@@ -445,7 +445,7 @@ impl CollapsingHeader {
|
|||||||
/// This is useful if the title label is dynamic or not unique.
|
/// This is useful if the title label is dynamic or not unique.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn id_salt(mut self, id_salt: impl Into<crate::IdSalt>) -> Self {
|
pub fn id_salt(mut self, id_salt: impl Into<crate::IdSalt>) -> Self {
|
||||||
self.id_salt = id_salt.into().id();
|
self.id_salt = id_salt.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,7 +454,7 @@ impl CollapsingHeader {
|
|||||||
#[deprecated = "Renamed id_salt"]
|
#[deprecated = "Renamed id_salt"]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn id_source(mut self, id_salt: impl Into<crate::IdSalt>) -> Self {
|
pub fn id_source(mut self, id_salt: impl Into<crate::IdSalt>) -> Self {
|
||||||
self.id_salt = id_salt.into().id();
|
self.id_salt = id_salt.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use epaint::Shape;
|
use epaint::Shape;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Align2, Context, Id, InnerResponse, NumExt as _, Painter, Popup, PopupCloseBehavior, Rect,
|
Align2, Context, Id, IdSalt, InnerResponse, NumExt as _, Painter, Popup, PopupCloseBehavior, Rect,
|
||||||
Response, ScrollArea, Sense, Stroke, TextStyle, TextWrapMode, Ui, UiBuilder, Vec2, WidgetInfo,
|
Response, ScrollArea, Sense, Stroke, TextStyle, TextWrapMode, Ui, UiBuilder, Vec2, WidgetInfo,
|
||||||
WidgetText, WidgetType, epaint, style::StyleModifier, style::WidgetVisuals, vec2,
|
WidgetText, WidgetType, epaint, style::StyleModifier, style::WidgetVisuals, vec2,
|
||||||
};
|
};
|
||||||
@@ -36,7 +36,7 @@ pub type IconPainter = Box<dyn FnOnce(&Ui, Rect, &WidgetVisuals, bool)>;
|
|||||||
/// ```
|
/// ```
|
||||||
#[must_use = "You should call .show*"]
|
#[must_use = "You should call .show*"]
|
||||||
pub struct ComboBox {
|
pub struct ComboBox {
|
||||||
id_salt: Id,
|
id_salt: IdSalt,
|
||||||
label: Option<WidgetText>,
|
label: Option<WidgetText>,
|
||||||
selected_text: WidgetText,
|
selected_text: WidgetText,
|
||||||
width: Option<f32>,
|
width: Option<f32>,
|
||||||
@@ -51,7 +51,7 @@ impl ComboBox {
|
|||||||
/// Create new [`ComboBox`] with id and label
|
/// Create new [`ComboBox`] with id and label
|
||||||
pub fn new(id_salt: impl Into<crate::IdSalt>, label: impl Into<WidgetText>) -> Self {
|
pub fn new(id_salt: impl Into<crate::IdSalt>, label: impl Into<WidgetText>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
id_salt: id_salt.into().id(),
|
id_salt: id_salt.into(),
|
||||||
label: Some(label.into()),
|
label: Some(label.into()),
|
||||||
selected_text: Default::default(),
|
selected_text: Default::default(),
|
||||||
width: None,
|
width: None,
|
||||||
@@ -67,7 +67,7 @@ impl ComboBox {
|
|||||||
pub fn from_label(label: impl Into<WidgetText>) -> Self {
|
pub fn from_label(label: impl Into<WidgetText>) -> Self {
|
||||||
let label = label.into();
|
let label = label.into();
|
||||||
Self {
|
Self {
|
||||||
id_salt: Id::new_salt(label.text()),
|
id_salt: IdSalt::new(label.text()),
|
||||||
label: Some(label),
|
label: Some(label),
|
||||||
selected_text: Default::default(),
|
selected_text: Default::default(),
|
||||||
width: None,
|
width: None,
|
||||||
@@ -82,7 +82,7 @@ impl ComboBox {
|
|||||||
/// Without label.
|
/// Without label.
|
||||||
pub fn from_id_salt(id_salt: impl Into<crate::IdSalt>) -> Self {
|
pub fn from_id_salt(id_salt: impl Into<crate::IdSalt>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
id_salt: id_salt.into().id(),
|
id_salt: id_salt.into(),
|
||||||
label: Default::default(),
|
label: Default::default(),
|
||||||
selected_text: Default::default(),
|
selected_text: Default::default(),
|
||||||
width: None,
|
width: None,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
Align2, Color32, Context, CursorIcon, Id, NumExt as _, Rect, Response, Sense, Shape, Ui,
|
Align2, Color32, Context, CursorIcon, Id, IdSalt, NumExt as _, Rect, Response, Sense, Shape,
|
||||||
UiBuilder, UiKind, UiStackInfo, Vec2, Vec2b, pos2, vec2,
|
Ui, UiBuilder, UiKind, UiStackInfo, Vec2, Vec2b, pos2, vec2,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
@@ -34,7 +34,7 @@ impl State {
|
|||||||
#[must_use = "You should call .show()"]
|
#[must_use = "You should call .show()"]
|
||||||
pub struct Resize {
|
pub struct Resize {
|
||||||
id: Option<Id>,
|
id: Option<Id>,
|
||||||
id_salt: Option<Id>,
|
id_salt: Option<IdSalt>,
|
||||||
|
|
||||||
/// If false, we are no enabled
|
/// If false, we are no enabled
|
||||||
resizable: Vec2b,
|
resizable: Vec2b,
|
||||||
@@ -79,7 +79,7 @@ impl Resize {
|
|||||||
/// A source for the unique [`Id`], e.g. `.id_salt("second_resize_area")` or `.id_salt(loop_index)`.
|
/// A source for the unique [`Id`], e.g. `.id_salt("second_resize_area")` or `.id_salt(loop_index)`.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn id_salt(mut self, id_salt: impl Into<crate::IdSalt>) -> Self {
|
pub fn id_salt(mut self, id_salt: impl Into<crate::IdSalt>) -> Self {
|
||||||
self.id_salt = Some(id_salt.into().id());
|
self.id_salt = Some(id_salt.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,7 +208,7 @@ impl Resize {
|
|||||||
fn begin(&self, ui: &mut Ui) -> Prepared {
|
fn begin(&self, ui: &mut Ui) -> Prepared {
|
||||||
let position = ui.available_rect_before_wrap().min;
|
let position = ui.available_rect_before_wrap().min;
|
||||||
let id = self.id.unwrap_or_else(|| {
|
let id = self.id.unwrap_or_else(|| {
|
||||||
let id_salt = self.id_salt.unwrap_or_else(|| Id::new("resize"));
|
let id_salt = self.id_salt.unwrap_or_else(|| IdSalt::from("resize"));
|
||||||
ui.make_persistent_id(id_salt)
|
ui.make_persistent_id(id_salt)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use emath::GuiRounding as _;
|
|||||||
use epaint::Margin;
|
use epaint::Margin;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Context, CursorIcon, Id, NumExt as _, Pos2, Rangef, Rect, Response, Sense, Ui, UiBuilder,
|
Context, CursorIcon, Id, IdSalt, NumExt as _, Pos2, Rangef, Rect, Response, Sense, Ui, UiBuilder,
|
||||||
UiKind, UiStackInfo, Vec2, Vec2b, WidgetInfo, emath, epaint, lerp, pass_state, pos2, remap,
|
UiKind, UiStackInfo, Vec2, Vec2b, WidgetInfo, emath, epaint, lerp, pass_state, pos2, remap,
|
||||||
remap_clamp,
|
remap_clamp,
|
||||||
};
|
};
|
||||||
@@ -290,7 +290,7 @@ pub struct ScrollArea {
|
|||||||
min_scrolled_size: Vec2,
|
min_scrolled_size: Vec2,
|
||||||
scroll_bar_visibility: ScrollBarVisibility,
|
scroll_bar_visibility: ScrollBarVisibility,
|
||||||
scroll_bar_rect: Option<Rect>,
|
scroll_bar_rect: Option<Rect>,
|
||||||
id_salt: Option<Id>,
|
id_salt: Option<IdSalt>,
|
||||||
offset_x: Option<f32>,
|
offset_x: Option<f32>,
|
||||||
offset_y: Option<f32>,
|
offset_y: Option<f32>,
|
||||||
on_hover_cursor: Option<CursorIcon>,
|
on_hover_cursor: Option<CursorIcon>,
|
||||||
@@ -433,7 +433,7 @@ impl ScrollArea {
|
|||||||
/// A source for the unique [`Id`], e.g. `.id_salt("second_scroll_area")` or `.id_salt(loop_index)`.
|
/// A source for the unique [`Id`], e.g. `.id_salt("second_scroll_area")` or `.id_salt(loop_index)`.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn id_salt(mut self, id_salt: impl Into<crate::IdSalt>) -> Self {
|
pub fn id_salt(mut self, id_salt: impl Into<crate::IdSalt>) -> Self {
|
||||||
self.id_salt = Some(id_salt.into().id());
|
self.id_salt = Some(id_salt.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -709,7 +709,7 @@ impl ScrollArea {
|
|||||||
|
|
||||||
let ctx = ui.ctx().clone();
|
let ctx = ui.ctx().clone();
|
||||||
|
|
||||||
let id_salt = id_salt.unwrap_or_else(|| Id::new("scroll_area"));
|
let id_salt = id_salt.unwrap_or_else(|| IdSalt::from("scroll_area"));
|
||||||
let id = ui.make_persistent_id(id_salt);
|
let id = ui.make_persistent_id(id_salt);
|
||||||
ctx.check_for_id_clash(
|
ctx.check_for_id_clash(
|
||||||
id,
|
id,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use std::sync::Arc;
|
|||||||
use emath::GuiRounding as _;
|
use emath::GuiRounding as _;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Align2, Color32, Context, Id, InnerResponse, NumExt as _, Painter, Rect, Region, Style, Ui,
|
Align2, Color32, Context, Id, IdSalt, InnerResponse, NumExt as _, Painter, Rect, Region, Style, Ui,
|
||||||
UiBuilder, Vec2, vec2,
|
UiBuilder, Vec2, vec2,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -312,7 +312,7 @@ impl GridLayout {
|
|||||||
/// ```
|
/// ```
|
||||||
#[must_use = "You should call .show()"]
|
#[must_use = "You should call .show()"]
|
||||||
pub struct Grid {
|
pub struct Grid {
|
||||||
id_salt: Id,
|
id_salt: IdSalt,
|
||||||
num_columns: Option<usize>,
|
num_columns: Option<usize>,
|
||||||
min_col_width: Option<f32>,
|
min_col_width: Option<f32>,
|
||||||
min_row_height: Option<f32>,
|
min_row_height: Option<f32>,
|
||||||
@@ -326,7 +326,7 @@ impl Grid {
|
|||||||
/// Create a new [`Grid`] with a locally unique identifier.
|
/// Create a new [`Grid`] with a locally unique identifier.
|
||||||
pub fn new(id_salt: impl Into<crate::IdSalt>) -> Self {
|
pub fn new(id_salt: impl Into<crate::IdSalt>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
id_salt: id_salt.into().id(),
|
id_salt: id_salt.into(),
|
||||||
num_columns: None,
|
num_columns: None,
|
||||||
min_col_width: None,
|
min_col_width: None,
|
||||||
min_row_height: None,
|
min_row_height: None,
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ fn test_id_new_rejects_id() {
|
|||||||
/// let id = Id::new("parent");
|
/// let id = Id::new("parent");
|
||||||
/// let salt: IdSalt = id.into();
|
/// let salt: IdSalt = id.into();
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy, Debug, Hash)]
|
||||||
pub struct IdSalt(Id);
|
pub struct IdSalt(Id);
|
||||||
|
|
||||||
impl IdSalt {
|
impl IdSalt {
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ impl Ui {
|
|||||||
|
|
||||||
let mut painter = self.painter.clone();
|
let mut painter = self.painter.clone();
|
||||||
|
|
||||||
let id_salt = id_salt.unwrap_or_else(|| Id::from("child"));
|
let id_salt = id_salt.unwrap_or_else(|| IdSalt::from("child"));
|
||||||
let max_rect = max_rect.unwrap_or_else(|| self.available_rect_before_wrap());
|
let max_rect = max_rect.unwrap_or_else(|| self.available_rect_before_wrap());
|
||||||
let mut layout = layout.unwrap_or_else(|| *self.layout());
|
let mut layout = layout.unwrap_or_else(|| *self.layout());
|
||||||
let enabled = self.enabled && !disabled && !invisible;
|
let enabled = self.enabled && !disabled && !invisible;
|
||||||
@@ -290,7 +290,7 @@ impl Ui {
|
|||||||
|
|
||||||
debug_assert!(!max_rect.any_nan(), "max_rect is NaN: {max_rect:?}");
|
debug_assert!(!max_rect.any_nan(), "max_rect is NaN: {max_rect:?}");
|
||||||
let (stable_id, unique_id) = if global_scope {
|
let (stable_id, unique_id) = if global_scope {
|
||||||
(id_salt, id_salt)
|
(id_salt.id(), id_salt.id())
|
||||||
} else {
|
} else {
|
||||||
let stable_id = self.id.with(id_salt);
|
let stable_id = self.id.with(id_salt);
|
||||||
let unique_id = stable_id.with(self.next_auto_id_salt);
|
let unique_id = stable_id.with(self.next_auto_id_salt);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use crate::{Id, IdSalt, LayerId, Layout, Rect, Sense, Style, UiStackInfo};
|
|||||||
#[must_use]
|
#[must_use]
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
pub struct UiBuilder {
|
pub struct UiBuilder {
|
||||||
pub id_salt: Option<Id>,
|
pub id_salt: Option<IdSalt>,
|
||||||
pub global_scope: bool,
|
pub global_scope: bool,
|
||||||
pub ui_stack_info: UiStackInfo,
|
pub ui_stack_info: UiStackInfo,
|
||||||
pub layer_id: Option<LayerId>,
|
pub layer_id: Option<LayerId>,
|
||||||
@@ -40,7 +40,7 @@ impl UiBuilder {
|
|||||||
/// within the parent, or give it none at all.
|
/// within the parent, or give it none at all.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn id_salt(mut self, id_salt: impl Into<IdSalt>) -> Self {
|
pub fn id_salt(mut self, id_salt: impl Into<IdSalt>) -> Self {
|
||||||
self.id_salt = Some(id_salt.into().id());
|
self.id_salt = Some(id_salt.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ impl UiBuilder {
|
|||||||
/// This is a shortcut for `.id_salt(my_id).global_scope(true)`.
|
/// This is a shortcut for `.id_salt(my_id).global_scope(true)`.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn id(mut self, id: Id) -> Self {
|
pub fn id(mut self, id: Id) -> Self {
|
||||||
self.id_salt = Some(id);
|
self.id_salt = Some(id.into());
|
||||||
self.global_scope = true;
|
self.global_scope = true;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ use epaint::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Align, Align2, Color32, Context, CursorIcon, Event, EventFilter, FontSelection, Id, ImeEvent,
|
Align, Align2, Color32, Context, CursorIcon, Event, EventFilter, FontSelection, Id, IdSalt,
|
||||||
|
ImeEvent,
|
||||||
Key, KeyboardShortcut, Margin, Modifiers, NumExt as _, Response, Sense, Shape, TextBuffer,
|
Key, KeyboardShortcut, Margin, Modifiers, NumExt as _, Response, Sense, Shape, TextBuffer,
|
||||||
TextStyle, TextWrapMode, Ui, Vec2, Widget, WidgetInfo, WidgetText, WidgetWithState, epaint,
|
TextStyle, TextWrapMode, Ui, Vec2, Widget, WidgetInfo, WidgetText, WidgetWithState, epaint,
|
||||||
os::OperatingSystem,
|
os::OperatingSystem,
|
||||||
@@ -70,7 +71,7 @@ pub struct TextEdit<'t> {
|
|||||||
hint_text: WidgetText,
|
hint_text: WidgetText,
|
||||||
hint_text_font: Option<FontSelection>,
|
hint_text_font: Option<FontSelection>,
|
||||||
id: Option<Id>,
|
id: Option<Id>,
|
||||||
id_salt: Option<Id>,
|
id_salt: Option<IdSalt>,
|
||||||
font_selection: FontSelection,
|
font_selection: FontSelection,
|
||||||
text_color: Option<Color32>,
|
text_color: Option<Color32>,
|
||||||
layouter: Option<LayouterFn<'t>>,
|
layouter: Option<LayouterFn<'t>>,
|
||||||
@@ -175,7 +176,7 @@ impl<'t> TextEdit<'t> {
|
|||||||
/// A source for the unique [`Id`], e.g. `.id_salt("second_text_edit_field")` or `.id_salt(loop_index)`.
|
/// A source for the unique [`Id`], e.g. `.id_salt("second_text_edit_field")` or `.id_salt(loop_index)`.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn id_salt(mut self, id_salt: impl Into<crate::IdSalt>) -> Self {
|
pub fn id_salt(mut self, id_salt: impl Into<crate::IdSalt>) -> Self {
|
||||||
self.id_salt = Some(id_salt.into().id());
|
self.id_salt = Some(id_salt.into());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use accesskit_consumer::{FilterResult, Node, NodeId, Tree, TreeChangeHandler};
|
|||||||
|
|
||||||
use eframe::epaint::text::TextWrapMode;
|
use eframe::epaint::text::TextWrapMode;
|
||||||
use egui::{
|
use egui::{
|
||||||
Button, Color32, Event, Frame, FullOutput, Id, Key, KeyboardShortcut, Label, Modifiers, Panel,
|
Button, Color32, Event, Frame, FullOutput, Id, IdSalt, Key, KeyboardShortcut, Label, Modifiers, Panel,
|
||||||
RawInput, RichText, ScrollArea, Ui, collapsing_header::CollapsingState,
|
RawInput, RichText, ScrollArea, Ui, collapsing_header::CollapsingState,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -213,7 +213,7 @@ impl AccessibilityInspectorPlugin {
|
|||||||
#[expect(unsafe_code)]
|
#[expect(unsafe_code)]
|
||||||
let egui_node_id = unsafe { Id::from_high_entropy_bits(node.locate().0.0) };
|
let egui_node_id = unsafe { Id::from_high_entropy_bits(node.locate().0.0) };
|
||||||
|
|
||||||
ui.push_id(node.id(), |ui| {
|
ui.push_id(IdSalt::new(node.id()), |ui| {
|
||||||
let child_count = node.children().len();
|
let child_count = node.children().len();
|
||||||
let has_children = child_count > 0;
|
let has_children = child_count > 0;
|
||||||
let default_open = child_count == 1 && node.role() != accesskit::Role::Label;
|
let default_open = child_count == 1 && node.role() != accesskit::Role::Label;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use egui::{Id, Pos2, Rect, Response, Sense, Ui, UiBuilder, emath::GuiRounding as _};
|
use egui::{Pos2, Rect, Response, Sense, Ui, UiBuilder, emath::GuiRounding as _};
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub(crate) enum CellSize {
|
pub(crate) enum CellSize {
|
||||||
@@ -117,7 +117,7 @@ impl<'l> StripLayout<'l> {
|
|||||||
flags: StripLayoutFlags,
|
flags: StripLayoutFlags,
|
||||||
width: CellSize,
|
width: CellSize,
|
||||||
height: CellSize,
|
height: CellSize,
|
||||||
child_ui_id_salt: Id,
|
child_ui_id_salt: egui::IdSalt,
|
||||||
add_cell_contents: impl FnOnce(&mut Ui),
|
add_cell_contents: impl FnOnce(&mut Ui),
|
||||||
) -> (Rect, Response) {
|
) -> (Rect, Response) {
|
||||||
let max_rect = self.cell_rect(&width, &height);
|
let max_rect = self.cell_rect(&width, &height);
|
||||||
@@ -201,7 +201,7 @@ impl<'l> StripLayout<'l> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
flags: StripLayoutFlags,
|
flags: StripLayoutFlags,
|
||||||
max_rect: Rect,
|
max_rect: Rect,
|
||||||
child_ui_id_salt: egui::Id,
|
child_ui_id_salt: egui::IdSalt,
|
||||||
add_cell_contents: impl FnOnce(&mut Ui),
|
add_cell_contents: impl FnOnce(&mut Ui),
|
||||||
) -> Ui {
|
) -> Ui {
|
||||||
let mut ui_builder = UiBuilder::new()
|
let mut ui_builder = UiBuilder::new()
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ impl Strip<'_, '_> {
|
|||||||
flags,
|
flags,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
egui::Id::new(self.size_index),
|
egui::IdSalt::new(self.size_index),
|
||||||
add_contents,
|
add_contents,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
//! Takes all available height, so if you want something below the table, put it in a strip.
|
//! Takes all available height, so if you want something below the table, put it in a strip.
|
||||||
|
|
||||||
use egui::{
|
use egui::{
|
||||||
Align, Id, NumExt as _, Rangef, Rect, Response, ScrollArea, Ui, Vec2, Vec2b,
|
Align, NumExt as _, Rangef, Rect, Response, ScrollArea, Ui, Vec2, Vec2b,
|
||||||
scroll_area::{ScrollAreaOutput, ScrollBarVisibility, ScrollSource},
|
scroll_area::{ScrollAreaOutput, ScrollBarVisibility, ScrollSource},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -246,7 +246,7 @@ impl Default for TableScrollOptions {
|
|||||||
/// ```
|
/// ```
|
||||||
pub struct TableBuilder<'a> {
|
pub struct TableBuilder<'a> {
|
||||||
ui: &'a mut Ui,
|
ui: &'a mut Ui,
|
||||||
id_salt: Id,
|
id_salt: egui::IdSalt,
|
||||||
columns: Vec<Column>,
|
columns: Vec<Column>,
|
||||||
striped: Option<bool>,
|
striped: Option<bool>,
|
||||||
resizable: bool,
|
resizable: bool,
|
||||||
@@ -260,7 +260,7 @@ impl<'a> TableBuilder<'a> {
|
|||||||
let cell_layout = *ui.layout();
|
let cell_layout = *ui.layout();
|
||||||
Self {
|
Self {
|
||||||
ui,
|
ui,
|
||||||
id_salt: Id::new("__table_state"),
|
id_salt: egui::IdSalt::from("__table_state"),
|
||||||
columns: Default::default(),
|
columns: Default::default(),
|
||||||
striped: None,
|
striped: None,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
@@ -284,7 +284,7 @@ impl<'a> TableBuilder<'a> {
|
|||||||
/// This is required if you have multiple tables in the same [`Ui`].
|
/// This is required if you have multiple tables in the same [`Ui`].
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn id_salt(mut self, id_salt: impl Into<egui::IdSalt>) -> Self {
|
pub fn id_salt(mut self, id_salt: impl Into<egui::IdSalt>) -> Self {
|
||||||
self.id_salt = id_salt.into().id();
|
self.id_salt = id_salt.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1314,7 +1314,7 @@ impl TableRow<'_, '_> {
|
|||||||
flags,
|
flags,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
egui::Id::new((self.row_index, col_index)),
|
egui::IdSalt::new((self.row_index, col_index)),
|
||||||
add_cell_contents,
|
add_cell_contents,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user