Browse Source

[refactor] rename Outline to LineStyle

readable-ids
Emil Ernerfeldt 5 years ago
parent
commit
0bb042924f
  1. 4
      emigui/src/containers/collapsing_header.rs
  2. 10
      emigui/src/containers/frame.rs
  3. 4
      emigui/src/context.rs
  4. 2
      emigui/src/examples/app.rs
  5. 2
      emigui/src/paint.rs
  6. 12
      emigui/src/paint/command.rs
  7. 4
      emigui/src/paint/mesher.rs
  8. 14
      emigui/src/style.rs
  9. 4
      emigui/src/ui.rs
  10. 4
      emigui/src/widgets/slider.rs

4
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)),
});
}

10
emigui/src/containers/frame.rs

@ -8,7 +8,7 @@ pub struct Frame {
pub margin: Vec2,
pub corner_radius: f32,
pub fill_color: Option<Color>,
pub outline: Option<Outline>,
pub outline: Option<LineStyle>,
}
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<Outline>) -> Self {
pub fn outline(mut self, outline: Option<LineStyle>) -> Self {
self.outline = outline;
self
}

4
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,
},
);

2
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);

2
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,

12
emigui/src/paint/command.rs

@ -11,7 +11,7 @@ pub enum PaintCmd {
Circle {
center: Pos2,
fill_color: Option<Color>,
outline: Option<Outline>,
outline: Option<LineStyle>,
radius: f32,
},
LineSegment {
@ -29,15 +29,14 @@ pub enum PaintCmd {
path: Path,
closed: bool,
fill_color: Option<Color>,
outline: Option<Outline>,
outline: Option<LineStyle>,
},
Rect {
rect: Rect,
corner_radius: f32,
fill_color: Option<Color>,
outline: Option<Outline>,
outline: Option<LineStyle>,
},
/// 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<f32>, color: impl Into<Color>) -> Self {
Self {
width: width.into(),

4
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,
)

14
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<Outline>,
pub rect_outline: Option<LineStyle>,
/// Button frames etdc
pub corner_radius: f32,

4
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);

4
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,
)),

Loading…
Cancel
Save