mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-02 04:48:27 +00:00
Skeleton for a TODO app
This commit is contained in:
parent
16f5cf42e3
commit
e9b63552a7
8 changed files with 194 additions and 0 deletions
|
|
@ -25,3 +25,5 @@ ExternalProject_Add(
|
||||||
|
|
||||||
add_subdirectory(examples/cpptest/)
|
add_subdirectory(examples/cpptest/)
|
||||||
add_subdirectory(examples/printerdemo/cpp/)
|
add_subdirectory(examples/printerdemo/cpp/)
|
||||||
|
add_subdirectory(examples/todo/cpp/)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ members = [
|
||||||
'examples/gallery/wasm',
|
'examples/gallery/wasm',
|
||||||
'examples/printerdemo/rust',
|
'examples/printerdemo/rust',
|
||||||
'examples/printerdemo/wasm',
|
'examples/printerdemo/wasm',
|
||||||
|
'examples/todo/rust',
|
||||||
'helper_crates/const-field-offset',
|
'helper_crates/const-field-offset',
|
||||||
'helper_crates/vtable',
|
'helper_crates/vtable',
|
||||||
'helper_crates/vtable/macro',
|
'helper_crates/vtable/macro',
|
||||||
|
|
|
||||||
49
examples/todo/cpp/CMakeLists.txt
Normal file
49
examples/todo/cpp/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
# LICENSE BEGIN
|
||||||
|
# This file is part of the SixtyFPS Project -- https://sixtyfps.io
|
||||||
|
# Copyright (c) 2020 Olivier Goffart <olivier.goffart@sixtyfps.io>
|
||||||
|
# Copyright (c) 2020 Simon Hausmann <simon.hausmann@sixtyfps.io>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
# This file is also available under commercial licensing terms.
|
||||||
|
# Please contact info@sixtyfps.io for more information.
|
||||||
|
# LICENSE END
|
||||||
|
cmake_minimum_required(VERSION 3.14)
|
||||||
|
project(sixtyfps_cpptest LANGUAGES CXX)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
|
### BEGIN This should be moved in some file in api/sixtyfps-cpp/cmake
|
||||||
|
|
||||||
|
|
||||||
|
#FIXME: i guess this file need to be generated so it knows where to look
|
||||||
|
find_program(SIXTYFPS_COMPILER sixtyfps_compiler HINTS
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/../../../target/release
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/../../../target/debug )
|
||||||
|
|
||||||
|
# FIXME that's not where all the things are
|
||||||
|
get_filename_component(_SIXTYFPS_TARGET_DIR ${SIXTYFPS_COMPILER} DIRECTORY)
|
||||||
|
|
||||||
|
function(SIXTYFPS_TARGET_60_SOURCES target)
|
||||||
|
foreach (it IN ITEMS ${ARGN})
|
||||||
|
get_filename_component(_60_BASE_NAME ${it} NAME_WE)
|
||||||
|
get_filename_component(_60_ABSOLUTE ${it} REALPATH BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_60_BASE_NAME}.h
|
||||||
|
COMMAND ${SIXTYFPS_COMPILER} ${_60_ABSOLUTE} > ${CMAKE_CURRENT_BINARY_DIR}/${_60_BASE_NAME}.h
|
||||||
|
DEPENDS ${_60_ABSOLUTE} ${SIXTYFPS_COMPILER}
|
||||||
|
COMMENT "Running sixtyfps_compiler on ${it}")
|
||||||
|
target_sources(${target} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/${_60_BASE_NAME}.h)
|
||||||
|
|
||||||
|
endforeach()
|
||||||
|
# FIXME: DO WE NEED THIS HERE?
|
||||||
|
target_include_directories(${target} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
find_package(SixtyFPS REQUIRED HINTS ${_SIXTYFPS_TARGET_DIR})
|
||||||
|
|
||||||
|
### END This should be moved in some file in api/sixtyfps-cpp/cmake
|
||||||
|
|
||||||
|
add_executable(todo main.cpp)
|
||||||
|
target_link_libraries(todo SixtyFPS::SixtyFPS)
|
||||||
|
sixtyfps_target_60_sources(todo ../ui/todo.60)
|
||||||
16
examples/todo/cpp/main.cpp
Normal file
16
examples/todo/cpp/main.cpp
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
/* LICENSE BEGIN
|
||||||
|
This file is part of the SixtyFPS Project -- https://sixtyfps.io
|
||||||
|
Copyright (c) 2020 Olivier Goffart <olivier.goffart@sixtyfps.io>
|
||||||
|
Copyright (c) 2020 Simon Hausmann <simon.hausmann@sixtyfps.io>
|
||||||
|
|
||||||
|
SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
This file is also available under commercial licensing terms.
|
||||||
|
Please contact info@sixtyfps.io for more information.
|
||||||
|
LICENSE END */
|
||||||
|
#include "todo.h"
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
static MainWindow demo;
|
||||||
|
demo.run();
|
||||||
|
}
|
||||||
18
examples/todo/rust/Cargo.toml
Normal file
18
examples/todo/rust/Cargo.toml
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
[package]
|
||||||
|
name = "todo"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Sixty FPS <info@sixtyfps.io>"]
|
||||||
|
edition = "2018"
|
||||||
|
build = "build.rs"
|
||||||
|
publish = false
|
||||||
|
license = "GPL-3.0-only"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
path = "main.rs"
|
||||||
|
name = "todo"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
sixtyfps = { path = "../../../api/sixtyfps-rs" }
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
sixtyfps-build = { path = "../../../api/sixtyfps-rs/sixtyfps-build" }
|
||||||
12
examples/todo/rust/build.rs
Normal file
12
examples/todo/rust/build.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
/* LICENSE BEGIN
|
||||||
|
This file is part of the SixtyFPS Project -- https://sixtyfps.io
|
||||||
|
Copyright (c) 2020 Olivier Goffart <olivier.goffart@sixtyfps.io>
|
||||||
|
Copyright (c) 2020 Simon Hausmann <simon.hausmann@sixtyfps.io>
|
||||||
|
|
||||||
|
SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
This file is also available under commercial licensing terms.
|
||||||
|
Please contact info@sixtyfps.io for more information.
|
||||||
|
LICENSE END */
|
||||||
|
fn main() {
|
||||||
|
sixtyfps_build::compile("../ui/todo.60").unwrap();
|
||||||
|
}
|
||||||
24
examples/todo/rust/main.rs
Normal file
24
examples/todo/rust/main.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
/* LICENSE BEGIN
|
||||||
|
This file is part of the SixtyFPS Project -- https://sixtyfps.io
|
||||||
|
Copyright (c) 2020 Olivier Goffart <olivier.goffart@sixtyfps.io>
|
||||||
|
Copyright (c) 2020 Simon Hausmann <simon.hausmann@sixtyfps.io>
|
||||||
|
|
||||||
|
SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
This file is also available under commercial licensing terms.
|
||||||
|
Please contact info@sixtyfps.io for more information.
|
||||||
|
LICENSE END */
|
||||||
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
|
sixtyfps::include_modules!();
|
||||||
|
|
||||||
|
#[cfg_attr(target_arch = "wasm32", wasm_bindgen(start))]
|
||||||
|
pub fn main() {
|
||||||
|
// This provides better error messages in debug mode.
|
||||||
|
// It's disabled in release mode so it doesn't bloat up the file size.
|
||||||
|
#[cfg(all(debug_assertions, target_arch = "wasm32"))]
|
||||||
|
console_error_panic_hook::set_once();
|
||||||
|
|
||||||
|
let main_window = MainWindow::new();
|
||||||
|
main_window.run();
|
||||||
|
}
|
||||||
72
examples/todo/ui/todo.60
Normal file
72
examples/todo/ui/todo.60
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
/* LICENSE BEGIN
|
||||||
|
This file is part of the SixtyFPS Project -- https://sixtyfps.io
|
||||||
|
Copyright (c) 2020 Olivier Goffart <olivier.goffart@sixtyfps.io>
|
||||||
|
Copyright (c) 2020 Simon Hausmann <simon.hausmann@sixtyfps.io>
|
||||||
|
|
||||||
|
SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
This file is also available under commercial licensing terms.
|
||||||
|
Please contact info@sixtyfps.io for more information.
|
||||||
|
LICENSE END */
|
||||||
|
|
||||||
|
import { SpinBox, Button, CheckBox, Slider } from "sixtyfps_widgets.60";
|
||||||
|
|
||||||
|
MainWindow := Window {
|
||||||
|
width: 400lx;
|
||||||
|
height: 600lx;
|
||||||
|
// signal todo_added(string);
|
||||||
|
|
||||||
|
property <[{title: string, checked: bool}]> todo_model: [
|
||||||
|
{ title: "Implement the .60 file", checked: true },
|
||||||
|
{ title: "Do the rust part", checked: false },
|
||||||
|
{ title: "Make the C++ code", checked: false },
|
||||||
|
{ title: "???", checked: false },
|
||||||
|
{ title: "Profit", checked: false },
|
||||||
|
];
|
||||||
|
|
||||||
|
GridLayout {
|
||||||
|
Row {
|
||||||
|
text_edit := Text {
|
||||||
|
text: "Something to do";
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
btn := Button {
|
||||||
|
text: "Add Todo";
|
||||||
|
clicked => {
|
||||||
|
// todo_added(text_edit.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
spacing := Rectangle {
|
||||||
|
height: 15lx;
|
||||||
|
maximum_height: 15lx;
|
||||||
|
minimum_height: 15lx;
|
||||||
|
row: 1;
|
||||||
|
rowspan: 2;
|
||||||
|
}
|
||||||
|
// Should be a ListView
|
||||||
|
list_view := Rectangle {
|
||||||
|
rowspan: 2;
|
||||||
|
row: 2;
|
||||||
|
for todo[index] in todo_model: Rectangle {
|
||||||
|
y: index * height;
|
||||||
|
width: parent.width;
|
||||||
|
height: 20lx;
|
||||||
|
GridLayout {
|
||||||
|
CheckBox {
|
||||||
|
text: todo.title;
|
||||||
|
checked: todo.checked;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Row {
|
||||||
|
Button {
|
||||||
|
col: 1;
|
||||||
|
text: "All done!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue