Comments (21)
@hanckmann git push --set-upstream origin 147-book. I've started with an initial version of the OrbTk book (check #107 and #108). If you like you could write the chapter "Write your first app" if you like. I could also assign you to the related issue and pull request.
from orbtk.
FYI.
I have started with the "first app" chapter.
I must admit that this is the first time doing this. So you might have to help me out here.
I have forked the repo, checked out the 147-book branch, and editing and committing my changes there.
I will ask later how to get those changes into your repository via a pull request (which I have also never done before).
from orbtk.
That’s great. Did you find the files of the book? A info bar at the top your repository should shown if you want to create a pull request for sour branch.
from orbtk.
@hanckmann @FloVanGH Hi guys, I would like to help with book. I made a little research and I found that the orbrk is the most understandable GUI framework for me and it just work. What I can't say about other frameworks.
from orbtk.
@SerhiiBilyk @hanckmann is working on the chapter write your first app. If you are interested you could start reading the book and give us feedback. If you miss something you could add it if you like. Maybe you could start with a second chapter. What do you think @hanckmann?
from orbtk.
use orbtk::prelude::*;
#[derive(Debug, Copy, Clone)]
enum Action {
Increment(i32),
}
#[derive(Default)]
pub struct MainViewState {
num: i32,
action: Option<Action>,
}
impl MainViewState {
fn action(&mut self, action: impl Into<Option<Action>>) {
self.action = action.into();
}
}
impl Template for MainView {
fn template(self, id: Entity, ctx: &mut BuildContext) -> Self {
self.name("MainView").child(
Button::create()
.min_size(100.0, 50.0)
.text(String::from("hello").to_string())
.on_click(move |states| -> bool {
println!("hello {:?}", states);
// state(id, states).action(Action::Increment(10));
// state(id, states).action(Action::Operator(sight));
true
})
.build(ctx),
)
}
}
impl State for MainViewState {
fn update(&self, ctx: &mut Context) {
if let Some(action) = self.action {
match action {
Action::Increment(digit) => {
// self.num += digit;
println!("Self {:?}", self.num);
}
_ => {}
}
}
// self.action = None;
}
}
widget!(MainView<MainViewState> {});
fn main() {
Application::new()
.window(|ctx| {
Window::create()
.title("OrbTk - minimal example")
.position((100.0, 100.0))
.size(400.0, 400.0)
.child(MainView::create().build(ctx))
.build(ctx)
})
.run();
}
/// StatesContext
fn state<'a>(id: Entity, states: &'a mut StatesContext) -> &'a mut MainViewState {
states.get_mut(id)
}
How can I import StatesContext ?
I cant find it even in documentation.
from orbtk.
@hanckmann which dependency do you use in your Cargo.toml file orbtk="0.3.1-alpha1"
or orbtk= { git = "https://github.com/redox-os/orbtk.git", branch="develop" }
. You have to use the git version, StatesContext is a new feature and not now available on the crates.io version.
from orbtk.
@FloVanGH is this ok for minimum counter example?
from orbtk.
@SerhiiBilyk the link is broken.
from orbtk.
@FloVanGH https://github.com/SerhiiBilyk/gui/blob/master/src/main.rs
from orbtk.
@SerhiiBilyk looks great.
Here some feedback:
// Is it possible to get rid of this line ?
self.action = None;
Yes it is. Check the work in progress todo app example: https://github.com/redox-os/orbtk/pull/109/files#diff-88def14d15394829e2ec6d406d7342a7R13. The App state uses a VecDeque for the actions / events. So you can pop all incoming actions from the vec deque instead of have an single action and set self.action = None;
The window title should be changed to Counter
or Write your first app
or what you think is the right name for your example.
I think you could remove the num field from the state.
Thank you.
from orbtk.
@FloVanGH Thank you
from orbtk.
I'm beginner and wonder when the update
would be called? Why self.action = Some(action)
would work if 2 actions comes simultaneously?
from orbtk.
@clouds56 in one run the update method of a state is called one time. If the state should handle multiple actions depends on the use case. If the state should handle only handle one action at time a single action is enough, otherwise e.g. a VecDeq<Action>
could be used.
from orbtk.
So if I understand correctly, when a any events (like click, keyboard) arrives, the corresponding widget would notified by handler like on_click
, after all widgets responses, it would call update
on all widgets (but not only the widgets affected by the event). And this is "one run" per event, right?
Therefore in the calculator example, 2 clicks must trigger 2 runs, so that there's no action would be lost.
I'd like to read the corresponding source code if possible but I'm not managed to find the location.
from orbtk.
@clouds56 yes you understand right. The source code you are looking for is in the EventStateSystem https://github.com/redox-os/orbtk/blob/develop/crates/api/src/systems/event_state_system.rs.
from orbtk.
FYI.
I have started with the "first app" chapter.
I must admit that this is the first time doing this. So you might have to help me out here.
I have forked the repo, checked out the 147-book branch, and editing and committing my changes there.
I will ask later how to get those changes into your repository via a pull request (which I have also never done before).
Almost 6 month since your first Quote. Is there any progress? Is there any assistance to coordinate the job?
What are the reachable goals to get a basic documentation to start off?
from orbtk.
One of the next topics are the simplification of some API parts. I think that should be done before releasing a guide with source code examples. To get a little more guidance until the guide is released I’ve added base concepts to the Readme.
But I hope we could release the first iteration of the guide after the api update.
from orbtk.
@FloVanGH
Thanks for the fast answer. I do appreciate all your valuable work and will try to dig deeper into the example code for now.
I will use the API to implement a basic from based application.
For what i have seen so for, one missing peace is the absence of a 'Login' widget, beside usefull stuff like "Tree View, Table View". The latter already seems to be on the agenda.
from orbtk.
I updated some comments as an issue for the "Do it" reference application. You will find it at.
https://codeberg.org/flovanco/doit/issues/7
from orbtk.
from orbtk.
Related Issues (20)
- [FAQ] Is this project dead? HOT 2
- Simple Example of ListView HOT 2
- Cannot run on Rust 2021 edition HOT 4
- Impossible to select the last tab after the previous last tab was closed HOT 2
- Text looks vague in macos HOT 5
- Is there a widget like TabLayout HOT 1
- About other languages HOT 5
- The Canvas example is missing
- How to solve it that undefined symbols for architecture x86_64 ?
- Hi is there a discord server for this? HOT 6
- Does not compile on Mac M1 Silicon / Arm64 architecture HOT 6
- Compilation failure: "Could not find native static library `SDL2main`" on Gentoo HOT 7
- Undefined symbols for architecture x86_64 HOT 1
- current develop branch breaks on MacOS, showing black window HOT 3
- Is this project still alive, and when can I expect the android and ios support coming out? HOT 1
- TextBlock does not show up HOT 1
- Why did you ditch developing OrbTK ? HOT 3
- orbtk sdl2-sys compiles standalone but not with orbtk
- example consider adding an explicit lifetime bound...
- Other Backends, no sdl2-dependencies possible?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from orbtk.