mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 08:11:12 +00:00
Use Rect position for drawing
This commit is contained in:
parent
cf91390e56
commit
ce4f22fd15
2 changed files with 5 additions and 7 deletions
|
@ -319,6 +319,7 @@ pub struct Bounds {
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
struct Drawable {
|
struct Drawable {
|
||||||
|
pos: Vector2<f32>,
|
||||||
bounds: Bounds,
|
bounds: Bounds,
|
||||||
content: DrawableContent,
|
content: DrawableContent,
|
||||||
}
|
}
|
||||||
|
@ -346,15 +347,10 @@ fn process_drawable(
|
||||||
load_op: LoadOp<wgpu::Color>,
|
load_op: LoadOp<wgpu::Color>,
|
||||||
texture_size: Bounds,
|
texture_size: Bounds,
|
||||||
) {
|
) {
|
||||||
// TODO iterate through drawables,
|
|
||||||
// calculating a pos using offset,
|
|
||||||
// calling draw and updating bounding boxes
|
|
||||||
let pos: Vector2<f32> = (0.0, 0.0).into();
|
|
||||||
|
|
||||||
draw(
|
draw(
|
||||||
drawable.bounds,
|
drawable.bounds,
|
||||||
drawable.content,
|
drawable.content,
|
||||||
pos,
|
drawable.pos,
|
||||||
staging_belt,
|
staging_belt,
|
||||||
glyph_brush,
|
glyph_brush,
|
||||||
cmd_encoder,
|
cmd_encoder,
|
||||||
|
@ -444,6 +440,7 @@ fn to_drawable(
|
||||||
};
|
};
|
||||||
|
|
||||||
let drawable = Drawable {
|
let drawable = Drawable {
|
||||||
|
pos: (rect.left, rect.top).into(),
|
||||||
bounds,
|
bounds,
|
||||||
content: DrawableContent::FillRect {
|
content: DrawableContent::FillRect {
|
||||||
color: rect.color,
|
color: rect.color,
|
||||||
|
@ -489,6 +486,7 @@ fn to_drawable(
|
||||||
}
|
}
|
||||||
|
|
||||||
let drawable = Drawable {
|
let drawable = Drawable {
|
||||||
|
pos: (0.0, 0.0).into(), // TODO store the pos in Text and read it here
|
||||||
bounds: text_bounds,
|
bounds: text_bounds,
|
||||||
content: DrawableContent::Text(section, offset),
|
content: DrawableContent::Text(section, offset),
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,7 +9,7 @@ pub extern "C" fn rust_main() -> i32 {
|
||||||
height: 1000.0,
|
height: 1000.0,
|
||||||
};
|
};
|
||||||
|
|
||||||
gui::run_event_loop("test title", state).expect("Error running event loop");
|
gui::run_event_loop("RocOut!", state).expect("Error running event loop");
|
||||||
|
|
||||||
// Exit code
|
// Exit code
|
||||||
0
|
0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue