fixed bug with defaut transparency and passing background color
This commit is contained in:
1 parent
7a1d8f0532
commit
5a00816fc9
2 files changed
+5
-5
No files matched your search
+3
-1
@@ -90,7 +90,7 @@ pub fn render_vnode<'a>(
|
|||||||
VNode::Element(el) => {
|
VNode::Element(el) => {
|
||||||
let area = Rect::new(*x as u16, *y as u16, *width as u16, *height as u16);
|
let area = Rect::new(*x as u16, *y as u16, *width as u16, *height as u16);
|
||||||
|
|
||||||
let new_style = node.block_style.merge(*style);
|
let mut new_style = node.block_style.merge(*style);
|
||||||
node.block_style = new_style;
|
node.block_style = new_style;
|
||||||
|
|
||||||
// the renderer will panic if a node is rendered out of range even if the size is zero
|
// the renderer will panic if a node is rendered out of range even if the size is zero
|
||||||
@@ -98,6 +98,8 @@ pub fn render_vnode<'a>(
|
|||||||
frame.render_widget(WidgetWithContext::new(node, cfg), area);
|
frame.render_widget(WidgetWithContext::new(node, cfg), area);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// do not pass background color to children
|
||||||
|
new_style.bg = None;
|
||||||
for el in el.children {
|
for el in el.children {
|
||||||
render_vnode(frame, layout, layouts, vdom, el, &new_style, cfg);
|
render_vnode(frame, layout, layouts, vdom, el, &new_style, cfg);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-4
@@ -26,8 +26,6 @@ impl RinkColor {
|
|||||||
} else {
|
} else {
|
||||||
if self.alpha == 0.0 {
|
if self.alpha == 0.0 {
|
||||||
other
|
other
|
||||||
} else if other == Color::Reset {
|
|
||||||
self.color
|
|
||||||
} else {
|
} else {
|
||||||
let [sr, sg, sb] = to_rgb(self.color);
|
let [sr, sg, sb] = to_rgb(self.color);
|
||||||
let [or, og, ob] = to_rgb(other);
|
let [or, og, ob] = to_rgb(other);
|
||||||
@@ -228,7 +226,7 @@ impl FromStr for RinkColor {
|
|||||||
})
|
})
|
||||||
} else if color.starts_with("rgb(") {
|
} else if color.starts_with("rgb(") {
|
||||||
let color_values = color[4..].trim_end_matches(')');
|
let color_values = color[4..].trim_end_matches(')');
|
||||||
if color.matches(',').count() == 4 {
|
if color.matches(',').count() == 3 {
|
||||||
let (alpha, rgb_values) =
|
let (alpha, rgb_values) =
|
||||||
color_values.rsplit_once(',').ok_or(ParseColorError)?;
|
color_values.rsplit_once(',').ok_or(ParseColorError)?;
|
||||||
if let Ok(a) = alpha.parse() {
|
if let Ok(a) = alpha.parse() {
|
||||||
@@ -324,7 +322,6 @@ fn to_rgb(c: Color) -> [u8; 3] {
|
|||||||
let r = ((v as u16 / 36) * 255 + 3) / 6;
|
let r = ((v as u16 / 36) * 255 + 3) / 6;
|
||||||
let g = (((v as u16 % 36) / 6) * 255 + 3) / 6;
|
let g = (((v as u16 % 36) / 6) * 255 + 3) / 6;
|
||||||
let b = ((v as u16 % 6) * 255 + 3) / 6;
|
let b = ((v as u16 % 6) * 255 + 3) / 6;
|
||||||
let vals = [v / 36, (v % 36) / 6, v % 6];
|
|
||||||
[r as u8, g as u8, b as u8]
|
[r as u8, g as u8, b as u8]
|
||||||
}
|
}
|
||||||
232..=255 => {
|
232..=255 => {
|
||||||
@@ -334,6 +331,7 @@ fn to_rgb(c: Color) -> [u8; 3] {
|
|||||||
// rink will never generate these colors, but they might be on the screen from another program
|
// rink will never generate these colors, but they might be on the screen from another program
|
||||||
_ => [0, 0, 0],
|
_ => [0, 0, 0],
|
||||||
},
|
},
|
||||||
|
Color::Reset => [0, 0, 0],
|
||||||
_ => todo!("{c:?}"),
|
_ => todo!("{c:?}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user