mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-12 05:16:48 +00:00
C++ tutorial: Remove inline source in getting start
This commit is contained in:
parent
c540cbaf2d
commit
031acd77d3
5 changed files with 61 additions and 15 deletions
18
docs/tutorial/cpp/src/CMakeLists.txt
Normal file
18
docs/tutorial/cpp/src/CMakeLists.txt
Normal file
|
@ -0,0 +1,18 @@
|
|||
# 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)
|
||||
|
||||
if (NOT TARGET SixtyFPS::SixtyFPS)
|
||||
find_package(SixtyFPS REQUIRED)
|
||||
endif()
|
||||
|
||||
add_executable(memory_tutorial_inital main_initial.cpp)
|
||||
target_link_libraries(memory_tutorial_inital PRIVATE SixtyFPS::SixtyFPS)
|
||||
sixtyfps_target_60_sources(memory_tutorial_inital memory.60)
|
|
@ -38,26 +38,13 @@ add the `memory.60` file to the target. We must then create, in the same directo
|
|||
the `memory.60` file. Let's just fill it with a hello world for now:
|
||||
|
||||
```60
|
||||
// memory.60
|
||||
MainWindow := Window {
|
||||
Text {
|
||||
text: "hello world";
|
||||
color: green;
|
||||
}
|
||||
}
|
||||
{{#include memory.60:main_window}}
|
||||
```
|
||||
|
||||
What's still missing is the `main.cpp`:
|
||||
|
||||
```cpp
|
||||
// main.cpp
|
||||
|
||||
#include "memory.h" // generated header from memory.60
|
||||
|
||||
int main() {
|
||||
auto main_window = MainWindow::create();
|
||||
main_window->run();
|
||||
}
|
||||
{{#include main_initial.cpp:main}}
|
||||
```
|
||||
|
||||
To recap, we now have a directory with a `CMakeLists.txt`, `memory.60` and `main.cpp`.
|
||||
|
|
20
docs/tutorial/cpp/src/main_initial.cpp
Normal file
20
docs/tutorial/cpp/src/main_initial.cpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
/* 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 */
|
||||
// ANCHOR: main
|
||||
// main.cpp
|
||||
|
||||
#include "memory.h" // generated header from memory.60
|
||||
|
||||
int main()
|
||||
{
|
||||
auto main_window = MainWindow::create();
|
||||
main_window->run();
|
||||
}
|
||||
// ANCHOR_END: main
|
18
docs/tutorial/cpp/src/memory.60
Normal file
18
docs/tutorial/cpp/src/memory.60
Normal file
|
@ -0,0 +1,18 @@
|
|||
/* 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 */
|
||||
// ANCHOR: main_window
|
||||
// memory.60
|
||||
MainWindow := Window {
|
||||
Text {
|
||||
text: "hello world";
|
||||
color: green;
|
||||
}
|
||||
}
|
||||
// ANCHOR_END: main_window
|
Loading…
Add table
Add a link
Reference in a new issue