Widget
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
pub mod layout;
|
pub mod layout;
|
||||||
pub mod render;
|
pub mod render;
|
||||||
pub mod widget;
|
|
||||||
pub mod unit;
|
pub mod unit;
|
||||||
|
pub mod widget;
|
||||||
|
|||||||
@@ -41,6 +41,12 @@ impl From<(u16, u16)> for Point {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<u16> for Point {
|
||||||
|
fn from(value: u16) -> Self {
|
||||||
|
Self { x: value, y: value }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<Rect> for Point {
|
impl From<Rect> for Point {
|
||||||
fn from(value: Rect) -> Self {
|
fn from(value: Rect) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
use crate::render::RenderScope;
|
|
||||||
|
|
||||||
pub trait Widget {
|
|
||||||
fn render(&self, scope: &mut RenderScope);
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
use crate::render::RenderScope;
|
||||||
|
|
||||||
|
pub trait Widget {
|
||||||
|
fn render(&self, scope: &mut RenderScope);
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Widget for str {
|
||||||
|
fn render(&self, scope: &mut RenderScope) {
|
||||||
|
scope.draw_text(0, self);
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-1
@@ -1,4 +1,7 @@
|
|||||||
use pulse_ui::layout::{LayoutItem, Rect, Size, layout};
|
use pulse_ui::{
|
||||||
|
layout::{LayoutItem, layout},
|
||||||
|
unit::{Rect, Size},
|
||||||
|
};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let layout = layout(vec![
|
let layout = layout(vec![
|
||||||
|
|||||||
Reference in New Issue
Block a user