From f3f8af39d42dc9636fea791cab15a7c971af4ac2 Mon Sep 17 00:00:00 2001 From: Joscha Date: Tue, 5 Mar 2024 00:21:48 +0100 Subject: [PATCH] Use Color in View --- showbits-common/src/view.rs | 6 ++++-- showbits-common/src/widgets/background.rs | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/showbits-common/src/view.rs b/showbits-common/src/view.rs index d659d32..0e5e1c0 100644 --- a/showbits-common/src/view.rs +++ b/showbits-common/src/view.rs @@ -1,4 +1,4 @@ -use crate::{Buffer, Rect, Vec2}; +use crate::{Buffer, Color, Rect, Vec2}; // TODO Add Orientation (from inkfo) @@ -38,10 +38,12 @@ impl<'a, C> View<'a, C> { pub fn at(&self, pos: Vec2) -> Option<&C> { self.buffer.at(self.pos_to_buffer_pos(pos)) } +} +impl View<'_, C> { pub fn set(&mut self, pos: Vec2, color: C) { if let Some(pixel) = self.buffer.at_mut(self.pos_to_buffer_pos(pos)) { - *pixel = color; + *pixel = color.over(*pixel); } } } diff --git a/showbits-common/src/widgets/background.rs b/showbits-common/src/widgets/background.rs index c3f49b3..5351d80 100644 --- a/showbits-common/src/widgets/background.rs +++ b/showbits-common/src/widgets/background.rs @@ -1,4 +1,4 @@ -use crate::{BoxedWidget, Vec2, Widget}; +use crate::{BoxedWidget, Color, Vec2, Widget}; pub struct Background { inner: BoxedWidget, @@ -11,7 +11,7 @@ impl Background { } } -impl Widget for Background { +impl Widget for Background { fn size(&self, max_width: Option, max_height: Option) -> crate::Vec2 { self.inner.size(max_width, max_height) }