mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 22:00:03 -04:00
Rename id_source to id_salt (#5025)
* Closes <https://github.com/emilk/egui/issues/5020 > * [x] I have followed the instructions in the PR template
This commit is contained in:
@@ -213,7 +213,7 @@ impl Default for TableScrollOptions {
|
||||
/// You must pre-allocate all columns with [`Self::column`]/[`Self::columns`].
|
||||
///
|
||||
/// If you have multiple [`Table`]:s in the same [`Ui`]
|
||||
/// you will need to give them unique id:s by with [`Self::id_source`].
|
||||
/// you will need to give them unique id:s by with [`Self::id_salt`].
|
||||
///
|
||||
/// ### Example
|
||||
/// ```
|
||||
@@ -244,7 +244,7 @@ impl Default for TableScrollOptions {
|
||||
/// ```
|
||||
pub struct TableBuilder<'a> {
|
||||
ui: &'a mut Ui,
|
||||
id_source: Id,
|
||||
id_salt: Id,
|
||||
columns: Vec<Column>,
|
||||
striped: Option<bool>,
|
||||
resizable: bool,
|
||||
@@ -258,7 +258,7 @@ impl<'a> TableBuilder<'a> {
|
||||
let cell_layout = *ui.layout();
|
||||
Self {
|
||||
ui,
|
||||
id_source: Id::new("__table_state"),
|
||||
id_salt: Id::new("__table_state"),
|
||||
columns: Default::default(),
|
||||
striped: None,
|
||||
resizable: false,
|
||||
@@ -272,8 +272,17 @@ impl<'a> TableBuilder<'a> {
|
||||
///
|
||||
/// This is required if you have multiple tables in the same [`Ui`].
|
||||
#[inline]
|
||||
pub fn id_source(mut self, id_source: impl std::hash::Hash) -> Self {
|
||||
self.id_source = Id::new(id_source);
|
||||
#[deprecated = "Renamed id_salt"]
|
||||
pub fn id_source(self, id_salt: impl std::hash::Hash) -> Self {
|
||||
self.id_salt(id_salt)
|
||||
}
|
||||
|
||||
/// Give this table a unique id within the parent [`Ui`].
|
||||
///
|
||||
/// This is required if you have multiple tables in the same [`Ui`].
|
||||
#[inline]
|
||||
pub fn id_salt(mut self, id_salt: impl std::hash::Hash) -> Self {
|
||||
self.id_salt = Id::new(id_salt);
|
||||
self
|
||||
}
|
||||
|
||||
@@ -431,7 +440,7 @@ impl<'a> TableBuilder<'a> {
|
||||
|
||||
/// Reset all column widths.
|
||||
pub fn reset(&mut self) {
|
||||
let state_id = self.ui.id().with(self.id_source);
|
||||
let state_id = self.ui.id().with(self.id_salt);
|
||||
TableState::reset(self.ui, state_id);
|
||||
}
|
||||
|
||||
@@ -441,7 +450,7 @@ impl<'a> TableBuilder<'a> {
|
||||
|
||||
let Self {
|
||||
ui,
|
||||
id_source,
|
||||
id_salt,
|
||||
columns,
|
||||
striped,
|
||||
resizable,
|
||||
@@ -452,7 +461,7 @@ impl<'a> TableBuilder<'a> {
|
||||
|
||||
let striped = striped.unwrap_or(ui.visuals().striped);
|
||||
|
||||
let state_id = ui.id().with(id_source);
|
||||
let state_id = ui.id().with(id_salt);
|
||||
|
||||
let (is_sizing_pass, state) =
|
||||
TableState::load(ui, state_id, resizable, &columns, available_width);
|
||||
@@ -509,7 +518,7 @@ impl<'a> TableBuilder<'a> {
|
||||
|
||||
let Self {
|
||||
ui,
|
||||
id_source,
|
||||
id_salt,
|
||||
columns,
|
||||
striped,
|
||||
resizable,
|
||||
@@ -520,7 +529,7 @@ impl<'a> TableBuilder<'a> {
|
||||
|
||||
let striped = striped.unwrap_or(ui.visuals().striped);
|
||||
|
||||
let state_id = ui.id().with(id_source);
|
||||
let state_id = ui.id().with(id_salt);
|
||||
|
||||
let (is_sizing_pass, state) =
|
||||
TableState::load(ui, state_id, resizable, &columns, available_width);
|
||||
|
||||
Reference in New Issue
Block a user