From 0bb042924f9ceac8558e766490f58d6b2a2cb33e Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sat, 23 May 2020 14:07:49 +0200 Subject: [PATCH] [refactor] rename Outline to LineStyle --- emigui/src/containers/collapsing_header.rs | 4 ++-- emigui/src/containers/frame.rs | 10 +++++----- emigui/src/context.rs | 4 ++-- emigui/src/examples/app.rs | 2 +- emigui/src/paint.rs | 2 +- emigui/src/paint/command.rs | 12 ++++++------ emigui/src/paint/mesher.rs | 4 ++-- emigui/src/style.rs | 14 +++++++------- emigui/src/ui.rs | 4 ++-- emigui/src/widgets/slider.rs | 4 ++-- 10 files changed, 30 insertions(+), 30 deletions(-) diff --git a/emigui/src/containers/collapsing_header.rs b/emigui/src/containers/collapsing_header.rs index aa7cc678d..666ae86da 100644 --- a/emigui/src/containers/collapsing_header.rs +++ b/emigui/src/containers/collapsing_header.rs @@ -1,6 +1,6 @@ use crate::{ layout::Direction, - paint::{Outline, PaintCmd, Path, TextStyle}, + paint::{LineStyle, PaintCmd, Path, TextStyle}, widgets::Label, *, }; @@ -87,7 +87,7 @@ impl State { path: Path::from_point_loop(&points), closed: true, fill_color: None, - outline: Some(Outline::new(stroke_width, stroke_color)), + outline: Some(LineStyle::new(stroke_width, stroke_color)), }); } diff --git a/emigui/src/containers/frame.rs b/emigui/src/containers/frame.rs index bdae70093..903fc3564 100644 --- a/emigui/src/containers/frame.rs +++ b/emigui/src/containers/frame.rs @@ -8,7 +8,7 @@ pub struct Frame { pub margin: Vec2, pub corner_radius: f32, pub fill_color: Option, - pub outline: Option, + pub outline: Option, } impl Frame { @@ -26,7 +26,7 @@ impl Frame { margin: Vec2::splat(1.0), corner_radius: 0.0, fill_color: None, - outline: Some(Outline::new(0.5, color::white(128))), + outline: Some(LineStyle::new(0.5, color::white(128))), } } @@ -35,7 +35,7 @@ impl Frame { margin: Vec2::splat(1.0), corner_radius: 2.0, fill_color: Some(style.background_fill_color), - outline: Some(Outline::new(1.0, color::white(128))), + outline: Some(LineStyle::new(1.0, color::white(128))), } } @@ -44,7 +44,7 @@ impl Frame { margin: style.window_padding, corner_radius: 5.0, fill_color: Some(style.background_fill_color), - outline: Some(Outline::new(1.0, color::white(128))), + outline: Some(LineStyle::new(1.0, color::white(128))), } } @@ -53,7 +53,7 @@ impl Frame { self } - pub fn outline(mut self, outline: Option) -> Self { + pub fn outline(mut self, outline: Option) -> Self { self.outline = outline; self } diff --git a/emigui/src/context.rs b/emigui/src/context.rs index 86a68529a..9f37a42a2 100644 --- a/emigui/src/context.rs +++ b/emigui/src/context.rs @@ -363,7 +363,7 @@ impl Context { PaintCmd::Rect { corner_radius: 0.0, fill_color: Some(color::gray(0, 240)), - outline: Some(Outline::new(1.0, color::RED)), + outline: Some(LineStyle::new(1.0, color::RED)), rect: rect.expand(2.0), }, ); @@ -392,7 +392,7 @@ impl Context { PaintCmd::Rect { corner_radius: 0.0, fill_color: None, - outline: Some(Outline::new(1.0, color::RED)), + outline: Some(LineStyle::new(1.0, color::RED)), rect, }, ); diff --git a/emigui/src/examples/app.rs b/emigui/src/examples/app.rs index b2c74cd5d..24a54bb5f 100644 --- a/emigui/src/examples/app.rs +++ b/emigui/src/examples/app.rs @@ -406,7 +406,7 @@ impl BoxPainting { pos2(10.0 + pos.x + (i as f32) * (self.size.x * 1.1), pos.y), self.size, ), - outline: Some(Outline::new(self.stroke_width, gray(255, 255))), + outline: Some(LineStyle::new(self.stroke_width, gray(255, 255))), }); } ui.add_paint_cmds(cmds); diff --git a/emigui/src/paint.rs b/emigui/src/paint.rs index 4681834e1..8f9526ded 100644 --- a/emigui/src/paint.rs +++ b/emigui/src/paint.rs @@ -7,7 +7,7 @@ mod texture_atlas; pub use { color::Color, - command::{Outline, PaintCmd}, + command::{LineStyle, PaintCmd}, fonts::{FontDefinitions, Fonts, TextStyle}, mesher::{PaintBatches, PaintOptions, Path, Triangles, Vertex}, texture_atlas::Texture, diff --git a/emigui/src/paint/command.rs b/emigui/src/paint/command.rs index 90600c7e0..d7c96f916 100644 --- a/emigui/src/paint/command.rs +++ b/emigui/src/paint/command.rs @@ -11,7 +11,7 @@ pub enum PaintCmd { Circle { center: Pos2, fill_color: Option, - outline: Option, + outline: Option, radius: f32, }, LineSegment { @@ -29,15 +29,14 @@ pub enum PaintCmd { path: Path, closed: bool, fill_color: Option, - outline: Option, + outline: Option, }, Rect { rect: Rect, corner_radius: f32, fill_color: Option, - outline: Option, + outline: Option, }, - /// Paint a single line of text Text { /// Top left corner of the first character. pos: Pos2, @@ -59,13 +58,14 @@ impl PaintCmd { } } +// TODO: rename LineStyle #[derive(Clone, Copy, Debug, Deserialize, Serialize)] -pub struct Outline { +pub struct LineStyle { pub width: f32, pub color: Color, } -impl Outline { +impl LineStyle { pub fn new(width: impl Into, color: impl Into) -> Self { Self { width: width.into(), diff --git a/emigui/src/paint/mesher.rs b/emigui/src/paint/mesher.rs index 519649352..f900b74b0 100644 --- a/emigui/src/paint/mesher.rs +++ b/emigui/src/paint/mesher.rs @@ -5,7 +5,7 @@ use { super::{ color::{self, srgba, Color}, fonts::Fonts, - Outline, PaintCmd, + LineStyle, PaintCmd, }, crate::math::*, }; @@ -693,7 +693,7 @@ pub fn paint_commands_into_triangles( rect: *clip_rect, corner_radius: 0.0, fill_color: None, - outline: Some(Outline::new(2.0, srgba(150, 255, 150, 255))), + outline: Some(LineStyle::new(2.0, srgba(150, 255, 150, 255))), }, triangles, ) diff --git a/emigui/src/style.rs b/emigui/src/style.rs index 7e8427802..16575873f 100644 --- a/emigui/src/style.rs +++ b/emigui/src/style.rs @@ -2,7 +2,7 @@ use serde_derive::{Deserialize, Serialize}; -use crate::{color::*, math::*, paint::Outline, types::*}; +use crate::{color::*, math::*, paint::LineStyle, types::*}; // TODO: split into Spacing and Style? #[derive(Clone, Copy, Debug, Deserialize, Serialize)] @@ -36,7 +36,7 @@ pub struct Style { /// For stuff like check marks in check boxes. pub line_width: f32, - pub thin_outline: Outline, + pub thin_outline: LineStyle, /// e.g. the background of windows pub background_fill_color: Color, @@ -75,7 +75,7 @@ impl Default for Style { interact: Default::default(), text_color: gray(160, 255), line_width: 1.0, - thin_outline: Outline::new(0.5, GRAY), + thin_outline: LineStyle::new(0.5, GRAY), background_fill_color: gray(32, 250), dark_bg_color: gray(0, 140), cursor_blink_hz: 1.0, @@ -104,7 +104,7 @@ impl Default for Interact { fill_color: srgba(120, 120, 200, 255), stroke_color: WHITE, stroke_width: 2.0, - rect_outline: Some(Outline::new(2.0, WHITE)), + rect_outline: Some(LineStyle::new(2.0, WHITE)), corner_radius: 5.0, }, hovered: WidgetStyle { @@ -112,7 +112,7 @@ impl Default for Interact { fill_color: srgba(100, 100, 150, 255), stroke_color: gray(240, 255), stroke_width: 1.5, - rect_outline: Some(Outline::new(1.0, WHITE)), + rect_outline: Some(LineStyle::new(1.0, WHITE)), corner_radius: 5.0, }, inactive: WidgetStyle { @@ -120,7 +120,7 @@ impl Default for Interact { fill_color: srgba(60, 60, 80, 255), stroke_color: gray(210, 255), // Mustn't look grayed out! stroke_width: 1.0, - rect_outline: Some(Outline::new(1.0, white(128))), + rect_outline: Some(LineStyle::new(1.0, white(128))), corner_radius: 0.0, }, } @@ -156,7 +156,7 @@ pub struct WidgetStyle { /// For surrounding rectangle of things that need it, /// like buttons, the box of the checkbox, etc. - pub rect_outline: Option, + pub rect_outline: Option, /// Button frames etdc pub corner_radius: f32, diff --git a/emigui/src/ui.rs b/emigui/src/ui.rs index 27a0e417e..41b0253f1 100644 --- a/emigui/src/ui.rs +++ b/emigui/src/ui.rs @@ -358,7 +358,7 @@ impl Ui { self.add_paint_cmd(PaintCmd::Rect { rect, corner_radius: 0.0, - outline: Some(Outline::new(1.0, LIGHT_BLUE)), + outline: Some(LineStyle::new(1.0, LIGHT_BLUE)), fill_color: None, }); @@ -442,7 +442,7 @@ impl Ui { self.add_paint_cmd(PaintCmd::Rect { corner_radius: 0.0, fill_color: None, - outline: Some(Outline::new(1.0, color::RED)), + outline: Some(LineStyle::new(1.0, color::RED)), rect, }); let align = (Align::Min, Align::Min); diff --git a/emigui/src/widgets/slider.rs b/emigui/src/widgets/slider.rs index 204913878..9f68a9141 100644 --- a/emigui/src/widgets/slider.rs +++ b/emigui/src/widgets/slider.rs @@ -175,14 +175,14 @@ impl<'a> Widget for Slider<'a> { rect: rail_rect, corner_radius: rail_radius, fill_color: Some(ui.style().background_fill_color), - outline: Some(Outline::new(1.0, color::gray(200, 255))), // TODO + 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), - outline: Some(Outline::new( + outline: Some(LineStyle::new( ui.style().interact(&interact).stroke_width, ui.style().interact(&interact).stroke_color, )),