mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 13:50:04 -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:
@@ -11,7 +11,7 @@ pub(crate) struct DatePickerButtonState {
|
||||
/// Shows a date, and will open a date picker popup when clicked.
|
||||
pub struct DatePickerButton<'a> {
|
||||
selection: &'a mut NaiveDate,
|
||||
id_source: Option<&'a str>,
|
||||
id_salt: Option<&'a str>,
|
||||
combo_boxes: bool,
|
||||
arrows: bool,
|
||||
calendar: bool,
|
||||
@@ -25,7 +25,7 @@ impl<'a> DatePickerButton<'a> {
|
||||
pub fn new(selection: &'a mut NaiveDate) -> Self {
|
||||
Self {
|
||||
selection,
|
||||
id_source: None,
|
||||
id_salt: None,
|
||||
combo_boxes: true,
|
||||
arrows: true,
|
||||
calendar: true,
|
||||
@@ -39,11 +39,19 @@ 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);
|
||||
pub fn id_salt(mut self, id_salt: &'a str) -> Self {
|
||||
self.id_salt = Some(id_salt);
|
||||
self
|
||||
}
|
||||
|
||||
/// Add id source.
|
||||
/// Must be set if multiple date picker buttons are in the same Ui.
|
||||
#[inline]
|
||||
#[deprecated = "Renamed id_salt"]
|
||||
pub fn id_source(self, id_salt: &'a str) -> Self {
|
||||
self.id_salt(id_salt)
|
||||
}
|
||||
|
||||
/// Show combo boxes in date picker popup. (Default: true)
|
||||
#[inline]
|
||||
pub fn combo_boxes(mut self, combo_boxes: bool) -> Self {
|
||||
@@ -97,7 +105,7 @@ impl<'a> DatePickerButton<'a> {
|
||||
|
||||
impl<'a> Widget for DatePickerButton<'a> {
|
||||
fn ui(self, ui: &mut Ui) -> egui::Response {
|
||||
let id = ui.make_persistent_id(self.id_source);
|
||||
let id = ui.make_persistent_id(self.id_salt);
|
||||
let mut button_state = ui
|
||||
.data_mut(|data| data.get_persisted::<DatePickerButtonState>(id))
|
||||
.unwrap_or_default();
|
||||
@@ -140,7 +148,7 @@ impl<'a> Widget for DatePickerButton<'a> {
|
||||
let InnerResponse {
|
||||
inner: saved,
|
||||
response: area_response,
|
||||
} = Area::new(ui.make_persistent_id(self.id_source))
|
||||
} = Area::new(ui.make_persistent_id(self.id_salt))
|
||||
.kind(egui::UiKind::Picker)
|
||||
.order(Order::Foreground)
|
||||
.fixed_pos(pos)
|
||||
|
||||
Reference in New Issue
Block a user