mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Hook up a stub layout task to the display lister
This commit is contained in:
parent
e089607ea0
commit
9a5f88d380
5 changed files with 74 additions and 33 deletions
|
@ -1,7 +1,8 @@
|
|||
fn input(
|
||||
osmain_ch: comm::chan<osmain::msg>,
|
||||
draw_ch: comm::chan<gfx::renderer::msg>,
|
||||
model_ch: comm::chan<layout::lister::msg>
|
||||
model_ch: comm::chan<layout::lister::msg>,
|
||||
layout_ch: comm::chan<layout::layout::msg>
|
||||
) {
|
||||
task::spawn {||
|
||||
let key_po = comm::port();
|
||||
|
@ -9,9 +10,12 @@ fn input(
|
|||
loop {
|
||||
alt comm::recv(key_po) {
|
||||
_ {
|
||||
comm::send(layout_ch, layout::layout::exit);
|
||||
comm::send(model_ch, layout::lister::exit);
|
||||
|
||||
let draw_exit_confirm_po = comm::port();
|
||||
comm::send(draw_ch, gfx::renderer::exit(comm::chan(draw_exit_confirm_po)));
|
||||
|
||||
comm::recv(draw_exit_confirm_po);
|
||||
comm::send(osmain_ch, osmain::exit);
|
||||
break;
|
||||
|
|
22
src/servo/layout/layout.rs
Normal file
22
src/servo/layout/layout.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
import task::*;
|
||||
import comm::*;
|
||||
|
||||
enum msg {
|
||||
do_layout,
|
||||
exit
|
||||
}
|
||||
|
||||
fn layout(lister: chan<lister::msg>) -> chan<msg> {
|
||||
spawn_listener::<msg> {|po|
|
||||
loop {
|
||||
alt recv(po) {
|
||||
do_layout {
|
||||
send(lister, lister::build)
|
||||
}
|
||||
exit {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,7 +18,7 @@ enum msg {
|
|||
|
||||
fn lister(renderer: chan<renderer::msg>) -> chan<msg> {
|
||||
|
||||
spawn_listener {|po|
|
||||
spawn_listener::<msg> {|po|
|
||||
let mut x1 = 100;
|
||||
let mut y1 = 100;
|
||||
let mut w1 = 200;
|
||||
|
@ -28,38 +28,43 @@ fn lister(renderer: chan<renderer::msg>) -> chan<msg> {
|
|||
let mut w2 = 300;
|
||||
let mut h2 = 300;
|
||||
|
||||
while !peek(po) {
|
||||
let dlist = [
|
||||
display_item({
|
||||
item_type: solid_color,
|
||||
bounds: geom::box(
|
||||
int_to_au(x1),
|
||||
int_to_au(y1),
|
||||
int_to_au(w1),
|
||||
int_to_au(h1))
|
||||
}),
|
||||
display_item({
|
||||
item_type: solid_color,
|
||||
bounds: geom::box(
|
||||
int_to_au(x2),
|
||||
int_to_au(y2),
|
||||
int_to_au(w2),
|
||||
int_to_au(h2))
|
||||
})
|
||||
];
|
||||
loop {
|
||||
alt recv(po) {
|
||||
build {
|
||||
let dlist = [
|
||||
display_item({
|
||||
item_type: solid_color,
|
||||
bounds: geom::box(
|
||||
int_to_au(x1),
|
||||
int_to_au(y1),
|
||||
int_to_au(w1),
|
||||
int_to_au(h1))
|
||||
}),
|
||||
display_item({
|
||||
item_type: solid_color,
|
||||
bounds: geom::box(
|
||||
int_to_au(x2),
|
||||
int_to_au(y2),
|
||||
int_to_au(w2),
|
||||
int_to_au(h2))
|
||||
})
|
||||
];
|
||||
|
||||
send(renderer, gfx::renderer::draw(dlist));
|
||||
send(renderer, gfx::renderer::draw(dlist));
|
||||
|
||||
std::timer::sleep(100u);
|
||||
|
||||
x1 += 1;
|
||||
y1 += 1;
|
||||
x2 -= 1;
|
||||
y2 -= 1;
|
||||
if x1 > 800 { x1 = 0 }
|
||||
if y1 > 600 { y1 = 0 }
|
||||
if x2 < 0 { x2 = 800 }
|
||||
if y2 < 0 { y2 = 600 }
|
||||
x1 += 1;
|
||||
y1 += 1;
|
||||
x2 -= 1;
|
||||
y2 -= 1;
|
||||
if x1 > 800 { x1 = 0 }
|
||||
if y1 > 600 { y1 = 0 }
|
||||
if x2 < 0 { x2 = 800 }
|
||||
if y2 < 0 { y2 = 600 }
|
||||
}
|
||||
exit {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ mod layout {
|
|||
mod base;
|
||||
mod display_list;
|
||||
mod lister;
|
||||
mod layout;
|
||||
}
|
||||
|
||||
mod widget {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import comm::*;
|
||||
import libc::c_double;
|
||||
import azure::*;
|
||||
import azure::bindgen::*;
|
||||
|
@ -14,6 +15,14 @@ fn main() {
|
|||
// The display list builder
|
||||
let lister = layout::lister::lister(renderer);
|
||||
|
||||
// The layout task
|
||||
let layout = layout::layout::layout(lister);
|
||||
|
||||
// The keyboard handler
|
||||
input::input(osmain_ch, renderer, lister);
|
||||
input::input(osmain_ch, renderer, lister, layout);
|
||||
|
||||
loop {
|
||||
std::timer::sleep(10u);
|
||||
send(layout, layout::layout::do_layout);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue