todo
This commit is contained in:
+2
-2
@@ -2,12 +2,12 @@ pub mod div;
|
||||
|
||||
use crate::widget::Element;
|
||||
|
||||
pub struct Rect(pub u32);
|
||||
pub struct Rect(pub u32, pub usize);
|
||||
|
||||
impl Element for Rect {
|
||||
fn render(&mut self, scope: &mut crate::render::RenderScope) {
|
||||
let (w, h) = scope.get_size();
|
||||
scope.draw_rect(0, 0, w, h, self.0);
|
||||
scope.draw_rect_rounded(0, 0, w, h, self.1, self.0);
|
||||
}
|
||||
|
||||
fn as_any(&self) -> &dyn std::any::Any {
|
||||
|
||||
+22
-25
@@ -29,8 +29,8 @@ fn main() {
|
||||
app.extension(MouseExtension::new());
|
||||
app.extension(VelocityExtension);
|
||||
|
||||
// milestones(&mut app);
|
||||
todos(&mut app);
|
||||
milestones(&mut app);
|
||||
// todos(&mut app);
|
||||
|
||||
app.run().unwrap();
|
||||
}
|
||||
@@ -64,29 +64,26 @@ fn milestones(app: &mut Screen) {
|
||||
}
|
||||
|
||||
fn todos(app: &mut Screen) {
|
||||
todo_box(app, Transform::center(), true, "Hello, World!");
|
||||
for row in 0..10 {
|
||||
let mut task = Div {
|
||||
style: DivStyle {
|
||||
background_color: 0x191919,
|
||||
corner_radius: 13,
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
task.draw(custom(plus)).component(Transform::new());
|
||||
|
||||
app.draw(task)
|
||||
.component(Transform::new().dimensions(550, 80).pos(
|
||||
osgui::style::Position::Center,
|
||||
osgui::style::Position::Const(90 + (100 * row)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
fn todo_box(app: &mut Screen, transform: Transform, done: bool, text: &str) {
|
||||
let text = text.to_string();
|
||||
app.draw(custom(move |scope: &mut RenderScope| {
|
||||
scope.draw_rect_rounded(0, 2, 24, 24, 8, 0xffffff);
|
||||
scope.draw_rect_rounded(3, 5, 18, 18, 4, 0x010101);
|
||||
if done {
|
||||
let (mut x, mut y) = (5, 14);
|
||||
while x != 8 {
|
||||
scope.draw_rect_rounded(x, y, 2, 2, 4, 0xffffff);
|
||||
x += 1;
|
||||
y += 1;
|
||||
}
|
||||
|
||||
while x != 17 && y != 7 {
|
||||
scope.draw_rect_rounded(x, y, 3, 2, 4, 0xffffff);
|
||||
x += 1;
|
||||
y -= 1;
|
||||
}
|
||||
}
|
||||
scope.draw_text(29, 0, 28.0, &text, 0xffffff);
|
||||
}))
|
||||
.component(transform.clone());
|
||||
fn plus(scope: &mut RenderScope) {
|
||||
scope.draw_rect(0, 12, 26, 3, 0xffffff);
|
||||
scope.draw_rect(12, 0, 3, 26, 0xffffff);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user