mirror of
https://github.com/danbulant/cushy
synced 2026-06-06 08:01:48 +00:00
parent
5b928327dc
commit
02e60e1049
3 changed files with 43 additions and 6 deletions
10
CHANGELOG.md
10
CHANGELOG.md
|
|
@ -47,6 +47,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
current outer size.
|
current outer size.
|
||||||
- `Graphics::draw_texture` and `Graphics::draw_textured_shape` now both accept
|
- `Graphics::draw_texture` and `Graphics::draw_textured_shape` now both accept
|
||||||
an opactiy parameter controlling how opaque the texture should be rendered at.
|
an opactiy parameter controlling how opaque the texture should be rendered at.
|
||||||
|
- `MakeWigetList` has had some of its functions moved to a new trait:
|
||||||
|
`IntoWidgetList`. A blanket implementation of `MakeWidgetList` is provided
|
||||||
|
for types that implement `IntoWidgetList`. In general, compilation errors
|
||||||
|
related to this change can be fixed by importing `IntoWidgetList`.
|
||||||
|
|
||||||
|
- `MakeWidgetList::into_rows` -> `IntoWidgetList::into_rows`
|
||||||
|
- `MakeWidgetList::into_columns` -> `IntoWidgetList::into_columns`
|
||||||
|
- `MakeWidgetList::into_layers` -> `IntoWidgetList::into_layers`
|
||||||
|
- `MakeWidgetList::into_wrap` -> `IntoWidgetList::into_wrap`
|
||||||
|
- `MakeWidgetList::into_list` -> `IntoWidgetList::into_list`
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use std::path::PathBuf;
|
||||||
|
|
||||||
use cushy::dialog::{FilePicker, PickFile};
|
use cushy::dialog::{FilePicker, PickFile};
|
||||||
use cushy::value::{Destination, Dynamic, Source};
|
use cushy::value::{Destination, Dynamic, Source};
|
||||||
use cushy::widget::{MakeWidget, MakeWidgetList};
|
use cushy::widget::{IntoWidgetList, MakeWidget};
|
||||||
use cushy::widgets::button::ButtonClick;
|
use cushy::widgets::button::ButtonClick;
|
||||||
use cushy::widgets::checkbox::Checkable;
|
use cushy::widgets::checkbox::Checkable;
|
||||||
use cushy::widgets::layers::Modal;
|
use cushy::widgets::layers::Modal;
|
||||||
|
|
|
||||||
|
|
@ -2395,37 +2395,64 @@ pub trait MakeWidgetList: Sized {
|
||||||
list.push(widget);
|
list.push(widget);
|
||||||
list
|
list
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A type that can be converted to a `Value<WidgetList>`.
|
||||||
|
pub trait IntoWidgetList: Sized {
|
||||||
|
/// Returns this list of widgets as a `Value<WidgetList>`.
|
||||||
|
fn into_widget_list(self) -> Value<WidgetList>;
|
||||||
|
|
||||||
/// Returns `self` as a vertical [`Stack`] of rows.
|
/// Returns `self` as a vertical [`Stack`] of rows.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
fn into_rows(self) -> Stack {
|
fn into_rows(self) -> Stack {
|
||||||
Stack::rows(self.make_widget_list())
|
Stack::rows(self.into_widget_list())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `self` as a horizontal [`Stack`] of columns.
|
/// Returns `self` as a horizontal [`Stack`] of columns.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
fn into_columns(self) -> Stack {
|
fn into_columns(self) -> Stack {
|
||||||
Stack::columns(self.make_widget_list())
|
Stack::columns(self.into_widget_list())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `self` as [`Layers`], with the widgets being stacked in the Z
|
/// Returns `self` as [`Layers`], with the widgets being stacked in the Z
|
||||||
/// direction.
|
/// direction.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
fn into_layers(self) -> Layers {
|
fn into_layers(self) -> Layers {
|
||||||
Layers::new(self.make_widget_list())
|
Layers::new(self.into_widget_list())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a [`Wrap`] that lays the children out horizontally, wrapping
|
/// Returns a [`Wrap`] that lays the children out horizontally, wrapping
|
||||||
/// into additional rows as needed.
|
/// into additional rows as needed.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
fn into_wrap(self) -> Wrap {
|
fn into_wrap(self) -> Wrap {
|
||||||
Wrap::new(self.make_widget_list())
|
Wrap::new(self.into_widget_list())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `self` as an unordered [`List`].
|
/// Returns `self` as an unordered [`List`].
|
||||||
#[must_use]
|
#[must_use]
|
||||||
fn into_list(self) -> List {
|
fn into_list(self) -> List {
|
||||||
List::new(self.make_widget_list())
|
List::new(self.into_widget_list())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> IntoWidgetList for T
|
||||||
|
where
|
||||||
|
T: MakeWidgetList,
|
||||||
|
{
|
||||||
|
fn into_widget_list(self) -> Value<WidgetList> {
|
||||||
|
Value::Constant(self.make_widget_list())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl IntoWidgetList for Dynamic<WidgetList> {
|
||||||
|
fn into_widget_list(self) -> Value<WidgetList> {
|
||||||
|
Value::Dynamic(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl IntoWidgetList for Value<WidgetList> {
|
||||||
|
fn into_widget_list(self) -> Value<WidgetList> {
|
||||||
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue