Struct zng_wgt_style::Style
source · pub struct Style(/* private fields */);
Expand description
W
Represents a set of properties that can be applied to any styleable widget.
Style can be instantiated using the same syntax as any widget, but it produces a StyleBuilder
instance instead of a widget. Widgets that have StyleMix<P>
can be modified using properties
defined in a style, the properties are dynamically spliced into each widget instance.
§Extend/Replace
Style instances extend the contextual style by default, meaning all properties set on the style are inserted over
the parent style, so properties set on the contextual style that are not reset in the new style are retained. You
can set replace
on a style to true
to fully remove all contextual properties and only use the
new style properties.
§Inherit Style
Note that you can declare a custom style widget using the same inheritance mechanism of normal widgets, as long
as they build to StyleBuilder
. This is different from the extend/replace mechanism as it operates on the style
type, not the instances.
Implementations§
source§impl Style
impl Style
sourcepub fn widget_new() -> Self
pub fn widget_new() -> Self
Start building a new instance.
sourcepub fn widget_type() -> WidgetType
pub fn widget_type() -> WidgetType
Gets the widget type info.
source§impl Style
impl Style
sourcepub fn widget_build(&mut self) -> StyleBuilder
pub fn widget_build(&mut self) -> StyleBuilder
Build the style.
Methods from Deref<Target = NonWidgetBase>§
sourcepub fn widget_builder(&mut self) -> &mut WidgetBuilder
pub fn widget_builder(&mut self) -> &mut WidgetBuilder
Returns a mutable reference to the widget builder.
sourcepub fn widget_when(&mut self) -> Option<&mut WhenInfo>
pub fn widget_when(&mut self) -> Option<&mut WhenInfo>
Returns a mutable reference to the when
block if called inside a when block.
sourcepub fn widget_take(&mut self) -> WidgetBuilder
pub fn widget_take(&mut self) -> WidgetBuilder
Takes the widget builder, finishing the widget macro build.
After this call trying to set a property using self
will panic,
the returned builder can still be manipulated directly.
sourcepub fn widget_build(&mut self) -> WidgetBuilder
pub fn widget_build(&mut self) -> WidgetBuilder
Finishes the build.
This is the fallback build that simply returns the builder, inheritors should override this method.
sourcepub fn widget_importance(&mut self) -> &mut Importance
pub fn widget_importance(&mut self) -> &mut Importance
Returns a mutable reference to the importance of the next property assigns, unsets or when blocks.
Note that during the widget_intrinsic
call this is Importance::WIDGET
and after it is Importance::INSTANCE
.
sourcepub fn start_when_block(
&mut self,
inputs: Box<[WhenInput]>,
state: Box<dyn VarBoxed<bool>>,
expr: &'static str,
location: SourceLocation,
)
pub fn start_when_block( &mut self, inputs: Box<[WhenInput]>, state: Box<dyn VarBoxed<bool>>, expr: &'static str, location: SourceLocation, )
Start building a when
block, all properties set after this call are pushed in the when block.
sourcepub fn end_when_block(&mut self)
pub fn end_when_block(&mut self)
End the current when
block, all properties set after this call are pushed in the widget.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Style
impl !RefUnwindSafe for Style
impl Send for Style
impl !Sync for Style
impl Unpin for Style
impl !UnwindSafe for Style
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more