[slider] bug fix: generate unique id for sliders
This commit is contained in:
parent
bea7e3a52e
commit
c35494e4ec
4 changed files with 4 additions and 4 deletions
|
@ -179,7 +179,7 @@ impl CollapsingHeader {
|
||||||
// TODO: horizontal layout, with icon and text as labels. Insert background behind using Frame.
|
// TODO: horizontal layout, with icon and text as labels. Insert background behind using Frame.
|
||||||
|
|
||||||
let title = label.text();
|
let title = label.text();
|
||||||
let id = ui.make_unique_id(title);
|
let id = ui.make_unique_child_id(title);
|
||||||
|
|
||||||
let available = ui.available_finite();
|
let available = ui.available_finite();
|
||||||
let text_pos = available.min + vec2(ui.style().indent, 0.0);
|
let text_pos = available.min + vec2(ui.style().indent, 0.0);
|
||||||
|
|
|
@ -55,7 +55,7 @@ fn menu_impl<'c>(
|
||||||
) {
|
) {
|
||||||
let title = title.into();
|
let title = title.into();
|
||||||
let bar_id = ui.id();
|
let bar_id = ui.id();
|
||||||
let menu_id = Id::new(&title);
|
let menu_id = bar_id.with(&title);
|
||||||
|
|
||||||
let mut bar_state = ui
|
let mut bar_state = ui
|
||||||
.memory()
|
.memory()
|
||||||
|
|
|
@ -280,7 +280,7 @@ impl Ui {
|
||||||
/// Use this to generate widget ids for widgets that have persistent state in Memory.
|
/// Use this to generate widget ids for widgets that have persistent state in Memory.
|
||||||
/// If the `id_source` is not unique within this ui
|
/// If the `id_source` is not unique within this ui
|
||||||
/// then an error will be printed at the current cursor position.
|
/// then an error will be printed at the current cursor position.
|
||||||
pub fn make_unique_id<IdSource>(&self, id_source: IdSource) -> Id
|
pub fn make_unique_child_id<IdSource>(&self, id_source: IdSource) -> Id
|
||||||
where
|
where
|
||||||
IdSource: Hash + std::fmt::Debug,
|
IdSource: Hash + std::fmt::Debug,
|
||||||
{
|
{
|
||||||
|
|
|
@ -105,7 +105,7 @@ impl<'a> Widget for Slider<'a> {
|
||||||
|
|
||||||
if let Some(text) = &self.text {
|
if let Some(text) = &self.text {
|
||||||
if self.id.is_none() {
|
if self.id.is_none() {
|
||||||
self.id = Some(Id::new(text));
|
self.id = Some(ui.make_unique_child_id(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
let text_on_top = self.text_on_top.unwrap_or_default();
|
let text_on_top = self.text_on_top.unwrap_or_default();
|
||||||
|
|
Loading…
Reference in a new issue