use Color's From impl in more places
This commit is contained in:
parent
58bd0824bf
commit
e7bd24c13e
7 changed files with 49 additions and 139 deletions
|
|
@ -444,12 +444,7 @@ fn explain_layout(
|
||||||
// TODO: Draw borders instead
|
// TODO: Draw borders instead
|
||||||
primitives.push(Primitive::Quad {
|
primitives.push(Primitive::Quad {
|
||||||
bounds: layout.bounds(),
|
bounds: layout.bounds(),
|
||||||
background: Background::Color(Color {
|
background: Background::Color([0.0, 0.0, 0.0, 0.05].into()),
|
||||||
r: 0.0,
|
|
||||||
g: 0.0,
|
|
||||||
b: 0.0,
|
|
||||||
a: 0.05,
|
|
||||||
}),
|
|
||||||
border_radius: 0,
|
border_radius: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{Primitive, Renderer};
|
use crate::{Primitive, Renderer};
|
||||||
use iced_native::{
|
use iced_native::{
|
||||||
button, Align, Background, Button, Color, Layout, Length, MouseCursor,
|
button, Align, Background, Button, Layout, Length, MouseCursor,
|
||||||
Node, Point, Rectangle, Style,
|
Node, Point, Rectangle, Style,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -53,23 +53,15 @@ impl button::Renderer for Renderer {
|
||||||
y: bounds.y + shadow_offset,
|
y: bounds.y + shadow_offset,
|
||||||
..bounds
|
..bounds
|
||||||
},
|
},
|
||||||
background: Background::Color(Color {
|
background: Background::Color(
|
||||||
r: 0.0,
|
[0.0, 0.0, 0.0, 0.5].into(),
|
||||||
b: 0.0,
|
),
|
||||||
g: 0.0,
|
|
||||||
a: 0.5,
|
|
||||||
}),
|
|
||||||
border_radius: button.border_radius,
|
border_radius: button.border_radius,
|
||||||
},
|
},
|
||||||
Primitive::Quad {
|
Primitive::Quad {
|
||||||
bounds,
|
bounds,
|
||||||
background: button.background.unwrap_or(
|
background: button.background.unwrap_or(
|
||||||
Background::Color(Color {
|
Background::Color([0.8, 0.8, 0.8].into()),
|
||||||
r: 0.8,
|
|
||||||
b: 0.8,
|
|
||||||
g: 0.8,
|
|
||||||
a: 1.0,
|
|
||||||
}),
|
|
||||||
),
|
),
|
||||||
border_radius: button.border_radius,
|
border_radius: button.border_radius,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::{Primitive, Renderer};
|
use crate::{Primitive, Renderer};
|
||||||
use iced_native::{
|
use iced_native::{
|
||||||
checkbox, text, text::HorizontalAlignment, text::VerticalAlignment, Align,
|
checkbox, text, text::HorizontalAlignment, text::VerticalAlignment, Align,
|
||||||
Background, Checkbox, Color, Column, Layout, Length, MouseCursor, Node,
|
Background, Checkbox, Column, Layout, Length, MouseCursor, Node,
|
||||||
Point, Rectangle, Row, Text, Widget,
|
Point, Rectangle, Row, Text, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -46,12 +46,7 @@ impl checkbox::Renderer for Renderer {
|
||||||
let (checkbox_border, checkbox_box) = (
|
let (checkbox_border, checkbox_box) = (
|
||||||
Primitive::Quad {
|
Primitive::Quad {
|
||||||
bounds: checkbox_bounds,
|
bounds: checkbox_bounds,
|
||||||
background: Background::Color(Color {
|
background: Background::Color([0.6, 0.6, 0.6].into()),
|
||||||
r: 0.6,
|
|
||||||
g: 0.6,
|
|
||||||
b: 0.6,
|
|
||||||
a: 1.0,
|
|
||||||
}),
|
|
||||||
border_radius: 6,
|
border_radius: 6,
|
||||||
},
|
},
|
||||||
Primitive::Quad {
|
Primitive::Quad {
|
||||||
|
|
@ -61,21 +56,14 @@ impl checkbox::Renderer for Renderer {
|
||||||
width: checkbox_bounds.width - 2.0,
|
width: checkbox_bounds.width - 2.0,
|
||||||
height: checkbox_bounds.height - 2.0,
|
height: checkbox_bounds.height - 2.0,
|
||||||
},
|
},
|
||||||
background: Background::Color(if is_mouse_over {
|
background: Background::Color(
|
||||||
Color {
|
if is_mouse_over {
|
||||||
r: 0.90,
|
[0.90, 0.90, 0.90]
|
||||||
g: 0.90,
|
} else {
|
||||||
b: 0.90,
|
[0.95, 0.95, 0.95]
|
||||||
a: 1.0,
|
|
||||||
}
|
}
|
||||||
} else {
|
.into(),
|
||||||
Color {
|
),
|
||||||
r: 0.95,
|
|
||||||
g: 0.95,
|
|
||||||
b: 0.95,
|
|
||||||
a: 1.0,
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
border_radius: 5,
|
border_radius: 5,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{Primitive, Renderer};
|
use crate::{Primitive, Renderer};
|
||||||
use iced_native::{
|
use iced_native::{
|
||||||
radio, text, Align, Background, Color, Column, Layout, Length, MouseCursor,
|
radio, text, Align, Background, Column, Layout, Length, MouseCursor,
|
||||||
Node, Point, Radio, Rectangle, Row, Text, Widget,
|
Node, Point, Radio, Rectangle, Row, Text, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -41,12 +41,7 @@ impl radio::Renderer for Renderer {
|
||||||
let (radio_border, radio_box) = (
|
let (radio_border, radio_box) = (
|
||||||
Primitive::Quad {
|
Primitive::Quad {
|
||||||
bounds: radio_bounds,
|
bounds: radio_bounds,
|
||||||
background: Background::Color(Color {
|
background: Background::Color([0.6, 0.6, 0.6].into()),
|
||||||
r: 0.6,
|
|
||||||
g: 0.6,
|
|
||||||
b: 0.6,
|
|
||||||
a: 1.0,
|
|
||||||
}),
|
|
||||||
border_radius: (SIZE / 2.0) as u16,
|
border_radius: (SIZE / 2.0) as u16,
|
||||||
},
|
},
|
||||||
Primitive::Quad {
|
Primitive::Quad {
|
||||||
|
|
@ -56,21 +51,14 @@ impl radio::Renderer for Renderer {
|
||||||
width: radio_bounds.width - 2.0,
|
width: radio_bounds.width - 2.0,
|
||||||
height: radio_bounds.height - 2.0,
|
height: radio_bounds.height - 2.0,
|
||||||
},
|
},
|
||||||
background: Background::Color(if is_mouse_over {
|
background: Background::Color(
|
||||||
Color {
|
if is_mouse_over {
|
||||||
r: 0.90,
|
[0.90, 0.90, 0.90]
|
||||||
g: 0.90,
|
} else {
|
||||||
b: 0.90,
|
[0.95, 0.95, 0.95]
|
||||||
a: 1.0,
|
|
||||||
}
|
}
|
||||||
} else {
|
.into(),
|
||||||
Color {
|
),
|
||||||
r: 0.95,
|
|
||||||
g: 0.95,
|
|
||||||
b: 0.95,
|
|
||||||
a: 1.0,
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
border_radius: (SIZE / 2.0 - 1.0) as u16,
|
border_radius: (SIZE / 2.0 - 1.0) as u16,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
@ -85,12 +73,7 @@ impl radio::Renderer for Renderer {
|
||||||
width: radio_bounds.width - DOT_SIZE,
|
width: radio_bounds.width - DOT_SIZE,
|
||||||
height: radio_bounds.height - DOT_SIZE,
|
height: radio_bounds.height - DOT_SIZE,
|
||||||
},
|
},
|
||||||
background: Background::Color(Color {
|
background: Background::Color([0.3, 0.3, 0.3].into()),
|
||||||
r: 0.30,
|
|
||||||
g: 0.30,
|
|
||||||
b: 0.30,
|
|
||||||
a: 1.0,
|
|
||||||
}),
|
|
||||||
border_radius: (DOT_SIZE / 2.0) as u16,
|
border_radius: (DOT_SIZE / 2.0) as u16,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{Primitive, Renderer};
|
use crate::{Primitive, Renderer};
|
||||||
use iced_native::{
|
use iced_native::{
|
||||||
scrollable, Background, Color, Layout, MouseCursor, Point, Rectangle,
|
scrollable, Background, Layout, MouseCursor, Point, Rectangle,
|
||||||
Scrollable, Vector, Widget,
|
Scrollable, Vector, Widget,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -78,12 +78,7 @@ impl scrollable::Renderer for Renderer {
|
||||||
- f32::from(2 * SCROLLBAR_MARGIN),
|
- f32::from(2 * SCROLLBAR_MARGIN),
|
||||||
height: scrollbar_height,
|
height: scrollbar_height,
|
||||||
},
|
},
|
||||||
background: Background::Color(Color {
|
background: Background::Color([0.0, 0.0, 0.0, 0.7].into()),
|
||||||
r: 0.0,
|
|
||||||
g: 0.0,
|
|
||||||
b: 0.0,
|
|
||||||
a: 0.7,
|
|
||||||
}),
|
|
||||||
border_radius: 5,
|
border_radius: 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -97,12 +92,9 @@ impl scrollable::Renderer for Renderer {
|
||||||
- f32::from(2 * SCROLLBAR_MARGIN),
|
- f32::from(2 * SCROLLBAR_MARGIN),
|
||||||
..scrollbar_bounds
|
..scrollbar_bounds
|
||||||
},
|
},
|
||||||
background: Background::Color(Color {
|
background: Background::Color(
|
||||||
r: 0.0,
|
[0.0, 0.0, 0.0, 0.3].into(),
|
||||||
g: 0.0,
|
),
|
||||||
b: 0.0,
|
|
||||||
a: 0.3,
|
|
||||||
}),
|
|
||||||
border_radius: 5,
|
border_radius: 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,12 +37,7 @@ impl slider::Renderer for Renderer {
|
||||||
width: bounds.width,
|
width: bounds.width,
|
||||||
height: 2.0,
|
height: 2.0,
|
||||||
},
|
},
|
||||||
background: Background::Color(Color {
|
background: Background::Color([0.6, 0.6, 0.6].into()),
|
||||||
r: 0.6,
|
|
||||||
g: 0.6,
|
|
||||||
b: 0.6,
|
|
||||||
a: 1.0,
|
|
||||||
}),
|
|
||||||
border_radius: 0,
|
border_radius: 0,
|
||||||
},
|
},
|
||||||
Primitive::Quad {
|
Primitive::Quad {
|
||||||
|
|
@ -71,12 +66,7 @@ impl slider::Renderer for Renderer {
|
||||||
width: HANDLE_WIDTH + 2.0,
|
width: HANDLE_WIDTH + 2.0,
|
||||||
height: HANDLE_HEIGHT + 2.0,
|
height: HANDLE_HEIGHT + 2.0,
|
||||||
},
|
},
|
||||||
background: Background::Color(Color {
|
background: Background::Color([0.6, 0.6, 0.6].into()),
|
||||||
r: 0.6,
|
|
||||||
g: 0.6,
|
|
||||||
b: 0.6,
|
|
||||||
a: 1.0,
|
|
||||||
}),
|
|
||||||
border_radius: 5,
|
border_radius: 5,
|
||||||
},
|
},
|
||||||
Primitive::Quad {
|
Primitive::Quad {
|
||||||
|
|
@ -86,28 +76,16 @@ impl slider::Renderer for Renderer {
|
||||||
width: HANDLE_WIDTH,
|
width: HANDLE_WIDTH,
|
||||||
height: HANDLE_HEIGHT,
|
height: HANDLE_HEIGHT,
|
||||||
},
|
},
|
||||||
background: Background::Color(if slider.state.is_dragging() {
|
background: Background::Color(
|
||||||
Color {
|
if slider.state.is_dragging() {
|
||||||
r: 0.85,
|
[0.85, 0.85, 0.85]
|
||||||
g: 0.85,
|
} else if is_mouse_over {
|
||||||
b: 0.85,
|
[0.90, 0.90, 0.90]
|
||||||
a: 1.0,
|
} else {
|
||||||
|
[0.95, 0.95, 0.95]
|
||||||
}
|
}
|
||||||
} else if is_mouse_over {
|
.into(),
|
||||||
Color {
|
),
|
||||||
r: 0.9,
|
|
||||||
g: 0.9,
|
|
||||||
b: 0.9,
|
|
||||||
a: 1.0,
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Color {
|
|
||||||
r: 0.95,
|
|
||||||
g: 0.95,
|
|
||||||
b: 0.95,
|
|
||||||
a: 1.0,
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
border_radius: 4,
|
border_radius: 4,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -25,20 +25,11 @@ impl text_input::Renderer for Renderer {
|
||||||
bounds,
|
bounds,
|
||||||
background: Background::Color(
|
background: Background::Color(
|
||||||
if is_mouse_over || text_input.state.is_focused {
|
if is_mouse_over || text_input.state.is_focused {
|
||||||
Color {
|
[0.5, 0.5, 0.5]
|
||||||
r: 0.5,
|
|
||||||
g: 0.5,
|
|
||||||
b: 0.5,
|
|
||||||
a: 1.0,
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Color {
|
[0.7, 0.7, 0.7]
|
||||||
r: 0.7,
|
}
|
||||||
g: 0.7,
|
.into(),
|
||||||
b: 0.7,
|
|
||||||
a: 1.0,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
border_radius: 5,
|
border_radius: 5,
|
||||||
};
|
};
|
||||||
|
|
@ -64,20 +55,11 @@ impl text_input::Renderer for Renderer {
|
||||||
text.clone()
|
text.clone()
|
||||||
},
|
},
|
||||||
color: if text.is_empty() {
|
color: if text.is_empty() {
|
||||||
Color {
|
[0.7, 0.7, 0.7]
|
||||||
r: 0.7,
|
|
||||||
g: 0.7,
|
|
||||||
b: 0.7,
|
|
||||||
a: 1.0,
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Color {
|
[0.3, 0.3, 0.3]
|
||||||
r: 0.3,
|
}
|
||||||
g: 0.3,
|
.into(),
|
||||||
b: 0.3,
|
|
||||||
a: 1.0,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
bounds: Rectangle {
|
bounds: Rectangle {
|
||||||
width: f32::INFINITY,
|
width: f32::INFINITY,
|
||||||
..text_bounds
|
..text_bounds
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue