combobox, minor fixes
This commit is contained in:
parent
232e19d0a9
commit
4b86519fa0
|
@ -139,9 +139,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.0.57"
|
version = "1.0.58"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0fde55d2a2bfaa4c9668bbc63f531fbdeee3ffe188f4662511ce2c22b3eedebe"
|
checksum = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cfg-if"
|
name = "cfg-if"
|
||||||
|
@ -281,9 +281,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "deflate"
|
name = "deflate"
|
||||||
version = "0.8.4"
|
version = "0.8.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e7e5d2a2273fed52a7f947ee55b092c4057025d7a3e04e5ecdbd25d6c3fb1bd7"
|
checksum = "73770f8e1fe7d64df17ca66ad28994a0a623ea497fa69486e14984e715c5d174"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"adler32",
|
"adler32",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
|
@ -359,9 +359,9 @@ checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "euclid"
|
name = "euclid"
|
||||||
version = "0.20.13"
|
version = "0.20.14"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "555d51b9a929edb14183fad621e2d5736fc8760707a24246047288d4c142b6bd"
|
checksum = "2bb7ef65b3777a325d1eeefefab5b6d4959da54747e33bd6258e789640f307ad"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"num-traits",
|
"num-traits",
|
||||||
]
|
]
|
||||||
|
@ -427,9 +427,9 @@ checksum = "452b31b3ffe7cf13de531eefae493301c85995a953c808d7c79a8f45abae0706"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hermit-abi"
|
name = "hermit-abi"
|
||||||
version = "0.1.14"
|
version = "0.1.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b9586eedd4ce6b3c498bc3b4dd92fc9f11166aa908a914071953768066c67909"
|
checksum = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
@ -463,9 +463,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "instant"
|
name = "instant"
|
||||||
version = "0.1.5"
|
version = "0.1.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "69da7ce1490173c2bf4d26bc8be429aaeeaf4cce6c4b970b7949651fa17655fe"
|
checksum = "5b141fdc7836c525d4d594027d318c84161ca17aaf8113ab1f81ab93ae897485"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
|
@ -480,9 +480,9 @@ checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jpeg-decoder"
|
name = "jpeg-decoder"
|
||||||
version = "0.1.19"
|
version = "0.1.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5b47b4c4e017b01abdc5bcc126d2d1002e5a75bbe3ce73f9f4f311a916363704"
|
checksum = "cc797adac5f083b8ff0ca6f6294a999393d76e197c36488e2ef732c4715f6fa3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"rayon",
|
"rayon",
|
||||||
|
@ -505,9 +505,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.71"
|
version = "0.2.72"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49"
|
checksum = "a9f8082297d534141b30c8d39e9b1773713ab50fdbe4ff30f750d063b3bfd701"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libloading"
|
name = "libloading"
|
||||||
|
@ -699,7 +699,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "orbtk"
|
name = "orbtk"
|
||||||
version = "0.3.1-alpha3"
|
version = "0.3.1-alpha3"
|
||||||
source = "git+https://github.com/redox-os/orbtk.git?branch=develop#e8b0f9a3f8dc322414f1ea64de57f72979e17496"
|
source = "git+https://github.com/redox-os/orbtk.git?branch=develop#cef2271030b413d680e3d73c6f9c733f1971229a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dces",
|
"dces",
|
||||||
"orbtk-api",
|
"orbtk-api",
|
||||||
|
@ -716,7 +716,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "orbtk-api"
|
name = "orbtk-api"
|
||||||
version = "0.3.1-alpha3"
|
version = "0.3.1-alpha3"
|
||||||
source = "git+https://github.com/redox-os/orbtk.git?branch=develop#e8b0f9a3f8dc322414f1ea64de57f72979e17496"
|
source = "git+https://github.com/redox-os/orbtk.git?branch=develop#cef2271030b413d680e3d73c6f9c733f1971229a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dces",
|
"dces",
|
||||||
"derive_more",
|
"derive_more",
|
||||||
|
@ -738,7 +738,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "orbtk-css-engine"
|
name = "orbtk-css-engine"
|
||||||
version = "0.3.1-alpha3"
|
version = "0.3.1-alpha3"
|
||||||
source = "git+https://github.com/redox-os/orbtk.git?branch=develop#e8b0f9a3f8dc322414f1ea64de57f72979e17496"
|
source = "git+https://github.com/redox-os/orbtk.git?branch=develop#cef2271030b413d680e3d73c6f9c733f1971229a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cssparser",
|
"cssparser",
|
||||||
"orbtk-utils",
|
"orbtk-utils",
|
||||||
|
@ -747,7 +747,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "orbtk-proc-macros"
|
name = "orbtk-proc-macros"
|
||||||
version = "0.3.1-alpha3"
|
version = "0.3.1-alpha3"
|
||||||
source = "git+https://github.com/redox-os/orbtk.git?branch=develop#e8b0f9a3f8dc322414f1ea64de57f72979e17496"
|
source = "git+https://github.com/redox-os/orbtk.git?branch=develop#cef2271030b413d680e3d73c6f9c733f1971229a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"case",
|
"case",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
|
@ -758,7 +758,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "orbtk-render"
|
name = "orbtk-render"
|
||||||
version = "0.3.1-alpha3"
|
version = "0.3.1-alpha3"
|
||||||
source = "git+https://github.com/redox-os/orbtk.git?branch=develop#e8b0f9a3f8dc322414f1ea64de57f72979e17496"
|
source = "git+https://github.com/redox-os/orbtk.git?branch=develop#cef2271030b413d680e3d73c6f9c733f1971229a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"image",
|
"image",
|
||||||
"orbtk-utils",
|
"orbtk-utils",
|
||||||
|
@ -770,7 +770,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "orbtk-shell"
|
name = "orbtk-shell"
|
||||||
version = "0.3.1-alpha3"
|
version = "0.3.1-alpha3"
|
||||||
source = "git+https://github.com/redox-os/orbtk.git?branch=develop#e8b0f9a3f8dc322414f1ea64de57f72979e17496"
|
source = "git+https://github.com/redox-os/orbtk.git?branch=develop#cef2271030b413d680e3d73c6f9c733f1971229a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"console_error_panic_hook",
|
"console_error_panic_hook",
|
||||||
"derive_more",
|
"derive_more",
|
||||||
|
@ -787,7 +787,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "orbtk-theme"
|
name = "orbtk-theme"
|
||||||
version = "0.3.1-alpha3"
|
version = "0.3.1-alpha3"
|
||||||
source = "git+https://github.com/redox-os/orbtk.git?branch=develop#e8b0f9a3f8dc322414f1ea64de57f72979e17496"
|
source = "git+https://github.com/redox-os/orbtk.git?branch=develop#cef2271030b413d680e3d73c6f9c733f1971229a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"orbtk-css-engine",
|
"orbtk-css-engine",
|
||||||
|
@ -796,7 +796,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "orbtk-tree"
|
name = "orbtk-tree"
|
||||||
version = "0.3.1-alpha3"
|
version = "0.3.1-alpha3"
|
||||||
source = "git+https://github.com/redox-os/orbtk.git?branch=develop#e8b0f9a3f8dc322414f1ea64de57f72979e17496"
|
source = "git+https://github.com/redox-os/orbtk.git?branch=develop#cef2271030b413d680e3d73c6f9c733f1971229a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dces",
|
"dces",
|
||||||
]
|
]
|
||||||
|
@ -804,12 +804,12 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "orbtk-utils"
|
name = "orbtk-utils"
|
||||||
version = "0.3.1-alpha3"
|
version = "0.3.1-alpha3"
|
||||||
source = "git+https://github.com/redox-os/orbtk.git?branch=develop#e8b0f9a3f8dc322414f1ea64de57f72979e17496"
|
source = "git+https://github.com/redox-os/orbtk.git?branch=develop#cef2271030b413d680e3d73c6f9c733f1971229a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "orbtk-widgets"
|
name = "orbtk-widgets"
|
||||||
version = "0.3.1-alpha3"
|
version = "0.3.1-alpha3"
|
||||||
source = "git+https://github.com/redox-os/orbtk.git?branch=develop#e8b0f9a3f8dc322414f1ea64de57f72979e17496"
|
source = "git+https://github.com/redox-os/orbtk.git?branch=develop#cef2271030b413d680e3d73c6f9c733f1971229a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dces",
|
"dces",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
@ -914,9 +914,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pkg-config"
|
name = "pkg-config"
|
||||||
version = "0.3.17"
|
version = "0.3.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677"
|
checksum = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "png"
|
name = "png"
|
||||||
|
@ -938,7 +938,7 @@ checksum = "c150bf7479fafe3dd8740dbe48cc33b2a3efb7b0fe3483aced8bbc39f6d0238d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"crc32fast",
|
"crc32fast",
|
||||||
"deflate 0.8.4",
|
"deflate 0.8.6",
|
||||||
"miniz_oxide",
|
"miniz_oxide",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1183,9 +1183,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_syscall"
|
name = "redox_syscall"
|
||||||
version = "0.1.56"
|
version = "0.1.57"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
|
checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_users"
|
name = "redox_users"
|
||||||
|
@ -1408,9 +1408,9 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smallvec"
|
name = "smallvec"
|
||||||
version = "1.4.0"
|
version = "1.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4"
|
checksum = "3757cb9d89161a2f24e1cf78efa0c1fcff485d18e3f55e0aa3480824ddaa0f3f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "spin_sleep"
|
name = "spin_sleep"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Grid {
|
Grid {
|
||||||
rows:2
|
rows:2
|
||||||
cols:2
|
columns:2
|
||||||
Rectangle {
|
Rectangle {
|
||||||
color: "#F3F0F4"
|
color: "#F3F0F4"
|
||||||
Text {
|
Text {
|
||||||
|
|
|
@ -6,18 +6,20 @@ Grid {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HelloTwitter {
|
HelloTwitter {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
color: "#8c63a4"
|
color: "#634B72"
|
||||||
Text {
|
Text {
|
||||||
id: target
|
id: target
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: "Hello, World!"
|
text: "Hello, World!"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Grid {
|
Grid {
|
||||||
rows: 2
|
rows: 2
|
||||||
columns: 2
|
columns: 2
|
||||||
|
@ -43,6 +45,20 @@ Grid {
|
||||||
]]
|
]]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Rectangle {
|
||||||
|
color: "#b29dbe"
|
||||||
|
ComboBox {
|
||||||
|
id: combobox
|
||||||
|
anchors.centerIn: parent
|
||||||
|
items = [[
|
||||||
|
["1", "World", "@@#$@#"]
|
||||||
|
]]
|
||||||
|
selected: 2
|
||||||
|
onselect = [[
|
||||||
|
update_property("target", "text", get_property("combobox","selected"));
|
||||||
|
]]
|
||||||
|
}
|
||||||
|
}
|
||||||
Rectangle {
|
Rectangle {
|
||||||
color: "#F3F0F4"
|
color: "#F3F0F4"
|
||||||
Button {
|
Button {
|
||||||
|
@ -54,12 +70,6 @@ Grid {
|
||||||
]]
|
]]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Rectangle {
|
|
||||||
color: "#b29dbe"
|
|
||||||
Text {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
text: "Hello, World!"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
25
src/lib.rs
25
src/lib.rs
|
@ -1,7 +1,7 @@
|
||||||
use orbtk::prelude::*;
|
use orbtk::prelude::*;
|
||||||
|
|
||||||
use rhai::Engine;
|
|
||||||
use rhai::RegisterFn;
|
use rhai::RegisterFn;
|
||||||
|
use rhai::{Array, 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;
|
||||||
|
@ -14,6 +14,7 @@ use evmap::{ReadHandle, WriteHandle};
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use std::borrow::BorrowMut;
|
use std::borrow::BorrowMut;
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
|
use std::ops::Index;
|
||||||
use std::sync::mpsc;
|
use std::sync::mpsc;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -131,13 +132,6 @@ impl State for MVState {
|
||||||
rng.gen_range(0.0, 1.0) as f32
|
rng.gen_range(0.0, 1.0) as f32
|
||||||
});
|
});
|
||||||
|
|
||||||
for ((entity, property), code) in self.ids.code.iter() {
|
|
||||||
let result = self.engine.eval::<(f32)>(code.as_str());
|
|
||||||
let point = result.unwrap();
|
|
||||||
println!("{}.{} = {} {:?}", entity, property, code, point);
|
|
||||||
ctx.child(entity.as_str()).set::<f32>(property, point);
|
|
||||||
}
|
|
||||||
|
|
||||||
for id in self.ids.indexes.iter() {
|
for id in self.ids.indexes.iter() {
|
||||||
if ctx.child(id.as_str()).has::<String16>("text") {
|
if ctx.child(id.as_str()).has::<String16>("text") {
|
||||||
let res = ctx.child(id.as_str()).get::<String16>("text").clone();
|
let res = ctx.child(id.as_str()).get::<String16>("text").clone();
|
||||||
|
@ -147,6 +141,21 @@ impl State for MVState {
|
||||||
}
|
}
|
||||||
w.update(id.clone() + ".text", res.as_string());
|
w.update(id.clone() + ".text", res.as_string());
|
||||||
}
|
}
|
||||||
|
if ctx.child(id.as_str()).has::<i32>("selected_index") {
|
||||||
|
let index = ctx.child(id.as_str()).get::<i32>("selected_index").clone();
|
||||||
|
match self.ids.code.get(&(id.clone(), String::from("items").clone())) {
|
||||||
|
Some(code) => {
|
||||||
|
let engine = Engine::new();
|
||||||
|
match engine.eval::<Array>(code.as_str()) {
|
||||||
|
Ok(list) => {
|
||||||
|
w.update(id.clone() + ".selected", list.index(index as usize).to_string());
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
w.refresh();
|
w.refresh();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
use crate::parser::Value::{QmlIdent, QmlString};
|
||||||
|
use crate::parser::{Value, QML};
|
||||||
|
use crate::state;
|
||||||
|
use crate::widget_builders::{parse_number, QmlContext, WidgetBuilder};
|
||||||
|
use orbtk::prelude::HashMap;
|
||||||
|
use orbtk::prelude::*;
|
||||||
|
use orbtk::Entity;
|
||||||
|
use rhai::{Array, Engine};
|
||||||
|
use std::ops::Index;
|
||||||
|
|
||||||
|
pub struct ComboBoxBuilder {}
|
||||||
|
|
||||||
|
impl WidgetBuilder for ComboBoxBuilder {
|
||||||
|
fn build(&self, properties: HashMap<String, Value>, _children: Vec<(String, QML)>) -> Box<dyn Fn(Entity, &mut BuildContext, usize, usize, &mut QmlContext) -> Entity> {
|
||||||
|
return Box::new(move |id, ctx, row, col, qmlctx| -> Entity {
|
||||||
|
let mut combo_box = ComboBox::new();
|
||||||
|
combo_box = combo_box.attach(Grid::row(row as usize));
|
||||||
|
combo_box = combo_box.attach(Grid::column(col as usize));
|
||||||
|
|
||||||
|
let widget_id = match properties.get("id") {
|
||||||
|
Some(QmlIdent(text)) => {
|
||||||
|
combo_box = combo_box.id(text.clone());
|
||||||
|
qmlctx.indexes.push(text.clone());
|
||||||
|
text.clone()
|
||||||
|
}
|
||||||
|
_ => String::new(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let items = match properties.get("items").unwrap() {
|
||||||
|
QmlString(code) => {
|
||||||
|
qmlctx.code.insert((widget_id, String::from("items")), code.to_string());
|
||||||
|
let engine = Engine::new();
|
||||||
|
match engine.eval::<Array>(code.as_str()) {
|
||||||
|
Ok(list) => {
|
||||||
|
println!("Found Combobox with {} items {:?}", list.len(), list);
|
||||||
|
list.to_vec()
|
||||||
|
}
|
||||||
|
_ => vec![],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => vec![],
|
||||||
|
};
|
||||||
|
|
||||||
|
combo_box = combo_box.count(items.len());
|
||||||
|
|
||||||
|
combo_box = combo_box.items_builder(move |bc, index| {
|
||||||
|
let text = items.index(index);
|
||||||
|
TextBlock::new().margin((0., 0., 0., 0.)).v_align("center").text(text.to_string()).build(bc)
|
||||||
|
});
|
||||||
|
|
||||||
|
let code = match properties.get("onselect").unwrap() {
|
||||||
|
QmlString(code) => code.clone(),
|
||||||
|
_ => String::new(),
|
||||||
|
};
|
||||||
|
|
||||||
|
combo_box = combo_box.on_changed(move |states, _| {
|
||||||
|
state(id, states).action(code.clone());
|
||||||
|
});
|
||||||
|
|
||||||
|
let selected = parse_number(properties.get("selected")) as u32;
|
||||||
|
combo_box = combo_box.selected_index(selected as i32);
|
||||||
|
|
||||||
|
match properties.get("anchors.centerIn") {
|
||||||
|
Some(QmlIdent(str)) => {
|
||||||
|
if str.eq("parent") {
|
||||||
|
combo_box = combo_box.v_align(Alignment::Center);
|
||||||
|
combo_box = combo_box.h_align(Alignment::Center);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
return combo_box.build(ctx);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,7 +13,7 @@ impl WidgetBuilder for GridBuilder {
|
||||||
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(properties.get("rows")) as u32;
|
let rows = parse_number(properties.get("rows")) as u32;
|
||||||
let _cols = parse_number(properties.get("cols")) as u32;
|
let cols = parse_number(properties.get("columns")) as u32;
|
||||||
|
|
||||||
let mut grid_rows = Rows::new();
|
let mut grid_rows = Rows::new();
|
||||||
for _i in 0..rows {
|
for _i in 0..rows {
|
||||||
|
@ -29,14 +29,14 @@ impl WidgetBuilder for GridBuilder {
|
||||||
|
|
||||||
let mut grow = 0u32;
|
let mut grow = 0u32;
|
||||||
let mut gcol = 0u32;
|
let mut gcol = 0u32;
|
||||||
//rect = rect.attach(Grid::column(gcol as usize));
|
|
||||||
let qwb = QmlWidgetBuilder::new();
|
let qwb = QmlWidgetBuilder::new();
|
||||||
for (child_type, child_qml) in children.iter() {
|
for (child_type, child_qml) in children.iter() {
|
||||||
grid = grid.child(qwb.build(id, grow as usize, gcol as usize, child_type.clone(), child_qml.clone(), ctx, qmlctx));
|
grid = grid.child(qwb.build(id, grow as usize, gcol as usize, child_type.clone(), child_qml.clone(), ctx, qmlctx));
|
||||||
grow += 1;
|
grow += 1;
|
||||||
if grow as u32 == rows {
|
if grow as u32 == rows {
|
||||||
grow = 0;
|
grow = 0;
|
||||||
gcol += 1;
|
gcol = (gcol + 1) % cols;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return grid.build(ctx);
|
return grid.build(ctx);
|
||||||
|
|
|
@ -8,11 +8,13 @@ use crate::widget_builders::textfield::TextBuilder;
|
||||||
use orbtk::prelude::*;
|
use orbtk::prelude::*;
|
||||||
use orbtk::Entity;
|
use orbtk::Entity;
|
||||||
|
|
||||||
|
use crate::widget_builders::combobox::ComboBoxBuilder;
|
||||||
use crate::widget_builders::image::ImageBuilder;
|
use crate::widget_builders::image::ImageBuilder;
|
||||||
use crate::widget_builders::import::ImportBuilder;
|
use crate::widget_builders::import::ImportBuilder;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
pub mod button;
|
pub mod button;
|
||||||
|
pub mod combobox;
|
||||||
pub mod grid;
|
pub mod grid;
|
||||||
pub mod image;
|
pub mod image;
|
||||||
pub mod import;
|
pub mod import;
|
||||||
|
@ -61,6 +63,7 @@ impl QmlWidgetBuilder {
|
||||||
qwb.widgets.insert(String::from("TextField"), Box::new(TextEditBuilder {}));
|
qwb.widgets.insert(String::from("TextField"), Box::new(TextEditBuilder {}));
|
||||||
qwb.widgets.insert(String::from("Button"), Box::new(ButtonBuilder {}));
|
qwb.widgets.insert(String::from("Button"), Box::new(ButtonBuilder {}));
|
||||||
qwb.widgets.insert(String::from("Image"), Box::new(ImageBuilder {}));
|
qwb.widgets.insert(String::from("Image"), Box::new(ImageBuilder {}));
|
||||||
|
qwb.widgets.insert(String::from("ComboBox"), Box::new(ComboBoxBuilder {}));
|
||||||
qwb
|
qwb
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue