use {Color, Colorable, Dimensions, Sizeable, Widget};
use super::Style as Style;
use widget;
#[derive(Copy, Clone, Debug)]
pub struct Oval {
pub common: widget::CommonBuilder,
pub style: Style,
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct State;
impl Oval {
pub fn styled(dim: Dimensions, style: Style) -> Self {
Oval {
common: widget::CommonBuilder::new(),
style: style,
}.wh(dim)
}
pub fn fill(dim: Dimensions) -> Self {
Oval::styled(dim, Style::fill())
}
pub fn fill_with(dim: Dimensions, color: Color) -> Self {
Oval::styled(dim, Style::fill_with(color))
}
pub fn outline(dim: Dimensions) -> Self {
Oval::styled(dim, Style::outline())
}
pub fn outline_styled(dim: Dimensions, line_style: widget::line::Style) -> Self {
Oval::styled(dim, Style::outline_styled(line_style))
}
}
impl Widget for Oval {
type State = State;
type Style = Style;
type Event = ();
fn common(&self) -> &widget::CommonBuilder {
&self.common
}
fn common_mut(&mut self) -> &mut widget::CommonBuilder {
&mut self.common
}
fn init_state(&self, _: widget::id::Generator) -> Self::State {
State
}
fn style(&self) -> Self::Style {
self.style.clone()
}
fn update(self, _args: widget::UpdateArgs<Self>) -> Self::Event {
}
}
impl Colorable for Oval {
fn color(mut self, color: Color) -> Self {
self.style.set_color(color);
self
}
}