move widgets on draw if region size is same
This commit is contained in:
@@ -10,7 +10,7 @@ use std::{
|
||||
|
||||
use crate::{
|
||||
layout::{FnTag, Ui, Widget, WidgetLike, WidgetTag},
|
||||
util::{CopyId, Id, RefCounter},
|
||||
util::{Id, RefCounter},
|
||||
};
|
||||
|
||||
pub struct AnyWidget;
|
||||
@@ -44,7 +44,7 @@ pub struct WidgetId<W = AnyWidget> {
|
||||
#[repr(C)]
|
||||
pub struct StaticWidgetId<W = AnyWidget> {
|
||||
pub(super) ty: TypeId,
|
||||
pub(super) id: CopyId,
|
||||
pub(super) id: Id,
|
||||
_pd: PhantomData<W>,
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ impl<W> std::fmt::Debug for WidgetId<W> {
|
||||
impl<W> Clone for WidgetId<W> {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
id: self.id.duplicate(),
|
||||
id: self.id,
|
||||
ty: self.ty,
|
||||
counter: self.counter.clone(),
|
||||
send: self.send.clone(),
|
||||
@@ -89,7 +89,7 @@ impl<W> WidgetId<W> {
|
||||
}
|
||||
|
||||
pub fn key(&self) -> Id {
|
||||
self.id.duplicate()
|
||||
self.id
|
||||
}
|
||||
|
||||
pub(super) fn cast_type<W2>(self) -> WidgetId<W2> {
|
||||
@@ -105,7 +105,7 @@ impl<W> WidgetId<W> {
|
||||
self.is_static.store(true, Ordering::Release);
|
||||
StaticWidgetId {
|
||||
ty: self.ty,
|
||||
id: self.id.copyable(),
|
||||
id: self.id,
|
||||
_pd: PhantomData,
|
||||
}
|
||||
}
|
||||
@@ -116,7 +116,7 @@ impl WidgetId {
|
||||
let send = self.send.clone();
|
||||
drop(std::mem::replace(
|
||||
self,
|
||||
Self::new(other.id.id(), self.ty, send, true),
|
||||
Self::new(other.id, self.ty, send, true),
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -124,7 +124,7 @@ impl WidgetId {
|
||||
impl<W> Drop for WidgetId<W> {
|
||||
fn drop(&mut self) {
|
||||
if self.counter.drop() && !self.is_static.load(Ordering::Acquire) {
|
||||
let _ = self.send.send(self.id.duplicate());
|
||||
let _ = self.send.send(self.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -194,7 +194,7 @@ impl<W: 'static, F: FnOnce(&mut Ui) -> WidgetId<W>> WidgetLike<IdFnTag> for F {
|
||||
|
||||
impl<W> StaticWidgetId<W> {
|
||||
pub fn to_id(&self, send: &Sender<Id>) -> WidgetId<W> {
|
||||
WidgetId::new(self.id.id(), self.ty, send.clone(), true)
|
||||
WidgetId::new(self.id, self.ty, send.clone(), true)
|
||||
}
|
||||
pub fn any(self) -> StaticWidgetId<AnyWidget> {
|
||||
// SAFETY: self is repr(C)
|
||||
|
||||
Reference in New Issue
Block a user