I forgot why I did it the other way lol (revert)
This commit is contained in:
@@ -6,7 +6,7 @@ pub struct Regioned {
|
||||
}
|
||||
|
||||
impl<Ctx: 'static> Widget<Ctx> for Regioned {
|
||||
fn draw(&self, mut painter: Painter<Ctx>) {
|
||||
fn draw(&self, painter: &mut Painter<Ctx>) {
|
||||
painter.draw_within(&self.inner, self.region);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ pub struct Image {
|
||||
}
|
||||
|
||||
impl<Ctx> Widget<Ctx> for Image {
|
||||
fn draw(&self, mut painter: Painter<Ctx>) {
|
||||
fn draw(&self, painter: &mut Painter<Ctx>) {
|
||||
if let Some(handle) = &self.handle {
|
||||
painter.draw_texture(handle);
|
||||
} else {
|
||||
|
||||
@@ -28,7 +28,7 @@ impl Rect {
|
||||
}
|
||||
|
||||
impl<Ctx> Widget<Ctx> for Rect {
|
||||
fn draw(&self, mut painter: Painter<Ctx>) {
|
||||
fn draw(&self, painter: &mut Painter<Ctx>) {
|
||||
painter.write(RectPrimitive {
|
||||
color: self.color,
|
||||
radius: self.radius,
|
||||
|
||||
@@ -6,7 +6,7 @@ pub struct Span {
|
||||
}
|
||||
|
||||
impl<Ctx: 'static> Widget<Ctx> for Span {
|
||||
fn draw(&self, mut painter: Painter<Ctx>) {
|
||||
fn draw(&self, painter: &mut Painter<Ctx>) {
|
||||
let total = self.sums();
|
||||
let mut start = UIScalar::min();
|
||||
for (child, length) in &self.children {
|
||||
|
||||
@@ -5,7 +5,7 @@ pub struct Stack {
|
||||
}
|
||||
|
||||
impl<Ctx> Widget<Ctx> for Stack {
|
||||
fn draw(&self, mut painter: Painter<Ctx>) {
|
||||
fn draw(&self, painter: &mut Painter<Ctx>) {
|
||||
for child in &self.children {
|
||||
painter.draw(child);
|
||||
}
|
||||
|
||||
@@ -60,20 +60,22 @@ impl<'a, Ctx> Painter<'a, Ctx> {
|
||||
if self.sensors_map.get(&id.id).is_some() {
|
||||
self.active_sensors.push((region, id.id.duplicate()));
|
||||
}
|
||||
self.nodes.get_dyn(id).draw(Painter {
|
||||
nodes: self.nodes,
|
||||
ctx: self.ctx,
|
||||
sensors_map: self.sensors_map,
|
||||
active_sensors: self.active_sensors,
|
||||
primitives: self.primitives,
|
||||
region,
|
||||
});
|
||||
// &mut self is passed to avoid copying all of the "static" pointers in self
|
||||
// so need to save non static data here
|
||||
let old = self.region;
|
||||
self.region = region;
|
||||
self.nodes.get_dyn(id).draw(self);
|
||||
self.region = old;
|
||||
}
|
||||
|
||||
pub fn draw_texture(&mut self, handle: &TextureHandle) {
|
||||
self.write(handle.inner);
|
||||
}
|
||||
|
||||
pub fn region(&self) -> UiRegion {
|
||||
self.region
|
||||
}
|
||||
|
||||
pub fn ctx(&mut self) -> &mut Ctx {
|
||||
self.ctx
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::{Painter, Ui, WidgetId, WidgetIdFnRet};
|
||||
use std::{any::Any, marker::PhantomData};
|
||||
|
||||
pub trait Widget<Ctx>: Any {
|
||||
fn draw(&self, painter: Painter<Ctx>);
|
||||
fn draw(&self, painter: &mut Painter<Ctx>);
|
||||
}
|
||||
|
||||
pub struct WidgetTag;
|
||||
|
||||
Reference in New Issue
Block a user