remove state generic from a lot of things

This commit is contained in:
2025-12-17 21:37:55 -05:00
parent 7e6369029f
commit 30bc55c78e
45 changed files with 740 additions and 856 deletions

View File

@@ -7,8 +7,8 @@ use crate::{
};
/// makes your surfaces look pretty
pub struct Painter<'a, 'b, State> {
pub(super) state: &'a mut DrawState<'b, State>,
pub struct Painter<'a, 'b> {
pub(super) state: &'a mut DrawState<'b>,
pub(super) region: UiRegion,
pub(super) mask: MaskIdx,
@@ -19,7 +19,7 @@ pub struct Painter<'a, 'b, State> {
pub(super) id: WidgetId,
}
impl<'a, 'c, State: 'static> Painter<'a, 'c, State> {
impl<'a, 'c> Painter<'a, 'c> {
fn primitive_at<P: Primitive>(&mut self, primitive: P, region: UiRegion) {
let h = self.state.layers.write(
self.layer,
@@ -52,17 +52,17 @@ impl<'a, 'c, State: 'static> Painter<'a, 'c, State> {
}
/// Draws a widget within this widget's region.
pub fn widget<W: ?Sized>(&mut self, id: &WidgetHandle<State, W>) {
pub fn widget<W: ?Sized>(&mut self, id: &WidgetHandle<W>) {
self.widget_at(id, self.region);
}
/// Draws a widget somewhere within this one.
/// Useful for drawing child widgets in select areas.
pub fn widget_within<W: ?Sized>(&mut self, id: &WidgetHandle<State, W>, region: UiRegion) {
pub fn widget_within<W: ?Sized>(&mut self, id: &WidgetHandle<W>, region: UiRegion) {
self.widget_at(id, region.within(&self.region));
}
fn widget_at<W: ?Sized>(&mut self, id: &WidgetHandle<State, W>, region: UiRegion) {
fn widget_at<W: ?Sized>(&mut self, id: &WidgetHandle<W>, region: UiRegion) {
self.children.push(id.id());
self.state
.draw_inner(self.layer, id.id(), region, Some(self.id), self.mask, None);
@@ -95,15 +95,11 @@ impl<'a, 'c, State: 'static> Painter<'a, 'c, State> {
self.region
}
pub fn size<W: ?Sized + Widget<State>>(&mut self, id: &WidgetHandle<State, W>) -> Size {
pub fn size<W: ?Sized + Widget>(&mut self, id: &WidgetHandle<W>) -> Size {
self.size_ctx().size(id)
}
pub fn len_axis<W: ?Sized + Widget<State>>(
&mut self,
id: &WidgetHandle<State, W>,
axis: Axis,
) -> Len {
pub fn len_axis<W: ?Sized + Widget>(&mut self, id: &WidgetHandle<W>, axis: Axis) -> Len {
match axis {
Axis::X => self.size_ctx().width(id),
Axis::Y => self.size_ctx().height(id),
@@ -138,7 +134,7 @@ impl<'a, 'c, State: 'static> Painter<'a, 'c, State> {
&self.id
}
pub fn size_ctx(&mut self) -> SizeCtx<'_, State> {
pub fn size_ctx(&mut self) -> SizeCtx<'_> {
self.state.size_ctx(self.id, self.region.size())
}
}