Giter VIP home page Giter VIP logo

terramach's Introduction

Terra Mach

Terra Mach is a mapping frontend system to build graphical interfaces for devices.

This project focuses on experiences around statistical data (graphs, diagrams), mapping, and user input. When it comes to user experience, elements a user interacts with are flexible enough to build most of common experiences.

The project is in active development. Most of the APIs are stable, though some breaking changes are still possible.

This project is highly inspired by Flutter. Terra Mach is written in a systems programming language Rust. It leverages graphics library Skia to enable high performant 2D graphics.

How to Use

Terra Mach crate is located in terramach folder. To use it checkout Terra Mach to your workspace and link it locally by supplying a path.

git clone https://github.com/lykhonis/terramach.git
cd MyProject

Add dependency in Cargo.toml.

[dependencies.terramach]
path = "../terramach/terramach"

Examples

Terra Mach comes with some prebuilt examples of what can be built with it.

Dashboard

Dashboard Preview

A dashboard sample app inspired by Dark Version design. The dashboard integrates Mapbox to access maps. The integration module is located in third-party crate.

Try example by running in command line:

cd examples/dashboard
cargo run --release

This may take awhile for initial build, so don't hesitate to grab some โ˜•.

In order to access maps, you would need to supply Mapbox access token in Settings.toml. Register and get Mapbox access token by signing up here.

cd examples/dashboard
touch Settings.toml

and insert following content:

[mapbox]
access-token = "ACCESS_TOKEN_GOES_HERE"
cache-path = "/tmp/mapbox.cache.db"

Build a Widget

TerraMach GUI is a composition of widgets and/or direct painting. For example, a Decoration widget paints background color but also manages its child widget.

A simple example of a counter app. On a tap, the counter is increased and UI is updated to reflect the change.

  1. Define a widget and its state (state is optional)
#[derive(Default, Clone, PartialEq, PartialWidget)]
struct Counter {}

#[derive(Default)]
struct CounterState {
    counter: usize,
}
  1. Implement a counter widget
impl Widget for Counter {
    // prepare state for the counter
    fn mount(&self, context: &mut WidgetContext, mount: &mut MountContext) {
        context.set_state(CounterState::default());
    }
    
    // build a counter widget with tap gesture and white background
    fn build(&self, context: &mut WidgetContext, build: &mut BuildContext) {
        let state = context.state::<CounterState>().unwrap();
        build.add_child(
            Gesture::new(
                0,
                build.event_emitter(),
                TapGesture::default(),
                None,
                Decoration::new(
                    Color::WHITE,
                    None,
                    Align::new(
                        Alignment::center(),
                        Text::new_text(format!("Counter {}", state.counter).as_str()),
                    ),
                ),
            ),
        );
    }
    
    // handle a single tap
    fn event(&self, context: &mut WidgetContext, event: &mut EventContext) {
        if let Event::Tap(_) = event.get() {
            let state = context.state_mut::<CounterState>().unwrap();
            state.counter += 1;
            event.mark_need_build();
        }
    }
}
  1. Start the app
fn main() {
    App::new((1020, 640))
        .with_title("Counter")
        .run(Counter::default());
}

Supported Platforms

In order:

Platform Status
Mac OS Supported
Android Partial
Linux Planned
Windows Planned
iOS Planned
Web Considered

License

This software is available publicly via GPLv3 license which can be found here. For any other request please contact me.

terramach's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terramach's Issues

License

I'm currently planning to write an open source cross platform application and I think skia would be a good fit. terramach seems like an excellent starting point for the GUI. Unfortunately, the GPL prevents me from using it, because GPL applications cannot be used in the iOS App Store. It would be great of terramach would be available under a slightly more permissive license such as the MPL (license used by firefox, also copyleft, but only on a "file level", so users would only required to publish modifications to the library).

I'm aware this is a big ask, and can totally understand if you are not willing to do this. Great work on terramach nevertheless.

Not clear on usage. Map GUI vs general GUI development.

Hi, this looks like an awesome project. After moving to Rust from Dart, I was looking for a library to develop cross-platform mobile apps using Rust + Skia, like Flutter.

This project seems to have similar aims.
Wanted some clarification -

Is this a cross-platform GUI kit to develop any kind of mobile app (like Flutter) + desktop/web or is it specifically for Mapping and Visualisations/Plotting.

Still alive?

I stop by every so often to see how progress is - it's been a while.

Absolutely understandable if you've got a lot on your plate leaving little time for this project.

Fail on fresh build of counter example

I'll have a closer look at some point later, but a build from a fresh clone of the repo results in the following:

   Compiling skia-safe v0.27.1
error[E0433]: failed to resolve: could not find `Context` in `gl`
  --> terramach/graphics/src/gl/gl.rs:40:52
   |
40 |             context: context.into().or_else(|| gl::Context::current())?,
   |                                                    ^^^^^^^ could not find `Context` in `gl`

error[E0412]: cannot find type `Context` in module `gl`
  --> terramach/graphics/src/gl/gl.rs:30:18
   |
30 |     context: gl::Context,
   |                  ^^^^^^^ not found in `gl`
   |
help: possible candidates are found in other modules, you can import them into scope
   |
19 | use core::task::Context;
   |
19 | use skia_safe::gpu::Context;
   |
19 | use std::task::Context;
   |

error[E0412]: cannot find type `Context` in module `gl`
  --> terramach/graphics/src/gl/gl.rs:36:39
   |
36 |         context: impl Into<Option<gl::Context>>,
   |                                       ^^^^^^^ not found in `gl`
   |
help: possible candidates are found in other modules, you can import them into scope
   |
19 | use core::task::Context;
   |
19 | use skia_safe::gpu::Context;
   |
19 | use std::task::Context;
   |

error[E0412]: cannot find type `Context` in module `gl`
  --> terramach/graphics/src/gl/gl.rs:49:43
   |
49 |     pub fn context(&mut self) -> &mut gl::Context {
   |                                           ^^^^^^^ not found in `gl`
   |
help: possible candidates are found in other modules, you can import them into scope
   |
19 | use core::task::Context;
   |
19 | use skia_safe::gpu::Context;
   |
19 | use std::task::Context;
   |

warning: unused import: `Rect`
  --> terramach/graphics/src/gl/display.rs:25:82
   |
25 |     AlphaType, Budgeted, ColorSpace, ColorType, Display as GrDisplay, ImageInfo, Rect, Size,
   |                                                                                  ^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

error[E0282]: type annotations needed
   --> terramach/graphics/src/gl/display.rs:162:13
    |
162 |             None,
    |             ^^^^ cannot infer type for type parameter `T` declared on the enum `Option`

error: aborting due to 5 previous errors

Some errors have detailed explanations: E0282, E0412, E0433.
For more information about an error, try `rustc --explain E0282`.
error: could not compile `terramach-graphics`.

To learn more, run the command again with --verbose.

Use of Vec<>::remove_item() causes crash despite #![feature]

error[E0554]: `#![feature]` may not be used on the stable release channel
  --> terramach/terramach/ui/lib.rs:19:1
   |
19 | #![feature(vec_remove_item)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
  --> terramach/terramach/ui/lib.rs:20:1
   |
20 | #![feature(panic_info_message)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This is what I am getting.

Maybe rather than using remove_item(), use a hash map or a handcrafted method?

Compilation Errors

I have tried to compile the example with Rust 1.42 and nightly and get the following:

error[E0433]: failed to resolve: could not find `Context` in `gl`
  --> terramach/graphics/src/gl/gl.rs:40:52
   |
40 |             context: context.into().or_else(|| gl::Context::current())?,
   |                                                    ^^^^^^^ could not find `Context` in `gl`

error[E0412]: cannot find type `Context` in module `gl`
  --> terramach/graphics/src/gl/gl.rs:30:18
   |
30 |     context: gl::Context,
   |                  ^^^^^^^ not found in `gl`
   |
help: possible candidates are found in other modules, you can import them into scope
   |
19 | use core::task::Context;
   |
19 | use skia_safe::gpu::Context;
   |
19 | use std::task::Context;
   |

error[E0412]: cannot find type `Context` in module `gl`
  --> terramach/graphics/src/gl/gl.rs:36:39
   |
36 |         context: impl Into<Option<gl::Context>>,
   |                                       ^^^^^^^ not found in `gl`
   |
help: possible candidates are found in other modules, you can import them into scope
   |
19 | use core::task::Context;
   |
19 | use skia_safe::gpu::Context;
   |
19 | use std::task::Context;
   |

error[E0412]: cannot find type `Context` in module `gl`
  --> terramach/graphics/src/gl/gl.rs:49:43
   |
49 |     pub fn context(&mut self) -> &mut gl::Context {
   |                                           ^^^^^^^ not found in `gl`
   |

error[E0282]: type annotations needed
   --> terramach/graphics/src/gl/display.rs:158:13
    |
158 |             None,
    |             ^^^^ cannot infer type for type parameter `T` declared on the enum `Option`

error: aborting due to 5 previous errors

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.