Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
/Android/app/build/
/Android/build/
/Android/local.properties
/.xmake/
115 changes: 115 additions & 0 deletions GETTING_STARTED.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Quick Start: Create an EUI-NEO Project

## 1. Create project directory

```sh
mkdir my-eui-app && cd my-eui-app
```

## 2. Create `xmake.lua`

```lua
set_languages("cxx17")
add_requires("eui-neo")

target("myapp")
set_kind("binary")
add_files("app.cpp")
add_packages("eui-neo")
```

## 3. Create `app.cpp`

```cpp
#include "eui_neo.h"
#include <string>

static std::string g_name;
static std::string g_greeting;

namespace app {

const DslAppConfig& dslAppConfig() {
static const DslAppConfig config = DslAppConfig{}
.title("Hello Demo")
.windowSize(480, 320);
return config;
}

void compose(eui::Ui& ui, const eui::Screen& screen) {
ui.column("root")
.size(screen.width, screen.height)
.content([&] {
ui.text("title")
.x(40.0f)
.y(32.0f)
.text("EUI-NEO Demo")
.fontSize(24.0f)
.build();

components::input(ui, "name_input")
.x(40.0f)
.y(88.0f)
.size(400.0f, 40.0f)
.placeholder("Enter your name...")
.value(g_name)
.onChange([](const std::string& value) {
g_name = value;
})
.build();

components::button(ui, "say_hello")
.x(40.0f)
.y(148.0f)
.size(160.0f, 44.0f)
.text("Say Hello")
.onClick([]() {
g_greeting = "Hello, " + g_name + "!";
})
.build();

if (!g_greeting.empty()) {
ui.text("greeting")
.x(40.0f)
.y(216.0f)
.text(g_greeting)
.fontSize(20.0f)
.build();
}
})
.build();
}

} // namespace app
```

## 4. Build and run

```sh
xmake f -m release -y
xmake
xmake run myapp
```

## Options

```sh
# SDL2 backend
xmake f --window_backend=sdl2

# Vulkan renderer
xmake f --render_backend=vulkan

# Shared library
xmake f --shared=y
```

## Included demo

Run the included `hello_demo` example:

```sh
xmake run hello_demo
```

Type a name, click "Say Hello", and see the greeting appear.
60 changes: 60 additions & 0 deletions apps/hello_demo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#include "eui_neo.h"
#include <string>

static std::string g_name;
static std::string g_greeting;

namespace app {

const DslAppConfig& dslAppConfig() {
static const DslAppConfig config = DslAppConfig{}
.title("Hello Demo")
.windowSize(480, 320);
return config;
}

void compose(eui::Ui& ui, const eui::Screen& screen) {
ui.column("root")
.size(screen.width, screen.height)
.content([&] {
ui.text("title")
.x(40.0f)
.y(32.0f)
.text("EUI-NEO Demo")
.fontSize(24.0f)
.build();

components::input(ui, "name_input")
.x(40.0f)
.y(88.0f)
.size(400.0f, 40.0f)
.placeholder("Enter your name...")
.value(g_name)
.onChange([](const std::string& value) {
g_name = value;
})
.build();

components::button(ui, "say_hello")
.x(40.0f)
.y(148.0f)
.size(160.0f, 44.0f)
.text("Say Hello")
.onClick([]() {
g_greeting = "Hello, " + g_name + "!";
})
.build();

if (!g_greeting.empty()) {
ui.text("greeting")
.x(40.0f)
.y(216.0f)
.text(g_greeting)
.fontSize(20.0f)
.build();
}
})
.build();
}

} // namespace app
Loading