made painter actually how I wanted it (draw now takes in an owned painter)
This commit is contained in:
@@ -6,9 +6,8 @@ pub struct Regioned {
|
||||
}
|
||||
|
||||
impl<Ctx: 'static> Widget<Ctx> for Regioned {
|
||||
fn draw(&self, painter: &mut Painter<Ctx>) {
|
||||
painter.region.select(&self.region);
|
||||
painter.draw_inner(&self.inner);
|
||||
fn draw(&self, mut painter: Painter<Ctx>) {
|
||||
painter.draw_within(&self.inner, self.region);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
use image::DynamicImage;
|
||||
|
||||
use crate::{Color, TextureHandle, Widget, WidgetFnRet, render::RectPrimitive};
|
||||
use crate::{Color, Painter, TextureHandle, Widget, WidgetFnRet, render::RectPrimitive};
|
||||
|
||||
pub struct Image {
|
||||
handle: Option<TextureHandle>,
|
||||
}
|
||||
|
||||
impl<Ctx> Widget<Ctx> for Image {
|
||||
fn draw(&self, painter: &mut crate::Painter<Ctx>) {
|
||||
fn draw(&self, mut painter: 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, painter: &mut Painter<Ctx>) {
|
||||
fn draw(&self, mut painter: 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, painter: &mut Painter<Ctx>) {
|
||||
fn draw(&self, mut painter: Painter<Ctx>) {
|
||||
let total = self.sums();
|
||||
let mut start = UIScalar::min();
|
||||
for (child, length) in &self.children {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use crate::{Widget, WidgetId};
|
||||
use crate::{Painter, Widget, WidgetId};
|
||||
|
||||
pub struct Stack {
|
||||
pub children: Vec<WidgetId>,
|
||||
}
|
||||
|
||||
impl<Ctx> Widget<Ctx> for Stack {
|
||||
fn draw(&self, painter: &mut crate::Painter<Ctx>) {
|
||||
fn draw(&self, mut painter: Painter<Ctx>) {
|
||||
for child in &self.children {
|
||||
painter.draw(child);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user