Make width
and height
required methods
This commit is contained in:
parent
2cbd5d60c4
commit
6cdf69e76b
@ -299,6 +299,14 @@ where
|
|||||||
A: Clone,
|
A: Clone,
|
||||||
Renderer: crate::Renderer,
|
Renderer: crate::Renderer,
|
||||||
{
|
{
|
||||||
|
fn width(&self) -> Length {
|
||||||
|
self.widget.width()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn height(&self) -> Length {
|
||||||
|
self.widget.height()
|
||||||
|
}
|
||||||
|
|
||||||
fn layout(
|
fn layout(
|
||||||
&self,
|
&self,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
@ -375,6 +383,14 @@ impl<'a, Message, Renderer> Widget<Message, Renderer>
|
|||||||
where
|
where
|
||||||
Renderer: crate::Renderer + renderer::Debugger,
|
Renderer: crate::Renderer + renderer::Debugger,
|
||||||
{
|
{
|
||||||
|
fn width(&self) -> Length {
|
||||||
|
self.element.widget.width()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn height(&self) -> Length {
|
||||||
|
self.element.widget.height()
|
||||||
|
}
|
||||||
|
|
||||||
fn layout(
|
fn layout(
|
||||||
&self,
|
&self,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
|
@ -69,6 +69,10 @@ pub trait Widget<Message, Renderer>: std::fmt::Debug
|
|||||||
where
|
where
|
||||||
Renderer: crate::Renderer,
|
Renderer: crate::Renderer,
|
||||||
{
|
{
|
||||||
|
fn width(&self) -> Length;
|
||||||
|
|
||||||
|
fn height(&self) -> Length;
|
||||||
|
|
||||||
/// Returns the [`Node`] of the [`Widget`].
|
/// Returns the [`Node`] of the [`Widget`].
|
||||||
///
|
///
|
||||||
/// This [`Node`] is used by the runtime to compute the [`Layout`] of the
|
/// This [`Node`] is used by the runtime to compute the [`Layout`] of the
|
||||||
@ -83,14 +87,6 @@ where
|
|||||||
limits: &layout::Limits,
|
limits: &layout::Limits,
|
||||||
) -> layout::Node;
|
) -> layout::Node;
|
||||||
|
|
||||||
fn width(&self) -> Length {
|
|
||||||
Length::Shrink
|
|
||||||
}
|
|
||||||
|
|
||||||
fn height(&self) -> Length {
|
|
||||||
Length::Shrink
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Draws the [`Widget`] using the associated `Renderer`.
|
/// Draws the [`Widget`] using the associated `Renderer`.
|
||||||
///
|
///
|
||||||
/// [`Widget`]: trait.Widget.html
|
/// [`Widget`]: trait.Widget.html
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
//! [`Class`]: enum.Class.html
|
//! [`Class`]: enum.Class.html
|
||||||
|
|
||||||
use crate::input::{mouse, ButtonState};
|
use crate::input::{mouse, ButtonState};
|
||||||
use crate::{layout, Element, Event, Hasher, Layout, Point, Widget};
|
use crate::{layout, Element, Event, Hasher, Layout, Length, Point, Widget};
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
|
|
||||||
pub use iced_core::button::State;
|
pub use iced_core::button::State;
|
||||||
@ -21,6 +21,14 @@ where
|
|||||||
Renderer: self::Renderer,
|
Renderer: self::Renderer,
|
||||||
Message: Clone + std::fmt::Debug,
|
Message: Clone + std::fmt::Debug,
|
||||||
{
|
{
|
||||||
|
fn width(&self) -> Length {
|
||||||
|
self.width
|
||||||
|
}
|
||||||
|
|
||||||
|
fn height(&self) -> Length {
|
||||||
|
Length::Shrink
|
||||||
|
}
|
||||||
|
|
||||||
fn layout(
|
fn layout(
|
||||||
&self,
|
&self,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
|
@ -14,6 +14,10 @@ where
|
|||||||
Length::Fill
|
Length::Fill
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn height(&self) -> Length {
|
||||||
|
Length::Shrink
|
||||||
|
}
|
||||||
|
|
||||||
fn layout(
|
fn layout(
|
||||||
&self,
|
&self,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
|
@ -15,6 +15,10 @@ where
|
|||||||
self.width
|
self.width
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn height(&self) -> Length {
|
||||||
|
self.height
|
||||||
|
}
|
||||||
|
|
||||||
fn layout(
|
fn layout(
|
||||||
&self,
|
&self,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
|
@ -15,6 +15,10 @@ where
|
|||||||
self.width
|
self.width
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn height(&self) -> Length {
|
||||||
|
self.height
|
||||||
|
}
|
||||||
|
|
||||||
fn layout(
|
fn layout(
|
||||||
&self,
|
&self,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
//! Display images in your user interface.
|
//! Display images in your user interface.
|
||||||
|
|
||||||
use crate::{layout, Element, Hasher, Layout, Point, Widget};
|
use crate::{layout, Element, Hasher, Layout, Length, Point, Widget};
|
||||||
|
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
|
|
||||||
@ -10,6 +10,14 @@ impl<Message, Renderer> Widget<Message, Renderer> for Image
|
|||||||
where
|
where
|
||||||
Renderer: self::Renderer,
|
Renderer: self::Renderer,
|
||||||
{
|
{
|
||||||
|
fn width(&self) -> Length {
|
||||||
|
self.width
|
||||||
|
}
|
||||||
|
|
||||||
|
fn height(&self) -> Length {
|
||||||
|
self.height
|
||||||
|
}
|
||||||
|
|
||||||
fn layout(
|
fn layout(
|
||||||
&self,
|
&self,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
|
@ -15,6 +15,10 @@ where
|
|||||||
Length::Fill
|
Length::Fill
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn height(&self) -> Length {
|
||||||
|
Length::Shrink
|
||||||
|
}
|
||||||
|
|
||||||
fn layout(
|
fn layout(
|
||||||
&self,
|
&self,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
|
@ -15,6 +15,10 @@ where
|
|||||||
self.width
|
self.width
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn height(&self) -> Length {
|
||||||
|
self.height
|
||||||
|
}
|
||||||
|
|
||||||
fn layout(
|
fn layout(
|
||||||
&self,
|
&self,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
|
@ -21,6 +21,14 @@ impl<'a, Message, Renderer> Widget<Message, Renderer>
|
|||||||
where
|
where
|
||||||
Renderer: self::Renderer + column::Renderer,
|
Renderer: self::Renderer + column::Renderer,
|
||||||
{
|
{
|
||||||
|
fn width(&self) -> Length {
|
||||||
|
Length::Fill
|
||||||
|
}
|
||||||
|
|
||||||
|
fn height(&self) -> Length {
|
||||||
|
self.height
|
||||||
|
}
|
||||||
|
|
||||||
fn layout(
|
fn layout(
|
||||||
&self,
|
&self,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
|
@ -19,6 +19,10 @@ where
|
|||||||
self.width
|
self.width
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn height(&self) -> Length {
|
||||||
|
Length::Shrink
|
||||||
|
}
|
||||||
|
|
||||||
fn layout(
|
fn layout(
|
||||||
&self,
|
&self,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
|
@ -13,6 +13,10 @@ where
|
|||||||
self.width
|
self.width
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn height(&self) -> Length {
|
||||||
|
self.height
|
||||||
|
}
|
||||||
|
|
||||||
fn layout(
|
fn layout(
|
||||||
&self,
|
&self,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
|
@ -15,6 +15,10 @@ where
|
|||||||
self.width
|
self.width
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn height(&self) -> Length {
|
||||||
|
Length::Shrink
|
||||||
|
}
|
||||||
|
|
||||||
fn layout(
|
fn layout(
|
||||||
&self,
|
&self,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
|
Loading…
Reference in New Issue
Block a user