Commit c83ba518 authored by Michael Aaron Murphy's avatar Michael Aaron Murphy

Merge branch 'orbgl' into 'master'

Integration of OrbGL as new renderer and API update

See merge request !103
parents a650cbf8 add0fb1a
image: 'rust:latest'
stages:
- build
- test
- build
- test
variables:
CARGO_HOME: $CI_PROJECT_DIR/cargo
CARGO_HOME: $CI_PROJECT_DIR/cargo
before_script:
- apt-get update -qq
- apt-get install -qq build-essential curl git
......@@ -41,12 +41,12 @@ build:redox:
- target/
test:linux:
stage: test
before_script:
stage: test
before_script:
- apt-get update && apt-get -y install cmake
- apt-get install libsdl2-dev -y
dependencies:
- build:linux
script:
- rustup default nightly
- cargo test
dependencies:
- build:linux
script:
- rustup default nightly
- cargo test
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug widgets",
"program": "${workspaceFolder}/target/debug/examples/widgets",
"cwd": "${workspaceFolder}",
"preLaunchTask": "build",
"sourceLanguages": [
"rust"
]
},
{
"type": "lldb",
"request": "launch",
"name": "Debug canvas",
"program": "${workspaceFolder}/target/debug/examples/canvas",
"cwd": "${workspaceFolder}",
"preLaunchTask": "build",
"sourceLanguages": [
"rust"
]
},
{
"type": "lldb",
"request": "launch",
"name": "Debug image",
"program": "${workspaceFolder}/target/debug/examples/image",
"cwd": "${workspaceFolder}",
"preLaunchTask": "build",
"sourceLanguages": [
"rust"
]
},
{
"type": "lldb",
"request": "launch",
"name": "Debug light theme",
"program": "${workspaceFolder}/target/debug/examples/light-theme",
"cwd": "${workspaceFolder}",
"preLaunchTask": "build",
"sourceLanguages": [
"rust"
]
},
{
"type": "lldb",
"request": "launch",
"name": "Debug messages",
"program": "${workspaceFolder}/target/debug/examples/messages",
"cwd": "${workspaceFolder}",
"preLaunchTask": "build",
"sourceLanguages": [
"rust"
]
},
{
"type": "lldb",
"request": "launch",
"name": "Debug grid",
"program": "${workspaceFolder}/target/debug/examples/grid",
"cwd": "${workspaceFolder}",
"preLaunchTask": "build",
"sourceLanguages": [
"rust"
]
},
{
"type": "lldb",
"request": "launch",
"name": "Debug minimal",
"program": "${workspaceFolder}/target/debug/examples/minimal",
"cwd": "${workspaceFolder}",
"preLaunchTask": "build",
"sourceLanguages": [
"rust"
]
},
{
"type": "lldb",
"request": "launch",
"name": "Debug tests",
"cargo": {
"args": [
"test",
"--no-run",
"--lib"
]
},
"args": [],
"cwd": "${workspaceFolder}"
}
]
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug widgets",
"program": "${workspaceFolder}/target/debug/examples/widgets",
"cwd": "${workspaceFolder}",
"preLaunchTask": "build",
"sourceLanguages": [
"rust"
]
},
{
"type": "lldb",
"request": "launch",
"name": "Debug canvas",
"program": "${workspaceFolder}/target/debug/examples/canvas",
"cwd": "${workspaceFolder}",
"preLaunchTask": "build",
"sourceLanguages": [
"rust"
]
},
{
"type": "lldb",
"request": "launch",
"name": "Debug image",
"program": "${workspaceFolder}/target/debug/examples/image",
"cwd": "${workspaceFolder}",
"preLaunchTask": "build",
"sourceLanguages": [
"rust"
]
},
{
"type": "lldb",
"request": "launch",
"name": "Debug light theme",
"program": "${workspaceFolder}/target/debug/examples/light-theme",
"cwd": "${workspaceFolder}",
"preLaunchTask": "build",
"sourceLanguages": [
"rust"
]
},
{
"type": "lldb",
"request": "launch",
"name": "Debug messages",
"program": "${workspaceFolder}/target/debug/examples/messages",
"cwd": "${workspaceFolder}",
"preLaunchTask": "build",
"sourceLanguages": [
"rust"
]
},
{
"type": "lldb",
"request": "launch",
"name": "Debug grid",
"program": "${workspaceFolder}/target/debug/examples/grid",
"cwd": "${workspaceFolder}",
"preLaunchTask": "build",
"sourceLanguages": [
"rust"
]
},
{
"type": "lldb",
"request": "launch",
"name": "Debug minimal",
"program": "${workspaceFolder}/target/debug/examples/minimal",
"cwd": "${workspaceFolder}",
"preLaunchTask": "build",
"sourceLanguages": [
"rust"
]
},
{
"type": "lldb",
"request": "launch",
"name": "Debug tests",
"cargo": {
"args": [
"test",
"--no-run",
"--lib"
]
},
"args": [],
"cwd": "${workspaceFolder}"
}
]
}
\ No newline at end of file
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "cargo",
"type": "shell",
"args": [
"build",
"--examples=minimal"
],
"presentation": {
"reveal": "always",
"panel": "new",
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "cargo",
"type": "shell",
"args": [
"build",
"--examples=minimal"
],
"presentation": {
"reveal": "always",
"panel": "new"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
\ No newline at end of file
This diff is collapsed.
......@@ -29,5 +29,9 @@ dces = { git = "https://gitlab.redox-os.org/redox-os/dces-rust.git" }
orbclient = "0.3.20"
orbfont = { git = "https://gitlab.redox-os.org/redox-os/orbfont.git" }
orbimage = "0.1.16"
# orbgl_api = { path = "../orbgl/orbgl_api" }
orbgl_api = { git = "https://gitlab.redox-os.org/redox-os/orbgl.git" }
# orbgl = { path = "../orbgl/orbgl" }
orbgl = { git = "https://gitlab.redox-os.org/redox-os/orbgl.git" }
# orbgl_shapes = { path = "../orbgl/orbgl_shapes" }
orbgl_shapes = { git = "https://gitlab.redox-os.org/redox-os/orbgl.git" }
......@@ -8,7 +8,7 @@
> OrbTk 0.3.0 is under heavy development and it's not compatible to earlier releases.
The Orbital Widget Toolkit is a multi platform (G)UI toolkit for building scalable user interfaces with the programming language Rust. It's based
on the [Entity Component System Pattern](https://en.wikipedia.org/wiki/Entity%E2%80%93component%E2%80%93system) and provides a functional-reactive API.
on the [Entity Component System Pattern](https://en.wikipedia.org/wiki/Entity%E2%80%93component%E2%80%93system) and provides a functional-reactive like API.
The main goals of OrbTk are fast performance, easy to use and cross platform.
......@@ -16,7 +16,7 @@ The main goals of OrbTk are fast performance, easy to use and cross platform.
## Features:
* Modern [Flutter](https://flutter.io/), [React](https://reactjs.org/), [Redux](https://redux.js.org/) like API
* Modern lightweight API
* Uses the Entity Component System library [DCES](https://gitlab.redox-os.org/redox-os/dces-rust) for widget and properties handling
* Updating instead of rebuilding sub-trees
* Flexible event system
......@@ -55,9 +55,8 @@ fn main() {
.create_window()
.bounds(Bounds::new(100.0, 100.0, 420.0, 730.0))
.title("OrbTk - minimal example")
.root(TextBlock::create().text("OrbTk").into())
.debug_flag(false)
.build();
.build(TextBlock::create().text("OrbTk"));
application.run();
}
```
......@@ -90,12 +89,13 @@ cargo doc --no-deps --open
* Exchange views / widgets / screens on runtime
* Split application in modules
* Theme update
* Support for Android, iOS and WebAssembly
* Support for Android, iOS, Ubuntu Touch and WebAssembly
* Vulkan / OpenGL Support
## Dependencies
* [OrbClient](https://gitlab.redox-os.org/redox-os/orbclient): window creation, drawing, window events
* [OrbGL](https://gitlab.redox-os.org/redox-os/orbgl): 2D/3D drawing
* [OrbClient](https://gitlab.redox-os.org/redox-os/orbclient): window creation, window events
* [OrbFont](https://gitlab.redox-os.org/redox-os/orbfont): font rendering
* [OrbImage](https://gitlab.redox-os.org/redox-os/orbimage/tree/master/src): image loading
* [DCES](https://gitlab.redox-os.org/redox-os/dces-rust): Entity Component System
......
use orbtk::*;
// use orbtk::*;
struct MainView;
// widget!(MainView);
impl Widget for MainView {
type Template = Template;
// impl Widget for MainView {
// fn create() -> Self {
// MainView::new()
// .parent_type(ParentType::Single)
// .debug_name("MainView")
// .child(TextBlock::create().text("Wait for next merge"))
// }
// }
fn create() -> Template {
Template::new()
.parent_type(ParentType::Single)
.debug_name("MainView")
.child(TextBlock::create().text("Wait for next merge"))
}
}
// fn main() {
// let mut application = Application::default();
// application
// .create_window()
// .bounds((100.0, 100.0, 800.0, 600.0))
// .title("OrbTk - canvas example")
// .root(MainView::create())
// .build();
// application.run();
// }
fn main() {
let mut application = Application::default();
application
.create_window()
.bounds((100.0, 100.0, 800.0, 600.0))
.title("OrbTk - canvas example")
.root(MainView::create())
.build();
application.run();
}
fn main() {}
\ No newline at end of file
use orbtk::*;
struct MainView;
widget!(MainView);
impl Widget for MainView {
type Template = Template;
fn create() -> Self::Template {
Template::new()
.child(
Grid::create()
.columns(
Columns::create()
.column("*")
.column("Auto")
.column(50.0)
.build(),
)
.rows(Rows::create().row("*").row("*").build())
.child(
Grid::create()
.selector("lynch")
.margin((10.0, 0.0, 0.0, 4.0))
.attach_property(GridColumn(0))
.child(
TextBlock::create()
.text("(0,0)")
.horizontal_alignment("Center")
.vertical_alignment("Center"),
),
)
.child(
Grid::create()
.selector("bluebayoux")
.margin(10.0)
.constraint(Constraint::create().width(150.0).build())
.attach_property(GridColumn(1))
.child(
TextBlock::create()
.text("(1,0)")
.horizontal_alignment("Center")
.vertical_alignment("Center"),
),
)
.child(
Grid::create()
.selector("linkwater")
.attach_property(GridColumn(2))
.child(
TextBlock::create()
.text("(2,0)")
.selector("linkwater")
.horizontal_alignment("Center")
.vertical_alignment("Center"),
),
)
.child(
Grid::create()
.selector("goldendream")
.attach_property(GridColumn(0))
.attach_property(GridRow(1))
.attach_property(ColumnSpan(3))
.child(
TextBlock::create()
.text("(0,1) - ColumnSpan 3")
.selector("goldendream")
.horizontal_alignment(HorizontalAlignment(Alignment::Center))
.vertical_alignment(VerticalAlignment(Alignment::Center)),
),
),
)
.debug_name("MainView")
impl Template for MainView {
fn template(self, _: Entity, context: &mut BuildContext) -> Self {
self.name("MainView").child(
Grid::create()
.columns(
Columns::create()
.column("*")
.column("Auto")
.column(50.0)
.build(),
)
.rows(Rows::create().row("*").row("*").build())
.child(
Grid::create()
.selector("lynch")
.margin((10.0, 0.0, 0.0, 4.0))
.attach(GridColumn(0))
.child(
TextBlock::create()
.text("(0,0)")
.selector("light-text")
.horizontal_alignment("Center")
.vertical_alignment("Center")
.build(context),
)
.build(context),
)
.child(
Grid::create()
.selector("bluebayoux")
.margin(10.0)
.constraint(Constraint::create().width(150.0).build())
.attach(GridColumn(1))
.child(
TextBlock::create()
.text("(1,0)")
.selector("white")
.horizontal_alignment("Center")
.vertical_alignment("Center")
.build(context),
)
.build(context),
)
.child(
Grid::create()
.selector("linkwater")
.attach(GridColumn(2))
.child(
TextBlock::create()
.text("(2,0)")
.selector("linkwater")
.horizontal_alignment("Center")
.vertical_alignment("Center")
.build(context),
)
.build(context),
)
.child(
Grid::create()
.selector("goldendream")
.attach(GridColumn(0))
.attach(GridRow(1))
.attach(ColumnSpan(3))
.child(
TextBlock::create()
.text("(0,1) - ColumnSpan 3")
.selector("goldendream")
.horizontal_alignment(HorizontalAlignment(Alignment::Center))
.vertical_alignment(VerticalAlignment(Alignment::Center))
.build(context),
)
.build(context),
)
.build(context),
)
}
}
......@@ -79,13 +86,12 @@ fn main() {
.create_window()
.bounds((100.0, 100.0, 420.0, 730.0))
.title("OrbTk - grid example")
.root(MainView::create())
.theme(
Theme::create()
.extension_path("examples/res/grid.css")
.build(),
)
.resizable(true)
.build();
.build(MainView::create());
application.run();
}
use orbtk::*;
struct MainView;
impl Widget for MainView {
type Template = Template;
fn create() -> Self::Template {
Template::new()
.debug_name("MainView")
.child(ImageWidget::create().image("res/orbtk-space.png"))
}
}
fn main() {
let mut application = Application::default();
application
.create_window()
.bounds((100.0, 100.0, 800.0, 420.0))
.title("OrbTk - image example")
.root(MainView::create())
.build();
.title("OrbTk - minimal example")
.debug_flag(false)
.build(ImageWidget::create().image("res/orbtk-space.png"));
application.run();
}
}
\ No newline at end of file
use orbtk::*;
use std::cell::Cell;
use std::{cell::Cell, rc::Rc};
use orbtk::*;
#[derive(Default)]
struct MainViewState {
pub struct MainViewState {
counter: Cell<i32>,
}
impl MainViewState {
pub fn increment(&self) {
fn increment(&self) {
self.counter.set(self.counter.get() + 1)
}
}
impl State for MainViewState {
fn update(&self, context: &mut Context<'_>) {
if let Ok(button_count_text) = context.widget().borrow_mut_property::<Text>() {
if let Some(button_count_text) = context.widget().try_get_mut::<Text>() {
button_count_text.0 = format!("Button count: {}", self.counter.get());
}
}
}
fn create_header(text: &str, grid: usize, column: usize) -> Template {
fn create_header(context: &mut BuildContext, text: &str, grid: usize, column: usize) -> Entity {
TextBlock::create()
.text(text)
.selector(Selector::from("textblock").class("h1"))
.attach_property(GridColumn(grid))
.attach_property(GridRow(column))
.into()
.selector(SelectorValue::new().with("text-block").class("h1"))
.attach(GridColumn(grid))
.attach(GridRow(column))
.build(context)
}
struct MainView;
impl Widget for MainView {
type Template = Template;
widget!(
MainView<MainViewState> {
count_text: Text
}
);
fn create() -> Self::Template {
let state = Rc::new(MainViewState::default());
let button_count_text = SharedProperty::new(Text::from("Button count: 0"));
impl Template for MainView {
fn template(self, id: Entity, context: &mut BuildContext) -> Self {
let state = self.clone_state();
Template::new()
.state(state.clone())
.child(
Grid::create()
.margin(8.0)
.columns(
Columns::create()
.column("Auto")
.column(32.0)
.column("Auto")
.column("*")
.build(),
)
.rows(
Rows::create()
.row("Auto")
.row("Auto")
.row("Auto")
.row("Auto")
.row("Auto")
.row("Auto")
.build(),
)
// Column 0
.child(create_header("Button", 0, 0))
.child(
Button::create()
.text("Button")
.margin((0.0, 8.0, 0.0, 0.0))