[refactor] rename fill_color
to just fill
This commit is contained in:
parent
c7a59b57d2
commit
d214574c97
16 changed files with 70 additions and 70 deletions
|
@ -86,7 +86,7 @@ impl State {
|
|||
ui.add_paint_cmd(PaintCmd::Path {
|
||||
path: Path::from_point_loop(&points),
|
||||
closed: true,
|
||||
fill_color: None,
|
||||
fill: None,
|
||||
outline: Some(LineStyle::new(stroke_width, stroke_color)),
|
||||
});
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ impl CollapsingHeader {
|
|||
where_to_put_background,
|
||||
PaintCmd::Rect {
|
||||
corner_radius: ui.style().interact(&interact).corner_radius,
|
||||
fill_color: ui.style().interact(&interact).bg_fill_color,
|
||||
fill: ui.style().interact(&interact).bg_fill,
|
||||
outline: None,
|
||||
rect: interact.rect,
|
||||
},
|
||||
|
|
|
@ -7,7 +7,7 @@ pub struct Frame {
|
|||
// On each side
|
||||
pub margin: Vec2,
|
||||
pub corner_radius: f32,
|
||||
pub fill_color: Option<Color>,
|
||||
pub fill: Option<Color>,
|
||||
pub outline: Option<LineStyle>,
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ impl Frame {
|
|||
Self {
|
||||
margin: style.window_padding,
|
||||
corner_radius: style.window.corner_radius,
|
||||
fill_color: Some(style.background_fill_color),
|
||||
fill: Some(style.background_fill),
|
||||
outline: style.interact.inactive.rect_outline, // becauce we can resize windows
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ impl Frame {
|
|||
Self {
|
||||
margin: Vec2::splat(1.0),
|
||||
corner_radius: 0.0,
|
||||
fill_color: None,
|
||||
fill: None,
|
||||
outline: Some(LineStyle::new(0.5, color::white(128))),
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ impl Frame {
|
|||
Self {
|
||||
margin: Vec2::splat(1.0),
|
||||
corner_radius: 2.0,
|
||||
fill_color: Some(style.background_fill_color),
|
||||
fill: Some(style.background_fill),
|
||||
outline: Some(LineStyle::new(1.0, color::white(128))),
|
||||
}
|
||||
}
|
||||
|
@ -43,13 +43,13 @@ impl Frame {
|
|||
Self {
|
||||
margin: style.window_padding,
|
||||
corner_radius: 5.0,
|
||||
fill_color: Some(style.background_fill_color),
|
||||
fill: Some(style.background_fill),
|
||||
outline: Some(LineStyle::new(1.0, color::white(128))),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fill_color(mut self, fill_color: Option<Color>) -> Self {
|
||||
self.fill_color = fill_color;
|
||||
pub fn fill(mut self, fill: Option<Color>) -> Self {
|
||||
self.fill = fill;
|
||||
self
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ impl Prepared {
|
|||
where_to_put_background,
|
||||
PaintCmd::Rect {
|
||||
corner_radius: frame.corner_radius,
|
||||
fill_color: frame.fill_color,
|
||||
fill: frame.fill,
|
||||
outline: frame.outline,
|
||||
rect: outer_rect,
|
||||
},
|
||||
|
|
|
@ -25,11 +25,11 @@ pub fn bar<R>(ui: &mut Ui, add_contents: impl FnOnce(&mut Ui) -> R) -> (R, Rect)
|
|||
Frame::menu_bar(ui.style()).show(ui, |ui| {
|
||||
let mut style = ui.style().clone();
|
||||
style.button_padding = vec2(2.0, 0.0);
|
||||
// style.interact.active.bg_fill_color = None;
|
||||
// style.interact.active.bg_fill = None;
|
||||
style.interact.active.rect_outline = None;
|
||||
// style.interact.hovered.bg_fill_color = None;
|
||||
// style.interact.hovered.bg_fill = None;
|
||||
style.interact.hovered.rect_outline = None;
|
||||
style.interact.inactive.bg_fill_color = None;
|
||||
style.interact.inactive.bg_fill = None;
|
||||
style.interact.inactive.rect_outline = None;
|
||||
ui.set_style(style);
|
||||
|
||||
|
@ -66,7 +66,7 @@ fn menu_impl<'c>(
|
|||
let mut button = Button::new(title);
|
||||
|
||||
if bar_state.open_menu == Some(menu_id) {
|
||||
button = button.fill_color(Some(ui.style().interact.active.fill_color));
|
||||
button = button.fill(Some(ui.style().interact.active.fill));
|
||||
}
|
||||
|
||||
let button_interact = ui.add(button);
|
||||
|
@ -86,11 +86,11 @@ fn menu_impl<'c>(
|
|||
resize.show(ui, |ui| {
|
||||
let mut style = ui.style().clone();
|
||||
style.button_padding = vec2(2.0, 0.0);
|
||||
// style.interact.active.bg_fill_color = None;
|
||||
// style.interact.active.bg_fill = None;
|
||||
style.interact.active.rect_outline = None;
|
||||
// style.interact.hovered.bg_fill_color = None;
|
||||
// style.interact.hovered.bg_fill = None;
|
||||
style.interact.hovered.rect_outline = None;
|
||||
style.interact.inactive.bg_fill_color = None;
|
||||
style.interact.inactive.bg_fill = None;
|
||||
style.interact.inactive.rect_outline = None;
|
||||
ui.set_style(style);
|
||||
ui.set_layout(Layout::justified(Direction::Vertical));
|
||||
|
|
|
@ -314,7 +314,7 @@ impl Resize {
|
|||
ui.add_paint_cmd(paint::PaintCmd::Rect {
|
||||
rect,
|
||||
corner_radius: 3.0,
|
||||
fill_color: None,
|
||||
fill: None,
|
||||
outline: Some(ui.style().thin_outline),
|
||||
});
|
||||
}
|
||||
|
|
|
@ -214,20 +214,20 @@ impl Prepared {
|
|||
);
|
||||
|
||||
let style = ui.style();
|
||||
let handle_fill_color = style.interact(&interact).fill_color;
|
||||
let handle_fill = style.interact(&interact).fill;
|
||||
let handle_outline = style.interact(&interact).rect_outline;
|
||||
|
||||
ui.add_paint_cmd(paint::PaintCmd::Rect {
|
||||
rect: outer_scroll_rect,
|
||||
corner_radius,
|
||||
fill_color: Some(ui.style().dark_bg_color),
|
||||
fill: Some(ui.style().dark_bg_color),
|
||||
outline: None,
|
||||
});
|
||||
|
||||
ui.add_paint_cmd(paint::PaintCmd::Rect {
|
||||
rect: handle_rect.expand(-2.0),
|
||||
corner_radius,
|
||||
fill_color: Some(handle_fill_color),
|
||||
fill: Some(handle_fill),
|
||||
outline: handle_outline,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ impl<'open> Window<'open> {
|
|||
self
|
||||
}
|
||||
|
||||
/// Usage: `Winmdow::new(...).frame(|f| f.fill_color(Some(BLUE)))`
|
||||
/// Usage: `Winmdow::new(...).frame(|f| f.fill(Some(BLUE)))`
|
||||
/// Not sure this is a good interface for this.
|
||||
pub fn frame(mut self, frame: Frame) -> Self {
|
||||
self.frame = Some(frame);
|
||||
|
@ -505,7 +505,7 @@ fn paint_frame_interaction(
|
|||
ui.add_paint_cmd(PaintCmd::Path {
|
||||
path,
|
||||
closed: false,
|
||||
fill_color: None,
|
||||
fill: None,
|
||||
outline: style.rect_outline,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -362,7 +362,7 @@ impl Context {
|
|||
layer,
|
||||
PaintCmd::Rect {
|
||||
corner_radius: 0.0,
|
||||
fill_color: Some(color::gray(0, 240)),
|
||||
fill: Some(color::gray(0, 240)),
|
||||
outline: Some(LineStyle::new(1.0, color::RED)),
|
||||
rect: rect.expand(2.0),
|
||||
},
|
||||
|
@ -391,7 +391,7 @@ impl Context {
|
|||
layer,
|
||||
PaintCmd::Rect {
|
||||
corner_radius: 0.0,
|
||||
fill_color: None,
|
||||
fill: None,
|
||||
outline: Some(LineStyle::new(1.0, color::RED)),
|
||||
rect,
|
||||
},
|
||||
|
|
|
@ -401,7 +401,7 @@ impl BoxPainting {
|
|||
for i in 0..self.num_boxes {
|
||||
cmds.push(PaintCmd::Rect {
|
||||
corner_radius: self.corner_radius,
|
||||
fill_color: Some(gray(136, 255)),
|
||||
fill: Some(gray(136, 255)),
|
||||
rect: Rect::from_min_size(
|
||||
pos2(10.0 + pos.x + (i as f32) * (self.size.x * 1.1), pos.y),
|
||||
self.size,
|
||||
|
@ -463,7 +463,7 @@ impl Painting {
|
|||
path: Path::from_open_points(&points),
|
||||
closed: false,
|
||||
outline: Some(LineStyle::new(2.0, LIGHT_GRAY)),
|
||||
fill_color: None,
|
||||
fill: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ impl FractalClock {
|
|||
.default_rect(ctx.rect().expand(-40.0))
|
||||
.scroll(false)
|
||||
// Dark background frame to make it pop:
|
||||
.frame(Frame::window(&ctx.style()).fill_color(Some(color::black(250))))
|
||||
.frame(Frame::window(&ctx.style()).fill(Some(color::black(250))))
|
||||
.show(ctx, |ui| self.ui(ui));
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ impl FractalClock {
|
|||
self.fractal_ui(ui);
|
||||
|
||||
let frame = Frame::popup(ui.style())
|
||||
.fill_color(Some(color::gray(34, 160)))
|
||||
.fill(Some(color::gray(34, 160)))
|
||||
.outline(None);
|
||||
|
||||
frame.show(&mut ui.left_column(320.0), |ui| {
|
||||
|
|
|
@ -10,7 +10,7 @@ use serde_derive::{Deserialize, Serialize};
|
|||
pub enum PaintCmd {
|
||||
Circle {
|
||||
center: Pos2,
|
||||
fill_color: Option<Color>,
|
||||
fill: Option<Color>,
|
||||
outline: Option<LineStyle>,
|
||||
radius: f32,
|
||||
},
|
||||
|
@ -22,13 +22,13 @@ pub enum PaintCmd {
|
|||
Path {
|
||||
path: Path,
|
||||
closed: bool,
|
||||
fill_color: Option<Color>,
|
||||
fill: Option<Color>,
|
||||
outline: Option<LineStyle>,
|
||||
},
|
||||
Rect {
|
||||
rect: Rect,
|
||||
corner_radius: f32,
|
||||
fill_color: Option<Color>,
|
||||
fill: Option<Color>,
|
||||
outline: Option<LineStyle>,
|
||||
},
|
||||
Text {
|
||||
|
|
|
@ -554,13 +554,13 @@ pub fn paint_command_into_triangles(
|
|||
match command {
|
||||
PaintCmd::Circle {
|
||||
center,
|
||||
fill_color,
|
||||
fill,
|
||||
outline,
|
||||
radius,
|
||||
} => {
|
||||
path.add_circle(center, radius);
|
||||
if let Some(color) = fill_color {
|
||||
fill_closed_path(out, options, &path.0, color);
|
||||
if let Some(fill) = fill {
|
||||
fill_closed_path(out, options, &path.0, fill);
|
||||
}
|
||||
if let Some(outline) = outline {
|
||||
paint_path_outline(out, options, Closed, &path.0, outline.color, outline.width);
|
||||
|
@ -580,16 +580,16 @@ pub fn paint_command_into_triangles(
|
|||
PaintCmd::Path {
|
||||
path,
|
||||
closed,
|
||||
fill_color,
|
||||
fill,
|
||||
outline,
|
||||
} => {
|
||||
if path.len() >= 2 {
|
||||
if let Some(fill_color) = fill_color {
|
||||
if let Some(fill) = fill {
|
||||
debug_assert!(
|
||||
closed,
|
||||
"You asked to fill a path that is not closed. That makes no sense."
|
||||
);
|
||||
fill_closed_path(out, options, &path.0, fill_color);
|
||||
fill_closed_path(out, options, &path.0, fill);
|
||||
}
|
||||
if let Some(outline) = outline {
|
||||
let typ = if closed { Closed } else { Open };
|
||||
|
@ -599,7 +599,7 @@ pub fn paint_command_into_triangles(
|
|||
}
|
||||
PaintCmd::Rect {
|
||||
corner_radius,
|
||||
fill_color,
|
||||
fill,
|
||||
outline,
|
||||
mut rect,
|
||||
} => {
|
||||
|
@ -609,8 +609,8 @@ pub fn paint_command_into_triangles(
|
|||
rect.max = rect.max.min(pos2(1e7, 1e7));
|
||||
|
||||
path.add_rounded_rectangle(rect, corner_radius);
|
||||
if let Some(fill_color) = fill_color {
|
||||
fill_closed_path(out, options, &path.0, fill_color);
|
||||
if let Some(fill) = fill {
|
||||
fill_closed_path(out, options, &path.0, fill);
|
||||
}
|
||||
if let Some(outline) = outline {
|
||||
paint_path_outline(out, options, Closed, &path.0, outline.color, outline.width);
|
||||
|
@ -686,7 +686,7 @@ pub fn paint_commands_into_triangles(
|
|||
PaintCmd::Rect {
|
||||
rect: *clip_rect,
|
||||
corner_radius: 0.0,
|
||||
fill_color: None,
|
||||
fill: None,
|
||||
outline: Some(LineStyle::new(2.0, srgba(150, 255, 150, 255))),
|
||||
},
|
||||
triangles,
|
||||
|
|
|
@ -39,7 +39,7 @@ pub struct Style {
|
|||
pub thin_outline: LineStyle,
|
||||
|
||||
/// e.g. the background of windows
|
||||
pub background_fill_color: Color,
|
||||
pub background_fill: Color,
|
||||
|
||||
/// e.g. the background of the slider or text edit
|
||||
pub dark_bg_color: Color,
|
||||
|
@ -76,7 +76,7 @@ impl Default for Style {
|
|||
text_color: gray(160, 255),
|
||||
line_width: 1.0,
|
||||
thin_outline: LineStyle::new(0.5, GRAY),
|
||||
background_fill_color: gray(32, 250),
|
||||
background_fill: gray(32, 250),
|
||||
dark_bg_color: gray(0, 140),
|
||||
cursor_blink_hz: 1.0,
|
||||
text_cursor_width: 2.0,
|
||||
|
@ -100,24 +100,24 @@ impl Default for Interact {
|
|||
fn default() -> Self {
|
||||
Self {
|
||||
active: WidgetStyle {
|
||||
bg_fill_color: Some(gray(0, 128)),
|
||||
fill_color: srgba(120, 120, 200, 255),
|
||||
bg_fill: Some(gray(0, 128)),
|
||||
fill: srgba(120, 120, 200, 255),
|
||||
stroke_color: WHITE,
|
||||
stroke_width: 2.0,
|
||||
rect_outline: Some(LineStyle::new(2.0, WHITE)),
|
||||
corner_radius: 5.0,
|
||||
},
|
||||
hovered: WidgetStyle {
|
||||
bg_fill_color: None,
|
||||
fill_color: srgba(100, 100, 150, 255),
|
||||
bg_fill: None,
|
||||
fill: srgba(100, 100, 150, 255),
|
||||
stroke_color: gray(240, 255),
|
||||
stroke_width: 1.5,
|
||||
rect_outline: Some(LineStyle::new(1.0, WHITE)),
|
||||
corner_radius: 5.0,
|
||||
},
|
||||
inactive: WidgetStyle {
|
||||
bg_fill_color: None,
|
||||
fill_color: srgba(60, 60, 80, 255),
|
||||
bg_fill: None,
|
||||
fill: srgba(60, 60, 80, 255),
|
||||
stroke_color: gray(210, 255), // Mustn't look grayed out!
|
||||
stroke_width: 1.0,
|
||||
rect_outline: Some(LineStyle::new(1.0, white(128))),
|
||||
|
@ -142,11 +142,11 @@ impl Interact {
|
|||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
||||
pub struct WidgetStyle {
|
||||
/// Background color of widget
|
||||
pub bg_fill_color: Option<Color>,
|
||||
pub bg_fill: Option<Color>,
|
||||
|
||||
/// Fill color of the interactive part of a component (slider grab, checkbox, ...)
|
||||
/// When you need a fill_color.
|
||||
pub fill_color: Color,
|
||||
/// When you need a fill.
|
||||
pub fill: Color,
|
||||
|
||||
/// Stroke and text color of the interactive part of a component (button, slider grab, checkbox, ...)
|
||||
pub stroke_color: Color,
|
||||
|
|
|
@ -359,7 +359,7 @@ impl Ui {
|
|||
rect,
|
||||
corner_radius: 0.0,
|
||||
outline: Some(LineStyle::new(1.0, LIGHT_BLUE)),
|
||||
fill_color: None,
|
||||
fill: None,
|
||||
});
|
||||
|
||||
let color = color::srgba(200, 0, 0, 255);
|
||||
|
@ -441,7 +441,7 @@ impl Ui {
|
|||
pub fn debug_rect(&mut self, rect: Rect, text: impl Into<String>) {
|
||||
self.add_paint_cmd(PaintCmd::Rect {
|
||||
corner_radius: 0.0,
|
||||
fill_color: None,
|
||||
fill: None,
|
||||
outline: Some(LineStyle::new(1.0, color::RED)),
|
||||
rect,
|
||||
});
|
||||
|
|
|
@ -196,7 +196,7 @@ pub struct Button {
|
|||
text_color: Option<Color>,
|
||||
text_style: TextStyle,
|
||||
/// None means default for interact
|
||||
fill_color: Option<Color>,
|
||||
fill: Option<Color>,
|
||||
}
|
||||
|
||||
impl Button {
|
||||
|
@ -205,7 +205,7 @@ impl Button {
|
|||
text: text.into(),
|
||||
text_color: None,
|
||||
text_style: TextStyle::Button,
|
||||
fill_color: None,
|
||||
fill: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -219,8 +219,8 @@ impl Button {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn fill_color(mut self, fill_color: Option<Color>) -> Self {
|
||||
self.fill_color = fill_color;
|
||||
pub fn fill(mut self, fill: Option<Color>) -> Self {
|
||||
self.fill = fill;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ impl Widget for Button {
|
|||
text,
|
||||
text_color,
|
||||
text_style,
|
||||
fill_color,
|
||||
fill,
|
||||
} = self;
|
||||
|
||||
let id = ui.make_position_id();
|
||||
|
@ -243,10 +243,10 @@ impl Widget for Button {
|
|||
let rect = ui.allocate_space(size);
|
||||
let interact = ui.interact(rect, id, Sense::click());
|
||||
let text_cursor = interact.rect.left_center() + vec2(padding.x, -0.5 * galley.size.y);
|
||||
let bg_fill_color = fill_color.or(ui.style().interact(&interact).bg_fill_color);
|
||||
let bg_fill = fill.or(ui.style().interact(&interact).bg_fill);
|
||||
ui.add_paint_cmd(PaintCmd::Rect {
|
||||
corner_radius: ui.style().interact(&interact).corner_radius,
|
||||
fill_color: bg_fill_color,
|
||||
fill: bg_fill,
|
||||
outline: ui.style().interact(&interact).rect_outline,
|
||||
rect: interact.rect,
|
||||
});
|
||||
|
@ -307,7 +307,7 @@ impl<'a> Widget for Checkbox<'a> {
|
|||
let (small_icon_rect, big_icon_rect) = ui.style().icon_rectangles(interact.rect);
|
||||
ui.add_paint_cmd(PaintCmd::Rect {
|
||||
corner_radius: ui.style().interact(&interact).corner_radius,
|
||||
fill_color: ui.style().interact(&interact).bg_fill_color,
|
||||
fill: ui.style().interact(&interact).bg_fill,
|
||||
outline: ui.style().interact(&interact).rect_outline,
|
||||
rect: big_icon_rect,
|
||||
});
|
||||
|
@ -323,7 +323,7 @@ impl<'a> Widget for Checkbox<'a> {
|
|||
]),
|
||||
closed: false,
|
||||
outline: Some(LineStyle::new(ui.style().line_width, stroke_color)),
|
||||
fill_color: None,
|
||||
fill: None,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -381,14 +381,14 @@ impl Widget for RadioButton {
|
|||
let text_cursor =
|
||||
interact.rect.min + ui.style().button_padding + vec2(ui.style().start_icon_width, 0.0);
|
||||
|
||||
let bg_fill_color = ui.style().interact(&interact).bg_fill_color;
|
||||
let bg_fill = ui.style().interact(&interact).bg_fill;
|
||||
let stroke_color = ui.style().interact(&interact).stroke_color;
|
||||
|
||||
let (small_icon_rect, big_icon_rect) = ui.style().icon_rectangles(interact.rect);
|
||||
|
||||
ui.add_paint_cmd(PaintCmd::Circle {
|
||||
center: big_icon_rect.center(),
|
||||
fill_color: bg_fill_color,
|
||||
fill: bg_fill,
|
||||
outline: ui.style().interact(&interact).rect_outline, // TODO
|
||||
radius: big_icon_rect.width() / 2.0,
|
||||
});
|
||||
|
@ -396,7 +396,7 @@ impl Widget for RadioButton {
|
|||
if checked {
|
||||
ui.add_paint_cmd(PaintCmd::Circle {
|
||||
center: small_icon_rect.center(),
|
||||
fill_color: Some(stroke_color),
|
||||
fill: Some(stroke_color),
|
||||
outline: None,
|
||||
radius: small_icon_rect.width() / 3.0,
|
||||
});
|
||||
|
|
|
@ -174,14 +174,14 @@ impl<'a> Widget for Slider<'a> {
|
|||
ui.add_paint_cmd(PaintCmd::Rect {
|
||||
rect: rail_rect,
|
||||
corner_radius: rail_radius,
|
||||
fill_color: Some(ui.style().background_fill_color),
|
||||
fill: Some(ui.style().background_fill),
|
||||
outline: Some(LineStyle::new(1.0, color::gray(200, 255))), // TODO
|
||||
});
|
||||
|
||||
ui.add_paint_cmd(PaintCmd::Circle {
|
||||
center: pos2(marker_center_x, rail_rect.center().y),
|
||||
radius: handle_radius,
|
||||
fill_color: Some(ui.style().interact(&interact).fill_color),
|
||||
fill: Some(ui.style().interact(&interact).fill),
|
||||
outline: Some(LineStyle::new(
|
||||
ui.style().interact(&interact).stroke_width,
|
||||
ui.style().interact(&interact).stroke_color,
|
||||
|
|
|
@ -122,7 +122,7 @@ impl<'t> Widget for TextEdit<'t> {
|
|||
ui.add_paint_cmd(PaintCmd::Rect {
|
||||
rect: bg_rect,
|
||||
corner_radius: ui.style().interact.style(&interact).corner_radius,
|
||||
fill_color: Some(ui.style().dark_bg_color),
|
||||
fill: Some(ui.style().dark_bg_color),
|
||||
outline: ui.style().interact.style(&interact).rect_outline,
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue