Giter Club home page Giter Club logo

Comments (21)

FloVanGH avatar FloVanGH commented on May 19, 2024

@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.

hanckmann avatar hanckmann commented on May 19, 2024

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.

FloVanGH avatar FloVanGH commented on May 19, 2024

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.

captain-yossarian avatar captain-yossarian commented on May 19, 2024

@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.

FloVanGH avatar FloVanGH commented on May 19, 2024

@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.

captain-yossarian avatar captain-yossarian commented on May 19, 2024

@hanckmann

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.

FloVanGH avatar FloVanGH commented on May 19, 2024

@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.

captain-yossarian avatar captain-yossarian commented on May 19, 2024

@FloVanGH is this ok for minimum counter example?

from orbtk.

FloVanGH avatar FloVanGH commented on May 19, 2024

@SerhiiBilyk the link is broken.

from orbtk.

captain-yossarian avatar captain-yossarian commented on May 19, 2024

@FloVanGH https://github.com/SerhiiBilyk/gui/blob/master/src/main.rs

from orbtk.

FloVanGH avatar FloVanGH commented on May 19, 2024

@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.

captain-yossarian avatar captain-yossarian commented on May 19, 2024

@FloVanGH Thank you

from orbtk.

clouds56 avatar clouds56 commented on May 19, 2024

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.

FloVanGH avatar FloVanGH commented on May 19, 2024

@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.

clouds56 avatar clouds56 commented on May 19, 2024

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.

FloVanGH avatar FloVanGH commented on May 19, 2024

@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.

rzerres avatar rzerres commented on May 19, 2024

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.

FloVanGH avatar FloVanGH commented on May 19, 2024

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.

rzerres avatar rzerres commented on May 19, 2024

@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.

rzerres avatar rzerres commented on May 19, 2024

@FloVanGH

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.

FloVanGH avatar FloVanGH commented on May 19, 2024

#108

from orbtk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.