Use the color property of the window as a background

This commit is contained in:
Olivier Goffart 2020-12-18 16:54:19 +01:00
parent 61399e566a
commit b42c16851a
3 changed files with 10 additions and 10 deletions

View file

@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file.
### Added
- title property to the Window element
- color property to the Window element
## [0.0.4] - 2020-12-04

View file

@ -13,11 +13,7 @@ App := Window {
width: 500px;
height: 550px;
title: "SixtyFPS Gallery";
Rectangle {
color: #ecedeb;
width: parent.width;
height: parent.height;
}
VerticalLayout {
padding: 20px;

View file

@ -722,11 +722,14 @@ impl<Backend: GraphicsBackend> crate::eventloop::GenericWindow for GraphicsWindo
let window = map_state.as_mapped();
let mut backend = window.backend.borrow_mut();
let size = backend.window().inner_size();
let mut frame = backend.new_frame(
size.width,
size.height,
&RgbaColor { red: 255 as u8, green: 255, blue: 255, alpha: 255 }.into(),
);
let root_item = component.as_ref().get_item_ref(0);
let background_color = if let Some(window_item) = ItemRef::downcast_pin(root_item) {
crate::items::Window::FIELD_OFFSETS.color.apply_pin(window_item).get()
} else {
RgbaColor { red: 255 as u8, green: 255, blue: 255, alpha: 255 }.into()
};
let mut frame = backend.new_frame(size.width, size.height, &background_color);
crate::item_rendering::render_component_items(
&component_rc,
&mut frame,