fixup
This commit is contained in:
parent
49d0637fc8
commit
277d9052b0
22
src/lib.rs
22
src/lib.rs
|
@ -1,6 +1,6 @@
|
||||||
use orbtk::prelude::*;
|
use orbtk::prelude::*;
|
||||||
use rhai::RegisterFn;
|
use rhai::RegisterFn;
|
||||||
use rhai::{packages::*, Engine, EvalAltResult, INT};
|
use rhai::{Engine};
|
||||||
use std::sync::mpsc::{Receiver, Sender};
|
use std::sync::mpsc::{Receiver, Sender};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
pub mod parser;
|
pub mod parser;
|
||||||
|
@ -33,11 +33,11 @@ impl Widget for MainViewState {
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
||||||
fn insert_handler(self, handler: impl Into<Rc<dyn EventHandler>>) -> Self {
|
fn insert_handler(self, _handler: impl Into<Rc<dyn EventHandler>>) -> Self {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn child(self, child: Entity) -> Self {
|
fn child(self, _child: Entity) -> Self {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ impl MVState {
|
||||||
.register_fn("update_property", move |x: &str, y: &str, z: &str| {
|
.register_fn("update_property", move |x: &str, y: &str, z: &str| {
|
||||||
tx.send((String::from(x), String::from(y), String::from(z)));
|
tx.send((String::from(x), String::from(y), String::from(z)));
|
||||||
});
|
});
|
||||||
let result = self.engine.eval::<()>(action.as_str());
|
let _result = self.engine.eval::<()>(action.as_str());
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
@ -69,12 +69,12 @@ impl State for MVState {
|
||||||
self.update(registry, ctx);
|
self.update(registry, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(&mut self, registry: &mut Registry, ctx: &mut Context) {
|
fn update(&mut self, _registry: &mut Registry, ctx: &mut Context) {
|
||||||
match &self.rx {
|
match &self.rx {
|
||||||
Some(rx) => match rx.recv_timeout(Duration::from_millis(1)) {
|
Some(rx) => match rx.recv_timeout(Duration::from_millis(1)) {
|
||||||
Ok((x, y, z)) => {
|
Ok((x, y, z)) => {
|
||||||
ctx.child(x.as_str())
|
ctx.child(x.as_str())
|
||||||
.set::<String16>(y.as_str(), String16::from("hijack"));
|
.set::<String16>(y.as_str(), String16::from(z));
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
|
@ -106,16 +106,16 @@ fn render_ctx(
|
||||||
grid = grid.attach(Grid::row(row as usize));
|
grid = grid.attach(Grid::row(row as usize));
|
||||||
grid = grid.attach(Grid::column(col as usize));
|
grid = grid.attach(Grid::column(col as usize));
|
||||||
let rows = parse_number(child.properties.get("rows")) as u32;
|
let rows = parse_number(child.properties.get("rows")) as u32;
|
||||||
let cols = parse_number(child.properties.get("cols")) as u32;
|
let _cols = parse_number(child.properties.get("cols")) as u32;
|
||||||
|
|
||||||
let mut grid_rows = Rows::create();
|
let mut grid_rows = Rows::create();
|
||||||
for i in 0..rows {
|
for _i in 0..rows {
|
||||||
grid_rows = grid_rows.row("stretch");
|
grid_rows = grid_rows.row("stretch");
|
||||||
}
|
}
|
||||||
grid = grid.rows(grid_rows.build());
|
grid = grid.rows(grid_rows.build());
|
||||||
|
|
||||||
let mut grid_cols = Columns::create();
|
let mut grid_cols = Columns::create();
|
||||||
for i in 0..rows {
|
for _i in 0..rows {
|
||||||
grid_cols = grid_cols.column("stretch");
|
grid_cols = grid_cols.column("stretch");
|
||||||
}
|
}
|
||||||
grid = grid.columns(grid_cols.build());
|
grid = grid.columns(grid_cols.build());
|
||||||
|
@ -140,8 +140,8 @@ fn render_ctx(
|
||||||
return Some(grid.build(ctx));
|
return Some(grid.build(ctx));
|
||||||
}
|
}
|
||||||
"Rectangle" => {
|
"Rectangle" => {
|
||||||
let width = parse_number(child.properties.get("width"));
|
let _width = parse_number(child.properties.get("width"));
|
||||||
let height = parse_number(child.properties.get("height"));
|
let _height = parse_number(child.properties.get("height"));
|
||||||
|
|
||||||
let color = match child.properties.get("color") {
|
let color = match child.properties.get("color") {
|
||||||
Some(QmlString(col)) => match col.as_str() {
|
Some(QmlString(col)) => match col.as_str() {
|
||||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -1,20 +1,15 @@
|
||||||
use orbtk::prelude::*;
|
use orbtk::prelude::*;
|
||||||
use rhai::RegisterFn;
|
|
||||||
use rhai::{packages::*, Engine, EvalAltResult, INT};
|
|
||||||
|
|
||||||
use rqml::parser::parse_qml;
|
use rqml::parser::parse_qml;
|
||||||
use rqml::{MVState, MainViewState};
|
use rqml::{MVState, MainViewState};
|
||||||
use std::borrow::{Borrow, BorrowMut};
|
|
||||||
use std::fs::read_to_string;
|
|
||||||
use std::sync::mpsc;
|
use std::sync::mpsc;
|
||||||
use std::sync::mpsc::{Receiver, Sender};
|
use std::sync::mpsc::{Receiver, Sender};
|
||||||
use std::thread;
|
use rhai::Engine;
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
Application::new()
|
Application::new()
|
||||||
.window(|ctx| {
|
.window(|ctx| {
|
||||||
let mut app_context: HashMap<String, Entity> = HashMap::new();
|
let _app_context: HashMap<String, Entity> = HashMap::new();
|
||||||
let qml_doc = parse_qml("./res/example.qml");
|
let qml_doc = parse_qml("./res/example.qml");
|
||||||
let top_level = qml_doc.children.clone();
|
let top_level = qml_doc.children.clone();
|
||||||
println!("{:?}", qml_doc);
|
println!("{:?}", qml_doc);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
extern crate pest;
|
extern crate pest;
|
||||||
|
|
||||||
use crate::Value::{QmlIdent, QmlNumber, QmlString};
|
use crate::Value::{QmlIdent, QmlNumber, QmlString};
|
||||||
use pest::iterators::{Pair, Pairs};
|
use pest::iterators::{Pairs};
|
||||||
use pest::Parser;
|
use pest::Parser;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fs::read_to_string;
|
use std::fs::read_to_string;
|
||||||
|
|
Loading…
Reference in New Issue