make painter not stupid (size ctx is kinda tho)
This commit is contained in:
@@ -4,14 +4,14 @@ use crate::{
|
||||
};
|
||||
|
||||
pub struct Widgets<State> {
|
||||
pub updates: HashSet<WidgetId>,
|
||||
pub needs_redraw: HashSet<WidgetId>,
|
||||
vec: SlotVec<WidgetData<State>>,
|
||||
}
|
||||
|
||||
impl<State> Default for Widgets<State> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
updates: Default::default(),
|
||||
needs_redraw: Default::default(),
|
||||
vec: Default::default(),
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ impl<State> Default for Widgets<State> {
|
||||
|
||||
impl<State: 'static> Widgets<State> {
|
||||
pub fn has_updates(&self) -> bool {
|
||||
!self.updates.is_empty()
|
||||
!self.needs_redraw.is_empty()
|
||||
}
|
||||
|
||||
pub fn get_dyn(&self, id: WidgetId) -> Option<&dyn Widget<State>> {
|
||||
@@ -27,13 +27,13 @@ impl<State: 'static> Widgets<State> {
|
||||
}
|
||||
|
||||
pub fn get_dyn_mut(&mut self, id: WidgetId) -> Option<&mut dyn Widget<State>> {
|
||||
self.updates.insert(id);
|
||||
self.needs_redraw.insert(id);
|
||||
Some(self.vec.get_mut(id)?.widget.as_mut())
|
||||
}
|
||||
|
||||
/// get_dyn but dynamic borrow checking of widgets
|
||||
/// lets you do recursive (tree) operations, like the painter does
|
||||
pub(crate) fn get_dyn_dynamic(&self, id: WidgetId) -> WidgetWrapper<'_, State> {
|
||||
pub(crate) fn get_dyn_dynamic<'a>(&self, id: WidgetId) -> WidgetWrapper<'a, State> {
|
||||
// SAFETY: must guarantee no other mutable references to this widget exist
|
||||
// done through the borrow variable
|
||||
#[allow(mutable_transmutes)]
|
||||
|
||||
Reference in New Issue
Block a user