gpui: Add opacity
to support transparency of the entire element (#17132)
Release Notes: - N/A --- Add this for let GPUI element to support fade in-out animation. ## Platform test - [x] macOS - [x] blade `cargo run -p gpui --example opacity --features macos-blade` ## Usage ```rs div() .opacity(0.5) .bg(gpui::black()) .text_color(gpui::black()) .child("Hello world") ``` This will apply the `opacity` it self and all children to use `opacity` value to render colors. ## Example ``` cargo run -p gpui --example opacity cargo run -p gpui --example opacity --features macos-blade ``` <img width="612" alt="image" src="https://github.com/user-attachments/assets/f1da87ed-31f5-4b55-a023-39e8ee1ba349">
This commit is contained in:
parent
072513f59f
commit
a092ff0c4f
10 changed files with 297 additions and 36 deletions
|
@ -640,16 +640,19 @@ impl From<MonochromeSprite> for Primitive {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[repr(C)]
|
||||
pub(crate) struct PolychromeSprite {
|
||||
pub order: DrawOrder,
|
||||
pub pad: u32, // align to 8 bytes
|
||||
pub grayscale: bool,
|
||||
pub opacity: f32,
|
||||
pub bounds: Bounds<ScaledPixels>,
|
||||
pub content_mask: ContentMask<ScaledPixels>,
|
||||
pub corner_radii: Corners<ScaledPixels>,
|
||||
pub tile: AtlasTile,
|
||||
}
|
||||
impl Eq for PolychromeSprite {}
|
||||
|
||||
impl Ord for PolychromeSprite {
|
||||
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue