remove context generic
This commit is contained in:
@@ -18,10 +18,9 @@ struct State {
|
||||
id: Option<Id>,
|
||||
}
|
||||
|
||||
pub struct Painter<'a, Ctx: 'static> {
|
||||
widgets: &'a Widgets<Ctx>,
|
||||
ctx: &'a mut Ctx,
|
||||
sensors_map: &'a SensorMap<Ctx>,
|
||||
pub struct Painter<'a> {
|
||||
widgets: &'a Widgets,
|
||||
sensors_map: &'a SensorMap,
|
||||
pub(super) active: &'a mut Active,
|
||||
pub(super) primitives: &'a mut Primitives,
|
||||
textures: &'a mut Textures,
|
||||
@@ -31,13 +30,12 @@ pub struct Painter<'a, Ctx: 'static> {
|
||||
state: State,
|
||||
}
|
||||
|
||||
impl<'a, Ctx> Painter<'a, Ctx> {
|
||||
impl<'a> Painter<'a> {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub(super) fn new(
|
||||
nodes: &'a Widgets<Ctx>,
|
||||
nodes: &'a Widgets,
|
||||
primitives: &'a mut Primitives,
|
||||
ctx: &'a mut Ctx,
|
||||
sensors_map: &'a SensorMap<Ctx>,
|
||||
sensors_map: &'a SensorMap,
|
||||
active: &'a mut Active,
|
||||
text: &'a mut TextData,
|
||||
textures: &'a mut Textures,
|
||||
@@ -45,7 +43,6 @@ impl<'a, Ctx> Painter<'a, Ctx> {
|
||||
) -> Self {
|
||||
Self {
|
||||
widgets: nodes,
|
||||
ctx,
|
||||
active,
|
||||
sensors_map,
|
||||
primitives,
|
||||
@@ -68,34 +65,22 @@ impl<'a, Ctx> Painter<'a, Ctx> {
|
||||
}
|
||||
|
||||
/// Draws a widget within this widget's region.
|
||||
pub fn draw<W>(&mut self, id: &WidgetId<W>)
|
||||
where
|
||||
Ctx: 'static,
|
||||
{
|
||||
pub fn draw<W>(&mut self, id: &WidgetId<W>) {
|
||||
self.draw_at(id, self.state.region);
|
||||
}
|
||||
|
||||
/// Draws a widget somewhere within this one.
|
||||
/// Useful for drawing child widgets in select areas.
|
||||
pub fn draw_within<W>(&mut self, id: &WidgetId<W>, region: UiRegion)
|
||||
where
|
||||
Ctx: 'static,
|
||||
{
|
||||
pub fn draw_within<W>(&mut self, id: &WidgetId<W>, region: UiRegion) {
|
||||
self.draw_at(id, region.within(&self.state.region));
|
||||
}
|
||||
|
||||
/// Draws a widget in an arbitrary region.
|
||||
pub fn draw_at<W>(&mut self, id: &WidgetId<W>, region: UiRegion)
|
||||
where
|
||||
Ctx: 'static,
|
||||
{
|
||||
pub fn draw_at<W>(&mut self, id: &WidgetId<W>, region: UiRegion) {
|
||||
self.draw_raw_at(&id.id, region);
|
||||
}
|
||||
|
||||
fn draw_raw_at(&mut self, id: &Id, region: UiRegion)
|
||||
where
|
||||
Ctx: 'static,
|
||||
{
|
||||
fn draw_raw_at(&mut self, id: &Id, region: UiRegion) {
|
||||
if self.active.widgets.contains_key(id) {
|
||||
panic!("widget drawn twice!");
|
||||
}
|
||||
@@ -158,10 +143,6 @@ impl<'a, Ctx> Painter<'a, Ctx> {
|
||||
self.state.region
|
||||
}
|
||||
|
||||
pub fn ctx(&mut self) -> &mut Ctx {
|
||||
self.ctx
|
||||
}
|
||||
|
||||
pub fn region_size(&self) -> Vec2 {
|
||||
self.state.region.in_size(self.screen_size)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user