replace free with max and min constraint

This commit is contained in:
figsoda 2020-10-30 17:43:39 -04:00
parent f6bf51fbf5
commit 62376aaf90
3 changed files with 10 additions and 6 deletions

View file

@ -5,7 +5,7 @@ Config(
Ratio(4, Textbox(Text("Artist"))),
Ratio(4, Textbox(Text("Album"))),
])),
Free(Queue(
Min(0, Queue(
columns: [
Ratio(5, QueueTitle),
Ratio(4, QueueArtist),

View file

@ -36,7 +36,8 @@ pub enum Widget {
#[derive(Debug, Deserialize)]
pub enum Constrained<T> {
Free(T),
Max(u16, T),
Min(u16, T),
Fixed(u16, T),
Ratio(u32, T),
}

View file

@ -34,8 +34,9 @@ pub fn render(
for x in xs {
let (w, constraint) = match x {
Constrained::Free(w) => (w, Constraint::Min(1)),
Constrained::Fixed(n, w) => (w, Constraint::Length(*n)),
Constrained::Max(n, w) => (w, Constraint::Max(*n)),
Constrained::Min(n, w) => (w, Constraint::Min(*n)),
Constrained::Ratio(n, w) => (w, Constraint::Ratio(*n, denom)),
};
ws.push(w);
@ -68,8 +69,9 @@ pub fn render(
for x in xs {
let (w, constraint) = match x {
Constrained::Free(w) => (w, Constraint::Min(1)),
Constrained::Fixed(n, w) => (w, Constraint::Length(*n)),
Constrained::Max(n, w) => (w, Constraint::Max(*n)),
Constrained::Min(n, w) => (w, Constraint::Min(*n)),
Constrained::Ratio(n, w) => (w, Constraint::Ratio(*n, denom)),
};
ws.push(w);
@ -118,8 +120,9 @@ pub fn render(
for column in columns {
let (xs, constraint) = match column {
Constrained::Free(xs) => (xs, Constraint::Min(1)),
Constrained::Fixed(n, xs) => (xs, Constraint::Length(*n)),
Constrained::Fixed(n, w) => (w, Constraint::Length(*n)),
Constrained::Max(n, w) => (w, Constraint::Max(*n)),
Constrained::Min(n, w) => (w, Constraint::Min(*n)),
Constrained::Ratio(n, xs) => (xs, Constraint::Ratio(*n, denom)),
};
let mut items = Vec::with_capacity(len);