Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applets: NAP applications inside Napkin #81

Open
wants to merge 246 commits into
base: 0.8
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
246 commits
Select commit Hold shift + click to select a range
5dda1bc
add render panel that contains a native (underlying) render window
cklosters Oct 2, 2024
8becd62
create render related qt and nap resources for drawing to a native qt…
cklosters Oct 2, 2024
dc720ba
Ensure nap render window initialization succeeds when using Qt enable…
cklosters Oct 3, 2024
31b4741
clear color to random when pressing space to ensure nap renders to qw…
cklosters Oct 3, 2024
b9f50bc
Give 3D render widget default position
cklosters Oct 3, 2024
379aa87
introduce async nap application runner for napkin
cklosters Oct 7, 2024
0f08c21
remove napparameter dependency from napapp (not required!)
cklosters Oct 7, 2024
bf6a9be
launch application template preview application
cklosters Oct 7, 2024
d11adc0
include napinput as dependency
cklosters Oct 8, 2024
d0bfd3b
allow for explicit enabling of SDL sub-system
cklosters Oct 8, 2024
44ac8fe
cleanup
cklosters Oct 8, 2024
03b7c9f
Introduce applet launcher and runner to spawn a complete nap applicat…
cklosters Oct 8, 2024
fae744f
Add update and draw call using simple timer - works!
cklosters Oct 9, 2024
c0c4db7
Add imgui and make the render preview a bit more challenging for debu…
cklosters Oct 9, 2024
6fc80ec
Ensure order of destruction render applets
cklosters Oct 9, 2024
2eaa910
Use window object creator to create render window from Qt window hand…
cklosters Oct 9, 2024
ed4d4eb
bit of cleanup
cklosters Oct 10, 2024
288fbd3
enable sdl event processing (for now)
cklosters Oct 10, 2024
e8c7dd5
- app intialization is now also threaded
cklosters Oct 10, 2024
4339d6a
Bit of cleanup
cklosters Oct 10, 2024
ad360bc
Introduce applet sdl event loop - polls and forwards sdl events (thre…
cklosters Oct 14, 2024
b8ed33d
poll and forward sdl events to active applet - not thread safe yet!
cklosters Oct 14, 2024
0163425
merge appletrunner and launcher - simplifies interface and handling
cklosters Oct 15, 2024
9a56f9b
use condition variable to wait for input or interval before processing
cklosters Oct 15, 2024
c75670b
Forward events thread safe
cklosters Oct 15, 2024
c6058f7
remove deprecated q timer from render panel
cklosters Oct 15, 2024
93ac62c
use generic nap event instead of input event to caputre window events…
cklosters Oct 15, 2024
240a192
process individual events instead of lists threaded
cklosters Oct 15, 2024
19b676f
Introduce RenderPanel QWidget that can be embedded into other widgets
cklosters Oct 15, 2024
1b59ca3
bit of cleanup
cklosters Oct 16, 2024
ef1fd32
remove second render appler
cklosters Oct 16, 2024
ebc32d5
improve preview applet initialization error handling
cklosters Oct 16, 2024
fecfe89
remove imgui from preview applet - uses incompatible global vulkan state
cklosters Oct 16, 2024
2f5bebb
remove imgui from napkin
cklosters Oct 16, 2024
f7173e7
Merge branch 'public' into napkin_applet_instances
cklosters Oct 17, 2024
c2c622d
Add second render applet - runs but unstable!
cklosters Oct 18, 2024
4d44751
- Initialize and run an applet on the same thread, thread-safe
cklosters Oct 18, 2024
14f338e
ensure that when initialization of applet fails objects are cleared i…
cklosters Oct 18, 2024
7458aba
improve dec names
cklosters Oct 18, 2024
be1e10f
Move window creation and initialization to applet core instance and r…
cklosters Oct 21, 2024
faefe29
Use applet event converter to convert and forward Qt mouse and keyboa…
cklosters Oct 21, 2024
6797d5b
bit of cleanup
cklosters Oct 22, 2024
a0d78c4
add napimgui library thread safe (local)
cklosters Oct 22, 2024
1e5112e
make vulkan resources local to imgui service instance
cklosters Oct 22, 2024
f25f35a
Forward mouse and keyboard events to imgui
cklosters Oct 22, 2024
c9be075
cleanup
cklosters Oct 23, 2024
ded975a
add applet path mapping
cklosters Oct 23, 2024
fb7f333
translate and forward qt window events
cklosters Oct 23, 2024
6f3a21c
fix Qt deprecation warnings
cklosters Oct 23, 2024
fc494f3
remove panel as in between widget, directly add window container
cklosters Oct 24, 2024
708ba9d
Give parent on creation of SDL widget window container - fixes issue …
cklosters Oct 24, 2024
76d6dbb
Don't recreate swapchain when receicing an out of sync resize event -…
cklosters Oct 24, 2024
3384a0f
Cleanup
cklosters Oct 24, 2024
dfcc8ff
add api applet messaging bridge
cklosters Oct 24, 2024
80d93b5
let applet runner forward the api events for us
cklosters Oct 24, 2024
fcb81bc
report error when api message isn't valid
cklosters Oct 24, 2024
3a406ac
make update frequency variable
cklosters Oct 24, 2024
cdd06c6
Sanitize threading and bail the moment abort is called without proces…
cklosters Oct 24, 2024
9323818
Merge branch 'public' into napkin_applet
cklosters Oct 24, 2024
23736b2
Merge branch 'public' into napkin_applet
cklosters Oct 28, 2024
47027fd
add module description to rtti type information
cklosters Nov 3, 2024
2d36aa7
return actual module description object, not just ID
cklosters Nov 3, 2024
eb1bb4c
add module descriptor handle, resolves to module descriptor when avai…
cklosters Nov 3, 2024
a9f34f1
add 'getModule' rtti utility function to retreive the module a type i…
cklosters Nov 3, 2024
a908d8a
make module description handle const
cklosters Nov 3, 2024
aa92af1
inline and move module descriptor to utility
cklosters Nov 3, 2024
7130093
Exclude creation of items that are not linked to the project, only na…
cklosters Nov 4, 2024
2fd10ab
Fix deprecation warnings
cklosters Nov 4, 2024
98e9e73
export module descriptor with unique name, instead of generic one
cklosters Nov 4, 2024
ce5083d
move module description handle to type info declaration
cklosters Nov 4, 2024
66178e6
bit of cleanup
cklosters Nov 4, 2024
8bc044d
- define and return a module descriptor handle, based on unique modul…
cklosters Nov 4, 2024
68b07e7
fix napcore module definition
cklosters Nov 4, 2024
8f38c58
Fix widget layout
cklosters Nov 5, 2024
b3e42f4
Merge branch 'napkin_applet_module_symbol' into napkin_applet
cklosters Nov 5, 2024
ebd2c91
Allow categorization of items in filter preview popup
cklosters Nov 5, 2024
9d9452c
filter popup and treeview cleanup
cklosters Nov 5, 2024
066b386
Add option to add an icon to the popup filter
cklosters Nov 5, 2024
e7f864e
use module descriptor pointer for module lookup instead of string
cklosters Nov 6, 2024
2521eb6
Ensure not nested items are aligned / shown correct in filter popup
cklosters Nov 6, 2024
0c82424
ensure size is computed on flat item list
cklosters Nov 7, 2024
a3b4bf9
Disable receiving paint updates for embedded render panel
cklosters Nov 7, 2024
f6ba0f6
Only recompute popup size when sorting has finished
cklosters Nov 7, 2024
ccfedf2
Turn Filter popup into a dialog instead of menu, enables correct hand…
cklosters Nov 7, 2024
cb352af
remove not required components
cklosters Nov 7, 2024
fe5a499
rename napkin apps to applets
cklosters Nov 11, 2024
d6253ef
Merge branch 'public' into napkin_applet
cklosters Nov 19, 2024
952aff4
Start implementing individual applets
cklosters Nov 19, 2024
cb92f04
Rename texturepanel to TexturePreviewPanel
cklosters Nov 19, 2024
f53c2fa
Introduce staging option to bind resource types to specific (compatib…
cklosters Nov 19, 2024
055cafe
Improve documentation
cklosters Nov 19, 2024
d067518
Trigger staging request when user action is performed
cklosters Nov 19, 2024
c5d2007
Cache compatible staging types and names, simplifies widget interface
cklosters Nov 19, 2024
0eb153e
Cleanup
cklosters Nov 19, 2024
09e5860
Merge branch 'public' into napkin_applet
cklosters Nov 19, 2024
b7efff9
add path setting interface to staging widgets and use selected user l…
cklosters Nov 20, 2024
b0d128e
Send texture to load using api event thread safe to texture preview a…
cklosters Nov 20, 2024
acc548e
Properly shut down applet when abort is called
cklosters Nov 20, 2024
a070c00
Allow loading and display of textures in texture preview applet (appl…
cklosters Nov 20, 2024
6b57d9c
Improve texture plane positioning
cklosters Nov 20, 2024
f8bd93b
Add option to change clear color and take into consideration menu bar…
cklosters Nov 20, 2024
808137d
Fix texture framing
cklosters Nov 21, 2024
9a2dd34
Introduce thread safe solution for changing working directory
cklosters Nov 21, 2024
afeb345
Ensure all load data load calls are thread safe in Napkin
cklosters Nov 21, 2024
d56675c
Remove explicit setting of working directory when loading core - path…
cklosters Nov 21, 2024
62bcec0
Raise staging widget when path is loaded
cklosters Nov 29, 2024
343d96b
- Reload staged object when property changes
cklosters Nov 29, 2024
ccfc53b
Add detailed staged texture info to gui
cklosters Nov 29, 2024
687987e
add pan-zoom 2D texture orthographic controller
cklosters Nov 30, 2024
b6a5488
Reset pan controls when a new texture is loaded into the applet
cklosters Nov 30, 2024
32987ab
Auto compute near and far clipping planes
cklosters Nov 30, 2024
5596187
Include MPL2 notice
cklosters Nov 30, 2024
39e749a
add rudimentary zoom controls to pan component
cklosters Dec 2, 2024
abd3a5d
simplify zoom calls
cklosters Dec 2, 2024
f1c997e
zoom from center, instead of origin
cklosters Dec 2, 2024
cc402f8
Revert "zoom from center, instead of origin"
cklosters Dec 3, 2024
dab8e96
Properly zoom into a window coordinate based on current zoom & pan se…
cklosters Dec 3, 2024
0906b1a
calculate pan settings based on relative change
cklosters Dec 3, 2024
68b07f1
Don't re-frame when a property changes, only when a new texture is lo…
cklosters Dec 3, 2024
5d92ce5
Fix texture load synchronization issues
cklosters Dec 3, 2024
3184f66
add frame icon
cklosters Dec 4, 2024
002456a
Rename pancontroller to zoompancontroller and improve documentation
cklosters Dec 4, 2024
fbc775f
Improve documentation
cklosters Dec 4, 2024
08418be
add ide groups for napkin src sub-directories
cklosters Dec 4, 2024
5086402
- test if the return value from module descriptor can be converted, o…
cklosters Dec 4, 2024
42eac9e
add preprocessor definition to enable the inclusion of applet resourc…
cklosters Dec 4, 2024
3892696
- Add support for key modifiers (ctrl, shift etc.)
cklosters Dec 5, 2024
75727b1
add keycode to utf conversion
cklosters Dec 5, 2024
a95c664
Added todo: move utf conversion to SDL or QT and stor result in key p…
cklosters Dec 5, 2024
4eb3404
Add keypad enter key to imgui and map to applet
cklosters Dec 5, 2024
2f78904
Fix qt keyboard to applet mapping
cklosters Dec 5, 2024
6fea1d3
Cleanup
cklosters Dec 5, 2024
bed1601
introduce KeyModifier bitmask
cklosters Dec 17, 2024
a8cbab3
introduce applet textuture controllers and fix namespaces - tie data …
cklosters Dec 17, 2024
604d728
add load texture component to control loading of textures sent from n…
cklosters Dec 17, 2024
8a64c09
- add naprenderadvanced to napkin as dependency for preview of cubemaps
cklosters Dec 18, 2024
0bf0999
add cube fallback texture and render advanced as applet requirement
cklosters Dec 18, 2024
b9356a4
- add cubemap as valid texture preview
cklosters Dec 18, 2024
607cfc7
Allow for switching between cubemap and regular 2d texture
cklosters Dec 18, 2024
60fbcf7
explicitly destroy loaded cube texture - TODO: Check if we can move t…
cklosters Dec 18, 2024
5afff9f
applet cleanup
cklosters Dec 18, 2024
b891be2
move texture preview applet gui to seperate class and file
cklosters Dec 19, 2024
38d829e
add texture opacity control
cklosters Dec 19, 2024
55573a0
Fix re-enabling of orbit camera controller & introduce reflection mes…
cklosters Dec 19, 2024
2ea560e
Introduce cubemap controller
cklosters Dec 19, 2024
3f6d83f
Add additional and selectable reflective reference meshes
cklosters Dec 19, 2024
1441981
add some reflective demo geometry for inspection
cklosters Dec 19, 2024
4ce75fa
Initialize bitmap before cubemap - prevents cubemap to be cleared whe…
cklosters Dec 31, 2024
6b83784
Allow applet runner to be suspended
cklosters Jan 1, 2025
4b6f033
Document and clean up applet suspension (pause)
cklosters Jan 1, 2025
32bd145
Assert when applet is still running after request to be suspended
cklosters Jan 1, 2025
74f8a91
bit of cleanup
cklosters Jan 1, 2025
1139a2b
return invalid suspend future when applet already suspended or inactive
cklosters Jan 2, 2025
8f6eb30
- Disable closing of floating QDockWidget, instead explicitly handle …
cklosters Jan 2, 2025
9a21797
Fix background color floating docks
cklosters Jan 2, 2025
1fefe5b
change .obj to binary .fbx format
cklosters Jan 3, 2025
6230329
Suspend loop until applet is shown - minimizes overhead when applet i…
cklosters Jan 3, 2025
9f17824
Add mesh rotation to cubemap preview applet
cklosters Jan 3, 2025
41fd092
Make rotation generic option between 2D and Cubemap preview
cklosters Jan 3, 2025
2e64529
Move 2D texture frame controller to root of 2D texture entity
cklosters Jan 3, 2025
dedbeb0
add uv coordinates to imported test geometry
cklosters Jan 3, 2025
6983ee6
Add 2D Texture Mesh component, next to orthographics zoom & pan contr…
cklosters Jan 6, 2025
5d594d3
Add option to switch between 2DTexture orthographic zoom & pan or per…
cklosters Jan 6, 2025
f4568cb
optimize demo meshes
cklosters Jan 7, 2025
74fe045
Add option to load a custom mesh into texture preview widget
cklosters Jan 7, 2025
ef4cba1
move load and ownership to individual components
cklosters Jan 8, 2025
6de4e62
Add mesh inspection to texture preview
cklosters Jan 8, 2025
63ee3b4
- Compute and cache bounding box for cube and texture preview meshes
cklosters Jan 9, 2025
7b55bbe
Imrpove framing of meshes after load and switches
cklosters Jan 9, 2025
b41dafb
Merge branch 'public' into napkin_applet
cklosters Jan 14, 2025
8f8de52
Use bounding sphere instead of plane to compute camera offset - gives…
cklosters Jan 14, 2025
a1e73d7
Compensate orbit movement speed based on loaded mesh size (space diag…
cklosters Jan 15, 2025
129294e
Update clipping planes based on size of selected mesh
cklosters Jan 15, 2025
5351a13
Fix rotation for off-center loaded custom meshes in texture preview
cklosters Jan 15, 2025
eff5e5a
cleanup
cklosters Jan 15, 2025
0d56799
cleanup
cklosters Jan 15, 2025
1e8a095
Add mesh bound information (min, max, center, width etc.) to preview …
cklosters Jan 17, 2025
cfc241a
use sphere radius instead of bounding sphere when framing selection
cklosters Jan 17, 2025
50c8ffd
fix uv wrap & framing
cklosters Jan 17, 2025
95eb111
Raise log and show latest log message when an important message is re…
cklosters Jan 17, 2025
c8f30b8
Merge branch 'public' into napkin_applet
cklosters Jan 21, 2025
3c2d99d
Rebuild and sync dock menu when main menu is shown for the first time
cklosters Jan 21, 2025
2f1a437
Fix variable formatting
cklosters Jan 21, 2025
217b240
Scroll to bottom before notifying others about the log message - cleaner
cklosters Jan 21, 2025
487f6d8
Consider frame process time when asking applet to sleep
cklosters Jan 21, 2025
413e8da
Only send events when applet is active
cklosters Jan 21, 2025
62658b2
Fix sizegrab color
cklosters Jan 21, 2025
1ae97d7
Fix 2DFrame plane bound information
cklosters Jan 22, 2025
bf124e9
Ensure that pressing up or down puts focus on the filter treeview
cklosters Jan 22, 2025
999e3e4
rename sdleventloop to sdleventsink and ignore all events handled by …
cklosters Jan 22, 2025
ebd538b
Add texture preview applet documentation
cklosters Jan 22, 2025
39ab023
rename napkin/resources/apps directory to 'applets'
cklosters Jan 22, 2025
0ec1131
immediately updte xform rotation when resetting rotate
cklosters Jan 23, 2025
18ed54a
Let panel implementations handle item loading and binding, instead of…
cklosters Jan 23, 2025
4a8b4bb
clear selection when document is closing
cklosters Jan 23, 2025
6072f7d
- Track last loaded object - monitored for property changes
cklosters Jan 23, 2025
3c7b4bf
Make all context signal parameters const ref
cklosters Jan 23, 2025
3d1b7d7
make property changed const ref
cklosters Jan 23, 2025
8a112ad
make more signals const ref
cklosters Jan 23, 2025
d5dfc13
Add documentation
cklosters Jan 23, 2025
d38c86e
initialize applets in parallel
cklosters Jan 23, 2025
19ee1bb
add future assert
cklosters Jan 23, 2025
f4d9fa4
napkin applet module cache
cklosters Jan 27, 2025
5043036
add module tooltip - useful to debug dependencies
cklosters Jan 27, 2025
3157943
Merge branch 'napkin_applet' into napkin_applet_cache
cklosters Jan 27, 2025
490a7cc
Cache sourced (dynamically loaded) modules, allows them to be re-used…
cklosters Jan 28, 2025
1b268bb
improve cache interface, make only getHandle() public and disable the…
cklosters Jan 28, 2025
f094567
Don't load already sourced modules again using an absolute path on wi…
cklosters Jan 29, 2025
f6fff78
- load modules on windows using library name instead of full path
cklosters Jan 29, 2025
c2f5650
don't make location resolve map static (local!)
cklosters Jan 29, 2025
bbdf53a
add applet module descriptions
cklosters Jan 29, 2025
b5d1d8a
move module descriptors to applet directory
cklosters Jan 29, 2025
906a8b4
Improve debug logging of library and data search paths
cklosters Jan 30, 2025
3927736
remove duplicate search path - not required anymore
cklosters Jan 30, 2025
7cebf35
add path mapping templates for applets running inside napkin
cklosters Jan 30, 2025
536079a
Push applet path mapping through build system stages
cklosters Jan 30, 2025
d6616fb
Ensure system module data required by napkin is installed on app release
cklosters Jan 31, 2025
2c7151b
Cleanup
cklosters Jan 31, 2025
d5468d9
show module version instead of api version
cklosters Feb 3, 2025
674cf04
fix module loading linux
cklosters Feb 3, 2025
0ab0ea2
fix deployment of napkin alongside app
cklosters Feb 3, 2025
97caa05
fix deployment of napkin alongside app
cklosters Feb 3, 2025
615c8e4
Bump to 0.8
cklosters Feb 3, 2025
8533124
Merge branch 'main' into napkin_applet
cklosters Feb 4, 2025
a478c66
cleanup fft
cklosters Feb 4, 2025
c999ac6
change explicit library loading message to debug
cklosters Feb 4, 2025
1dc9e5e
allocate memory before filling
cklosters Feb 5, 2025
11f8165
fix compute flocking includes
cklosters Feb 5, 2025
79db5c7
add default uv grid test texture
cklosters Feb 5, 2025
0059fec
allow texture usage to be selected
cklosters Feb 5, 2025
624e7c7
rename uvgridtexture to uvtesttexture
cklosters Feb 5, 2025
9490ade
Bit of cleanup
cklosters Feb 5, 2025
ee78cc1
fix include
cklosters Feb 6, 2025
9f657a2
change applet color palette when napkin color palette changes
cklosters Feb 6, 2025
409a3cc
update icons when inversion is different
cklosters Feb 6, 2025
da3be48
move gui style related configurable options to dedicated unit and upd…
cklosters Feb 6, 2025
47686af
- Add more custom 3D meshes, including: ShaderBall, Humanoid, Toy an…
cklosters Feb 7, 2025
a01407f
- Introduce EquiRectangularCubeMap, which generates a cubemap from an…
cklosters Feb 10, 2025
d127871
Add default plane and sunset cubemap for testing purposes
cklosters Feb 10, 2025
132ffca
fix content
cklosters Feb 10, 2025
32352c0
introduce and use applet extension to gain access to project being ed…
cklosters Feb 11, 2025
cf80a33
rename 'LoadTextureComponent' to 'TexturePreviewAPIComponent'
cklosters Feb 11, 2025
99517bd
Merge branch '0.8' into napkin_applet
cklosters Feb 19, 2025
443f666
improve error handling
cklosters Feb 19, 2025
3c6216d
Provide good cube face size defaults
cklosters Feb 19, 2025
cf1d0f6
Fix build
cklosters Feb 19, 2025
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
4 changes: 4 additions & 0 deletions cmake/framework_release_packaging.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -766,5 +766,9 @@ function(package_path_mappings)
install(DIRECTORY ${NAP_ROOT}/tools/buildsystem/path_mappings/${MAPPINGS_PREFIX}/
DESTINATION tools/buildsystem/path_mappings
PATTERN "source.json" EXCLUDE)

install(DIRECTORY ${NAP_ROOT}/tools/buildsystem/path_mappings/applet
DESTINATION tools/buildsystem/path_mappings
PATTERN "framework_release.json" EXCLUDE)
endfunction()

36 changes: 31 additions & 5 deletions cmake/install_napkin_with_app.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@ endif()
include(${CMAKE_CURRENT_LIST_DIR}/macros_and_functions.cmake)

# NAP modules which Napkin uses (as a minimum)
set(NAPKIN_DEPENDENT_NAP_MODULES napscene napmath)
set(NAPKIN_DEPENDENT_NAP_MODULES napscene
napcolor
napfont
naprender
napcameracontrol
napapp
napinput
napsdlinput
napimgui
napapi
naprenderadvanced)

# Qt frameworks which Napkin uses
set(NAPKIN_QT_INSTALL_FRAMEWORKS QtCore QtGui QtWidgets QtOpenGL)
Expand All @@ -24,10 +34,21 @@ if(pybind11_FOUND)
endif()

if(WIN32)
add_custom_command(TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory "${NAP_ROOT}/tools/napkin" "$<TARGET_FILE_DIR:${PROJECT_NAME}>/napkin"
COMMENT "Copy Napkin")
# Copy napkin directory -> exclude path mapping
install(DIRECTORY ${NAP_ROOT}/tools/napkin/
DESTINATION napkin
PATTERN "*/path_mapping.json" EXCLUDE
PATTERN "*/napkin.ini" EXCLUDE)

# Napkin has dependencies the application might not have -> we must include the (shared) data for those.
# For example: renderadvanced is required by Napkin but not by most demos -> it requires those shaders to run
foreach(NAP_MODULE ${NAPKIN_DEPENDENT_NAP_MODULES})
set(MODULE_EXTRA_CMAKE_PATH ${NAP_ROOT}/system_modules/${NAP_MODULE}/module_extra.cmake)
if(EXISTS ${MODULE_EXTRA_CMAKE_PATH})
include(${MODULE_EXTRA_CMAKE_PATH})
endif()
endforeach()

elseif(APPLE)
list(APPEND NAPKIN_QT_INSTALL_FRAMEWORKS QtDBus)

Expand Down Expand Up @@ -123,5 +144,10 @@ else()
unset(INSTALLING_MODULE_FOR_NAPKIN)
endif()

# Install path mapping for applets running in packaged app context
install(FILES ${NAP_ROOT}/tools/buildsystem/path_mappings/applet/packaged_app.json
DESTINATION napkin/resources/applets
RENAME path_mapping.json)

# Install Qt licenses into packaged app
install(DIRECTORY ${THIRDPARTY_DIR}/Qt/licenses/ DESTINATION licenses/Qt)
4 changes: 2 additions & 2 deletions cmake/version.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set(NAP_MAJOR_VERSION 0)
set(NAP_MINOR_VERSION 7)
set(NAP_PATCH_VERSION 7)
set(NAP_MINOR_VERSION 8)
set(NAP_PATCH_VERSION 0)
set(NAP_VERSION "${NAP_MAJOR_VERSION}.${NAP_MINOR_VERSION}.${NAP_PATCH_VERSION}")
# Be careful updating this as it's currently parsed during packaging by package.py
message(STATUS "NAP version: ${NAP_VERSION}")
6 changes: 3 additions & 3 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ if(APPLE)
src/nap/osx/directorywatcher.cpp
src/nap/osx/module.cpp
src/nap/osx/core_env.cpp
src/nap/native/modulemanager_ext.cpp
src/nap/native/logger_ext.cpp
src/nap/native/core_ext.cpp
src/nap/native/resourcemanager_ext.cpp
src/nap/native/modulecache_ext.cpp
)
elseif(MSVC)
add_library(${PROJECT_NAME} SHARED
${SOURCES}
src/nap/win32/directorywatcher.cpp
src/nap/win32/module.cpp
src/nap/win32/core_env.cpp
src/nap/native/modulemanager_ext.cpp
src/nap/native/logger_ext.cpp
src/nap/native/core_ext.cpp
src/nap/native/resourcemanager_ext.cpp
src/nap/native/modulecache_ext.cpp
)
elseif(UNIX)
file(GLOB FILEWATCHER_SOURCES
Expand All @@ -44,10 +44,10 @@ elseif(UNIX)
src/nap/linux/directorywatcher.cpp
src/nap/linux/module.cpp
src/nap/linux/core_env.cpp
src/nap/native/modulemanager_ext.cpp
src/nap/native/logger_ext.cpp
src/nap/native/core_ext.cpp
src/nap/native/resourcemanager_ext.cpp
src/nap/native/modulecache_ext.cpp
)
endif()

Expand Down
8 changes: 2 additions & 6 deletions core/src/nap/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace nap
// Initialize timer
mTimer.reset();
mResourceManager = std::make_unique<ResourceManager>(*this);
mModuleManager = std::make_unique<ModuleManager>(*this);
mModuleManager = std::make_unique<ModuleManager>();
}


Expand Down Expand Up @@ -89,11 +89,6 @@ namespace nap
if (!loadProjectInfo(projectInfofile, context, error))
return false;

// Ensure our current working directory is where the executable is.
// Works around issues with the current working directory not being set as
// expected when apps are launched directly from macOS Finder and probably other things too.
nap::utility::changeDir(nap::utility::getExecutableDir());

// Setup our Python environment
#ifdef NAP_ENABLE_PYTHON
setupPythonEnvironment();
Expand Down Expand Up @@ -443,6 +438,7 @@ namespace nap
return false;

// Initialize it
nap::Logger::debug("Initializing project '%s'", mProjectInfo->mTitle.c_str());
if (!mProjectInfo->init(projectFilename, context, err))
{
err.fail("Failed to initialize project");
Expand Down
21 changes: 21 additions & 0 deletions core/src/nap/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,15 @@ namespace nap
template <typename T>
const T& getExtension() const;

/**
* Returns the extension associated with this instance of core as T.
* Note that an extension is given explicitly to core on construction.
* When using the default constructor core has no interface associated with it!
* @return extension associated with core as type T
*/
template <typename T>
T& getExtension();

/**
* @return if core has an extension of type T
*/
Expand Down Expand Up @@ -520,6 +529,18 @@ const T& nap::Core::getExtension() const
}


/**
* Returns the core extension as an extension of type T
*/
template <typename T>
T& nap::Core::getExtension()
{
T* core_ext = rtti_cast<T>(mExtension.get());
assert(core_ext != nullptr);
return *core_ext;
}


/**
* Returns if core has an extension of type T
*/
Expand Down
1 change: 1 addition & 0 deletions core/src/nap/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ namespace nap
* Most events are wrapped in a unique pointer to manage lifetime automatically
*/
using EventPtr = std::unique_ptr<nap::Event>;
using EventPtrList = std::vector<EventPtr>;
}
49 changes: 41 additions & 8 deletions core/src/nap/linux/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,59 @@

// Local Includes
#include <nap/module.h>
#include <nap/logger.h>

// External Includes
#include <utility/fileutils.h>
#include <assert.h>
#include <dlfcn.h> // Posix shared object loading
#include <linux/limits.h>

namespace nap
{
void initModules()
{ }


void* loadModule(const nap::ModuleInfo& modInfo, const std::string& modulePath, std::string& errorString)
void* loadModule(const nap::ModuleInfo& modInfo, const std::string& library, std::string& outLocation, std::string& errorString)
{
// If we failed to load the module, get the error string
void* result = dlopen(modulePath.c_str(), RTLD_LAZY);
if (result == nullptr)
errorString = dlerror();
// Attempt to load the library using default OS system mapping
// If that fails attempt to locate it using library search paths
void* handle = dlopen(library.c_str(), RTLD_LAZY);
if (handle == nullptr)
{
for (const auto& path : modInfo.mLibSearchPaths)
{
// Find it
std::string full_path = utility::forceSeparator(utility::stringFormat("%s/%s",
path.c_str(), library.c_str()));
if (!utility::fileExists(full_path))
continue;

return result;
// Load it
Logger::debug("Explicitly loading library: %s", full_path.c_str());
handle = dlopen(full_path.c_str(), RTLD_LAZY);
if (handle != nullptr)
break;
}
}

// Ensure we have a handle
if (handle == nullptr)
{
errorString = utility::stringFormat("dlopen for library '%s' failed:\n%s", library.c_str(), dlerror());
return nullptr;
}

// Get library load origin
char path[PATH_MAX];
if (dlinfo(handle, RTLD_DI_ORIGIN, &path) == -1)
{
errorString = utility::stringFormat("origin resolve for '%s' failed:\n%s", library.c_str(), dlerror());
return nullptr;
}

// Set out location
outLocation = path;
return handle;
}


Expand Down
3 changes: 2 additions & 1 deletion core/src/nap/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ namespace nap
: LogHandler(), mFilename(mFilename)
{
// Set the default formatter to use a timestamp
setLogLevel(Logger::debugLevel());
setFormatter(&timestampLogMessageFormatter);

// Kick off the writing thread
Expand All @@ -144,8 +145,8 @@ namespace nap

FileLogHandler::~FileLogHandler()
{
mRunning = false;
// Wait for the stream to close
mRunning = false;
if (mWriteThread->joinable())
mWriteThread->join();
}
Expand Down
10 changes: 6 additions & 4 deletions core/src/nap/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,13 @@ namespace nap


/**
* Log handler that will print to the console
* Log handler that will print to the console.
* By default, messages with an info level and higher are included.
*/
class ConsoleLogHandler : public LogHandler
{
public:
ConsoleLogHandler() = default;
ConsoleLogHandler() { setLogLevel(Logger::infoLevel()); }

/**
* Write the contents to the outputstream
Expand All @@ -324,15 +325,16 @@ namespace nap

/**
* Log handler that will write log messages to a file.
* By default, messages with a debug level and higher are included.
* Upon construction, it will open a file stream to write to
* and will remain open for the lifetime of the handler.
* The file writer runs another thread to keep the call site unburdened
* The file writer runs another thread to keep the call site unburdened.
*/
class FileLogHandler : public LogHandler
{
public:
FileLogHandler(const std::string& mFilename);
~FileLogHandler();
~FileLogHandler() override;

/**
* Write a message to the provided file
Expand Down
7 changes: 4 additions & 3 deletions core/src/nap/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ namespace nap
/**
* Platform-wrapper function to load a shared library
* @param modInfo The moduleInfo, used to add additional dll search paths
* @param modulePath The path to the shared library to load
* @param errorString If the module failed to load, the error string
* @param library The name of the library to load, including extension
* @param outLocation the location the loaded module, if loading succeeds
* @param error Holds the error if loading fails
* @return Handle to the loaded module
*/
NAPAPI void* loadModule(const nap::ModuleInfo& modInfo, const std::string& modulePath, std::string& errorString);
NAPAPI void* loadModule(const nap::ModuleInfo& modInfo, const std::string& library, std::string& outLocation, std::string& error);

/**
* Platform-wrapper function to unload a shared library
Expand Down
79 changes: 79 additions & 0 deletions core/src/nap/modulecache.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

// Local includes
#include "modulecache.h"
#include "module.h"

// External includes
#include <utility/fileutils.h>

namespace nap
{
//////////////////////////////////////////////////////////////////////////
// Module
//////////////////////////////////////////////////////////////////////////

std::string Module::findAsset(const std::string& name) const
{
return utility::findFileInDirectories(name, this->getInformation().mDataSearchPaths);
}


//////////////////////////////////////////////////////////////////////////
// Module Cache
//////////////////////////////////////////////////////////////////////////

ModuleCache::Handle::Handle(nap::ModuleCache& cache, std::mutex& mutex) : mLock(mutex),
mCache(&cache)
{ }


ModuleCache::Handle::Handle(Handle&& other) noexcept
{
mLock = std::move(other.mLock);
mCache = std::move(other.mCache);
}


nap::ModuleCache::Handle& ModuleCache::Handle::operator=(Handle&& other) noexcept
{
mLock = std::move(other.mLock);
mCache = std::move(other.mCache);
return *this;
}


nap::ModuleCache::Handle ModuleCache::getHandle()
{
// Create unique cache, local to unit
static ModuleCache cache;
static std::mutex mutex;
static std::once_flag init_flag;

// Platform specific initialization
std::call_once(init_flag, [&]() {
initModules();
});

// Create cache handle, lock and return
return ModuleCache::Handle(cache, mutex);
}


const nap::Module* ModuleCache::findModule(const std::string& moduleName) const
{
auto found_it = std::find_if(mModules.begin(), mModules.end(), [&](const auto& it) {
return it->mName == moduleName;
});
return found_it == mModules.end() ? nullptr : found_it->get();
}


const nap::Module* ModuleCache::Handle::sourceModule(const ProjectInfo& projectinfo, const std::string& moduleName, utility::ErrorState& err)
{
assert(mCache != nullptr);
return mCache->sourceModule(projectinfo, moduleName, err);
}
}
Loading