mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 06:11:16 +00:00
Add an Opacity element that does nothing
This commit is contained in:
parent
dc12a22780
commit
ba2f2d5719
5 changed files with 87 additions and 1 deletions
|
@ -48,6 +48,7 @@ extern const cbindgen_private::ItemVTable TextInputVTable;
|
||||||
extern const cbindgen_private::ItemVTable ClipVTable;
|
extern const cbindgen_private::ItemVTable ClipVTable;
|
||||||
extern const cbindgen_private::ItemVTable BoxShadowVTable;
|
extern const cbindgen_private::ItemVTable BoxShadowVTable;
|
||||||
extern const cbindgen_private::ItemVTable RotateVTable;
|
extern const cbindgen_private::ItemVTable RotateVTable;
|
||||||
|
extern const cbindgen_private::ItemVTable OpacityVTable;
|
||||||
|
|
||||||
extern const cbindgen_private::ItemVTable NativeButtonVTable;
|
extern const cbindgen_private::ItemVTable NativeButtonVTable;
|
||||||
extern const cbindgen_private::ItemVTable NativeCheckBoxVTable;
|
extern const cbindgen_private::ItemVTable NativeCheckBoxVTable;
|
||||||
|
@ -153,6 +154,7 @@ using cbindgen_private::ClippedImage;
|
||||||
using cbindgen_private::Flickable;
|
using cbindgen_private::Flickable;
|
||||||
using cbindgen_private::FocusScope;
|
using cbindgen_private::FocusScope;
|
||||||
using cbindgen_private::Image;
|
using cbindgen_private::Image;
|
||||||
|
using cbindgen_private::Opacity;
|
||||||
using cbindgen_private::Path;
|
using cbindgen_private::Path;
|
||||||
using cbindgen_private::Rectangle;
|
using cbindgen_private::Rectangle;
|
||||||
using cbindgen_private::Rotate;
|
using cbindgen_private::Rotate;
|
||||||
|
|
|
@ -200,6 +200,15 @@ export Clip := _ {
|
||||||
//-default_size_binding:expands_to_parent_geometry
|
//-default_size_binding:expands_to_parent_geometry
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export Opacity := _ {
|
||||||
|
property <length> x;
|
||||||
|
property <length> y;
|
||||||
|
property <length> width;
|
||||||
|
property <length> height;
|
||||||
|
property <float> opacity;
|
||||||
|
//-default_size_binding:expands_to_parent_geometry
|
||||||
|
}
|
||||||
|
|
||||||
Row := _ {
|
Row := _ {
|
||||||
//-is_non_item_type
|
//-is_non_item_type
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,9 @@ When adding an item or a property, it needs to be kept in sync with different pl
|
||||||
- It needs to be changed in this module
|
- It needs to be changed in this module
|
||||||
- In the compiler: builtins.60
|
- In the compiler: builtins.60
|
||||||
- In the interpreter (new item only): dynamic_component.rs
|
- In the interpreter (new item only): dynamic_component.rs
|
||||||
- For the C++ code (new item only): the cbindgen.rs to export the new item, and the `using` declaration in sixtyfps.h
|
- For the C++ code (new item only):
|
||||||
|
- the cbindgen.rs to export the new item
|
||||||
|
- the `using` declaration in sixtyfps.h for the item and its vtable
|
||||||
- Don't forget to update the documentation
|
- Don't forget to update the documentation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -630,6 +632,77 @@ ItemVTable_static! {
|
||||||
pub static ClipVTable for Clip
|
pub static ClipVTable for Clip
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(FieldOffsets, Default, SixtyFPSElement)]
|
||||||
|
#[pin]
|
||||||
|
/// The Opacity Item is not meant to be used directly by the .60 code, instead, the `opacity: xxx` or `visible: false` should be used
|
||||||
|
pub struct Opacity {
|
||||||
|
// FIXME: this element shouldn't need these geometry property
|
||||||
|
pub x: Property<f32>,
|
||||||
|
pub y: Property<f32>,
|
||||||
|
pub width: Property<f32>,
|
||||||
|
pub height: Property<f32>,
|
||||||
|
pub opacity: Property<f32>,
|
||||||
|
pub cached_rendering_data: CachedRenderingData,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Item for Opacity {
|
||||||
|
fn init(self: Pin<&Self>, _window: &ComponentWindow) {}
|
||||||
|
|
||||||
|
fn geometry(self: Pin<&Self>) -> Rect {
|
||||||
|
euclid::rect(self.x(), self.y(), self.width(), self.height())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn layouting_info(self: Pin<&Self>, _window: &ComponentWindow) -> LayoutInfo {
|
||||||
|
LayoutInfo { horizontal_stretch: 1., vertical_stretch: 1., ..LayoutInfo::default() }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn implicit_size(self: Pin<&Self>, _window: &ComponentWindow) -> Size {
|
||||||
|
Default::default()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn input_event_filter_before_children(
|
||||||
|
self: Pin<&Self>,
|
||||||
|
_: MouseEvent,
|
||||||
|
_window: &ComponentWindow,
|
||||||
|
_self_rc: &ItemRc,
|
||||||
|
) -> InputEventFilterResult {
|
||||||
|
InputEventFilterResult::ForwardAndIgnore
|
||||||
|
}
|
||||||
|
|
||||||
|
fn input_event(
|
||||||
|
self: Pin<&Self>,
|
||||||
|
_: MouseEvent,
|
||||||
|
_window: &ComponentWindow,
|
||||||
|
_self_rc: &ItemRc,
|
||||||
|
) -> InputEventResult {
|
||||||
|
InputEventResult::EventIgnored
|
||||||
|
}
|
||||||
|
|
||||||
|
fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &ComponentWindow) -> KeyEventResult {
|
||||||
|
KeyEventResult::EventIgnored
|
||||||
|
}
|
||||||
|
|
||||||
|
fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &ComponentWindow) {}
|
||||||
|
|
||||||
|
fn render(self: Pin<&Self>, backend: &mut ItemRendererRef) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ItemConsts for Opacity {
|
||||||
|
const cached_rendering_data_offset: const_field_offset::FieldOffset<
|
||||||
|
Opacity,
|
||||||
|
CachedRenderingData,
|
||||||
|
> = Opacity::FIELD_OFFSETS.cached_rendering_data.as_unpinned_projection();
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemVTable_static! {
|
||||||
|
/// The VTable for `Opacity`
|
||||||
|
#[no_mangle]
|
||||||
|
pub static OpacityVTable for Opacity
|
||||||
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(FieldOffsets, Default, SixtyFPSElement)]
|
#[derive(FieldOffsets, Default, SixtyFPSElement)]
|
||||||
#[pin]
|
#[pin]
|
||||||
|
|
|
@ -623,6 +623,7 @@ fn generate_component<'id>(
|
||||||
rtti_for::<Clip>(),
|
rtti_for::<Clip>(),
|
||||||
rtti_for::<BoxShadow>(),
|
rtti_for::<BoxShadow>(),
|
||||||
rtti_for::<Rotate>(),
|
rtti_for::<Rotate>(),
|
||||||
|
rtti_for::<Opacity>(),
|
||||||
]
|
]
|
||||||
.iter()
|
.iter()
|
||||||
.cloned(),
|
.cloned(),
|
||||||
|
|
|
@ -72,6 +72,7 @@ fn gen_corelib(root_dir: &Path, include_dir: &Path) -> anyhow::Result<()> {
|
||||||
"BoxShadow",
|
"BoxShadow",
|
||||||
"FillRule",
|
"FillRule",
|
||||||
"Rotate",
|
"Rotate",
|
||||||
|
"Opacity",
|
||||||
]
|
]
|
||||||
.iter()
|
.iter()
|
||||||
.map(|x| x.to_string())
|
.map(|x| x.to_string())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue