#![cfg_attr(target_arch = "xtensa", no_std, no_main)]
#![cfg_attr(
target_arch = "xtensa",
feature(impl_trait_in_assoc_type, type_alias_impl_trait)
)]
use oxivgl::{
style::{GradDsc, GradExtend, Selector, Style, StyleBuilder, color_make, lv_pct},
view::{NavAction, View},
widgets::{Button, Obj, WidgetError},
};
#[derive(Default)]
struct Grad2 {
_obj: Option<Obj<'static>>,
_bullet1: Option<Button<'static>>,
_bullet2: Option<Button<'static>>,
_style: Option<Style>, }
impl View for Grad2 {
fn create(&mut self, container: &Obj<'static>) -> Result<(), WidgetError> {
let colors = [color_make(0xff, 0, 0), color_make(0, 0xff, 0)];
let opas = [255u8, 0];
let mut grad = GradDsc::new();
grad.init_stops(&colors, &opas, &[])
.linear(100, 100, 200, 150, GradExtend::Pad);
let mut style = StyleBuilder::new();
style
.bg_opa(255)
.bg_grad(grad)
.border_width(2)
.pad_all(0)
.radius(12);
let style = style.build();
let obj = Obj::new(container)?;
obj.size(lv_pct(80), lv_pct(80)).center();
obj.add_style(&style, Selector::DEFAULT);
let bullet1 = Button::new(&obj)?;
bullet1.size(15, 15).pos(100, 100);
bullet1.bg_color(0x0000ff).bg_opa(255);
let bullet2 = Button::new(&obj)?;
bullet2.size(15, 15).pos(200, 150);
bullet2.bg_color(0x00ffff).bg_opa(255);
self._style = Some(style);
self._obj = Some(obj);
self._bullet1 = Some(bullet1);
self._bullet2 = Some(bullet2);
Ok(())
}
fn update(&mut self) -> Result<NavAction, WidgetError> {
Ok(NavAction::None)
}
}
oxivgl_examples_common::example_main!(Grad2::default());